am 2892dfbe: Merge "Fix default population of wifi settings" into jb-mr1-dev

* commit '2892dfbeafec5315d05fb6ceabeaee73b88f5ff0':
  Fix default population of wifi settings
This commit is contained in:
Christopher Tate
2012-09-15 16:11:25 -07:00
committed by Android Git Automerger
4 changed files with 68 additions and 54 deletions

View File

@@ -3563,46 +3563,51 @@ public final class Settings {
public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins"; public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
/** /**
* Whether to notify the user of open networks. * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
* <p> * instead.
* If not connected and the scan results have an open network, we will
* put this notification up. If we attempt to connect to a network or
* the open network(s) disappear, we remove the notification. When we
* show the notification, we will not show it again for
* {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
*/ */
@Deprecated
public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
"wifi_networks_available_notification_on"; Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
/** /**
* @deprecated Moved to Global namespace
* {@hide} * {@hide}
*/ */
@Deprecated
public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON = public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
"wimax_networks_available_notification_on"; Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON;
/** /**
* Delay (in seconds) before repeating the Wi-Fi networks available notification. * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
* Connecting to a network will reset the timer. * instead.
*/ */
@Deprecated
public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
"wifi_networks_available_repeat_delay"; Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
/** /**
* 802.11 country code in ISO 3166 format * @deprecated Use {@link android.provider.Settings.Global#WIFI_COUNTRY_CODE}
* instead.
* @hide * @hide
*/ */
public static final String WIFI_COUNTRY_CODE = "wifi_country_code"; @Deprecated
public static final String WIFI_COUNTRY_CODE = Global.WIFI_COUNTRY_CODE;
/** /**
* When the number of open networks exceeds this number, the * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
* least-recently-used excess networks will be removed. * instead.
*/ */
public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept"; @Deprecated
public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
/** /**
* Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this. * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
* instead.
*/ */
public static final String WIFI_ON = "wifi_on"; @Deprecated
public static final String WIFI_ON = Global.WIFI_ON;
/** /**
* Used to save the Wifi_ON state prior to tethering. * Used to save the Wifi_ON state prior to tethering.
@@ -3610,8 +3615,10 @@ public final class Settings {
* the user turns off tethering. * the user turns off tethering.
* *
* @hide * @hide
* @deprecated moved to Global
*/ */
public static final String WIFI_SAVED_STATE = "wifi_saved_state"; @Deprecated
public static final String WIFI_SAVED_STATE = Global.WIFI_SAVED_STATE;
/** /**
* AP SSID * AP SSID
@@ -4220,24 +4227,30 @@ public final class Settings {
* When idle, it is possible for the device to be switched from Wi-Fi to * When idle, it is possible for the device to be switched from Wi-Fi to
* the mobile data network. * the mobile data network.
* @hide * @hide
* @deprecated Moved to Global
*/ */
public static final String WIFI_IDLE_MS = "wifi_idle_ms"; @Deprecated
public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
/** /**
* The interval in milliseconds to issue wake up scans when wifi needs * The interval in milliseconds to issue wake up scans when wifi needs
* to connect. This is necessary to connect to an access point when * to connect. This is necessary to connect to an access point when
* device is on the move and the screen is off. * device is on the move and the screen is off.
* @hide * @hide
* @deprecated Moved to Global
*/ */
@Deprecated
public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS = public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
"wifi_framework_scan_interval_ms"; Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS;
/** /**
* The interval in milliseconds to scan as used by the wifi supplicant * The interval in milliseconds to scan as used by the wifi supplicant
* @hide * @hide
* @deprecated Moved to Global
*/ */
@Deprecated
public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS = public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
"wifi_supplicant_scan_interval_ms"; Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS;
/** /**
* @deprecated Moved to Settings.Global * @deprecated Moved to Settings.Global

View File

@@ -1803,17 +1803,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.PACKAGE_VERIFIER_ENABLE,
R.bool.def_package_verifier_enable);
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
R.string.def_location_providers_allowed); R.string.def_location_providers_allowed);
loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
R.bool.def_wifi_on);
loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
R.bool.def_networks_available_notification_on);
String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
if (!TextUtils.isEmpty(wifiWatchList)) { if (!TextUtils.isEmpty(wifiWatchList)) {
loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList); loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList);
@@ -1943,6 +1935,15 @@ public class DatabaseHelper extends SQLiteOpenHelper {
R.integer.def_wifi_sleep_policy); R.integer.def_wifi_sleep_policy);
// --- Previously in 'secure' // --- Previously in 'secure'
loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE,
R.bool.def_package_verifier_enable);
loadBooleanSetting(stmt, Settings.Global.WIFI_ON,
R.bool.def_wifi_on);
loadBooleanSetting(stmt, Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
R.bool.def_networks_available_notification_on);
loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON, loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON,
R.bool.def_bluetooth_on); R.bool.def_bluetooth_on);

View File

@@ -133,8 +133,8 @@ public class WifiService extends IWifiManager.Stub {
private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000; private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000;
/** /**
* See {@link Settings.Secure#WIFI_IDLE_MS}. This is the default value if a * See {@link Settings.Global#WIFI_IDLE_MS}. This is the default value if a
* Settings.Secure value is not present. This timeout value is chosen as * Settings.Global value is not present. This timeout value is chosen as
* the approximate point at which the battery drain caused by Wi-Fi * the approximate point at which the battery drain caused by Wi-Fi
* being enabled but not active exceeds the battery drain caused by * being enabled but not active exceeds the battery drain caused by
* re-establishing a connection to the mobile data network. * re-establishing a connection to the mobile data network.
@@ -431,8 +431,8 @@ public class WifiService extends IWifiManager.Stub {
mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper()); mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());
// Setting is in seconds // Setting is in seconds
NOTIFICATION_REPEAT_DELAY_MS = Settings.Secure.getInt(context.getContentResolver(), NOTIFICATION_REPEAT_DELAY_MS = Settings.Global.getInt(context.getContentResolver(),
Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l; Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler()); mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler());
mNotificationEnabledSettingObserver.register(); mNotificationEnabledSettingObserver.register();
} }
@@ -502,9 +502,9 @@ public class WifiService extends IWifiManager.Stub {
final ContentResolver cr = mContext.getContentResolver(); final ContentResolver cr = mContext.getContentResolver();
int wifiSavedState = 0; int wifiSavedState = 0;
try { try {
wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE); wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
if(wifiSavedState == 1) if(wifiSavedState == 1)
Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 0); Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
} catch (Settings.SettingNotFoundException e) { } catch (Settings.SettingNotFoundException e) {
; ;
} }
@@ -514,9 +514,9 @@ public class WifiService extends IWifiManager.Stub {
private int getPersistedWifiState() { private int getPersistedWifiState() {
final ContentResolver cr = mContext.getContentResolver(); final ContentResolver cr = mContext.getContentResolver();
try { try {
return Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON); return Settings.Global.getInt(cr, Settings.Global.WIFI_ON);
} catch (Settings.SettingNotFoundException e) { } catch (Settings.SettingNotFoundException e) {
Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, WIFI_DISABLED); Settings.Global.putInt(cr, Settings.Global.WIFI_ON, WIFI_DISABLED);
return WIFI_DISABLED; return WIFI_DISABLED;
} }
} }
@@ -564,7 +564,7 @@ public class WifiService extends IWifiManager.Stub {
private void persistWifiState(int state) { private void persistWifiState(int state) {
final ContentResolver cr = mContext.getContentResolver(); final ContentResolver cr = mContext.getContentResolver();
mPersistWifiState.set(state); mPersistWifiState.set(state);
Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, state); Settings.Global.putInt(cr, Settings.Global.WIFI_ON, state);
} }
/** /**
@@ -996,11 +996,11 @@ public class WifiService extends IWifiManager.Stub {
String action = intent.getAction(); String action = intent.getAction();
long idleMillis = long idleMillis =
Settings.Secure.getLong(mContext.getContentResolver(), Settings.Global.getLong(mContext.getContentResolver(),
Settings.Secure.WIFI_IDLE_MS, DEFAULT_IDLE_MS); Settings.Global.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
int stayAwakeConditions = int stayAwakeConditions =
Settings.System.getInt(mContext.getContentResolver(), Settings.Global.getInt(mContext.getContentResolver(),
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0); Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
if (action.equals(Intent.ACTION_SCREEN_ON)) { if (action.equals(Intent.ACTION_SCREEN_ON)) {
if (DBG) { if (DBG) {
Slog.d(TAG, "ACTION_SCREEN_ON"); Slog.d(TAG, "ACTION_SCREEN_ON");
@@ -1779,8 +1779,8 @@ public class WifiService extends IWifiManager.Stub {
public void register() { public void register() {
ContentResolver cr = mContext.getContentResolver(); ContentResolver cr = mContext.getContentResolver();
cr.registerContentObserver(Settings.Secure.getUriFor( cr.registerContentObserver(Settings.Global.getUriFor(
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this); Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
mNotificationEnabled = getValue(); mNotificationEnabled = getValue();
} }
@@ -1793,8 +1793,8 @@ public class WifiService extends IWifiManager.Stub {
} }
private boolean getValue() { private boolean getValue() {
return Settings.Secure.getInt(mContext.getContentResolver(), return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1; Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
} }
} }

View File

@@ -396,14 +396,14 @@ public class WifiStateMachine extends StateMachine {
* Default framework scan interval in milliseconds. This is used in the scenario in which * Default framework scan interval in milliseconds. This is used in the scenario in which
* wifi chipset does not support background scanning to set up a * wifi chipset does not support background scanning to set up a
* periodic wake up scan so that the device can connect to a new access * periodic wake up scan so that the device can connect to a new access
* point on the move. {@link Settings.Secure#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} can * point on the move. {@link Settings.Global#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} can
* override this. * override this.
*/ */
private final int mDefaultFrameworkScanIntervalMs; private final int mDefaultFrameworkScanIntervalMs;
/** /**
* Supplicant scan interval in milliseconds. * Supplicant scan interval in milliseconds.
* Comes from {@link Settings.Secure#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} or * Comes from {@link Settings.Global#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} or
* from the default config if the setting is not set * from the default config if the setting is not set
*/ */
private long mSupplicantScanIntervalMs; private long mSupplicantScanIntervalMs;
@@ -2402,8 +2402,8 @@ public class WifiStateMachine extends StateMachine {
int defaultInterval = mContext.getResources().getInteger( int defaultInterval = mContext.getResources().getInteger(
com.android.internal.R.integer.config_wifi_supplicant_scan_interval); com.android.internal.R.integer.config_wifi_supplicant_scan_interval);
mSupplicantScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(), mSupplicantScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS, Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
defaultInterval); defaultInterval);
mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000); mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000);
@@ -3441,8 +3441,8 @@ public class WifiStateMachine extends StateMachine {
if (DBG) log(getName() + "\n"); if (DBG) log(getName() + "\n");
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
mFrameworkScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(), mFrameworkScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
Settings.Secure.WIFI_FRAMEWORK_SCAN_INTERVAL_MS, Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
mDefaultFrameworkScanIntervalMs); mDefaultFrameworkScanIntervalMs);
/* /*
* We initiate background scanning if it is enabled, otherwise we * We initiate background scanning if it is enabled, otherwise we