Settings.java revision 06efb530a479ea12398c1b3ee4b80e2ac85a1680
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.provider;
18
19import android.annotation.SdkConstant;
20import android.annotation.SdkConstant.SdkConstantType;
21import android.app.SearchManager;
22import android.content.ComponentName;
23import android.content.ContentResolver;
24import android.content.ContentValues;
25import android.content.Context;
26import android.content.IContentProvider;
27import android.content.Intent;
28import android.content.pm.ActivityInfo;
29import android.content.pm.PackageManager;
30import android.content.pm.ResolveInfo;
31import android.content.res.Configuration;
32import android.content.res.Resources;
33import android.database.Cursor;
34import android.database.SQLException;
35import android.net.Uri;
36import android.net.wifi.WifiManager;
37import android.os.BatteryManager;
38import android.os.Bundle;
39import android.os.IBinder;
40import android.os.Process;
41import android.os.RemoteException;
42import android.os.ServiceManager;
43import android.os.SystemProperties;
44import android.os.UserHandle;
45import android.speech.tts.TextToSpeech;
46import android.text.TextUtils;
47import android.util.AndroidException;
48import android.util.Log;
49import android.view.WindowOrientationListener;
50
51import com.android.internal.widget.ILockSettings;
52
53import java.net.URISyntaxException;
54import java.util.HashMap;
55import java.util.HashSet;
56
57/**
58 * The Settings provider contains global system-level device preferences.
59 */
60public final class Settings {
61
62    // Intent actions for Settings
63
64    /**
65     * Activity Action: Show system settings.
66     * <p>
67     * Input: Nothing.
68     * <p>
69     * Output: Nothing.
70     */
71    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
72    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
73
74    /**
75     * Activity Action: Show settings to allow configuration of APNs.
76     * <p>
77     * Input: Nothing.
78     * <p>
79     * Output: Nothing.
80     */
81    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
82    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
83
84    /**
85     * Activity Action: Show settings to allow configuration of current location
86     * sources.
87     * <p>
88     * In some cases, a matching Activity may not exist, so ensure you
89     * safeguard against this.
90     * <p>
91     * Input: Nothing.
92     * <p>
93     * Output: Nothing.
94     */
95    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
96    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
97            "android.settings.LOCATION_SOURCE_SETTINGS";
98
99    /**
100     * Activity Action: Show settings to allow configuration of wireless controls
101     * such as Wi-Fi, Bluetooth and Mobile networks.
102     * <p>
103     * In some cases, a matching Activity may not exist, so ensure you
104     * safeguard against this.
105     * <p>
106     * Input: Nothing.
107     * <p>
108     * Output: Nothing.
109     */
110    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
111    public static final String ACTION_WIRELESS_SETTINGS =
112            "android.settings.WIRELESS_SETTINGS";
113
114    /**
115     * Activity Action: Show settings to allow entering/exiting airplane mode.
116     * <p>
117     * In some cases, a matching Activity may not exist, so ensure you
118     * safeguard against this.
119     * <p>
120     * Input: Nothing.
121     * <p>
122     * Output: Nothing.
123     */
124    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
125    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
126            "android.settings.AIRPLANE_MODE_SETTINGS";
127
128    /**
129     * Activity Action: Show settings for accessibility modules.
130     * <p>
131     * In some cases, a matching Activity may not exist, so ensure you
132     * safeguard against this.
133     * <p>
134     * Input: Nothing.
135     * <p>
136     * Output: Nothing.
137     */
138    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
139    public static final String ACTION_ACCESSIBILITY_SETTINGS =
140            "android.settings.ACCESSIBILITY_SETTINGS";
141
142    /**
143     * Activity Action: Show settings to allow configuration of security and
144     * location privacy.
145     * <p>
146     * In some cases, a matching Activity may not exist, so ensure you
147     * safeguard against this.
148     * <p>
149     * Input: Nothing.
150     * <p>
151     * Output: Nothing.
152     */
153    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
154    public static final String ACTION_SECURITY_SETTINGS =
155            "android.settings.SECURITY_SETTINGS";
156
157    /**
158     * Activity Action: Show settings to allow configuration of privacy options.
159     * <p>
160     * In some cases, a matching Activity may not exist, so ensure you
161     * safeguard against this.
162     * <p>
163     * Input: Nothing.
164     * <p>
165     * Output: Nothing.
166     */
167    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
168    public static final String ACTION_PRIVACY_SETTINGS =
169            "android.settings.PRIVACY_SETTINGS";
170
171    /**
172     * Activity Action: Show settings to allow configuration of Wi-Fi.
173
174     * <p>
175     * In some cases, a matching Activity may not exist, so ensure you
176     * safeguard against this.
177     * <p>
178     * Input: Nothing.
179     * <p>
180     * Output: Nothing.
181
182     */
183    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
184    public static final String ACTION_WIFI_SETTINGS =
185            "android.settings.WIFI_SETTINGS";
186
187    /**
188     * Activity Action: Show settings to allow configuration of a static IP
189     * address for Wi-Fi.
190     * <p>
191     * In some cases, a matching Activity may not exist, so ensure you safeguard
192     * against this.
193     * <p>
194     * Input: Nothing.
195     * <p>
196     * Output: Nothing.
197     */
198    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
199    public static final String ACTION_WIFI_IP_SETTINGS =
200            "android.settings.WIFI_IP_SETTINGS";
201
202    /**
203     * Activity Action: Show settings to allow configuration of Bluetooth.
204     * <p>
205     * In some cases, a matching Activity may not exist, so ensure you
206     * safeguard against this.
207     * <p>
208     * Input: Nothing.
209     * <p>
210     * Output: Nothing.
211     */
212    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
213    public static final String ACTION_BLUETOOTH_SETTINGS =
214            "android.settings.BLUETOOTH_SETTINGS";
215
216    /**
217     * Activity Action: Show settings to allow configuration of date and time.
218     * <p>
219     * In some cases, a matching Activity may not exist, so ensure you
220     * safeguard against this.
221     * <p>
222     * Input: Nothing.
223     * <p>
224     * Output: Nothing.
225     */
226    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
227    public static final String ACTION_DATE_SETTINGS =
228            "android.settings.DATE_SETTINGS";
229
230    /**
231     * Activity Action: Show settings to allow configuration of sound and volume.
232     * <p>
233     * In some cases, a matching Activity may not exist, so ensure you
234     * safeguard against this.
235     * <p>
236     * Input: Nothing.
237     * <p>
238     * Output: Nothing.
239     */
240    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
241    public static final String ACTION_SOUND_SETTINGS =
242            "android.settings.SOUND_SETTINGS";
243
244    /**
245     * Activity Action: Show settings to allow configuration of display.
246     * <p>
247     * In some cases, a matching Activity may not exist, so ensure you
248     * safeguard against this.
249     * <p>
250     * Input: Nothing.
251     * <p>
252     * Output: Nothing.
253     */
254    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
255    public static final String ACTION_DISPLAY_SETTINGS =
256            "android.settings.DISPLAY_SETTINGS";
257
258    /**
259     * Activity Action: Show settings to allow configuration of locale.
260     * <p>
261     * In some cases, a matching Activity may not exist, so ensure you
262     * safeguard against this.
263     * <p>
264     * Input: Nothing.
265     * <p>
266     * Output: Nothing.
267     */
268    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
269    public static final String ACTION_LOCALE_SETTINGS =
270            "android.settings.LOCALE_SETTINGS";
271
272    /**
273     * Activity Action: Show settings to configure input methods, in particular
274     * allowing the user to enable input methods.
275     * <p>
276     * In some cases, a matching Activity may not exist, so ensure you
277     * safeguard against this.
278     * <p>
279     * Input: Nothing.
280     * <p>
281     * Output: Nothing.
282     */
283    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
284    public static final String ACTION_INPUT_METHOD_SETTINGS =
285            "android.settings.INPUT_METHOD_SETTINGS";
286
287    /**
288     * Activity Action: Show settings to enable/disable input method subtypes.
289     * <p>
290     * In some cases, a matching Activity may not exist, so ensure you
291     * safeguard against this.
292     * <p>
293     * To tell which input method's subtypes are displayed in the settings, add
294     * {@link #EXTRA_INPUT_METHOD_ID} extra to this Intent with the input method id.
295     * If there is no extra in this Intent, subtypes from all installed input methods
296     * will be displayed in the settings.
297     *
298     * @see android.view.inputmethod.InputMethodInfo#getId
299     * <p>
300     * Input: Nothing.
301     * <p>
302     * Output: Nothing.
303     */
304    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
305    public static final String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
306            "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
307
308    /**
309     * Activity Action: Show a dialog to select input method.
310     * <p>
311     * In some cases, a matching Activity may not exist, so ensure you
312     * safeguard against this.
313     * <p>
314     * Input: Nothing.
315     * <p>
316     * Output: Nothing.
317     * @hide
318     */
319    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
320    public static final String ACTION_SHOW_INPUT_METHOD_PICKER =
321            "android.settings.SHOW_INPUT_METHOD_PICKER";
322
323    /**
324     * Activity Action: Show settings to manage the user input dictionary.
325     * <p>
326     * In some cases, a matching Activity may not exist, so ensure you
327     * safeguard against this.
328     * <p>
329     * Input: Nothing.
330     * <p>
331     * Output: Nothing.
332     */
333    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
334    public static final String ACTION_USER_DICTIONARY_SETTINGS =
335            "android.settings.USER_DICTIONARY_SETTINGS";
336
337    /**
338     * Activity Action: Adds a word to the user dictionary.
339     * <p>
340     * In some cases, a matching Activity may not exist, so ensure you
341     * safeguard against this.
342     * <p>
343     * Input: An extra with key <code>word</code> that contains the word
344     * that should be added to the dictionary.
345     * <p>
346     * Output: Nothing.
347     *
348     * @hide
349     */
350    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
351    public static final String ACTION_USER_DICTIONARY_INSERT =
352            "com.android.settings.USER_DICTIONARY_INSERT";
353
354    /**
355     * Activity Action: Show settings to allow configuration of application-related settings.
356     * <p>
357     * In some cases, a matching Activity may not exist, so ensure you
358     * safeguard against this.
359     * <p>
360     * Input: Nothing.
361     * <p>
362     * Output: Nothing.
363     */
364    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
365    public static final String ACTION_APPLICATION_SETTINGS =
366            "android.settings.APPLICATION_SETTINGS";
367
368    /**
369     * Activity Action: Show settings to allow configuration of application
370     * development-related settings.
371     * <p>
372     * In some cases, a matching Activity may not exist, so ensure you safeguard
373     * against this.
374     * <p>
375     * Input: Nothing.
376     * <p>
377     * Output: Nothing.
378     */
379    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
380    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
381            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
382
383    /**
384     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
385     * <p>
386     * In some cases, a matching Activity may not exist, so ensure you
387     * safeguard against this.
388     * <p>
389     * Input: Nothing.
390     * <p>
391     * Output: Nothing.
392     */
393    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
394    public static final String ACTION_QUICK_LAUNCH_SETTINGS =
395            "android.settings.QUICK_LAUNCH_SETTINGS";
396
397    /**
398     * Activity Action: Show settings to manage installed applications.
399     * <p>
400     * In some cases, a matching Activity may not exist, so ensure you
401     * safeguard against this.
402     * <p>
403     * Input: Nothing.
404     * <p>
405     * Output: Nothing.
406     */
407    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
408    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
409            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
410
411    /**
412     * Activity Action: Show settings to manage all applications.
413     * <p>
414     * In some cases, a matching Activity may not exist, so ensure you
415     * safeguard against this.
416     * <p>
417     * Input: Nothing.
418     * <p>
419     * Output: Nothing.
420     */
421    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
422    public static final String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
423            "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS";
424
425    /**
426     * Activity Action: Show screen of details about a particular application.
427     * <p>
428     * In some cases, a matching Activity may not exist, so ensure you
429     * safeguard against this.
430     * <p>
431     * Input: The Intent's data URI specifies the application package name
432     * to be shown, with the "package" scheme.  That is "package:com.my.app".
433     * <p>
434     * Output: Nothing.
435     */
436    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
437    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
438            "android.settings.APPLICATION_DETAILS_SETTINGS";
439
440    /**
441     * Activity Action: Show settings for system update functionality.
442     * <p>
443     * In some cases, a matching Activity may not exist, so ensure you
444     * safeguard against this.
445     * <p>
446     * Input: Nothing.
447     * <p>
448     * Output: Nothing.
449     *
450     * @hide
451     */
452    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
453    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
454            "android.settings.SYSTEM_UPDATE_SETTINGS";
455
456    /**
457     * Activity Action: Show settings to allow configuration of sync settings.
458     * <p>
459     * In some cases, a matching Activity may not exist, so ensure you
460     * safeguard against this.
461     * <p>
462     * The account types available to add via the add account button may be restricted by adding an
463     * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's
464     * authorities. Only account types which can sync with that content provider will be offered to
465     * the user.
466     * <p>
467     * Input: Nothing.
468     * <p>
469     * Output: Nothing.
470     */
471    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
472    public static final String ACTION_SYNC_SETTINGS =
473            "android.settings.SYNC_SETTINGS";
474
475    /**
476     * Activity Action: Show add account screen for creating a new account.
477     * <p>
478     * In some cases, a matching Activity may not exist, so ensure you
479     * safeguard against this.
480     * <p>
481     * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES}
482     * extra to the Intent with one or more syncable content provider's authorities.  Only account
483     * types which can sync with that content provider will be offered to the user.
484     * <p>
485     * Input: Nothing.
486     * <p>
487     * Output: Nothing.
488     */
489    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
490    public static final String ACTION_ADD_ACCOUNT =
491            "android.settings.ADD_ACCOUNT_SETTINGS";
492
493    /**
494     * Activity Action: Show settings for selecting the network operator.
495     * <p>
496     * In some cases, a matching Activity may not exist, so ensure you
497     * safeguard against this.
498     * <p>
499     * Input: Nothing.
500     * <p>
501     * Output: Nothing.
502     */
503    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
504    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
505            "android.settings.NETWORK_OPERATOR_SETTINGS";
506
507    /**
508     * Activity Action: Show settings for selection of 2G/3G.
509     * <p>
510     * In some cases, a matching Activity may not exist, so ensure you
511     * safeguard against this.
512     * <p>
513     * Input: Nothing.
514     * <p>
515     * Output: Nothing.
516     */
517    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
518    public static final String ACTION_DATA_ROAMING_SETTINGS =
519            "android.settings.DATA_ROAMING_SETTINGS";
520
521    /**
522     * Activity Action: Show settings for internal storage.
523     * <p>
524     * In some cases, a matching Activity may not exist, so ensure you
525     * safeguard against this.
526     * <p>
527     * Input: Nothing.
528     * <p>
529     * Output: Nothing.
530     */
531    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
532    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
533            "android.settings.INTERNAL_STORAGE_SETTINGS";
534    /**
535     * Activity Action: Show settings for memory card storage.
536     * <p>
537     * In some cases, a matching Activity may not exist, so ensure you
538     * safeguard against this.
539     * <p>
540     * Input: Nothing.
541     * <p>
542     * Output: Nothing.
543     */
544    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
545    public static final String ACTION_MEMORY_CARD_SETTINGS =
546            "android.settings.MEMORY_CARD_SETTINGS";
547
548    /**
549     * Activity Action: Show settings for global search.
550     * <p>
551     * In some cases, a matching Activity may not exist, so ensure you
552     * safeguard against this.
553     * <p>
554     * Input: Nothing.
555     * <p>
556     * Output: Nothing
557     */
558    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
559    public static final String ACTION_SEARCH_SETTINGS =
560        "android.search.action.SEARCH_SETTINGS";
561
562    /**
563     * Activity Action: Show general device information settings (serial
564     * number, software version, phone number, etc.).
565     * <p>
566     * In some cases, a matching Activity may not exist, so ensure you
567     * safeguard against this.
568     * <p>
569     * Input: Nothing.
570     * <p>
571     * Output: Nothing
572     */
573    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
574    public static final String ACTION_DEVICE_INFO_SETTINGS =
575        "android.settings.DEVICE_INFO_SETTINGS";
576
577    /**
578     * Activity Action: Show NFC settings.
579     * <p>
580     * This shows UI that allows NFC to be turned on or off.
581     * <p>
582     * In some cases, a matching Activity may not exist, so ensure you
583     * safeguard against this.
584     * <p>
585     * Input: Nothing.
586     * <p>
587     * Output: Nothing
588     * @see android.nfc.NfcAdapter#isEnabled()
589     */
590    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
591    public static final String ACTION_NFC_SETTINGS = "android.settings.NFC_SETTINGS";
592
593    /**
594     * Activity Action: Show NFC Sharing settings.
595     * <p>
596     * This shows UI that allows NDEF Push (Android Beam) to be turned on or
597     * off.
598     * <p>
599     * In some cases, a matching Activity may not exist, so ensure you
600     * safeguard against this.
601     * <p>
602     * Input: Nothing.
603     * <p>
604     * Output: Nothing
605     * @see android.nfc.NfcAdapter#isNdefPushEnabled()
606     */
607    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
608    public static final String ACTION_NFCSHARING_SETTINGS =
609        "android.settings.NFCSHARING_SETTINGS";
610
611    // End of Intent actions for Settings
612
613    /**
614     * @hide - Private call() method on SettingsProvider to read from 'system' table.
615     */
616    public static final String CALL_METHOD_GET_SYSTEM = "GET_system";
617
618    /**
619     * @hide - Private call() method on SettingsProvider to read from 'secure' table.
620     */
621    public static final String CALL_METHOD_GET_SECURE = "GET_secure";
622
623    /**
624     * @hide - Private call() method on SettingsProvider to read from 'global' table.
625     */
626    public static final String CALL_METHOD_GET_GLOBAL = "GET_global";
627
628    /**
629     * @hide - User handle argument extra to the fast-path call()-based requests
630     */
631    public static final String CALL_METHOD_USER_KEY = "_user";
632
633    /** @hide - Private call() method to write to 'system' table */
634    public static final String CALL_METHOD_PUT_SYSTEM = "PUT_system";
635
636    /** @hide - Private call() method to write to 'secure' table */
637    public static final String CALL_METHOD_PUT_SECURE = "PUT_secure";
638
639    /** @hide - Private call() method to write to 'global' table */
640    public static final String CALL_METHOD_PUT_GLOBAL= "PUT_global";
641
642    /**
643     * Activity Extra: Limit available options in launched activity based on the given authority.
644     * <p>
645     * This can be passed as an extra field in an Activity Intent with one or more syncable content
646     * provider's authorities as a String[]. This field is used by some intents to alter the
647     * behavior of the called activity.
648     * <p>
649     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based
650     * on the authority given.
651     */
652    public static final String EXTRA_AUTHORITIES =
653            "authorities";
654
655    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
656
657    private static final String JID_RESOURCE_PREFIX = "android";
658
659    public static final String AUTHORITY = "settings";
660
661    private static final String TAG = "Settings";
662    private static final boolean LOCAL_LOGV = false;
663
664    public static class SettingNotFoundException extends AndroidException {
665        public SettingNotFoundException(String msg) {
666            super(msg);
667        }
668    }
669
670    /**
671     * Common base for tables of name/value settings.
672     */
673    public static class NameValueTable implements BaseColumns {
674        public static final String NAME = "name";
675        public static final String VALUE = "value";
676
677        protected static boolean putString(ContentResolver resolver, Uri uri,
678                String name, String value) {
679            // The database will take care of replacing duplicates.
680            try {
681                ContentValues values = new ContentValues();
682                values.put(NAME, name);
683                values.put(VALUE, value);
684                resolver.insert(uri, values);
685                return true;
686            } catch (SQLException e) {
687                Log.w(TAG, "Can't set key " + name + " in " + uri, e);
688                return false;
689            }
690        }
691
692        public static Uri getUriFor(Uri uri, String name) {
693            return Uri.withAppendedPath(uri, name);
694        }
695    }
696
697    // Thread-safe.
698    private static class NameValueCache {
699        private final String mVersionSystemProperty;
700        private final Uri mUri;
701
702        private static final String[] SELECT_VALUE =
703            new String[] { Settings.NameValueTable.VALUE };
704        private static final String NAME_EQ_PLACEHOLDER = "name=?";
705
706        // Must synchronize on 'this' to access mValues and mValuesVersion.
707        private final HashMap<String, String> mValues = new HashMap<String, String>();
708        private long mValuesVersion = 0;
709
710        // Initially null; set lazily and held forever.  Synchronized on 'this'.
711        private IContentProvider mContentProvider = null;
712
713        // The method we'll call (or null, to not use) on the provider
714        // for the fast path of retrieving settings.
715        private final String mCallGetCommand;
716        private final String mCallSetCommand;
717
718        public NameValueCache(String versionSystemProperty, Uri uri,
719                String getCommand, String setCommand) {
720            mVersionSystemProperty = versionSystemProperty;
721            mUri = uri;
722            mCallGetCommand = getCommand;
723            mCallSetCommand = setCommand;
724        }
725
726        private IContentProvider lazyGetProvider(ContentResolver cr) {
727            IContentProvider cp = null;
728            synchronized (this) {
729                cp = mContentProvider;
730                if (cp == null) {
731                    cp = mContentProvider = cr.acquireProvider(mUri.getAuthority());
732                }
733            }
734            return cp;
735        }
736
737        public boolean putStringForUser(ContentResolver cr, String name, String value,
738                final int userHandle) {
739            try {
740                Bundle arg = new Bundle();
741                arg.putString(Settings.NameValueTable.VALUE, value);
742                IContentProvider cp = lazyGetProvider(cr);
743                cp.call(mCallSetCommand, name, arg);
744            } catch (RemoteException e) {
745                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
746                return false;
747            }
748            return true;
749        }
750
751        public boolean putString(ContentResolver cr, String name, String value) {
752            return putStringForUser(cr, name, value, UserHandle.myUserId());
753        }
754
755        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
756            long newValuesVersion = SystemProperties.getLong(mVersionSystemProperty, 0);
757
758            synchronized (this) {
759                if (mValuesVersion != newValuesVersion) {
760                    if (LOCAL_LOGV || false) {
761                        Log.v(TAG, "invalidate [" + mUri.getLastPathSegment() + "]: current " +
762                                newValuesVersion + " != cached " + mValuesVersion);
763                    }
764
765                    mValues.clear();
766                    mValuesVersion = newValuesVersion;
767                }
768
769                if (mValues.containsKey(name)) {
770                    return mValues.get(name);  // Could be null, that's OK -- negative caching
771                }
772            }
773
774            IContentProvider cp = lazyGetProvider(cr);
775
776            // Try the fast path first, not using query().  If this
777            // fails (alternate Settings provider that doesn't support
778            // this interface?) then we fall back to the query/table
779            // interface.
780            if (mCallGetCommand != null) {
781                try {
782                    Bundle args = null;
783                    if (userHandle != UserHandle.myUserId()) {
784                        args = new Bundle();
785                        args.putInt(CALL_METHOD_USER_KEY, userHandle);
786                    }
787                    Bundle b = cp.call(mCallGetCommand, name, args);
788                    if (b != null) {
789                        String value = b.getPairValue();
790                        synchronized (this) {
791                            mValues.put(name, value);
792                        }
793                        return value;
794                    }
795                    // If the response Bundle is null, we fall through
796                    // to the query interface below.
797                } catch (RemoteException e) {
798                    // Not supported by the remote side?  Fall through
799                    // to query().
800                }
801            }
802
803            Cursor c = null;
804            try {
805                c = cp.query(mUri, SELECT_VALUE, NAME_EQ_PLACEHOLDER,
806                             new String[]{name}, null, null);
807                if (c == null) {
808                    Log.w(TAG, "Can't get key " + name + " from " + mUri);
809                    return null;
810                }
811
812                String value = c.moveToNext() ? c.getString(0) : null;
813                synchronized (this) {
814                    mValues.put(name, value);
815                }
816                if (LOCAL_LOGV) {
817                    Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +
818                            name + " = " + (value == null ? "(null)" : value));
819                }
820                return value;
821            } catch (RemoteException e) {
822                Log.w(TAG, "Can't get key " + name + " from " + mUri, e);
823                return null;  // Return null, but don't cache it.
824            } finally {
825                if (c != null) c.close();
826            }
827        }
828
829        public String getString(ContentResolver cr, String name) {
830            return getStringForUser(cr, name, UserHandle.myUserId());
831        }
832    }
833
834    /**
835     * System settings, containing miscellaneous system preferences.  This
836     * table holds simple name/value pairs.  There are convenience
837     * functions for accessing individual settings entries.
838     */
839    public static final class System extends NameValueTable {
840        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version";
841
842        // Populated lazily, guarded by class object:
843        private static NameValueCache sNameValueCache = null;
844
845        private static final HashSet<String> MOVED_TO_SECURE;
846        static {
847            MOVED_TO_SECURE = new HashSet<String>(30);
848            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
849            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
850            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
851            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
852            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
853            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
854            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
855            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
856            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
857            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
858            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
859            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
860            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
861            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
862            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
863            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
864            MOVED_TO_SECURE.add(Secure.WIFI_ON);
865            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
866            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
867            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
868            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
869            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
870            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
871            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
872            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
873            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
874            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
875            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
876        }
877
878        private static final HashSet<String> MOVED_TO_GLOBAL;
879        static {
880            MOVED_TO_GLOBAL = new HashSet<String>();
881            MOVED_TO_GLOBAL.add(Global.ADB_ENABLED);
882            MOVED_TO_GLOBAL.add(Global.BLUETOOTH_ON);
883            MOVED_TO_GLOBAL.add(Global.DATA_ROAMING);
884            MOVED_TO_GLOBAL.add(Global.DEVICE_PROVISIONED);
885            MOVED_TO_GLOBAL.add(Global.INSTALL_NON_MARKET_APPS);
886            MOVED_TO_GLOBAL.add(Global.USB_MASS_STORAGE_ENABLED);
887
888            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_ON);
889            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_RADIOS);
890            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
891            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME);
892            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME_ZONE);
893            MOVED_TO_GLOBAL.add(Settings.Global.CAR_DOCK_SOUND);
894            MOVED_TO_GLOBAL.add(Settings.Global.CAR_UNDOCK_SOUND);
895            MOVED_TO_GLOBAL.add(Settings.Global.DESK_DOCK_SOUND);
896            MOVED_TO_GLOBAL.add(Settings.Global.DESK_UNDOCK_SOUND);
897            MOVED_TO_GLOBAL.add(Settings.Global.DOCK_SOUNDS_ENABLED);
898            MOVED_TO_GLOBAL.add(Settings.Global.LOCK_SOUND);
899            MOVED_TO_GLOBAL.add(Settings.Global.UNLOCK_SOUND);
900            MOVED_TO_GLOBAL.add(Settings.Global.LOW_BATTERY_SOUND);
901            MOVED_TO_GLOBAL.add(Settings.Global.POWER_SOUNDS_ENABLED);
902            MOVED_TO_GLOBAL.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
903            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SLEEP_POLICY);
904        }
905
906        private static void lazyInitCache() {
907            if (sNameValueCache == null) {
908                sNameValueCache = new NameValueCache(
909                        SYS_PROP_SETTING_VERSION + '_' + UserHandle.myUserId(),
910                        CONTENT_URI,
911                        CALL_METHOD_GET_SYSTEM,
912                        CALL_METHOD_PUT_SYSTEM);
913            }
914        }
915
916        /**
917         * Look up a name in the database.
918         * @param resolver to access the database with
919         * @param name to look up in the table
920         * @return the corresponding value, or null if not present
921         */
922        public synchronized static String getString(ContentResolver resolver, String name) {
923            return getStringForUser(resolver, name, UserHandle.myUserId());
924        }
925
926        /** @hide */
927        public synchronized static String getStringForUser(ContentResolver resolver, String name,
928                int userHandle) {
929            if (MOVED_TO_SECURE.contains(name)) {
930                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
931                        + " to android.provider.Settings.Secure, returning read-only value.");
932                return Secure.getStringForUser(resolver, name, userHandle);
933            }
934            if (MOVED_TO_GLOBAL.contains(name)) {
935                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
936                        + " to android.provider.Settings.Global, returning read-only value.");
937                return Global.getStringForUser(resolver, name, userHandle);
938            }
939            lazyInitCache();
940            return sNameValueCache.getStringForUser(resolver, name, userHandle);
941        }
942
943        /**
944         * Store a name/value pair into the database.
945         * @param resolver to access the database with
946         * @param name to store
947         * @param value to associate with the name
948         * @return true if the value was set, false on database errors
949         */
950        public static boolean putString(ContentResolver resolver, String name, String value) {
951            return putStringForUser(resolver, name, value, UserHandle.myUserId());
952        }
953
954        /** @hide */
955        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
956                int userHandle) {
957            if (MOVED_TO_SECURE.contains(name)) {
958                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
959                        + " to android.provider.Settings.Secure, value is unchanged.");
960                return false;
961            }
962            if (MOVED_TO_GLOBAL.contains(name)) {
963                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
964                        + " to android.provider.Settings.Global, value is unchanged.");
965                return false;
966            }
967            lazyInitCache();
968            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
969        }
970
971        /**
972         * Construct the content URI for a particular name/value pair,
973         * useful for monitoring changes with a ContentObserver.
974         * @param name to look up in the table
975         * @return the corresponding content URI, or null if not present
976         */
977        public static Uri getUriFor(String name) {
978            if (MOVED_TO_SECURE.contains(name)) {
979                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
980                    + " to android.provider.Settings.Secure, returning Secure URI.");
981                return Secure.getUriFor(Secure.CONTENT_URI, name);
982            }
983            if (MOVED_TO_GLOBAL.contains(name)) {
984                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
985                        + " to android.provider.Settings.Global, returning read-only global URI.");
986                return Global.getUriFor(Global.CONTENT_URI, name);
987            }
988            return getUriFor(CONTENT_URI, name);
989        }
990
991        /**
992         * Convenience function for retrieving a single system settings value
993         * as an integer.  Note that internally setting values are always
994         * stored as strings; this function converts the string to an integer
995         * for you.  The default value will be returned if the setting is
996         * not defined or not an integer.
997         *
998         * @param cr The ContentResolver to access.
999         * @param name The name of the setting to retrieve.
1000         * @param def Value to return if the setting is not defined.
1001         *
1002         * @return The setting's current value, or 'def' if it is not defined
1003         * or not a valid integer.
1004         */
1005        public static int getInt(ContentResolver cr, String name, int def) {
1006            return getIntForUser(cr, name, def, UserHandle.myUserId());
1007        }
1008
1009        /** @hide */
1010        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
1011            String v = getStringForUser(cr, name, userHandle);
1012            try {
1013                return v != null ? Integer.parseInt(v) : def;
1014            } catch (NumberFormatException e) {
1015                return def;
1016            }
1017        }
1018
1019        /**
1020         * Convenience function for retrieving a single system settings value
1021         * as an integer.  Note that internally setting values are always
1022         * stored as strings; this function converts the string to an integer
1023         * for you.
1024         * <p>
1025         * This version does not take a default value.  If the setting has not
1026         * been set, or the string value is not a number,
1027         * it throws {@link SettingNotFoundException}.
1028         *
1029         * @param cr The ContentResolver to access.
1030         * @param name The name of the setting to retrieve.
1031         *
1032         * @throws SettingNotFoundException Thrown if a setting by the given
1033         * name can't be found or the setting value is not an integer.
1034         *
1035         * @return The setting's current value.
1036         */
1037        public static int getInt(ContentResolver cr, String name)
1038                throws SettingNotFoundException {
1039            return getIntForUser(cr, name, UserHandle.myUserId());
1040        }
1041
1042        /** @hide */
1043        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
1044                throws SettingNotFoundException {
1045            String v = getStringForUser(cr, name, userHandle);
1046            try {
1047                return Integer.parseInt(v);
1048            } catch (NumberFormatException e) {
1049                throw new SettingNotFoundException(name);
1050            }
1051        }
1052
1053        /**
1054         * Convenience function for updating a single settings value as an
1055         * integer. This will either create a new entry in the table if the
1056         * given name does not exist, or modify the value of the existing row
1057         * with that name.  Note that internally setting values are always
1058         * stored as strings, so this function converts the given value to a
1059         * string before storing it.
1060         *
1061         * @param cr The ContentResolver to access.
1062         * @param name The name of the setting to modify.
1063         * @param value The new value for the setting.
1064         * @return true if the value was set, false on database errors
1065         */
1066        public static boolean putInt(ContentResolver cr, String name, int value) {
1067            return putIntForUser(cr, name, value, UserHandle.myUserId());
1068        }
1069
1070        /** @hide */
1071        public static boolean putIntForUser(ContentResolver cr, String name, int value,
1072                int userHandle) {
1073            return putStringForUser(cr, name, Integer.toString(value), userHandle);
1074        }
1075
1076        /**
1077         * Convenience function for retrieving a single system settings value
1078         * as a {@code long}.  Note that internally setting values are always
1079         * stored as strings; this function converts the string to a {@code long}
1080         * for you.  The default value will be returned if the setting is
1081         * not defined or not a {@code long}.
1082         *
1083         * @param cr The ContentResolver to access.
1084         * @param name The name of the setting to retrieve.
1085         * @param def Value to return if the setting is not defined.
1086         *
1087         * @return The setting's current value, or 'def' if it is not defined
1088         * or not a valid {@code long}.
1089         */
1090        public static long getLong(ContentResolver cr, String name, long def) {
1091            return getLongForUser(cr, name, def, UserHandle.myUserId());
1092        }
1093
1094        /** @hide */
1095        public static long getLongForUser(ContentResolver cr, String name, long def,
1096                int userHandle) {
1097            String valString = getStringForUser(cr, name, userHandle);
1098            long value;
1099            try {
1100                value = valString != null ? Long.parseLong(valString) : def;
1101            } catch (NumberFormatException e) {
1102                value = def;
1103            }
1104            return value;
1105        }
1106
1107        /**
1108         * Convenience function for retrieving a single system settings value
1109         * as a {@code long}.  Note that internally setting values are always
1110         * stored as strings; this function converts the string to a {@code long}
1111         * for you.
1112         * <p>
1113         * This version does not take a default value.  If the setting has not
1114         * been set, or the string value is not a number,
1115         * it throws {@link SettingNotFoundException}.
1116         *
1117         * @param cr The ContentResolver to access.
1118         * @param name The name of the setting to retrieve.
1119         *
1120         * @return The setting's current value.
1121         * @throws SettingNotFoundException Thrown if a setting by the given
1122         * name can't be found or the setting value is not an integer.
1123         */
1124        public static long getLong(ContentResolver cr, String name)
1125                throws SettingNotFoundException {
1126            return getLongForUser(cr, name, UserHandle.myUserId());
1127        }
1128
1129        /** @hide */
1130        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
1131                throws SettingNotFoundException {
1132            String valString = getStringForUser(cr, name, userHandle);
1133            try {
1134                return Long.parseLong(valString);
1135            } catch (NumberFormatException e) {
1136                throw new SettingNotFoundException(name);
1137            }
1138        }
1139
1140        /**
1141         * Convenience function for updating a single settings value as a long
1142         * integer. This will either create a new entry in the table if the
1143         * given name does not exist, or modify the value of the existing row
1144         * with that name.  Note that internally setting values are always
1145         * stored as strings, so this function converts the given value to a
1146         * string before storing it.
1147         *
1148         * @param cr The ContentResolver to access.
1149         * @param name The name of the setting to modify.
1150         * @param value The new value for the setting.
1151         * @return true if the value was set, false on database errors
1152         */
1153        public static boolean putLong(ContentResolver cr, String name, long value) {
1154            return putLongForUser(cr, name, value, UserHandle.myUserId());
1155        }
1156
1157        /** @hide */
1158        public static boolean putLongForUser(ContentResolver cr, String name, long value,
1159                int userHandle) {
1160            return putStringForUser(cr, name, Long.toString(value), userHandle);
1161        }
1162
1163        /**
1164         * Convenience function for retrieving a single system settings value
1165         * as a floating point number.  Note that internally setting values are
1166         * always stored as strings; this function converts the string to an
1167         * float for you. The default value will be returned if the setting
1168         * is not defined or not a valid float.
1169         *
1170         * @param cr The ContentResolver to access.
1171         * @param name The name of the setting to retrieve.
1172         * @param def Value to return if the setting is not defined.
1173         *
1174         * @return The setting's current value, or 'def' if it is not defined
1175         * or not a valid float.
1176         */
1177        public static float getFloat(ContentResolver cr, String name, float def) {
1178            return getFloatForUser(cr, name, def, UserHandle.myUserId());
1179        }
1180
1181        /** @hide */
1182        public static float getFloatForUser(ContentResolver cr, String name, float def,
1183                int userHandle) {
1184            String v = getStringForUser(cr, name, userHandle);
1185            try {
1186                return v != null ? Float.parseFloat(v) : def;
1187            } catch (NumberFormatException e) {
1188                return def;
1189            }
1190        }
1191
1192        /**
1193         * Convenience function for retrieving a single system settings value
1194         * as a float.  Note that internally setting values are always
1195         * stored as strings; this function converts the string to a float
1196         * for you.
1197         * <p>
1198         * This version does not take a default value.  If the setting has not
1199         * been set, or the string value is not a number,
1200         * it throws {@link SettingNotFoundException}.
1201         *
1202         * @param cr The ContentResolver to access.
1203         * @param name The name of the setting to retrieve.
1204         *
1205         * @throws SettingNotFoundException Thrown if a setting by the given
1206         * name can't be found or the setting value is not a float.
1207         *
1208         * @return The setting's current value.
1209         */
1210        public static float getFloat(ContentResolver cr, String name)
1211                throws SettingNotFoundException {
1212            return getFloatForUser(cr, name, UserHandle.myUserId());
1213        }
1214
1215        /** @hide */
1216        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
1217                throws SettingNotFoundException {
1218            String v = getStringForUser(cr, name, userHandle);
1219            if (v == null) {
1220                throw new SettingNotFoundException(name);
1221            }
1222            try {
1223                return Float.parseFloat(v);
1224            } catch (NumberFormatException e) {
1225                throw new SettingNotFoundException(name);
1226            }
1227        }
1228
1229        /**
1230         * Convenience function for updating a single settings value as a
1231         * floating point number. This will either create a new entry in the
1232         * table if the given name does not exist, or modify the value of the
1233         * existing row with that name.  Note that internally setting values
1234         * are always stored as strings, so this function converts the given
1235         * value to a string before storing it.
1236         *
1237         * @param cr The ContentResolver to access.
1238         * @param name The name of the setting to modify.
1239         * @param value The new value for the setting.
1240         * @return true if the value was set, false on database errors
1241         */
1242        public static boolean putFloat(ContentResolver cr, String name, float value) {
1243            return putFloatForUser(cr, name, value, UserHandle.myUserId());
1244        }
1245
1246        /** @hide */
1247        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
1248                int userHandle) {
1249            return putStringForUser(cr, name, Float.toString(value), userHandle);
1250        }
1251
1252        /**
1253         * Convenience function to read all of the current
1254         * configuration-related settings into a
1255         * {@link Configuration} object.
1256         *
1257         * @param cr The ContentResolver to access.
1258         * @param outConfig Where to place the configuration settings.
1259         */
1260        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
1261            getConfigurationForUser(cr, outConfig, UserHandle.myUserId());
1262        }
1263
1264        /** @hide */
1265        public static void getConfigurationForUser(ContentResolver cr, Configuration outConfig,
1266                int userHandle) {
1267            outConfig.fontScale = Settings.System.getFloatForUser(
1268                cr, FONT_SCALE, outConfig.fontScale, userHandle);
1269            if (outConfig.fontScale < 0) {
1270                outConfig.fontScale = 1;
1271            }
1272        }
1273
1274        /**
1275         * @hide Erase the fields in the Configuration that should be applied
1276         * by the settings.
1277         */
1278        public static void clearConfiguration(Configuration inoutConfig) {
1279            inoutConfig.fontScale = 0;
1280        }
1281
1282        /**
1283         * Convenience function to write a batch of configuration-related
1284         * settings from a {@link Configuration} object.
1285         *
1286         * @param cr The ContentResolver to access.
1287         * @param config The settings to write.
1288         * @return true if the values were set, false on database errors
1289         */
1290        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
1291            return putConfigurationForUser(cr, config, UserHandle.myUserId());
1292        }
1293
1294        /** @hide */
1295        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
1296                int userHandle) {
1297            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle);
1298        }
1299
1300        /** @hide */
1301        public static boolean hasInterestingConfigurationChanges(int changes) {
1302            return (changes&ActivityInfo.CONFIG_FONT_SCALE) != 0;
1303        }
1304
1305        /** @deprecated - Do not use */
1306        @Deprecated
1307        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
1308            return getShowGTalkServiceStatusForUser(cr, UserHandle.myUserId());
1309        }
1310
1311        /**
1312         * @hide
1313         * @deprecated - Do not use
1314         */
1315        public static boolean getShowGTalkServiceStatusForUser(ContentResolver cr,
1316                int userHandle) {
1317            return getIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, 0, userHandle) != 0;
1318        }
1319
1320        /** @deprecated - Do not use */
1321        @Deprecated
1322        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
1323            /* intentionally empty */
1324        }
1325
1326        /**
1327         * @hide
1328         * @deprecated - Do not use
1329         */
1330        @Deprecated
1331        public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean flag,
1332                int userHandle) {
1333            putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
1334        }
1335
1336        /**
1337         * The content:// style URL for this table
1338         */
1339        public static final Uri CONTENT_URI =
1340            Uri.parse("content://" + AUTHORITY + "/system");
1341
1342        /**
1343         * @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
1344         */
1345        @Deprecated
1346        public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN;
1347
1348        /**
1349         * What happens when the user presses the end call button if they're not
1350         * on a call.<br/>
1351         * <b>Values:</b><br/>
1352         * 0 - The end button does nothing.<br/>
1353         * 1 - The end button goes to the home screen.<br/>
1354         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
1355         * 3 - The end button goes to the home screen.  If the user is already on the
1356         * home screen, it puts the device to sleep.
1357         */
1358        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
1359
1360        /**
1361         * END_BUTTON_BEHAVIOR value for "go home".
1362         * @hide
1363         */
1364        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
1365
1366        /**
1367         * END_BUTTON_BEHAVIOR value for "go to sleep".
1368         * @hide
1369         */
1370        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
1371
1372        /**
1373         * END_BUTTON_BEHAVIOR default value.
1374         * @hide
1375         */
1376        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
1377
1378        /**
1379         * Is advanced settings mode turned on. 0 == no, 1 == yes
1380         * @hide
1381         */
1382        public static final String ADVANCED_SETTINGS = "advanced_settings";
1383
1384        /**
1385         * ADVANCED_SETTINGS default value.
1386         * @hide
1387         */
1388        public static final int ADVANCED_SETTINGS_DEFAULT = 0;
1389
1390        /**
1391         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
1392         */
1393        @Deprecated
1394        public static final String AIRPLANE_MODE_ON = Global.AIRPLANE_MODE_ON;
1395
1396        /**
1397         * @deprecated Use {@link android.provider.Settings.Global#RADIO_BLUETOOTH} instead
1398         */
1399        @Deprecated
1400        public static final String RADIO_BLUETOOTH = Global.RADIO_BLUETOOTH;
1401
1402        /**
1403         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIFI} instead
1404         */
1405        @Deprecated
1406        public static final String RADIO_WIFI = Global.RADIO_WIFI;
1407
1408        /**
1409         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIMAX} instead
1410         * {@hide}
1411         */
1412        @Deprecated
1413        public static final String RADIO_WIMAX = Global.RADIO_WIMAX;
1414
1415        /**
1416         * @deprecated Use {@link android.provider.Settings.Global#RADIO_CELL} instead
1417         */
1418        @Deprecated
1419        public static final String RADIO_CELL = Global.RADIO_CELL;
1420
1421        /**
1422         * @deprecated Use {@link android.provider.Settings.Global#RADIO_NFC} instead
1423         */
1424        @Deprecated
1425        public static final String RADIO_NFC = Global.RADIO_NFC;
1426
1427        /**
1428         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_RADIOS} instead
1429         */
1430        @Deprecated
1431        public static final String AIRPLANE_MODE_RADIOS = Global.AIRPLANE_MODE_RADIOS;
1432
1433        /**
1434         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_TOGGLEABLE_RADIOS} instead
1435         *
1436         * {@hide}
1437         */
1438        @Deprecated
1439        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS =
1440                Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS;
1441
1442        /**
1443         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY} instead
1444         */
1445        @Deprecated
1446        public static final String WIFI_SLEEP_POLICY = Global.WIFI_SLEEP_POLICY;
1447
1448        /**
1449         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_DEFAULT} instead
1450         */
1451        @Deprecated
1452        public static final int WIFI_SLEEP_POLICY_DEFAULT = Global.WIFI_SLEEP_POLICY_DEFAULT;
1453
1454        /**
1455         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED} instead
1456         */
1457        @Deprecated
1458        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED =
1459                Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
1460
1461        /**
1462         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER} instead
1463         */
1464        @Deprecated
1465        public static final int WIFI_SLEEP_POLICY_NEVER = Global.WIFI_SLEEP_POLICY_NEVER;
1466
1467        //TODO: deprecate static IP constants
1468        /**
1469         * Whether to use static IP and other static network attributes.
1470         * <p>
1471         * Set to 1 for true and 0 for false.
1472         */
1473        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
1474
1475        /**
1476         * The static IP address.
1477         * <p>
1478         * Example: "192.168.1.51"
1479         */
1480        public static final String WIFI_STATIC_IP = "wifi_static_ip";
1481
1482        /**
1483         * If using static IP, the gateway's IP address.
1484         * <p>
1485         * Example: "192.168.1.1"
1486         */
1487        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
1488
1489        /**
1490         * If using static IP, the net mask.
1491         * <p>
1492         * Example: "255.255.255.0"
1493         */
1494        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
1495
1496        /**
1497         * If using static IP, the primary DNS's IP address.
1498         * <p>
1499         * Example: "192.168.1.1"
1500         */
1501        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
1502
1503        /**
1504         * If using static IP, the secondary DNS's IP address.
1505         * <p>
1506         * Example: "192.168.1.2"
1507         */
1508        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
1509
1510
1511        /**
1512         * Determines whether remote devices may discover and/or connect to
1513         * this device.
1514         * <P>Type: INT</P>
1515         * 2 -- discoverable and connectable
1516         * 1 -- connectable but not discoverable
1517         * 0 -- neither connectable nor discoverable
1518         */
1519        public static final String BLUETOOTH_DISCOVERABILITY =
1520            "bluetooth_discoverability";
1521
1522        /**
1523         * Bluetooth discoverability timeout.  If this value is nonzero, then
1524         * Bluetooth becomes discoverable for a certain number of seconds,
1525         * after which is becomes simply connectable.  The value is in seconds.
1526         */
1527        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
1528            "bluetooth_discoverability_timeout";
1529
1530        /**
1531         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
1532         * instead
1533         */
1534        @Deprecated
1535        public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
1536
1537        /**
1538         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
1539         * instead
1540         */
1541        @Deprecated
1542        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
1543
1544        /**
1545         * @deprecated Use
1546         * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
1547         * instead
1548         */
1549        @Deprecated
1550        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
1551            "lock_pattern_tactile_feedback_enabled";
1552
1553
1554        /**
1555         * A formatted string of the next alarm that is set, or the empty string
1556         * if there is no alarm set.
1557         */
1558        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
1559
1560        /**
1561         * Scaling factor for fonts, float.
1562         */
1563        public static final String FONT_SCALE = "font_scale";
1564
1565        /**
1566         * Name of an application package to be debugged.
1567         */
1568        public static final String DEBUG_APP = "debug_app";
1569
1570        /**
1571         * If 1, when launching DEBUG_APP it will wait for the debugger before
1572         * starting user code.  If 0, it will run normally.
1573         */
1574        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
1575
1576        /**
1577         * Whether or not to dim the screen. 0=no  1=yes
1578         * @deprecated This setting is no longer used.
1579         */
1580        @Deprecated
1581        public static final String DIM_SCREEN = "dim_screen";
1582
1583        /**
1584         * The timeout before the screen turns off.
1585         */
1586        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
1587
1588        /**
1589         * If 0, the compatibility mode is off for all applications.
1590         * If 1, older applications run under compatibility mode.
1591         * TODO: remove this settings before code freeze (bug/1907571)
1592         * @hide
1593         */
1594        public static final String COMPATIBILITY_MODE = "compatibility_mode";
1595
1596        /**
1597         * The screen backlight brightness between 0 and 255.
1598         */
1599        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
1600
1601        /**
1602         * Control whether to enable automatic brightness mode.
1603         */
1604        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
1605
1606        /**
1607         * Adjustment to auto-brightness to make it generally more (>0.0 <1.0)
1608         * or less (<0.0 >-1.0) bright.
1609         * @hide
1610         */
1611        public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj";
1612
1613        /**
1614         * SCREEN_BRIGHTNESS_MODE value for manual mode.
1615         */
1616        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
1617
1618        /**
1619         * SCREEN_BRIGHTNESS_MODE value for automatic mode.
1620         */
1621        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
1622
1623        /**
1624         * Control whether the process CPU usage meter should be shown.
1625         */
1626        public static final String SHOW_PROCESSES = "show_processes";
1627
1628        /**
1629         * If 1, the activity manager will aggressively finish activities and
1630         * processes as soon as they are no longer needed.  If 0, the normal
1631         * extended lifetime is used.
1632         */
1633        public static final String ALWAYS_FINISH_ACTIVITIES =
1634                "always_finish_activities";
1635
1636
1637        /**
1638         * Ringer mode. This is used internally, changing this value will not
1639         * change the ringer mode. See AudioManager.
1640         */
1641        public static final String MODE_RINGER = "mode_ringer";
1642
1643        /**
1644         * Determines which streams are affected by ringer mode changes. The
1645         * stream type's bit should be set to 1 if it should be muted when going
1646         * into an inaudible ringer mode.
1647         */
1648        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
1649
1650         /**
1651          * Determines which streams are affected by mute. The
1652          * stream type's bit should be set to 1 if it should be muted when a mute request
1653          * is received.
1654          */
1655         public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
1656
1657        /**
1658         * Whether vibrate is on for different events. This is used internally,
1659         * changing this value will not change the vibrate. See AudioManager.
1660         */
1661        public static final String VIBRATE_ON = "vibrate_on";
1662
1663        /**
1664         * If 1, redirects the system vibrator to all currently attached input devices
1665         * that support vibration.  If there are no such input devices, then the system
1666         * vibrator is used instead.
1667         * If 0, does not register the system vibrator.
1668         *
1669         * This setting is mainly intended to provide a compatibility mechanism for
1670         * applications that only know about the system vibrator and do not use the
1671         * input device vibrator API.
1672         *
1673         * @hide
1674         */
1675        public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices";
1676
1677        /**
1678         * Ringer volume. This is used internally, changing this value will not
1679         * change the volume. See AudioManager.
1680         */
1681        public static final String VOLUME_RING = "volume_ring";
1682
1683        /**
1684         * System/notifications volume. This is used internally, changing this
1685         * value will not change the volume. See AudioManager.
1686         */
1687        public static final String VOLUME_SYSTEM = "volume_system";
1688
1689        /**
1690         * Voice call volume. This is used internally, changing this value will
1691         * not change the volume. See AudioManager.
1692         */
1693        public static final String VOLUME_VOICE = "volume_voice";
1694
1695        /**
1696         * Music/media/gaming volume. This is used internally, changing this
1697         * value will not change the volume. See AudioManager.
1698         */
1699        public static final String VOLUME_MUSIC = "volume_music";
1700
1701        /**
1702         * Alarm volume. This is used internally, changing this
1703         * value will not change the volume. See AudioManager.
1704         */
1705        public static final String VOLUME_ALARM = "volume_alarm";
1706
1707        /**
1708         * Notification volume. This is used internally, changing this
1709         * value will not change the volume. See AudioManager.
1710         */
1711        public static final String VOLUME_NOTIFICATION = "volume_notification";
1712
1713        /**
1714         * Bluetooth Headset volume. This is used internally, changing this value will
1715         * not change the volume. See AudioManager.
1716         */
1717        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";
1718
1719        /**
1720         * Master volume (float in the range 0.0f to 1.0f).
1721         * @hide
1722         */
1723        public static final String VOLUME_MASTER = "volume_master";
1724
1725        /**
1726         * Master volume mute (int 1 = mute, 0 = not muted).
1727         *
1728         * @hide
1729         */
1730        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";
1731
1732        /**
1733         * Whether the notifications should use the ring volume (value of 1) or
1734         * a separate notification volume (value of 0). In most cases, users
1735         * will have this enabled so the notification and ringer volumes will be
1736         * the same. However, power users can disable this and use the separate
1737         * notification volume control.
1738         * <p>
1739         * Note: This is a one-off setting that will be removed in the future
1740         * when there is profile support. For this reason, it is kept hidden
1741         * from the public APIs.
1742         *
1743         * @hide
1744         * @deprecated
1745         */
1746        @Deprecated
1747        public static final String NOTIFICATIONS_USE_RING_VOLUME =
1748            "notifications_use_ring_volume";
1749
1750        /**
1751         * Whether silent mode should allow vibration feedback. This is used
1752         * internally in AudioService and the Sound settings activity to
1753         * coordinate decoupling of vibrate and silent modes. This setting
1754         * will likely be removed in a future release with support for
1755         * audio/vibe feedback profiles.
1756         *
1757         * Not used anymore. On devices with vibrator, the user explicitly selects
1758         * silent or vibrate mode.
1759         * Kept for use by legacy database upgrade code in DatabaseHelper.
1760         * @hide
1761         */
1762        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
1763
1764        /**
1765         * The mapping of stream type (integer) to its setting.
1766         */
1767        public static final String[] VOLUME_SETTINGS = {
1768            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
1769            VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO
1770        };
1771
1772        /**
1773         * Appended to various volume related settings to record the previous
1774         * values before they the settings were affected by a silent/vibrate
1775         * ringer mode change.
1776         */
1777        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
1778
1779        /**
1780         * Persistent store for the system-wide default ringtone URI.
1781         * <p>
1782         * If you need to play the default ringtone at any given time, it is recommended
1783         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
1784         * to the set default ringtone at the time of playing.
1785         *
1786         * @see #DEFAULT_RINGTONE_URI
1787         */
1788        public static final String RINGTONE = "ringtone";
1789
1790        /**
1791         * A {@link Uri} that will point to the current default ringtone at any
1792         * given time.
1793         * <p>
1794         * If the current default ringtone is in the DRM provider and the caller
1795         * does not have permission, the exception will be a
1796         * FileNotFoundException.
1797         */
1798        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
1799
1800        /**
1801         * Persistent store for the system-wide default notification sound.
1802         *
1803         * @see #RINGTONE
1804         * @see #DEFAULT_NOTIFICATION_URI
1805         */
1806        public static final String NOTIFICATION_SOUND = "notification_sound";
1807
1808        /**
1809         * A {@link Uri} that will point to the current default notification
1810         * sound at any given time.
1811         *
1812         * @see #DEFAULT_RINGTONE_URI
1813         */
1814        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
1815
1816        /**
1817         * Persistent store for the system-wide default alarm alert.
1818         *
1819         * @see #RINGTONE
1820         * @see #DEFAULT_ALARM_ALERT_URI
1821         */
1822        public static final String ALARM_ALERT = "alarm_alert";
1823
1824        /**
1825         * A {@link Uri} that will point to the current default alarm alert at
1826         * any given time.
1827         *
1828         * @see #DEFAULT_ALARM_ALERT_URI
1829         */
1830        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
1831
1832        /**
1833         * Persistent store for the system default media button event receiver.
1834         *
1835         * @hide
1836         */
1837        public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver";
1838
1839        /**
1840         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
1841         */
1842        public static final String TEXT_AUTO_REPLACE = "auto_replace";
1843
1844        /**
1845         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
1846         */
1847        public static final String TEXT_AUTO_CAPS = "auto_caps";
1848
1849        /**
1850         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
1851         * feature converts two spaces to a "." and space.
1852         */
1853        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
1854
1855        /**
1856         * Setting to showing password characters in text editors. 1 = On, 0 = Off
1857         */
1858        public static final String TEXT_SHOW_PASSWORD = "show_password";
1859
1860        public static final String SHOW_GTALK_SERVICE_STATUS =
1861                "SHOW_GTALK_SERVICE_STATUS";
1862
1863        /**
1864         * Name of activity to use for wallpaper on the home screen.
1865         */
1866        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
1867
1868        /**
1869         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME}
1870         * instead
1871         */
1872        @Deprecated
1873        public static final String AUTO_TIME = Global.AUTO_TIME;
1874
1875        /**
1876         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE}
1877         * instead
1878         */
1879        @Deprecated
1880        public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE;
1881
1882        /**
1883         * Display times as 12 or 24 hours
1884         *   12
1885         *   24
1886         */
1887        public static final String TIME_12_24 = "time_12_24";
1888
1889        /**
1890         * Date format string
1891         *   mm/dd/yyyy
1892         *   dd/mm/yyyy
1893         *   yyyy/mm/dd
1894         */
1895        public static final String DATE_FORMAT = "date_format";
1896
1897        /**
1898         * Whether the setup wizard has been run before (on first boot), or if
1899         * it still needs to be run.
1900         *
1901         * nonzero = it has been run in the past
1902         * 0 = it has not been run in the past
1903         */
1904        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
1905
1906        /**
1907         * Scaling factor for normal window animations. Setting to 0 will disable window
1908         * animations.
1909         */
1910        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
1911
1912        /**
1913         * Scaling factor for activity transition animations. Setting to 0 will disable window
1914         * animations.
1915         */
1916        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
1917
1918        /**
1919         * Scaling factor for Animator-based animations. This affects both the start delay and
1920         * duration of all such animations. Setting to 0 will cause animations to end immediately.
1921         * The default value is 1.
1922         */
1923        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
1924
1925        /**
1926         * Scaling factor for normal window animations. Setting to 0 will disable window
1927         * animations.
1928         * @hide
1929         */
1930        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
1931
1932        /**
1933         * Control whether the accelerometer will be used to change screen
1934         * orientation.  If 0, it will not be used unless explicitly requested
1935         * by the application; if 1, it will be used by default unless explicitly
1936         * disabled by the application.
1937         */
1938        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
1939
1940        /**
1941         * Default screen rotation when no other policy applies.
1942         * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
1943         * preference, this rotation value will be used. Must be one of the
1944         * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
1945         *
1946         * @see Display#getRotation
1947         */
1948        public static final String USER_ROTATION = "user_rotation";
1949
1950        /**
1951         * Control whether the rotation lock toggle in the System UI should be hidden.
1952         * Typically this is done for accessibility purposes to make it harder for
1953         * the user to accidentally toggle the rotation lock while the display rotation
1954         * has been locked for accessibility.
1955         *
1956         * If 0, then rotation lock toggle is not hidden for accessibility (although it may be
1957         * unavailable for other reasons).  If 1, then the rotation lock toggle is hidden.
1958         *
1959         * @hide
1960         */
1961        public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY =
1962                "hide_rotation_lock_toggle_for_accessibility";
1963
1964        /**
1965         * Whether the phone vibrates when it is ringing due to an incoming call. This will
1966         * be used by Phone and Setting apps; it shouldn't affect other apps.
1967         * The value is boolean (1 or 0).
1968         *
1969         * Note: this is not same as "vibrate on ring", which had been available until ICS.
1970         * It was about AudioManager's setting and thus affected all the applications which
1971         * relied on the setting, while this is purely about the vibration setting for incoming
1972         * calls.
1973         *
1974         * @hide
1975         */
1976        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
1977
1978        /**
1979         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
1980         * boolean (1 or 0).
1981         */
1982        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
1983
1984        /**
1985         * CDMA only settings
1986         * DTMF tone type played by the dialer when dialing.
1987         *                 0 = Normal
1988         *                 1 = Long
1989         * @hide
1990         */
1991        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
1992
1993        /**
1994         * CDMA only settings
1995         * Emergency Tone  0 = Off
1996         *                 1 = Alert
1997         *                 2 = Vibrate
1998         * @hide
1999         */
2000        public static final String EMERGENCY_TONE = "emergency_tone";
2001
2002        /**
2003         * CDMA only settings
2004         * Whether the auto retry is enabled. The value is
2005         * boolean (1 or 0).
2006         * @hide
2007         */
2008        public static final String CALL_AUTO_RETRY = "call_auto_retry";
2009
2010        /**
2011         * Whether the hearing aid is enabled. The value is
2012         * boolean (1 or 0).
2013         * @hide
2014         */
2015        public static final String HEARING_AID = "hearing_aid";
2016
2017        /**
2018         * CDMA only settings
2019         * TTY Mode
2020         * 0 = OFF
2021         * 1 = FULL
2022         * 2 = VCO
2023         * 3 = HCO
2024         * @hide
2025         */
2026        public static final String TTY_MODE = "tty_mode";
2027
2028        /**
2029         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
2030         * boolean (1 or 0).
2031         */
2032        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
2033
2034        /**
2035         * Whether the haptic feedback (long presses, ...) are enabled. The value is
2036         * boolean (1 or 0).
2037         */
2038        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
2039
2040        /**
2041         * @deprecated Each application that shows web suggestions should have its own
2042         * setting for this.
2043         */
2044        @Deprecated
2045        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
2046
2047        /**
2048         * Whether the notification LED should repeatedly flash when a notification is
2049         * pending. The value is boolean (1 or 0).
2050         * @hide
2051         */
2052        public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse";
2053
2054        /**
2055         * Show pointer location on screen?
2056         * 0 = no
2057         * 1 = yes
2058         * @hide
2059         */
2060        public static final String POINTER_LOCATION = "pointer_location";
2061
2062        /**
2063         * Show touch positions on screen?
2064         * 0 = no
2065         * 1 = yes
2066         * @hide
2067         */
2068        public static final String SHOW_TOUCHES = "show_touches";
2069
2070        /**
2071         * Log raw orientation data from {@link WindowOrientationListener} for use with the
2072         * orientationplot.py tool.
2073         * 0 = no
2074         * 1 = yes
2075         * @hide
2076         */
2077        public static final String WINDOW_ORIENTATION_LISTENER_LOG =
2078                "window_orientation_listener_log";
2079
2080        /**
2081         * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED}
2082         * instead
2083         * @hide
2084         */
2085        @Deprecated
2086        public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED;
2087
2088        /**
2089         * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED}
2090         * instead
2091         * @hide
2092         */
2093        @Deprecated
2094        public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED;
2095
2096        /**
2097         * Whether to play sounds when the keyguard is shown and dismissed.
2098         * @hide
2099         */
2100        public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled";
2101
2102        /**
2103         * Whether the lockscreen should be completely disabled.
2104         * @hide
2105         */
2106        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";
2107
2108        /**
2109         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
2110         * instead
2111         * @hide
2112         */
2113        @Deprecated
2114        public static final String LOW_BATTERY_SOUND = Global.LOW_BATTERY_SOUND;
2115
2116        /**
2117         * @deprecated Use {@link android.provider.Settings.Global#DESK_DOCK_SOUND}
2118         * instead
2119         * @hide
2120         */
2121        @Deprecated
2122        public static final String DESK_DOCK_SOUND = Global.DESK_DOCK_SOUND;
2123
2124        /**
2125         * @deprecated Use {@link android.provider.Settings.Global#DESK_UNDOCK_SOUND}
2126         * instead
2127         * @hide
2128         */
2129        @Deprecated
2130        public static final String DESK_UNDOCK_SOUND = Global.DESK_UNDOCK_SOUND;
2131
2132        /**
2133         * @deprecated Use {@link android.provider.Settings.Global#CAR_DOCK_SOUND}
2134         * instead
2135         * @hide
2136         */
2137        @Deprecated
2138        public static final String CAR_DOCK_SOUND = Global.CAR_DOCK_SOUND;
2139
2140        /**
2141         * @deprecated Use {@link android.provider.Settings.Global#CAR_UNDOCK_SOUND}
2142         * instead
2143         * @hide
2144         */
2145        @Deprecated
2146        public static final String CAR_UNDOCK_SOUND = Global.CAR_UNDOCK_SOUND;
2147
2148        /**
2149         * @deprecated Use {@link android.provider.Settings.Global#LOCK_SOUND}
2150         * instead
2151         * @hide
2152         */
2153        @Deprecated
2154        public static final String LOCK_SOUND = Global.LOCK_SOUND;
2155
2156        /**
2157         * @deprecated Use {@link android.provider.Settings.Global#UNLOCK_SOUND}
2158         * instead
2159         * @hide
2160         */
2161        @Deprecated
2162        public static final String UNLOCK_SOUND = Global.UNLOCK_SOUND;
2163
2164        /**
2165         * Receive incoming SIP calls?
2166         * 0 = no
2167         * 1 = yes
2168         * @hide
2169         */
2170        public static final String SIP_RECEIVE_CALLS = "sip_receive_calls";
2171
2172        /**
2173         * Call Preference String.
2174         * "SIP_ALWAYS" : Always use SIP with network access
2175         * "SIP_ADDRESS_ONLY" : Only if destination is a SIP address
2176         * "SIP_ASK_ME_EACH_TIME" : Always ask me each time
2177         * @hide
2178         */
2179        public static final String SIP_CALL_OPTIONS = "sip_call_options";
2180
2181        /**
2182         * One of the sip call options: Always use SIP with network access.
2183         * @hide
2184         */
2185        public static final String SIP_ALWAYS = "SIP_ALWAYS";
2186
2187        /**
2188         * One of the sip call options: Only if destination is a SIP address.
2189         * @hide
2190         */
2191        public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY";
2192
2193        /**
2194         * One of the sip call options: Always ask me each time.
2195         * @hide
2196         */
2197        public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME";
2198
2199        /**
2200         * Pointer speed setting.
2201         * This is an integer value in a range between -7 and +7, so there are 15 possible values.
2202         *   -7 = slowest
2203         *    0 = default speed
2204         *   +7 = fastest
2205         * @hide
2206         */
2207        public static final String POINTER_SPEED = "pointer_speed";
2208
2209        /**
2210         * Settings to backup. This is here so that it's in the same place as the settings
2211         * keys and easy to update.
2212         *
2213         * NOTE: Settings are backed up and restored in the order they appear
2214         *       in this array. If you have one setting depending on another,
2215         *       make sure that they are ordered appropriately.
2216         *
2217         * @hide
2218         */
2219        public static final String[] SETTINGS_TO_BACKUP = {
2220            STAY_ON_WHILE_PLUGGED_IN,
2221            WIFI_USE_STATIC_IP,
2222            WIFI_STATIC_IP,
2223            WIFI_STATIC_GATEWAY,
2224            WIFI_STATIC_NETMASK,
2225            WIFI_STATIC_DNS1,
2226            WIFI_STATIC_DNS2,
2227            BLUETOOTH_DISCOVERABILITY,
2228            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
2229            DIM_SCREEN,
2230            SCREEN_OFF_TIMEOUT,
2231            SCREEN_BRIGHTNESS,
2232            SCREEN_BRIGHTNESS_MODE,
2233            SCREEN_AUTO_BRIGHTNESS_ADJ,
2234            VIBRATE_INPUT_DEVICES,
2235            MODE_RINGER,
2236            MODE_RINGER_STREAMS_AFFECTED,
2237            MUTE_STREAMS_AFFECTED,
2238            VOLUME_VOICE,
2239            VOLUME_SYSTEM,
2240            VOLUME_RING,
2241            VOLUME_MUSIC,
2242            VOLUME_ALARM,
2243            VOLUME_NOTIFICATION,
2244            VOLUME_BLUETOOTH_SCO,
2245            VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE,
2246            VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE,
2247            VOLUME_RING + APPEND_FOR_LAST_AUDIBLE,
2248            VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE,
2249            VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
2250            VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
2251            VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE,
2252            TEXT_AUTO_REPLACE,
2253            TEXT_AUTO_CAPS,
2254            TEXT_AUTO_PUNCTUATE,
2255            TEXT_SHOW_PASSWORD,
2256            AUTO_TIME,
2257            AUTO_TIME_ZONE,
2258            TIME_12_24,
2259            DATE_FORMAT,
2260            DTMF_TONE_WHEN_DIALING,
2261            DTMF_TONE_TYPE_WHEN_DIALING,
2262            EMERGENCY_TONE,
2263            CALL_AUTO_RETRY,
2264            HEARING_AID,
2265            TTY_MODE,
2266            SOUND_EFFECTS_ENABLED,
2267            HAPTIC_FEEDBACK_ENABLED,
2268            POWER_SOUNDS_ENABLED,
2269            DOCK_SOUNDS_ENABLED,
2270            LOCKSCREEN_SOUNDS_ENABLED,
2271            SHOW_WEB_SUGGESTIONS,
2272            NOTIFICATION_LIGHT_PULSE,
2273            SIP_CALL_OPTIONS,
2274            SIP_RECEIVE_CALLS,
2275            POINTER_SPEED,
2276            VIBRATE_WHEN_RINGING
2277        };
2278
2279        // Settings moved to Settings.Secure
2280
2281        /**
2282         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED}
2283         * instead
2284         */
2285        @Deprecated
2286        public static final String ADB_ENABLED = Global.ADB_ENABLED;
2287
2288        /**
2289         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
2290         */
2291        @Deprecated
2292        public static final String ANDROID_ID = Secure.ANDROID_ID;
2293
2294        /**
2295         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
2296         */
2297        @Deprecated
2298        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
2299
2300        /**
2301         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
2302         */
2303        @Deprecated
2304        public static final String DATA_ROAMING = Global.DATA_ROAMING;
2305
2306        /**
2307         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
2308         */
2309        @Deprecated
2310        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
2311
2312        /**
2313         * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead
2314         */
2315        @Deprecated
2316        public static final String HTTP_PROXY = Secure.HTTP_PROXY;
2317
2318        /**
2319         * @deprecated Use {@link android.provider.Settings.Global#INSTALL_NON_MARKET_APPS} instead
2320         */
2321        @Deprecated
2322        public static final String INSTALL_NON_MARKET_APPS = Global.INSTALL_NON_MARKET_APPS;
2323
2324        /**
2325         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
2326         * instead
2327         */
2328        @Deprecated
2329        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
2330
2331        /**
2332         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
2333         */
2334        @Deprecated
2335        public static final String LOGGING_ID = Secure.LOGGING_ID;
2336
2337        /**
2338         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
2339         */
2340        @Deprecated
2341        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
2342
2343        /**
2344         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
2345         * instead
2346         */
2347        @Deprecated
2348        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
2349
2350        /**
2351         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
2352         * instead
2353         */
2354        @Deprecated
2355        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
2356
2357        /**
2358         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
2359         * instead
2360         */
2361        @Deprecated
2362        public static final String PARENTAL_CONTROL_REDIRECT_URL =
2363            Secure.PARENTAL_CONTROL_REDIRECT_URL;
2364
2365        /**
2366         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
2367         */
2368        @Deprecated
2369        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
2370
2371        /**
2372         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
2373         */
2374        @Deprecated
2375        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
2376
2377        /**
2378         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
2379         */
2380        @Deprecated
2381        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
2382
2383       /**
2384         * @deprecated Use
2385         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
2386         */
2387        @Deprecated
2388        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
2389
2390        /**
2391         * @deprecated Use
2392         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
2393         */
2394        @Deprecated
2395        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
2396                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
2397
2398        /**
2399         * @deprecated Use
2400         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
2401         */
2402        @Deprecated
2403        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
2404                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
2405
2406        /**
2407         * @deprecated Use
2408         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
2409         */
2410        @Deprecated
2411        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
2412                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
2413
2414        /**
2415         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
2416         * instead
2417         */
2418        @Deprecated
2419        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
2420
2421        /**
2422         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead
2423         */
2424        @Deprecated
2425        public static final String WIFI_ON = Global.WIFI_ON;
2426
2427        /**
2428         * @deprecated Use
2429         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
2430         * instead
2431         */
2432        @Deprecated
2433        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
2434                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
2435
2436        /**
2437         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
2438         */
2439        @Deprecated
2440        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
2441
2442        /**
2443         * @deprecated Use
2444         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
2445         */
2446        @Deprecated
2447        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
2448                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
2449
2450        /**
2451         * @deprecated Use
2452         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
2453         */
2454        @Deprecated
2455        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
2456                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
2457
2458        /**
2459         * @deprecated Use
2460         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
2461         * instead
2462         */
2463        @Deprecated
2464        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
2465                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
2466
2467        /**
2468         * @deprecated Use
2469         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
2470         */
2471        @Deprecated
2472        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
2473            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
2474
2475        /**
2476         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
2477         * instead
2478         */
2479        @Deprecated
2480        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
2481
2482        /**
2483         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
2484         */
2485        @Deprecated
2486        public static final String WIFI_WATCHDOG_ON = Global.WIFI_WATCHDOG_ON;
2487
2488        /**
2489         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
2490         */
2491        @Deprecated
2492        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
2493
2494        /**
2495         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
2496         * instead
2497         */
2498        @Deprecated
2499        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
2500
2501        /**
2502         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
2503         * instead
2504         */
2505        @Deprecated
2506        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
2507            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
2508    }
2509
2510    /**
2511     * Secure system settings, containing system preferences that applications
2512     * can read but are not allowed to write.  These are for preferences that
2513     * the user must explicitly modify through the system UI or specialized
2514     * APIs for those values, not modified directly by applications.
2515     */
2516    public static final class Secure extends NameValueTable {
2517        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
2518
2519        // Populated lazily, guarded by class object:
2520        private static NameValueCache sNameValueCache = null;
2521
2522        private static ILockSettings sLockSettings = null;
2523
2524        private static boolean sIsSystemProcess;
2525        private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
2526        private static final HashSet<String> MOVED_TO_GLOBAL;
2527        static {
2528            MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
2529            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
2530            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
2531            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
2532
2533            MOVED_TO_GLOBAL = new HashSet<String>();
2534            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
2535            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
2536            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
2537            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
2538            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
2539            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
2540            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE);
2541            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI);
2542            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
2543            MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
2544            MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
2545            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_DENSITY_FORCED);
2546            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
2547            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
2548            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
2549            MOVED_TO_GLOBAL.add(Settings.Global.INSTALL_NON_MARKET_APPS);
2550            MOVED_TO_GLOBAL.add(Settings.Global.MOBILE_DATA);
2551            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION);
2552            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_DELETE_AGE);
2553            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES);
2554            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE);
2555            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_ENABLED);
2556            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES);
2557            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_POLL_INTERVAL);
2558            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_REPORT_XT_OVER_DEV);
2559            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_SAMPLE_ENABLED);
2560            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE);
2561            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION);
2562            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_DELETE_AGE);
2563            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES);
2564            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_ROTATE_AGE);
2565            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION);
2566            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE);
2567            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES);
2568            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE);
2569            MOVED_TO_GLOBAL.add(Settings.Global.NETWORK_PREFERENCE);
2570            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_DIFF);
2571            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_SPACING);
2572            MOVED_TO_GLOBAL.add(Settings.Global.NTP_SERVER);
2573            MOVED_TO_GLOBAL.add(Settings.Global.NTP_TIMEOUT);
2574            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT);
2575            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS);
2576            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT);
2577            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS);
2578            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT);
2579            MOVED_TO_GLOBAL.add(Settings.Global.SAMPLING_PROFILER_MS);
2580            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
2581            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST);
2582            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL);
2583            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_APN);
2584            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_REQUIRED);
2585            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_SUPPORTED);
2586            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_HELP_URI);
2587            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC);
2588            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_NOTIFICATION_TYPE);
2589            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_POLLING_SEC);
2590            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_RESET_DAY);
2591            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_THRESHOLD_BYTES);
2592            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_VALUE_KBITSPS);
2593            MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED);
2594            MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL);
2595            MOVED_TO_GLOBAL.add(Settings.Global.WEB_AUTOFILL_QUERY_URL);
2596            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE);
2597            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS);
2598            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND);
2599            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS);
2600            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT);
2601            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS);
2602            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
2603            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
2604            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT);
2605            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
2606            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
2607            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
2608            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
2609            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
2610            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_NUM_ARP_PINGS);
2611            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
2612            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
2613            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS);
2614            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
2615            MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
2616        }
2617
2618        private static void lazyInitCache() {
2619            if (sNameValueCache == null) {
2620                sNameValueCache = new NameValueCache(
2621                        SYS_PROP_SETTING_VERSION + '_' + UserHandle.myUserId(),
2622                        CONTENT_URI,
2623                        CALL_METHOD_GET_SECURE,
2624                        CALL_METHOD_PUT_SECURE);
2625            }
2626        }
2627
2628        /**
2629         * Look up a name in the database.
2630         * @param resolver to access the database with
2631         * @param name to look up in the table
2632         * @return the corresponding value, or null if not present
2633         */
2634        public synchronized static String getString(ContentResolver resolver, String name) {
2635            return getStringForUser(resolver, name, UserHandle.myUserId());
2636        }
2637
2638        /** @hide */
2639        public synchronized static String getStringForUser(ContentResolver resolver, String name,
2640                int userHandle) {
2641            if (MOVED_TO_GLOBAL.contains(name)) {
2642                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
2643                        + " to android.provider.Settings.Global.");
2644                return Global.getStringForUser(resolver, name, userHandle);
2645            }
2646
2647            if (sLockSettings == null) {
2648                sLockSettings = ILockSettings.Stub.asInterface(
2649                        (IBinder) ServiceManager.getService("lock_settings"));
2650                sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
2651            }
2652            if (sLockSettings != null && !sIsSystemProcess
2653                    && MOVED_TO_LOCK_SETTINGS.contains(name)) {
2654                try {
2655                    return sLockSettings.getString(name, "0", userHandle);
2656                } catch (RemoteException re) {
2657                    // Fall through
2658                }
2659            }
2660
2661            lazyInitCache();
2662            return sNameValueCache.getStringForUser(resolver, name, userHandle);
2663        }
2664
2665        /**
2666         * Store a name/value pair into the database.
2667         * @param resolver to access the database with
2668         * @param name to store
2669         * @param value to associate with the name
2670         * @return true if the value was set, false on database errors
2671         */
2672        public static boolean putString(ContentResolver resolver, String name, String value) {
2673            return putStringForUser(resolver, name, value, UserHandle.myUserId());
2674        }
2675
2676        /** @hide */
2677        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
2678                int userHandle) {
2679            if (MOVED_TO_GLOBAL.contains(name)) {
2680                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2681                        + " to android.provider.Settings.Global");
2682                return Global.putStringForUser(resolver, name, value, userHandle);
2683            }
2684            lazyInitCache();
2685            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
2686        }
2687
2688        /**
2689         * Construct the content URI for a particular name/value pair,
2690         * useful for monitoring changes with a ContentObserver.
2691         * @param name to look up in the table
2692         * @return the corresponding content URI, or null if not present
2693         */
2694        public static Uri getUriFor(String name) {
2695            if (MOVED_TO_GLOBAL.contains(name)) {
2696                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
2697                        + " to android.provider.Settings.Global, returning global URI.");
2698                return Global.getUriFor(Global.CONTENT_URI, name);
2699            }
2700            return getUriFor(CONTENT_URI, name);
2701        }
2702
2703        /**
2704         * Convenience function for retrieving a single secure settings value
2705         * as an integer.  Note that internally setting values are always
2706         * stored as strings; this function converts the string to an integer
2707         * for you.  The default value will be returned if the setting is
2708         * not defined or not an integer.
2709         *
2710         * @param cr The ContentResolver to access.
2711         * @param name The name of the setting to retrieve.
2712         * @param def Value to return if the setting is not defined.
2713         *
2714         * @return The setting's current value, or 'def' if it is not defined
2715         * or not a valid integer.
2716         */
2717        public static int getInt(ContentResolver cr, String name, int def) {
2718            return getIntForUser(cr, name, def, UserHandle.myUserId());
2719        }
2720
2721        /** @hide */
2722        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
2723            String v = getStringForUser(cr, name, userHandle);
2724            try {
2725                return v != null ? Integer.parseInt(v) : def;
2726            } catch (NumberFormatException e) {
2727                return def;
2728            }
2729        }
2730
2731        /**
2732         * Convenience function for retrieving a single secure settings value
2733         * as an integer.  Note that internally setting values are always
2734         * stored as strings; this function converts the string to an integer
2735         * for you.
2736         * <p>
2737         * This version does not take a default value.  If the setting has not
2738         * been set, or the string value is not a number,
2739         * it throws {@link SettingNotFoundException}.
2740         *
2741         * @param cr The ContentResolver to access.
2742         * @param name The name of the setting to retrieve.
2743         *
2744         * @throws SettingNotFoundException Thrown if a setting by the given
2745         * name can't be found or the setting value is not an integer.
2746         *
2747         * @return The setting's current value.
2748         */
2749        public static int getInt(ContentResolver cr, String name)
2750                throws SettingNotFoundException {
2751            return getIntForUser(cr, name, UserHandle.myUserId());
2752        }
2753
2754        /** @hide */
2755        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
2756                throws SettingNotFoundException {
2757            String v = getStringForUser(cr, name, userHandle);
2758            try {
2759                return Integer.parseInt(v);
2760            } catch (NumberFormatException e) {
2761                throw new SettingNotFoundException(name);
2762            }
2763        }
2764
2765        /**
2766         * Convenience function for updating a single settings value as an
2767         * integer. This will either create a new entry in the table if the
2768         * given name does not exist, or modify the value of the existing row
2769         * with that name.  Note that internally setting values are always
2770         * stored as strings, so this function converts the given value to a
2771         * string before storing it.
2772         *
2773         * @param cr The ContentResolver to access.
2774         * @param name The name of the setting to modify.
2775         * @param value The new value for the setting.
2776         * @return true if the value was set, false on database errors
2777         */
2778        public static boolean putInt(ContentResolver cr, String name, int value) {
2779            return putIntForUser(cr, name, value, UserHandle.myUserId());
2780        }
2781
2782        /** @hide */
2783        public static boolean putIntForUser(ContentResolver cr, String name, int value,
2784                int userHandle) {
2785            return putStringForUser(cr, name, Integer.toString(value), userHandle);
2786        }
2787
2788        /**
2789         * Convenience function for retrieving a single secure settings value
2790         * as a {@code long}.  Note that internally setting values are always
2791         * stored as strings; this function converts the string to a {@code long}
2792         * for you.  The default value will be returned if the setting is
2793         * not defined or not a {@code long}.
2794         *
2795         * @param cr The ContentResolver to access.
2796         * @param name The name of the setting to retrieve.
2797         * @param def Value to return if the setting is not defined.
2798         *
2799         * @return The setting's current value, or 'def' if it is not defined
2800         * or not a valid {@code long}.
2801         */
2802        public static long getLong(ContentResolver cr, String name, long def) {
2803            return getLongForUser(cr, name, def, UserHandle.myUserId());
2804        }
2805
2806        /** @hide */
2807        public static long getLongForUser(ContentResolver cr, String name, long def,
2808                int userHandle) {
2809            String valString = getStringForUser(cr, name, userHandle);
2810            long value;
2811            try {
2812                value = valString != null ? Long.parseLong(valString) : def;
2813            } catch (NumberFormatException e) {
2814                value = def;
2815            }
2816            return value;
2817        }
2818
2819        /**
2820         * Convenience function for retrieving a single secure settings value
2821         * as a {@code long}.  Note that internally setting values are always
2822         * stored as strings; this function converts the string to a {@code long}
2823         * for you.
2824         * <p>
2825         * This version does not take a default value.  If the setting has not
2826         * been set, or the string value is not a number,
2827         * it throws {@link SettingNotFoundException}.
2828         *
2829         * @param cr The ContentResolver to access.
2830         * @param name The name of the setting to retrieve.
2831         *
2832         * @return The setting's current value.
2833         * @throws SettingNotFoundException Thrown if a setting by the given
2834         * name can't be found or the setting value is not an integer.
2835         */
2836        public static long getLong(ContentResolver cr, String name)
2837                throws SettingNotFoundException {
2838            return getLongForUser(cr, name, UserHandle.myUserId());
2839        }
2840
2841        /** @hide */
2842        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
2843                throws SettingNotFoundException {
2844            String valString = getStringForUser(cr, name, userHandle);
2845            try {
2846                return Long.parseLong(valString);
2847            } catch (NumberFormatException e) {
2848                throw new SettingNotFoundException(name);
2849            }
2850        }
2851
2852        /**
2853         * Convenience function for updating a secure settings value as a long
2854         * integer. This will either create a new entry in the table if the
2855         * given name does not exist, or modify the value of the existing row
2856         * with that name.  Note that internally setting values are always
2857         * stored as strings, so this function converts the given value to a
2858         * string before storing it.
2859         *
2860         * @param cr The ContentResolver to access.
2861         * @param name The name of the setting to modify.
2862         * @param value The new value for the setting.
2863         * @return true if the value was set, false on database errors
2864         */
2865        public static boolean putLong(ContentResolver cr, String name, long value) {
2866            return putLongForUser(cr, name, value, UserHandle.myUserId());
2867        }
2868
2869        /** @hide */
2870        public static boolean putLongForUser(ContentResolver cr, String name, long value,
2871                int userHandle) {
2872            return putStringForUser(cr, name, Long.toString(value), userHandle);
2873        }
2874
2875        /**
2876         * Convenience function for retrieving a single secure settings value
2877         * as a floating point number.  Note that internally setting values are
2878         * always stored as strings; this function converts the string to an
2879         * float for you. The default value will be returned if the setting
2880         * is not defined or not a valid float.
2881         *
2882         * @param cr The ContentResolver to access.
2883         * @param name The name of the setting to retrieve.
2884         * @param def Value to return if the setting is not defined.
2885         *
2886         * @return The setting's current value, or 'def' if it is not defined
2887         * or not a valid float.
2888         */
2889        public static float getFloat(ContentResolver cr, String name, float def) {
2890            return getFloatForUser(cr, name, def, UserHandle.myUserId());
2891        }
2892
2893        /** @hide */
2894        public static float getFloatForUser(ContentResolver cr, String name, float def,
2895                int userHandle) {
2896            String v = getStringForUser(cr, name, userHandle);
2897            try {
2898                return v != null ? Float.parseFloat(v) : def;
2899            } catch (NumberFormatException e) {
2900                return def;
2901            }
2902        }
2903
2904        /**
2905         * Convenience function for retrieving a single secure settings value
2906         * as a float.  Note that internally setting values are always
2907         * stored as strings; this function converts the string to a float
2908         * for you.
2909         * <p>
2910         * This version does not take a default value.  If the setting has not
2911         * been set, or the string value is not a number,
2912         * it throws {@link SettingNotFoundException}.
2913         *
2914         * @param cr The ContentResolver to access.
2915         * @param name The name of the setting to retrieve.
2916         *
2917         * @throws SettingNotFoundException Thrown if a setting by the given
2918         * name can't be found or the setting value is not a float.
2919         *
2920         * @return The setting's current value.
2921         */
2922        public static float getFloat(ContentResolver cr, String name)
2923                throws SettingNotFoundException {
2924            return getFloatForUser(cr, name, UserHandle.myUserId());
2925        }
2926
2927        /** @hide */
2928        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
2929                throws SettingNotFoundException {
2930            String v = getStringForUser(cr, name, userHandle);
2931            if (v == null) {
2932                throw new SettingNotFoundException(name);
2933            }
2934            try {
2935                return Float.parseFloat(v);
2936            } catch (NumberFormatException e) {
2937                throw new SettingNotFoundException(name);
2938            }
2939        }
2940
2941        /**
2942         * Convenience function for updating a single settings value as a
2943         * floating point number. This will either create a new entry in the
2944         * table if the given name does not exist, or modify the value of the
2945         * existing row with that name.  Note that internally setting values
2946         * are always stored as strings, so this function converts the given
2947         * value to a string before storing it.
2948         *
2949         * @param cr The ContentResolver to access.
2950         * @param name The name of the setting to modify.
2951         * @param value The new value for the setting.
2952         * @return true if the value was set, false on database errors
2953         */
2954        public static boolean putFloat(ContentResolver cr, String name, float value) {
2955            return putFloatForUser(cr, name, value, UserHandle.myUserId());
2956        }
2957
2958        /** @hide */
2959        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
2960                int userHandle) {
2961            return putStringForUser(cr, name, Float.toString(value), userHandle);
2962        }
2963
2964        /**
2965         * The content:// style URL for this table
2966         */
2967        public static final Uri CONTENT_URI =
2968            Uri.parse("content://" + AUTHORITY + "/secure");
2969
2970        /**
2971         * @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
2972         * instead
2973         */
2974        @Deprecated
2975        public static final String DEVELOPMENT_SETTINGS_ENABLED =
2976                Global.DEVELOPMENT_SETTINGS_ENABLED;
2977
2978        /**
2979         * When the user has enable the option to have a "bug report" command
2980         * in the power menu.
2981         * @hide
2982         */
2983        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
2984
2985        /**
2986         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
2987         */
2988        @Deprecated
2989        public static final String ADB_ENABLED = Global.ADB_ENABLED;
2990
2991        /**
2992         * Setting to allow mock locations and location provider status to be injected into the
2993         * LocationManager service for testing purposes during application development.  These
2994         * locations and status values  override actual location and status information generated
2995         * by network, gps, or other location providers.
2996         */
2997        public static final String ALLOW_MOCK_LOCATION = "mock_location";
2998
2999        /**
3000         * A 64-bit number (as a hex string) that is randomly
3001         * generated on the device's first boot and should remain
3002         * constant for the lifetime of the device.  (The value may
3003         * change if a factory reset is performed on the device.)
3004         */
3005        public static final String ANDROID_ID = "android_id";
3006
3007        /**
3008         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
3009         */
3010        @Deprecated
3011        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
3012
3013        /**
3014         * Get the key that retrieves a bluetooth headset's priority.
3015         * @hide
3016         */
3017        public static final String getBluetoothHeadsetPriorityKey(String address) {
3018            return ("bluetooth_headset_priority_" + address.toUpperCase());
3019        }
3020
3021        /**
3022         * Get the key that retrieves a bluetooth a2dp sink's priority.
3023         * @hide
3024         */
3025        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
3026            return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
3027        }
3028
3029        /**
3030         * Get the key that retrieves a bluetooth Input Device's priority.
3031         * @hide
3032         */
3033        public static final String getBluetoothInputDevicePriorityKey(String address) {
3034            return ("bluetooth_input_device_priority_" + address.toUpperCase());
3035        }
3036
3037        /**
3038         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
3039         */
3040        public static final String DATA_ROAMING = Global.DATA_ROAMING;
3041
3042        /**
3043         * Setting to record the input method used by default, holding the ID
3044         * of the desired method.
3045         */
3046        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
3047
3048        /**
3049         * Setting to record the input method subtype used by default, holding the ID
3050         * of the desired method.
3051         */
3052        public static final String SELECTED_INPUT_METHOD_SUBTYPE =
3053                "selected_input_method_subtype";
3054
3055        /**
3056         * Setting to record the history of input method subtype, holding the pair of ID of IME
3057         * and its last used subtype.
3058         * @hide
3059         */
3060        public static final String INPUT_METHODS_SUBTYPE_HISTORY =
3061                "input_methods_subtype_history";
3062
3063        /**
3064         * Setting to record the visibility of input method selector
3065         */
3066        public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
3067                "input_method_selector_visibility";
3068
3069        /**
3070         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
3071         */
3072        @Deprecated
3073        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
3074
3075        /**
3076         * List of input methods that are currently enabled.  This is a string
3077         * containing the IDs of all enabled input methods, each ID separated
3078         * by ':'.
3079         */
3080        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
3081
3082        /**
3083         * List of system input methods that are currently disabled.  This is a string
3084         * containing the IDs of all disabled input methods, each ID separated
3085         * by ':'.
3086         * @hide
3087         */
3088        public static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
3089
3090        /**
3091         * Host name and port for global http proxy.  Uses ':' seperator for between host and port
3092         * TODO - deprecate in favor of global_http_proxy_host, etc
3093         */
3094        public static final String HTTP_PROXY = "http_proxy";
3095
3096        /**
3097         * Host name for global http proxy.  Set via ConnectivityManager.
3098         * @hide
3099         */
3100        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
3101
3102        /**
3103         * Integer host port for global http proxy.  Set via ConnectivityManager.
3104         * @hide
3105         */
3106        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
3107
3108        /**
3109         * Exclusion list for global proxy. This string contains a list of comma-separated
3110         * domains where the global proxy does not apply. Domains should be listed in a comma-
3111         * separated list. Example of acceptable formats: ".domain1.com,my.domain2.com"
3112         * Use ConnectivityManager to set/get.
3113         * @hide
3114         */
3115        public static final String GLOBAL_HTTP_PROXY_EXCLUSION_LIST =
3116                "global_http_proxy_exclusion_list";
3117
3118        /**
3119         * Enables the UI setting to allow the user to specify the global HTTP proxy
3120         * and associated exclusion list.
3121         * @hide
3122         */
3123        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
3124
3125        /**
3126         * Setting for default DNS in case nobody suggests one
3127         * @hide
3128         */
3129        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
3130
3131        /**
3132         * @deprecated Use {@link android.provider.Settings.Global#INSTALL_NON_MARKET_APPS} instead
3133         */
3134        @Deprecated
3135        public static final String INSTALL_NON_MARKET_APPS = Global.INSTALL_NON_MARKET_APPS;
3136
3137        /**
3138         * Comma-separated list of location providers that activities may access.
3139         */
3140        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
3141
3142        /**
3143         * A flag containing settings used for biometric weak
3144         * @hide
3145         */
3146        public static final String LOCK_BIOMETRIC_WEAK_FLAGS =
3147                "lock_biometric_weak_flags";
3148
3149        /**
3150         * Whether autolock is enabled (0 = false, 1 = true)
3151         */
3152        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
3153
3154        /**
3155         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
3156         */
3157        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
3158
3159        /**
3160         * Whether lock pattern will vibrate as user enters (0 = false, 1 = true)
3161         */
3162        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
3163            "lock_pattern_tactile_feedback_enabled";
3164
3165        /**
3166         * This preference allows the device to be locked given time after screen goes off,
3167         * subject to current DeviceAdmin policy limits.
3168         * @hide
3169         */
3170        public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout";
3171
3172
3173        /**
3174         * This preference contains the string that shows for owner info on LockScren.
3175         * @hide
3176         */
3177        public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
3178
3179        /**
3180         * This preference enables showing the owner info on LockScren.
3181         * @hide
3182         */
3183        public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
3184            "lock_screen_owner_info_enabled";
3185
3186        /**
3187         * @deprecated Use {@link android.provider.Settings.Global#DISPLAY_SIZE_FORCED} instead
3188         * @hide
3189         */
3190        @Deprecated
3191        public static final String DISPLAY_SIZE_FORCED = Global.DISPLAY_SIZE_FORCED;
3192
3193        /**
3194         * @deprecated Use {@link android.provider.Settings.Global#DISPLAY_DENSITY_FORCED} instead
3195         * @hide
3196         */
3197        @Deprecated
3198        public static final String DISPLAY_DENSITY_FORCED = Global.DISPLAY_DENSITY_FORCED;
3199
3200        /**
3201         * @deprecated Use {@link android.provider.Settings.Global#ASSISTED_GPS_ENABLE} instead
3202         * @hide
3203         */
3204        @Deprecated
3205        public static final String ASSISTED_GPS_ENABLED = Global.ASSISTED_GPS_ENABLED;
3206
3207        /**
3208         * The Logging ID (a unique 64-bit value) as a hex string.
3209         * Used as a pseudonymous identifier for logging.
3210         * @deprecated This identifier is poorly initialized and has
3211         * many collisions.  It should not be used.
3212         */
3213        @Deprecated
3214        public static final String LOGGING_ID = "logging_id";
3215
3216        /**
3217         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
3218         */
3219        @Deprecated
3220        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
3221
3222        /**
3223         * @deprecated Use {@link android.provider.Settings.Global#TETHER_SUPPORTED} instead
3224         * @hide
3225         */
3226        @Deprecated
3227        public static final String TETHER_SUPPORTED = Global.TETHER_SUPPORTED;
3228
3229        /**
3230         * @deprecated Use {@link android.provider.Settings.Global#TETHER_DUN_REQUIRED} instead
3231         * @hide
3232         */
3233        @Deprecated
3234        public static final String TETHER_DUN_REQUIRED = Global.TETHER_DUN_REQUIRED;
3235
3236        /**
3237         * @deprecated Use {@link android.provider.Settings.Global#TETHER_DUN_REQUIRED} instead
3238         * @hide
3239         */
3240        @Deprecated
3241        public static final String TETHER_DUN_APN = Global.TETHER_DUN_APN;
3242
3243        /**
3244         * @deprecated Use {@link android.provider.Settings.Global#DATA_ACTIVITY_TIMEOUT_MOBILE}
3245         * instead
3246         * @hide
3247         */
3248        @Deprecated
3249        public static final String DATA_ACTIVITY_TIMEOUT_MOBILE =
3250            Global.DATA_ACTIVITY_TIMEOUT_MOBILE;
3251
3252        /**
3253         * @deprecated Use {@link android.provider.Settings.Global#DATA_ACTIVITY_TIMEOUT_MOBILE}
3254         * instead
3255         * @hide
3256         */
3257        @Deprecated
3258        public static final String DATA_ACTIVITY_TIMEOUT_WIFI = Global.DATA_ACTIVITY_TIMEOUT_WIFI;
3259
3260        /**
3261         * No longer supported.
3262         */
3263        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
3264
3265        /**
3266         * No longer supported.
3267         */
3268        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
3269
3270        /**
3271         * No longer supported.
3272         */
3273        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
3274
3275        /**
3276         * @deprecated Use {@link android.provider.Settings.Global#SAMPLING_PROFILER_MS} instead
3277         * @hide
3278         */
3279        @Deprecated
3280        public static final String SAMPLING_PROFILER_MS = Global.SAMPLING_PROFILER_MS;
3281
3282        /**
3283         * Settings classname to launch when Settings is clicked from All
3284         * Applications.  Needed because of user testing between the old
3285         * and new Settings apps.
3286         */
3287        // TODO: 881807
3288        public static final String SETTINGS_CLASSNAME = "settings_classname";
3289
3290        /**
3291         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
3292         */
3293        @Deprecated
3294        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
3295
3296        /**
3297         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
3298         */
3299        @Deprecated
3300        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
3301
3302        /**
3303         * If accessibility is enabled.
3304         */
3305        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
3306
3307        /**
3308         * If touch exploration is enabled.
3309         */
3310        public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled";
3311
3312        /**
3313         * List of the enabled accessibility providers.
3314         */
3315        public static final String ENABLED_ACCESSIBILITY_SERVICES =
3316            "enabled_accessibility_services";
3317
3318        /**
3319         * List of the accessibility services to which the user has graned
3320         * permission to put the device into touch exploration mode.
3321         *
3322         * @hide
3323         */
3324        public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES =
3325            "touch_exploration_granted_accessibility_services";
3326
3327        /**
3328         * Whether to speak passwords while in accessibility mode.
3329         */
3330        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
3331
3332        /**
3333         * If injection of accessibility enhancing JavaScript screen-reader
3334         * is enabled.
3335         * <p>
3336         *   Note: The JavaScript based screen-reader is served by the
3337         *   Google infrastructure and enable users with disabilities to
3338         *   efficiantly navigate in and explore web content.
3339         * </p>
3340         * <p>
3341         *   This property represents a boolean value.
3342         * </p>
3343         * @hide
3344         */
3345        public static final String ACCESSIBILITY_SCRIPT_INJECTION =
3346            "accessibility_script_injection";
3347
3348        /**
3349         * The URL for the injected JavaScript based screen-reader used
3350         * for providing accessiblity of content in WebView.
3351         * <p>
3352         *   Note: The JavaScript based screen-reader is served by the
3353         *   Google infrastructure and enable users with disabilities to
3354         *   efficiently navigate in and explore web content.
3355         * </p>
3356         * <p>
3357         *   This property represents a string value.
3358         * </p>
3359         * @hide
3360         */
3361        public static final String ACCESSIBILITY_SCREEN_READER_URL =
3362            "accessibility_script_injection_url";
3363
3364        /**
3365         * Key bindings for navigation in built-in accessibility support for web content.
3366         * <p>
3367         *   Note: These key bindings are for the built-in accessibility navigation for
3368         *   web content which is used as a fall back solution if JavaScript in a WebView
3369         *   is not enabled or the user has not opted-in script injection from Google.
3370         * </p>
3371         * <p>
3372         *   The bindings are separated by semi-colon. A binding is a mapping from
3373         *   a key to a sequence of actions (for more details look at
3374         *   android.webkit.AccessibilityInjector). A key is represented as the hexademical
3375         *   string representation of an integer obtained from a meta state (optional) shifted
3376         *   sixteen times left and bitwise ored with a key code. An action is represented
3377         *   as a hexademical string representation of an integer where the first two digits
3378         *   are navigation action index, the second, the third, and the fourth digit pairs
3379         *   represent the action arguments. The separate actions in a binding are colon
3380         *   separated. The key and the action sequence it maps to are separated by equals.
3381         * </p>
3382         * <p>
3383         *   For example, the binding below maps the DPAD right button to traverse the
3384         *   current navigation axis once without firing an accessibility event and to
3385         *   perform the same traversal again but to fire an event:
3386         *   <code>
3387         *     0x16=0x01000100:0x01000101;
3388         *   </code>
3389         * </p>
3390         * <p>
3391         *   The goal of this binding is to enable dynamic rebinding of keys to
3392         *   navigation actions for web content without requiring a framework change.
3393         * </p>
3394         * <p>
3395         *   This property represents a string value.
3396         * </p>
3397         * @hide
3398         */
3399        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
3400            "accessibility_web_content_key_bindings";
3401
3402        /**
3403         * The timout for considering a press to be a long press in milliseconds.
3404         * @hide
3405         */
3406        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
3407
3408        /**
3409         * Setting to always use the default text-to-speech settings regardless
3410         * of the application settings.
3411         * 1 = override application settings,
3412         * 0 = use application settings (if specified).
3413         *
3414         * @deprecated  The value of this setting is no longer respected by
3415         * the framework text to speech APIs as of the Ice Cream Sandwich release.
3416         */
3417        @Deprecated
3418        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
3419
3420        /**
3421         * Default text-to-speech engine speech rate. 100 = 1x
3422         */
3423        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
3424
3425        /**
3426         * Default text-to-speech engine pitch. 100 = 1x
3427         */
3428        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
3429
3430        /**
3431         * Default text-to-speech engine.
3432         */
3433        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
3434
3435        /**
3436         * Default text-to-speech language.
3437         *
3438         * @deprecated this setting is no longer in use, as of the Ice Cream
3439         * Sandwich release. Apps should never need to read this setting directly,
3440         * instead can query the TextToSpeech framework classes for the default
3441         * locale. {@link TextToSpeech#getLanguage()}.
3442         */
3443        @Deprecated
3444        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
3445
3446        /**
3447         * Default text-to-speech country.
3448         *
3449         * @deprecated this setting is no longer in use, as of the Ice Cream
3450         * Sandwich release. Apps should never need to read this setting directly,
3451         * instead can query the TextToSpeech framework classes for the default
3452         * locale. {@link TextToSpeech#getLanguage()}.
3453         */
3454        @Deprecated
3455        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
3456
3457        /**
3458         * Default text-to-speech locale variant.
3459         *
3460         * @deprecated this setting is no longer in use, as of the Ice Cream
3461         * Sandwich release. Apps should never need to read this setting directly,
3462         * instead can query the TextToSpeech framework classes for the
3463         * locale that is in use {@link TextToSpeech#getLanguage()}.
3464         */
3465        @Deprecated
3466        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
3467
3468        /**
3469         * Stores the default tts locales on a per engine basis. Stored as
3470         * a comma seperated list of values, each value being of the form
3471         * {@code engine_name:locale} for example,
3472         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
3473         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
3474         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
3475         * setting directly, and can query the TextToSpeech framework classes
3476         * for the locale that is in use.
3477         *
3478         * @hide
3479         */
3480        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
3481
3482        /**
3483         * Space delimited list of plugin packages that are enabled.
3484         */
3485        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
3486
3487        /**
3488         * Whether to notify the user of open networks.
3489         * <p>
3490         * If not connected and the scan results have an open network, we will
3491         * put this notification up. If we attempt to connect to a network or
3492         * the open network(s) disappear, we remove the notification. When we
3493         * show the notification, we will not show it again for
3494         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
3495         */
3496        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3497                "wifi_networks_available_notification_on";
3498        /**
3499         * {@hide}
3500         */
3501        public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3502                "wimax_networks_available_notification_on";
3503
3504        /**
3505         * Delay (in seconds) before repeating the Wi-Fi networks available notification.
3506         * Connecting to a network will reset the timer.
3507         */
3508        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
3509                "wifi_networks_available_repeat_delay";
3510
3511        /**
3512         * 802.11 country code in ISO 3166 format
3513         * @hide
3514         */
3515        public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
3516
3517
3518        /**
3519         * When the number of open networks exceeds this number, the
3520         * least-recently-used excess networks will be removed.
3521         */
3522        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
3523
3524        /**
3525         * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
3526         */
3527        public static final String WIFI_ON = "wifi_on";
3528
3529        /**
3530         * Used to save the Wifi_ON state prior to tethering.
3531         * This state will be checked to restore Wifi after
3532         * the user turns off tethering.
3533         *
3534         * @hide
3535         */
3536        public static final String WIFI_SAVED_STATE = "wifi_saved_state";
3537
3538        /**
3539         * AP SSID
3540         *
3541         * @hide
3542         */
3543        public static final String WIFI_AP_SSID = "wifi_ap_ssid";
3544
3545        /**
3546         * AP security
3547         *
3548         * @hide
3549         */
3550        public static final String WIFI_AP_SECURITY = "wifi_ap_security";
3551
3552        /**
3553         * AP passphrase
3554         *
3555         * @hide
3556         */
3557        public static final String WIFI_AP_PASSWD = "wifi_ap_passwd";
3558
3559        /**
3560         * The acceptable packet loss percentage (range 0 - 100) before trying
3561         * another AP on the same network.
3562         */
3563        @Deprecated
3564        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
3565                "wifi_watchdog_acceptable_packet_loss_percentage";
3566
3567        /**
3568         * The number of access points required for a network in order for the
3569         * watchdog to monitor it.
3570         */
3571        @Deprecated
3572        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
3573
3574        /**
3575         * The delay between background checks.
3576         */
3577        @Deprecated
3578        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
3579                "wifi_watchdog_background_check_delay_ms";
3580
3581        /**
3582         * Whether the Wi-Fi watchdog is enabled for background checking even
3583         * after it thinks the user has connected to a good access point.
3584         */
3585        @Deprecated
3586        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
3587                "wifi_watchdog_background_check_enabled";
3588
3589        /**
3590         * The timeout for a background ping
3591         */
3592        @Deprecated
3593        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
3594                "wifi_watchdog_background_check_timeout_ms";
3595
3596        /**
3597         * The number of initial pings to perform that *may* be ignored if they
3598         * fail. Again, if these fail, they will *not* be used in packet loss
3599         * calculation. For example, one network always seemed to time out for
3600         * the first couple pings, so this is set to 3 by default.
3601         */
3602        @Deprecated
3603        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
3604            "wifi_watchdog_initial_ignored_ping_count";
3605
3606        /**
3607         * The maximum number of access points (per network) to attempt to test.
3608         * If this number is reached, the watchdog will no longer monitor the
3609         * initial connection state for the network. This is a safeguard for
3610         * networks containing multiple APs whose DNS does not respond to pings.
3611         */
3612        @Deprecated
3613        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
3614
3615        /**
3616         * Whether the Wi-Fi watchdog is enabled.
3617         */
3618        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
3619
3620        /**
3621         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
3622         */
3623        @Deprecated
3624        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
3625
3626        /**
3627         * The number of pings to test if an access point is a good connection.
3628         */
3629        @Deprecated
3630        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
3631
3632        /**
3633         * The delay between pings.
3634         */
3635        @Deprecated
3636        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
3637
3638        /**
3639         * The timeout per ping.
3640         */
3641        @Deprecated
3642        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
3643
3644        /**
3645         * ms delay before rechecking an 'online' wifi connection when it is thought to be unstable.
3646         * @hide
3647         */
3648        public static final String WIFI_WATCHDOG_ARP_CHECK_INTERVAL_MS =
3649                "wifi_watchdog_arp_interval_ms";
3650
3651        /**
3652         * ms delay interval between rssi polling when the signal is known to be weak
3653         * @hide
3654         */
3655        public static final String WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS =
3656                "wifi_watchdog_rssi_fetch_interval_ms";
3657
3658
3659        /**
3660         * Number of ARP pings per check.
3661         * @hide
3662         */
3663        public static final String WIFI_WATCHDOG_NUM_ARP_PINGS = "wifi_watchdog_num_arp_pings";
3664
3665        /**
3666         * Minimum number of responses to the arp pings to consider the test 'successful'.
3667         * @hide
3668         */
3669        public static final String WIFI_WATCHDOG_MIN_ARP_RESPONSES =
3670                "wifi_watchdog_min_arp_responses";
3671
3672        /**
3673         * Timeout on ARP pings
3674         * @hide
3675         */
3676        public static final String WIFI_WATCHDOG_ARP_PING_TIMEOUT_MS =
3677                "wifi_watchdog_arp_ping_timeout_ms";
3678
3679        /**
3680         * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
3681         * the setting needs to be set to 0 to disable it.
3682         * @hide
3683         */
3684        public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
3685                "wifi_watchdog_poor_network_test_enabled";
3686
3687        /**
3688         * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
3689         * needs to be set to 0 to disable it.
3690         * @hide
3691         */
3692        public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
3693                "wifi_suspend_optimizations_enabled";
3694
3695        /**
3696         * @deprecated Use
3697         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
3698         */
3699        @Deprecated
3700        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
3701
3702        /**
3703         * The operational wifi frequency band
3704         * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
3705         * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
3706         * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
3707         *
3708         * @hide
3709         */
3710        public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
3711
3712        /**
3713         * The Wi-Fi peer-to-peer device name
3714         * @hide
3715         */
3716        public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
3717
3718        /**
3719         * Setting to turn off captive portal detection. Feature is enabled by default and
3720         * the setting needs to be set to 0 to disable it.
3721         * @hide
3722         */
3723        public static final String CAPTIVE_PORTAL_DETECTION_ENABLED =
3724                "captive_portal_detection_enabled";
3725
3726        /**
3727         * The server used for captive portal detection upon a new conection. A 204 response
3728         * code from the server is used for validation.
3729         * @hide
3730         */
3731        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
3732
3733        /**
3734         * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
3735         * data connectivity to be established after a disconnect from Wi-Fi.
3736         */
3737        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
3738            "wifi_mobile_data_transition_wakelock_timeout_ms";
3739
3740        /**
3741         * Whether network service discovery is enabled.
3742         * @hide
3743         */
3744        public static final String NSD_ON = "nsd_on";
3745
3746        /**
3747         * Whether background data usage is allowed by the user. See
3748         * ConnectivityManager for more info.
3749         */
3750        @Deprecated
3751        public static final String BACKGROUND_DATA = "background_data";
3752
3753        /**
3754         * Origins for which browsers should allow geolocation by default.
3755         * The value is a space-separated list of origins.
3756         */
3757        public static final String ALLOWED_GEOLOCATION_ORIGINS
3758                = "allowed_geolocation_origins";
3759
3760        /**
3761         * @deprecated Use {@link android.provider.Settings.Global#MOBILE_DATA} instead
3762         * @hide
3763         */
3764        @Deprecated
3765        public static final String MOBILE_DATA = Global.MOBILE_DATA;
3766
3767        /**
3768         * @deprecated Use {@link android.provider.Settings.Global#CDMA_ROAMING_MODE} instead
3769         * @hide
3770         */
3771        @Deprecated
3772        public static final String CDMA_ROAMING_MODE = Global.CDMA_ROAMING_MODE;
3773
3774        /**
3775         * @deprecated Use {@link android.provider.Settings.Global#CDMA_ROAMING_MODE} instead
3776         * @hide
3777         */
3778        @Deprecated
3779        public static final String CDMA_SUBSCRIPTION_MODE = Global.CDMA_SUBSCRIPTION_MODE;
3780
3781        /**
3782         * The preferred network mode   7 = Global
3783         *                              6 = EvDo only
3784         *                              5 = CDMA w/o EvDo
3785         *                              4 = CDMA / EvDo auto
3786         *                              3 = GSM / WCDMA auto
3787         *                              2 = WCDMA only
3788         *                              1 = GSM only
3789         *                              0 = GSM / WCDMA preferred
3790         * @hide
3791         */
3792        public static final String PREFERRED_NETWORK_MODE =
3793                "preferred_network_mode";
3794
3795        /**
3796         * The preferred TTY mode     0 = TTy Off, CDMA default
3797         *                            1 = TTY Full
3798         *                            2 = TTY HCO
3799         *                            3 = TTY VCO
3800         * @hide
3801         */
3802        public static final String PREFERRED_TTY_MODE =
3803                "preferred_tty_mode";
3804
3805
3806        /**
3807         * @deprecated Use {@link android.provider.Settings.Global#CDMA_CELL_BROADCAST_SMS} instead
3808         * @hide
3809         */
3810        @Deprecated
3811        public static final String CDMA_CELL_BROADCAST_SMS = Global.CDMA_CELL_BROADCAST_SMS;
3812
3813        /**
3814         * The cdma subscription 0 = Subscription from RUIM, when available
3815         *                       1 = Subscription from NV
3816         * @hide
3817         */
3818        public static final String PREFERRED_CDMA_SUBSCRIPTION =
3819                "preferred_cdma_subscription";
3820
3821        /**
3822         * Whether the enhanced voice privacy mode is enabled.
3823         * 0 = normal voice privacy
3824         * 1 = enhanced voice privacy
3825         * @hide
3826         */
3827        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
3828
3829        /**
3830         * Whether the TTY mode mode is enabled.
3831         * 0 = disabled
3832         * 1 = enabled
3833         * @hide
3834         */
3835        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
3836
3837        /**
3838         * The number of milliseconds to delay before sending out Connectivyt Change broadcasts
3839         * @hide
3840         */
3841        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
3842
3843        /**
3844         * Default value for CONNECTIVITY_CHANGE_DELAY in milliseconds.
3845         * @hide
3846         */
3847        public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000;
3848
3849        /**
3850         * Controls whether settings backup is enabled.
3851         * Type: int ( 0 = disabled, 1 = enabled )
3852         * @hide
3853         */
3854        public static final String BACKUP_ENABLED = "backup_enabled";
3855
3856        /**
3857         * Controls whether application data is automatically restored from backup
3858         * at install time.
3859         * Type: int ( 0 = disabled, 1 = enabled )
3860         * @hide
3861         */
3862        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
3863
3864        /**
3865         * Indicates whether settings backup has been fully provisioned.
3866         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
3867         * @hide
3868         */
3869        public static final String BACKUP_PROVISIONED = "backup_provisioned";
3870
3871        /**
3872         * Component of the transport to use for backup/restore.
3873         * @hide
3874         */
3875        public static final String BACKUP_TRANSPORT = "backup_transport";
3876
3877        /**
3878         * Version for which the setup wizard was last shown.  Bumped for
3879         * each release when there is new setup information to show.
3880         * @hide
3881         */
3882        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
3883
3884        /**
3885         * How frequently (in seconds) to check the memory status of the
3886         * device.
3887         * @hide
3888         */
3889        public static final String MEMCHECK_INTERVAL = "memcheck_interval";
3890
3891        /**
3892         * Max frequency (in seconds) to log memory check stats, in realtime
3893         * seconds.  This allows for throttling of logs when the device is
3894         * running for large amounts of time.
3895         * @hide
3896         */
3897        public static final String MEMCHECK_LOG_REALTIME_INTERVAL =
3898                "memcheck_log_realtime_interval";
3899
3900        /**
3901         * Boolean indicating whether rebooting due to system memory checks
3902         * is enabled.
3903         * @hide
3904         */
3905        public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled";
3906
3907        /**
3908         * How many bytes the system process must be below to avoid scheduling
3909         * a soft reboot.  This reboot will happen when it is next determined
3910         * to be a good time.
3911         * @hide
3912         */
3913        public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft";
3914
3915        /**
3916         * How many bytes the system process must be below to avoid scheduling
3917         * a hard reboot.  This reboot will happen immediately.
3918         * @hide
3919         */
3920        public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard";
3921
3922        /**
3923         * How many bytes the phone process must be below to avoid scheduling
3924         * a soft restart.  This restart will happen when it is next determined
3925         * to be a good time.
3926         * @hide
3927         */
3928        public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft";
3929
3930        /**
3931         * How many bytes the phone process must be below to avoid scheduling
3932         * a hard restart.  This restart will happen immediately.
3933         * @hide
3934         */
3935        public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard";
3936
3937        /**
3938         * Boolean indicating whether restarting the phone process due to
3939         * memory checks is enabled.
3940         * @hide
3941         */
3942        public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled";
3943
3944        /**
3945         * First time during the day it is okay to kill processes
3946         * or reboot the device due to low memory situations.  This number is
3947         * in seconds since midnight.
3948         * @hide
3949         */
3950        public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time";
3951
3952        /**
3953         * Last time during the day it is okay to kill processes
3954         * or reboot the device due to low memory situations.  This number is
3955         * in seconds since midnight.
3956         * @hide
3957         */
3958        public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time";
3959
3960        /**
3961         * How long the screen must have been off in order to kill processes
3962         * or reboot.  This number is in seconds.  A value of -1 means to
3963         * entirely disregard whether the screen is on.
3964         * @hide
3965         */
3966        public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off";
3967
3968        /**
3969         * How much time there must be until the next alarm in order to kill processes
3970         * or reboot.  This number is in seconds.  Note: this value must be
3971         * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will
3972         * always see an alarm scheduled within its time.
3973         * @hide
3974         */
3975        public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm";
3976
3977        /**
3978         * How frequently to check whether it is a good time to restart things,
3979         * if the device is in a bad state.  This number is in seconds.  Note:
3980         * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else
3981         * the alarm to schedule the recheck will always appear within the
3982         * minimum "do not execute now" time.
3983         * @hide
3984         */
3985        public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval";
3986
3987        /**
3988         * How frequently (in DAYS) to reboot the device.  If 0, no reboots
3989         * will occur.
3990         * @hide
3991         */
3992        public static final String REBOOT_INTERVAL = "reboot_interval";
3993
3994        /**
3995         * First time during the day it is okay to force a reboot of the
3996         * device (if REBOOT_INTERVAL is set).  This number is
3997         * in seconds since midnight.
3998         * @hide
3999         */
4000        public static final String REBOOT_START_TIME = "reboot_start_time";
4001
4002        /**
4003         * The window of time (in seconds) after each REBOOT_INTERVAL in which
4004         * a reboot can be executed.  If 0, a reboot will always be executed at
4005         * exactly the given time.  Otherwise, it will only be executed if
4006         * the device is idle within the window.
4007         * @hide
4008         */
4009        public static final String REBOOT_WINDOW = "reboot_window";
4010
4011        /**
4012         * Threshold values for the duration and level of a discharge cycle, under
4013         * which we log discharge cycle info.
4014         * @hide
4015         */
4016        public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD =
4017                "battery_discharge_duration_threshold";
4018        /** @hide */
4019        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
4020
4021        /**
4022         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents
4023         * on application crashes and ANRs. If this is disabled, the crash/ANR dialog
4024         * will never display the "Report" button.
4025         * Type: int ( 0 = disallow, 1 = allow )
4026         * @hide
4027         */
4028        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
4029
4030        /**
4031         * @deprecated Use {@link android.provider.Settings.Global#WTF_IS_FATAL} instead
4032         * @hide
4033         */
4034        @Deprecated
4035        public static final String WTF_IS_FATAL = Global.WTF_IS_FATAL;
4036
4037        /**
4038         * Maximum age of entries kept by {@link com.android.internal.os.IDropBoxManagerService}.
4039         * @hide
4040         */
4041        public static final String DROPBOX_AGE_SECONDS =
4042                "dropbox_age_seconds";
4043        /**
4044         * Maximum number of entry files which {@link com.android.internal.os.IDropBoxManagerService} will keep around.
4045         * @hide
4046         */
4047        public static final String DROPBOX_MAX_FILES =
4048                "dropbox_max_files";
4049        /**
4050         * Maximum amount of disk space used by {@link com.android.internal.os.IDropBoxManagerService} no matter what.
4051         * @hide
4052         */
4053        public static final String DROPBOX_QUOTA_KB =
4054                "dropbox_quota_kb";
4055        /**
4056         * Percent of free disk (excluding reserve) which {@link com.android.internal.os.IDropBoxManagerService} will use.
4057         * @hide
4058         */
4059        public static final String DROPBOX_QUOTA_PERCENT =
4060                "dropbox_quota_percent";
4061        /**
4062         * Percent of total disk which {@link com.android.internal.os.IDropBoxManagerService} will never dip into.
4063         * @hide
4064         */
4065        public static final String DROPBOX_RESERVE_PERCENT =
4066                "dropbox_reserve_percent";
4067        /**
4068         * Prefix for per-tag dropbox disable/enable settings.
4069         * @hide
4070         */
4071        public static final String DROPBOX_TAG_PREFIX =
4072                "dropbox:";
4073        /**
4074         * Lines of logcat to include with system crash/ANR/etc. reports,
4075         * as a prefix of the dropbox tag of the report type.
4076         * For example, "logcat_for_system_server_anr" controls the lines
4077         * of logcat captured with system server ANR reports.  0 to disable.
4078         * @hide
4079         */
4080        public static final String ERROR_LOGCAT_PREFIX =
4081                "logcat_for_";
4082
4083
4084        /**
4085         * Screen timeout in milliseconds corresponding to the
4086         * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest
4087         * possible screen timeout behavior.)
4088         * @hide
4089         */
4090        public static final String SHORT_KEYLIGHT_DELAY_MS =
4091                "short_keylight_delay_ms";
4092
4093        /**
4094         * The interval in minutes after which the amount of free storage left on the
4095         * device is logged to the event log
4096         * @hide
4097         */
4098        public static final String SYS_FREE_STORAGE_LOG_INTERVAL =
4099                "sys_free_storage_log_interval";
4100
4101        /**
4102         * Threshold for the amount of change in disk free space required to report the amount of
4103         * free space. Used to prevent spamming the logs when the disk free space isn't changing
4104         * frequently.
4105         * @hide
4106         */
4107        public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD =
4108                "disk_free_change_reporting_threshold";
4109
4110
4111        /**
4112         * Minimum percentage of free storage on the device that is used to determine if
4113         * the device is running low on storage.  The default is 10.
4114         * <p>Say this value is set to 10, the device is considered running low on storage
4115         * if 90% or more of the device storage is filled up.
4116         * @hide
4117         */
4118        public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE =
4119                "sys_storage_threshold_percentage";
4120
4121        /**
4122         * Maximum byte size of the low storage threshold.  This is to ensure
4123         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in
4124         * an overly large threshold for large storage devices.  Currently this
4125         * must be less than 2GB.  This default is 500MB.
4126         * @hide
4127         */
4128        public static final String SYS_STORAGE_THRESHOLD_MAX_BYTES =
4129                "sys_storage_threshold_max_bytes";
4130
4131        /**
4132         * Minimum bytes of free storage on the device before the data
4133         * partition is considered full. By default, 1 MB is reserved
4134         * to avoid system-wide SQLite disk full exceptions.
4135         * @hide
4136         */
4137        public static final String SYS_STORAGE_FULL_THRESHOLD_BYTES =
4138                "sys_storage_full_threshold_bytes";
4139
4140        /**
4141         * The interval in milliseconds after which Wi-Fi is considered idle.
4142         * When idle, it is possible for the device to be switched from Wi-Fi to
4143         * the mobile data network.
4144         * @hide
4145         */
4146        public static final String WIFI_IDLE_MS = "wifi_idle_ms";
4147
4148        /**
4149         * The interval in milliseconds to issue wake up scans when wifi needs
4150         * to connect. This is necessary to connect to an access point when
4151         * device is on the move and the screen is off.
4152         * @hide
4153         */
4154        public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
4155                "wifi_framework_scan_interval_ms";
4156
4157        /**
4158         * The interval in milliseconds to scan as used by the wifi supplicant
4159         * @hide
4160         */
4161        public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
4162                "wifi_supplicant_scan_interval_ms";
4163
4164        /**
4165         * @deprecated Moved to Settings.Global
4166         * @hide
4167         */
4168        @Deprecated
4169        public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
4170                Global.PDP_WATCHDOG_POLL_INTERVAL_MS;
4171
4172        /**
4173         * @deprecated Moved to Settings.Global
4174         * @hide
4175         */
4176        @Deprecated
4177        public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
4178                Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS;
4179
4180        /**
4181         * @deprecated Moved to Settings.Global
4182         * @hide
4183         */
4184        @Deprecated
4185        public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
4186                Global.PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS;
4187
4188        /**
4189         * @deprecated Moved to Settings.Global
4190         * @hide
4191         */
4192        @Deprecated
4193        public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
4194                Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT;
4195
4196        /**
4197         * @deprecated Moved to Settings.Global
4198         * @hide
4199         */
4200        @Deprecated
4201        public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
4202                Global.PDP_WATCHDOG_ERROR_POLL_COUNT;
4203
4204        /**
4205         * @deprecated Moved to Settings.Global
4206         * @hide
4207         */
4208        @Deprecated
4209        public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
4210                Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT;
4211
4212        /**
4213         * The number of milliseconds to delay when checking for data stalls during
4214         * non-aggressive detection. (screen is turned off.)
4215         * @hide
4216         */
4217        public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
4218                "data_stall_alarm_non_aggressive_delay_in_ms";
4219
4220        /**
4221         * The number of milliseconds to delay when checking for data stalls during
4222         * aggressive detection. (screen on or suspected data stall)
4223         * @hide
4224         */
4225        public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
4226                "data_stall_alarm_aggressive_delay_in_ms";
4227
4228        /**
4229         * The interval in milliseconds at which to check gprs registration
4230         * after the first registration mismatch of gprs and voice service,
4231         * to detect possible data network registration problems.
4232         *
4233         * @hide
4234         */
4235        public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
4236                "gprs_register_check_period_ms";
4237
4238        /**
4239         * @deprecated Use {@link android.provider.Settings.Global#NITZ_UPDATE_SPACING} instead
4240         * @hide
4241         */
4242        public static final String NITZ_UPDATE_SPACING = Global.NITZ_UPDATE_SPACING;
4243
4244        /**
4245         * @deprecated Use {@link android.provider.Settings.Global#NITZ_UPDATE_SPACING} instead
4246         * @hide
4247         */
4248        public static final String NITZ_UPDATE_DIFF = Global.NITZ_UPDATE_DIFF;
4249
4250        /**
4251         * The maximum reconnect delay for short network outages or when the network is suspended
4252         * due to phone use.
4253         * @hide
4254         */
4255        public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
4256                "sync_max_retry_delay_in_seconds";
4257
4258        /**
4259         * The interval in milliseconds at which to check the number of SMS sent
4260         * out without asking for use permit, to limit the un-authorized SMS
4261         * usage.
4262         * @hide
4263         */
4264        public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
4265                "sms_outgoing_check_interval_ms";
4266
4267        /**
4268         * The number of outgoing SMS sent without asking for user permit
4269         * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
4270         * @hide
4271         */
4272        public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
4273                "sms_outgoing_check_max_count";
4274
4275        /**
4276         * The global search provider chosen by the user (if multiple global
4277         * search providers are installed). This will be the provider returned
4278         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
4279         * installed. This setting is stored as a flattened component name as
4280         * per {@link ComponentName#flattenToString()}.
4281         *
4282         * @hide
4283         */
4284        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
4285                "search_global_search_activity";
4286
4287        /**
4288         * The number of promoted sources in GlobalSearch.
4289         * @hide
4290         */
4291        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
4292        /**
4293         * The maximum number of suggestions returned by GlobalSearch.
4294         * @hide
4295         */
4296        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
4297        /**
4298         * The number of suggestions GlobalSearch will ask each non-web search source for.
4299         * @hide
4300         */
4301        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
4302        /**
4303         * The number of suggestions the GlobalSearch will ask the web search source for.
4304         * @hide
4305         */
4306        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
4307                "search_web_results_override_limit";
4308        /**
4309         * The number of milliseconds that GlobalSearch will wait for suggestions from
4310         * promoted sources before continuing with all other sources.
4311         * @hide
4312         */
4313        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
4314                "search_promoted_source_deadline_millis";
4315        /**
4316         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
4317         * @hide
4318         */
4319        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
4320        /**
4321         * The maximum number of milliseconds that GlobalSearch shows the previous results
4322         * after receiving a new query.
4323         * @hide
4324         */
4325        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
4326        /**
4327         * The maximum age of log data used for shortcuts in GlobalSearch.
4328         * @hide
4329         */
4330        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
4331        /**
4332         * The maximum age of log data used for source ranking in GlobalSearch.
4333         * @hide
4334         */
4335        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
4336                "search_max_source_event_age_millis";
4337        /**
4338         * The minimum number of impressions needed to rank a source in GlobalSearch.
4339         * @hide
4340         */
4341        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
4342                "search_min_impressions_for_source_ranking";
4343        /**
4344         * The minimum number of clicks needed to rank a source in GlobalSearch.
4345         * @hide
4346         */
4347        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
4348                "search_min_clicks_for_source_ranking";
4349        /**
4350         * The maximum number of shortcuts shown by GlobalSearch.
4351         * @hide
4352         */
4353        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
4354        /**
4355         * The size of the core thread pool for suggestion queries in GlobalSearch.
4356         * @hide
4357         */
4358        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
4359                "search_query_thread_core_pool_size";
4360        /**
4361         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
4362         * @hide
4363         */
4364        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
4365                "search_query_thread_max_pool_size";
4366        /**
4367         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
4368         * @hide
4369         */
4370        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
4371                "search_shortcut_refresh_core_pool_size";
4372        /**
4373         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
4374         * @hide
4375         */
4376        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
4377                "search_shortcut_refresh_max_pool_size";
4378        /**
4379         * The maximun time that excess threads in the GlobalSeach thread pools will
4380         * wait before terminating.
4381         * @hide
4382         */
4383        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
4384                "search_thread_keepalive_seconds";
4385        /**
4386         * The maximum number of concurrent suggestion queries to each source.
4387         * @hide
4388         */
4389        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
4390                "search_per_source_concurrent_query_limit";
4391
4392        /**
4393         * Whether or not alert sounds are played on MountService events. (0 = false, 1 = true)
4394         * @hide
4395         */
4396        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
4397
4398        /**
4399         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
4400         * @hide
4401         */
4402        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
4403
4404        /**
4405         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
4406         * @hide
4407         */
4408        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
4409
4410        /**
4411         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
4412         * @hide
4413         */
4414        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
4415
4416        /**
4417         * If nonzero, ANRs in invisible background processes bring up a dialog.
4418         * Otherwise, the process will be silently killed.
4419         * @hide
4420         */
4421        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
4422
4423        /**
4424         * The {@link ComponentName} string of the service to be used as the voice recognition
4425         * service.
4426         *
4427         * @hide
4428         */
4429        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
4430
4431
4432        /**
4433         * The {@link ComponentName} string of the selected spell checker service which is
4434         * one of the services managed by the text service manager.
4435         *
4436         * @hide
4437         */
4438        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
4439
4440        /**
4441         * The {@link ComponentName} string of the selected subtype of the selected spell checker
4442         * service which is one of the services managed by the text service manager.
4443         *
4444         * @hide
4445         */
4446        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
4447                "selected_spell_checker_subtype";
4448
4449        /**
4450         * The {@link ComponentName} string whether spell checker is enabled or not.
4451         *
4452         * @hide
4453         */
4454        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
4455
4456        /**
4457         * What happens when the user presses the Power button while in-call
4458         * and the screen is on.<br/>
4459         * <b>Values:</b><br/>
4460         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
4461         * 2 - The Power button hangs up the current call.<br/>
4462         *
4463         * @hide
4464         */
4465        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
4466
4467        /**
4468         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
4469         * @hide
4470         */
4471        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
4472
4473        /**
4474         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
4475         * @hide
4476         */
4477        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
4478
4479        /**
4480         * INCALL_POWER_BUTTON_BEHAVIOR default value.
4481         * @hide
4482         */
4483        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
4484                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
4485
4486        /**
4487         * The current night mode that has been selected by the user.  Owned
4488         * and controlled by UiModeManagerService.  Constants are as per
4489         * UiModeManager.
4490         * @hide
4491         */
4492        public static final String UI_NIGHT_MODE = "ui_night_mode";
4493
4494        /**
4495         * Let user pick default install location.
4496         * @hide
4497         */
4498        public static final String SET_INSTALL_LOCATION = "set_install_location";
4499
4500        /**
4501         * Default install location value.
4502         * 0 = auto, let system decide
4503         * 1 = internal
4504         * 2 = sdcard
4505         * @hide
4506         */
4507        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
4508
4509        /**
4510         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_POLLING_SEC} instead
4511         * @hide
4512         */
4513        @Deprecated
4514        public static final String THROTTLE_POLLING_SEC = Global.THROTTLE_POLLING_SEC;
4515
4516        /**
4517         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_THRESHOLD_BYTES} instead
4518         * @hide
4519         */
4520        @Deprecated
4521        public static final String THROTTLE_THRESHOLD_BYTES = Global.THROTTLE_THRESHOLD_BYTES;
4522
4523        /**
4524         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_VALUE_KBITSPS} instead
4525         * @hide
4526         */
4527        @Deprecated
4528        public static final String THROTTLE_VALUE_KBITSPS = Global.THROTTLE_VALUE_KBITSPS;
4529
4530        /**
4531         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_VALUE_KBITSPS} instead
4532         * @hide
4533         */
4534        @Deprecated
4535        public static final String THROTTLE_RESET_DAY = Global.THROTTLE_RESET_DAY;
4536
4537        /**
4538         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_NOTIFICATION_TYPE} instead
4539         * @hide
4540         */
4541        @Deprecated
4542        public static final String THROTTLE_NOTIFICATION_TYPE = Global.THROTTLE_NOTIFICATION_TYPE;
4543
4544        /**
4545         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_HELP_URI} instead
4546         * @hide
4547         */
4548        @Deprecated
4549        public static final String THROTTLE_HELP_URI = Global.THROTTLE_HELP_URI;
4550
4551        /**
4552         * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_MAX_NTP_CACHE_AGE_SEC} instead
4553         * @hide
4554         */
4555        @Deprecated
4556        public static final String THROTTLE_MAX_NTP_CACHE_AGE_SEC =
4557                Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC;
4558
4559        /**
4560         * @deprecated Use {@link android.provider.Settings.Global#DOWNLOAD_MAX_BYTES_OVER_MOBILE} instead
4561         * @hide
4562         */
4563        @Deprecated
4564        public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
4565                Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE;
4566
4567        /**
4568         * @deprecated Use {@link android.provider.Settings.Global#DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE} instead
4569         * @hide
4570         */
4571        @Deprecated
4572        public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
4573                Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE;
4574
4575        /**
4576         * ms during which to consume extra events related to Inet connection condition
4577         * after a transtion to fully-connected
4578         * @hide
4579         */
4580        public static final String INET_CONDITION_DEBOUNCE_UP_DELAY =
4581                "inet_condition_debounce_up_delay";
4582
4583        /**
4584         * ms during which to consume extra events related to Inet connection condtion
4585         * after a transtion to partly-connected
4586         * @hide
4587         */
4588        public static final String INET_CONDITION_DEBOUNCE_DOWN_DELAY =
4589                "inet_condition_debounce_down_delay";
4590
4591        /**
4592         * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DATA_SERVICE_URL} instead
4593         * @hide
4594         */
4595        @Deprecated
4596        public static final String SETUP_PREPAID_DATA_SERVICE_URL =
4597                Global.SETUP_PREPAID_DATA_SERVICE_URL;
4598
4599        /**
4600         * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DETECTION_TARGET_URL} instead
4601         * @hide
4602         */
4603        @Deprecated
4604        public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
4605                Global.SETUP_PREPAID_DETECTION_TARGET_URL;
4606
4607        /**
4608         * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DETECTION_REDIR_HOST} instead
4609         * @hide
4610         */
4611        @Deprecated
4612        public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
4613                Global.SETUP_PREPAID_DETECTION_REDIR_HOST;
4614
4615        /**
4616         * Whether screensavers are enabled.
4617         * @hide
4618         */
4619        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
4620
4621        /**
4622         * The user's chosen screensaver components.
4623         *
4624         * These will be launched by the PhoneWindowManager after a timeout when not on
4625         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
4626         * @hide
4627         */
4628        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
4629
4630        /**
4631         * If screensavers are enabled, whether the screensaver should be automatically launched
4632         * when the device is inserted into a (desk) dock.
4633         * @hide
4634         */
4635        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
4636
4637        /**
4638         * If screensavers are enabled, whether the screensaver should be automatically launched
4639         * when the screen times out when not on battery.
4640         * @hide
4641         */
4642        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
4643
4644        /**
4645         * If screensavers are enabled, the default screensaver component.
4646         * @hide
4647         */
4648        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
4649
4650        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4651         * {@hide} */
4652        @Deprecated
4653        public static final String NETSTATS_ENABLED = Global.NETSTATS_ENABLED;
4654        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4655         * {@hide} */
4656        @Deprecated
4657        public static final String NETSTATS_POLL_INTERVAL = Global.NETSTATS_POLL_INTERVAL;
4658        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4659         * {@hide} */
4660        @Deprecated
4661        public static final String NETSTATS_TIME_CACHE_MAX_AGE = Global.NETSTATS_TIME_CACHE_MAX_AGE;
4662        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4663         * {@hide} */
4664        @Deprecated
4665        public static final String NETSTATS_GLOBAL_ALERT_BYTES = Global.NETSTATS_GLOBAL_ALERT_BYTES;
4666        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4667         * {@hide} */
4668        @Deprecated
4669        public static final String NETSTATS_SAMPLE_ENABLED = Global.NETSTATS_SAMPLE_ENABLED;
4670        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4671         * {@hide} */
4672        @Deprecated
4673        public static final String NETSTATS_REPORT_XT_OVER_DEV = Global.NETSTATS_REPORT_XT_OVER_DEV;
4674
4675        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4676         * {@hide} */
4677        @Deprecated
4678        public static final String NETSTATS_DEV_BUCKET_DURATION = Global.NETSTATS_DEV_BUCKET_DURATION;
4679        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4680         * {@hide} */
4681        @Deprecated
4682        public static final String NETSTATS_DEV_PERSIST_BYTES = Global.NETSTATS_DEV_PERSIST_BYTES;
4683        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4684         * {@hide} */
4685        @Deprecated
4686        public static final String NETSTATS_DEV_ROTATE_AGE = Global.NETSTATS_DEV_ROTATE_AGE;
4687        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4688         * {@hide} */
4689        @Deprecated
4690        public static final String NETSTATS_DEV_DELETE_AGE = Global.NETSTATS_DEV_DELETE_AGE;
4691
4692        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4693         * {@hide} */
4694        @Deprecated
4695        public static final String NETSTATS_UID_BUCKET_DURATION = Global.NETSTATS_UID_BUCKET_DURATION;
4696        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4697         * {@hide} */
4698        @Deprecated
4699        public static final String NETSTATS_UID_PERSIST_BYTES = Global.NETSTATS_UID_PERSIST_BYTES;
4700        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4701         * {@hide} */
4702        @Deprecated
4703        public static final String NETSTATS_UID_ROTATE_AGE = Global.NETSTATS_UID_ROTATE_AGE;
4704        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4705         * {@hide} */
4706        @Deprecated
4707        public static final String NETSTATS_UID_DELETE_AGE = Global.NETSTATS_UID_DELETE_AGE;
4708
4709        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4710         * {@hide} */
4711        @Deprecated
4712        public static final String NETSTATS_UID_TAG_BUCKET_DURATION = Global.NETSTATS_UID_TAG_BUCKET_DURATION;
4713        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4714         * {@hide} */
4715        @Deprecated
4716        public static final String NETSTATS_UID_TAG_PERSIST_BYTES = Global.NETSTATS_UID_TAG_PERSIST_BYTES;
4717        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4718         * {@hide} */
4719        @Deprecated
4720        public static final String NETSTATS_UID_TAG_ROTATE_AGE = Global.NETSTATS_UID_TAG_ROTATE_AGE;
4721        /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now
4722         * {@hide} */
4723        @Deprecated
4724        public static final String NETSTATS_UID_TAG_DELETE_AGE = Global.NETSTATS_UID_TAG_DELETE_AGE;
4725
4726        /** Preferred NTP server. {@hide}
4727         * @deprecated moved to Settings.Global */
4728        public static final String NTP_SERVER = Global.NTP_SERVER;
4729
4730        /** Timeout in milliseconds to wait for NTP server. {@hide}
4731         * @deprecated moved to Settings.Global */
4732        public static final String NTP_TIMEOUT = Global.NTP_TIMEOUT;
4733
4734        /** Autofill server address (Used in WebView/browser).
4735         * @deprecated moved to Settings.Global
4736         * {@hide} */
4737        public static final String WEB_AUTOFILL_QUERY_URL = Global.WEB_AUTOFILL_QUERY_URL;
4738
4739        /**
4740         * Whether the package manager should send package verification broadcasts for verifiers to
4741         * review apps prior to installation.
4742         *
4743         * 1 = request apps to be verified prior to installation, if a verifier exists.
4744         * 0 = do not verify apps before installation
4745         * {@hide}
4746         */
4747        public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
4748
4749        /** Timeout for package verification. {@hide} */
4750        public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
4751
4752        /** Default response code for package verification. {@hide} */
4753        public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
4754
4755        /** {@hide} */
4756        public static final String
4757                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
4758
4759        /**
4760         * Duration in milliseconds before pre-authorized URIs for the contacts
4761         * provider should expire.
4762         * @hide
4763         */
4764        public static final String CONTACTS_PREAUTH_URI_EXPIRATION =
4765                "contacts_preauth_uri_expiration";
4766
4767        /**
4768         * Prefix for SMS short code regex patterns (country code is appended).
4769         * @see com.android.internal.telephony.SmsUsageMonitor
4770         * @hide
4771         */
4772        public static final String SMS_SHORT_CODES_PREFIX = "sms_short_codes_";
4773
4774        /**
4775         * Overlay display devices setting.
4776         * The associated value is a specially formatted string that describes the
4777         * size and density of simulated secondary display devices.
4778         * <p>
4779         * Format: {width}x{height}/{dpi};...
4780         * </p><p>
4781         * Example:
4782         * <ul>
4783         * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
4784         * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
4785         * at 1080p and the second at 720p.</li>
4786         * <li>If the value is empty, then no overlay display devices are created.</li>
4787         * </ul></p>
4788         *
4789         * @hide
4790         */
4791        public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
4792
4793        /**
4794         * This are the settings to be backed up.
4795         *
4796         * NOTE: Settings are backed up and restored in the order they appear
4797         *       in this array. If you have one setting depending on another,
4798         *       make sure that they are ordered appropriately.
4799         *
4800         * @hide
4801         */
4802        public static final String[] SETTINGS_TO_BACKUP = {
4803            ADB_ENABLED,
4804            BUGREPORT_IN_POWER_MENU,
4805            ALLOW_MOCK_LOCATION,
4806            PARENTAL_CONTROL_ENABLED,
4807            PARENTAL_CONTROL_REDIRECT_URL,
4808            USB_MASS_STORAGE_ENABLED,
4809            ACCESSIBILITY_SCRIPT_INJECTION,
4810            BACKUP_AUTO_RESTORE,
4811            ENABLED_ACCESSIBILITY_SERVICES,
4812            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
4813            TOUCH_EXPLORATION_ENABLED,
4814            ACCESSIBILITY_ENABLED,
4815            ACCESSIBILITY_SPEAK_PASSWORD,
4816            TTS_USE_DEFAULTS,
4817            TTS_DEFAULT_RATE,
4818            TTS_DEFAULT_PITCH,
4819            TTS_DEFAULT_SYNTH,
4820            TTS_DEFAULT_LANG,
4821            TTS_DEFAULT_COUNTRY,
4822            TTS_ENABLED_PLUGINS,
4823            TTS_DEFAULT_LOCALE,
4824            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
4825            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
4826            WIFI_NUM_OPEN_NETWORKS_KEPT,
4827            MOUNT_PLAY_NOTIFICATION_SND,
4828            MOUNT_UMS_AUTOSTART,
4829            MOUNT_UMS_PROMPT,
4830            MOUNT_UMS_NOTIFY_ENABLED,
4831            UI_NIGHT_MODE,
4832            LOCK_SCREEN_OWNER_INFO,
4833            LOCK_SCREEN_OWNER_INFO_ENABLED
4834        };
4835
4836        /**
4837         * Helper method for determining if a location provider is enabled.
4838         * @param cr the content resolver to use
4839         * @param provider the location provider to query
4840         * @return true if the provider is enabled
4841         */
4842        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
4843            String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED);
4844            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
4845        }
4846
4847        /**
4848         * Thread-safe method for enabling or disabling a single location provider.
4849         * @param cr the content resolver to use
4850         * @param provider the location provider to enable or disable
4851         * @param enabled true if the provider should be enabled
4852         */
4853        public static final void setLocationProviderEnabled(ContentResolver cr,
4854                String provider, boolean enabled) {
4855            // to ensure thread safety, we write the provider name with a '+' or '-'
4856            // and let the SettingsProvider handle it rather than reading and modifying
4857            // the list of enabled providers.
4858            if (enabled) {
4859                provider = "+" + provider;
4860            } else {
4861                provider = "-" + provider;
4862            }
4863            putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider);
4864        }
4865    }
4866
4867    /**
4868     * Global system settings, containing preferences that always apply identically
4869     * to all defined users.  Applications can read these but are not allowed to write;
4870     * like the "Secure" settings, these are for preferences that the user must
4871     * explicitly modify through the system UI or specialized APIs for those values.
4872     */
4873    public static final class Global extends NameValueTable {
4874        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_global_version";
4875
4876        /**
4877         * The content:// style URL for global secure settings items.  Not public.
4878         */
4879        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
4880
4881        /**
4882         * Whether Airplane Mode is on.
4883         */
4884        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
4885
4886        /**
4887         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
4888         */
4889        public static final String RADIO_BLUETOOTH = "bluetooth";
4890
4891        /**
4892         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
4893         */
4894        public static final String RADIO_WIFI = "wifi";
4895
4896        /**
4897         * {@hide}
4898         */
4899        public static final String RADIO_WIMAX = "wimax";
4900        /**
4901         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
4902         */
4903        public static final String RADIO_CELL = "cell";
4904
4905        /**
4906         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
4907         */
4908        public static final String RADIO_NFC = "nfc";
4909
4910        /**
4911         * A comma separated list of radios that need to be disabled when airplane mode
4912         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
4913         * included in the comma separated list.
4914         */
4915        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
4916
4917        /**
4918         * A comma separated list of radios that should to be disabled when airplane mode
4919         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
4920         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
4921         * will be turned off when entering airplane mode, but the user will be able to reenable
4922         * Wifi in the Settings app.
4923         *
4924         * {@hide}
4925         */
4926        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
4927
4928        /**
4929         * The policy for deciding when Wi-Fi should go to sleep (which will in
4930         * turn switch to using the mobile data as an Internet connection).
4931         * <p>
4932         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
4933         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
4934         * {@link #WIFI_SLEEP_POLICY_NEVER}.
4935         */
4936        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
4937
4938        /**
4939         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
4940         * policy, which is to sleep shortly after the turning off
4941         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
4942         */
4943        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
4944
4945        /**
4946         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
4947         * the device is on battery, and never go to sleep when the device is
4948         * plugged in.
4949         */
4950        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
4951
4952        /**
4953         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
4954         */
4955        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
4956
4957        /**
4958         * Value to specify if the user prefers the date, time and time zone
4959         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
4960         */
4961        public static final String AUTO_TIME = "auto_time";
4962
4963        /**
4964         * Value to specify if the user prefers the time zone
4965         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
4966         */
4967        public static final String AUTO_TIME_ZONE = "auto_time_zone";
4968
4969        /**
4970         * URI for the car dock "in" event sound.
4971         * @hide
4972         */
4973        public static final String CAR_DOCK_SOUND = "car_dock_sound";
4974
4975        /**
4976         * URI for the car dock "out" event sound.
4977         * @hide
4978         */
4979        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
4980
4981        /**
4982         * URI for the desk dock "in" event sound.
4983         * @hide
4984         */
4985        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
4986
4987        /**
4988         * URI for the desk dock "out" event sound.
4989         * @hide
4990         */
4991        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
4992
4993        /**
4994         * Whether to play a sound for dock events.
4995         * @hide
4996         */
4997        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
4998
4999        /**
5000         * URI for the "device locked" (keyguard shown) sound.
5001         * @hide
5002         */
5003        public static final String LOCK_SOUND = "lock_sound";
5004
5005        /**
5006         * URI for the "device unlocked" sound.
5007         * @hide
5008         */
5009        public static final String UNLOCK_SOUND = "unlock_sound";
5010
5011        /**
5012         * URI for the low battery sound file.
5013         * @hide
5014         */
5015        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
5016
5017        /**
5018         * Whether to play a sound for low-battery alerts.
5019         * @hide
5020         */
5021        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
5022
5023        /**
5024         * Whether we keep the device on while the device is plugged in.
5025         * Supported values are:
5026         * <ul>
5027         * <li>{@code 0} to never stay on while plugged in</li>
5028         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
5029         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
5030         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
5031         * </ul>
5032         * These values can be OR-ed together.
5033         */
5034        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
5035
5036        /**
5037         * Whether ADB is enabled.
5038         */
5039        public static final String ADB_ENABLED = "adb_enabled";
5040
5041        /**
5042         * Whether assisted GPS should be enabled or not.
5043         * @hide
5044         */
5045        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
5046
5047        /**
5048         * Whether bluetooth is enabled/disabled
5049         * 0=disabled. 1=enabled.
5050         */
5051        public static final String BLUETOOTH_ON = "bluetooth_on";
5052
5053        /**
5054         * CDMA Cell Broadcast SMS
5055         *                            0 = CDMA Cell Broadcast SMS disabled
5056         *                            1 = CDMA Cell Broadcast SMS enabled
5057         * @hide
5058         */
5059        public static final String CDMA_CELL_BROADCAST_SMS =
5060                "cdma_cell_broadcast_sms";
5061
5062        /**
5063         * The CDMA roaming mode 0 = Home Networks, CDMA default
5064         *                       1 = Roaming on Affiliated networks
5065         *                       2 = Roaming on any networks
5066         * @hide
5067         */
5068        public static final String CDMA_ROAMING_MODE = "roaming_settings";
5069
5070        /**
5071         * The CDMA subscription mode 0 = RUIM/SIM (default)
5072         *                                1 = NV
5073         * @hide
5074         */
5075        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
5076
5077        /** Inactivity timeout to track mobile data activity.
5078        *
5079        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
5080        * infer the data activity of mobile network. After a period of no activity on mobile
5081        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
5082        * intent is fired to indicate a transition of network status from "active" to "idle". Any
5083        * subsequent activity on mobile networks triggers the firing of {@code
5084        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
5085        *
5086        * Network activity refers to transmitting or receiving data on the network interfaces.
5087        *
5088        * Tracking is disabled if set to zero or negative value.
5089        *
5090        * @hide
5091        */
5092       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
5093
5094       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
5095        * but for Wifi network.
5096        * @hide
5097        */
5098       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
5099
5100       /**
5101        * Whether or not data roaming is enabled. (0 = false, 1 = true)
5102        */
5103       public static final String DATA_ROAMING = "data_roaming";
5104
5105       /**
5106        * Whether user has enabled development settings.
5107        */
5108       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
5109
5110       /**
5111        * Whether the device has been provisioned (0 = false, 1 = true)
5112        */
5113       public static final String DEVICE_PROVISIONED = "device_provisioned";
5114
5115       /**
5116        * The saved value for WindowManagerService.setForcedDisplayDensity().
5117        * One integer in dpi.  If unset, then use the real display density.
5118        * @hide
5119        */
5120       public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
5121
5122       /**
5123        * The saved value for WindowManagerService.setForcedDisplaySize().
5124        * Two integers separated by a comma.  If unset, then use the real display size.
5125        * @hide
5126        */
5127       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
5128
5129       /**
5130        * The maximum size, in bytes, of a download that the download manager will transfer over
5131        * a non-wifi connection.
5132        * @hide
5133        */
5134       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
5135               "download_manager_max_bytes_over_mobile";
5136
5137       /**
5138        * The recommended maximum size, in bytes, of a download that the download manager should
5139        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
5140        * have the option to start the download over the mobile connection anyway.
5141        * @hide
5142        */
5143       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
5144               "download_manager_recommended_max_bytes_over_mobile";
5145
5146       /**
5147        * Whether the package installer should allow installation of apps downloaded from
5148        * sources other than Google Play.
5149        *
5150        * 1 = allow installing from other sources
5151        * 0 = only allow installing from Google Play
5152        */
5153       public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
5154
5155       /**
5156        * Whether mobile data connections are allowed by the user.  See
5157        * ConnectivityManager for more info.
5158        * @hide
5159        */
5160       public static final String MOBILE_DATA = "mobile_data";
5161
5162       /** {@hide} */
5163       public static final String NETSTATS_ENABLED = "netstats_enabled";
5164       /** {@hide} */
5165       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
5166       /** {@hide} */
5167       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
5168       /** {@hide} */
5169       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
5170       /** {@hide} */
5171       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
5172       /** {@hide} */
5173       public static final String NETSTATS_REPORT_XT_OVER_DEV = "netstats_report_xt_over_dev";
5174
5175       /** {@hide} */
5176       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
5177       /** {@hide} */
5178       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
5179       /** {@hide} */
5180       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
5181       /** {@hide} */
5182       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
5183
5184       /** {@hide} */
5185       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
5186       /** {@hide} */
5187       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
5188       /** {@hide} */
5189       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
5190       /** {@hide} */
5191       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
5192
5193       /** {@hide} */
5194       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
5195       /** {@hide} */
5196       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
5197       /** {@hide} */
5198       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
5199       /** {@hide} */
5200       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
5201
5202       /**
5203        * User preference for which network(s) should be used. Only the
5204        * connectivity service should touch this.
5205        */
5206       public static final String NETWORK_PREFERENCE = "network_preference";
5207
5208       /**
5209        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
5210        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
5211        * exceeded.
5212        * @hide
5213        */
5214       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
5215
5216       /**
5217        * The length of time in milli-seconds that automatic small adjustments to
5218        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
5219        * @hide
5220        */
5221       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
5222
5223       /** Preferred NTP server. {@hide} */
5224       public static final String NTP_SERVER = "ntp_server";
5225       /** Timeout in milliseconds to wait for NTP server. {@hide} */
5226       public static final String NTP_TIMEOUT = "ntp_timeout";
5227
5228       /**
5229        * The interval in milliseconds at which to check packet counts on the
5230        * mobile data interface when screen is on, to detect possible data
5231        * connection problems.
5232        * @hide
5233        */
5234       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
5235               "pdp_watchdog_poll_interval_ms";
5236
5237       /**
5238        * The interval in milliseconds at which to check packet counts on the
5239        * mobile data interface when screen is off, to detect possible data
5240        * connection problems.
5241        * @hide
5242        */
5243       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
5244               "pdp_watchdog_long_poll_interval_ms";
5245
5246       /**
5247        * The interval in milliseconds at which to check packet counts on the
5248        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
5249        * outgoing packets has been reached without incoming packets.
5250        * @hide
5251        */
5252       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
5253               "pdp_watchdog_error_poll_interval_ms";
5254
5255       /**
5256        * The number of outgoing packets sent without seeing an incoming packet
5257        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
5258        * device is logged to the event log
5259        * @hide
5260        */
5261       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
5262               "pdp_watchdog_trigger_packet_count";
5263
5264       /**
5265        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
5266        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
5267        * attempting data connection recovery.
5268        * @hide
5269        */
5270       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
5271               "pdp_watchdog_error_poll_count";
5272
5273       /**
5274        * The number of failed PDP reset attempts before moving to something more
5275        * drastic: re-registering to the network.
5276        * @hide
5277        */
5278       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
5279               "pdp_watchdog_max_pdp_reset_fail_count";
5280
5281       /**
5282        * A positive value indicates how often the SamplingProfiler
5283        * should take snapshots. Zero value means SamplingProfiler
5284        * is disabled.
5285        *
5286        * @hide
5287        */
5288       public static final String SAMPLING_PROFILER_MS = "sampling_profiler_ms";
5289
5290       /**
5291        * URL to open browser on to allow user to manage a prepay account
5292        * @hide
5293        */
5294       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
5295               "setup_prepaid_data_service_url";
5296
5297       /**
5298        * URL to attempt a GET on to see if this is a prepay device
5299        * @hide
5300        */
5301       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
5302               "setup_prepaid_detection_target_url";
5303
5304       /**
5305        * Host to check for a redirect to after an attempt to GET
5306        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
5307        * this is a prepaid device with zero balance.)
5308        * @hide
5309        */
5310       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
5311               "setup_prepaid_detection_redir_host";
5312
5313       /**
5314        * Used to disable Tethering on a device - defaults to true
5315        * @hide
5316        */
5317       public static final String TETHER_SUPPORTED = "tether_supported";
5318
5319       /**
5320        * Used to require DUN APN on the device or not - defaults to a build config value
5321        * which defaults to false
5322        * @hide
5323        */
5324       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
5325
5326       /**
5327        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
5328        * corresponding build config values are set it will override the APN DB
5329        * values.
5330        * Consists of a comma seperated list of strings:
5331        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
5332        * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
5333        * @hide
5334        */
5335       public static final String TETHER_DUN_APN = "tether_dun_apn";
5336
5337       /**
5338        * The bandwidth throttle polling freqency in seconds
5339        * @hide
5340        */
5341       public static final String THROTTLE_POLLING_SEC = "throttle_polling_sec";
5342
5343       /**
5344        * The bandwidth throttle threshold (long)
5345        * @hide
5346        */
5347       public static final String THROTTLE_THRESHOLD_BYTES = "throttle_threshold_bytes";
5348
5349       /**
5350        * The bandwidth throttle value (kbps)
5351        * @hide
5352        */
5353       public static final String THROTTLE_VALUE_KBITSPS = "throttle_value_kbitsps";
5354
5355       /**
5356        * The bandwidth throttle reset calendar day (1-28)
5357        * @hide
5358        */
5359       public static final String THROTTLE_RESET_DAY = "throttle_reset_day";
5360
5361       /**
5362        * The throttling notifications we should send
5363        * @hide
5364        */
5365       public static final String THROTTLE_NOTIFICATION_TYPE = "throttle_notification_type";
5366
5367       /**
5368        * Help URI for data throttling policy
5369        * @hide
5370        */
5371       public static final String THROTTLE_HELP_URI = "throttle_help_uri";
5372
5373       /**
5374        * The length of time in Sec that we allow our notion of NTP time
5375        * to be cached before we refresh it
5376        * @hide
5377        */
5378       public static final String THROTTLE_MAX_NTP_CACHE_AGE_SEC =
5379               "throttle_max_ntp_cache_age_sec";
5380
5381       /**
5382        * USB Mass Storage Enabled
5383        */
5384       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
5385
5386       /**
5387        * If this setting is set (to anything), then all references
5388        * to Gmail on the device must change to Google Mail.
5389        */
5390       public static final String USE_GOOGLE_MAIL = "use_google_mail";
5391
5392       /** Autofill server address (Used in WebView/browser).
5393        * {@hide} */
5394       public static final String WEB_AUTOFILL_QUERY_URL =
5395           "web_autofill_query_url";
5396
5397       /**
5398        * Whether to notify the user of open networks.
5399        * <p>
5400        * If not connected and the scan results have an open network, we will
5401        * put this notification up. If we attempt to connect to a network or
5402        * the open network(s) disappear, we remove the notification. When we
5403        * show the notification, we will not show it again for
5404        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
5405        */
5406       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
5407               "wifi_networks_available_notification_on";
5408       /**
5409        * {@hide}
5410        */
5411       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
5412               "wimax_networks_available_notification_on";
5413
5414       /**
5415        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
5416        * Connecting to a network will reset the timer.
5417        */
5418       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
5419               "wifi_networks_available_repeat_delay";
5420
5421       /**
5422        * 802.11 country code in ISO 3166 format
5423        * @hide
5424        */
5425       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
5426
5427       /**
5428        * The interval in milliseconds to issue wake up scans when wifi needs
5429        * to connect. This is necessary to connect to an access point when
5430        * device is on the move and the screen is off.
5431        * @hide
5432        */
5433       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
5434               "wifi_framework_scan_interval_ms";
5435
5436       /**
5437        * The interval in milliseconds after which Wi-Fi is considered idle.
5438        * When idle, it is possible for the device to be switched from Wi-Fi to
5439        * the mobile data network.
5440        * @hide
5441        */
5442       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
5443
5444       /**
5445        * When the number of open networks exceeds this number, the
5446        * least-recently-used excess networks will be removed.
5447        */
5448       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
5449
5450       /**
5451        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
5452        */
5453       public static final String WIFI_ON = "wifi_on";
5454
5455       /**
5456        * Used to save the Wifi_ON state prior to tethering.
5457        * This state will be checked to restore Wifi after
5458        * the user turns off tethering.
5459        *
5460        * @hide
5461        */
5462       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
5463
5464       /**
5465        * The interval in milliseconds to scan as used by the wifi supplicant
5466        * @hide
5467        */
5468       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
5469               "wifi_supplicant_scan_interval_ms";
5470
5471       /**
5472        * Whether the Wi-Fi watchdog is enabled.
5473        */
5474       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
5475
5476       /**
5477        * ms delay interval between rssi polling when the signal is known to be weak
5478        * @hide
5479        */
5480       public static final String WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS =
5481               "wifi_watchdog_rssi_fetch_interval_ms";
5482
5483       /**
5484        * Number of ARP pings per check.
5485        * @hide
5486        */
5487       public static final String WIFI_WATCHDOG_NUM_ARP_PINGS = "wifi_watchdog_num_arp_pings";
5488
5489       /**
5490        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
5491        * the setting needs to be set to 0 to disable it.
5492        * @hide
5493        */
5494       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
5495               "wifi_watchdog_poor_network_test_enabled";
5496
5497       /**
5498        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
5499        * needs to be set to 0 to disable it.
5500        * @hide
5501        */
5502       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
5503               "wifi_suspend_optimizations_enabled";
5504
5505       /**
5506        * The maximum number of times we will retry a connection to an access
5507        * point for which we have failed in acquiring an IP address from DHCP.
5508        * A value of N means that we will make N+1 connection attempts in all.
5509        */
5510       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
5511
5512       /**
5513        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
5514        * data connectivity to be established after a disconnect from Wi-Fi.
5515        */
5516       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
5517           "wifi_mobile_data_transition_wakelock_timeout_ms";
5518
5519       /**
5520        * The operational wifi frequency band
5521        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
5522        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
5523        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
5524        *
5525        * @hide
5526        */
5527       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
5528
5529       /**
5530        * The Wi-Fi peer-to-peer device name
5531        * @hide
5532        */
5533       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
5534
5535       /**
5536        * Nonzero causes Log.wtf() to crash.
5537        * @hide
5538        */
5539       public static final String WTF_IS_FATAL = "wtf_is_fatal";
5540
5541
5542
5543
5544        // Populated lazily, guarded by class object:
5545        private static NameValueCache sNameValueCache = null;
5546
5547        private static void lazyInitCache() {
5548            if (sNameValueCache == null) {
5549                sNameValueCache = new NameValueCache(
5550                        SYS_PROP_SETTING_VERSION,
5551                        CONTENT_URI,
5552                        CALL_METHOD_GET_GLOBAL,
5553                        CALL_METHOD_PUT_GLOBAL);
5554            }
5555        }
5556
5557        /**
5558         * Look up a name in the database.
5559         * @param resolver to access the database with
5560         * @param name to look up in the table
5561         * @return the corresponding value, or null if not present
5562         */
5563        public synchronized static String getString(ContentResolver resolver, String name) {
5564            return getStringForUser(resolver, name, UserHandle.myUserId());
5565        }
5566
5567        /** @hide */
5568        public synchronized static String getStringForUser(ContentResolver resolver, String name,
5569                int userHandle) {
5570            lazyInitCache();
5571            return sNameValueCache.getStringForUser(resolver, name, userHandle);
5572        }
5573
5574        /**
5575         * Store a name/value pair into the database.
5576         * @param resolver to access the database with
5577         * @param name to store
5578         * @param value to associate with the name
5579         * @return true if the value was set, false on database errors
5580         */
5581        public static boolean putString(ContentResolver resolver,
5582                String name, String value) {
5583            return putStringForUser(resolver, name, value, UserHandle.myUserId());
5584        }
5585
5586        /** @hide */
5587        public static boolean putStringForUser(ContentResolver resolver,
5588                String name, String value, int userHandle) {
5589            lazyInitCache();
5590            if (LOCAL_LOGV) {
5591                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
5592                        + " for " + userHandle);
5593            }
5594            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
5595        }
5596
5597        /**
5598         * Construct the content URI for a particular name/value pair,
5599         * useful for monitoring changes with a ContentObserver.
5600         * @param name to look up in the table
5601         * @return the corresponding content URI, or null if not present
5602         */
5603        public static Uri getUriFor(String name) {
5604            return getUriFor(CONTENT_URI, name);
5605        }
5606
5607        /**
5608         * Convenience function for retrieving a single secure settings value
5609         * as an integer.  Note that internally setting values are always
5610         * stored as strings; this function converts the string to an integer
5611         * for you.  The default value will be returned if the setting is
5612         * not defined or not an integer.
5613         *
5614         * @param cr The ContentResolver to access.
5615         * @param name The name of the setting to retrieve.
5616         * @param def Value to return if the setting is not defined.
5617         *
5618         * @return The setting's current value, or 'def' if it is not defined
5619         * or not a valid integer.
5620         */
5621        public static int getInt(ContentResolver cr, String name, int def) {
5622            String v = getString(cr, name);
5623            try {
5624                return v != null ? Integer.parseInt(v) : def;
5625            } catch (NumberFormatException e) {
5626                return def;
5627            }
5628        }
5629
5630        /**
5631         * Convenience function for retrieving a single secure settings value
5632         * as an integer.  Note that internally setting values are always
5633         * stored as strings; this function converts the string to an integer
5634         * for you.
5635         * <p>
5636         * This version does not take a default value.  If the setting has not
5637         * been set, or the string value is not a number,
5638         * it throws {@link SettingNotFoundException}.
5639         *
5640         * @param cr The ContentResolver to access.
5641         * @param name The name of the setting to retrieve.
5642         *
5643         * @throws SettingNotFoundException Thrown if a setting by the given
5644         * name can't be found or the setting value is not an integer.
5645         *
5646         * @return The setting's current value.
5647         */
5648        public static int getInt(ContentResolver cr, String name)
5649                throws SettingNotFoundException {
5650            String v = getString(cr, name);
5651            try {
5652                return Integer.parseInt(v);
5653            } catch (NumberFormatException e) {
5654                throw new SettingNotFoundException(name);
5655            }
5656        }
5657
5658        /**
5659         * Convenience function for updating a single settings value as an
5660         * integer. This will either create a new entry in the table if the
5661         * given name does not exist, or modify the value of the existing row
5662         * with that name.  Note that internally setting values are always
5663         * stored as strings, so this function converts the given value to a
5664         * string before storing it.
5665         *
5666         * @param cr The ContentResolver to access.
5667         * @param name The name of the setting to modify.
5668         * @param value The new value for the setting.
5669         * @return true if the value was set, false on database errors
5670         */
5671        public static boolean putInt(ContentResolver cr, String name, int value) {
5672            return putString(cr, name, Integer.toString(value));
5673        }
5674
5675        /**
5676         * Convenience function for retrieving a single secure settings value
5677         * as a {@code long}.  Note that internally setting values are always
5678         * stored as strings; this function converts the string to a {@code long}
5679         * for you.  The default value will be returned if the setting is
5680         * not defined or not a {@code long}.
5681         *
5682         * @param cr The ContentResolver to access.
5683         * @param name The name of the setting to retrieve.
5684         * @param def Value to return if the setting is not defined.
5685         *
5686         * @return The setting's current value, or 'def' if it is not defined
5687         * or not a valid {@code long}.
5688         */
5689        public static long getLong(ContentResolver cr, String name, long def) {
5690            String valString = getString(cr, name);
5691            long value;
5692            try {
5693                value = valString != null ? Long.parseLong(valString) : def;
5694            } catch (NumberFormatException e) {
5695                value = def;
5696            }
5697            return value;
5698        }
5699
5700        /**
5701         * Convenience function for retrieving a single secure settings value
5702         * as a {@code long}.  Note that internally setting values are always
5703         * stored as strings; this function converts the string to a {@code long}
5704         * for you.
5705         * <p>
5706         * This version does not take a default value.  If the setting has not
5707         * been set, or the string value is not a number,
5708         * it throws {@link SettingNotFoundException}.
5709         *
5710         * @param cr The ContentResolver to access.
5711         * @param name The name of the setting to retrieve.
5712         *
5713         * @return The setting's current value.
5714         * @throws SettingNotFoundException Thrown if a setting by the given
5715         * name can't be found or the setting value is not an integer.
5716         */
5717        public static long getLong(ContentResolver cr, String name)
5718                throws SettingNotFoundException {
5719            String valString = getString(cr, name);
5720            try {
5721                return Long.parseLong(valString);
5722            } catch (NumberFormatException e) {
5723                throw new SettingNotFoundException(name);
5724            }
5725        }
5726
5727        /**
5728         * Convenience function for updating a secure settings value as a long
5729         * integer. This will either create a new entry in the table if the
5730         * given name does not exist, or modify the value of the existing row
5731         * with that name.  Note that internally setting values are always
5732         * stored as strings, so this function converts the given value to a
5733         * string before storing it.
5734         *
5735         * @param cr The ContentResolver to access.
5736         * @param name The name of the setting to modify.
5737         * @param value The new value for the setting.
5738         * @return true if the value was set, false on database errors
5739         */
5740        public static boolean putLong(ContentResolver cr, String name, long value) {
5741            return putString(cr, name, Long.toString(value));
5742        }
5743
5744        /**
5745         * Convenience function for retrieving a single secure settings value
5746         * as a floating point number.  Note that internally setting values are
5747         * always stored as strings; this function converts the string to an
5748         * float for you. The default value will be returned if the setting
5749         * is not defined or not a valid float.
5750         *
5751         * @param cr The ContentResolver to access.
5752         * @param name The name of the setting to retrieve.
5753         * @param def Value to return if the setting is not defined.
5754         *
5755         * @return The setting's current value, or 'def' if it is not defined
5756         * or not a valid float.
5757         */
5758        public static float getFloat(ContentResolver cr, String name, float def) {
5759            String v = getString(cr, name);
5760            try {
5761                return v != null ? Float.parseFloat(v) : def;
5762            } catch (NumberFormatException e) {
5763                return def;
5764            }
5765        }
5766
5767        /**
5768         * Convenience function for retrieving a single secure settings value
5769         * as a float.  Note that internally setting values are always
5770         * stored as strings; this function converts the string to a float
5771         * for you.
5772         * <p>
5773         * This version does not take a default value.  If the setting has not
5774         * been set, or the string value is not a number,
5775         * it throws {@link SettingNotFoundException}.
5776         *
5777         * @param cr The ContentResolver to access.
5778         * @param name The name of the setting to retrieve.
5779         *
5780         * @throws SettingNotFoundException Thrown if a setting by the given
5781         * name can't be found or the setting value is not a float.
5782         *
5783         * @return The setting's current value.
5784         */
5785        public static float getFloat(ContentResolver cr, String name)
5786                throws SettingNotFoundException {
5787            String v = getString(cr, name);
5788            if (v == null) {
5789                throw new SettingNotFoundException(name);
5790            }
5791            try {
5792                return Float.parseFloat(v);
5793            } catch (NumberFormatException e) {
5794                throw new SettingNotFoundException(name);
5795            }
5796        }
5797
5798        /**
5799         * Convenience function for updating a single settings value as a
5800         * floating point number. This will either create a new entry in the
5801         * table if the given name does not exist, or modify the value of the
5802         * existing row with that name.  Note that internally setting values
5803         * are always stored as strings, so this function converts the given
5804         * value to a string before storing it.
5805         *
5806         * @param cr The ContentResolver to access.
5807         * @param name The name of the setting to modify.
5808         * @param value The new value for the setting.
5809         * @return true if the value was set, false on database errors
5810         */
5811        public static boolean putFloat(ContentResolver cr, String name, float value) {
5812            return putString(cr, name, Float.toString(value));
5813        }
5814    }
5815
5816    /**
5817     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
5818     * Intent URL, allowing it to be either a web page or a particular
5819     * application activity.
5820     *
5821     * @hide
5822     */
5823    public static final class Bookmarks implements BaseColumns
5824    {
5825        private static final String TAG = "Bookmarks";
5826
5827        /**
5828         * The content:// style URL for this table
5829         */
5830        public static final Uri CONTENT_URI =
5831            Uri.parse("content://" + AUTHORITY + "/bookmarks");
5832
5833        /**
5834         * The row ID.
5835         * <p>Type: INTEGER</p>
5836         */
5837        public static final String ID = "_id";
5838
5839        /**
5840         * Descriptive name of the bookmark that can be displayed to the user.
5841         * If this is empty, the title should be resolved at display time (use
5842         * {@link #getTitle(Context, Cursor)} any time you want to display the
5843         * title of a bookmark.)
5844         * <P>
5845         * Type: TEXT
5846         * </P>
5847         */
5848        public static final String TITLE = "title";
5849
5850        /**
5851         * Arbitrary string (displayed to the user) that allows bookmarks to be
5852         * organized into categories.  There are some special names for
5853         * standard folders, which all start with '@'.  The label displayed for
5854         * the folder changes with the locale (via {@link #getLabelForFolder}) but
5855         * the folder name does not change so you can consistently query for
5856         * the folder regardless of the current locale.
5857         *
5858         * <P>Type: TEXT</P>
5859         *
5860         */
5861        public static final String FOLDER = "folder";
5862
5863        /**
5864         * The Intent URL of the bookmark, describing what it points to.  This
5865         * value is given to {@link android.content.Intent#getIntent} to create
5866         * an Intent that can be launched.
5867         * <P>Type: TEXT</P>
5868         */
5869        public static final String INTENT = "intent";
5870
5871        /**
5872         * Optional shortcut character associated with this bookmark.
5873         * <P>Type: INTEGER</P>
5874         */
5875        public static final String SHORTCUT = "shortcut";
5876
5877        /**
5878         * The order in which the bookmark should be displayed
5879         * <P>Type: INTEGER</P>
5880         */
5881        public static final String ORDERING = "ordering";
5882
5883        private static final String[] sIntentProjection = { INTENT };
5884        private static final String[] sShortcutProjection = { ID, SHORTCUT };
5885        private static final String sShortcutSelection = SHORTCUT + "=?";
5886
5887        /**
5888         * Convenience function to retrieve the bookmarked Intent for a
5889         * particular shortcut key.
5890         *
5891         * @param cr The ContentResolver to query.
5892         * @param shortcut The shortcut key.
5893         *
5894         * @return Intent The bookmarked URL, or null if there is no bookmark
5895         *         matching the given shortcut.
5896         */
5897        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
5898        {
5899            Intent intent = null;
5900
5901            Cursor c = cr.query(CONTENT_URI,
5902                    sIntentProjection, sShortcutSelection,
5903                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
5904            // Keep trying until we find a valid shortcut
5905            try {
5906                while (intent == null && c.moveToNext()) {
5907                    try {
5908                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
5909                        intent = Intent.parseUri(intentURI, 0);
5910                    } catch (java.net.URISyntaxException e) {
5911                        // The stored URL is bad...  ignore it.
5912                    } catch (IllegalArgumentException e) {
5913                        // Column not found
5914                        Log.w(TAG, "Intent column not found", e);
5915                    }
5916                }
5917            } finally {
5918                if (c != null) c.close();
5919            }
5920
5921            return intent;
5922        }
5923
5924        /**
5925         * Add a new bookmark to the system.
5926         *
5927         * @param cr The ContentResolver to query.
5928         * @param intent The desired target of the bookmark.
5929         * @param title Bookmark title that is shown to the user; null if none
5930         *            or it should be resolved to the intent's title.
5931         * @param folder Folder in which to place the bookmark; null if none.
5932         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
5933         *            this is non-zero and there is an existing bookmark entry
5934         *            with this same shortcut, then that existing shortcut is
5935         *            cleared (the bookmark is not removed).
5936         * @return The unique content URL for the new bookmark entry.
5937         */
5938        public static Uri add(ContentResolver cr,
5939                                           Intent intent,
5940                                           String title,
5941                                           String folder,
5942                                           char shortcut,
5943                                           int ordering)
5944        {
5945            // If a shortcut is supplied, and it is already defined for
5946            // another bookmark, then remove the old definition.
5947            if (shortcut != 0) {
5948                cr.delete(CONTENT_URI, sShortcutSelection,
5949                        new String[] { String.valueOf((int) shortcut) });
5950            }
5951
5952            ContentValues values = new ContentValues();
5953            if (title != null) values.put(TITLE, title);
5954            if (folder != null) values.put(FOLDER, folder);
5955            values.put(INTENT, intent.toUri(0));
5956            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
5957            values.put(ORDERING, ordering);
5958            return cr.insert(CONTENT_URI, values);
5959        }
5960
5961        /**
5962         * Return the folder name as it should be displayed to the user.  This
5963         * takes care of localizing special folders.
5964         *
5965         * @param r Resources object for current locale; only need access to
5966         *          system resources.
5967         * @param folder The value found in the {@link #FOLDER} column.
5968         *
5969         * @return CharSequence The label for this folder that should be shown
5970         *         to the user.
5971         */
5972        public static CharSequence getLabelForFolder(Resources r, String folder) {
5973            return folder;
5974        }
5975
5976        /**
5977         * Return the title as it should be displayed to the user. This takes
5978         * care of localizing bookmarks that point to activities.
5979         *
5980         * @param context A context.
5981         * @param cursor A cursor pointing to the row whose title should be
5982         *        returned. The cursor must contain at least the {@link #TITLE}
5983         *        and {@link #INTENT} columns.
5984         * @return A title that is localized and can be displayed to the user,
5985         *         or the empty string if one could not be found.
5986         */
5987        public static CharSequence getTitle(Context context, Cursor cursor) {
5988            int titleColumn = cursor.getColumnIndex(TITLE);
5989            int intentColumn = cursor.getColumnIndex(INTENT);
5990            if (titleColumn == -1 || intentColumn == -1) {
5991                throw new IllegalArgumentException(
5992                        "The cursor must contain the TITLE and INTENT columns.");
5993            }
5994
5995            String title = cursor.getString(titleColumn);
5996            if (!TextUtils.isEmpty(title)) {
5997                return title;
5998            }
5999
6000            String intentUri = cursor.getString(intentColumn);
6001            if (TextUtils.isEmpty(intentUri)) {
6002                return "";
6003            }
6004
6005            Intent intent;
6006            try {
6007                intent = Intent.parseUri(intentUri, 0);
6008            } catch (URISyntaxException e) {
6009                return "";
6010            }
6011
6012            PackageManager packageManager = context.getPackageManager();
6013            ResolveInfo info = packageManager.resolveActivity(intent, 0);
6014            return info != null ? info.loadLabel(packageManager) : "";
6015        }
6016    }
6017
6018    /**
6019     * Returns the device ID that we should use when connecting to the mobile gtalk server.
6020     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
6021     * from the GoogleLoginService.
6022     *
6023     * @param androidId The Android ID for this device.
6024     * @return The device ID that should be used when connecting to the mobile gtalk server.
6025     * @hide
6026     */
6027    public static String getGTalkDeviceId(long androidId) {
6028        return "android-" + Long.toHexString(androidId);
6029    }
6030}
6031