summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorRobert Greenwalt <robdroid@android.com>2009-05-13 15:10:16 -0700
committerRobert Greenwalt <robdroid@android.com>2009-05-13 15:10:16 -0700
commit5347bd4cda2b6afc18f8acab48e52131f35ed13c (patch)
treeaf3c0e520ff5712344bd5174b7d02d24ef34c4e7 /wifi/java/android/net
parent6347c322b36cdf6a30a35e80d205d00d40368e61 (diff)
downloadframeworks_base-5347bd4cda2b6afc18f8acab48e52131f35ed13c.zip
frameworks_base-5347bd4cda2b6afc18f8acab48e52131f35ed13c.tar.gz
frameworks_base-5347bd4cda2b6afc18f8acab48e52131f35ed13c.tar.bz2
Add wifi multicast filter api (enable/disable).
Fixes 1833432. Automatically re-disables any request when the app exits/crashes. Also hooked into Battery Stats for power managment analysis.
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl6
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java61
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java14
3 files changed, 76 insertions, 5 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index f9a0845..00829d6 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -69,5 +69,11 @@ interface IWifiManager
boolean acquireWifiLock(IBinder lock, int lockType, String tag);
boolean releaseWifiLock(IBinder lock);
+
+ boolean isWifiMulticastEnabled();
+
+ void enableWifiMulticast(IBinder binder, String tag);
+
+ void disableWifiMulticast();
}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index a51e88f..658a7b2 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -823,4 +823,65 @@ public class WifiManager {
public WifiLock createWifiLock(String tag) {
return new WifiLock(WIFI_MODE_FULL, tag);
}
+
+ /**
+ * Check multicast filter status.
+ *
+ * @return true if multicast packets are allowed.
+ *
+ * @hide pending API council approval
+ */
+ public boolean isWifiMulticastEnabled() {
+ try {
+ return mService.isWifiMulticastEnabled();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Turn on the reception of multicast packets.
+ * The default behavior is to disable multicast packets as they
+ * have a noticable negative effect on battery life. An
+ * application can turn them on, but should not leave it on for longer
+ * than needed. When the app quits (or crashes) its request will
+ * be reverted.
+ *
+ * @param tag a string associated with this request for debugging.
+ *
+ * @return true on success
+ *
+ * @see #disableWifiMulticast
+ *
+ * @hide pending API council approval
+ */
+ public boolean enableWifiMulticast(String tag) {
+ try {
+ mService.enableWifiMulticast(new Binder(), tag);
+ return true;
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Return to the default multicast-off setting.
+ * Note that if others had turned on Multicast reception, your
+ * call will not turn it back off - they must also turn off their
+ * request for multicast reception.
+ *
+ * @return true on success
+ *
+ * @see #enableWifiMulticast
+ *
+ * @hide pending API council approval
+ */
+ public boolean disableWifiMulticast() {
+ try {
+ mService.disableWifiMulticast();
+ return true;
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
}
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 6ea35f5..64084cf 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -732,15 +732,19 @@ public class WifiStateTracker extends NetworkStateTracker {
/*
* Filter out multicast packets. This saves battery power, since
* the CPU doesn't have to spend time processing packets that
- * are going to end up being thrown away. Obviously, if we
- * ever want to support multicast, this will have to change.
+ * are going to end up being thrown away.
+ *
+ * Note that rather than turn this off directly, we use the
+ * public api - this keeps us all in sync - turn multicast on
+ * first and then off.. if nobody else wants it on it'll be
+ * off then and it's all synchronized within the API.
*/
+ mWM.enableWifiMulticast("WifiStateTracker");
+ mWM.disableWifiMulticast();
+
if (mBluetoothA2dp == null) {
mBluetoothA2dp = new BluetoothA2dp(mContext);
}
- synchronized (this) {
- WifiNative.startPacketFiltering();
- }
checkIsBluetoothPlaying();
break;