Methods Summary |
---|
void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
pw.println("mPersistWifiState " + mPersistWifiState);
pw.println("mAirplaneModeOn " + mAirplaneModeOn);
|
private boolean | getPersistedAirplaneModeOn()
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
|
private boolean | getPersistedScanAlwaysAvailable()
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE,
0) == 1;
|
private int | getPersistedWifiState()
final ContentResolver cr = mContext.getContentResolver();
try {
return Settings.Global.getInt(cr, Settings.Global.WIFI_ON);
} catch (Settings.SettingNotFoundException e) {
Settings.Global.putInt(cr, Settings.Global.WIFI_ON, WIFI_DISABLED);
return WIFI_DISABLED;
}
|
synchronized boolean | handleAirplaneModeToggled()
// Is Wi-Fi sensitive to airplane mode changes ?
if (!isAirplaneSensitive()) {
return false;
}
mAirplaneModeOn = getPersistedAirplaneModeOn();
if (mAirplaneModeOn) {
// Wifi disabled due to airplane on
if (mPersistWifiState == WIFI_ENABLED) {
persistWifiState(WIFI_DISABLED_AIRPLANE_ON);
}
} else {
/* On airplane mode disable, restore wifi state if necessary */
if (testAndClearWifiSavedState() ||
mPersistWifiState == WIFI_ENABLED_AIRPLANE_OVERRIDE) {
persistWifiState(WIFI_ENABLED);
}
}
return true;
|
synchronized void | handleWifiScanAlwaysAvailableToggled()
mScanAlwaysAvailable = getPersistedScanAlwaysAvailable();
|
synchronized boolean | handleWifiToggled(boolean wifiEnabled)
// Can Wi-Fi be toggled in airplane mode ?
if (mAirplaneModeOn && !isAirplaneToggleable()) {
return false;
}
if (wifiEnabled) {
if (mAirplaneModeOn) {
persistWifiState(WIFI_ENABLED_AIRPLANE_OVERRIDE);
} else {
persistWifiState(WIFI_ENABLED);
}
} else {
// When wifi state is disabled, we do not care
// if airplane mode is on or not. The scenario of
// wifi being disabled due to airplane mode being turned on
// is handled handleAirplaneModeToggled()
persistWifiState(WIFI_DISABLED);
}
return true;
|
synchronized boolean | isAirplaneModeOn()Returns true if airplane mode is currently on.
return mAirplaneModeOn;
|
private boolean | isAirplaneSensitive()
String airplaneModeRadios = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_RADIOS);
return airplaneModeRadios == null
|| airplaneModeRadios.contains(Settings.Global.RADIO_WIFI);
|
private boolean | isAirplaneToggleable()
String toggleableRadios = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
return toggleableRadios != null
&& toggleableRadios.contains(Settings.Global.RADIO_WIFI);
|
synchronized boolean | isScanAlwaysAvailable()
return !mAirplaneModeOn && mScanAlwaysAvailable;
|
synchronized boolean | isWifiToggleEnabled()
if (!mCheckSavedStateAtBoot) {
mCheckSavedStateAtBoot = true;
if (testAndClearWifiSavedState()) return true;
}
if (mAirplaneModeOn) {
return mPersistWifiState == WIFI_ENABLED_AIRPLANE_OVERRIDE;
} else {
return mPersistWifiState != WIFI_DISABLED;
}
|
private void | persistWifiState(int state)
final ContentResolver cr = mContext.getContentResolver();
mPersistWifiState = state;
Settings.Global.putInt(cr, Settings.Global.WIFI_ON, state);
|
private boolean | testAndClearWifiSavedState()
final ContentResolver cr = mContext.getContentResolver();
int wifiSavedState = 0;
try {
wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
if(wifiSavedState == 1)
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
} catch (Settings.SettingNotFoundException e) {
;
}
return (wifiSavedState == 1);
|