diff options
author | Vinit Deshapnde <vinitd@google.com> | 2013-07-11 15:12:44 -0700 |
---|---|---|
committer | Vinit Deshapnde <vinitd@google.com> | 2013-07-11 15:12:44 -0700 |
commit | 64f0d5ba158e9135bcd48d64a1c0db282a4628ba (patch) | |
tree | ffa817f70cc63f723df334e5879ec5ab9a383eac /wifi | |
parent | ada2f7e17bf7032ba0ab06c80713c0720711ac4b (diff) | |
download | frameworks_base-64f0d5ba158e9135bcd48d64a1c0db282a4628ba.zip frameworks_base-64f0d5ba158e9135bcd48d64a1c0db282a4628ba.tar.gz frameworks_base-64f0d5ba158e9135bcd48d64a1c0db282a4628ba.tar.bz2 |
Allow enabling TDLS on specific routes
This change exposes couple of internal APIs to enable TDLS between local
machine and a remote machine. The implementation translates client provided
remote IP to a MAC address using system ARP cache, and then instructs the
driver to enable TDLS with that endpoint. Another API takes application
specified MAC address.
Bug: 8538898
Change-Id: Ida343fc42ba3a817a4f380255596e7fb7fcdfb9b
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 4 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 38 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 7 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 17 |
4 files changed, 66 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 547ae95..6a4bd45 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -110,5 +110,9 @@ interface IWifiManager String getConfigFile(); void captivePortalCheckComplete(); + + void enableTdls(String remoteIPAddress, boolean enable); + + void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable); } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index a3c172a..86ca4a7 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -32,6 +32,7 @@ import android.os.Messenger; import android.util.Log; import android.util.SparseArray; +import java.net.InetAddress; import java.util.concurrent.CountDownLatch; import com.android.internal.util.AsyncChannel; @@ -1132,6 +1133,43 @@ public class WifiManager { } } + + /** + * Enable TDLS on a specific local route + * + * This API is used by WiFi display, but eventually it can be made public, + * just depends on how popular TDLS gets + * + * @param remoteIPAddress IP address of the endpoint to setup TDLS with + * @param enable true = setup and false = tear down TDLS + * @hide + */ + public void enableTdls(InetAddress remoteIPAddress, boolean enable) { + try { + mService.enableTdls(remoteIPAddress.getHostAddress(), enable); + } catch (RemoteException e) { + // Just ignore the exception + } + } + + /** + * Enable TDLS on a specific local route + * + * This API is used by WiFi display, but eventually it can be made public, + * just depends on how popular TDLS gets + * + * @param remoteMacAddress MAC address of the remote endpoint such as 00:00:0c:9f:f2:ab + * @param enable true = setup and false = tear down TDLS + * @hide + */ + public void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable) { + try { + mService.enableTdlsWithMacAddress(remoteMacAddress, enable); + } catch (RemoteException e) { + // Just ignore the exception + } + } + /* TODO: deprecate synchronous API and open up the following API */ private static final int BASE = Protocol.BASE_WIFI_MANAGER; diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index ae41c9a..7ee7085 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -370,6 +370,13 @@ public class WifiNative { doBooleanCommand("SCAN_INTERVAL " + scanInterval); } + public void startTdls(String macAddr, boolean enable) { + if (enable) + doBooleanCommand("TDLS_SETUP " + macAddr); + else + doBooleanCommand("TDLS_TEARDOWN " + macAddr); + } + /** Example output: * RSSI=-65 * LINKSPEED=48 diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index d509b37..a095648 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -337,6 +337,8 @@ public class WifiStateMachine extends StateMachine { static final int CMD_SET_FREQUENCY_BAND = BASE + 90; /* Enable background scan for configured networks */ static final int CMD_ENABLE_BACKGROUND_SCAN = BASE + 91; + /* Enable TDLS on a specific MAC address */ + static final int CMD_ENABLE_TDLS = BASE + 92; /* Commands from/to the SupplicantStateTracker */ /* Reset the supplicant state tracker */ @@ -1074,6 +1076,14 @@ public class WifiStateMachine extends StateMachine { } /** + * Enable TDLS for a specific MAC address + */ + public void enableTdls(String remoteMacAddress, boolean enable) { + int enabler = enable ? 1 : 0; + sendMessage(CMD_ENABLE_TDLS, enabler, 0, remoteMacAddress); + } + + /** * Returns the operational frequency band */ public int getFrequencyBand() { @@ -2595,6 +2605,13 @@ public class WifiStateMachine extends StateMachine { setSuspendOptimizationsNative(SUSPEND_DUE_TO_HIGH_PERF, true); } break; + case CMD_ENABLE_TDLS: + if (message.obj != null) { + String remoteAddress = (String) message.obj; + boolean enable = (message.arg1 == 1); + mWifiNative.startTdls(remoteAddress, enable); + } + break; default: return NOT_HANDLED; } |