summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-03-24 17:58:59 -0700
committerIrfan Sheriff <isheriff@google.com>2010-03-25 15:10:34 -0700
commita3bd409a0a5dea446bd1b6edca1b367f3f70b503 (patch)
treefeea7bb56c78a921f04969d1124f9182c48e6a27
parentbfb7bfa53847832db2a3eb05e5eff7cb974c3c7a (diff)
downloadframeworks_base-a3bd409a0a5dea446bd1b6edca1b367f3f70b503.zip
frameworks_base-a3bd409a0a5dea446bd1b6edca1b367f3f70b503.tar.gz
frameworks_base-a3bd409a0a5dea446bd1b6edca1b367f3f70b503.tar.bz2
settings variable for wifi saved state
We add a variable for saving wifi state to restore after tethering. Bring up wifi on boot up if the state indicates so. Bug: 2537983 Change-Id: I9c6548b93df6fcbc0cec1e6b857f7224dc6d1b2c
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--services/java/com/android/server/WifiService.java18
2 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 6e37f69..b8e5747 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2508,11 +2508,13 @@ public final class Settings {
public static final String WIFI_ON = "wifi_on";
/**
- * Whether the Wi-Fi AP should be on.
+ * Used to save the Wifi_ON state prior to tethering.
+ * This state will be checked to restore Wifi after
+ * the user turns off tethering.
*
* @hide
*/
- public static final String WIFI_AP_ON = "wifi_ap_on";
+ public static final String WIFI_SAVED_STATE = "wifi_saved_state";
/**
* AP SSID
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 6fe4c98..e4d7623 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -264,10 +264,11 @@ public class WifiService extends IWifiManager.Stub {
* if needed
*/
public void startWifi() {
- boolean wifiEnabled = getPersistedWifiEnabled();
+ /* Start if Wi-Fi is enabled or the saved state indicates Wi-Fi was on */
+ boolean wifiEnabled = getPersistedWifiEnabled() || testAndClearWifiSavedState();
Slog.i(TAG, "WifiService starting up with Wi-Fi " +
(wifiEnabled ? "enabled" : "disabled"));
- setWifiEnabledBlocking(wifiEnabled, false, Process.myUid());
+ setWifiEnabledBlocking(wifiEnabled, true, Process.myUid());
}
private void updateTetherState(ArrayList<String> available, ArrayList<String> tethered) {
@@ -316,6 +317,19 @@ public class WifiService extends IWifiManager.Stub {
}
}
+ private boolean testAndClearWifiSavedState() {
+ final ContentResolver cr = mContext.getContentResolver();
+ int wifiSavedState = 0;
+ try {
+ wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE);
+ if(wifiSavedState == 1)
+ Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 0);
+ } catch (Settings.SettingNotFoundException e) {
+ ;
+ }
+ return (wifiSavedState == 1);
+ }
+
private boolean getPersistedWifiEnabled() {
final ContentResolver cr = mContext.getContentResolver();
try {