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