diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-07-21 13:45:38 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-21 13:45:38 -0700 |
commit | d7a374f6f8f52a88d7e9a4660d9bf9037cf0b659 (patch) | |
tree | 1e1de80e54f7d0a5a2956587d64b396def9805ed /wifi | |
parent | d2bea209658c1e2b7575cddf4338d44e305ee554 (diff) | |
parent | b0c1b80f471bd49af60e7b78161d814e355a6972 (diff) | |
download | frameworks_base-d7a374f6f8f52a88d7e9a4660d9bf9037cf0b659.zip frameworks_base-d7a374f6f8f52a88d7e9a4660d9bf9037cf0b659.tar.gz frameworks_base-d7a374f6f8f52a88d7e9a4660d9bf9037cf0b659.tar.bz2 |
Merge "Fix multicast API"
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 22 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 66 |
2 files changed, 72 insertions, 16 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 6e13d0f..f1f0fcc 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -104,18 +104,30 @@ public class WifiNative { public native static boolean stopDriverCommand(); + + /** + * Start filtering out Multicast V4 packets + * @return {@code true} if the operation succeeded, {@code false} otherwise + */ + public native static boolean startFilteringMulticastV4Packets(); + + /** + * Stop filtering out Multicast V4 packets. + * @return {@code true} if the operation succeeded, {@code false} otherwise + */ + public native static boolean stopFilteringMulticastV4Packets(); + /** - * Start filtering out multicast packets, to reduce battery consumption - * that would result from processing them, only to discard them. + * Start filtering out Multicast V6 packets * @return {@code true} if the operation succeeded, {@code false} otherwise */ - public native static boolean startPacketFiltering(); + public native static boolean startFilteringMulticastV6Packets(); /** - * Stop filtering out multicast packets. + * Stop filtering out Multicast V6 packets. * @return {@code true} if the operation succeeded, {@code false} otherwise */ - public native static boolean stopPacketFiltering(); + public native static boolean stopFilteringMulticastV6Packets(); public native static boolean setPowerModeCommand(int mode); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 12efeb1..f08bb6a 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -82,6 +82,7 @@ import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; /** @@ -160,6 +161,9 @@ public class WifiStateMachine extends StateMachine { /* Tracks current frequency mode */ private AtomicInteger mFrequencyBand = new AtomicInteger(WifiManager.WIFI_FREQUENCY_BAND_AUTO); + /* Tracks if we are filtering Multicast v4 packets. Default is to filter. */ + private AtomicBoolean mFilteringMulticastV4Packets = new AtomicBoolean(true); + // Channel for sending replies. private AsyncChannel mReplyChannel = new AsyncChannel(); @@ -285,6 +289,11 @@ public class WifiStateMachine extends StateMachine { static final int CMD_START_PACKET_FILTERING = BASE + 84; /* Clear packet filter */ static final int CMD_STOP_PACKET_FILTERING = BASE + 85; + + /* arg1 values to CMD_STOP_PACKET_FILTERING and CMD_START_PACKET_FILTERING */ + static final int MULTICAST_V6 = 1; + static final int MULTICAST_V4 = 0; + /* Connect to a specified network (network id * or WifiConfiguration) This involves increasing * the priority of the network, enabling the network @@ -868,17 +877,33 @@ public class WifiStateMachine extends StateMachine { } /** - * Start packet filtering + * Start filtering Multicast v4 packets + */ + public void startFilteringMulticastV4Packets() { + mFilteringMulticastV4Packets.set(true); + sendMessage(obtainMessage(CMD_START_PACKET_FILTERING, MULTICAST_V4, 0)); + } + + /** + * Stop filtering Multicast v4 packets + */ + public void stopFilteringMulticastV4Packets() { + mFilteringMulticastV4Packets.set(false); + sendMessage(obtainMessage(CMD_STOP_PACKET_FILTERING, MULTICAST_V4, 0)); + } + + /** + * Start filtering Multicast v4 packets */ - public void startPacketFiltering() { - sendMessage(CMD_START_PACKET_FILTERING); + public void startFilteringMulticastV6Packets() { + sendMessage(obtainMessage(CMD_START_PACKET_FILTERING, MULTICAST_V6, 0)); } /** - * Stop packet filtering + * Stop filtering Multicast v4 packets */ - public void stopPacketFiltering() { - sendMessage(CMD_STOP_PACKET_FILTERING); + public void stopFilteringMulticastV6Packets() { + sendMessage(obtainMessage(CMD_STOP_PACKET_FILTERING, MULTICAST_V6, 0)); } /** @@ -2074,9 +2099,6 @@ public class WifiStateMachine extends StateMachine { WifiConfigStore.initialize(mContext); - //TODO: initialize and fix multicast filtering - //mWM.initializeMulticastFiltering(); - sendSupplicantConnectionChangedBroadcast(true); transitionTo(mDriverStartedState); break; @@ -2359,6 +2381,16 @@ public class WifiStateMachine extends StateMachine { /* initialize network state */ setNetworkDetailedState(DetailedState.DISCONNECTED); + /* Remove any filtering on Multicast v6 at start */ + WifiNative.stopFilteringMulticastV6Packets(); + + /* Reset Multicast v4 filtering state */ + if (mFilteringMulticastV4Packets.get()) { + WifiNative.startFilteringMulticastV4Packets(); + } else { + WifiNative.stopFilteringMulticastV4Packets(); + } + if (mIsScanMode) { WifiNative.setScanResultHandlingCommand(SCAN_ONLY_MODE); WifiNative.disconnectCommand(); @@ -2419,10 +2451,22 @@ public class WifiStateMachine extends StateMachine { mWakeLock.release(); break; case CMD_START_PACKET_FILTERING: - WifiNative.startPacketFiltering(); + if (message.arg1 == MULTICAST_V6) { + WifiNative.startFilteringMulticastV6Packets(); + } else if (message.arg1 == MULTICAST_V4) { + WifiNative.startFilteringMulticastV4Packets(); + } else { + Log.e(TAG, "Illegal arugments to CMD_START_PACKET_FILTERING"); + } break; case CMD_STOP_PACKET_FILTERING: - WifiNative.stopPacketFiltering(); + if (message.arg1 == MULTICAST_V6) { + WifiNative.stopFilteringMulticastV6Packets(); + } else if (message.arg1 == MULTICAST_V4) { + WifiNative.stopFilteringMulticastV4Packets(); + } else { + Log.e(TAG, "Illegal arugments to CMD_STOP_PACKET_FILTERING"); + } break; default: return NOT_HANDLED; |