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
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user