summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNalla Kartheek <karthe@codeaurora.org>2016-07-20 16:55:47 +0530
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:08:00 -0600
commitd05213619e549580eebdc25517f290bc2f8eeee1 (patch)
tree066ced9010b77be9298843319d99e7617e7f28f0
parentdd54f2ab94ea8fcb2cb4521606074e1a0e5003bf (diff)
downloadandroid_frameworks_opt_net_wifi-d05213619e549580eebdc25517f290bc2f8eeee1.tar.gz
android_frameworks_opt_net_wifi-d05213619e549580eebdc25517f290bc2f8eeee1.tar.bz2
android_frameworks_opt_net_wifi-d05213619e549580eebdc25517f290bc2f8eeee1.zip
Wifi: Reset wifi networks for factory reset if wifi is off state
Framework enables wifi and query for saved networks to reset. These two operations are sequential. Saved profiles are generated in framework once wifi turn on process completes. If the factory reset is attempted when the Wi-Fi is TURNED OFF, the networks queried would be NULL, and thus they shall not be cleared. To fix this issue, listen for wifi state change events, and reset the networks once wifi state enabled event is received. Change-Id: I846186ae2867bf4657774d6511bd8e0635b249ac CRs-Fixed: 1043902
-rwxr-xr-xservice/java/com/android/server/wifi/WifiServiceImpl.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index c7aa1e593..505ad0dd8 100755
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -135,6 +135,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
private static final String TAG = "WifiService";
private static final boolean DBG = true;
private static final boolean VDBG = false;
+ private boolean mIsFactoryResetOn = false;
private static final String BOOT_DEFAULT_WIFI_COUNTRY_CODE = "ro.boot.wificountrycode";
final WifiStateMachine mWifiStateMachine;
@@ -1434,6 +1435,15 @@ public class WifiServiceImpl extends IWifiManager.Stub {
mWifiController.sendMessage(CMD_EMERGENCY_CALL_STATE_CHANGED, inCall ? 1 : 0, 0);
} else if (action.equals(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED)) {
handleIdleModeChanged();
+ } else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
+ int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+ WifiManager.WIFI_STATE_UNKNOWN);
+ if (state == WifiManager.WIFI_STATE_ENABLED) {
+ if (mIsFactoryResetOn) {
+ resetWifiNetworks();
+ mIsFactoryResetOn = false;
+ }
+ }
}
}
};
@@ -1462,6 +1472,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+ intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
@@ -2007,6 +2018,17 @@ public class WifiServiceImpl extends IWifiManager.Stub {
return mStaAndApConcurrency == 1;
}
+ private void resetWifiNetworks() {
+ // Delete all Wifi SSIDs
+ List<WifiConfiguration> networks = getConfiguredNetworks();
+ if (networks != null) {
+ for (WifiConfiguration config : networks) {
+ removeNetwork(config.networkId);
+ }
+ saveConfiguration();
+ }
+ }
+
public void factoryReset() {
enforceConnectivityInternalPermission();
@@ -2020,15 +2042,12 @@ public class WifiServiceImpl extends IWifiManager.Stub {
}
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) {
- // Enable wifi
- setWifiEnabled(true);
- // Delete all Wifi SSIDs
- List<WifiConfiguration> networks = getConfiguredNetworks();
- if (networks != null) {
- for (WifiConfiguration config : networks) {
- removeNetwork(config.networkId);
- }
- saveConfiguration();
+ if (getWifiEnabledState() == WifiManager.WIFI_STATE_ENABLED) {
+ resetWifiNetworks();
+ } else {
+ mIsFactoryResetOn = true;
+ // Enable wifi
+ setWifiEnabled(true);
}
}
}