Skip to content

Commit 6f5a9a9

Browse files
author
Christopher Tate
committed
Fix default population of wifi settings
Various wifi settings that are explicitly defaulted did not get their default code properly converted to refer to the correct settings database table. A collection of moved-to-Global settings that had not yet been marked @deprecated in the Secure.* namespace are now so marked. Also updated the namespace used to refer to wifi settings from the Wifi Service. These changes are cosmetic, but they do eliminate a number of runtime log messages. Bug 7153671 Change-Id: I9e5b6464d025cfb480ef97373996e38e82f90593
1 parent 4f49d94 commit 6f5a9a9

File tree

4 files changed

+68
-54
lines changed

4 files changed

+68
-54
lines changed

core/java/android/provider/Settings.java

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,55 +3563,62 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
35633563
public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
35643564

35653565
/**
3566-
* Whether to notify the user of open networks.
3567-
* <p>
3568-
* If not connected and the scan results have an open network, we will
3569-
* put this notification up. If we attempt to connect to a network or
3570-
* the open network(s) disappear, we remove the notification. When we
3571-
* show the notification, we will not show it again for
3572-
* {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
3566+
* @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
3567+
* instead.
35733568
*/
3569+
@Deprecated
35743570
public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3575-
"wifi_networks_available_notification_on";
3571+
Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
35763572
/**
3573+
* @deprecated Moved to Global namespace
35773574
* {@hide}
35783575
*/
3576+
@Deprecated
35793577
public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3580-
"wimax_networks_available_notification_on";
3578+
Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON;
35813579

35823580
/**
3583-
* Delay (in seconds) before repeating the Wi-Fi networks available notification.
3584-
* Connecting to a network will reset the timer.
3581+
* @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
3582+
* instead.
35853583
*/
3584+
@Deprecated
35863585
public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
3587-
"wifi_networks_available_repeat_delay";
3586+
Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
35883587

35893588
/**
3590-
* 802.11 country code in ISO 3166 format
3589+
* @deprecated Use {@link android.provider.Settings.Global#WIFI_COUNTRY_CODE}
3590+
* instead.
35913591
* @hide
35923592
*/
3593-
public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
3593+
@Deprecated
3594+
public static final String WIFI_COUNTRY_CODE = Global.WIFI_COUNTRY_CODE;
35943595

35953596

35963597
/**
3597-
* When the number of open networks exceeds this number, the
3598-
* least-recently-used excess networks will be removed.
3598+
* @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
3599+
* instead.
35993600
*/
3600-
public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
3601+
@Deprecated
3602+
public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
3603+
Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
36013604

36023605
/**
3603-
* Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this.
3606+
* @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
3607+
* instead.
36043608
*/
3605-
public static final String WIFI_ON = "wifi_on";
3609+
@Deprecated
3610+
public static final String WIFI_ON = Global.WIFI_ON;
36063611

36073612
/**
36083613
* Used to save the Wifi_ON state prior to tethering.
36093614
* This state will be checked to restore Wifi after
36103615
* the user turns off tethering.
36113616
*
36123617
* @hide
3618+
* @deprecated moved to Global
36133619
*/
3614-
public static final String WIFI_SAVED_STATE = "wifi_saved_state";
3620+
@Deprecated
3621+
public static final String WIFI_SAVED_STATE = Global.WIFI_SAVED_STATE;
36153622

36163623
/**
36173624
* AP SSID
@@ -4220,24 +4227,30 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
42204227
* When idle, it is possible for the device to be switched from Wi-Fi to
42214228
* the mobile data network.
42224229
* @hide
4230+
* @deprecated Moved to Global
42234231
*/
4224-
public static final String WIFI_IDLE_MS = "wifi_idle_ms";
4232+
@Deprecated
4233+
public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
42254234

