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