Settings.java revision b3006d38c6fdb964d9101f38e596e01de3591e56
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.annotation.SystemApi;
22import android.app.SearchManager;
23import android.app.WallpaperManager;
24import android.content.ComponentName;
25import android.content.ContentResolver;
26import android.content.ContentValues;
27import android.content.Context;
28import android.content.IContentProvider;
29import android.content.Intent;
30import android.content.pm.ActivityInfo;
31import android.content.pm.PackageManager;
32import android.content.pm.ResolveInfo;
33import android.content.res.Configuration;
34import android.content.res.Resources;
35import android.database.Cursor;
36import android.database.SQLException;
37import android.location.LocationManager;
38import android.net.ConnectivityManager;
39import android.net.Uri;
40import android.net.wifi.WifiManager;
41import android.os.BatteryManager;
42import android.os.Bundle;
43import android.os.DropBoxManager;
44import android.os.IBinder;
45import android.os.Process;
46import android.os.RemoteException;
47import android.os.ServiceManager;
48import android.os.SystemProperties;
49import android.os.UserHandle;
50import android.os.Build.VERSION_CODES;
51import android.speech.tts.TextToSpeech;
52import android.text.TextUtils;
53import android.util.AndroidException;
54import android.util.ArrayMap;
55import android.util.ArraySet;
56import android.util.Log;
57
58import com.android.internal.util.ArrayUtils;
59import com.android.internal.widget.ILockSettings;
60
61import java.net.URISyntaxException;
62import java.text.SimpleDateFormat;
63import java.util.HashMap;
64import java.util.HashSet;
65import java.util.Locale;
66import java.util.Map;
67import java.util.Set;
68
69/**
70 * The Settings provider contains global system-level device preferences.
71 */
72public final class Settings {
73
74    // Intent actions for Settings
75
76    /**
77     * Activity Action: Show system settings.
78     * <p>
79     * Input: Nothing.
80     * <p>
81     * Output: Nothing.
82     */
83    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
84    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
85
86    /**
87     * Activity Action: Show settings to allow configuration of APNs.
88     * <p>
89     * Input: Nothing.
90     * <p>
91     * Output: Nothing.
92     */
93    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
94    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
95
96    /**
97     * Activity Action: Show settings to allow configuration of current location
98     * sources.
99     * <p>
100     * In some cases, a matching Activity may not exist, so ensure you
101     * safeguard against this.
102     * <p>
103     * Input: Nothing.
104     * <p>
105     * Output: Nothing.
106     */
107    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
108    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
109            "android.settings.LOCATION_SOURCE_SETTINGS";
110
111    /**
112     * Activity Action: Show settings to allow configuration of wireless controls
113     * such as Wi-Fi, Bluetooth and Mobile networks.
114     * <p>
115     * In some cases, a matching Activity may not exist, so ensure you
116     * safeguard against this.
117     * <p>
118     * Input: Nothing.
119     * <p>
120     * Output: Nothing.
121     */
122    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
123    public static final String ACTION_WIRELESS_SETTINGS =
124            "android.settings.WIRELESS_SETTINGS";
125
126    /**
127     * Activity Action: Show settings to allow entering/exiting airplane mode.
128     * <p>
129     * In some cases, a matching Activity may not exist, so ensure you
130     * safeguard against this.
131     * <p>
132     * Input: Nothing.
133     * <p>
134     * Output: Nothing.
135     */
136    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
137    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
138            "android.settings.AIRPLANE_MODE_SETTINGS";
139
140    /**
141     * Activity Action: Modify Airplane mode settings using a voice command.
142     * <p>
143     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
144     * <p>
145     * This intent MUST be started using
146     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
147     * startVoiceActivity}.
148     * <p>
149     * Note: The activity implementing this intent MUST verify that
150     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
151     * modifying the setting.
152     * <p>
153     * Input: To tell which state airplane mode should be set to, add the
154     * {@link #EXTRA_AIRPLANE_MODE_ENABLED} extra to this Intent with the state specified.
155     * If the extra is not included, no changes will be made.
156     * <p>
157     * Output: Nothing.
158     */
159    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
160    public static final String ACTION_VOICE_CONTROL_AIRPLANE_MODE =
161            "android.settings.VOICE_CONTROL_AIRPLANE_MODE";
162
163    /**
164     * Activity Action: Show settings for accessibility modules.
165     * <p>
166     * In some cases, a matching Activity may not exist, so ensure you
167     * safeguard against this.
168     * <p>
169     * Input: Nothing.
170     * <p>
171     * Output: Nothing.
172     */
173    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
174    public static final String ACTION_ACCESSIBILITY_SETTINGS =
175            "android.settings.ACCESSIBILITY_SETTINGS";
176
177    /**
178     * Activity Action: Show settings to control access to usage information.
179     * <p>
180     * In some cases, a matching Activity may not exist, so ensure you
181     * safeguard against this.
182     * <p>
183     * Input: Nothing.
184     * <p>
185     * Output: Nothing.
186     */
187    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
188    public static final String ACTION_USAGE_ACCESS_SETTINGS =
189            "android.settings.USAGE_ACCESS_SETTINGS";
190
191    /**
192     * Activity Action: Show settings to allow configuration of security and
193     * location privacy.
194     * <p>
195     * In some cases, a matching Activity may not exist, so ensure you
196     * safeguard against this.
197     * <p>
198     * Input: Nothing.
199     * <p>
200     * Output: Nothing.
201     */
202    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
203    public static final String ACTION_SECURITY_SETTINGS =
204            "android.settings.SECURITY_SETTINGS";
205
206    /**
207     * Activity Action: Show trusted credentials settings, opening to the user tab,
208     * to allow management of installed credentials.
209     * <p>
210     * In some cases, a matching Activity may not exist, so ensure you
211     * safeguard against this.
212     * <p>
213     * Input: Nothing.
214     * <p>
215     * Output: Nothing.
216     * @hide
217     */
218    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
219    public static final String ACTION_TRUSTED_CREDENTIALS_USER =
220            "com.android.settings.TRUSTED_CREDENTIALS_USER";
221
222    /**
223     * Activity Action: Show dialog explaining that an installed CA cert may enable
224     * monitoring of encrypted network traffic.
225     * <p>
226     * In some cases, a matching Activity may not exist, so ensure you
227     * safeguard against this.
228     * <p>
229     * Input: Nothing.
230     * <p>
231     * Output: Nothing.
232     * @hide
233     */
234    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
235    public static final String ACTION_MONITORING_CERT_INFO =
236            "com.android.settings.MONITORING_CERT_INFO";
237
238    /**
239     * Activity Action: Show settings to allow configuration of privacy options.
240     * <p>
241     * In some cases, a matching Activity may not exist, so ensure you
242     * safeguard against this.
243     * <p>
244     * Input: Nothing.
245     * <p>
246     * Output: Nothing.
247     */
248    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
249    public static final String ACTION_PRIVACY_SETTINGS =
250            "android.settings.PRIVACY_SETTINGS";
251
252    /**
253     * Activity Action: Show settings to allow configuration of Wi-Fi.
254     * <p>
255     * In some cases, a matching Activity may not exist, so ensure you
256     * safeguard against this.
257     * <p>
258     * Input: Nothing.
259     * <p>
260     * Output: Nothing.
261
262     */
263    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
264    public static final String ACTION_WIFI_SETTINGS =
265            "android.settings.WIFI_SETTINGS";
266
267    /**
268     * Activity Action: Show settings to allow configuration of a static IP
269     * address for Wi-Fi.
270     * <p>
271     * In some cases, a matching Activity may not exist, so ensure you safeguard
272     * against this.
273     * <p>
274     * Input: Nothing.
275     * <p>
276     * Output: Nothing.
277     */
278    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
279    public static final String ACTION_WIFI_IP_SETTINGS =
280            "android.settings.WIFI_IP_SETTINGS";
281
282    /**
283     * Activity Action: Show settings to allow configuration of Bluetooth.
284     * <p>
285     * In some cases, a matching Activity may not exist, so ensure you
286     * safeguard against this.
287     * <p>
288     * Input: Nothing.
289     * <p>
290     * Output: Nothing.
291     */
292    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
293    public static final String ACTION_BLUETOOTH_SETTINGS =
294            "android.settings.BLUETOOTH_SETTINGS";
295
296    /**
297     * Activity Action: Show settings to allow configuration of Wifi Displays.
298     * <p>
299     * In some cases, a matching Activity may not exist, so ensure you
300     * safeguard against this.
301     * <p>
302     * Input: Nothing.
303     * <p>
304     * Output: Nothing.
305     * @hide
306     */
307    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
308    public static final String ACTION_WIFI_DISPLAY_SETTINGS =
309            "android.settings.WIFI_DISPLAY_SETTINGS";
310
311    /**
312     * Activity Action: Show settings to allow configuration of
313     * {@link android.media.routing.MediaRouteService media route providers}.
314     * <p>
315     * In some cases, a matching Activity may not exist, so ensure you
316     * safeguard against this.
317     * <p>
318     * Input: Nothing.
319     * <p>
320     * Output: Nothing.
321     */
322    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
323    public static final String ACTION_CAST_SETTINGS =
324            "android.settings.CAST_SETTINGS";
325
326    /**
327     * Activity Action: Show settings to allow configuration of date and time.
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     */
336    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
337    public static final String ACTION_DATE_SETTINGS =
338            "android.settings.DATE_SETTINGS";
339
340    /**
341     * Activity Action: Show settings to allow configuration of sound and volume.
342     * <p>
343     * In some cases, a matching Activity may not exist, so ensure you
344     * safeguard against this.
345     * <p>
346     * Input: Nothing.
347     * <p>
348     * Output: Nothing.
349     */
350    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
351    public static final String ACTION_SOUND_SETTINGS =
352            "android.settings.SOUND_SETTINGS";
353
354    /**
355     * Activity Action: Show settings to allow configuration of display.
356     * <p>
357     * In some cases, a matching Activity may not exist, so ensure you
358     * safeguard against this.
359     * <p>
360     * Input: Nothing.
361     * <p>
362     * Output: Nothing.
363     */
364    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
365    public static final String ACTION_DISPLAY_SETTINGS =
366            "android.settings.DISPLAY_SETTINGS";
367
368    /**
369     * Activity Action: Show settings to allow configuration of locale.
370     * <p>
371     * In some cases, a matching Activity may not exist, so ensure you
372     * safeguard against this.
373     * <p>
374     * Input: Nothing.
375     * <p>
376     * Output: Nothing.
377     */
378    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
379    public static final String ACTION_LOCALE_SETTINGS =
380            "android.settings.LOCALE_SETTINGS";
381
382    /**
383     * Activity Action: Show settings to configure input methods, in particular
384     * allowing the user to enable input methods.
385     * <p>
386     * In some cases, a matching Activity may not exist, so ensure you
387     * safeguard against this.
388     * <p>
389     * Input: Nothing.
390     * <p>
391     * Output: Nothing.
392     */
393    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
394    public static final String ACTION_VOICE_INPUT_SETTINGS =
395            "android.settings.VOICE_INPUT_SETTINGS";
396
397    /**
398     * Activity Action: Show settings to configure input methods, in particular
399     * allowing the user to enable input methods.
400     * <p>
401     * In some cases, a matching Activity may not exist, so ensure you
402     * safeguard against this.
403     * <p>
404     * Input: Nothing.
405     * <p>
406     * Output: Nothing.
407     */
408    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
409    public static final String ACTION_INPUT_METHOD_SETTINGS =
410            "android.settings.INPUT_METHOD_SETTINGS";
411
412    /**
413     * Activity Action: Show settings to enable/disable input method subtypes.
414     * <p>
415     * In some cases, a matching Activity may not exist, so ensure you
416     * safeguard against this.
417     * <p>
418     * To tell which input method's subtypes are displayed in the settings, add
419     * {@link #EXTRA_INPUT_METHOD_ID} extra to this Intent with the input method id.
420     * If there is no extra in this Intent, subtypes from all installed input methods
421     * will be displayed in the settings.
422     *
423     * @see android.view.inputmethod.InputMethodInfo#getId
424     * <p>
425     * Input: Nothing.
426     * <p>
427     * Output: Nothing.
428     */
429    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
430    public static final String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
431            "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
432
433    /**
434     * Activity Action: Show a dialog to select input method.
435     * <p>
436     * In some cases, a matching Activity may not exist, so ensure you
437     * safeguard against this.
438     * <p>
439     * Input: Nothing.
440     * <p>
441     * Output: Nothing.
442     * @hide
443     */
444    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
445    public static final String ACTION_SHOW_INPUT_METHOD_PICKER =
446            "android.settings.SHOW_INPUT_METHOD_PICKER";
447
448    /**
449     * Activity Action: Show settings to manage the user input dictionary.
450     * <p>
451     * Starting with {@link android.os.Build.VERSION_CODES#KITKAT},
452     * it is guaranteed there will always be an appropriate implementation for this Intent action.
453     * In prior releases of the platform this was optional, so ensure you safeguard against it.
454     * <p>
455     * Input: Nothing.
456     * <p>
457     * Output: Nothing.
458     */
459    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
460    public static final String ACTION_USER_DICTIONARY_SETTINGS =
461            "android.settings.USER_DICTIONARY_SETTINGS";
462
463    /**
464     * Activity Action: Adds a word to the user dictionary.
465     * <p>
466     * In some cases, a matching Activity may not exist, so ensure you
467     * safeguard against this.
468     * <p>
469     * Input: An extra with key <code>word</code> that contains the word
470     * that should be added to the dictionary.
471     * <p>
472     * Output: Nothing.
473     *
474     * @hide
475     */
476    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
477    public static final String ACTION_USER_DICTIONARY_INSERT =
478            "com.android.settings.USER_DICTIONARY_INSERT";
479
480    /**
481     * Activity Action: Show settings to allow configuration of application-related settings.
482     * <p>
483     * In some cases, a matching Activity may not exist, so ensure you
484     * safeguard against this.
485     * <p>
486     * Input: Nothing.
487     * <p>
488     * Output: Nothing.
489     */
490    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
491    public static final String ACTION_APPLICATION_SETTINGS =
492            "android.settings.APPLICATION_SETTINGS";
493
494    /**
495     * Activity Action: Show settings to allow configuration of application
496     * development-related settings.  As of
497     * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} this action is
498     * a required part of the platform.
499     * <p>
500     * Input: Nothing.
501     * <p>
502     * Output: Nothing.
503     */
504    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
505    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
506            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
507
508    /**
509     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
510     * <p>
511     * In some cases, a matching Activity may not exist, so ensure you
512     * safeguard against this.
513     * <p>
514     * Input: Nothing.
515     * <p>
516     * Output: Nothing.
517     */
518    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
519    public static final String ACTION_QUICK_LAUNCH_SETTINGS =
520            "android.settings.QUICK_LAUNCH_SETTINGS";
521
522    /**
523     * Activity Action: Show settings to manage installed applications.
524     * <p>
525     * In some cases, a matching Activity may not exist, so ensure you
526     * safeguard against this.
527     * <p>
528     * Input: Nothing.
529     * <p>
530     * Output: Nothing.
531     */
532    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
533    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
534            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
535
536    /**
537     * Activity Action: Show settings to manage all applications.
538     * <p>
539     * In some cases, a matching Activity may not exist, so ensure you
540     * safeguard against this.
541     * <p>
542     * Input: Nothing.
543     * <p>
544     * Output: Nothing.
545     */
546    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
547    public static final String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
548            "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS";
549
550    /**
551     * Activity Action: Show screen of details about a particular application.
552     * <p>
553     * In some cases, a matching Activity may not exist, so ensure you
554     * safeguard against this.
555     * <p>
556     * Input: The Intent's data URI specifies the application package name
557     * to be shown, with the "package" scheme.  That is "package:com.my.app".
558     * <p>
559     * Output: Nothing.
560     */
561    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
562    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
563            "android.settings.APPLICATION_DETAILS_SETTINGS";
564
565    /**
566     * @hide
567     * Activity Action: Show the "app ops" settings screen.
568     * <p>
569     * Input: Nothing.
570     * <p>
571     * Output: Nothing.
572     */
573    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
574    public static final String ACTION_APP_OPS_SETTINGS =
575            "android.settings.APP_OPS_SETTINGS";
576
577    /**
578     * Activity Action: Show settings for system update functionality.
579     * <p>
580     * In some cases, a matching Activity may not exist, so ensure you
581     * safeguard against this.
582     * <p>
583     * Input: Nothing.
584     * <p>
585     * Output: Nothing.
586     *
587     * @hide
588     */
589    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
590    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
591            "android.settings.SYSTEM_UPDATE_SETTINGS";
592
593    /**
594     * Activity Action: Show settings to allow configuration of sync settings.
595     * <p>
596     * In some cases, a matching Activity may not exist, so ensure you
597     * safeguard against this.
598     * <p>
599     * The account types available to add via the add account button may be restricted by adding an
600     * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's
601     * authorities. Only account types which can sync with that content provider will be offered to
602     * the user.
603     * <p>
604     * Input: Nothing.
605     * <p>
606     * Output: Nothing.
607     */
608    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
609    public static final String ACTION_SYNC_SETTINGS =
610            "android.settings.SYNC_SETTINGS";
611
612    /**
613     * Activity Action: Show add account screen for creating a new account.
614     * <p>
615     * In some cases, a matching Activity may not exist, so ensure you
616     * safeguard against this.
617     * <p>
618     * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES}
619     * extra to the Intent with one or more syncable content provider's authorities.  Only account
620     * types which can sync with that content provider will be offered to the user.
621     * <p>
622     * Account types can also be filtered by adding an {@link #EXTRA_ACCOUNT_TYPES} extra to the
623     * Intent with one or more account types.
624     * <p>
625     * Input: Nothing.
626     * <p>
627     * Output: Nothing.
628     */
629    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
630    public static final String ACTION_ADD_ACCOUNT =
631            "android.settings.ADD_ACCOUNT_SETTINGS";
632
633    /**
634     * Activity Action: Show settings for selecting the network operator.
635     * <p>
636     * In some cases, a matching Activity may not exist, so ensure you
637     * safeguard against this.
638     * <p>
639     * Input: Nothing.
640     * <p>
641     * Output: Nothing.
642     */
643    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
645            "android.settings.NETWORK_OPERATOR_SETTINGS";
646
647    /**
648     * Activity Action: Show settings for selection of 2G/3G.
649     * <p>
650     * In some cases, a matching Activity may not exist, so ensure you
651     * safeguard against this.
652     * <p>
653     * Input: Nothing.
654     * <p>
655     * Output: Nothing.
656     */
657    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
658    public static final String ACTION_DATA_ROAMING_SETTINGS =
659            "android.settings.DATA_ROAMING_SETTINGS";
660
661    /**
662     * Activity Action: Show settings for internal storage.
663     * <p>
664     * In some cases, a matching Activity may not exist, so ensure you
665     * safeguard against this.
666     * <p>
667     * Input: Nothing.
668     * <p>
669     * Output: Nothing.
670     */
671    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
672    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
673            "android.settings.INTERNAL_STORAGE_SETTINGS";
674    /**
675     * Activity Action: Show settings for memory card storage.
676     * <p>
677     * In some cases, a matching Activity may not exist, so ensure you
678     * safeguard against this.
679     * <p>
680     * Input: Nothing.
681     * <p>
682     * Output: Nothing.
683     */
684    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
685    public static final String ACTION_MEMORY_CARD_SETTINGS =
686            "android.settings.MEMORY_CARD_SETTINGS";
687
688    /**
689     * Activity Action: Show settings for global search.
690     * <p>
691     * In some cases, a matching Activity may not exist, so ensure you
692     * safeguard against this.
693     * <p>
694     * Input: Nothing.
695     * <p>
696     * Output: Nothing
697     */
698    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
699    public static final String ACTION_SEARCH_SETTINGS =
700        "android.search.action.SEARCH_SETTINGS";
701
702    /**
703     * Activity Action: Show general device information settings (serial
704     * number, software version, phone number, etc.).
705     * <p>
706     * In some cases, a matching Activity may not exist, so ensure you
707     * safeguard against this.
708     * <p>
709     * Input: Nothing.
710     * <p>
711     * Output: Nothing
712     */
713    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714    public static final String ACTION_DEVICE_INFO_SETTINGS =
715        "android.settings.DEVICE_INFO_SETTINGS";
716
717    /**
718     * Activity Action: Show NFC settings.
719     * <p>
720     * This shows UI that allows NFC to be turned on or off.
721     * <p>
722     * In some cases, a matching Activity may not exist, so ensure you
723     * safeguard against this.
724     * <p>
725     * Input: Nothing.
726     * <p>
727     * Output: Nothing
728     * @see android.nfc.NfcAdapter#isEnabled()
729     */
730    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
731    public static final String ACTION_NFC_SETTINGS = "android.settings.NFC_SETTINGS";
732
733    /**
734     * Activity Action: Show NFC Sharing settings.
735     * <p>
736     * This shows UI that allows NDEF Push (Android Beam) to be turned on or
737     * off.
738     * <p>
739     * In some cases, a matching Activity may not exist, so ensure you
740     * safeguard against this.
741     * <p>
742     * Input: Nothing.
743     * <p>
744     * Output: Nothing
745     * @see android.nfc.NfcAdapter#isNdefPushEnabled()
746     */
747    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
748    public static final String ACTION_NFCSHARING_SETTINGS =
749        "android.settings.NFCSHARING_SETTINGS";
750
751    /**
752     * Activity Action: Show NFC Tap & Pay settings
753     * <p>
754     * This shows UI that allows the user to configure Tap&Pay
755     * settings.
756     * <p>
757     * In some cases, a matching Activity may not exist, so ensure you
758     * safeguard against this.
759     * <p>
760     * Input: Nothing.
761     * <p>
762     * Output: Nothing
763     */
764    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
765    public static final String ACTION_NFC_PAYMENT_SETTINGS =
766        "android.settings.NFC_PAYMENT_SETTINGS";
767
768    /**
769     * Activity Action: Show Daydream settings.
770     * <p>
771     * In some cases, a matching Activity may not exist, so ensure you
772     * safeguard against this.
773     * <p>
774     * Input: Nothing.
775     * <p>
776     * Output: Nothing.
777     * @see android.service.dreams.DreamService
778     */
779    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
780    public static final String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
781
782    /**
783     * Activity Action: Show Notification listener settings.
784     * <p>
785     * In some cases, a matching Activity may not exist, so ensure you
786     * safeguard against this.
787     * <p>
788     * Input: Nothing.
789     * <p>
790     * Output: Nothing.
791     * @see android.service.notification.NotificationListenerService
792     */
793    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
794    public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS
795            = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
796
797    /**
798     * @hide
799     */
800    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
801    public static final String ACTION_CONDITION_PROVIDER_SETTINGS
802            = "android.settings.ACTION_CONDITION_PROVIDER_SETTINGS";
803
804    /**
805     * Activity Action: Show settings for video captioning.
806     * <p>
807     * In some cases, a matching Activity may not exist, so ensure you safeguard
808     * against this.
809     * <p>
810     * Input: Nothing.
811     * <p>
812     * Output: Nothing.
813     */
814    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
815    public static final String ACTION_CAPTIONING_SETTINGS = "android.settings.CAPTIONING_SETTINGS";
816
817    /**
818     * Activity Action: Show the top level print settings.
819     * <p>
820     * In some cases, a matching Activity may not exist, so ensure you
821     * safeguard against this.
822     * <p>
823     * Input: Nothing.
824     * <p>
825     * Output: Nothing.
826     */
827    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
828    public static final String ACTION_PRINT_SETTINGS =
829            "android.settings.ACTION_PRINT_SETTINGS";
830
831    /**
832     * Activity Action: Show Zen Mode configuration settings.
833     *
834     * @hide
835     */
836    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
837    public static final String ACTION_ZEN_MODE_SETTINGS = "android.settings.ZEN_MODE_SETTINGS";
838
839    /**
840     * Activity Action: Show Zen Mode priority configuration settings.
841     *
842     * @hide
843     */
844    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
845    public static final String ACTION_ZEN_MODE_PRIORITY_SETTINGS
846            = "android.settings.ZEN_MODE_PRIORITY_SETTINGS";
847
848    /**
849     * Activity Action: Show Zen Mode automation configuration settings.
850     *
851     * @hide
852     */
853    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
854    public static final String ACTION_ZEN_MODE_AUTOMATION_SETTINGS
855            = "android.settings.ZEN_MODE_AUTOMATION_SETTINGS";
856
857    /**
858     * Activity Action: Modify do not disturb mode settings.
859     * <p>
860     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
861     * <p>
862     * This intent MUST be started using
863     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
864     * startVoiceActivity}.
865     * <p>
866     * Note: The Activity implementing this intent MUST verify that
867     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction}.
868     * returns true before modifying the setting.
869     * <p>
870     * Input: The optional {@link #EXTRA_DO_NOT_DISTURB_MODE_MINUTES} extra can be used to indicate
871     * how long the user wishes to avoid interruptions for. The optional
872     * {@link #EXTRA_DO_NOT_DISTURB_MODE_ENABLED} extra can be to indicate if the user is
873     * enabling or disabling do not disturb mode. If either extra is not included, the
874     * user maybe asked to provide the value.
875     * <p>
876     * Output: Nothing.
877     */
878    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
879    public static final String ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE =
880            "android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE";
881
882    /**
883     * Activity Action: Show the regulatory information screen for the device.
884     * <p>
885     * In some cases, a matching Activity may not exist, so ensure you safeguard
886     * against this.
887     * <p>
888     * Input: Nothing.
889     * <p>
890     * Output: Nothing.
891     */
892    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
893    public static final String
894            ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
895
896    /**
897     * Activity Action: Show Device Name Settings.
898     * <p>
899     * In some cases, a matching Activity may not exist, so ensure you safeguard
900     * against this.
901     *
902     * @hide
903     */
904    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
905    public static final String DEVICE_NAME_SETTINGS = "android.settings.DEVICE_NAME";
906
907    /**
908     * Activity Action: Show pairing settings.
909     * <p>
910     * In some cases, a matching Activity may not exist, so ensure you safeguard
911     * against this.
912     *
913     * @hide
914     */
915    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
916    public static final String ACTION_PAIRING_SETTINGS = "android.settings.PAIRING_SETTINGS";
917
918    /**
919     * Activity Action: Show battery saver settings.
920     * <p>
921     * In some cases, a matching Activity may not exist, so ensure you safeguard
922     * against this.
923     */
924    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
925    public static final String ACTION_BATTERY_SAVER_SETTINGS
926            = "android.settings.BATTERY_SAVER_SETTINGS";
927
928    /**
929     * Activity Action: Modify Battery Saver mode setting using a voice command.
930     * <p>
931     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
932     * <p>
933     * This intent MUST be started using
934     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
935     * startVoiceActivity}.
936     * <p>
937     * Note: The activity implementing this intent MUST verify that
938     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
939     * modifying the setting.
940     * <p>
941     * Input: To tell which state batter saver mode should be set to, add the
942     * {@link #EXTRA_BATTERY_SAVER_MODE_ENABLED} extra to this Intent with the state specified.
943     * If the extra is not included, no changes will be made.
944     * <p>
945     * Output: Nothing.
946     */
947    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
948    public static final String ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE =
949            "android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE";
950
951    /**
952     * Activity Action: Show Home selection settings. If there are multiple activities
953     * that can satisfy the {@link Intent#CATEGORY_HOME} intent, this screen allows you
954     * to pick your preferred activity.
955     */
956    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
957    public static final String ACTION_HOME_SETTINGS
958            = "android.settings.HOME_SETTINGS";
959
960    /**
961     * Activity Action: Show notification settings.
962     *
963     * @hide
964     */
965    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
966    public static final String ACTION_NOTIFICATION_SETTINGS
967            = "android.settings.NOTIFICATION_SETTINGS";
968
969    /**
970     * Activity Action: Show notification settings for a single app.
971     *
972     * @hide
973     */
974    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
975    public static final String ACTION_APP_NOTIFICATION_SETTINGS
976            = "android.settings.APP_NOTIFICATION_SETTINGS";
977
978    /**
979     * Activity Action: Show notification redaction settings.
980     *
981     * @hide
982     */
983    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
984    public static final String ACTION_APP_NOTIFICATION_REDACTION
985            = "android.settings.ACTION_APP_NOTIFICATION_REDACTION";
986
987    /** @hide */ public static final String EXTRA_APP_UID = "app_uid";
988    /** @hide */ public static final String EXTRA_APP_PACKAGE = "app_package";
989
990    // End of Intent actions for Settings
991
992    /**
993     * @hide - Private call() method on SettingsProvider to read from 'system' table.
994     */
995    public static final String CALL_METHOD_GET_SYSTEM = "GET_system";
996
997    /**
998     * @hide - Private call() method on SettingsProvider to read from 'secure' table.
999     */
1000    public static final String CALL_METHOD_GET_SECURE = "GET_secure";
1001
1002    /**
1003     * @hide - Private call() method on SettingsProvider to read from 'global' table.
1004     */
1005    public static final String CALL_METHOD_GET_GLOBAL = "GET_global";
1006
1007    /**
1008     * @hide - User handle argument extra to the fast-path call()-based requests
1009     */
1010    public static final String CALL_METHOD_USER_KEY = "_user";
1011
1012    /** @hide - Private call() method to write to 'system' table */
1013    public static final String CALL_METHOD_PUT_SYSTEM = "PUT_system";
1014
1015    /** @hide - Private call() method to write to 'secure' table */
1016    public static final String CALL_METHOD_PUT_SECURE = "PUT_secure";
1017
1018    /** @hide - Private call() method to write to 'global' table */
1019    public static final String CALL_METHOD_PUT_GLOBAL= "PUT_global";
1020
1021    /**
1022     * Activity Extra: Limit available options in launched activity based on the given authority.
1023     * <p>
1024     * This can be passed as an extra field in an Activity Intent with one or more syncable content
1025     * provider's authorities as a String[]. This field is used by some intents to alter the
1026     * behavior of the called activity.
1027     * <p>
1028     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based
1029     * on the authority given.
1030     */
1031    public static final String EXTRA_AUTHORITIES = "authorities";
1032
1033    /**
1034     * Activity Extra: Limit available options in launched activity based on the given account
1035     * types.
1036     * <p>
1037     * This can be passed as an extra field in an Activity Intent with one or more account types
1038     * as a String[]. This field is used by some intents to alter the behavior of the called
1039     * activity.
1040     * <p>
1041     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types to the specified
1042     * list.
1043     */
1044    public static final String EXTRA_ACCOUNT_TYPES = "account_types";
1045
1046    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
1047
1048    /**
1049     * Activity Extra: The device identifier to act upon.
1050     * <p>
1051     * This can be passed as an extra field in an Activity Intent with a single
1052     * InputDeviceIdentifier. This field is used by some activities to jump straight into the
1053     * settings for the given device.
1054     * <p>
1055     * Example: The {@link #ACTION_INPUT_METHOD_SETTINGS} intent opens the keyboard layout
1056     * dialog for the given device.
1057     * @hide
1058     */
1059    public static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
1060
1061    /**
1062     * Activity Extra: Enable or disable Airplane Mode.
1063     * <p>
1064     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_AIRPLANE_MODE}
1065     * intent as a boolean to indicate if it should be enabled.
1066     */
1067    public static final String EXTRA_AIRPLANE_MODE_ENABLED = "airplane_mode_enabled";
1068
1069    /**
1070     * Activity Extra: Enable or disable Battery saver mode.
1071     * <p>
1072     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE}
1073     * intent as a boolean to indicate if it should be enabled.
1074     */
1075    public static final String EXTRA_BATTERY_SAVER_MODE_ENABLED =
1076            "android.settings.extra.battery_saver_mode_enabled";
1077
1078    /**
1079     * Activity Extra: Enable or disable Do Not Disturb mode.
1080     * <p>
1081     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1082     * intent as a boolean to indicate if it should be enabled.
1083     */
1084    public static final String EXTRA_DO_NOT_DISTURB_MODE_ENABLED =
1085            "android.settings.extra.do_not_disturb_mode_enabled";
1086
1087    /**
1088     * Activity Extra: How many minutes to enable do not disturb mode for.
1089     * <p>
1090     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1091     * intent to indicate how long do not disturb mode should be enabled for.
1092     */
1093    public static final String EXTRA_DO_NOT_DISTURB_MODE_MINUTES =
1094            "android.settings.extra.do_not_disturb_mode_minutes";
1095
1096    private static final String JID_RESOURCE_PREFIX = "android";
1097
1098    public static final String AUTHORITY = "settings";
1099
1100    private static final String TAG = "Settings";
1101    private static final boolean LOCAL_LOGV = false;
1102
1103    // Lock ensures that when enabling/disabling the master location switch, we don't end up
1104    // with a partial enable/disable state in multi-threaded situations.
1105    private static final Object mLocationSettingsLock = new Object();
1106
1107    public static class SettingNotFoundException extends AndroidException {
1108        public SettingNotFoundException(String msg) {
1109            super(msg);
1110        }
1111    }
1112
1113    /**
1114     * Common base for tables of name/value settings.
1115     */
1116    public static class NameValueTable implements BaseColumns {
1117        public static final String NAME = "name";
1118        public static final String VALUE = "value";
1119
1120        protected static boolean putString(ContentResolver resolver, Uri uri,
1121                String name, String value) {
1122            // The database will take care of replacing duplicates.
1123            try {
1124                ContentValues values = new ContentValues();
1125                values.put(NAME, name);
1126                values.put(VALUE, value);
1127                resolver.insert(uri, values);
1128                return true;
1129            } catch (SQLException e) {
1130                Log.w(TAG, "Can't set key " + name + " in " + uri, e);
1131                return false;
1132            }
1133        }
1134
1135        public static Uri getUriFor(Uri uri, String name) {
1136            return Uri.withAppendedPath(uri, name);
1137        }
1138    }
1139
1140    // Thread-safe.
1141    private static class NameValueCache {
1142        private final String mVersionSystemProperty;
1143        private final Uri mUri;
1144
1145        private static final String[] SELECT_VALUE =
1146            new String[] { Settings.NameValueTable.VALUE };
1147        private static final String NAME_EQ_PLACEHOLDER = "name=?";
1148
1149        // Must synchronize on 'this' to access mValues and mValuesVersion.
1150        private final HashMap<String, String> mValues = new HashMap<String, String>();
1151        private long mValuesVersion = 0;
1152
1153        // Initially null; set lazily and held forever.  Synchronized on 'this'.
1154        private IContentProvider mContentProvider = null;
1155
1156        // The method we'll call (or null, to not use) on the provider
1157        // for the fast path of retrieving settings.
1158        private final String mCallGetCommand;
1159        private final String mCallSetCommand;
1160
1161        public NameValueCache(String versionSystemProperty, Uri uri,
1162                String getCommand, String setCommand) {
1163            mVersionSystemProperty = versionSystemProperty;
1164            mUri = uri;
1165            mCallGetCommand = getCommand;
1166            mCallSetCommand = setCommand;
1167        }
1168
1169        private IContentProvider lazyGetProvider(ContentResolver cr) {
1170            IContentProvider cp = null;
1171            synchronized (this) {
1172                cp = mContentProvider;
1173                if (cp == null) {
1174                    cp = mContentProvider = cr.acquireProvider(mUri.getAuthority());
1175                }
1176            }
1177            return cp;
1178        }
1179
1180        public boolean putStringForUser(ContentResolver cr, String name, String value,
1181                final int userHandle) {
1182            try {
1183                Bundle arg = new Bundle();
1184                arg.putString(Settings.NameValueTable.VALUE, value);
1185                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
1186                IContentProvider cp = lazyGetProvider(cr);
1187                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
1188            } catch (RemoteException e) {
1189                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
1190                return false;
1191            }
1192            return true;
1193        }
1194
1195        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
1196            final boolean isSelf = (userHandle == UserHandle.myUserId());
1197            if (isSelf) {
1198                long newValuesVersion = SystemProperties.getLong(mVersionSystemProperty, 0);
1199
1200                // Our own user's settings data uses a client-side cache
1201                synchronized (this) {
1202                    if (mValuesVersion != newValuesVersion) {
1203                        if (LOCAL_LOGV || false) {
1204                            Log.v(TAG, "invalidate [" + mUri.getLastPathSegment() + "]: current "
1205                                    + newValuesVersion + " != cached " + mValuesVersion);
1206                        }
1207
1208                        mValues.clear();
1209                        mValuesVersion = newValuesVersion;
1210                    }
1211
1212                    if (mValues.containsKey(name)) {
1213                        return mValues.get(name);  // Could be null, that's OK -- negative caching
1214                    }
1215                }
1216            } else {
1217                if (LOCAL_LOGV) Log.v(TAG, "get setting for user " + userHandle
1218                        + " by user " + UserHandle.myUserId() + " so skipping cache");
1219            }
1220
1221            IContentProvider cp = lazyGetProvider(cr);
1222
1223            // Try the fast path first, not using query().  If this
1224            // fails (alternate Settings provider that doesn't support
1225            // this interface?) then we fall back to the query/table
1226            // interface.
1227            if (mCallGetCommand != null) {
1228                try {
1229                    Bundle args = null;
1230                    if (!isSelf) {
1231                        args = new Bundle();
1232                        args.putInt(CALL_METHOD_USER_KEY, userHandle);
1233                    }
1234                    Bundle b = cp.call(cr.getPackageName(), mCallGetCommand, name, args);
1235                    if (b != null) {
1236                        String value = b.getPairValue();
1237                        // Don't update our cache for reads of other users' data
1238                        if (isSelf) {
1239                            synchronized (this) {
1240                                mValues.put(name, value);
1241                            }
1242                        } else {
1243                            if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
1244                                    + " by " + UserHandle.myUserId()
1245                                    + " so not updating cache");
1246                        }
1247                        return value;
1248                    }
1249                    // If the response Bundle is null, we fall through
1250                    // to the query interface below.
1251                } catch (RemoteException e) {
1252                    // Not supported by the remote side?  Fall through
1253                    // to query().
1254                }
1255            }
1256
1257            Cursor c = null;
1258            try {
1259                c = cp.query(cr.getPackageName(), mUri, SELECT_VALUE, NAME_EQ_PLACEHOLDER,
1260                             new String[]{name}, null, null);
1261                if (c == null) {
1262                    Log.w(TAG, "Can't get key " + name + " from " + mUri);
1263                    return null;
1264                }
1265
1266                String value = c.moveToNext() ? c.getString(0) : null;
1267                synchronized (this) {
1268                    mValues.put(name, value);
1269                }
1270                if (LOCAL_LOGV) {
1271                    Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +
1272                            name + " = " + (value == null ? "(null)" : value));
1273                }
1274                return value;
1275            } catch (RemoteException e) {
1276                Log.w(TAG, "Can't get key " + name + " from " + mUri, e);
1277                return null;  // Return null, but don't cache it.
1278            } finally {
1279                if (c != null) c.close();
1280            }
1281        }
1282    }
1283
1284    /**
1285     * System settings, containing miscellaneous system preferences.  This
1286     * table holds simple name/value pairs.  There are convenience
1287     * functions for accessing individual settings entries.
1288     */
1289    public static final class System extends NameValueTable {
1290        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version";
1291
1292        /** @hide */
1293        public static interface Validator {
1294            public boolean validate(String value);
1295        }
1296
1297        /**
1298         * The content:// style URL for this table
1299         */
1300        public static final Uri CONTENT_URI =
1301            Uri.parse("content://" + AUTHORITY + "/system");
1302
1303        private static final NameValueCache sNameValueCache = new NameValueCache(
1304                SYS_PROP_SETTING_VERSION,
1305                CONTENT_URI,
1306                CALL_METHOD_GET_SYSTEM,
1307                CALL_METHOD_PUT_SYSTEM);
1308
1309        private static final HashSet<String> MOVED_TO_SECURE;
1310        static {
1311            MOVED_TO_SECURE = new HashSet<String>(30);
1312            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
1313            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
1314            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
1315            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
1316            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
1317            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
1318            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
1319            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
1320            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
1321            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
1322            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
1323            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
1324            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
1325            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
1326            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
1327            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
1328            MOVED_TO_SECURE.add(Secure.WIFI_ON);
1329            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
1330            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
1331            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
1332            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
1333            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
1334            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
1335            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
1336            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
1337            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
1338            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
1339            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
1340
1341            // At one time in System, then Global, but now back in Secure
1342            MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
1343        }
1344
1345        private static final HashSet<String> MOVED_TO_GLOBAL;
1346        private static final HashSet<String> MOVED_TO_SECURE_THEN_GLOBAL;
1347        static {
1348            MOVED_TO_GLOBAL = new HashSet<String>();
1349            MOVED_TO_SECURE_THEN_GLOBAL = new HashSet<String>();
1350
1351            // these were originally in system but migrated to secure in the past,
1352            // so are duplicated in the Secure.* namespace
1353            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.ADB_ENABLED);
1354            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.BLUETOOTH_ON);
1355            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DATA_ROAMING);
1356            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DEVICE_PROVISIONED);
1357            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.USB_MASS_STORAGE_ENABLED);
1358            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.HTTP_PROXY);
1359
1360            // these are moving directly from system to global
1361            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_ON);
1362            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_RADIOS);
1363            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
1364            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME);
1365            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME_ZONE);
1366            MOVED_TO_GLOBAL.add(Settings.Global.CAR_DOCK_SOUND);
1367            MOVED_TO_GLOBAL.add(Settings.Global.CAR_UNDOCK_SOUND);
1368            MOVED_TO_GLOBAL.add(Settings.Global.DESK_DOCK_SOUND);
1369            MOVED_TO_GLOBAL.add(Settings.Global.DESK_UNDOCK_SOUND);
1370            MOVED_TO_GLOBAL.add(Settings.Global.DOCK_SOUNDS_ENABLED);
1371            MOVED_TO_GLOBAL.add(Settings.Global.LOCK_SOUND);
1372            MOVED_TO_GLOBAL.add(Settings.Global.UNLOCK_SOUND);
1373            MOVED_TO_GLOBAL.add(Settings.Global.LOW_BATTERY_SOUND);
1374            MOVED_TO_GLOBAL.add(Settings.Global.POWER_SOUNDS_ENABLED);
1375            MOVED_TO_GLOBAL.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
1376            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SLEEP_POLICY);
1377            MOVED_TO_GLOBAL.add(Settings.Global.MODE_RINGER);
1378            MOVED_TO_GLOBAL.add(Settings.Global.WINDOW_ANIMATION_SCALE);
1379            MOVED_TO_GLOBAL.add(Settings.Global.TRANSITION_ANIMATION_SCALE);
1380            MOVED_TO_GLOBAL.add(Settings.Global.ANIMATOR_DURATION_SCALE);
1381            MOVED_TO_GLOBAL.add(Settings.Global.FANCY_IME_ANIMATIONS);
1382            MOVED_TO_GLOBAL.add(Settings.Global.COMPATIBILITY_MODE);
1383            MOVED_TO_GLOBAL.add(Settings.Global.EMERGENCY_TONE);
1384            MOVED_TO_GLOBAL.add(Settings.Global.CALL_AUTO_RETRY);
1385            MOVED_TO_GLOBAL.add(Settings.Global.DEBUG_APP);
1386            MOVED_TO_GLOBAL.add(Settings.Global.WAIT_FOR_DEBUGGER);
1387            MOVED_TO_GLOBAL.add(Settings.Global.SHOW_PROCESSES);
1388            MOVED_TO_GLOBAL.add(Settings.Global.ALWAYS_FINISH_ACTIVITIES);
1389            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_CONTENT_URL);
1390            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_METADATA_URL);
1391            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_CONTENT_URL);
1392            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_METADATA_URL);
1393            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_CONTENT_URL);
1394            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_METADATA_URL);
1395            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_CONTENT_URL);
1396            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_METADATA_URL);
1397        }
1398
1399        private static final Validator sBooleanValidator =
1400                new DiscreteValueValidator(new String[] {"0", "1"});
1401
1402        private static final Validator sNonNegativeIntegerValidator = new Validator() {
1403            @Override
1404            public boolean validate(String value) {
1405                try {
1406                    return Integer.parseInt(value) >= 0;
1407                } catch (NumberFormatException e) {
1408                    return false;
1409                }
1410            }
1411        };
1412
1413        private static final Validator sUriValidator = new Validator() {
1414            @Override
1415            public boolean validate(String value) {
1416                try {
1417                    Uri.decode(value);
1418                    return true;
1419                } catch (IllegalArgumentException e) {
1420                    return false;
1421                }
1422            }
1423        };
1424
1425        private static final Validator sLenientIpAddressValidator = new Validator() {
1426            private static final int MAX_IPV6_LENGTH = 45;
1427
1428            @Override
1429            public boolean validate(String value) {
1430                return value.length() <= MAX_IPV6_LENGTH;
1431            }
1432        };
1433
1434        /** @hide */
1435        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
1436            outKeySet.addAll(MOVED_TO_GLOBAL);
1437            outKeySet.addAll(MOVED_TO_SECURE_THEN_GLOBAL);
1438        }
1439
1440        /** @hide */
1441        public static void getMovedToSecureSettings(Set<String> outKeySet) {
1442            outKeySet.addAll(MOVED_TO_SECURE);
1443        }
1444
1445        /** @hide */
1446        public static void getNonLegacyMovedKeys(HashSet<String> outKeySet) {
1447            outKeySet.addAll(MOVED_TO_GLOBAL);
1448        }
1449
1450        /**
1451         * Look up a name in the database.
1452         * @param resolver to access the database with
1453         * @param name to look up in the table
1454         * @return the corresponding value, or null if not present
1455         */
1456        public static String getString(ContentResolver resolver, String name) {
1457            return getStringForUser(resolver, name, UserHandle.myUserId());
1458        }
1459
1460        /** @hide */
1461        public static String getStringForUser(ContentResolver resolver, String name,
1462                int userHandle) {
1463            if (MOVED_TO_SECURE.contains(name)) {
1464                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1465                        + " to android.provider.Settings.Secure, returning read-only value.");
1466                return Secure.getStringForUser(resolver, name, userHandle);
1467            }
1468            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
1469                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1470                        + " to android.provider.Settings.Global, returning read-only value.");
1471                return Global.getStringForUser(resolver, name, userHandle);
1472            }
1473            return sNameValueCache.getStringForUser(resolver, name, userHandle);
1474        }
1475
1476        /**
1477         * Store a name/value pair into the database.
1478         * @param resolver to access the database with
1479         * @param name to store
1480         * @param value to associate with the name
1481         * @return true if the value was set, false on database errors
1482         */
1483        public static boolean putString(ContentResolver resolver, String name, String value) {
1484            return putStringForUser(resolver, name, value, UserHandle.myUserId());
1485        }
1486
1487        /** @hide */
1488        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
1489                int userHandle) {
1490            if (MOVED_TO_SECURE.contains(name)) {
1491                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1492                        + " to android.provider.Settings.Secure, value is unchanged.");
1493                return false;
1494            }
1495            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
1496                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1497                        + " to android.provider.Settings.Global, value is unchanged.");
1498                return false;
1499            }
1500            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
1501        }
1502
1503        /**
1504         * Construct the content URI for a particular name/value pair,
1505         * useful for monitoring changes with a ContentObserver.
1506         * @param name to look up in the table
1507         * @return the corresponding content URI, or null if not present
1508         */
1509        public static Uri getUriFor(String name) {
1510            if (MOVED_TO_SECURE.contains(name)) {
1511                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1512                    + " to android.provider.Settings.Secure, returning Secure URI.");
1513                return Secure.getUriFor(Secure.CONTENT_URI, name);
1514            }
1515            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
1516                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1517                        + " to android.provider.Settings.Global, returning read-only global URI.");
1518                return Global.getUriFor(Global.CONTENT_URI, name);
1519            }
1520            return getUriFor(CONTENT_URI, name);
1521        }
1522
1523        /**
1524         * Convenience function for retrieving a single system settings value
1525         * as an integer.  Note that internally setting values are always
1526         * stored as strings; this function converts the string to an integer
1527         * for you.  The default value will be returned if the setting is
1528         * not defined or not an integer.
1529         *
1530         * @param cr The ContentResolver to access.
1531         * @param name The name of the setting to retrieve.
1532         * @param def Value to return if the setting is not defined.
1533         *
1534         * @return The setting's current value, or 'def' if it is not defined
1535         * or not a valid integer.
1536         */
1537        public static int getInt(ContentResolver cr, String name, int def) {
1538            return getIntForUser(cr, name, def, UserHandle.myUserId());
1539        }
1540
1541        /** @hide */
1542        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
1543            String v = getStringForUser(cr, name, userHandle);
1544            try {
1545                return v != null ? Integer.parseInt(v) : def;
1546            } catch (NumberFormatException e) {
1547                return def;
1548            }
1549        }
1550
1551        /**
1552         * Convenience function for retrieving a single system settings value
1553         * as an integer.  Note that internally setting values are always
1554         * stored as strings; this function converts the string to an integer
1555         * for you.
1556         * <p>
1557         * This version does not take a default value.  If the setting has not
1558         * been set, or the string value is not a number,
1559         * it throws {@link SettingNotFoundException}.
1560         *
1561         * @param cr The ContentResolver to access.
1562         * @param name The name of the setting to retrieve.
1563         *
1564         * @throws SettingNotFoundException Thrown if a setting by the given
1565         * name can't be found or the setting value is not an integer.
1566         *
1567         * @return The setting's current value.
1568         */
1569        public static int getInt(ContentResolver cr, String name)
1570                throws SettingNotFoundException {
1571            return getIntForUser(cr, name, UserHandle.myUserId());
1572        }
1573
1574        /** @hide */
1575        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
1576                throws SettingNotFoundException {
1577            String v = getStringForUser(cr, name, userHandle);
1578            try {
1579                return Integer.parseInt(v);
1580            } catch (NumberFormatException e) {
1581                throw new SettingNotFoundException(name);
1582            }
1583        }
1584
1585        /**
1586         * Convenience function for updating a single settings value as an
1587         * integer. This will either create a new entry in the table if the
1588         * given name does not exist, or modify the value of the existing row
1589         * with that name.  Note that internally setting values are always
1590         * stored as strings, so this function converts the given value to a
1591         * string before storing it.
1592         *
1593         * @param cr The ContentResolver to access.
1594         * @param name The name of the setting to modify.
1595         * @param value The new value for the setting.
1596         * @return true if the value was set, false on database errors
1597         */
1598        public static boolean putInt(ContentResolver cr, String name, int value) {
1599            return putIntForUser(cr, name, value, UserHandle.myUserId());
1600        }
1601
1602        /** @hide */
1603        public static boolean putIntForUser(ContentResolver cr, String name, int value,
1604                int userHandle) {
1605            return putStringForUser(cr, name, Integer.toString(value), userHandle);
1606        }
1607
1608        /**
1609         * Convenience function for retrieving a single system settings value
1610         * as a {@code long}.  Note that internally setting values are always
1611         * stored as strings; this function converts the string to a {@code long}
1612         * for you.  The default value will be returned if the setting is
1613         * not defined or not a {@code long}.
1614         *
1615         * @param cr The ContentResolver to access.
1616         * @param name The name of the setting to retrieve.
1617         * @param def Value to return if the setting is not defined.
1618         *
1619         * @return The setting's current value, or 'def' if it is not defined
1620         * or not a valid {@code long}.
1621         */
1622        public static long getLong(ContentResolver cr, String name, long def) {
1623            return getLongForUser(cr, name, def, UserHandle.myUserId());
1624        }
1625
1626        /** @hide */
1627        public static long getLongForUser(ContentResolver cr, String name, long def,
1628                int userHandle) {
1629            String valString = getStringForUser(cr, name, userHandle);
1630            long value;
1631            try {
1632                value = valString != null ? Long.parseLong(valString) : def;
1633            } catch (NumberFormatException e) {
1634                value = def;
1635            }
1636            return value;
1637        }
1638
1639        /**
1640         * Convenience function for retrieving a single system settings value
1641         * as a {@code long}.  Note that internally setting values are always
1642         * stored as strings; this function converts the string to a {@code long}
1643         * for you.
1644         * <p>
1645         * This version does not take a default value.  If the setting has not
1646         * been set, or the string value is not a number,
1647         * it throws {@link SettingNotFoundException}.
1648         *
1649         * @param cr The ContentResolver to access.
1650         * @param name The name of the setting to retrieve.
1651         *
1652         * @return The setting's current value.
1653         * @throws SettingNotFoundException Thrown if a setting by the given
1654         * name can't be found or the setting value is not an integer.
1655         */
1656        public static long getLong(ContentResolver cr, String name)
1657                throws SettingNotFoundException {
1658            return getLongForUser(cr, name, UserHandle.myUserId());
1659        }
1660
1661        /** @hide */
1662        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
1663                throws SettingNotFoundException {
1664            String valString = getStringForUser(cr, name, userHandle);
1665            try {
1666                return Long.parseLong(valString);
1667            } catch (NumberFormatException e) {
1668                throw new SettingNotFoundException(name);
1669            }
1670        }
1671
1672        /**
1673         * Convenience function for updating a single settings value as a long
1674         * integer. This will either create a new entry in the table if the
1675         * given name does not exist, or modify the value of the existing row
1676         * with that name.  Note that internally setting values are always
1677         * stored as strings, so this function converts the given value to a
1678         * string before storing it.
1679         *
1680         * @param cr The ContentResolver to access.
1681         * @param name The name of the setting to modify.
1682         * @param value The new value for the setting.
1683         * @return true if the value was set, false on database errors
1684         */
1685        public static boolean putLong(ContentResolver cr, String name, long value) {
1686            return putLongForUser(cr, name, value, UserHandle.myUserId());
1687        }
1688
1689        /** @hide */
1690        public static boolean putLongForUser(ContentResolver cr, String name, long value,
1691                int userHandle) {
1692            return putStringForUser(cr, name, Long.toString(value), userHandle);
1693        }
1694
1695        /**
1696         * Convenience function for retrieving a single system settings value
1697         * as a floating point number.  Note that internally setting values are
1698         * always stored as strings; this function converts the string to an
1699         * float for you. The default value will be returned if the setting
1700         * is not defined or not a valid float.
1701         *
1702         * @param cr The ContentResolver to access.
1703         * @param name The name of the setting to retrieve.
1704         * @param def Value to return if the setting is not defined.
1705         *
1706         * @return The setting's current value, or 'def' if it is not defined
1707         * or not a valid float.
1708         */
1709        public static float getFloat(ContentResolver cr, String name, float def) {
1710            return getFloatForUser(cr, name, def, UserHandle.myUserId());
1711        }
1712
1713        /** @hide */
1714        public static float getFloatForUser(ContentResolver cr, String name, float def,
1715                int userHandle) {
1716            String v = getStringForUser(cr, name, userHandle);
1717            try {
1718                return v != null ? Float.parseFloat(v) : def;
1719            } catch (NumberFormatException e) {
1720                return def;
1721            }
1722        }
1723
1724        /**
1725         * Convenience function for retrieving a single system settings value
1726         * as a float.  Note that internally setting values are always
1727         * stored as strings; this function converts the string to a float
1728         * for you.
1729         * <p>
1730         * This version does not take a default value.  If the setting has not
1731         * been set, or the string value is not a number,
1732         * it throws {@link SettingNotFoundException}.
1733         *
1734         * @param cr The ContentResolver to access.
1735         * @param name The name of the setting to retrieve.
1736         *
1737         * @throws SettingNotFoundException Thrown if a setting by the given
1738         * name can't be found or the setting value is not a float.
1739         *
1740         * @return The setting's current value.
1741         */
1742        public static float getFloat(ContentResolver cr, String name)
1743                throws SettingNotFoundException {
1744            return getFloatForUser(cr, name, UserHandle.myUserId());
1745        }
1746
1747        /** @hide */
1748        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
1749                throws SettingNotFoundException {
1750            String v = getStringForUser(cr, name, userHandle);
1751            if (v == null) {
1752                throw new SettingNotFoundException(name);
1753            }
1754            try {
1755                return Float.parseFloat(v);
1756            } catch (NumberFormatException e) {
1757                throw new SettingNotFoundException(name);
1758            }
1759        }
1760
1761        /**
1762         * Convenience function for updating a single settings value as a
1763         * floating point number. This will either create a new entry in the
1764         * table if the given name does not exist, or modify the value of the
1765         * existing row with that name.  Note that internally setting values
1766         * are always stored as strings, so this function converts the given
1767         * value to a string before storing it.
1768         *
1769         * @param cr The ContentResolver to access.
1770         * @param name The name of the setting to modify.
1771         * @param value The new value for the setting.
1772         * @return true if the value was set, false on database errors
1773         */
1774        public static boolean putFloat(ContentResolver cr, String name, float value) {
1775            return putFloatForUser(cr, name, value, UserHandle.myUserId());
1776        }
1777
1778        /** @hide */
1779        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
1780                int userHandle) {
1781            return putStringForUser(cr, name, Float.toString(value), userHandle);
1782        }
1783
1784        /**
1785         * Convenience function to read all of the current
1786         * configuration-related settings into a
1787         * {@link Configuration} object.
1788         *
1789         * @param cr The ContentResolver to access.
1790         * @param outConfig Where to place the configuration settings.
1791         */
1792        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
1793            getConfigurationForUser(cr, outConfig, UserHandle.myUserId());
1794        }
1795
1796        /** @hide */
1797        public static void getConfigurationForUser(ContentResolver cr, Configuration outConfig,
1798                int userHandle) {
1799            outConfig.fontScale = Settings.System.getFloatForUser(
1800                cr, FONT_SCALE, outConfig.fontScale, userHandle);
1801            if (outConfig.fontScale < 0) {
1802                outConfig.fontScale = 1;
1803            }
1804        }
1805
1806        /**
1807         * @hide Erase the fields in the Configuration that should be applied
1808         * by the settings.
1809         */
1810        public static void clearConfiguration(Configuration inoutConfig) {
1811            inoutConfig.fontScale = 0;
1812        }
1813
1814        /**
1815         * Convenience function to write a batch of configuration-related
1816         * settings from a {@link Configuration} object.
1817         *
1818         * @param cr The ContentResolver to access.
1819         * @param config The settings to write.
1820         * @return true if the values were set, false on database errors
1821         */
1822        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
1823            return putConfigurationForUser(cr, config, UserHandle.myUserId());
1824        }
1825
1826        /** @hide */
1827        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
1828                int userHandle) {
1829            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle);
1830        }
1831
1832        /** @hide */
1833        public static boolean hasInterestingConfigurationChanges(int changes) {
1834            return (changes&ActivityInfo.CONFIG_FONT_SCALE) != 0;
1835        }
1836
1837        /** @deprecated - Do not use */
1838        @Deprecated
1839        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
1840            return getShowGTalkServiceStatusForUser(cr, UserHandle.myUserId());
1841        }
1842
1843        /**
1844         * @hide
1845         * @deprecated - Do not use
1846         */
1847        public static boolean getShowGTalkServiceStatusForUser(ContentResolver cr,
1848                int userHandle) {
1849            return getIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, 0, userHandle) != 0;
1850        }
1851
1852        /** @deprecated - Do not use */
1853        @Deprecated
1854        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
1855            setShowGTalkServiceStatusForUser(cr, flag, UserHandle.myUserId());
1856        }
1857
1858        /**
1859         * @hide
1860         * @deprecated - Do not use
1861         */
1862        @Deprecated
1863        public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean flag,
1864                int userHandle) {
1865            putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
1866        }
1867
1868        private static final class DiscreteValueValidator implements Validator {
1869            private final String[] mValues;
1870
1871            public DiscreteValueValidator(String[] values) {
1872                mValues = values;
1873            }
1874
1875            @Override
1876            public boolean validate(String value) {
1877                return ArrayUtils.contains(mValues, value);
1878            }
1879        }
1880
1881        private static final class InclusiveIntegerRangeValidator implements Validator {
1882            private final int mMin;
1883            private final int mMax;
1884
1885            public InclusiveIntegerRangeValidator(int min, int max) {
1886                mMin = min;
1887                mMax = max;
1888            }
1889
1890            @Override
1891            public boolean validate(String value) {
1892                try {
1893                    final int intValue = Integer.parseInt(value);
1894                    return intValue >= mMin && intValue <= mMax;
1895                } catch (NumberFormatException e) {
1896                    return false;
1897                }
1898            }
1899        }
1900
1901        private static final class InclusiveFloatRangeValidator implements Validator {
1902            private final float mMin;
1903            private final float mMax;
1904
1905            public InclusiveFloatRangeValidator(float min, float max) {
1906                mMin = min;
1907                mMax = max;
1908            }
1909
1910            @Override
1911            public boolean validate(String value) {
1912                try {
1913                    final float floatValue = Float.parseFloat(value);
1914                    return floatValue >= mMin && floatValue <= mMax;
1915                } catch (NumberFormatException e) {
1916                    return false;
1917                }
1918            }
1919        }
1920
1921        /**
1922         * @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
1923         */
1924        @Deprecated
1925        public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN;
1926
1927        /**
1928         * What happens when the user presses the end call button if they're not
1929         * on a call.<br/>
1930         * <b>Values:</b><br/>
1931         * 0 - The end button does nothing.<br/>
1932         * 1 - The end button goes to the home screen.<br/>
1933         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
1934         * 3 - The end button goes to the home screen.  If the user is already on the
1935         * home screen, it puts the device to sleep.
1936         */
1937        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
1938
1939        private static final Validator END_BUTTON_BEHAVIOR_VALIDATOR =
1940                new InclusiveIntegerRangeValidator(0, 3);
1941
1942        /**
1943         * END_BUTTON_BEHAVIOR value for "go home".
1944         * @hide
1945         */
1946        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
1947
1948        /**
1949         * END_BUTTON_BEHAVIOR value for "go to sleep".
1950         * @hide
1951         */
1952        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
1953
1954        /**
1955         * END_BUTTON_BEHAVIOR default value.
1956         * @hide
1957         */
1958        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
1959
1960        /**
1961         * Is advanced settings mode turned on. 0 == no, 1 == yes
1962         * @hide
1963         */
1964        public static final String ADVANCED_SETTINGS = "advanced_settings";
1965
1966        private static final Validator ADVANCED_SETTINGS_VALIDATOR = sBooleanValidator;
1967
1968        /**
1969         * ADVANCED_SETTINGS default value.
1970         * @hide
1971         */
1972        public static final int ADVANCED_SETTINGS_DEFAULT = 0;
1973
1974        /**
1975         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
1976         */
1977        @Deprecated
1978        public static final String AIRPLANE_MODE_ON = Global.AIRPLANE_MODE_ON;
1979
1980        /**
1981         * @deprecated Use {@link android.provider.Settings.Global#RADIO_BLUETOOTH} instead
1982         */
1983        @Deprecated
1984        public static final String RADIO_BLUETOOTH = Global.RADIO_BLUETOOTH;
1985
1986        /**
1987         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIFI} instead
1988         */
1989        @Deprecated
1990        public static final String RADIO_WIFI = Global.RADIO_WIFI;
1991
1992        /**
1993         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIMAX} instead
1994         * {@hide}
1995         */
1996        @Deprecated
1997        public static final String RADIO_WIMAX = Global.RADIO_WIMAX;
1998
1999        /**
2000         * @deprecated Use {@link android.provider.Settings.Global#RADIO_CELL} instead
2001         */
2002        @Deprecated
2003        public static final String RADIO_CELL = Global.RADIO_CELL;
2004
2005        /**
2006         * @deprecated Use {@link android.provider.Settings.Global#RADIO_NFC} instead
2007         */
2008        @Deprecated
2009        public static final String RADIO_NFC = Global.RADIO_NFC;
2010
2011        /**
2012         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_RADIOS} instead
2013         */
2014        @Deprecated
2015        public static final String AIRPLANE_MODE_RADIOS = Global.AIRPLANE_MODE_RADIOS;
2016
2017        /**
2018         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_TOGGLEABLE_RADIOS} instead
2019         *
2020         * {@hide}
2021         */
2022        @Deprecated
2023        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS =
2024                Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS;
2025
2026        /**
2027         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY} instead
2028         */
2029        @Deprecated
2030        public static final String WIFI_SLEEP_POLICY = Global.WIFI_SLEEP_POLICY;
2031
2032        /**
2033         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_DEFAULT} instead
2034         */
2035        @Deprecated
2036        public static final int WIFI_SLEEP_POLICY_DEFAULT = Global.WIFI_SLEEP_POLICY_DEFAULT;
2037
2038        /**
2039         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED} instead
2040         */
2041        @Deprecated
2042        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED =
2043                Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
2044
2045        /**
2046         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER} instead
2047         */
2048        @Deprecated
2049        public static final int WIFI_SLEEP_POLICY_NEVER = Global.WIFI_SLEEP_POLICY_NEVER;
2050
2051        /**
2052         * @deprecated Use {@link android.provider.Settings.Global#MODE_RINGER} instead
2053         */
2054        @Deprecated
2055        public static final String MODE_RINGER = Global.MODE_RINGER;
2056
2057        /**
2058         * Whether to use static IP and other static network attributes.
2059         * <p>
2060         * Set to 1 for true and 0 for false.
2061         *
2062         * @deprecated Use {@link WifiManager} instead
2063         */
2064        @Deprecated
2065        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
2066
2067        private static final Validator WIFI_USE_STATIC_IP_VALIDATOR = sBooleanValidator;
2068
2069        /**
2070         * The static IP address.
2071         * <p>
2072         * Example: "192.168.1.51"
2073         *
2074         * @deprecated Use {@link WifiManager} instead
2075         */
2076        @Deprecated
2077        public static final String WIFI_STATIC_IP = "wifi_static_ip";
2078
2079        private static final Validator WIFI_STATIC_IP_VALIDATOR = sLenientIpAddressValidator;
2080
2081        /**
2082         * If using static IP, the gateway's IP address.
2083         * <p>
2084         * Example: "192.168.1.1"
2085         *
2086         * @deprecated Use {@link WifiManager} instead
2087         */
2088        @Deprecated
2089        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
2090
2091        private static final Validator WIFI_STATIC_GATEWAY_VALIDATOR = sLenientIpAddressValidator;
2092
2093        /**
2094         * If using static IP, the net mask.
2095         * <p>
2096         * Example: "255.255.255.0"
2097         *
2098         * @deprecated Use {@link WifiManager} instead
2099         */
2100        @Deprecated
2101        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
2102
2103        private static final Validator WIFI_STATIC_NETMASK_VALIDATOR = sLenientIpAddressValidator;
2104
2105        /**
2106         * If using static IP, the primary DNS's IP address.
2107         * <p>
2108         * Example: "192.168.1.1"
2109         *
2110         * @deprecated Use {@link WifiManager} instead
2111         */
2112        @Deprecated
2113        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
2114
2115        private static final Validator WIFI_STATIC_DNS1_VALIDATOR = sLenientIpAddressValidator;
2116
2117        /**
2118         * If using static IP, the secondary DNS's IP address.
2119         * <p>
2120         * Example: "192.168.1.2"
2121         *
2122         * @deprecated Use {@link WifiManager} instead
2123         */
2124        @Deprecated
2125        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
2126
2127        private static final Validator WIFI_STATIC_DNS2_VALIDATOR = sLenientIpAddressValidator;
2128
2129        /**
2130         * Determines whether remote devices may discover and/or connect to
2131         * this device.
2132         * <P>Type: INT</P>
2133         * 2 -- discoverable and connectable
2134         * 1 -- connectable but not discoverable
2135         * 0 -- neither connectable nor discoverable
2136         */
2137        public static final String BLUETOOTH_DISCOVERABILITY =
2138            "bluetooth_discoverability";
2139
2140        private static final Validator BLUETOOTH_DISCOVERABILITY_VALIDATOR =
2141                new InclusiveIntegerRangeValidator(0, 2);
2142
2143        /**
2144         * Bluetooth discoverability timeout.  If this value is nonzero, then
2145         * Bluetooth becomes discoverable for a certain number of seconds,
2146         * after which is becomes simply connectable.  The value is in seconds.
2147         */
2148        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
2149            "bluetooth_discoverability_timeout";
2150
2151        private static final Validator BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR =
2152                sNonNegativeIntegerValidator;
2153
2154        /**
2155         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
2156         * instead
2157         */
2158        @Deprecated
2159        public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
2160
2161        /**
2162         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
2163         * instead
2164         */
2165        @Deprecated
2166        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
2167
2168        /**
2169         * @deprecated Use
2170         * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
2171         * instead
2172         */
2173        @Deprecated
2174        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
2175            "lock_pattern_tactile_feedback_enabled";
2176
2177        /**
2178         * A formatted string of the next alarm that is set, or the empty string
2179         * if there is no alarm set.
2180         *
2181         * @deprecated Use {@link android.app.AlarmManager#getNextAlarmClock()}.
2182         */
2183        @Deprecated
2184        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
2185
2186        private static final Validator NEXT_ALARM_FORMATTED_VALIDATOR = new Validator() {
2187            private static final int MAX_LENGTH = 1000;
2188
2189            @Override
2190            public boolean validate(String value) {
2191                // TODO: No idea what the correct format is.
2192                return value == null || value.length() < MAX_LENGTH;
2193            }
2194        };
2195
2196        /**
2197         * Scaling factor for fonts, float.
2198         */
2199        public static final String FONT_SCALE = "font_scale";
2200
2201        private static final Validator FONT_SCALE_VALIDATOR = new Validator() {
2202            @Override
2203            public boolean validate(String value) {
2204                try {
2205                    return Float.parseFloat(value) >= 0;
2206                } catch (NumberFormatException e) {
2207                    return false;
2208                }
2209            }
2210        };
2211
2212        /**
2213         * Name of an application package to be debugged.
2214         *
2215         * @deprecated Use {@link Global#DEBUG_APP} instead
2216         */
2217        @Deprecated
2218        public static final String DEBUG_APP = Global.DEBUG_APP;
2219
2220        /**
2221         * If 1, when launching DEBUG_APP it will wait for the debugger before
2222         * starting user code.  If 0, it will run normally.
2223         *
2224         * @deprecated Use {@link Global#WAIT_FOR_DEBUGGER} instead
2225         */
2226        @Deprecated
2227        public static final String WAIT_FOR_DEBUGGER = Global.WAIT_FOR_DEBUGGER;
2228
2229        /**
2230         * Whether or not to dim the screen. 0=no  1=yes
2231         * @deprecated This setting is no longer used.
2232         */
2233        @Deprecated
2234        public static final String DIM_SCREEN = "dim_screen";
2235
2236        private static final Validator DIM_SCREEN_VALIDATOR = sBooleanValidator;
2237
2238        /**
2239         * The amount of time in milliseconds before the device goes to sleep or begins
2240         * to dream after a period of inactivity.  This value is also known as the
2241         * user activity timeout period since the screen isn't necessarily turned off
2242         * when it expires.
2243         */
2244        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
2245
2246        private static final Validator SCREEN_OFF_TIMEOUT_VALIDATOR = sNonNegativeIntegerValidator;
2247
2248        /**
2249         * The screen backlight brightness between 0 and 255.
2250         */
2251        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
2252
2253        private static final Validator SCREEN_BRIGHTNESS_VALIDATOR =
2254                new InclusiveIntegerRangeValidator(0, 255);
2255
2256        /**
2257         * Control whether to enable automatic brightness mode.
2258         */
2259        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
2260
2261        private static final Validator SCREEN_BRIGHTNESS_MODE_VALIDATOR = sBooleanValidator;
2262
2263        /**
2264         * Adjustment to auto-brightness to make it generally more (>0.0 <1.0)
2265         * or less (<0.0 >-1.0) bright.
2266         * @hide
2267         */
2268        public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj";
2269
2270        private static final Validator SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR =
2271                new InclusiveFloatRangeValidator(-1, 1);
2272
2273        /**
2274         * SCREEN_BRIGHTNESS_MODE value for manual mode.
2275         */
2276        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
2277
2278        /**
2279         * SCREEN_BRIGHTNESS_MODE value for automatic mode.
2280         */
2281        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
2282
2283        /**
2284         * Control whether the process CPU usage meter should be shown.
2285         *
2286         * @deprecated Use {@link Global#SHOW_PROCESSES} instead
2287         */
2288        @Deprecated
2289        public static final String SHOW_PROCESSES = Global.SHOW_PROCESSES;
2290
2291        /**
2292         * If 1, the activity manager will aggressively finish activities and
2293         * processes as soon as they are no longer needed.  If 0, the normal
2294         * extended lifetime is used.
2295         *
2296         * @deprecated Use {@link Global#ALWAYS_FINISH_ACTIVITIES} instead
2297         */
2298        @Deprecated
2299        public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
2300
2301        /**
2302         * Determines which streams are affected by ringer mode changes. The
2303         * stream type's bit should be set to 1 if it should be muted when going
2304         * into an inaudible ringer mode.
2305         */
2306        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
2307
2308        private static final Validator MODE_RINGER_STREAMS_AFFECTED_VALIDATOR =
2309                sNonNegativeIntegerValidator;
2310
2311        /**
2312          * Determines which streams are affected by mute. The
2313          * stream type's bit should be set to 1 if it should be muted when a mute request
2314          * is received.
2315          */
2316        public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
2317
2318        private static final Validator MUTE_STREAMS_AFFECTED_VALIDATOR =
2319                sNonNegativeIntegerValidator;
2320
2321        /**
2322         * Whether vibrate is on for different events. This is used internally,
2323         * changing this value will not change the vibrate. See AudioManager.
2324         */
2325        public static final String VIBRATE_ON = "vibrate_on";
2326
2327        private static final Validator VIBRATE_ON_VALIDATOR = sBooleanValidator;
2328
2329        /**
2330         * If 1, redirects the system vibrator to all currently attached input devices
2331         * that support vibration.  If there are no such input devices, then the system
2332         * vibrator is used instead.
2333         * If 0, does not register the system vibrator.
2334         *
2335         * This setting is mainly intended to provide a compatibility mechanism for
2336         * applications that only know about the system vibrator and do not use the
2337         * input device vibrator API.
2338         *
2339         * @hide
2340         */
2341        public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices";
2342
2343        private static final Validator VIBRATE_INPUT_DEVICES_VALIDATOR = sBooleanValidator;
2344
2345        /**
2346         * Ringer volume. This is used internally, changing this value will not
2347         * change the volume. See AudioManager.
2348         *
2349         * @removed Not used by anything since API 2.
2350         */
2351        public static final String VOLUME_RING = "volume_ring";
2352
2353        /**
2354         * System/notifications volume. This is used internally, changing this
2355         * value will not change the volume. See AudioManager.
2356         *
2357         * @removed Not used by anything since API 2.
2358         */
2359        public static final String VOLUME_SYSTEM = "volume_system";
2360
2361        /**
2362         * Voice call volume. This is used internally, changing this value will
2363         * not change the volume. See AudioManager.
2364         *
2365         * @removed Not used by anything since API 2.
2366         */
2367        public static final String VOLUME_VOICE = "volume_voice";
2368
2369        /**
2370         * Music/media/gaming volume. This is used internally, changing this
2371         * value will not change the volume. See AudioManager.
2372         *
2373         * @removed Not used by anything since API 2.
2374         */
2375        public static final String VOLUME_MUSIC = "volume_music";
2376
2377        /**
2378         * Alarm volume. This is used internally, changing this
2379         * value will not change the volume. See AudioManager.
2380         *
2381         * @removed Not used by anything since API 2.
2382         */
2383        public static final String VOLUME_ALARM = "volume_alarm";
2384
2385        /**
2386         * Notification volume. This is used internally, changing this
2387         * value will not change the volume. See AudioManager.
2388         *
2389         * @removed Not used by anything since API 2.
2390         */
2391        public static final String VOLUME_NOTIFICATION = "volume_notification";
2392
2393        /**
2394         * Bluetooth Headset volume. This is used internally, changing this value will
2395         * not change the volume. See AudioManager.
2396         *
2397         * @removed Not used by anything since API 2.
2398         */
2399        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";
2400
2401        /**
2402         * Master volume (float in the range 0.0f to 1.0f).
2403         *
2404         * @hide
2405         */
2406        public static final String VOLUME_MASTER = "volume_master";
2407
2408        /**
2409         * Master volume mute (int 1 = mute, 0 = not muted).
2410         *
2411         * @hide
2412         */
2413        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";
2414
2415        private static final Validator VOLUME_MASTER_MUTE_VALIDATOR = sBooleanValidator;
2416
2417        /**
2418         * Microphone mute (int 1 = mute, 0 = not muted).
2419         *
2420         * @hide
2421         */
2422        public static final String MICROPHONE_MUTE = "microphone_mute";
2423
2424        private static final Validator MICROPHONE_MUTE_VALIDATOR = sBooleanValidator;
2425
2426        /**
2427         * Whether the notifications should use the ring volume (value of 1) or
2428         * a separate notification volume (value of 0). In most cases, users
2429         * will have this enabled so the notification and ringer volumes will be
2430         * the same. However, power users can disable this and use the separate
2431         * notification volume control.
2432         * <p>
2433         * Note: This is a one-off setting that will be removed in the future
2434         * when there is profile support. For this reason, it is kept hidden
2435         * from the public APIs.
2436         *
2437         * @hide
2438         * @deprecated
2439         */
2440        @Deprecated
2441        public static final String NOTIFICATIONS_USE_RING_VOLUME =
2442            "notifications_use_ring_volume";
2443
2444        private static final Validator NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR = sBooleanValidator;
2445
2446        /**
2447         * Whether silent mode should allow vibration feedback. This is used
2448         * internally in AudioService and the Sound settings activity to
2449         * coordinate decoupling of vibrate and silent modes. This setting
2450         * will likely be removed in a future release with support for
2451         * audio/vibe feedback profiles.
2452         *
2453         * Not used anymore. On devices with vibrator, the user explicitly selects
2454         * silent or vibrate mode.
2455         * Kept for use by legacy database upgrade code in DatabaseHelper.
2456         * @hide
2457         */
2458        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
2459
2460        private static final Validator VIBRATE_IN_SILENT_VALIDATOR = sBooleanValidator;
2461
2462        /**
2463         * The mapping of stream type (integer) to its setting.
2464         *
2465         * @removed  Not used by anything since API 2.
2466         */
2467        public static final String[] VOLUME_SETTINGS = {
2468            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
2469            VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO
2470        };
2471
2472        /**
2473         * Appended to various volume related settings to record the previous
2474         * values before they the settings were affected by a silent/vibrate
2475         * ringer mode change.
2476         *
2477         * @removed  Not used by anything since API 2.
2478         */
2479        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
2480
2481        /**
2482         * Persistent store for the system-wide default ringtone URI.
2483         * <p>
2484         * If you need to play the default ringtone at any given time, it is recommended
2485         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
2486         * to the set default ringtone at the time of playing.
2487         *
2488         * @see #DEFAULT_RINGTONE_URI
2489         */
2490        public static final String RINGTONE = "ringtone";
2491
2492        private static final Validator RINGTONE_VALIDATOR = sUriValidator;
2493
2494        /**
2495         * A {@link Uri} that will point to the current default ringtone at any
2496         * given time.
2497         * <p>
2498         * If the current default ringtone is in the DRM provider and the caller
2499         * does not have permission, the exception will be a
2500         * FileNotFoundException.
2501         */
2502        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
2503
2504        /**
2505         * Persistent store for the system-wide default notification sound.
2506         *
2507         * @see #RINGTONE
2508         * @see #DEFAULT_NOTIFICATION_URI
2509         */
2510        public static final String NOTIFICATION_SOUND = "notification_sound";
2511
2512        private static final Validator NOTIFICATION_SOUND_VALIDATOR = sUriValidator;
2513
2514        /**
2515         * A {@link Uri} that will point to the current default notification
2516         * sound at any given time.
2517         *
2518         * @see #DEFAULT_RINGTONE_URI
2519         */
2520        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
2521
2522        /**
2523         * Persistent store for the system-wide default alarm alert.
2524         *
2525         * @see #RINGTONE
2526         * @see #DEFAULT_ALARM_ALERT_URI
2527         */
2528        public static final String ALARM_ALERT = "alarm_alert";
2529
2530        private static final Validator ALARM_ALERT_VALIDATOR = sUriValidator;
2531
2532        /**
2533         * A {@link Uri} that will point to the current default alarm alert at
2534         * any given time.
2535         *
2536         * @see #DEFAULT_ALARM_ALERT_URI
2537         */
2538        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
2539
2540        /**
2541         * Persistent store for the system default media button event receiver.
2542         *
2543         * @hide
2544         */
2545        public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver";
2546
2547        private static final Validator MEDIA_BUTTON_RECEIVER_VALIDATOR = new Validator() {
2548            @Override
2549            public boolean validate(String value) {
2550                try {
2551                    ComponentName.unflattenFromString(value);
2552                    return true;
2553                } catch (NullPointerException e) {
2554                    return false;
2555                }
2556            }
2557        };
2558
2559        /**
2560         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
2561         */
2562        public static final String TEXT_AUTO_REPLACE = "auto_replace";
2563
2564        private static final Validator TEXT_AUTO_REPLACE_VALIDATOR = sBooleanValidator;
2565
2566        /**
2567         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
2568         */
2569        public static final String TEXT_AUTO_CAPS = "auto_caps";
2570
2571        private static final Validator TEXT_AUTO_CAPS_VALIDATOR = sBooleanValidator;
2572
2573        /**
2574         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
2575         * feature converts two spaces to a "." and space.
2576         */
2577        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
2578
2579        private static final Validator TEXT_AUTO_PUNCTUATE_VALIDATOR = sBooleanValidator;
2580
2581        /**
2582         * Setting to showing password characters in text editors. 1 = On, 0 = Off
2583         */
2584        public static final String TEXT_SHOW_PASSWORD = "show_password";
2585
2586        private static final Validator TEXT_SHOW_PASSWORD_VALIDATOR = sBooleanValidator;
2587
2588        public static final String SHOW_GTALK_SERVICE_STATUS =
2589                "SHOW_GTALK_SERVICE_STATUS";
2590
2591        private static final Validator SHOW_GTALK_SERVICE_STATUS_VALIDATOR = sBooleanValidator;
2592
2593        /**
2594         * Name of activity to use for wallpaper on the home screen.
2595         *
2596         * @deprecated Use {@link WallpaperManager} instead.
2597         */
2598        @Deprecated
2599        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
2600
2601        private static final Validator WALLPAPER_ACTIVITY_VALIDATOR = new Validator() {
2602            private static final int MAX_LENGTH = 1000;
2603
2604            @Override
2605            public boolean validate(String value) {
2606                if (value != null && value.length() > MAX_LENGTH) {
2607                    return false;
2608                }
2609                return ComponentName.unflattenFromString(value) != null;
2610            }
2611        };
2612
2613        /**
2614         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME}
2615         * instead
2616         */
2617        @Deprecated
2618        public static final String AUTO_TIME = Global.AUTO_TIME;
2619
2620        /**
2621         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE}
2622         * instead
2623         */
2624        @Deprecated
2625        public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE;
2626
2627        /**
2628         * Display times as 12 or 24 hours
2629         *   12
2630         *   24
2631         */
2632        public static final String TIME_12_24 = "time_12_24";
2633
2634        /** @hide */
2635        public static final Validator TIME_12_24_VALIDATOR =
2636                new DiscreteValueValidator(new String[] {"12", "24"});
2637
2638        /**
2639         * Date format string
2640         *   mm/dd/yyyy
2641         *   dd/mm/yyyy
2642         *   yyyy/mm/dd
2643         */
2644        public static final String DATE_FORMAT = "date_format";
2645
2646        /** @hide */
2647        public static final Validator DATE_FORMAT_VALIDATOR = new Validator() {
2648            @Override
2649            public boolean validate(String value) {
2650                try {
2651                    new SimpleDateFormat(value);
2652                    return true;
2653                } catch (IllegalArgumentException e) {
2654                    return false;
2655                }
2656            }
2657        };
2658
2659        /**
2660         * Whether the setup wizard has been run before (on first boot), or if
2661         * it still needs to be run.
2662         *
2663         * nonzero = it has been run in the past
2664         * 0 = it has not been run in the past
2665         */
2666        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
2667
2668        /** @hide */
2669        public static final Validator SETUP_WIZARD_HAS_RUN_VALIDATOR = sBooleanValidator;
2670
2671        /**
2672         * Scaling factor for normal window animations. Setting to 0 will disable window
2673         * animations.
2674         *
2675         * @deprecated Use {@link Global#WINDOW_ANIMATION_SCALE} instead
2676         */
2677        @Deprecated
2678        public static final String WINDOW_ANIMATION_SCALE = Global.WINDOW_ANIMATION_SCALE;
2679
2680        /**
2681         * Scaling factor for activity transition animations. Setting to 0 will disable window
2682         * animations.
2683         *
2684         * @deprecated Use {@link Global#TRANSITION_ANIMATION_SCALE} instead
2685         */
2686        @Deprecated
2687        public static final String TRANSITION_ANIMATION_SCALE = Global.TRANSITION_ANIMATION_SCALE;
2688
2689        /**
2690         * Scaling factor for Animator-based animations. This affects both the start delay and
2691         * duration of all such animations. Setting to 0 will cause animations to end immediately.
2692         * The default value is 1.
2693         *
2694         * @deprecated Use {@link Global#ANIMATOR_DURATION_SCALE} instead
2695         */
2696        @Deprecated
2697        public static final String ANIMATOR_DURATION_SCALE = Global.ANIMATOR_DURATION_SCALE;
2698
2699        /**
2700         * Control whether the accelerometer will be used to change screen
2701         * orientation.  If 0, it will not be used unless explicitly requested
2702         * by the application; if 1, it will be used by default unless explicitly
2703         * disabled by the application.
2704         */
2705        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
2706
2707        /** @hide */
2708        public static final Validator ACCELEROMETER_ROTATION_VALIDATOR = sBooleanValidator;
2709
2710        /**
2711         * Default screen rotation when no other policy applies.
2712         * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
2713         * preference, this rotation value will be used. Must be one of the
2714         * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
2715         *
2716         * @see android.view.Display#getRotation
2717         */
2718        public static final String USER_ROTATION = "user_rotation";
2719
2720        /** @hide */
2721        public static final Validator USER_ROTATION_VALIDATOR =
2722                new InclusiveIntegerRangeValidator(0, 3);
2723
2724        /**
2725         * Control whether the rotation lock toggle in the System UI should be hidden.
2726         * Typically this is done for accessibility purposes to make it harder for
2727         * the user to accidentally toggle the rotation lock while the display rotation
2728         * has been locked for accessibility.
2729         *
2730         * If 0, then rotation lock toggle is not hidden for accessibility (although it may be
2731         * unavailable for other reasons).  If 1, then the rotation lock toggle is hidden.
2732         *
2733         * @hide
2734         */
2735        public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY =
2736                "hide_rotation_lock_toggle_for_accessibility";
2737
2738        /** @hide */
2739        public static final Validator HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR =
2740                sBooleanValidator;
2741
2742        /**
2743         * Whether the phone vibrates when it is ringing due to an incoming call. This will
2744         * be used by Phone and Setting apps; it shouldn't affect other apps.
2745         * The value is boolean (1 or 0).
2746         *
2747         * Note: this is not same as "vibrate on ring", which had been available until ICS.
2748         * It was about AudioManager's setting and thus affected all the applications which
2749         * relied on the setting, while this is purely about the vibration setting for incoming
2750         * calls.
2751         *
2752         * @hide
2753         */
2754        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
2755
2756        /** @hide */
2757        public static final Validator VIBRATE_WHEN_RINGING_VALIDATOR = sBooleanValidator;
2758
2759        /**
2760         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
2761         * boolean (1 or 0).
2762         */
2763        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
2764
2765        /** @hide */
2766        public static final Validator DTMF_TONE_WHEN_DIALING_VALIDATOR = sBooleanValidator;
2767
2768        /**
2769         * CDMA only settings
2770         * DTMF tone type played by the dialer when dialing.
2771         *                 0 = Normal
2772         *                 1 = Long
2773         * @hide
2774         */
2775        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
2776
2777        /** @hide */
2778        public static final Validator DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR = sBooleanValidator;
2779
2780        /**
2781         * Whether the hearing aid is enabled. The value is
2782         * boolean (1 or 0).
2783         * @hide
2784         */
2785        public static final String HEARING_AID = "hearing_aid";
2786
2787        /** @hide */
2788        public static final Validator HEARING_AID_VALIDATOR = sBooleanValidator;
2789
2790        /**
2791         * CDMA only settings
2792         * TTY Mode
2793         * 0 = OFF
2794         * 1 = FULL
2795         * 2 = VCO
2796         * 3 = HCO
2797         * @hide
2798         */
2799        public static final String TTY_MODE = "tty_mode";
2800
2801        /** @hide */
2802        public static final Validator TTY_MODE_VALIDATOR = new InclusiveIntegerRangeValidator(0, 3);
2803
2804        /**
2805         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
2806         * boolean (1 or 0).
2807         */
2808        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
2809
2810        /** @hide */
2811        public static final Validator SOUND_EFFECTS_ENABLED_VALIDATOR = sBooleanValidator;
2812
2813        /**
2814         * Whether the haptic feedback (long presses, ...) are enabled. The value is
2815         * boolean (1 or 0).
2816         */
2817        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
2818
2819        /** @hide */
2820        public static final Validator HAPTIC_FEEDBACK_ENABLED_VALIDATOR = sBooleanValidator;
2821
2822        /**
2823         * @deprecated Each application that shows web suggestions should have its own
2824         * setting for this.
2825         */
2826        @Deprecated
2827        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
2828
2829        /** @hide */
2830        public static final Validator SHOW_WEB_SUGGESTIONS_VALIDATOR = sBooleanValidator;
2831
2832        /**
2833         * Whether the notification LED should repeatedly flash when a notification is
2834         * pending. The value is boolean (1 or 0).
2835         * @hide
2836         */
2837        public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse";
2838
2839        /** @hide */
2840        public static final Validator NOTIFICATION_LIGHT_PULSE_VALIDATOR = sBooleanValidator;
2841
2842        /**
2843         * Show pointer location on screen?
2844         * 0 = no
2845         * 1 = yes
2846         * @hide
2847         */
2848        public static final String POINTER_LOCATION = "pointer_location";
2849
2850        /** @hide */
2851        public static final Validator POINTER_LOCATION_VALIDATOR = sBooleanValidator;
2852
2853        /**
2854         * Show touch positions on screen?
2855         * 0 = no
2856         * 1 = yes
2857         * @hide
2858         */
2859        public static final String SHOW_TOUCHES = "show_touches";
2860
2861        /** @hide */
2862        public static final Validator SHOW_TOUCHES_VALIDATOR = sBooleanValidator;
2863
2864        /**
2865         * Log raw orientation data from
2866         * {@link com.android.server.policy.WindowOrientationListener} for use with the
2867         * orientationplot.py tool.
2868         * 0 = no
2869         * 1 = yes
2870         * @hide
2871         */
2872        public static final String WINDOW_ORIENTATION_LISTENER_LOG =
2873                "window_orientation_listener_log";
2874
2875        /** @hide */
2876        public static final Validator WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR = sBooleanValidator;
2877
2878        /**
2879         * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED}
2880         * instead
2881         * @hide
2882         */
2883        @Deprecated
2884        public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED;
2885
2886        /**
2887         * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED}
2888         * instead
2889         * @hide
2890         */
2891        @Deprecated
2892        public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED;
2893
2894        /**
2895         * Whether to play sounds when the keyguard is shown and dismissed.
2896         * @hide
2897         */
2898        public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled";
2899
2900        /** @hide */
2901        public static final Validator LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR = sBooleanValidator;
2902
2903        /**
2904         * Whether the lockscreen should be completely disabled.
2905         * @hide
2906         */
2907        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";
2908
2909        /** @hide */
2910        public static final Validator LOCKSCREEN_DISABLED_VALIDATOR = sBooleanValidator;
2911
2912        /**
2913         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
2914         * instead
2915         * @hide
2916         */
2917        @Deprecated
2918        public static final String LOW_BATTERY_SOUND = Global.LOW_BATTERY_SOUND;
2919
2920        /**
2921         * @deprecated Use {@link android.provider.Settings.Global#DESK_DOCK_SOUND}
2922         * instead
2923         * @hide
2924         */
2925        @Deprecated
2926        public static final String DESK_DOCK_SOUND = Global.DESK_DOCK_SOUND;
2927
2928        /**
2929         * @deprecated Use {@link android.provider.Settings.Global#DESK_UNDOCK_SOUND}
2930         * instead
2931         * @hide
2932         */
2933        @Deprecated
2934        public static final String DESK_UNDOCK_SOUND = Global.DESK_UNDOCK_SOUND;
2935
2936        /**
2937         * @deprecated Use {@link android.provider.Settings.Global#CAR_DOCK_SOUND}
2938         * instead
2939         * @hide
2940         */
2941        @Deprecated
2942        public static final String CAR_DOCK_SOUND = Global.CAR_DOCK_SOUND;
2943
2944        /**
2945         * @deprecated Use {@link android.provider.Settings.Global#CAR_UNDOCK_SOUND}
2946         * instead
2947         * @hide
2948         */
2949        @Deprecated
2950        public static final String CAR_UNDOCK_SOUND = Global.CAR_UNDOCK_SOUND;
2951
2952        /**
2953         * @deprecated Use {@link android.provider.Settings.Global#LOCK_SOUND}
2954         * instead
2955         * @hide
2956         */
2957        @Deprecated
2958        public static final String LOCK_SOUND = Global.LOCK_SOUND;
2959
2960        /**
2961         * @deprecated Use {@link android.provider.Settings.Global#UNLOCK_SOUND}
2962         * instead
2963         * @hide
2964         */
2965        @Deprecated
2966        public static final String UNLOCK_SOUND = Global.UNLOCK_SOUND;
2967
2968        /**
2969         * Receive incoming SIP calls?
2970         * 0 = no
2971         * 1 = yes
2972         * @hide
2973         */
2974        public static final String SIP_RECEIVE_CALLS = "sip_receive_calls";
2975
2976        /** @hide */
2977        public static final Validator SIP_RECEIVE_CALLS_VALIDATOR = sBooleanValidator;
2978
2979        /**
2980         * Call Preference String.
2981         * "SIP_ALWAYS" : Always use SIP with network access
2982         * "SIP_ADDRESS_ONLY" : Only if destination is a SIP address
2983         * @hide
2984         */
2985        public static final String SIP_CALL_OPTIONS = "sip_call_options";
2986
2987        /** @hide */
2988        public static final Validator SIP_CALL_OPTIONS_VALIDATOR = new DiscreteValueValidator(
2989                new String[] {"SIP_ALWAYS", "SIP_ADDRESS_ONLY"});
2990
2991        /**
2992         * One of the sip call options: Always use SIP with network access.
2993         * @hide
2994         */
2995        public static final String SIP_ALWAYS = "SIP_ALWAYS";
2996
2997        /** @hide */
2998        public static final Validator SIP_ALWAYS_VALIDATOR = sBooleanValidator;
2999
3000        /**
3001         * One of the sip call options: Only if destination is a SIP address.
3002         * @hide
3003         */
3004        public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY";
3005
3006        /** @hide */
3007        public static final Validator SIP_ADDRESS_ONLY_VALIDATOR = sBooleanValidator;
3008
3009        /**
3010         * @deprecated Use SIP_ALWAYS or SIP_ADDRESS_ONLY instead.  Formerly used to indicate that
3011         * the user should be prompted each time a call is made whether it should be placed using
3012         * SIP.  The {@link com.android.providers.settings.DatabaseHelper} replaces this with
3013         * SIP_ADDRESS_ONLY.
3014         * @hide
3015         */
3016        @Deprecated
3017        public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME";
3018
3019        /** @hide */
3020        public static final Validator SIP_ASK_ME_EACH_TIME_VALIDATOR = sBooleanValidator;
3021
3022        /**
3023         * Pointer speed setting.
3024         * This is an integer value in a range between -7 and +7, so there are 15 possible values.
3025         *   -7 = slowest
3026         *    0 = default speed
3027         *   +7 = fastest
3028         * @hide
3029         */
3030        public static final String POINTER_SPEED = "pointer_speed";
3031
3032        /** @hide */
3033        public static final Validator POINTER_SPEED_VALIDATOR =
3034                new InclusiveFloatRangeValidator(-7, 7);
3035
3036        /**
3037         * Whether lock-to-app will be triggered by long-press on recents.
3038         * @hide
3039         */
3040        public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled";
3041
3042        /** @hide */
3043        public static final Validator LOCK_TO_APP_ENABLED_VALIDATOR = sBooleanValidator;
3044
3045        /**
3046         * I am the lolrus.
3047         * <p>
3048         * Nonzero values indicate that the user has a bukkit.
3049         * Backward-compatible with <code>PrefGetPreference(prefAllowEasterEggs)</code>.
3050         * @hide
3051         */
3052        public static final String EGG_MODE = "egg_mode";
3053
3054        /** @hide */
3055        public static final Validator EGG_MODE_VALIDATOR = sBooleanValidator;
3056
3057        /**
3058         * IMPORTANT: If you add a new public settings you also have to add it to
3059         * PUBLIC_SETTINGS below. If the new setting is hidden you have to add
3060         * it to PRIVATE_SETTINGS below. Also add a validator that can validate
3061         * the setting value. See an example above.
3062         */
3063
3064        /**
3065         * Settings to backup. This is here so that it's in the same place as the settings
3066         * keys and easy to update.
3067         *
3068         * NOTE: Settings are backed up and restored in the order they appear
3069         *       in this array. If you have one setting depending on another,
3070         *       make sure that they are ordered appropriately.
3071         *
3072         * @hide
3073         */
3074        public static final String[] SETTINGS_TO_BACKUP = {
3075            STAY_ON_WHILE_PLUGGED_IN,   // moved to global
3076            WIFI_USE_STATIC_IP,
3077            WIFI_STATIC_IP,
3078            WIFI_STATIC_GATEWAY,
3079            WIFI_STATIC_NETMASK,
3080            WIFI_STATIC_DNS1,
3081            WIFI_STATIC_DNS2,
3082            BLUETOOTH_DISCOVERABILITY,
3083            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
3084            DIM_SCREEN,
3085            SCREEN_OFF_TIMEOUT,
3086            SCREEN_BRIGHTNESS,
3087            SCREEN_BRIGHTNESS_MODE,
3088            SCREEN_AUTO_BRIGHTNESS_ADJ,
3089            VIBRATE_INPUT_DEVICES,
3090            MODE_RINGER_STREAMS_AFFECTED,
3091            TEXT_AUTO_REPLACE,
3092            TEXT_AUTO_CAPS,
3093            TEXT_AUTO_PUNCTUATE,
3094            TEXT_SHOW_PASSWORD,
3095            AUTO_TIME,                  // moved to global
3096            AUTO_TIME_ZONE,             // moved to global
3097            TIME_12_24,
3098            DATE_FORMAT,
3099            DTMF_TONE_WHEN_DIALING,
3100            DTMF_TONE_TYPE_WHEN_DIALING,
3101            HEARING_AID,
3102            TTY_MODE,
3103            SOUND_EFFECTS_ENABLED,
3104            HAPTIC_FEEDBACK_ENABLED,
3105            POWER_SOUNDS_ENABLED,       // moved to global
3106            DOCK_SOUNDS_ENABLED,        // moved to global
3107            LOCKSCREEN_SOUNDS_ENABLED,
3108            SHOW_WEB_SUGGESTIONS,
3109            NOTIFICATION_LIGHT_PULSE,
3110            SIP_CALL_OPTIONS,
3111            SIP_RECEIVE_CALLS,
3112            POINTER_SPEED,
3113            VIBRATE_WHEN_RINGING,
3114            RINGTONE,
3115            LOCK_TO_APP_ENABLED,
3116            NOTIFICATION_SOUND
3117        };
3118
3119        /**
3120         * These are all public system settings
3121         *
3122         * @hide
3123         */
3124        public static final Set<String> PUBLIC_SETTINGS = new ArraySet<>();
3125        static {
3126            PUBLIC_SETTINGS.add(END_BUTTON_BEHAVIOR);
3127            PUBLIC_SETTINGS.add(WIFI_USE_STATIC_IP);
3128            PUBLIC_SETTINGS.add(WIFI_STATIC_IP);
3129            PUBLIC_SETTINGS.add(WIFI_STATIC_GATEWAY);
3130            PUBLIC_SETTINGS.add(WIFI_STATIC_NETMASK);
3131            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS1);
3132            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS2);
3133            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY);
3134            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY_TIMEOUT);
3135            PUBLIC_SETTINGS.add(NEXT_ALARM_FORMATTED);
3136            PUBLIC_SETTINGS.add(FONT_SCALE);
3137            PUBLIC_SETTINGS.add(DIM_SCREEN);
3138            PUBLIC_SETTINGS.add(SCREEN_OFF_TIMEOUT);
3139            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS);
3140            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS_MODE);
3141            PUBLIC_SETTINGS.add(MODE_RINGER_STREAMS_AFFECTED);
3142            PUBLIC_SETTINGS.add(MUTE_STREAMS_AFFECTED);
3143            PUBLIC_SETTINGS.add(VIBRATE_ON);
3144            PUBLIC_SETTINGS.add(VOLUME_RING);
3145            PUBLIC_SETTINGS.add(VOLUME_SYSTEM);
3146            PUBLIC_SETTINGS.add(VOLUME_VOICE);
3147            PUBLIC_SETTINGS.add(VOLUME_MUSIC);
3148            PUBLIC_SETTINGS.add(VOLUME_ALARM);
3149            PUBLIC_SETTINGS.add(VOLUME_NOTIFICATION);
3150            PUBLIC_SETTINGS.add(VOLUME_BLUETOOTH_SCO);
3151            PUBLIC_SETTINGS.add(RINGTONE);
3152            PUBLIC_SETTINGS.add(NOTIFICATION_SOUND);
3153            PUBLIC_SETTINGS.add(ALARM_ALERT);
3154            PUBLIC_SETTINGS.add(TEXT_AUTO_REPLACE);
3155            PUBLIC_SETTINGS.add(TEXT_AUTO_CAPS);
3156            PUBLIC_SETTINGS.add(TEXT_AUTO_PUNCTUATE);
3157            PUBLIC_SETTINGS.add(TEXT_SHOW_PASSWORD);
3158            PUBLIC_SETTINGS.add(SHOW_GTALK_SERVICE_STATUS);
3159            PUBLIC_SETTINGS.add(WALLPAPER_ACTIVITY);
3160            PUBLIC_SETTINGS.add(TIME_12_24);
3161            PUBLIC_SETTINGS.add(DATE_FORMAT);
3162            PUBLIC_SETTINGS.add(SETUP_WIZARD_HAS_RUN);
3163            PUBLIC_SETTINGS.add(ACCELEROMETER_ROTATION);
3164            PUBLIC_SETTINGS.add(USER_ROTATION);
3165            PUBLIC_SETTINGS.add(DTMF_TONE_WHEN_DIALING);
3166            PUBLIC_SETTINGS.add(SOUND_EFFECTS_ENABLED);
3167            PUBLIC_SETTINGS.add(HAPTIC_FEEDBACK_ENABLED);
3168            PUBLIC_SETTINGS.add(SHOW_WEB_SUGGESTIONS);
3169        }
3170
3171        /**
3172         * These are all hidden system settings.
3173         *
3174         * @hide
3175         */
3176        public static final Set<String> PRIVATE_SETTINGS = new ArraySet<>();
3177        static {
3178            PRIVATE_SETTINGS.add(WIFI_USE_STATIC_IP);
3179            PRIVATE_SETTINGS.add(END_BUTTON_BEHAVIOR);
3180            PRIVATE_SETTINGS.add(ADVANCED_SETTINGS);
3181            PRIVATE_SETTINGS.add(SCREEN_AUTO_BRIGHTNESS_ADJ);
3182            PRIVATE_SETTINGS.add(VIBRATE_INPUT_DEVICES);
3183            PRIVATE_SETTINGS.add(VOLUME_MASTER);
3184            PRIVATE_SETTINGS.add(VOLUME_MASTER_MUTE);
3185            PRIVATE_SETTINGS.add(MICROPHONE_MUTE);
3186            PRIVATE_SETTINGS.add(NOTIFICATIONS_USE_RING_VOLUME);
3187            PRIVATE_SETTINGS.add(VIBRATE_IN_SILENT);
3188            PRIVATE_SETTINGS.add(MEDIA_BUTTON_RECEIVER);
3189            PRIVATE_SETTINGS.add(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY);
3190            PRIVATE_SETTINGS.add(VIBRATE_WHEN_RINGING);
3191            PRIVATE_SETTINGS.add(DTMF_TONE_TYPE_WHEN_DIALING);
3192            PRIVATE_SETTINGS.add(HEARING_AID);
3193            PRIVATE_SETTINGS.add(TTY_MODE);
3194            PRIVATE_SETTINGS.add(NOTIFICATION_LIGHT_PULSE);
3195            PRIVATE_SETTINGS.add(POINTER_LOCATION);
3196            PRIVATE_SETTINGS.add(SHOW_TOUCHES);
3197            PRIVATE_SETTINGS.add(WINDOW_ORIENTATION_LISTENER_LOG);
3198            PRIVATE_SETTINGS.add(POWER_SOUNDS_ENABLED);
3199            PRIVATE_SETTINGS.add(DOCK_SOUNDS_ENABLED);
3200            PRIVATE_SETTINGS.add(LOCKSCREEN_SOUNDS_ENABLED);
3201            PRIVATE_SETTINGS.add(LOCKSCREEN_DISABLED);
3202            PRIVATE_SETTINGS.add(LOW_BATTERY_SOUND);
3203            PRIVATE_SETTINGS.add(DESK_DOCK_SOUND);
3204            PRIVATE_SETTINGS.add(DESK_UNDOCK_SOUND);
3205            PRIVATE_SETTINGS.add(CAR_DOCK_SOUND);
3206            PRIVATE_SETTINGS.add(CAR_UNDOCK_SOUND);
3207            PRIVATE_SETTINGS.add(LOCK_SOUND);
3208            PRIVATE_SETTINGS.add(UNLOCK_SOUND);
3209            PRIVATE_SETTINGS.add(SIP_RECEIVE_CALLS);
3210            PRIVATE_SETTINGS.add(SIP_CALL_OPTIONS);
3211            PRIVATE_SETTINGS.add(SIP_ALWAYS);
3212            PRIVATE_SETTINGS.add(SIP_ADDRESS_ONLY);
3213            PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME);
3214            PRIVATE_SETTINGS.add(POINTER_SPEED);
3215            PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED);
3216            PRIVATE_SETTINGS.add(EGG_MODE);
3217        }
3218
3219        /**
3220         * These are all public system settings
3221         *
3222         * @hide
3223         */
3224        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
3225        static {
3226            VALIDATORS.put(END_BUTTON_BEHAVIOR,END_BUTTON_BEHAVIOR_VALIDATOR);
3227            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
3228            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY, BLUETOOTH_DISCOVERABILITY_VALIDATOR);
3229            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY_TIMEOUT,
3230                    BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR);
3231            VALIDATORS.put(NEXT_ALARM_FORMATTED, NEXT_ALARM_FORMATTED_VALIDATOR);
3232            VALIDATORS.put(FONT_SCALE, FONT_SCALE_VALIDATOR);
3233            VALIDATORS.put(DIM_SCREEN, DIM_SCREEN_VALIDATOR);
3234            VALIDATORS.put(SCREEN_OFF_TIMEOUT, SCREEN_OFF_TIMEOUT_VALIDATOR);
3235            VALIDATORS.put(SCREEN_BRIGHTNESS, SCREEN_BRIGHTNESS_VALIDATOR);
3236            VALIDATORS.put(SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_VALIDATOR);
3237            VALIDATORS.put(MODE_RINGER_STREAMS_AFFECTED, MODE_RINGER_STREAMS_AFFECTED_VALIDATOR);
3238            VALIDATORS.put(MUTE_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED_VALIDATOR);
3239            VALIDATORS.put(VIBRATE_ON, VIBRATE_ON_VALIDATOR);
3240            VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR);
3241            VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR);
3242            VALIDATORS.put(ALARM_ALERT, ALARM_ALERT_VALIDATOR);
3243            VALIDATORS.put(TEXT_AUTO_REPLACE, TEXT_AUTO_REPLACE_VALIDATOR);
3244            VALIDATORS.put(TEXT_AUTO_CAPS, TEXT_AUTO_CAPS_VALIDATOR);
3245            VALIDATORS.put(TEXT_AUTO_PUNCTUATE, TEXT_AUTO_PUNCTUATE_VALIDATOR);
3246            VALIDATORS.put(TEXT_SHOW_PASSWORD, TEXT_SHOW_PASSWORD_VALIDATOR);
3247            VALIDATORS.put(SHOW_GTALK_SERVICE_STATUS, SHOW_GTALK_SERVICE_STATUS_VALIDATOR);
3248            VALIDATORS.put(WALLPAPER_ACTIVITY, WALLPAPER_ACTIVITY_VALIDATOR);
3249            VALIDATORS.put(TIME_12_24, TIME_12_24_VALIDATOR);
3250            VALIDATORS.put(DATE_FORMAT, DATE_FORMAT_VALIDATOR);
3251            VALIDATORS.put(SETUP_WIZARD_HAS_RUN, SETUP_WIZARD_HAS_RUN_VALIDATOR);
3252            VALIDATORS.put(ACCELEROMETER_ROTATION, ACCELEROMETER_ROTATION_VALIDATOR);
3253            VALIDATORS.put(USER_ROTATION, USER_ROTATION_VALIDATOR);
3254            VALIDATORS.put(DTMF_TONE_WHEN_DIALING, DTMF_TONE_WHEN_DIALING_VALIDATOR);
3255            VALIDATORS.put(SOUND_EFFECTS_ENABLED, SOUND_EFFECTS_ENABLED_VALIDATOR);
3256            VALIDATORS.put(HAPTIC_FEEDBACK_ENABLED, HAPTIC_FEEDBACK_ENABLED_VALIDATOR);
3257            VALIDATORS.put(SHOW_WEB_SUGGESTIONS, SHOW_WEB_SUGGESTIONS_VALIDATOR);
3258            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
3259            VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR);
3260            VALIDATORS.put(ADVANCED_SETTINGS, ADVANCED_SETTINGS_VALIDATOR);
3261            VALIDATORS.put(SCREEN_AUTO_BRIGHTNESS_ADJ, SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR);
3262            VALIDATORS.put(VIBRATE_INPUT_DEVICES, VIBRATE_INPUT_DEVICES_VALIDATOR);
3263            VALIDATORS.put(VOLUME_MASTER_MUTE, VOLUME_MASTER_MUTE_VALIDATOR);
3264            VALIDATORS.put(MICROPHONE_MUTE, MICROPHONE_MUTE_VALIDATOR);
3265            VALIDATORS.put(NOTIFICATIONS_USE_RING_VOLUME, NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR);
3266            VALIDATORS.put(VIBRATE_IN_SILENT, VIBRATE_IN_SILENT_VALIDATOR);
3267            VALIDATORS.put(MEDIA_BUTTON_RECEIVER, MEDIA_BUTTON_RECEIVER_VALIDATOR);
3268            VALIDATORS.put(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY,
3269                    HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR);
3270            VALIDATORS.put(VIBRATE_WHEN_RINGING, VIBRATE_WHEN_RINGING_VALIDATOR);
3271            VALIDATORS.put(DTMF_TONE_TYPE_WHEN_DIALING, DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR);
3272            VALIDATORS.put(HEARING_AID, HEARING_AID_VALIDATOR);
3273            VALIDATORS.put(TTY_MODE, TTY_MODE_VALIDATOR);
3274            VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, NOTIFICATION_LIGHT_PULSE_VALIDATOR);
3275            VALIDATORS.put(POINTER_LOCATION, POINTER_LOCATION_VALIDATOR);
3276            VALIDATORS.put(SHOW_TOUCHES, SHOW_TOUCHES_VALIDATOR);
3277            VALIDATORS.put(WINDOW_ORIENTATION_LISTENER_LOG,
3278                    WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR);
3279            VALIDATORS.put(LOCKSCREEN_SOUNDS_ENABLED, LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR);
3280            VALIDATORS.put(LOCKSCREEN_DISABLED, LOCKSCREEN_DISABLED_VALIDATOR);
3281            VALIDATORS.put(SIP_RECEIVE_CALLS, SIP_RECEIVE_CALLS_VALIDATOR);
3282            VALIDATORS.put(SIP_CALL_OPTIONS, SIP_CALL_OPTIONS_VALIDATOR);
3283            VALIDATORS.put(SIP_ALWAYS, SIP_ALWAYS_VALIDATOR);
3284            VALIDATORS.put(SIP_ADDRESS_ONLY, SIP_ADDRESS_ONLY_VALIDATOR);
3285            VALIDATORS.put(SIP_ASK_ME_EACH_TIME, SIP_ASK_ME_EACH_TIME_VALIDATOR);
3286            VALIDATORS.put(POINTER_SPEED, POINTER_SPEED_VALIDATOR);
3287            VALIDATORS.put(LOCK_TO_APP_ENABLED, LOCK_TO_APP_ENABLED_VALIDATOR);
3288            VALIDATORS.put(EGG_MODE, EGG_MODE_VALIDATOR);
3289            VALIDATORS.put(WIFI_STATIC_IP, WIFI_STATIC_IP_VALIDATOR);
3290            VALIDATORS.put(WIFI_STATIC_GATEWAY, WIFI_STATIC_GATEWAY_VALIDATOR);
3291            VALIDATORS.put(WIFI_STATIC_NETMASK, WIFI_STATIC_NETMASK_VALIDATOR);
3292            VALIDATORS.put(WIFI_STATIC_DNS1, WIFI_STATIC_DNS1_VALIDATOR);
3293            VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR);
3294        }
3295
3296        /**
3297         * These entries are considered common between the personal and the managed profile,
3298         * since the managed profile doesn't get to change them.
3299         */
3300        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
3301        static {
3302            CLONE_TO_MANAGED_PROFILE.add(DATE_FORMAT);
3303            CLONE_TO_MANAGED_PROFILE.add(HAPTIC_FEEDBACK_ENABLED);
3304            CLONE_TO_MANAGED_PROFILE.add(SOUND_EFFECTS_ENABLED);
3305            CLONE_TO_MANAGED_PROFILE.add(TEXT_SHOW_PASSWORD);
3306            CLONE_TO_MANAGED_PROFILE.add(TIME_12_24);
3307        }
3308
3309        /** @hide */
3310        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
3311            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
3312        }
3313
3314        /**
3315         * When to use Wi-Fi calling
3316         *
3317         * @see android.telephony.TelephonyManager.WifiCallingChoices
3318         * @hide
3319         */
3320        public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls";
3321
3322        // Settings moved to Settings.Secure
3323
3324        /**
3325         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED}
3326         * instead
3327         */
3328        @Deprecated
3329        public static final String ADB_ENABLED = Global.ADB_ENABLED;
3330
3331        /**
3332         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
3333         */
3334        @Deprecated
3335        public static final String ANDROID_ID = Secure.ANDROID_ID;
3336
3337        /**
3338         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
3339         */
3340        @Deprecated
3341        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
3342
3343        /**
3344         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
3345         */
3346        @Deprecated
3347        public static final String DATA_ROAMING = Global.DATA_ROAMING;
3348
3349        /**
3350         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
3351         */
3352        @Deprecated
3353        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
3354
3355        /**
3356         * @deprecated Use {@link android.provider.Settings.Global#HTTP_PROXY} instead
3357         */
3358        @Deprecated
3359        public static final String HTTP_PROXY = Global.HTTP_PROXY;
3360
3361        /**
3362         * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
3363         */
3364        @Deprecated
3365        public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
3366
3367        /**
3368         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
3369         * instead
3370         */
3371        @Deprecated
3372        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
3373
3374        /**
3375         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
3376         */
3377        @Deprecated
3378        public static final String LOGGING_ID = Secure.LOGGING_ID;
3379
3380        /**
3381         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
3382         */
3383        @Deprecated
3384        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
3385
3386        /**
3387         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
3388         * instead
3389         */
3390        @Deprecated
3391        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
3392
3393        /**
3394         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
3395         * instead
3396         */
3397        @Deprecated
3398        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
3399
3400        /**
3401         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
3402         * instead
3403         */
3404        @Deprecated
3405        public static final String PARENTAL_CONTROL_REDIRECT_URL =
3406            Secure.PARENTAL_CONTROL_REDIRECT_URL;
3407
3408        /**
3409         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
3410         */
3411        @Deprecated
3412        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
3413
3414        /**
3415         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
3416         */
3417        @Deprecated
3418        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
3419
3420        /**
3421         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
3422         */
3423        @Deprecated
3424        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
3425
3426       /**
3427         * @deprecated Use
3428         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
3429         */
3430        @Deprecated
3431        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
3432
3433        /**
3434         * @deprecated Use
3435         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
3436         */
3437        @Deprecated
3438        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
3439                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
3440
3441        /**
3442         * @deprecated Use
3443         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
3444         */
3445        @Deprecated
3446        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3447                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
3448
3449        /**
3450         * @deprecated Use
3451         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
3452         */
3453        @Deprecated
3454        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
3455                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
3456
3457        /**
3458         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
3459         * instead
3460         */
3461        @Deprecated
3462        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
3463
3464        /**
3465         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead
3466         */
3467        @Deprecated
3468        public static final String WIFI_ON = Global.WIFI_ON;
3469
3470        /**
3471         * @deprecated Use
3472         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
3473         * instead
3474         */
3475        @Deprecated
3476        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
3477                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
3478
3479        /**
3480         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
3481         */
3482        @Deprecated
3483        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
3484
3485        /**
3486         * @deprecated Use
3487         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
3488         */
3489        @Deprecated
3490        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
3491                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
3492
3493        /**
3494         * @deprecated Use
3495         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
3496         */
3497        @Deprecated
3498        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
3499                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
3500
3501        /**
3502         * @deprecated Use
3503         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
3504         * instead
3505         */
3506        @Deprecated
3507        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
3508                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
3509
3510        /**
3511         * @deprecated Use
3512         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
3513         */
3514        @Deprecated
3515        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
3516            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
3517
3518        /**
3519         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
3520         * instead
3521         */
3522        @Deprecated
3523        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
3524
3525        /**
3526         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
3527         */
3528        @Deprecated
3529        public static final String WIFI_WATCHDOG_ON = Global.WIFI_WATCHDOG_ON;
3530
3531        /**
3532         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
3533         */
3534        @Deprecated
3535        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
3536
3537        /**
3538         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
3539         * instead
3540         */
3541        @Deprecated
3542        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
3543
3544        /**
3545         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
3546         * instead
3547         */
3548        @Deprecated
3549        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
3550            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
3551    }
3552
3553    /**
3554     * Secure system settings, containing system preferences that applications
3555     * can read but are not allowed to write.  These are for preferences that
3556     * the user must explicitly modify through the system UI or specialized
3557     * APIs for those values, not modified directly by applications.
3558     */
3559    public static final class Secure extends NameValueTable {
3560        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
3561
3562        /**
3563         * The content:// style URL for this table
3564         */
3565        public static final Uri CONTENT_URI =
3566            Uri.parse("content://" + AUTHORITY + "/secure");
3567
3568        // Populated lazily, guarded by class object:
3569        private static final NameValueCache sNameValueCache = new NameValueCache(
3570                SYS_PROP_SETTING_VERSION,
3571                CONTENT_URI,
3572                CALL_METHOD_GET_SECURE,
3573                CALL_METHOD_PUT_SECURE);
3574
3575        private static ILockSettings sLockSettings = null;
3576
3577        private static boolean sIsSystemProcess;
3578        private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
3579        private static final HashSet<String> MOVED_TO_GLOBAL;
3580        static {
3581            MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
3582            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
3583            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
3584            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
3585
3586            MOVED_TO_GLOBAL = new HashSet<String>();
3587            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
3588            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
3589            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
3590            MOVED_TO_GLOBAL.add(Settings.Global.BUGREPORT_IN_POWER_MENU);
3591            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
3592            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
3593            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
3594            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE);
3595            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI);
3596            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
3597            MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
3598            MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
3599            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_DENSITY_FORCED);
3600            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
3601            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
3602            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
3603            MOVED_TO_GLOBAL.add(Settings.Global.MOBILE_DATA);
3604            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION);
3605            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_DELETE_AGE);
3606            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES);
3607            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE);
3608            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_ENABLED);
3609            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES);
3610            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_POLL_INTERVAL);
3611            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_SAMPLE_ENABLED);
3612            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE);
3613            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION);
3614            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_DELETE_AGE);
3615            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES);
3616            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_ROTATE_AGE);
3617            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION);
3618            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE);
3619            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES);
3620            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE);
3621            MOVED_TO_GLOBAL.add(Settings.Global.NETWORK_PREFERENCE);
3622            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_DIFF);
3623            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_SPACING);
3624            MOVED_TO_GLOBAL.add(Settings.Global.NTP_SERVER);
3625            MOVED_TO_GLOBAL.add(Settings.Global.NTP_TIMEOUT);
3626            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT);
3627            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS);
3628            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT);
3629            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS);
3630            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT);
3631            MOVED_TO_GLOBAL.add(Settings.Global.SAMPLING_PROFILER_MS);
3632            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
3633            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST);
3634            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL);
3635            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_APN);
3636            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_REQUIRED);
3637            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_SUPPORTED);
3638            MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED);
3639            MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL);
3640            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE);
3641            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS);
3642            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND);
3643            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS);
3644            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT);
3645            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS);
3646            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
3647            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
3648            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT);
3649            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
3650            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
3651            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
3652            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
3653            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
3654            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ENHANCED_AUTO_JOIN);
3655            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORK_SHOW_RSSI);
3656            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
3657            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
3658            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
3659            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_ENABLE);
3660            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT);
3661            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE);
3662            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS);
3663            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS);
3664            MOVED_TO_GLOBAL.add(Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS);
3665            MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
3666            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD);
3667            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_THRESHOLD);
3668            MOVED_TO_GLOBAL.add(Settings.Global.SEND_ACTION_APP_ERROR);
3669            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_AGE_SECONDS);
3670            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_MAX_FILES);
3671            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_KB);
3672            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_PERCENT);
3673            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_RESERVE_PERCENT);
3674            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_TAG_PREFIX);
3675            MOVED_TO_GLOBAL.add(Settings.Global.ERROR_LOGCAT_PREFIX);
3676            MOVED_TO_GLOBAL.add(Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL);
3677            MOVED_TO_GLOBAL.add(Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD);
3678            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE);
3679            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES);
3680            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES);
3681            MOVED_TO_GLOBAL.add(Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS);
3682            MOVED_TO_GLOBAL.add(Settings.Global.CONNECTIVITY_CHANGE_DELAY);
3683            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED);
3684            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_SERVER);
3685            MOVED_TO_GLOBAL.add(Settings.Global.NSD_ON);
3686            MOVED_TO_GLOBAL.add(Settings.Global.SET_INSTALL_LOCATION);
3687            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_INSTALL_LOCATION);
3688            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY);
3689            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY);
3690            MOVED_TO_GLOBAL.add(Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT);
3691            MOVED_TO_GLOBAL.add(Settings.Global.HTTP_PROXY);
3692            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_HOST);
3693            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_PORT);
3694            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
3695            MOVED_TO_GLOBAL.add(Settings.Global.SET_GLOBAL_HTTP_PROXY);
3696            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_DNS_SERVER);
3697            MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_NETWORK_MODE);
3698            MOVED_TO_GLOBAL.add(Settings.Global.WEBVIEW_DATA_REDUCTION_PROXY_KEY);
3699        }
3700
3701        /** @hide */
3702        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
3703            outKeySet.addAll(MOVED_TO_GLOBAL);
3704        }
3705
3706        /**
3707         * Look up a name in the database.
3708         * @param resolver to access the database with
3709         * @param name to look up in the table
3710         * @return the corresponding value, or null if not present
3711         */
3712        public static String getString(ContentResolver resolver, String name) {
3713            return getStringForUser(resolver, name, UserHandle.myUserId());
3714        }
3715
3716        /** @hide */
3717        public static String getStringForUser(ContentResolver resolver, String name,
3718                int userHandle) {
3719            if (MOVED_TO_GLOBAL.contains(name)) {
3720                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
3721                        + " to android.provider.Settings.Global.");
3722                return Global.getStringForUser(resolver, name, userHandle);
3723            }
3724
3725            if (MOVED_TO_LOCK_SETTINGS.contains(name)) {
3726                synchronized (Secure.class) {
3727                    if (sLockSettings == null) {
3728                        sLockSettings = ILockSettings.Stub.asInterface(
3729                                (IBinder) ServiceManager.getService("lock_settings"));
3730                        sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
3731                    }
3732                }
3733                if (sLockSettings != null && !sIsSystemProcess) {
3734                    try {
3735                        return sLockSettings.getString(name, "0", userHandle);
3736                    } catch (RemoteException re) {
3737                        // Fall through
3738                    }
3739                }
3740            }
3741
3742            return sNameValueCache.getStringForUser(resolver, name, userHandle);
3743        }
3744
3745        /**
3746         * Store a name/value pair into the database.
3747         * @param resolver to access the database with
3748         * @param name to store
3749         * @param value to associate with the name
3750         * @return true if the value was set, false on database errors
3751         */
3752        public static boolean putString(ContentResolver resolver, String name, String value) {
3753            return putStringForUser(resolver, name, value, UserHandle.myUserId());
3754        }
3755
3756        /** @hide */
3757        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
3758                int userHandle) {
3759            if (LOCATION_MODE.equals(name)) {
3760                // HACK ALERT: temporary hack to work around b/10491283.
3761                // TODO: once b/10491283 fixed, remove this hack
3762                return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle);
3763            }
3764            if (MOVED_TO_GLOBAL.contains(name)) {
3765                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
3766                        + " to android.provider.Settings.Global");
3767                return Global.putStringForUser(resolver, name, value, userHandle);
3768            }
3769            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
3770        }
3771
3772        /**
3773         * Construct the content URI for a particular name/value pair,
3774         * useful for monitoring changes with a ContentObserver.
3775         * @param name to look up in the table
3776         * @return the corresponding content URI, or null if not present
3777         */
3778        public static Uri getUriFor(String name) {
3779            if (MOVED_TO_GLOBAL.contains(name)) {
3780                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
3781                        + " to android.provider.Settings.Global, returning global URI.");
3782                return Global.getUriFor(Global.CONTENT_URI, name);
3783            }
3784            return getUriFor(CONTENT_URI, name);
3785        }
3786
3787        /**
3788         * Convenience function for retrieving a single secure settings value
3789         * as an integer.  Note that internally setting values are always
3790         * stored as strings; this function converts the string to an integer
3791         * for you.  The default value will be returned if the setting is
3792         * not defined or not an integer.
3793         *
3794         * @param cr The ContentResolver to access.
3795         * @param name The name of the setting to retrieve.
3796         * @param def Value to return if the setting is not defined.
3797         *
3798         * @return The setting's current value, or 'def' if it is not defined
3799         * or not a valid integer.
3800         */
3801        public static int getInt(ContentResolver cr, String name, int def) {
3802            return getIntForUser(cr, name, def, UserHandle.myUserId());
3803        }
3804
3805        /** @hide */
3806        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
3807            if (LOCATION_MODE.equals(name)) {
3808                // HACK ALERT: temporary hack to work around b/10491283.
3809                // TODO: once b/10491283 fixed, remove this hack
3810                return getLocationModeForUser(cr, userHandle);
3811            }
3812            String v = getStringForUser(cr, name, userHandle);
3813            try {
3814                return v != null ? Integer.parseInt(v) : def;
3815            } catch (NumberFormatException e) {
3816                return def;
3817            }
3818        }
3819
3820        /**
3821         * Convenience function for retrieving a single secure settings value
3822         * as an integer.  Note that internally setting values are always
3823         * stored as strings; this function converts the string to an integer
3824         * for you.
3825         * <p>
3826         * This version does not take a default value.  If the setting has not
3827         * been set, or the string value is not a number,
3828         * it throws {@link SettingNotFoundException}.
3829         *
3830         * @param cr The ContentResolver to access.
3831         * @param name The name of the setting to retrieve.
3832         *
3833         * @throws SettingNotFoundException Thrown if a setting by the given
3834         * name can't be found or the setting value is not an integer.
3835         *
3836         * @return The setting's current value.
3837         */
3838        public static int getInt(ContentResolver cr, String name)
3839                throws SettingNotFoundException {
3840            return getIntForUser(cr, name, UserHandle.myUserId());
3841        }
3842
3843        /** @hide */
3844        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
3845                throws SettingNotFoundException {
3846            if (LOCATION_MODE.equals(name)) {
3847                // HACK ALERT: temporary hack to work around b/10491283.
3848                // TODO: once b/10491283 fixed, remove this hack
3849                return getLocationModeForUser(cr, userHandle);
3850            }
3851            String v = getStringForUser(cr, name, userHandle);
3852            try {
3853                return Integer.parseInt(v);
3854            } catch (NumberFormatException e) {
3855                throw new SettingNotFoundException(name);
3856            }
3857        }
3858
3859        /**
3860         * Convenience function for updating a single settings value as an
3861         * integer. This will either create a new entry in the table if the
3862         * given name does not exist, or modify the value of the existing row
3863         * with that name.  Note that internally setting values are always
3864         * stored as strings, so this function converts the given value to a
3865         * string before storing it.
3866         *
3867         * @param cr The ContentResolver to access.
3868         * @param name The name of the setting to modify.
3869         * @param value The new value for the setting.
3870         * @return true if the value was set, false on database errors
3871         */
3872        public static boolean putInt(ContentResolver cr, String name, int value) {
3873            return putIntForUser(cr, name, value, UserHandle.myUserId());
3874        }
3875
3876        /** @hide */
3877        public static boolean putIntForUser(ContentResolver cr, String name, int value,
3878                int userHandle) {
3879            return putStringForUser(cr, name, Integer.toString(value), userHandle);
3880        }
3881
3882        /**
3883         * Convenience function for retrieving a single secure settings value
3884         * as a {@code long}.  Note that internally setting values are always
3885         * stored as strings; this function converts the string to a {@code long}
3886         * for you.  The default value will be returned if the setting is
3887         * not defined or not a {@code long}.
3888         *
3889         * @param cr The ContentResolver to access.
3890         * @param name The name of the setting to retrieve.
3891         * @param def Value to return if the setting is not defined.
3892         *
3893         * @return The setting's current value, or 'def' if it is not defined
3894         * or not a valid {@code long}.
3895         */
3896        public static long getLong(ContentResolver cr, String name, long def) {
3897            return getLongForUser(cr, name, def, UserHandle.myUserId());
3898        }
3899
3900        /** @hide */
3901        public static long getLongForUser(ContentResolver cr, String name, long def,
3902                int userHandle) {
3903            String valString = getStringForUser(cr, name, userHandle);
3904            long value;
3905            try {
3906                value = valString != null ? Long.parseLong(valString) : def;
3907            } catch (NumberFormatException e) {
3908                value = def;
3909            }
3910            return value;
3911        }
3912
3913        /**
3914         * Convenience function for retrieving a single secure settings value
3915         * as a {@code long}.  Note that internally setting values are always
3916         * stored as strings; this function converts the string to a {@code long}
3917         * for you.
3918         * <p>
3919         * This version does not take a default value.  If the setting has not
3920         * been set, or the string value is not a number,
3921         * it throws {@link SettingNotFoundException}.
3922         *
3923         * @param cr The ContentResolver to access.
3924         * @param name The name of the setting to retrieve.
3925         *
3926         * @return The setting's current value.
3927         * @throws SettingNotFoundException Thrown if a setting by the given
3928         * name can't be found or the setting value is not an integer.
3929         */
3930        public static long getLong(ContentResolver cr, String name)
3931                throws SettingNotFoundException {
3932            return getLongForUser(cr, name, UserHandle.myUserId());
3933        }
3934
3935        /** @hide */
3936        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
3937                throws SettingNotFoundException {
3938            String valString = getStringForUser(cr, name, userHandle);
3939            try {
3940                return Long.parseLong(valString);
3941            } catch (NumberFormatException e) {
3942                throw new SettingNotFoundException(name);
3943            }
3944        }
3945
3946        /**
3947         * Convenience function for updating a secure settings value as a long
3948         * integer. This will either create a new entry in the table if the
3949         * given name does not exist, or modify the value of the existing row
3950         * with that name.  Note that internally setting values are always
3951         * stored as strings, so this function converts the given value to a
3952         * string before storing it.
3953         *
3954         * @param cr The ContentResolver to access.
3955         * @param name The name of the setting to modify.
3956         * @param value The new value for the setting.
3957         * @return true if the value was set, false on database errors
3958         */
3959        public static boolean putLong(ContentResolver cr, String name, long value) {
3960            return putLongForUser(cr, name, value, UserHandle.myUserId());
3961        }
3962
3963        /** @hide */
3964        public static boolean putLongForUser(ContentResolver cr, String name, long value,
3965                int userHandle) {
3966            return putStringForUser(cr, name, Long.toString(value), userHandle);
3967        }
3968
3969        /**
3970         * Convenience function for retrieving a single secure settings value
3971         * as a floating point number.  Note that internally setting values are
3972         * always stored as strings; this function converts the string to an
3973         * float for you. The default value will be returned if the setting
3974         * is not defined or not a valid float.
3975         *
3976         * @param cr The ContentResolver to access.
3977         * @param name The name of the setting to retrieve.
3978         * @param def Value to return if the setting is not defined.
3979         *
3980         * @return The setting's current value, or 'def' if it is not defined
3981         * or not a valid float.
3982         */
3983        public static float getFloat(ContentResolver cr, String name, float def) {
3984            return getFloatForUser(cr, name, def, UserHandle.myUserId());
3985        }
3986
3987        /** @hide */
3988        public static float getFloatForUser(ContentResolver cr, String name, float def,
3989                int userHandle) {
3990            String v = getStringForUser(cr, name, userHandle);
3991            try {
3992                return v != null ? Float.parseFloat(v) : def;
3993            } catch (NumberFormatException e) {
3994                return def;
3995            }
3996        }
3997
3998        /**
3999         * Convenience function for retrieving a single secure settings value
4000         * as a float.  Note that internally setting values are always
4001         * stored as strings; this function converts the string to a float
4002         * for you.
4003         * <p>
4004         * This version does not take a default value.  If the setting has not
4005         * been set, or the string value is not a number,
4006         * it throws {@link SettingNotFoundException}.
4007         *
4008         * @param cr The ContentResolver to access.
4009         * @param name The name of the setting to retrieve.
4010         *
4011         * @throws SettingNotFoundException Thrown if a setting by the given
4012         * name can't be found or the setting value is not a float.
4013         *
4014         * @return The setting's current value.
4015         */
4016        public static float getFloat(ContentResolver cr, String name)
4017                throws SettingNotFoundException {
4018            return getFloatForUser(cr, name, UserHandle.myUserId());
4019        }
4020
4021        /** @hide */
4022        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
4023                throws SettingNotFoundException {
4024            String v = getStringForUser(cr, name, userHandle);
4025            if (v == null) {
4026                throw new SettingNotFoundException(name);
4027            }
4028            try {
4029                return Float.parseFloat(v);
4030            } catch (NumberFormatException e) {
4031                throw new SettingNotFoundException(name);
4032            }
4033        }
4034
4035        /**
4036         * Convenience function for updating a single settings value as a
4037         * floating point number. This will either create a new entry in the
4038         * table if the given name does not exist, or modify the value of the
4039         * existing row with that name.  Note that internally setting values
4040         * are always stored as strings, so this function converts the given
4041         * value to a string before storing it.
4042         *
4043         * @param cr The ContentResolver to access.
4044         * @param name The name of the setting to modify.
4045         * @param value The new value for the setting.
4046         * @return true if the value was set, false on database errors
4047         */
4048        public static boolean putFloat(ContentResolver cr, String name, float value) {
4049            return putFloatForUser(cr, name, value, UserHandle.myUserId());
4050        }
4051
4052        /** @hide */
4053        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
4054                int userHandle) {
4055            return putStringForUser(cr, name, Float.toString(value), userHandle);
4056        }
4057
4058        /**
4059         * @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
4060         * instead
4061         */
4062        @Deprecated
4063        public static final String DEVELOPMENT_SETTINGS_ENABLED =
4064                Global.DEVELOPMENT_SETTINGS_ENABLED;
4065
4066        /**
4067         * When the user has enable the option to have a "bug report" command
4068         * in the power menu.
4069         * @deprecated Use {@link android.provider.Settings.Global#BUGREPORT_IN_POWER_MENU} instead
4070         * @hide
4071         */
4072        @Deprecated
4073        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
4074
4075        /**
4076         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
4077         */
4078        @Deprecated
4079        public static final String ADB_ENABLED = Global.ADB_ENABLED;
4080
4081        /**
4082         * Setting to allow mock locations and location provider status to be injected into the
4083         * LocationManager service for testing purposes during application development.  These
4084         * locations and status values  override actual location and status information generated
4085         * by network, gps, or other location providers.
4086         */
4087        public static final String ALLOW_MOCK_LOCATION = "mock_location";
4088
4089        /**
4090         * A 64-bit number (as a hex string) that is randomly
4091         * generated when the user first sets up the device and should remain
4092         * constant for the lifetime of the user's device. The value may
4093         * change if a factory reset is performed on the device.
4094         * <p class="note"><strong>Note:</strong> When a device has <a
4095         * href="{@docRoot}about/versions/android-4.2.html#MultipleUsers">multiple users</a>
4096         * (available on certain devices running Android 4.2 or higher), each user appears as a
4097         * completely separate device, so the {@code ANDROID_ID} value is unique to each
4098         * user.</p>
4099         */
4100        public static final String ANDROID_ID = "android_id";
4101
4102        /**
4103         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
4104         */
4105        @Deprecated
4106        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
4107
4108        /**
4109         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
4110         */
4111        @Deprecated
4112        public static final String DATA_ROAMING = Global.DATA_ROAMING;
4113
4114        /**
4115         * Setting to record the input method used by default, holding the ID
4116         * of the desired method.
4117         */
4118        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
4119
4120        /**
4121         * Setting to record the input method subtype used by default, holding the ID
4122         * of the desired method.
4123         */
4124        public static final String SELECTED_INPUT_METHOD_SUBTYPE =
4125                "selected_input_method_subtype";
4126
4127        /**
4128         * Setting to record the history of input method subtype, holding the pair of ID of IME
4129         * and its last used subtype.
4130         * @hide
4131         */
4132        public static final String INPUT_METHODS_SUBTYPE_HISTORY =
4133                "input_methods_subtype_history";
4134
4135        /**
4136         * Setting to record the visibility of input method selector
4137         */
4138        public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
4139                "input_method_selector_visibility";
4140
4141        /**
4142         * The currently selected voice interaction service flattened ComponentName.
4143         * @hide
4144         */
4145        public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
4146
4147        /**
4148         * bluetooth HCI snoop log configuration
4149         * @hide
4150         */
4151        public static final String BLUETOOTH_HCI_LOG =
4152                "bluetooth_hci_log";
4153
4154        /**
4155         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
4156         */
4157        @Deprecated
4158        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
4159
4160        /**
4161         * Whether the current user has been set up via setup wizard (0 = false, 1 = true)
4162         * @hide
4163         */
4164        public static final String USER_SETUP_COMPLETE = "user_setup_complete";
4165
4166        /**
4167         * List of input methods that are currently enabled.  This is a string
4168         * containing the IDs of all enabled input methods, each ID separated
4169         * by ':'.
4170         */
4171        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
4172
4173        /**
4174         * List of system input methods that are currently disabled.  This is a string
4175         * containing the IDs of all disabled input methods, each ID separated
4176         * by ':'.
4177         * @hide
4178         */
4179        public static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
4180
4181        /**
4182         * Whether to show the IME when a hard keyboard is connected. This is a boolean that
4183         * determines if the IME should be shown when a hard keyboard is attached.
4184         * @hide
4185         */
4186        public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
4187
4188        /**
4189         * Host name and port for global http proxy. Uses ':' seperator for
4190         * between host and port.
4191         *
4192         * @deprecated Use {@link Global#HTTP_PROXY}
4193         */
4194        @Deprecated
4195        public static final String HTTP_PROXY = Global.HTTP_PROXY;
4196
4197        /**
4198         * Whether applications can be installed for this user via the system's
4199         * {@link Intent#ACTION_INSTALL_PACKAGE} mechanism.
4200         *
4201         * <p>1 = permit app installation via the system package installer intent
4202         * <p>0 = do not allow use of the package installer
4203         */
4204        public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
4205
4206        /**
4207         * Comma-separated list of location providers that activities may access. Do not rely on
4208         * this value being present in settings.db or on ContentObserver notifications on the
4209         * corresponding Uri.
4210         *
4211         * @deprecated use {@link #LOCATION_MODE} and
4212         * {@link LocationManager#MODE_CHANGED_ACTION} (or
4213         * {@link LocationManager#PROVIDERS_CHANGED_ACTION})
4214         */
4215        @Deprecated
4216        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
4217
4218        /**
4219         * The degree of location access enabled by the user.
4220         * <p>
4221         * When used with {@link #putInt(ContentResolver, String, int)}, must be one of {@link
4222         * #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, {@link
4223         * #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. When used with {@link
4224         * #getInt(ContentResolver, String)}, the caller must gracefully handle additional location
4225         * modes that might be added in the future.
4226         * <p>
4227         * Note: do not rely on this value being present in settings.db or on ContentObserver
4228         * notifications for the corresponding Uri. Use {@link LocationManager#MODE_CHANGED_ACTION}
4229         * to receive changes in this value.
4230         */
4231        public static final String LOCATION_MODE = "location_mode";
4232
4233        /**
4234         * Location access disabled.
4235         */
4236        public static final int LOCATION_MODE_OFF = 0;
4237        /**
4238         * Network Location Provider disabled, but GPS and other sensors enabled.
4239         */
4240        public static final int LOCATION_MODE_SENSORS_ONLY = 1;
4241        /**
4242         * Reduced power usage, such as limiting the number of GPS updates per hour. Requests
4243         * with {@link android.location.Criteria#POWER_HIGH} may be downgraded to
4244         * {@link android.location.Criteria#POWER_MEDIUM}.
4245         */
4246        public static final int LOCATION_MODE_BATTERY_SAVING = 2;
4247        /**
4248         * Best-effort location computation allowed.
4249         */
4250        public static final int LOCATION_MODE_HIGH_ACCURACY = 3;
4251
4252        /**
4253         * A flag containing settings used for biometric weak
4254         * @hide
4255         */
4256        @Deprecated
4257        public static final String LOCK_BIOMETRIC_WEAK_FLAGS =
4258                "lock_biometric_weak_flags";
4259
4260        /**
4261         * Whether lock-to-app will lock the keyguard when exiting.
4262         * @hide
4263         */
4264        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";
4265
4266        /**
4267         * Whether autolock is enabled (0 = false, 1 = true)
4268         *
4269         * @deprecated Use {@link android.app.KeyguardManager} to determine the state and security
4270         *             level of the keyguard.
4271         */
4272        @Deprecated
4273        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
4274
4275        /**
4276         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
4277         */
4278        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
4279
4280        /**
4281         * Whether lock pattern will vibrate as user enters (0 = false, 1 =
4282         * true)
4283         *
4284         * @deprecated Starting in {@link VERSION_CODES#JELLY_BEAN_MR1} the
4285         *             lockscreen uses
4286         *             {@link Settings.System#HAPTIC_FEEDBACK_ENABLED}.
4287         */
4288        @Deprecated
4289        public static final String
4290                LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
4291
4292        /**
4293         * This preference allows the device to be locked given time after screen goes off,
4294         * subject to current DeviceAdmin policy limits.
4295         * @hide
4296         */
4297        public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout";
4298
4299
4300        /**
4301         * This preference contains the string that shows for owner info on LockScreen.
4302         * @hide
4303         * @deprecated
4304         */
4305        public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
4306
4307        /**
4308         * Ids of the user-selected appwidgets on the lockscreen (comma-delimited).
4309         * @hide
4310         */
4311        @Deprecated
4312        public static final String LOCK_SCREEN_APPWIDGET_IDS =
4313            "lock_screen_appwidget_ids";
4314
4315        /**
4316         * List of enrolled fingerprint identifiers (comma-delimited).
4317         * @hide
4318         */
4319        public static final String USER_FINGERPRINT_IDS = "user_fingerprint_ids";
4320
4321        /**
4322         * Id of the appwidget shown on the lock screen when appwidgets are disabled.
4323         * @hide
4324         */
4325        @Deprecated
4326        public static final String LOCK_SCREEN_FALLBACK_APPWIDGET_ID =
4327            "lock_screen_fallback_appwidget_id";
4328
4329        /**
4330         * Index of the lockscreen appwidget to restore, -1 if none.
4331         * @hide
4332         */
4333        @Deprecated
4334        public static final String LOCK_SCREEN_STICKY_APPWIDGET =
4335            "lock_screen_sticky_appwidget";
4336
4337        /**
4338         * This preference enables showing the owner info on LockScreen.
4339         * @hide
4340         * @deprecated
4341         */
4342        public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
4343            "lock_screen_owner_info_enabled";
4344
4345        /**
4346         * When set by a user, allows notifications to be shown atop a securely locked screen
4347         * in their full "private" form (same as when the device is unlocked).
4348         * @hide
4349         */
4350        public static final String LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS =
4351                "lock_screen_allow_private_notifications";
4352
4353        /**
4354         * Set by the system to track if the user needs to see the call to action for
4355         * the lockscreen notification policy.
4356         * @hide
4357         */
4358        public static final String SHOW_NOTE_ABOUT_NOTIFICATION_HIDING =
4359                "show_note_about_notification_hiding";
4360
4361        /**
4362         * Set to 1 by the system after trust agents have been initialized.
4363         * @hide
4364         */
4365        public static final String TRUST_AGENTS_INITIALIZED =
4366                "trust_agents_initialized";
4367
4368        /**
4369         * The Logging ID (a unique 64-bit value) as a hex string.
4370         * Used as a pseudonymous identifier for logging.
4371         * @deprecated This identifier is poorly initialized and has
4372         * many collisions.  It should not be used.
4373         */
4374        @Deprecated
4375        public static final String LOGGING_ID = "logging_id";
4376
4377        /**
4378         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
4379         */
4380        @Deprecated
4381        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
4382
4383        /**
4384         * No longer supported.
4385         */
4386        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
4387
4388        /**
4389         * No longer supported.
4390         */
4391        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
4392
4393        /**
4394         * No longer supported.
4395         */
4396        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
4397
4398        /**
4399         * Settings classname to launch when Settings is clicked from All
4400         * Applications.  Needed because of user testing between the old
4401         * and new Settings apps.
4402         */
4403        // TODO: 881807
4404        public static final String SETTINGS_CLASSNAME = "settings_classname";
4405
4406        /**
4407         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
4408         */
4409        @Deprecated
4410        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
4411
4412        /**
4413         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
4414         */
4415        @Deprecated
4416        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
4417
4418        /**
4419         * If accessibility is enabled.
4420         */
4421        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
4422
4423        /**
4424         * If touch exploration is enabled.
4425         */
4426        public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled";
4427
4428        /**
4429         * List of the enabled accessibility providers.
4430         */
4431        public static final String ENABLED_ACCESSIBILITY_SERVICES =
4432            "enabled_accessibility_services";
4433
4434        /**
4435         * List of the accessibility services to which the user has granted
4436         * permission to put the device into touch exploration mode.
4437         *
4438         * @hide
4439         */
4440        public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES =
4441            "touch_exploration_granted_accessibility_services";
4442
4443        /**
4444         * Whether to speak passwords while in accessibility mode.
4445         */
4446        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
4447
4448        /**
4449         * Whether to draw text with high contrast while in accessibility mode.
4450         *
4451         * @hide
4452         */
4453        public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED =
4454                "high_text_contrast_enabled";
4455
4456        /**
4457         * If injection of accessibility enhancing JavaScript screen-reader
4458         * is enabled.
4459         * <p>
4460         *   Note: The JavaScript based screen-reader is served by the
4461         *   Google infrastructure and enable users with disabilities to
4462         *   efficiently navigate in and explore web content.
4463         * </p>
4464         * <p>
4465         *   This property represents a boolean value.
4466         * </p>
4467         * @hide
4468         */
4469        public static final String ACCESSIBILITY_SCRIPT_INJECTION =
4470            "accessibility_script_injection";
4471
4472        /**
4473         * The URL for the injected JavaScript based screen-reader used
4474         * for providing accessibility of content in WebView.
4475         * <p>
4476         *   Note: The JavaScript based screen-reader is served by the
4477         *   Google infrastructure and enable users with disabilities to
4478         *   efficiently navigate in and explore web content.
4479         * </p>
4480         * <p>
4481         *   This property represents a string value.
4482         * </p>
4483         * @hide
4484         */
4485        public static final String ACCESSIBILITY_SCREEN_READER_URL =
4486            "accessibility_script_injection_url";
4487
4488        /**
4489         * Key bindings for navigation in built-in accessibility support for web content.
4490         * <p>
4491         *   Note: These key bindings are for the built-in accessibility navigation for
4492         *   web content which is used as a fall back solution if JavaScript in a WebView
4493         *   is not enabled or the user has not opted-in script injection from Google.
4494         * </p>
4495         * <p>
4496         *   The bindings are separated by semi-colon. A binding is a mapping from
4497         *   a key to a sequence of actions (for more details look at
4498         *   android.webkit.AccessibilityInjector). A key is represented as the hexademical
4499         *   string representation of an integer obtained from a meta state (optional) shifted
4500         *   sixteen times left and bitwise ored with a key code. An action is represented
4501         *   as a hexademical string representation of an integer where the first two digits
4502         *   are navigation action index, the second, the third, and the fourth digit pairs
4503         *   represent the action arguments. The separate actions in a binding are colon
4504         *   separated. The key and the action sequence it maps to are separated by equals.
4505         * </p>
4506         * <p>
4507         *   For example, the binding below maps the DPAD right button to traverse the
4508         *   current navigation axis once without firing an accessibility event and to
4509         *   perform the same traversal again but to fire an event:
4510         *   <code>
4511         *     0x16=0x01000100:0x01000101;
4512         *   </code>
4513         * </p>
4514         * <p>
4515         *   The goal of this binding is to enable dynamic rebinding of keys to
4516         *   navigation actions for web content without requiring a framework change.
4517         * </p>
4518         * <p>
4519         *   This property represents a string value.
4520         * </p>
4521         * @hide
4522         */
4523        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
4524            "accessibility_web_content_key_bindings";
4525
4526        /**
4527         * Setting that specifies whether the display magnification is enabled.
4528         * Display magnifications allows the user to zoom in the display content
4529         * and is targeted to low vision users. The current magnification scale
4530         * is controlled by {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
4531         *
4532         * @hide
4533         */
4534        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED =
4535                "accessibility_display_magnification_enabled";
4536
4537        /**
4538         * Setting that specifies what the display magnification scale is.
4539         * Display magnifications allows the user to zoom in the display
4540         * content and is targeted to low vision users. Whether a display
4541         * magnification is performed is controlled by
4542         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED}
4543         *
4544         * @hide
4545         */
4546        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE =
4547                "accessibility_display_magnification_scale";
4548
4549        /**
4550         * Setting that specifies whether the display magnification should be
4551         * automatically updated. If this fearture is enabled the system will
4552         * exit magnification mode or pan the viewport when a context change
4553         * occurs. For example, on staring a new activity or rotating the screen,
4554         * the system may zoom out so the user can see the new context he is in.
4555         * Another example is on showing a window that is not visible in the
4556         * magnified viewport the system may pan the viewport to make the window
4557         * the has popped up so the user knows that the context has changed.
4558         * Whether a screen magnification is performed is controlled by
4559         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED}
4560         *
4561         * @hide
4562         */
4563        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE =
4564                "accessibility_display_magnification_auto_update";
4565
4566        /**
4567         * Setting that specifies whether timed text (captions) should be
4568         * displayed in video content. Text display properties are controlled by
4569         * the following settings:
4570         * <ul>
4571         * <li>{@link #ACCESSIBILITY_CAPTIONING_LOCALE}
4572         * <li>{@link #ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR}
4573         * <li>{@link #ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR}
4574         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_COLOR}
4575         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_TYPE}
4576         * <li>{@link #ACCESSIBILITY_CAPTIONING_TYPEFACE}
4577         * <li>{@link #ACCESSIBILITY_CAPTIONING_FONT_SCALE}
4578         * </ul>
4579         *
4580         * @hide
4581         */
4582        public static final String ACCESSIBILITY_CAPTIONING_ENABLED =
4583                "accessibility_captioning_enabled";
4584
4585        /**
4586         * Setting that specifies the language for captions as a locale string,
4587         * e.g. en_US.
4588         *
4589         * @see java.util.Locale#toString
4590         * @hide
4591         */
4592        public static final String ACCESSIBILITY_CAPTIONING_LOCALE =
4593                "accessibility_captioning_locale";
4594
4595        /**
4596         * Integer property that specifies the preset style for captions, one
4597         * of:
4598         * <ul>
4599         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESET_CUSTOM}
4600         * <li>a valid index of {@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESETS}
4601         * </ul>
4602         *
4603         * @see java.util.Locale#toString
4604         * @hide
4605         */
4606        public static final String ACCESSIBILITY_CAPTIONING_PRESET =
4607                "accessibility_captioning_preset";
4608
4609        /**
4610         * Integer property that specifes the background color for captions as a
4611         * packed 32-bit color.
4612         *
4613         * @see android.graphics.Color#argb
4614         * @hide
4615         */
4616        public static final String ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR =
4617                "accessibility_captioning_background_color";
4618
4619        /**
4620         * Integer property that specifes the foreground color for captions as a
4621         * packed 32-bit color.
4622         *
4623         * @see android.graphics.Color#argb
4624         * @hide
4625         */
4626        public static final String ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR =
4627                "accessibility_captioning_foreground_color";
4628
4629        /**
4630         * Integer property that specifes the edge type for captions, one of:
4631         * <ul>
4632         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_NONE}
4633         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_OUTLINE}
4634         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_DROP_SHADOW}
4635         * </ul>
4636         *
4637         * @see #ACCESSIBILITY_CAPTIONING_EDGE_COLOR
4638         * @hide
4639         */
4640        public static final String ACCESSIBILITY_CAPTIONING_EDGE_TYPE =
4641                "accessibility_captioning_edge_type";
4642
4643        /**
4644         * Integer property that specifes the edge color for captions as a
4645         * packed 32-bit color.
4646         *
4647         * @see #ACCESSIBILITY_CAPTIONING_EDGE_TYPE
4648         * @see android.graphics.Color#argb
4649         * @hide
4650         */
4651        public static final String ACCESSIBILITY_CAPTIONING_EDGE_COLOR =
4652                "accessibility_captioning_edge_color";
4653
4654        /**
4655         * Integer property that specifes the window color for captions as a
4656         * packed 32-bit color.
4657         *
4658         * @see android.graphics.Color#argb
4659         * @hide
4660         */
4661        public static final String ACCESSIBILITY_CAPTIONING_WINDOW_COLOR =
4662                "accessibility_captioning_window_color";
4663
4664        /**
4665         * String property that specifies the typeface for captions, one of:
4666         * <ul>
4667         * <li>DEFAULT
4668         * <li>MONOSPACE
4669         * <li>SANS_SERIF
4670         * <li>SERIF
4671         * </ul>
4672         *
4673         * @see android.graphics.Typeface
4674         * @hide
4675         */
4676        public static final String ACCESSIBILITY_CAPTIONING_TYPEFACE =
4677                "accessibility_captioning_typeface";
4678
4679        /**
4680         * Floating point property that specifies font scaling for captions.
4681         *
4682         * @hide
4683         */
4684        public static final String ACCESSIBILITY_CAPTIONING_FONT_SCALE =
4685                "accessibility_captioning_font_scale";
4686
4687        /**
4688         * Setting that specifies whether display color inversion is enabled.
4689         */
4690        public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED =
4691                "accessibility_display_inversion_enabled";
4692
4693        /**
4694         * Setting that specifies whether display color space adjustment is
4695         * enabled.
4696         *
4697         * @hide
4698         */
4699        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED =
4700                "accessibility_display_daltonizer_enabled";
4701
4702        /**
4703         * Integer property that specifies the type of color space adjustment to
4704         * perform. Valid values are defined in AccessibilityManager.
4705         *
4706         * @hide
4707         */
4708        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER =
4709                "accessibility_display_daltonizer";
4710
4711        /**
4712         * The timout for considering a press to be a long press in milliseconds.
4713         * @hide
4714         */
4715        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
4716
4717        /**
4718         * List of the enabled print services.
4719         * @hide
4720         */
4721        public static final String ENABLED_PRINT_SERVICES =
4722            "enabled_print_services";
4723
4724        /**
4725         * List of the system print services we enabled on first boot. On
4726         * first boot we enable all system, i.e. bundled print services,
4727         * once, so they work out-of-the-box.
4728         * @hide
4729         */
4730        public static final String ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES =
4731            "enabled_on_first_boot_system_print_services";
4732
4733        /**
4734         * Setting to always use the default text-to-speech settings regardless
4735         * of the application settings.
4736         * 1 = override application settings,
4737         * 0 = use application settings (if specified).
4738         *
4739         * @deprecated  The value of this setting is no longer respected by
4740         * the framework text to speech APIs as of the Ice Cream Sandwich release.
4741         */
4742        @Deprecated
4743        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
4744
4745        /**
4746         * Default text-to-speech engine speech rate. 100 = 1x
4747         */
4748        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
4749
4750        /**
4751         * Default text-to-speech engine pitch. 100 = 1x
4752         */
4753        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
4754
4755        /**
4756         * Default text-to-speech engine.
4757         */
4758        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
4759
4760        /**
4761         * Default text-to-speech language.
4762         *
4763         * @deprecated this setting is no longer in use, as of the Ice Cream
4764         * Sandwich release. Apps should never need to read this setting directly,
4765         * instead can query the TextToSpeech framework classes for the default
4766         * locale. {@link TextToSpeech#getLanguage()}.
4767         */
4768        @Deprecated
4769        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
4770
4771        /**
4772         * Default text-to-speech country.
4773         *
4774         * @deprecated this setting is no longer in use, as of the Ice Cream
4775         * Sandwich release. Apps should never need to read this setting directly,
4776         * instead can query the TextToSpeech framework classes for the default
4777         * locale. {@link TextToSpeech#getLanguage()}.
4778         */
4779        @Deprecated
4780        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
4781
4782        /**
4783         * Default text-to-speech locale variant.
4784         *
4785         * @deprecated this setting is no longer in use, as of the Ice Cream
4786         * Sandwich release. Apps should never need to read this setting directly,
4787         * instead can query the TextToSpeech framework classes for the
4788         * locale that is in use {@link TextToSpeech#getLanguage()}.
4789         */
4790        @Deprecated
4791        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
4792
4793        /**
4794         * Stores the default tts locales on a per engine basis. Stored as
4795         * a comma seperated list of values, each value being of the form
4796         * {@code engine_name:locale} for example,
4797         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
4798         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
4799         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
4800         * setting directly, and can query the TextToSpeech framework classes
4801         * for the locale that is in use.
4802         *
4803         * @hide
4804         */
4805        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
4806
4807        /**
4808         * Space delimited list of plugin packages that are enabled.
4809         */
4810        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
4811
4812        /**
4813         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
4814         * instead.
4815         */
4816        @Deprecated
4817        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
4818                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
4819
4820        /**
4821         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
4822         * instead.
4823         */
4824        @Deprecated
4825        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
4826                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
4827
4828        /**
4829         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
4830         * instead.
4831         */
4832        @Deprecated
4833        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
4834                Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
4835
4836        /**
4837         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
4838         * instead.
4839         */
4840        @Deprecated
4841        public static final String WIFI_ON = Global.WIFI_ON;
4842
4843        /**
4844         * The acceptable packet loss percentage (range 0 - 100) before trying
4845         * another AP on the same network.
4846         * @deprecated This setting is not used.
4847         */
4848        @Deprecated
4849        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
4850                "wifi_watchdog_acceptable_packet_loss_percentage";
4851
4852        /**
4853         * The number of access points required for a network in order for the
4854         * watchdog to monitor it.
4855         * @deprecated This setting is not used.
4856         */
4857        @Deprecated
4858        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
4859
4860        /**
4861         * The delay between background checks.
4862         * @deprecated This setting is not used.
4863         */
4864        @Deprecated
4865        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
4866                "wifi_watchdog_background_check_delay_ms";
4867
4868        /**
4869         * Whether the Wi-Fi watchdog is enabled for background checking even
4870         * after it thinks the user has connected to a good access point.
4871         * @deprecated This setting is not used.
4872         */
4873        @Deprecated
4874        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
4875                "wifi_watchdog_background_check_enabled";
4876
4877        /**
4878         * The timeout for a background ping
4879         * @deprecated This setting is not used.
4880         */
4881        @Deprecated
4882        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
4883                "wifi_watchdog_background_check_timeout_ms";
4884
4885        /**
4886         * The number of initial pings to perform that *may* be ignored if they
4887         * fail. Again, if these fail, they will *not* be used in packet loss
4888         * calculation. For example, one network always seemed to time out for
4889         * the first couple pings, so this is set to 3 by default.
4890         * @deprecated This setting is not used.
4891         */
4892        @Deprecated
4893        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
4894            "wifi_watchdog_initial_ignored_ping_count";
4895
4896        /**
4897         * The maximum number of access points (per network) to attempt to test.
4898         * If this number is reached, the watchdog will no longer monitor the
4899         * initial connection state for the network. This is a safeguard for
4900         * networks containing multiple APs whose DNS does not respond to pings.
4901         * @deprecated This setting is not used.
4902         */
4903        @Deprecated
4904        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
4905
4906        /**
4907         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
4908         */
4909        @Deprecated
4910        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
4911
4912        /**
4913         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
4914         * @deprecated This setting is not used.
4915         */
4916        @Deprecated
4917        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
4918
4919        /**
4920         * The number of pings to test if an access point is a good connection.
4921         * @deprecated This setting is not used.
4922         */
4923        @Deprecated
4924        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
4925
4926        /**
4927         * The delay between pings.
4928         * @deprecated This setting is not used.
4929         */
4930        @Deprecated
4931        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
4932
4933        /**
4934         * The timeout per ping.
4935         * @deprecated This setting is not used.
4936         */
4937        @Deprecated
4938        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
4939
4940        /**
4941         * @deprecated Use
4942         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
4943         */
4944        @Deprecated
4945        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
4946
4947        /**
4948         * @deprecated Use
4949         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
4950         */
4951        @Deprecated
4952        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
4953                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
4954
4955        /**
4956         * The number of milliseconds to hold on to a PendingIntent based request. This delay gives
4957         * the receivers of the PendingIntent an opportunity to make a new network request before
4958         * the Network satisfying the request is potentially removed.
4959         *
4960         * @hide
4961         */
4962        public static final String CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS =
4963                "connectivity_release_pending_intent_delay_ms";
4964
4965        /**
4966         * Whether background data usage is allowed.
4967         *
4968         * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH},
4969         *             availability of background data depends on several
4970         *             combined factors. When background data is unavailable,
4971         *             {@link ConnectivityManager#getActiveNetworkInfo()} will
4972         *             now appear disconnected.
4973         */
4974        @Deprecated
4975        public static final String BACKGROUND_DATA = "background_data";
4976
4977        /**
4978         * Origins for which browsers should allow geolocation by default.
4979         * The value is a space-separated list of origins.
4980         */
4981        public static final String ALLOWED_GEOLOCATION_ORIGINS
4982                = "allowed_geolocation_origins";
4983
4984        /**
4985         * The preferred TTY mode     0 = TTy Off, CDMA default
4986         *                            1 = TTY Full
4987         *                            2 = TTY HCO
4988         *                            3 = TTY VCO
4989         * @hide
4990         */
4991        public static final String PREFERRED_TTY_MODE =
4992                "preferred_tty_mode";
4993
4994        /**
4995         * Whether the enhanced voice privacy mode is enabled.
4996         * 0 = normal voice privacy
4997         * 1 = enhanced voice privacy
4998         * @hide
4999         */
5000        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
5001
5002        /**
5003         * Whether the TTY mode mode is enabled.
5004         * 0 = disabled
5005         * 1 = enabled
5006         * @hide
5007         */
5008        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
5009
5010        /**
5011         * Controls whether settings backup is enabled.
5012         * Type: int ( 0 = disabled, 1 = enabled )
5013         * @hide
5014         */
5015        public static final String BACKUP_ENABLED = "backup_enabled";
5016
5017        /**
5018         * Controls whether application data is automatically restored from backup
5019         * at install time.
5020         * Type: int ( 0 = disabled, 1 = enabled )
5021         * @hide
5022         */
5023        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
5024
5025        /**
5026         * Indicates whether settings backup has been fully provisioned.
5027         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
5028         * @hide
5029         */
5030        public static final String BACKUP_PROVISIONED = "backup_provisioned";
5031
5032        /**
5033         * Component of the transport to use for backup/restore.
5034         * @hide
5035         */
5036        public static final String BACKUP_TRANSPORT = "backup_transport";
5037
5038        /**
5039         * Version for which the setup wizard was last shown.  Bumped for
5040         * each release when there is new setup information to show.
5041         * @hide
5042         */
5043        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
5044
5045        /**
5046         * The interval in milliseconds after which Wi-Fi is considered idle.
5047         * When idle, it is possible for the device to be switched from Wi-Fi to
5048         * the mobile data network.
5049         * @hide
5050         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
5051         * instead.
5052         */
5053        @Deprecated
5054        public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
5055
5056        /**
5057         * The global search provider chosen by the user (if multiple global
5058         * search providers are installed). This will be the provider returned
5059         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
5060         * installed. This setting is stored as a flattened component name as
5061         * per {@link ComponentName#flattenToString()}.
5062         *
5063         * @hide
5064         */
5065        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
5066                "search_global_search_activity";
5067
5068        /**
5069         * The number of promoted sources in GlobalSearch.
5070         * @hide
5071         */
5072        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
5073        /**
5074         * The maximum number of suggestions returned by GlobalSearch.
5075         * @hide
5076         */
5077        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
5078        /**
5079         * The number of suggestions GlobalSearch will ask each non-web search source for.
5080         * @hide
5081         */
5082        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
5083        /**
5084         * The number of suggestions the GlobalSearch will ask the web search source for.
5085         * @hide
5086         */
5087        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
5088                "search_web_results_override_limit";
5089        /**
5090         * The number of milliseconds that GlobalSearch will wait for suggestions from
5091         * promoted sources before continuing with all other sources.
5092         * @hide
5093         */
5094        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
5095                "search_promoted_source_deadline_millis";
5096        /**
5097         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
5098         * @hide
5099         */
5100        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
5101        /**
5102         * The maximum number of milliseconds that GlobalSearch shows the previous results
5103         * after receiving a new query.
5104         * @hide
5105         */
5106        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
5107        /**
5108         * The maximum age of log data used for shortcuts in GlobalSearch.
5109         * @hide
5110         */
5111        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
5112        /**
5113         * The maximum age of log data used for source ranking in GlobalSearch.
5114         * @hide
5115         */
5116        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
5117                "search_max_source_event_age_millis";
5118        /**
5119         * The minimum number of impressions needed to rank a source in GlobalSearch.
5120         * @hide
5121         */
5122        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
5123                "search_min_impressions_for_source_ranking";
5124        /**
5125         * The minimum number of clicks needed to rank a source in GlobalSearch.
5126         * @hide
5127         */
5128        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
5129                "search_min_clicks_for_source_ranking";
5130        /**
5131         * The maximum number of shortcuts shown by GlobalSearch.
5132         * @hide
5133         */
5134        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
5135        /**
5136         * The size of the core thread pool for suggestion queries in GlobalSearch.
5137         * @hide
5138         */
5139        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
5140                "search_query_thread_core_pool_size";
5141        /**
5142         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
5143         * @hide
5144         */
5145        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
5146                "search_query_thread_max_pool_size";
5147        /**
5148         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
5149         * @hide
5150         */
5151        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
5152                "search_shortcut_refresh_core_pool_size";
5153        /**
5154         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
5155         * @hide
5156         */
5157        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
5158                "search_shortcut_refresh_max_pool_size";
5159        /**
5160         * The maximun time that excess threads in the GlobalSeach thread pools will
5161         * wait before terminating.
5162         * @hide
5163         */
5164        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
5165                "search_thread_keepalive_seconds";
5166        /**
5167         * The maximum number of concurrent suggestion queries to each source.
5168         * @hide
5169         */
5170        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
5171                "search_per_source_concurrent_query_limit";
5172
5173        /**
5174         * Whether or not alert sounds are played on MountService events. (0 = false, 1 = true)
5175         * @hide
5176         */
5177        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
5178
5179        /**
5180         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
5181         * @hide
5182         */
5183        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
5184
5185        /**
5186         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
5187         * @hide
5188         */
5189        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
5190
5191        /**
5192         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
5193         * @hide
5194         */
5195        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
5196
5197        /**
5198         * If nonzero, ANRs in invisible background processes bring up a dialog.
5199         * Otherwise, the process will be silently killed.
5200         * @hide
5201         */
5202        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
5203
5204        /**
5205         * The {@link ComponentName} string of the service to be used as the voice recognition
5206         * service.
5207         *
5208         * @hide
5209         */
5210        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
5211
5212        /**
5213         * Stores whether an user has consented to have apps verified through PAM.
5214         * The value is boolean (1 or 0).
5215         *
5216         * @hide
5217         */
5218        public static final String PACKAGE_VERIFIER_USER_CONSENT =
5219            "package_verifier_user_consent";
5220
5221        /**
5222         * The {@link ComponentName} string of the selected spell checker service which is
5223         * one of the services managed by the text service manager.
5224         *
5225         * @hide
5226         */
5227        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
5228
5229        /**
5230         * The {@link ComponentName} string of the selected subtype of the selected spell checker
5231         * service which is one of the services managed by the text service manager.
5232         *
5233         * @hide
5234         */
5235        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
5236                "selected_spell_checker_subtype";
5237
5238        /**
5239         * The {@link ComponentName} string whether spell checker is enabled or not.
5240         *
5241         * @hide
5242         */
5243        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
5244
5245        /**
5246         * What happens when the user presses the Power button while in-call
5247         * and the screen is on.<br/>
5248         * <b>Values:</b><br/>
5249         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
5250         * 2 - The Power button hangs up the current call.<br/>
5251         *
5252         * @hide
5253         */
5254        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
5255
5256        /**
5257         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
5258         * @hide
5259         */
5260        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
5261
5262        /**
5263         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
5264         * @hide
5265         */
5266        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
5267
5268        /**
5269         * INCALL_POWER_BUTTON_BEHAVIOR default value.
5270         * @hide
5271         */
5272        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
5273                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
5274
5275        /**
5276         * Whether the device should wake when the wake gesture sensor detects motion.
5277         * @hide
5278         */
5279        public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";
5280
5281        /**
5282         * Whether the device should doze if configured.
5283         * @hide
5284         */
5285        public static final String DOZE_ENABLED = "doze_enabled";
5286
5287        /**
5288         * The current night mode that has been selected by the user.  Owned
5289         * and controlled by UiModeManagerService.  Constants are as per
5290         * UiModeManager.
5291         * @hide
5292         */
5293        public static final String UI_NIGHT_MODE = "ui_night_mode";
5294
5295        /**
5296         * Whether screensavers are enabled.
5297         * @hide
5298         */
5299        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
5300
5301        /**
5302         * The user's chosen screensaver components.
5303         *
5304         * These will be launched by the PhoneWindowManager after a timeout when not on
5305         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
5306         * @hide
5307         */
5308        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
5309
5310        /**
5311         * If screensavers are enabled, whether the screensaver should be automatically launched
5312         * when the device is inserted into a (desk) dock.
5313         * @hide
5314         */
5315        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
5316
5317        /**
5318         * If screensavers are enabled, whether the screensaver should be automatically launched
5319         * when the screen times out when not on battery.
5320         * @hide
5321         */
5322        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
5323
5324        /**
5325         * If screensavers are enabled, the default screensaver component.
5326         * @hide
5327         */
5328        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
5329
5330        /**
5331         * The default NFC payment component
5332         * @hide
5333         */
5334        public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
5335
5336        /**
5337         * Whether NFC payment is handled by the foreground application or a default.
5338         * @hide
5339         */
5340        public static final String NFC_PAYMENT_FOREGROUND = "nfc_payment_foreground";
5341
5342        /**
5343         * Specifies the package name currently configured to be the primary sms application
5344         * @hide
5345         */
5346        public static final String SMS_DEFAULT_APPLICATION = "sms_default_application";
5347
5348        /**
5349         * Specifies the package name currently configured to be the emergency assistance application
5350         *
5351         * @see android.telephony.TelephonyManager#ACTION_EMERGENCY_ASSISTANCE
5352         *
5353         * @hide
5354         */
5355        public static final String EMERGENCY_ASSISTANCE_APPLICATION = "emergency_assistance_application";
5356
5357        /**
5358         * Names of the packages that the current user has explicitly allowed to
5359         * see all of the user's notifications, separated by ':'.
5360         *
5361         * @hide
5362         */
5363        public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
5364
5365        /**
5366         * @hide
5367         */
5368        public static final String ENABLED_CONDITION_PROVIDERS = "enabled_condition_providers";
5369
5370        /** @hide */
5371        public static final String BAR_SERVICE_COMPONENT = "bar_service_component";
5372
5373        /** @hide */
5374        public static final String VOLUME_CONTROLLER_SERVICE_COMPONENT
5375                = "volume_controller_service_component";
5376
5377        /** @hide */
5378        public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
5379
5380        /**
5381         * This is the query URI for finding a print service to install.
5382         *
5383         * @hide
5384         */
5385        public static final String PRINT_SERVICE_SEARCH_URI = "print_service_search_uri";
5386
5387        /**
5388         * This is the query URI for finding a NFC payment service to install.
5389         *
5390         * @hide
5391         */
5392        public static final String PAYMENT_SERVICE_SEARCH_URI = "payment_service_search_uri";
5393
5394        /**
5395         * If enabled, apps should try to skip any introductory hints on first launch. This might
5396         * apply to users that are already familiar with the environment or temporary users.
5397         * <p>
5398         * Type : int (0 to show hints, 1 to skip showing hints)
5399         */
5400        public static final String SKIP_FIRST_USE_HINTS = "skip_first_use_hints";
5401
5402        /**
5403         * Persisted playback time after a user confirmation of an unsafe volume level.
5404         *
5405         * @hide
5406         */
5407        public static final String UNSAFE_VOLUME_MUSIC_ACTIVE_MS = "unsafe_volume_music_active_ms";
5408
5409        /**
5410         * This preference enables notification display on the lockscreen.
5411         * @hide
5412         */
5413        public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
5414                "lock_screen_show_notifications";
5415
5416        /**
5417         * List of TV inputs that are currently hidden. This is a string
5418         * containing the IDs of all hidden TV inputs. Each ID is encoded by
5419         * {@link android.net.Uri#encode(String)} and separated by ':'.
5420         * @hide
5421         */
5422        public static final String TV_INPUT_HIDDEN_INPUTS = "tv_input_hidden_inputs";
5423
5424        /**
5425         * List of custom TV input labels. This is a string containing <TV input id, custom name>
5426         * pairs. TV input id and custom name are encoded by {@link android.net.Uri#encode(String)}
5427         * and separated by ','. Each pair is separated by ':'.
5428         * @hide
5429         */
5430        public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels";
5431
5432        /**
5433         * Whether automatic routing of system audio to USB audio peripheral is disabled.
5434         * The value is boolean (1 or 0), where 1 means automatic routing is disabled,
5435         * and 0 means automatic routing is enabled.
5436         *
5437         * @hide
5438         */
5439        public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
5440                "usb_audio_automatic_routing_disabled";
5441
5442        /**
5443         * The timeout in milliseconds before the device fully goes to sleep after
5444         * a period of inactivity.  This value sets an upper bound on how long the device
5445         * will stay awake or dreaming without user activity.  It should generally
5446         * be longer than {@link Settings.System#SCREEN_OFF_TIMEOUT} as otherwise the device
5447         * will sleep before it ever has a chance to dream.
5448         * <p>
5449         * Use -1 to disable this timeout.
5450         * </p>
5451         *
5452         * @hide
5453         */
5454        public static final String SLEEP_TIMEOUT = "sleep_timeout";
5455
5456        /**
5457         * Duration in milliseconds that an app should be inactive before it is considered idle.
5458         * <p/>Type: Long
5459         * @hide
5460         */
5461        public static final String APP_IDLE_DURATION = "app_idle_duration";
5462
5463        /**
5464         * This are the settings to be backed up.
5465         *
5466         * NOTE: Settings are backed up and restored in the order they appear
5467         *       in this array. If you have one setting depending on another,
5468         *       make sure that they are ordered appropriately.
5469         *
5470         * @hide
5471         */
5472        public static final String[] SETTINGS_TO_BACKUP = {
5473            BUGREPORT_IN_POWER_MENU,                            // moved to global
5474            ALLOW_MOCK_LOCATION,
5475            PARENTAL_CONTROL_ENABLED,
5476            PARENTAL_CONTROL_REDIRECT_URL,
5477            USB_MASS_STORAGE_ENABLED,                           // moved to global
5478            ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
5479            ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
5480            ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
5481            ACCESSIBILITY_SCRIPT_INJECTION,
5482            BACKUP_AUTO_RESTORE,
5483            ENABLED_ACCESSIBILITY_SERVICES,
5484            ENABLED_NOTIFICATION_LISTENERS,
5485            ENABLED_INPUT_METHODS,
5486            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
5487            TOUCH_EXPLORATION_ENABLED,
5488            ACCESSIBILITY_ENABLED,
5489            ACCESSIBILITY_SPEAK_PASSWORD,
5490            ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
5491            ACCESSIBILITY_CAPTIONING_ENABLED,
5492            ACCESSIBILITY_CAPTIONING_LOCALE,
5493            ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
5494            ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
5495            ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
5496            ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
5497            ACCESSIBILITY_CAPTIONING_TYPEFACE,
5498            ACCESSIBILITY_CAPTIONING_FONT_SCALE,
5499            TTS_USE_DEFAULTS,
5500            TTS_DEFAULT_RATE,
5501            TTS_DEFAULT_PITCH,
5502            TTS_DEFAULT_SYNTH,
5503            TTS_DEFAULT_LANG,
5504            TTS_DEFAULT_COUNTRY,
5505            TTS_ENABLED_PLUGINS,
5506            TTS_DEFAULT_LOCALE,
5507            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
5508            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
5509            WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
5510            SELECTED_SPELL_CHECKER,
5511            SELECTED_SPELL_CHECKER_SUBTYPE,
5512            SPELL_CHECKER_ENABLED,
5513            MOUNT_PLAY_NOTIFICATION_SND,
5514            MOUNT_UMS_AUTOSTART,
5515            MOUNT_UMS_PROMPT,
5516            MOUNT_UMS_NOTIFY_ENABLED,
5517            UI_NIGHT_MODE,
5518            SLEEP_TIMEOUT
5519        };
5520
5521        /**
5522         * These entries are considered common between the personal and the managed profile,
5523         * since the managed profile doesn't get to change them.
5524         */
5525        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
5526
5527        static {
5528            CLONE_TO_MANAGED_PROFILE.add(ACCESSIBILITY_ENABLED);
5529            CLONE_TO_MANAGED_PROFILE.add(ALLOW_MOCK_LOCATION);
5530            CLONE_TO_MANAGED_PROFILE.add(ALLOWED_GEOLOCATION_ORIGINS);
5531            CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD);
5532            CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES);
5533            CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS);
5534            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
5535            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED);
5536            CLONE_TO_MANAGED_PROFILE.add(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
5537            CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE);
5538            CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER);
5539            CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER_SUBTYPE);
5540        }
5541
5542        /** @hide */
5543        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
5544            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
5545        }
5546
5547        /**
5548         * Helper method for determining if a location provider is enabled.
5549         *
5550         * @param cr the content resolver to use
5551         * @param provider the location provider to query
5552         * @return true if the provider is enabled
5553         *
5554         * @deprecated use {@link #LOCATION_MODE} or
5555         *             {@link LocationManager#isProviderEnabled(String)}
5556         */
5557        @Deprecated
5558        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
5559            return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId());
5560        }
5561
5562        /**
5563         * Helper method for determining if a location provider is enabled.
5564         * @param cr the content resolver to use
5565         * @param provider the location provider to query
5566         * @param userId the userId to query
5567         * @return true if the provider is enabled
5568         * @deprecated use {@link #LOCATION_MODE} or
5569         *             {@link LocationManager#isProviderEnabled(String)}
5570         * @hide
5571         */
5572        @Deprecated
5573        public static final boolean isLocationProviderEnabledForUser(ContentResolver cr, String provider, int userId) {
5574            String allowedProviders = Settings.Secure.getStringForUser(cr,
5575                    LOCATION_PROVIDERS_ALLOWED, userId);
5576            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
5577        }
5578
5579        /**
5580         * Thread-safe method for enabling or disabling a single location provider.
5581         * @param cr the content resolver to use
5582         * @param provider the location provider to enable or disable
5583         * @param enabled true if the provider should be enabled
5584         * @deprecated use {@link #putInt(ContentResolver, String, int)} and {@link #LOCATION_MODE}
5585         */
5586        @Deprecated
5587        public static final void setLocationProviderEnabled(ContentResolver cr,
5588                String provider, boolean enabled) {
5589            setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId());
5590        }
5591
5592        /**
5593         * Thread-safe method for enabling or disabling a single location provider.
5594         *
5595         * @param cr the content resolver to use
5596         * @param provider the location provider to enable or disable
5597         * @param enabled true if the provider should be enabled
5598         * @param userId the userId for which to enable/disable providers
5599         * @return true if the value was set, false on database errors
5600         * @deprecated use {@link #putIntForUser(ContentResolver, String, int, int)} and
5601         *             {@link #LOCATION_MODE}
5602         * @hide
5603         */
5604        @Deprecated
5605        public static final boolean setLocationProviderEnabledForUser(ContentResolver cr,
5606                String provider, boolean enabled, int userId) {
5607            synchronized (mLocationSettingsLock) {
5608                // to ensure thread safety, we write the provider name with a '+' or '-'
5609                // and let the SettingsProvider handle it rather than reading and modifying
5610                // the list of enabled providers.
5611                if (enabled) {
5612                    provider = "+" + provider;
5613                } else {
5614                    provider = "-" + provider;
5615                }
5616                return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
5617                        userId);
5618            }
5619        }
5620
5621        /**
5622         * Thread-safe method for setting the location mode to one of
5623         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
5624         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
5625         *
5626         * @param cr the content resolver to use
5627         * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY}
5628         * @param userId the userId for which to change mode
5629         * @return true if the value was set, false on database errors
5630         *
5631         * @throws IllegalArgumentException if mode is not one of the supported values
5632         */
5633        private static final boolean setLocationModeForUser(ContentResolver cr, int mode,
5634                int userId) {
5635            synchronized (mLocationSettingsLock) {
5636                boolean gps = false;
5637                boolean network = false;
5638                switch (mode) {
5639                    case LOCATION_MODE_OFF:
5640                        break;
5641                    case LOCATION_MODE_SENSORS_ONLY:
5642                        gps = true;
5643                        break;
5644                    case LOCATION_MODE_BATTERY_SAVING:
5645                        network = true;
5646                        break;
5647                    case LOCATION_MODE_HIGH_ACCURACY:
5648                        gps = true;
5649                        network = true;
5650                        break;
5651                    default:
5652                        throw new IllegalArgumentException("Invalid location mode: " + mode);
5653                }
5654                // Note it's important that we set the NLP mode first. The Google implementation
5655                // of NLP clears its NLP consent setting any time it receives a
5656                // LocationManager.PROVIDERS_CHANGED_ACTION broadcast and NLP is disabled. Also,
5657                // it shows an NLP consent dialog any time it receives the broadcast, NLP is
5658                // enabled, and the NLP consent is not set. If 1) we were to enable GPS first,
5659                // 2) a setup wizard has its own NLP consent UI that sets the NLP consent setting,
5660                // and 3) the receiver happened to complete before we enabled NLP, then the Google
5661                // NLP would detect the attempt to enable NLP and show a redundant NLP consent
5662                // dialog. Then the people who wrote the setup wizard would be sad.
5663                boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
5664                        cr, LocationManager.NETWORK_PROVIDER, network, userId);
5665                boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
5666                        cr, LocationManager.GPS_PROVIDER, gps, userId);
5667                return gpsSuccess && nlpSuccess;
5668            }
5669        }
5670
5671        /**
5672         * Thread-safe method for reading the location mode, returns one of
5673         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
5674         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
5675         *
5676         * @param cr the content resolver to use
5677         * @param userId the userId for which to read the mode
5678         * @return the location mode
5679         */
5680        private static final int getLocationModeForUser(ContentResolver cr, int userId) {
5681            synchronized (mLocationSettingsLock) {
5682                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
5683                        cr, LocationManager.GPS_PROVIDER, userId);
5684                boolean networkEnabled = Settings.Secure.isLocationProviderEnabledForUser(
5685                        cr, LocationManager.NETWORK_PROVIDER, userId);
5686                if (gpsEnabled && networkEnabled) {
5687                    return LOCATION_MODE_HIGH_ACCURACY;
5688                } else if (gpsEnabled) {
5689                    return LOCATION_MODE_SENSORS_ONLY;
5690                } else if (networkEnabled) {
5691                    return LOCATION_MODE_BATTERY_SAVING;
5692                } else {
5693                    return LOCATION_MODE_OFF;
5694                }
5695            }
5696        }
5697    }
5698
5699    /**
5700     * Global system settings, containing preferences that always apply identically
5701     * to all defined users.  Applications can read these but are not allowed to write;
5702     * like the "Secure" settings, these are for preferences that the user must
5703     * explicitly modify through the system UI or specialized APIs for those values.
5704     */
5705    public static final class Global extends NameValueTable {
5706        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_global_version";
5707
5708        /**
5709         * The content:// style URL for global secure settings items.  Not public.
5710         */
5711        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
5712
5713        /**
5714         * Whether users are allowed to add more users or guest from lockscreen.
5715         * <p>
5716         * Type: int
5717         * @hide
5718         */
5719        public static final String ADD_USERS_WHEN_LOCKED = "add_users_when_locked";
5720
5721        /**
5722         * Setting whether the global gesture for enabling accessibility is enabled.
5723         * If this gesture is enabled the user will be able to perfrom it to enable
5724         * the accessibility state without visiting the settings app.
5725         * @hide
5726         */
5727        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
5728                "enable_accessibility_global_gesture_enabled";
5729
5730        /**
5731         * Whether Airplane Mode is on.
5732         */
5733        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
5734
5735        /**
5736         * Whether Theater Mode is on.
5737         * {@hide}
5738         */
5739        @SystemApi
5740        public static final String THEATER_MODE_ON = "theater_mode_on";
5741
5742        /**
5743         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
5744         */
5745        public static final String RADIO_BLUETOOTH = "bluetooth";
5746
5747        /**
5748         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
5749         */
5750        public static final String RADIO_WIFI = "wifi";
5751
5752        /**
5753         * {@hide}
5754         */
5755        public static final String RADIO_WIMAX = "wimax";
5756        /**
5757         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
5758         */
5759        public static final String RADIO_CELL = "cell";
5760
5761        /**
5762         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
5763         */
5764        public static final String RADIO_NFC = "nfc";
5765
5766        /**
5767         * A comma separated list of radios that need to be disabled when airplane mode
5768         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
5769         * included in the comma separated list.
5770         */
5771        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
5772
5773        /**
5774         * A comma separated list of radios that should to be disabled when airplane mode
5775         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
5776         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
5777         * will be turned off when entering airplane mode, but the user will be able to reenable
5778         * Wifi in the Settings app.
5779         *
5780         * {@hide}
5781         */
5782        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
5783
5784        /**
5785         * The policy for deciding when Wi-Fi should go to sleep (which will in
5786         * turn switch to using the mobile data as an Internet connection).
5787         * <p>
5788         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
5789         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
5790         * {@link #WIFI_SLEEP_POLICY_NEVER}.
5791         */
5792        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
5793
5794        /**
5795         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
5796         * policy, which is to sleep shortly after the turning off
5797         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
5798         */
5799        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
5800
5801        /**
5802         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
5803         * the device is on battery, and never go to sleep when the device is
5804         * plugged in.
5805         */
5806        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
5807
5808        /**
5809         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
5810         */
5811        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
5812
5813        /**
5814         * Value to specify if the user prefers the date, time and time zone
5815         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
5816         */
5817        public static final String AUTO_TIME = "auto_time";
5818
5819        /**
5820         * Value to specify if the user prefers the time zone
5821         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
5822         */
5823        public static final String AUTO_TIME_ZONE = "auto_time_zone";
5824
5825        /**
5826         * URI for the car dock "in" event sound.
5827         * @hide
5828         */
5829        public static final String CAR_DOCK_SOUND = "car_dock_sound";
5830
5831        /**
5832         * URI for the car dock "out" event sound.
5833         * @hide
5834         */
5835        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
5836
5837        /**
5838         * URI for the desk dock "in" event sound.
5839         * @hide
5840         */
5841        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
5842
5843        /**
5844         * URI for the desk dock "out" event sound.
5845         * @hide
5846         */
5847        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
5848
5849        /**
5850         * Whether to play a sound for dock events.
5851         * @hide
5852         */
5853        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
5854
5855        /**
5856         * URI for the "device locked" (keyguard shown) sound.
5857         * @hide
5858         */
5859        public static final String LOCK_SOUND = "lock_sound";
5860
5861        /**
5862         * URI for the "device unlocked" sound.
5863         * @hide
5864         */
5865        public static final String UNLOCK_SOUND = "unlock_sound";
5866
5867        /**
5868         * URI for the "device is trusted" sound, which is played when the device enters the trusted
5869         * state without unlocking.
5870         * @hide
5871         */
5872        public static final String TRUSTED_SOUND = "trusted_sound";
5873
5874        /**
5875         * URI for the low battery sound file.
5876         * @hide
5877         */
5878        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
5879
5880        /**
5881         * Whether to play a sound for low-battery alerts.
5882         * @hide
5883         */
5884        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
5885
5886        /**
5887         * URI for the "wireless charging started" sound.
5888         * @hide
5889         */
5890        public static final String WIRELESS_CHARGING_STARTED_SOUND =
5891                "wireless_charging_started_sound";
5892
5893        /**
5894         * Whether we keep the device on while the device is plugged in.
5895         * Supported values are:
5896         * <ul>
5897         * <li>{@code 0} to never stay on while plugged in</li>
5898         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
5899         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
5900         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
5901         * </ul>
5902         * These values can be OR-ed together.
5903         */
5904        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
5905
5906        /**
5907         * When the user has enable the option to have a "bug report" command
5908         * in the power menu.
5909         * @hide
5910         */
5911        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
5912
5913        /**
5914         * Whether ADB is enabled.
5915         */
5916        public static final String ADB_ENABLED = "adb_enabled";
5917
5918        /**
5919         * Whether Views are allowed to save their attribute data.
5920         * @hide
5921         */
5922        public static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
5923
5924        /**
5925         * Whether assisted GPS should be enabled or not.
5926         * @hide
5927         */
5928        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
5929
5930        /**
5931         * Whether bluetooth is enabled/disabled
5932         * 0=disabled. 1=enabled.
5933         */
5934        public static final String BLUETOOTH_ON = "bluetooth_on";
5935
5936        /**
5937         * CDMA Cell Broadcast SMS
5938         *                            0 = CDMA Cell Broadcast SMS disabled
5939         *                            1 = CDMA Cell Broadcast SMS enabled
5940         * @hide
5941         */
5942        public static final String CDMA_CELL_BROADCAST_SMS =
5943                "cdma_cell_broadcast_sms";
5944
5945        /**
5946         * The CDMA roaming mode 0 = Home Networks, CDMA default
5947         *                       1 = Roaming on Affiliated networks
5948         *                       2 = Roaming on any networks
5949         * @hide
5950         */
5951        public static final String CDMA_ROAMING_MODE = "roaming_settings";
5952
5953        /**
5954         * The CDMA subscription mode 0 = RUIM/SIM (default)
5955         *                                1 = NV
5956         * @hide
5957         */
5958        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
5959
5960        /** Inactivity timeout to track mobile data activity.
5961        *
5962        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
5963        * infer the data activity of mobile network. After a period of no activity on mobile
5964        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
5965        * intent is fired to indicate a transition of network status from "active" to "idle". Any
5966        * subsequent activity on mobile networks triggers the firing of {@code
5967        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
5968        *
5969        * Network activity refers to transmitting or receiving data on the network interfaces.
5970        *
5971        * Tracking is disabled if set to zero or negative value.
5972        *
5973        * @hide
5974        */
5975       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
5976
5977       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
5978        * but for Wifi network.
5979        * @hide
5980        */
5981       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
5982
5983       /**
5984        * Whether or not data roaming is enabled. (0 = false, 1 = true)
5985        */
5986       public static final String DATA_ROAMING = "data_roaming";
5987
5988       /**
5989        * The value passed to a Mobile DataConnection via bringUp which defines the
5990        * number of retries to preform when setting up the initial connection. The default
5991        * value defined in DataConnectionTrackerBase#DEFAULT_MDC_INITIAL_RETRY is currently 1.
5992        * @hide
5993        */
5994       public static final String MDC_INITIAL_MAX_RETRY = "mdc_initial_max_retry";
5995
5996       /**
5997        * Whether user has enabled development settings.
5998        */
5999       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
6000
6001       /**
6002        * Whether the device has been provisioned (0 = false, 1 = true)
6003        */
6004       public static final String DEVICE_PROVISIONED = "device_provisioned";
6005
6006       /**
6007        * The saved value for WindowManagerService.setForcedDisplayDensity().
6008        * One integer in dpi.  If unset, then use the real display density.
6009        * @hide
6010        */
6011       public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
6012
6013       /**
6014        * The saved value for WindowManagerService.setForcedDisplaySize().
6015        * Two integers separated by a comma.  If unset, then use the real display size.
6016        * @hide
6017        */
6018       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
6019
6020       /**
6021        * The maximum size, in bytes, of a download that the download manager will transfer over
6022        * a non-wifi connection.
6023        * @hide
6024        */
6025       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
6026               "download_manager_max_bytes_over_mobile";
6027
6028       /**
6029        * The recommended maximum size, in bytes, of a download that the download manager should
6030        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
6031        * have the option to start the download over the mobile connection anyway.
6032        * @hide
6033        */
6034       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
6035               "download_manager_recommended_max_bytes_over_mobile";
6036
6037       /**
6038        * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
6039        */
6040       @Deprecated
6041       public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
6042
6043       /**
6044        * Whether HDMI control shall be enabled. If disabled, no CEC/MHL command will be
6045        * sent or processed. (0 = false, 1 = true)
6046        * @hide
6047        */
6048       public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled";
6049
6050       /**
6051        * Whether HDMI system audio is enabled. If enabled, TV internal speaker is muted,
6052        * and the output is redirected to AV Receiver connected via
6053        * {@Global#HDMI_SYSTEM_AUDIO_OUTPUT}.
6054        * @hide
6055        */
6056       public static final String HDMI_SYSTEM_AUDIO_ENABLED = "hdmi_system_audio_enabled";
6057
6058       /**
6059        * Whether TV will automatically turn on upon reception of the CEC command
6060        * &lt;Text View On&gt; or &lt;Image View On&gt;. (0 = false, 1 = true)
6061        * @hide
6062        */
6063       public static final String HDMI_CONTROL_AUTO_WAKEUP_ENABLED =
6064               "hdmi_control_auto_wakeup_enabled";
6065
6066       /**
6067        * Whether TV will also turn off other CEC devices when it goes to standby mode.
6068        * (0 = false, 1 = true)
6069        * @hide
6070        */
6071       public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
6072               "hdmi_control_auto_device_off_enabled";
6073
6074       /**
6075        * Whether to use the DHCP client from Lollipop and earlier instead of the newer Android DHCP
6076        * client.
6077        * (0 = false, 1 = true)
6078        * @hide
6079        */
6080       public static final String LEGACY_DHCP_CLIENT = "legacy_dhcp_client";
6081
6082       /**
6083        * Whether TV will switch to MHL port when a mobile device is plugged in.
6084        * (0 = false, 1 = true)
6085        * @hide
6086        */
6087       public static final String MHL_INPUT_SWITCHING_ENABLED = "mhl_input_switching_enabled";
6088
6089       /**
6090        * Whether TV will charge the mobile device connected at MHL port. (0 = false, 1 = true)
6091        * @hide
6092        */
6093       public static final String MHL_POWER_CHARGE_ENABLED = "mhl_power_charge_enabled";
6094
6095       /**
6096        * Whether mobile data connections are allowed by the user.  See
6097        * ConnectivityManager for more info.
6098        * @hide
6099        */
6100       public static final String MOBILE_DATA = "mobile_data";
6101
6102       /** {@hide} */
6103       public static final String NETSTATS_ENABLED = "netstats_enabled";
6104       /** {@hide} */
6105       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
6106       /** {@hide} */
6107       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
6108       /** {@hide} */
6109       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
6110       /** {@hide} */
6111       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
6112
6113       /** {@hide} */
6114       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
6115       /** {@hide} */
6116       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
6117       /** {@hide} */
6118       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
6119       /** {@hide} */
6120       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
6121
6122       /** {@hide} */
6123       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
6124       /** {@hide} */
6125       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
6126       /** {@hide} */
6127       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
6128       /** {@hide} */
6129       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
6130
6131       /** {@hide} */
6132       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
6133       /** {@hide} */
6134       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
6135       /** {@hide} */
6136       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
6137       /** {@hide} */
6138       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
6139
6140       /**
6141        * User preference for which network(s) should be used. Only the
6142        * connectivity service should touch this.
6143        */
6144       public static final String NETWORK_PREFERENCE = "network_preference";
6145
6146       /**
6147        * Which package name to use for network scoring. If null, or if the package is not a valid
6148        * scorer app, external network scores will neither be requested nor accepted.
6149        * @hide
6150        */
6151       public static final String NETWORK_SCORER_APP = "network_scorer_app";
6152
6153       /**
6154        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
6155        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
6156        * exceeded.
6157        * @hide
6158        */
6159       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
6160
6161       /**
6162        * The length of time in milli-seconds that automatic small adjustments to
6163        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
6164        * @hide
6165        */
6166       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
6167
6168       /** Preferred NTP server. {@hide} */
6169       public static final String NTP_SERVER = "ntp_server";
6170       /** Timeout in milliseconds to wait for NTP server. {@hide} */
6171       public static final String NTP_TIMEOUT = "ntp_timeout";
6172
6173       /**
6174        * Whether the package manager should send package verification broadcasts for verifiers to
6175        * review apps prior to installation.
6176        * 1 = request apps to be verified prior to installation, if a verifier exists.
6177        * 0 = do not verify apps before installation
6178        * @hide
6179        */
6180       public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
6181
6182       /** Timeout for package verification.
6183        * @hide */
6184       public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
6185
6186       /** Default response code for package verification.
6187        * @hide */
6188       public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
6189
6190       /**
6191        * Show package verification setting in the Settings app.
6192        * 1 = show (default)
6193        * 0 = hide
6194        * @hide
6195        */
6196       public static final String PACKAGE_VERIFIER_SETTING_VISIBLE = "verifier_setting_visible";
6197
6198       /**
6199        * Run package verification on apps installed through ADB/ADT/USB
6200        * 1 = perform package verification on ADB installs (default)
6201        * 0 = bypass package verification on ADB installs
6202        * @hide
6203        */
6204       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
6205
6206       /**
6207        * Time since last fstrim (milliseconds) after which we force one to happen
6208        * during device startup.  If unset, the default is 3 days.
6209        * @hide
6210        */
6211       public static final String FSTRIM_MANDATORY_INTERVAL = "fstrim_mandatory_interval";
6212
6213       /**
6214        * The interval in milliseconds at which to check packet counts on the
6215        * mobile data interface when screen is on, to detect possible data
6216        * connection problems.
6217        * @hide
6218        */
6219       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
6220               "pdp_watchdog_poll_interval_ms";
6221
6222       /**
6223        * The interval in milliseconds at which to check packet counts on the
6224        * mobile data interface when screen is off, to detect possible data
6225        * connection problems.
6226        * @hide
6227        */
6228       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
6229               "pdp_watchdog_long_poll_interval_ms";
6230
6231       /**
6232        * The interval in milliseconds at which to check packet counts on the
6233        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
6234        * outgoing packets has been reached without incoming packets.
6235        * @hide
6236        */
6237       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
6238               "pdp_watchdog_error_poll_interval_ms";
6239
6240       /**
6241        * The number of outgoing packets sent without seeing an incoming packet
6242        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
6243        * device is logged to the event log
6244        * @hide
6245        */
6246       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
6247               "pdp_watchdog_trigger_packet_count";
6248
6249       /**
6250        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
6251        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
6252        * attempting data connection recovery.
6253        * @hide
6254        */
6255       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
6256               "pdp_watchdog_error_poll_count";
6257
6258       /**
6259        * The number of failed PDP reset attempts before moving to something more
6260        * drastic: re-registering to the network.
6261        * @hide
6262        */
6263       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
6264               "pdp_watchdog_max_pdp_reset_fail_count";
6265
6266       /**
6267        * A positive value indicates how often the SamplingProfiler
6268        * should take snapshots. Zero value means SamplingProfiler
6269        * is disabled.
6270        *
6271        * @hide
6272        */
6273       public static final String SAMPLING_PROFILER_MS = "sampling_profiler_ms";
6274
6275       /**
6276        * URL to open browser on to allow user to manage a prepay account
6277        * @hide
6278        */
6279       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
6280               "setup_prepaid_data_service_url";
6281
6282       /**
6283        * URL to attempt a GET on to see if this is a prepay device
6284        * @hide
6285        */
6286       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
6287               "setup_prepaid_detection_target_url";
6288
6289       /**
6290        * Host to check for a redirect to after an attempt to GET
6291        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
6292        * this is a prepaid device with zero balance.)
6293        * @hide
6294        */
6295       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
6296               "setup_prepaid_detection_redir_host";
6297
6298       /**
6299        * The interval in milliseconds at which to check the number of SMS sent out without asking
6300        * for use permit, to limit the un-authorized SMS usage.
6301        *
6302        * @hide
6303        */
6304       public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
6305               "sms_outgoing_check_interval_ms";
6306
6307       /**
6308        * The number of outgoing SMS sent without asking for user permit (of {@link
6309        * #SMS_OUTGOING_CHECK_INTERVAL_MS}
6310        *
6311        * @hide
6312        */
6313       public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
6314               "sms_outgoing_check_max_count";
6315
6316       /**
6317        * Used to disable SMS short code confirmation - defaults to true.
6318        * True indcates we will do the check, etc.  Set to false to disable.
6319        * @see com.android.internal.telephony.SmsUsageMonitor
6320        * @hide
6321        */
6322       public static final String SMS_SHORT_CODE_CONFIRMATION = "sms_short_code_confirmation";
6323
6324        /**
6325         * Used to select which country we use to determine premium sms codes.
6326         * One of com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_SIM,
6327         * com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_NETWORK,
6328         * or com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_BOTH.
6329         * @hide
6330         */
6331        public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule";
6332
6333       /**
6334        * Used to select TCP's default initial receiver window size in segments - defaults to a build config value
6335        * @hide
6336        */
6337       public static final String TCP_DEFAULT_INIT_RWND = "tcp_default_init_rwnd";
6338
6339       /**
6340        * Used to disable Tethering on a device - defaults to true
6341        * @hide
6342        */
6343       public static final String TETHER_SUPPORTED = "tether_supported";
6344
6345       /**
6346        * Used to require DUN APN on the device or not - defaults to a build config value
6347        * which defaults to false
6348        * @hide
6349        */
6350       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
6351
6352       /**
6353        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
6354        * corresponding build config values are set it will override the APN DB
6355        * values.
6356        * Consists of a comma seperated list of strings:
6357        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
6358        * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
6359        * @hide
6360        */
6361       public static final String TETHER_DUN_APN = "tether_dun_apn";
6362
6363       /**
6364        * USB Mass Storage Enabled
6365        */
6366       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
6367
6368       /**
6369        * If this setting is set (to anything), then all references
6370        * to Gmail on the device must change to Google Mail.
6371        */
6372       public static final String USE_GOOGLE_MAIL = "use_google_mail";
6373
6374        /**
6375         * Webview Data reduction proxy key.
6376         * @hide
6377         */
6378        public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
6379                "webview_data_reduction_proxy_key";
6380
6381       /**
6382        * Whether Wifi display is enabled/disabled
6383        * 0=disabled. 1=enabled.
6384        * @hide
6385        */
6386       public static final String WIFI_DISPLAY_ON = "wifi_display_on";
6387
6388       /**
6389        * Whether Wifi display certification mode is enabled/disabled
6390        * 0=disabled. 1=enabled.
6391        * @hide
6392        */
6393       public static final String WIFI_DISPLAY_CERTIFICATION_ON =
6394               "wifi_display_certification_on";
6395
6396       /**
6397        * WPS Configuration method used by Wifi display, this setting only
6398        * takes effect when WIFI_DISPLAY_CERTIFICATION_ON is 1 (enabled).
6399        *
6400        * Possible values are:
6401        *
6402        * WpsInfo.INVALID: use default WPS method chosen by framework
6403        * WpsInfo.PBC    : use Push button
6404        * WpsInfo.KEYPAD : use Keypad
6405        * WpsInfo.DISPLAY: use Display
6406        * @hide
6407        */
6408       public static final String WIFI_DISPLAY_WPS_CONFIG =
6409           "wifi_display_wps_config";
6410
6411       /**
6412        * Whether to notify the user of open networks.
6413        * <p>
6414        * If not connected and the scan results have an open network, we will
6415        * put this notification up. If we attempt to connect to a network or
6416        * the open network(s) disappear, we remove the notification. When we
6417        * show the notification, we will not show it again for
6418        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
6419        */
6420       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
6421               "wifi_networks_available_notification_on";
6422       /**
6423        * {@hide}
6424        */
6425       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
6426               "wimax_networks_available_notification_on";
6427
6428       /**
6429        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
6430        * Connecting to a network will reset the timer.
6431        */
6432       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
6433               "wifi_networks_available_repeat_delay";
6434
6435       /**
6436        * 802.11 country code in ISO 3166 format
6437        * @hide
6438        */
6439       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
6440
6441       /**
6442        * The interval in milliseconds to issue wake up scans when wifi needs
6443        * to connect. This is necessary to connect to an access point when
6444        * device is on the move and the screen is off.
6445        * @hide
6446        */
6447       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
6448               "wifi_framework_scan_interval_ms";
6449
6450       /**
6451        * The interval in milliseconds after which Wi-Fi is considered idle.
6452        * When idle, it is possible for the device to be switched from Wi-Fi to
6453        * the mobile data network.
6454        * @hide
6455        */
6456       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
6457
6458       /**
6459        * When the number of open networks exceeds this number, the
6460        * least-recently-used excess networks will be removed.
6461        */
6462       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
6463
6464       /**
6465        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
6466        */
6467       public static final String WIFI_ON = "wifi_on";
6468
6469       /**
6470        * Setting to allow scans to be enabled even wifi is turned off for connectivity.
6471        * @hide
6472        */
6473       public static final String WIFI_SCAN_ALWAYS_AVAILABLE =
6474                "wifi_scan_always_enabled";
6475
6476       /**
6477        * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
6478        * connectivity.
6479        * @hide
6480        */
6481       public static final String BLE_SCAN_ALWAYS_AVAILABLE =
6482               "ble_scan_always_enabled";
6483
6484       /**
6485        * Used to save the Wifi_ON state prior to tethering.
6486        * This state will be checked to restore Wifi after
6487        * the user turns off tethering.
6488        *
6489        * @hide
6490        */
6491       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
6492
6493       /**
6494        * The interval in milliseconds to scan as used by the wifi supplicant
6495        * @hide
6496        */
6497       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
6498               "wifi_supplicant_scan_interval_ms";
6499
6500        /**
6501         * whether frameworks handles wifi auto-join
6502         * @hide
6503         */
6504       public static final String WIFI_ENHANCED_AUTO_JOIN =
6505                "wifi_enhanced_auto_join";
6506
6507        /**
6508         * whether settings show RSSI
6509         * @hide
6510         */
6511        public static final String WIFI_NETWORK_SHOW_RSSI =
6512                "wifi_network_show_rssi";
6513
6514        /**
6515        * The interval in milliseconds to scan at supplicant when p2p is connected
6516        * @hide
6517        */
6518       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
6519               "wifi_scan_interval_p2p_connected_ms";
6520
6521       /**
6522        * Whether the Wi-Fi watchdog is enabled.
6523        */
6524       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
6525
6526       /**
6527        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
6528        * the setting needs to be set to 0 to disable it.
6529        * @hide
6530        */
6531       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
6532               "wifi_watchdog_poor_network_test_enabled";
6533
6534       /**
6535        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
6536        * needs to be set to 0 to disable it.
6537        * @hide
6538        */
6539       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
6540               "wifi_suspend_optimizations_enabled";
6541
6542       /**
6543        * The maximum number of times we will retry a connection to an access
6544        * point for which we have failed in acquiring an IP address from DHCP.
6545        * A value of N means that we will make N+1 connection attempts in all.
6546        */
6547       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
6548
6549       /**
6550        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
6551        * data connectivity to be established after a disconnect from Wi-Fi.
6552        */
6553       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
6554           "wifi_mobile_data_transition_wakelock_timeout_ms";
6555
6556       /**
6557        * The operational wifi frequency band
6558        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
6559        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
6560        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
6561        *
6562        * @hide
6563        */
6564       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
6565
6566       /**
6567        * The Wi-Fi peer-to-peer device name
6568        * @hide
6569        */
6570       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
6571
6572       /**
6573        * The min time between wifi disable and wifi enable
6574        * @hide
6575        */
6576       public static final String WIFI_REENABLE_DELAY_MS = "wifi_reenable_delay";
6577
6578       /**
6579        * Timeout for ephemeral networks when all known BSSIDs go out of range. We will disconnect
6580        * from an ephemeral network if there is no BSSID for that network with a non-null score that
6581        * has been seen in this time period.
6582        *
6583        * If this is less than or equal to zero, we use a more conservative behavior and only check
6584        * for a non-null score from the currently connected or target BSSID.
6585        * @hide
6586        */
6587       public static final String WIFI_EPHEMERAL_OUT_OF_RANGE_TIMEOUT_MS =
6588               "wifi_ephemeral_out_of_range_timeout_ms";
6589
6590       /**
6591        * The number of milliseconds to delay when checking for data stalls during
6592        * non-aggressive detection. (screen is turned off.)
6593        * @hide
6594        */
6595       public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
6596               "data_stall_alarm_non_aggressive_delay_in_ms";
6597
6598       /**
6599        * The number of milliseconds to delay when checking for data stalls during
6600        * aggressive detection. (screen on or suspected data stall)
6601        * @hide
6602        */
6603       public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
6604               "data_stall_alarm_aggressive_delay_in_ms";
6605
6606       /**
6607        * The number of milliseconds to allow the provisioning apn to remain active
6608        * @hide
6609        */
6610       public static final String PROVISIONING_APN_ALARM_DELAY_IN_MS =
6611               "provisioning_apn_alarm_delay_in_ms";
6612
6613       /**
6614        * The interval in milliseconds at which to check gprs registration
6615        * after the first registration mismatch of gprs and voice service,
6616        * to detect possible data network registration problems.
6617        *
6618        * @hide
6619        */
6620       public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
6621               "gprs_register_check_period_ms";
6622
6623       /**
6624        * Nonzero causes Log.wtf() to crash.
6625        * @hide
6626        */
6627       public static final String WTF_IS_FATAL = "wtf_is_fatal";
6628
6629       /**
6630        * Ringer mode. This is used internally, changing this value will not
6631        * change the ringer mode. See AudioManager.
6632        */
6633       public static final String MODE_RINGER = "mode_ringer";
6634
6635       /**
6636        * Overlay display devices setting.
6637        * The associated value is a specially formatted string that describes the
6638        * size and density of simulated secondary display devices.
6639        * <p>
6640        * Format: {width}x{height}/{dpi};...
6641        * </p><p>
6642        * Example:
6643        * <ul>
6644        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
6645        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
6646        * at 1080p and the second at 720p.</li>
6647        * <li>If the value is empty, then no overlay display devices are created.</li>
6648        * </ul></p>
6649        *
6650        * @hide
6651        */
6652       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
6653
6654        /**
6655         * Threshold values for the duration and level of a discharge cycle,
6656         * under which we log discharge cycle info.
6657         *
6658         * @hide
6659         */
6660        public static final String
6661                BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold";
6662
6663        /** @hide */
6664        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
6665
6666        /**
6667         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR
6668         * intents on application crashes and ANRs. If this is disabled, the
6669         * crash/ANR dialog will never display the "Report" button.
6670         * <p>
6671         * Type: int (0 = disallow, 1 = allow)
6672         *
6673         * @hide
6674         */
6675        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
6676
6677        /**
6678         * Maximum age of entries kept by {@link DropBoxManager}.
6679         *
6680         * @hide
6681         */
6682        public static final String DROPBOX_AGE_SECONDS = "dropbox_age_seconds";
6683
6684        /**
6685         * Maximum number of entry files which {@link DropBoxManager} will keep
6686         * around.
6687         *
6688         * @hide
6689         */
6690        public static final String DROPBOX_MAX_FILES = "dropbox_max_files";
6691
6692        /**
6693         * Maximum amount of disk space used by {@link DropBoxManager} no matter
6694         * what.
6695         *
6696         * @hide
6697         */
6698        public static final String DROPBOX_QUOTA_KB = "dropbox_quota_kb";
6699
6700        /**
6701         * Percent of free disk (excluding reserve) which {@link DropBoxManager}
6702         * will use.
6703         *
6704         * @hide
6705         */
6706        public static final String DROPBOX_QUOTA_PERCENT = "dropbox_quota_percent";
6707
6708        /**
6709         * Percent of total disk which {@link DropBoxManager} will never dip
6710         * into.
6711         *
6712         * @hide
6713         */
6714        public static final String DROPBOX_RESERVE_PERCENT = "dropbox_reserve_percent";
6715
6716        /**
6717         * Prefix for per-tag dropbox disable/enable settings.
6718         *
6719         * @hide
6720         */
6721        public static final String DROPBOX_TAG_PREFIX = "dropbox:";
6722
6723        /**
6724         * Lines of logcat to include with system crash/ANR/etc. reports, as a
6725         * prefix of the dropbox tag of the report type. For example,
6726         * "logcat_for_system_server_anr" controls the lines of logcat captured
6727         * with system server ANR reports. 0 to disable.
6728         *
6729         * @hide
6730         */
6731        public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
6732
6733        /**
6734         * The interval in minutes after which the amount of free storage left
6735         * on the device is logged to the event log
6736         *
6737         * @hide
6738         */
6739        public static final String SYS_FREE_STORAGE_LOG_INTERVAL = "sys_free_storage_log_interval";
6740
6741        /**
6742         * Threshold for the amount of change in disk free space required to
6743         * report the amount of free space. Used to prevent spamming the logs
6744         * when the disk free space isn't changing frequently.
6745         *
6746         * @hide
6747         */
6748        public static final String
6749                DISK_FREE_CHANGE_REPORTING_THRESHOLD = "disk_free_change_reporting_threshold";
6750
6751        /**
6752         * Minimum percentage of free storage on the device that is used to
6753         * determine if the device is running low on storage. The default is 10.
6754         * <p>
6755         * Say this value is set to 10, the device is considered running low on
6756         * storage if 90% or more of the device storage is filled up.
6757         *
6758         * @hide
6759         */
6760        public static final String
6761                SYS_STORAGE_THRESHOLD_PERCENTAGE = "sys_storage_threshold_percentage";
6762
6763        /**
6764         * Maximum byte size of the low storage threshold. This is to ensure
6765         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in an
6766         * overly large threshold for large storage devices. Currently this must
6767         * be less than 2GB. This default is 500MB.
6768         *
6769         * @hide
6770         */
6771        public static final String
6772                SYS_STORAGE_THRESHOLD_MAX_BYTES = "sys_storage_threshold_max_bytes";
6773
6774        /**
6775         * Minimum bytes of free storage on the device before the data partition
6776         * is considered full. By default, 1 MB is reserved to avoid system-wide
6777         * SQLite disk full exceptions.
6778         *
6779         * @hide
6780         */
6781        public static final String
6782                SYS_STORAGE_FULL_THRESHOLD_BYTES = "sys_storage_full_threshold_bytes";
6783
6784        /**
6785         * The maximum reconnect delay for short network outages or when the
6786         * network is suspended due to phone use.
6787         *
6788         * @hide
6789         */
6790        public static final String
6791                SYNC_MAX_RETRY_DELAY_IN_SECONDS = "sync_max_retry_delay_in_seconds";
6792
6793        /**
6794         * The number of milliseconds to delay before sending out
6795         * {@link ConnectivityManager#CONNECTIVITY_ACTION} broadcasts. Ignored.
6796         *
6797         * @hide
6798         */
6799        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
6800
6801
6802        /**
6803         * Network sampling interval, in seconds. We'll generate link information
6804         * about bytes/packets sent and error rates based on data sampled in this interval
6805         *
6806         * @hide
6807         */
6808
6809        public static final String CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS =
6810                "connectivity_sampling_interval_in_seconds";
6811
6812        /**
6813         * The series of successively longer delays used in retrying to download PAC file.
6814         * Last delay is used between successful PAC downloads.
6815         *
6816         * @hide
6817         */
6818        public static final String PAC_CHANGE_DELAY = "pac_change_delay";
6819
6820        /**
6821         * Setting to turn off captive portal detection. Feature is enabled by
6822         * default and the setting needs to be set to 0 to disable it.
6823         *
6824         * @hide
6825         */
6826        public static final String
6827                CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled";
6828
6829        /**
6830         * The server used for captive portal detection upon a new conection. A
6831         * 204 response code from the server is used for validation.
6832         *
6833         * @hide
6834         */
6835        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
6836
6837        /**
6838         * Whether network service discovery is enabled.
6839         *
6840         * @hide
6841         */
6842        public static final String NSD_ON = "nsd_on";
6843
6844        /**
6845         * Let user pick default install location.
6846         *
6847         * @hide
6848         */
6849        public static final String SET_INSTALL_LOCATION = "set_install_location";
6850
6851        /**
6852         * Default install location value.
6853         * 0 = auto, let system decide
6854         * 1 = internal
6855         * 2 = sdcard
6856         * @hide
6857         */
6858        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
6859
6860        /**
6861         * ms during which to consume extra events related to Inet connection
6862         * condition after a transtion to fully-connected
6863         *
6864         * @hide
6865         */
6866        public static final String
6867                INET_CONDITION_DEBOUNCE_UP_DELAY = "inet_condition_debounce_up_delay";
6868
6869        /**
6870         * ms during which to consume extra events related to Inet connection
6871         * condtion after a transtion to partly-connected
6872         *
6873         * @hide
6874         */
6875        public static final String
6876                INET_CONDITION_DEBOUNCE_DOWN_DELAY = "inet_condition_debounce_down_delay";
6877
6878        /** {@hide} */
6879        public static final String
6880                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
6881
6882        /**
6883         * Host name and port for global http proxy. Uses ':' seperator for
6884         * between host and port.
6885         */
6886        public static final String HTTP_PROXY = "http_proxy";
6887
6888        /**
6889         * Host name for global http proxy. Set via ConnectivityManager.
6890         *
6891         * @hide
6892         */
6893        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
6894
6895        /**
6896         * Integer host port for global http proxy. Set via ConnectivityManager.
6897         *
6898         * @hide
6899         */
6900        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
6901
6902        /**
6903         * Exclusion list for global proxy. This string contains a list of
6904         * comma-separated domains where the global proxy does not apply.
6905         * Domains should be listed in a comma- separated list. Example of
6906         * acceptable formats: ".domain1.com,my.domain2.com" Use
6907         * ConnectivityManager to set/get.
6908         *
6909         * @hide
6910         */
6911        public static final String
6912                GLOBAL_HTTP_PROXY_EXCLUSION_LIST = "global_http_proxy_exclusion_list";
6913
6914        /**
6915         * The location PAC File for the proxy.
6916         * @hide
6917         */
6918        public static final String
6919                GLOBAL_HTTP_PROXY_PAC = "global_proxy_pac_url";
6920
6921        /**
6922         * Enables the UI setting to allow the user to specify the global HTTP
6923         * proxy and associated exclusion list.
6924         *
6925         * @hide
6926         */
6927        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
6928
6929        /**
6930         * Setting for default DNS in case nobody suggests one
6931         *
6932         * @hide
6933         */
6934        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
6935
6936        /** {@hide} */
6937        public static final String
6938                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
6939        /** {@hide} */
6940        public static final String
6941                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
6942        /** {@hide} */
6943        public static final String
6944                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
6945        /** {@hide} */
6946        public static final String
6947                BLUETOOTH_MAP_PRIORITY_PREFIX = "bluetooth_map_priority_";
6948
6949        /**
6950         * Get the key that retrieves a bluetooth headset's priority.
6951         * @hide
6952         */
6953        public static final String getBluetoothHeadsetPriorityKey(String address) {
6954            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
6955        }
6956
6957        /**
6958         * Get the key that retrieves a bluetooth a2dp sink's priority.
6959         * @hide
6960         */
6961        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
6962            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
6963        }
6964
6965        /**
6966         * Get the key that retrieves a bluetooth Input Device's priority.
6967         * @hide
6968         */
6969        public static final String getBluetoothInputDevicePriorityKey(String address) {
6970            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
6971        }
6972
6973        /**
6974         * Get the key that retrieves a bluetooth map priority.
6975         * @hide
6976         */
6977        public static final String getBluetoothMapPriorityKey(String address) {
6978            return BLUETOOTH_MAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
6979        }
6980        /**
6981         * Scaling factor for normal window animations. Setting to 0 will
6982         * disable window animations.
6983         */
6984        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
6985
6986        /**
6987         * Scaling factor for activity transition animations. Setting to 0 will
6988         * disable window animations.
6989         */
6990        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
6991
6992        /**
6993         * Scaling factor for Animator-based animations. This affects both the
6994         * start delay and duration of all such animations. Setting to 0 will
6995         * cause animations to end immediately. The default value is 1.
6996         */
6997        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
6998
6999        /**
7000         * Scaling factor for normal window animations. Setting to 0 will
7001         * disable window animations.
7002         *
7003         * @hide
7004         */
7005        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
7006
7007        /**
7008         * If 0, the compatibility mode is off for all applications.
7009         * If 1, older applications run under compatibility mode.
7010         * TODO: remove this settings before code freeze (bug/1907571)
7011         * @hide
7012         */
7013        public static final String COMPATIBILITY_MODE = "compatibility_mode";
7014
7015        /**
7016         * CDMA only settings
7017         * Emergency Tone  0 = Off
7018         *                 1 = Alert
7019         *                 2 = Vibrate
7020         * @hide
7021         */
7022        public static final String EMERGENCY_TONE = "emergency_tone";
7023
7024        /**
7025         * CDMA only settings
7026         * Whether the auto retry is enabled. The value is
7027         * boolean (1 or 0).
7028         * @hide
7029         */
7030        public static final String CALL_AUTO_RETRY = "call_auto_retry";
7031
7032        /**
7033         * See RIL_PreferredNetworkType in ril.h
7034         * @hide
7035         */
7036        public static final String PREFERRED_NETWORK_MODE =
7037                "preferred_network_mode";
7038
7039        /**
7040         * Setting to 1 will hide carrier network settings.
7041         * Default is 0.
7042         * @hide
7043         */
7044        public static final String HIDE_CARRIER_NETWORK_SETTINGS =
7045                "hide_carrier_network_settings";
7046
7047        /**
7048         * Name of an application package to be debugged.
7049         */
7050        public static final String DEBUG_APP = "debug_app";
7051
7052        /**
7053         * If 1, when launching DEBUG_APP it will wait for the debugger before
7054         * starting user code.  If 0, it will run normally.
7055         */
7056        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
7057
7058        /**
7059         * Control whether the process CPU usage meter should be shown.
7060         */
7061        public static final String SHOW_PROCESSES = "show_processes";
7062
7063        /**
7064         * If 1 low power mode is enabled.
7065         * @hide
7066         */
7067        public static final String LOW_POWER_MODE = "low_power";
7068
7069        /**
7070         * Battery level [1-99] at which low power mode automatically turns on.
7071         * If 0, it will not automatically turn on.
7072         * @hide
7073         */
7074        public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level";
7075
7076         /**
7077         * If 1, the activity manager will aggressively finish activities and
7078         * processes as soon as they are no longer needed.  If 0, the normal
7079         * extended lifetime is used.
7080         */
7081        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
7082
7083        /**
7084         * Use Dock audio output for media:
7085         *      0 = disabled
7086         *      1 = enabled
7087         * @hide
7088         */
7089        public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
7090
7091        /**
7092         * Persisted safe headphone volume management state by AudioService
7093         * @hide
7094         */
7095        public static final String AUDIO_SAFE_VOLUME_STATE = "audio_safe_volume_state";
7096
7097        /**
7098         * URL for tzinfo (time zone) updates
7099         * @hide
7100         */
7101        public static final String TZINFO_UPDATE_CONTENT_URL = "tzinfo_content_url";
7102
7103        /**
7104         * URL for tzinfo (time zone) update metadata
7105         * @hide
7106         */
7107        public static final String TZINFO_UPDATE_METADATA_URL = "tzinfo_metadata_url";
7108
7109        /**
7110         * URL for selinux (mandatory access control) updates
7111         * @hide
7112         */
7113        public static final String SELINUX_UPDATE_CONTENT_URL = "selinux_content_url";
7114
7115        /**
7116         * URL for selinux (mandatory access control) update metadata
7117         * @hide
7118         */
7119        public static final String SELINUX_UPDATE_METADATA_URL = "selinux_metadata_url";
7120
7121        /**
7122         * URL for sms short code updates
7123         * @hide
7124         */
7125        public static final String SMS_SHORT_CODES_UPDATE_CONTENT_URL =
7126                "sms_short_codes_content_url";
7127
7128        /**
7129         * URL for sms short code update metadata
7130         * @hide
7131         */
7132        public static final String SMS_SHORT_CODES_UPDATE_METADATA_URL =
7133                "sms_short_codes_metadata_url";
7134
7135        /**
7136         * URL for cert pinlist updates
7137         * @hide
7138         */
7139        public static final String CERT_PIN_UPDATE_CONTENT_URL = "cert_pin_content_url";
7140
7141        /**
7142         * URL for cert pinlist updates
7143         * @hide
7144         */
7145        public static final String CERT_PIN_UPDATE_METADATA_URL = "cert_pin_metadata_url";
7146
7147        /**
7148         * URL for intent firewall updates
7149         * @hide
7150         */
7151        public static final String INTENT_FIREWALL_UPDATE_CONTENT_URL =
7152                "intent_firewall_content_url";
7153
7154        /**
7155         * URL for intent firewall update metadata
7156         * @hide
7157         */
7158        public static final String INTENT_FIREWALL_UPDATE_METADATA_URL =
7159                "intent_firewall_metadata_url";
7160
7161        /**
7162         * SELinux enforcement status. If 0, permissive; if 1, enforcing.
7163         * @hide
7164         */
7165        public static final String SELINUX_STATUS = "selinux_status";
7166
7167        /**
7168         * Developer setting to force RTL layout.
7169         * @hide
7170         */
7171        public static final String DEVELOPMENT_FORCE_RTL = "debug.force_rtl";
7172
7173        /**
7174         * Milliseconds after screen-off after which low battery sounds will be silenced.
7175         *
7176         * If zero, battery sounds will always play.
7177         * Defaults to @integer/def_low_battery_sound_timeout in SettingsProvider.
7178         *
7179         * @hide
7180         */
7181        public static final String LOW_BATTERY_SOUND_TIMEOUT = "low_battery_sound_timeout";
7182
7183        /**
7184         * Milliseconds to wait before bouncing Wi-Fi after settings is restored. Note that after
7185         * the caller is done with this, they should call {@link ContentResolver#delete} to
7186         * clean up any value that they may have written.
7187         *
7188         * @hide
7189         */
7190        public static final String WIFI_BOUNCE_DELAY_OVERRIDE_MS = "wifi_bounce_delay_override_ms";
7191
7192        /**
7193         * Defines global runtime overrides to window policy.
7194         *
7195         * See {@link com.android.server.policy.PolicyControl} for value format.
7196         *
7197         * @hide
7198         */
7199        public static final String POLICY_CONTROL = "policy_control";
7200
7201        /**
7202         * Defines global zen mode.  ZEN_MODE_OFF, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
7203         * or ZEN_MODE_NO_INTERRUPTIONS.
7204         *
7205         * @hide
7206         */
7207        public static final String ZEN_MODE = "zen_mode";
7208
7209        /** @hide */ public static final int ZEN_MODE_OFF = 0;
7210        /** @hide */ public static final int ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
7211        /** @hide */ public static final int ZEN_MODE_NO_INTERRUPTIONS = 2;
7212        /** @hide */ public static final int ZEN_MODE_ALARMS = 3;
7213
7214        /** @hide */ public static String zenModeToString(int mode) {
7215            if (mode == ZEN_MODE_IMPORTANT_INTERRUPTIONS) return "ZEN_MODE_IMPORTANT_INTERRUPTIONS";
7216            if (mode == ZEN_MODE_ALARMS) return "ZEN_MODE_ALARMS";
7217            if (mode == ZEN_MODE_NO_INTERRUPTIONS) return "ZEN_MODE_NO_INTERRUPTIONS";
7218            return "ZEN_MODE_OFF";
7219        }
7220
7221        /**
7222         * Opaque value, changes when persisted zen mode configuration changes.
7223         *
7224         * @hide
7225         */
7226        public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
7227
7228        /**
7229         * Defines global heads up toggle.  One of HEADS_UP_OFF, HEADS_UP_ON.
7230         *
7231         * @hide
7232         */
7233        public static final String HEADS_UP_NOTIFICATIONS_ENABLED =
7234                "heads_up_notifications_enabled";
7235
7236        /** @hide */ public static final int HEADS_UP_OFF = 0;
7237        /** @hide */ public static final int HEADS_UP_ON = 1;
7238
7239        /**
7240         * The name of the device
7241         *
7242         * @hide
7243         */
7244        public static final String DEVICE_NAME = "device_name";
7245
7246        /**
7247         * Whether it should be possible to create a guest user on the device.
7248         * <p>
7249         * Type: int (0 for disabled, 1 for enabled)
7250         * @hide
7251         */
7252        public static final String GUEST_USER_ENABLED = "guest_user_enabled";
7253
7254        /**
7255         * Whether the NetworkScoringService has been first initialized.
7256         * <p>
7257         * Type: int (0 for false, 1 for true)
7258         * @hide
7259         */
7260        public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned";
7261
7262        /**
7263         * Whether the user wants to be prompted for password to decrypt the device on boot.
7264         * This only matters if the storage is encrypted.
7265         * <p>
7266         * Type: int (0 for false, 1 for true)
7267         * @hide
7268         */
7269        public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt";
7270
7271        /**
7272         * Whether the Volte/VT is enabled
7273         * <p>
7274         * Type: int (0 for false, 1 for true)
7275         * @hide
7276         */
7277        public static final String ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled";
7278
7279        /**
7280         * Whether WFC is enabled
7281         * <p>
7282         * Type: int (0 for false, 1 for true)
7283         *
7284         * @hide
7285         */
7286        public static final String WFC_IMS_ENABLED = "wfc_ims_enabled";
7287
7288        /**
7289         * WFC Mode.
7290         * <p>
7291         * Type: int - 2=Wi-Fi preferred, 1=Cellular preferred, 0=Wi-Fi only
7292         *
7293         * @hide
7294         */
7295        public static final String WFC_IMS_MODE = "wfc_ims_mode";
7296
7297        /**
7298         * Whether WFC roaming is enabled
7299         * <p>
7300         * Type: int (0 for false, 1 for true)
7301         *
7302         * @hide
7303         */
7304        public static final String WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled";
7305
7306        /**
7307         * Global override to disable VoLTE (independent of user setting)
7308         * <p>
7309         * Type: int (1 for disable VoLTE, 0 to use user configuration)
7310         * @hide
7311         */
7312        public static final String VOLTE_FEATURE_DISABLED = "volte_feature_disabled";
7313
7314        /**
7315         * Whether user can enable/disable LTE as a preferred network. A carrier might control
7316         * this via gservices, OMA-DM, carrier app, etc.
7317         * <p>
7318         * Type: int (0 for false, 1 for true)
7319         * @hide
7320         */
7321        public static final String LTE_SERVICE_FORCED = "lte_service_forced";
7322
7323        /**
7324         * Settings to backup. This is here so that it's in the same place as the settings
7325         * keys and easy to update.
7326         *
7327         * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
7328         * and Secure as well.  This is because those tables drive both backup and
7329         * restore, and restore needs to properly whitelist keys that used to live
7330         * in those namespaces.  The keys will only actually be backed up / restored
7331         * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
7332         *
7333         * NOTE: Settings are backed up and restored in the order they appear
7334         *       in this array. If you have one setting depending on another,
7335         *       make sure that they are ordered appropriately.
7336         *
7337         * @hide
7338         */
7339        public static final String[] SETTINGS_TO_BACKUP = {
7340            BUGREPORT_IN_POWER_MENU,
7341            STAY_ON_WHILE_PLUGGED_IN,
7342            AUTO_TIME,
7343            AUTO_TIME_ZONE,
7344            POWER_SOUNDS_ENABLED,
7345            DOCK_SOUNDS_ENABLED,
7346            USB_MASS_STORAGE_ENABLED,
7347            ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED,
7348            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
7349            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
7350            WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
7351            WIFI_NUM_OPEN_NETWORKS_KEPT,
7352            EMERGENCY_TONE,
7353            CALL_AUTO_RETRY,
7354            DOCK_AUDIO_MEDIA_ENABLED,
7355            LOW_POWER_MODE_TRIGGER_LEVEL
7356        };
7357
7358        // Populated lazily, guarded by class object:
7359        private static NameValueCache sNameValueCache = new NameValueCache(
7360                    SYS_PROP_SETTING_VERSION,
7361                    CONTENT_URI,
7362                    CALL_METHOD_GET_GLOBAL,
7363                    CALL_METHOD_PUT_GLOBAL);
7364
7365        // Certain settings have been moved from global to the per-user secure namespace
7366        private static final HashSet<String> MOVED_TO_SECURE;
7367        static {
7368            MOVED_TO_SECURE = new HashSet<String>(1);
7369            MOVED_TO_SECURE.add(Settings.Global.INSTALL_NON_MARKET_APPS);
7370        }
7371
7372        /** @hide */
7373        public static void getMovedToSecureSettings(Set<String> outKeySet) {
7374            outKeySet.addAll(MOVED_TO_SECURE);
7375        }
7376
7377        /**
7378         * Look up a name in the database.
7379         * @param resolver to access the database with
7380         * @param name to look up in the table
7381         * @return the corresponding value, or null if not present
7382         */
7383        public static String getString(ContentResolver resolver, String name) {
7384            return getStringForUser(resolver, name, UserHandle.myUserId());
7385        }
7386
7387        /** @hide */
7388        public static String getStringForUser(ContentResolver resolver, String name,
7389                int userHandle) {
7390            if (MOVED_TO_SECURE.contains(name)) {
7391                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
7392                        + " to android.provider.Settings.Secure, returning read-only value.");
7393                return Secure.getStringForUser(resolver, name, userHandle);
7394            }
7395            return sNameValueCache.getStringForUser(resolver, name, userHandle);
7396        }
7397
7398        /**
7399         * Store a name/value pair into the database.
7400         * @param resolver to access the database with
7401         * @param name to store
7402         * @param value to associate with the name
7403         * @return true if the value was set, false on database errors
7404         */
7405        public static boolean putString(ContentResolver resolver,
7406                String name, String value) {
7407            return putStringForUser(resolver, name, value, UserHandle.myUserId());
7408        }
7409
7410        /** @hide */
7411        public static boolean putStringForUser(ContentResolver resolver,
7412                String name, String value, int userHandle) {
7413            if (LOCAL_LOGV) {
7414                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
7415                        + " for " + userHandle);
7416            }
7417            // Global and Secure have the same access policy so we can forward writes
7418            if (MOVED_TO_SECURE.contains(name)) {
7419                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
7420                        + " to android.provider.Settings.Secure, value is unchanged.");
7421                return Secure.putStringForUser(resolver, name, value, userHandle);
7422            }
7423            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
7424        }
7425
7426        /**
7427         * Construct the content URI for a particular name/value pair,
7428         * useful for monitoring changes with a ContentObserver.
7429         * @param name to look up in the table
7430         * @return the corresponding content URI, or null if not present
7431         */
7432        public static Uri getUriFor(String name) {
7433            return getUriFor(CONTENT_URI, name);
7434        }
7435
7436        /**
7437         * Convenience function for retrieving a single secure settings value
7438         * as an integer.  Note that internally setting values are always
7439         * stored as strings; this function converts the string to an integer
7440         * for you.  The default value will be returned if the setting is
7441         * not defined or not an integer.
7442         *
7443         * @param cr The ContentResolver to access.
7444         * @param name The name of the setting to retrieve.
7445         * @param def Value to return if the setting is not defined.
7446         *
7447         * @return The setting's current value, or 'def' if it is not defined
7448         * or not a valid integer.
7449         */
7450        public static int getInt(ContentResolver cr, String name, int def) {
7451            String v = getString(cr, name);
7452            try {
7453                return v != null ? Integer.parseInt(v) : def;
7454            } catch (NumberFormatException e) {
7455                return def;
7456            }
7457        }
7458
7459        /**
7460         * Convenience function for retrieving a single secure settings value
7461         * as an integer.  Note that internally setting values are always
7462         * stored as strings; this function converts the string to an integer
7463         * for you.
7464         * <p>
7465         * This version does not take a default value.  If the setting has not
7466         * been set, or the string value is not a number,
7467         * it throws {@link SettingNotFoundException}.
7468         *
7469         * @param cr The ContentResolver to access.
7470         * @param name The name of the setting to retrieve.
7471         *
7472         * @throws SettingNotFoundException Thrown if a setting by the given
7473         * name can't be found or the setting value is not an integer.
7474         *
7475         * @return The setting's current value.
7476         */
7477        public static int getInt(ContentResolver cr, String name)
7478                throws SettingNotFoundException {
7479            String v = getString(cr, name);
7480            try {
7481                return Integer.parseInt(v);
7482            } catch (NumberFormatException e) {
7483                throw new SettingNotFoundException(name);
7484            }
7485        }
7486
7487        /**
7488         * Convenience function for updating a single settings value as an
7489         * integer. This will either create a new entry in the table if the
7490         * given name does not exist, or modify the value of the existing row
7491         * with that name.  Note that internally setting values are always
7492         * stored as strings, so this function converts the given value to a
7493         * string before storing it.
7494         *
7495         * @param cr The ContentResolver to access.
7496         * @param name The name of the setting to modify.
7497         * @param value The new value for the setting.
7498         * @return true if the value was set, false on database errors
7499         */
7500        public static boolean putInt(ContentResolver cr, String name, int value) {
7501            return putString(cr, name, Integer.toString(value));
7502        }
7503
7504        /**
7505         * Convenience function for retrieving a single secure settings value
7506         * as a {@code long}.  Note that internally setting values are always
7507         * stored as strings; this function converts the string to a {@code long}
7508         * for you.  The default value will be returned if the setting is
7509         * not defined or not a {@code long}.
7510         *
7511         * @param cr The ContentResolver to access.
7512         * @param name The name of the setting to retrieve.
7513         * @param def Value to return if the setting is not defined.
7514         *
7515         * @return The setting's current value, or 'def' if it is not defined
7516         * or not a valid {@code long}.
7517         */
7518        public static long getLong(ContentResolver cr, String name, long def) {
7519            String valString = getString(cr, name);
7520            long value;
7521            try {
7522                value = valString != null ? Long.parseLong(valString) : def;
7523            } catch (NumberFormatException e) {
7524                value = def;
7525            }
7526            return value;
7527        }
7528
7529        /**
7530         * Convenience function for retrieving a single secure settings value
7531         * as a {@code long}.  Note that internally setting values are always
7532         * stored as strings; this function converts the string to a {@code long}
7533         * for you.
7534         * <p>
7535         * This version does not take a default value.  If the setting has not
7536         * been set, or the string value is not a number,
7537         * it throws {@link SettingNotFoundException}.
7538         *
7539         * @param cr The ContentResolver to access.
7540         * @param name The name of the setting to retrieve.
7541         *
7542         * @return The setting's current value.
7543         * @throws SettingNotFoundException Thrown if a setting by the given
7544         * name can't be found or the setting value is not an integer.
7545         */
7546        public static long getLong(ContentResolver cr, String name)
7547                throws SettingNotFoundException {
7548            String valString = getString(cr, name);
7549            try {
7550                return Long.parseLong(valString);
7551            } catch (NumberFormatException e) {
7552                throw new SettingNotFoundException(name);
7553            }
7554        }
7555
7556        /**
7557         * Convenience function for updating a secure settings value as a long
7558         * integer. This will either create a new entry in the table if the
7559         * given name does not exist, or modify the value of the existing row
7560         * with that name.  Note that internally setting values are always
7561         * stored as strings, so this function converts the given value to a
7562         * string before storing it.
7563         *
7564         * @param cr The ContentResolver to access.
7565         * @param name The name of the setting to modify.
7566         * @param value The new value for the setting.
7567         * @return true if the value was set, false on database errors
7568         */
7569        public static boolean putLong(ContentResolver cr, String name, long value) {
7570            return putString(cr, name, Long.toString(value));
7571        }
7572
7573        /**
7574         * Convenience function for retrieving a single secure settings value
7575         * as a floating point number.  Note that internally setting values are
7576         * always stored as strings; this function converts the string to an
7577         * float for you. The default value will be returned if the setting
7578         * is not defined or not a valid float.
7579         *
7580         * @param cr The ContentResolver to access.
7581         * @param name The name of the setting to retrieve.
7582         * @param def Value to return if the setting is not defined.
7583         *
7584         * @return The setting's current value, or 'def' if it is not defined
7585         * or not a valid float.
7586         */
7587        public static float getFloat(ContentResolver cr, String name, float def) {
7588            String v = getString(cr, name);
7589            try {
7590                return v != null ? Float.parseFloat(v) : def;
7591            } catch (NumberFormatException e) {
7592                return def;
7593            }
7594        }
7595
7596        /**
7597         * Convenience function for retrieving a single secure settings value
7598         * as a float.  Note that internally setting values are always
7599         * stored as strings; this function converts the string to a float
7600         * for you.
7601         * <p>
7602         * This version does not take a default value.  If the setting has not
7603         * been set, or the string value is not a number,
7604         * it throws {@link SettingNotFoundException}.
7605         *
7606         * @param cr The ContentResolver to access.
7607         * @param name The name of the setting to retrieve.
7608         *
7609         * @throws SettingNotFoundException Thrown if a setting by the given
7610         * name can't be found or the setting value is not a float.
7611         *
7612         * @return The setting's current value.
7613         */
7614        public static float getFloat(ContentResolver cr, String name)
7615                throws SettingNotFoundException {
7616            String v = getString(cr, name);
7617            if (v == null) {
7618                throw new SettingNotFoundException(name);
7619            }
7620            try {
7621                return Float.parseFloat(v);
7622            } catch (NumberFormatException e) {
7623                throw new SettingNotFoundException(name);
7624            }
7625        }
7626
7627        /**
7628         * Convenience function for updating a single settings value as a
7629         * floating point number. This will either create a new entry in the
7630         * table if the given name does not exist, or modify the value of the
7631         * existing row with that name.  Note that internally setting values
7632         * are always stored as strings, so this function converts the given
7633         * value to a string before storing it.
7634         *
7635         * @param cr The ContentResolver to access.
7636         * @param name The name of the setting to modify.
7637         * @param value The new value for the setting.
7638         * @return true if the value was set, false on database errors
7639         */
7640        public static boolean putFloat(ContentResolver cr, String name, float value) {
7641            return putString(cr, name, Float.toString(value));
7642        }
7643
7644
7645        /**
7646          * Subscription to be used for voice call on a multi sim device. The supported values
7647          * are 0 = SUB1, 1 = SUB2 and etc.
7648          * @hide
7649          */
7650        public static final String MULTI_SIM_VOICE_CALL_SUBSCRIPTION = "multi_sim_voice_call";
7651
7652        /**
7653          * Used to provide option to user to select subscription during dial.
7654          * The supported values are 0 = disable or 1 = enable prompt.
7655          * @hide
7656          */
7657        public static final String MULTI_SIM_VOICE_PROMPT = "multi_sim_voice_prompt";
7658
7659        /**
7660          * Subscription to be used for data call on a multi sim device. The supported values
7661          * are 0 = SUB1, 1 = SUB2 and etc.
7662          * @hide
7663          */
7664        public static final String MULTI_SIM_DATA_CALL_SUBSCRIPTION = "multi_sim_data_call";
7665
7666        /**
7667          * Subscription to be used for SMS on a multi sim device. The supported values
7668          * are 0 = SUB1, 1 = SUB2 and etc.
7669          * @hide
7670          */
7671        public static final String MULTI_SIM_SMS_SUBSCRIPTION = "multi_sim_sms";
7672
7673       /**
7674          * Used to provide option to user to select subscription during send SMS.
7675          * The value 1 - enable, 0 - disable
7676          * @hide
7677          */
7678        public static final String MULTI_SIM_SMS_PROMPT = "multi_sim_sms_prompt";
7679
7680
7681
7682        /** User preferred subscriptions setting.
7683          * This holds the details of the user selected subscription from the card and
7684          * the activation status. Each settings string have the coma separated values
7685          * iccId,appType,appId,activationStatus,3gppIndex,3gpp2Index
7686          * @hide
7687         */
7688        public static final String[] MULTI_SIM_USER_PREFERRED_SUBS = {"user_preferred_sub1",
7689                "user_preferred_sub2","user_preferred_sub3"};
7690    }
7691
7692    /**
7693     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
7694     * Intent URL, allowing it to be either a web page or a particular
7695     * application activity.
7696     *
7697     * @hide
7698     */
7699    public static final class Bookmarks implements BaseColumns
7700    {
7701        private static final String TAG = "Bookmarks";
7702
7703        /**
7704         * The content:// style URL for this table
7705         */
7706        public static final Uri CONTENT_URI =
7707            Uri.parse("content://" + AUTHORITY + "/bookmarks");
7708
7709        /**
7710         * The row ID.
7711         * <p>Type: INTEGER</p>
7712         */
7713        public static final String ID = "_id";
7714
7715        /**
7716         * Descriptive name of the bookmark that can be displayed to the user.
7717         * If this is empty, the title should be resolved at display time (use
7718         * {@link #getTitle(Context, Cursor)} any time you want to display the
7719         * title of a bookmark.)
7720         * <P>
7721         * Type: TEXT
7722         * </P>
7723         */
7724        public static final String TITLE = "title";
7725
7726        /**
7727         * Arbitrary string (displayed to the user) that allows bookmarks to be
7728         * organized into categories.  There are some special names for
7729         * standard folders, which all start with '@'.  The label displayed for
7730         * the folder changes with the locale (via {@link #getLabelForFolder}) but
7731         * the folder name does not change so you can consistently query for
7732         * the folder regardless of the current locale.
7733         *
7734         * <P>Type: TEXT</P>
7735         *
7736         */
7737        public static final String FOLDER = "folder";
7738
7739        /**
7740         * The Intent URL of the bookmark, describing what it points to.  This
7741         * value is given to {@link android.content.Intent#getIntent} to create
7742         * an Intent that can be launched.
7743         * <P>Type: TEXT</P>
7744         */
7745        public static final String INTENT = "intent";
7746
7747        /**
7748         * Optional shortcut character associated with this bookmark.
7749         * <P>Type: INTEGER</P>
7750         */
7751        public static final String SHORTCUT = "shortcut";
7752
7753        /**
7754         * The order in which the bookmark should be displayed
7755         * <P>Type: INTEGER</P>
7756         */
7757        public static final String ORDERING = "ordering";
7758
7759        private static final String[] sIntentProjection = { INTENT };
7760        private static final String[] sShortcutProjection = { ID, SHORTCUT };
7761        private static final String sShortcutSelection = SHORTCUT + "=?";
7762
7763        /**
7764         * Convenience function to retrieve the bookmarked Intent for a
7765         * particular shortcut key.
7766         *
7767         * @param cr The ContentResolver to query.
7768         * @param shortcut The shortcut key.
7769         *
7770         * @return Intent The bookmarked URL, or null if there is no bookmark
7771         *         matching the given shortcut.
7772         */
7773        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
7774        {
7775            Intent intent = null;
7776
7777            Cursor c = cr.query(CONTENT_URI,
7778                    sIntentProjection, sShortcutSelection,
7779                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
7780            // Keep trying until we find a valid shortcut
7781            try {
7782                while (intent == null && c.moveToNext()) {
7783                    try {
7784                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
7785                        intent = Intent.parseUri(intentURI, 0);
7786                    } catch (java.net.URISyntaxException e) {
7787                        // The stored URL is bad...  ignore it.
7788                    } catch (IllegalArgumentException e) {
7789                        // Column not found
7790                        Log.w(TAG, "Intent column not found", e);
7791                    }
7792                }
7793            } finally {
7794                if (c != null) c.close();
7795            }
7796
7797            return intent;
7798        }
7799
7800        /**
7801         * Add a new bookmark to the system.
7802         *
7803         * @param cr The ContentResolver to query.
7804         * @param intent The desired target of the bookmark.
7805         * @param title Bookmark title that is shown to the user; null if none
7806         *            or it should be resolved to the intent's title.
7807         * @param folder Folder in which to place the bookmark; null if none.
7808         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
7809         *            this is non-zero and there is an existing bookmark entry
7810         *            with this same shortcut, then that existing shortcut is
7811         *            cleared (the bookmark is not removed).
7812         * @return The unique content URL for the new bookmark entry.
7813         */
7814        public static Uri add(ContentResolver cr,
7815                                           Intent intent,
7816                                           String title,
7817                                           String folder,
7818                                           char shortcut,
7819                                           int ordering)
7820        {
7821            // If a shortcut is supplied, and it is already defined for
7822            // another bookmark, then remove the old definition.
7823            if (shortcut != 0) {
7824                cr.delete(CONTENT_URI, sShortcutSelection,
7825                        new String[] { String.valueOf((int) shortcut) });
7826            }
7827
7828            ContentValues values = new ContentValues();
7829            if (title != null) values.put(TITLE, title);
7830            if (folder != null) values.put(FOLDER, folder);
7831            values.put(INTENT, intent.toUri(0));
7832            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
7833            values.put(ORDERING, ordering);
7834            return cr.insert(CONTENT_URI, values);
7835        }
7836
7837        /**
7838         * Return the folder name as it should be displayed to the user.  This
7839         * takes care of localizing special folders.
7840         *
7841         * @param r Resources object for current locale; only need access to
7842         *          system resources.
7843         * @param folder The value found in the {@link #FOLDER} column.
7844         *
7845         * @return CharSequence The label for this folder that should be shown
7846         *         to the user.
7847         */
7848        public static CharSequence getLabelForFolder(Resources r, String folder) {
7849            return folder;
7850        }
7851
7852        /**
7853         * Return the title as it should be displayed to the user. This takes
7854         * care of localizing bookmarks that point to activities.
7855         *
7856         * @param context A context.
7857         * @param cursor A cursor pointing to the row whose title should be
7858         *        returned. The cursor must contain at least the {@link #TITLE}
7859         *        and {@link #INTENT} columns.
7860         * @return A title that is localized and can be displayed to the user,
7861         *         or the empty string if one could not be found.
7862         */
7863        public static CharSequence getTitle(Context context, Cursor cursor) {
7864            int titleColumn = cursor.getColumnIndex(TITLE);
7865            int intentColumn = cursor.getColumnIndex(INTENT);
7866            if (titleColumn == -1 || intentColumn == -1) {
7867                throw new IllegalArgumentException(
7868                        "The cursor must contain the TITLE and INTENT columns.");
7869            }
7870
7871            String title = cursor.getString(titleColumn);
7872            if (!TextUtils.isEmpty(title)) {
7873                return title;
7874            }
7875
7876            String intentUri = cursor.getString(intentColumn);
7877            if (TextUtils.isEmpty(intentUri)) {
7878                return "";
7879            }
7880
7881            Intent intent;
7882            try {
7883                intent = Intent.parseUri(intentUri, 0);
7884            } catch (URISyntaxException e) {
7885                return "";
7886            }
7887
7888            PackageManager packageManager = context.getPackageManager();
7889            ResolveInfo info = packageManager.resolveActivity(intent, 0);
7890            return info != null ? info.loadLabel(packageManager) : "";
7891        }
7892    }
7893
7894    /**
7895     * Returns the device ID that we should use when connecting to the mobile gtalk server.
7896     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
7897     * from the GoogleLoginService.
7898     *
7899     * @param androidId The Android ID for this device.
7900     * @return The device ID that should be used when connecting to the mobile gtalk server.
7901     * @hide
7902     */
7903    public static String getGTalkDeviceId(long androidId) {
7904        return "android-" + Long.toHexString(androidId);
7905    }
7906}
7907