summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-07 10:45:29 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-07 10:45:29 -0700
commit52e37725c8f94224dfd5157fed75a33411772a39 (patch)
tree50412457fd4b4e7333ebfcdcc9417aca81c1c134
parentd5603c126acdd94d9f7400bb1d04188020a425b4 (diff)
parentc5b5b0fb94d078148b5fe5f6b8bb4ee361949f3e (diff)
downloadframeworks_base-52e37725c8f94224dfd5157fed75a33411772a39.zip
frameworks_base-52e37725c8f94224dfd5157fed75a33411772a39.tar.gz
frameworks_base-52e37725c8f94224dfd5157fed75a33411772a39.tar.bz2
Merge change 20423
* changes: Retain state of wifi connection after restore
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 2b36904..e53171f 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -122,7 +122,7 @@ public class SettingsBackupAgent extends BackupHelperAgent {
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
- enableWifi(false);
+
enableBluetooth(false);
while (data.readNextHeader()) {
@@ -134,11 +134,15 @@ public class SettingsBackupAgent extends BackupHelperAgent {
} else if (KEY_SECURE.equals(key)) {
restoreSettings(data, Settings.Secure.CONTENT_URI);
} else if (FILE_WIFI_SUPPLICANT.equals(key)) {
+ int retainedWifiState = enableWifi(false);
restoreFile(FILE_WIFI_SUPPLICANT, data);
FileUtils.setPermissions(FILE_WIFI_SUPPLICANT,
FileUtils.S_IRUSR | FileUtils.S_IWUSR |
FileUtils.S_IRGRP | FileUtils.S_IWGRP,
Process.myUid(), Process.WIFI_UID);
+ // retain the previous WIFI state.
+ enableWifi(retainedWifiState == WifiManager.WIFI_STATE_ENABLED ||
+ retainedWifiState == WifiManager.WIFI_STATE_ENABLING);
} else if (KEY_SYNC.equals(key)) {
mSettingsHelper.setSyncProviders(data);
} else if (KEY_LOCALE.equals(key)) {
@@ -257,7 +261,7 @@ public class SettingsBackupAgent extends BackupHelperAgent {
}
/**
- * Given a cursor sorted by key name and a set of keys sorted by name,
+ * Given a cursor sorted by key name and a set of keys sorted by name,
* extract the required keys and values and write them to a byte array.
* @param sortedCursor
* @param sortedKeys
@@ -373,11 +377,14 @@ public class SettingsBackupAgent extends BackupHelperAgent {
return result;
}
- private void enableWifi(boolean enable) {
+ private int enableWifi(boolean enable) {
WifiManager wfm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wfm != null) {
+ int state = wfm.getWifiState();
wfm.setWifiEnabled(enable);
+ return state;
}
+ return WifiManager.WIFI_STATE_UNKNOWN;
}
private void enableBluetooth(boolean enable) {