From 212b95f587f4af637fb2429f29f7d0add1bd251f Mon Sep 17 00:00:00 2001 From: Christopher Wiley Date: Tue, 2 Aug 2016 11:38:57 -0700 Subject: [PATCH] Remove WiFi related methods from NetworkManagementService These are no longer necessary, since WiFi manages its own details. Bug: 30041228 Change-Id: Ia3824da43367ae74d3f3a204318cfe5470d74957 Test: Compiles --- .../android/os/INetworkManagementService.aidl | 17 --- .../server/NetworkManagementService.java | 103 +----------------- 2 files changed, 5 insertions(+), 115 deletions(-) diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 0c211d6821eb5..1c3d6bdba861e 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -24,7 +24,6 @@ import android.net.Network; import android.net.NetworkStats; import android.net.RouteInfo; import android.net.UidRange; -import android.net.wifi.WifiConfiguration; import android.os.INetworkActivityListener; /** @@ -222,22 +221,6 @@ interface INetworkManagementService */ void detachPppd(String tty); - /** - * Load firmware for operation in the given mode. Currently the three - * modes supported are "AP", "STA" and "P2P". - */ - void wifiFirmwareReload(String wlanIface, String mode); - - /** - * Start Wifi Access Point - */ - void startAccessPoint(in WifiConfiguration wifiConfig, String iface); - - /** - * Stop Wifi Access Point - */ - void stopAccessPoint(String iface); - /** ** DATA USAGE RELATED **/ diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index f2a2b3df04cf9..5a44205edab84 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -216,7 +216,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub private CountDownLatch mConnectedSignal = new CountDownLatch(1); private final RemoteCallbackList mObservers = - new RemoteCallbackList(); + new RemoteCallbackList<>(); private final NetworkStatsFactory mStatsFactory = new NetworkStatsFactory(); @@ -289,7 +289,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub private int mLastPowerStateFromWifi = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; private final RemoteCallbackList mNetworkActivityListeners = - new RemoteCallbackList(); + new RemoteCallbackList<>(); private boolean mNetworkActive; /** @@ -1172,7 +1172,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub private ArrayList readRouteList(String filename) { FileInputStream fstream = null; - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); try { fstream = new FileInputStream(filename); @@ -1296,7 +1296,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); } - List routes = new ArrayList(); + List routes = new ArrayList<>(); // The RouteInfo constructor truncates the LinkAddress to a network prefix, thus making it // suitable to use as a route destination. routes.add(new RouteInfo(getInterfaceConfig(iface).getLinkAddress(), null, iface)); @@ -1356,7 +1356,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } private List excludeLinkLocal(List addresses) { - ArrayList filtered = new ArrayList(addresses.size()); + ArrayList filtered = new ArrayList<>(addresses.size()); for (InterfaceAddress ia : addresses) { if (!ia.getAddress().isLinkLocalAddress()) filtered.add(ia); @@ -1469,99 +1469,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } - /** - * Private method used to call execute for a command given the provided arguments. - * - * This function checks the returned NativeDaemonEvent for the provided expected response code - * and message. If either of these is not correct, an error is logged. - * - * @param String command The command to execute. - * @param Object[] args If needed, arguments for the command to execute. - * @param int expectedResponseCode The code expected to be returned in the corresponding event. - * @param String expectedResponseMessage The message expected in the returned event. - * @param String logMsg The message to log as an error (TAG will be applied). - */ - private void executeOrLogWithMessage(String command, Object[] args, - int expectedResponseCode, String expectedResponseMessage, String logMsg) - throws NativeDaemonConnectorException { - NativeDaemonEvent event = mConnector.execute(command, args); - if (event.getCode() != expectedResponseCode - || !event.getMessage().equals(expectedResponseMessage)) { - Log.e(TAG, logMsg + ": event = " + event); - } - } - - @Override - public void startAccessPoint(WifiConfiguration wifiConfig, String wlanIface) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] args; - String logMsg = "startAccessPoint Error setting up softap"; - try { - if (wifiConfig == null) { - args = new Object[] {"set", wlanIface}; - } else { - args = new Object[] {"set", wlanIface, wifiConfig.SSID, - "broadcast", Integer.toString(wifiConfig.apChannel), - getSecurityType(wifiConfig), new SensitiveArg(wifiConfig.preSharedKey)}; - } - executeOrLogWithMessage(SOFT_AP_COMMAND, args, NetdResponseCode.SoftapStatusResult, - SOFT_AP_COMMAND_SUCCESS, logMsg); - - logMsg = "startAccessPoint Error starting softap"; - args = new Object[] {"startap"}; - executeOrLogWithMessage(SOFT_AP_COMMAND, args, NetdResponseCode.SoftapStatusResult, - SOFT_AP_COMMAND_SUCCESS, logMsg); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - private static String getSecurityType(WifiConfiguration wifiConfig) { - switch (wifiConfig.getAuthType()) { - case KeyMgmt.WPA_PSK: - return "wpa-psk"; - case KeyMgmt.WPA2_PSK: - return "wpa2-psk"; - default: - return "open"; - } - } - - /* @param mode can be "AP", "STA" or "P2P" */ - @Override - public void wifiFirmwareReload(String wlanIface, String mode) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] args = {"fwreload", wlanIface, mode}; - String logMsg = "wifiFirmwareReload Error reloading " - + wlanIface + " fw in " + mode + " mode"; - try { - executeOrLogWithMessage(SOFT_AP_COMMAND, args, NetdResponseCode.SoftapStatusResult, - SOFT_AP_COMMAND_SUCCESS, logMsg); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - - // Ensure that before we return from this command, any asynchronous - // notifications generated before the command completed have been - // processed by all NetworkManagementEventObservers. - mConnector.waitForCallbacks(); - } - - @Override - public void stopAccessPoint(String wlanIface) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] args = {"stopap"}; - String logMsg = "stopAccessPoint Error stopping softap"; - - try { - executeOrLogWithMessage(SOFT_AP_COMMAND, args, NetdResponseCode.SoftapStatusResult, - SOFT_AP_COMMAND_SUCCESS, logMsg); - wifiFirmwareReload(wlanIface, "STA"); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - @Override public void addIdleTimer(String iface, int timeout, final int type) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);