Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2892dfbe authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Fix default population of wifi settings" into jb-mr1-dev

parents 8dd9206a 6f5a9a96
Loading
Loading
Loading
Loading
+36 −23
Original line number Diff line number Diff line
@@ -3563,46 +3563,51 @@ public final class Settings {
        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";

        /**
         * Whether to notify the user of open networks.
         * <p>
         * 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 Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
         * instead.
         */
        @Deprecated
        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}
         */
        @Deprecated
        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.
         * Connecting to a network will reset the timer.
         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
         * instead.
         */
        @Deprecated
        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
         */
        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
         * least-recently-used excess networks will be removed.
         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
         * 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.
@@ -3610,8 +3615,10 @@ public final class Settings {
         * the user turns off tethering.
         *
         * @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
@@ -4220,24 +4227,30 @@ public final class Settings {
         * When idle, it is possible for the device to be switched from Wi-Fi to
         * the mobile data network.
         * @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
         * to connect. This is necessary to connect to an access point when
         * device is on the move and the screen is off.
         * @hide
         * @deprecated Moved to Global
         */
        @Deprecated
        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
         * @hide
         * @deprecated Moved to Global
         */
        @Deprecated
        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
+9 −8
Original line number Diff line number Diff line
@@ -1803,17 +1803,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
                    + " VALUES(?,?);");

            loadBooleanSetting(stmt, Settings.Secure.PACKAGE_VERIFIER_ENABLE,
                R.bool.def_package_verifier_enable);

            loadStringSetting(stmt, Settings.Secure.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");
            if (!TextUtils.isEmpty(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);

            // --- 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,
                    R.bool.def_bluetooth_on);

+17 −17
Original line number Diff line number Diff line
@@ -133,8 +133,8 @@ public class WifiService extends IWifiManager.Stub {
    private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000;

    /**
     * See {@link Settings.Secure#WIFI_IDLE_MS}. This is the default value if a
     * Settings.Secure value is not present. This timeout value is chosen as
     * See {@link Settings.Global#WIFI_IDLE_MS}. This is the default value if a
     * Settings.Global value is not present. This timeout value is chosen as
     * the approximate point at which the battery drain caused by Wi-Fi
     * being enabled but not active exceeds the battery drain caused by
     * re-establishing a connection to the mobile data network.
@@ -431,8 +431,8 @@ public class WifiService extends IWifiManager.Stub {
        mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());

        // Setting is in seconds
        NOTIFICATION_REPEAT_DELAY_MS = Settings.Secure.getInt(context.getContentResolver(),
                Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
        NOTIFICATION_REPEAT_DELAY_MS = Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
        mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler());
        mNotificationEnabledSettingObserver.register();
    }
@@ -502,9 +502,9 @@ public class WifiService extends IWifiManager.Stub {
        final ContentResolver cr = mContext.getContentResolver();
        int wifiSavedState = 0;
        try {
            wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE);
            wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
            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) {
            ;
        }
@@ -514,9 +514,9 @@ public class WifiService extends IWifiManager.Stub {
    private int getPersistedWifiState() {
        final ContentResolver cr = mContext.getContentResolver();
        try {
            return Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON);
            return Settings.Global.getInt(cr, Settings.Global.WIFI_ON);
        } 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;
        }
    }
@@ -564,7 +564,7 @@ public class WifiService extends IWifiManager.Stub {
    private void persistWifiState(int state) {
        final ContentResolver cr = mContext.getContentResolver();
        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();

            long idleMillis =
                Settings.Secure.getLong(mContext.getContentResolver(),
                                        Settings.Secure.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
                Settings.Global.getLong(mContext.getContentResolver(),
                                        Settings.Global.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
            int stayAwakeConditions =
                Settings.System.getInt(mContext.getContentResolver(),
                                       Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
                Settings.Global.getInt(mContext.getContentResolver(),
                                       Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
            if (action.equals(Intent.ACTION_SCREEN_ON)) {
                if (DBG) {
                    Slog.d(TAG, "ACTION_SCREEN_ON");
@@ -1779,8 +1779,8 @@ public class WifiService extends IWifiManager.Stub {

        public void register() {
            ContentResolver cr = mContext.getContentResolver();
            cr.registerContentObserver(Settings.Secure.getUriFor(
                Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
            cr.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
            mNotificationEnabled = getValue();
        }

@@ -1793,8 +1793,8 @@ public class WifiService extends IWifiManager.Stub {
        }

        private boolean getValue() {
            return Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
            return Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
        }
    }

+6 −6
Original line number Diff line number Diff line
@@ -396,14 +396,14 @@ public class WifiStateMachine extends StateMachine {
     * 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
     * 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.
     */
    private final int mDefaultFrameworkScanIntervalMs;

    /**
     * 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
     */
    private long mSupplicantScanIntervalMs;
@@ -2402,8 +2402,8 @@ public class WifiStateMachine extends StateMachine {
            int defaultInterval = mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_wifi_supplicant_scan_interval);

            mSupplicantScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(),
                    Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
            mSupplicantScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
                    Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
                    defaultInterval);

            mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000);
@@ -3441,8 +3441,8 @@ public class WifiStateMachine extends StateMachine {
            if (DBG) log(getName() + "\n");
            EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());

            mFrameworkScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(),
                    Settings.Secure.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
            mFrameworkScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
                    Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
                    mDefaultFrameworkScanIntervalMs);
            /*
             * We initiate background scanning if it is enabled, otherwise we