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