Loading wifi/java/android/net/wifi/WifiConfigStore.java +54 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.HandlerThread; import android.os.UserHandle; import android.security.KeyStore; import android.text.TextUtils; import android.util.LocalLog; import android.util.Log; import java.io.BufferedInputStream; Loading Loading @@ -108,7 +109,7 @@ class WifiConfigStore { private Context mContext; private static final String TAG = "WifiConfigStore"; private static final boolean DBG = false; private static final boolean DBG = true; /* configured networks with network id as the key */ private HashMap<Integer, WifiConfiguration> mConfiguredNetworks = Loading Loading @@ -145,12 +146,19 @@ class WifiConfigStore { private static final String EXCLUSION_LIST_KEY = "exclusionList"; private static final String EOS = "eos"; private final LocalLog mLocalLog; private WifiNative mWifiNative; private final KeyStore mKeyStore = KeyStore.getInstance(); WifiConfigStore(Context c, WifiNative wn) { mContext = c; mWifiNative = wn; if (DBG) { mLocalLog = new LocalLog(1024); // takes about 64 K mWifiNative.setLocalLog(mLocalLog); } } /** Loading Loading @@ -212,6 +220,7 @@ class WifiConfigStore { * @return false if the network id is invalid */ boolean selectNetwork(int netId) { localLog("selectNetwork", netId); if (netId == INVALID_NETWORK_ID) return false; // Reset the priority of each network at start or if it goes too high. Loading Loading @@ -248,6 +257,7 @@ class WifiConfigStore { * @return network update result */ NetworkUpdateResult saveNetwork(WifiConfiguration config) { localLog("saveNetwork", config.networkId); // A new network cannot have null SSID if (config == null || (config.networkId == INVALID_NETWORK_ID && config.SSID == null)) { Loading Loading @@ -296,6 +306,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean forgetNetwork(int netId) { localLog("forgetNetwork", netId); if (mWifiNative.removeNetwork(netId)) { mWifiNative.saveConfig(); removeConfigAndSendBroadcastIfNeeded(netId); Loading @@ -316,6 +327,7 @@ class WifiConfigStore { * @return network Id */ int addOrUpdateNetwork(WifiConfiguration config) { localLog("addOrUpdateNetwork", config.networkId); NetworkUpdateResult result = addOrUpdateNetworkNative(config); if (result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID) { sendConfiguredNetworksChangedBroadcast(mConfiguredNetworks.get(result.getNetworkId()), Loading @@ -335,6 +347,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean removeNetwork(int netId) { localLog("removeNetwork", netId); boolean ret = mWifiNative.removeNetwork(netId); if (ret) { removeConfigAndSendBroadcastIfNeeded(netId); Loading Loading @@ -369,8 +382,10 @@ class WifiConfigStore { boolean enableNetwork(int netId, boolean disableOthers) { boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers); if (disableOthers) { localLog("enableNetwork(disableOthers=true) ", netId); sendConfiguredNetworksChangedBroadcast(); } else { localLog("enableNetwork(disableOthers=false) ", netId); WifiConfiguration enabledNetwork = null; synchronized(mConfiguredNetworks) { enabledNetwork = mConfiguredNetworks.get(netId); Loading @@ -397,6 +412,7 @@ class WifiConfigStore { } void disableAllNetworks() { localLog("disableAllNetworks"); boolean networkDisabled = false; for(WifiConfiguration config : mConfiguredNetworks.values()) { if(config != null && config.status != Status.DISABLED) { Loading Loading @@ -429,6 +445,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean disableNetwork(int netId, int reason) { localLog("disableNetwork", netId); boolean ret = mWifiNative.disableNetwork(netId); WifiConfiguration network = null; WifiConfiguration config = mConfiguredNetworks.get(netId); Loading Loading @@ -639,10 +656,13 @@ class WifiConfigStore { config.proxySettings = ProxySettings.NONE; mConfiguredNetworks.put(config.networkId, config); mNetworkIds.put(configKey(config), config.networkId); localLog("loaded configured network", config.networkId); } readIpAndProxyConfigurations(); sendConfiguredNetworksChangedBroadcast(); localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks"); } /* Mark all networks except specified netId as disabled */ Loading Loading @@ -972,6 +992,9 @@ class WifiConfigStore { * network configuration. Otherwise, the networkId should * refer to an existing configuration. */ localLog("addOrUpdateNetworkNative " + config.getPrintableSsid()); int netId = config.networkId; boolean newNetwork = false; // networkId of INVALID_NETWORK_ID means we want to create a new network Loading Loading @@ -1577,6 +1600,12 @@ class WifiConfigStore { pw.println(conf); } pw.println(); if (mLocalLog != null) { pw.println("WifiConfigStore - Log Begin ----"); mLocalLog.dump(fd, pw, args); pw.println("WifiConfigStore - Log End ----"); } } public String getConfigFile() { Loading @@ -1590,4 +1619,28 @@ class WifiConfigStore { private void log(String s) { Log.d(TAG, s); } private void localLog(String s) { if (mLocalLog != null) { mLocalLog.log(s); } } private void localLog(String s, int netId) { if (mLocalLog == null) { return; } WifiConfiguration config; synchronized(mConfiguredNetworks) { config = mConfiguredNetworks.get(netId); } if (config != null) { mLocalLog.log(s + " " + config.getPrintableSsid()); } else { mLocalLog.log(s + " " + netId); } } } wifi/java/android/net/wifi/WifiMonitor.java +1 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ public class WifiMonitor { } else { mIfaceMap.remove(iface); m.mWifiStateMachine.sendMessage(SUP_DISCONNECTION_EVENT); Log.e(TAG, "startMonitoring(" + iface + ") failed!"); break; } } Loading wifi/java/android/net/wifi/WifiNative.java +22 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pGroup; import android.text.TextUtils; import android.net.wifi.p2p.nsd.WifiP2pServiceInfo; import android.util.LocalLog; import android.util.Log; import java.util.ArrayList; Loading Loading @@ -91,6 +92,18 @@ public class WifiNative { } } private LocalLog mLocalLog; public void setLocalLog(LocalLog l) { mLocalLog = l; } private void localLog(String s) { if (mLocalLog != null) mLocalLog.log(mInterfaceName + ": " + s); } public boolean connectToSupplicant() { return connectToSupplicantNative(); } Loading Loading @@ -144,15 +157,18 @@ public class WifiNative { } public String listNetworks() { localLog("LIST_NETWORKS"); return doStringCommand("LIST_NETWORKS"); } public int addNetwork() { localLog("ADD_NETWORK"); return doIntCommand("ADD_NETWORK"); } public boolean setNetworkVariable(int netId, String name, String value) { if (TextUtils.isEmpty(name) || TextUtils.isEmpty(value)) return false; localLog("SET_NETWORK " + netId + " " + name + "=" + value); return doBooleanCommand("SET_NETWORK " + netId + " " + name + " " + value); } Loading @@ -162,22 +178,27 @@ public class WifiNative { } public boolean removeNetwork(int netId) { localLog("REMOVE_NETWORK " + netId); return doBooleanCommand("REMOVE_NETWORK " + netId); } public boolean enableNetwork(int netId, boolean disableOthers) { if (disableOthers) { localLog("SELECT_NETWORK " + netId); return doBooleanCommand("SELECT_NETWORK " + netId); } else { localLog("ENABLE_NETWORK " + netId); return doBooleanCommand("ENABLE_NETWORK " + netId); } } public boolean disableNetwork(int netId) { localLog("DISABLE_NETWORK " + netId); return doBooleanCommand("DISABLE_NETWORK " + netId); } public boolean reconnect() { localLog("RECONNECT"); return doBooleanCommand("RECONNECT"); } Loading Loading @@ -376,6 +397,7 @@ public class WifiNative { } public boolean saveConfig() { localLog("SAVE_CONFIG"); return doBooleanCommand("SAVE_CONFIG"); } Loading wifi/java/android/net/wifi/WifiStateMachine.java +3 −0 Original line number Diff line number Diff line Loading @@ -2790,7 +2790,10 @@ public class WifiStateMachine extends StateMachine { } else { /* Driver stop may have disabled networks, enable right after start */ mWifiConfigStore.enableAllNetworks(); if (DBG) log("Attempting to reconnect to wifi network .."); mWifiNative.reconnect(); // Status pulls in the current supplicant state and network connection state // events over the monitor connection. This helps framework sync up with // current supplicant state Loading Loading
wifi/java/android/net/wifi/WifiConfigStore.java +54 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.HandlerThread; import android.os.UserHandle; import android.security.KeyStore; import android.text.TextUtils; import android.util.LocalLog; import android.util.Log; import java.io.BufferedInputStream; Loading Loading @@ -108,7 +109,7 @@ class WifiConfigStore { private Context mContext; private static final String TAG = "WifiConfigStore"; private static final boolean DBG = false; private static final boolean DBG = true; /* configured networks with network id as the key */ private HashMap<Integer, WifiConfiguration> mConfiguredNetworks = Loading Loading @@ -145,12 +146,19 @@ class WifiConfigStore { private static final String EXCLUSION_LIST_KEY = "exclusionList"; private static final String EOS = "eos"; private final LocalLog mLocalLog; private WifiNative mWifiNative; private final KeyStore mKeyStore = KeyStore.getInstance(); WifiConfigStore(Context c, WifiNative wn) { mContext = c; mWifiNative = wn; if (DBG) { mLocalLog = new LocalLog(1024); // takes about 64 K mWifiNative.setLocalLog(mLocalLog); } } /** Loading Loading @@ -212,6 +220,7 @@ class WifiConfigStore { * @return false if the network id is invalid */ boolean selectNetwork(int netId) { localLog("selectNetwork", netId); if (netId == INVALID_NETWORK_ID) return false; // Reset the priority of each network at start or if it goes too high. Loading Loading @@ -248,6 +257,7 @@ class WifiConfigStore { * @return network update result */ NetworkUpdateResult saveNetwork(WifiConfiguration config) { localLog("saveNetwork", config.networkId); // A new network cannot have null SSID if (config == null || (config.networkId == INVALID_NETWORK_ID && config.SSID == null)) { Loading Loading @@ -296,6 +306,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean forgetNetwork(int netId) { localLog("forgetNetwork", netId); if (mWifiNative.removeNetwork(netId)) { mWifiNative.saveConfig(); removeConfigAndSendBroadcastIfNeeded(netId); Loading @@ -316,6 +327,7 @@ class WifiConfigStore { * @return network Id */ int addOrUpdateNetwork(WifiConfiguration config) { localLog("addOrUpdateNetwork", config.networkId); NetworkUpdateResult result = addOrUpdateNetworkNative(config); if (result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID) { sendConfiguredNetworksChangedBroadcast(mConfiguredNetworks.get(result.getNetworkId()), Loading @@ -335,6 +347,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean removeNetwork(int netId) { localLog("removeNetwork", netId); boolean ret = mWifiNative.removeNetwork(netId); if (ret) { removeConfigAndSendBroadcastIfNeeded(netId); Loading Loading @@ -369,8 +382,10 @@ class WifiConfigStore { boolean enableNetwork(int netId, boolean disableOthers) { boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers); if (disableOthers) { localLog("enableNetwork(disableOthers=true) ", netId); sendConfiguredNetworksChangedBroadcast(); } else { localLog("enableNetwork(disableOthers=false) ", netId); WifiConfiguration enabledNetwork = null; synchronized(mConfiguredNetworks) { enabledNetwork = mConfiguredNetworks.get(netId); Loading @@ -397,6 +412,7 @@ class WifiConfigStore { } void disableAllNetworks() { localLog("disableAllNetworks"); boolean networkDisabled = false; for(WifiConfiguration config : mConfiguredNetworks.values()) { if(config != null && config.status != Status.DISABLED) { Loading Loading @@ -429,6 +445,7 @@ class WifiConfigStore { * @return {@code true} if it succeeds, {@code false} otherwise */ boolean disableNetwork(int netId, int reason) { localLog("disableNetwork", netId); boolean ret = mWifiNative.disableNetwork(netId); WifiConfiguration network = null; WifiConfiguration config = mConfiguredNetworks.get(netId); Loading Loading @@ -639,10 +656,13 @@ class WifiConfigStore { config.proxySettings = ProxySettings.NONE; mConfiguredNetworks.put(config.networkId, config); mNetworkIds.put(configKey(config), config.networkId); localLog("loaded configured network", config.networkId); } readIpAndProxyConfigurations(); sendConfiguredNetworksChangedBroadcast(); localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks"); } /* Mark all networks except specified netId as disabled */ Loading Loading @@ -972,6 +992,9 @@ class WifiConfigStore { * network configuration. Otherwise, the networkId should * refer to an existing configuration. */ localLog("addOrUpdateNetworkNative " + config.getPrintableSsid()); int netId = config.networkId; boolean newNetwork = false; // networkId of INVALID_NETWORK_ID means we want to create a new network Loading Loading @@ -1577,6 +1600,12 @@ class WifiConfigStore { pw.println(conf); } pw.println(); if (mLocalLog != null) { pw.println("WifiConfigStore - Log Begin ----"); mLocalLog.dump(fd, pw, args); pw.println("WifiConfigStore - Log End ----"); } } public String getConfigFile() { Loading @@ -1590,4 +1619,28 @@ class WifiConfigStore { private void log(String s) { Log.d(TAG, s); } private void localLog(String s) { if (mLocalLog != null) { mLocalLog.log(s); } } private void localLog(String s, int netId) { if (mLocalLog == null) { return; } WifiConfiguration config; synchronized(mConfiguredNetworks) { config = mConfiguredNetworks.get(netId); } if (config != null) { mLocalLog.log(s + " " + config.getPrintableSsid()); } else { mLocalLog.log(s + " " + netId); } } }
wifi/java/android/net/wifi/WifiMonitor.java +1 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ public class WifiMonitor { } else { mIfaceMap.remove(iface); m.mWifiStateMachine.sendMessage(SUP_DISCONNECTION_EVENT); Log.e(TAG, "startMonitoring(" + iface + ") failed!"); break; } } Loading
wifi/java/android/net/wifi/WifiNative.java +22 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pGroup; import android.text.TextUtils; import android.net.wifi.p2p.nsd.WifiP2pServiceInfo; import android.util.LocalLog; import android.util.Log; import java.util.ArrayList; Loading Loading @@ -91,6 +92,18 @@ public class WifiNative { } } private LocalLog mLocalLog; public void setLocalLog(LocalLog l) { mLocalLog = l; } private void localLog(String s) { if (mLocalLog != null) mLocalLog.log(mInterfaceName + ": " + s); } public boolean connectToSupplicant() { return connectToSupplicantNative(); } Loading Loading @@ -144,15 +157,18 @@ public class WifiNative { } public String listNetworks() { localLog("LIST_NETWORKS"); return doStringCommand("LIST_NETWORKS"); } public int addNetwork() { localLog("ADD_NETWORK"); return doIntCommand("ADD_NETWORK"); } public boolean setNetworkVariable(int netId, String name, String value) { if (TextUtils.isEmpty(name) || TextUtils.isEmpty(value)) return false; localLog("SET_NETWORK " + netId + " " + name + "=" + value); return doBooleanCommand("SET_NETWORK " + netId + " " + name + " " + value); } Loading @@ -162,22 +178,27 @@ public class WifiNative { } public boolean removeNetwork(int netId) { localLog("REMOVE_NETWORK " + netId); return doBooleanCommand("REMOVE_NETWORK " + netId); } public boolean enableNetwork(int netId, boolean disableOthers) { if (disableOthers) { localLog("SELECT_NETWORK " + netId); return doBooleanCommand("SELECT_NETWORK " + netId); } else { localLog("ENABLE_NETWORK " + netId); return doBooleanCommand("ENABLE_NETWORK " + netId); } } public boolean disableNetwork(int netId) { localLog("DISABLE_NETWORK " + netId); return doBooleanCommand("DISABLE_NETWORK " + netId); } public boolean reconnect() { localLog("RECONNECT"); return doBooleanCommand("RECONNECT"); } Loading Loading @@ -376,6 +397,7 @@ public class WifiNative { } public boolean saveConfig() { localLog("SAVE_CONFIG"); return doBooleanCommand("SAVE_CONFIG"); } Loading
wifi/java/android/net/wifi/WifiStateMachine.java +3 −0 Original line number Diff line number Diff line Loading @@ -2790,7 +2790,10 @@ public class WifiStateMachine extends StateMachine { } else { /* Driver stop may have disabled networks, enable right after start */ mWifiConfigStore.enableAllNetworks(); if (DBG) log("Attempting to reconnect to wifi network .."); mWifiNative.reconnect(); // Status pulls in the current supplicant state and network connection state // events over the monitor connection. This helps framework sync up with // current supplicant state Loading