42264235
/**
42274236
* The interval in milliseconds to issue wake up scans when wifi needs
42284237
* to connect. This is necessary to connect to an access point when
42294238
* device is on the move and the screen is off.
42304239
* @hide
4240+
* @deprecated Moved to Global
42314241
*/
4242+
@Deprecated
42324243
public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
4233-
"wifi_framework_scan_interval_ms";
4244+
Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS;
42344245

42354246
/**
42364247
* The interval in milliseconds to scan as used by the wifi supplicant
42374248
* @hide
4249+
* @deprecated Moved to Global
42384250
*/
4251+
@Deprecated
42394252
public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
4240-
"wifi_supplicant_scan_interval_ms";
4253+
Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS;
42414254

42424255
/**
42434256
* @deprecated Moved to Settings.Global

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,17 +1803,9 @@ private void loadSecureSettings(SQLiteDatabase db) {
18031803
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
18041804
+ " VALUES(?,?);");
18051805

1806-
loadBooleanSetting(stmt, Settings.Secure.PACKAGE_VERIFIER_ENABLE,
1807-
R.bool.def_package_verifier_enable);
1808-
18091806
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
18101807
R.string.def_location_providers_allowed);
18111808

1812-
loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
1813-
R.bool.def_wifi_on);
1814-
loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
1815-
R.bool.def_networks_available_notification_on);
1816-
18171809
String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
18181810
if (!TextUtils.isEmpty(wifiWatchList)) {
18191811
loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList);
@@ -1943,6 +1935,15 @@ private void loadGlobalSettings(SQLiteDatabase db) {
19431935
R.integer.def_wifi_sleep_policy);
19441936

19451937
// --- Previously in 'secure'
1938+
loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE,
1939+
R.bool.def_package_verifier_enable);
1940+
1941+
loadBooleanSetting(stmt, Settings.Global.WIFI_ON,
1942+
R.bool.def_wifi_on);
1943+
1944+
loadBooleanSetting(stmt, Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
1945+
R.bool.def_networks_available_notification_on);
1946+
19461947
loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON,
19471948
R.bool.def_bluetooth_on);
19481949

services/java/com/android/server/WifiService.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public class WifiService extends IWifiManager.Stub {
133133
private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000;
134134

135135
/**
136-
* See {@link Settings.Secure#WIFI_IDLE_MS}. This is the default value if a
137-
* Settings.Secure value is not present. This timeout value is chosen as
136+
* See {@link Settings.Global#WIFI_IDLE_MS}. This is the default value if a
137+
* Settings.Global value is not present. This timeout value is chosen as
138138
* the approximate point at which the battery drain caused by Wi-Fi
139139
* being enabled but not active exceeds the battery drain caused by
140140
* re-establishing a connection to the mobile data network.
@@ -431,8 +431,8 @@ public void onReceive(Context context, Intent intent) {
431431
mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());
432432

433433
// Setting is in seconds
434-
NOTIFICATION_REPEAT_DELAY_MS = Settings.Secure.getInt(context.getContentResolver(),
435-
Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
434+
NOTIFICATION_REPEAT_DELAY_MS = Settings.Global.getInt(context.getContentResolver(),
435+
Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
436436
mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler());
437437
mNotificationEnabledSettingObserver.register();
438438
}
@@ -502,9 +502,9 @@ private boolean testAndClearWifiSavedState() {
502502
final ContentResolver cr = mContext.getContentResolver();
503503
int wifiSavedState = 0;
504504
try {
505-
wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE);
505+
wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
506506
if(wifiSavedState == 1)
507-
Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 0);
507+
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
508508
} catch (Settings.SettingNotFoundException e) {
509509
;
510510
}
@@ -514,9 +514,9 @@ private boolean testAndClearWifiSavedState() {
514514
private int getPersistedWifiState() {
515515
final ContentResolver cr = mContext.getContentResolver();
516516
try {
517-
return Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON);
517+
return Settings.Global.getInt(cr, Settings.Global.WIFI_ON);
518518
} catch (Settings.SettingNotFoundException e) {
519-
Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, WIFI_DISABLED);
519+
Settings.Global.putInt(cr, Settings.Global.WIFI_ON, WIFI_DISABLED);
520520
return WIFI_DISABLED;
521521
}
522522
}
@@ -564,7 +564,7 @@ private void handleAirplaneModeToggled(boolean airplaneEnabled) {
564564
private void persistWifiState(int state) {
565565
final ContentResolver cr = mContext.getContentResolver();
566566
mPersistWifiState.set(state);
567-
Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, state);
567+
Settings.Global.putInt(cr, Settings.Global.WIFI_ON, state);
568568
}
569569

570570
/**
@@ -996,11 +996,11 @@ public void onReceive(Context context, Intent intent) {
996996
String action = intent.getAction();
997997

998998
long idleMillis =
999-
Settings.Secure.getLong(mContext.getContentResolver(),
1000-
Settings.Secure.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
999+
Settings.Global.getLong(mContext.getContentResolver(),
1000+
Settings.Global.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
10011001
int stayAwakeConditions =
1002-
Settings.System.getInt(mContext.getContentResolver(),
1003-
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
1002+
Settings.Global.getInt(mContext.getContentResolver(),
1003+
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
10041004
if (action.equals(Intent.ACTION_SCREEN_ON)) {
10051005
if (DBG) {
10061006
Slog.d(TAG, "ACTION_SCREEN_ON");
@@ -1779,8 +1779,8 @@ public NotificationEnabledSettingObserver(Handler handler) {
17791779

17801780
public void register() {
17811781
ContentResolver cr = mContext.getContentResolver();
1782-
cr.registerContentObserver(Settings.Secure.getUriFor(
1783-
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
1782+
cr.registerContentObserver(Settings.Global.getUriFor(
1783+
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
17841784
mNotificationEnabled = getValue();
17851785
}
17861786

@@ -1793,8 +1793,8 @@ public void onChange(boolean selfChange) {
17931793
}
17941794

17951795
private boolean getValue() {
1796-
return Settings.Secure.getInt(mContext.getContentResolver(),
1797-
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
1796+
return Settings.Global.getInt(mContext.getContentResolver(),
1797+
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
17981798
}
17991799
}
18001800

wifi/java/android/net/wifi/WifiStateMachine.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,14 @@ public class WifiStateMachine extends StateMachine {
398398
* Default framework scan interval in milliseconds. This is used in the scenario in which
399399
* wifi chipset does not support background scanning to set up a
400400
* periodic wake up scan so that the device can connect to a new access
401-
* point on the move. {@link Settings.Secure#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} can
401+
* point on the move. {@link Settings.Global#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} can
402402
* override this.
403403
*/
404404
private final int mDefaultFrameworkScanIntervalMs;
405405

406406
/**
407407
* Supplicant scan interval in milliseconds.
408-
* Comes from {@link Settings.Secure#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} or
408+
* Comes from {@link Settings.Global#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} or
409409
* from the default config if the setting is not set
410410
*/
411411
private long mSupplicantScanIntervalMs;
@@ -2403,8 +2403,8 @@ public void enter() {
24032403
int defaultInterval = mContext.getResources().getInteger(
24042404
com.android.internal.R.integer.config_wifi_supplicant_scan_interval);
24052405

2406-
mSupplicantScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(),
2407-
Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
2406+
mSupplicantScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
2407+
Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
24082408
defaultInterval);
24092409

24102410
mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000);
@@ -3445,8 +3445,8 @@ public void enter() {
34453445
if (DBG) log(getName() + "\n");
34463446
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
34473447

3448-
mFrameworkScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(),
3449-
Settings.Secure.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
3448+
mFrameworkScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
3449+
Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
34503450
mDefaultFrameworkScanIntervalMs);
34513451
/*
34523452
* We initiate background scanning if it is enabled, otherwise we

0 commit comments

Comments
 (0)