From e2d155a51e68694e17fa6e27d05c928215a5dbcf Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Wed, 21 Oct 2009 14:58:34 -0700 Subject: Add a new API for initing Wifi multicast filtering Gets rid of the old method which generated Log noise. bug: 1973855 --- services/java/com/android/server/WifiService.java | 13 +++++++++++++ wifi/java/android/net/wifi/IWifiManager.aidl | 2 ++ wifi/java/android/net/wifi/WifiManager.java | 13 +++++++++++++ wifi/java/android/net/wifi/WifiStateTracker.java | 10 +--------- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 89d969d..370ee68 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -1829,6 +1829,19 @@ public class WifiService extends IWifiManager.Stub { } } + public void initializeMulticastFiltering() { + enforceMulticastChangePermission(); + + synchronized (mMulticasters) { + // if anybody had requested filters be off, leave off + if (mMulticasters.size() != 0) { + return; + } else { + WifiNative.startPacketFiltering(); + } + } + } + public void acquireMulticastLock(IBinder binder, String tag) { enforceMulticastChangePermission(); diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 73dbb6f..f3738e3 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -70,6 +70,8 @@ interface IWifiManager boolean releaseWifiLock(IBinder lock); + void initializeMulticastFiltering(); + boolean isMulticastEnabled(); void acquireMulticastLock(IBinder binder, String tag); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 27755ed..178f76e 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1056,4 +1056,17 @@ public class WifiManager { return false; } } + + /** + * Initialize the multicast filtering to 'on' + * @hide no intent to publish + */ + public boolean initializeMulticastFiltering() { + try { + mService.initializeMulticastFiltering(); + 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 b7d3a6e..d8538ea 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -786,16 +786,8 @@ 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. - * - * 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. */ - WifiManager.MulticastLock l = - mWM.createMulticastLock("WifiStateTracker"); - l.acquire(); - l.release(); + mWM.initializeMulticastFiltering(); if (mBluetoothA2dp == null) { mBluetoothA2dp = new BluetoothA2dp(mContext); -- cgit v1.1