Loading services/java/com/android/server/WifiService.java +15 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ public class WifiService extends IWifiManager.Stub { private static final int MESSAGE_START_ACCESS_POINT = 6; private static final int MESSAGE_STOP_ACCESS_POINT = 7; private static final int MESSAGE_SET_CHANNELS = 8; private static final int MESSAGE_ENABLE_NETWORKS = 9; private final WifiHandler mWifiHandler; Loading Loading @@ -1663,6 +1664,12 @@ public class WifiService extends IWifiManager.Stub { mDeviceIdle = false; mScreenOff = false; mWifiStateTracker.enableRssiPolling(true); /* DHCP or other temporary failures in the past can prevent * a disabled network from being connected to, enable on screen on */ if (mWifiStateTracker.isAnyNetworkDisabled()) { sendEnableNetworksMessage(); } } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { Slog.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; Loading Loading @@ -1794,6 +1801,10 @@ public class WifiService extends IWifiManager.Stub { uid, 0, wifiConfig).sendToTarget(); } private void sendEnableNetworksMessage() { Message.obtain(mWifiHandler, MESSAGE_ENABLE_NETWORKS).sendToTarget(); } private void updateWifiState() { // send a message so it's all serialized Message.obtain(mWifiHandler, MESSAGE_UPDATE_STATE, 0, 0).sendToTarget(); Loading Loading @@ -1956,6 +1967,10 @@ public class WifiService extends IWifiManager.Stub { setNumAllowedChannelsBlocking(msg.arg1, msg.arg2 == 1); break; case MESSAGE_ENABLE_NETWORKS: mWifiStateTracker.enableAllNetworks(getConfiguredNetworks()); break; } } } Loading wifi/java/android/net/wifi/WifiStateTracker.java +28 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicBoolean; /** * Track the state of Wifi connectivity. All event handling is done here, Loading Loading @@ -216,6 +217,9 @@ public class WifiStateTracker extends NetworkStateTracker { private boolean mUseStaticIp = false; private int mReconnectCount; /* Tracks if any network in the configuration is disabled */ private AtomicBoolean mIsAnyNetworkDisabled = new AtomicBoolean(false); // used to store the (non-persisted) num determined during device boot // (from mcc or other phone info) before the driver is started. private int mNumAllowedChannels = 0; Loading Loading @@ -814,6 +818,7 @@ public class WifiStateTracker extends NetworkStateTracker { mTornDownByConnMgr = false; mLastBssid = null; mLastSsid = null; mIsAnyNetworkDisabled.set(false); requestConnectionInfo(); SupplicantState supplState = mWifiInfo.getSupplicantState(); /** Loading Loading @@ -1585,6 +1590,10 @@ public class WifiStateTracker extends NetworkStateTracker { mWifiState.set(wifiState); } public boolean isAnyNetworkDisabled() { return mIsAnyNetworkDisabled.get(); } /** * The WifiNative interface functions are listed below. * The only native call that is not synchronized on Loading Loading @@ -1785,9 +1794,27 @@ public class WifiStateTracker extends NetworkStateTracker { if (mWifiState.get() != WIFI_STATE_ENABLED) { return false; } if (disableOthers) mIsAnyNetworkDisabled.set(true); return WifiNative.enableNetworkCommand(netId, disableOthers); } /** * Enable all networks * * @param networks list of configured networks */ public synchronized void enableAllNetworks(List<WifiConfiguration> networks) { if (mWifiState.get() != WIFI_STATE_ENABLED) { return; } mIsAnyNetworkDisabled.set(false); for (WifiConfiguration config : networks) { if (config.status == WifiConfiguration.Status.DISABLED) { WifiNative.enableNetworkCommand(config.networkId, false); } } } /** * Disable a network * Loading @@ -1798,6 +1825,7 @@ public class WifiStateTracker extends NetworkStateTracker { if (mWifiState.get() != WIFI_STATE_ENABLED) { return false; } mIsAnyNetworkDisabled.set(true); return WifiNative.disableNetworkCommand(netId); } Loading Loading
services/java/com/android/server/WifiService.java +15 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ public class WifiService extends IWifiManager.Stub { private static final int MESSAGE_START_ACCESS_POINT = 6; private static final int MESSAGE_STOP_ACCESS_POINT = 7; private static final int MESSAGE_SET_CHANNELS = 8; private static final int MESSAGE_ENABLE_NETWORKS = 9; private final WifiHandler mWifiHandler; Loading Loading @@ -1663,6 +1664,12 @@ public class WifiService extends IWifiManager.Stub { mDeviceIdle = false; mScreenOff = false; mWifiStateTracker.enableRssiPolling(true); /* DHCP or other temporary failures in the past can prevent * a disabled network from being connected to, enable on screen on */ if (mWifiStateTracker.isAnyNetworkDisabled()) { sendEnableNetworksMessage(); } } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { Slog.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; Loading Loading @@ -1794,6 +1801,10 @@ public class WifiService extends IWifiManager.Stub { uid, 0, wifiConfig).sendToTarget(); } private void sendEnableNetworksMessage() { Message.obtain(mWifiHandler, MESSAGE_ENABLE_NETWORKS).sendToTarget(); } private void updateWifiState() { // send a message so it's all serialized Message.obtain(mWifiHandler, MESSAGE_UPDATE_STATE, 0, 0).sendToTarget(); Loading Loading @@ -1956,6 +1967,10 @@ public class WifiService extends IWifiManager.Stub { setNumAllowedChannelsBlocking(msg.arg1, msg.arg2 == 1); break; case MESSAGE_ENABLE_NETWORKS: mWifiStateTracker.enableAllNetworks(getConfiguredNetworks()); break; } } } Loading
wifi/java/android/net/wifi/WifiStateTracker.java +28 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicBoolean; /** * Track the state of Wifi connectivity. All event handling is done here, Loading Loading @@ -216,6 +217,9 @@ public class WifiStateTracker extends NetworkStateTracker { private boolean mUseStaticIp = false; private int mReconnectCount; /* Tracks if any network in the configuration is disabled */ private AtomicBoolean mIsAnyNetworkDisabled = new AtomicBoolean(false); // used to store the (non-persisted) num determined during device boot // (from mcc or other phone info) before the driver is started. private int mNumAllowedChannels = 0; Loading Loading @@ -814,6 +818,7 @@ public class WifiStateTracker extends NetworkStateTracker { mTornDownByConnMgr = false; mLastBssid = null; mLastSsid = null; mIsAnyNetworkDisabled.set(false); requestConnectionInfo(); SupplicantState supplState = mWifiInfo.getSupplicantState(); /** Loading Loading @@ -1585,6 +1590,10 @@ public class WifiStateTracker extends NetworkStateTracker { mWifiState.set(wifiState); } public boolean isAnyNetworkDisabled() { return mIsAnyNetworkDisabled.get(); } /** * The WifiNative interface functions are listed below. * The only native call that is not synchronized on Loading Loading @@ -1785,9 +1794,27 @@ public class WifiStateTracker extends NetworkStateTracker { if (mWifiState.get() != WIFI_STATE_ENABLED) { return false; } if (disableOthers) mIsAnyNetworkDisabled.set(true); return WifiNative.enableNetworkCommand(netId, disableOthers); } /** * Enable all networks * * @param networks list of configured networks */ public synchronized void enableAllNetworks(List<WifiConfiguration> networks) { if (mWifiState.get() != WIFI_STATE_ENABLED) { return; } mIsAnyNetworkDisabled.set(false); for (WifiConfiguration config : networks) { if (config.status == WifiConfiguration.Status.DISABLED) { WifiNative.enableNetworkCommand(config.networkId, false); } } } /** * Disable a network * Loading @@ -1798,6 +1825,7 @@ public class WifiStateTracker extends NetworkStateTracker { if (mWifiState.get() != WIFI_STATE_ENABLED) { return false; } mIsAnyNetworkDisabled.set(true); return WifiNative.disableNetworkCommand(netId); } Loading