From 90542758d4fef2e5ff8badaf3b40c2a227fbfc47 Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Tue, 19 Jun 2012 15:44:35 -0700 Subject: [PATCH] Cleanup softap interface to netd Change-Id: I01e6c5b5a5a8ddaf05b979f9cc6d1293c86e8773 --- .../android/os/INetworkManagementService.aidl | 6 ++--- .../server/NetworkManagementService.java | 13 +++++----- .../android/net/wifi/WifiStateMachine.java | 25 ++++++------------- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index e7ea3558dae1a..b64a73a3eb8ca 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -218,17 +218,17 @@ interface INetworkManagementService /** * Start Wifi Access Point */ - void startAccessPoint(in WifiConfiguration wifiConfig, String wlanIface, String softapIface); + void startAccessPoint(in WifiConfiguration wifiConfig, String iface); /** * Stop Wifi Access Point */ - void stopAccessPoint(String wlanIface); + void stopAccessPoint(String iface); /** * Set Access Point config */ - void setAccessPoint(in WifiConfiguration wifiConfig, String wlanIface, String softapIface); + void setAccessPoint(in WifiConfiguration wifiConfig, String iface); /** ** DATA USAGE RELATED diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 11644e3b93e26..09792f558a535 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -923,14 +923,14 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void startAccessPoint( - WifiConfiguration wifiConfig, String wlanIface, String softapIface) { + WifiConfiguration wifiConfig, String wlanIface) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { wifiFirmwareReload(wlanIface, "AP"); if (wifiConfig == null) { - mConnector.execute("softap", "set", wlanIface, softapIface); + mConnector.execute("softap", "set", wlanIface); } else { - mConnector.execute("softap", "set", wlanIface, softapIface, wifiConfig.SSID, + mConnector.execute("softap", "set", wlanIface, wifiConfig.SSID, getSecurityType(wifiConfig), wifiConfig.preSharedKey); } mConnector.execute("softap", "startap"); @@ -966,7 +966,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { mConnector.execute("softap", "stopap"); - mConnector.execute("softap", "stop", wlanIface); wifiFirmwareReload(wlanIface, "STA"); } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); @@ -974,13 +973,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface, String softapIface) { + public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { if (wifiConfig == null) { - mConnector.execute("softap", "set", wlanIface, softapIface); + mConnector.execute("softap", "set", wlanIface); } else { - mConnector.execute("softap", "set", wlanIface, softapIface, wifiConfig.SSID, + mConnector.execute("softap", "set", wlanIface, wifiConfig.SSID, getSecurityType(wifiConfig), wifiConfig.preSharedKey); } } catch (NativeDaemonConnectorException e) { diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 23b1b4499b7af..ed72459cf468b 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -23,13 +23,8 @@ import static android.net.wifi.WifiManager.WIFI_STATE_ENABLING; import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN; /** - * TODO: Add soft AP states as part of WIFI_STATE_XXX - * Retain WIFI_STATE_ENABLING that indicates driver is loading - * Add WIFI_STATE_AP_ENABLED to indicate soft AP has started - * and WIFI_STATE_FAILED for failure + * TODO: * Deprecate WIFI_STATE_UNKNOWN - * - * Doing this will simplify the logic for sending broadcasts */ import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLED; import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING; @@ -94,13 +89,10 @@ import java.util.regex.Pattern; * Track the state of Wifi connectivity. All event handling is done here, * and all changes in connectivity state are initiated here. * - * Wi-Fi now supports three modes of operation: Client, Soft Ap and Direct - * In the current implementation, we do not support any concurrency and thus only - * one of Client, Soft Ap or Direct operation is supported at any time. - * - * The WifiStateMachine supports Soft Ap and Client operations while WifiP2pService - * handles Direct. WifiP2pService and WifiStateMachine co-ordinate to ensure only - * one exists at a certain time. + * Wi-Fi now supports three modes of operation: Client, SoftAp and p2p + * In the current implementation, we support concurrent wifi p2p and wifi operation. + * The WifiStateMachine handles SoftAp and Client operations while WifiP2pService + * handles p2p operation. * * @hide */ @@ -110,9 +102,6 @@ public class WifiStateMachine extends StateMachine { private static final String NETWORKTYPE = "WIFI"; private static final boolean DBG = false; - /* TODO: This is no more used with the hostapd code. Clean up */ - private static final String SOFTAP_IFACE = "wl0.1"; - private WifiMonitor mWifiMonitor; private WifiNative mWifiNative; private WifiConfigStore mWifiConfigStore; @@ -1794,12 +1783,12 @@ public class WifiStateMachine extends StateMachine { new Thread(new Runnable() { public void run() { try { - mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE); + mNwService.startAccessPoint(config, mInterfaceName); } catch (Exception e) { loge("Exception in softap start " + e); try { mNwService.stopAccessPoint(mInterfaceName); - mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE); + mNwService.startAccessPoint(config, mInterfaceName); } catch (Exception e1) { loge("Exception in softap re-start " + e1); sendMessage(CMD_START_AP_FAILURE);