Settings.java revision e89ba5222c0fb84da85adabcb0d98e3a60180a04
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.Manifest;
20import android.annotation.IntDef;
21import android.annotation.IntRange;
22import android.annotation.NonNull;
23import android.annotation.Nullable;
24import android.annotation.RequiresPermission;
25import android.annotation.SdkConstant;
26import android.annotation.SdkConstant.SdkConstantType;
27import android.annotation.SystemApi;
28import android.annotation.TestApi;
29import android.annotation.UserIdInt;
30import android.app.ActivityThread;
31import android.app.AppOpsManager;
32import android.app.Application;
33import android.app.SearchManager;
34import android.app.WallpaperManager;
35import android.content.ComponentName;
36import android.content.ContentResolver;
37import android.content.ContentValues;
38import android.content.Context;
39import android.content.IContentProvider;
40import android.content.Intent;
41import android.content.pm.ActivityInfo;
42import android.content.pm.PackageManager;
43import android.content.pm.ResolveInfo;
44import android.content.res.Configuration;
45import android.content.res.Resources;
46import android.database.Cursor;
47import android.database.SQLException;
48import android.location.LocationManager;
49import android.net.ConnectivityManager;
50import android.net.Uri;
51import android.net.wifi.WifiManager;
52import android.os.BatteryManager;
53import android.os.Build.VERSION_CODES;
54import android.os.Bundle;
55import android.os.DropBoxManager;
56import android.os.IBinder;
57import android.os.LocaleList;
58import android.os.Process;
59import android.os.RemoteException;
60import android.os.ServiceManager;
61import android.os.UserHandle;
62import android.speech.tts.TextToSpeech;
63import android.text.TextUtils;
64import android.util.AndroidException;
65import android.util.ArrayMap;
66import android.util.ArraySet;
67import android.util.Log;
68import android.util.MemoryIntArray;
69
70import com.android.internal.annotations.GuardedBy;
71import com.android.internal.util.ArrayUtils;
72import com.android.internal.widget.ILockSettings;
73
74import java.io.IOException;
75import java.lang.annotation.Retention;
76import java.lang.annotation.RetentionPolicy;
77import java.net.URISyntaxException;
78import java.text.SimpleDateFormat;
79import java.util.HashMap;
80import java.util.HashSet;
81import java.util.Locale;
82import java.util.Map;
83import java.util.Set;
84
85/**
86 * The Settings provider contains global system-level device preferences.
87 */
88public final class Settings {
89
90    // Intent actions for Settings
91
92    /**
93     * Activity Action: Show system settings.
94     * <p>
95     * Input: Nothing.
96     * <p>
97     * Output: Nothing.
98     */
99    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
100    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
101
102    /**
103     * Activity Action: Show settings to allow configuration of APNs.
104     * <p>
105     * Input: Nothing.
106     * <p>
107     * Output: Nothing.
108     */
109    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
110    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
111
112    /**
113     * Activity Action: Show settings to allow configuration of current location
114     * sources.
115     * <p>
116     * In some cases, a matching Activity may not exist, so ensure you
117     * safeguard against this.
118     * <p>
119     * Input: Nothing.
120     * <p>
121     * Output: Nothing.
122     */
123    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
124    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
125            "android.settings.LOCATION_SOURCE_SETTINGS";
126
127    /**
128     * Activity Action: Show settings to allow configuration of users.
129     * <p>
130     * In some cases, a matching Activity may not exist, so ensure you
131     * safeguard against this.
132     * <p>
133     * Input: Nothing.
134     * <p>
135     * Output: Nothing.
136     * @hide
137     */
138    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
139    public static final String ACTION_USER_SETTINGS =
140            "android.settings.USER_SETTINGS";
141
142    /**
143     * Activity Action: Show settings to allow configuration of wireless controls
144     * such as Wi-Fi, Bluetooth and Mobile networks.
145     * <p>
146     * In some cases, a matching Activity may not exist, so ensure you
147     * safeguard against this.
148     * <p>
149     * Input: Nothing.
150     * <p>
151     * Output: Nothing.
152     */
153    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
154    public static final String ACTION_WIRELESS_SETTINGS =
155            "android.settings.WIRELESS_SETTINGS";
156
157    /**
158     * Activity Action: Show tether provisioning activity.
159     *
160     * <p>
161     * In some cases, a matching Activity may not exist, so ensure you
162     * safeguard against this.
163     * <p>
164     * Input: {@link ConnectivityManager.EXTRA_TETHER_TYPE} should be included to specify which type
165     * of tethering should be checked. {@link ConnectivityManager.EXTRA_PROVISION_CALLBACK} should
166     * contain a {@link ResultReceiver} which will be called back with a tether result code.
167     * <p>
168     * Output: The result of the provisioning check.
169     * {@link ConnectivityManager.TETHER_ERROR_NO_ERROR} if successful,
170     * {@link ConnectivityManager.TETHER_ERROR_PROVISION_FAILED} for failure.
171     *
172     * @hide
173     */
174    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
175    public static final String ACTION_TETHER_PROVISIONING =
176            "android.settings.TETHER_PROVISIONING_UI";
177
178    /**
179     * Activity Action: Show settings to allow entering/exiting airplane mode.
180     * <p>
181     * In some cases, a matching Activity may not exist, so ensure you
182     * safeguard against this.
183     * <p>
184     * Input: Nothing.
185     * <p>
186     * Output: Nothing.
187     */
188    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
189    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
190            "android.settings.AIRPLANE_MODE_SETTINGS";
191
192    /**
193     * Activity Action: Modify Airplane mode settings using a voice command.
194     * <p>
195     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
196     * <p>
197     * This intent MUST be started using
198     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
199     * startVoiceActivity}.
200     * <p>
201     * Note: The activity implementing this intent MUST verify that
202     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
203     * modifying the setting.
204     * <p>
205     * Input: To tell which state airplane mode should be set to, add the
206     * {@link #EXTRA_AIRPLANE_MODE_ENABLED} extra to this Intent with the state specified.
207     * If the extra is not included, no changes will be made.
208     * <p>
209     * Output: Nothing.
210     */
211    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
212    public static final String ACTION_VOICE_CONTROL_AIRPLANE_MODE =
213            "android.settings.VOICE_CONTROL_AIRPLANE_MODE";
214
215    /**
216     * Activity Action: Show settings for accessibility modules.
217     * <p>
218     * In some cases, a matching Activity may not exist, so ensure you
219     * safeguard against this.
220     * <p>
221     * Input: Nothing.
222     * <p>
223     * Output: Nothing.
224     */
225    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
226    public static final String ACTION_ACCESSIBILITY_SETTINGS =
227            "android.settings.ACCESSIBILITY_SETTINGS";
228
229    /**
230     * Activity Action: Show settings to control access to usage information.
231     * <p>
232     * In some cases, a matching Activity may not exist, so ensure you
233     * safeguard against this.
234     * <p>
235     * Input: Nothing.
236     * <p>
237     * Output: Nothing.
238     */
239    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
240    public static final String ACTION_USAGE_ACCESS_SETTINGS =
241            "android.settings.USAGE_ACCESS_SETTINGS";
242
243    /**
244     * Activity Category: Show application settings related to usage access.
245     * <p>
246     * An activity that provides a user interface for adjusting usage access related
247     * preferences for its containing application. Optional but recommended for apps that
248     * use {@link android.Manifest.permission#PACKAGE_USAGE_STATS}.
249     * <p>
250     * The activity may define meta-data to describe what usage access is
251     * used for within their app with {@link #METADATA_USAGE_ACCESS_REASON}, which
252     * will be displayed in Settings.
253     * <p>
254     * Input: Nothing.
255     * <p>
256     * Output: Nothing.
257     */
258    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
259    public static final String INTENT_CATEGORY_USAGE_ACCESS_CONFIG =
260            "android.intent.category.USAGE_ACCESS_CONFIG";
261
262    /**
263     * Metadata key: Reason for needing usage access.
264     * <p>
265     * A key for metadata attached to an activity that receives action
266     * {@link #INTENT_CATEGORY_USAGE_ACCESS_CONFIG}, shown to the
267     * user as description of how the app uses usage access.
268     * <p>
269     */
270    public static final String METADATA_USAGE_ACCESS_REASON =
271            "android.settings.metadata.USAGE_ACCESS_REASON";
272
273    /**
274     * Activity Action: Show settings to allow configuration of security and
275     * location privacy.
276     * <p>
277     * In some cases, a matching Activity may not exist, so ensure you
278     * safeguard against this.
279     * <p>
280     * Input: Nothing.
281     * <p>
282     * Output: Nothing.
283     */
284    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
285    public static final String ACTION_SECURITY_SETTINGS =
286            "android.settings.SECURITY_SETTINGS";
287
288    /**
289     * Activity Action: Show trusted credentials settings, opening to the user tab,
290     * to allow management of installed credentials.
291     * <p>
292     * In some cases, a matching Activity may not exist, so ensure you
293     * safeguard against this.
294     * <p>
295     * Input: Nothing.
296     * <p>
297     * Output: Nothing.
298     * @hide
299     */
300    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
301    public static final String ACTION_TRUSTED_CREDENTIALS_USER =
302            "com.android.settings.TRUSTED_CREDENTIALS_USER";
303
304    /**
305     * Activity Action: Show dialog explaining that an installed CA cert may enable
306     * monitoring of encrypted network traffic.
307     * <p>
308     * In some cases, a matching Activity may not exist, so ensure you
309     * safeguard against this. Add {@link #EXTRA_NUMBER_OF_CERTIFICATES} extra to indicate the
310     * number of certificates.
311     * <p>
312     * Input: Nothing.
313     * <p>
314     * Output: Nothing.
315     * @hide
316     */
317    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
318    public static final String ACTION_MONITORING_CERT_INFO =
319            "com.android.settings.MONITORING_CERT_INFO";
320
321    /**
322     * Activity Action: Show settings to allow configuration of privacy options.
323     * <p>
324     * In some cases, a matching Activity may not exist, so ensure you
325     * safeguard against this.
326     * <p>
327     * Input: Nothing.
328     * <p>
329     * Output: Nothing.
330     */
331    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
332    public static final String ACTION_PRIVACY_SETTINGS =
333            "android.settings.PRIVACY_SETTINGS";
334
335    /**
336     * Activity Action: Show settings to allow configuration of VPN.
337     * <p>
338     * In some cases, a matching Activity may not exist, so ensure you
339     * safeguard against this.
340     * <p>
341     * Input: Nothing.
342     * <p>
343     * Output: Nothing.
344     */
345    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
346    public static final String ACTION_VPN_SETTINGS =
347            "android.settings.VPN_SETTINGS";
348
349    /**
350     * Activity Action: Show settings to allow configuration of Wi-Fi.
351     * <p>
352     * In some cases, a matching Activity may not exist, so ensure you
353     * safeguard against this.
354     * <p>
355     * Input: Nothing.
356     * <p>
357     * Output: Nothing.
358     */
359    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
360    public static final String ACTION_WIFI_SETTINGS =
361            "android.settings.WIFI_SETTINGS";
362
363    /**
364     * Activity Action: Show settings to allow configuration of a static IP
365     * address for Wi-Fi.
366     * <p>
367     * In some cases, a matching Activity may not exist, so ensure you safeguard
368     * against this.
369     * <p>
370     * Input: Nothing.
371     * <p>
372     * Output: Nothing.
373     */
374    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
375    public static final String ACTION_WIFI_IP_SETTINGS =
376            "android.settings.WIFI_IP_SETTINGS";
377
378    /**
379     * Activity Action: Show settings to allow configuration of Wi-Fi saved networks.
380     * <p>
381     * In some cases, a matching Activity may not exist, so ensure you
382     * safeguard against this.
383     * <p>
384     * Input: Nothing.
385     * <p>
386     * Output: Nothing.
387     * @hide
388     */
389    @SystemApi
390    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
391    public static final String ACTION_WIFI_SAVED_NETWORK_SETTINGS =
392            "android.settings.WIFI_SAVED_NETWORK_SETTINGS";
393
394    /**
395     * Activity Action: Show settings to allow configuration of Bluetooth.
396     * <p>
397     * In some cases, a matching Activity may not exist, so ensure you
398     * safeguard against this.
399     * <p>
400     * Input: Nothing.
401     * <p>
402     * Output: Nothing.
403     */
404    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
405    public static final String ACTION_BLUETOOTH_SETTINGS =
406            "android.settings.BLUETOOTH_SETTINGS";
407
408    /**
409     * Activity Action: Show settings to allow configuration of cast endpoints.
410     * <p>
411     * In some cases, a matching Activity may not exist, so ensure you
412     * safeguard against this.
413     * <p>
414     * Input: Nothing.
415     * <p>
416     * Output: Nothing.
417     */
418    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
419    public static final String ACTION_CAST_SETTINGS =
420            "android.settings.CAST_SETTINGS";
421
422    /**
423     * Activity Action: Show settings to allow configuration of date and time.
424     * <p>
425     * In some cases, a matching Activity may not exist, so ensure you
426     * safeguard against this.
427     * <p>
428     * Input: Nothing.
429     * <p>
430     * Output: Nothing.
431     */
432    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
433    public static final String ACTION_DATE_SETTINGS =
434            "android.settings.DATE_SETTINGS";
435
436    /**
437     * Activity Action: Show settings to allow configuration of sound and volume.
438     * <p>
439     * In some cases, a matching Activity may not exist, so ensure you
440     * safeguard against this.
441     * <p>
442     * Input: Nothing.
443     * <p>
444     * Output: Nothing.
445     */
446    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
447    public static final String ACTION_SOUND_SETTINGS =
448            "android.settings.SOUND_SETTINGS";
449
450    /**
451     * Activity Action: Show settings to allow configuration of display.
452     * <p>
453     * In some cases, a matching Activity may not exist, so ensure you
454     * safeguard against this.
455     * <p>
456     * Input: Nothing.
457     * <p>
458     * Output: Nothing.
459     */
460    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
461    public static final String ACTION_DISPLAY_SETTINGS =
462            "android.settings.DISPLAY_SETTINGS";
463
464    /**
465     * Activity Action: Show settings to allow configuration of Night display.
466     * <p>
467     * In some cases, a matching Activity may not exist, so ensure you
468     * safeguard against this.
469     * <p>
470     * Input: Nothing.
471     * <p>
472     * Output: Nothing.
473     *
474     * @hide
475     */
476    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
477    public static final String ACTION_NIGHT_DISPLAY_SETTINGS =
478            "android.settings.NIGHT_DISPLAY_SETTINGS";
479
480    /**
481     * Activity Action: Show settings to allow configuration of locale.
482     * <p>
483     * In some cases, a matching Activity may not exist, so ensure you
484     * safeguard against this.
485     * <p>
486     * Input: Nothing.
487     * <p>
488     * Output: Nothing.
489     */
490    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
491    public static final String ACTION_LOCALE_SETTINGS =
492            "android.settings.LOCALE_SETTINGS";
493
494    /**
495     * Activity Action: Show settings to configure input methods, in particular
496     * allowing the user to enable input methods.
497     * <p>
498     * In some cases, a matching Activity may not exist, so ensure you
499     * safeguard against this.
500     * <p>
501     * Input: Nothing.
502     * <p>
503     * Output: Nothing.
504     */
505    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
506    public static final String ACTION_VOICE_INPUT_SETTINGS =
507            "android.settings.VOICE_INPUT_SETTINGS";
508
509    /**
510     * Activity Action: Show settings to configure input methods, in particular
511     * allowing the user to enable input methods.
512     * <p>
513     * In some cases, a matching Activity may not exist, so ensure you
514     * safeguard against this.
515     * <p>
516     * Input: Nothing.
517     * <p>
518     * Output: Nothing.
519     */
520    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
521    public static final String ACTION_INPUT_METHOD_SETTINGS =
522            "android.settings.INPUT_METHOD_SETTINGS";
523
524    /**
525     * Activity Action: Show settings to enable/disable input method subtypes.
526     * <p>
527     * In some cases, a matching Activity may not exist, so ensure you
528     * safeguard against this.
529     * <p>
530     * To tell which input method's subtypes are displayed in the settings, add
531     * {@link #EXTRA_INPUT_METHOD_ID} extra to this Intent with the input method id.
532     * If there is no extra in this Intent, subtypes from all installed input methods
533     * will be displayed in the settings.
534     *
535     * @see android.view.inputmethod.InputMethodInfo#getId
536     * <p>
537     * Input: Nothing.
538     * <p>
539     * Output: Nothing.
540     */
541    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
542    public static final String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
543            "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
544
545    /**
546     * Activity Action: Show a dialog to select input method.
547     * <p>
548     * In some cases, a matching Activity may not exist, so ensure you
549     * safeguard against this.
550     * <p>
551     * Input: Nothing.
552     * <p>
553     * Output: Nothing.
554     * @hide
555     */
556    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
557    public static final String ACTION_SHOW_INPUT_METHOD_PICKER =
558            "android.settings.SHOW_INPUT_METHOD_PICKER";
559
560    /**
561     * Activity Action: Show settings to manage the user input dictionary.
562     * <p>
563     * Starting with {@link android.os.Build.VERSION_CODES#KITKAT},
564     * it is guaranteed there will always be an appropriate implementation for this Intent action.
565     * In prior releases of the platform this was optional, so ensure you safeguard against it.
566     * <p>
567     * Input: Nothing.
568     * <p>
569     * Output: Nothing.
570     */
571    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
572    public static final String ACTION_USER_DICTIONARY_SETTINGS =
573            "android.settings.USER_DICTIONARY_SETTINGS";
574
575    /**
576     * Activity Action: Show settings to configure the hardware keyboard.
577     * <p>
578     * In some cases, a matching Activity may not exist, so ensure you
579     * safeguard against this.
580     * <p>
581     * Input: Nothing.
582     * <p>
583     * Output: Nothing.
584     */
585    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
586    public static final String ACTION_HARD_KEYBOARD_SETTINGS =
587            "android.settings.HARD_KEYBOARD_SETTINGS";
588
589    /**
590     * Activity Action: Adds a word to the user dictionary.
591     * <p>
592     * In some cases, a matching Activity may not exist, so ensure you
593     * safeguard against this.
594     * <p>
595     * Input: An extra with key <code>word</code> that contains the word
596     * that should be added to the dictionary.
597     * <p>
598     * Output: Nothing.
599     *
600     * @hide
601     */
602    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
603    public static final String ACTION_USER_DICTIONARY_INSERT =
604            "com.android.settings.USER_DICTIONARY_INSERT";
605
606    /**
607     * Activity Action: Show settings to allow configuration of application-related settings.
608     * <p>
609     * In some cases, a matching Activity may not exist, so ensure you
610     * safeguard against this.
611     * <p>
612     * Input: Nothing.
613     * <p>
614     * Output: Nothing.
615     */
616    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
617    public static final String ACTION_APPLICATION_SETTINGS =
618            "android.settings.APPLICATION_SETTINGS";
619
620    /**
621     * Activity Action: Show settings to allow configuration of application
622     * development-related settings.  As of
623     * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} this action is
624     * a required part of the platform.
625     * <p>
626     * Input: Nothing.
627     * <p>
628     * Output: Nothing.
629     */
630    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
631    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
632            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
633
634    /**
635     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
636     * <p>
637     * In some cases, a matching Activity may not exist, so ensure you
638     * safeguard against this.
639     * <p>
640     * Input: Nothing.
641     * <p>
642     * Output: Nothing.
643     */
644    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
645    public static final String ACTION_QUICK_LAUNCH_SETTINGS =
646            "android.settings.QUICK_LAUNCH_SETTINGS";
647
648    /**
649     * Activity Action: Show settings to manage installed applications.
650     * <p>
651     * In some cases, a matching Activity may not exist, so ensure you
652     * safeguard against this.
653     * <p>
654     * Input: Nothing.
655     * <p>
656     * Output: Nothing.
657     */
658    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
659    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
660            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
661
662    /**
663     * Activity Action: Show settings to manage all applications.
664     * <p>
665     * In some cases, a matching Activity may not exist, so ensure you
666     * safeguard against this.
667     * <p>
668     * Input: Nothing.
669     * <p>
670     * Output: Nothing.
671     */
672    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
673    public static final String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
674            "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS";
675
676    /**
677     * Activity Action: Show screen for controlling which apps can draw on top of other apps.
678     * <p>
679     * In some cases, a matching Activity may not exist, so ensure you
680     * safeguard against this.
681     * <p>
682     * Input: Optionally, the Intent's data URI can specify the application package name to
683     * directly invoke the management GUI specific to the package name. For example
684     * "package:com.my.app".
685     * <p>
686     * Output: Nothing.
687     */
688    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
689    public static final String ACTION_MANAGE_OVERLAY_PERMISSION =
690            "android.settings.action.MANAGE_OVERLAY_PERMISSION";
691
692    /**
693     * Activity Action: Show screen for controlling which apps are allowed to write/modify
694     * system settings.
695     * <p>
696     * In some cases, a matching Activity may not exist, so ensure you
697     * safeguard against this.
698     * <p>
699     * Input: Optionally, the Intent's data URI can specify the application package name to
700     * directly invoke the management GUI specific to the package name. For example
701     * "package:com.my.app".
702     * <p>
703     * Output: Nothing.
704     */
705    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
706    public static final String ACTION_MANAGE_WRITE_SETTINGS =
707            "android.settings.action.MANAGE_WRITE_SETTINGS";
708
709    /**
710     * Activity Action: Show screen of details about a particular application.
711     * <p>
712     * In some cases, a matching Activity may not exist, so ensure you
713     * safeguard against this.
714     * <p>
715     * Input: The Intent's data URI specifies the application package name
716     * to be shown, with the "package" scheme.  That is "package:com.my.app".
717     * <p>
718     * Output: Nothing.
719     */
720    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
721    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
722            "android.settings.APPLICATION_DETAILS_SETTINGS";
723
724    /**
725     * Activity Action: Show screen for controlling which apps can ignore battery optimizations.
726     * <p>
727     * Input: Nothing.
728     * <p>
729     * Output: Nothing.
730     * <p>
731     * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
732     * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
733     * already ignoring optimizations.  You can use
734     * {@link #ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS} to ask the user to put you
735     * on this list.
736     */
737    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
738    public static final String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS =
739            "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
740
741    /**
742     * Activity Action: Ask the user to allow an app to ignore battery optimizations (that is,
743     * put them on the whitelist of apps shown by
744     * {@link #ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}).  For an app to use this, it also
745     * must hold the {@link android.Manifest.permission#REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}
746     * permission.
747     * <p><b>Note:</b> most applications should <em>not</em> use this; there are many facilities
748     * provided by the platform for applications to operate correctly in the various power
749     * saving modes.  This is only for unusual applications that need to deeply control their own
750     * execution, at the potential expense of the user's battery life.  Note that these applications
751     * greatly run the risk of showing to the user as high power consumers on their device.</p>
752     * <p>
753     * Input: The Intent's data URI must specify the application package name
754     * to be shown, with the "package" scheme.  That is "package:com.my.app".
755     * <p>
756     * Output: Nothing.
757     * <p>
758     * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
759     * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
760     * already ignoring optimizations.
761     */
762    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
763    public static final String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS =
764            "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
765
766    /**
767     * Activity Action: Show screen for controlling background data
768     * restrictions for a particular application.
769     * <p>
770     * Input: Intent's data URI set with an application name, using the
771     * "package" schema (like "package:com.my.app").
772     *
773     * <p>
774     * Output: Nothing.
775     * <p>
776     * Applications can also use {@link android.net.ConnectivityManager#getRestrictBackgroundStatus
777     * ConnectivityManager#getRestrictBackgroundStatus()} to determine the
778     * status of the background data restrictions for them.
779     */
780    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
781    public static final String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS =
782            "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
783
784    /**
785     * @hide
786     * Activity Action: Show the "app ops" settings screen.
787     * <p>
788     * Input: Nothing.
789     * <p>
790     * Output: Nothing.
791     */
792    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
793    public static final String ACTION_APP_OPS_SETTINGS =
794            "android.settings.APP_OPS_SETTINGS";
795
796    /**
797     * Activity Action: Show settings for system update functionality.
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     *
806     * @hide
807     */
808    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
809    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
810            "android.settings.SYSTEM_UPDATE_SETTINGS";
811
812    /**
813     * Activity Action: Show settings to allow configuration of sync settings.
814     * <p>
815     * In some cases, a matching Activity may not exist, so ensure you
816     * safeguard against this.
817     * <p>
818     * The account types available to add via the add account button may be restricted by adding an
819     * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's
820     * authorities. Only account types which can sync with that content provider will be offered to
821     * the user.
822     * <p>
823     * Input: Nothing.
824     * <p>
825     * Output: Nothing.
826     */
827    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
828    public static final String ACTION_SYNC_SETTINGS =
829            "android.settings.SYNC_SETTINGS";
830
831    /**
832     * Activity Action: Show add account screen for creating a new account.
833     * <p>
834     * In some cases, a matching Activity may not exist, so ensure you
835     * safeguard against this.
836     * <p>
837     * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES}
838     * extra to the Intent with one or more syncable content provider's authorities.  Only account
839     * types which can sync with that content provider will be offered to the user.
840     * <p>
841     * Account types can also be filtered by adding an {@link #EXTRA_ACCOUNT_TYPES} extra to the
842     * Intent with one or more account types.
843     * <p>
844     * Input: Nothing.
845     * <p>
846     * Output: Nothing.
847     */
848    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
849    public static final String ACTION_ADD_ACCOUNT =
850            "android.settings.ADD_ACCOUNT_SETTINGS";
851
852    /**
853     * Activity Action: Show settings for selecting the network operator.
854     * <p>
855     * In some cases, a matching Activity may not exist, so ensure you
856     * safeguard against this.
857     * <p>
858     * Input: Nothing.
859     * <p>
860     * Output: Nothing.
861     */
862    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
863    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
864            "android.settings.NETWORK_OPERATOR_SETTINGS";
865
866    /**
867     * Activity Action: Show settings for selection of 2G/3G.
868     * <p>
869     * In some cases, a matching Activity may not exist, so ensure you
870     * safeguard against this.
871     * <p>
872     * Input: Nothing.
873     * <p>
874     * Output: Nothing.
875     */
876    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
877    public static final String ACTION_DATA_ROAMING_SETTINGS =
878            "android.settings.DATA_ROAMING_SETTINGS";
879
880    /**
881     * Activity Action: Show settings for internal storage.
882     * <p>
883     * In some cases, a matching Activity may not exist, so ensure you
884     * safeguard against this.
885     * <p>
886     * Input: Nothing.
887     * <p>
888     * Output: Nothing.
889     */
890    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
891    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
892            "android.settings.INTERNAL_STORAGE_SETTINGS";
893    /**
894     * Activity Action: Show settings for memory card storage.
895     * <p>
896     * In some cases, a matching Activity may not exist, so ensure you
897     * safeguard against this.
898     * <p>
899     * Input: Nothing.
900     * <p>
901     * Output: Nothing.
902     */
903    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
904    public static final String ACTION_MEMORY_CARD_SETTINGS =
905            "android.settings.MEMORY_CARD_SETTINGS";
906
907    /**
908     * Activity Action: Show settings for global search.
909     * <p>
910     * In some cases, a matching Activity may not exist, so ensure you
911     * safeguard against this.
912     * <p>
913     * Input: Nothing.
914     * <p>
915     * Output: Nothing
916     */
917    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
918    public static final String ACTION_SEARCH_SETTINGS =
919        "android.search.action.SEARCH_SETTINGS";
920
921    /**
922     * Activity Action: Show general device information settings (serial
923     * number, software version, phone number, etc.).
924     * <p>
925     * In some cases, a matching Activity may not exist, so ensure you
926     * safeguard against this.
927     * <p>
928     * Input: Nothing.
929     * <p>
930     * Output: Nothing
931     */
932    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
933    public static final String ACTION_DEVICE_INFO_SETTINGS =
934        "android.settings.DEVICE_INFO_SETTINGS";
935
936    /**
937     * Activity Action: Show NFC settings.
938     * <p>
939     * This shows UI that allows NFC to be turned on or off.
940     * <p>
941     * In some cases, a matching Activity may not exist, so ensure you
942     * safeguard against this.
943     * <p>
944     * Input: Nothing.
945     * <p>
946     * Output: Nothing
947     * @see android.nfc.NfcAdapter#isEnabled()
948     */
949    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
950    public static final String ACTION_NFC_SETTINGS = "android.settings.NFC_SETTINGS";
951
952    /**
953     * Activity Action: Show NFC Sharing settings.
954     * <p>
955     * This shows UI that allows NDEF Push (Android Beam) to be turned on or
956     * off.
957     * <p>
958     * In some cases, a matching Activity may not exist, so ensure you
959     * safeguard against this.
960     * <p>
961     * Input: Nothing.
962     * <p>
963     * Output: Nothing
964     * @see android.nfc.NfcAdapter#isNdefPushEnabled()
965     */
966    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
967    public static final String ACTION_NFCSHARING_SETTINGS =
968        "android.settings.NFCSHARING_SETTINGS";
969
970    /**
971     * Activity Action: Show NFC Tap & Pay settings
972     * <p>
973     * This shows UI that allows the user to configure Tap&Pay
974     * settings.
975     * <p>
976     * In some cases, a matching Activity may not exist, so ensure you
977     * safeguard against this.
978     * <p>
979     * Input: Nothing.
980     * <p>
981     * Output: Nothing
982     */
983    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
984    public static final String ACTION_NFC_PAYMENT_SETTINGS =
985        "android.settings.NFC_PAYMENT_SETTINGS";
986
987    /**
988     * Activity Action: Show Daydream settings.
989     * <p>
990     * In some cases, a matching Activity may not exist, so ensure you
991     * safeguard against this.
992     * <p>
993     * Input: Nothing.
994     * <p>
995     * Output: Nothing.
996     * @see android.service.dreams.DreamService
997     */
998    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999    public static final String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
1000
1001    /**
1002     * Activity Action: Show Notification listener settings.
1003     * <p>
1004     * In some cases, a matching Activity may not exist, so ensure you
1005     * safeguard against this.
1006     * <p>
1007     * Input: Nothing.
1008     * <p>
1009     * Output: Nothing.
1010     * @see android.service.notification.NotificationListenerService
1011     */
1012    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1013    public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS
1014            = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
1015
1016    /**
1017     * Activity Action: Show Do Not Disturb access settings.
1018     * <p>
1019     * Users can grant and deny access to Do Not Disturb configuration from here.
1020     * See {@link android.app.NotificationManager#isNotificationPolicyAccessGranted()} for more
1021     * details.
1022     * <p>
1023     * Input: Nothing.
1024     * <p>
1025     * Output: Nothing.
1026     */
1027    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1028    public static final String ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS
1029            = "android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS";
1030
1031    /**
1032     * @hide
1033     */
1034    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1035    public static final String ACTION_CONDITION_PROVIDER_SETTINGS
1036            = "android.settings.ACTION_CONDITION_PROVIDER_SETTINGS";
1037
1038    /**
1039     * Activity Action: Show settings for video captioning.
1040     * <p>
1041     * In some cases, a matching Activity may not exist, so ensure you safeguard
1042     * against this.
1043     * <p>
1044     * Input: Nothing.
1045     * <p>
1046     * Output: Nothing.
1047     */
1048    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1049    public static final String ACTION_CAPTIONING_SETTINGS = "android.settings.CAPTIONING_SETTINGS";
1050
1051    /**
1052     * Activity Action: Show the top level print settings.
1053     * <p>
1054     * In some cases, a matching Activity may not exist, so ensure you
1055     * safeguard against this.
1056     * <p>
1057     * Input: Nothing.
1058     * <p>
1059     * Output: Nothing.
1060     */
1061    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1062    public static final String ACTION_PRINT_SETTINGS =
1063            "android.settings.ACTION_PRINT_SETTINGS";
1064
1065    /**
1066     * Activity Action: Show Zen Mode configuration settings.
1067     *
1068     * @hide
1069     */
1070    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1071    public static final String ACTION_ZEN_MODE_SETTINGS = "android.settings.ZEN_MODE_SETTINGS";
1072
1073    /**
1074     * Activity Action: Show Zen Mode priority configuration settings.
1075     */
1076    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1077    public static final String ACTION_ZEN_MODE_PRIORITY_SETTINGS
1078            = "android.settings.ZEN_MODE_PRIORITY_SETTINGS";
1079
1080    /**
1081     * Activity Action: Show Zen Mode automation configuration settings.
1082     *
1083     * @hide
1084     */
1085    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086    public static final String ACTION_ZEN_MODE_AUTOMATION_SETTINGS
1087            = "android.settings.ZEN_MODE_AUTOMATION_SETTINGS";
1088
1089    /**
1090     * Activity Action: Modify do not disturb mode settings.
1091     * <p>
1092     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
1093     * <p>
1094     * This intent MUST be started using
1095     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
1096     * startVoiceActivity}.
1097     * <p>
1098     * Note: The Activity implementing this intent MUST verify that
1099     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction}.
1100     * returns true before modifying the setting.
1101     * <p>
1102     * Input: The optional {@link #EXTRA_DO_NOT_DISTURB_MODE_MINUTES} extra can be used to indicate
1103     * how long the user wishes to avoid interruptions for. The optional
1104     * {@link #EXTRA_DO_NOT_DISTURB_MODE_ENABLED} extra can be to indicate if the user is
1105     * enabling or disabling do not disturb mode. If either extra is not included, the
1106     * user maybe asked to provide the value.
1107     * <p>
1108     * Output: Nothing.
1109     */
1110    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1111    public static final String ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE =
1112            "android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE";
1113
1114    /**
1115     * Activity Action: Show Zen Mode schedule rule configuration settings.
1116     *
1117     * @hide
1118     */
1119    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1120    public static final String ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS
1121            = "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS";
1122
1123    /**
1124     * Activity Action: Show Zen Mode event rule configuration settings.
1125     *
1126     * @hide
1127     */
1128    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1129    public static final String ACTION_ZEN_MODE_EVENT_RULE_SETTINGS
1130            = "android.settings.ZEN_MODE_EVENT_RULE_SETTINGS";
1131
1132    /**
1133     * Activity Action: Show Zen Mode external rule configuration settings.
1134     *
1135     * @hide
1136     */
1137    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1138    public static final String ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS
1139            = "android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS";
1140
1141    /**
1142     * Activity Action: Show the regulatory information screen for the device.
1143     * <p>
1144     * In some cases, a matching Activity may not exist, so ensure you safeguard
1145     * against this.
1146     * <p>
1147     * Input: Nothing.
1148     * <p>
1149     * Output: Nothing.
1150     */
1151    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1152    public static final String
1153            ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
1154
1155    /**
1156     * Activity Action: Show Device Name Settings.
1157     * <p>
1158     * In some cases, a matching Activity may not exist, so ensure you safeguard
1159     * against this.
1160     *
1161     * @hide
1162     */
1163    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1164    public static final String DEVICE_NAME_SETTINGS = "android.settings.DEVICE_NAME";
1165
1166    /**
1167     * Activity Action: Show pairing settings.
1168     * <p>
1169     * In some cases, a matching Activity may not exist, so ensure you safeguard
1170     * against this.
1171     *
1172     * @hide
1173     */
1174    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175    public static final String ACTION_PAIRING_SETTINGS = "android.settings.PAIRING_SETTINGS";
1176
1177    /**
1178     * Activity Action: Show battery saver settings.
1179     * <p>
1180     * In some cases, a matching Activity may not exist, so ensure you safeguard
1181     * against this.
1182     */
1183    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1184    public static final String ACTION_BATTERY_SAVER_SETTINGS
1185            = "android.settings.BATTERY_SAVER_SETTINGS";
1186
1187    /**
1188     * Activity Action: Modify Battery Saver mode setting using a voice command.
1189     * <p>
1190     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
1191     * <p>
1192     * This intent MUST be started using
1193     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
1194     * startVoiceActivity}.
1195     * <p>
1196     * Note: The activity implementing this intent MUST verify that
1197     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
1198     * modifying the setting.
1199     * <p>
1200     * Input: To tell which state batter saver mode should be set to, add the
1201     * {@link #EXTRA_BATTERY_SAVER_MODE_ENABLED} extra to this Intent with the state specified.
1202     * If the extra is not included, no changes will be made.
1203     * <p>
1204     * Output: Nothing.
1205     */
1206    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1207    public static final String ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE =
1208            "android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE";
1209
1210    /**
1211     * Activity Action: Show Home selection settings. If there are multiple activities
1212     * that can satisfy the {@link Intent#CATEGORY_HOME} intent, this screen allows you
1213     * to pick your preferred activity.
1214     */
1215    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1216    public static final String ACTION_HOME_SETTINGS
1217            = "android.settings.HOME_SETTINGS";
1218
1219    /**
1220     * Activity Action: Show Default apps settings.
1221     * <p>
1222     * In some cases, a matching Activity may not exist, so ensure you
1223     * safeguard against this.
1224     * <p>
1225     * Input: Nothing.
1226     * <p>
1227     * Output: Nothing.
1228     */
1229    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1230    public static final String ACTION_MANAGE_DEFAULT_APPS_SETTINGS
1231            = "android.settings.MANAGE_DEFAULT_APPS_SETTINGS";
1232
1233    /**
1234     * Activity Action: Show notification settings.
1235     *
1236     * @hide
1237     */
1238    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239    public static final String ACTION_NOTIFICATION_SETTINGS
1240            = "android.settings.NOTIFICATION_SETTINGS";
1241
1242    /**
1243     * Activity Action: Show notification settings for a single app.
1244     *
1245     * @hide
1246     */
1247    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1248    public static final String ACTION_APP_NOTIFICATION_SETTINGS
1249            = "android.settings.APP_NOTIFICATION_SETTINGS";
1250
1251    /**
1252     * Activity Action: Show notification redaction settings.
1253     *
1254     * @hide
1255     */
1256    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257    public static final String ACTION_APP_NOTIFICATION_REDACTION
1258            = "android.settings.ACTION_APP_NOTIFICATION_REDACTION";
1259
1260    /** @hide */ public static final String EXTRA_APP_UID = "app_uid";
1261    /** @hide */ public static final String EXTRA_APP_PACKAGE = "app_package";
1262
1263    /**
1264     * Activity Action: Show a dialog with disabled by policy message.
1265     * <p> If an user action is disabled by policy, this dialog can be triggered to let
1266     * the user know about this.
1267     * <p>
1268     * Input: Nothing.
1269     * <p>
1270     * Output: Nothing.
1271     *
1272     * @hide
1273     */
1274    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275    public static final String ACTION_SHOW_ADMIN_SUPPORT_DETAILS
1276            = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
1277
1278    /**
1279     * Activity Action: Show a dialog for remote bugreport flow.
1280     * <p>
1281     * Input: Nothing.
1282     * <p>
1283     * Output: Nothing.
1284     *
1285     * @hide
1286     */
1287    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288    public static final String ACTION_SHOW_REMOTE_BUGREPORT_DIALOG
1289            = "android.settings.SHOW_REMOTE_BUGREPORT_DIALOG";
1290
1291    /**
1292     * Activity Action: Show VR listener settings.
1293     * <p>
1294     * Input: Nothing.
1295     * <p>
1296     * Output: Nothing.
1297     *
1298     * @see android.service.vr.VrListenerService
1299     */
1300    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1301    public static final String ACTION_VR_LISTENER_SETTINGS
1302            = "android.settings.VR_LISTENER_SETTINGS";
1303
1304    /**
1305     * Activity Action: Show Storage Manager settings.
1306     * <p>
1307     * Input: Nothing.
1308     * <p>
1309     * Output: Nothing.
1310     *
1311     * @hide
1312     */
1313    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314    public static final String ACTION_STORAGE_MANAGER_SETTINGS
1315            = "android.settings.STORAGE_MANAGER_SETTINGS";
1316
1317    /**
1318     * Activity Action: Allows user to select current webview implementation.
1319     * <p>
1320     * Input: Nothing.
1321     * <p>
1322     * Output: Nothing.
1323     */
1324    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1325    public static final String ACTION_WEBVIEW_SETTINGS = "android.settings.WEBVIEW_SETTINGS";
1326
1327    /**
1328     * Activity Action: Show enterprise privacy section.
1329     * <p>
1330     * Input: Nothing.
1331     * <p>
1332     * Output: Nothing.
1333     * @hide
1334     */
1335    @SystemApi
1336    @TestApi
1337    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1338    public static final String ACTION_ENTERPRISE_PRIVACY_SETTINGS
1339            = "android.settings.ENTERPRISE_PRIVACY_SETTINGS";
1340
1341    // End of Intent actions for Settings
1342
1343    /**
1344     * @hide - Private call() method on SettingsProvider to read from 'system' table.
1345     */
1346    public static final String CALL_METHOD_GET_SYSTEM = "GET_system";
1347
1348    /**
1349     * @hide - Private call() method on SettingsProvider to read from 'secure' table.
1350     */
1351    public static final String CALL_METHOD_GET_SECURE = "GET_secure";
1352
1353    /**
1354     * @hide - Private call() method on SettingsProvider to read from 'global' table.
1355     */
1356    public static final String CALL_METHOD_GET_GLOBAL = "GET_global";
1357
1358    /**
1359     * @hide - Specifies that the caller of the fast-path call()-based flow tracks
1360     * the settings generation in order to cache values locally. If this key is
1361     * mapped to a <code>null</code> string extra in the request bundle, the response
1362     * bundle will contain the same key mapped to a parcelable extra which would be
1363     * an {@link android.util.MemoryIntArray}. The response will also contain an
1364     * integer mapped to the {@link #CALL_METHOD_GENERATION_INDEX_KEY} which is the
1365     * index in the array clients should use to lookup the generation. For efficiency
1366     * the caller should request the generation tracking memory array only if it
1367     * doesn't already have it.
1368     *
1369     * @see #CALL_METHOD_GENERATION_INDEX_KEY
1370     */
1371    public static final String CALL_METHOD_TRACK_GENERATION_KEY = "_track_generation";
1372
1373    /**
1374     * @hide Key with the location in the {@link android.util.MemoryIntArray} where
1375     * to look up the generation id of the backing table. The value is an integer.
1376     *
1377     * @see #CALL_METHOD_TRACK_GENERATION_KEY
1378     */
1379    public static final String CALL_METHOD_GENERATION_INDEX_KEY = "_generation_index";
1380
1381    /**
1382     * @hide Key with the settings table generation. The value is an integer.
1383     *
1384     * @see #CALL_METHOD_TRACK_GENERATION_KEY
1385     */
1386    public static final String CALL_METHOD_GENERATION_KEY = "_generation";
1387
1388    /**
1389     * @hide - User handle argument extra to the fast-path call()-based requests
1390     */
1391    public static final String CALL_METHOD_USER_KEY = "_user";
1392
1393    /**
1394     * @hide - Boolean argument extra to the fast-path call()-based requests
1395     */
1396    public static final String CALL_METHOD_MAKE_DEFAULT_KEY = "_make_default";
1397
1398    /**
1399     * @hide - User handle argument extra to the fast-path call()-based requests
1400     */
1401    public static final String CALL_METHOD_RESET_MODE_KEY = "_reset_mode";
1402
1403    /**
1404     * @hide - String argument extra to the fast-path call()-based requests
1405     */
1406    public static final String CALL_METHOD_TAG_KEY = "_tag";
1407
1408    /** @hide - Private call() method to write to 'system' table */
1409    public static final String CALL_METHOD_PUT_SYSTEM = "PUT_system";
1410
1411    /** @hide - Private call() method to write to 'secure' table */
1412    public static final String CALL_METHOD_PUT_SECURE = "PUT_secure";
1413
1414    /** @hide - Private call() method to write to 'global' table */
1415    public static final String CALL_METHOD_PUT_GLOBAL= "PUT_global";
1416
1417    /** @hide - Private call() method to reset to defaults the 'global' table */
1418    public static final String CALL_METHOD_RESET_GLOBAL = "RESET_global";
1419
1420    /** @hide - Private call() method to reset to defaults the 'secure' table */
1421    public static final String CALL_METHOD_RESET_SECURE = "RESET_secure";
1422
1423    /**
1424     * Activity Extra: Limit available options in launched activity based on the given authority.
1425     * <p>
1426     * This can be passed as an extra field in an Activity Intent with one or more syncable content
1427     * provider's authorities as a String[]. This field is used by some intents to alter the
1428     * behavior of the called activity.
1429     * <p>
1430     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based
1431     * on the authority given.
1432     */
1433    public static final String EXTRA_AUTHORITIES = "authorities";
1434
1435    /**
1436     * Activity Extra: Limit available options in launched activity based on the given account
1437     * types.
1438     * <p>
1439     * This can be passed as an extra field in an Activity Intent with one or more account types
1440     * as a String[]. This field is used by some intents to alter the behavior of the called
1441     * activity.
1442     * <p>
1443     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types to the specified
1444     * list.
1445     */
1446    public static final String EXTRA_ACCOUNT_TYPES = "account_types";
1447
1448    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
1449
1450    /**
1451     * Activity Extra: The device identifier to act upon.
1452     * <p>
1453     * This can be passed as an extra field in an Activity Intent with a single
1454     * InputDeviceIdentifier. This field is used by some activities to jump straight into the
1455     * settings for the given device.
1456     * <p>
1457     * Example: The {@link #ACTION_INPUT_METHOD_SETTINGS} intent opens the keyboard layout
1458     * dialog for the given device.
1459     * @hide
1460     */
1461    public static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
1462
1463    /**
1464     * Activity Extra: Enable or disable Airplane Mode.
1465     * <p>
1466     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_AIRPLANE_MODE}
1467     * intent as a boolean to indicate if it should be enabled.
1468     */
1469    public static final String EXTRA_AIRPLANE_MODE_ENABLED = "airplane_mode_enabled";
1470
1471    /**
1472     * Activity Extra: Enable or disable Battery saver mode.
1473     * <p>
1474     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE}
1475     * intent as a boolean to indicate if it should be enabled.
1476     */
1477    public static final String EXTRA_BATTERY_SAVER_MODE_ENABLED =
1478            "android.settings.extra.battery_saver_mode_enabled";
1479
1480    /**
1481     * Activity Extra: Enable or disable Do Not Disturb mode.
1482     * <p>
1483     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1484     * intent as a boolean to indicate if it should be enabled.
1485     */
1486    public static final String EXTRA_DO_NOT_DISTURB_MODE_ENABLED =
1487            "android.settings.extra.do_not_disturb_mode_enabled";
1488
1489    /**
1490     * Activity Extra: How many minutes to enable do not disturb mode for.
1491     * <p>
1492     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1493     * intent to indicate how long do not disturb mode should be enabled for.
1494     */
1495    public static final String EXTRA_DO_NOT_DISTURB_MODE_MINUTES =
1496            "android.settings.extra.do_not_disturb_mode_minutes";
1497
1498    /**
1499     * Reset mode: reset to defaults only settings changed by the
1500     * calling package. If there is a default set the setting
1501     * will be set to it, otherwise the setting will be deleted.
1502     * This is the only type of reset available to non-system clients.
1503     * @hide
1504     */
1505    public static final int RESET_MODE_PACKAGE_DEFAULTS = 1;
1506
1507    /**
1508     * Reset mode: reset all settings set by untrusted packages, which is
1509     * packages that aren't a part of the system, to the current defaults.
1510     * If there is a default set the setting will be set to it, otherwise
1511     * the setting will be deleted. This mode is only available to the system.
1512     * @hide
1513     */
1514    public static final int RESET_MODE_UNTRUSTED_DEFAULTS = 2;
1515
1516    /**
1517     * Reset mode: delete all settings set by untrusted packages, which is
1518     * packages that aren't a part of the system. If a setting is set by an
1519     * untrusted package it will be deleted if its default is not provided
1520     * by the system, otherwise the setting will be set to its default.
1521     * This mode is only available to the system.
1522     * @hide
1523     */
1524    public static final int RESET_MODE_UNTRUSTED_CHANGES = 3;
1525
1526    /**
1527     * Reset mode: reset all settings to defaults specified by trusted
1528     * packages, which is packages that are a part of the system, and
1529     * delete all settings set by untrusted packages. If a setting has
1530     * a default set by a system package it will be set to the default,
1531     * otherwise the setting will be deleted. This mode is only available
1532     * to the system.
1533     * @hide
1534     */
1535    public static final int RESET_MODE_TRUSTED_DEFAULTS = 4;
1536
1537    /** @hide */
1538    @Retention(RetentionPolicy.SOURCE)
1539    @IntDef({
1540            RESET_MODE_PACKAGE_DEFAULTS,
1541            RESET_MODE_UNTRUSTED_DEFAULTS,
1542            RESET_MODE_UNTRUSTED_CHANGES,
1543            RESET_MODE_TRUSTED_DEFAULTS
1544    })
1545    public @interface ResetMode{}
1546
1547    /**
1548     * Activity Extra: Number of certificates
1549     * <p>
1550     * This can be passed as an extra field to the {@link #ACTION_MONITORING_CERT_INFO}
1551     * intent to indicate the number of certificates
1552     * @hide
1553     */
1554    public static final String EXTRA_NUMBER_OF_CERTIFICATES =
1555            "android.settings.extra.number_of_certificates";
1556
1557    private static final String JID_RESOURCE_PREFIX = "android";
1558
1559    public static final String AUTHORITY = "settings";
1560
1561    private static final String TAG = "Settings";
1562    private static final boolean LOCAL_LOGV = false;
1563
1564    // Lock ensures that when enabling/disabling the master location switch, we don't end up
1565    // with a partial enable/disable state in multi-threaded situations.
1566    private static final Object mLocationSettingsLock = new Object();
1567
1568    public static class SettingNotFoundException extends AndroidException {
1569        public SettingNotFoundException(String msg) {
1570            super(msg);
1571        }
1572    }
1573
1574    /**
1575     * Common base for tables of name/value settings.
1576     */
1577    public static class NameValueTable implements BaseColumns {
1578        public static final String NAME = "name";
1579        public static final String VALUE = "value";
1580
1581        protected static boolean putString(ContentResolver resolver, Uri uri,
1582                String name, String value) {
1583            // The database will take care of replacing duplicates.
1584            try {
1585                ContentValues values = new ContentValues();
1586                values.put(NAME, name);
1587                values.put(VALUE, value);
1588                resolver.insert(uri, values);
1589                return true;
1590            } catch (SQLException e) {
1591                Log.w(TAG, "Can't set key " + name + " in " + uri, e);
1592                return false;
1593            }
1594        }
1595
1596        public static Uri getUriFor(Uri uri, String name) {
1597            return Uri.withAppendedPath(uri, name);
1598        }
1599    }
1600
1601    private static final class GenerationTracker {
1602        private final MemoryIntArray mArray;
1603        private final Runnable mErrorHandler;
1604        private final int mIndex;
1605        private int mCurrentGeneration;
1606
1607        public GenerationTracker(@NonNull MemoryIntArray array, int index,
1608                int generation, Runnable errorHandler) {
1609            mArray = array;
1610            mIndex = index;
1611            mErrorHandler = errorHandler;
1612            mCurrentGeneration = generation;
1613        }
1614
1615        public boolean isGenerationChanged() {
1616            final int currentGeneration = readCurrentGeneration();
1617            if (currentGeneration >= 0) {
1618                if (currentGeneration == mCurrentGeneration) {
1619                    return false;
1620                }
1621                mCurrentGeneration = currentGeneration;
1622            }
1623            return true;
1624        }
1625
1626        private int readCurrentGeneration() {
1627            try {
1628                return mArray.get(mIndex);
1629            } catch (IOException e) {
1630                Log.e(TAG, "Error getting current generation", e);
1631                if (mErrorHandler != null) {
1632                    mErrorHandler.run();
1633                }
1634            }
1635            return -1;
1636        }
1637
1638        public void destroy() {
1639            try {
1640                mArray.close();
1641            } catch (IOException e) {
1642                Log.e(TAG, "Error closing backing array", e);
1643                if (mErrorHandler != null) {
1644                    mErrorHandler.run();
1645                }
1646            }
1647        }
1648    }
1649
1650    private static final class ContentProviderHolder {
1651        private final Object mLock = new Object();
1652
1653        @GuardedBy("mLock")
1654        private final Uri mUri;
1655        @GuardedBy("mLock")
1656        private IContentProvider mContentProvider;
1657
1658        public ContentProviderHolder(Uri uri) {
1659            mUri = uri;
1660        }
1661
1662        public IContentProvider getProvider(ContentResolver contentResolver) {
1663            synchronized (mLock) {
1664                if (mContentProvider == null) {
1665                    mContentProvider = contentResolver
1666                            .acquireProvider(mUri.getAuthority());
1667                }
1668                return mContentProvider;
1669            }
1670        }
1671    }
1672
1673    // Thread-safe.
1674    private static class NameValueCache {
1675        private static final boolean DEBUG = false;
1676
1677        private static final String[] SELECT_VALUE_PROJECTION = new String[] {
1678                Settings.NameValueTable.VALUE
1679        };
1680
1681        private static final String NAME_EQ_PLACEHOLDER = "name=?";
1682
1683        // Must synchronize on 'this' to access mValues and mValuesVersion.
1684        private final HashMap<String, String> mValues = new HashMap<>();
1685
1686        private final Uri mUri;
1687        private final ContentProviderHolder mProviderHolder;
1688
1689        // The method we'll call (or null, to not use) on the provider
1690        // for the fast path of retrieving settings.
1691        private final String mCallGetCommand;
1692        private final String mCallSetCommand;
1693
1694        @GuardedBy("this")
1695        private GenerationTracker mGenerationTracker;
1696
1697        public NameValueCache(Uri uri, String getCommand, String setCommand,
1698                ContentProviderHolder providerHolder) {
1699            mUri = uri;
1700            mCallGetCommand = getCommand;
1701            mCallSetCommand = setCommand;
1702            mProviderHolder = providerHolder;
1703        }
1704
1705        public boolean putStringForUser(ContentResolver cr, String name, String value,
1706                String tag, boolean makeDefault, final int userHandle) {
1707            try {
1708                Bundle arg = new Bundle();
1709                arg.putString(Settings.NameValueTable.VALUE, value);
1710                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
1711                if (tag != null) {
1712                    arg.putString(CALL_METHOD_TAG_KEY, tag);
1713                }
1714                if (makeDefault) {
1715                    arg.putBoolean(CALL_METHOD_MAKE_DEFAULT_KEY, true);
1716                }
1717                IContentProvider cp = mProviderHolder.getProvider(cr);
1718                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
1719            } catch (RemoteException e) {
1720                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
1721                return false;
1722            }
1723            return true;
1724        }
1725
1726        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
1727            final boolean isSelf = (userHandle == UserHandle.myUserId());
1728            if (isSelf) {
1729                synchronized (NameValueCache.this) {
1730                    if (mGenerationTracker != null) {
1731                        if (mGenerationTracker.isGenerationChanged()) {
1732                            if (DEBUG) {
1733                                Log.i(TAG, "Generation changed for type:"
1734                                        + mUri.getPath() + " in package:"
1735                                        + cr.getPackageName() +" and user:" + userHandle);
1736                            }
1737                            mValues.clear();
1738                        } else if (mValues.containsKey(name)) {
1739                            return mValues.get(name);
1740                        }
1741                    }
1742                }
1743            } else {
1744                if (LOCAL_LOGV) Log.v(TAG, "get setting for user " + userHandle
1745                        + " by user " + UserHandle.myUserId() + " so skipping cache");
1746            }
1747
1748            IContentProvider cp = mProviderHolder.getProvider(cr);
1749
1750            // Try the fast path first, not using query().  If this
1751            // fails (alternate Settings provider that doesn't support
1752            // this interface?) then we fall back to the query/table
1753            // interface.
1754            if (mCallGetCommand != null) {
1755                try {
1756                    Bundle args = null;
1757                    if (!isSelf) {
1758                        args = new Bundle();
1759                        args.putInt(CALL_METHOD_USER_KEY, userHandle);
1760                    }
1761                    boolean needsGenerationTracker = false;
1762                    synchronized (NameValueCache.this) {
1763                        if (isSelf && mGenerationTracker == null) {
1764                            needsGenerationTracker = true;
1765                            if (args == null) {
1766                                args = new Bundle();
1767                            }
1768                            args.putString(CALL_METHOD_TRACK_GENERATION_KEY, null);
1769                            if (DEBUG) {
1770                                Log.i(TAG, "Requested generation tracker for type: "+ mUri.getPath()
1771                                        + " in package:" + cr.getPackageName() +" and user:"
1772                                        + userHandle);
1773                            }
1774                        }
1775                    }
1776                    Bundle b = cp.call(cr.getPackageName(), mCallGetCommand, name, args);
1777                    if (b != null) {
1778                        String value = b.getString(Settings.NameValueTable.VALUE);
1779                        // Don't update our cache for reads of other users' data
1780                        if (isSelf) {
1781                            synchronized (NameValueCache.this) {
1782                                if (needsGenerationTracker) {
1783                                    MemoryIntArray array = b.getParcelable(
1784                                            CALL_METHOD_TRACK_GENERATION_KEY);
1785                                    final int index = b.getInt(
1786                                            CALL_METHOD_GENERATION_INDEX_KEY, -1);
1787                                    if (array != null && index >= 0) {
1788                                        final int generation = b.getInt(
1789                                                CALL_METHOD_GENERATION_KEY, 0);
1790                                        if (DEBUG) {
1791                                            Log.i(TAG, "Received generation tracker for type:"
1792                                                    + mUri.getPath() + " in package:"
1793                                                    + cr.getPackageName() + " and user:"
1794                                                    + userHandle + " with index:" + index);
1795                                        }
1796                                        if (mGenerationTracker != null) {
1797                                            mGenerationTracker.destroy();
1798                                        }
1799                                        mGenerationTracker = new GenerationTracker(array, index,
1800                                                generation, () -> {
1801                                            synchronized (NameValueCache.this) {
1802                                                Log.e(TAG, "Error accessing generation"
1803                                                        + " tracker - removing");
1804                                                if (mGenerationTracker != null) {
1805                                                    GenerationTracker generationTracker =
1806                                                            mGenerationTracker;
1807                                                    mGenerationTracker = null;
1808                                                    generationTracker.destroy();
1809                                                    mValues.clear();
1810                                                }
1811                                            }
1812                                        });
1813                                    }
1814                                }
1815                                mValues.put(name, value);
1816                            }
1817                        } else {
1818                            if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
1819                                    + " by " + UserHandle.myUserId()
1820                                    + " so not updating cache");
1821                        }
1822                        return value;
1823                    }
1824                    // If the response Bundle is null, we fall through
1825                    // to the query interface below.
1826                } catch (RemoteException e) {
1827                    // Not supported by the remote side?  Fall through
1828                    // to query().
1829                }
1830            }
1831
1832            Cursor c = null;
1833            try {
1834                Bundle queryArgs = ContentResolver.createSqlQueryBundle(
1835                        NAME_EQ_PLACEHOLDER, new String[]{name}, null);
1836                c = cp.query(cr.getPackageName(), mUri, SELECT_VALUE_PROJECTION, queryArgs, null);
1837                if (c == null) {
1838                    Log.w(TAG, "Can't get key " + name + " from " + mUri);
1839                    return null;
1840                }
1841
1842                String value = c.moveToNext() ? c.getString(0) : null;
1843                synchronized (NameValueCache.this) {
1844                    mValues.put(name, value);
1845                }
1846                if (LOCAL_LOGV) {
1847                    Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +
1848                            name + " = " + (value == null ? "(null)" : value));
1849                }
1850                return value;
1851            } catch (RemoteException e) {
1852                Log.w(TAG, "Can't get key " + name + " from " + mUri, e);
1853                return null;  // Return null, but don't cache it.
1854            } finally {
1855                if (c != null) c.close();
1856            }
1857        }
1858    }
1859
1860    /**
1861     * Checks if the specified context can draw on top of other apps. As of API
1862     * level 23, an app cannot draw on top of other apps unless it declares the
1863     * {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission in its
1864     * manifest, <em>and</em> the user specifically grants the app this
1865     * capability. To prompt the user to grant this approval, the app must send an
1866     * intent with the action
1867     * {@link android.provider.Settings#ACTION_MANAGE_OVERLAY_PERMISSION}, which
1868     * causes the system to display a permission management screen.
1869     *
1870     * @param context App context.
1871     * @return true if the specified context can draw on top of other apps, false otherwise
1872     */
1873    public static boolean canDrawOverlays(Context context) {
1874        return Settings.isCallingPackageAllowedToDrawOverlays(context, Process.myUid(),
1875                context.getOpPackageName(), false);
1876    }
1877
1878    /**
1879     * System settings, containing miscellaneous system preferences.  This
1880     * table holds simple name/value pairs.  There are convenience
1881     * functions for accessing individual settings entries.
1882     */
1883    public static final class System extends NameValueTable {
1884        private static final float DEFAULT_FONT_SCALE = 1.0f;
1885
1886        /** @hide */
1887        public static interface Validator {
1888            public boolean validate(String value);
1889        }
1890
1891        /**
1892         * The content:// style URL for this table
1893         */
1894        public static final Uri CONTENT_URI =
1895            Uri.parse("content://" + AUTHORITY + "/system");
1896
1897        private static final ContentProviderHolder sProviderHolder =
1898                new ContentProviderHolder(CONTENT_URI);
1899
1900        private static final NameValueCache sNameValueCache = new NameValueCache(
1901                CONTENT_URI,
1902                CALL_METHOD_GET_SYSTEM,
1903                CALL_METHOD_PUT_SYSTEM,
1904                sProviderHolder);
1905
1906        private static final HashSet<String> MOVED_TO_SECURE;
1907        static {
1908            MOVED_TO_SECURE = new HashSet<>(30);
1909            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
1910            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
1911            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
1912            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
1913            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
1914            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
1915            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
1916            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
1917            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
1918            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
1919            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
1920            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
1921            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
1922            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
1923            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
1924            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
1925            MOVED_TO_SECURE.add(Secure.WIFI_ON);
1926            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
1927            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
1928            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
1929            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
1930            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
1931            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
1932            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
1933            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
1934            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
1935            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
1936            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
1937
1938            // At one time in System, then Global, but now back in Secure
1939            MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
1940        }
1941
1942        private static final HashSet<String> MOVED_TO_GLOBAL;
1943        private static final HashSet<String> MOVED_TO_SECURE_THEN_GLOBAL;
1944        static {
1945            MOVED_TO_GLOBAL = new HashSet<>();
1946            MOVED_TO_SECURE_THEN_GLOBAL = new HashSet<>();
1947
1948            // these were originally in system but migrated to secure in the past,
1949            // so are duplicated in the Secure.* namespace
1950            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.ADB_ENABLED);
1951            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.BLUETOOTH_ON);
1952            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DATA_ROAMING);
1953            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DEVICE_PROVISIONED);
1954            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.USB_MASS_STORAGE_ENABLED);
1955            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.HTTP_PROXY);
1956
1957            // these are moving directly from system to global
1958            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_ON);
1959            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_RADIOS);
1960            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
1961            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME);
1962            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME_ZONE);
1963            MOVED_TO_GLOBAL.add(Settings.Global.CAR_DOCK_SOUND);
1964            MOVED_TO_GLOBAL.add(Settings.Global.CAR_UNDOCK_SOUND);
1965            MOVED_TO_GLOBAL.add(Settings.Global.DESK_DOCK_SOUND);
1966            MOVED_TO_GLOBAL.add(Settings.Global.DESK_UNDOCK_SOUND);
1967            MOVED_TO_GLOBAL.add(Settings.Global.DOCK_SOUNDS_ENABLED);
1968            MOVED_TO_GLOBAL.add(Settings.Global.LOCK_SOUND);
1969            MOVED_TO_GLOBAL.add(Settings.Global.UNLOCK_SOUND);
1970            MOVED_TO_GLOBAL.add(Settings.Global.LOW_BATTERY_SOUND);
1971            MOVED_TO_GLOBAL.add(Settings.Global.POWER_SOUNDS_ENABLED);
1972            MOVED_TO_GLOBAL.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
1973            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SLEEP_POLICY);
1974            MOVED_TO_GLOBAL.add(Settings.Global.MODE_RINGER);
1975            MOVED_TO_GLOBAL.add(Settings.Global.WINDOW_ANIMATION_SCALE);
1976            MOVED_TO_GLOBAL.add(Settings.Global.TRANSITION_ANIMATION_SCALE);
1977            MOVED_TO_GLOBAL.add(Settings.Global.ANIMATOR_DURATION_SCALE);
1978            MOVED_TO_GLOBAL.add(Settings.Global.FANCY_IME_ANIMATIONS);
1979            MOVED_TO_GLOBAL.add(Settings.Global.COMPATIBILITY_MODE);
1980            MOVED_TO_GLOBAL.add(Settings.Global.EMERGENCY_TONE);
1981            MOVED_TO_GLOBAL.add(Settings.Global.CALL_AUTO_RETRY);
1982            MOVED_TO_GLOBAL.add(Settings.Global.DEBUG_APP);
1983            MOVED_TO_GLOBAL.add(Settings.Global.WAIT_FOR_DEBUGGER);
1984            MOVED_TO_GLOBAL.add(Settings.Global.ALWAYS_FINISH_ACTIVITIES);
1985            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_CONTENT_URL);
1986            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_METADATA_URL);
1987            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_CONTENT_URL);
1988            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_METADATA_URL);
1989            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_CONTENT_URL);
1990            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_METADATA_URL);
1991            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_CONTENT_URL);
1992            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_METADATA_URL);
1993        }
1994
1995        private static final Validator sBooleanValidator =
1996                new DiscreteValueValidator(new String[] {"0", "1"});
1997
1998        private static final Validator sNonNegativeIntegerValidator = new Validator() {
1999            @Override
2000            public boolean validate(String value) {
2001                try {
2002                    return Integer.parseInt(value) >= 0;
2003                } catch (NumberFormatException e) {
2004                    return false;
2005                }
2006            }
2007        };
2008
2009        private static final Validator sUriValidator = new Validator() {
2010            @Override
2011            public boolean validate(String value) {
2012                try {
2013                    Uri.decode(value);
2014                    return true;
2015                } catch (IllegalArgumentException e) {
2016                    return false;
2017                }
2018            }
2019        };
2020
2021        private static final Validator sLenientIpAddressValidator = new Validator() {
2022            private static final int MAX_IPV6_LENGTH = 45;
2023
2024            @Override
2025            public boolean validate(String value) {
2026                return value.length() <= MAX_IPV6_LENGTH;
2027            }
2028        };
2029
2030        /** @hide */
2031        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
2032            outKeySet.addAll(MOVED_TO_GLOBAL);
2033            outKeySet.addAll(MOVED_TO_SECURE_THEN_GLOBAL);
2034        }
2035
2036        /** @hide */
2037        public static void getMovedToSecureSettings(Set<String> outKeySet) {
2038            outKeySet.addAll(MOVED_TO_SECURE);
2039        }
2040
2041        /** @hide */
2042        public static void getNonLegacyMovedKeys(HashSet<String> outKeySet) {
2043            outKeySet.addAll(MOVED_TO_GLOBAL);
2044        }
2045
2046        /**
2047         * Look up a name in the database.
2048         * @param resolver to access the database with
2049         * @param name to look up in the table
2050         * @return the corresponding value, or null if not present
2051         */
2052        public static String getString(ContentResolver resolver, String name) {
2053            return getStringForUser(resolver, name, UserHandle.myUserId());
2054        }
2055
2056        /** @hide */
2057        public static String getStringForUser(ContentResolver resolver, String name,
2058                int userHandle) {
2059            if (MOVED_TO_SECURE.contains(name)) {
2060                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2061                        + " to android.provider.Settings.Secure, returning read-only value.");
2062                return Secure.getStringForUser(resolver, name, userHandle);
2063            }
2064            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2065                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2066                        + " to android.provider.Settings.Global, returning read-only value.");
2067                return Global.getStringForUser(resolver, name, userHandle);
2068            }
2069            return sNameValueCache.getStringForUser(resolver, name, userHandle);
2070        }
2071
2072        /**
2073         * Store a name/value pair into the database.
2074         * @param resolver to access the database with
2075         * @param name to store
2076         * @param value to associate with the name
2077         * @return true if the value was set, false on database errors
2078         */
2079        public static boolean putString(ContentResolver resolver, String name, String value) {
2080            return putStringForUser(resolver, name, value, UserHandle.myUserId());
2081        }
2082
2083        /** @hide */
2084        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
2085                int userHandle) {
2086            if (MOVED_TO_SECURE.contains(name)) {
2087                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2088                        + " to android.provider.Settings.Secure, value is unchanged.");
2089                return false;
2090            }
2091            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2092                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2093                        + " to android.provider.Settings.Global, value is unchanged.");
2094                return false;
2095            }
2096            return sNameValueCache.putStringForUser(resolver, name, value, null, false, userHandle);
2097        }
2098
2099        /**
2100         * Construct the content URI for a particular name/value pair,
2101         * useful for monitoring changes with a ContentObserver.
2102         * @param name to look up in the table
2103         * @return the corresponding content URI, or null if not present
2104         */
2105        public static Uri getUriFor(String name) {
2106            if (MOVED_TO_SECURE.contains(name)) {
2107                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2108                    + " to android.provider.Settings.Secure, returning Secure URI.");
2109                return Secure.getUriFor(Secure.CONTENT_URI, name);
2110            }
2111            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2112                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2113                        + " to android.provider.Settings.Global, returning read-only global URI.");
2114                return Global.getUriFor(Global.CONTENT_URI, name);
2115            }
2116            return getUriFor(CONTENT_URI, name);
2117        }
2118
2119        /**
2120         * Convenience function for retrieving a single system settings value
2121         * as an integer.  Note that internally setting values are always
2122         * stored as strings; this function converts the string to an integer
2123         * for you.  The default value will be returned if the setting is
2124         * not defined or not an integer.
2125         *
2126         * @param cr The ContentResolver to access.
2127         * @param name The name of the setting to retrieve.
2128         * @param def Value to return if the setting is not defined.
2129         *
2130         * @return The setting's current value, or 'def' if it is not defined
2131         * or not a valid integer.
2132         */
2133        public static int getInt(ContentResolver cr, String name, int def) {
2134            return getIntForUser(cr, name, def, UserHandle.myUserId());
2135        }
2136
2137        /** @hide */
2138        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
2139            String v = getStringForUser(cr, name, userHandle);
2140            try {
2141                return v != null ? Integer.parseInt(v) : def;
2142            } catch (NumberFormatException e) {
2143                return def;
2144            }
2145        }
2146
2147        /**
2148         * Convenience function for retrieving a single system settings value
2149         * as an integer.  Note that internally setting values are always
2150         * stored as strings; this function converts the string to an integer
2151         * for you.
2152         * <p>
2153         * This version does not take a default value.  If the setting has not
2154         * been set, or the string value is not a number,
2155         * it throws {@link SettingNotFoundException}.
2156         *
2157         * @param cr The ContentResolver to access.
2158         * @param name The name of the setting to retrieve.
2159         *
2160         * @throws SettingNotFoundException Thrown if a setting by the given
2161         * name can't be found or the setting value is not an integer.
2162         *
2163         * @return The setting's current value.
2164         */
2165        public static int getInt(ContentResolver cr, String name)
2166                throws SettingNotFoundException {
2167            return getIntForUser(cr, name, UserHandle.myUserId());
2168        }
2169
2170        /** @hide */
2171        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
2172                throws SettingNotFoundException {
2173            String v = getStringForUser(cr, name, userHandle);
2174            try {
2175                return Integer.parseInt(v);
2176            } catch (NumberFormatException e) {
2177                throw new SettingNotFoundException(name);
2178            }
2179        }
2180
2181        /**
2182         * Convenience function for updating a single settings value as an
2183         * integer. This will either create a new entry in the table if the
2184         * given name does not exist, or modify the value of the existing row
2185         * with that name.  Note that internally setting values are always
2186         * stored as strings, so this function converts the given value to a
2187         * string before storing it.
2188         *
2189         * @param cr The ContentResolver to access.
2190         * @param name The name of the setting to modify.
2191         * @param value The new value for the setting.
2192         * @return true if the value was set, false on database errors
2193         */
2194        public static boolean putInt(ContentResolver cr, String name, int value) {
2195            return putIntForUser(cr, name, value, UserHandle.myUserId());
2196        }
2197
2198        /** @hide */
2199        public static boolean putIntForUser(ContentResolver cr, String name, int value,
2200                int userHandle) {
2201            return putStringForUser(cr, name, Integer.toString(value), userHandle);
2202        }
2203
2204        /**
2205         * Convenience function for retrieving a single system settings value
2206         * as a {@code long}.  Note that internally setting values are always
2207         * stored as strings; this function converts the string to a {@code long}
2208         * for you.  The default value will be returned if the setting is
2209         * not defined or not a {@code long}.
2210         *
2211         * @param cr The ContentResolver to access.
2212         * @param name The name of the setting to retrieve.
2213         * @param def Value to return if the setting is not defined.
2214         *
2215         * @return The setting's current value, or 'def' if it is not defined
2216         * or not a valid {@code long}.
2217         */
2218        public static long getLong(ContentResolver cr, String name, long def) {
2219            return getLongForUser(cr, name, def, UserHandle.myUserId());
2220        }
2221
2222        /** @hide */
2223        public static long getLongForUser(ContentResolver cr, String name, long def,
2224                int userHandle) {
2225            String valString = getStringForUser(cr, name, userHandle);
2226            long value;
2227            try {
2228                value = valString != null ? Long.parseLong(valString) : def;
2229            } catch (NumberFormatException e) {
2230                value = def;
2231            }
2232            return value;
2233        }
2234
2235        /**
2236         * Convenience function for retrieving a single system settings value
2237         * as a {@code long}.  Note that internally setting values are always
2238         * stored as strings; this function converts the string to a {@code long}
2239         * for you.
2240         * <p>
2241         * This version does not take a default value.  If the setting has not
2242         * been set, or the string value is not a number,
2243         * it throws {@link SettingNotFoundException}.
2244         *
2245         * @param cr The ContentResolver to access.
2246         * @param name The name of the setting to retrieve.
2247         *
2248         * @return The setting's current value.
2249         * @throws SettingNotFoundException Thrown if a setting by the given
2250         * name can't be found or the setting value is not an integer.
2251         */
2252        public static long getLong(ContentResolver cr, String name)
2253                throws SettingNotFoundException {
2254            return getLongForUser(cr, name, UserHandle.myUserId());
2255        }
2256
2257        /** @hide */
2258        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
2259                throws SettingNotFoundException {
2260            String valString = getStringForUser(cr, name, userHandle);
2261            try {
2262                return Long.parseLong(valString);
2263            } catch (NumberFormatException e) {
2264                throw new SettingNotFoundException(name);
2265            }
2266        }
2267
2268        /**
2269         * Convenience function for updating a single settings value as a long
2270         * integer. This will either create a new entry in the table if the
2271         * given name does not exist, or modify the value of the existing row
2272         * with that name.  Note that internally setting values are always
2273         * stored as strings, so this function converts the given value to a
2274         * string before storing it.
2275         *
2276         * @param cr The ContentResolver to access.
2277         * @param name The name of the setting to modify.
2278         * @param value The new value for the setting.
2279         * @return true if the value was set, false on database errors
2280         */
2281        public static boolean putLong(ContentResolver cr, String name, long value) {
2282            return putLongForUser(cr, name, value, UserHandle.myUserId());
2283        }
2284
2285        /** @hide */
2286        public static boolean putLongForUser(ContentResolver cr, String name, long value,
2287                int userHandle) {
2288            return putStringForUser(cr, name, Long.toString(value), userHandle);
2289        }
2290
2291        /**
2292         * Convenience function for retrieving a single system settings value
2293         * as a floating point number.  Note that internally setting values are
2294         * always stored as strings; this function converts the string to an
2295         * float for you. The default value will be returned if the setting
2296         * is not defined or not a valid float.
2297         *
2298         * @param cr The ContentResolver to access.
2299         * @param name The name of the setting to retrieve.
2300         * @param def Value to return if the setting is not defined.
2301         *
2302         * @return The setting's current value, or 'def' if it is not defined
2303         * or not a valid float.
2304         */
2305        public static float getFloat(ContentResolver cr, String name, float def) {
2306            return getFloatForUser(cr, name, def, UserHandle.myUserId());
2307        }
2308
2309        /** @hide */
2310        public static float getFloatForUser(ContentResolver cr, String name, float def,
2311                int userHandle) {
2312            String v = getStringForUser(cr, name, userHandle);
2313            try {
2314                return v != null ? Float.parseFloat(v) : def;
2315            } catch (NumberFormatException e) {
2316                return def;
2317            }
2318        }
2319
2320        /**
2321         * Convenience function for retrieving a single system settings value
2322         * as a float.  Note that internally setting values are always
2323         * stored as strings; this function converts the string to a float
2324         * for you.
2325         * <p>
2326         * This version does not take a default value.  If the setting has not
2327         * been set, or the string value is not a number,
2328         * it throws {@link SettingNotFoundException}.
2329         *
2330         * @param cr The ContentResolver to access.
2331         * @param name The name of the setting to retrieve.
2332         *
2333         * @throws SettingNotFoundException Thrown if a setting by the given
2334         * name can't be found or the setting value is not a float.
2335         *
2336         * @return The setting's current value.
2337         */
2338        public static float getFloat(ContentResolver cr, String name)
2339                throws SettingNotFoundException {
2340            return getFloatForUser(cr, name, UserHandle.myUserId());
2341        }
2342
2343        /** @hide */
2344        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
2345                throws SettingNotFoundException {
2346            String v = getStringForUser(cr, name, userHandle);
2347            if (v == null) {
2348                throw new SettingNotFoundException(name);
2349            }
2350            try {
2351                return Float.parseFloat(v);
2352            } catch (NumberFormatException e) {
2353                throw new SettingNotFoundException(name);
2354            }
2355        }
2356
2357        /**
2358         * Convenience function for updating a single settings value as a
2359         * floating point number. This will either create a new entry in the
2360         * table if the given name does not exist, or modify the value of the
2361         * existing row with that name.  Note that internally setting values
2362         * are always stored as strings, so this function converts the given
2363         * value to a string before storing it.
2364         *
2365         * @param cr The ContentResolver to access.
2366         * @param name The name of the setting to modify.
2367         * @param value The new value for the setting.
2368         * @return true if the value was set, false on database errors
2369         */
2370        public static boolean putFloat(ContentResolver cr, String name, float value) {
2371            return putFloatForUser(cr, name, value, UserHandle.myUserId());
2372        }
2373
2374        /** @hide */
2375        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
2376                int userHandle) {
2377            return putStringForUser(cr, name, Float.toString(value), userHandle);
2378        }
2379
2380        /**
2381         * Convenience function to read all of the current
2382         * configuration-related settings into a
2383         * {@link Configuration} object.
2384         *
2385         * @param cr The ContentResolver to access.
2386         * @param outConfig Where to place the configuration settings.
2387         */
2388        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
2389            adjustConfigurationForUser(cr, outConfig, UserHandle.myUserId(),
2390                    false /* updateSettingsIfEmpty */);
2391        }
2392
2393        /** @hide */
2394        public static void adjustConfigurationForUser(ContentResolver cr, Configuration outConfig,
2395                int userHandle, boolean updateSettingsIfEmpty) {
2396            outConfig.fontScale = Settings.System.getFloatForUser(
2397                    cr, FONT_SCALE, DEFAULT_FONT_SCALE, userHandle);
2398            if (outConfig.fontScale < 0) {
2399                outConfig.fontScale = DEFAULT_FONT_SCALE;
2400            }
2401
2402            final String localeValue =
2403                    Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle);
2404            if (localeValue != null) {
2405                outConfig.setLocales(LocaleList.forLanguageTags(localeValue));
2406            } else {
2407                // Do not update configuration with emtpy settings since we need to take over the
2408                // locale list of previous user if the settings value is empty. This happens when a
2409                // new user is created.
2410
2411                if (updateSettingsIfEmpty) {
2412                    // Make current configuration persistent. This is necessary the first time a
2413                    // user log in. At the first login, the configuration settings are empty, so we
2414                    // need to store the adjusted configuration as the initial settings.
2415                    Settings.System.putStringForUser(
2416                            cr, SYSTEM_LOCALES, outConfig.getLocales().toLanguageTags(),
2417                            userHandle);
2418                }
2419            }
2420        }
2421
2422        /**
2423         * @hide Erase the fields in the Configuration that should be applied
2424         * by the settings.
2425         */
2426        public static void clearConfiguration(Configuration inoutConfig) {
2427            inoutConfig.fontScale = 0;
2428            if (!inoutConfig.userSetLocale && !inoutConfig.getLocales().isEmpty()) {
2429                inoutConfig.clearLocales();
2430            }
2431        }
2432
2433        /**
2434         * Convenience function to write a batch of configuration-related
2435         * settings from a {@link Configuration} object.
2436         *
2437         * @param cr The ContentResolver to access.
2438         * @param config The settings to write.
2439         * @return true if the values were set, false on database errors
2440         */
2441        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
2442            return putConfigurationForUser(cr, config, UserHandle.myUserId());
2443        }
2444
2445        /** @hide */
2446        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
2447                int userHandle) {
2448            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle) &&
2449                    Settings.System.putStringForUser(
2450                            cr, SYSTEM_LOCALES, config.getLocales().toLanguageTags(), userHandle);
2451        }
2452
2453        /** @hide */
2454        public static boolean hasInterestingConfigurationChanges(int changes) {
2455            return (changes & ActivityInfo.CONFIG_FONT_SCALE) != 0 ||
2456                    (changes & ActivityInfo.CONFIG_LOCALE) != 0;
2457        }
2458
2459        /** @deprecated - Do not use */
2460        @Deprecated
2461        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
2462            return getShowGTalkServiceStatusForUser(cr, UserHandle.myUserId());
2463        }
2464
2465        /**
2466         * @hide
2467         * @deprecated - Do not use
2468         */
2469        @Deprecated
2470        public static boolean getShowGTalkServiceStatusForUser(ContentResolver cr,
2471                int userHandle) {
2472            return getIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, 0, userHandle) != 0;
2473        }
2474
2475        /** @deprecated - Do not use */
2476        @Deprecated
2477        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
2478            setShowGTalkServiceStatusForUser(cr, flag, UserHandle.myUserId());
2479        }
2480
2481        /**
2482         * @hide
2483         * @deprecated - Do not use
2484         */
2485        @Deprecated
2486        public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean flag,
2487                int userHandle) {
2488            putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
2489        }
2490
2491        private static final class DiscreteValueValidator implements Validator {
2492            private final String[] mValues;
2493
2494            public DiscreteValueValidator(String[] values) {
2495                mValues = values;
2496            }
2497
2498            @Override
2499            public boolean validate(String value) {
2500                return ArrayUtils.contains(mValues, value);
2501            }
2502        }
2503
2504        private static final class InclusiveIntegerRangeValidator implements Validator {
2505            private final int mMin;
2506            private final int mMax;
2507
2508            public InclusiveIntegerRangeValidator(int min, int max) {
2509                mMin = min;
2510                mMax = max;
2511            }
2512
2513            @Override
2514            public boolean validate(String value) {
2515                try {
2516                    final int intValue = Integer.parseInt(value);
2517                    return intValue >= mMin && intValue <= mMax;
2518                } catch (NumberFormatException e) {
2519                    return false;
2520                }
2521            }
2522        }
2523
2524        private static final class InclusiveFloatRangeValidator implements Validator {
2525            private final float mMin;
2526            private final float mMax;
2527
2528            public InclusiveFloatRangeValidator(float min, float max) {
2529                mMin = min;
2530                mMax = max;
2531            }
2532
2533            @Override
2534            public boolean validate(String value) {
2535                try {
2536                    final float floatValue = Float.parseFloat(value);
2537                    return floatValue >= mMin && floatValue <= mMax;
2538                } catch (NumberFormatException e) {
2539                    return false;
2540                }
2541            }
2542        }
2543
2544        /**
2545         * @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
2546         */
2547        @Deprecated
2548        public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN;
2549
2550        /**
2551         * What happens when the user presses the end call button if they're not
2552         * on a call.<br/>
2553         * <b>Values:</b><br/>
2554         * 0 - The end button does nothing.<br/>
2555         * 1 - The end button goes to the home screen.<br/>
2556         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
2557         * 3 - The end button goes to the home screen.  If the user is already on the
2558         * home screen, it puts the device to sleep.
2559         */
2560        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
2561
2562        private static final Validator END_BUTTON_BEHAVIOR_VALIDATOR =
2563                new InclusiveIntegerRangeValidator(0, 3);
2564
2565        /**
2566         * END_BUTTON_BEHAVIOR value for "go home".
2567         * @hide
2568         */
2569        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
2570
2571        /**
2572         * END_BUTTON_BEHAVIOR value for "go to sleep".
2573         * @hide
2574         */
2575        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
2576
2577        /**
2578         * END_BUTTON_BEHAVIOR default value.
2579         * @hide
2580         */
2581        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
2582
2583        /**
2584         * Is advanced settings mode turned on. 0 == no, 1 == yes
2585         * @hide
2586         */
2587        public static final String ADVANCED_SETTINGS = "advanced_settings";
2588
2589        private static final Validator ADVANCED_SETTINGS_VALIDATOR = sBooleanValidator;
2590
2591        /**
2592         * ADVANCED_SETTINGS default value.
2593         * @hide
2594         */
2595        public static final int ADVANCED_SETTINGS_DEFAULT = 0;
2596
2597        /**
2598         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
2599         */
2600        @Deprecated
2601        public static final String AIRPLANE_MODE_ON = Global.AIRPLANE_MODE_ON;
2602
2603        /**
2604         * @deprecated Use {@link android.provider.Settings.Global#RADIO_BLUETOOTH} instead
2605         */
2606        @Deprecated
2607        public static final String RADIO_BLUETOOTH = Global.RADIO_BLUETOOTH;
2608
2609        /**
2610         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIFI} instead
2611         */
2612        @Deprecated
2613        public static final String RADIO_WIFI = Global.RADIO_WIFI;
2614
2615        /**
2616         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIMAX} instead
2617         * {@hide}
2618         */
2619        @Deprecated
2620        public static final String RADIO_WIMAX = Global.RADIO_WIMAX;
2621
2622        /**
2623         * @deprecated Use {@link android.provider.Settings.Global#RADIO_CELL} instead
2624         */
2625        @Deprecated
2626        public static final String RADIO_CELL = Global.RADIO_CELL;
2627
2628        /**
2629         * @deprecated Use {@link android.provider.Settings.Global#RADIO_NFC} instead
2630         */
2631        @Deprecated
2632        public static final String RADIO_NFC = Global.RADIO_NFC;
2633
2634        /**
2635         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_RADIOS} instead
2636         */
2637        @Deprecated
2638        public static final String AIRPLANE_MODE_RADIOS = Global.AIRPLANE_MODE_RADIOS;
2639
2640        /**
2641         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_TOGGLEABLE_RADIOS} instead
2642         *
2643         * {@hide}
2644         */
2645        @Deprecated
2646        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS =
2647                Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS;
2648
2649        /**
2650         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY} instead
2651         */
2652        @Deprecated
2653        public static final String WIFI_SLEEP_POLICY = Global.WIFI_SLEEP_POLICY;
2654
2655        /**
2656         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_DEFAULT} instead
2657         */
2658        @Deprecated
2659        public static final int WIFI_SLEEP_POLICY_DEFAULT = Global.WIFI_SLEEP_POLICY_DEFAULT;
2660
2661        /**
2662         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED} instead
2663         */
2664        @Deprecated
2665        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED =
2666                Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
2667
2668        /**
2669         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER} instead
2670         */
2671        @Deprecated
2672        public static final int WIFI_SLEEP_POLICY_NEVER = Global.WIFI_SLEEP_POLICY_NEVER;
2673
2674        /**
2675         * @deprecated Use {@link android.provider.Settings.Global#MODE_RINGER} instead
2676         */
2677        @Deprecated
2678        public static final String MODE_RINGER = Global.MODE_RINGER;
2679
2680        /**
2681         * Whether to use static IP and other static network attributes.
2682         * <p>
2683         * Set to 1 for true and 0 for false.
2684         *
2685         * @deprecated Use {@link WifiManager} instead
2686         */
2687        @Deprecated
2688        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
2689
2690        private static final Validator WIFI_USE_STATIC_IP_VALIDATOR = sBooleanValidator;
2691
2692        /**
2693         * The static IP address.
2694         * <p>
2695         * Example: "192.168.1.51"
2696         *
2697         * @deprecated Use {@link WifiManager} instead
2698         */
2699        @Deprecated
2700        public static final String WIFI_STATIC_IP = "wifi_static_ip";
2701
2702        private static final Validator WIFI_STATIC_IP_VALIDATOR = sLenientIpAddressValidator;
2703
2704        /**
2705         * If using static IP, the gateway's IP address.
2706         * <p>
2707         * Example: "192.168.1.1"
2708         *
2709         * @deprecated Use {@link WifiManager} instead
2710         */
2711        @Deprecated
2712        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
2713
2714        private static final Validator WIFI_STATIC_GATEWAY_VALIDATOR = sLenientIpAddressValidator;
2715
2716        /**
2717         * If using static IP, the net mask.
2718         * <p>
2719         * Example: "255.255.255.0"
2720         *
2721         * @deprecated Use {@link WifiManager} instead
2722         */
2723        @Deprecated
2724        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
2725
2726        private static final Validator WIFI_STATIC_NETMASK_VALIDATOR = sLenientIpAddressValidator;
2727
2728        /**
2729         * If using static IP, the primary DNS's IP address.
2730         * <p>
2731         * Example: "192.168.1.1"
2732         *
2733         * @deprecated Use {@link WifiManager} instead
2734         */
2735        @Deprecated
2736        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
2737
2738        private static final Validator WIFI_STATIC_DNS1_VALIDATOR = sLenientIpAddressValidator;
2739
2740        /**
2741         * If using static IP, the secondary DNS's IP address.
2742         * <p>
2743         * Example: "192.168.1.2"
2744         *
2745         * @deprecated Use {@link WifiManager} instead
2746         */
2747        @Deprecated
2748        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
2749
2750        private static final Validator WIFI_STATIC_DNS2_VALIDATOR = sLenientIpAddressValidator;
2751
2752        /**
2753         * Determines whether remote devices may discover and/or connect to
2754         * this device.
2755         * <P>Type: INT</P>
2756         * 2 -- discoverable and connectable
2757         * 1 -- connectable but not discoverable
2758         * 0 -- neither connectable nor discoverable
2759         */
2760        public static final String BLUETOOTH_DISCOVERABILITY =
2761            "bluetooth_discoverability";
2762
2763        private static final Validator BLUETOOTH_DISCOVERABILITY_VALIDATOR =
2764                new InclusiveIntegerRangeValidator(0, 2);
2765
2766        /**
2767         * Bluetooth discoverability timeout.  If this value is nonzero, then
2768         * Bluetooth becomes discoverable for a certain number of seconds,
2769         * after which is becomes simply connectable.  The value is in seconds.
2770         */
2771        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
2772            "bluetooth_discoverability_timeout";
2773
2774        private static final Validator BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR =
2775                sNonNegativeIntegerValidator;
2776
2777        /**
2778         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
2779         * instead
2780         */
2781        @Deprecated
2782        public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
2783
2784        /**
2785         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
2786         * instead
2787         */
2788        @Deprecated
2789        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
2790
2791        /**
2792         * @deprecated Use
2793         * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
2794         * instead
2795         */
2796        @Deprecated
2797        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
2798            "lock_pattern_tactile_feedback_enabled";
2799
2800        /**
2801         * A formatted string of the next alarm that is set, or the empty string
2802         * if there is no alarm set.
2803         *
2804         * @deprecated Use {@link android.app.AlarmManager#getNextAlarmClock()}.
2805         */
2806        @Deprecated
2807        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
2808
2809        private static final Validator NEXT_ALARM_FORMATTED_VALIDATOR = new Validator() {
2810            private static final int MAX_LENGTH = 1000;
2811
2812            @Override
2813            public boolean validate(String value) {
2814                // TODO: No idea what the correct format is.
2815                return value == null || value.length() < MAX_LENGTH;
2816            }
2817        };
2818
2819        /**
2820         * Scaling factor for fonts, float.
2821         */
2822        public static final String FONT_SCALE = "font_scale";
2823
2824        private static final Validator FONT_SCALE_VALIDATOR = new Validator() {
2825            @Override
2826            public boolean validate(String value) {
2827                try {
2828                    return Float.parseFloat(value) >= 0;
2829                } catch (NumberFormatException e) {
2830                    return false;
2831                }
2832            }
2833        };
2834
2835        /**
2836         * The serialized system locale value.
2837         *
2838         * Do not use this value directory.
2839         * To get system locale, use {@link LocaleList#getDefault} instead.
2840         * To update system locale, use {@link com.android.internal.app.LocalePicker#updateLocales}
2841         * instead.
2842         * @hide
2843         */
2844        public static final String SYSTEM_LOCALES = "system_locales";
2845
2846
2847        /**
2848         * Name of an application package to be debugged.
2849         *
2850         * @deprecated Use {@link Global#DEBUG_APP} instead
2851         */
2852        @Deprecated
2853        public static final String DEBUG_APP = Global.DEBUG_APP;
2854
2855        /**
2856         * If 1, when launching DEBUG_APP it will wait for the debugger before
2857         * starting user code.  If 0, it will run normally.
2858         *
2859         * @deprecated Use {@link Global#WAIT_FOR_DEBUGGER} instead
2860         */
2861        @Deprecated
2862        public static final String WAIT_FOR_DEBUGGER = Global.WAIT_FOR_DEBUGGER;
2863
2864        /**
2865         * Whether or not to dim the screen. 0=no  1=yes
2866         * @deprecated This setting is no longer used.
2867         */
2868        @Deprecated
2869        public static final String DIM_SCREEN = "dim_screen";
2870
2871        private static final Validator DIM_SCREEN_VALIDATOR = sBooleanValidator;
2872
2873        /**
2874         * The amount of time in milliseconds before the device goes to sleep or begins
2875         * to dream after a period of inactivity.  This value is also known as the
2876         * user activity timeout period since the screen isn't necessarily turned off
2877         * when it expires.
2878         */
2879        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
2880
2881        private static final Validator SCREEN_OFF_TIMEOUT_VALIDATOR = sNonNegativeIntegerValidator;
2882
2883        /**
2884         * The screen backlight brightness between 0 and 255.
2885         */
2886        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
2887
2888        private static final Validator SCREEN_BRIGHTNESS_VALIDATOR =
2889                new InclusiveIntegerRangeValidator(0, 255);
2890
2891        /**
2892         * The screen backlight brightness between 0 and 255.
2893         * @hide
2894         */
2895        public static final String SCREEN_BRIGHTNESS_FOR_VR = "screen_brightness_for_vr";
2896
2897        private static final Validator SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR =
2898                new InclusiveIntegerRangeValidator(0, 255);
2899
2900        /**
2901         * Control whether to enable automatic brightness mode.
2902         */
2903        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
2904
2905        private static final Validator SCREEN_BRIGHTNESS_MODE_VALIDATOR = sBooleanValidator;
2906
2907        /**
2908         * Adjustment to auto-brightness to make it generally more (>0.0 <1.0)
2909         * or less (<0.0 >-1.0) bright.
2910         * @hide
2911         */
2912        public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj";
2913
2914        private static final Validator SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR =
2915                new InclusiveFloatRangeValidator(-1, 1);
2916
2917        /**
2918         * SCREEN_BRIGHTNESS_MODE value for manual mode.
2919         */
2920        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
2921
2922        /**
2923         * SCREEN_BRIGHTNESS_MODE value for automatic mode.
2924         */
2925        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
2926
2927        /**
2928         * Control whether the process CPU usage meter should be shown.
2929         *
2930         * @deprecated This functionality is no longer available as of
2931         * {@link android.os.Build.VERSION_CODES#N_MR1}.
2932         */
2933        @Deprecated
2934        public static final String SHOW_PROCESSES = Global.SHOW_PROCESSES;
2935
2936        /**
2937         * If 1, the activity manager will aggressively finish activities and
2938         * processes as soon as they are no longer needed.  If 0, the normal
2939         * extended lifetime is used.
2940         *
2941         * @deprecated Use {@link Global#ALWAYS_FINISH_ACTIVITIES} instead
2942         */
2943        @Deprecated
2944        public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
2945
2946        /**
2947         * Determines which streams are affected by ringer mode changes. The
2948         * stream type's bit should be set to 1 if it should be muted when going
2949         * into an inaudible ringer mode.
2950         */
2951        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
2952
2953        private static final Validator MODE_RINGER_STREAMS_AFFECTED_VALIDATOR =
2954                sNonNegativeIntegerValidator;
2955
2956        /**
2957          * Determines which streams are affected by mute. The
2958          * stream type's bit should be set to 1 if it should be muted when a mute request
2959          * is received.
2960          */
2961        public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
2962
2963        private static final Validator MUTE_STREAMS_AFFECTED_VALIDATOR =
2964                sNonNegativeIntegerValidator;
2965
2966        /**
2967         * Whether vibrate is on for different events. This is used internally,
2968         * changing this value will not change the vibrate. See AudioManager.
2969         */
2970        public static final String VIBRATE_ON = "vibrate_on";
2971
2972        private static final Validator VIBRATE_ON_VALIDATOR = sBooleanValidator;
2973
2974        /**
2975         * If 1, redirects the system vibrator to all currently attached input devices
2976         * that support vibration.  If there are no such input devices, then the system
2977         * vibrator is used instead.
2978         * If 0, does not register the system vibrator.
2979         *
2980         * This setting is mainly intended to provide a compatibility mechanism for
2981         * applications that only know about the system vibrator and do not use the
2982         * input device vibrator API.
2983         *
2984         * @hide
2985         */
2986        public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices";
2987
2988        private static final Validator VIBRATE_INPUT_DEVICES_VALIDATOR = sBooleanValidator;
2989
2990        /**
2991         * Ringer volume. This is used internally, changing this value will not
2992         * change the volume. See AudioManager.
2993         *
2994         * @removed Not used by anything since API 2.
2995         */
2996        public static final String VOLUME_RING = "volume_ring";
2997
2998        /**
2999         * System/notifications volume. This is used internally, changing this
3000         * value will not change the volume. See AudioManager.
3001         *
3002         * @removed Not used by anything since API 2.
3003         */
3004        public static final String VOLUME_SYSTEM = "volume_system";
3005
3006        /**
3007         * Voice call volume. This is used internally, changing this value will
3008         * not change the volume. See AudioManager.
3009         *
3010         * @removed Not used by anything since API 2.
3011         */
3012        public static final String VOLUME_VOICE = "volume_voice";
3013
3014        /**
3015         * Music/media/gaming volume. This is used internally, changing this
3016         * value will not change the volume. See AudioManager.
3017         *
3018         * @removed Not used by anything since API 2.
3019         */
3020        public static final String VOLUME_MUSIC = "volume_music";
3021
3022        /**
3023         * Alarm volume. This is used internally, changing this
3024         * value will not change the volume. See AudioManager.
3025         *
3026         * @removed Not used by anything since API 2.
3027         */
3028        public static final String VOLUME_ALARM = "volume_alarm";
3029
3030        /**
3031         * Notification volume. This is used internally, changing this
3032         * value will not change the volume. See AudioManager.
3033         *
3034         * @removed Not used by anything since API 2.
3035         */
3036        public static final String VOLUME_NOTIFICATION = "volume_notification";
3037
3038        /**
3039         * Bluetooth Headset volume. This is used internally, changing this value will
3040         * not change the volume. See AudioManager.
3041         *
3042         * @removed Not used by anything since API 2.
3043         */
3044        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";
3045
3046        /**
3047         * Master volume (float in the range 0.0f to 1.0f).
3048         *
3049         * @hide
3050         */
3051        public static final String VOLUME_MASTER = "volume_master";
3052
3053        /**
3054         * Master mono (int 1 = mono, 0 = normal).
3055         *
3056         * @hide
3057         */
3058        public static final String MASTER_MONO = "master_mono";
3059
3060        private static final Validator MASTER_MONO_VALIDATOR = sBooleanValidator;
3061
3062        /**
3063         * Whether the notifications should use the ring volume (value of 1) or
3064         * a separate notification volume (value of 0). In most cases, users
3065         * will have this enabled so the notification and ringer volumes will be
3066         * the same. However, power users can disable this and use the separate
3067         * notification volume control.
3068         * <p>
3069         * Note: This is a one-off setting that will be removed in the future
3070         * when there is profile support. For this reason, it is kept hidden
3071         * from the public APIs.
3072         *
3073         * @hide
3074         * @deprecated
3075         */
3076        @Deprecated
3077        public static final String NOTIFICATIONS_USE_RING_VOLUME =
3078            "notifications_use_ring_volume";
3079
3080        private static final Validator NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR = sBooleanValidator;
3081
3082        /**
3083         * Whether silent mode should allow vibration feedback. This is used
3084         * internally in AudioService and the Sound settings activity to
3085         * coordinate decoupling of vibrate and silent modes. This setting
3086         * will likely be removed in a future release with support for
3087         * audio/vibe feedback profiles.
3088         *
3089         * Not used anymore. On devices with vibrator, the user explicitly selects
3090         * silent or vibrate mode.
3091         * Kept for use by legacy database upgrade code in DatabaseHelper.
3092         * @hide
3093         */
3094        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
3095
3096        private static final Validator VIBRATE_IN_SILENT_VALIDATOR = sBooleanValidator;
3097
3098        /**
3099         * The mapping of stream type (integer) to its setting.
3100         *
3101         * @removed  Not used by anything since API 2.
3102         */
3103        public static final String[] VOLUME_SETTINGS = {
3104            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
3105            VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO
3106        };
3107
3108        /**
3109         * Appended to various volume related settings to record the previous
3110         * values before they the settings were affected by a silent/vibrate
3111         * ringer mode change.
3112         *
3113         * @removed  Not used by anything since API 2.
3114         */
3115        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
3116
3117        /**
3118         * Persistent store for the system-wide default ringtone URI.
3119         * <p>
3120         * If you need to play the default ringtone at any given time, it is recommended
3121         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
3122         * to the set default ringtone at the time of playing.
3123         *
3124         * @see #DEFAULT_RINGTONE_URI
3125         */
3126        public static final String RINGTONE = "ringtone";
3127
3128        private static final Validator RINGTONE_VALIDATOR = sUriValidator;
3129
3130        /**
3131         * A {@link Uri} that will point to the current default ringtone at any
3132         * given time.
3133         * <p>
3134         * If the current default ringtone is in the DRM provider and the caller
3135         * does not have permission, the exception will be a
3136         * FileNotFoundException.
3137         */
3138        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
3139
3140        /** {@hide} */
3141        public static final String RINGTONE_CACHE = "ringtone_cache";
3142        /** {@hide} */
3143        public static final Uri RINGTONE_CACHE_URI = getUriFor(RINGTONE_CACHE);
3144
3145        /**
3146         * Persistent store for the system-wide default notification sound.
3147         *
3148         * @see #RINGTONE
3149         * @see #DEFAULT_NOTIFICATION_URI
3150         */
3151        public static final String NOTIFICATION_SOUND = "notification_sound";
3152
3153        private static final Validator NOTIFICATION_SOUND_VALIDATOR = sUriValidator;
3154
3155        /**
3156         * A {@link Uri} that will point to the current default notification
3157         * sound at any given time.
3158         *
3159         * @see #DEFAULT_RINGTONE_URI
3160         */
3161        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
3162
3163        /** {@hide} */
3164        public static final String NOTIFICATION_SOUND_CACHE = "notification_sound_cache";
3165        /** {@hide} */
3166        public static final Uri NOTIFICATION_SOUND_CACHE_URI = getUriFor(NOTIFICATION_SOUND_CACHE);
3167
3168        /**
3169         * Persistent store for the system-wide default alarm alert.
3170         *
3171         * @see #RINGTONE
3172         * @see #DEFAULT_ALARM_ALERT_URI
3173         */
3174        public static final String ALARM_ALERT = "alarm_alert";
3175
3176        private static final Validator ALARM_ALERT_VALIDATOR = sUriValidator;
3177
3178        /**
3179         * A {@link Uri} that will point to the current default alarm alert at
3180         * any given time.
3181         *
3182         * @see #DEFAULT_ALARM_ALERT_URI
3183         */
3184        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
3185
3186        /** {@hide} */
3187        public static final String ALARM_ALERT_CACHE = "alarm_alert_cache";
3188        /** {@hide} */
3189        public static final Uri ALARM_ALERT_CACHE_URI = getUriFor(ALARM_ALERT_CACHE);
3190
3191        /**
3192         * Persistent store for the system default media button event receiver.
3193         *
3194         * @hide
3195         */
3196        public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver";
3197
3198        private static final Validator MEDIA_BUTTON_RECEIVER_VALIDATOR = new Validator() {
3199            @Override
3200            public boolean validate(String value) {
3201                try {
3202                    ComponentName.unflattenFromString(value);
3203                    return true;
3204                } catch (NullPointerException e) {
3205                    return false;
3206                }
3207            }
3208        };
3209
3210        /**
3211         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
3212         */
3213        public static final String TEXT_AUTO_REPLACE = "auto_replace";
3214
3215        private static final Validator TEXT_AUTO_REPLACE_VALIDATOR = sBooleanValidator;
3216
3217        /**
3218         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
3219         */
3220        public static final String TEXT_AUTO_CAPS = "auto_caps";
3221
3222        private static final Validator TEXT_AUTO_CAPS_VALIDATOR = sBooleanValidator;
3223
3224        /**
3225         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
3226         * feature converts two spaces to a "." and space.
3227         */
3228        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
3229
3230        private static final Validator TEXT_AUTO_PUNCTUATE_VALIDATOR = sBooleanValidator;
3231
3232        /**
3233         * Setting to showing password characters in text editors. 1 = On, 0 = Off
3234         */
3235        public static final String TEXT_SHOW_PASSWORD = "show_password";
3236
3237        private static final Validator TEXT_SHOW_PASSWORD_VALIDATOR = sBooleanValidator;
3238
3239        public static final String SHOW_GTALK_SERVICE_STATUS =
3240                "SHOW_GTALK_SERVICE_STATUS";
3241
3242        private static final Validator SHOW_GTALK_SERVICE_STATUS_VALIDATOR = sBooleanValidator;
3243
3244        /**
3245         * Name of activity to use for wallpaper on the home screen.
3246         *
3247         * @deprecated Use {@link WallpaperManager} instead.
3248         */
3249        @Deprecated
3250        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
3251
3252        private static final Validator WALLPAPER_ACTIVITY_VALIDATOR = new Validator() {
3253            private static final int MAX_LENGTH = 1000;
3254
3255            @Override
3256            public boolean validate(String value) {
3257                if (value != null && value.length() > MAX_LENGTH) {
3258                    return false;
3259                }
3260                return ComponentName.unflattenFromString(value) != null;
3261            }
3262        };
3263
3264        /**
3265         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME}
3266         * instead
3267         */
3268        @Deprecated
3269        public static final String AUTO_TIME = Global.AUTO_TIME;
3270
3271        /**
3272         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE}
3273         * instead
3274         */
3275        @Deprecated
3276        public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE;
3277
3278        /**
3279         * Display times as 12 or 24 hours
3280         *   12
3281         *   24
3282         */
3283        public static final String TIME_12_24 = "time_12_24";
3284
3285        /** @hide */
3286        public static final Validator TIME_12_24_VALIDATOR =
3287                new DiscreteValueValidator(new String[] {"12", "24"});
3288
3289        /**
3290         * Date format string
3291         *   mm/dd/yyyy
3292         *   dd/mm/yyyy
3293         *   yyyy/mm/dd
3294         */
3295        public static final String DATE_FORMAT = "date_format";
3296
3297        /** @hide */
3298        public static final Validator DATE_FORMAT_VALIDATOR = new Validator() {
3299            @Override
3300            public boolean validate(String value) {
3301                try {
3302                    new SimpleDateFormat(value);
3303                    return true;
3304                } catch (IllegalArgumentException e) {
3305                    return false;
3306                }
3307            }
3308        };
3309
3310        /**
3311         * Whether the setup wizard has been run before (on first boot), or if
3312         * it still needs to be run.
3313         *
3314         * nonzero = it has been run in the past
3315         * 0 = it has not been run in the past
3316         */
3317        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
3318
3319        /** @hide */
3320        public static final Validator SETUP_WIZARD_HAS_RUN_VALIDATOR = sBooleanValidator;
3321
3322        /**
3323         * Scaling factor for normal window animations. Setting to 0 will disable window
3324         * animations.
3325         *
3326         * @deprecated Use {@link Global#WINDOW_ANIMATION_SCALE} instead
3327         */
3328        @Deprecated
3329        public static final String WINDOW_ANIMATION_SCALE = Global.WINDOW_ANIMATION_SCALE;
3330
3331        /**
3332         * Scaling factor for activity transition animations. Setting to 0 will disable window
3333         * animations.
3334         *
3335         * @deprecated Use {@link Global#TRANSITION_ANIMATION_SCALE} instead
3336         */
3337        @Deprecated
3338        public static final String TRANSITION_ANIMATION_SCALE = Global.TRANSITION_ANIMATION_SCALE;
3339
3340        /**
3341         * Scaling factor for Animator-based animations. This affects both the start delay and
3342         * duration of all such animations. Setting to 0 will cause animations to end immediately.
3343         * The default value is 1.
3344         *
3345         * @deprecated Use {@link Global#ANIMATOR_DURATION_SCALE} instead
3346         */
3347        @Deprecated
3348        public static final String ANIMATOR_DURATION_SCALE = Global.ANIMATOR_DURATION_SCALE;
3349
3350        /**
3351         * Control whether the accelerometer will be used to change screen
3352         * orientation.  If 0, it will not be used unless explicitly requested
3353         * by the application; if 1, it will be used by default unless explicitly
3354         * disabled by the application.
3355         */
3356        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
3357
3358        /** @hide */
3359        public static final Validator ACCELEROMETER_ROTATION_VALIDATOR = sBooleanValidator;
3360
3361        /**
3362         * Default screen rotation when no other policy applies.
3363         * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
3364         * preference, this rotation value will be used. Must be one of the
3365         * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
3366         *
3367         * @see android.view.Display#getRotation
3368         */
3369        public static final String USER_ROTATION = "user_rotation";
3370
3371        /** @hide */
3372        public static final Validator USER_ROTATION_VALIDATOR =
3373                new InclusiveIntegerRangeValidator(0, 3);
3374
3375        /**
3376         * Control whether the rotation lock toggle in the System UI should be hidden.
3377         * Typically this is done for accessibility purposes to make it harder for
3378         * the user to accidentally toggle the rotation lock while the display rotation
3379         * has been locked for accessibility.
3380         *
3381         * If 0, then rotation lock toggle is not hidden for accessibility (although it may be
3382         * unavailable for other reasons).  If 1, then the rotation lock toggle is hidden.
3383         *
3384         * @hide
3385         */
3386        public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY =
3387                "hide_rotation_lock_toggle_for_accessibility";
3388
3389        /** @hide */
3390        public static final Validator HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR =
3391                sBooleanValidator;
3392
3393        /**
3394         * Whether the phone vibrates when it is ringing due to an incoming call. This will
3395         * be used by Phone and Setting apps; it shouldn't affect other apps.
3396         * The value is boolean (1 or 0).
3397         *
3398         * Note: this is not same as "vibrate on ring", which had been available until ICS.
3399         * It was about AudioManager's setting and thus affected all the applications which
3400         * relied on the setting, while this is purely about the vibration setting for incoming
3401         * calls.
3402         */
3403        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
3404
3405        /** @hide */
3406        public static final Validator VIBRATE_WHEN_RINGING_VALIDATOR = sBooleanValidator;
3407
3408        /**
3409         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
3410         * boolean (1 or 0).
3411         */
3412        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
3413
3414        /** @hide */
3415        public static final Validator DTMF_TONE_WHEN_DIALING_VALIDATOR = sBooleanValidator;
3416
3417        /**
3418         * CDMA only settings
3419         * DTMF tone type played by the dialer when dialing.
3420         *                 0 = Normal
3421         *                 1 = Long
3422         */
3423        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
3424
3425        /** @hide */
3426        public static final Validator DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR = sBooleanValidator;
3427
3428        /**
3429         * Whether the hearing aid is enabled. The value is
3430         * boolean (1 or 0).
3431         * @hide
3432         */
3433        public static final String HEARING_AID = "hearing_aid";
3434
3435        /** @hide */
3436        public static final Validator HEARING_AID_VALIDATOR = sBooleanValidator;
3437
3438        /**
3439         * CDMA only settings
3440         * TTY Mode
3441         * 0 = OFF
3442         * 1 = FULL
3443         * 2 = VCO
3444         * 3 = HCO
3445         * @hide
3446         */
3447        public static final String TTY_MODE = "tty_mode";
3448
3449        /** @hide */
3450        public static final Validator TTY_MODE_VALIDATOR = new InclusiveIntegerRangeValidator(0, 3);
3451
3452        /**
3453         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
3454         * boolean (1 or 0).
3455         */
3456        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
3457
3458        /** @hide */
3459        public static final Validator SOUND_EFFECTS_ENABLED_VALIDATOR = sBooleanValidator;
3460
3461        /**
3462         * Whether the haptic feedback (long presses, ...) are enabled. The value is
3463         * boolean (1 or 0).
3464         */
3465        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
3466
3467        /** @hide */
3468        public static final Validator HAPTIC_FEEDBACK_ENABLED_VALIDATOR = sBooleanValidator;
3469
3470        /**
3471         * @deprecated Each application that shows web suggestions should have its own
3472         * setting for this.
3473         */
3474        @Deprecated
3475        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
3476
3477        /** @hide */
3478        public static final Validator SHOW_WEB_SUGGESTIONS_VALIDATOR = sBooleanValidator;
3479
3480        /**
3481         * Whether the notification LED should repeatedly flash when a notification is
3482         * pending. The value is boolean (1 or 0).
3483         * @hide
3484         */
3485        public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse";
3486
3487        /** @hide */
3488        public static final Validator NOTIFICATION_LIGHT_PULSE_VALIDATOR = sBooleanValidator;
3489
3490        /**
3491         * Show pointer location on screen?
3492         * 0 = no
3493         * 1 = yes
3494         * @hide
3495         */
3496        public static final String POINTER_LOCATION = "pointer_location";
3497
3498        /** @hide */
3499        public static final Validator POINTER_LOCATION_VALIDATOR = sBooleanValidator;
3500
3501        /**
3502         * Show touch positions on screen?
3503         * 0 = no
3504         * 1 = yes
3505         * @hide
3506         */
3507        public static final String SHOW_TOUCHES = "show_touches";
3508
3509        /** @hide */
3510        public static final Validator SHOW_TOUCHES_VALIDATOR = sBooleanValidator;
3511
3512        /**
3513         * Log raw orientation data from
3514         * {@link com.android.server.policy.WindowOrientationListener} for use with the
3515         * orientationplot.py tool.
3516         * 0 = no
3517         * 1 = yes
3518         * @hide
3519         */
3520        public static final String WINDOW_ORIENTATION_LISTENER_LOG =
3521                "window_orientation_listener_log";
3522
3523        /** @hide */
3524        public static final Validator WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR = sBooleanValidator;
3525
3526        /**
3527         * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED}
3528         * instead
3529         * @hide
3530         */
3531        @Deprecated
3532        public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED;
3533
3534        /**
3535         * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED}
3536         * instead
3537         * @hide
3538         */
3539        @Deprecated
3540        public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED;
3541
3542        /**
3543         * Whether to play sounds when the keyguard is shown and dismissed.
3544         * @hide
3545         */
3546        public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled";
3547
3548        /** @hide */
3549        public static final Validator LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR = sBooleanValidator;
3550
3551        /**
3552         * Whether the lockscreen should be completely disabled.
3553         * @hide
3554         */
3555        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";
3556
3557        /** @hide */
3558        public static final Validator LOCKSCREEN_DISABLED_VALIDATOR = sBooleanValidator;
3559
3560        /**
3561         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
3562         * instead
3563         * @hide
3564         */
3565        @Deprecated
3566        public static final String LOW_BATTERY_SOUND = Global.LOW_BATTERY_SOUND;
3567
3568        /**
3569         * @deprecated Use {@link android.provider.Settings.Global#DESK_DOCK_SOUND}
3570         * instead
3571         * @hide
3572         */
3573        @Deprecated
3574        public static final String DESK_DOCK_SOUND = Global.DESK_DOCK_SOUND;
3575
3576        /**
3577         * @deprecated Use {@link android.provider.Settings.Global#DESK_UNDOCK_SOUND}
3578         * instead
3579         * @hide
3580         */
3581        @Deprecated
3582        public static final String DESK_UNDOCK_SOUND = Global.DESK_UNDOCK_SOUND;
3583
3584        /**
3585         * @deprecated Use {@link android.provider.Settings.Global#CAR_DOCK_SOUND}
3586         * instead
3587         * @hide
3588         */
3589        @Deprecated
3590        public static final String CAR_DOCK_SOUND = Global.CAR_DOCK_SOUND;
3591
3592        /**
3593         * @deprecated Use {@link android.provider.Settings.Global#CAR_UNDOCK_SOUND}
3594         * instead
3595         * @hide
3596         */
3597        @Deprecated
3598        public static final String CAR_UNDOCK_SOUND = Global.CAR_UNDOCK_SOUND;
3599
3600        /**
3601         * @deprecated Use {@link android.provider.Settings.Global#LOCK_SOUND}
3602         * instead
3603         * @hide
3604         */
3605        @Deprecated
3606        public static final String LOCK_SOUND = Global.LOCK_SOUND;
3607
3608        /**
3609         * @deprecated Use {@link android.provider.Settings.Global#UNLOCK_SOUND}
3610         * instead
3611         * @hide
3612         */
3613        @Deprecated
3614        public static final String UNLOCK_SOUND = Global.UNLOCK_SOUND;
3615
3616        /**
3617         * Receive incoming SIP calls?
3618         * 0 = no
3619         * 1 = yes
3620         * @hide
3621         */
3622        public static final String SIP_RECEIVE_CALLS = "sip_receive_calls";
3623
3624        /** @hide */
3625        public static final Validator SIP_RECEIVE_CALLS_VALIDATOR = sBooleanValidator;
3626
3627        /**
3628         * Call Preference String.
3629         * "SIP_ALWAYS" : Always use SIP with network access
3630         * "SIP_ADDRESS_ONLY" : Only if destination is a SIP address
3631         * @hide
3632         */
3633        public static final String SIP_CALL_OPTIONS = "sip_call_options";
3634
3635        /** @hide */
3636        public static final Validator SIP_CALL_OPTIONS_VALIDATOR = new DiscreteValueValidator(
3637                new String[] {"SIP_ALWAYS", "SIP_ADDRESS_ONLY"});
3638
3639        /**
3640         * One of the sip call options: Always use SIP with network access.
3641         * @hide
3642         */
3643        public static final String SIP_ALWAYS = "SIP_ALWAYS";
3644
3645        /** @hide */
3646        public static final Validator SIP_ALWAYS_VALIDATOR = sBooleanValidator;
3647
3648        /**
3649         * One of the sip call options: Only if destination is a SIP address.
3650         * @hide
3651         */
3652        public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY";
3653
3654        /** @hide */
3655        public static final Validator SIP_ADDRESS_ONLY_VALIDATOR = sBooleanValidator;
3656
3657        /**
3658         * @deprecated Use SIP_ALWAYS or SIP_ADDRESS_ONLY instead.  Formerly used to indicate that
3659         * the user should be prompted each time a call is made whether it should be placed using
3660         * SIP.  The {@link com.android.providers.settings.DatabaseHelper} replaces this with
3661         * SIP_ADDRESS_ONLY.
3662         * @hide
3663         */
3664        @Deprecated
3665        public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME";
3666
3667        /** @hide */
3668        public static final Validator SIP_ASK_ME_EACH_TIME_VALIDATOR = sBooleanValidator;
3669
3670        /**
3671         * Pointer speed setting.
3672         * This is an integer value in a range between -7 and +7, so there are 15 possible values.
3673         *   -7 = slowest
3674         *    0 = default speed
3675         *   +7 = fastest
3676         * @hide
3677         */
3678        public static final String POINTER_SPEED = "pointer_speed";
3679
3680        /** @hide */
3681        public static final Validator POINTER_SPEED_VALIDATOR =
3682                new InclusiveFloatRangeValidator(-7, 7);
3683
3684        /**
3685         * Whether lock-to-app will be triggered by long-press on recents.
3686         * @hide
3687         */
3688        public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled";
3689
3690        /** @hide */
3691        public static final Validator LOCK_TO_APP_ENABLED_VALIDATOR = sBooleanValidator;
3692
3693        /**
3694         * I am the lolrus.
3695         * <p>
3696         * Nonzero values indicate that the user has a bukkit.
3697         * Backward-compatible with <code>PrefGetPreference(prefAllowEasterEggs)</code>.
3698         * @hide
3699         */
3700        public static final String EGG_MODE = "egg_mode";
3701
3702        /** @hide */
3703        public static final Validator EGG_MODE_VALIDATOR = new Validator() {
3704            @Override
3705            public boolean validate(String value) {
3706                try {
3707                    return Long.parseLong(value) >= 0;
3708                } catch (NumberFormatException e) {
3709                    return false;
3710                }
3711            }
3712        };
3713
3714        /**
3715         * IMPORTANT: If you add a new public settings you also have to add it to
3716         * PUBLIC_SETTINGS below. If the new setting is hidden you have to add
3717         * it to PRIVATE_SETTINGS below. Also add a validator that can validate
3718         * the setting value. See an example above.
3719         */
3720
3721        /**
3722         * Settings to backup. This is here so that it's in the same place as the settings
3723         * keys and easy to update.
3724         *
3725         * NOTE: Settings are backed up and restored in the order they appear
3726         *       in this array. If you have one setting depending on another,
3727         *       make sure that they are ordered appropriately.
3728         *
3729         * @hide
3730         */
3731        public static final String[] SETTINGS_TO_BACKUP = {
3732            STAY_ON_WHILE_PLUGGED_IN,   // moved to global
3733            WIFI_USE_STATIC_IP,
3734            WIFI_STATIC_IP,
3735            WIFI_STATIC_GATEWAY,
3736            WIFI_STATIC_NETMASK,
3737            WIFI_STATIC_DNS1,
3738            WIFI_STATIC_DNS2,
3739            BLUETOOTH_DISCOVERABILITY,
3740            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
3741            FONT_SCALE,
3742            DIM_SCREEN,
3743            SCREEN_OFF_TIMEOUT,
3744            SCREEN_BRIGHTNESS,
3745            SCREEN_BRIGHTNESS_MODE,
3746            SCREEN_AUTO_BRIGHTNESS_ADJ,
3747            VIBRATE_INPUT_DEVICES,
3748            MODE_RINGER_STREAMS_AFFECTED,
3749            TEXT_AUTO_REPLACE,
3750            TEXT_AUTO_CAPS,
3751            TEXT_AUTO_PUNCTUATE,
3752            TEXT_SHOW_PASSWORD,
3753            AUTO_TIME,                  // moved to global
3754            AUTO_TIME_ZONE,             // moved to global
3755            TIME_12_24,
3756            DATE_FORMAT,
3757            DTMF_TONE_WHEN_DIALING,
3758            DTMF_TONE_TYPE_WHEN_DIALING,
3759            HEARING_AID,
3760            TTY_MODE,
3761            MASTER_MONO,
3762            SOUND_EFFECTS_ENABLED,
3763            HAPTIC_FEEDBACK_ENABLED,
3764            POWER_SOUNDS_ENABLED,       // moved to global
3765            DOCK_SOUNDS_ENABLED,        // moved to global
3766            LOCKSCREEN_SOUNDS_ENABLED,
3767            SHOW_WEB_SUGGESTIONS,
3768            SIP_CALL_OPTIONS,
3769            SIP_RECEIVE_CALLS,
3770            POINTER_SPEED,
3771            VIBRATE_WHEN_RINGING,
3772            RINGTONE,
3773            LOCK_TO_APP_ENABLED,
3774            NOTIFICATION_SOUND,
3775            ACCELEROMETER_ROTATION
3776        };
3777
3778        /**
3779         * These are all public system settings
3780         *
3781         * @hide
3782         */
3783        public static final Set<String> PUBLIC_SETTINGS = new ArraySet<>();
3784        static {
3785            PUBLIC_SETTINGS.add(END_BUTTON_BEHAVIOR);
3786            PUBLIC_SETTINGS.add(WIFI_USE_STATIC_IP);
3787            PUBLIC_SETTINGS.add(WIFI_STATIC_IP);
3788            PUBLIC_SETTINGS.add(WIFI_STATIC_GATEWAY);
3789            PUBLIC_SETTINGS.add(WIFI_STATIC_NETMASK);
3790            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS1);
3791            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS2);
3792            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY);
3793            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY_TIMEOUT);
3794            PUBLIC_SETTINGS.add(NEXT_ALARM_FORMATTED);
3795            PUBLIC_SETTINGS.add(FONT_SCALE);
3796            PUBLIC_SETTINGS.add(DIM_SCREEN);
3797            PUBLIC_SETTINGS.add(SCREEN_OFF_TIMEOUT);
3798            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS);
3799            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS_MODE);
3800            PUBLIC_SETTINGS.add(MODE_RINGER_STREAMS_AFFECTED);
3801            PUBLIC_SETTINGS.add(MUTE_STREAMS_AFFECTED);
3802            PUBLIC_SETTINGS.add(VIBRATE_ON);
3803            PUBLIC_SETTINGS.add(VOLUME_RING);
3804            PUBLIC_SETTINGS.add(VOLUME_SYSTEM);
3805            PUBLIC_SETTINGS.add(VOLUME_VOICE);
3806            PUBLIC_SETTINGS.add(VOLUME_MUSIC);
3807            PUBLIC_SETTINGS.add(VOLUME_ALARM);
3808            PUBLIC_SETTINGS.add(VOLUME_NOTIFICATION);
3809            PUBLIC_SETTINGS.add(VOLUME_BLUETOOTH_SCO);
3810            PUBLIC_SETTINGS.add(RINGTONE);
3811            PUBLIC_SETTINGS.add(NOTIFICATION_SOUND);
3812            PUBLIC_SETTINGS.add(ALARM_ALERT);
3813            PUBLIC_SETTINGS.add(TEXT_AUTO_REPLACE);
3814            PUBLIC_SETTINGS.add(TEXT_AUTO_CAPS);
3815            PUBLIC_SETTINGS.add(TEXT_AUTO_PUNCTUATE);
3816            PUBLIC_SETTINGS.add(TEXT_SHOW_PASSWORD);
3817            PUBLIC_SETTINGS.add(SHOW_GTALK_SERVICE_STATUS);
3818            PUBLIC_SETTINGS.add(WALLPAPER_ACTIVITY);
3819            PUBLIC_SETTINGS.add(TIME_12_24);
3820            PUBLIC_SETTINGS.add(DATE_FORMAT);
3821            PUBLIC_SETTINGS.add(SETUP_WIZARD_HAS_RUN);
3822            PUBLIC_SETTINGS.add(ACCELEROMETER_ROTATION);
3823            PUBLIC_SETTINGS.add(USER_ROTATION);
3824            PUBLIC_SETTINGS.add(DTMF_TONE_WHEN_DIALING);
3825            PUBLIC_SETTINGS.add(SOUND_EFFECTS_ENABLED);
3826            PUBLIC_SETTINGS.add(HAPTIC_FEEDBACK_ENABLED);
3827            PUBLIC_SETTINGS.add(SHOW_WEB_SUGGESTIONS);
3828            PUBLIC_SETTINGS.add(VIBRATE_WHEN_RINGING);
3829        }
3830
3831        /**
3832         * These are all hidden system settings.
3833         *
3834         * @hide
3835         */
3836        public static final Set<String> PRIVATE_SETTINGS = new ArraySet<>();
3837        static {
3838            PRIVATE_SETTINGS.add(WIFI_USE_STATIC_IP);
3839            PRIVATE_SETTINGS.add(END_BUTTON_BEHAVIOR);
3840            PRIVATE_SETTINGS.add(ADVANCED_SETTINGS);
3841            PRIVATE_SETTINGS.add(SCREEN_AUTO_BRIGHTNESS_ADJ);
3842            PRIVATE_SETTINGS.add(VIBRATE_INPUT_DEVICES);
3843            PRIVATE_SETTINGS.add(VOLUME_MASTER);
3844            PRIVATE_SETTINGS.add(MASTER_MONO);
3845            PRIVATE_SETTINGS.add(NOTIFICATIONS_USE_RING_VOLUME);
3846            PRIVATE_SETTINGS.add(VIBRATE_IN_SILENT);
3847            PRIVATE_SETTINGS.add(MEDIA_BUTTON_RECEIVER);
3848            PRIVATE_SETTINGS.add(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY);
3849            PRIVATE_SETTINGS.add(DTMF_TONE_TYPE_WHEN_DIALING);
3850            PRIVATE_SETTINGS.add(HEARING_AID);
3851            PRIVATE_SETTINGS.add(TTY_MODE);
3852            PRIVATE_SETTINGS.add(NOTIFICATION_LIGHT_PULSE);
3853            PRIVATE_SETTINGS.add(POINTER_LOCATION);
3854            PRIVATE_SETTINGS.add(SHOW_TOUCHES);
3855            PRIVATE_SETTINGS.add(WINDOW_ORIENTATION_LISTENER_LOG);
3856            PRIVATE_SETTINGS.add(POWER_SOUNDS_ENABLED);
3857            PRIVATE_SETTINGS.add(DOCK_SOUNDS_ENABLED);
3858            PRIVATE_SETTINGS.add(LOCKSCREEN_SOUNDS_ENABLED);
3859            PRIVATE_SETTINGS.add(LOCKSCREEN_DISABLED);
3860            PRIVATE_SETTINGS.add(LOW_BATTERY_SOUND);
3861            PRIVATE_SETTINGS.add(DESK_DOCK_SOUND);
3862            PRIVATE_SETTINGS.add(DESK_UNDOCK_SOUND);
3863            PRIVATE_SETTINGS.add(CAR_DOCK_SOUND);
3864            PRIVATE_SETTINGS.add(CAR_UNDOCK_SOUND);
3865            PRIVATE_SETTINGS.add(LOCK_SOUND);
3866            PRIVATE_SETTINGS.add(UNLOCK_SOUND);
3867            PRIVATE_SETTINGS.add(SIP_RECEIVE_CALLS);
3868            PRIVATE_SETTINGS.add(SIP_CALL_OPTIONS);
3869            PRIVATE_SETTINGS.add(SIP_ALWAYS);
3870            PRIVATE_SETTINGS.add(SIP_ADDRESS_ONLY);
3871            PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME);
3872            PRIVATE_SETTINGS.add(POINTER_SPEED);
3873            PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED);
3874            PRIVATE_SETTINGS.add(EGG_MODE);
3875        }
3876
3877        /**
3878         * These are all public system settings
3879         *
3880         * @hide
3881         */
3882        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
3883        static {
3884            VALIDATORS.put(END_BUTTON_BEHAVIOR,END_BUTTON_BEHAVIOR_VALIDATOR);
3885            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
3886            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY, BLUETOOTH_DISCOVERABILITY_VALIDATOR);
3887            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY_TIMEOUT,
3888                    BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR);
3889            VALIDATORS.put(NEXT_ALARM_FORMATTED, NEXT_ALARM_FORMATTED_VALIDATOR);
3890            VALIDATORS.put(FONT_SCALE, FONT_SCALE_VALIDATOR);
3891            VALIDATORS.put(DIM_SCREEN, DIM_SCREEN_VALIDATOR);
3892            VALIDATORS.put(SCREEN_OFF_TIMEOUT, SCREEN_OFF_TIMEOUT_VALIDATOR);
3893            VALIDATORS.put(SCREEN_BRIGHTNESS, SCREEN_BRIGHTNESS_VALIDATOR);
3894            VALIDATORS.put(SCREEN_BRIGHTNESS_FOR_VR, SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR);
3895            VALIDATORS.put(SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_VALIDATOR);
3896            VALIDATORS.put(MODE_RINGER_STREAMS_AFFECTED, MODE_RINGER_STREAMS_AFFECTED_VALIDATOR);
3897            VALIDATORS.put(MUTE_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED_VALIDATOR);
3898            VALIDATORS.put(VIBRATE_ON, VIBRATE_ON_VALIDATOR);
3899            VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR);
3900            VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR);
3901            VALIDATORS.put(ALARM_ALERT, ALARM_ALERT_VALIDATOR);
3902            VALIDATORS.put(TEXT_AUTO_REPLACE, TEXT_AUTO_REPLACE_VALIDATOR);
3903            VALIDATORS.put(TEXT_AUTO_CAPS, TEXT_AUTO_CAPS_VALIDATOR);
3904            VALIDATORS.put(TEXT_AUTO_PUNCTUATE, TEXT_AUTO_PUNCTUATE_VALIDATOR);
3905            VALIDATORS.put(TEXT_SHOW_PASSWORD, TEXT_SHOW_PASSWORD_VALIDATOR);
3906            VALIDATORS.put(SHOW_GTALK_SERVICE_STATUS, SHOW_GTALK_SERVICE_STATUS_VALIDATOR);
3907            VALIDATORS.put(WALLPAPER_ACTIVITY, WALLPAPER_ACTIVITY_VALIDATOR);
3908            VALIDATORS.put(TIME_12_24, TIME_12_24_VALIDATOR);
3909            VALIDATORS.put(DATE_FORMAT, DATE_FORMAT_VALIDATOR);
3910            VALIDATORS.put(SETUP_WIZARD_HAS_RUN, SETUP_WIZARD_HAS_RUN_VALIDATOR);
3911            VALIDATORS.put(ACCELEROMETER_ROTATION, ACCELEROMETER_ROTATION_VALIDATOR);
3912            VALIDATORS.put(USER_ROTATION, USER_ROTATION_VALIDATOR);
3913            VALIDATORS.put(DTMF_TONE_WHEN_DIALING, DTMF_TONE_WHEN_DIALING_VALIDATOR);
3914            VALIDATORS.put(SOUND_EFFECTS_ENABLED, SOUND_EFFECTS_ENABLED_VALIDATOR);
3915            VALIDATORS.put(HAPTIC_FEEDBACK_ENABLED, HAPTIC_FEEDBACK_ENABLED_VALIDATOR);
3916            VALIDATORS.put(SHOW_WEB_SUGGESTIONS, SHOW_WEB_SUGGESTIONS_VALIDATOR);
3917            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
3918            VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR);
3919            VALIDATORS.put(ADVANCED_SETTINGS, ADVANCED_SETTINGS_VALIDATOR);
3920            VALIDATORS.put(SCREEN_AUTO_BRIGHTNESS_ADJ, SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR);
3921            VALIDATORS.put(VIBRATE_INPUT_DEVICES, VIBRATE_INPUT_DEVICES_VALIDATOR);
3922            VALIDATORS.put(MASTER_MONO, MASTER_MONO_VALIDATOR);
3923            VALIDATORS.put(NOTIFICATIONS_USE_RING_VOLUME, NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR);
3924            VALIDATORS.put(VIBRATE_IN_SILENT, VIBRATE_IN_SILENT_VALIDATOR);
3925            VALIDATORS.put(MEDIA_BUTTON_RECEIVER, MEDIA_BUTTON_RECEIVER_VALIDATOR);
3926            VALIDATORS.put(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY,
3927                    HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR);
3928            VALIDATORS.put(VIBRATE_WHEN_RINGING, VIBRATE_WHEN_RINGING_VALIDATOR);
3929            VALIDATORS.put(DTMF_TONE_TYPE_WHEN_DIALING, DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR);
3930            VALIDATORS.put(HEARING_AID, HEARING_AID_VALIDATOR);
3931            VALIDATORS.put(TTY_MODE, TTY_MODE_VALIDATOR);
3932            VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, NOTIFICATION_LIGHT_PULSE_VALIDATOR);
3933            VALIDATORS.put(POINTER_LOCATION, POINTER_LOCATION_VALIDATOR);
3934            VALIDATORS.put(SHOW_TOUCHES, SHOW_TOUCHES_VALIDATOR);
3935            VALIDATORS.put(WINDOW_ORIENTATION_LISTENER_LOG,
3936                    WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR);
3937            VALIDATORS.put(LOCKSCREEN_SOUNDS_ENABLED, LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR);
3938            VALIDATORS.put(LOCKSCREEN_DISABLED, LOCKSCREEN_DISABLED_VALIDATOR);
3939            VALIDATORS.put(SIP_RECEIVE_CALLS, SIP_RECEIVE_CALLS_VALIDATOR);
3940            VALIDATORS.put(SIP_CALL_OPTIONS, SIP_CALL_OPTIONS_VALIDATOR);
3941            VALIDATORS.put(SIP_ALWAYS, SIP_ALWAYS_VALIDATOR);
3942            VALIDATORS.put(SIP_ADDRESS_ONLY, SIP_ADDRESS_ONLY_VALIDATOR);
3943            VALIDATORS.put(SIP_ASK_ME_EACH_TIME, SIP_ASK_ME_EACH_TIME_VALIDATOR);
3944            VALIDATORS.put(POINTER_SPEED, POINTER_SPEED_VALIDATOR);
3945            VALIDATORS.put(LOCK_TO_APP_ENABLED, LOCK_TO_APP_ENABLED_VALIDATOR);
3946            VALIDATORS.put(EGG_MODE, EGG_MODE_VALIDATOR);
3947            VALIDATORS.put(WIFI_STATIC_IP, WIFI_STATIC_IP_VALIDATOR);
3948            VALIDATORS.put(WIFI_STATIC_GATEWAY, WIFI_STATIC_GATEWAY_VALIDATOR);
3949            VALIDATORS.put(WIFI_STATIC_NETMASK, WIFI_STATIC_NETMASK_VALIDATOR);
3950            VALIDATORS.put(WIFI_STATIC_DNS1, WIFI_STATIC_DNS1_VALIDATOR);
3951            VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR);
3952        }
3953
3954        /**
3955         * These entries are considered common between the personal and the managed profile,
3956         * since the managed profile doesn't get to change them.
3957         */
3958        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
3959        static {
3960            CLONE_TO_MANAGED_PROFILE.add(DATE_FORMAT);
3961            CLONE_TO_MANAGED_PROFILE.add(HAPTIC_FEEDBACK_ENABLED);
3962            CLONE_TO_MANAGED_PROFILE.add(SOUND_EFFECTS_ENABLED);
3963            CLONE_TO_MANAGED_PROFILE.add(TEXT_SHOW_PASSWORD);
3964            CLONE_TO_MANAGED_PROFILE.add(TIME_12_24);
3965        }
3966
3967        /** @hide */
3968        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
3969            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
3970        }
3971
3972        /**
3973         * These entries should be cloned from this profile's parent only if the dependency's
3974         * value is true ("1")
3975         *
3976         * Note: the dependencies must be Secure settings
3977         *
3978         * @hide
3979         */
3980        public static final Map<String, String> CLONE_FROM_PARENT_ON_VALUE = new ArrayMap<>();
3981        static {
3982            CLONE_FROM_PARENT_ON_VALUE.put(RINGTONE, Secure.SYNC_PARENT_SOUNDS);
3983            CLONE_FROM_PARENT_ON_VALUE.put(NOTIFICATION_SOUND, Secure.SYNC_PARENT_SOUNDS);
3984            CLONE_FROM_PARENT_ON_VALUE.put(ALARM_ALERT, Secure.SYNC_PARENT_SOUNDS);
3985        }
3986
3987        /** @hide */
3988        public static void getCloneFromParentOnValueSettings(Map<String, String> outMap) {
3989            outMap.putAll(CLONE_FROM_PARENT_ON_VALUE);
3990        }
3991
3992        /**
3993         * When to use Wi-Fi calling
3994         *
3995         * @see android.telephony.TelephonyManager.WifiCallingChoices
3996         * @hide
3997         */
3998        public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls";
3999
4000        // Settings moved to Settings.Secure
4001
4002        /**
4003         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED}
4004         * instead
4005         */
4006        @Deprecated
4007        public static final String ADB_ENABLED = Global.ADB_ENABLED;
4008
4009        /**
4010         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
4011         */
4012        @Deprecated
4013        public static final String ANDROID_ID = Secure.ANDROID_ID;
4014
4015        /**
4016         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
4017         */
4018        @Deprecated
4019        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
4020
4021        /**
4022         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
4023         */
4024        @Deprecated
4025        public static final String DATA_ROAMING = Global.DATA_ROAMING;
4026
4027        /**
4028         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
4029         */
4030        @Deprecated
4031        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
4032
4033        /**
4034         * @deprecated Use {@link android.provider.Settings.Global#HTTP_PROXY} instead
4035         */
4036        @Deprecated
4037        public static final String HTTP_PROXY = Global.HTTP_PROXY;
4038
4039        /**
4040         * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
4041         */
4042        @Deprecated
4043        public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
4044
4045        /**
4046         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
4047         * instead
4048         */
4049        @Deprecated
4050        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
4051
4052        /**
4053         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
4054         */
4055        @Deprecated
4056        public static final String LOGGING_ID = Secure.LOGGING_ID;
4057
4058        /**
4059         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
4060         */
4061        @Deprecated
4062        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
4063
4064        /**
4065         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
4066         * instead
4067         */
4068        @Deprecated
4069        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
4070
4071        /**
4072         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
4073         * instead
4074         */
4075        @Deprecated
4076        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
4077
4078        /**
4079         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
4080         * instead
4081         */
4082        @Deprecated
4083        public static final String PARENTAL_CONTROL_REDIRECT_URL =
4084            Secure.PARENTAL_CONTROL_REDIRECT_URL;
4085
4086        /**
4087         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
4088         */
4089        @Deprecated
4090        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
4091
4092        /**
4093         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
4094         */
4095        @Deprecated
4096        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
4097
4098        /**
4099         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
4100         */
4101        @Deprecated
4102        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
4103
4104       /**
4105         * @deprecated Use
4106         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
4107         */
4108        @Deprecated
4109        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
4110
4111        /**
4112         * @deprecated Use
4113         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
4114         */
4115        @Deprecated
4116        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
4117                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
4118
4119        /**
4120         * @deprecated Use
4121         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
4122         */
4123        @Deprecated
4124        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
4125                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
4126
4127        /**
4128         * @deprecated Use
4129         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
4130         */
4131        @Deprecated
4132        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
4133                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
4134
4135        /**
4136         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
4137         * instead
4138         */
4139        @Deprecated
4140        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
4141
4142        /**
4143         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead
4144         */
4145        @Deprecated
4146        public static final String WIFI_ON = Global.WIFI_ON;
4147
4148        /**
4149         * @deprecated Use
4150         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
4151         * instead
4152         */
4153        @Deprecated
4154        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
4155                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
4156
4157        /**
4158         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
4159         */
4160        @Deprecated
4161        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
4162
4163        /**
4164         * @deprecated Use
4165         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
4166         */
4167        @Deprecated
4168        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
4169                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
4170
4171        /**
4172         * @deprecated Use
4173         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
4174         */
4175        @Deprecated
4176        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
4177                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
4178
4179        /**
4180         * @deprecated Use
4181         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
4182         * instead
4183         */
4184        @Deprecated
4185        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
4186                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
4187
4188        /**
4189         * @deprecated Use
4190         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
4191         */
4192        @Deprecated
4193        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
4194            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
4195
4196        /**
4197         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
4198         * instead
4199         */
4200        @Deprecated
4201        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
4202
4203        /**
4204         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
4205         */
4206        @Deprecated
4207        public static final String WIFI_WATCHDOG_ON = Global.WIFI_WATCHDOG_ON;
4208
4209        /**
4210         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
4211         */
4212        @Deprecated
4213        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
4214
4215        /**
4216         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
4217         * instead
4218         */
4219        @Deprecated
4220        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
4221
4222        /**
4223         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
4224         * instead
4225         */
4226        @Deprecated
4227        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
4228            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
4229
4230        /**
4231         * Checks if the specified app can modify system settings. As of API
4232         * level 23, an app cannot modify system settings unless it declares the
4233         * {@link android.Manifest.permission#WRITE_SETTINGS}
4234         * permission in its manifest, <em>and</em> the user specifically grants
4235         * the app this capability. To prompt the user to grant this approval,
4236         * the app must send an intent with the action {@link
4237         * android.provider.Settings#ACTION_MANAGE_WRITE_SETTINGS}, which causes
4238         * the system to display a permission management screen.
4239         *
4240         * @param context App context.
4241         * @return true if the calling app can write to system settings, false otherwise
4242         */
4243        public static boolean canWrite(Context context) {
4244            return isCallingPackageAllowedToWriteSettings(context, Process.myUid(),
4245                    context.getOpPackageName(), false);
4246        }
4247    }
4248
4249    /**
4250     * Secure system settings, containing system preferences that applications
4251     * can read but are not allowed to write.  These are for preferences that
4252     * the user must explicitly modify through the system UI or specialized
4253     * APIs for those values, not modified directly by applications.
4254     */
4255    public static final class Secure extends NameValueTable {
4256        /**
4257         * The content:// style URL for this table
4258         */
4259        public static final Uri CONTENT_URI =
4260            Uri.parse("content://" + AUTHORITY + "/secure");
4261
4262        private static final ContentProviderHolder sProviderHolder =
4263                new ContentProviderHolder(CONTENT_URI);
4264
4265        // Populated lazily, guarded by class object:
4266        private static final NameValueCache sNameValueCache = new NameValueCache(
4267                CONTENT_URI,
4268                CALL_METHOD_GET_SECURE,
4269                CALL_METHOD_PUT_SECURE,
4270                sProviderHolder);
4271
4272        private static ILockSettings sLockSettings = null;
4273
4274        private static boolean sIsSystemProcess;
4275        private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
4276        private static final HashSet<String> MOVED_TO_GLOBAL;
4277        static {
4278            MOVED_TO_LOCK_SETTINGS = new HashSet<>(3);
4279            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
4280            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
4281            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
4282
4283            MOVED_TO_GLOBAL = new HashSet<>();
4284            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
4285            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
4286            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
4287            MOVED_TO_GLOBAL.add(Settings.Global.BUGREPORT_IN_POWER_MENU);
4288            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
4289            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
4290            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
4291            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE);
4292            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI);
4293            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
4294            MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
4295            MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
4296            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
4297            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
4298            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
4299            MOVED_TO_GLOBAL.add(Settings.Global.MOBILE_DATA);
4300            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION);
4301            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_DELETE_AGE);
4302            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES);
4303            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE);
4304            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_ENABLED);
4305            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES);
4306            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_POLL_INTERVAL);
4307            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_SAMPLE_ENABLED);
4308            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE);
4309            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION);
4310            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_DELETE_AGE);
4311            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES);
4312            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_ROTATE_AGE);
4313            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION);
4314            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE);
4315            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES);
4316            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE);
4317            MOVED_TO_GLOBAL.add(Settings.Global.NETWORK_PREFERENCE);
4318            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_DIFF);
4319            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_SPACING);
4320            MOVED_TO_GLOBAL.add(Settings.Global.NTP_SERVER);
4321            MOVED_TO_GLOBAL.add(Settings.Global.NTP_TIMEOUT);
4322            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT);
4323            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS);
4324            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT);
4325            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS);
4326            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT);
4327            MOVED_TO_GLOBAL.add(Settings.Global.SAMPLING_PROFILER_MS);
4328            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
4329            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST);
4330            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL);
4331            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_APN);
4332            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_REQUIRED);
4333            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_SUPPORTED);
4334            MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED);
4335            MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL);
4336            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE);
4337            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS);
4338            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND);
4339            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS);
4340            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT);
4341            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS);
4342            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
4343            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
4344            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT);
4345            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
4346            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
4347            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
4348            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
4349            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
4350            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_VERBOSE_LOGGING_ENABLED);
4351            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ENHANCED_AUTO_JOIN);
4352            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORK_SHOW_RSSI);
4353            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
4354            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
4355            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
4356            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_ENABLE);
4357            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT);
4358            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE);
4359            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS);
4360            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS);
4361            MOVED_TO_GLOBAL.add(Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS);
4362            MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
4363            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD);
4364            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_THRESHOLD);
4365            MOVED_TO_GLOBAL.add(Settings.Global.SEND_ACTION_APP_ERROR);
4366            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_AGE_SECONDS);
4367            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_MAX_FILES);
4368            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_KB);
4369            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_PERCENT);
4370            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_RESERVE_PERCENT);
4371            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_TAG_PREFIX);
4372            MOVED_TO_GLOBAL.add(Settings.Global.ERROR_LOGCAT_PREFIX);
4373            MOVED_TO_GLOBAL.add(Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL);
4374            MOVED_TO_GLOBAL.add(Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD);
4375            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE);
4376            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES);
4377            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES);
4378            MOVED_TO_GLOBAL.add(Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS);
4379            MOVED_TO_GLOBAL.add(Settings.Global.CONNECTIVITY_CHANGE_DELAY);
4380            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED);
4381            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_SERVER);
4382            MOVED_TO_GLOBAL.add(Settings.Global.NSD_ON);
4383            MOVED_TO_GLOBAL.add(Settings.Global.SET_INSTALL_LOCATION);
4384            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_INSTALL_LOCATION);
4385            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY);
4386            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY);
4387            MOVED_TO_GLOBAL.add(Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT);
4388            MOVED_TO_GLOBAL.add(Settings.Global.HTTP_PROXY);
4389            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_HOST);
4390            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_PORT);
4391            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
4392            MOVED_TO_GLOBAL.add(Settings.Global.SET_GLOBAL_HTTP_PROXY);
4393            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_DNS_SERVER);
4394            MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_NETWORK_MODE);
4395            MOVED_TO_GLOBAL.add(Settings.Global.WEBVIEW_DATA_REDUCTION_PROXY_KEY);
4396        }
4397
4398        /** @hide */
4399        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
4400            outKeySet.addAll(MOVED_TO_GLOBAL);
4401        }
4402
4403        /**
4404         * Look up a name in the database.
4405         * @param resolver to access the database with
4406         * @param name to look up in the table
4407         * @return the corresponding value, or null if not present
4408         */
4409        public static String getString(ContentResolver resolver, String name) {
4410            return getStringForUser(resolver, name, UserHandle.myUserId());
4411        }
4412
4413        /** @hide */
4414        public static String getStringForUser(ContentResolver resolver, String name,
4415                int userHandle) {
4416            if (MOVED_TO_GLOBAL.contains(name)) {
4417                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
4418                        + " to android.provider.Settings.Global.");
4419                return Global.getStringForUser(resolver, name, userHandle);
4420            }
4421
4422            if (MOVED_TO_LOCK_SETTINGS.contains(name)) {
4423                synchronized (Secure.class) {
4424                    if (sLockSettings == null) {
4425                        sLockSettings = ILockSettings.Stub.asInterface(
4426                                (IBinder) ServiceManager.getService("lock_settings"));
4427                        sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
4428                    }
4429                }
4430                if (sLockSettings != null && !sIsSystemProcess) {
4431                    // No context; use the ActivityThread's context as an approximation for
4432                    // determining the target API level.
4433                    Application application = ActivityThread.currentApplication();
4434
4435                    boolean isPreMnc = application != null
4436                            && application.getApplicationInfo() != null
4437                            && application.getApplicationInfo().targetSdkVersion
4438                            <= VERSION_CODES.LOLLIPOP_MR1;
4439                    if (isPreMnc) {
4440                        try {
4441                            return sLockSettings.getString(name, "0", userHandle);
4442                        } catch (RemoteException re) {
4443                            // Fall through
4444                        }
4445                    } else {
4446                        throw new SecurityException("Settings.Secure." + name
4447                                + " is deprecated and no longer accessible."
4448                                + " See API documentation for potential replacements.");
4449                    }
4450                }
4451            }
4452
4453            return sNameValueCache.getStringForUser(resolver, name, userHandle);
4454        }
4455
4456        /**
4457         * Store a name/value pair into the database.
4458         * @param resolver to access the database with
4459         * @param name to store
4460         * @param value to associate with the name
4461         * @return true if the value was set, false on database errors
4462         */
4463        public static boolean putString(ContentResolver resolver, String name, String value) {
4464            return putStringForUser(resolver, name, value, UserHandle.myUserId());
4465        }
4466
4467        /** @hide */
4468        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
4469                int userHandle) {
4470            return putStringForUser(resolver, name, value, null, false, userHandle);
4471        }
4472
4473        /** @hide */
4474        public static boolean putStringForUser(@NonNull ContentResolver resolver,
4475                @NonNull String name, @Nullable String value, @Nullable String tag,
4476                boolean makeDefault, @UserIdInt int userHandle) {
4477            if (LOCATION_MODE.equals(name)) {
4478                // Map LOCATION_MODE to underlying location provider storage API
4479                return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle);
4480            }
4481            if (MOVED_TO_GLOBAL.contains(name)) {
4482                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
4483                        + " to android.provider.Settings.Global");
4484                return Global.putStringForUser(resolver, name, value,
4485                        tag, makeDefault, userHandle);
4486            }
4487            return sNameValueCache.putStringForUser(resolver, name, value, tag,
4488                    makeDefault, userHandle);
4489        }
4490
4491        /**
4492         * Store a name/value pair into the database.
4493         * <p>
4494         * The method takes an optional tag to associate with the setting
4495         * which can be used to clear only settings made by your package and
4496         * associated with this tag by passing the tag to {@link
4497         * #resetToDefaults(ContentResolver, String)}. Anyone can override
4498         * the current tag. Also if another package changes the setting
4499         * then the tag will be set to the one specified in the set call
4500         * which can be null. Also any of the settings setters that do not
4501         * take a tag as an argument effectively clears the tag.
4502         * </p><p>
4503         * For example, if you set settings A and B with tags T1 and T2 and
4504         * another app changes setting A (potentially to the same value), it
4505         * can assign to it a tag T3 (note that now the package that changed
4506         * the setting is not yours). Now if you reset your changes for T1 and
4507         * T2 only setting B will be reset and A not (as it was changed by
4508         * another package) but since A did not change you are in the desired
4509         * initial state. Now if the other app changes the value of A (assuming
4510         * you registered an observer in the beginning) you would detect that
4511         * the setting was changed by another app and handle this appropriately
4512         * (ignore, set back to some value, etc).
4513         * </p><p>
4514         * Also the method takes an argument whether to make the value the
4515         * default for this setting. If the system already specified a default
4516         * value, then the one passed in here will <strong>not</strong>
4517         * be set as the default.
4518         * </p>
4519         *
4520         * @param resolver to access the database with.
4521         * @param name to store.
4522         * @param value to associate with the name.
4523         * @param tag to associate with the setting.
4524         * @param makeDefault whether to make the value the default one.
4525         * @return true if the value was set, false on database errors.
4526         *
4527         * @see #resetToDefaults(ContentResolver, String)
4528         *
4529         * @hide
4530         */
4531        @SystemApi
4532        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
4533        public static boolean putString(@NonNull ContentResolver resolver,
4534                @NonNull String name, @Nullable String value, @Nullable String tag,
4535                boolean makeDefault) {
4536            return putStringForUser(resolver, name, value, tag, makeDefault,
4537                    UserHandle.myUserId());
4538        }
4539
4540        /**
4541         * Reset the settings to their defaults. This would reset <strong>only</strong>
4542         * settings set by the caller's package. Think of it of a way to undo your own
4543         * changes to the global settings. Passing in the optional tag will reset only
4544         * settings changed by your package and associated with this tag.
4545         *
4546         * @param resolver Handle to the content resolver.
4547         * @param tag Optional tag which should be associated with the settings to reset.
4548         *
4549         * @see #putString(ContentResolver, String, String, String, boolean)
4550         *
4551         * @hide
4552         */
4553        @SystemApi
4554        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
4555        public static void resetToDefaults(@NonNull ContentResolver resolver,
4556                @Nullable String tag) {
4557            resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
4558                    UserHandle.myUserId());
4559        }
4560
4561        /**
4562         *
4563         * Reset the settings to their defaults for a given user with a specific mode. The
4564         * optional tag argument is valid only for {@link #RESET_MODE_PACKAGE_DEFAULTS}
4565         * allowing resetting the settings made by a package and associated with the tag.
4566         *
4567         * @param resolver Handle to the content resolver.
4568         * @param tag Optional tag which should be associated with the settings to reset.
4569         * @param mode The reset mode.
4570         * @param userHandle The user for which to reset to defaults.
4571         *
4572         * @see #RESET_MODE_PACKAGE_DEFAULTS
4573         * @see #RESET_MODE_UNTRUSTED_DEFAULTS
4574         * @see #RESET_MODE_UNTRUSTED_CHANGES
4575         * @see #RESET_MODE_TRUSTED_DEFAULTS
4576         *
4577         * @hide
4578         */
4579        public static void resetToDefaultsAsUser(@NonNull ContentResolver resolver,
4580                @Nullable String tag, @ResetMode int mode, @IntRange(from = 0) int userHandle) {
4581            try {
4582                Bundle arg = new Bundle();
4583                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
4584                if (tag != null) {
4585                    arg.putString(CALL_METHOD_TAG_KEY, tag);
4586                }
4587                arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode);
4588                IContentProvider cp = sProviderHolder.getProvider(resolver);
4589                cp.call(resolver.getPackageName(), CALL_METHOD_RESET_SECURE, null, arg);
4590            } catch (RemoteException e) {
4591                Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e);
4592            }
4593        }
4594
4595        /**
4596         * Construct the content URI for a particular name/value pair,
4597         * useful for monitoring changes with a ContentObserver.
4598         * @param name to look up in the table
4599         * @return the corresponding content URI, or null if not present
4600         */
4601        public static Uri getUriFor(String name) {
4602            if (MOVED_TO_GLOBAL.contains(name)) {
4603                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
4604                        + " to android.provider.Settings.Global, returning global URI.");
4605                return Global.getUriFor(Global.CONTENT_URI, name);
4606            }
4607            return getUriFor(CONTENT_URI, name);
4608        }
4609
4610        /**
4611         * Convenience function for retrieving a single secure settings value
4612         * as an integer.  Note that internally setting values are always
4613         * stored as strings; this function converts the string to an integer
4614         * for you.  The default value will be returned if the setting is
4615         * not defined or not an integer.
4616         *
4617         * @param cr The ContentResolver to access.
4618         * @param name The name of the setting to retrieve.
4619         * @param def Value to return if the setting is not defined.
4620         *
4621         * @return The setting's current value, or 'def' if it is not defined
4622         * or not a valid integer.
4623         */
4624        public static int getInt(ContentResolver cr, String name, int def) {
4625            return getIntForUser(cr, name, def, UserHandle.myUserId());
4626        }
4627
4628        /** @hide */
4629        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
4630            if (LOCATION_MODE.equals(name)) {
4631                // Map from to underlying location provider storage API to location mode
4632                return getLocationModeForUser(cr, userHandle);
4633            }
4634            String v = getStringForUser(cr, name, userHandle);
4635            try {
4636                return v != null ? Integer.parseInt(v) : def;
4637            } catch (NumberFormatException e) {
4638                return def;
4639            }
4640        }
4641
4642        /**
4643         * Convenience function for retrieving a single secure settings value
4644         * as an integer.  Note that internally setting values are always
4645         * stored as strings; this function converts the string to an integer
4646         * for you.
4647         * <p>
4648         * This version does not take a default value.  If the setting has not
4649         * been set, or the string value is not a number,
4650         * it throws {@link SettingNotFoundException}.
4651         *
4652         * @param cr The ContentResolver to access.
4653         * @param name The name of the setting to retrieve.
4654         *
4655         * @throws SettingNotFoundException Thrown if a setting by the given
4656         * name can't be found or the setting value is not an integer.
4657         *
4658         * @return The setting's current value.
4659         */
4660        public static int getInt(ContentResolver cr, String name)
4661                throws SettingNotFoundException {
4662            return getIntForUser(cr, name, UserHandle.myUserId());
4663        }
4664
4665        /** @hide */
4666        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
4667                throws SettingNotFoundException {
4668            if (LOCATION_MODE.equals(name)) {
4669                // Map from to underlying location provider storage API to location mode
4670                return getLocationModeForUser(cr, userHandle);
4671            }
4672            String v = getStringForUser(cr, name, userHandle);
4673            try {
4674                return Integer.parseInt(v);
4675            } catch (NumberFormatException e) {
4676                throw new SettingNotFoundException(name);
4677            }
4678        }
4679
4680        /**
4681         * Convenience function for updating a single settings value as an
4682         * integer. This will either create a new entry in the table if the
4683         * given name does not exist, or modify the value of the existing row
4684         * with that name.  Note that internally setting values are always
4685         * stored as strings, so this function converts the given value to a
4686         * string before storing it.
4687         *
4688         * @param cr The ContentResolver to access.
4689         * @param name The name of the setting to modify.
4690         * @param value The new value for the setting.
4691         * @return true if the value was set, false on database errors
4692         */
4693        public static boolean putInt(ContentResolver cr, String name, int value) {
4694            return putIntForUser(cr, name, value, UserHandle.myUserId());
4695        }
4696
4697        /** @hide */
4698        public static boolean putIntForUser(ContentResolver cr, String name, int value,
4699                int userHandle) {
4700            return putStringForUser(cr, name, Integer.toString(value), userHandle);
4701        }
4702
4703        /**
4704         * Convenience function for retrieving a single secure settings value
4705         * as a {@code long}.  Note that internally setting values are always
4706         * stored as strings; this function converts the string to a {@code long}
4707         * for you.  The default value will be returned if the setting is
4708         * not defined or not a {@code long}.
4709         *
4710         * @param cr The ContentResolver to access.
4711         * @param name The name of the setting to retrieve.
4712         * @param def Value to return if the setting is not defined.
4713         *
4714         * @return The setting's current value, or 'def' if it is not defined
4715         * or not a valid {@code long}.
4716         */
4717        public static long getLong(ContentResolver cr, String name, long def) {
4718            return getLongForUser(cr, name, def, UserHandle.myUserId());
4719        }
4720
4721        /** @hide */
4722        public static long getLongForUser(ContentResolver cr, String name, long def,
4723                int userHandle) {
4724            String valString = getStringForUser(cr, name, userHandle);
4725            long value;
4726            try {
4727                value = valString != null ? Long.parseLong(valString) : def;
4728            } catch (NumberFormatException e) {
4729                value = def;
4730            }
4731            return value;
4732        }
4733
4734        /**
4735         * Convenience function for retrieving a single secure settings value
4736         * as a {@code long}.  Note that internally setting values are always
4737         * stored as strings; this function converts the string to a {@code long}
4738         * for you.
4739         * <p>
4740         * This version does not take a default value.  If the setting has not
4741         * been set, or the string value is not a number,
4742         * it throws {@link SettingNotFoundException}.
4743         *
4744         * @param cr The ContentResolver to access.
4745         * @param name The name of the setting to retrieve.
4746         *
4747         * @return The setting's current value.
4748         * @throws SettingNotFoundException Thrown if a setting by the given
4749         * name can't be found or the setting value is not an integer.
4750         */
4751        public static long getLong(ContentResolver cr, String name)
4752                throws SettingNotFoundException {
4753            return getLongForUser(cr, name, UserHandle.myUserId());
4754        }
4755
4756        /** @hide */
4757        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
4758                throws SettingNotFoundException {
4759            String valString = getStringForUser(cr, name, userHandle);
4760            try {
4761                return Long.parseLong(valString);
4762            } catch (NumberFormatException e) {
4763                throw new SettingNotFoundException(name);
4764            }
4765        }
4766
4767        /**
4768         * Convenience function for updating a secure settings value as a long
4769         * integer. This will either create a new entry in the table if the
4770         * given name does not exist, or modify the value of the existing row
4771         * with that name.  Note that internally setting values are always
4772         * stored as strings, so this function converts the given value to a
4773         * string before storing it.
4774         *
4775         * @param cr The ContentResolver to access.
4776         * @param name The name of the setting to modify.
4777         * @param value The new value for the setting.
4778         * @return true if the value was set, false on database errors
4779         */
4780        public static boolean putLong(ContentResolver cr, String name, long value) {
4781            return putLongForUser(cr, name, value, UserHandle.myUserId());
4782        }
4783
4784        /** @hide */
4785        public static boolean putLongForUser(ContentResolver cr, String name, long value,
4786                int userHandle) {
4787            return putStringForUser(cr, name, Long.toString(value), userHandle);
4788        }
4789
4790        /**
4791         * Convenience function for retrieving a single secure settings value
4792         * as a floating point number.  Note that internally setting values are
4793         * always stored as strings; this function converts the string to an
4794         * float for you. The default value will be returned if the setting
4795         * is not defined or not a valid float.
4796         *
4797         * @param cr The ContentResolver to access.
4798         * @param name The name of the setting to retrieve.
4799         * @param def Value to return if the setting is not defined.
4800         *
4801         * @return The setting's current value, or 'def' if it is not defined
4802         * or not a valid float.
4803         */
4804        public static float getFloat(ContentResolver cr, String name, float def) {
4805            return getFloatForUser(cr, name, def, UserHandle.myUserId());
4806        }
4807
4808        /** @hide */
4809        public static float getFloatForUser(ContentResolver cr, String name, float def,
4810                int userHandle) {
4811            String v = getStringForUser(cr, name, userHandle);
4812            try {
4813                return v != null ? Float.parseFloat(v) : def;
4814            } catch (NumberFormatException e) {
4815                return def;
4816            }
4817        }
4818
4819        /**
4820         * Convenience function for retrieving a single secure settings value
4821         * as a float.  Note that internally setting values are always
4822         * stored as strings; this function converts the string to a float
4823         * for you.
4824         * <p>
4825         * This version does not take a default value.  If the setting has not
4826         * been set, or the string value is not a number,
4827         * it throws {@link SettingNotFoundException}.
4828         *
4829         * @param cr The ContentResolver to access.
4830         * @param name The name of the setting to retrieve.
4831         *
4832         * @throws SettingNotFoundException Thrown if a setting by the given
4833         * name can't be found or the setting value is not a float.
4834         *
4835         * @return The setting's current value.
4836         */
4837        public static float getFloat(ContentResolver cr, String name)
4838                throws SettingNotFoundException {
4839            return getFloatForUser(cr, name, UserHandle.myUserId());
4840        }
4841
4842        /** @hide */
4843        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
4844                throws SettingNotFoundException {
4845            String v = getStringForUser(cr, name, userHandle);
4846            if (v == null) {
4847                throw new SettingNotFoundException(name);
4848            }
4849            try {
4850                return Float.parseFloat(v);
4851            } catch (NumberFormatException e) {
4852                throw new SettingNotFoundException(name);
4853            }
4854        }
4855
4856        /**
4857         * Convenience function for updating a single settings value as a
4858         * floating point number. This will either create a new entry in the
4859         * table if the given name does not exist, or modify the value of the
4860         * existing row with that name.  Note that internally setting values
4861         * are always stored as strings, so this function converts the given
4862         * value to a string before storing it.
4863         *
4864         * @param cr The ContentResolver to access.
4865         * @param name The name of the setting to modify.
4866         * @param value The new value for the setting.
4867         * @return true if the value was set, false on database errors
4868         */
4869        public static boolean putFloat(ContentResolver cr, String name, float value) {
4870            return putFloatForUser(cr, name, value, UserHandle.myUserId());
4871        }
4872
4873        /** @hide */
4874        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
4875                int userHandle) {
4876            return putStringForUser(cr, name, Float.toString(value), userHandle);
4877        }
4878
4879        /**
4880         * @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
4881         * instead
4882         */
4883        @Deprecated
4884        public static final String DEVELOPMENT_SETTINGS_ENABLED =
4885                Global.DEVELOPMENT_SETTINGS_ENABLED;
4886
4887        /**
4888         * When the user has enable the option to have a "bug report" command
4889         * in the power menu.
4890         * @deprecated Use {@link android.provider.Settings.Global#BUGREPORT_IN_POWER_MENU} instead
4891         * @hide
4892         */
4893        @Deprecated
4894        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
4895
4896        /**
4897         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
4898         */
4899        @Deprecated
4900        public static final String ADB_ENABLED = Global.ADB_ENABLED;
4901
4902        /**
4903         * Setting to allow mock locations and location provider status to be injected into the
4904         * LocationManager service for testing purposes during application development.  These
4905         * locations and status values  override actual location and status information generated
4906         * by network, gps, or other location providers.
4907         *
4908         * @deprecated This settings is not used anymore.
4909         */
4910        @Deprecated
4911        public static final String ALLOW_MOCK_LOCATION = "mock_location";
4912
4913        /**
4914         * A 64-bit number (as a hex string) that is randomly
4915         * generated when the user first sets up the device and should remain
4916         * constant for the lifetime of the user's device. The value may
4917         * change if a factory reset is performed on the device.
4918         * <p class="note"><strong>Note:</strong> When a device has <a
4919         * href="{@docRoot}about/versions/android-4.2.html#MultipleUsers">multiple users</a>
4920         * (available on certain devices running Android 4.2 or higher), each user appears as a
4921         * completely separate device, so the {@code ANDROID_ID} value is unique to each
4922         * user.</p>
4923         */
4924        public static final String ANDROID_ID = "android_id";
4925
4926        /**
4927         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
4928         */
4929        @Deprecated
4930        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
4931
4932        /**
4933         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
4934         */
4935        @Deprecated
4936        public static final String DATA_ROAMING = Global.DATA_ROAMING;
4937
4938        /**
4939         * Setting to record the input method used by default, holding the ID
4940         * of the desired method.
4941         */
4942        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
4943
4944        /**
4945         * Setting to record the input method subtype used by default, holding the ID
4946         * of the desired method.
4947         */
4948        public static final String SELECTED_INPUT_METHOD_SUBTYPE =
4949                "selected_input_method_subtype";
4950
4951        /**
4952         * Setting to record the history of input method subtype, holding the pair of ID of IME
4953         * and its last used subtype.
4954         * @hide
4955         */
4956        public static final String INPUT_METHODS_SUBTYPE_HISTORY =
4957                "input_methods_subtype_history";
4958
4959        /**
4960         * Setting to record the visibility of input method selector
4961         */
4962        public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
4963                "input_method_selector_visibility";
4964
4965        /**
4966         * The currently selected voice interaction service flattened ComponentName.
4967         * @hide
4968         */
4969        @TestApi
4970        public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
4971
4972        /**
4973         * The currently selected auto-fill service flattened ComponentName.
4974         * @hide
4975         */
4976        @TestApi
4977        public static final String AUTO_FILL_SERVICE = "auto_fill_service";
4978
4979        /**
4980         * bluetooth HCI snoop log configuration
4981         * @hide
4982         */
4983        public static final String BLUETOOTH_HCI_LOG =
4984                "bluetooth_hci_log";
4985
4986        /**
4987         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
4988         */
4989        @Deprecated
4990        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
4991
4992        /**
4993         * Whether the current user has been set up via setup wizard (0 = false, 1 = true)
4994         * @hide
4995         */
4996        public static final String USER_SETUP_COMPLETE = "user_setup_complete";
4997
4998        /**
4999         * Prefix for category name that marks whether a suggested action from that category was
5000         * completed.
5001         * @hide
5002         */
5003        public static final String COMPLETED_CATEGORY_PREFIX = "suggested.completed_category.";
5004
5005        /**
5006         * List of input methods that are currently enabled.  This is a string
5007         * containing the IDs of all enabled input methods, each ID separated
5008         * by ':'.
5009         */
5010        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
5011
5012        /**
5013         * List of system input methods that are currently disabled.  This is a string
5014         * containing the IDs of all disabled input methods, each ID separated
5015         * by ':'.
5016         * @hide
5017         */
5018        public static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
5019
5020        /**
5021         * Whether to show the IME when a hard keyboard is connected. This is a boolean that
5022         * determines if the IME should be shown when a hard keyboard is attached.
5023         * @hide
5024         */
5025        public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
5026
5027        /**
5028         * Host name and port for global http proxy. Uses ':' seperator for
5029         * between host and port.
5030         *
5031         * @deprecated Use {@link Global#HTTP_PROXY}
5032         */
5033        @Deprecated
5034        public static final String HTTP_PROXY = Global.HTTP_PROXY;
5035
5036        /**
5037         * Package designated as always-on VPN provider.
5038         *
5039         * @hide
5040         */
5041        public static final String ALWAYS_ON_VPN_APP = "always_on_vpn_app";
5042
5043        /**
5044         * Whether to block networking outside of VPN connections while always-on is set.
5045         * @see #ALWAYS_ON_VPN_APP
5046         *
5047         * @hide
5048         */
5049        public static final String ALWAYS_ON_VPN_LOCKDOWN = "always_on_vpn_lockdown";
5050
5051        /**
5052         * Whether applications can be installed for this user via the system's
5053         * {@link Intent#ACTION_INSTALL_PACKAGE} mechanism.
5054         *
5055         * <p>1 = permit app installation via the system package installer intent
5056         * <p>0 = do not allow use of the package installer
5057         */
5058        public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
5059
5060        /**
5061         * Comma-separated list of location providers that activities may access. Do not rely on
5062         * this value being present in settings.db or on ContentObserver notifications on the
5063         * corresponding Uri.
5064         *
5065         * @deprecated use {@link #LOCATION_MODE} and
5066         * {@link LocationManager#MODE_CHANGED_ACTION} (or
5067         * {@link LocationManager#PROVIDERS_CHANGED_ACTION})
5068         */
5069        @Deprecated
5070        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
5071
5072        /**
5073         * The degree of location access enabled by the user.
5074         * <p>
5075         * When used with {@link #putInt(ContentResolver, String, int)}, must be one of {@link
5076         * #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, {@link
5077         * #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. When used with {@link
5078         * #getInt(ContentResolver, String)}, the caller must gracefully handle additional location
5079         * modes that might be added in the future.
5080         * <p>
5081         * Note: do not rely on this value being present in settings.db or on ContentObserver
5082         * notifications for the corresponding Uri. Use {@link LocationManager#MODE_CHANGED_ACTION}
5083         * to receive changes in this value.
5084         */
5085        public static final String LOCATION_MODE = "location_mode";
5086        /**
5087         * Stores the previous location mode when {@link #LOCATION_MODE} is set to
5088         * {@link #LOCATION_MODE_OFF}
5089         * @hide
5090         */
5091        public static final String LOCATION_PREVIOUS_MODE = "location_previous_mode";
5092
5093        /**
5094         * Sets all location providers to the previous states before location was turned off.
5095         * @hide
5096         */
5097        public static final int LOCATION_MODE_PREVIOUS = -1;
5098        /**
5099         * Location access disabled.
5100         */
5101        public static final int LOCATION_MODE_OFF = 0;
5102        /**
5103         * Network Location Provider disabled, but GPS and other sensors enabled.
5104         */
5105        public static final int LOCATION_MODE_SENSORS_ONLY = 1;
5106        /**
5107         * Reduced power usage, such as limiting the number of GPS updates per hour. Requests
5108         * with {@link android.location.Criteria#POWER_HIGH} may be downgraded to
5109         * {@link android.location.Criteria#POWER_MEDIUM}.
5110         */
5111        public static final int LOCATION_MODE_BATTERY_SAVING = 2;
5112        /**
5113         * Best-effort location computation allowed.
5114         */
5115        public static final int LOCATION_MODE_HIGH_ACCURACY = 3;
5116
5117        /**
5118         * A flag containing settings used for biometric weak
5119         * @hide
5120         */
5121        @Deprecated
5122        public static final String LOCK_BIOMETRIC_WEAK_FLAGS =
5123                "lock_biometric_weak_flags";
5124
5125        /**
5126         * Whether lock-to-app will lock the keyguard when exiting.
5127         * @hide
5128         */
5129        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";
5130
5131        /**
5132         * Whether autolock is enabled (0 = false, 1 = true)
5133         *
5134         * @deprecated Use {@link android.app.KeyguardManager} to determine the state and security
5135         *             level of the keyguard. Accessing this setting from an app that is targeting
5136         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5137         */
5138        @Deprecated
5139        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
5140
5141        /**
5142         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
5143         *
5144         * @deprecated Accessing this setting from an app that is targeting
5145         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5146         */
5147        @Deprecated
5148        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
5149
5150        /**
5151         * Whether lock pattern will vibrate as user enters (0 = false, 1 =
5152         * true)
5153         *
5154         * @deprecated Starting in {@link VERSION_CODES#JELLY_BEAN_MR1} the
5155         *             lockscreen uses
5156         *             {@link Settings.System#HAPTIC_FEEDBACK_ENABLED}.
5157         *             Accessing this setting from an app that is targeting
5158         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5159         */
5160        @Deprecated
5161        public static final String
5162                LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
5163
5164        /**
5165         * This preference allows the device to be locked given time after screen goes off,
5166         * subject to current DeviceAdmin policy limits.
5167         * @hide
5168         */
5169        public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout";
5170
5171
5172        /**
5173         * This preference contains the string that shows for owner info on LockScreen.
5174         * @hide
5175         * @deprecated
5176         */
5177        @Deprecated
5178        public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
5179
5180        /**
5181         * Ids of the user-selected appwidgets on the lockscreen (comma-delimited).
5182         * @hide
5183         */
5184        @Deprecated
5185        public static final String LOCK_SCREEN_APPWIDGET_IDS =
5186            "lock_screen_appwidget_ids";
5187
5188        /**
5189         * Id of the appwidget shown on the lock screen when appwidgets are disabled.
5190         * @hide
5191         */
5192        @Deprecated
5193        public static final String LOCK_SCREEN_FALLBACK_APPWIDGET_ID =
5194            "lock_screen_fallback_appwidget_id";
5195
5196        /**
5197         * Index of the lockscreen appwidget to restore, -1 if none.
5198         * @hide
5199         */
5200        @Deprecated
5201        public static final String LOCK_SCREEN_STICKY_APPWIDGET =
5202            "lock_screen_sticky_appwidget";
5203
5204        /**
5205         * This preference enables showing the owner info on LockScreen.
5206         * @hide
5207         * @deprecated
5208         */
5209        @Deprecated
5210        public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
5211            "lock_screen_owner_info_enabled";
5212
5213        /**
5214         * When set by a user, allows notifications to be shown atop a securely locked screen
5215         * in their full "private" form (same as when the device is unlocked).
5216         * @hide
5217         */
5218        public static final String LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS =
5219                "lock_screen_allow_private_notifications";
5220
5221        /**
5222         * When set by a user, allows notification remote input atop a securely locked screen
5223         * without having to unlock
5224         * @hide
5225         */
5226        public static final String LOCK_SCREEN_ALLOW_REMOTE_INPUT =
5227                "lock_screen_allow_remote_input";
5228
5229        /**
5230         * Set by the system to track if the user needs to see the call to action for
5231         * the lockscreen notification policy.
5232         * @hide
5233         */
5234        public static final String SHOW_NOTE_ABOUT_NOTIFICATION_HIDING =
5235                "show_note_about_notification_hiding";
5236
5237        /**
5238         * Set to 1 by the system after trust agents have been initialized.
5239         * @hide
5240         */
5241        public static final String TRUST_AGENTS_INITIALIZED =
5242                "trust_agents_initialized";
5243
5244        /**
5245         * The Logging ID (a unique 64-bit value) as a hex string.
5246         * Used as a pseudonymous identifier for logging.
5247         * @deprecated This identifier is poorly initialized and has
5248         * many collisions.  It should not be used.
5249         */
5250        @Deprecated
5251        public static final String LOGGING_ID = "logging_id";
5252
5253        /**
5254         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
5255         */
5256        @Deprecated
5257        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
5258
5259        /**
5260         * No longer supported.
5261         */
5262        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
5263
5264        /**
5265         * No longer supported.
5266         */
5267        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
5268
5269        /**
5270         * No longer supported.
5271         */
5272        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
5273
5274        /**
5275         * Settings classname to launch when Settings is clicked from All
5276         * Applications.  Needed because of user testing between the old
5277         * and new Settings apps.
5278         */
5279        // TODO: 881807
5280        public static final String SETTINGS_CLASSNAME = "settings_classname";
5281
5282        /**
5283         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
5284         */
5285        @Deprecated
5286        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
5287
5288        /**
5289         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
5290         */
5291        @Deprecated
5292        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
5293
5294        /**
5295         * If accessibility is enabled.
5296         */
5297        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
5298
5299        /**
5300         * If touch exploration is enabled.
5301         */
5302        public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled";
5303
5304        /**
5305         * List of the enabled accessibility providers.
5306         */
5307        public static final String ENABLED_ACCESSIBILITY_SERVICES =
5308            "enabled_accessibility_services";
5309
5310        /**
5311         * List of the accessibility services to which the user has granted
5312         * permission to put the device into touch exploration mode.
5313         *
5314         * @hide
5315         */
5316        public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES =
5317            "touch_exploration_granted_accessibility_services";
5318
5319        /**
5320         * Whether to speak passwords while in accessibility mode.
5321         */
5322        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
5323
5324        /**
5325         * Whether to draw text with high contrast while in accessibility mode.
5326         *
5327         * @hide
5328         */
5329        public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED =
5330                "high_text_contrast_enabled";
5331
5332        /**
5333         * If injection of accessibility enhancing JavaScript screen-reader
5334         * is enabled.
5335         * <p>
5336         *   Note: The JavaScript based screen-reader is served by the
5337         *   Google infrastructure and enable users with disabilities to
5338         *   efficiently navigate in and explore web content.
5339         * </p>
5340         * <p>
5341         *   This property represents a boolean value.
5342         * </p>
5343         * @hide
5344         */
5345        public static final String ACCESSIBILITY_SCRIPT_INJECTION =
5346            "accessibility_script_injection";
5347
5348        /**
5349         * The URL for the injected JavaScript based screen-reader used
5350         * for providing accessibility of content in WebView.
5351         * <p>
5352         *   Note: The JavaScript based screen-reader is served by the
5353         *   Google infrastructure and enable users with disabilities to
5354         *   efficiently navigate in and explore web content.
5355         * </p>
5356         * <p>
5357         *   This property represents a string value.
5358         * </p>
5359         * @hide
5360         */
5361        public static final String ACCESSIBILITY_SCREEN_READER_URL =
5362            "accessibility_script_injection_url";
5363
5364        /**
5365         * Key bindings for navigation in built-in accessibility support for web content.
5366         * <p>
5367         *   Note: These key bindings are for the built-in accessibility navigation for
5368         *   web content which is used as a fall back solution if JavaScript in a WebView
5369         *   is not enabled or the user has not opted-in script injection from Google.
5370         * </p>
5371         * <p>
5372         *   The bindings are separated by semi-colon. A binding is a mapping from
5373         *   a key to a sequence of actions (for more details look at
5374         *   android.webkit.AccessibilityInjector). A key is represented as the hexademical
5375         *   string representation of an integer obtained from a meta state (optional) shifted
5376         *   sixteen times left and bitwise ored with a key code. An action is represented
5377         *   as a hexademical string representation of an integer where the first two digits
5378         *   are navigation action index, the second, the third, and the fourth digit pairs
5379         *   represent the action arguments. The separate actions in a binding are colon
5380         *   separated. The key and the action sequence it maps to are separated by equals.
5381         * </p>
5382         * <p>
5383         *   For example, the binding below maps the DPAD right button to traverse the
5384         *   current navigation axis once without firing an accessibility event and to
5385         *   perform the same traversal again but to fire an event:
5386         *   <code>
5387         *     0x16=0x01000100:0x01000101;
5388         *   </code>
5389         * </p>
5390         * <p>
5391         *   The goal of this binding is to enable dynamic rebinding of keys to
5392         *   navigation actions for web content without requiring a framework change.
5393         * </p>
5394         * <p>
5395         *   This property represents a string value.
5396         * </p>
5397         * @hide
5398         */
5399        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
5400            "accessibility_web_content_key_bindings";
5401
5402        /**
5403         * Setting that specifies whether the display magnification is enabled.
5404         * Display magnifications allows the user to zoom in the display content
5405         * and is targeted to low vision users. The current magnification scale
5406         * is controlled by {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
5407         *
5408         * @hide
5409         */
5410        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED =
5411                "accessibility_display_magnification_enabled";
5412
5413        /**
5414         * Setting that specifies what the display magnification scale is.
5415         * Display magnifications allows the user to zoom in the display
5416         * content and is targeted to low vision users. Whether a display
5417         * magnification is performed is controlled by
5418         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED}
5419         *
5420         * @hide
5421         */
5422        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE =
5423                "accessibility_display_magnification_scale";
5424
5425        /**
5426         * Unused mangnification setting
5427         *
5428         * @hide
5429         * @deprecated
5430         */
5431        @Deprecated
5432        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE =
5433                "accessibility_display_magnification_auto_update";
5434
5435        /**
5436         * Setting that specifies what mode the soft keyboard is in (default or hidden). Can be
5437         * modified from an AccessibilityService using the SoftKeyboardController.
5438         *
5439         * @hide
5440         */
5441        public static final String ACCESSIBILITY_SOFT_KEYBOARD_MODE =
5442                "accessibility_soft_keyboard_mode";
5443
5444        /**
5445         * Default soft keyboard behavior.
5446         *
5447         * @hide
5448         */
5449        public static final int SHOW_MODE_AUTO = 0;
5450
5451        /**
5452         * Soft keyboard is never shown.
5453         *
5454         * @hide
5455         */
5456        public static final int SHOW_MODE_HIDDEN = 1;
5457
5458        /**
5459         * Setting that specifies whether timed text (captions) should be
5460         * displayed in video content. Text display properties are controlled by
5461         * the following settings:
5462         * <ul>
5463         * <li>{@link #ACCESSIBILITY_CAPTIONING_LOCALE}
5464         * <li>{@link #ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR}
5465         * <li>{@link #ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR}
5466         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_COLOR}
5467         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_TYPE}
5468         * <li>{@link #ACCESSIBILITY_CAPTIONING_TYPEFACE}
5469         * <li>{@link #ACCESSIBILITY_CAPTIONING_FONT_SCALE}
5470         * </ul>
5471         *
5472         * @hide
5473         */
5474        public static final String ACCESSIBILITY_CAPTIONING_ENABLED =
5475                "accessibility_captioning_enabled";
5476
5477        /**
5478         * Setting that specifies the language for captions as a locale string,
5479         * e.g. en_US.
5480         *
5481         * @see java.util.Locale#toString
5482         * @hide
5483         */
5484        public static final String ACCESSIBILITY_CAPTIONING_LOCALE =
5485                "accessibility_captioning_locale";
5486
5487        /**
5488         * Integer property that specifies the preset style for captions, one
5489         * of:
5490         * <ul>
5491         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESET_CUSTOM}
5492         * <li>a valid index of {@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESETS}
5493         * </ul>
5494         *
5495         * @see java.util.Locale#toString
5496         * @hide
5497         */
5498        public static final String ACCESSIBILITY_CAPTIONING_PRESET =
5499                "accessibility_captioning_preset";
5500
5501        /**
5502         * Integer property that specifes the background color for captions as a
5503         * packed 32-bit color.
5504         *
5505         * @see android.graphics.Color#argb
5506         * @hide
5507         */
5508        public static final String ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR =
5509                "accessibility_captioning_background_color";
5510
5511        /**
5512         * Integer property that specifes the foreground color for captions as a
5513         * packed 32-bit color.
5514         *
5515         * @see android.graphics.Color#argb
5516         * @hide
5517         */
5518        public static final String ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR =
5519                "accessibility_captioning_foreground_color";
5520
5521        /**
5522         * Integer property that specifes the edge type for captions, one of:
5523         * <ul>
5524         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_NONE}
5525         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_OUTLINE}
5526         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_DROP_SHADOW}
5527         * </ul>
5528         *
5529         * @see #ACCESSIBILITY_CAPTIONING_EDGE_COLOR
5530         * @hide
5531         */
5532        public static final String ACCESSIBILITY_CAPTIONING_EDGE_TYPE =
5533                "accessibility_captioning_edge_type";
5534
5535        /**
5536         * Integer property that specifes the edge color for captions as a
5537         * packed 32-bit color.
5538         *
5539         * @see #ACCESSIBILITY_CAPTIONING_EDGE_TYPE
5540         * @see android.graphics.Color#argb
5541         * @hide
5542         */
5543        public static final String ACCESSIBILITY_CAPTIONING_EDGE_COLOR =
5544                "accessibility_captioning_edge_color";
5545
5546        /**
5547         * Integer property that specifes the window color for captions as a
5548         * packed 32-bit color.
5549         *
5550         * @see android.graphics.Color#argb
5551         * @hide
5552         */
5553        public static final String ACCESSIBILITY_CAPTIONING_WINDOW_COLOR =
5554                "accessibility_captioning_window_color";
5555
5556        /**
5557         * String property that specifies the typeface for captions, one of:
5558         * <ul>
5559         * <li>DEFAULT
5560         * <li>MONOSPACE
5561         * <li>SANS_SERIF
5562         * <li>SERIF
5563         * </ul>
5564         *
5565         * @see android.graphics.Typeface
5566         * @hide
5567         */
5568        public static final String ACCESSIBILITY_CAPTIONING_TYPEFACE =
5569                "accessibility_captioning_typeface";
5570
5571        /**
5572         * Floating point property that specifies font scaling for captions.
5573         *
5574         * @hide
5575         */
5576        public static final String ACCESSIBILITY_CAPTIONING_FONT_SCALE =
5577                "accessibility_captioning_font_scale";
5578
5579        /**
5580         * Setting that specifies whether display color inversion is enabled.
5581         */
5582        public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED =
5583                "accessibility_display_inversion_enabled";
5584
5585        /**
5586         * Setting that specifies whether display color space adjustment is
5587         * enabled.
5588         *
5589         * @hide
5590         */
5591        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED =
5592                "accessibility_display_daltonizer_enabled";
5593
5594        /**
5595         * Integer property that specifies the type of color space adjustment to
5596         * perform. Valid values are defined in AccessibilityManager.
5597         *
5598         * @hide
5599         */
5600        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER =
5601                "accessibility_display_daltonizer";
5602
5603        /**
5604         * Setting that specifies whether automatic click when the mouse pointer stops moving is
5605         * enabled.
5606         *
5607         * @hide
5608         */
5609        public static final String ACCESSIBILITY_AUTOCLICK_ENABLED =
5610                "accessibility_autoclick_enabled";
5611
5612        /**
5613         * Integer setting specifying amount of time in ms the mouse pointer has to stay still
5614         * before performing click when {@link #ACCESSIBILITY_AUTOCLICK_ENABLED} is set.
5615         *
5616         * @see #ACCESSIBILITY_AUTOCLICK_ENABLED
5617         * @hide
5618         */
5619        public static final String ACCESSIBILITY_AUTOCLICK_DELAY =
5620                "accessibility_autoclick_delay";
5621
5622        /**
5623         * Whether or not larger size icons are used for the pointer of mouse/trackpad for
5624         * accessibility.
5625         * (0 = false, 1 = true)
5626         * @hide
5627         */
5628        public static final String ACCESSIBILITY_LARGE_POINTER_ICON =
5629                "accessibility_large_pointer_icon";
5630
5631        /**
5632         * The timeout for considering a press to be a long press in milliseconds.
5633         * @hide
5634         */
5635        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
5636
5637        /**
5638         * The duration in milliseconds between the first tap's up event and the second tap's
5639         * down event for an interaction to be considered part of the same multi-press.
5640         * @hide
5641         */
5642        public static final String MULTI_PRESS_TIMEOUT = "multi_press_timeout";
5643
5644        /**
5645         * List of the enabled print services.
5646         *
5647         * N and beyond uses {@link #DISABLED_PRINT_SERVICES}. But this might be used in an upgrade
5648         * from pre-N.
5649         *
5650         * @hide
5651         */
5652        public static final String ENABLED_PRINT_SERVICES =
5653            "enabled_print_services";
5654
5655        /**
5656         * List of the disabled print services.
5657         *
5658         * @hide
5659         */
5660        public static final String DISABLED_PRINT_SERVICES =
5661            "disabled_print_services";
5662
5663        /**
5664         * The saved value for WindowManagerService.setForcedDisplayDensity()
5665         * formatted as a single integer representing DPI. If unset, then use
5666         * the real display density.
5667         *
5668         * @hide
5669         */
5670        public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
5671
5672        /**
5673         * Setting to always use the default text-to-speech settings regardless
5674         * of the application settings.
5675         * 1 = override application settings,
5676         * 0 = use application settings (if specified).
5677         *
5678         * @deprecated  The value of this setting is no longer respected by
5679         * the framework text to speech APIs as of the Ice Cream Sandwich release.
5680         */
5681        @Deprecated
5682        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
5683
5684        /**
5685         * Default text-to-speech engine speech rate. 100 = 1x
5686         */
5687        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
5688
5689        /**
5690         * Default text-to-speech engine pitch. 100 = 1x
5691         */
5692        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
5693
5694        /**
5695         * Default text-to-speech engine.
5696         */
5697        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
5698
5699        /**
5700         * Default text-to-speech language.
5701         *
5702         * @deprecated this setting is no longer in use, as of the Ice Cream
5703         * Sandwich release. Apps should never need to read this setting directly,
5704         * instead can query the TextToSpeech framework classes for the default
5705         * locale. {@link TextToSpeech#getLanguage()}.
5706         */
5707        @Deprecated
5708        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
5709
5710        /**
5711         * Default text-to-speech country.
5712         *
5713         * @deprecated this setting is no longer in use, as of the Ice Cream
5714         * Sandwich release. Apps should never need to read this setting directly,
5715         * instead can query the TextToSpeech framework classes for the default
5716         * locale. {@link TextToSpeech#getLanguage()}.
5717         */
5718        @Deprecated
5719        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
5720
5721        /**
5722         * Default text-to-speech locale variant.
5723         *
5724         * @deprecated this setting is no longer in use, as of the Ice Cream
5725         * Sandwich release. Apps should never need to read this setting directly,
5726         * instead can query the TextToSpeech framework classes for the
5727         * locale that is in use {@link TextToSpeech#getLanguage()}.
5728         */
5729        @Deprecated
5730        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
5731
5732        /**
5733         * Stores the default tts locales on a per engine basis. Stored as
5734         * a comma seperated list of values, each value being of the form
5735         * {@code engine_name:locale} for example,
5736         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
5737         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
5738         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
5739         * setting directly, and can query the TextToSpeech framework classes
5740         * for the locale that is in use.
5741         *
5742         * @hide
5743         */
5744        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
5745
5746        /**
5747         * Space delimited list of plugin packages that are enabled.
5748         */
5749        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
5750
5751        /**
5752         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
5753         * instead.
5754         */
5755        @Deprecated
5756        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
5757                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
5758
5759        /**
5760         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
5761         * instead.
5762         */
5763        @Deprecated
5764        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
5765                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
5766
5767        /**
5768         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
5769         * instead.
5770         */
5771        @Deprecated
5772        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
5773                Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
5774
5775        /**
5776         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
5777         * instead.
5778         */
5779        @Deprecated
5780        public static final String WIFI_ON = Global.WIFI_ON;
5781
5782        /**
5783         * The acceptable packet loss percentage (range 0 - 100) before trying
5784         * another AP on the same network.
5785         * @deprecated This setting is not used.
5786         */
5787        @Deprecated
5788        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
5789                "wifi_watchdog_acceptable_packet_loss_percentage";
5790
5791        /**
5792         * The number of access points required for a network in order for the
5793         * watchdog to monitor it.
5794         * @deprecated This setting is not used.
5795         */
5796        @Deprecated
5797        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
5798
5799        /**
5800         * The delay between background checks.
5801         * @deprecated This setting is not used.
5802         */
5803        @Deprecated
5804        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
5805                "wifi_watchdog_background_check_delay_ms";
5806
5807        /**
5808         * Whether the Wi-Fi watchdog is enabled for background checking even
5809         * after it thinks the user has connected to a good access point.
5810         * @deprecated This setting is not used.
5811         */
5812        @Deprecated
5813        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
5814                "wifi_watchdog_background_check_enabled";
5815
5816        /**
5817         * The timeout for a background ping
5818         * @deprecated This setting is not used.
5819         */
5820        @Deprecated
5821        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
5822                "wifi_watchdog_background_check_timeout_ms";
5823
5824        /**
5825         * The number of initial pings to perform that *may* be ignored if they
5826         * fail. Again, if these fail, they will *not* be used in packet loss
5827         * calculation. For example, one network always seemed to time out for
5828         * the first couple pings, so this is set to 3 by default.
5829         * @deprecated This setting is not used.
5830         */
5831        @Deprecated
5832        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
5833            "wifi_watchdog_initial_ignored_ping_count";
5834
5835        /**
5836         * The maximum number of access points (per network) to attempt to test.
5837         * If this number is reached, the watchdog will no longer monitor the
5838         * initial connection state for the network. This is a safeguard for
5839         * networks containing multiple APs whose DNS does not respond to pings.
5840         * @deprecated This setting is not used.
5841         */
5842        @Deprecated
5843        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
5844
5845        /**
5846         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
5847         */
5848        @Deprecated
5849        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
5850
5851        /**
5852         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
5853         * @deprecated This setting is not used.
5854         */
5855        @Deprecated
5856        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
5857
5858        /**
5859         * The number of pings to test if an access point is a good connection.
5860         * @deprecated This setting is not used.
5861         */
5862        @Deprecated
5863        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
5864
5865        /**
5866         * The delay between pings.
5867         * @deprecated This setting is not used.
5868         */
5869        @Deprecated
5870        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
5871
5872        /**
5873         * The timeout per ping.
5874         * @deprecated This setting is not used.
5875         */
5876        @Deprecated
5877        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
5878
5879        /**
5880         * @deprecated Use
5881         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
5882         */
5883        @Deprecated
5884        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
5885
5886        /**
5887         * @deprecated Use
5888         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
5889         */
5890        @Deprecated
5891        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
5892                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
5893
5894        /**
5895         * The number of milliseconds to hold on to a PendingIntent based request. This delay gives
5896         * the receivers of the PendingIntent an opportunity to make a new network request before
5897         * the Network satisfying the request is potentially removed.
5898         *
5899         * @hide
5900         */
5901        public static final String CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS =
5902                "connectivity_release_pending_intent_delay_ms";
5903
5904        /**
5905         * Whether background data usage is allowed.
5906         *
5907         * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH},
5908         *             availability of background data depends on several
5909         *             combined factors. When background data is unavailable,
5910         *             {@link ConnectivityManager#getActiveNetworkInfo()} will
5911         *             now appear disconnected.
5912         */
5913        @Deprecated
5914        public static final String BACKGROUND_DATA = "background_data";
5915
5916        /**
5917         * Origins for which browsers should allow geolocation by default.
5918         * The value is a space-separated list of origins.
5919         */
5920        public static final String ALLOWED_GEOLOCATION_ORIGINS
5921                = "allowed_geolocation_origins";
5922
5923        /**
5924         * The preferred TTY mode     0 = TTy Off, CDMA default
5925         *                            1 = TTY Full
5926         *                            2 = TTY HCO
5927         *                            3 = TTY VCO
5928         * @hide
5929         */
5930        public static final String PREFERRED_TTY_MODE =
5931                "preferred_tty_mode";
5932
5933        /**
5934         * Whether the enhanced voice privacy mode is enabled.
5935         * 0 = normal voice privacy
5936         * 1 = enhanced voice privacy
5937         * @hide
5938         */
5939        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
5940
5941        /**
5942         * Whether the TTY mode mode is enabled.
5943         * 0 = disabled
5944         * 1 = enabled
5945         * @hide
5946         */
5947        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
5948
5949        /**
5950         * Controls whether settings backup is enabled.
5951         * Type: int ( 0 = disabled, 1 = enabled )
5952         * @hide
5953         */
5954        public static final String BACKUP_ENABLED = "backup_enabled";
5955
5956        /**
5957         * Controls whether application data is automatically restored from backup
5958         * at install time.
5959         * Type: int ( 0 = disabled, 1 = enabled )
5960         * @hide
5961         */
5962        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
5963
5964        /**
5965         * Indicates whether settings backup has been fully provisioned.
5966         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
5967         * @hide
5968         */
5969        public static final String BACKUP_PROVISIONED = "backup_provisioned";
5970
5971        /**
5972         * Component of the transport to use for backup/restore.
5973         * @hide
5974         */
5975        public static final String BACKUP_TRANSPORT = "backup_transport";
5976
5977        /**
5978         * Version for which the setup wizard was last shown.  Bumped for
5979         * each release when there is new setup information to show.
5980         * @hide
5981         */
5982        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
5983
5984        /**
5985         * The interval in milliseconds after which Wi-Fi is considered idle.
5986         * When idle, it is possible for the device to be switched from Wi-Fi to
5987         * the mobile data network.
5988         * @hide
5989         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
5990         * instead.
5991         */
5992        @Deprecated
5993        public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
5994
5995        /**
5996         * The global search provider chosen by the user (if multiple global
5997         * search providers are installed). This will be the provider returned
5998         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
5999         * installed. This setting is stored as a flattened component name as
6000         * per {@link ComponentName#flattenToString()}.
6001         *
6002         * @hide
6003         */
6004        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
6005                "search_global_search_activity";
6006
6007        /**
6008         * The number of promoted sources in GlobalSearch.
6009         * @hide
6010         */
6011        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
6012        /**
6013         * The maximum number of suggestions returned by GlobalSearch.
6014         * @hide
6015         */
6016        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
6017        /**
6018         * The number of suggestions GlobalSearch will ask each non-web search source for.
6019         * @hide
6020         */
6021        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
6022        /**
6023         * The number of suggestions the GlobalSearch will ask the web search source for.
6024         * @hide
6025         */
6026        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
6027                "search_web_results_override_limit";
6028        /**
6029         * The number of milliseconds that GlobalSearch will wait for suggestions from
6030         * promoted sources before continuing with all other sources.
6031         * @hide
6032         */
6033        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
6034                "search_promoted_source_deadline_millis";
6035        /**
6036         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
6037         * @hide
6038         */
6039        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
6040        /**
6041         * The maximum number of milliseconds that GlobalSearch shows the previous results
6042         * after receiving a new query.
6043         * @hide
6044         */
6045        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
6046        /**
6047         * The maximum age of log data used for shortcuts in GlobalSearch.
6048         * @hide
6049         */
6050        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
6051        /**
6052         * The maximum age of log data used for source ranking in GlobalSearch.
6053         * @hide
6054         */
6055        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
6056                "search_max_source_event_age_millis";
6057        /**
6058         * The minimum number of impressions needed to rank a source in GlobalSearch.
6059         * @hide
6060         */
6061        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
6062                "search_min_impressions_for_source_ranking";
6063        /**
6064         * The minimum number of clicks needed to rank a source in GlobalSearch.
6065         * @hide
6066         */
6067        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
6068                "search_min_clicks_for_source_ranking";
6069        /**
6070         * The maximum number of shortcuts shown by GlobalSearch.
6071         * @hide
6072         */
6073        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
6074        /**
6075         * The size of the core thread pool for suggestion queries in GlobalSearch.
6076         * @hide
6077         */
6078        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
6079                "search_query_thread_core_pool_size";
6080        /**
6081         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
6082         * @hide
6083         */
6084        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
6085                "search_query_thread_max_pool_size";
6086        /**
6087         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
6088         * @hide
6089         */
6090        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
6091                "search_shortcut_refresh_core_pool_size";
6092        /**
6093         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
6094         * @hide
6095         */
6096        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
6097                "search_shortcut_refresh_max_pool_size";
6098        /**
6099         * The maximun time that excess threads in the GlobalSeach thread pools will
6100         * wait before terminating.
6101         * @hide
6102         */
6103        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
6104                "search_thread_keepalive_seconds";
6105        /**
6106         * The maximum number of concurrent suggestion queries to each source.
6107         * @hide
6108         */
6109        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
6110                "search_per_source_concurrent_query_limit";
6111
6112        /**
6113         * Whether or not alert sounds are played on StorageManagerService events.
6114         * (0 = false, 1 = true)
6115         * @hide
6116         */
6117        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
6118
6119        /**
6120         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
6121         * @hide
6122         */
6123        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
6124
6125        /**
6126         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
6127         * @hide
6128         */
6129        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
6130
6131        /**
6132         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
6133         * @hide
6134         */
6135        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
6136
6137        /**
6138         * If nonzero, ANRs in invisible background processes bring up a dialog.
6139         * Otherwise, the process will be silently killed.
6140         *
6141         * Also prevents ANRs and crash dialogs from being suppressed.
6142         * @hide
6143         */
6144        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
6145
6146        /**
6147         * The {@link ComponentName} string of the service to be used as the voice recognition
6148         * service.
6149         *
6150         * @hide
6151         */
6152        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
6153
6154        /**
6155         * Stores whether an user has consented to have apps verified through PAM.
6156         * The value is boolean (1 or 0).
6157         *
6158         * @hide
6159         */
6160        public static final String PACKAGE_VERIFIER_USER_CONSENT =
6161            "package_verifier_user_consent";
6162
6163        /**
6164         * The {@link ComponentName} string of the selected spell checker service which is
6165         * one of the services managed by the text service manager.
6166         *
6167         * @hide
6168         */
6169        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
6170
6171        /**
6172         * The {@link ComponentName} string of the selected subtype of the selected spell checker
6173         * service which is one of the services managed by the text service manager.
6174         *
6175         * @hide
6176         */
6177        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
6178                "selected_spell_checker_subtype";
6179
6180        /**
6181         * The {@link ComponentName} string whether spell checker is enabled or not.
6182         *
6183         * @hide
6184         */
6185        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
6186
6187        /**
6188         * What happens when the user presses the Power button while in-call
6189         * and the screen is on.<br/>
6190         * <b>Values:</b><br/>
6191         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
6192         * 2 - The Power button hangs up the current call.<br/>
6193         *
6194         * @hide
6195         */
6196        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
6197
6198        /**
6199         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
6200         * @hide
6201         */
6202        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
6203
6204        /**
6205         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
6206         * @hide
6207         */
6208        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
6209
6210        /**
6211         * INCALL_POWER_BUTTON_BEHAVIOR default value.
6212         * @hide
6213         */
6214        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
6215                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
6216
6217        /**
6218         * What happens when the user presses the Back button while in-call
6219         * and the screen is on.<br/>
6220         * <b>Values:</b><br/>
6221         * 0 - The Back buttons does nothing different.<br/>
6222         * 1 - The Back button hangs up the current call.<br/>
6223         *
6224         * @hide
6225         */
6226        public static final String INCALL_BACK_BUTTON_BEHAVIOR = "incall_back_button_behavior";
6227
6228        /**
6229         * INCALL_BACK_BUTTON_BEHAVIOR value for no action.
6230         * @hide
6231         */
6232        public static final int INCALL_BACK_BUTTON_BEHAVIOR_NONE = 0x0;
6233
6234        /**
6235         * INCALL_BACK_BUTTON_BEHAVIOR value for "hang up".
6236         * @hide
6237         */
6238        public static final int INCALL_BACK_BUTTON_BEHAVIOR_HANGUP = 0x1;
6239
6240        /**
6241         * INCALL_POWER_BUTTON_BEHAVIOR default value.
6242         * @hide
6243         */
6244        public static final int INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT =
6245                INCALL_BACK_BUTTON_BEHAVIOR_NONE;
6246
6247        /**
6248         * Whether the device should wake when the wake gesture sensor detects motion.
6249         * @hide
6250         */
6251        public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";
6252
6253        /**
6254         * Whether the device should doze if configured.
6255         * @hide
6256         */
6257        public static final String DOZE_ENABLED = "doze_enabled";
6258
6259        /**
6260         * Whether doze should be always on.
6261         * @hide
6262         */
6263        public static final String DOZE_ALWAYS_ON = "doze_always_on";
6264
6265        /**
6266         * Whether the device should pulse on pick up gesture.
6267         * @hide
6268         */
6269        public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
6270
6271        /**
6272         * Whether the device should pulse on double tap gesture.
6273         * @hide
6274         */
6275        public static final String DOZE_PULSE_ON_DOUBLE_TAP = "doze_pulse_on_double_tap";
6276
6277        /**
6278         * The current night mode that has been selected by the user.  Owned
6279         * and controlled by UiModeManagerService.  Constants are as per
6280         * UiModeManager.
6281         * @hide
6282         */
6283        public static final String UI_NIGHT_MODE = "ui_night_mode";
6284
6285        /**
6286         * Whether screensavers are enabled.
6287         * @hide
6288         */
6289        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
6290
6291        /**
6292         * The user's chosen screensaver components.
6293         *
6294         * These will be launched by the PhoneWindowManager after a timeout when not on
6295         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
6296         * @hide
6297         */
6298        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
6299
6300        /**
6301         * If screensavers are enabled, whether the screensaver should be automatically launched
6302         * when the device is inserted into a (desk) dock.
6303         * @hide
6304         */
6305        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
6306
6307        /**
6308         * If screensavers are enabled, whether the screensaver should be automatically launched
6309         * when the screen times out when not on battery.
6310         * @hide
6311         */
6312        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
6313
6314        /**
6315         * If screensavers are enabled, the default screensaver component.
6316         * @hide
6317         */
6318        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
6319
6320        /**
6321         * The default NFC payment component
6322         * @hide
6323         */
6324        public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
6325
6326        /**
6327         * Whether NFC payment is handled by the foreground application or a default.
6328         * @hide
6329         */
6330        public static final String NFC_PAYMENT_FOREGROUND = "nfc_payment_foreground";
6331
6332        /**
6333         * Specifies the package name currently configured to be the primary sms application
6334         * @hide
6335         */
6336        public static final String SMS_DEFAULT_APPLICATION = "sms_default_application";
6337
6338        /**
6339         * Specifies the package name currently configured to be the default dialer application
6340         * @hide
6341         */
6342        public static final String DIALER_DEFAULT_APPLICATION = "dialer_default_application";
6343
6344        /**
6345         * Specifies the package name currently configured to be the emergency assistance application
6346         *
6347         * @see android.telephony.TelephonyManager#ACTION_EMERGENCY_ASSISTANCE
6348         *
6349         * @hide
6350         */
6351        public static final String EMERGENCY_ASSISTANCE_APPLICATION = "emergency_assistance_application";
6352
6353        /**
6354         * Specifies whether the current app context on scren (assist data) will be sent to the
6355         * assist application (active voice interaction service).
6356         *
6357         * @hide
6358         */
6359        public static final String ASSIST_STRUCTURE_ENABLED = "assist_structure_enabled";
6360
6361        /**
6362         * Specifies whether a screenshot of the screen contents will be sent to the assist
6363         * application (active voice interaction service).
6364         *
6365         * @hide
6366         */
6367        public static final String ASSIST_SCREENSHOT_ENABLED = "assist_screenshot_enabled";
6368
6369        /**
6370         * Specifies whether the screen will show an animation if screen contents are sent to the
6371         * assist application (active voice interaction service).
6372         *
6373         * Note that the disclosure will be forced for third-party assistants or if the device
6374         * does not support disabling it.
6375         *
6376         * @hide
6377         */
6378        public static final String ASSIST_DISCLOSURE_ENABLED = "assist_disclosure_enabled";
6379
6380        /**
6381         * Name of the service components that the current user has explicitly allowed to
6382         * see and assist with all of the user's notifications.
6383         *
6384         * @hide
6385         */
6386        public static final String ENABLED_NOTIFICATION_ASSISTANT =
6387                "enabled_notification_assistant";
6388
6389        /**
6390         * Names of the service components that the current user has explicitly allowed to
6391         * see all of the user's notifications, separated by ':'.
6392         *
6393         * @hide
6394         */
6395        public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
6396
6397        /**
6398         * Names of the packages that the current user has explicitly allowed to
6399         * manage notification policy configuration, separated by ':'.
6400         *
6401         * @hide
6402         */
6403        @TestApi
6404        public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES =
6405                "enabled_notification_policy_access_packages";
6406
6407        /**
6408         * Defines whether managed profile ringtones should be synced from it's parent profile
6409         * <p>
6410         * 0 = ringtones are not synced
6411         * 1 = ringtones are synced from the profile's parent (default)
6412         * <p>
6413         * This value is only used for managed profiles.
6414         * @hide
6415         */
6416        public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
6417
6418        /** @hide */
6419        public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
6420
6421        /**
6422         * This is the query URI for finding a print service to install.
6423         *
6424         * @hide
6425         */
6426        public static final String PRINT_SERVICE_SEARCH_URI = "print_service_search_uri";
6427
6428        /**
6429         * This is the query URI for finding a NFC payment service to install.
6430         *
6431         * @hide
6432         */
6433        public static final String PAYMENT_SERVICE_SEARCH_URI = "payment_service_search_uri";
6434
6435        /**
6436         * If enabled, apps should try to skip any introductory hints on first launch. This might
6437         * apply to users that are already familiar with the environment or temporary users.
6438         * <p>
6439         * Type : int (0 to show hints, 1 to skip showing hints)
6440         */
6441        public static final String SKIP_FIRST_USE_HINTS = "skip_first_use_hints";
6442
6443        /**
6444         * Persisted playback time after a user confirmation of an unsafe volume level.
6445         *
6446         * @hide
6447         */
6448        public static final String UNSAFE_VOLUME_MUSIC_ACTIVE_MS = "unsafe_volume_music_active_ms";
6449
6450        /**
6451         * This preference enables notification display on the lockscreen.
6452         * @hide
6453         */
6454        public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
6455                "lock_screen_show_notifications";
6456
6457        /**
6458         * List of TV inputs that are currently hidden. This is a string
6459         * containing the IDs of all hidden TV inputs. Each ID is encoded by
6460         * {@link android.net.Uri#encode(String)} and separated by ':'.
6461         * @hide
6462         */
6463        public static final String TV_INPUT_HIDDEN_INPUTS = "tv_input_hidden_inputs";
6464
6465        /**
6466         * List of custom TV input labels. This is a string containing <TV input id, custom name>
6467         * pairs. TV input id and custom name are encoded by {@link android.net.Uri#encode(String)}
6468         * and separated by ','. Each pair is separated by ':'.
6469         * @hide
6470         */
6471        public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels";
6472
6473        /**
6474         * Whether automatic routing of system audio to USB audio peripheral is disabled.
6475         * The value is boolean (1 or 0), where 1 means automatic routing is disabled,
6476         * and 0 means automatic routing is enabled.
6477         *
6478         * @hide
6479         */
6480        public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
6481                "usb_audio_automatic_routing_disabled";
6482
6483        /**
6484         * The timeout in milliseconds before the device fully goes to sleep after
6485         * a period of inactivity.  This value sets an upper bound on how long the device
6486         * will stay awake or dreaming without user activity.  It should generally
6487         * be longer than {@link Settings.System#SCREEN_OFF_TIMEOUT} as otherwise the device
6488         * will sleep before it ever has a chance to dream.
6489         * <p>
6490         * Use -1 to disable this timeout.
6491         * </p>
6492         *
6493         * @hide
6494         */
6495        public static final String SLEEP_TIMEOUT = "sleep_timeout";
6496
6497        /**
6498         * Controls whether double tap to wake is enabled.
6499         * @hide
6500         */
6501        public static final String DOUBLE_TAP_TO_WAKE = "double_tap_to_wake";
6502
6503        /**
6504         * The current assistant component. It could be a voice interaction service,
6505         * or an activity that handles ACTION_ASSIST, or empty which means using the default
6506         * handling.
6507         *
6508         * @hide
6509         */
6510        public static final String ASSISTANT = "assistant";
6511
6512        /**
6513         * Whether the camera launch gesture should be disabled.
6514         *
6515         * @hide
6516         */
6517        public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled";
6518
6519        /**
6520         * Whether the camera launch gesture to double tap the power button when the screen is off
6521         * should be disabled.
6522         *
6523         * @hide
6524         */
6525        public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
6526                "camera_double_tap_power_gesture_disabled";
6527
6528        /**
6529         * Whether the camera double twist gesture to flip between front and back mode should be
6530         * enabled.
6531         *
6532         * @hide
6533         */
6534        public static final String CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED =
6535                "camera_double_twist_to_flip_enabled";
6536
6537        /**
6538         * Control whether Night display is currently activated.
6539         * @hide
6540         */
6541        public static final String NIGHT_DISPLAY_ACTIVATED = "night_display_activated";
6542
6543        /**
6544         * Control whether Night display will automatically activate/deactivate.
6545         * @hide
6546         */
6547        public static final String NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode";
6548
6549        /**
6550         * Custom time when Night display is scheduled to activate.
6551         * Represented as milliseconds from midnight (e.g. 79200000 == 10pm).
6552         * @hide
6553         */
6554        public static final String NIGHT_DISPLAY_CUSTOM_START_TIME = "night_display_custom_start_time";
6555
6556        /**
6557         * Custom time when Night display is scheduled to deactivate.
6558         * Represented as milliseconds from midnight (e.g. 21600000 == 6am).
6559         * @hide
6560         */
6561        public static final String NIGHT_DISPLAY_CUSTOM_END_TIME = "night_display_custom_end_time";
6562
6563        /**
6564         * Whether brightness should automatically adjust based on twilight state.
6565         * @hide
6566         */
6567        public static final String BRIGHTNESS_USE_TWILIGHT = "brightness_use_twilight";
6568
6569        /**
6570         * Names of the service components that the current user has explicitly allowed to
6571         * be a VR mode listener, separated by ':'.
6572         *
6573         * @hide
6574         */
6575        public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
6576
6577        /**
6578         * Behavior of the display while in VR mode.
6579         *
6580         * One of {@link #VR_DISPLAY_MODE_LOW_PERSISTENCE} or {@link #VR_DISPLAY_MODE_OFF}.
6581         *
6582         * @hide
6583         */
6584        public static final String VR_DISPLAY_MODE = "vr_display_mode";
6585
6586        /**
6587         * Lower the display persistence while the system is in VR mode.
6588         *
6589         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
6590         *
6591         * @hide.
6592         */
6593        public static final int VR_DISPLAY_MODE_LOW_PERSISTENCE = 0;
6594
6595        /**
6596         * Do not alter the display persistence while the system is in VR mode.
6597         *
6598         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
6599         *
6600         * @hide.
6601         */
6602        public static final int VR_DISPLAY_MODE_OFF = 1;
6603
6604        /**
6605         * Whether CarrierAppUtils#disableCarrierAppsUntilPrivileged has been executed at least
6606         * once.
6607         *
6608         * <p>This is used to ensure that we only take one pass which will disable apps that are not
6609         * privileged (if any). From then on, we only want to enable apps (when a matching SIM is
6610         * inserted), to avoid disabling an app that the user might actively be using.
6611         *
6612         * <p>Will be set to 1 once executed.
6613         *
6614         * @hide
6615         */
6616        public static final String CARRIER_APPS_HANDLED = "carrier_apps_handled";
6617
6618        /**
6619         * Whether parent user can access remote contact in managed profile.
6620         *
6621         * @hide
6622         */
6623        public static final String MANAGED_PROFILE_CONTACT_REMOTE_SEARCH =
6624                "managed_profile_contact_remote_search";
6625
6626        /**
6627         * Whether or not the automatic storage manager is enabled and should run on the device.
6628         *
6629         * @hide
6630         */
6631        public static final String AUTOMATIC_STORAGE_MANAGER_ENABLED =
6632                "automatic_storage_manager_enabled";
6633
6634        /**
6635         * How many days of information for the automatic storage manager to retain on the device.
6636         *
6637         * @hide
6638         */
6639        public static final String AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN =
6640                "automatic_storage_manager_days_to_retain";
6641
6642        /**
6643         * Default number of days of information for the automatic storage manager to retain.
6644         *
6645         * @hide
6646         */
6647        public static final int AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT = 90;
6648
6649        /**
6650         * How many bytes the automatic storage manager has cleared out.
6651         *
6652         * @hide
6653         */
6654        public static final String AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED =
6655                "automatic_storage_manager_bytes_cleared";
6656
6657
6658        /**
6659         * Last run time for the automatic storage manager.
6660         *
6661         * @hide
6662         */
6663        public static final String AUTOMATIC_STORAGE_MANAGER_LAST_RUN =
6664                "automatic_storage_manager_last_run";
6665
6666        /**
6667         * Whether SystemUI navigation keys is enabled.
6668         * @hide
6669         */
6670        public static final String SYSTEM_NAVIGATION_KEYS_ENABLED =
6671                "system_navigation_keys_enabled";
6672
6673        /**
6674         * Whether Downloads folder backup is enabled and should run on the device.
6675         *
6676         * @hide
6677         */
6678        public static final String DOWNLOADS_BACKUP_ENABLED = "downloads_backup_enabled";
6679
6680        /**
6681         * Whether Downloads folder backup should only occur if the device is using a metered
6682         * network.
6683         *
6684         * @hide
6685         */
6686        public static final String DOWNLOADS_BACKUP_ALLOW_METERED =
6687                "downloads_backup_allow_metered";
6688
6689        /**
6690         * Whether Downloads folder backup should only occur if the device is charging.
6691         *
6692         * @hide
6693         */
6694        public static final String DOWNLOADS_BACKUP_CHARGING_ONLY =
6695                "downloads_backup_charging_only";
6696
6697        /**
6698         * How many days of information for the automatic storage manager to retain on the device
6699         * for downloads.
6700         *
6701         * @hide
6702         */
6703        public static final String AUTOMATIC_STORAGE_MANAGER_DOWNLOADS_DAYS_TO_RETAIN =
6704                "automatic_storage_manager_downloads_days_to_retain";
6705
6706        /**
6707         * Holds comma separated list of ordering of QS tiles.
6708         * @hide
6709         */
6710        public static final String QS_TILES = "sysui_qs_tiles";
6711
6712        /**
6713         * Whether preloaded APKs have been installed for the user.
6714         * @hide
6715         */
6716        public static final String DEMO_USER_SETUP_COMPLETE
6717                = "demo_user_setup_complete";
6718
6719        /**
6720         * Specifies whether the web action API is enabled.
6721         *
6722         * @hide
6723         */
6724        public static final String WEB_ACTION_ENABLED = "web_action_enabled";
6725
6726        /**
6727         * Has this pairable device been paired or upgraded from a previously paired system.
6728         * @hide
6729         */
6730        public static final String DEVICE_PAIRED = "device_paired";
6731
6732        /**
6733         * This are the settings to be backed up.
6734         *
6735         * NOTE: Settings are backed up and restored in the order they appear
6736         *       in this array. If you have one setting depending on another,
6737         *       make sure that they are ordered appropriately.
6738         *
6739         * @hide
6740         */
6741        public static final String[] SETTINGS_TO_BACKUP = {
6742            BUGREPORT_IN_POWER_MENU,                            // moved to global
6743            ALLOW_MOCK_LOCATION,
6744            PARENTAL_CONTROL_ENABLED,
6745            PARENTAL_CONTROL_REDIRECT_URL,
6746            USB_MASS_STORAGE_ENABLED,                           // moved to global
6747            ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
6748            ACCESSIBILITY_DISPLAY_DALTONIZER,
6749            ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
6750            ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
6751            ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
6752            ACCESSIBILITY_SCRIPT_INJECTION,
6753            ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS,
6754            ENABLED_ACCESSIBILITY_SERVICES,
6755            ENABLED_NOTIFICATION_LISTENERS,
6756            ENABLED_VR_LISTENERS,
6757            ENABLED_INPUT_METHODS,
6758            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
6759            TOUCH_EXPLORATION_ENABLED,
6760            ACCESSIBILITY_ENABLED,
6761            ACCESSIBILITY_SPEAK_PASSWORD,
6762            ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
6763            ACCESSIBILITY_CAPTIONING_PRESET,
6764            ACCESSIBILITY_CAPTIONING_ENABLED,
6765            ACCESSIBILITY_CAPTIONING_LOCALE,
6766            ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
6767            ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
6768            ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
6769            ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
6770            ACCESSIBILITY_CAPTIONING_TYPEFACE,
6771            ACCESSIBILITY_CAPTIONING_FONT_SCALE,
6772            ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
6773            TTS_USE_DEFAULTS,
6774            TTS_DEFAULT_RATE,
6775            TTS_DEFAULT_PITCH,
6776            TTS_DEFAULT_SYNTH,
6777            TTS_DEFAULT_LANG,
6778            TTS_DEFAULT_COUNTRY,
6779            TTS_ENABLED_PLUGINS,
6780            TTS_DEFAULT_LOCALE,
6781            SHOW_IME_WITH_HARD_KEYBOARD,
6782            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
6783            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
6784            WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
6785            SELECTED_SPELL_CHECKER,
6786            SELECTED_SPELL_CHECKER_SUBTYPE,
6787            SPELL_CHECKER_ENABLED,
6788            MOUNT_PLAY_NOTIFICATION_SND,
6789            MOUNT_UMS_AUTOSTART,
6790            MOUNT_UMS_PROMPT,
6791            MOUNT_UMS_NOTIFY_ENABLED,
6792            SLEEP_TIMEOUT,
6793            DOUBLE_TAP_TO_WAKE,
6794            WAKE_GESTURE_ENABLED,
6795            LONG_PRESS_TIMEOUT,
6796            CAMERA_GESTURE_DISABLED,
6797            ACCESSIBILITY_AUTOCLICK_ENABLED,
6798            ACCESSIBILITY_AUTOCLICK_DELAY,
6799            ACCESSIBILITY_LARGE_POINTER_ICON,
6800            PREFERRED_TTY_MODE,
6801            ENHANCED_VOICE_PRIVACY_ENABLED,
6802            TTY_MODE_ENABLED,
6803            INCALL_POWER_BUTTON_BEHAVIOR,
6804            NIGHT_DISPLAY_CUSTOM_START_TIME,
6805            NIGHT_DISPLAY_CUSTOM_END_TIME,
6806            NIGHT_DISPLAY_AUTO_MODE,
6807            NIGHT_DISPLAY_ACTIVATED,
6808            SYNC_PARENT_SOUNDS,
6809            CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
6810            CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
6811            SYSTEM_NAVIGATION_KEYS_ENABLED,
6812            QS_TILES,
6813            DOZE_ENABLED,
6814            DOZE_PULSE_ON_PICK_UP,
6815            DOZE_PULSE_ON_DOUBLE_TAP,
6816            NFC_PAYMENT_DEFAULT_COMPONENT
6817        };
6818
6819        /**
6820         * These entries are considered common between the personal and the managed profile,
6821         * since the managed profile doesn't get to change them.
6822         */
6823        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
6824
6825        static {
6826            CLONE_TO_MANAGED_PROFILE.add(ACCESSIBILITY_ENABLED);
6827            CLONE_TO_MANAGED_PROFILE.add(ALLOW_MOCK_LOCATION);
6828            CLONE_TO_MANAGED_PROFILE.add(ALLOWED_GEOLOCATION_ORIGINS);
6829            CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD);
6830            CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES);
6831            CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS);
6832            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
6833            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PREVIOUS_MODE);
6834            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED);
6835            CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE);
6836            CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER);
6837            CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER_SUBTYPE);
6838        }
6839
6840        /** @hide */
6841        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
6842            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
6843        }
6844
6845        /**
6846         * Helper method for determining if a location provider is enabled.
6847         *
6848         * @param cr the content resolver to use
6849         * @param provider the location provider to query
6850         * @return true if the provider is enabled
6851         *
6852         * @deprecated use {@link #LOCATION_MODE} or
6853         *             {@link LocationManager#isProviderEnabled(String)}
6854         */
6855        @Deprecated
6856        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
6857            return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId());
6858        }
6859
6860        /**
6861         * Helper method for determining if a location provider is enabled.
6862         * @param cr the content resolver to use
6863         * @param provider the location provider to query
6864         * @param userId the userId to query
6865         * @return true if the provider is enabled
6866         * @deprecated use {@link #LOCATION_MODE} or
6867         *             {@link LocationManager#isProviderEnabled(String)}
6868         * @hide
6869         */
6870        @Deprecated
6871        public static final boolean isLocationProviderEnabledForUser(ContentResolver cr, String provider, int userId) {
6872            String allowedProviders = Settings.Secure.getStringForUser(cr,
6873                    LOCATION_PROVIDERS_ALLOWED, userId);
6874            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
6875        }
6876
6877        /**
6878         * Thread-safe method for enabling or disabling a single location provider.
6879         * @param cr the content resolver to use
6880         * @param provider the location provider to enable or disable
6881         * @param enabled true if the provider should be enabled
6882         * @deprecated use {@link #putInt(ContentResolver, String, int)} and {@link #LOCATION_MODE}
6883         */
6884        @Deprecated
6885        public static final void setLocationProviderEnabled(ContentResolver cr,
6886                String provider, boolean enabled) {
6887            setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId());
6888        }
6889
6890        /**
6891         * Thread-safe method for enabling or disabling a single location provider.
6892         *
6893         * @param cr the content resolver to use
6894         * @param provider the location provider to enable or disable
6895         * @param enabled true if the provider should be enabled
6896         * @param userId the userId for which to enable/disable providers
6897         * @return true if the value was set, false on database errors
6898         * @deprecated use {@link #putIntForUser(ContentResolver, String, int, int)} and
6899         *             {@link #LOCATION_MODE}
6900         * @hide
6901         */
6902        @Deprecated
6903        public static final boolean setLocationProviderEnabledForUser(ContentResolver cr,
6904                String provider, boolean enabled, int userId) {
6905            synchronized (mLocationSettingsLock) {
6906                // to ensure thread safety, we write the provider name with a '+' or '-'
6907                // and let the SettingsProvider handle it rather than reading and modifying
6908                // the list of enabled providers.
6909                if (enabled) {
6910                    provider = "+" + provider;
6911                } else {
6912                    provider = "-" + provider;
6913                }
6914                return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
6915                        userId);
6916            }
6917        }
6918
6919        /**
6920         * Saves the current location mode into {@link #LOCATION_PREVIOUS_MODE}.
6921         */
6922        private static final boolean saveLocationModeForUser(ContentResolver cr, int userId) {
6923            final int mode = getLocationModeForUser(cr, userId);
6924            return putIntForUser(cr, Settings.Secure.LOCATION_PREVIOUS_MODE, mode, userId);
6925        }
6926
6927        /**
6928         * Restores the current location mode from {@link #LOCATION_PREVIOUS_MODE}.
6929         */
6930        private static final boolean restoreLocationModeForUser(ContentResolver cr, int userId) {
6931            int mode = getIntForUser(cr, Settings.Secure.LOCATION_PREVIOUS_MODE,
6932                    LOCATION_MODE_HIGH_ACCURACY, userId);
6933            // Make sure that the previous mode is never "off". Otherwise the user won't be able to
6934            // turn on location any longer.
6935            if (mode == LOCATION_MODE_OFF) {
6936                mode = LOCATION_MODE_HIGH_ACCURACY;
6937            }
6938            return setLocationModeForUser(cr, mode, userId);
6939        }
6940
6941        /**
6942         * Thread-safe method for setting the location mode to one of
6943         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
6944         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
6945         * Necessary because the mode is a composite of the underlying location provider
6946         * settings.
6947         *
6948         * @param cr the content resolver to use
6949         * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY}
6950         * @param userId the userId for which to change mode
6951         * @return true if the value was set, false on database errors
6952         *
6953         * @throws IllegalArgumentException if mode is not one of the supported values
6954         */
6955        private static final boolean setLocationModeForUser(ContentResolver cr, int mode,
6956                int userId) {
6957            synchronized (mLocationSettingsLock) {
6958                boolean gps = false;
6959                boolean network = false;
6960                switch (mode) {
6961                    case LOCATION_MODE_PREVIOUS:
6962                        // Retrieve the actual mode and set to that mode.
6963                        return restoreLocationModeForUser(cr, userId);
6964                    case LOCATION_MODE_OFF:
6965                        saveLocationModeForUser(cr, userId);
6966                        break;
6967                    case LOCATION_MODE_SENSORS_ONLY:
6968                        gps = true;
6969                        break;
6970                    case LOCATION_MODE_BATTERY_SAVING:
6971                        network = true;
6972                        break;
6973                    case LOCATION_MODE_HIGH_ACCURACY:
6974                        gps = true;
6975                        network = true;
6976                        break;
6977                    default:
6978                        throw new IllegalArgumentException("Invalid location mode: " + mode);
6979                }
6980                // Note it's important that we set the NLP mode first. The Google implementation
6981                // of NLP clears its NLP consent setting any time it receives a
6982                // LocationManager.PROVIDERS_CHANGED_ACTION broadcast and NLP is disabled. Also,
6983                // it shows an NLP consent dialog any time it receives the broadcast, NLP is
6984                // enabled, and the NLP consent is not set. If 1) we were to enable GPS first,
6985                // 2) a setup wizard has its own NLP consent UI that sets the NLP consent setting,
6986                // and 3) the receiver happened to complete before we enabled NLP, then the Google
6987                // NLP would detect the attempt to enable NLP and show a redundant NLP consent
6988                // dialog. Then the people who wrote the setup wizard would be sad.
6989                boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
6990                        cr, LocationManager.NETWORK_PROVIDER, network, userId);
6991                boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
6992                        cr, LocationManager.GPS_PROVIDER, gps, userId);
6993                return gpsSuccess && nlpSuccess;
6994            }
6995        }
6996
6997        /**
6998         * Thread-safe method for reading the location mode, returns one of
6999         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
7000         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. Necessary
7001         * because the mode is a composite of the underlying location provider settings.
7002         *
7003         * @param cr the content resolver to use
7004         * @param userId the userId for which to read the mode
7005         * @return the location mode
7006         */
7007        private static final int getLocationModeForUser(ContentResolver cr, int userId) {
7008            synchronized (mLocationSettingsLock) {
7009                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
7010                        cr, LocationManager.GPS_PROVIDER, userId);
7011                boolean networkEnabled = Settings.Secure.isLocationProviderEnabledForUser(
7012                        cr, LocationManager.NETWORK_PROVIDER, userId);
7013                if (gpsEnabled && networkEnabled) {
7014                    return LOCATION_MODE_HIGH_ACCURACY;
7015                } else if (gpsEnabled) {
7016                    return LOCATION_MODE_SENSORS_ONLY;
7017                } else if (networkEnabled) {
7018                    return LOCATION_MODE_BATTERY_SAVING;
7019                } else {
7020                    return LOCATION_MODE_OFF;
7021                }
7022            }
7023        }
7024    }
7025
7026    /**
7027     * Global system settings, containing preferences that always apply identically
7028     * to all defined users.  Applications can read these but are not allowed to write;
7029     * like the "Secure" settings, these are for preferences that the user must
7030     * explicitly modify through the system UI or specialized APIs for those values.
7031     */
7032    public static final class Global extends NameValueTable {
7033        /**
7034         * The content:// style URL for global secure settings items.  Not public.
7035         */
7036        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
7037
7038        /**
7039         * Whether users are allowed to add more users or guest from lockscreen.
7040         * <p>
7041         * Type: int
7042         * @hide
7043         */
7044        public static final String ADD_USERS_WHEN_LOCKED = "add_users_when_locked";
7045
7046        /**
7047         * Setting whether the global gesture for enabling accessibility is enabled.
7048         * If this gesture is enabled the user will be able to perfrom it to enable
7049         * the accessibility state without visiting the settings app.
7050         * @hide
7051         */
7052        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
7053                "enable_accessibility_global_gesture_enabled";
7054
7055        /**
7056         * Whether Airplane Mode is on.
7057         */
7058        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
7059
7060        /**
7061         * Whether Theater Mode is on.
7062         * {@hide}
7063         */
7064        @SystemApi
7065        public static final String THEATER_MODE_ON = "theater_mode_on";
7066
7067        /**
7068         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
7069         */
7070        public static final String RADIO_BLUETOOTH = "bluetooth";
7071
7072        /**
7073         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
7074         */
7075        public static final String RADIO_WIFI = "wifi";
7076
7077        /**
7078         * {@hide}
7079         */
7080        public static final String RADIO_WIMAX = "wimax";
7081        /**
7082         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
7083         */
7084        public static final String RADIO_CELL = "cell";
7085
7086        /**
7087         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
7088         */
7089        public static final String RADIO_NFC = "nfc";
7090
7091        /**
7092         * A comma separated list of radios that need to be disabled when airplane mode
7093         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
7094         * included in the comma separated list.
7095         */
7096        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
7097
7098        /**
7099         * A comma separated list of radios that should to be disabled when airplane mode
7100         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
7101         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
7102         * will be turned off when entering airplane mode, but the user will be able to reenable
7103         * Wifi in the Settings app.
7104         *
7105         * {@hide}
7106         */
7107        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
7108
7109        /**
7110         * A Long representing a bitmap of profiles that should be disabled when bluetooth starts.
7111         * See {@link android.bluetooth.BluetoothProfile}.
7112         * {@hide}
7113         */
7114        public static final String BLUETOOTH_DISABLED_PROFILES = "bluetooth_disabled_profiles";
7115
7116        /**
7117         * A semi-colon separated list of Bluetooth interoperability workarounds.
7118         * Each entry is a partial Bluetooth device address string and an integer representing
7119         * the feature to be disabled, separated by a comma. The integer must correspond
7120         * to a interoperability feature as defined in "interop.h" in /system/bt.
7121         * <p>
7122         * Example: <br/>
7123         *   "00:11:22,0;01:02:03:04,2"
7124         * @hide
7125         */
7126       public static final String BLUETOOTH_INTEROPERABILITY_LIST = "bluetooth_interoperability_list";
7127
7128        /**
7129         * The policy for deciding when Wi-Fi should go to sleep (which will in
7130         * turn switch to using the mobile data as an Internet connection).
7131         * <p>
7132         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
7133         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
7134         * {@link #WIFI_SLEEP_POLICY_NEVER}.
7135         */
7136        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
7137
7138        /**
7139         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
7140         * policy, which is to sleep shortly after the turning off
7141         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
7142         */
7143        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
7144
7145        /**
7146         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
7147         * the device is on battery, and never go to sleep when the device is
7148         * plugged in.
7149         */
7150        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
7151
7152        /**
7153         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
7154         */
7155        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
7156
7157        /**
7158         * Value to specify if the user prefers the date, time and time zone
7159         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
7160         */
7161        public static final String AUTO_TIME = "auto_time";
7162
7163        /**
7164         * Value to specify if the user prefers the time zone
7165         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
7166         */
7167        public static final String AUTO_TIME_ZONE = "auto_time_zone";
7168
7169        /**
7170         * URI for the car dock "in" event sound.
7171         * @hide
7172         */
7173        public static final String CAR_DOCK_SOUND = "car_dock_sound";
7174
7175        /**
7176         * URI for the car dock "out" event sound.
7177         * @hide
7178         */
7179        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
7180
7181        /**
7182         * URI for the desk dock "in" event sound.
7183         * @hide
7184         */
7185        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
7186
7187        /**
7188         * URI for the desk dock "out" event sound.
7189         * @hide
7190         */
7191        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
7192
7193        /**
7194         * Whether to play a sound for dock events.
7195         * @hide
7196         */
7197        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
7198
7199        /**
7200         * Whether to play a sound for dock events, only when an accessibility service is on.
7201         * @hide
7202         */
7203        public static final String DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY = "dock_sounds_enabled_when_accessbility";
7204
7205        /**
7206         * URI for the "device locked" (keyguard shown) sound.
7207         * @hide
7208         */
7209        public static final String LOCK_SOUND = "lock_sound";
7210
7211        /**
7212         * URI for the "device unlocked" sound.
7213         * @hide
7214         */
7215        public static final String UNLOCK_SOUND = "unlock_sound";
7216
7217        /**
7218         * URI for the "device is trusted" sound, which is played when the device enters the trusted
7219         * state without unlocking.
7220         * @hide
7221         */
7222        public static final String TRUSTED_SOUND = "trusted_sound";
7223
7224        /**
7225         * URI for the low battery sound file.
7226         * @hide
7227         */
7228        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
7229
7230        /**
7231         * Whether to play a sound for low-battery alerts.
7232         * @hide
7233         */
7234        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
7235
7236        /**
7237         * URI for the "wireless charging started" sound.
7238         * @hide
7239         */
7240        public static final String WIRELESS_CHARGING_STARTED_SOUND =
7241                "wireless_charging_started_sound";
7242
7243        /**
7244         * Whether to play a sound for charging events.
7245         * @hide
7246         */
7247        public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled";
7248
7249        /**
7250         * Whether we keep the device on while the device is plugged in.
7251         * Supported values are:
7252         * <ul>
7253         * <li>{@code 0} to never stay on while plugged in</li>
7254         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
7255         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
7256         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
7257         * </ul>
7258         * These values can be OR-ed together.
7259         */
7260        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
7261
7262        /**
7263         * When the user has enable the option to have a "bug report" command
7264         * in the power menu.
7265         * @hide
7266         */
7267        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
7268
7269        /**
7270         * Whether ADB is enabled.
7271         */
7272        public static final String ADB_ENABLED = "adb_enabled";
7273
7274        /**
7275         * Whether Views are allowed to save their attribute data.
7276         * @hide
7277         */
7278        public static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
7279
7280        /**
7281         * Whether assisted GPS should be enabled or not.
7282         * @hide
7283         */
7284        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
7285
7286        /**
7287         * Whether bluetooth is enabled/disabled
7288         * 0=disabled. 1=enabled.
7289         */
7290        public static final String BLUETOOTH_ON = "bluetooth_on";
7291
7292        /**
7293         * CDMA Cell Broadcast SMS
7294         *                            0 = CDMA Cell Broadcast SMS disabled
7295         *                            1 = CDMA Cell Broadcast SMS enabled
7296         * @hide
7297         */
7298        public static final String CDMA_CELL_BROADCAST_SMS =
7299                "cdma_cell_broadcast_sms";
7300
7301        /**
7302         * The CDMA roaming mode 0 = Home Networks, CDMA default
7303         *                       1 = Roaming on Affiliated networks
7304         *                       2 = Roaming on any networks
7305         * @hide
7306         */
7307        public static final String CDMA_ROAMING_MODE = "roaming_settings";
7308
7309        /**
7310         * The CDMA subscription mode 0 = RUIM/SIM (default)
7311         *                                1 = NV
7312         * @hide
7313         */
7314        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
7315
7316        /** Inactivity timeout to track mobile data activity.
7317        *
7318        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
7319        * infer the data activity of mobile network. After a period of no activity on mobile
7320        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
7321        * intent is fired to indicate a transition of network status from "active" to "idle". Any
7322        * subsequent activity on mobile networks triggers the firing of {@code
7323        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
7324        *
7325        * Network activity refers to transmitting or receiving data on the network interfaces.
7326        *
7327        * Tracking is disabled if set to zero or negative value.
7328        *
7329        * @hide
7330        */
7331       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
7332
7333       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
7334        * but for Wifi network.
7335        * @hide
7336        */
7337       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
7338
7339       /**
7340        * Whether or not data roaming is enabled. (0 = false, 1 = true)
7341        */
7342       public static final String DATA_ROAMING = "data_roaming";
7343
7344       /**
7345        * The value passed to a Mobile DataConnection via bringUp which defines the
7346        * number of retries to preform when setting up the initial connection. The default
7347        * value defined in DataConnectionTrackerBase#DEFAULT_MDC_INITIAL_RETRY is currently 1.
7348        * @hide
7349        */
7350       public static final String MDC_INITIAL_MAX_RETRY = "mdc_initial_max_retry";
7351
7352       /**
7353        * Whether any package can be on external storage. When this is true, any
7354        * package, regardless of manifest values, is a candidate for installing
7355        * or moving onto external storage. (0 = false, 1 = true)
7356        * @hide
7357        */
7358       public static final String FORCE_ALLOW_ON_EXTERNAL = "force_allow_on_external";
7359
7360        /**
7361         * Whether any activity can be resized. When this is true, any
7362         * activity, regardless of manifest values, can be resized for multi-window.
7363         * (0 = false, 1 = true)
7364         * @hide
7365         */
7366        public static final String DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES
7367                = "force_resizable_activities";
7368
7369        /**
7370         * Whether to enable experimental freeform support for windows.
7371         * @hide
7372         */
7373        public static final String DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT
7374                = "enable_freeform_support";
7375
7376       /**
7377        * Whether user has enabled development settings.
7378        */
7379       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
7380
7381       /**
7382        * Whether the device has been provisioned (0 = false, 1 = true).
7383        * <p>On a multiuser device with a separate system user, the screen may be locked
7384        * as soon as this is set to true and further activities cannot be launched on the
7385        * system user unless they are marked to show over keyguard.
7386        */
7387       public static final String DEVICE_PROVISIONED = "device_provisioned";
7388
7389       /**
7390        * Whether mobile data should be allowed while the device is being provisioned.
7391        * This allows the provisioning process to turn off mobile data before the user
7392        * has an opportunity to set things up, preventing other processes from burning
7393        * precious bytes before wifi is setup.
7394        * (0 = false, 1 = true)
7395        * @hide
7396        */
7397       public static final String DEVICE_PROVISIONING_MOBILE_DATA_ENABLED =
7398               "device_provisioning_mobile_data";
7399
7400       /**
7401        * The saved value for WindowManagerService.setForcedDisplaySize().
7402        * Two integers separated by a comma.  If unset, then use the real display size.
7403        * @hide
7404        */
7405       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
7406
7407       /**
7408        * The saved value for WindowManagerService.setForcedDisplayScalingMode().
7409        * 0 or unset if scaling is automatic, 1 if scaling is disabled.
7410        * @hide
7411        */
7412       public static final String DISPLAY_SCALING_FORCE = "display_scaling_force";
7413
7414       /**
7415        * The maximum size, in bytes, of a download that the download manager will transfer over
7416        * a non-wifi connection.
7417        * @hide
7418        */
7419       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
7420               "download_manager_max_bytes_over_mobile";
7421
7422       /**
7423        * The recommended maximum size, in bytes, of a download that the download manager should
7424        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
7425        * have the option to start the download over the mobile connection anyway.
7426        * @hide
7427        */
7428       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
7429               "download_manager_recommended_max_bytes_over_mobile";
7430
7431       /**
7432        * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
7433        */
7434       @Deprecated
7435       public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
7436
7437       /**
7438        * Whether HDMI control shall be enabled. If disabled, no CEC/MHL command will be
7439        * sent or processed. (0 = false, 1 = true)
7440        * @hide
7441        */
7442       public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled";
7443
7444       /**
7445        * Whether HDMI system audio is enabled. If enabled, TV internal speaker is muted,
7446        * and the output is redirected to AV Receiver connected via
7447        * {@Global#HDMI_SYSTEM_AUDIO_OUTPUT}.
7448        * @hide
7449        */
7450       public static final String HDMI_SYSTEM_AUDIO_ENABLED = "hdmi_system_audio_enabled";
7451
7452       /**
7453        * Whether TV will automatically turn on upon reception of the CEC command
7454        * &lt;Text View On&gt; or &lt;Image View On&gt;. (0 = false, 1 = true)
7455        * @hide
7456        */
7457       public static final String HDMI_CONTROL_AUTO_WAKEUP_ENABLED =
7458               "hdmi_control_auto_wakeup_enabled";
7459
7460       /**
7461        * Whether TV will also turn off other CEC devices when it goes to standby mode.
7462        * (0 = false, 1 = true)
7463        * @hide
7464        */
7465       public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
7466               "hdmi_control_auto_device_off_enabled";
7467
7468       /**
7469        * Whether TV will switch to MHL port when a mobile device is plugged in.
7470        * (0 = false, 1 = true)
7471        * @hide
7472        */
7473       public static final String MHL_INPUT_SWITCHING_ENABLED = "mhl_input_switching_enabled";
7474
7475       /**
7476        * Whether TV will charge the mobile device connected at MHL port. (0 = false, 1 = true)
7477        * @hide
7478        */
7479       public static final String MHL_POWER_CHARGE_ENABLED = "mhl_power_charge_enabled";
7480
7481       /**
7482        * Whether mobile data connections are allowed by the user.  See
7483        * ConnectivityManager for more info.
7484        * @hide
7485        */
7486       public static final String MOBILE_DATA = "mobile_data";
7487
7488       /**
7489        * Whether the mobile data connection should remain active even when higher
7490        * priority networks like WiFi are active, to help make network switching faster.
7491        *
7492        * See ConnectivityService for more info.
7493        *
7494        * (0 = disabled, 1 = enabled)
7495        * @hide
7496        */
7497       public static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
7498
7499        /**
7500         * Size of the event buffer for IP connectivity metrics.
7501         * @hide
7502         */
7503        public static final String CONNECTIVITY_METRICS_BUFFER_SIZE =
7504              "connectivity_metrics_buffer_size";
7505
7506       /** {@hide} */
7507       public static final String NETSTATS_ENABLED = "netstats_enabled";
7508       /** {@hide} */
7509       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
7510       /** {@hide} */
7511       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
7512       /** {@hide} */
7513       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
7514       /** {@hide} */
7515       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
7516
7517       /** {@hide} */
7518       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
7519       /** {@hide} */
7520       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
7521       /** {@hide} */
7522       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
7523       /** {@hide} */
7524       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
7525
7526       /** {@hide} */
7527       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
7528       /** {@hide} */
7529       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
7530       /** {@hide} */
7531       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
7532       /** {@hide} */
7533       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
7534
7535       /** {@hide} */
7536       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
7537       /** {@hide} */
7538       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
7539       /** {@hide} */
7540       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
7541       /** {@hide} */
7542       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
7543
7544       /**
7545        * User preference for which network(s) should be used. Only the
7546        * connectivity service should touch this.
7547        */
7548       public static final String NETWORK_PREFERENCE = "network_preference";
7549
7550       /**
7551        * Which package name to use for network scoring. If null, or if the package is not a valid
7552        * scorer app, external network scores will neither be requested nor accepted.
7553        * @hide
7554        */
7555       public static final String NETWORK_SCORER_APP = "network_scorer_app";
7556
7557       /**
7558        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
7559        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
7560        * exceeded.
7561        * @hide
7562        */
7563       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
7564
7565       /**
7566        * The length of time in milli-seconds that automatic small adjustments to
7567        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
7568        * @hide
7569        */
7570       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
7571
7572       /** Preferred NTP server. {@hide} */
7573       public static final String NTP_SERVER = "ntp_server";
7574       /** Timeout in milliseconds to wait for NTP server. {@hide} */
7575       public static final String NTP_TIMEOUT = "ntp_timeout";
7576
7577       /** {@hide} */
7578       public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval";
7579
7580       /**
7581        * Sample validity in seconds to configure for the system DNS resolver.
7582        * {@hide}
7583        */
7584       public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS =
7585               "dns_resolver_sample_validity_seconds";
7586
7587       /**
7588        * Success threshold in percent for use with the system DNS resolver.
7589        * {@hide}
7590        */
7591       public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT =
7592                "dns_resolver_success_threshold_percent";
7593
7594       /**
7595        * Minimum number of samples needed for statistics to be considered meaningful in the
7596        * system DNS resolver.
7597        * {@hide}
7598        */
7599       public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples";
7600
7601       /**
7602        * Maximum number taken into account for statistics purposes in the system DNS resolver.
7603        * {@hide}
7604        */
7605       public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples";
7606
7607       /**
7608        * Whether to disable the automatic scheduling of system updates.
7609        * 1 = system updates won't be automatically scheduled (will always
7610        * present notification instead).
7611        * 0 = system updates will be automatically scheduled. (default)
7612        * @hide
7613        */
7614       @SystemApi
7615       public static final String OTA_DISABLE_AUTOMATIC_UPDATE = "ota_disable_automatic_update";
7616
7617       /**
7618        * Whether the package manager should send package verification broadcasts for verifiers to
7619        * review apps prior to installation.
7620        * 1 = request apps to be verified prior to installation, if a verifier exists.
7621        * 0 = do not verify apps before installation
7622        * @hide
7623        */
7624       public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
7625
7626       /** Timeout for package verification.
7627        * @hide */
7628       public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
7629
7630       /** Default response code for package verification.
7631        * @hide */
7632       public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
7633
7634       /**
7635        * Show package verification setting in the Settings app.
7636        * 1 = show (default)
7637        * 0 = hide
7638        * @hide
7639        */
7640       public static final String PACKAGE_VERIFIER_SETTING_VISIBLE = "verifier_setting_visible";
7641
7642       /**
7643        * Run package verification on apps installed through ADB/ADT/USB
7644        * 1 = perform package verification on ADB installs (default)
7645        * 0 = bypass package verification on ADB installs
7646        * @hide
7647        */
7648       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
7649
7650       /**
7651        * Time since last fstrim (milliseconds) after which we force one to happen
7652        * during device startup.  If unset, the default is 3 days.
7653        * @hide
7654        */
7655       public static final String FSTRIM_MANDATORY_INTERVAL = "fstrim_mandatory_interval";
7656
7657       /**
7658        * The interval in milliseconds at which to check packet counts on the
7659        * mobile data interface when screen is on, to detect possible data
7660        * connection problems.
7661        * @hide
7662        */
7663       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
7664               "pdp_watchdog_poll_interval_ms";
7665
7666       /**
7667        * The interval in milliseconds at which to check packet counts on the
7668        * mobile data interface when screen is off, to detect possible data
7669        * connection problems.
7670        * @hide
7671        */
7672       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
7673               "pdp_watchdog_long_poll_interval_ms";
7674
7675       /**
7676        * The interval in milliseconds at which to check packet counts on the
7677        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
7678        * outgoing packets has been reached without incoming packets.
7679        * @hide
7680        */
7681       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
7682               "pdp_watchdog_error_poll_interval_ms";
7683
7684       /**
7685        * The number of outgoing packets sent without seeing an incoming packet
7686        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
7687        * device is logged to the event log
7688        * @hide
7689        */
7690       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
7691               "pdp_watchdog_trigger_packet_count";
7692
7693       /**
7694        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
7695        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
7696        * attempting data connection recovery.
7697        * @hide
7698        */
7699       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
7700               "pdp_watchdog_error_poll_count";
7701
7702       /**
7703        * The number of failed PDP reset attempts before moving to something more
7704        * drastic: re-registering to the network.
7705        * @hide
7706        */
7707       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
7708               "pdp_watchdog_max_pdp_reset_fail_count";
7709
7710       /**
7711        * A positive value indicates how often the SamplingProfiler
7712        * should take snapshots. Zero value means SamplingProfiler
7713        * is disabled.
7714        *
7715        * @hide
7716        */
7717       public static final String SAMPLING_PROFILER_MS = "sampling_profiler_ms";
7718
7719       /**
7720        * URL to open browser on to allow user to manage a prepay account
7721        * @hide
7722        */
7723       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
7724               "setup_prepaid_data_service_url";
7725
7726       /**
7727        * URL to attempt a GET on to see if this is a prepay device
7728        * @hide
7729        */
7730       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
7731               "setup_prepaid_detection_target_url";
7732
7733       /**
7734        * Host to check for a redirect to after an attempt to GET
7735        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
7736        * this is a prepaid device with zero balance.)
7737        * @hide
7738        */
7739       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
7740               "setup_prepaid_detection_redir_host";
7741
7742       /**
7743        * The interval in milliseconds at which to check the number of SMS sent out without asking
7744        * for use permit, to limit the un-authorized SMS usage.
7745        *
7746        * @hide
7747        */
7748       public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
7749               "sms_outgoing_check_interval_ms";
7750
7751       /**
7752        * The number of outgoing SMS sent without asking for user permit (of {@link
7753        * #SMS_OUTGOING_CHECK_INTERVAL_MS}
7754        *
7755        * @hide
7756        */
7757       public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
7758               "sms_outgoing_check_max_count";
7759
7760       /**
7761        * Used to disable SMS short code confirmation - defaults to true.
7762        * True indcates we will do the check, etc.  Set to false to disable.
7763        * @see com.android.internal.telephony.SmsUsageMonitor
7764        * @hide
7765        */
7766       public static final String SMS_SHORT_CODE_CONFIRMATION = "sms_short_code_confirmation";
7767
7768        /**
7769         * Used to select which country we use to determine premium sms codes.
7770         * One of com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_SIM,
7771         * com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_NETWORK,
7772         * or com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_BOTH.
7773         * @hide
7774         */
7775        public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule";
7776
7777       /**
7778        * Used to select TCP's default initial receiver window size in segments - defaults to a build config value
7779        * @hide
7780        */
7781       public static final String TCP_DEFAULT_INIT_RWND = "tcp_default_init_rwnd";
7782
7783       /**
7784        * Used to disable Tethering on a device - defaults to true
7785        * @hide
7786        */
7787       public static final String TETHER_SUPPORTED = "tether_supported";
7788
7789       /**
7790        * Used to require DUN APN on the device or not - defaults to a build config value
7791        * which defaults to false
7792        * @hide
7793        */
7794       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
7795
7796       /**
7797        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
7798        * corresponding build config values are set it will override the APN DB
7799        * values.
7800        * Consists of a comma seperated list of strings:
7801        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
7802        * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
7803        * @hide
7804        */
7805       public static final String TETHER_DUN_APN = "tether_dun_apn";
7806
7807       /**
7808        * List of carrier apps which are whitelisted to prompt the user for install when
7809        * a sim card with matching uicc carrier privilege rules is inserted.
7810        *
7811        * The value is "package1;package2;..."
7812        * @hide
7813        */
7814       public static final String CARRIER_APP_WHITELIST = "carrier_app_whitelist";
7815
7816       /**
7817        * USB Mass Storage Enabled
7818        */
7819       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
7820
7821       /**
7822        * If this setting is set (to anything), then all references
7823        * to Gmail on the device must change to Google Mail.
7824        */
7825       public static final String USE_GOOGLE_MAIL = "use_google_mail";
7826
7827        /**
7828         * Webview Data reduction proxy key.
7829         * @hide
7830         */
7831        public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
7832                "webview_data_reduction_proxy_key";
7833
7834       /**
7835        * Whether or not the WebView fallback mechanism should be enabled.
7836        * 0=disabled, 1=enabled.
7837        * @hide
7838        */
7839       public static final String WEBVIEW_FALLBACK_LOGIC_ENABLED =
7840               "webview_fallback_logic_enabled";
7841
7842       /**
7843        * Name of the package used as WebView provider (if unset the provider is instead determined
7844        * by the system).
7845        * @hide
7846        */
7847       public static final String WEBVIEW_PROVIDER = "webview_provider";
7848
7849       /**
7850        * Developer setting to enable WebView multiprocess rendering.
7851        * @hide
7852        */
7853       @SystemApi
7854       public static final String WEBVIEW_MULTIPROCESS = "webview_multiprocess";
7855
7856       /**
7857        * The maximum number of notifications shown in 24 hours when switching networks.
7858        * @hide
7859        */
7860       public static final String NETWORK_SWITCH_NOTIFICATION_DAILY_LIMIT =
7861              "network_switch_notification_daily_limit";
7862
7863       /**
7864        * The minimum time in milliseconds between notifications when switching networks.
7865        * @hide
7866        */
7867       public static final String NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS =
7868              "network_switch_notification_rate_limit_millis";
7869
7870       /**
7871        * Whether to automatically switch away from wifi networks that lose Internet access.
7872        * Only meaningful if config_networkAvoidBadWifi is set to 0, otherwise the system always
7873        * avoids such networks. Valid values are:
7874        *
7875        * 0: Don't avoid bad wifi, don't prompt the user. Get stuck on bad wifi like it's 2013.
7876        * null: Ask the user whether to switch away from bad wifi.
7877        * 1: Avoid bad wifi.
7878        *
7879        * @hide
7880        */
7881       public static final String NETWORK_AVOID_BAD_WIFI = "network_avoid_bad_wifi";
7882
7883       /**
7884        * Whether Wifi display is enabled/disabled
7885        * 0=disabled. 1=enabled.
7886        * @hide
7887        */
7888       public static final String WIFI_DISPLAY_ON = "wifi_display_on";
7889
7890       /**
7891        * Whether Wifi display certification mode is enabled/disabled
7892        * 0=disabled. 1=enabled.
7893        * @hide
7894        */
7895       public static final String WIFI_DISPLAY_CERTIFICATION_ON =
7896               "wifi_display_certification_on";
7897
7898       /**
7899        * WPS Configuration method used by Wifi display, this setting only
7900        * takes effect when WIFI_DISPLAY_CERTIFICATION_ON is 1 (enabled).
7901        *
7902        * Possible values are:
7903        *
7904        * WpsInfo.INVALID: use default WPS method chosen by framework
7905        * WpsInfo.PBC    : use Push button
7906        * WpsInfo.KEYPAD : use Keypad
7907        * WpsInfo.DISPLAY: use Display
7908        * @hide
7909        */
7910       public static final String WIFI_DISPLAY_WPS_CONFIG =
7911           "wifi_display_wps_config";
7912
7913       /**
7914        * Whether to notify the user of open networks.
7915        * <p>
7916        * If not connected and the scan results have an open network, we will
7917        * put this notification up. If we attempt to connect to a network or
7918        * the open network(s) disappear, we remove the notification. When we
7919        * show the notification, we will not show it again for
7920        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
7921        */
7922       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
7923               "wifi_networks_available_notification_on";
7924       /**
7925        * {@hide}
7926        */
7927       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
7928               "wimax_networks_available_notification_on";
7929
7930       /**
7931        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
7932        * Connecting to a network will reset the timer.
7933        */
7934       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
7935               "wifi_networks_available_repeat_delay";
7936
7937       /**
7938        * 802.11 country code in ISO 3166 format
7939        * @hide
7940        */
7941       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
7942
7943       /**
7944        * The interval in milliseconds to issue wake up scans when wifi needs
7945        * to connect. This is necessary to connect to an access point when
7946        * device is on the move and the screen is off.
7947        * @hide
7948        */
7949       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
7950               "wifi_framework_scan_interval_ms";
7951
7952       /**
7953        * The interval in milliseconds after which Wi-Fi is considered idle.
7954        * When idle, it is possible for the device to be switched from Wi-Fi to
7955        * the mobile data network.
7956        * @hide
7957        */
7958       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
7959
7960       /**
7961        * When the number of open networks exceeds this number, the
7962        * least-recently-used excess networks will be removed.
7963        */
7964       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
7965
7966       /**
7967        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
7968        */
7969       public static final String WIFI_ON = "wifi_on";
7970
7971       /**
7972        * Setting to allow scans to be enabled even wifi is turned off for connectivity.
7973        * @hide
7974        */
7975       public static final String WIFI_SCAN_ALWAYS_AVAILABLE =
7976                "wifi_scan_always_enabled";
7977
7978        /**
7979         * Value to specify if Wi-Fi Wakeup feature is enabled.
7980         *
7981         * Type: int (0 for false, 1 for true)
7982         * @hide
7983         */
7984        @SystemApi
7985        public static final String WIFI_WAKEUP_ENABLED = "wifi_wakeup_enabled";
7986
7987        /**
7988         * Value to specify if network recommendations from
7989         * {@link com.android.server.NetworkScoreService} are enabled.
7990         *
7991         * Type: int (0 for false, 1 for true)
7992         * @hide
7993         */
7994        @SystemApi
7995        public static final String NETWORK_RECOMMENDATIONS_ENABLED =
7996                "network_recommendations_enabled";
7997
7998       /**
7999        * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
8000        * connectivity.
8001        * @hide
8002        */
8003       public static final String BLE_SCAN_ALWAYS_AVAILABLE =
8004               "ble_scan_always_enabled";
8005
8006       /**
8007        * Used to save the Wifi_ON state prior to tethering.
8008        * This state will be checked to restore Wifi after
8009        * the user turns off tethering.
8010        *
8011        * @hide
8012        */
8013       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
8014
8015       /**
8016        * The interval in milliseconds to scan as used by the wifi supplicant
8017        * @hide
8018        */
8019       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
8020               "wifi_supplicant_scan_interval_ms";
8021
8022        /**
8023         * whether frameworks handles wifi auto-join
8024         * @hide
8025         */
8026       public static final String WIFI_ENHANCED_AUTO_JOIN =
8027                "wifi_enhanced_auto_join";
8028
8029        /**
8030         * whether settings show RSSI
8031         * @hide
8032         */
8033        public static final String WIFI_NETWORK_SHOW_RSSI =
8034                "wifi_network_show_rssi";
8035
8036        /**
8037        * The interval in milliseconds to scan at supplicant when p2p is connected
8038        * @hide
8039        */
8040       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
8041               "wifi_scan_interval_p2p_connected_ms";
8042
8043       /**
8044        * Whether the Wi-Fi watchdog is enabled.
8045        */
8046       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
8047
8048       /**
8049        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
8050        * the setting needs to be set to 0 to disable it.
8051        * @hide
8052        */
8053       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
8054               "wifi_watchdog_poor_network_test_enabled";
8055
8056       /**
8057        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
8058        * needs to be set to 0 to disable it.
8059        * @hide
8060        */
8061       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
8062               "wifi_suspend_optimizations_enabled";
8063
8064       /**
8065        * Setting to enable verbose logging in Wi-Fi; disabled by default, and setting to 1
8066        * will enable it. In the future, additional values may be supported.
8067        * @hide
8068        */
8069       public static final String WIFI_VERBOSE_LOGGING_ENABLED =
8070               "wifi_verbose_logging_enabled";
8071
8072       /**
8073        * The maximum number of times we will retry a connection to an access
8074        * point for which we have failed in acquiring an IP address from DHCP.
8075        * A value of N means that we will make N+1 connection attempts in all.
8076        */
8077       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
8078
8079       /**
8080        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
8081        * data connectivity to be established after a disconnect from Wi-Fi.
8082        */
8083       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
8084           "wifi_mobile_data_transition_wakelock_timeout_ms";
8085
8086       /**
8087        * This setting controls whether WiFi configurations created by a Device Owner app
8088        * should be locked down (that is, be editable or removable only by the Device Owner App,
8089        * not even by Settings app).
8090        * This setting takes integer values. Non-zero values mean DO created configurations
8091        * are locked down. Value of zero means they are not. Default value in the absence of
8092        * actual value to this setting is 0.
8093        */
8094       public static final String WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN =
8095               "wifi_device_owner_configs_lockdown";
8096
8097       /**
8098        * The operational wifi frequency band
8099        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
8100        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
8101        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
8102        *
8103        * @hide
8104        */
8105       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
8106
8107       /**
8108        * The Wi-Fi peer-to-peer device name
8109        * @hide
8110        */
8111       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
8112
8113       /**
8114        * The min time between wifi disable and wifi enable
8115        * @hide
8116        */
8117       public static final String WIFI_REENABLE_DELAY_MS = "wifi_reenable_delay";
8118
8119       /**
8120        * Timeout for ephemeral networks when all known BSSIDs go out of range. We will disconnect
8121        * from an ephemeral network if there is no BSSID for that network with a non-null score that
8122        * has been seen in this time period.
8123        *
8124        * If this is less than or equal to zero, we use a more conservative behavior and only check
8125        * for a non-null score from the currently connected or target BSSID.
8126        * @hide
8127        */
8128       public static final String WIFI_EPHEMERAL_OUT_OF_RANGE_TIMEOUT_MS =
8129               "wifi_ephemeral_out_of_range_timeout_ms";
8130
8131       /**
8132        * The number of milliseconds to delay when checking for data stalls during
8133        * non-aggressive detection. (screen is turned off.)
8134        * @hide
8135        */
8136       public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
8137               "data_stall_alarm_non_aggressive_delay_in_ms";
8138
8139       /**
8140        * The number of milliseconds to delay when checking for data stalls during
8141        * aggressive detection. (screen on or suspected data stall)
8142        * @hide
8143        */
8144       public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
8145               "data_stall_alarm_aggressive_delay_in_ms";
8146
8147       /**
8148        * The number of milliseconds to allow the provisioning apn to remain active
8149        * @hide
8150        */
8151       public static final String PROVISIONING_APN_ALARM_DELAY_IN_MS =
8152               "provisioning_apn_alarm_delay_in_ms";
8153
8154       /**
8155        * The interval in milliseconds at which to check gprs registration
8156        * after the first registration mismatch of gprs and voice service,
8157        * to detect possible data network registration problems.
8158        *
8159        * @hide
8160        */
8161       public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
8162               "gprs_register_check_period_ms";
8163
8164       /**
8165        * Nonzero causes Log.wtf() to crash.
8166        * @hide
8167        */
8168       public static final String WTF_IS_FATAL = "wtf_is_fatal";
8169
8170       /**
8171        * Ringer mode. This is used internally, changing this value will not
8172        * change the ringer mode. See AudioManager.
8173        */
8174       public static final String MODE_RINGER = "mode_ringer";
8175
8176       /**
8177        * Overlay display devices setting.
8178        * The associated value is a specially formatted string that describes the
8179        * size and density of simulated secondary display devices.
8180        * <p>
8181        * Format: {width}x{height}/{dpi};...
8182        * </p><p>
8183        * Example:
8184        * <ul>
8185        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
8186        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
8187        * at 1080p and the second at 720p.</li>
8188        * <li>If the value is empty, then no overlay display devices are created.</li>
8189        * </ul></p>
8190        *
8191        * @hide
8192        */
8193       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
8194
8195        /**
8196         * Threshold values for the duration and level of a discharge cycle,
8197         * under which we log discharge cycle info.
8198         *
8199         * @hide
8200         */
8201        public static final String
8202                BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold";
8203
8204        /** @hide */
8205        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
8206
8207        /**
8208         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR
8209         * intents on application crashes and ANRs. If this is disabled, the
8210         * crash/ANR dialog will never display the "Report" button.
8211         * <p>
8212         * Type: int (0 = disallow, 1 = allow)
8213         *
8214         * @hide
8215         */
8216        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
8217
8218        /**
8219         * Maximum age of entries kept by {@link DropBoxManager}.
8220         *
8221         * @hide
8222         */
8223        public static final String DROPBOX_AGE_SECONDS = "dropbox_age_seconds";
8224
8225        /**
8226         * Maximum number of entry files which {@link DropBoxManager} will keep
8227         * around.
8228         *
8229         * @hide
8230         */
8231        public static final String DROPBOX_MAX_FILES = "dropbox_max_files";
8232
8233        /**
8234         * Maximum amount of disk space used by {@link DropBoxManager} no matter
8235         * what.
8236         *
8237         * @hide
8238         */
8239        public static final String DROPBOX_QUOTA_KB = "dropbox_quota_kb";
8240
8241        /**
8242         * Percent of free disk (excluding reserve) which {@link DropBoxManager}
8243         * will use.
8244         *
8245         * @hide
8246         */
8247        public static final String DROPBOX_QUOTA_PERCENT = "dropbox_quota_percent";
8248
8249        /**
8250         * Percent of total disk which {@link DropBoxManager} will never dip
8251         * into.
8252         *
8253         * @hide
8254         */
8255        public static final String DROPBOX_RESERVE_PERCENT = "dropbox_reserve_percent";
8256
8257        /**
8258         * Prefix for per-tag dropbox disable/enable settings.
8259         *
8260         * @hide
8261         */
8262        public static final String DROPBOX_TAG_PREFIX = "dropbox:";
8263
8264        /**
8265         * Lines of logcat to include with system crash/ANR/etc. reports, as a
8266         * prefix of the dropbox tag of the report type. For example,
8267         * "logcat_for_system_server_anr" controls the lines of logcat captured
8268         * with system server ANR reports. 0 to disable.
8269         *
8270         * @hide
8271         */
8272        public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
8273
8274        /**
8275         * The interval in minutes after which the amount of free storage left
8276         * on the device is logged to the event log
8277         *
8278         * @hide
8279         */
8280        public static final String SYS_FREE_STORAGE_LOG_INTERVAL = "sys_free_storage_log_interval";
8281
8282        /**
8283         * Threshold for the amount of change in disk free space required to
8284         * report the amount of free space. Used to prevent spamming the logs
8285         * when the disk free space isn't changing frequently.
8286         *
8287         * @hide
8288         */
8289        public static final String
8290                DISK_FREE_CHANGE_REPORTING_THRESHOLD = "disk_free_change_reporting_threshold";
8291
8292        /**
8293         * Minimum percentage of free storage on the device that is used to
8294         * determine if the device is running low on storage. The default is 10.
8295         * <p>
8296         * Say this value is set to 10, the device is considered running low on
8297         * storage if 90% or more of the device storage is filled up.
8298         *
8299         * @hide
8300         */
8301        public static final String
8302                SYS_STORAGE_THRESHOLD_PERCENTAGE = "sys_storage_threshold_percentage";
8303
8304        /**
8305         * Maximum byte size of the low storage threshold. This is to ensure
8306         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in an
8307         * overly large threshold for large storage devices. Currently this must
8308         * be less than 2GB. This default is 500MB.
8309         *
8310         * @hide
8311         */
8312        public static final String
8313                SYS_STORAGE_THRESHOLD_MAX_BYTES = "sys_storage_threshold_max_bytes";
8314
8315        /**
8316         * Minimum bytes of free storage on the device before the data partition
8317         * is considered full. By default, 1 MB is reserved to avoid system-wide
8318         * SQLite disk full exceptions.
8319         *
8320         * @hide
8321         */
8322        public static final String
8323                SYS_STORAGE_FULL_THRESHOLD_BYTES = "sys_storage_full_threshold_bytes";
8324
8325        /**
8326         * The maximum reconnect delay for short network outages or when the
8327         * network is suspended due to phone use.
8328         *
8329         * @hide
8330         */
8331        public static final String
8332                SYNC_MAX_RETRY_DELAY_IN_SECONDS = "sync_max_retry_delay_in_seconds";
8333
8334        /**
8335         * The number of milliseconds to delay before sending out
8336         * {@link ConnectivityManager#CONNECTIVITY_ACTION} broadcasts. Ignored.
8337         *
8338         * @hide
8339         */
8340        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
8341
8342
8343        /**
8344         * Network sampling interval, in seconds. We'll generate link information
8345         * about bytes/packets sent and error rates based on data sampled in this interval
8346         *
8347         * @hide
8348         */
8349
8350        public static final String CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS =
8351                "connectivity_sampling_interval_in_seconds";
8352
8353        /**
8354         * The series of successively longer delays used in retrying to download PAC file.
8355         * Last delay is used between successful PAC downloads.
8356         *
8357         * @hide
8358         */
8359        public static final String PAC_CHANGE_DELAY = "pac_change_delay";
8360
8361        /**
8362         * Don't attempt to detect captive portals.
8363         *
8364         * @hide
8365         */
8366        public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0;
8367
8368        /**
8369         * When detecting a captive portal, display a notification that
8370         * prompts the user to sign in.
8371         *
8372         * @hide
8373         */
8374        public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1;
8375
8376        /**
8377         * When detecting a captive portal, immediately disconnect from the
8378         * network and do not reconnect to that network in the future.
8379         *
8380         * @hide
8381         */
8382        public static final int CAPTIVE_PORTAL_MODE_AVOID = 2;
8383
8384        /**
8385         * What to do when connecting a network that presents a captive portal.
8386         * Must be one of the CAPTIVE_PORTAL_MODE_* constants above.
8387         *
8388         * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT.
8389         * @hide
8390         */
8391        public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode";
8392
8393        /**
8394         * Setting to turn off captive portal detection. Feature is enabled by
8395         * default and the setting needs to be set to 0 to disable it.
8396         *
8397         * @deprecated use CAPTIVE_PORTAL_MODE_IGNORE to disable captive portal detection
8398         * @hide
8399         */
8400        @Deprecated
8401        public static final String
8402                CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled";
8403
8404        /**
8405         * The server used for captive portal detection upon a new conection. A
8406         * 204 response code from the server is used for validation.
8407         * TODO: remove this deprecated symbol.
8408         *
8409         * @hide
8410         */
8411        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
8412
8413        /**
8414         * The URL used for HTTPS captive portal detection upon a new connection.
8415         * A 204 response code from the server is used for validation.
8416         *
8417         * @hide
8418         */
8419        public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url";
8420
8421        /**
8422         * The URL used for HTTP captive portal detection upon a new connection.
8423         * A 204 response code from the server is used for validation.
8424         *
8425         * @hide
8426         */
8427        public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url";
8428
8429        /**
8430         * The URL used for fallback HTTP captive portal detection when previous HTTP
8431         * and HTTPS captive portal detection attemps did not return a conclusive answer.
8432         *
8433         * @hide
8434         */
8435        public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url";
8436
8437        /**
8438         * Whether to use HTTPS for network validation. This is enabled by default and the setting
8439         * needs to be set to 0 to disable it. This setting is a misnomer because captive portals
8440         * don't actually use HTTPS, but it's consistent with the other settings.
8441         *
8442         * @hide
8443         */
8444        public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https";
8445
8446        /**
8447         * Which User-Agent string to use in the header of the captive portal detection probes.
8448         * The User-Agent field is unset when this setting has no value (HttpUrlConnection default).
8449         *
8450         * @hide
8451         */
8452        public static final String CAPTIVE_PORTAL_USER_AGENT = "captive_portal_user_agent";
8453
8454        /**
8455         * Whether network service discovery is enabled.
8456         *
8457         * @hide
8458         */
8459        public static final String NSD_ON = "nsd_on";
8460
8461        /**
8462         * Let user pick default install location.
8463         *
8464         * @hide
8465         */
8466        public static final String SET_INSTALL_LOCATION = "set_install_location";
8467
8468        /**
8469         * Default install location value.
8470         * 0 = auto, let system decide
8471         * 1 = internal
8472         * 2 = sdcard
8473         * @hide
8474         */
8475        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
8476
8477        /**
8478         * ms during which to consume extra events related to Inet connection
8479         * condition after a transtion to fully-connected
8480         *
8481         * @hide
8482         */
8483        public static final String
8484                INET_CONDITION_DEBOUNCE_UP_DELAY = "inet_condition_debounce_up_delay";
8485
8486        /**
8487         * ms during which to consume extra events related to Inet connection
8488         * condtion after a transtion to partly-connected
8489         *
8490         * @hide
8491         */
8492        public static final String
8493                INET_CONDITION_DEBOUNCE_DOWN_DELAY = "inet_condition_debounce_down_delay";
8494
8495        /** {@hide} */
8496        public static final String
8497                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
8498
8499        /**
8500         * Host name and port for global http proxy. Uses ':' seperator for
8501         * between host and port.
8502         */
8503        public static final String HTTP_PROXY = "http_proxy";
8504
8505        /**
8506         * Host name for global http proxy. Set via ConnectivityManager.
8507         *
8508         * @hide
8509         */
8510        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
8511
8512        /**
8513         * Integer host port for global http proxy. Set via ConnectivityManager.
8514         *
8515         * @hide
8516         */
8517        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
8518
8519        /**
8520         * Exclusion list for global proxy. This string contains a list of
8521         * comma-separated domains where the global proxy does not apply.
8522         * Domains should be listed in a comma- separated list. Example of
8523         * acceptable formats: ".domain1.com,my.domain2.com" Use
8524         * ConnectivityManager to set/get.
8525         *
8526         * @hide
8527         */
8528        public static final String
8529                GLOBAL_HTTP_PROXY_EXCLUSION_LIST = "global_http_proxy_exclusion_list";
8530
8531        /**
8532         * The location PAC File for the proxy.
8533         * @hide
8534         */
8535        public static final String
8536                GLOBAL_HTTP_PROXY_PAC = "global_proxy_pac_url";
8537
8538        /**
8539         * Enables the UI setting to allow the user to specify the global HTTP
8540         * proxy and associated exclusion list.
8541         *
8542         * @hide
8543         */
8544        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
8545
8546        /**
8547         * Setting for default DNS in case nobody suggests one
8548         *
8549         * @hide
8550         */
8551        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
8552
8553        /** {@hide} */
8554        public static final String
8555                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
8556        /** {@hide} */
8557        public static final String
8558                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
8559        /** {@hide} */
8560        public static final String
8561                BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX = "bluetooth_a2dp_src_priority_";
8562        /** {@hide} */
8563        public static final String
8564                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
8565        /** {@hide} */
8566        public static final String
8567                BLUETOOTH_MAP_PRIORITY_PREFIX = "bluetooth_map_priority_";
8568        /** {@hide} */
8569        public static final String
8570                BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX = "bluetooth_map_client_priority_";
8571        /** {@hide} */
8572        public static final String
8573                BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX = "bluetooth_pbap_client_priority_";
8574        /** {@hide} */
8575        public static final String
8576                BLUETOOTH_SAP_PRIORITY_PREFIX = "bluetooth_sap_priority_";
8577        /** {@hide} */
8578        public static final String
8579                BLUETOOTH_PAN_PRIORITY_PREFIX = "bluetooth_pan_priority_";
8580
8581        /**
8582         * Device Idle (Doze) specific settings.
8583         * This is encoded as a key=value list, separated by commas. Ex:
8584         *
8585         * "inactive_to=60000,sensing_to=400000"
8586         *
8587         * The following keys are supported:
8588         *
8589         * <pre>
8590         * inactive_to                      (long)
8591         * sensing_to                       (long)
8592         * motion_inactive_to               (long)
8593         * idle_after_inactive_to           (long)
8594         * idle_pending_to                  (long)
8595         * max_idle_pending_to              (long)
8596         * idle_pending_factor              (float)
8597         * idle_to                          (long)
8598         * max_idle_to                      (long)
8599         * idle_factor                      (float)
8600         * min_time_to_alarm                (long)
8601         * max_temp_app_whitelist_duration  (long)
8602         * notification_whitelist_duration  (long)
8603         * </pre>
8604         *
8605         * <p>
8606         * Type: string
8607         * @hide
8608         * @see com.android.server.DeviceIdleController.Constants
8609         */
8610        public static final String DEVICE_IDLE_CONSTANTS = "device_idle_constants";
8611
8612        /**
8613         * Device Idle (Doze) specific settings for watches. See {@code #DEVICE_IDLE_CONSTANTS}
8614         *
8615         * <p>
8616         * Type: string
8617         * @hide
8618         * @see com.android.server.DeviceIdleController.Constants
8619         */
8620        public static final String DEVICE_IDLE_CONSTANTS_WATCH = "device_idle_constants_watch";
8621
8622        /**
8623         * App standby (app idle) specific settings.
8624         * This is encoded as a key=value list, separated by commas. Ex:
8625         *
8626         * "idle_duration=5000,parole_interval=4500"
8627         *
8628         * The following keys are supported:
8629         *
8630         * <pre>
8631         * idle_duration2       (long)
8632         * wallclock_threshold  (long)
8633         * parole_interval      (long)
8634         * parole_duration      (long)
8635         *
8636         * idle_duration        (long) // This is deprecated and used to circumvent b/26355386.
8637         * </pre>
8638         *
8639         * <p>
8640         * Type: string
8641         * @hide
8642         * @see com.android.server.usage.UsageStatsService.SettingsObserver
8643         */
8644        public static final String APP_IDLE_CONSTANTS = "app_idle_constants";
8645
8646        /**
8647         * Alarm manager specific settings.
8648         * This is encoded as a key=value list, separated by commas. Ex:
8649         *
8650         * "min_futurity=5000,allow_while_idle_short_time=4500"
8651         *
8652         * The following keys are supported:
8653         *
8654         * <pre>
8655         * min_futurity                         (long)
8656         * min_interval                         (long)
8657         * allow_while_idle_short_time          (long)
8658         * allow_while_idle_long_time           (long)
8659         * allow_while_idle_whitelist_duration  (long)
8660         * </pre>
8661         *
8662         * <p>
8663         * Type: string
8664         * @hide
8665         * @see com.android.server.AlarmManagerService.Constants
8666         */
8667        public static final String ALARM_MANAGER_CONSTANTS = "alarm_manager_constants";
8668
8669        /**
8670         * Job scheduler specific settings.
8671         * This is encoded as a key=value list, separated by commas. Ex:
8672         *
8673         * "min_ready_jobs_count=2,moderate_use_factor=.5"
8674         *
8675         * The following keys are supported:
8676         *
8677         * <pre>
8678         * min_idle_count                       (int)
8679         * min_charging_count                   (int)
8680         * min_connectivity_count               (int)
8681         * min_content_count                    (int)
8682         * min_ready_jobs_count                 (int)
8683         * heavy_use_factor                     (float)
8684         * moderate_use_factor                  (float)
8685         * fg_job_count                         (int)
8686         * bg_normal_job_count                  (int)
8687         * bg_moderate_job_count                (int)
8688         * bg_low_job_count                     (int)
8689         * bg_critical_job_count                (int)
8690         * </pre>
8691         *
8692         * <p>
8693         * Type: string
8694         * @hide
8695         * @see com.android.server.job.JobSchedulerService.Constants
8696         */
8697        public static final String JOB_SCHEDULER_CONSTANTS = "job_scheduler_constants";
8698
8699        /**
8700         * ShortcutManager specific settings.
8701         * This is encoded as a key=value list, separated by commas. Ex:
8702         *
8703         * "reset_interval_sec=86400,max_updates_per_interval=1"
8704         *
8705         * The following keys are supported:
8706         *
8707         * <pre>
8708         * reset_interval_sec              (long)
8709         * max_updates_per_interval        (int)
8710         * max_icon_dimension_dp           (int, DP)
8711         * max_icon_dimension_dp_lowram    (int, DP)
8712         * max_shortcuts                   (int)
8713         * icon_quality                    (int, 0-100)
8714         * icon_format                     (String)
8715         * </pre>
8716         *
8717         * <p>
8718         * Type: string
8719         * @hide
8720         * @see com.android.server.pm.ShortcutService.ConfigConstants
8721         */
8722        public static final String SHORTCUT_MANAGER_CONSTANTS = "shortcut_manager_constants";
8723
8724        /**
8725         * Get the key that retrieves a bluetooth headset's priority.
8726         * @hide
8727         */
8728        public static final String getBluetoothHeadsetPriorityKey(String address) {
8729            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8730        }
8731
8732        /**
8733         * Get the key that retrieves a bluetooth a2dp sink's priority.
8734         * @hide
8735         */
8736        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
8737            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8738        }
8739
8740        /**
8741         * Get the key that retrieves a bluetooth a2dp src's priority.
8742         * @hide
8743         */
8744        public static final String getBluetoothA2dpSrcPriorityKey(String address) {
8745            return BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8746        }
8747
8748        /**
8749         * Get the key that retrieves a bluetooth Input Device's priority.
8750         * @hide
8751         */
8752        public static final String getBluetoothInputDevicePriorityKey(String address) {
8753            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8754        }
8755
8756        /**
8757         * Get the key that retrieves a bluetooth pan client priority.
8758         * @hide
8759         */
8760        public static final String getBluetoothPanPriorityKey(String address) {
8761            return BLUETOOTH_PAN_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8762        }
8763
8764        /**
8765         * Get the key that retrieves a bluetooth map priority.
8766         * @hide
8767         */
8768        public static final String getBluetoothMapPriorityKey(String address) {
8769            return BLUETOOTH_MAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8770        }
8771
8772        /**
8773         * Get the key that retrieves a bluetooth map client priority.
8774         * @hide
8775         */
8776        public static final String getBluetoothMapClientPriorityKey(String address) {
8777            return BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8778        }
8779
8780        /**
8781         * Get the key that retrieves a bluetooth pbap client priority.
8782         * @hide
8783         */
8784        public static final String getBluetoothPbapClientPriorityKey(String address) {
8785            return BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8786        }
8787
8788        /**
8789         * Get the key that retrieves a bluetooth sap priority.
8790         * @hide
8791         */
8792        public static final String getBluetoothSapPriorityKey(String address) {
8793            return BLUETOOTH_SAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
8794        }
8795
8796        /**
8797         * Scaling factor for normal window animations. Setting to 0 will
8798         * disable window animations.
8799         */
8800        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
8801
8802        /**
8803         * Scaling factor for activity transition animations. Setting to 0 will
8804         * disable window animations.
8805         */
8806        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
8807
8808        /**
8809         * Scaling factor for Animator-based animations. This affects both the
8810         * start delay and duration of all such animations. Setting to 0 will
8811         * cause animations to end immediately. The default value is 1.
8812         */
8813        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
8814
8815        /**
8816         * Scaling factor for normal window animations. Setting to 0 will
8817         * disable window animations.
8818         *
8819         * @hide
8820         */
8821        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
8822
8823        /**
8824         * If 0, the compatibility mode is off for all applications.
8825         * If 1, older applications run under compatibility mode.
8826         * TODO: remove this settings before code freeze (bug/1907571)
8827         * @hide
8828         */
8829        public static final String COMPATIBILITY_MODE = "compatibility_mode";
8830
8831        /**
8832         * CDMA only settings
8833         * Emergency Tone  0 = Off
8834         *                 1 = Alert
8835         *                 2 = Vibrate
8836         * @hide
8837         */
8838        public static final String EMERGENCY_TONE = "emergency_tone";
8839
8840        /**
8841         * CDMA only settings
8842         * Whether the auto retry is enabled. The value is
8843         * boolean (1 or 0).
8844         * @hide
8845         */
8846        public static final String CALL_AUTO_RETRY = "call_auto_retry";
8847
8848        /**
8849         * A setting that can be read whether the emergency affordance is currently needed.
8850         * The value is a boolean (1 or 0).
8851         * @hide
8852         */
8853        public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed";
8854
8855        /**
8856         * See RIL_PreferredNetworkType in ril.h
8857         * @hide
8858         */
8859        public static final String PREFERRED_NETWORK_MODE =
8860                "preferred_network_mode";
8861
8862        /**
8863         * Name of an application package to be debugged.
8864         */
8865        public static final String DEBUG_APP = "debug_app";
8866
8867        /**
8868         * If 1, when launching DEBUG_APP it will wait for the debugger before
8869         * starting user code.  If 0, it will run normally.
8870         */
8871        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
8872
8873        /**
8874         * Control whether the process CPU usage meter should be shown.
8875         *
8876         * @deprecated This functionality is no longer available as of
8877         * {@link android.os.Build.VERSION_CODES#N_MR1}.
8878         */
8879        @Deprecated
8880        public static final String SHOW_PROCESSES = "show_processes";
8881
8882        /**
8883         * If 1 low power mode is enabled.
8884         * @hide
8885         */
8886        public static final String LOW_POWER_MODE = "low_power";
8887
8888        /**
8889         * Battery level [1-99] at which low power mode automatically turns on.
8890         * If 0, it will not automatically turn on.
8891         * @hide
8892         */
8893        public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level";
8894
8895         /**
8896         * If not 0, the activity manager will aggressively finish activities and
8897         * processes as soon as they are no longer needed.  If 0, the normal
8898         * extended lifetime is used.
8899         */
8900        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
8901
8902        /**
8903         * Use Dock audio output for media:
8904         *      0 = disabled
8905         *      1 = enabled
8906         * @hide
8907         */
8908        public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
8909
8910        /**
8911         * The surround sound formats AC3, DTS or IEC61937 are
8912         * available for use if they are detected.
8913         * This is the default mode.
8914         *
8915         * Note that AUTO is equivalent to ALWAYS for Android TVs and other
8916         * devices that have an S/PDIF output. This is because S/PDIF
8917         * is unidirectional and the TV cannot know if a decoder is
8918         * connected. So it assumes they are always available.
8919         * @hide
8920         */
8921         public static final int ENCODED_SURROUND_OUTPUT_AUTO = 0;
8922
8923        /**
8924         * AC3, DTS or IEC61937 are NEVER available, even if they
8925         * are detected by the hardware. Those formats will not be
8926         * reported.
8927         *
8928         * An example use case would be an AVR reports that it is capable of
8929         * surround sound decoding but is broken. If NEVER is chosen
8930         * then apps must use PCM output instead of encoded output.
8931         * @hide
8932         */
8933         public static final int ENCODED_SURROUND_OUTPUT_NEVER = 1;
8934
8935        /**
8936         * AC3, DTS or IEC61937 are ALWAYS available, even if they
8937         * are not detected by the hardware. Those formats will be
8938         * reported as part of the HDMI output capability. Applications
8939         * are then free to use either PCM or encoded output.
8940         *
8941         * An example use case would be a when TV was connected over
8942         * TOS-link to an AVR. But the TV could not see it because TOS-link
8943         * is unidirectional.
8944         * @hide
8945         */
8946         public static final int ENCODED_SURROUND_OUTPUT_ALWAYS = 2;
8947
8948        /**
8949         * Set to ENCODED_SURROUND_OUTPUT_AUTO,
8950         * ENCODED_SURROUND_OUTPUT_NEVER or
8951         * ENCODED_SURROUND_OUTPUT_ALWAYS
8952         * @hide
8953         */
8954        public static final String ENCODED_SURROUND_OUTPUT = "encoded_surround_output";
8955
8956        /**
8957         * Persisted safe headphone volume management state by AudioService
8958         * @hide
8959         */
8960        public static final String AUDIO_SAFE_VOLUME_STATE = "audio_safe_volume_state";
8961
8962        /**
8963         * URL for tzinfo (time zone) updates
8964         * @hide
8965         */
8966        public static final String TZINFO_UPDATE_CONTENT_URL = "tzinfo_content_url";
8967
8968        /**
8969         * URL for tzinfo (time zone) update metadata
8970         * @hide
8971         */
8972        public static final String TZINFO_UPDATE_METADATA_URL = "tzinfo_metadata_url";
8973
8974        /**
8975         * URL for selinux (mandatory access control) updates
8976         * @hide
8977         */
8978        public static final String SELINUX_UPDATE_CONTENT_URL = "selinux_content_url";
8979
8980        /**
8981         * URL for selinux (mandatory access control) update metadata
8982         * @hide
8983         */
8984        public static final String SELINUX_UPDATE_METADATA_URL = "selinux_metadata_url";
8985
8986        /**
8987         * URL for sms short code updates
8988         * @hide
8989         */
8990        public static final String SMS_SHORT_CODES_UPDATE_CONTENT_URL =
8991                "sms_short_codes_content_url";
8992
8993        /**
8994         * URL for sms short code update metadata
8995         * @hide
8996         */
8997        public static final String SMS_SHORT_CODES_UPDATE_METADATA_URL =
8998                "sms_short_codes_metadata_url";
8999
9000        /**
9001         * URL for apn_db updates
9002         * @hide
9003         */
9004        public static final String APN_DB_UPDATE_CONTENT_URL = "apn_db_content_url";
9005
9006        /**
9007         * URL for apn_db update metadata
9008         * @hide
9009         */
9010        public static final String APN_DB_UPDATE_METADATA_URL = "apn_db_metadata_url";
9011
9012        /**
9013         * URL for cert pinlist updates
9014         * @hide
9015         */
9016        public static final String CERT_PIN_UPDATE_CONTENT_URL = "cert_pin_content_url";
9017
9018        /**
9019         * URL for cert pinlist updates
9020         * @hide
9021         */
9022        public static final String CERT_PIN_UPDATE_METADATA_URL = "cert_pin_metadata_url";
9023
9024        /**
9025         * URL for intent firewall updates
9026         * @hide
9027         */
9028        public static final String INTENT_FIREWALL_UPDATE_CONTENT_URL =
9029                "intent_firewall_content_url";
9030
9031        /**
9032         * URL for intent firewall update metadata
9033         * @hide
9034         */
9035        public static final String INTENT_FIREWALL_UPDATE_METADATA_URL =
9036                "intent_firewall_metadata_url";
9037
9038        /**
9039         * SELinux enforcement status. If 0, permissive; if 1, enforcing.
9040         * @hide
9041         */
9042        public static final String SELINUX_STATUS = "selinux_status";
9043
9044        /**
9045         * Developer setting to force RTL layout.
9046         * @hide
9047         */
9048        public static final String DEVELOPMENT_FORCE_RTL = "debug.force_rtl";
9049
9050        /**
9051         * Milliseconds after screen-off after which low battery sounds will be silenced.
9052         *
9053         * If zero, battery sounds will always play.
9054         * Defaults to @integer/def_low_battery_sound_timeout in SettingsProvider.
9055         *
9056         * @hide
9057         */
9058        public static final String LOW_BATTERY_SOUND_TIMEOUT = "low_battery_sound_timeout";
9059
9060        /**
9061         * Milliseconds to wait before bouncing Wi-Fi after settings is restored. Note that after
9062         * the caller is done with this, they should call {@link ContentResolver#delete} to
9063         * clean up any value that they may have written.
9064         *
9065         * @hide
9066         */
9067        public static final String WIFI_BOUNCE_DELAY_OVERRIDE_MS = "wifi_bounce_delay_override_ms";
9068
9069        /**
9070         * Defines global runtime overrides to window policy.
9071         *
9072         * See {@link com.android.server.policy.PolicyControl} for value format.
9073         *
9074         * @hide
9075         */
9076        public static final String POLICY_CONTROL = "policy_control";
9077
9078        /**
9079         * Defines global zen mode.  ZEN_MODE_OFF, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
9080         * or ZEN_MODE_NO_INTERRUPTIONS.
9081         *
9082         * @hide
9083         */
9084        public static final String ZEN_MODE = "zen_mode";
9085
9086        /** @hide */ public static final int ZEN_MODE_OFF = 0;
9087        /** @hide */ public static final int ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
9088        /** @hide */ public static final int ZEN_MODE_NO_INTERRUPTIONS = 2;
9089        /** @hide */ public static final int ZEN_MODE_ALARMS = 3;
9090
9091        /** @hide */ public static String zenModeToString(int mode) {
9092            if (mode == ZEN_MODE_IMPORTANT_INTERRUPTIONS) return "ZEN_MODE_IMPORTANT_INTERRUPTIONS";
9093            if (mode == ZEN_MODE_ALARMS) return "ZEN_MODE_ALARMS";
9094            if (mode == ZEN_MODE_NO_INTERRUPTIONS) return "ZEN_MODE_NO_INTERRUPTIONS";
9095            return "ZEN_MODE_OFF";
9096        }
9097
9098        /** @hide */ public static boolean isValidZenMode(int value) {
9099            switch (value) {
9100                case Global.ZEN_MODE_OFF:
9101                case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
9102                case Global.ZEN_MODE_ALARMS:
9103                case Global.ZEN_MODE_NO_INTERRUPTIONS:
9104                    return true;
9105                default:
9106                    return false;
9107            }
9108        }
9109
9110        /**
9111         * Value of the ringer before entering zen mode.
9112         *
9113         * @hide
9114         */
9115        public static final String ZEN_MODE_RINGER_LEVEL = "zen_mode_ringer_level";
9116
9117        /**
9118         * Opaque value, changes when persisted zen mode configuration changes.
9119         *
9120         * @hide
9121         */
9122        public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
9123
9124        /**
9125         * Defines global heads up toggle.  One of HEADS_UP_OFF, HEADS_UP_ON.
9126         *
9127         * @hide
9128         */
9129        public static final String HEADS_UP_NOTIFICATIONS_ENABLED =
9130                "heads_up_notifications_enabled";
9131
9132        /** @hide */ public static final int HEADS_UP_OFF = 0;
9133        /** @hide */ public static final int HEADS_UP_ON = 1;
9134
9135        /**
9136         * The name of the device
9137         */
9138        public static final String DEVICE_NAME = "device_name";
9139
9140        /**
9141         * Whether the NetworkScoringService has been first initialized.
9142         * <p>
9143         * Type: int (0 for false, 1 for true)
9144         * @hide
9145         */
9146        public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned";
9147
9148        /**
9149         * Whether the user wants to be prompted for password to decrypt the device on boot.
9150         * This only matters if the storage is encrypted.
9151         * <p>
9152         * Type: int (0 for false, 1 for true)
9153         * @hide
9154         */
9155        public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt";
9156
9157        /**
9158         * Whether the Volte is enabled
9159         * <p>
9160         * Type: int (0 for false, 1 for true)
9161         * @hide
9162         */
9163        public static final String ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled";
9164
9165        /**
9166         * Whether VT (Video Telephony over IMS) is enabled
9167         * <p>
9168         * Type: int (0 for false, 1 for true)
9169         *
9170         * @hide
9171         */
9172        public static final String VT_IMS_ENABLED = "vt_ims_enabled";
9173
9174        /**
9175         * Whether WFC is enabled
9176         * <p>
9177         * Type: int (0 for false, 1 for true)
9178         *
9179         * @hide
9180         */
9181        public static final String WFC_IMS_ENABLED = "wfc_ims_enabled";
9182
9183        /**
9184         * WFC mode on home/non-roaming network.
9185         * <p>
9186         * Type: int - 2=Wi-Fi preferred, 1=Cellular preferred, 0=Wi-Fi only
9187         *
9188         * @hide
9189         */
9190        public static final String WFC_IMS_MODE = "wfc_ims_mode";
9191
9192        /**
9193         * WFC mode on roaming network.
9194         * <p>
9195         * Type: int - see {@link WFC_IMS_MODE} for values
9196         *
9197         * @hide
9198         */
9199        public static final String WFC_IMS_ROAMING_MODE = "wfc_ims_roaming_mode";
9200
9201        /**
9202         * Whether WFC roaming is enabled
9203         * <p>
9204         * Type: int (0 for false, 1 for true)
9205         *
9206         * @hide
9207         */
9208        public static final String WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled";
9209
9210        /**
9211         * Whether user can enable/disable LTE as a preferred network. A carrier might control
9212         * this via gservices, OMA-DM, carrier app, etc.
9213         * <p>
9214         * Type: int (0 for false, 1 for true)
9215         * @hide
9216         */
9217        public static final String LTE_SERVICE_FORCED = "lte_service_forced";
9218
9219        /**
9220         * Ephemeral app cookie max size in bytes.
9221         * <p>
9222         * Type: int
9223         * @hide
9224         */
9225        public static final String EPHEMERAL_COOKIE_MAX_SIZE_BYTES =
9226                "ephemeral_cookie_max_size_bytes";
9227
9228        /**
9229         * Toggle to enable/disable the entire ephemeral feature. By default, ephemeral is
9230         * enabled. Set to zero to disable.
9231         * <p>
9232         * Type: int (0 for false, 1 for true)
9233         *
9234         * @hide
9235         */
9236        public static final String ENABLE_EPHEMERAL_FEATURE = "enable_ephemeral_feature";
9237
9238        /**
9239         * The duration for caching uninstalled ephemeral apps.
9240         * <p>
9241         * Type: long
9242         * @hide
9243         */
9244        public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS =
9245                "uninstalled_ephemeral_app_cache_duration_millis";
9246
9247        /**
9248         * Allows switching users when system user is locked.
9249         * <p>
9250         * Type: int
9251         * @hide
9252         */
9253        public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED =
9254                "allow_user_switching_when_system_user_locked";
9255
9256        /**
9257         * Boot count since the device starts running APK level 24.
9258         * <p>
9259         * Type: int
9260         */
9261        public static final String BOOT_COUNT = "boot_count";
9262
9263        /**
9264         * Whether the safe boot is disallowed.
9265         *
9266         * <p>This setting should have the identical value as the corresponding user restriction.
9267         * The purpose of the setting is to make the restriction available in early boot stages
9268         * before the user restrictions are loaded.
9269         * @hide
9270         */
9271        public static final String SAFE_BOOT_DISALLOWED = "safe_boot_disallowed";
9272
9273        /**
9274         * Whether this device is currently in retail demo mode. If true, device
9275         * usage is severely limited.
9276         * <p>
9277         * Type: int (0 for false, 1 for true)
9278         * @hide
9279         */
9280        public static final String DEVICE_DEMO_MODE = "device_demo_mode";
9281
9282        /**
9283         * Retail mode specific settings. This is encoded as a key=value list, separated by commas.
9284         * Ex: "user_inactivity_timeout_ms=30000,warning_dialog_timeout_ms=10000". The following
9285         * keys are supported:
9286         *
9287         * <pre>
9288         * user_inactivity_timeout_ms  (long)
9289         * warning_dialog_timeout_ms   (long)
9290         * </pre>
9291         * <p>
9292         * Type: string
9293         *
9294         * @hide
9295         */
9296        public static final String RETAIL_DEMO_MODE_CONSTANTS = "retail_demo_mode_constants";
9297
9298        /**
9299         * The reason for the settings database being downgraded. This is only for
9300         * troubleshooting purposes and its value should not be interpreted in any way.
9301         *
9302         * Type: string
9303         *
9304         * @hide
9305         */
9306        public static final String DATABASE_DOWNGRADE_REASON = "database_downgrade_reason";
9307
9308        /**
9309         * Flag to toggle journal mode WAL on or off for the contacts database. WAL is enabled by
9310         * default. Set to 0 to disable.
9311         *
9312         * @hide
9313         */
9314        public static final String CONTACTS_DATABASE_WAL_ENABLED = "contacts_database_wal_enabled";
9315
9316        /**
9317         * Settings to backup. This is here so that it's in the same place as the settings
9318         * keys and easy to update.
9319         *
9320         * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
9321         * and Secure as well.  This is because those tables drive both backup and
9322         * restore, and restore needs to properly whitelist keys that used to live
9323         * in those namespaces.  The keys will only actually be backed up / restored
9324         * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
9325         *
9326         * NOTE: Settings are backed up and restored in the order they appear
9327         *       in this array. If you have one setting depending on another,
9328         *       make sure that they are ordered appropriately.
9329         *
9330         * @hide
9331         */
9332        public static final String[] SETTINGS_TO_BACKUP = {
9333            BUGREPORT_IN_POWER_MENU,
9334            STAY_ON_WHILE_PLUGGED_IN,
9335            AUTO_TIME,
9336            AUTO_TIME_ZONE,
9337            POWER_SOUNDS_ENABLED,
9338            DOCK_SOUNDS_ENABLED,
9339            CHARGING_SOUNDS_ENABLED,
9340            USB_MASS_STORAGE_ENABLED,
9341            ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED,
9342            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
9343            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
9344            WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
9345            WIFI_NUM_OPEN_NETWORKS_KEPT,
9346            EMERGENCY_TONE,
9347            CALL_AUTO_RETRY,
9348            DOCK_AUDIO_MEDIA_ENABLED,
9349            ENCODED_SURROUND_OUTPUT,
9350            LOW_POWER_MODE_TRIGGER_LEVEL
9351        };
9352
9353        private static final ContentProviderHolder sProviderHolder =
9354                new ContentProviderHolder(CONTENT_URI);
9355
9356        // Populated lazily, guarded by class object:
9357        private static final NameValueCache sNameValueCache = new NameValueCache(
9358                    CONTENT_URI,
9359                    CALL_METHOD_GET_GLOBAL,
9360                    CALL_METHOD_PUT_GLOBAL,
9361                    sProviderHolder);
9362
9363        // Certain settings have been moved from global to the per-user secure namespace
9364        private static final HashSet<String> MOVED_TO_SECURE;
9365        static {
9366            MOVED_TO_SECURE = new HashSet<>(1);
9367            MOVED_TO_SECURE.add(Settings.Global.INSTALL_NON_MARKET_APPS);
9368        }
9369
9370        /** @hide */
9371        public static void getMovedToSecureSettings(Set<String> outKeySet) {
9372            outKeySet.addAll(MOVED_TO_SECURE);
9373        }
9374
9375        /**
9376         * Look up a name in the database.
9377         * @param resolver to access the database with
9378         * @param name to look up in the table
9379         * @return the corresponding value, or null if not present
9380         */
9381        public static String getString(ContentResolver resolver, String name) {
9382            return getStringForUser(resolver, name, UserHandle.myUserId());
9383        }
9384
9385        /** @hide */
9386        public static String getStringForUser(ContentResolver resolver, String name,
9387                int userHandle) {
9388            if (MOVED_TO_SECURE.contains(name)) {
9389                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
9390                        + " to android.provider.Settings.Secure, returning read-only value.");
9391                return Secure.getStringForUser(resolver, name, userHandle);
9392            }
9393            return sNameValueCache.getStringForUser(resolver, name, userHandle);
9394        }
9395
9396        /**
9397         * Store a name/value pair into the database.
9398         * @param resolver to access the database with
9399         * @param name to store
9400         * @param value to associate with the name
9401         * @return true if the value was set, false on database errors
9402         */
9403        public static boolean putString(ContentResolver resolver,
9404                String name, String value) {
9405            return putStringForUser(resolver, name, value, null, false, UserHandle.myUserId());
9406        }
9407
9408        /**
9409         * Store a name/value pair into the database.
9410         * <p>
9411         * The method takes an optional tag to associate with the setting
9412         * which can be used to clear only settings made by your package and
9413         * associated with this tag by passing the tag to {@link
9414         * #resetToDefaults(ContentResolver, String)}. Anyone can override
9415         * the current tag. Also if another package changes the setting
9416         * then the tag will be set to the one specified in the set call
9417         * which can be null. Also any of the settings setters that do not
9418         * take a tag as an argument effectively clears the tag.
9419         * </p><p>
9420         * For example, if you set settings A and B with tags T1 and T2 and
9421         * another app changes setting A (potentially to the same value), it
9422         * can assign to it a tag T3 (note that now the package that changed
9423         * the setting is not yours). Now if you reset your changes for T1 and
9424         * T2 only setting B will be reset and A not (as it was changed by
9425         * another package) but since A did not change you are in the desired
9426         * initial state. Now if the other app changes the value of A (assuming
9427         * you registered an observer in the beginning) you would detect that
9428         * the setting was changed by another app and handle this appropriately
9429         * (ignore, set back to some value, etc).
9430         * </p><p>
9431         * Also the method takes an argument whether to make the value the
9432         * default for this setting. If the system already specified a default
9433         * value, then the one passed in here will <strong>not</strong>
9434         * be set as the default.
9435         * </p>
9436         *
9437         * @param resolver to access the database with.
9438         * @param name to store.
9439         * @param value to associate with the name.
9440         * @param tag to associated with the setting.
9441         * @param makeDefault whether to make the value the default one.
9442         * @return true if the value was set, false on database errors.
9443         *
9444         * @see #resetToDefaults(ContentResolver, String)
9445         *
9446         * @hide
9447         */
9448        @SystemApi
9449        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
9450        public static boolean putString(@NonNull ContentResolver resolver,
9451                @NonNull String name, @Nullable String value, @Nullable String tag,
9452                boolean makeDefault) {
9453            return putStringForUser(resolver, name, value, tag, makeDefault,
9454                    UserHandle.myUserId());
9455        }
9456
9457        /**
9458         * Reset the settings to their defaults. This would reset <strong>only</strong>
9459         * settings set by the caller's package. Think of it of a way to undo your own
9460         * changes to the secure settings. Passing in the optional tag will reset only
9461         * settings changed by your package and associated with this tag.
9462         *
9463         * @param resolver Handle to the content resolver.
9464         * @param tag Optional tag which should be associated with the settings to reset.
9465         *
9466         * @see #putString(ContentResolver, String, String, String, boolean)
9467         *
9468         * @hide
9469         */
9470        @SystemApi
9471        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
9472        public static void resetToDefaults(@NonNull ContentResolver resolver,
9473                @Nullable String tag) {
9474            resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
9475                    UserHandle.myUserId());
9476        }
9477
9478        /**
9479         * Reset the settings to their defaults for a given user with a specific mode. The
9480         * optional tag argument is valid only for {@link #RESET_MODE_PACKAGE_DEFAULTS}
9481         * allowing resetting the settings made by a package and associated with the tag.
9482         *
9483         * @param resolver Handle to the content resolver.
9484         * @param tag Optional tag which should be associated with the settings to reset.
9485         * @param mode The reset mode.
9486         * @param userHandle The user for which to reset to defaults.
9487         *
9488         * @see #RESET_MODE_PACKAGE_DEFAULTS
9489         * @see #RESET_MODE_UNTRUSTED_DEFAULTS
9490         * @see #RESET_MODE_UNTRUSTED_CHANGES
9491         * @see #RESET_MODE_TRUSTED_DEFAULTS
9492         *
9493         * @hide
9494         */
9495        public static void resetToDefaultsAsUser(@NonNull ContentResolver resolver,
9496                @Nullable String tag, @ResetMode int mode, @IntRange(from = 0) int userHandle) {
9497            try {
9498                Bundle arg = new Bundle();
9499                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
9500                if (tag != null) {
9501                    arg.putString(CALL_METHOD_TAG_KEY, tag);
9502                }
9503                arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode);
9504                IContentProvider cp = sProviderHolder.getProvider(resolver);
9505                cp.call(resolver.getPackageName(), CALL_METHOD_RESET_GLOBAL, null, arg);
9506            } catch (RemoteException e) {
9507                Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e);
9508            }
9509        }
9510
9511        /** @hide */
9512        public static boolean putStringForUser(ContentResolver resolver,
9513                String name, String value, int userHandle) {
9514            return putStringForUser(resolver, name, value, null, false, userHandle);
9515        }
9516
9517        /** @hide */
9518        public static boolean putStringForUser(@NonNull ContentResolver resolver,
9519                @NonNull String name, @Nullable String value, @Nullable String tag,
9520                boolean makeDefault, @UserIdInt int userHandle) {
9521            if (LOCAL_LOGV) {
9522                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
9523                        + " for " + userHandle);
9524            }
9525            // Global and Secure have the same access policy so we can forward writes
9526            if (MOVED_TO_SECURE.contains(name)) {
9527                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
9528                        + " to android.provider.Settings.Secure, value is unchanged.");
9529                return Secure.putStringForUser(resolver, name, value, tag,
9530                        makeDefault, userHandle);
9531            }
9532            return sNameValueCache.putStringForUser(resolver, name, value, tag,
9533                    makeDefault, userHandle);
9534        }
9535
9536        /**
9537         * Construct the content URI for a particular name/value pair,
9538         * useful for monitoring changes with a ContentObserver.
9539         * @param name to look up in the table
9540         * @return the corresponding content URI, or null if not present
9541         */
9542        public static Uri getUriFor(String name) {
9543            return getUriFor(CONTENT_URI, name);
9544        }
9545
9546        /**
9547         * Convenience function for retrieving a single secure settings value
9548         * as an integer.  Note that internally setting values are always
9549         * stored as strings; this function converts the string to an integer
9550         * for you.  The default value will be returned if the setting is
9551         * not defined or not an integer.
9552         *
9553         * @param cr The ContentResolver to access.
9554         * @param name The name of the setting to retrieve.
9555         * @param def Value to return if the setting is not defined.
9556         *
9557         * @return The setting's current value, or 'def' if it is not defined
9558         * or not a valid integer.
9559         */
9560        public static int getInt(ContentResolver cr, String name, int def) {
9561            String v = getString(cr, name);
9562            try {
9563                return v != null ? Integer.parseInt(v) : def;
9564            } catch (NumberFormatException e) {
9565                return def;
9566            }
9567        }
9568
9569        /**
9570         * Convenience function for retrieving a single secure settings value
9571         * as an integer.  Note that internally setting values are always
9572         * stored as strings; this function converts the string to an integer
9573         * for you.
9574         * <p>
9575         * This version does not take a default value.  If the setting has not
9576         * been set, or the string value is not a number,
9577         * it throws {@link SettingNotFoundException}.
9578         *
9579         * @param cr The ContentResolver to access.
9580         * @param name The name of the setting to retrieve.
9581         *
9582         * @throws SettingNotFoundException Thrown if a setting by the given
9583         * name can't be found or the setting value is not an integer.
9584         *
9585         * @return The setting's current value.
9586         */
9587        public static int getInt(ContentResolver cr, String name)
9588                throws SettingNotFoundException {
9589            String v = getString(cr, name);
9590            try {
9591                return Integer.parseInt(v);
9592            } catch (NumberFormatException e) {
9593                throw new SettingNotFoundException(name);
9594            }
9595        }
9596
9597        /**
9598         * Convenience function for updating a single settings value as an
9599         * integer. This will either create a new entry in the table if the
9600         * given name does not exist, or modify the value of the existing row
9601         * with that name.  Note that internally setting values are always
9602         * stored as strings, so this function converts the given value to a
9603         * string before storing it.
9604         *
9605         * @param cr The ContentResolver to access.
9606         * @param name The name of the setting to modify.
9607         * @param value The new value for the setting.
9608         * @return true if the value was set, false on database errors
9609         */
9610        public static boolean putInt(ContentResolver cr, String name, int value) {
9611            return putString(cr, name, Integer.toString(value));
9612        }
9613
9614        /**
9615         * Convenience function for retrieving a single secure settings value
9616         * as a {@code long}.  Note that internally setting values are always
9617         * stored as strings; this function converts the string to a {@code long}
9618         * for you.  The default value will be returned if the setting is
9619         * not defined or not a {@code long}.
9620         *
9621         * @param cr The ContentResolver to access.
9622         * @param name The name of the setting to retrieve.
9623         * @param def Value to return if the setting is not defined.
9624         *
9625         * @return The setting's current value, or 'def' if it is not defined
9626         * or not a valid {@code long}.
9627         */
9628        public static long getLong(ContentResolver cr, String name, long def) {
9629            String valString = getString(cr, name);
9630            long value;
9631            try {
9632                value = valString != null ? Long.parseLong(valString) : def;
9633            } catch (NumberFormatException e) {
9634                value = def;
9635            }
9636            return value;
9637        }
9638
9639        /**
9640         * Convenience function for retrieving a single secure settings value
9641         * as a {@code long}.  Note that internally setting values are always
9642         * stored as strings; this function converts the string to a {@code long}
9643         * for you.
9644         * <p>
9645         * This version does not take a default value.  If the setting has not
9646         * been set, or the string value is not a number,
9647         * it throws {@link SettingNotFoundException}.
9648         *
9649         * @param cr The ContentResolver to access.
9650         * @param name The name of the setting to retrieve.
9651         *
9652         * @return The setting's current value.
9653         * @throws SettingNotFoundException Thrown if a setting by the given
9654         * name can't be found or the setting value is not an integer.
9655         */
9656        public static long getLong(ContentResolver cr, String name)
9657                throws SettingNotFoundException {
9658            String valString = getString(cr, name);
9659            try {
9660                return Long.parseLong(valString);
9661            } catch (NumberFormatException e) {
9662                throw new SettingNotFoundException(name);
9663            }
9664        }
9665
9666        /**
9667         * Convenience function for updating a secure settings value as a long
9668         * integer. This will either create a new entry in the table if the
9669         * given name does not exist, or modify the value of the existing row
9670         * with that name.  Note that internally setting values are always
9671         * stored as strings, so this function converts the given value to a
9672         * string before storing it.
9673         *
9674         * @param cr The ContentResolver to access.
9675         * @param name The name of the setting to modify.
9676         * @param value The new value for the setting.
9677         * @return true if the value was set, false on database errors
9678         */
9679        public static boolean putLong(ContentResolver cr, String name, long value) {
9680            return putString(cr, name, Long.toString(value));
9681        }
9682
9683        /**
9684         * Convenience function for retrieving a single secure settings value
9685         * as a floating point number.  Note that internally setting values are
9686         * always stored as strings; this function converts the string to an
9687         * float for you. The default value will be returned if the setting
9688         * is not defined or not a valid float.
9689         *
9690         * @param cr The ContentResolver to access.
9691         * @param name The name of the setting to retrieve.
9692         * @param def Value to return if the setting is not defined.
9693         *
9694         * @return The setting's current value, or 'def' if it is not defined
9695         * or not a valid float.
9696         */
9697        public static float getFloat(ContentResolver cr, String name, float def) {
9698            String v = getString(cr, name);
9699            try {
9700                return v != null ? Float.parseFloat(v) : def;
9701            } catch (NumberFormatException e) {
9702                return def;
9703            }
9704        }
9705
9706        /**
9707         * Convenience function for retrieving a single secure settings value
9708         * as a float.  Note that internally setting values are always
9709         * stored as strings; this function converts the string to a float
9710         * for you.
9711         * <p>
9712         * This version does not take a default value.  If the setting has not
9713         * been set, or the string value is not a number,
9714         * it throws {@link SettingNotFoundException}.
9715         *
9716         * @param cr The ContentResolver to access.
9717         * @param name The name of the setting to retrieve.
9718         *
9719         * @throws SettingNotFoundException Thrown if a setting by the given
9720         * name can't be found or the setting value is not a float.
9721         *
9722         * @return The setting's current value.
9723         */
9724        public static float getFloat(ContentResolver cr, String name)
9725                throws SettingNotFoundException {
9726            String v = getString(cr, name);
9727            if (v == null) {
9728                throw new SettingNotFoundException(name);
9729            }
9730            try {
9731                return Float.parseFloat(v);
9732            } catch (NumberFormatException e) {
9733                throw new SettingNotFoundException(name);
9734            }
9735        }
9736
9737        /**
9738         * Convenience function for updating a single settings value as a
9739         * floating point number. This will either create a new entry in the
9740         * table if the given name does not exist, or modify the value of the
9741         * existing row with that name.  Note that internally setting values
9742         * are always stored as strings, so this function converts the given
9743         * value to a string before storing it.
9744         *
9745         * @param cr The ContentResolver to access.
9746         * @param name The name of the setting to modify.
9747         * @param value The new value for the setting.
9748         * @return true if the value was set, false on database errors
9749         */
9750        public static boolean putFloat(ContentResolver cr, String name, float value) {
9751            return putString(cr, name, Float.toString(value));
9752        }
9753
9754        /**
9755          * Subscription to be used for voice call on a multi sim device. The supported values
9756          * are 0 = SUB1, 1 = SUB2 and etc.
9757          * @hide
9758          */
9759        public static final String MULTI_SIM_VOICE_CALL_SUBSCRIPTION = "multi_sim_voice_call";
9760
9761        /**
9762          * Used to provide option to user to select subscription during dial.
9763          * The supported values are 0 = disable or 1 = enable prompt.
9764          * @hide
9765          */
9766        public static final String MULTI_SIM_VOICE_PROMPT = "multi_sim_voice_prompt";
9767
9768        /**
9769          * Subscription to be used for data call on a multi sim device. The supported values
9770          * are 0 = SUB1, 1 = SUB2 and etc.
9771          * @hide
9772          */
9773        public static final String MULTI_SIM_DATA_CALL_SUBSCRIPTION = "multi_sim_data_call";
9774
9775        /**
9776          * Subscription to be used for SMS on a multi sim device. The supported values
9777          * are 0 = SUB1, 1 = SUB2 and etc.
9778          * @hide
9779          */
9780        public static final String MULTI_SIM_SMS_SUBSCRIPTION = "multi_sim_sms";
9781
9782       /**
9783          * Used to provide option to user to select subscription during send SMS.
9784          * The value 1 - enable, 0 - disable
9785          * @hide
9786          */
9787        public static final String MULTI_SIM_SMS_PROMPT = "multi_sim_sms_prompt";
9788
9789
9790
9791        /** User preferred subscriptions setting.
9792          * This holds the details of the user selected subscription from the card and
9793          * the activation status. Each settings string have the coma separated values
9794          * iccId,appType,appId,activationStatus,3gppIndex,3gpp2Index
9795          * @hide
9796         */
9797        public static final String[] MULTI_SIM_USER_PREFERRED_SUBS = {"user_preferred_sub1",
9798                "user_preferred_sub2","user_preferred_sub3"};
9799
9800        /**
9801         * Whether to enable new contacts aggregator or not.
9802         * The value 1 - enable, 0 - disable
9803         * @hide
9804         */
9805        public static final String NEW_CONTACT_AGGREGATOR = "new_contact_aggregator";
9806
9807        /**
9808         * Whether to enable contacts metadata syncing or not
9809         * The value 1 - enable, 0 - disable
9810         *
9811         * @removed
9812         */
9813        @Deprecated
9814        public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
9815
9816        /**
9817         * Whether to enable contacts metadata syncing or not
9818         * The value 1 - enable, 0 - disable
9819         */
9820        public static final String CONTACT_METADATA_SYNC_ENABLED = "contact_metadata_sync_enabled";
9821
9822        /**
9823         * Whether to enable cellular on boot.
9824         * The value 1 - enable, 0 - disable
9825         * @hide
9826         */
9827        public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
9828
9829        /**
9830         * The maximum allowed notification enqueue rate in Hertz.
9831         *
9832         * Should be a float, and includes both posts and updates.
9833         * @hide
9834         */
9835        public static final String MAX_NOTIFICATION_ENQUEUE_RATE = "max_notification_enqueue_rate";
9836
9837        /**
9838         * Whether cell is enabled/disabled
9839         * @hide
9840         */
9841        public static final String CELL_ON = "cell_on";
9842    }
9843
9844    /**
9845     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
9846     * Intent URL, allowing it to be either a web page or a particular
9847     * application activity.
9848     *
9849     * @hide
9850     */
9851    public static final class Bookmarks implements BaseColumns
9852    {
9853        private static final String TAG = "Bookmarks";
9854
9855        /**
9856         * The content:// style URL for this table
9857         */
9858        public static final Uri CONTENT_URI =
9859            Uri.parse("content://" + AUTHORITY + "/bookmarks");
9860
9861        /**
9862         * The row ID.
9863         * <p>Type: INTEGER</p>
9864         */
9865        public static final String ID = "_id";
9866
9867        /**
9868         * Descriptive name of the bookmark that can be displayed to the user.
9869         * If this is empty, the title should be resolved at display time (use
9870         * {@link #getTitle(Context, Cursor)} any time you want to display the
9871         * title of a bookmark.)
9872         * <P>
9873         * Type: TEXT
9874         * </P>
9875         */
9876        public static final String TITLE = "title";
9877
9878        /**
9879         * Arbitrary string (displayed to the user) that allows bookmarks to be
9880         * organized into categories.  There are some special names for
9881         * standard folders, which all start with '@'.  The label displayed for
9882         * the folder changes with the locale (via {@link #getLabelForFolder}) but
9883         * the folder name does not change so you can consistently query for
9884         * the folder regardless of the current locale.
9885         *
9886         * <P>Type: TEXT</P>
9887         *
9888         */
9889        public static final String FOLDER = "folder";
9890
9891        /**
9892         * The Intent URL of the bookmark, describing what it points to.  This
9893         * value is given to {@link android.content.Intent#getIntent} to create
9894         * an Intent that can be launched.
9895         * <P>Type: TEXT</P>
9896         */
9897        public static final String INTENT = "intent";
9898
9899        /**
9900         * Optional shortcut character associated with this bookmark.
9901         * <P>Type: INTEGER</P>
9902         */
9903        public static final String SHORTCUT = "shortcut";
9904
9905        /**
9906         * The order in which the bookmark should be displayed
9907         * <P>Type: INTEGER</P>
9908         */
9909        public static final String ORDERING = "ordering";
9910
9911        private static final String[] sIntentProjection = { INTENT };
9912        private static final String[] sShortcutProjection = { ID, SHORTCUT };
9913        private static final String sShortcutSelection = SHORTCUT + "=?";
9914
9915        /**
9916         * Convenience function to retrieve the bookmarked Intent for a
9917         * particular shortcut key.
9918         *
9919         * @param cr The ContentResolver to query.
9920         * @param shortcut The shortcut key.
9921         *
9922         * @return Intent The bookmarked URL, or null if there is no bookmark
9923         *         matching the given shortcut.
9924         */
9925        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
9926        {
9927            Intent intent = null;
9928
9929            Cursor c = cr.query(CONTENT_URI,
9930                    sIntentProjection, sShortcutSelection,
9931                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
9932            // Keep trying until we find a valid shortcut
9933            try {
9934                while (intent == null && c.moveToNext()) {
9935                    try {
9936                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
9937                        intent = Intent.parseUri(intentURI, 0);
9938                    } catch (java.net.URISyntaxException e) {
9939                        // The stored URL is bad...  ignore it.
9940                    } catch (IllegalArgumentException e) {
9941                        // Column not found
9942                        Log.w(TAG, "Intent column not found", e);
9943                    }
9944                }
9945            } finally {
9946                if (c != null) c.close();
9947            }
9948
9949            return intent;
9950        }
9951
9952        /**
9953         * Add a new bookmark to the system.
9954         *
9955         * @param cr The ContentResolver to query.
9956         * @param intent The desired target of the bookmark.
9957         * @param title Bookmark title that is shown to the user; null if none
9958         *            or it should be resolved to the intent's title.
9959         * @param folder Folder in which to place the bookmark; null if none.
9960         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
9961         *            this is non-zero and there is an existing bookmark entry
9962         *            with this same shortcut, then that existing shortcut is
9963         *            cleared (the bookmark is not removed).
9964         * @return The unique content URL for the new bookmark entry.
9965         */
9966        public static Uri add(ContentResolver cr,
9967                                           Intent intent,
9968                                           String title,
9969                                           String folder,
9970                                           char shortcut,
9971                                           int ordering)
9972        {
9973            // If a shortcut is supplied, and it is already defined for
9974            // another bookmark, then remove the old definition.
9975            if (shortcut != 0) {
9976                cr.delete(CONTENT_URI, sShortcutSelection,
9977                        new String[] { String.valueOf((int) shortcut) });
9978            }
9979
9980            ContentValues values = new ContentValues();
9981            if (title != null) values.put(TITLE, title);
9982            if (folder != null) values.put(FOLDER, folder);
9983            values.put(INTENT, intent.toUri(0));
9984            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
9985            values.put(ORDERING, ordering);
9986            return cr.insert(CONTENT_URI, values);
9987        }
9988
9989        /**
9990         * Return the folder name as it should be displayed to the user.  This
9991         * takes care of localizing special folders.
9992         *
9993         * @param r Resources object for current locale; only need access to
9994         *          system resources.
9995         * @param folder The value found in the {@link #FOLDER} column.
9996         *
9997         * @return CharSequence The label for this folder that should be shown
9998         *         to the user.
9999         */
10000        public static CharSequence getLabelForFolder(Resources r, String folder) {
10001            return folder;
10002        }
10003
10004        /**
10005         * Return the title as it should be displayed to the user. This takes
10006         * care of localizing bookmarks that point to activities.
10007         *
10008         * @param context A context.
10009         * @param cursor A cursor pointing to the row whose title should be
10010         *        returned. The cursor must contain at least the {@link #TITLE}
10011         *        and {@link #INTENT} columns.
10012         * @return A title that is localized and can be displayed to the user,
10013         *         or the empty string if one could not be found.
10014         */
10015        public static CharSequence getTitle(Context context, Cursor cursor) {
10016            int titleColumn = cursor.getColumnIndex(TITLE);
10017            int intentColumn = cursor.getColumnIndex(INTENT);
10018            if (titleColumn == -1 || intentColumn == -1) {
10019                throw new IllegalArgumentException(
10020                        "The cursor must contain the TITLE and INTENT columns.");
10021            }
10022
10023            String title = cursor.getString(titleColumn);
10024            if (!TextUtils.isEmpty(title)) {
10025                return title;
10026            }
10027
10028            String intentUri = cursor.getString(intentColumn);
10029            if (TextUtils.isEmpty(intentUri)) {
10030                return "";
10031            }
10032
10033            Intent intent;
10034            try {
10035                intent = Intent.parseUri(intentUri, 0);
10036            } catch (URISyntaxException e) {
10037                return "";
10038            }
10039
10040            PackageManager packageManager = context.getPackageManager();
10041            ResolveInfo info = packageManager.resolveActivity(intent, 0);
10042            return info != null ? info.loadLabel(packageManager) : "";
10043        }
10044    }
10045
10046    /**
10047     * Returns the device ID that we should use when connecting to the mobile gtalk server.
10048     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
10049     * from the GoogleLoginService.
10050     *
10051     * @param androidId The Android ID for this device.
10052     * @return The device ID that should be used when connecting to the mobile gtalk server.
10053     * @hide
10054     */
10055    public static String getGTalkDeviceId(long androidId) {
10056        return "android-" + Long.toHexString(androidId);
10057    }
10058
10059    private static final String[] PM_WRITE_SETTINGS = {
10060        android.Manifest.permission.WRITE_SETTINGS
10061    };
10062    private static final String[] PM_CHANGE_NETWORK_STATE = {
10063        android.Manifest.permission.CHANGE_NETWORK_STATE,
10064        android.Manifest.permission.WRITE_SETTINGS
10065    };
10066    private static final String[] PM_SYSTEM_ALERT_WINDOW = {
10067        android.Manifest.permission.SYSTEM_ALERT_WINDOW
10068    };
10069
10070    /**
10071     * Performs a strict and comprehensive check of whether a calling package is allowed to
10072     * write/modify system settings, as the condition differs for pre-M, M+, and
10073     * privileged/preinstalled apps. If the provided uid does not match the
10074     * callingPackage, a negative result will be returned.
10075     * @hide
10076     */
10077    public static boolean isCallingPackageAllowedToWriteSettings(Context context, int uid,
10078            String callingPackage, boolean throwException) {
10079        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
10080                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
10081                PM_WRITE_SETTINGS, false);
10082    }
10083
10084    /**
10085     * Performs a strict and comprehensive check of whether a calling package is allowed to
10086     * write/modify system settings, as the condition differs for pre-M, M+, and
10087     * privileged/preinstalled apps. If the provided uid does not match the
10088     * callingPackage, a negative result will be returned. The caller is expected to have
10089     * the WRITE_SETTINGS permission declared.
10090     *
10091     * Note: if the check is successful, the operation of this app will be updated to the
10092     * current time.
10093     * @hide
10094     */
10095    public static boolean checkAndNoteWriteSettingsOperation(Context context, int uid,
10096            String callingPackage, boolean throwException) {
10097        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
10098                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
10099                PM_WRITE_SETTINGS, true);
10100    }
10101
10102    /**
10103     * Performs a strict and comprehensive check of whether a calling package is allowed to
10104     * change the state of network, as the condition differs for pre-M, M+, and
10105     * privileged/preinstalled apps. The caller is expected to have either the
10106     * CHANGE_NETWORK_STATE or the WRITE_SETTINGS permission declared. Either of these
10107     * permissions allow changing network state; WRITE_SETTINGS is a runtime permission and
10108     * can be revoked, but (except in M, excluding M MRs), CHANGE_NETWORK_STATE is a normal
10109     * permission and cannot be revoked. See http://b/23597341
10110     *
10111     * Note: if the check succeeds because the application holds WRITE_SETTINGS, the operation
10112     * of this app will be updated to the current time.
10113     * @hide
10114     */
10115    public static boolean checkAndNoteChangeNetworkStateOperation(Context context, int uid,
10116            String callingPackage, boolean throwException) {
10117        if (context.checkCallingOrSelfPermission(android.Manifest.permission.CHANGE_NETWORK_STATE)
10118                == PackageManager.PERMISSION_GRANTED) {
10119            return true;
10120        }
10121        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
10122                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
10123                PM_CHANGE_NETWORK_STATE, true);
10124    }
10125
10126    /**
10127     * Performs a strict and comprehensive check of whether a calling package is allowed to
10128     * draw on top of other apps, as the conditions differs for pre-M, M+, and
10129     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
10130     * a negative result will be returned.
10131     * @hide
10132     */
10133    public static boolean isCallingPackageAllowedToDrawOverlays(Context context, int uid,
10134            String callingPackage, boolean throwException) {
10135        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
10136                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
10137                PM_SYSTEM_ALERT_WINDOW, false);
10138    }
10139
10140    /**
10141     * Performs a strict and comprehensive check of whether a calling package is allowed to
10142     * draw on top of other apps, as the conditions differs for pre-M, M+, and
10143     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
10144     * a negative result will be returned.
10145     *
10146     * Note: if the check is successful, the operation of this app will be updated to the
10147     * current time.
10148     * @hide
10149     */
10150    public static boolean checkAndNoteDrawOverlaysOperation(Context context, int uid, String
10151            callingPackage, boolean throwException) {
10152        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
10153                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
10154                PM_SYSTEM_ALERT_WINDOW, true);
10155    }
10156
10157    /**
10158     * Helper method to perform a general and comprehensive check of whether an operation that is
10159     * protected by appops can be performed by a caller or not. e.g. OP_SYSTEM_ALERT_WINDOW and
10160     * OP_WRITE_SETTINGS
10161     * @hide
10162     */
10163    public static boolean isCallingPackageAllowedToPerformAppOpsProtectedOperation(Context context,
10164            int uid, String callingPackage, boolean throwException, int appOpsOpCode, String[]
10165            permissions, boolean makeNote) {
10166        if (callingPackage == null) {
10167            return false;
10168        }
10169
10170        AppOpsManager appOpsMgr = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
10171        int mode = AppOpsManager.MODE_DEFAULT;
10172        if (makeNote) {
10173            mode = appOpsMgr.noteOpNoThrow(appOpsOpCode, uid, callingPackage);
10174        } else {
10175            mode = appOpsMgr.checkOpNoThrow(appOpsOpCode, uid, callingPackage);
10176        }
10177
10178        switch (mode) {
10179            case AppOpsManager.MODE_ALLOWED:
10180                return true;
10181
10182            case AppOpsManager.MODE_DEFAULT:
10183                // this is the default operating mode after an app's installation
10184                // In this case we will check all associated static permission to see
10185                // if it is granted during install time.
10186                for (String permission : permissions) {
10187                    if (context.checkCallingOrSelfPermission(permission) == PackageManager
10188                            .PERMISSION_GRANTED) {
10189                        // if either of the permissions are granted, we will allow it
10190                        return true;
10191                    }
10192                }
10193
10194            default:
10195                // this is for all other cases trickled down here...
10196                if (!throwException) {
10197                    return false;
10198                }
10199        }
10200
10201        // prepare string to throw SecurityException
10202        StringBuilder exceptionMessage = new StringBuilder();
10203        exceptionMessage.append(callingPackage);
10204        exceptionMessage.append(" was not granted ");
10205        if (permissions.length > 1) {
10206            exceptionMessage.append(" either of these permissions: ");
10207        } else {
10208            exceptionMessage.append(" this permission: ");
10209        }
10210        for (int i = 0; i < permissions.length; i++) {
10211            exceptionMessage.append(permissions[i]);
10212            exceptionMessage.append((i == permissions.length - 1) ? "." : ", ");
10213        }
10214
10215        throw new SecurityException(exceptionMessage.toString());
10216    }
10217
10218    /**
10219     * Retrieves a correponding package name for a given uid. It will query all
10220     * packages that are associated with the given uid, but it will return only
10221     * the zeroth result.
10222     * Note: If package could not be found, a null is returned.
10223     * @hide
10224     */
10225    public static String getPackageNameForUid(Context context, int uid) {
10226        String[] packages = context.getPackageManager().getPackagesForUid(uid);
10227        if (packages == null) {
10228            return null;
10229        }
10230        return packages[0];
10231    }
10232}
10233