diff options
author | Christian Sonntag <cxs@android.com> | 2009-08-07 10:00:21 -0700 |
---|---|---|
committer | Christian Sonntag <cxs@android.com> | 2009-08-07 10:00:21 -0700 |
commit | c5b5b0fb94d078148b5fe5f6b8bb4ee361949f3e (patch) | |
tree | 2a503f5b925c2cc2c4a42b5e81793ce252ced6a0 /packages | |
parent | 69682b4c3722152add97165161dd013740eebe77 (diff) | |
download | frameworks_base-c5b5b0fb94d078148b5fe5f6b8bb4ee361949f3e.zip frameworks_base-c5b5b0fb94d078148b5fe5f6b8bb4ee361949f3e.tar.gz frameworks_base-c5b5b0fb94d078148b5fe5f6b8bb4ee361949f3e.tar.bz2 |
Retain state of wifi connection after restore
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java | 13 |
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) { |