summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
commitb2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54 (patch)
treee167affc928677f3dd70e173150a77e3943e97a9 /wifi
parentf5b4b98fada53d91c4c2ebeb5a1d33ccc95c94d2 (diff)
downloadframeworks_base-b2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54.zip
frameworks_base-b2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54.tar.gz
frameworks_base-b2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54.tar.bz2
auto import from //branches/cupcake/...@137197
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java10
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java33
2 files changed, 43 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 2a47a71..3851ac0 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -117,6 +117,16 @@ public class WifiNative {
* @return Whether the mode was successfully set.
*/
public native static boolean setBluetoothCoexistenceModeCommand(int mode);
+
+ /**
+ * Enable or disable Bluetooth coexistence scan mode. When this mode is on,
+ * some of the low-level scan parameters used by the driver are changed to
+ * reduce interference with A2DP streaming.
+ *
+ * @param isSet whether to enable or disable this mode
+ * @return {@code true} if the command succeeded, {@code false} otherwise.
+ */
+ public native static boolean setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode);
public native static boolean saveConfigCommand();
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index f0009be..452a8fa 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -38,6 +38,7 @@ import android.util.Config;
import android.app.Notification;
import android.app.PendingIntent;
import android.bluetooth.BluetoothHeadset;
+import android.bluetooth.BluetoothA2dp;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.Context;
@@ -244,6 +245,10 @@ public class WifiStateTracker extends NetworkStateTracker {
private int mRunState;
private boolean mIsScanOnly;
+
+ private BluetoothA2dp mBluetoothA2dp;
+
+ private boolean mBluetoothScanMode;
private String mInterfaceName;
private static String LS = System.getProperty("line.separator");
@@ -577,6 +582,30 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
+ /**
+ * Enable or disable Bluetooth coexistence scan mode. When this mode is on,
+ * some of the low-level scan parameters used by the driver are changed to
+ * reduce interference with A2DP streaming.
+ *
+ * @param isBluetoothPlaying whether to enable or disable this mode
+ */
+ public synchronized void setBluetoothScanMode(boolean isBluetoothPlaying) {
+ WifiNative.setBluetoothCoexistenceScanModeCommand(isBluetoothPlaying);
+ }
+
+ private void checkIsBluetoothPlaying() {
+ boolean isBluetoothPlaying = false;
+ List<String> connected = mBluetoothA2dp.listConnectedSinks();
+
+ for (String address : connected) {
+ if (mBluetoothA2dp.getSinkState(address) == BluetoothA2dp.STATE_PLAYING) {
+ isBluetoothPlaying = true;
+ break;
+ }
+ }
+ setBluetoothScanMode(isBluetoothPlaying);
+ }
+
@Override
public void releaseWakeLock() {
if (mReleaseWakeLockCallback != null) {
@@ -682,9 +711,13 @@ public class WifiStateTracker extends NetworkStateTracker {
* are going to end up being thrown away. Obviously, if we
* ever want to support multicast, this will have to change.
*/
+ if (mBluetoothA2dp == null) {
+ mBluetoothA2dp = new BluetoothA2dp(mContext);
+ }
synchronized (this) {
WifiNative.startPacketFiltering();
}
+ checkIsBluetoothPlaying();
break;
case EVENT_SUPPLICANT_DISCONNECT: