Settings.java revision 6750352248bcce6668eabd1911d092b7fe31a1cd
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 static android.provider.SettingsValidators.ANY_INTEGER_VALIDATOR;
20import static android.provider.SettingsValidators.ANY_STRING_VALIDATOR;
21import static android.provider.SettingsValidators.BOOLEAN_VALIDATOR;
22import static android.provider.SettingsValidators.COMPONENT_NAME_VALIDATOR;
23import static android.provider.SettingsValidators.LENIENT_IP_ADDRESS_VALIDATOR;
24import static android.provider.SettingsValidators.LOCALE_VALIDATOR;
25import static android.provider.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR;
26import static android.provider.SettingsValidators.PACKAGE_NAME_VALIDATOR;
27import static android.provider.SettingsValidators.URI_VALIDATOR;
28
29import android.Manifest;
30import android.annotation.IntDef;
31import android.annotation.IntRange;
32import android.annotation.NonNull;
33import android.annotation.Nullable;
34import android.annotation.RequiresPermission;
35import android.annotation.SdkConstant;
36import android.annotation.SdkConstant.SdkConstantType;
37import android.annotation.SystemApi;
38import android.annotation.TestApi;
39import android.annotation.UserIdInt;
40import android.app.ActivityThread;
41import android.app.AppOpsManager;
42import android.app.Application;
43import android.app.NotificationChannel;
44import android.app.NotificationManager;
45import android.app.SearchManager;
46import android.app.WallpaperManager;
47import android.content.ComponentName;
48import android.content.ContentResolver;
49import android.content.ContentValues;
50import android.content.Context;
51import android.content.IContentProvider;
52import android.content.Intent;
53import android.content.pm.ActivityInfo;
54import android.content.pm.PackageManager;
55import android.content.pm.ResolveInfo;
56import android.content.res.Configuration;
57import android.content.res.Resources;
58import android.database.Cursor;
59import android.database.SQLException;
60import android.location.LocationManager;
61import android.net.ConnectivityManager;
62import android.net.NetworkScoreManager;
63import android.net.Uri;
64import android.net.wifi.WifiManager;
65import android.os.BatteryManager;
66import android.os.Binder;
67import android.os.Build.VERSION_CODES;
68import android.os.Bundle;
69import android.os.DropBoxManager;
70import android.os.IBinder;
71import android.os.LocaleList;
72import android.os.Process;
73import android.os.RemoteException;
74import android.os.ResultReceiver;
75import android.os.ServiceManager;
76import android.os.UserHandle;
77import android.provider.SettingsValidators.Validator;
78import android.speech.tts.TextToSpeech;
79import android.telephony.SubscriptionManager;
80import android.text.TextUtils;
81import android.util.AndroidException;
82import android.util.ArrayMap;
83import android.util.ArraySet;
84import android.util.Log;
85import android.util.MemoryIntArray;
86import android.util.StatsLog;
87import android.view.textservice.TextServicesManager;
88
89import com.android.internal.annotations.GuardedBy;
90import com.android.internal.widget.ILockSettings;
91
92import java.io.IOException;
93import java.lang.annotation.Retention;
94import java.lang.annotation.RetentionPolicy;
95import java.net.URISyntaxException;
96import java.text.SimpleDateFormat;
97import java.util.HashMap;
98import java.util.HashSet;
99import java.util.Locale;
100import java.util.Map;
101import java.util.Set;
102
103/**
104 * The Settings provider contains global system-level device preferences.
105 */
106public final class Settings {
107
108    // Intent actions for Settings
109
110    /**
111     * Activity Action: Show system settings.
112     * <p>
113     * Input: Nothing.
114     * <p>
115     * Output: Nothing.
116     */
117    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
118    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
119
120    /**
121     * Activity Action: Show settings to allow configuration of APNs.
122     * <p>
123     * Input: Nothing.
124     * <p>
125     * Output: Nothing.
126     */
127    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
128    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
129
130    /**
131     * Activity Action: Show settings to allow configuration of current location
132     * sources.
133     * <p>
134     * In some cases, a matching Activity may not exist, so ensure you
135     * safeguard against this.
136     * <p>
137     * Input: Nothing.
138     * <p>
139     * Output: Nothing.
140     */
141    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
142    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
143            "android.settings.LOCATION_SOURCE_SETTINGS";
144
145    /**
146     * Activity Action: Show settings to allow configuration of users.
147     * <p>
148     * In some cases, a matching Activity may not exist, so ensure you
149     * safeguard against this.
150     * <p>
151     * Input: Nothing.
152     * <p>
153     * Output: Nothing.
154     * @hide
155     */
156    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
157    public static final String ACTION_USER_SETTINGS =
158            "android.settings.USER_SETTINGS";
159
160    /**
161     * Activity Action: Show settings to allow configuration of wireless controls
162     * such as Wi-Fi, Bluetooth and Mobile networks.
163     * <p>
164     * In some cases, a matching Activity may not exist, so ensure you
165     * safeguard against this.
166     * <p>
167     * Input: Nothing.
168     * <p>
169     * Output: Nothing.
170     */
171    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
172    public static final String ACTION_WIRELESS_SETTINGS =
173            "android.settings.WIRELESS_SETTINGS";
174
175    /**
176     * Activity Action: Show tether provisioning activity.
177     *
178     * <p>
179     * In some cases, a matching Activity may not exist, so ensure you
180     * safeguard against this.
181     * <p>
182     * Input: {@link ConnectivityManager#EXTRA_TETHER_TYPE} should be included to specify which type
183     * of tethering should be checked. {@link ConnectivityManager#EXTRA_PROVISION_CALLBACK} should
184     * contain a {@link ResultReceiver} which will be called back with a tether result code.
185     * <p>
186     * Output: The result of the provisioning check.
187     * {@link ConnectivityManager#TETHER_ERROR_NO_ERROR} if successful,
188     * {@link ConnectivityManager#TETHER_ERROR_PROVISION_FAILED} for failure.
189     *
190     * @hide
191     */
192    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
193    public static final String ACTION_TETHER_PROVISIONING =
194            "android.settings.TETHER_PROVISIONING_UI";
195
196    /**
197     * Activity Action: Show settings to allow entering/exiting airplane mode.
198     * <p>
199     * In some cases, a matching Activity may not exist, so ensure you
200     * safeguard against this.
201     * <p>
202     * Input: Nothing.
203     * <p>
204     * Output: Nothing.
205     */
206    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
207    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
208            "android.settings.AIRPLANE_MODE_SETTINGS";
209
210    /**
211     * Activity Action: Show mobile data usage list.
212     * <p>
213     * Input: {@link EXTRA_NETWORK_TEMPLATE} and {@link EXTRA_SUB_ID} should be included to specify
214     * how and what mobile data statistics should be collected.
215     * <p>
216     * Output: Nothing
217     * @hide
218     */
219    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
220    public static final String ACTION_MOBILE_DATA_USAGE =
221            "android.settings.MOBILE_DATA_USAGE";
222
223    /** @hide */
224    public static final String EXTRA_NETWORK_TEMPLATE = "network_template";
225
226    /**
227     * An int extra specifying a subscription ID.
228     *
229     * @see android.telephony.SubscriptionInfo#getSubscriptionId
230     */
231    public static final String EXTRA_SUB_ID = "android.provider.extra.SUB_ID";
232
233    /**
234     * Activity Action: Modify Airplane mode settings using a voice command.
235     * <p>
236     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
237     * <p>
238     * This intent MUST be started using
239     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
240     * startVoiceActivity}.
241     * <p>
242     * Note: The activity implementing this intent MUST verify that
243     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
244     * modifying the setting.
245     * <p>
246     * Input: To tell which state airplane mode should be set to, add the
247     * {@link #EXTRA_AIRPLANE_MODE_ENABLED} extra to this Intent with the state specified.
248     * If the extra is not included, no changes will be made.
249     * <p>
250     * Output: Nothing.
251     */
252    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
253    public static final String ACTION_VOICE_CONTROL_AIRPLANE_MODE =
254            "android.settings.VOICE_CONTROL_AIRPLANE_MODE";
255
256    /**
257     * Activity Action: Show settings for accessibility modules.
258     * <p>
259     * In some cases, a matching Activity may not exist, so ensure you
260     * safeguard against this.
261     * <p>
262     * Input: Nothing.
263     * <p>
264     * Output: Nothing.
265     */
266    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
267    public static final String ACTION_ACCESSIBILITY_SETTINGS =
268            "android.settings.ACCESSIBILITY_SETTINGS";
269
270    /**
271     * Activity Action: Show settings to control access to usage information.
272     * <p>
273     * In some cases, a matching Activity may not exist, so ensure you
274     * safeguard against this.
275     * <p>
276     * Input: Nothing.
277     * <p>
278     * Output: Nothing.
279     */
280    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
281    public static final String ACTION_USAGE_ACCESS_SETTINGS =
282            "android.settings.USAGE_ACCESS_SETTINGS";
283
284    /**
285     * Activity Category: Show application settings related to usage access.
286     * <p>
287     * An activity that provides a user interface for adjusting usage access related
288     * preferences for its containing application. Optional but recommended for apps that
289     * use {@link android.Manifest.permission#PACKAGE_USAGE_STATS}.
290     * <p>
291     * The activity may define meta-data to describe what usage access is
292     * used for within their app with {@link #METADATA_USAGE_ACCESS_REASON}, which
293     * will be displayed in Settings.
294     * <p>
295     * Input: Nothing.
296     * <p>
297     * Output: Nothing.
298     */
299    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
300    public static final String INTENT_CATEGORY_USAGE_ACCESS_CONFIG =
301            "android.intent.category.USAGE_ACCESS_CONFIG";
302
303    /**
304     * Metadata key: Reason for needing usage access.
305     * <p>
306     * A key for metadata attached to an activity that receives action
307     * {@link #INTENT_CATEGORY_USAGE_ACCESS_CONFIG}, shown to the
308     * user as description of how the app uses usage access.
309     * <p>
310     */
311    public static final String METADATA_USAGE_ACCESS_REASON =
312            "android.settings.metadata.USAGE_ACCESS_REASON";
313
314    /**
315     * Activity Action: Show settings to allow configuration of security and
316     * location privacy.
317     * <p>
318     * In some cases, a matching Activity may not exist, so ensure you
319     * safeguard against this.
320     * <p>
321     * Input: Nothing.
322     * <p>
323     * Output: Nothing.
324     */
325    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
326    public static final String ACTION_SECURITY_SETTINGS =
327            "android.settings.SECURITY_SETTINGS";
328
329    /**
330     * Activity Action: Show settings to allow configuration of trusted external sources
331     *
332     * Input: Optionally, the Intent's data URI can specify the application package name to
333     * directly invoke the management GUI specific to the package name. For example
334     * "package:com.my.app".
335     * <p>
336     * Output: Nothing.
337     */
338    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
339    public static final String ACTION_MANAGE_UNKNOWN_APP_SOURCES =
340            "android.settings.MANAGE_UNKNOWN_APP_SOURCES";
341
342    /**
343     * Activity Action: Show trusted credentials settings, opening to the user tab,
344     * to allow management of installed credentials.
345     * <p>
346     * In some cases, a matching Activity may not exist, so ensure you
347     * safeguard against this.
348     * <p>
349     * Input: Nothing.
350     * <p>
351     * Output: Nothing.
352     * @hide
353     */
354    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
355    public static final String ACTION_TRUSTED_CREDENTIALS_USER =
356            "com.android.settings.TRUSTED_CREDENTIALS_USER";
357
358    /**
359     * Activity Action: Show dialog explaining that an installed CA cert may enable
360     * monitoring of encrypted network traffic.
361     * <p>
362     * In some cases, a matching Activity may not exist, so ensure you
363     * safeguard against this. Add {@link #EXTRA_NUMBER_OF_CERTIFICATES} extra to indicate the
364     * number of certificates.
365     * <p>
366     * Input: Nothing.
367     * <p>
368     * Output: Nothing.
369     * @hide
370     */
371    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
372    public static final String ACTION_MONITORING_CERT_INFO =
373            "com.android.settings.MONITORING_CERT_INFO";
374
375    /**
376     * Activity Action: Show settings to allow configuration of privacy options.
377     * <p>
378     * In some cases, a matching Activity may not exist, so ensure you
379     * safeguard against this.
380     * <p>
381     * Input: Nothing.
382     * <p>
383     * Output: Nothing.
384     */
385    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
386    public static final String ACTION_PRIVACY_SETTINGS =
387            "android.settings.PRIVACY_SETTINGS";
388
389    /**
390     * Activity Action: Show settings to allow configuration of VPN.
391     * <p>
392     * In some cases, a matching Activity may not exist, so ensure you
393     * safeguard against this.
394     * <p>
395     * Input: Nothing.
396     * <p>
397     * Output: Nothing.
398     */
399    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
400    public static final String ACTION_VPN_SETTINGS =
401            "android.settings.VPN_SETTINGS";
402
403    /**
404     * Activity Action: Show settings to allow configuration of Wi-Fi.
405     * <p>
406     * In some cases, a matching Activity may not exist, so ensure you
407     * safeguard against this.
408     * <p>
409     * Input: Nothing.
410     * <p>
411     * Output: Nothing.
412     */
413    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
414    public static final String ACTION_WIFI_SETTINGS =
415            "android.settings.WIFI_SETTINGS";
416
417    /**
418     * Activity Action: Show settings to allow configuration of a static IP
419     * address for Wi-Fi.
420     * <p>
421     * In some cases, a matching Activity may not exist, so ensure you safeguard
422     * against this.
423     * <p>
424     * Input: Nothing.
425     * <p>
426     * Output: Nothing.
427     */
428    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
429    public static final String ACTION_WIFI_IP_SETTINGS =
430            "android.settings.WIFI_IP_SETTINGS";
431
432    /**
433     * Activity Action: Show settings to allow configuration of Bluetooth.
434     * <p>
435     * In some cases, a matching Activity may not exist, so ensure you
436     * safeguard against this.
437     * <p>
438     * Input: Nothing.
439     * <p>
440     * Output: Nothing.
441     */
442    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
443    public static final String ACTION_BLUETOOTH_SETTINGS =
444            "android.settings.BLUETOOTH_SETTINGS";
445
446    /**
447     * Activity Action: Show settings to allow configuration of Assist Gesture.
448     * <p>
449     * In some cases, a matching Activity may not exist, so ensure you
450     * safeguard against this.
451     * <p>
452     * Input: Nothing.
453     * <p>
454     * Output: Nothing.
455     * @hide
456     */
457    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
458    public static final String ACTION_ASSIST_GESTURE_SETTINGS =
459            "android.settings.ASSIST_GESTURE_SETTINGS";
460
461    /**
462     * Activity Action: Show settings to enroll fingerprints, and setup PIN/Pattern/Pass if
463     * necessary.
464     * <p>
465     * Input: Nothing.
466     * <p>
467     * Output: Nothing.
468     */
469    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
470    public static final String ACTION_FINGERPRINT_ENROLL =
471            "android.settings.FINGERPRINT_ENROLL";
472
473    /**
474     * Activity Action: Show settings to allow configuration of cast endpoints.
475     * <p>
476     * In some cases, a matching Activity may not exist, so ensure you
477     * safeguard against this.
478     * <p>
479     * Input: Nothing.
480     * <p>
481     * Output: Nothing.
482     */
483    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
484    public static final String ACTION_CAST_SETTINGS =
485            "android.settings.CAST_SETTINGS";
486
487    /**
488     * Activity Action: Show settings to allow configuration of date and time.
489     * <p>
490     * In some cases, a matching Activity may not exist, so ensure you
491     * safeguard against this.
492     * <p>
493     * Input: Nothing.
494     * <p>
495     * Output: Nothing.
496     */
497    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
498    public static final String ACTION_DATE_SETTINGS =
499            "android.settings.DATE_SETTINGS";
500
501    /**
502     * Activity Action: Show settings to allow configuration of sound and volume.
503     * <p>
504     * In some cases, a matching Activity may not exist, so ensure you
505     * safeguard against this.
506     * <p>
507     * Input: Nothing.
508     * <p>
509     * Output: Nothing.
510     */
511    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
512    public static final String ACTION_SOUND_SETTINGS =
513            "android.settings.SOUND_SETTINGS";
514
515    /**
516     * Activity Action: Show settings to allow configuration of display.
517     * <p>
518     * In some cases, a matching Activity may not exist, so ensure you
519     * safeguard against this.
520     * <p>
521     * Input: Nothing.
522     * <p>
523     * Output: Nothing.
524     */
525    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
526    public static final String ACTION_DISPLAY_SETTINGS =
527            "android.settings.DISPLAY_SETTINGS";
528
529    /**
530     * Activity Action: Show settings to allow configuration of Night display.
531     * <p>
532     * In some cases, a matching Activity may not exist, so ensure you
533     * safeguard against this.
534     * <p>
535     * Input: Nothing.
536     * <p>
537     * Output: Nothing.
538     */
539    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
540    public static final String ACTION_NIGHT_DISPLAY_SETTINGS =
541            "android.settings.NIGHT_DISPLAY_SETTINGS";
542
543    /**
544     * Activity Action: Show settings to allow configuration of locale.
545     * <p>
546     * In some cases, a matching Activity may not exist, so ensure you
547     * safeguard against this.
548     * <p>
549     * Input: Nothing.
550     * <p>
551     * Output: Nothing.
552     */
553    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
554    public static final String ACTION_LOCALE_SETTINGS =
555            "android.settings.LOCALE_SETTINGS";
556
557    /**
558     * Activity Action: Show settings to configure input methods, in particular
559     * allowing the user to enable input methods.
560     * <p>
561     * In some cases, a matching Activity may not exist, so ensure you
562     * safeguard against this.
563     * <p>
564     * Input: Nothing.
565     * <p>
566     * Output: Nothing.
567     */
568    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
569    public static final String ACTION_VOICE_INPUT_SETTINGS =
570            "android.settings.VOICE_INPUT_SETTINGS";
571
572    /**
573     * Activity Action: Show settings to configure input methods, in particular
574     * allowing the user to enable input methods.
575     * <p>
576     * In some cases, a matching Activity may not exist, so ensure you
577     * safeguard against this.
578     * <p>
579     * Input: Nothing.
580     * <p>
581     * Output: Nothing.
582     */
583    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
584    public static final String ACTION_INPUT_METHOD_SETTINGS =
585            "android.settings.INPUT_METHOD_SETTINGS";
586
587    /**
588     * Activity Action: Show settings to enable/disable input method subtypes.
589     * <p>
590     * In some cases, a matching Activity may not exist, so ensure you
591     * safeguard against this.
592     * <p>
593     * To tell which input method's subtypes are displayed in the settings, add
594     * {@link #EXTRA_INPUT_METHOD_ID} extra to this Intent with the input method id.
595     * If there is no extra in this Intent, subtypes from all installed input methods
596     * will be displayed in the settings.
597     *
598     * @see android.view.inputmethod.InputMethodInfo#getId
599     * <p>
600     * Input: Nothing.
601     * <p>
602     * Output: Nothing.
603     */
604    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
605    public static final String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
606            "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
607
608    /**
609     * Activity Action: Show settings to manage the user input dictionary.
610     * <p>
611     * Starting with {@link android.os.Build.VERSION_CODES#KITKAT},
612     * it is guaranteed there will always be an appropriate implementation for this Intent action.
613     * In prior releases of the platform this was optional, so ensure you safeguard against it.
614     * <p>
615     * Input: Nothing.
616     * <p>
617     * Output: Nothing.
618     */
619    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
620    public static final String ACTION_USER_DICTIONARY_SETTINGS =
621            "android.settings.USER_DICTIONARY_SETTINGS";
622
623    /**
624     * Activity Action: Show settings to configure the hardware keyboard.
625     * <p>
626     * In some cases, a matching Activity may not exist, so ensure you
627     * safeguard against this.
628     * <p>
629     * Input: Nothing.
630     * <p>
631     * Output: Nothing.
632     */
633    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
634    public static final String ACTION_HARD_KEYBOARD_SETTINGS =
635            "android.settings.HARD_KEYBOARD_SETTINGS";
636
637    /**
638     * Activity Action: Adds a word to the user dictionary.
639     * <p>
640     * In some cases, a matching Activity may not exist, so ensure you
641     * safeguard against this.
642     * <p>
643     * Input: An extra with key <code>word</code> that contains the word
644     * that should be added to the dictionary.
645     * <p>
646     * Output: Nothing.
647     *
648     * @hide
649     */
650    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
651    public static final String ACTION_USER_DICTIONARY_INSERT =
652            "com.android.settings.USER_DICTIONARY_INSERT";
653
654    /**
655     * Activity Action: Show settings to allow configuration of application-related settings.
656     * <p>
657     * In some cases, a matching Activity may not exist, so ensure you
658     * safeguard against this.
659     * <p>
660     * Input: Nothing.
661     * <p>
662     * Output: Nothing.
663     */
664    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
665    public static final String ACTION_APPLICATION_SETTINGS =
666            "android.settings.APPLICATION_SETTINGS";
667
668    /**
669     * Activity Action: Show settings to allow configuration of application
670     * development-related settings.  As of
671     * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} this action is
672     * a required part of the platform.
673     * <p>
674     * Input: Nothing.
675     * <p>
676     * Output: Nothing.
677     */
678    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
679    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
680            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
681
682    /**
683     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
684     * <p>
685     * In some cases, a matching Activity may not exist, so ensure you
686     * safeguard against this.
687     * <p>
688     * Input: Nothing.
689     * <p>
690     * Output: Nothing.
691     */
692    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
693    public static final String ACTION_QUICK_LAUNCH_SETTINGS =
694            "android.settings.QUICK_LAUNCH_SETTINGS";
695
696    /**
697     * Activity Action: Show settings to manage installed applications.
698     * <p>
699     * In some cases, a matching Activity may not exist, so ensure you
700     * safeguard against this.
701     * <p>
702     * Input: Nothing.
703     * <p>
704     * Output: Nothing.
705     */
706    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
707    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
708            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
709
710    /**
711     * Activity Action: Show settings to manage all applications.
712     * <p>
713     * In some cases, a matching Activity may not exist, so ensure you
714     * safeguard against this.
715     * <p>
716     * Input: Nothing.
717     * <p>
718     * Output: Nothing.
719     */
720    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
721    public static final String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
722            "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS";
723
724    /**
725     * Activity Action: Show screen for controlling which apps can draw on top of other apps.
726     * <p>
727     * In some cases, a matching Activity may not exist, so ensure you
728     * safeguard against this.
729     * <p>
730     * Input: Optionally, the Intent's data URI can specify the application package name to
731     * directly invoke the management GUI specific to the package name. For example
732     * "package:com.my.app".
733     * <p>
734     * Output: Nothing.
735     */
736    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
737    public static final String ACTION_MANAGE_OVERLAY_PERMISSION =
738            "android.settings.action.MANAGE_OVERLAY_PERMISSION";
739
740    /**
741     * Activity Action: Show screen for controlling which apps are allowed to write/modify
742     * system settings.
743     * <p>
744     * In some cases, a matching Activity may not exist, so ensure you
745     * safeguard against this.
746     * <p>
747     * Input: Optionally, the Intent's data URI can specify the application package name to
748     * directly invoke the management GUI specific to the package name. For example
749     * "package:com.my.app".
750     * <p>
751     * Output: Nothing.
752     */
753    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
754    public static final String ACTION_MANAGE_WRITE_SETTINGS =
755            "android.settings.action.MANAGE_WRITE_SETTINGS";
756
757    /**
758     * Activity Action: Show screen of details about a particular application.
759     * <p>
760     * In some cases, a matching Activity may not exist, so ensure you
761     * safeguard against this.
762     * <p>
763     * Input: The Intent's data URI specifies the application package name
764     * to be shown, with the "package" scheme.  That is "package:com.my.app".
765     * <p>
766     * Output: Nothing.
767     */
768    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
769    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
770            "android.settings.APPLICATION_DETAILS_SETTINGS";
771
772    /**
773     * Activity Action: Show list of applications that have been running
774     * foreground services (to the user "running in the background").
775     * <p>
776     * Input: Extras "packages" is a string array of package names.
777     * <p>
778     * Output: Nothing.
779     * @hide
780     */
781    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
782    public static final String ACTION_FOREGROUND_SERVICES_SETTINGS =
783            "android.settings.FOREGROUND_SERVICES_SETTINGS";
784
785    /**
786     * Activity Action: Show screen for controlling which apps can ignore battery optimizations.
787     * <p>
788     * Input: Nothing.
789     * <p>
790     * Output: Nothing.
791     * <p>
792     * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
793     * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
794     * already ignoring optimizations.  You can use
795     * {@link #ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS} to ask the user to put you
796     * on this list.
797     */
798    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
799    public static final String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS =
800            "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
801
802    /**
803     * Activity Action: Ask the user to allow an app to ignore battery optimizations (that is,
804     * put them on the whitelist of apps shown by
805     * {@link #ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}).  For an app to use this, it also
806     * must hold the {@link android.Manifest.permission#REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}
807     * permission.
808     * <p><b>Note:</b> most applications should <em>not</em> use this; there are many facilities
809     * provided by the platform for applications to operate correctly in the various power
810     * saving modes.  This is only for unusual applications that need to deeply control their own
811     * execution, at the potential expense of the user's battery life.  Note that these applications
812     * greatly run the risk of showing to the user as high power consumers on their device.</p>
813     * <p>
814     * Input: The Intent's data URI must specify the application package name
815     * to be shown, with the "package" scheme.  That is "package:com.my.app".
816     * <p>
817     * Output: Nothing.
818     * <p>
819     * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
820     * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
821     * already ignoring optimizations.
822     */
823    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
824    public static final String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS =
825            "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
826
827    /**
828     * Activity Action: Show screen for controlling background data
829     * restrictions for a particular application.
830     * <p>
831     * Input: Intent's data URI set with an application name, using the
832     * "package" schema (like "package:com.my.app").
833     *
834     * <p>
835     * Output: Nothing.
836     * <p>
837     * Applications can also use {@link android.net.ConnectivityManager#getRestrictBackgroundStatus
838     * ConnectivityManager#getRestrictBackgroundStatus()} to determine the
839     * status of the background data restrictions for them.
840     */
841    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
842    public static final String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS =
843            "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
844
845    /**
846     * @hide
847     * Activity Action: Show the "app ops" settings screen.
848     * <p>
849     * Input: Nothing.
850     * <p>
851     * Output: Nothing.
852     */
853    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
854    public static final String ACTION_APP_OPS_SETTINGS =
855            "android.settings.APP_OPS_SETTINGS";
856
857    /**
858     * Activity Action: Show settings for system update functionality.
859     * <p>
860     * In some cases, a matching Activity may not exist, so ensure you
861     * safeguard against this.
862     * <p>
863     * Input: Nothing.
864     * <p>
865     * Output: Nothing.
866     *
867     * @hide
868     */
869    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
870    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
871            "android.settings.SYSTEM_UPDATE_SETTINGS";
872
873    /**
874     * Activity Action: Show settings for managed profile settings.
875     * <p>
876     * In some cases, a matching Activity may not exist, so ensure you
877     * safeguard against this.
878     * <p>
879     * Input: Nothing.
880     * <p>
881     * Output: Nothing.
882     *
883     * @hide
884     */
885    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
886    public static final String ACTION_MANAGED_PROFILE_SETTINGS =
887            "android.settings.MANAGED_PROFILE_SETTINGS";
888
889    /**
890     * Activity Action: Show settings to allow configuration of sync settings.
891     * <p>
892     * In some cases, a matching Activity may not exist, so ensure you
893     * safeguard against this.
894     * <p>
895     * The account types available to add via the add account button may be restricted by adding an
896     * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's
897     * authorities. Only account types which can sync with that content provider will be offered to
898     * the user.
899     * <p>
900     * Input: Nothing.
901     * <p>
902     * Output: Nothing.
903     */
904    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
905    public static final String ACTION_SYNC_SETTINGS =
906            "android.settings.SYNC_SETTINGS";
907
908    /**
909     * Activity Action: Show add account screen for creating a new account.
910     * <p>
911     * In some cases, a matching Activity may not exist, so ensure you
912     * safeguard against this.
913     * <p>
914     * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES}
915     * extra to the Intent with one or more syncable content provider's authorities.  Only account
916     * types which can sync with that content provider will be offered to the user.
917     * <p>
918     * Account types can also be filtered by adding an {@link #EXTRA_ACCOUNT_TYPES} extra to the
919     * Intent with one or more account types.
920     * <p>
921     * Input: Nothing.
922     * <p>
923     * Output: Nothing.
924     */
925    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
926    public static final String ACTION_ADD_ACCOUNT =
927            "android.settings.ADD_ACCOUNT_SETTINGS";
928
929    /**
930     * Activity Action: Show settings for selecting the network operator.
931     * <p>
932     * In some cases, a matching Activity may not exist, so ensure you
933     * safeguard against this.
934     * <p>
935     * The subscription ID of the subscription for which available network operators should be
936     * displayed may be optionally specified with {@link #EXTRA_SUB_ID}.
937     * <p>
938     * Input: Nothing.
939     * <p>
940     * Output: Nothing.
941     */
942    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
943    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
944            "android.settings.NETWORK_OPERATOR_SETTINGS";
945
946    /**
947     * Activity Action: Show settings for selection of 2G/3G.
948     * <p>
949     * In some cases, a matching Activity may not exist, so ensure you
950     * safeguard against this.
951     * <p>
952     * Input: Nothing.
953     * <p>
954     * Output: Nothing.
955     */
956    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
957    public static final String ACTION_DATA_ROAMING_SETTINGS =
958            "android.settings.DATA_ROAMING_SETTINGS";
959
960    /**
961     * Activity Action: Show settings for internal storage.
962     * <p>
963     * In some cases, a matching Activity may not exist, so ensure you
964     * safeguard against this.
965     * <p>
966     * Input: Nothing.
967     * <p>
968     * Output: Nothing.
969     */
970    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
971    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
972            "android.settings.INTERNAL_STORAGE_SETTINGS";
973    /**
974     * Activity Action: Show settings for memory card storage.
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_MEMORY_CARD_SETTINGS =
985            "android.settings.MEMORY_CARD_SETTINGS";
986
987    /**
988     * Activity Action: Show settings for global search.
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     */
997    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
998    public static final String ACTION_SEARCH_SETTINGS =
999        "android.search.action.SEARCH_SETTINGS";
1000
1001    /**
1002     * Activity Action: Show general device information settings (serial
1003     * number, software version, phone number, etc.).
1004     * <p>
1005     * In some cases, a matching Activity may not exist, so ensure you
1006     * safeguard against this.
1007     * <p>
1008     * Input: Nothing.
1009     * <p>
1010     * Output: Nothing
1011     */
1012    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1013    public static final String ACTION_DEVICE_INFO_SETTINGS =
1014        "android.settings.DEVICE_INFO_SETTINGS";
1015
1016    /**
1017     * Activity Action: Show NFC settings.
1018     * <p>
1019     * This shows UI that allows NFC to be turned on or off.
1020     * <p>
1021     * In some cases, a matching Activity may not exist, so ensure you
1022     * safeguard against this.
1023     * <p>
1024     * Input: Nothing.
1025     * <p>
1026     * Output: Nothing
1027     * @see android.nfc.NfcAdapter#isEnabled()
1028     */
1029    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1030    public static final String ACTION_NFC_SETTINGS = "android.settings.NFC_SETTINGS";
1031
1032    /**
1033     * Activity Action: Show NFC Sharing settings.
1034     * <p>
1035     * This shows UI that allows NDEF Push (Android Beam) to be turned on or
1036     * off.
1037     * <p>
1038     * In some cases, a matching Activity may not exist, so ensure you
1039     * safeguard against this.
1040     * <p>
1041     * Input: Nothing.
1042     * <p>
1043     * Output: Nothing
1044     * @see android.nfc.NfcAdapter#isNdefPushEnabled()
1045     */
1046    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1047    public static final String ACTION_NFCSHARING_SETTINGS =
1048        "android.settings.NFCSHARING_SETTINGS";
1049
1050    /**
1051     * Activity Action: Show NFC Tap & Pay settings
1052     * <p>
1053     * This shows UI that allows the user to configure Tap&Pay
1054     * settings.
1055     * <p>
1056     * In some cases, a matching Activity may not exist, so ensure you
1057     * safeguard against this.
1058     * <p>
1059     * Input: Nothing.
1060     * <p>
1061     * Output: Nothing
1062     */
1063    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1064    public static final String ACTION_NFC_PAYMENT_SETTINGS =
1065        "android.settings.NFC_PAYMENT_SETTINGS";
1066
1067    /**
1068     * Activity Action: Show Daydream settings.
1069     * <p>
1070     * In some cases, a matching Activity may not exist, so ensure you
1071     * safeguard against this.
1072     * <p>
1073     * Input: Nothing.
1074     * <p>
1075     * Output: Nothing.
1076     * @see android.service.dreams.DreamService
1077     */
1078    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1079    public static final String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
1080
1081    /**
1082     * Activity Action: Show Notification listener settings.
1083     * <p>
1084     * In some cases, a matching Activity may not exist, so ensure you
1085     * safeguard against this.
1086     * <p>
1087     * Input: Nothing.
1088     * <p>
1089     * Output: Nothing.
1090     * @see android.service.notification.NotificationListenerService
1091     */
1092    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1093    public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS
1094            = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
1095
1096    /**
1097     * Activity Action: Show Do Not Disturb access settings.
1098     * <p>
1099     * Users can grant and deny access to Do Not Disturb configuration from here.
1100     * See {@link android.app.NotificationManager#isNotificationPolicyAccessGranted()} for more
1101     * details.
1102     * <p>
1103     * Input: Nothing.
1104     * <p>
1105     * Output: Nothing.
1106     */
1107    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1108    public static final String ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS
1109            = "android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS";
1110
1111    /**
1112     * @hide
1113     */
1114    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1115    public static final String ACTION_CONDITION_PROVIDER_SETTINGS
1116            = "android.settings.ACTION_CONDITION_PROVIDER_SETTINGS";
1117
1118    /**
1119     * Activity Action: Show settings for video captioning.
1120     * <p>
1121     * In some cases, a matching Activity may not exist, so ensure you safeguard
1122     * against this.
1123     * <p>
1124     * Input: Nothing.
1125     * <p>
1126     * Output: Nothing.
1127     */
1128    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1129    public static final String ACTION_CAPTIONING_SETTINGS = "android.settings.CAPTIONING_SETTINGS";
1130
1131    /**
1132     * Activity Action: Show the top level print settings.
1133     * <p>
1134     * In some cases, a matching Activity may not exist, so ensure you
1135     * safeguard against this.
1136     * <p>
1137     * Input: Nothing.
1138     * <p>
1139     * Output: Nothing.
1140     */
1141    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1142    public static final String ACTION_PRINT_SETTINGS =
1143            "android.settings.ACTION_PRINT_SETTINGS";
1144
1145    /**
1146     * Activity Action: Show Zen Mode configuration settings.
1147     *
1148     * @hide
1149     */
1150    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1151    public static final String ACTION_ZEN_MODE_SETTINGS = "android.settings.ZEN_MODE_SETTINGS";
1152
1153    /**
1154     * Activity Action: Show Zen Mode (aka Do Not Disturb) priority configuration settings.
1155     */
1156    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1157    public static final String ACTION_ZEN_MODE_PRIORITY_SETTINGS
1158            = "android.settings.ZEN_MODE_PRIORITY_SETTINGS";
1159
1160    /**
1161     * Activity Action: Show Zen Mode automation configuration settings.
1162     *
1163     * @hide
1164     */
1165    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166    public static final String ACTION_ZEN_MODE_AUTOMATION_SETTINGS
1167            = "android.settings.ZEN_MODE_AUTOMATION_SETTINGS";
1168
1169    /**
1170     * Activity Action: Modify do not disturb mode settings.
1171     * <p>
1172     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
1173     * <p>
1174     * This intent MUST be started using
1175     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
1176     * startVoiceActivity}.
1177     * <p>
1178     * Note: The Activity implementing this intent MUST verify that
1179     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction}.
1180     * returns true before modifying the setting.
1181     * <p>
1182     * Input: The optional {@link #EXTRA_DO_NOT_DISTURB_MODE_MINUTES} extra can be used to indicate
1183     * how long the user wishes to avoid interruptions for. The optional
1184     * {@link #EXTRA_DO_NOT_DISTURB_MODE_ENABLED} extra can be to indicate if the user is
1185     * enabling or disabling do not disturb mode. If either extra is not included, the
1186     * user maybe asked to provide the value.
1187     * <p>
1188     * Output: Nothing.
1189     */
1190    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191    public static final String ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE =
1192            "android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE";
1193
1194    /**
1195     * Activity Action: Show Zen Mode schedule rule configuration settings.
1196     *
1197     * @hide
1198     */
1199    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1200    public static final String ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS
1201            = "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS";
1202
1203    /**
1204     * Activity Action: Show Zen Mode event rule configuration settings.
1205     *
1206     * @hide
1207     */
1208    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209    public static final String ACTION_ZEN_MODE_EVENT_RULE_SETTINGS
1210            = "android.settings.ZEN_MODE_EVENT_RULE_SETTINGS";
1211
1212    /**
1213     * Activity Action: Show Zen Mode external rule configuration settings.
1214     *
1215     * @hide
1216     */
1217    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1218    public static final String ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS
1219            = "android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS";
1220
1221    /**
1222     * Activity Action: Show the regulatory information screen for the device.
1223     * <p>
1224     * In some cases, a matching Activity may not exist, so ensure you safeguard
1225     * against this.
1226     * <p>
1227     * Input: Nothing.
1228     * <p>
1229     * Output: Nothing.
1230     */
1231    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1232    public static final String
1233            ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
1234
1235    /**
1236     * Activity Action: Show Device Name Settings.
1237     * <p>
1238     * In some cases, a matching Activity may not exist, so ensure you safeguard
1239     * against this.
1240     *
1241     * @hide
1242     */
1243    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244    public static final String DEVICE_NAME_SETTINGS = "android.settings.DEVICE_NAME";
1245
1246    /**
1247     * Activity Action: Show pairing settings.
1248     * <p>
1249     * In some cases, a matching Activity may not exist, so ensure you safeguard
1250     * against this.
1251     *
1252     * @hide
1253     */
1254    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255    public static final String ACTION_PAIRING_SETTINGS = "android.settings.PAIRING_SETTINGS";
1256
1257    /**
1258     * Activity Action: Show battery saver settings.
1259     * <p>
1260     * In some cases, a matching Activity may not exist, so ensure you safeguard
1261     * against this.
1262     */
1263    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264    public static final String ACTION_BATTERY_SAVER_SETTINGS
1265            = "android.settings.BATTERY_SAVER_SETTINGS";
1266
1267    /**
1268     * Activity Action: Modify Battery Saver mode setting using a voice command.
1269     * <p>
1270     * In some cases, a matching Activity may not exist, so ensure you safeguard against this.
1271     * <p>
1272     * This intent MUST be started using
1273     * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity
1274     * startVoiceActivity}.
1275     * <p>
1276     * Note: The activity implementing this intent MUST verify that
1277     * {@link android.app.Activity#isVoiceInteraction isVoiceInteraction} returns true before
1278     * modifying the setting.
1279     * <p>
1280     * Input: To tell which state batter saver mode should be set to, add the
1281     * {@link #EXTRA_BATTERY_SAVER_MODE_ENABLED} extra to this Intent with the state specified.
1282     * If the extra is not included, no changes will be made.
1283     * <p>
1284     * Output: Nothing.
1285     */
1286    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1287    public static final String ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE =
1288            "android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE";
1289
1290    /**
1291     * Activity Action: Show Home selection settings. If there are multiple activities
1292     * that can satisfy the {@link Intent#CATEGORY_HOME} intent, this screen allows you
1293     * to pick your preferred activity.
1294     */
1295    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296    public static final String ACTION_HOME_SETTINGS
1297            = "android.settings.HOME_SETTINGS";
1298
1299    /**
1300     * Activity Action: Show Default apps settings.
1301     * <p>
1302     * In some cases, a matching Activity may not exist, so ensure you
1303     * safeguard against this.
1304     * <p>
1305     * Input: Nothing.
1306     * <p>
1307     * Output: Nothing.
1308     */
1309    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310    public static final String ACTION_MANAGE_DEFAULT_APPS_SETTINGS
1311            = "android.settings.MANAGE_DEFAULT_APPS_SETTINGS";
1312
1313    /**
1314     * Activity Action: Show notification settings.
1315     *
1316     * @hide
1317     */
1318    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319    public static final String ACTION_NOTIFICATION_SETTINGS
1320            = "android.settings.NOTIFICATION_SETTINGS";
1321
1322    /**
1323     * Activity Action: Show notification settings for a single app.
1324     * <p>
1325     *     Input: {@link #EXTRA_APP_PACKAGE}, the package containing the channel to display.
1326     *     Input: Optionally, {@link #EXTRA_CHANNEL_ID}, to highlight that channel.
1327     * <p>
1328     * Output: Nothing.
1329     */
1330    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331    public static final String ACTION_APP_NOTIFICATION_SETTINGS
1332            = "android.settings.APP_NOTIFICATION_SETTINGS";
1333
1334    /**
1335     * Activity Action: Show notification settings for a single {@link NotificationChannel}.
1336     * <p>
1337     *     Input: {@link #EXTRA_APP_PACKAGE}, the package containing the channel to display.
1338     *     Input: {@link #EXTRA_CHANNEL_ID}, the id of the channel to display.
1339     * <p>
1340     * Output: Nothing.
1341     */
1342    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1343    public static final String ACTION_CHANNEL_NOTIFICATION_SETTINGS
1344            = "android.settings.CHANNEL_NOTIFICATION_SETTINGS";
1345
1346    /**
1347     * Activity Extra: The package owner of the notification channel settings to display.
1348     * <p>
1349     * This must be passed as an extra field to the {@link #ACTION_CHANNEL_NOTIFICATION_SETTINGS}.
1350     */
1351    public static final String EXTRA_APP_PACKAGE = "android.provider.extra.APP_PACKAGE";
1352
1353    /**
1354     * Activity Extra: The {@link NotificationChannel#getId()} of the notification channel settings
1355     * to display.
1356     * <p>
1357     * This must be passed as an extra field to the {@link #ACTION_CHANNEL_NOTIFICATION_SETTINGS}.
1358     */
1359    public static final String EXTRA_CHANNEL_ID = "android.provider.extra.CHANNEL_ID";
1360
1361    /**
1362     * Activity Action: Show notification redaction settings.
1363     *
1364     * @hide
1365     */
1366    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1367    public static final String ACTION_APP_NOTIFICATION_REDACTION
1368            = "android.settings.ACTION_APP_NOTIFICATION_REDACTION";
1369
1370    /** @hide */ public static final String EXTRA_APP_UID = "app_uid";
1371
1372    /**
1373     * Activity Action: Show a dialog with disabled by policy message.
1374     * <p> If an user action is disabled by policy, this dialog can be triggered to let
1375     * the user know about this.
1376     * <p>
1377     * Input: Nothing.
1378     * <p>
1379     * Output: Nothing.
1380     *
1381     * @hide
1382     */
1383    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1384    public static final String ACTION_SHOW_ADMIN_SUPPORT_DETAILS
1385            = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
1386
1387    /**
1388     * Activity Action: Show a dialog for remote bugreport flow.
1389     * <p>
1390     * Input: Nothing.
1391     * <p>
1392     * Output: Nothing.
1393     *
1394     * @hide
1395     */
1396    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1397    public static final String ACTION_SHOW_REMOTE_BUGREPORT_DIALOG
1398            = "android.settings.SHOW_REMOTE_BUGREPORT_DIALOG";
1399
1400    /**
1401     * Activity Action: Show VR listener settings.
1402     * <p>
1403     * Input: Nothing.
1404     * <p>
1405     * Output: Nothing.
1406     *
1407     * @see android.service.vr.VrListenerService
1408     */
1409    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1410    public static final String ACTION_VR_LISTENER_SETTINGS
1411            = "android.settings.VR_LISTENER_SETTINGS";
1412
1413    /**
1414     * Activity Action: Show Picture-in-picture settings.
1415     * <p>
1416     * Input: Nothing.
1417     * <p>
1418     * Output: Nothing.
1419     *
1420     * @hide
1421     */
1422    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423    public static final String ACTION_PICTURE_IN_PICTURE_SETTINGS
1424            = "android.settings.PICTURE_IN_PICTURE_SETTINGS";
1425
1426    /**
1427     * Activity Action: Show Storage Manager settings.
1428     * <p>
1429     * Input: Nothing.
1430     * <p>
1431     * Output: Nothing.
1432     *
1433     * @hide
1434     */
1435    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1436    public static final String ACTION_STORAGE_MANAGER_SETTINGS
1437            = "android.settings.STORAGE_MANAGER_SETTINGS";
1438
1439    /**
1440     * Activity Action: Allows user to select current webview implementation.
1441     * <p>
1442     * Input: Nothing.
1443     * <p>
1444     * Output: Nothing.
1445     */
1446    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1447    public static final String ACTION_WEBVIEW_SETTINGS = "android.settings.WEBVIEW_SETTINGS";
1448
1449    /**
1450     * Activity Action: Show enterprise privacy section.
1451     * <p>
1452     * Input: Nothing.
1453     * <p>
1454     * Output: Nothing.
1455     * @hide
1456     */
1457    @SystemApi
1458    @TestApi
1459    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1460    public static final String ACTION_ENTERPRISE_PRIVACY_SETTINGS
1461            = "android.settings.ENTERPRISE_PRIVACY_SETTINGS";
1462
1463    /**
1464     * Activity Action: Show screen that let user select its Autofill Service.
1465     * <p>
1466     * Input: Intent's data URI set with an application name, using the
1467     * "package" schema (like "package:com.my.app").
1468     *
1469     * <p>
1470     * Output: {@link android.app.Activity#RESULT_OK} if user selected an Autofill Service belonging
1471     * to the caller package.
1472     *
1473     * <p>
1474     * <b>NOTE: </b> Applications should call
1475     * {@link android.view.autofill.AutofillManager#hasEnabledAutofillServices()} and
1476     * {@link android.view.autofill.AutofillManager#isAutofillSupported()}, and only use this action
1477     * to start an activity if they return {@code false} and {@code true} respectively.
1478     */
1479    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1480    public static final String ACTION_REQUEST_SET_AUTOFILL_SERVICE =
1481            "android.settings.REQUEST_SET_AUTOFILL_SERVICE";
1482
1483    /**
1484     * Activity Action: Show screen for controlling which apps have access on volume directories.
1485     * <p>
1486     * Input: Nothing.
1487     * <p>
1488     * Output: Nothing.
1489     * <p>
1490     * Applications typically use this action to ask the user to revert the "Do not ask again"
1491     * status of directory access requests made by
1492     * {@link android.os.storage.StorageVolume#createAccessIntent(String)}.
1493     */
1494    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1495    public static final String ACTION_STORAGE_VOLUME_ACCESS_SETTINGS =
1496            "android.settings.STORAGE_VOLUME_ACCESS_SETTINGS";
1497
1498    // End of Intent actions for Settings
1499
1500    /**
1501     * @hide - Private call() method on SettingsProvider to read from 'system' table.
1502     */
1503    public static final String CALL_METHOD_GET_SYSTEM = "GET_system";
1504
1505    /**
1506     * @hide - Private call() method on SettingsProvider to read from 'secure' table.
1507     */
1508    public static final String CALL_METHOD_GET_SECURE = "GET_secure";
1509
1510    /**
1511     * @hide - Private call() method on SettingsProvider to read from 'global' table.
1512     */
1513    public static final String CALL_METHOD_GET_GLOBAL = "GET_global";
1514
1515    /**
1516     * @hide - Specifies that the caller of the fast-path call()-based flow tracks
1517     * the settings generation in order to cache values locally. If this key is
1518     * mapped to a <code>null</code> string extra in the request bundle, the response
1519     * bundle will contain the same key mapped to a parcelable extra which would be
1520     * an {@link android.util.MemoryIntArray}. The response will also contain an
1521     * integer mapped to the {@link #CALL_METHOD_GENERATION_INDEX_KEY} which is the
1522     * index in the array clients should use to lookup the generation. For efficiency
1523     * the caller should request the generation tracking memory array only if it
1524     * doesn't already have it.
1525     *
1526     * @see #CALL_METHOD_GENERATION_INDEX_KEY
1527     */
1528    public static final String CALL_METHOD_TRACK_GENERATION_KEY = "_track_generation";
1529
1530    /**
1531     * @hide Key with the location in the {@link android.util.MemoryIntArray} where
1532     * to look up the generation id of the backing table. The value is an integer.
1533     *
1534     * @see #CALL_METHOD_TRACK_GENERATION_KEY
1535     */
1536    public static final String CALL_METHOD_GENERATION_INDEX_KEY = "_generation_index";
1537
1538    /**
1539     * @hide Key with the settings table generation. The value is an integer.
1540     *
1541     * @see #CALL_METHOD_TRACK_GENERATION_KEY
1542     */
1543    public static final String CALL_METHOD_GENERATION_KEY = "_generation";
1544
1545    /**
1546     * @hide - User handle argument extra to the fast-path call()-based requests
1547     */
1548    public static final String CALL_METHOD_USER_KEY = "_user";
1549
1550    /**
1551     * @hide - Boolean argument extra to the fast-path call()-based requests
1552     */
1553    public static final String CALL_METHOD_MAKE_DEFAULT_KEY = "_make_default";
1554
1555    /**
1556     * @hide - User handle argument extra to the fast-path call()-based requests
1557     */
1558    public static final String CALL_METHOD_RESET_MODE_KEY = "_reset_mode";
1559
1560    /**
1561     * @hide - String argument extra to the fast-path call()-based requests
1562     */
1563    public static final String CALL_METHOD_TAG_KEY = "_tag";
1564
1565    /** @hide - Private call() method to write to 'system' table */
1566    public static final String CALL_METHOD_PUT_SYSTEM = "PUT_system";
1567
1568    /** @hide - Private call() method to write to 'secure' table */
1569    public static final String CALL_METHOD_PUT_SECURE = "PUT_secure";
1570
1571    /** @hide - Private call() method to write to 'global' table */
1572    public static final String CALL_METHOD_PUT_GLOBAL= "PUT_global";
1573
1574    /** @hide - Private call() method to reset to defaults the 'global' table */
1575    public static final String CALL_METHOD_RESET_GLOBAL = "RESET_global";
1576
1577    /** @hide - Private call() method to reset to defaults the 'secure' table */
1578    public static final String CALL_METHOD_RESET_SECURE = "RESET_secure";
1579
1580    /**
1581     * Activity Extra: Limit available options in launched activity based on the given authority.
1582     * <p>
1583     * This can be passed as an extra field in an Activity Intent with one or more syncable content
1584     * provider's authorities as a String[]. This field is used by some intents to alter the
1585     * behavior of the called activity.
1586     * <p>
1587     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based
1588     * on the authority given.
1589     */
1590    public static final String EXTRA_AUTHORITIES = "authorities";
1591
1592    /**
1593     * Activity Extra: Limit available options in launched activity based on the given account
1594     * types.
1595     * <p>
1596     * This can be passed as an extra field in an Activity Intent with one or more account types
1597     * as a String[]. This field is used by some intents to alter the behavior of the called
1598     * activity.
1599     * <p>
1600     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types to the specified
1601     * list.
1602     */
1603    public static final String EXTRA_ACCOUNT_TYPES = "account_types";
1604
1605    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
1606
1607    /**
1608     * Activity Extra: The device identifier to act upon.
1609     * <p>
1610     * This can be passed as an extra field in an Activity Intent with a single
1611     * InputDeviceIdentifier. This field is used by some activities to jump straight into the
1612     * settings for the given device.
1613     * <p>
1614     * Example: The {@link #ACTION_INPUT_METHOD_SETTINGS} intent opens the keyboard layout
1615     * dialog for the given device.
1616     * @hide
1617     */
1618    public static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
1619
1620    /**
1621     * Activity Extra: Enable or disable Airplane Mode.
1622     * <p>
1623     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_AIRPLANE_MODE}
1624     * intent as a boolean to indicate if it should be enabled.
1625     */
1626    public static final String EXTRA_AIRPLANE_MODE_ENABLED = "airplane_mode_enabled";
1627
1628    /**
1629     * Activity Extra: Enable or disable Battery saver mode.
1630     * <p>
1631     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE}
1632     * intent as a boolean to indicate if it should be enabled.
1633     */
1634    public static final String EXTRA_BATTERY_SAVER_MODE_ENABLED =
1635            "android.settings.extra.battery_saver_mode_enabled";
1636
1637    /**
1638     * Activity Extra: Enable or disable Do Not Disturb mode.
1639     * <p>
1640     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1641     * intent as a boolean to indicate if it should be enabled.
1642     */
1643    public static final String EXTRA_DO_NOT_DISTURB_MODE_ENABLED =
1644            "android.settings.extra.do_not_disturb_mode_enabled";
1645
1646    /**
1647     * Activity Extra: How many minutes to enable do not disturb mode for.
1648     * <p>
1649     * This can be passed as an extra field to the {@link #ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE}
1650     * intent to indicate how long do not disturb mode should be enabled for.
1651     */
1652    public static final String EXTRA_DO_NOT_DISTURB_MODE_MINUTES =
1653            "android.settings.extra.do_not_disturb_mode_minutes";
1654
1655    /**
1656     * Reset mode: reset to defaults only settings changed by the
1657     * calling package. If there is a default set the setting
1658     * will be set to it, otherwise the setting will be deleted.
1659     * This is the only type of reset available to non-system clients.
1660     * @hide
1661     */
1662    public static final int RESET_MODE_PACKAGE_DEFAULTS = 1;
1663
1664    /**
1665     * Reset mode: reset all settings set by untrusted packages, which is
1666     * packages that aren't a part of the system, to the current defaults.
1667     * If there is a default set the setting will be set to it, otherwise
1668     * the setting will be deleted. This mode is only available to the system.
1669     * @hide
1670     */
1671    public static final int RESET_MODE_UNTRUSTED_DEFAULTS = 2;
1672
1673    /**
1674     * Reset mode: delete all settings set by untrusted packages, which is
1675     * packages that aren't a part of the system. If a setting is set by an
1676     * untrusted package it will be deleted if its default is not provided
1677     * by the system, otherwise the setting will be set to its default.
1678     * This mode is only available to the system.
1679     * @hide
1680     */
1681    public static final int RESET_MODE_UNTRUSTED_CHANGES = 3;
1682
1683    /**
1684     * Reset mode: reset all settings to defaults specified by trusted
1685     * packages, which is packages that are a part of the system, and
1686     * delete all settings set by untrusted packages. If a setting has
1687     * a default set by a system package it will be set to the default,
1688     * otherwise the setting will be deleted. This mode is only available
1689     * to the system.
1690     * @hide
1691     */
1692    public static final int RESET_MODE_TRUSTED_DEFAULTS = 4;
1693
1694    /** @hide */
1695    @Retention(RetentionPolicy.SOURCE)
1696    @IntDef(prefix = { "RESET_MODE_" }, value = {
1697            RESET_MODE_PACKAGE_DEFAULTS,
1698            RESET_MODE_UNTRUSTED_DEFAULTS,
1699            RESET_MODE_UNTRUSTED_CHANGES,
1700            RESET_MODE_TRUSTED_DEFAULTS
1701    })
1702    public @interface ResetMode{}
1703
1704    /**
1705     * Activity Extra: Number of certificates
1706     * <p>
1707     * This can be passed as an extra field to the {@link #ACTION_MONITORING_CERT_INFO}
1708     * intent to indicate the number of certificates
1709     * @hide
1710     */
1711    public static final String EXTRA_NUMBER_OF_CERTIFICATES =
1712            "android.settings.extra.number_of_certificates";
1713
1714    private static final String JID_RESOURCE_PREFIX = "android";
1715
1716    public static final String AUTHORITY = "settings";
1717
1718    private static final String TAG = "Settings";
1719    private static final boolean LOCAL_LOGV = false;
1720
1721    // Lock ensures that when enabling/disabling the master location switch, we don't end up
1722    // with a partial enable/disable state in multi-threaded situations.
1723    private static final Object mLocationSettingsLock = new Object();
1724
1725    // Used in system server calling uid workaround in call()
1726    private static boolean sInSystemServer = false;
1727    private static final Object sInSystemServerLock = new Object();
1728
1729    /** @hide */
1730    public static void setInSystemServer() {
1731        synchronized (sInSystemServerLock) {
1732            sInSystemServer = true;
1733        }
1734    }
1735
1736    /** @hide */
1737    public static boolean isInSystemServer() {
1738        synchronized (sInSystemServerLock) {
1739            return sInSystemServer;
1740        }
1741    }
1742
1743    public static class SettingNotFoundException extends AndroidException {
1744        public SettingNotFoundException(String msg) {
1745            super(msg);
1746        }
1747    }
1748
1749    /**
1750     * Common base for tables of name/value settings.
1751     */
1752    public static class NameValueTable implements BaseColumns {
1753        public static final String NAME = "name";
1754        public static final String VALUE = "value";
1755
1756        protected static boolean putString(ContentResolver resolver, Uri uri,
1757                String name, String value) {
1758            // The database will take care of replacing duplicates.
1759            try {
1760                ContentValues values = new ContentValues();
1761                values.put(NAME, name);
1762                values.put(VALUE, value);
1763                resolver.insert(uri, values);
1764                return true;
1765            } catch (SQLException e) {
1766                Log.w(TAG, "Can't set key " + name + " in " + uri, e);
1767                return false;
1768            }
1769        }
1770
1771        public static Uri getUriFor(Uri uri, String name) {
1772            return Uri.withAppendedPath(uri, name);
1773        }
1774    }
1775
1776    private static final class GenerationTracker {
1777        private final MemoryIntArray mArray;
1778        private final Runnable mErrorHandler;
1779        private final int mIndex;
1780        private int mCurrentGeneration;
1781
1782        public GenerationTracker(@NonNull MemoryIntArray array, int index,
1783                int generation, Runnable errorHandler) {
1784            mArray = array;
1785            mIndex = index;
1786            mErrorHandler = errorHandler;
1787            mCurrentGeneration = generation;
1788        }
1789
1790        public boolean isGenerationChanged() {
1791            final int currentGeneration = readCurrentGeneration();
1792            if (currentGeneration >= 0) {
1793                if (currentGeneration == mCurrentGeneration) {
1794                    return false;
1795                }
1796                mCurrentGeneration = currentGeneration;
1797            }
1798            return true;
1799        }
1800
1801        public int getCurrentGeneration() {
1802            return mCurrentGeneration;
1803        }
1804
1805        private int readCurrentGeneration() {
1806            try {
1807                return mArray.get(mIndex);
1808            } catch (IOException e) {
1809                Log.e(TAG, "Error getting current generation", e);
1810                if (mErrorHandler != null) {
1811                    mErrorHandler.run();
1812                }
1813            }
1814            return -1;
1815        }
1816
1817        public void destroy() {
1818            try {
1819                mArray.close();
1820            } catch (IOException e) {
1821                Log.e(TAG, "Error closing backing array", e);
1822                if (mErrorHandler != null) {
1823                    mErrorHandler.run();
1824                }
1825            }
1826        }
1827    }
1828
1829    private static final class ContentProviderHolder {
1830        private final Object mLock = new Object();
1831
1832        @GuardedBy("mLock")
1833        private final Uri mUri;
1834        @GuardedBy("mLock")
1835        private IContentProvider mContentProvider;
1836
1837        public ContentProviderHolder(Uri uri) {
1838            mUri = uri;
1839        }
1840
1841        public IContentProvider getProvider(ContentResolver contentResolver) {
1842            synchronized (mLock) {
1843                if (mContentProvider == null) {
1844                    mContentProvider = contentResolver
1845                            .acquireProvider(mUri.getAuthority());
1846                }
1847                return mContentProvider;
1848            }
1849        }
1850
1851        public void clearProviderForTest() {
1852            synchronized (mLock) {
1853                mContentProvider = null;
1854            }
1855        }
1856    }
1857
1858    // Thread-safe.
1859    private static class NameValueCache {
1860        private static final boolean DEBUG = false;
1861
1862        private static final String[] SELECT_VALUE_PROJECTION = new String[] {
1863                Settings.NameValueTable.VALUE
1864        };
1865
1866        private static final String NAME_EQ_PLACEHOLDER = "name=?";
1867
1868        // Must synchronize on 'this' to access mValues and mValuesVersion.
1869        private final HashMap<String, String> mValues = new HashMap<>();
1870
1871        private final Uri mUri;
1872        private final ContentProviderHolder mProviderHolder;
1873
1874        // The method we'll call (or null, to not use) on the provider
1875        // for the fast path of retrieving settings.
1876        private final String mCallGetCommand;
1877        private final String mCallSetCommand;
1878
1879        @GuardedBy("this")
1880        private GenerationTracker mGenerationTracker;
1881
1882        public NameValueCache(Uri uri, String getCommand, String setCommand,
1883                ContentProviderHolder providerHolder) {
1884            mUri = uri;
1885            mCallGetCommand = getCommand;
1886            mCallSetCommand = setCommand;
1887            mProviderHolder = providerHolder;
1888        }
1889
1890        public boolean putStringForUser(ContentResolver cr, String name, String value,
1891                String tag, boolean makeDefault, final int userHandle) {
1892            try {
1893                Bundle arg = new Bundle();
1894                arg.putString(Settings.NameValueTable.VALUE, value);
1895                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
1896                if (tag != null) {
1897                    arg.putString(CALL_METHOD_TAG_KEY, tag);
1898                }
1899                if (makeDefault) {
1900                    arg.putBoolean(CALL_METHOD_MAKE_DEFAULT_KEY, true);
1901                }
1902                IContentProvider cp = mProviderHolder.getProvider(cr);
1903                String prevValue = getStringForUser(cr, name, userHandle);
1904                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
1905                String newValue = getStringForUser(cr, name, userHandle);
1906                StatsLog.write(StatsLog.SETTING_CHANGED, name, value, newValue, prevValue, tag,
1907                        makeDefault, userHandle);
1908            } catch (RemoteException e) {
1909                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
1910                return false;
1911            }
1912            return true;
1913        }
1914
1915        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
1916            final boolean isSelf = (userHandle == UserHandle.myUserId());
1917            int currentGeneration = -1;
1918            if (isSelf) {
1919                synchronized (NameValueCache.this) {
1920                    if (mGenerationTracker != null) {
1921                        if (mGenerationTracker.isGenerationChanged()) {
1922                            if (DEBUG) {
1923                                Log.i(TAG, "Generation changed for type:"
1924                                        + mUri.getPath() + " in package:"
1925                                        + cr.getPackageName() +" and user:" + userHandle);
1926                            }
1927                            mValues.clear();
1928                        } else if (mValues.containsKey(name)) {
1929                            return mValues.get(name);
1930                        }
1931                        if (mGenerationTracker != null) {
1932                            currentGeneration = mGenerationTracker.getCurrentGeneration();
1933                        }
1934                    }
1935                }
1936            } else {
1937                if (LOCAL_LOGV) Log.v(TAG, "get setting for user " + userHandle
1938                        + " by user " + UserHandle.myUserId() + " so skipping cache");
1939            }
1940
1941            IContentProvider cp = mProviderHolder.getProvider(cr);
1942
1943            // Try the fast path first, not using query().  If this
1944            // fails (alternate Settings provider that doesn't support
1945            // this interface?) then we fall back to the query/table
1946            // interface.
1947            if (mCallGetCommand != null) {
1948                try {
1949                    Bundle args = null;
1950                    if (!isSelf) {
1951                        args = new Bundle();
1952                        args.putInt(CALL_METHOD_USER_KEY, userHandle);
1953                    }
1954                    boolean needsGenerationTracker = false;
1955                    synchronized (NameValueCache.this) {
1956                        if (isSelf && mGenerationTracker == null) {
1957                            needsGenerationTracker = true;
1958                            if (args == null) {
1959                                args = new Bundle();
1960                            }
1961                            args.putString(CALL_METHOD_TRACK_GENERATION_KEY, null);
1962                            if (DEBUG) {
1963                                Log.i(TAG, "Requested generation tracker for type: "+ mUri.getPath()
1964                                        + " in package:" + cr.getPackageName() +" and user:"
1965                                        + userHandle);
1966                            }
1967                        }
1968                    }
1969                    Bundle b;
1970                    // If we're in system server and in a binder transaction we need to clear the
1971                    // calling uid. This works around code in system server that did not call
1972                    // clearCallingIdentity, previously this wasn't needed because reading settings
1973                    // did not do permission checking but thats no longer the case.
1974                    // Long term this should be removed and callers should properly call
1975                    // clearCallingIdentity or use a ContentResolver from the caller as needed.
1976                    if (Settings.isInSystemServer() && Binder.getCallingUid() != Process.myUid()) {
1977                        final long token = Binder.clearCallingIdentity();
1978                        try {
1979                            b = cp.call(cr.getPackageName(), mCallGetCommand, name, args);
1980                        } finally {
1981                            Binder.restoreCallingIdentity(token);
1982                        }
1983                    } else {
1984                        b = cp.call(cr.getPackageName(), mCallGetCommand, name, args);
1985                    }
1986                    if (b != null) {
1987                        String value = b.getString(Settings.NameValueTable.VALUE);
1988                        // Don't update our cache for reads of other users' data
1989                        if (isSelf) {
1990                            synchronized (NameValueCache.this) {
1991                                if (needsGenerationTracker) {
1992                                    MemoryIntArray array = b.getParcelable(
1993                                            CALL_METHOD_TRACK_GENERATION_KEY);
1994                                    final int index = b.getInt(
1995                                            CALL_METHOD_GENERATION_INDEX_KEY, -1);
1996                                    if (array != null && index >= 0) {
1997                                        final int generation = b.getInt(
1998                                                CALL_METHOD_GENERATION_KEY, 0);
1999                                        if (DEBUG) {
2000                                            Log.i(TAG, "Received generation tracker for type:"
2001                                                    + mUri.getPath() + " in package:"
2002                                                    + cr.getPackageName() + " and user:"
2003                                                    + userHandle + " with index:" + index);
2004                                        }
2005                                        if (mGenerationTracker != null) {
2006                                            mGenerationTracker.destroy();
2007                                        }
2008                                        mGenerationTracker = new GenerationTracker(array, index,
2009                                                generation, () -> {
2010                                            synchronized (NameValueCache.this) {
2011                                                Log.e(TAG, "Error accessing generation"
2012                                                        + " tracker - removing");
2013                                                if (mGenerationTracker != null) {
2014                                                    GenerationTracker generationTracker =
2015                                                            mGenerationTracker;
2016                                                    mGenerationTracker = null;
2017                                                    generationTracker.destroy();
2018                                                    mValues.clear();
2019                                                }
2020                                            }
2021                                        });
2022                                    }
2023                                }
2024                                if (mGenerationTracker != null && currentGeneration ==
2025                                        mGenerationTracker.getCurrentGeneration()) {
2026                                    mValues.put(name, value);
2027                                }
2028                            }
2029                        } else {
2030                            if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
2031                                    + " by " + UserHandle.myUserId()
2032                                    + " so not updating cache");
2033                        }
2034                        return value;
2035                    }
2036                    // If the response Bundle is null, we fall through
2037                    // to the query interface below.
2038                } catch (RemoteException e) {
2039                    // Not supported by the remote side?  Fall through
2040                    // to query().
2041                }
2042            }
2043
2044            Cursor c = null;
2045            try {
2046                Bundle queryArgs = ContentResolver.createSqlQueryBundle(
2047                        NAME_EQ_PLACEHOLDER, new String[]{name}, null);
2048                // Same workaround as above.
2049                if (Settings.isInSystemServer() && Binder.getCallingUid() != Process.myUid()) {
2050                    final long token = Binder.clearCallingIdentity();
2051                    try {
2052                        c = cp.query(cr.getPackageName(), mUri, SELECT_VALUE_PROJECTION, queryArgs,
2053                                null);
2054                    } finally {
2055                        Binder.restoreCallingIdentity(token);
2056                    }
2057                } else {
2058                    c = cp.query(cr.getPackageName(), mUri, SELECT_VALUE_PROJECTION, queryArgs,
2059                            null);
2060                }
2061                if (c == null) {
2062                    Log.w(TAG, "Can't get key " + name + " from " + mUri);
2063                    return null;
2064                }
2065
2066                String value = c.moveToNext() ? c.getString(0) : null;
2067                synchronized (NameValueCache.this) {
2068                    if(mGenerationTracker != null &&
2069                            currentGeneration == mGenerationTracker.getCurrentGeneration()) {
2070                        mValues.put(name, value);
2071                    }
2072                }
2073                if (LOCAL_LOGV) {
2074                    Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +
2075                            name + " = " + (value == null ? "(null)" : value));
2076                }
2077                return value;
2078            } catch (RemoteException e) {
2079                Log.w(TAG, "Can't get key " + name + " from " + mUri, e);
2080                return null;  // Return null, but don't cache it.
2081            } finally {
2082                if (c != null) c.close();
2083            }
2084        }
2085
2086        public void clearGenerationTrackerForTest() {
2087            synchronized (NameValueCache.this) {
2088                if (mGenerationTracker != null) {
2089                    mGenerationTracker.destroy();
2090                }
2091                mValues.clear();
2092                mGenerationTracker = null;
2093            }
2094        }
2095    }
2096
2097    /**
2098     * Checks if the specified context can draw on top of other apps. As of API
2099     * level 23, an app cannot draw on top of other apps unless it declares the
2100     * {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission in its
2101     * manifest, <em>and</em> the user specifically grants the app this
2102     * capability. To prompt the user to grant this approval, the app must send an
2103     * intent with the action
2104     * {@link android.provider.Settings#ACTION_MANAGE_OVERLAY_PERMISSION}, which
2105     * causes the system to display a permission management screen.
2106     *
2107     * @param context App context.
2108     * @return true if the specified context can draw on top of other apps, false otherwise
2109     */
2110    public static boolean canDrawOverlays(Context context) {
2111        return Settings.isCallingPackageAllowedToDrawOverlays(context, Process.myUid(),
2112                context.getOpPackageName(), false);
2113    }
2114
2115    /**
2116     * System settings, containing miscellaneous system preferences.  This
2117     * table holds simple name/value pairs.  There are convenience
2118     * functions for accessing individual settings entries.
2119     */
2120    public static final class System extends NameValueTable {
2121        // NOTE: If you add new settings here, be sure to add them to
2122        // com.android.providers.settings.SettingsProtoDumpUtil#dumpProtoSystemSettingsLocked.
2123
2124        private static final float DEFAULT_FONT_SCALE = 1.0f;
2125
2126        /**
2127         * The content:// style URL for this table
2128         */
2129        public static final Uri CONTENT_URI =
2130            Uri.parse("content://" + AUTHORITY + "/system");
2131
2132        private static final ContentProviderHolder sProviderHolder =
2133                new ContentProviderHolder(CONTENT_URI);
2134
2135        private static final NameValueCache sNameValueCache = new NameValueCache(
2136                CONTENT_URI,
2137                CALL_METHOD_GET_SYSTEM,
2138                CALL_METHOD_PUT_SYSTEM,
2139                sProviderHolder);
2140
2141        private static final HashSet<String> MOVED_TO_SECURE;
2142        static {
2143            MOVED_TO_SECURE = new HashSet<>(30);
2144            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
2145            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
2146            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
2147            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
2148            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
2149            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
2150            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
2151            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
2152            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
2153            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
2154            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
2155            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
2156            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
2157            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
2158            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
2159            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
2160            MOVED_TO_SECURE.add(Secure.WIFI_ON);
2161            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
2162            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
2163            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
2164            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
2165            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
2166            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
2167            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
2168            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
2169            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
2170            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
2171            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
2172
2173            // At one time in System, then Global, but now back in Secure
2174            MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
2175        }
2176
2177        private static final HashSet<String> MOVED_TO_GLOBAL;
2178        private static final HashSet<String> MOVED_TO_SECURE_THEN_GLOBAL;
2179        static {
2180            MOVED_TO_GLOBAL = new HashSet<>();
2181            MOVED_TO_SECURE_THEN_GLOBAL = new HashSet<>();
2182
2183            // these were originally in system but migrated to secure in the past,
2184            // so are duplicated in the Secure.* namespace
2185            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.ADB_ENABLED);
2186            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.BLUETOOTH_ON);
2187            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DATA_ROAMING);
2188            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DEVICE_PROVISIONED);
2189            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.USB_MASS_STORAGE_ENABLED);
2190            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.HTTP_PROXY);
2191
2192            // these are moving directly from system to global
2193            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_ON);
2194            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_RADIOS);
2195            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
2196            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME);
2197            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME_ZONE);
2198            MOVED_TO_GLOBAL.add(Settings.Global.CAR_DOCK_SOUND);
2199            MOVED_TO_GLOBAL.add(Settings.Global.CAR_UNDOCK_SOUND);
2200            MOVED_TO_GLOBAL.add(Settings.Global.DESK_DOCK_SOUND);
2201            MOVED_TO_GLOBAL.add(Settings.Global.DESK_UNDOCK_SOUND);
2202            MOVED_TO_GLOBAL.add(Settings.Global.DOCK_SOUNDS_ENABLED);
2203            MOVED_TO_GLOBAL.add(Settings.Global.LOCK_SOUND);
2204            MOVED_TO_GLOBAL.add(Settings.Global.UNLOCK_SOUND);
2205            MOVED_TO_GLOBAL.add(Settings.Global.LOW_BATTERY_SOUND);
2206            MOVED_TO_GLOBAL.add(Settings.Global.POWER_SOUNDS_ENABLED);
2207            MOVED_TO_GLOBAL.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
2208            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SLEEP_POLICY);
2209            MOVED_TO_GLOBAL.add(Settings.Global.MODE_RINGER);
2210            MOVED_TO_GLOBAL.add(Settings.Global.WINDOW_ANIMATION_SCALE);
2211            MOVED_TO_GLOBAL.add(Settings.Global.TRANSITION_ANIMATION_SCALE);
2212            MOVED_TO_GLOBAL.add(Settings.Global.ANIMATOR_DURATION_SCALE);
2213            MOVED_TO_GLOBAL.add(Settings.Global.FANCY_IME_ANIMATIONS);
2214            MOVED_TO_GLOBAL.add(Settings.Global.COMPATIBILITY_MODE);
2215            MOVED_TO_GLOBAL.add(Settings.Global.EMERGENCY_TONE);
2216            MOVED_TO_GLOBAL.add(Settings.Global.CALL_AUTO_RETRY);
2217            MOVED_TO_GLOBAL.add(Settings.Global.DEBUG_APP);
2218            MOVED_TO_GLOBAL.add(Settings.Global.WAIT_FOR_DEBUGGER);
2219            MOVED_TO_GLOBAL.add(Settings.Global.ALWAYS_FINISH_ACTIVITIES);
2220            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_CONTENT_URL);
2221            MOVED_TO_GLOBAL.add(Settings.Global.TZINFO_UPDATE_METADATA_URL);
2222            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_CONTENT_URL);
2223            MOVED_TO_GLOBAL.add(Settings.Global.SELINUX_UPDATE_METADATA_URL);
2224            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_CONTENT_URL);
2225            MOVED_TO_GLOBAL.add(Settings.Global.SMS_SHORT_CODES_UPDATE_METADATA_URL);
2226            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_CONTENT_URL);
2227            MOVED_TO_GLOBAL.add(Settings.Global.CERT_PIN_UPDATE_METADATA_URL);
2228        }
2229
2230        /** @hide */
2231        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
2232            outKeySet.addAll(MOVED_TO_GLOBAL);
2233            outKeySet.addAll(MOVED_TO_SECURE_THEN_GLOBAL);
2234        }
2235
2236        /** @hide */
2237        public static void getMovedToSecureSettings(Set<String> outKeySet) {
2238            outKeySet.addAll(MOVED_TO_SECURE);
2239        }
2240
2241        /** @hide */
2242        public static void getNonLegacyMovedKeys(HashSet<String> outKeySet) {
2243            outKeySet.addAll(MOVED_TO_GLOBAL);
2244        }
2245
2246        /** @hide */
2247        public static void clearProviderForTest() {
2248            sProviderHolder.clearProviderForTest();
2249            sNameValueCache.clearGenerationTrackerForTest();
2250        }
2251
2252        /**
2253         * Look up a name in the database.
2254         * @param resolver to access the database with
2255         * @param name to look up in the table
2256         * @return the corresponding value, or null if not present
2257         */
2258        public static String getString(ContentResolver resolver, String name) {
2259            return getStringForUser(resolver, name, resolver.getUserId());
2260        }
2261
2262        /** @hide */
2263        public static String getStringForUser(ContentResolver resolver, String name,
2264                int userHandle) {
2265            if (MOVED_TO_SECURE.contains(name)) {
2266                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2267                        + " to android.provider.Settings.Secure, returning read-only value.");
2268                return Secure.getStringForUser(resolver, name, userHandle);
2269            }
2270            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2271                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2272                        + " to android.provider.Settings.Global, returning read-only value.");
2273                return Global.getStringForUser(resolver, name, userHandle);
2274            }
2275            return sNameValueCache.getStringForUser(resolver, name, userHandle);
2276        }
2277
2278        /**
2279         * Store a name/value pair into the database.
2280         * @param resolver to access the database with
2281         * @param name to store
2282         * @param value to associate with the name
2283         * @return true if the value was set, false on database errors
2284         */
2285        public static boolean putString(ContentResolver resolver, String name, String value) {
2286            return putStringForUser(resolver, name, value, resolver.getUserId());
2287        }
2288
2289        /** @hide */
2290        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
2291                int userHandle) {
2292            if (MOVED_TO_SECURE.contains(name)) {
2293                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2294                        + " to android.provider.Settings.Secure, value is unchanged.");
2295                return false;
2296            }
2297            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2298                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2299                        + " to android.provider.Settings.Global, value is unchanged.");
2300                return false;
2301            }
2302            return sNameValueCache.putStringForUser(resolver, name, value, null, false, userHandle);
2303        }
2304
2305        /**
2306         * Construct the content URI for a particular name/value pair,
2307         * useful for monitoring changes with a ContentObserver.
2308         * @param name to look up in the table
2309         * @return the corresponding content URI, or null if not present
2310         */
2311        public static Uri getUriFor(String name) {
2312            if (MOVED_TO_SECURE.contains(name)) {
2313                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2314                    + " to android.provider.Settings.Secure, returning Secure URI.");
2315                return Secure.getUriFor(Secure.CONTENT_URI, name);
2316            }
2317            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
2318                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2319                        + " to android.provider.Settings.Global, returning read-only global URI.");
2320                return Global.getUriFor(Global.CONTENT_URI, name);
2321            }
2322            return getUriFor(CONTENT_URI, name);
2323        }
2324
2325        /**
2326         * Convenience function for retrieving a single system settings value
2327         * as an integer.  Note that internally setting values are always
2328         * stored as strings; this function converts the string to an integer
2329         * for you.  The default value will be returned if the setting is
2330         * not defined or not an integer.
2331         *
2332         * @param cr The ContentResolver to access.
2333         * @param name The name of the setting to retrieve.
2334         * @param def Value to return if the setting is not defined.
2335         *
2336         * @return The setting's current value, or 'def' if it is not defined
2337         * or not a valid integer.
2338         */
2339        public static int getInt(ContentResolver cr, String name, int def) {
2340            return getIntForUser(cr, name, def, cr.getUserId());
2341        }
2342
2343        /** @hide */
2344        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
2345            String v = getStringForUser(cr, name, userHandle);
2346            try {
2347                return v != null ? Integer.parseInt(v) : def;
2348            } catch (NumberFormatException e) {
2349                return def;
2350            }
2351        }
2352
2353        /**
2354         * Convenience function for retrieving a single system settings value
2355         * as an integer.  Note that internally setting values are always
2356         * stored as strings; this function converts the string to an integer
2357         * for you.
2358         * <p>
2359         * This version does not take a default value.  If the setting has not
2360         * been set, or the string value is not a number,
2361         * it throws {@link SettingNotFoundException}.
2362         *
2363         * @param cr The ContentResolver to access.
2364         * @param name The name of the setting to retrieve.
2365         *
2366         * @throws SettingNotFoundException Thrown if a setting by the given
2367         * name can't be found or the setting value is not an integer.
2368         *
2369         * @return The setting's current value.
2370         */
2371        public static int getInt(ContentResolver cr, String name)
2372                throws SettingNotFoundException {
2373            return getIntForUser(cr, name, cr.getUserId());
2374        }
2375
2376        /** @hide */
2377        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
2378                throws SettingNotFoundException {
2379            String v = getStringForUser(cr, name, userHandle);
2380            try {
2381                return Integer.parseInt(v);
2382            } catch (NumberFormatException e) {
2383                throw new SettingNotFoundException(name);
2384            }
2385        }
2386
2387        /**
2388         * Convenience function for updating a single settings value as an
2389         * integer. This will either create a new entry in the table if the
2390         * given name does not exist, or modify the value of the existing row
2391         * with that name.  Note that internally setting values are always
2392         * stored as strings, so this function converts the given value to a
2393         * string before storing it.
2394         *
2395         * @param cr The ContentResolver to access.
2396         * @param name The name of the setting to modify.
2397         * @param value The new value for the setting.
2398         * @return true if the value was set, false on database errors
2399         */
2400        public static boolean putInt(ContentResolver cr, String name, int value) {
2401            return putIntForUser(cr, name, value, cr.getUserId());
2402        }
2403
2404        /** @hide */
2405        public static boolean putIntForUser(ContentResolver cr, String name, int value,
2406                int userHandle) {
2407            return putStringForUser(cr, name, Integer.toString(value), userHandle);
2408        }
2409
2410        /**
2411         * Convenience function for retrieving a single system settings value
2412         * as a {@code long}.  Note that internally setting values are always
2413         * stored as strings; this function converts the string to a {@code long}
2414         * for you.  The default value will be returned if the setting is
2415         * not defined or not a {@code long}.
2416         *
2417         * @param cr The ContentResolver to access.
2418         * @param name The name of the setting to retrieve.
2419         * @param def Value to return if the setting is not defined.
2420         *
2421         * @return The setting's current value, or 'def' if it is not defined
2422         * or not a valid {@code long}.
2423         */
2424        public static long getLong(ContentResolver cr, String name, long def) {
2425            return getLongForUser(cr, name, def, cr.getUserId());
2426        }
2427
2428        /** @hide */
2429        public static long getLongForUser(ContentResolver cr, String name, long def,
2430                int userHandle) {
2431            String valString = getStringForUser(cr, name, userHandle);
2432            long value;
2433            try {
2434                value = valString != null ? Long.parseLong(valString) : def;
2435            } catch (NumberFormatException e) {
2436                value = def;
2437            }
2438            return value;
2439        }
2440
2441        /**
2442         * Convenience function for retrieving a single system settings value
2443         * as a {@code long}.  Note that internally setting values are always
2444         * stored as strings; this function converts the string to a {@code long}
2445         * for you.
2446         * <p>
2447         * This version does not take a default value.  If the setting has not
2448         * been set, or the string value is not a number,
2449         * it throws {@link SettingNotFoundException}.
2450         *
2451         * @param cr The ContentResolver to access.
2452         * @param name The name of the setting to retrieve.
2453         *
2454         * @return The setting's current value.
2455         * @throws SettingNotFoundException Thrown if a setting by the given
2456         * name can't be found or the setting value is not an integer.
2457         */
2458        public static long getLong(ContentResolver cr, String name)
2459                throws SettingNotFoundException {
2460            return getLongForUser(cr, name, cr.getUserId());
2461        }
2462
2463        /** @hide */
2464        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
2465                throws SettingNotFoundException {
2466            String valString = getStringForUser(cr, name, userHandle);
2467            try {
2468                return Long.parseLong(valString);
2469            } catch (NumberFormatException e) {
2470                throw new SettingNotFoundException(name);
2471            }
2472        }
2473
2474        /**
2475         * Convenience function for updating a single settings value as a long
2476         * integer. This will either create a new entry in the table if the
2477         * given name does not exist, or modify the value of the existing row
2478         * with that name.  Note that internally setting values are always
2479         * stored as strings, so this function converts the given value to a
2480         * string before storing it.
2481         *
2482         * @param cr The ContentResolver to access.
2483         * @param name The name of the setting to modify.
2484         * @param value The new value for the setting.
2485         * @return true if the value was set, false on database errors
2486         */
2487        public static boolean putLong(ContentResolver cr, String name, long value) {
2488            return putLongForUser(cr, name, value, cr.getUserId());
2489        }
2490
2491        /** @hide */
2492        public static boolean putLongForUser(ContentResolver cr, String name, long value,
2493                int userHandle) {
2494            return putStringForUser(cr, name, Long.toString(value), userHandle);
2495        }
2496
2497        /**
2498         * Convenience function for retrieving a single system settings value
2499         * as a floating point number.  Note that internally setting values are
2500         * always stored as strings; this function converts the string to an
2501         * float for you. The default value will be returned if the setting
2502         * is not defined or not a valid float.
2503         *
2504         * @param cr The ContentResolver to access.
2505         * @param name The name of the setting to retrieve.
2506         * @param def Value to return if the setting is not defined.
2507         *
2508         * @return The setting's current value, or 'def' if it is not defined
2509         * or not a valid float.
2510         */
2511        public static float getFloat(ContentResolver cr, String name, float def) {
2512            return getFloatForUser(cr, name, def, cr.getUserId());
2513        }
2514
2515        /** @hide */
2516        public static float getFloatForUser(ContentResolver cr, String name, float def,
2517                int userHandle) {
2518            String v = getStringForUser(cr, name, userHandle);
2519            try {
2520                return v != null ? Float.parseFloat(v) : def;
2521            } catch (NumberFormatException e) {
2522                return def;
2523            }
2524        }
2525
2526        /**
2527         * Convenience function for retrieving a single system settings value
2528         * as a float.  Note that internally setting values are always
2529         * stored as strings; this function converts the string to a float
2530         * for you.
2531         * <p>
2532         * This version does not take a default value.  If the setting has not
2533         * been set, or the string value is not a number,
2534         * it throws {@link SettingNotFoundException}.
2535         *
2536         * @param cr The ContentResolver to access.
2537         * @param name The name of the setting to retrieve.
2538         *
2539         * @throws SettingNotFoundException Thrown if a setting by the given
2540         * name can't be found or the setting value is not a float.
2541         *
2542         * @return The setting's current value.
2543         */
2544        public static float getFloat(ContentResolver cr, String name)
2545                throws SettingNotFoundException {
2546            return getFloatForUser(cr, name, cr.getUserId());
2547        }
2548
2549        /** @hide */
2550        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
2551                throws SettingNotFoundException {
2552            String v = getStringForUser(cr, name, userHandle);
2553            if (v == null) {
2554                throw new SettingNotFoundException(name);
2555            }
2556            try {
2557                return Float.parseFloat(v);
2558            } catch (NumberFormatException e) {
2559                throw new SettingNotFoundException(name);
2560            }
2561        }
2562
2563        /**
2564         * Convenience function for updating a single settings value as a
2565         * floating point number. This will either create a new entry in the
2566         * table if the given name does not exist, or modify the value of the
2567         * existing row with that name.  Note that internally setting values
2568         * are always stored as strings, so this function converts the given
2569         * value to a string before storing it.
2570         *
2571         * @param cr The ContentResolver to access.
2572         * @param name The name of the setting to modify.
2573         * @param value The new value for the setting.
2574         * @return true if the value was set, false on database errors
2575         */
2576        public static boolean putFloat(ContentResolver cr, String name, float value) {
2577            return putFloatForUser(cr, name, value, cr.getUserId());
2578        }
2579
2580        /** @hide */
2581        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
2582                int userHandle) {
2583            return putStringForUser(cr, name, Float.toString(value), userHandle);
2584        }
2585
2586        /**
2587         * Convenience function to read all of the current
2588         * configuration-related settings into a
2589         * {@link Configuration} object.
2590         *
2591         * @param cr The ContentResolver to access.
2592         * @param outConfig Where to place the configuration settings.
2593         */
2594        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
2595            adjustConfigurationForUser(cr, outConfig, cr.getUserId(),
2596                    false /* updateSettingsIfEmpty */);
2597        }
2598
2599        /** @hide */
2600        public static void adjustConfigurationForUser(ContentResolver cr, Configuration outConfig,
2601                int userHandle, boolean updateSettingsIfEmpty) {
2602            outConfig.fontScale = Settings.System.getFloatForUser(
2603                    cr, FONT_SCALE, DEFAULT_FONT_SCALE, userHandle);
2604            if (outConfig.fontScale < 0) {
2605                outConfig.fontScale = DEFAULT_FONT_SCALE;
2606            }
2607
2608            final String localeValue =
2609                    Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle);
2610            if (localeValue != null) {
2611                outConfig.setLocales(LocaleList.forLanguageTags(localeValue));
2612            } else {
2613                // Do not update configuration with emtpy settings since we need to take over the
2614                // locale list of previous user if the settings value is empty. This happens when a
2615                // new user is created.
2616
2617                if (updateSettingsIfEmpty) {
2618                    // Make current configuration persistent. This is necessary the first time a
2619                    // user log in. At the first login, the configuration settings are empty, so we
2620                    // need to store the adjusted configuration as the initial settings.
2621                    Settings.System.putStringForUser(
2622                            cr, SYSTEM_LOCALES, outConfig.getLocales().toLanguageTags(),
2623                            userHandle);
2624                }
2625            }
2626        }
2627
2628        /**
2629         * @hide Erase the fields in the Configuration that should be applied
2630         * by the settings.
2631         */
2632        public static void clearConfiguration(Configuration inoutConfig) {
2633            inoutConfig.fontScale = 0;
2634            if (!inoutConfig.userSetLocale && !inoutConfig.getLocales().isEmpty()) {
2635                inoutConfig.clearLocales();
2636            }
2637        }
2638
2639        /**
2640         * Convenience function to write a batch of configuration-related
2641         * settings from a {@link Configuration} object.
2642         *
2643         * @param cr The ContentResolver to access.
2644         * @param config The settings to write.
2645         * @return true if the values were set, false on database errors
2646         */
2647        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
2648            return putConfigurationForUser(cr, config, cr.getUserId());
2649        }
2650
2651        /** @hide */
2652        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
2653                int userHandle) {
2654            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle) &&
2655                    Settings.System.putStringForUser(
2656                            cr, SYSTEM_LOCALES, config.getLocales().toLanguageTags(), userHandle);
2657        }
2658
2659        /** @hide */
2660        public static boolean hasInterestingConfigurationChanges(int changes) {
2661            return (changes & ActivityInfo.CONFIG_FONT_SCALE) != 0 ||
2662                    (changes & ActivityInfo.CONFIG_LOCALE) != 0;
2663        }
2664
2665        /** @deprecated - Do not use */
2666        @Deprecated
2667        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
2668            return getShowGTalkServiceStatusForUser(cr, cr.getUserId());
2669        }
2670
2671        /**
2672         * @hide
2673         * @deprecated - Do not use
2674         */
2675        @Deprecated
2676        public static boolean getShowGTalkServiceStatusForUser(ContentResolver cr,
2677                int userHandle) {
2678            return getIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, 0, userHandle) != 0;
2679        }
2680
2681        /** @deprecated - Do not use */
2682        @Deprecated
2683        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
2684            setShowGTalkServiceStatusForUser(cr, flag, cr.getUserId());
2685        }
2686
2687        /**
2688         * @hide
2689         * @deprecated - Do not use
2690         */
2691        @Deprecated
2692        public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean flag,
2693                int userHandle) {
2694            putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
2695        }
2696
2697        /**
2698         * @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
2699         */
2700        @Deprecated
2701        public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN;
2702
2703        private static final Validator STAY_ON_WHILE_PLUGGED_IN_VALIDATOR = new Validator() {
2704            @Override
2705            public boolean validate(String value) {
2706                try {
2707                    int val = Integer.parseInt(value);
2708                    return (val == 0)
2709                            || (val == BatteryManager.BATTERY_PLUGGED_AC)
2710                            || (val == BatteryManager.BATTERY_PLUGGED_USB)
2711                            || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS)
2712                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
2713                                    | BatteryManager.BATTERY_PLUGGED_USB))
2714                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
2715                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
2716                            || (val == (BatteryManager.BATTERY_PLUGGED_USB
2717                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
2718                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
2719                                    | BatteryManager.BATTERY_PLUGGED_USB
2720                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS));
2721                } catch (NumberFormatException e) {
2722                    return false;
2723                }
2724            }
2725        };
2726
2727        /**
2728         * What happens when the user presses the end call button if they're not
2729         * on a call.<br/>
2730         * <b>Values:</b><br/>
2731         * 0 - The end button does nothing.<br/>
2732         * 1 - The end button goes to the home screen.<br/>
2733         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
2734         * 3 - The end button goes to the home screen.  If the user is already on the
2735         * home screen, it puts the device to sleep.
2736         */
2737        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
2738
2739        private static final Validator END_BUTTON_BEHAVIOR_VALIDATOR =
2740                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
2741
2742        /**
2743         * END_BUTTON_BEHAVIOR value for "go home".
2744         * @hide
2745         */
2746        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
2747
2748        /**
2749         * END_BUTTON_BEHAVIOR value for "go to sleep".
2750         * @hide
2751         */
2752        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
2753
2754        /**
2755         * END_BUTTON_BEHAVIOR default value.
2756         * @hide
2757         */
2758        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
2759
2760        /**
2761         * Is advanced settings mode turned on. 0 == no, 1 == yes
2762         * @hide
2763         */
2764        public static final String ADVANCED_SETTINGS = "advanced_settings";
2765
2766        private static final Validator ADVANCED_SETTINGS_VALIDATOR = BOOLEAN_VALIDATOR;
2767
2768        /**
2769         * ADVANCED_SETTINGS default value.
2770         * @hide
2771         */
2772        public static final int ADVANCED_SETTINGS_DEFAULT = 0;
2773
2774        /**
2775         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
2776         */
2777        @Deprecated
2778        public static final String AIRPLANE_MODE_ON = Global.AIRPLANE_MODE_ON;
2779
2780        /**
2781         * @deprecated Use {@link android.provider.Settings.Global#RADIO_BLUETOOTH} instead
2782         */
2783        @Deprecated
2784        public static final String RADIO_BLUETOOTH = Global.RADIO_BLUETOOTH;
2785
2786        /**
2787         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIFI} instead
2788         */
2789        @Deprecated
2790        public static final String RADIO_WIFI = Global.RADIO_WIFI;
2791
2792        /**
2793         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIMAX} instead
2794         * {@hide}
2795         */
2796        @Deprecated
2797        public static final String RADIO_WIMAX = Global.RADIO_WIMAX;
2798
2799        /**
2800         * @deprecated Use {@link android.provider.Settings.Global#RADIO_CELL} instead
2801         */
2802        @Deprecated
2803        public static final String RADIO_CELL = Global.RADIO_CELL;
2804
2805        /**
2806         * @deprecated Use {@link android.provider.Settings.Global#RADIO_NFC} instead
2807         */
2808        @Deprecated
2809        public static final String RADIO_NFC = Global.RADIO_NFC;
2810
2811        /**
2812         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_RADIOS} instead
2813         */
2814        @Deprecated
2815        public static final String AIRPLANE_MODE_RADIOS = Global.AIRPLANE_MODE_RADIOS;
2816
2817        /**
2818         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_TOGGLEABLE_RADIOS} instead
2819         *
2820         * {@hide}
2821         */
2822        @Deprecated
2823        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS =
2824                Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS;
2825
2826        /**
2827         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY} instead
2828         */
2829        @Deprecated
2830        public static final String WIFI_SLEEP_POLICY = Global.WIFI_SLEEP_POLICY;
2831
2832        /**
2833         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_DEFAULT} instead
2834         */
2835        @Deprecated
2836        public static final int WIFI_SLEEP_POLICY_DEFAULT = Global.WIFI_SLEEP_POLICY_DEFAULT;
2837
2838        /**
2839         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED} instead
2840         */
2841        @Deprecated
2842        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED =
2843                Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
2844
2845        /**
2846         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER} instead
2847         */
2848        @Deprecated
2849        public static final int WIFI_SLEEP_POLICY_NEVER = Global.WIFI_SLEEP_POLICY_NEVER;
2850
2851        /**
2852         * @deprecated Use {@link android.provider.Settings.Global#MODE_RINGER} instead
2853         */
2854        @Deprecated
2855        public static final String MODE_RINGER = Global.MODE_RINGER;
2856
2857        /**
2858         * Whether to use static IP and other static network attributes.
2859         * <p>
2860         * Set to 1 for true and 0 for false.
2861         *
2862         * @deprecated Use {@link WifiManager} instead
2863         */
2864        @Deprecated
2865        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
2866
2867        private static final Validator WIFI_USE_STATIC_IP_VALIDATOR = BOOLEAN_VALIDATOR;
2868
2869        /**
2870         * The static IP address.
2871         * <p>
2872         * Example: "192.168.1.51"
2873         *
2874         * @deprecated Use {@link WifiManager} instead
2875         */
2876        @Deprecated
2877        public static final String WIFI_STATIC_IP = "wifi_static_ip";
2878
2879        private static final Validator WIFI_STATIC_IP_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR;
2880
2881        /**
2882         * If using static IP, the gateway's IP address.
2883         * <p>
2884         * Example: "192.168.1.1"
2885         *
2886         * @deprecated Use {@link WifiManager} instead
2887         */
2888        @Deprecated
2889        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
2890
2891        private static final Validator WIFI_STATIC_GATEWAY_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR;
2892
2893        /**
2894         * If using static IP, the net mask.
2895         * <p>
2896         * Example: "255.255.255.0"
2897         *
2898         * @deprecated Use {@link WifiManager} instead
2899         */
2900        @Deprecated
2901        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
2902
2903        private static final Validator WIFI_STATIC_NETMASK_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR;
2904
2905        /**
2906         * If using static IP, the primary DNS's IP address.
2907         * <p>
2908         * Example: "192.168.1.1"
2909         *
2910         * @deprecated Use {@link WifiManager} instead
2911         */
2912        @Deprecated
2913        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
2914
2915        private static final Validator WIFI_STATIC_DNS1_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR;
2916
2917        /**
2918         * If using static IP, the secondary DNS's IP address.
2919         * <p>
2920         * Example: "192.168.1.2"
2921         *
2922         * @deprecated Use {@link WifiManager} instead
2923         */
2924        @Deprecated
2925        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
2926
2927        private static final Validator WIFI_STATIC_DNS2_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR;
2928
2929        /**
2930         * Determines whether remote devices may discover and/or connect to
2931         * this device.
2932         * <P>Type: INT</P>
2933         * 2 -- discoverable and connectable
2934         * 1 -- connectable but not discoverable
2935         * 0 -- neither connectable nor discoverable
2936         */
2937        public static final String BLUETOOTH_DISCOVERABILITY =
2938            "bluetooth_discoverability";
2939
2940        private static final Validator BLUETOOTH_DISCOVERABILITY_VALIDATOR =
2941                new SettingsValidators.InclusiveIntegerRangeValidator(0, 2);
2942
2943        /**
2944         * Bluetooth discoverability timeout.  If this value is nonzero, then
2945         * Bluetooth becomes discoverable for a certain number of seconds,
2946         * after which is becomes simply connectable.  The value is in seconds.
2947         */
2948        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
2949            "bluetooth_discoverability_timeout";
2950
2951        private static final Validator BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR =
2952                NON_NEGATIVE_INTEGER_VALIDATOR;
2953
2954        /**
2955         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
2956         * instead
2957         */
2958        @Deprecated
2959        public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
2960
2961        /**
2962         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
2963         * instead
2964         */
2965        @Deprecated
2966        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
2967
2968        /**
2969         * @deprecated Use
2970         * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
2971         * instead
2972         */
2973        @Deprecated
2974        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
2975            "lock_pattern_tactile_feedback_enabled";
2976
2977        /**
2978         * A formatted string of the next alarm that is set, or the empty string
2979         * if there is no alarm set.
2980         *
2981         * @deprecated Use {@link android.app.AlarmManager#getNextAlarmClock()}.
2982         */
2983        @Deprecated
2984        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
2985
2986        private static final Validator NEXT_ALARM_FORMATTED_VALIDATOR = new Validator() {
2987            private static final int MAX_LENGTH = 1000;
2988
2989            @Override
2990            public boolean validate(String value) {
2991                // TODO: No idea what the correct format is.
2992                return value == null || value.length() < MAX_LENGTH;
2993            }
2994        };
2995
2996        /**
2997         * Scaling factor for fonts, float.
2998         */
2999        public static final String FONT_SCALE = "font_scale";
3000
3001        private static final Validator FONT_SCALE_VALIDATOR = new Validator() {
3002            @Override
3003            public boolean validate(String value) {
3004                try {
3005                    return Float.parseFloat(value) >= 0;
3006                } catch (NumberFormatException e) {
3007                    return false;
3008                }
3009            }
3010        };
3011
3012        /**
3013         * The serialized system locale value.
3014         *
3015         * Do not use this value directory.
3016         * To get system locale, use {@link LocaleList#getDefault} instead.
3017         * To update system locale, use {@link com.android.internal.app.LocalePicker#updateLocales}
3018         * instead.
3019         * @hide
3020         */
3021        public static final String SYSTEM_LOCALES = "system_locales";
3022
3023
3024        /**
3025         * Name of an application package to be debugged.
3026         *
3027         * @deprecated Use {@link Global#DEBUG_APP} instead
3028         */
3029        @Deprecated
3030        public static final String DEBUG_APP = Global.DEBUG_APP;
3031
3032        /**
3033         * If 1, when launching DEBUG_APP it will wait for the debugger before
3034         * starting user code.  If 0, it will run normally.
3035         *
3036         * @deprecated Use {@link Global#WAIT_FOR_DEBUGGER} instead
3037         */
3038        @Deprecated
3039        public static final String WAIT_FOR_DEBUGGER = Global.WAIT_FOR_DEBUGGER;
3040
3041        /**
3042         * Whether or not to dim the screen. 0=no  1=yes
3043         * @deprecated This setting is no longer used.
3044         */
3045        @Deprecated
3046        public static final String DIM_SCREEN = "dim_screen";
3047
3048        private static final Validator DIM_SCREEN_VALIDATOR = BOOLEAN_VALIDATOR;
3049
3050        /**
3051         * The display color mode.
3052         * @hide
3053         */
3054        public static final String DISPLAY_COLOR_MODE = "display_color_mode";
3055
3056        /**
3057         * The amount of time in milliseconds before the device goes to sleep or begins
3058         * to dream after a period of inactivity.  This value is also known as the
3059         * user activity timeout period since the screen isn't necessarily turned off
3060         * when it expires.
3061         *
3062         * <p>
3063         * This value is bounded by maximum timeout set by
3064         * {@link android.app.admin.DevicePolicyManager#setMaximumTimeToLock(ComponentName, long)}.
3065         */
3066        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
3067
3068        private static final Validator SCREEN_OFF_TIMEOUT_VALIDATOR =
3069                NON_NEGATIVE_INTEGER_VALIDATOR;
3070
3071        /**
3072         * The screen backlight brightness between 0 and 255.
3073         */
3074        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
3075
3076        private static final Validator SCREEN_BRIGHTNESS_VALIDATOR =
3077                new SettingsValidators.InclusiveIntegerRangeValidator(0, 255);
3078
3079        /**
3080         * The screen backlight brightness between 0 and 255.
3081         * @hide
3082         */
3083        public static final String SCREEN_BRIGHTNESS_FOR_VR = "screen_brightness_for_vr";
3084
3085        private static final Validator SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR =
3086                new SettingsValidators.InclusiveIntegerRangeValidator(0, 255);
3087
3088        /**
3089         * Control whether to enable automatic brightness mode.
3090         */
3091        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
3092
3093        private static final Validator SCREEN_BRIGHTNESS_MODE_VALIDATOR = BOOLEAN_VALIDATOR;
3094
3095        /**
3096         * Adjustment to auto-brightness to make it generally more (>0.0 <1.0)
3097         * or less (<0.0 >-1.0) bright.
3098         * @hide
3099         */
3100        public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj";
3101
3102        private static final Validator SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR =
3103                new SettingsValidators.InclusiveFloatRangeValidator(-1, 1);
3104
3105        /**
3106         * SCREEN_BRIGHTNESS_MODE value for manual mode.
3107         */
3108        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
3109
3110        /**
3111         * SCREEN_BRIGHTNESS_MODE value for automatic mode.
3112         */
3113        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
3114
3115        /**
3116         * Control whether the process CPU usage meter should be shown.
3117         *
3118         * @deprecated This functionality is no longer available as of
3119         * {@link android.os.Build.VERSION_CODES#N_MR1}.
3120         */
3121        @Deprecated
3122        public static final String SHOW_PROCESSES = Global.SHOW_PROCESSES;
3123
3124        /**
3125         * If 1, the activity manager will aggressively finish activities and
3126         * processes as soon as they are no longer needed.  If 0, the normal
3127         * extended lifetime is used.
3128         *
3129         * @deprecated Use {@link Global#ALWAYS_FINISH_ACTIVITIES} instead
3130         */
3131        @Deprecated
3132        public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
3133
3134        /**
3135         * Determines which streams are affected by ringer and zen mode changes. The
3136         * stream type's bit should be set to 1 if it should be muted when going
3137         * into an inaudible ringer mode.
3138         */
3139        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
3140
3141        private static final Validator MODE_RINGER_STREAMS_AFFECTED_VALIDATOR =
3142                NON_NEGATIVE_INTEGER_VALIDATOR;
3143
3144        /**
3145          * Determines which streams are affected by mute. The
3146          * stream type's bit should be set to 1 if it should be muted when a mute request
3147          * is received.
3148          */
3149        public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
3150
3151        private static final Validator MUTE_STREAMS_AFFECTED_VALIDATOR =
3152                NON_NEGATIVE_INTEGER_VALIDATOR;
3153
3154        /**
3155         * Whether vibrate is on for different events. This is used internally,
3156         * changing this value will not change the vibrate. See AudioManager.
3157         */
3158        public static final String VIBRATE_ON = "vibrate_on";
3159
3160        private static final Validator VIBRATE_ON_VALIDATOR = BOOLEAN_VALIDATOR;
3161
3162        /**
3163         * If 1, redirects the system vibrator to all currently attached input devices
3164         * that support vibration.  If there are no such input devices, then the system
3165         * vibrator is used instead.
3166         * If 0, does not register the system vibrator.
3167         *
3168         * This setting is mainly intended to provide a compatibility mechanism for
3169         * applications that only know about the system vibrator and do not use the
3170         * input device vibrator API.
3171         *
3172         * @hide
3173         */
3174        public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices";
3175
3176        private static final Validator VIBRATE_INPUT_DEVICES_VALIDATOR = BOOLEAN_VALIDATOR;
3177
3178        /**
3179         * The intensity of notification vibrations, if configurable.
3180         *
3181         * Not all devices are capable of changing their vibration intensity; on these devices
3182         * there will likely be no difference between the various vibration intensities except for
3183         * intensity 0 (off) and the rest.
3184         *
3185         * <b>Values:</b><br/>
3186         * 0 - Vibration is disabled<br/>
3187         * 1 - Weak vibrations<br/>
3188         * 2 - Medium vibrations<br/>
3189         * 3 - Strong vibrations
3190         * @hide
3191         */
3192        public static final String NOTIFICATION_VIBRATION_INTENSITY =
3193                "notification_vibration_intensity";
3194
3195        /**
3196         * The intensity of haptic feedback vibrations, if configurable.
3197         *
3198         * Not all devices are capable of changing their feedback intensity; on these devices
3199         * there will likely be no difference between the various vibration intensities except for
3200         * intensity 0 (off) and the rest.
3201         *
3202         * <b>Values:</b><br/>
3203         * 0 - Vibration is disabled<br/>
3204         * 1 - Weak vibrations<br/>
3205         * 2 - Medium vibrations<br/>
3206         * 3 - Strong vibrations
3207         * @hide
3208         */
3209        public static final String HAPTIC_FEEDBACK_INTENSITY =
3210                "haptic_feedback_intensity";
3211
3212        private static final Validator VIBRATION_INTENSITY_VALIDATOR =
3213                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
3214
3215        /**
3216         * Ringer volume. This is used internally, changing this value will not
3217         * change the volume. See AudioManager.
3218         *
3219         * @removed Not used by anything since API 2.
3220         */
3221        public static final String VOLUME_RING = "volume_ring";
3222
3223        /**
3224         * System/notifications volume. This is used internally, changing this
3225         * value will not change the volume. See AudioManager.
3226         *
3227         * @removed Not used by anything since API 2.
3228         */
3229        public static final String VOLUME_SYSTEM = "volume_system";
3230
3231        /**
3232         * Voice call volume. This is used internally, changing this value will
3233         * not change the volume. See AudioManager.
3234         *
3235         * @removed Not used by anything since API 2.
3236         */
3237        public static final String VOLUME_VOICE = "volume_voice";
3238
3239        /**
3240         * Music/media/gaming volume. This is used internally, changing this
3241         * value will not change the volume. See AudioManager.
3242         *
3243         * @removed Not used by anything since API 2.
3244         */
3245        public static final String VOLUME_MUSIC = "volume_music";
3246
3247        /**
3248         * Alarm volume. This is used internally, changing this
3249         * value will not change the volume. See AudioManager.
3250         *
3251         * @removed Not used by anything since API 2.
3252         */
3253        public static final String VOLUME_ALARM = "volume_alarm";
3254
3255        /**
3256         * Notification volume. This is used internally, changing this
3257         * value will not change the volume. See AudioManager.
3258         *
3259         * @removed Not used by anything since API 2.
3260         */
3261        public static final String VOLUME_NOTIFICATION = "volume_notification";
3262
3263        /**
3264         * Bluetooth Headset volume. This is used internally, changing this value will
3265         * not change the volume. See AudioManager.
3266         *
3267         * @removed Not used by anything since API 2.
3268         */
3269        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";
3270
3271        /**
3272         * @hide
3273         * Acessibility volume. This is used internally, changing this
3274         * value will not change the volume.
3275         */
3276        public static final String VOLUME_ACCESSIBILITY = "volume_a11y";
3277
3278        /**
3279         * Master volume (float in the range 0.0f to 1.0f).
3280         *
3281         * @hide
3282         */
3283        public static final String VOLUME_MASTER = "volume_master";
3284
3285        /**
3286         * Master mono (int 1 = mono, 0 = normal).
3287         *
3288         * @hide
3289         */
3290        public static final String MASTER_MONO = "master_mono";
3291
3292        private static final Validator MASTER_MONO_VALIDATOR = BOOLEAN_VALIDATOR;
3293
3294        /**
3295         * Whether the notifications should use the ring volume (value of 1) or
3296         * a separate notification volume (value of 0). In most cases, users
3297         * will have this enabled so the notification and ringer volumes will be
3298         * the same. However, power users can disable this and use the separate
3299         * notification volume control.
3300         * <p>
3301         * Note: This is a one-off setting that will be removed in the future
3302         * when there is profile support. For this reason, it is kept hidden
3303         * from the public APIs.
3304         *
3305         * @hide
3306         * @deprecated
3307         */
3308        @Deprecated
3309        public static final String NOTIFICATIONS_USE_RING_VOLUME =
3310            "notifications_use_ring_volume";
3311
3312        private static final Validator NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR = BOOLEAN_VALIDATOR;
3313
3314        /**
3315         * Whether silent mode should allow vibration feedback. This is used
3316         * internally in AudioService and the Sound settings activity to
3317         * coordinate decoupling of vibrate and silent modes. This setting
3318         * will likely be removed in a future release with support for
3319         * audio/vibe feedback profiles.
3320         *
3321         * Not used anymore. On devices with vibrator, the user explicitly selects
3322         * silent or vibrate mode.
3323         * Kept for use by legacy database upgrade code in DatabaseHelper.
3324         * @hide
3325         */
3326        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
3327
3328        private static final Validator VIBRATE_IN_SILENT_VALIDATOR = BOOLEAN_VALIDATOR;
3329
3330        /**
3331         * The mapping of stream type (integer) to its setting.
3332         *
3333         * @removed  Not used by anything since API 2.
3334         */
3335        public static final String[] VOLUME_SETTINGS = {
3336            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
3337            VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO
3338        };
3339
3340        /**
3341         * @hide
3342         * The mapping of stream type (integer) to its setting.
3343         * Unlike the VOLUME_SETTINGS array, this one contains as many entries as
3344         * AudioSystem.NUM_STREAM_TYPES, and has empty strings for stream types whose volumes
3345         * are never persisted.
3346         */
3347        public static final String[] VOLUME_SETTINGS_INT = {
3348                VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
3349                VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO,
3350                "" /*STREAM_SYSTEM_ENFORCED, no setting for this stream*/,
3351                "" /*STREAM_DTMF, no setting for this stream*/,
3352                "" /*STREAM_TTS, no setting for this stream*/,
3353                VOLUME_ACCESSIBILITY
3354            };
3355
3356        /**
3357         * Appended to various volume related settings to record the previous
3358         * values before they the settings were affected by a silent/vibrate
3359         * ringer mode change.
3360         *
3361         * @removed  Not used by anything since API 2.
3362         */
3363        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
3364
3365        /**
3366         * Persistent store for the system-wide default ringtone URI.
3367         * <p>
3368         * If you need to play the default ringtone at any given time, it is recommended
3369         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
3370         * to the set default ringtone at the time of playing.
3371         *
3372         * @see #DEFAULT_RINGTONE_URI
3373         */
3374        public static final String RINGTONE = "ringtone";
3375
3376        private static final Validator RINGTONE_VALIDATOR = URI_VALIDATOR;
3377
3378        /**
3379         * A {@link Uri} that will point to the current default ringtone at any
3380         * given time.
3381         * <p>
3382         * If the current default ringtone is in the DRM provider and the caller
3383         * does not have permission, the exception will be a
3384         * FileNotFoundException.
3385         */
3386        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
3387
3388        /** {@hide} */
3389        public static final String RINGTONE_CACHE = "ringtone_cache";
3390        /** {@hide} */
3391        public static final Uri RINGTONE_CACHE_URI = getUriFor(RINGTONE_CACHE);
3392
3393        /**
3394         * Persistent store for the system-wide default notification sound.
3395         *
3396         * @see #RINGTONE
3397         * @see #DEFAULT_NOTIFICATION_URI
3398         */
3399        public static final String NOTIFICATION_SOUND = "notification_sound";
3400
3401        private static final Validator NOTIFICATION_SOUND_VALIDATOR = URI_VALIDATOR;
3402
3403        /**
3404         * A {@link Uri} that will point to the current default notification
3405         * sound at any given time.
3406         *
3407         * @see #DEFAULT_RINGTONE_URI
3408         */
3409        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
3410
3411        /** {@hide} */
3412        public static final String NOTIFICATION_SOUND_CACHE = "notification_sound_cache";
3413        /** {@hide} */
3414        public static final Uri NOTIFICATION_SOUND_CACHE_URI = getUriFor(NOTIFICATION_SOUND_CACHE);
3415
3416        /**
3417         * Persistent store for the system-wide default alarm alert.
3418         *
3419         * @see #RINGTONE
3420         * @see #DEFAULT_ALARM_ALERT_URI
3421         */
3422        public static final String ALARM_ALERT = "alarm_alert";
3423
3424        private static final Validator ALARM_ALERT_VALIDATOR = URI_VALIDATOR;
3425
3426        /**
3427         * A {@link Uri} that will point to the current default alarm alert at
3428         * any given time.
3429         *
3430         * @see #DEFAULT_ALARM_ALERT_URI
3431         */
3432        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
3433
3434        /** {@hide} */
3435        public static final String ALARM_ALERT_CACHE = "alarm_alert_cache";
3436        /** {@hide} */
3437        public static final Uri ALARM_ALERT_CACHE_URI = getUriFor(ALARM_ALERT_CACHE);
3438
3439        /**
3440         * Persistent store for the system default media button event receiver.
3441         *
3442         * @hide
3443         */
3444        public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver";
3445
3446        private static final Validator MEDIA_BUTTON_RECEIVER_VALIDATOR = COMPONENT_NAME_VALIDATOR;
3447
3448        /**
3449         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
3450         */
3451        public static final String TEXT_AUTO_REPLACE = "auto_replace";
3452
3453        private static final Validator TEXT_AUTO_REPLACE_VALIDATOR = BOOLEAN_VALIDATOR;
3454
3455        /**
3456         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
3457         */
3458        public static final String TEXT_AUTO_CAPS = "auto_caps";
3459
3460        private static final Validator TEXT_AUTO_CAPS_VALIDATOR = BOOLEAN_VALIDATOR;
3461
3462        /**
3463         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
3464         * feature converts two spaces to a "." and space.
3465         */
3466        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
3467
3468        private static final Validator TEXT_AUTO_PUNCTUATE_VALIDATOR = BOOLEAN_VALIDATOR;
3469
3470        /**
3471         * Setting to showing password characters in text editors. 1 = On, 0 = Off
3472         */
3473        public static final String TEXT_SHOW_PASSWORD = "show_password";
3474
3475        private static final Validator TEXT_SHOW_PASSWORD_VALIDATOR = BOOLEAN_VALIDATOR;
3476
3477        public static final String SHOW_GTALK_SERVICE_STATUS =
3478                "SHOW_GTALK_SERVICE_STATUS";
3479
3480        private static final Validator SHOW_GTALK_SERVICE_STATUS_VALIDATOR = BOOLEAN_VALIDATOR;
3481
3482        /**
3483         * Name of activity to use for wallpaper on the home screen.
3484         *
3485         * @deprecated Use {@link WallpaperManager} instead.
3486         */
3487        @Deprecated
3488        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
3489
3490        private static final Validator WALLPAPER_ACTIVITY_VALIDATOR = new Validator() {
3491            private static final int MAX_LENGTH = 1000;
3492
3493            @Override
3494            public boolean validate(String value) {
3495                if (value != null && value.length() > MAX_LENGTH) {
3496                    return false;
3497                }
3498                return ComponentName.unflattenFromString(value) != null;
3499            }
3500        };
3501
3502        /**
3503         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME}
3504         * instead
3505         */
3506        @Deprecated
3507        public static final String AUTO_TIME = Global.AUTO_TIME;
3508
3509        private static final Validator AUTO_TIME_VALIDATOR = BOOLEAN_VALIDATOR;
3510
3511        /**
3512         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE}
3513         * instead
3514         */
3515        @Deprecated
3516        public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE;
3517
3518        private static final Validator AUTO_TIME_ZONE_VALIDATOR = BOOLEAN_VALIDATOR;
3519
3520        /**
3521         * Display times as 12 or 24 hours
3522         *   12
3523         *   24
3524         */
3525        public static final String TIME_12_24 = "time_12_24";
3526
3527        /** @hide */
3528        public static final Validator TIME_12_24_VALIDATOR =
3529                new SettingsValidators.DiscreteValueValidator(new String[] {"12", "24", null});
3530
3531        /**
3532         * Date format string
3533         *   mm/dd/yyyy
3534         *   dd/mm/yyyy
3535         *   yyyy/mm/dd
3536         */
3537        public static final String DATE_FORMAT = "date_format";
3538
3539        /** @hide */
3540        public static final Validator DATE_FORMAT_VALIDATOR = new Validator() {
3541            @Override
3542            public boolean validate(String value) {
3543                try {
3544                    new SimpleDateFormat(value);
3545                    return true;
3546                } catch (IllegalArgumentException e) {
3547                    return false;
3548                }
3549            }
3550        };
3551
3552        /**
3553         * Whether the setup wizard has been run before (on first boot), or if
3554         * it still needs to be run.
3555         *
3556         * nonzero = it has been run in the past
3557         * 0 = it has not been run in the past
3558         */
3559        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
3560
3561        /** @hide */
3562        public static final Validator SETUP_WIZARD_HAS_RUN_VALIDATOR = BOOLEAN_VALIDATOR;
3563
3564        /**
3565         * Scaling factor for normal window animations. Setting to 0 will disable window
3566         * animations.
3567         *
3568         * @deprecated Use {@link Global#WINDOW_ANIMATION_SCALE} instead
3569         */
3570        @Deprecated
3571        public static final String WINDOW_ANIMATION_SCALE = Global.WINDOW_ANIMATION_SCALE;
3572
3573        /**
3574         * Scaling factor for activity transition animations. Setting to 0 will disable window
3575         * animations.
3576         *
3577         * @deprecated Use {@link Global#TRANSITION_ANIMATION_SCALE} instead
3578         */
3579        @Deprecated
3580        public static final String TRANSITION_ANIMATION_SCALE = Global.TRANSITION_ANIMATION_SCALE;
3581
3582        /**
3583         * Scaling factor for Animator-based animations. This affects both the start delay and
3584         * duration of all such animations. Setting to 0 will cause animations to end immediately.
3585         * The default value is 1.
3586         *
3587         * @deprecated Use {@link Global#ANIMATOR_DURATION_SCALE} instead
3588         */
3589        @Deprecated
3590        public static final String ANIMATOR_DURATION_SCALE = Global.ANIMATOR_DURATION_SCALE;
3591
3592        /**
3593         * Control whether the accelerometer will be used to change screen
3594         * orientation.  If 0, it will not be used unless explicitly requested
3595         * by the application; if 1, it will be used by default unless explicitly
3596         * disabled by the application.
3597         */
3598        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
3599
3600        /** @hide */
3601        public static final Validator ACCELEROMETER_ROTATION_VALIDATOR = BOOLEAN_VALIDATOR;
3602
3603        /**
3604         * Default screen rotation when no other policy applies.
3605         * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
3606         * preference, this rotation value will be used. Must be one of the
3607         * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
3608         *
3609         * @see android.view.Display#getRotation
3610         */
3611        public static final String USER_ROTATION = "user_rotation";
3612
3613        /** @hide */
3614        public static final Validator USER_ROTATION_VALIDATOR =
3615                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
3616
3617        /**
3618         * Control whether the rotation lock toggle in the System UI should be hidden.
3619         * Typically this is done for accessibility purposes to make it harder for
3620         * the user to accidentally toggle the rotation lock while the display rotation
3621         * has been locked for accessibility.
3622         *
3623         * If 0, then rotation lock toggle is not hidden for accessibility (although it may be
3624         * unavailable for other reasons).  If 1, then the rotation lock toggle is hidden.
3625         *
3626         * @hide
3627         */
3628        public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY =
3629                "hide_rotation_lock_toggle_for_accessibility";
3630
3631        /** @hide */
3632        public static final Validator HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR =
3633                BOOLEAN_VALIDATOR;
3634
3635        /**
3636         * Whether the phone vibrates when it is ringing due to an incoming call. This will
3637         * be used by Phone and Setting apps; it shouldn't affect other apps.
3638         * The value is boolean (1 or 0).
3639         *
3640         * Note: this is not same as "vibrate on ring", which had been available until ICS.
3641         * It was about AudioManager's setting and thus affected all the applications which
3642         * relied on the setting, while this is purely about the vibration setting for incoming
3643         * calls.
3644         */
3645        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
3646
3647        /** @hide */
3648        public static final Validator VIBRATE_WHEN_RINGING_VALIDATOR = BOOLEAN_VALIDATOR;
3649
3650        /**
3651         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
3652         * boolean (1 or 0).
3653         */
3654        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
3655
3656        /** @hide */
3657        public static final Validator DTMF_TONE_WHEN_DIALING_VALIDATOR = BOOLEAN_VALIDATOR;
3658
3659        /**
3660         * CDMA only settings
3661         * DTMF tone type played by the dialer when dialing.
3662         *                 0 = Normal
3663         *                 1 = Long
3664         */
3665        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
3666
3667        /** @hide */
3668        public static final Validator DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR = BOOLEAN_VALIDATOR;
3669
3670        /**
3671         * Whether the hearing aid is enabled. The value is
3672         * boolean (1 or 0).
3673         * @hide
3674         */
3675        public static final String HEARING_AID = "hearing_aid";
3676
3677        /** @hide */
3678        public static final Validator HEARING_AID_VALIDATOR = BOOLEAN_VALIDATOR;
3679
3680        /**
3681         * CDMA only settings
3682         * TTY Mode
3683         * 0 = OFF
3684         * 1 = FULL
3685         * 2 = VCO
3686         * 3 = HCO
3687         * @hide
3688         */
3689        public static final String TTY_MODE = "tty_mode";
3690
3691        /** @hide */
3692        public static final Validator TTY_MODE_VALIDATOR =
3693                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
3694
3695        /**
3696         * User-selected RTT mode. When on, outgoing and incoming calls will be answered as RTT
3697         * calls when supported by the device and carrier. Boolean value.
3698         * 0 = OFF
3699         * 1 = ON
3700         */
3701        public static final String RTT_CALLING_MODE = "rtt_calling_mode";
3702
3703        /** @hide */
3704        public static final Validator RTT_CALLING_MODE_VALIDATOR = BOOLEAN_VALIDATOR;
3705
3706        /**
3707         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
3708         * boolean (1 or 0).
3709         */
3710        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
3711
3712        /** @hide */
3713        public static final Validator SOUND_EFFECTS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3714
3715        /**
3716         * Whether the haptic feedback (long presses, ...) are enabled. The value is
3717         * boolean (1 or 0).
3718         */
3719        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
3720
3721        /** @hide */
3722        public static final Validator HAPTIC_FEEDBACK_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3723
3724        /**
3725         * @deprecated Each application that shows web suggestions should have its own
3726         * setting for this.
3727         */
3728        @Deprecated
3729        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
3730
3731        /** @hide */
3732        public static final Validator SHOW_WEB_SUGGESTIONS_VALIDATOR = BOOLEAN_VALIDATOR;
3733
3734        /**
3735         * Whether the notification LED should repeatedly flash when a notification is
3736         * pending. The value is boolean (1 or 0).
3737         * @hide
3738         */
3739        public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse";
3740
3741        /** @hide */
3742        public static final Validator NOTIFICATION_LIGHT_PULSE_VALIDATOR = BOOLEAN_VALIDATOR;
3743
3744        /**
3745         * Show pointer location on screen?
3746         * 0 = no
3747         * 1 = yes
3748         * @hide
3749         */
3750        public static final String POINTER_LOCATION = "pointer_location";
3751
3752        /** @hide */
3753        public static final Validator POINTER_LOCATION_VALIDATOR = BOOLEAN_VALIDATOR;
3754
3755        /**
3756         * Show touch positions on screen?
3757         * 0 = no
3758         * 1 = yes
3759         * @hide
3760         */
3761        public static final String SHOW_TOUCHES = "show_touches";
3762
3763        /** @hide */
3764        public static final Validator SHOW_TOUCHES_VALIDATOR = BOOLEAN_VALIDATOR;
3765
3766        /**
3767         * Log raw orientation data from
3768         * {@link com.android.server.policy.WindowOrientationListener} for use with the
3769         * orientationplot.py tool.
3770         * 0 = no
3771         * 1 = yes
3772         * @hide
3773         */
3774        public static final String WINDOW_ORIENTATION_LISTENER_LOG =
3775                "window_orientation_listener_log";
3776
3777        /** @hide */
3778        public static final Validator WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR = BOOLEAN_VALIDATOR;
3779
3780        /**
3781         * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED}
3782         * instead
3783         * @hide
3784         */
3785        @Deprecated
3786        public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED;
3787
3788        private static final Validator POWER_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3789
3790        /**
3791         * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED}
3792         * instead
3793         * @hide
3794         */
3795        @Deprecated
3796        public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED;
3797
3798        private static final Validator DOCK_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3799
3800        /**
3801         * Whether to play sounds when the keyguard is shown and dismissed.
3802         * @hide
3803         */
3804        public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled";
3805
3806        /** @hide */
3807        public static final Validator LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3808
3809        /**
3810         * Whether the lockscreen should be completely disabled.
3811         * @hide
3812         */
3813        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";
3814
3815        /** @hide */
3816        public static final Validator LOCKSCREEN_DISABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3817
3818        /**
3819         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
3820         * instead
3821         * @hide
3822         */
3823        @Deprecated
3824        public static final String LOW_BATTERY_SOUND = Global.LOW_BATTERY_SOUND;
3825
3826        /**
3827         * @deprecated Use {@link android.provider.Settings.Global#DESK_DOCK_SOUND}
3828         * instead
3829         * @hide
3830         */
3831        @Deprecated
3832        public static final String DESK_DOCK_SOUND = Global.DESK_DOCK_SOUND;
3833
3834        /**
3835         * @deprecated Use {@link android.provider.Settings.Global#DESK_UNDOCK_SOUND}
3836         * instead
3837         * @hide
3838         */
3839        @Deprecated
3840        public static final String DESK_UNDOCK_SOUND = Global.DESK_UNDOCK_SOUND;
3841
3842        /**
3843         * @deprecated Use {@link android.provider.Settings.Global#CAR_DOCK_SOUND}
3844         * instead
3845         * @hide
3846         */
3847        @Deprecated
3848        public static final String CAR_DOCK_SOUND = Global.CAR_DOCK_SOUND;
3849
3850        /**
3851         * @deprecated Use {@link android.provider.Settings.Global#CAR_UNDOCK_SOUND}
3852         * instead
3853         * @hide
3854         */
3855        @Deprecated
3856        public static final String CAR_UNDOCK_SOUND = Global.CAR_UNDOCK_SOUND;
3857
3858        /**
3859         * @deprecated Use {@link android.provider.Settings.Global#LOCK_SOUND}
3860         * instead
3861         * @hide
3862         */
3863        @Deprecated
3864        public static final String LOCK_SOUND = Global.LOCK_SOUND;
3865
3866        /**
3867         * @deprecated Use {@link android.provider.Settings.Global#UNLOCK_SOUND}
3868         * instead
3869         * @hide
3870         */
3871        @Deprecated
3872        public static final String UNLOCK_SOUND = Global.UNLOCK_SOUND;
3873
3874        /**
3875         * Receive incoming SIP calls?
3876         * 0 = no
3877         * 1 = yes
3878         * @hide
3879         */
3880        public static final String SIP_RECEIVE_CALLS = "sip_receive_calls";
3881
3882        /** @hide */
3883        public static final Validator SIP_RECEIVE_CALLS_VALIDATOR = BOOLEAN_VALIDATOR;
3884
3885        /**
3886         * Call Preference String.
3887         * "SIP_ALWAYS" : Always use SIP with network access
3888         * "SIP_ADDRESS_ONLY" : Only if destination is a SIP address
3889         * @hide
3890         */
3891        public static final String SIP_CALL_OPTIONS = "sip_call_options";
3892
3893        /** @hide */
3894        public static final Validator SIP_CALL_OPTIONS_VALIDATOR =
3895                new SettingsValidators.DiscreteValueValidator(
3896                        new String[] {"SIP_ALWAYS", "SIP_ADDRESS_ONLY"});
3897
3898        /**
3899         * One of the sip call options: Always use SIP with network access.
3900         * @hide
3901         */
3902        public static final String SIP_ALWAYS = "SIP_ALWAYS";
3903
3904        /** @hide */
3905        public static final Validator SIP_ALWAYS_VALIDATOR = BOOLEAN_VALIDATOR;
3906
3907        /**
3908         * One of the sip call options: Only if destination is a SIP address.
3909         * @hide
3910         */
3911        public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY";
3912
3913        /** @hide */
3914        public static final Validator SIP_ADDRESS_ONLY_VALIDATOR = BOOLEAN_VALIDATOR;
3915
3916        /**
3917         * @deprecated Use SIP_ALWAYS or SIP_ADDRESS_ONLY instead.  Formerly used to indicate that
3918         * the user should be prompted each time a call is made whether it should be placed using
3919         * SIP.  The {@link com.android.providers.settings.DatabaseHelper} replaces this with
3920         * SIP_ADDRESS_ONLY.
3921         * @hide
3922         */
3923        @Deprecated
3924        public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME";
3925
3926        /** @hide */
3927        public static final Validator SIP_ASK_ME_EACH_TIME_VALIDATOR = BOOLEAN_VALIDATOR;
3928
3929        /**
3930         * Pointer speed setting.
3931         * This is an integer value in a range between -7 and +7, so there are 15 possible values.
3932         *   -7 = slowest
3933         *    0 = default speed
3934         *   +7 = fastest
3935         * @hide
3936         */
3937        public static final String POINTER_SPEED = "pointer_speed";
3938
3939        /** @hide */
3940        public static final Validator POINTER_SPEED_VALIDATOR =
3941                new SettingsValidators.InclusiveFloatRangeValidator(-7, 7);
3942
3943        /**
3944         * Whether lock-to-app will be triggered by long-press on recents.
3945         * @hide
3946         */
3947        public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled";
3948
3949        /** @hide */
3950        public static final Validator LOCK_TO_APP_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
3951
3952        /**
3953         * I am the lolrus.
3954         * <p>
3955         * Nonzero values indicate that the user has a bukkit.
3956         * Backward-compatible with <code>PrefGetPreference(prefAllowEasterEggs)</code>.
3957         * @hide
3958         */
3959        public static final String EGG_MODE = "egg_mode";
3960
3961        /** @hide */
3962        public static final Validator EGG_MODE_VALIDATOR = new Validator() {
3963            @Override
3964            public boolean validate(String value) {
3965                try {
3966                    return Long.parseLong(value) >= 0;
3967                } catch (NumberFormatException e) {
3968                    return false;
3969                }
3970            }
3971        };
3972
3973        /**
3974         * Setting to determine whether or not to show the battery percentage in the status bar.
3975         *    0 - Don't show percentage
3976         *    1 - Show percentage
3977         * @hide
3978         */
3979        public static final String SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
3980
3981        /** @hide */
3982        private static final Validator SHOW_BATTERY_PERCENT_VALIDATOR = BOOLEAN_VALIDATOR;
3983
3984        /**
3985         * IMPORTANT: If you add a new public settings you also have to add it to
3986         * PUBLIC_SETTINGS below. If the new setting is hidden you have to add
3987         * it to PRIVATE_SETTINGS below. Also add a validator that can validate
3988         * the setting value. See an example above.
3989         */
3990
3991        /**
3992         * Settings to backup. This is here so that it's in the same place as the settings
3993         * keys and easy to update.
3994         *
3995         * NOTE: Settings are backed up and restored in the order they appear
3996         *       in this array. If you have one setting depending on another,
3997         *       make sure that they are ordered appropriately.
3998         *
3999         * @hide
4000         */
4001        public static final String[] SETTINGS_TO_BACKUP = {
4002            STAY_ON_WHILE_PLUGGED_IN,   // moved to global
4003            WIFI_USE_STATIC_IP,
4004            WIFI_STATIC_IP,
4005            WIFI_STATIC_GATEWAY,
4006            WIFI_STATIC_NETMASK,
4007            WIFI_STATIC_DNS1,
4008            WIFI_STATIC_DNS2,
4009            BLUETOOTH_DISCOVERABILITY,
4010            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
4011            FONT_SCALE,
4012            DIM_SCREEN,
4013            SCREEN_OFF_TIMEOUT,
4014            SCREEN_BRIGHTNESS,
4015            SCREEN_BRIGHTNESS_MODE,
4016            SCREEN_AUTO_BRIGHTNESS_ADJ,
4017            SCREEN_BRIGHTNESS_FOR_VR,
4018            VIBRATE_INPUT_DEVICES,
4019            MODE_RINGER_STREAMS_AFFECTED,
4020            TEXT_AUTO_REPLACE,
4021            TEXT_AUTO_CAPS,
4022            TEXT_AUTO_PUNCTUATE,
4023            TEXT_SHOW_PASSWORD,
4024            AUTO_TIME,                  // moved to global
4025            AUTO_TIME_ZONE,             // moved to global
4026            TIME_12_24,
4027            DATE_FORMAT,
4028            DTMF_TONE_WHEN_DIALING,
4029            DTMF_TONE_TYPE_WHEN_DIALING,
4030            HEARING_AID,
4031            RTT_CALLING_MODE,
4032            TTY_MODE,
4033            MASTER_MONO,
4034            SOUND_EFFECTS_ENABLED,
4035            HAPTIC_FEEDBACK_ENABLED,
4036            POWER_SOUNDS_ENABLED,       // moved to global
4037            DOCK_SOUNDS_ENABLED,        // moved to global
4038            LOCKSCREEN_SOUNDS_ENABLED,
4039            SHOW_WEB_SUGGESTIONS,
4040            SIP_CALL_OPTIONS,
4041            SIP_RECEIVE_CALLS,
4042            POINTER_SPEED,
4043            VIBRATE_WHEN_RINGING,
4044            RINGTONE,
4045            LOCK_TO_APP_ENABLED,
4046            NOTIFICATION_SOUND,
4047            ACCELEROMETER_ROTATION,
4048            SHOW_BATTERY_PERCENT,
4049            NOTIFICATION_VIBRATION_INTENSITY,
4050            HAPTIC_FEEDBACK_INTENSITY,
4051        };
4052
4053        /**
4054         * Keys we no longer back up under the current schema, but want to continue to
4055         * process when restoring historical backup datasets.
4056         *
4057         * All settings in {@link LEGACY_RESTORE_SETTINGS} array *must* have a non-null validator,
4058         * otherwise they won't be restored.
4059         *
4060         * @hide
4061         */
4062        public static final String[] LEGACY_RESTORE_SETTINGS = {
4063        };
4064
4065        /**
4066         * These are all public system settings
4067         *
4068         * @hide
4069         */
4070        public static final Set<String> PUBLIC_SETTINGS = new ArraySet<>();
4071        static {
4072            PUBLIC_SETTINGS.add(END_BUTTON_BEHAVIOR);
4073            PUBLIC_SETTINGS.add(WIFI_USE_STATIC_IP);
4074            PUBLIC_SETTINGS.add(WIFI_STATIC_IP);
4075            PUBLIC_SETTINGS.add(WIFI_STATIC_GATEWAY);
4076            PUBLIC_SETTINGS.add(WIFI_STATIC_NETMASK);
4077            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS1);
4078            PUBLIC_SETTINGS.add(WIFI_STATIC_DNS2);
4079            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY);
4080            PUBLIC_SETTINGS.add(BLUETOOTH_DISCOVERABILITY_TIMEOUT);
4081            PUBLIC_SETTINGS.add(NEXT_ALARM_FORMATTED);
4082            PUBLIC_SETTINGS.add(FONT_SCALE);
4083            PUBLIC_SETTINGS.add(DIM_SCREEN);
4084            PUBLIC_SETTINGS.add(SCREEN_OFF_TIMEOUT);
4085            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS);
4086            PUBLIC_SETTINGS.add(SCREEN_BRIGHTNESS_MODE);
4087            PUBLIC_SETTINGS.add(MODE_RINGER_STREAMS_AFFECTED);
4088            PUBLIC_SETTINGS.add(MUTE_STREAMS_AFFECTED);
4089            PUBLIC_SETTINGS.add(VIBRATE_ON);
4090            PUBLIC_SETTINGS.add(VOLUME_RING);
4091            PUBLIC_SETTINGS.add(VOLUME_SYSTEM);
4092            PUBLIC_SETTINGS.add(VOLUME_VOICE);
4093            PUBLIC_SETTINGS.add(VOLUME_MUSIC);
4094            PUBLIC_SETTINGS.add(VOLUME_ALARM);
4095            PUBLIC_SETTINGS.add(VOLUME_NOTIFICATION);
4096            PUBLIC_SETTINGS.add(VOLUME_BLUETOOTH_SCO);
4097            PUBLIC_SETTINGS.add(RINGTONE);
4098            PUBLIC_SETTINGS.add(NOTIFICATION_SOUND);
4099            PUBLIC_SETTINGS.add(ALARM_ALERT);
4100            PUBLIC_SETTINGS.add(TEXT_AUTO_REPLACE);
4101            PUBLIC_SETTINGS.add(TEXT_AUTO_CAPS);
4102            PUBLIC_SETTINGS.add(TEXT_AUTO_PUNCTUATE);
4103            PUBLIC_SETTINGS.add(TEXT_SHOW_PASSWORD);
4104            PUBLIC_SETTINGS.add(SHOW_GTALK_SERVICE_STATUS);
4105            PUBLIC_SETTINGS.add(WALLPAPER_ACTIVITY);
4106            PUBLIC_SETTINGS.add(TIME_12_24);
4107            PUBLIC_SETTINGS.add(DATE_FORMAT);
4108            PUBLIC_SETTINGS.add(SETUP_WIZARD_HAS_RUN);
4109            PUBLIC_SETTINGS.add(ACCELEROMETER_ROTATION);
4110            PUBLIC_SETTINGS.add(USER_ROTATION);
4111            PUBLIC_SETTINGS.add(DTMF_TONE_WHEN_DIALING);
4112            PUBLIC_SETTINGS.add(SOUND_EFFECTS_ENABLED);
4113            PUBLIC_SETTINGS.add(HAPTIC_FEEDBACK_ENABLED);
4114            PUBLIC_SETTINGS.add(SHOW_WEB_SUGGESTIONS);
4115            PUBLIC_SETTINGS.add(VIBRATE_WHEN_RINGING);
4116        }
4117
4118        /**
4119         * These are all hidden system settings.
4120         *
4121         * @hide
4122         */
4123        public static final Set<String> PRIVATE_SETTINGS = new ArraySet<>();
4124        static {
4125            PRIVATE_SETTINGS.add(WIFI_USE_STATIC_IP);
4126            PRIVATE_SETTINGS.add(END_BUTTON_BEHAVIOR);
4127            PRIVATE_SETTINGS.add(ADVANCED_SETTINGS);
4128            PRIVATE_SETTINGS.add(SCREEN_AUTO_BRIGHTNESS_ADJ);
4129            PRIVATE_SETTINGS.add(VIBRATE_INPUT_DEVICES);
4130            PRIVATE_SETTINGS.add(VOLUME_MASTER);
4131            PRIVATE_SETTINGS.add(MASTER_MONO);
4132            PRIVATE_SETTINGS.add(NOTIFICATIONS_USE_RING_VOLUME);
4133            PRIVATE_SETTINGS.add(VIBRATE_IN_SILENT);
4134            PRIVATE_SETTINGS.add(MEDIA_BUTTON_RECEIVER);
4135            PRIVATE_SETTINGS.add(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY);
4136            PRIVATE_SETTINGS.add(DTMF_TONE_TYPE_WHEN_DIALING);
4137            PRIVATE_SETTINGS.add(HEARING_AID);
4138            PRIVATE_SETTINGS.add(TTY_MODE);
4139            PRIVATE_SETTINGS.add(NOTIFICATION_LIGHT_PULSE);
4140            PRIVATE_SETTINGS.add(POINTER_LOCATION);
4141            PRIVATE_SETTINGS.add(SHOW_TOUCHES);
4142            PRIVATE_SETTINGS.add(WINDOW_ORIENTATION_LISTENER_LOG);
4143            PRIVATE_SETTINGS.add(POWER_SOUNDS_ENABLED);
4144            PRIVATE_SETTINGS.add(DOCK_SOUNDS_ENABLED);
4145            PRIVATE_SETTINGS.add(LOCKSCREEN_SOUNDS_ENABLED);
4146            PRIVATE_SETTINGS.add(LOCKSCREEN_DISABLED);
4147            PRIVATE_SETTINGS.add(LOW_BATTERY_SOUND);
4148            PRIVATE_SETTINGS.add(DESK_DOCK_SOUND);
4149            PRIVATE_SETTINGS.add(DESK_UNDOCK_SOUND);
4150            PRIVATE_SETTINGS.add(CAR_DOCK_SOUND);
4151            PRIVATE_SETTINGS.add(CAR_UNDOCK_SOUND);
4152            PRIVATE_SETTINGS.add(LOCK_SOUND);
4153            PRIVATE_SETTINGS.add(UNLOCK_SOUND);
4154            PRIVATE_SETTINGS.add(SIP_RECEIVE_CALLS);
4155            PRIVATE_SETTINGS.add(SIP_CALL_OPTIONS);
4156            PRIVATE_SETTINGS.add(SIP_ALWAYS);
4157            PRIVATE_SETTINGS.add(SIP_ADDRESS_ONLY);
4158            PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME);
4159            PRIVATE_SETTINGS.add(POINTER_SPEED);
4160            PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED);
4161            PRIVATE_SETTINGS.add(EGG_MODE);
4162            PRIVATE_SETTINGS.add(SHOW_BATTERY_PERCENT);
4163        }
4164
4165        /**
4166         * These are all public system settings
4167         *
4168         * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator,
4169         * otherwise they won't be restored.
4170         *
4171         * @hide
4172         */
4173        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
4174        static {
4175            VALIDATORS.put(STAY_ON_WHILE_PLUGGED_IN, STAY_ON_WHILE_PLUGGED_IN_VALIDATOR);
4176            VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR);
4177            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
4178            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY, BLUETOOTH_DISCOVERABILITY_VALIDATOR);
4179            VALIDATORS.put(BLUETOOTH_DISCOVERABILITY_TIMEOUT,
4180                    BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR);
4181            VALIDATORS.put(NEXT_ALARM_FORMATTED, NEXT_ALARM_FORMATTED_VALIDATOR);
4182            VALIDATORS.put(FONT_SCALE, FONT_SCALE_VALIDATOR);
4183            VALIDATORS.put(DIM_SCREEN, DIM_SCREEN_VALIDATOR);
4184            VALIDATORS.put(SCREEN_OFF_TIMEOUT, SCREEN_OFF_TIMEOUT_VALIDATOR);
4185            VALIDATORS.put(SCREEN_BRIGHTNESS, SCREEN_BRIGHTNESS_VALIDATOR);
4186            VALIDATORS.put(SCREEN_BRIGHTNESS_FOR_VR, SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR);
4187            VALIDATORS.put(SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_VALIDATOR);
4188            VALIDATORS.put(MODE_RINGER_STREAMS_AFFECTED, MODE_RINGER_STREAMS_AFFECTED_VALIDATOR);
4189            VALIDATORS.put(MUTE_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED_VALIDATOR);
4190            VALIDATORS.put(VIBRATE_ON, VIBRATE_ON_VALIDATOR);
4191            VALIDATORS.put(NOTIFICATION_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
4192            VALIDATORS.put(HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
4193            VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR);
4194            VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR);
4195            VALIDATORS.put(ALARM_ALERT, ALARM_ALERT_VALIDATOR);
4196            VALIDATORS.put(TEXT_AUTO_REPLACE, TEXT_AUTO_REPLACE_VALIDATOR);
4197            VALIDATORS.put(TEXT_AUTO_CAPS, TEXT_AUTO_CAPS_VALIDATOR);
4198            VALIDATORS.put(TEXT_AUTO_PUNCTUATE, TEXT_AUTO_PUNCTUATE_VALIDATOR);
4199            VALIDATORS.put(TEXT_SHOW_PASSWORD, TEXT_SHOW_PASSWORD_VALIDATOR);
4200            VALIDATORS.put(AUTO_TIME, AUTO_TIME_VALIDATOR);
4201            VALIDATORS.put(AUTO_TIME_ZONE, AUTO_TIME_ZONE_VALIDATOR);
4202            VALIDATORS.put(SHOW_GTALK_SERVICE_STATUS, SHOW_GTALK_SERVICE_STATUS_VALIDATOR);
4203            VALIDATORS.put(WALLPAPER_ACTIVITY, WALLPAPER_ACTIVITY_VALIDATOR);
4204            VALIDATORS.put(TIME_12_24, TIME_12_24_VALIDATOR);
4205            VALIDATORS.put(DATE_FORMAT, DATE_FORMAT_VALIDATOR);
4206            VALIDATORS.put(SETUP_WIZARD_HAS_RUN, SETUP_WIZARD_HAS_RUN_VALIDATOR);
4207            VALIDATORS.put(ACCELEROMETER_ROTATION, ACCELEROMETER_ROTATION_VALIDATOR);
4208            VALIDATORS.put(USER_ROTATION, USER_ROTATION_VALIDATOR);
4209            VALIDATORS.put(DTMF_TONE_WHEN_DIALING, DTMF_TONE_WHEN_DIALING_VALIDATOR);
4210            VALIDATORS.put(SOUND_EFFECTS_ENABLED, SOUND_EFFECTS_ENABLED_VALIDATOR);
4211            VALIDATORS.put(HAPTIC_FEEDBACK_ENABLED, HAPTIC_FEEDBACK_ENABLED_VALIDATOR);
4212            VALIDATORS.put(POWER_SOUNDS_ENABLED, POWER_SOUNDS_ENABLED_VALIDATOR);
4213            VALIDATORS.put(DOCK_SOUNDS_ENABLED, DOCK_SOUNDS_ENABLED_VALIDATOR);
4214            VALIDATORS.put(SHOW_WEB_SUGGESTIONS, SHOW_WEB_SUGGESTIONS_VALIDATOR);
4215            VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR);
4216            VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR);
4217            VALIDATORS.put(ADVANCED_SETTINGS, ADVANCED_SETTINGS_VALIDATOR);
4218            VALIDATORS.put(SCREEN_AUTO_BRIGHTNESS_ADJ, SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR);
4219            VALIDATORS.put(VIBRATE_INPUT_DEVICES, VIBRATE_INPUT_DEVICES_VALIDATOR);
4220            VALIDATORS.put(MASTER_MONO, MASTER_MONO_VALIDATOR);
4221            VALIDATORS.put(NOTIFICATIONS_USE_RING_VOLUME, NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR);
4222            VALIDATORS.put(VIBRATE_IN_SILENT, VIBRATE_IN_SILENT_VALIDATOR);
4223            VALIDATORS.put(MEDIA_BUTTON_RECEIVER, MEDIA_BUTTON_RECEIVER_VALIDATOR);
4224            VALIDATORS.put(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY,
4225                    HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR);
4226            VALIDATORS.put(VIBRATE_WHEN_RINGING, VIBRATE_WHEN_RINGING_VALIDATOR);
4227            VALIDATORS.put(DTMF_TONE_TYPE_WHEN_DIALING, DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR);
4228            VALIDATORS.put(HEARING_AID, HEARING_AID_VALIDATOR);
4229            VALIDATORS.put(TTY_MODE, TTY_MODE_VALIDATOR);
4230            VALIDATORS.put(RTT_CALLING_MODE, RTT_CALLING_MODE_VALIDATOR);
4231            VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, NOTIFICATION_LIGHT_PULSE_VALIDATOR);
4232            VALIDATORS.put(POINTER_LOCATION, POINTER_LOCATION_VALIDATOR);
4233            VALIDATORS.put(SHOW_TOUCHES, SHOW_TOUCHES_VALIDATOR);
4234            VALIDATORS.put(WINDOW_ORIENTATION_LISTENER_LOG,
4235                    WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR);
4236            VALIDATORS.put(LOCKSCREEN_SOUNDS_ENABLED, LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR);
4237            VALIDATORS.put(LOCKSCREEN_DISABLED, LOCKSCREEN_DISABLED_VALIDATOR);
4238            VALIDATORS.put(SIP_RECEIVE_CALLS, SIP_RECEIVE_CALLS_VALIDATOR);
4239            VALIDATORS.put(SIP_CALL_OPTIONS, SIP_CALL_OPTIONS_VALIDATOR);
4240            VALIDATORS.put(SIP_ALWAYS, SIP_ALWAYS_VALIDATOR);
4241            VALIDATORS.put(SIP_ADDRESS_ONLY, SIP_ADDRESS_ONLY_VALIDATOR);
4242            VALIDATORS.put(SIP_ASK_ME_EACH_TIME, SIP_ASK_ME_EACH_TIME_VALIDATOR);
4243            VALIDATORS.put(POINTER_SPEED, POINTER_SPEED_VALIDATOR);
4244            VALIDATORS.put(LOCK_TO_APP_ENABLED, LOCK_TO_APP_ENABLED_VALIDATOR);
4245            VALIDATORS.put(EGG_MODE, EGG_MODE_VALIDATOR);
4246            VALIDATORS.put(WIFI_STATIC_IP, WIFI_STATIC_IP_VALIDATOR);
4247            VALIDATORS.put(WIFI_STATIC_GATEWAY, WIFI_STATIC_GATEWAY_VALIDATOR);
4248            VALIDATORS.put(WIFI_STATIC_NETMASK, WIFI_STATIC_NETMASK_VALIDATOR);
4249            VALIDATORS.put(WIFI_STATIC_DNS1, WIFI_STATIC_DNS1_VALIDATOR);
4250            VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR);
4251            VALIDATORS.put(SHOW_BATTERY_PERCENT, SHOW_BATTERY_PERCENT_VALIDATOR);
4252        }
4253
4254        /**
4255         * These entries are considered common between the personal and the managed profile,
4256         * since the managed profile doesn't get to change them.
4257         */
4258        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
4259        static {
4260            CLONE_TO_MANAGED_PROFILE.add(DATE_FORMAT);
4261            CLONE_TO_MANAGED_PROFILE.add(HAPTIC_FEEDBACK_ENABLED);
4262            CLONE_TO_MANAGED_PROFILE.add(SOUND_EFFECTS_ENABLED);
4263            CLONE_TO_MANAGED_PROFILE.add(TEXT_SHOW_PASSWORD);
4264            CLONE_TO_MANAGED_PROFILE.add(TIME_12_24);
4265        }
4266
4267        /** @hide */
4268        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
4269            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
4270        }
4271
4272        /**
4273         * These entries should be cloned from this profile's parent only if the dependency's
4274         * value is true ("1")
4275         *
4276         * Note: the dependencies must be Secure settings
4277         *
4278         * @hide
4279         */
4280        public static final Map<String, String> CLONE_FROM_PARENT_ON_VALUE = new ArrayMap<>();
4281        static {
4282            CLONE_FROM_PARENT_ON_VALUE.put(RINGTONE, Secure.SYNC_PARENT_SOUNDS);
4283            CLONE_FROM_PARENT_ON_VALUE.put(NOTIFICATION_SOUND, Secure.SYNC_PARENT_SOUNDS);
4284            CLONE_FROM_PARENT_ON_VALUE.put(ALARM_ALERT, Secure.SYNC_PARENT_SOUNDS);
4285        }
4286
4287        /** @hide */
4288        public static void getCloneFromParentOnValueSettings(Map<String, String> outMap) {
4289            outMap.putAll(CLONE_FROM_PARENT_ON_VALUE);
4290        }
4291
4292        /**
4293         * System settings which can be accessed by instant apps.
4294         * @hide
4295         */
4296        public static final Set<String> INSTANT_APP_SETTINGS = new ArraySet<>();
4297        static {
4298            INSTANT_APP_SETTINGS.add(TEXT_AUTO_REPLACE);
4299            INSTANT_APP_SETTINGS.add(TEXT_AUTO_CAPS);
4300            INSTANT_APP_SETTINGS.add(TEXT_AUTO_PUNCTUATE);
4301            INSTANT_APP_SETTINGS.add(TEXT_SHOW_PASSWORD);
4302            INSTANT_APP_SETTINGS.add(DATE_FORMAT);
4303            INSTANT_APP_SETTINGS.add(FONT_SCALE);
4304            INSTANT_APP_SETTINGS.add(HAPTIC_FEEDBACK_ENABLED);
4305            INSTANT_APP_SETTINGS.add(TIME_12_24);
4306            INSTANT_APP_SETTINGS.add(SOUND_EFFECTS_ENABLED);
4307            INSTANT_APP_SETTINGS.add(ACCELEROMETER_ROTATION);
4308        }
4309
4310        /**
4311         * When to use Wi-Fi calling
4312         *
4313         * @see android.telephony.TelephonyManager.WifiCallingChoices
4314         * @hide
4315         */
4316        public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls";
4317
4318        // Settings moved to Settings.Secure
4319
4320        /**
4321         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED}
4322         * instead
4323         */
4324        @Deprecated
4325        public static final String ADB_ENABLED = Global.ADB_ENABLED;
4326
4327        /**
4328         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
4329         */
4330        @Deprecated
4331        public static final String ANDROID_ID = Secure.ANDROID_ID;
4332
4333        /**
4334         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
4335         */
4336        @Deprecated
4337        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
4338
4339        private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR;
4340
4341        /**
4342         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
4343         */
4344        @Deprecated
4345        public static final String DATA_ROAMING = Global.DATA_ROAMING;
4346
4347        /**
4348         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
4349         */
4350        @Deprecated
4351        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
4352
4353        /**
4354         * @deprecated Use {@link android.provider.Settings.Global#HTTP_PROXY} instead
4355         */
4356        @Deprecated
4357        public static final String HTTP_PROXY = Global.HTTP_PROXY;
4358
4359        /**
4360         * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
4361         */
4362        @Deprecated
4363        public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
4364
4365        /**
4366         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
4367         * instead
4368         */
4369        @Deprecated
4370        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
4371
4372        /**
4373         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
4374         */
4375        @Deprecated
4376        public static final String LOGGING_ID = Secure.LOGGING_ID;
4377
4378        /**
4379         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
4380         */
4381        @Deprecated
4382        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
4383
4384        /**
4385         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
4386         * instead
4387         */
4388        @Deprecated
4389        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
4390
4391        /**
4392         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
4393         * instead
4394         */
4395        @Deprecated
4396        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
4397
4398        /**
4399         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
4400         * instead
4401         */
4402        @Deprecated
4403        public static final String PARENTAL_CONTROL_REDIRECT_URL =
4404            Secure.PARENTAL_CONTROL_REDIRECT_URL;
4405
4406        /**
4407         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
4408         */
4409        @Deprecated
4410        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
4411
4412        /**
4413         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
4414         */
4415        @Deprecated
4416        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
4417
4418        private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
4419
4420        /**
4421         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
4422         */
4423        @Deprecated
4424        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
4425
4426       /**
4427         * @deprecated Use
4428         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
4429         */
4430        @Deprecated
4431        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
4432
4433        /**
4434         * @deprecated Use
4435         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
4436         */
4437        @Deprecated
4438        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
4439                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
4440
4441        /**
4442         * @deprecated Use
4443         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
4444         */
4445        @Deprecated
4446        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
4447                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
4448
4449        private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
4450                BOOLEAN_VALIDATOR;
4451
4452        /**
4453         * @deprecated Use
4454         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
4455         */
4456        @Deprecated
4457        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
4458                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
4459
4460        private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR =
4461                NON_NEGATIVE_INTEGER_VALIDATOR;
4462
4463        /**
4464         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
4465         * instead
4466         */
4467        @Deprecated
4468        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
4469
4470        private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR =
4471                NON_NEGATIVE_INTEGER_VALIDATOR;
4472
4473        /**
4474         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead
4475         */
4476        @Deprecated
4477        public static final String WIFI_ON = Global.WIFI_ON;
4478
4479        /**
4480         * @deprecated Use
4481         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
4482         * instead
4483         */
4484        @Deprecated
4485        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
4486                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
4487
4488        /**
4489         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
4490         */
4491        @Deprecated
4492        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
4493
4494        /**
4495         * @deprecated Use
4496         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
4497         */
4498        @Deprecated
4499        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
4500                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
4501
4502        /**
4503         * @deprecated Use
4504         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
4505         */
4506        @Deprecated
4507        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
4508                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
4509
4510        /**
4511         * @deprecated Use
4512         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
4513         * instead
4514         */
4515        @Deprecated
4516        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
4517                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
4518
4519        /**
4520         * @deprecated Use
4521         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
4522         */
4523        @Deprecated
4524        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
4525            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
4526
4527        /**
4528         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
4529         * instead
4530         */
4531        @Deprecated
4532        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
4533
4534        /**
4535         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
4536         */
4537        @Deprecated
4538        public static final String WIFI_WATCHDOG_ON = Global.WIFI_WATCHDOG_ON;
4539
4540        /**
4541         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
4542         */
4543        @Deprecated
4544        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
4545
4546        /**
4547         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
4548         * instead
4549         */
4550        @Deprecated
4551        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
4552
4553        /**
4554         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
4555         * instead
4556         */
4557        @Deprecated
4558        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
4559            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
4560
4561        /**
4562         * Checks if the specified app can modify system settings. As of API
4563         * level 23, an app cannot modify system settings unless it declares the
4564         * {@link android.Manifest.permission#WRITE_SETTINGS}
4565         * permission in its manifest, <em>and</em> the user specifically grants
4566         * the app this capability. To prompt the user to grant this approval,
4567         * the app must send an intent with the action {@link
4568         * android.provider.Settings#ACTION_MANAGE_WRITE_SETTINGS}, which causes
4569         * the system to display a permission management screen.
4570         *
4571         * @param context App context.
4572         * @return true if the calling app can write to system settings, false otherwise
4573         */
4574        public static boolean canWrite(Context context) {
4575            return isCallingPackageAllowedToWriteSettings(context, Process.myUid(),
4576                    context.getOpPackageName(), false);
4577        }
4578    }
4579
4580    /**
4581     * Secure system settings, containing system preferences that applications
4582     * can read but are not allowed to write.  These are for preferences that
4583     * the user must explicitly modify through the system UI or specialized
4584     * APIs for those values, not modified directly by applications.
4585     */
4586    public static final class Secure extends NameValueTable {
4587        // NOTE: If you add new settings here, be sure to add them to
4588        // com.android.providers.settings.SettingsProtoDumpUtil#dumpProtoSecureSettingsLocked.
4589
4590        /**
4591         * The content:// style URL for this table
4592         */
4593        public static final Uri CONTENT_URI =
4594            Uri.parse("content://" + AUTHORITY + "/secure");
4595
4596        private static final ContentProviderHolder sProviderHolder =
4597                new ContentProviderHolder(CONTENT_URI);
4598
4599        // Populated lazily, guarded by class object:
4600        private static final NameValueCache sNameValueCache = new NameValueCache(
4601                CONTENT_URI,
4602                CALL_METHOD_GET_SECURE,
4603                CALL_METHOD_PUT_SECURE,
4604                sProviderHolder);
4605
4606        private static ILockSettings sLockSettings = null;
4607
4608        private static boolean sIsSystemProcess;
4609        private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
4610        private static final HashSet<String> MOVED_TO_GLOBAL;
4611        static {
4612            MOVED_TO_LOCK_SETTINGS = new HashSet<>(3);
4613            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
4614            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
4615            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
4616
4617            MOVED_TO_GLOBAL = new HashSet<>();
4618            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
4619            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
4620            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
4621            MOVED_TO_GLOBAL.add(Settings.Global.BUGREPORT_IN_POWER_MENU);
4622            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
4623            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
4624            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
4625            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE);
4626            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI);
4627            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
4628            MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
4629            MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
4630            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
4631            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
4632            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
4633            MOVED_TO_GLOBAL.add(Settings.Global.MOBILE_DATA);
4634            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION);
4635            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_DELETE_AGE);
4636            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES);
4637            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE);
4638            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_ENABLED);
4639            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES);
4640            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_POLL_INTERVAL);
4641            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_SAMPLE_ENABLED);
4642            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE);
4643            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION);
4644            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_DELETE_AGE);
4645            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES);
4646            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_ROTATE_AGE);
4647            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION);
4648            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE);
4649            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES);
4650            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE);
4651            MOVED_TO_GLOBAL.add(Settings.Global.NETWORK_PREFERENCE);
4652            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_DIFF);
4653            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_SPACING);
4654            MOVED_TO_GLOBAL.add(Settings.Global.NTP_SERVER);
4655            MOVED_TO_GLOBAL.add(Settings.Global.NTP_TIMEOUT);
4656            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT);
4657            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS);
4658            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT);
4659            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS);
4660            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT);
4661            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
4662            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST);
4663            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL);
4664            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_APN);
4665            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_REQUIRED);
4666            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_SUPPORTED);
4667            MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED);
4668            MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL);
4669            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE);
4670            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS);
4671            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND);
4672            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS);
4673            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT);
4674            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS);
4675            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
4676            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
4677            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT);
4678            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
4679            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
4680            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
4681            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
4682            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
4683            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_VERBOSE_LOGGING_ENABLED);
4684            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ENHANCED_AUTO_JOIN);
4685            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORK_SHOW_RSSI);
4686            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
4687            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
4688            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
4689            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_ENABLE);
4690            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT);
4691            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE);
4692            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS);
4693            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS);
4694            MOVED_TO_GLOBAL.add(Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS);
4695            MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
4696            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD);
4697            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_THRESHOLD);
4698            MOVED_TO_GLOBAL.add(Settings.Global.SEND_ACTION_APP_ERROR);
4699            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_AGE_SECONDS);
4700            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_MAX_FILES);
4701            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_KB);
4702            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_PERCENT);
4703            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_RESERVE_PERCENT);
4704            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_TAG_PREFIX);
4705            MOVED_TO_GLOBAL.add(Settings.Global.ERROR_LOGCAT_PREFIX);
4706            MOVED_TO_GLOBAL.add(Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL);
4707            MOVED_TO_GLOBAL.add(Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD);
4708            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE);
4709            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES);
4710            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES);
4711            MOVED_TO_GLOBAL.add(Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS);
4712            MOVED_TO_GLOBAL.add(Settings.Global.CONNECTIVITY_CHANGE_DELAY);
4713            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED);
4714            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_SERVER);
4715            MOVED_TO_GLOBAL.add(Settings.Global.NSD_ON);
4716            MOVED_TO_GLOBAL.add(Settings.Global.SET_INSTALL_LOCATION);
4717            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_INSTALL_LOCATION);
4718            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY);
4719            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY);
4720            MOVED_TO_GLOBAL.add(Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT);
4721            MOVED_TO_GLOBAL.add(Settings.Global.HTTP_PROXY);
4722            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_HOST);
4723            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_PORT);
4724            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
4725            MOVED_TO_GLOBAL.add(Settings.Global.SET_GLOBAL_HTTP_PROXY);
4726            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_DNS_SERVER);
4727            MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_NETWORK_MODE);
4728            MOVED_TO_GLOBAL.add(Settings.Global.WEBVIEW_DATA_REDUCTION_PROXY_KEY);
4729        }
4730
4731        /** @hide */
4732        public static void getMovedToGlobalSettings(Set<String> outKeySet) {
4733            outKeySet.addAll(MOVED_TO_GLOBAL);
4734        }
4735
4736        /** @hide */
4737        public static void clearProviderForTest() {
4738            sProviderHolder.clearProviderForTest();
4739            sNameValueCache.clearGenerationTrackerForTest();
4740        }
4741
4742        /**
4743         * Look up a name in the database.
4744         * @param resolver to access the database with
4745         * @param name to look up in the table
4746         * @return the corresponding value, or null if not present
4747         */
4748        public static String getString(ContentResolver resolver, String name) {
4749            return getStringForUser(resolver, name, resolver.getUserId());
4750        }
4751
4752        /** @hide */
4753        public static String getStringForUser(ContentResolver resolver, String name,
4754                int userHandle) {
4755            if (MOVED_TO_GLOBAL.contains(name)) {
4756                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
4757                        + " to android.provider.Settings.Global.");
4758                return Global.getStringForUser(resolver, name, userHandle);
4759            }
4760
4761            if (MOVED_TO_LOCK_SETTINGS.contains(name)) {
4762                synchronized (Secure.class) {
4763                    if (sLockSettings == null) {
4764                        sLockSettings = ILockSettings.Stub.asInterface(
4765                                (IBinder) ServiceManager.getService("lock_settings"));
4766                        sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
4767                    }
4768                }
4769                if (sLockSettings != null && !sIsSystemProcess) {
4770                    // No context; use the ActivityThread's context as an approximation for
4771                    // determining the target API level.
4772                    Application application = ActivityThread.currentApplication();
4773
4774                    boolean isPreMnc = application != null
4775                            && application.getApplicationInfo() != null
4776                            && application.getApplicationInfo().targetSdkVersion
4777                            <= VERSION_CODES.LOLLIPOP_MR1;
4778                    if (isPreMnc) {
4779                        try {
4780                            return sLockSettings.getString(name, "0", userHandle);
4781                        } catch (RemoteException re) {
4782                            // Fall through
4783                        }
4784                    } else {
4785                        throw new SecurityException("Settings.Secure." + name
4786                                + " is deprecated and no longer accessible."
4787                                + " See API documentation for potential replacements.");
4788                    }
4789                }
4790            }
4791
4792            return sNameValueCache.getStringForUser(resolver, name, userHandle);
4793        }
4794
4795        /**
4796         * Store a name/value pair into the database.
4797         * @param resolver to access the database with
4798         * @param name to store
4799         * @param value to associate with the name
4800         * @return true if the value was set, false on database errors
4801         */
4802        public static boolean putString(ContentResolver resolver, String name, String value) {
4803            return putStringForUser(resolver, name, value, resolver.getUserId());
4804        }
4805
4806        /** @hide */
4807        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
4808                int userHandle) {
4809            return putStringForUser(resolver, name, value, null, false, userHandle);
4810        }
4811
4812        /** @hide */
4813        public static boolean putStringForUser(@NonNull ContentResolver resolver,
4814                @NonNull String name, @Nullable String value, @Nullable String tag,
4815                boolean makeDefault, @UserIdInt int userHandle) {
4816            if (LOCATION_MODE.equals(name)) {
4817                // Map LOCATION_MODE to underlying location provider storage API
4818                return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle);
4819            }
4820            if (MOVED_TO_GLOBAL.contains(name)) {
4821                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
4822                        + " to android.provider.Settings.Global");
4823                return Global.putStringForUser(resolver, name, value,
4824                        tag, makeDefault, userHandle);
4825            }
4826            return sNameValueCache.putStringForUser(resolver, name, value, tag,
4827                    makeDefault, userHandle);
4828        }
4829
4830        /**
4831         * Store a name/value pair into the database.
4832         * <p>
4833         * The method takes an optional tag to associate with the setting
4834         * which can be used to clear only settings made by your package and
4835         * associated with this tag by passing the tag to {@link
4836         * #resetToDefaults(ContentResolver, String)}. Anyone can override
4837         * the current tag. Also if another package changes the setting
4838         * then the tag will be set to the one specified in the set call
4839         * which can be null. Also any of the settings setters that do not
4840         * take a tag as an argument effectively clears the tag.
4841         * </p><p>
4842         * For example, if you set settings A and B with tags T1 and T2 and
4843         * another app changes setting A (potentially to the same value), it
4844         * can assign to it a tag T3 (note that now the package that changed
4845         * the setting is not yours). Now if you reset your changes for T1 and
4846         * T2 only setting B will be reset and A not (as it was changed by
4847         * another package) but since A did not change you are in the desired
4848         * initial state. Now if the other app changes the value of A (assuming
4849         * you registered an observer in the beginning) you would detect that
4850         * the setting was changed by another app and handle this appropriately
4851         * (ignore, set back to some value, etc).
4852         * </p><p>
4853         * Also the method takes an argument whether to make the value the
4854         * default for this setting. If the system already specified a default
4855         * value, then the one passed in here will <strong>not</strong>
4856         * be set as the default.
4857         * </p>
4858         *
4859         * @param resolver to access the database with.
4860         * @param name to store.
4861         * @param value to associate with the name.
4862         * @param tag to associate with the setting.
4863         * @param makeDefault whether to make the value the default one.
4864         * @return true if the value was set, false on database errors.
4865         *
4866         * @see #resetToDefaults(ContentResolver, String)
4867         *
4868         * @hide
4869         */
4870        @SystemApi
4871        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
4872        public static boolean putString(@NonNull ContentResolver resolver,
4873                @NonNull String name, @Nullable String value, @Nullable String tag,
4874                boolean makeDefault) {
4875            return putStringForUser(resolver, name, value, tag, makeDefault,
4876                    resolver.getUserId());
4877        }
4878
4879        /**
4880         * Reset the settings to their defaults. This would reset <strong>only</strong>
4881         * settings set by the caller's package. Think of it of a way to undo your own
4882         * changes to the global settings. Passing in the optional tag will reset only
4883         * settings changed by your package and associated with this tag.
4884         *
4885         * @param resolver Handle to the content resolver.
4886         * @param tag Optional tag which should be associated with the settings to reset.
4887         *
4888         * @see #putString(ContentResolver, String, String, String, boolean)
4889         *
4890         * @hide
4891         */
4892        @SystemApi
4893        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
4894        public static void resetToDefaults(@NonNull ContentResolver resolver,
4895                @Nullable String tag) {
4896            resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
4897                    resolver.getUserId());
4898        }
4899
4900        /**
4901         *
4902         * Reset the settings to their defaults for a given user with a specific mode. The
4903         * optional tag argument is valid only for {@link #RESET_MODE_PACKAGE_DEFAULTS}
4904         * allowing resetting the settings made by a package and associated with the tag.
4905         *
4906         * @param resolver Handle to the content resolver.
4907         * @param tag Optional tag which should be associated with the settings to reset.
4908         * @param mode The reset mode.
4909         * @param userHandle The user for which to reset to defaults.
4910         *
4911         * @see #RESET_MODE_PACKAGE_DEFAULTS
4912         * @see #RESET_MODE_UNTRUSTED_DEFAULTS
4913         * @see #RESET_MODE_UNTRUSTED_CHANGES
4914         * @see #RESET_MODE_TRUSTED_DEFAULTS
4915         *
4916         * @hide
4917         */
4918        public static void resetToDefaultsAsUser(@NonNull ContentResolver resolver,
4919                @Nullable String tag, @ResetMode int mode, @IntRange(from = 0) int userHandle) {
4920            try {
4921                Bundle arg = new Bundle();
4922                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
4923                if (tag != null) {
4924                    arg.putString(CALL_METHOD_TAG_KEY, tag);
4925                }
4926                arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode);
4927                IContentProvider cp = sProviderHolder.getProvider(resolver);
4928                cp.call(resolver.getPackageName(), CALL_METHOD_RESET_SECURE, null, arg);
4929            } catch (RemoteException e) {
4930                Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e);
4931            }
4932        }
4933
4934        /**
4935         * Construct the content URI for a particular name/value pair,
4936         * useful for monitoring changes with a ContentObserver.
4937         * @param name to look up in the table
4938         * @return the corresponding content URI, or null if not present
4939         */
4940        public static Uri getUriFor(String name) {
4941            if (MOVED_TO_GLOBAL.contains(name)) {
4942                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
4943                        + " to android.provider.Settings.Global, returning global URI.");
4944                return Global.getUriFor(Global.CONTENT_URI, name);
4945            }
4946            return getUriFor(CONTENT_URI, name);
4947        }
4948
4949        /**
4950         * Convenience function for retrieving a single secure settings value
4951         * as an integer.  Note that internally setting values are always
4952         * stored as strings; this function converts the string to an integer
4953         * for you.  The default value will be returned if the setting is
4954         * not defined or not an integer.
4955         *
4956         * @param cr The ContentResolver to access.
4957         * @param name The name of the setting to retrieve.
4958         * @param def Value to return if the setting is not defined.
4959         *
4960         * @return The setting's current value, or 'def' if it is not defined
4961         * or not a valid integer.
4962         */
4963        public static int getInt(ContentResolver cr, String name, int def) {
4964            return getIntForUser(cr, name, def, cr.getUserId());
4965        }
4966
4967        /** @hide */
4968        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
4969            if (LOCATION_MODE.equals(name)) {
4970                // Map from to underlying location provider storage API to location mode
4971                return getLocationModeForUser(cr, userHandle);
4972            }
4973            String v = getStringForUser(cr, name, userHandle);
4974            try {
4975                return v != null ? Integer.parseInt(v) : def;
4976            } catch (NumberFormatException e) {
4977                return def;
4978            }
4979        }
4980
4981        /**
4982         * Convenience function for retrieving a single secure settings value
4983         * as an integer.  Note that internally setting values are always
4984         * stored as strings; this function converts the string to an integer
4985         * for you.
4986         * <p>
4987         * This version does not take a default value.  If the setting has not
4988         * been set, or the string value is not a number,
4989         * it throws {@link SettingNotFoundException}.
4990         *
4991         * @param cr The ContentResolver to access.
4992         * @param name The name of the setting to retrieve.
4993         *
4994         * @throws SettingNotFoundException Thrown if a setting by the given
4995         * name can't be found or the setting value is not an integer.
4996         *
4997         * @return The setting's current value.
4998         */
4999        public static int getInt(ContentResolver cr, String name)
5000                throws SettingNotFoundException {
5001            return getIntForUser(cr, name, cr.getUserId());
5002        }
5003
5004        /** @hide */
5005        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
5006                throws SettingNotFoundException {
5007            if (LOCATION_MODE.equals(name)) {
5008                // Map from to underlying location provider storage API to location mode
5009                return getLocationModeForUser(cr, userHandle);
5010            }
5011            String v = getStringForUser(cr, name, userHandle);
5012            try {
5013                return Integer.parseInt(v);
5014            } catch (NumberFormatException e) {
5015                throw new SettingNotFoundException(name);
5016            }
5017        }
5018
5019        /**
5020         * Convenience function for updating a single settings value as an
5021         * integer. This will either create a new entry in the table if the
5022         * given name does not exist, or modify the value of the existing row
5023         * with that name.  Note that internally setting values are always
5024         * stored as strings, so this function converts the given value to a
5025         * string before storing it.
5026         *
5027         * @param cr The ContentResolver to access.
5028         * @param name The name of the setting to modify.
5029         * @param value The new value for the setting.
5030         * @return true if the value was set, false on database errors
5031         */
5032        public static boolean putInt(ContentResolver cr, String name, int value) {
5033            return putIntForUser(cr, name, value, cr.getUserId());
5034        }
5035
5036        /** @hide */
5037        public static boolean putIntForUser(ContentResolver cr, String name, int value,
5038                int userHandle) {
5039            return putStringForUser(cr, name, Integer.toString(value), userHandle);
5040        }
5041
5042        /**
5043         * Convenience function for retrieving a single secure settings value
5044         * as a {@code long}.  Note that internally setting values are always
5045         * stored as strings; this function converts the string to a {@code long}
5046         * for you.  The default value will be returned if the setting is
5047         * not defined or not a {@code long}.
5048         *
5049         * @param cr The ContentResolver to access.
5050         * @param name The name of the setting to retrieve.
5051         * @param def Value to return if the setting is not defined.
5052         *
5053         * @return The setting's current value, or 'def' if it is not defined
5054         * or not a valid {@code long}.
5055         */
5056        public static long getLong(ContentResolver cr, String name, long def) {
5057            return getLongForUser(cr, name, def, cr.getUserId());
5058        }
5059
5060        /** @hide */
5061        public static long getLongForUser(ContentResolver cr, String name, long def,
5062                int userHandle) {
5063            String valString = getStringForUser(cr, name, userHandle);
5064            long value;
5065            try {
5066                value = valString != null ? Long.parseLong(valString) : def;
5067            } catch (NumberFormatException e) {
5068                value = def;
5069            }
5070            return value;
5071        }
5072
5073        /**
5074         * Convenience function for retrieving a single secure settings value
5075         * as a {@code long}.  Note that internally setting values are always
5076         * stored as strings; this function converts the string to a {@code long}
5077         * for you.
5078         * <p>
5079         * This version does not take a default value.  If the setting has not
5080         * been set, or the string value is not a number,
5081         * it throws {@link SettingNotFoundException}.
5082         *
5083         * @param cr The ContentResolver to access.
5084         * @param name The name of the setting to retrieve.
5085         *
5086         * @return The setting's current value.
5087         * @throws SettingNotFoundException Thrown if a setting by the given
5088         * name can't be found or the setting value is not an integer.
5089         */
5090        public static long getLong(ContentResolver cr, String name)
5091                throws SettingNotFoundException {
5092            return getLongForUser(cr, name, cr.getUserId());
5093        }
5094
5095        /** @hide */
5096        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
5097                throws SettingNotFoundException {
5098            String valString = getStringForUser(cr, name, userHandle);
5099            try {
5100                return Long.parseLong(valString);
5101            } catch (NumberFormatException e) {
5102                throw new SettingNotFoundException(name);
5103            }
5104        }
5105
5106        /**
5107         * Convenience function for updating a secure settings value as a long
5108         * integer. This will either create a new entry in the table if the
5109         * given name does not exist, or modify the value of the existing row
5110         * with that name.  Note that internally setting values are always
5111         * stored as strings, so this function converts the given value to a
5112         * string before storing it.
5113         *
5114         * @param cr The ContentResolver to access.
5115         * @param name The name of the setting to modify.
5116         * @param value The new value for the setting.
5117         * @return true if the value was set, false on database errors
5118         */
5119        public static boolean putLong(ContentResolver cr, String name, long value) {
5120            return putLongForUser(cr, name, value, cr.getUserId());
5121        }
5122
5123        /** @hide */
5124        public static boolean putLongForUser(ContentResolver cr, String name, long value,
5125                int userHandle) {
5126            return putStringForUser(cr, name, Long.toString(value), userHandle);
5127        }
5128
5129        /**
5130         * Convenience function for retrieving a single secure settings value
5131         * as a floating point number.  Note that internally setting values are
5132         * always stored as strings; this function converts the string to an
5133         * float for you. The default value will be returned if the setting
5134         * is not defined or not a valid float.
5135         *
5136         * @param cr The ContentResolver to access.
5137         * @param name The name of the setting to retrieve.
5138         * @param def Value to return if the setting is not defined.
5139         *
5140         * @return The setting's current value, or 'def' if it is not defined
5141         * or not a valid float.
5142         */
5143        public static float getFloat(ContentResolver cr, String name, float def) {
5144            return getFloatForUser(cr, name, def, cr.getUserId());
5145        }
5146
5147        /** @hide */
5148        public static float getFloatForUser(ContentResolver cr, String name, float def,
5149                int userHandle) {
5150            String v = getStringForUser(cr, name, userHandle);
5151            try {
5152                return v != null ? Float.parseFloat(v) : def;
5153            } catch (NumberFormatException e) {
5154                return def;
5155            }
5156        }
5157
5158        /**
5159         * Convenience function for retrieving a single secure settings value
5160         * as a float.  Note that internally setting values are always
5161         * stored as strings; this function converts the string to a float
5162         * for you.
5163         * <p>
5164         * This version does not take a default value.  If the setting has not
5165         * been set, or the string value is not a number,
5166         * it throws {@link SettingNotFoundException}.
5167         *
5168         * @param cr The ContentResolver to access.
5169         * @param name The name of the setting to retrieve.
5170         *
5171         * @throws SettingNotFoundException Thrown if a setting by the given
5172         * name can't be found or the setting value is not a float.
5173         *
5174         * @return The setting's current value.
5175         */
5176        public static float getFloat(ContentResolver cr, String name)
5177                throws SettingNotFoundException {
5178            return getFloatForUser(cr, name, cr.getUserId());
5179        }
5180
5181        /** @hide */
5182        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
5183                throws SettingNotFoundException {
5184            String v = getStringForUser(cr, name, userHandle);
5185            if (v == null) {
5186                throw new SettingNotFoundException(name);
5187            }
5188            try {
5189                return Float.parseFloat(v);
5190            } catch (NumberFormatException e) {
5191                throw new SettingNotFoundException(name);
5192            }
5193        }
5194
5195        /**
5196         * Convenience function for updating a single settings value as a
5197         * floating point number. This will either create a new entry in the
5198         * table if the given name does not exist, or modify the value of the
5199         * existing row with that name.  Note that internally setting values
5200         * are always stored as strings, so this function converts the given
5201         * value to a string before storing it.
5202         *
5203         * @param cr The ContentResolver to access.
5204         * @param name The name of the setting to modify.
5205         * @param value The new value for the setting.
5206         * @return true if the value was set, false on database errors
5207         */
5208        public static boolean putFloat(ContentResolver cr, String name, float value) {
5209            return putFloatForUser(cr, name, value, cr.getUserId());
5210        }
5211
5212        /** @hide */
5213        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
5214                int userHandle) {
5215            return putStringForUser(cr, name, Float.toString(value), userHandle);
5216        }
5217
5218        /**
5219         * @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
5220         * instead
5221         */
5222        @Deprecated
5223        public static final String DEVELOPMENT_SETTINGS_ENABLED =
5224                Global.DEVELOPMENT_SETTINGS_ENABLED;
5225
5226        /**
5227         * When the user has enable the option to have a "bug report" command
5228         * in the power menu.
5229         * @deprecated Use {@link android.provider.Settings.Global#BUGREPORT_IN_POWER_MENU} instead
5230         * @hide
5231         */
5232        @Deprecated
5233        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
5234
5235        private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
5236
5237        /**
5238         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
5239         */
5240        @Deprecated
5241        public static final String ADB_ENABLED = Global.ADB_ENABLED;
5242
5243        /**
5244         * Setting to allow mock locations and location provider status to be injected into the
5245         * LocationManager service for testing purposes during application development.  These
5246         * locations and status values  override actual location and status information generated
5247         * by network, gps, or other location providers.
5248         *
5249         * @deprecated This settings is not used anymore.
5250         */
5251        @Deprecated
5252        public static final String ALLOW_MOCK_LOCATION = "mock_location";
5253
5254        private static final Validator ALLOW_MOCK_LOCATION_VALIDATOR = BOOLEAN_VALIDATOR;
5255
5256        /**
5257         * On Android 8.0 (API level 26) and higher versions of the platform,
5258         * a 64-bit number (expressed as a hexadecimal string), unique to
5259         * each combination of app-signing key, user, and device.
5260         * Values of {@code ANDROID_ID} are scoped by signing key and user.
5261         * The value may change if a factory reset is performed on the
5262         * device or if an APK signing key changes.
5263         *
5264         * For more information about how the platform handles {@code ANDROID_ID}
5265         * in Android 8.0 (API level 26) and higher, see <a
5266         * href="{@docRoot}preview/behavior-changes.html#privacy-all">
5267         * Android 8.0 Behavior Changes</a>.
5268         *
5269         * <p class="note"><strong>Note:</strong> For apps that were installed
5270         * prior to updating the device to a version of Android 8.0
5271         * (API level 26) or higher, the value of {@code ANDROID_ID} changes
5272         * if the app is uninstalled and then reinstalled after the OTA.
5273         * To preserve values across uninstalls after an OTA to Android 8.0
5274         * or higher, developers can use
5275         * <a href="{@docRoot}guide/topics/data/keyvaluebackup.html">
5276         * Key/Value Backup</a>.</p>
5277         *
5278         * <p>In versions of the platform lower than Android 8.0 (API level 26),
5279         * a 64-bit number (expressed as a hexadecimal string) that is randomly
5280         * generated when the user first sets up the device and should remain
5281         * constant for the lifetime of the user's device.
5282         *
5283         * On devices that have
5284         * <a href="{@docRoot}about/versions/android-4.2.html#MultipleUsers">
5285         * multiple users</a>, each user appears as a
5286         * completely separate device, so the {@code ANDROID_ID} value is
5287         * unique to each user.</p>
5288         *
5289         * <p class="note"><strong>Note:</strong> If the caller is an Instant App the ID is scoped
5290         * to the Instant App, it is generated when the Instant App is first installed and reset if
5291         * the user clears the Instant App.
5292         */
5293        public static final String ANDROID_ID = "android_id";
5294
5295        /**
5296         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
5297         */
5298        @Deprecated
5299        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
5300
5301        private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR;
5302
5303        /**
5304         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
5305         */
5306        @Deprecated
5307        public static final String DATA_ROAMING = Global.DATA_ROAMING;
5308
5309        /**
5310         * Setting to record the input method used by default, holding the ID
5311         * of the desired method.
5312         */
5313        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
5314
5315        /**
5316         * Setting to record the input method subtype used by default, holding the ID
5317         * of the desired method.
5318         */
5319        public static final String SELECTED_INPUT_METHOD_SUBTYPE =
5320                "selected_input_method_subtype";
5321
5322        /**
5323         * Setting to record the history of input method subtype, holding the pair of ID of IME
5324         * and its last used subtype.
5325         * @hide
5326         */
5327        public static final String INPUT_METHODS_SUBTYPE_HISTORY =
5328                "input_methods_subtype_history";
5329
5330        /**
5331         * Setting to record the visibility of input method selector
5332         */
5333        public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
5334                "input_method_selector_visibility";
5335
5336        /**
5337         * The currently selected voice interaction service flattened ComponentName.
5338         * @hide
5339         */
5340        @TestApi
5341        public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
5342
5343        /**
5344         * The currently selected autofill service flattened ComponentName.
5345         * @hide
5346         */
5347        @TestApi
5348        public static final String AUTOFILL_SERVICE = "autofill_service";
5349
5350        private static final Validator AUTOFILL_SERVICE_VALIDATOR = COMPONENT_NAME_VALIDATOR;
5351
5352        /**
5353         * Boolean indicating if Autofill supports field classification.
5354         *
5355         * @see android.service.autofill.AutofillService
5356         *
5357         * @hide
5358         */
5359        @SystemApi
5360        @TestApi
5361        public static final String AUTOFILL_FEATURE_FIELD_CLASSIFICATION =
5362                "autofill_field_classification";
5363
5364        /**
5365         * Defines value returned by {@link android.service.autofill.UserData#getMaxUserDataSize()}.
5366         *
5367         * @hide
5368         */
5369        @SystemApi
5370        @TestApi
5371        public static final String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE =
5372                "autofill_user_data_max_user_data_size";
5373
5374        /**
5375         * Defines value returned by
5376         * {@link android.service.autofill.UserData#getMaxFieldClassificationIdsSize()}.
5377         *
5378         * @hide
5379         */
5380        @SystemApi
5381        @TestApi
5382        public static final String AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE =
5383                "autofill_user_data_max_field_classification_size";
5384
5385        /**
5386         * Defines value returned by
5387         * {@link android.service.autofill.UserData#getMaxCategoryCount()}.
5388         *
5389         * @hide
5390         */
5391        @SystemApi
5392        @TestApi
5393        public static final String AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT =
5394                "autofill_user_data_max_category_count";
5395
5396        /**
5397         * Defines value returned by {@link android.service.autofill.UserData#getMaxValueLength()}.
5398         *
5399         * @hide
5400         */
5401        @SystemApi
5402        @TestApi
5403        public static final String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH =
5404                "autofill_user_data_max_value_length";
5405
5406        /**
5407         * Defines value returned by {@link android.service.autofill.UserData#getMinValueLength()}.
5408         *
5409         * @hide
5410         */
5411        @SystemApi
5412        @TestApi
5413        public static final String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH =
5414                "autofill_user_data_min_value_length";
5415
5416        /**
5417         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
5418         */
5419        @Deprecated
5420        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
5421
5422        /**
5423         * Whether the current user has been set up via setup wizard (0 = false, 1 = true)
5424         * @hide
5425         */
5426        @TestApi
5427        public static final String USER_SETUP_COMPLETE = "user_setup_complete";
5428
5429        /**
5430         * Whether the current user has been set up via setup wizard (0 = false, 1 = true)
5431         * This value differs from USER_SETUP_COMPLETE in that it can be reset back to 0
5432         * in case SetupWizard has been re-enabled on TV devices.
5433         *
5434         * @hide
5435         */
5436        public static final String TV_USER_SETUP_COMPLETE = "tv_user_setup_complete";
5437
5438        /**
5439         * Prefix for category name that marks whether a suggested action from that category was
5440         * completed.
5441         * @hide
5442         */
5443        public static final String COMPLETED_CATEGORY_PREFIX = "suggested.completed_category.";
5444
5445        /**
5446         * List of input methods that are currently enabled.  This is a string
5447         * containing the IDs of all enabled input methods, each ID separated
5448         * by ':'.
5449         *
5450         * Format like "ime0;subtype0;subtype1;subtype2:ime1:ime2;subtype0"
5451         * where imeId is ComponentName and subtype is int32.
5452         */
5453        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
5454
5455        /**
5456         * List of system input methods that are currently disabled.  This is a string
5457         * containing the IDs of all disabled input methods, each ID separated
5458         * by ':'.
5459         * @hide
5460         */
5461        public static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
5462
5463        /**
5464         * Whether to show the IME when a hard keyboard is connected. This is a boolean that
5465         * determines if the IME should be shown when a hard keyboard is attached.
5466         * @hide
5467         */
5468        public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
5469
5470        private static final Validator SHOW_IME_WITH_HARD_KEYBOARD_VALIDATOR = BOOLEAN_VALIDATOR;
5471
5472        /**
5473         * Host name and port for global http proxy. Uses ':' seperator for
5474         * between host and port.
5475         *
5476         * @deprecated Use {@link Global#HTTP_PROXY}
5477         */
5478        @Deprecated
5479        public static final String HTTP_PROXY = Global.HTTP_PROXY;
5480
5481        /**
5482         * Package designated as always-on VPN provider.
5483         *
5484         * @hide
5485         */
5486        public static final String ALWAYS_ON_VPN_APP = "always_on_vpn_app";
5487
5488        /**
5489         * Whether to block networking outside of VPN connections while always-on is set.
5490         * @see #ALWAYS_ON_VPN_APP
5491         *
5492         * @hide
5493         */
5494        public static final String ALWAYS_ON_VPN_LOCKDOWN = "always_on_vpn_lockdown";
5495
5496        /**
5497         * Whether applications can be installed for this user via the system's
5498         * {@link Intent#ACTION_INSTALL_PACKAGE} mechanism.
5499         *
5500         * <p>1 = permit app installation via the system package installer intent
5501         * <p>0 = do not allow use of the package installer
5502         * @deprecated Starting from {@link android.os.Build.VERSION_CODES#O}, apps should use
5503         * {@link PackageManager#canRequestPackageInstalls()}
5504         * @see PackageManager#canRequestPackageInstalls()
5505         */
5506        public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
5507
5508        /**
5509         * A flag to tell {@link com.android.server.devicepolicy.DevicePolicyManagerService} that
5510         * the default for {@link #INSTALL_NON_MARKET_APPS} is reversed for this user on OTA. So it
5511         * can set the restriction {@link android.os.UserManager#DISALLOW_INSTALL_UNKNOWN_SOURCES}
5512         * on behalf of the profile owner if needed to make the change transparent for profile
5513         * owners.
5514         *
5515         * @hide
5516         */
5517        public static final String UNKNOWN_SOURCES_DEFAULT_REVERSED =
5518                "unknown_sources_default_reversed";
5519
5520        /**
5521         * Comma-separated list of location providers that activities may access. Do not rely on
5522         * this value being present in settings.db or on ContentObserver notifications on the
5523         * corresponding Uri.
5524         *
5525         * @deprecated use {@link #LOCATION_MODE} and
5526         * {@link LocationManager#MODE_CHANGED_ACTION} (or
5527         * {@link LocationManager#PROVIDERS_CHANGED_ACTION})
5528         */
5529        @Deprecated
5530        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
5531
5532        /**
5533         * The degree of location access enabled by the user.
5534         * <p>
5535         * When used with {@link #putInt(ContentResolver, String, int)}, must be one of {@link
5536         * #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, {@link
5537         * #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. When used with {@link
5538         * #getInt(ContentResolver, String)}, the caller must gracefully handle additional location
5539         * modes that might be added in the future.
5540         * <p>
5541         * Note: do not rely on this value being present in settings.db or on ContentObserver
5542         * notifications for the corresponding Uri. Use {@link LocationManager#MODE_CHANGED_ACTION}
5543         * to receive changes in this value.
5544         *
5545         * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
5546         *             get the status of a location provider, use
5547         *             {@link LocationManager#isProviderEnabled(String)}.
5548         */
5549        @Deprecated
5550        public static final String LOCATION_MODE = "location_mode";
5551
5552        /**
5553         * The App or module that changes the location mode.
5554         * @hide
5555         */
5556        public static final String LOCATION_CHANGER = "location_changer";
5557        /**
5558         * The location changer is unknown or unable to detect.
5559         * @hide
5560         */
5561        public static final int LOCATION_CHANGER_UNKNOWN = 0;
5562        /**
5563         * Location settings in system settings.
5564         * @hide
5565         */
5566        public static final int LOCATION_CHANGER_SYSTEM_SETTINGS = 1;
5567        /**
5568         * The location icon in drop down notification drawer.
5569         * @hide
5570         */
5571        public static final int LOCATION_CHANGER_QUICK_SETTINGS = 2;
5572
5573        /**
5574         * Location access disabled.
5575         *
5576         * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
5577         *             get the status of a location provider, use
5578         *             {@link LocationManager#isProviderEnabled(String)}.
5579         */
5580        @Deprecated
5581        public static final int LOCATION_MODE_OFF = 0;
5582
5583        /**
5584         * Network Location Provider disabled, but GPS and other sensors enabled.
5585         *
5586         * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
5587         *             get the status of a location provider, use
5588         *             {@link LocationManager#isProviderEnabled(String)}.
5589         */
5590        @Deprecated
5591        public static final int LOCATION_MODE_SENSORS_ONLY = 1;
5592
5593        /**
5594         * Reduced power usage, such as limiting the number of GPS updates per hour. Requests
5595         * with {@link android.location.Criteria#POWER_HIGH} may be downgraded to
5596         * {@link android.location.Criteria#POWER_MEDIUM}.
5597         *
5598         * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
5599         *             get the status of a location provider, use
5600         *             {@link LocationManager#isProviderEnabled(String)}.
5601         */
5602        @Deprecated
5603        public static final int LOCATION_MODE_BATTERY_SAVING = 2;
5604
5605        /**
5606         * Best-effort location computation allowed.
5607         *
5608         * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
5609         *             get the status of a location provider, use
5610         *             {@link LocationManager#isProviderEnabled(String)}.
5611         */
5612        @Deprecated
5613        public static final int LOCATION_MODE_HIGH_ACCURACY = 3;
5614
5615        /**
5616         * A flag containing settings used for biometric weak
5617         * @hide
5618         */
5619        @Deprecated
5620        public static final String LOCK_BIOMETRIC_WEAK_FLAGS =
5621                "lock_biometric_weak_flags";
5622
5623        /**
5624         * Whether lock-to-app will lock the keyguard when exiting.
5625         * @hide
5626         */
5627        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";
5628
5629        /**
5630         * Whether autolock is enabled (0 = false, 1 = true)
5631         *
5632         * @deprecated Use {@link android.app.KeyguardManager} to determine the state and security
5633         *             level of the keyguard. Accessing this setting from an app that is targeting
5634         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5635         */
5636        @Deprecated
5637        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
5638
5639        /**
5640         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
5641         *
5642         * @deprecated Accessing this setting from an app that is targeting
5643         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5644         */
5645        @Deprecated
5646        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
5647
5648        /**
5649         * Whether lock pattern will vibrate as user enters (0 = false, 1 =
5650         * true)
5651         *
5652         * @deprecated Starting in {@link VERSION_CODES#JELLY_BEAN_MR1} the
5653         *             lockscreen uses
5654         *             {@link Settings.System#HAPTIC_FEEDBACK_ENABLED}.
5655         *             Accessing this setting from an app that is targeting
5656         *             {@link VERSION_CODES#M} or later throws a {@code SecurityException}.
5657         */
5658        @Deprecated
5659        public static final String
5660                LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
5661
5662        /**
5663         * This preference allows the device to be locked given time after screen goes off,
5664         * subject to current DeviceAdmin policy limits.
5665         * @hide
5666         */
5667        public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout";
5668
5669
5670        /**
5671         * This preference contains the string that shows for owner info on LockScreen.
5672         * @hide
5673         * @deprecated
5674         */
5675        @Deprecated
5676        public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
5677
5678        /**
5679         * Ids of the user-selected appwidgets on the lockscreen (comma-delimited).
5680         * @hide
5681         */
5682        @Deprecated
5683        public static final String LOCK_SCREEN_APPWIDGET_IDS =
5684            "lock_screen_appwidget_ids";
5685
5686        /**
5687         * Id of the appwidget shown on the lock screen when appwidgets are disabled.
5688         * @hide
5689         */
5690        @Deprecated
5691        public static final String LOCK_SCREEN_FALLBACK_APPWIDGET_ID =
5692            "lock_screen_fallback_appwidget_id";
5693
5694        /**
5695         * Index of the lockscreen appwidget to restore, -1 if none.
5696         * @hide
5697         */
5698        @Deprecated
5699        public static final String LOCK_SCREEN_STICKY_APPWIDGET =
5700            "lock_screen_sticky_appwidget";
5701
5702        /**
5703         * This preference enables showing the owner info on LockScreen.
5704         * @hide
5705         * @deprecated
5706         */
5707        @Deprecated
5708        public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
5709            "lock_screen_owner_info_enabled";
5710
5711        /**
5712         * When set by a user, allows notifications to be shown atop a securely locked screen
5713         * in their full "private" form (same as when the device is unlocked).
5714         * @hide
5715         */
5716        public static final String LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS =
5717                "lock_screen_allow_private_notifications";
5718
5719        /**
5720         * When set by a user, allows notification remote input atop a securely locked screen
5721         * without having to unlock
5722         * @hide
5723         */
5724        public static final String LOCK_SCREEN_ALLOW_REMOTE_INPUT =
5725                "lock_screen_allow_remote_input";
5726
5727        /**
5728         * Set by the system to track if the user needs to see the call to action for
5729         * the lockscreen notification policy.
5730         * @hide
5731         */
5732        public static final String SHOW_NOTE_ABOUT_NOTIFICATION_HIDING =
5733                "show_note_about_notification_hiding";
5734
5735        /**
5736         * Set to 1 by the system after trust agents have been initialized.
5737         * @hide
5738         */
5739        public static final String TRUST_AGENTS_INITIALIZED =
5740                "trust_agents_initialized";
5741
5742        /**
5743         * The Logging ID (a unique 64-bit value) as a hex string.
5744         * Used as a pseudonymous identifier for logging.
5745         * @deprecated This identifier is poorly initialized and has
5746         * many collisions.  It should not be used.
5747         */
5748        @Deprecated
5749        public static final String LOGGING_ID = "logging_id";
5750
5751        /**
5752         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
5753         */
5754        @Deprecated
5755        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
5756
5757        /**
5758         * No longer supported.
5759         */
5760        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
5761
5762        /**
5763         * No longer supported.
5764         */
5765        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
5766
5767        /**
5768         * No longer supported.
5769         */
5770        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
5771
5772        /**
5773         * Settings classname to launch when Settings is clicked from All
5774         * Applications.  Needed because of user testing between the old
5775         * and new Settings apps.
5776         */
5777        // TODO: 881807
5778        public static final String SETTINGS_CLASSNAME = "settings_classname";
5779
5780        /**
5781         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
5782         */
5783        @Deprecated
5784        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
5785
5786        private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
5787
5788        /**
5789         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
5790         */
5791        @Deprecated
5792        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
5793
5794        /**
5795         * If accessibility is enabled.
5796         */
5797        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
5798
5799        private static final Validator ACCESSIBILITY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
5800
5801        /**
5802         * Setting specifying if the accessibility shortcut is enabled.
5803         * @hide
5804         */
5805        public static final String ACCESSIBILITY_SHORTCUT_ENABLED =
5806                "accessibility_shortcut_enabled";
5807
5808        private static final Validator ACCESSIBILITY_SHORTCUT_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
5809
5810        /**
5811         * Setting specifying if the accessibility shortcut is enabled.
5812         * @hide
5813         */
5814        public static final String ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN =
5815                "accessibility_shortcut_on_lock_screen";
5816
5817        private static final Validator ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN_VALIDATOR =
5818                BOOLEAN_VALIDATOR;
5819
5820        /**
5821         * Setting specifying if the accessibility shortcut dialog has been shown to this user.
5822         * @hide
5823         */
5824        public static final String ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN =
5825                "accessibility_shortcut_dialog_shown";
5826
5827        private static final Validator ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN_VALIDATOR =
5828                BOOLEAN_VALIDATOR;
5829
5830        /**
5831         * Setting specifying the accessibility service to be toggled via the accessibility
5832         * shortcut. Must be its flattened {@link ComponentName}.
5833         * @hide
5834         */
5835        public static final String ACCESSIBILITY_SHORTCUT_TARGET_SERVICE =
5836                "accessibility_shortcut_target_service";
5837
5838        private static final Validator ACCESSIBILITY_SHORTCUT_TARGET_SERVICE_VALIDATOR =
5839                COMPONENT_NAME_VALIDATOR;
5840
5841        /**
5842         * Setting specifying the accessibility service or feature to be toggled via the
5843         * accessibility button in the navigation bar. This is either a flattened
5844         * {@link ComponentName} or the class name of a system class implementing a supported
5845         * accessibility feature.
5846         * @hide
5847         */
5848        public static final String ACCESSIBILITY_BUTTON_TARGET_COMPONENT =
5849                "accessibility_button_target_component";
5850
5851        private static final Validator ACCESSIBILITY_BUTTON_TARGET_COMPONENT_VALIDATOR =
5852                new Validator() {
5853                    @Override
5854                    public boolean validate(String value) {
5855                        // technically either ComponentName or class name, but there's proper value
5856                        // validation at callsites, so allow any non-null string
5857                        return value != null;
5858                    }
5859                };
5860
5861        /**
5862         * If touch exploration is enabled.
5863         */
5864        public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled";
5865
5866        private static final Validator TOUCH_EXPLORATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
5867
5868        /**
5869         * List of the enabled accessibility providers.
5870         */
5871        public static final String ENABLED_ACCESSIBILITY_SERVICES =
5872            "enabled_accessibility_services";
5873
5874        private static final Validator ENABLED_ACCESSIBILITY_SERVICES_VALIDATOR =
5875                new SettingsValidators.ComponentNameListValidator(":");
5876
5877        /**
5878         * List of the accessibility services to which the user has granted
5879         * permission to put the device into touch exploration mode.
5880         *
5881         * @hide
5882         */
5883        public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES =
5884            "touch_exploration_granted_accessibility_services";
5885
5886        private static final Validator TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES_VALIDATOR =
5887                new SettingsValidators.ComponentNameListValidator(":");
5888
5889        /**
5890         * Uri of the slice that's presented on the keyguard.
5891         * Defaults to a slice with the date and next alarm.
5892         *
5893         * @hide
5894         */
5895        public static final String KEYGUARD_SLICE_URI = "keyguard_slice_uri";
5896
5897        /**
5898         * Whether to speak passwords while in accessibility mode.
5899         *
5900         * @deprecated The speaking of passwords is controlled by individual accessibility services.
5901         * Apps should ignore this setting and provide complete information to accessibility
5902         * at all times, which was the behavior when this value was {@code true}.
5903         */
5904        @Deprecated
5905        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
5906
5907        private static final Validator ACCESSIBILITY_SPEAK_PASSWORD_VALIDATOR = BOOLEAN_VALIDATOR;
5908
5909        /**
5910         * Whether to draw text with high contrast while in accessibility mode.
5911         *
5912         * @hide
5913         */
5914        public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED =
5915                "high_text_contrast_enabled";
5916
5917        private static final Validator ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR =
5918                BOOLEAN_VALIDATOR;
5919
5920        /**
5921         * Setting that specifies whether the display magnification is enabled via a system-wide
5922         * triple tap gesture. Display magnifications allows the user to zoom in the display content
5923         * and is targeted to low vision users. The current magnification scale is controlled by
5924         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
5925         *
5926         * @hide
5927         */
5928        @TestApi
5929        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED =
5930                "accessibility_display_magnification_enabled";
5931
5932        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR =
5933                BOOLEAN_VALIDATOR;
5934
5935        /**
5936         * Setting that specifies whether the display magnification is enabled via a shortcut
5937         * affordance within the system's navigation area. Display magnifications allows the user to
5938         * zoom in the display content and is targeted to low vision users. The current
5939         * magnification scale is controlled by {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
5940         *
5941         * @hide
5942         */
5943        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED =
5944                "accessibility_display_magnification_navbar_enabled";
5945
5946        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR
5947                = BOOLEAN_VALIDATOR;
5948
5949        /**
5950         * Setting that specifies what the display magnification scale is.
5951         * Display magnifications allows the user to zoom in the display
5952         * content and is targeted to low vision users. Whether a display
5953         * magnification is performed is controlled by
5954         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED} and
5955         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED}
5956         *
5957         * @hide
5958         */
5959        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE =
5960                "accessibility_display_magnification_scale";
5961
5962        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR =
5963                new SettingsValidators.InclusiveFloatRangeValidator(1.0f, Float.MAX_VALUE);
5964
5965        /**
5966         * Unused mangnification setting
5967         *
5968         * @hide
5969         * @deprecated
5970         */
5971        @Deprecated
5972        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE =
5973                "accessibility_display_magnification_auto_update";
5974
5975        /**
5976         * Setting that specifies what mode the soft keyboard is in (default or hidden). Can be
5977         * modified from an AccessibilityService using the SoftKeyboardController.
5978         *
5979         * @hide
5980         */
5981        public static final String ACCESSIBILITY_SOFT_KEYBOARD_MODE =
5982                "accessibility_soft_keyboard_mode";
5983
5984        /**
5985         * Default soft keyboard behavior.
5986         *
5987         * @hide
5988         */
5989        public static final int SHOW_MODE_AUTO = 0;
5990
5991        /**
5992         * Soft keyboard is never shown.
5993         *
5994         * @hide
5995         */
5996        public static final int SHOW_MODE_HIDDEN = 1;
5997
5998        /**
5999         * Setting that specifies whether timed text (captions) should be
6000         * displayed in video content. Text display properties are controlled by
6001         * the following settings:
6002         * <ul>
6003         * <li>{@link #ACCESSIBILITY_CAPTIONING_LOCALE}
6004         * <li>{@link #ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR}
6005         * <li>{@link #ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR}
6006         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_COLOR}
6007         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_TYPE}
6008         * <li>{@link #ACCESSIBILITY_CAPTIONING_TYPEFACE}
6009         * <li>{@link #ACCESSIBILITY_CAPTIONING_FONT_SCALE}
6010         * </ul>
6011         *
6012         * @hide
6013         */
6014        public static final String ACCESSIBILITY_CAPTIONING_ENABLED =
6015                "accessibility_captioning_enabled";
6016
6017        private static final Validator ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR =
6018                BOOLEAN_VALIDATOR;
6019
6020        /**
6021         * Setting that specifies the language for captions as a locale string,
6022         * e.g. en_US.
6023         *
6024         * @see java.util.Locale#toString
6025         * @hide
6026         */
6027        public static final String ACCESSIBILITY_CAPTIONING_LOCALE =
6028                "accessibility_captioning_locale";
6029
6030        private static final Validator ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR = LOCALE_VALIDATOR;
6031
6032        /**
6033         * Integer property that specifies the preset style for captions, one
6034         * of:
6035         * <ul>
6036         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESET_CUSTOM}
6037         * <li>a valid index of {@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESETS}
6038         * </ul>
6039         *
6040         * @see java.util.Locale#toString
6041         * @hide
6042         */
6043        public static final String ACCESSIBILITY_CAPTIONING_PRESET =
6044                "accessibility_captioning_preset";
6045
6046        private static final Validator ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR =
6047                new SettingsValidators.DiscreteValueValidator(new String[]{"-1", "0", "1", "2",
6048                        "3", "4"});
6049
6050        /**
6051         * Integer property that specifes the background color for captions as a
6052         * packed 32-bit color.
6053         *
6054         * @see android.graphics.Color#argb
6055         * @hide
6056         */
6057        public static final String ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR =
6058                "accessibility_captioning_background_color";
6059
6060        private static final Validator ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR =
6061                ANY_INTEGER_VALIDATOR;
6062
6063        /**
6064         * Integer property that specifes the foreground color for captions as a
6065         * packed 32-bit color.
6066         *
6067         * @see android.graphics.Color#argb
6068         * @hide
6069         */
6070        public static final String ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR =
6071                "accessibility_captioning_foreground_color";
6072
6073        private static final Validator ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR =
6074                ANY_INTEGER_VALIDATOR;
6075
6076        /**
6077         * Integer property that specifes the edge type for captions, one of:
6078         * <ul>
6079         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_NONE}
6080         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_OUTLINE}
6081         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_DROP_SHADOW}
6082         * </ul>
6083         *
6084         * @see #ACCESSIBILITY_CAPTIONING_EDGE_COLOR
6085         * @hide
6086         */
6087        public static final String ACCESSIBILITY_CAPTIONING_EDGE_TYPE =
6088                "accessibility_captioning_edge_type";
6089
6090        private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR =
6091                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1", "2"});
6092
6093        /**
6094         * Integer property that specifes the edge color for captions as a
6095         * packed 32-bit color.
6096         *
6097         * @see #ACCESSIBILITY_CAPTIONING_EDGE_TYPE
6098         * @see android.graphics.Color#argb
6099         * @hide
6100         */
6101        public static final String ACCESSIBILITY_CAPTIONING_EDGE_COLOR =
6102                "accessibility_captioning_edge_color";
6103
6104        private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR =
6105                ANY_INTEGER_VALIDATOR;
6106
6107        /**
6108         * Integer property that specifes the window color for captions as a
6109         * packed 32-bit color.
6110         *
6111         * @see android.graphics.Color#argb
6112         * @hide
6113         */
6114        public static final String ACCESSIBILITY_CAPTIONING_WINDOW_COLOR =
6115                "accessibility_captioning_window_color";
6116
6117        private static final Validator ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR =
6118                ANY_INTEGER_VALIDATOR;
6119
6120        /**
6121         * String property that specifies the typeface for captions, one of:
6122         * <ul>
6123         * <li>DEFAULT
6124         * <li>MONOSPACE
6125         * <li>SANS_SERIF
6126         * <li>SERIF
6127         * </ul>
6128         *
6129         * @see android.graphics.Typeface
6130         * @hide
6131         */
6132        public static final String ACCESSIBILITY_CAPTIONING_TYPEFACE =
6133                "accessibility_captioning_typeface";
6134
6135        private static final Validator ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR =
6136                new SettingsValidators.DiscreteValueValidator(new String[]{"DEFAULT",
6137                        "MONOSPACE", "SANS_SERIF", "SERIF"});
6138
6139        /**
6140         * Floating point property that specifies font scaling for captions.
6141         *
6142         * @hide
6143         */
6144        public static final String ACCESSIBILITY_CAPTIONING_FONT_SCALE =
6145                "accessibility_captioning_font_scale";
6146
6147        private static final Validator ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR =
6148                new SettingsValidators.InclusiveFloatRangeValidator(0.5f, 2.0f);
6149
6150        /**
6151         * Setting that specifies whether display color inversion is enabled.
6152         */
6153        public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED =
6154                "accessibility_display_inversion_enabled";
6155
6156        private static final Validator ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR =
6157                BOOLEAN_VALIDATOR;
6158
6159        /**
6160         * Setting that specifies whether display color space adjustment is
6161         * enabled.
6162         *
6163         * @hide
6164         */
6165        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED =
6166                "accessibility_display_daltonizer_enabled";
6167
6168        private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR =
6169                BOOLEAN_VALIDATOR;
6170
6171        /**
6172         * Integer property that specifies the type of color space adjustment to
6173         * perform. Valid values are defined in AccessibilityManager:
6174         * - AccessibilityManager.DALTONIZER_DISABLED = -1
6175         * - AccessibilityManager.DALTONIZER_SIMULATE_MONOCHROMACY = 0
6176         * - AccessibilityManager.DALTONIZER_CORRECT_DEUTERANOMALY = 12
6177         *
6178         * @hide
6179         */
6180        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER =
6181                "accessibility_display_daltonizer";
6182
6183        private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR =
6184                new SettingsValidators.DiscreteValueValidator(new String[] {"-1", "0", "12"});
6185
6186        /**
6187         * Setting that specifies whether automatic click when the mouse pointer stops moving is
6188         * enabled.
6189         *
6190         * @hide
6191         */
6192        public static final String ACCESSIBILITY_AUTOCLICK_ENABLED =
6193                "accessibility_autoclick_enabled";
6194
6195        private static final Validator ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR =
6196                BOOLEAN_VALIDATOR;
6197
6198        /**
6199         * Integer setting specifying amount of time in ms the mouse pointer has to stay still
6200         * before performing click when {@link #ACCESSIBILITY_AUTOCLICK_ENABLED} is set.
6201         *
6202         * @see #ACCESSIBILITY_AUTOCLICK_ENABLED
6203         * @hide
6204         */
6205        public static final String ACCESSIBILITY_AUTOCLICK_DELAY =
6206                "accessibility_autoclick_delay";
6207
6208        private static final Validator ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR =
6209                NON_NEGATIVE_INTEGER_VALIDATOR;
6210
6211        /**
6212         * Whether or not larger size icons are used for the pointer of mouse/trackpad for
6213         * accessibility.
6214         * (0 = false, 1 = true)
6215         * @hide
6216         */
6217        public static final String ACCESSIBILITY_LARGE_POINTER_ICON =
6218                "accessibility_large_pointer_icon";
6219
6220        private static final Validator ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR =
6221                BOOLEAN_VALIDATOR;
6222
6223        /**
6224         * The timeout for considering a press to be a long press in milliseconds.
6225         * @hide
6226         */
6227        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
6228
6229        private static final Validator LONG_PRESS_TIMEOUT_VALIDATOR =
6230                NON_NEGATIVE_INTEGER_VALIDATOR;
6231
6232        /**
6233         * The duration in milliseconds between the first tap's up event and the second tap's
6234         * down event for an interaction to be considered part of the same multi-press.
6235         * @hide
6236         */
6237        public static final String MULTI_PRESS_TIMEOUT = "multi_press_timeout";
6238
6239        /**
6240         * List of the enabled print services.
6241         *
6242         * N and beyond uses {@link #DISABLED_PRINT_SERVICES}. But this might be used in an upgrade
6243         * from pre-N.
6244         *
6245         * @hide
6246         */
6247        public static final String ENABLED_PRINT_SERVICES =
6248            "enabled_print_services";
6249
6250        /**
6251         * List of the disabled print services.
6252         *
6253         * @hide
6254         */
6255        @TestApi
6256        public static final String DISABLED_PRINT_SERVICES =
6257            "disabled_print_services";
6258
6259        /**
6260         * The saved value for WindowManagerService.setForcedDisplayDensity()
6261         * formatted as a single integer representing DPI. If unset, then use
6262         * the real display density.
6263         *
6264         * @hide
6265         */
6266        public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
6267
6268        /**
6269         * Setting to always use the default text-to-speech settings regardless
6270         * of the application settings.
6271         * 1 = override application settings,
6272         * 0 = use application settings (if specified).
6273         *
6274         * @deprecated  The value of this setting is no longer respected by
6275         * the framework text to speech APIs as of the Ice Cream Sandwich release.
6276         */
6277        @Deprecated
6278        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
6279
6280        /**
6281         * Default text-to-speech engine speech rate. 100 = 1x
6282         */
6283        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
6284
6285        private static final Validator TTS_DEFAULT_RATE_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR;
6286
6287        /**
6288         * Default text-to-speech engine pitch. 100 = 1x
6289         */
6290        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
6291
6292        private static final Validator TTS_DEFAULT_PITCH_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR;
6293
6294        /**
6295         * Default text-to-speech engine.
6296         */
6297        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
6298
6299        private static final Validator TTS_DEFAULT_SYNTH_VALIDATOR = PACKAGE_NAME_VALIDATOR;
6300
6301        /**
6302         * Default text-to-speech language.
6303         *
6304         * @deprecated this setting is no longer in use, as of the Ice Cream
6305         * Sandwich release. Apps should never need to read this setting directly,
6306         * instead can query the TextToSpeech framework classes for the default
6307         * locale. {@link TextToSpeech#getLanguage()}.
6308         */
6309        @Deprecated
6310        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
6311
6312        /**
6313         * Default text-to-speech country.
6314         *
6315         * @deprecated this setting is no longer in use, as of the Ice Cream
6316         * Sandwich release. Apps should never need to read this setting directly,
6317         * instead can query the TextToSpeech framework classes for the default
6318         * locale. {@link TextToSpeech#getLanguage()}.
6319         */
6320        @Deprecated
6321        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
6322
6323        /**
6324         * Default text-to-speech locale variant.
6325         *
6326         * @deprecated this setting is no longer in use, as of the Ice Cream
6327         * Sandwich release. Apps should never need to read this setting directly,
6328         * instead can query the TextToSpeech framework classes for the
6329         * locale that is in use {@link TextToSpeech#getLanguage()}.
6330         */
6331        @Deprecated
6332        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
6333
6334        /**
6335         * Stores the default tts locales on a per engine basis. Stored as
6336         * a comma seperated list of values, each value being of the form
6337         * {@code engine_name:locale} for example,
6338         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
6339         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
6340         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
6341         * setting directly, and can query the TextToSpeech framework classes
6342         * for the locale that is in use.
6343         *
6344         * @hide
6345         */
6346        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
6347
6348        private static final Validator TTS_DEFAULT_LOCALE_VALIDATOR = new Validator() {
6349            @Override
6350            public boolean validate(String value) {
6351                if (value == null || value.length() == 0) {
6352                    return false;
6353                }
6354                String[] ttsLocales = value.split(",");
6355                boolean valid = true;
6356                for (String ttsLocale : ttsLocales) {
6357                    String[] parts = ttsLocale.split(":");
6358                    valid |= ((parts.length == 2)
6359                            && (parts[0].length() > 0)
6360                            && ANY_STRING_VALIDATOR.validate(parts[0])
6361                            && LOCALE_VALIDATOR.validate(parts[1]));
6362                }
6363                return valid;
6364            }
6365        };
6366
6367        /**
6368         * Space delimited list of plugin packages that are enabled.
6369         */
6370        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
6371
6372        private static final Validator TTS_ENABLED_PLUGINS_VALIDATOR =
6373                new SettingsValidators.PackageNameListValidator(" ");
6374
6375        /**
6376         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
6377         * instead.
6378         */
6379        @Deprecated
6380        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
6381                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
6382
6383        private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
6384                BOOLEAN_VALIDATOR;
6385
6386        /**
6387         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
6388         * instead.
6389         */
6390        @Deprecated
6391        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
6392                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
6393
6394        private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR =
6395                NON_NEGATIVE_INTEGER_VALIDATOR;
6396
6397        /**
6398         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
6399         * instead.
6400         */
6401        @Deprecated
6402        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
6403                Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
6404
6405        private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR =
6406                NON_NEGATIVE_INTEGER_VALIDATOR;
6407
6408        /**
6409         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
6410         * instead.
6411         */
6412        @Deprecated
6413        public static final String WIFI_ON = Global.WIFI_ON;
6414
6415        /**
6416         * The acceptable packet loss percentage (range 0 - 100) before trying
6417         * another AP on the same network.
6418         * @deprecated This setting is not used.
6419         */
6420        @Deprecated
6421        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
6422                "wifi_watchdog_acceptable_packet_loss_percentage";
6423
6424        /**
6425         * The number of access points required for a network in order for the
6426         * watchdog to monitor it.
6427         * @deprecated This setting is not used.
6428         */
6429        @Deprecated
6430        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
6431
6432        /**
6433         * The delay between background checks.
6434         * @deprecated This setting is not used.
6435         */
6436        @Deprecated
6437        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
6438                "wifi_watchdog_background_check_delay_ms";
6439
6440        /**
6441         * Whether the Wi-Fi watchdog is enabled for background checking even
6442         * after it thinks the user has connected to a good access point.
6443         * @deprecated This setting is not used.
6444         */
6445        @Deprecated
6446        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
6447                "wifi_watchdog_background_check_enabled";
6448
6449        /**
6450         * The timeout for a background ping
6451         * @deprecated This setting is not used.
6452         */
6453        @Deprecated
6454        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
6455                "wifi_watchdog_background_check_timeout_ms";
6456
6457        /**
6458         * The number of initial pings to perform that *may* be ignored if they
6459         * fail. Again, if these fail, they will *not* be used in packet loss
6460         * calculation. For example, one network always seemed to time out for
6461         * the first couple pings, so this is set to 3 by default.
6462         * @deprecated This setting is not used.
6463         */
6464        @Deprecated
6465        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
6466            "wifi_watchdog_initial_ignored_ping_count";
6467
6468        /**
6469         * The maximum number of access points (per network) to attempt to test.
6470         * If this number is reached, the watchdog will no longer monitor the
6471         * initial connection state for the network. This is a safeguard for
6472         * networks containing multiple APs whose DNS does not respond to pings.
6473         * @deprecated This setting is not used.
6474         */
6475        @Deprecated
6476        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
6477
6478        /**
6479         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
6480         */
6481        @Deprecated
6482        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
6483
6484        /**
6485         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
6486         * @deprecated This setting is not used.
6487         */
6488        @Deprecated
6489        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
6490
6491        /**
6492         * The number of pings to test if an access point is a good connection.
6493         * @deprecated This setting is not used.
6494         */
6495        @Deprecated
6496        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
6497
6498        /**
6499         * The delay between pings.
6500         * @deprecated This setting is not used.
6501         */
6502        @Deprecated
6503        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
6504
6505        /**
6506         * The timeout per ping.
6507         * @deprecated This setting is not used.
6508         */
6509        @Deprecated
6510        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
6511
6512        /**
6513         * @deprecated Use
6514         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
6515         */
6516        @Deprecated
6517        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
6518
6519        /**
6520         * @deprecated Use
6521         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
6522         */
6523        @Deprecated
6524        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
6525                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
6526
6527        /**
6528         * The number of milliseconds to hold on to a PendingIntent based request. This delay gives
6529         * the receivers of the PendingIntent an opportunity to make a new network request before
6530         * the Network satisfying the request is potentially removed.
6531         *
6532         * @hide
6533         */
6534        public static final String CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS =
6535                "connectivity_release_pending_intent_delay_ms";
6536
6537        /**
6538         * Whether background data usage is allowed.
6539         *
6540         * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH},
6541         *             availability of background data depends on several
6542         *             combined factors. When background data is unavailable,
6543         *             {@link ConnectivityManager#getActiveNetworkInfo()} will
6544         *             now appear disconnected.
6545         */
6546        @Deprecated
6547        public static final String BACKGROUND_DATA = "background_data";
6548
6549        /**
6550         * Origins for which browsers should allow geolocation by default.
6551         * The value is a space-separated list of origins.
6552         */
6553        public static final String ALLOWED_GEOLOCATION_ORIGINS
6554                = "allowed_geolocation_origins";
6555
6556        /**
6557         * The preferred TTY mode     0 = TTy Off, CDMA default
6558         *                            1 = TTY Full
6559         *                            2 = TTY HCO
6560         *                            3 = TTY VCO
6561         * @hide
6562         */
6563        public static final String PREFERRED_TTY_MODE =
6564                "preferred_tty_mode";
6565
6566        private static final Validator PREFERRED_TTY_MODE_VALIDATOR =
6567                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1", "2", "3"});
6568
6569        /**
6570         * Whether the enhanced voice privacy mode is enabled.
6571         * 0 = normal voice privacy
6572         * 1 = enhanced voice privacy
6573         * @hide
6574         */
6575        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
6576
6577        private static final Validator ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6578
6579        /**
6580         * Whether the TTY mode mode is enabled.
6581         * 0 = disabled
6582         * 1 = enabled
6583         * @hide
6584         */
6585        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
6586
6587        private static final Validator TTY_MODE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6588
6589        /**
6590         * Controls whether settings backup is enabled.
6591         * Type: int ( 0 = disabled, 1 = enabled )
6592         * @hide
6593         */
6594        public static final String BACKUP_ENABLED = "backup_enabled";
6595
6596        /**
6597         * Controls whether application data is automatically restored from backup
6598         * at install time.
6599         * Type: int ( 0 = disabled, 1 = enabled )
6600         * @hide
6601         */
6602        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
6603
6604        /**
6605         * Indicates whether settings backup has been fully provisioned.
6606         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
6607         * @hide
6608         */
6609        public static final String BACKUP_PROVISIONED = "backup_provisioned";
6610
6611        /**
6612         * Component of the transport to use for backup/restore.
6613         * @hide
6614         */
6615        public static final String BACKUP_TRANSPORT = "backup_transport";
6616
6617        /**
6618         * Version for which the setup wizard was last shown.  Bumped for
6619         * each release when there is new setup information to show.
6620         * @hide
6621         */
6622        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
6623
6624        /**
6625         * The interval in milliseconds after which Wi-Fi is considered idle.
6626         * When idle, it is possible for the device to be switched from Wi-Fi to
6627         * the mobile data network.
6628         * @hide
6629         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
6630         * instead.
6631         */
6632        @Deprecated
6633        public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
6634
6635        /**
6636         * The global search provider chosen by the user (if multiple global
6637         * search providers are installed). This will be the provider returned
6638         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
6639         * installed. This setting is stored as a flattened component name as
6640         * per {@link ComponentName#flattenToString()}.
6641         *
6642         * @hide
6643         */
6644        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
6645                "search_global_search_activity";
6646
6647        /**
6648         * The number of promoted sources in GlobalSearch.
6649         * @hide
6650         */
6651        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
6652        /**
6653         * The maximum number of suggestions returned by GlobalSearch.
6654         * @hide
6655         */
6656        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
6657        /**
6658         * The number of suggestions GlobalSearch will ask each non-web search source for.
6659         * @hide
6660         */
6661        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
6662        /**
6663         * The number of suggestions the GlobalSearch will ask the web search source for.
6664         * @hide
6665         */
6666        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
6667                "search_web_results_override_limit";
6668        /**
6669         * The number of milliseconds that GlobalSearch will wait for suggestions from
6670         * promoted sources before continuing with all other sources.
6671         * @hide
6672         */
6673        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
6674                "search_promoted_source_deadline_millis";
6675        /**
6676         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
6677         * @hide
6678         */
6679        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
6680        /**
6681         * The maximum number of milliseconds that GlobalSearch shows the previous results
6682         * after receiving a new query.
6683         * @hide
6684         */
6685        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
6686        /**
6687         * The maximum age of log data used for shortcuts in GlobalSearch.
6688         * @hide
6689         */
6690        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
6691        /**
6692         * The maximum age of log data used for source ranking in GlobalSearch.
6693         * @hide
6694         */
6695        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
6696                "search_max_source_event_age_millis";
6697        /**
6698         * The minimum number of impressions needed to rank a source in GlobalSearch.
6699         * @hide
6700         */
6701        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
6702                "search_min_impressions_for_source_ranking";
6703        /**
6704         * The minimum number of clicks needed to rank a source in GlobalSearch.
6705         * @hide
6706         */
6707        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
6708                "search_min_clicks_for_source_ranking";
6709        /**
6710         * The maximum number of shortcuts shown by GlobalSearch.
6711         * @hide
6712         */
6713        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
6714        /**
6715         * The size of the core thread pool for suggestion queries in GlobalSearch.
6716         * @hide
6717         */
6718        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
6719                "search_query_thread_core_pool_size";
6720        /**
6721         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
6722         * @hide
6723         */
6724        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
6725                "search_query_thread_max_pool_size";
6726        /**
6727         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
6728         * @hide
6729         */
6730        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
6731                "search_shortcut_refresh_core_pool_size";
6732        /**
6733         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
6734         * @hide
6735         */
6736        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
6737                "search_shortcut_refresh_max_pool_size";
6738        /**
6739         * The maximun time that excess threads in the GlobalSeach thread pools will
6740         * wait before terminating.
6741         * @hide
6742         */
6743        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
6744                "search_thread_keepalive_seconds";
6745        /**
6746         * The maximum number of concurrent suggestion queries to each source.
6747         * @hide
6748         */
6749        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
6750                "search_per_source_concurrent_query_limit";
6751
6752        /**
6753         * Whether or not alert sounds are played on StorageManagerService events.
6754         * (0 = false, 1 = true)
6755         * @hide
6756         */
6757        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
6758
6759        private static final Validator MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR = BOOLEAN_VALIDATOR;
6760
6761        /**
6762         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
6763         * @hide
6764         */
6765        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
6766
6767        private static final Validator MOUNT_UMS_AUTOSTART_VALIDATOR = BOOLEAN_VALIDATOR;
6768
6769        /**
6770         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
6771         * @hide
6772         */
6773        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
6774
6775        private static final Validator MOUNT_UMS_PROMPT_VALIDATOR = BOOLEAN_VALIDATOR;
6776
6777        /**
6778         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
6779         * @hide
6780         */
6781        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
6782
6783        private static final Validator MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6784
6785        /**
6786         * If nonzero, ANRs in invisible background processes bring up a dialog.
6787         * Otherwise, the process will be silently killed.
6788         *
6789         * Also prevents ANRs and crash dialogs from being suppressed.
6790         * @hide
6791         */
6792        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
6793
6794        /**
6795         * If nonzero, crashes in foreground processes will bring up a dialog.
6796         * Otherwise, the process will be silently killed.
6797         * @hide
6798         */
6799        public static final String SHOW_FIRST_CRASH_DIALOG_DEV_OPTION =
6800                "show_first_crash_dialog_dev_option";
6801
6802        private static final Validator SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR =
6803                BOOLEAN_VALIDATOR;
6804
6805        /**
6806         * The {@link ComponentName} string of the service to be used as the voice recognition
6807         * service.
6808         *
6809         * @hide
6810         */
6811        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
6812
6813        /**
6814         * Stores whether an user has consented to have apps verified through PAM.
6815         * The value is boolean (1 or 0).
6816         *
6817         * @hide
6818         */
6819        public static final String PACKAGE_VERIFIER_USER_CONSENT =
6820            "package_verifier_user_consent";
6821
6822        /**
6823         * The {@link ComponentName} string of the selected spell checker service which is
6824         * one of the services managed by the text service manager.
6825         *
6826         * @hide
6827         */
6828        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
6829
6830        private static final Validator SELECTED_SPELL_CHECKER_VALIDATOR = COMPONENT_NAME_VALIDATOR;
6831
6832        /**
6833         * The {@link ComponentName} string of the selected subtype of the selected spell checker
6834         * service which is one of the services managed by the text service manager.
6835         *
6836         * @hide
6837         */
6838        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
6839                "selected_spell_checker_subtype";
6840
6841        private static final Validator SELECTED_SPELL_CHECKER_SUBTYPE_VALIDATOR =
6842                COMPONENT_NAME_VALIDATOR;
6843
6844        /**
6845         * Whether spell checker is enabled or not.
6846         *
6847         * @hide
6848         */
6849        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
6850
6851        private static final Validator SPELL_CHECKER_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6852
6853        /**
6854         * What happens when the user presses the Power button while in-call
6855         * and the screen is on.<br/>
6856         * <b>Values:</b><br/>
6857         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
6858         * 2 - The Power button hangs up the current call.<br/>
6859         *
6860         * @hide
6861         */
6862        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
6863
6864        private static final Validator INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR =
6865                new SettingsValidators.DiscreteValueValidator(new String[]{"1", "2"});
6866
6867        /**
6868         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
6869         * @hide
6870         */
6871        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
6872
6873        /**
6874         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
6875         * @hide
6876         */
6877        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
6878
6879        /**
6880         * INCALL_POWER_BUTTON_BEHAVIOR default value.
6881         * @hide
6882         */
6883        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
6884                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
6885
6886        /**
6887         * What happens when the user presses the Back button while in-call
6888         * and the screen is on.<br/>
6889         * <b>Values:</b><br/>
6890         * 0 - The Back buttons does nothing different.<br/>
6891         * 1 - The Back button hangs up the current call.<br/>
6892         *
6893         * @hide
6894         */
6895        public static final String INCALL_BACK_BUTTON_BEHAVIOR = "incall_back_button_behavior";
6896
6897        /**
6898         * INCALL_BACK_BUTTON_BEHAVIOR value for no action.
6899         * @hide
6900         */
6901        public static final int INCALL_BACK_BUTTON_BEHAVIOR_NONE = 0x0;
6902
6903        /**
6904         * INCALL_BACK_BUTTON_BEHAVIOR value for "hang up".
6905         * @hide
6906         */
6907        public static final int INCALL_BACK_BUTTON_BEHAVIOR_HANGUP = 0x1;
6908
6909        /**
6910         * INCALL_POWER_BUTTON_BEHAVIOR default value.
6911         * @hide
6912         */
6913        public static final int INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT =
6914                INCALL_BACK_BUTTON_BEHAVIOR_NONE;
6915
6916        /**
6917         * Whether the device should wake when the wake gesture sensor detects motion.
6918         * @hide
6919         */
6920        public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";
6921
6922        private static final Validator WAKE_GESTURE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6923
6924        /**
6925         * Whether the device should doze if configured.
6926         * @hide
6927         */
6928        public static final String DOZE_ENABLED = "doze_enabled";
6929
6930        private static final Validator DOZE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6931
6932        /**
6933         * Whether doze should be always on.
6934         * @hide
6935         */
6936        public static final String DOZE_ALWAYS_ON = "doze_always_on";
6937
6938        /**
6939         * Whether the device should pulse on pick up gesture.
6940         * @hide
6941         */
6942        public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
6943
6944        private static final Validator DOZE_PULSE_ON_PICK_UP_VALIDATOR = BOOLEAN_VALIDATOR;
6945
6946        /**
6947         * Whether the device should pulse on long press gesture.
6948         * @hide
6949         */
6950        public static final String DOZE_PULSE_ON_LONG_PRESS = "doze_pulse_on_long_press";
6951
6952        /**
6953         * Whether the device should pulse on double tap gesture.
6954         * @hide
6955         */
6956        public static final String DOZE_PULSE_ON_DOUBLE_TAP = "doze_pulse_on_double_tap";
6957
6958        private static final Validator DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR = BOOLEAN_VALIDATOR;
6959
6960        /**
6961         * The current night mode that has been selected by the user.  Owned
6962         * and controlled by UiModeManagerService.  Constants are as per
6963         * UiModeManager.
6964         * @hide
6965         */
6966        public static final String UI_NIGHT_MODE = "ui_night_mode";
6967
6968        /**
6969         * Whether screensavers are enabled.
6970         * @hide
6971         */
6972        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
6973
6974        private static final Validator SCREENSAVER_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6975
6976        /**
6977         * The user's chosen screensaver components.
6978         *
6979         * These will be launched by the PhoneWindowManager after a timeout when not on
6980         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
6981         * @hide
6982         */
6983        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
6984
6985        private static final Validator SCREENSAVER_COMPONENTS_VALIDATOR =
6986                new SettingsValidators.ComponentNameListValidator(",");
6987
6988        /**
6989         * If screensavers are enabled, whether the screensaver should be automatically launched
6990         * when the device is inserted into a (desk) dock.
6991         * @hide
6992         */
6993        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
6994
6995        private static final Validator SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR = BOOLEAN_VALIDATOR;
6996
6997        /**
6998         * If screensavers are enabled, whether the screensaver should be automatically launched
6999         * when the screen times out when not on battery.
7000         * @hide
7001         */
7002        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
7003
7004        private static final Validator SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR = BOOLEAN_VALIDATOR;
7005
7006        /**
7007         * If screensavers are enabled, the default screensaver component.
7008         * @hide
7009         */
7010        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
7011
7012        /**
7013         * The default NFC payment component
7014         * @hide
7015         */
7016        public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
7017
7018        private static final Validator NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR =
7019                COMPONENT_NAME_VALIDATOR;
7020
7021        /**
7022         * Whether NFC payment is handled by the foreground application or a default.
7023         * @hide
7024         */
7025        public static final String NFC_PAYMENT_FOREGROUND = "nfc_payment_foreground";
7026
7027        /**
7028         * Specifies the package name currently configured to be the primary sms application
7029         * @hide
7030         */
7031        public static final String SMS_DEFAULT_APPLICATION = "sms_default_application";
7032
7033        /**
7034         * Specifies the package name currently configured to be the default dialer application
7035         * @hide
7036         */
7037        public static final String DIALER_DEFAULT_APPLICATION = "dialer_default_application";
7038
7039        /**
7040         * Specifies the package name currently configured to be the emergency assistance application
7041         *
7042         * @see android.telephony.TelephonyManager#ACTION_EMERGENCY_ASSISTANCE
7043         *
7044         * @hide
7045         */
7046        public static final String EMERGENCY_ASSISTANCE_APPLICATION = "emergency_assistance_application";
7047
7048        /**
7049         * Specifies whether the current app context on scren (assist data) will be sent to the
7050         * assist application (active voice interaction service).
7051         *
7052         * @hide
7053         */
7054        public static final String ASSIST_STRUCTURE_ENABLED = "assist_structure_enabled";
7055
7056        /**
7057         * Specifies whether a screenshot of the screen contents will be sent to the assist
7058         * application (active voice interaction service).
7059         *
7060         * @hide
7061         */
7062        public static final String ASSIST_SCREENSHOT_ENABLED = "assist_screenshot_enabled";
7063
7064        /**
7065         * Specifies whether the screen will show an animation if screen contents are sent to the
7066         * assist application (active voice interaction service).
7067         *
7068         * Note that the disclosure will be forced for third-party assistants or if the device
7069         * does not support disabling it.
7070         *
7071         * @hide
7072         */
7073        public static final String ASSIST_DISCLOSURE_ENABLED = "assist_disclosure_enabled";
7074
7075        /**
7076         * Control if rotation suggestions are sent to System UI when in rotation locked mode.
7077         * Done to enable screen rotation while the the screen rotation is locked. Enabling will
7078         * poll the accelerometer in rotation locked mode.
7079         *
7080         * If 0, then rotation suggestions are not sent to System UI. If 1, suggestions are sent.
7081         *
7082         * @hide
7083         */
7084
7085        public static final String SHOW_ROTATION_SUGGESTIONS = "show_rotation_suggestions";
7086
7087        /**
7088         * The disabled state of SHOW_ROTATION_SUGGESTIONS.
7089         * @hide
7090         */
7091        public static final int SHOW_ROTATION_SUGGESTIONS_DISABLED = 0x0;
7092
7093        /**
7094         * The enabled state of SHOW_ROTATION_SUGGESTIONS.
7095         * @hide
7096         */
7097        public static final int SHOW_ROTATION_SUGGESTIONS_ENABLED = 0x1;
7098
7099        /**
7100         * The default state of SHOW_ROTATION_SUGGESTIONS.
7101         * @hide
7102         */
7103        public static final int SHOW_ROTATION_SUGGESTIONS_DEFAULT =
7104                SHOW_ROTATION_SUGGESTIONS_ENABLED;
7105
7106        /**
7107         * The number of accepted rotation suggestions. Used to determine if the user has been
7108         * introduced to rotation suggestions.
7109         * @hide
7110         */
7111        public static final String NUM_ROTATION_SUGGESTIONS_ACCEPTED =
7112                "num_rotation_suggestions_accepted";
7113
7114        /**
7115         * Read only list of the service components that the current user has explicitly allowed to
7116         * see and assist with all of the user's notifications.
7117         *
7118         * @deprecated Use
7119         * {@link NotificationManager#isNotificationListenerAccessGranted(ComponentName)}.
7120         * @hide
7121         */
7122        @Deprecated
7123        public static final String ENABLED_NOTIFICATION_ASSISTANT =
7124                "enabled_notification_assistant";
7125
7126        private static final Validator ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR =
7127                new SettingsValidators.ComponentNameListValidator(":");
7128
7129        /**
7130         * Read only list of the service components that the current user has explicitly allowed to
7131         * see all of the user's notifications, separated by ':'.
7132         *
7133         * @hide
7134         * @deprecated Use
7135         * {@link NotificationManager#isNotificationAssistantAccessGranted(ComponentName)}.
7136         */
7137        @Deprecated
7138        public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
7139
7140        private static final Validator ENABLED_NOTIFICATION_LISTENERS_VALIDATOR =
7141                new SettingsValidators.ComponentNameListValidator(":");
7142
7143        /**
7144         * Read only list of the packages that the current user has explicitly allowed to
7145         * manage do not disturb, separated by ':'.
7146         *
7147         * @deprecated Use {@link NotificationManager#isNotificationPolicyAccessGranted()}.
7148         * @hide
7149         */
7150        @Deprecated
7151        @TestApi
7152        public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES =
7153                "enabled_notification_policy_access_packages";
7154
7155        private static final Validator ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR =
7156                new SettingsValidators.PackageNameListValidator(":");
7157
7158        /**
7159         * Defines whether managed profile ringtones should be synced from it's parent profile
7160         * <p>
7161         * 0 = ringtones are not synced
7162         * 1 = ringtones are synced from the profile's parent (default)
7163         * <p>
7164         * This value is only used for managed profiles.
7165         * @hide
7166         */
7167        @TestApi
7168        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
7169        public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
7170
7171        private static final Validator SYNC_PARENT_SOUNDS_VALIDATOR = BOOLEAN_VALIDATOR;
7172
7173        /** @hide */
7174        public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
7175
7176        /**
7177         * This is the query URI for finding a print service to install.
7178         *
7179         * @hide
7180         */
7181        public static final String PRINT_SERVICE_SEARCH_URI = "print_service_search_uri";
7182
7183        /**
7184         * This is the query URI for finding a NFC payment service to install.
7185         *
7186         * @hide
7187         */
7188        public static final String PAYMENT_SERVICE_SEARCH_URI = "payment_service_search_uri";
7189
7190        /**
7191         * This is the query URI for finding a auto fill service to install.
7192         *
7193         * @hide
7194         */
7195        public static final String AUTOFILL_SERVICE_SEARCH_URI = "autofill_service_search_uri";
7196
7197        /**
7198         * If enabled, apps should try to skip any introductory hints on first launch. This might
7199         * apply to users that are already familiar with the environment or temporary users.
7200         * <p>
7201         * Type : int (0 to show hints, 1 to skip showing hints)
7202         */
7203        public static final String SKIP_FIRST_USE_HINTS = "skip_first_use_hints";
7204
7205        /**
7206         * Persisted playback time after a user confirmation of an unsafe volume level.
7207         *
7208         * @hide
7209         */
7210        public static final String UNSAFE_VOLUME_MUSIC_ACTIVE_MS = "unsafe_volume_music_active_ms";
7211
7212        /**
7213         * This preference enables notification display on the lockscreen.
7214         * @hide
7215         */
7216        public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
7217                "lock_screen_show_notifications";
7218
7219        /**
7220         * List of TV inputs that are currently hidden. This is a string
7221         * containing the IDs of all hidden TV inputs. Each ID is encoded by
7222         * {@link android.net.Uri#encode(String)} and separated by ':'.
7223         * @hide
7224         */
7225        public static final String TV_INPUT_HIDDEN_INPUTS = "tv_input_hidden_inputs";
7226
7227        /**
7228         * List of custom TV input labels. This is a string containing <TV input id, custom name>
7229         * pairs. TV input id and custom name are encoded by {@link android.net.Uri#encode(String)}
7230         * and separated by ','. Each pair is separated by ':'.
7231         * @hide
7232         */
7233        public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels";
7234
7235        /**
7236         * Whether automatic routing of system audio to USB audio peripheral is disabled.
7237         * The value is boolean (1 or 0), where 1 means automatic routing is disabled,
7238         * and 0 means automatic routing is enabled.
7239         *
7240         * @hide
7241         */
7242        public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
7243                "usb_audio_automatic_routing_disabled";
7244
7245        /**
7246         * The timeout in milliseconds before the device fully goes to sleep after
7247         * a period of inactivity.  This value sets an upper bound on how long the device
7248         * will stay awake or dreaming without user activity.  It should generally
7249         * be longer than {@link Settings.System#SCREEN_OFF_TIMEOUT} as otherwise the device
7250         * will sleep before it ever has a chance to dream.
7251         * <p>
7252         * Use -1 to disable this timeout.
7253         * </p>
7254         *
7255         * @hide
7256         */
7257        public static final String SLEEP_TIMEOUT = "sleep_timeout";
7258
7259        private static final Validator SLEEP_TIMEOUT_VALIDATOR =
7260                new SettingsValidators.InclusiveIntegerRangeValidator(-1, Integer.MAX_VALUE);
7261
7262        /**
7263         * Controls whether double tap to wake is enabled.
7264         * @hide
7265         */
7266        public static final String DOUBLE_TAP_TO_WAKE = "double_tap_to_wake";
7267
7268        private static final Validator DOUBLE_TAP_TO_WAKE_VALIDATOR = BOOLEAN_VALIDATOR;
7269
7270        /**
7271         * The current assistant component. It could be a voice interaction service,
7272         * or an activity that handles ACTION_ASSIST, or empty which means using the default
7273         * handling.
7274         *
7275         * @hide
7276         */
7277        public static final String ASSISTANT = "assistant";
7278
7279        /**
7280         * Whether the camera launch gesture should be disabled.
7281         *
7282         * @hide
7283         */
7284        public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled";
7285
7286        private static final Validator CAMERA_GESTURE_DISABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7287
7288        /**
7289         * Whether the camera launch gesture to double tap the power button when the screen is off
7290         * should be disabled.
7291         *
7292         * @hide
7293         */
7294        public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
7295                "camera_double_tap_power_gesture_disabled";
7296
7297        private static final Validator CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR =
7298                BOOLEAN_VALIDATOR;
7299
7300        /**
7301         * Whether the camera double twist gesture to flip between front and back mode should be
7302         * enabled.
7303         *
7304         * @hide
7305         */
7306        public static final String CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED =
7307                "camera_double_twist_to_flip_enabled";
7308
7309        private static final Validator CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR =
7310                BOOLEAN_VALIDATOR;
7311
7312        /**
7313         * Whether or not the smart camera lift trigger that launches the camera when the user moves
7314         * the phone into a position for taking photos should be enabled.
7315         *
7316         * @hide
7317         */
7318        public static final String CAMERA_LIFT_TRIGGER_ENABLED = "camera_lift_trigger_enabled";
7319
7320        /**
7321         * The default enable state of the camera lift trigger.
7322         *
7323         * @hide
7324         */
7325        public static final int CAMERA_LIFT_TRIGGER_ENABLED_DEFAULT = 1;
7326
7327        /**
7328         * Whether the assist gesture should be enabled.
7329         *
7330         * @hide
7331         */
7332        public static final String ASSIST_GESTURE_ENABLED = "assist_gesture_enabled";
7333
7334        private static final Validator ASSIST_GESTURE_ENABLED_VALIDATOR =
7335                BOOLEAN_VALIDATOR;
7336
7337        /**
7338         * Sensitivity control for the assist gesture.
7339         *
7340         * @hide
7341         */
7342        public static final String ASSIST_GESTURE_SENSITIVITY = "assist_gesture_sensitivity";
7343
7344        private static final Validator ASSIST_GESTURE_SENSITIVITY_VALIDATOR =
7345                new SettingsValidators.InclusiveFloatRangeValidator(0.0f, 1.0f);
7346
7347        /**
7348         * Whether the assist gesture should silence alerts.
7349         *
7350         * @hide
7351         */
7352        public static final String ASSIST_GESTURE_SILENCE_ALERTS_ENABLED =
7353                "assist_gesture_silence_alerts_enabled";
7354
7355        private static final Validator ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR =
7356                BOOLEAN_VALIDATOR;
7357
7358        /**
7359         * Whether the assist gesture should wake the phone.
7360         *
7361         * @hide
7362         */
7363        public static final String ASSIST_GESTURE_WAKE_ENABLED =
7364                "assist_gesture_wake_enabled";
7365
7366        private static final Validator ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR =
7367                BOOLEAN_VALIDATOR;
7368
7369        /**
7370         * Whether Assist Gesture Deferred Setup has been completed
7371         *
7372         * @hide
7373         */
7374        public static final String ASSIST_GESTURE_SETUP_COMPLETE = "assist_gesture_setup_complete";
7375
7376        private static final Validator ASSIST_GESTURE_SETUP_COMPLETE_VALIDATOR = BOOLEAN_VALIDATOR;
7377
7378        /**
7379         * Control whether Night display is currently activated.
7380         * @hide
7381         */
7382        public static final String NIGHT_DISPLAY_ACTIVATED = "night_display_activated";
7383
7384        /**
7385         * Control whether Night display will automatically activate/deactivate.
7386         * @hide
7387         */
7388        public static final String NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode";
7389
7390        private static final Validator NIGHT_DISPLAY_AUTO_MODE_VALIDATOR =
7391                new SettingsValidators.InclusiveIntegerRangeValidator(0, 2);
7392
7393        /**
7394         * Control the color temperature of Night Display, represented in Kelvin.
7395         * @hide
7396         */
7397        public static final String NIGHT_DISPLAY_COLOR_TEMPERATURE =
7398                "night_display_color_temperature";
7399
7400        private static final Validator NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR =
7401                NON_NEGATIVE_INTEGER_VALIDATOR;
7402
7403        /**
7404         * Custom time when Night display is scheduled to activate.
7405         * Represented as milliseconds from midnight (e.g. 79200000 == 10pm).
7406         * @hide
7407         */
7408        public static final String NIGHT_DISPLAY_CUSTOM_START_TIME =
7409                "night_display_custom_start_time";
7410
7411        private static final Validator NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR =
7412                NON_NEGATIVE_INTEGER_VALIDATOR;
7413
7414        /**
7415         * Custom time when Night display is scheduled to deactivate.
7416         * Represented as milliseconds from midnight (e.g. 21600000 == 6am).
7417         * @hide
7418         */
7419        public static final String NIGHT_DISPLAY_CUSTOM_END_TIME = "night_display_custom_end_time";
7420
7421        private static final Validator NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR =
7422                NON_NEGATIVE_INTEGER_VALIDATOR;
7423
7424        /**
7425         * A String representing the LocalDateTime when Night display was last activated. Use to
7426         * decide whether to apply the current activated state after a reboot or user change. In
7427         * legacy cases, this is represented by the time in milliseconds (since epoch).
7428         * @hide
7429         */
7430        public static final String NIGHT_DISPLAY_LAST_ACTIVATED_TIME =
7431                "night_display_last_activated_time";
7432
7433        /**
7434         * Names of the service components that the current user has explicitly allowed to
7435         * be a VR mode listener, separated by ':'.
7436         *
7437         * @hide
7438         */
7439        public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
7440
7441        private static final Validator ENABLED_VR_LISTENERS_VALIDATOR =
7442                new SettingsValidators.ComponentNameListValidator(":");
7443
7444        /**
7445         * Behavior of the display while in VR mode.
7446         *
7447         * One of {@link #VR_DISPLAY_MODE_LOW_PERSISTENCE} or {@link #VR_DISPLAY_MODE_OFF}.
7448         *
7449         * @hide
7450         */
7451        public static final String VR_DISPLAY_MODE = "vr_display_mode";
7452
7453        private static final Validator VR_DISPLAY_MODE_VALIDATOR =
7454                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1"});
7455
7456        /**
7457         * Lower the display persistence while the system is in VR mode.
7458         *
7459         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
7460         *
7461         * @hide.
7462         */
7463        public static final int VR_DISPLAY_MODE_LOW_PERSISTENCE = 0;
7464
7465        /**
7466         * Do not alter the display persistence while the system is in VR mode.
7467         *
7468         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
7469         *
7470         * @hide.
7471         */
7472        public static final int VR_DISPLAY_MODE_OFF = 1;
7473
7474        /**
7475         * Whether CarrierAppUtils#disableCarrierAppsUntilPrivileged has been executed at least
7476         * once.
7477         *
7478         * <p>This is used to ensure that we only take one pass which will disable apps that are not
7479         * privileged (if any). From then on, we only want to enable apps (when a matching SIM is
7480         * inserted), to avoid disabling an app that the user might actively be using.
7481         *
7482         * <p>Will be set to 1 once executed.
7483         *
7484         * @hide
7485         */
7486        public static final String CARRIER_APPS_HANDLED = "carrier_apps_handled";
7487
7488        /**
7489         * Whether parent user can access remote contact in managed profile.
7490         *
7491         * @hide
7492         */
7493        public static final String MANAGED_PROFILE_CONTACT_REMOTE_SEARCH =
7494                "managed_profile_contact_remote_search";
7495
7496        /**
7497         * Whether or not the automatic storage manager is enabled and should run on the device.
7498         *
7499         * @hide
7500         */
7501        public static final String AUTOMATIC_STORAGE_MANAGER_ENABLED =
7502                "automatic_storage_manager_enabled";
7503
7504        /**
7505         * How many days of information for the automatic storage manager to retain on the device.
7506         *
7507         * @hide
7508         */
7509        public static final String AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN =
7510                "automatic_storage_manager_days_to_retain";
7511
7512        private static final Validator AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR =
7513                NON_NEGATIVE_INTEGER_VALIDATOR;
7514
7515        /**
7516         * Default number of days of information for the automatic storage manager to retain.
7517         *
7518         * @hide
7519         */
7520        public static final int AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT = 90;
7521
7522        /**
7523         * How many bytes the automatic storage manager has cleared out.
7524         *
7525         * @hide
7526         */
7527        public static final String AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED =
7528                "automatic_storage_manager_bytes_cleared";
7529
7530
7531        /**
7532         * Last run time for the automatic storage manager.
7533         *
7534         * @hide
7535         */
7536        public static final String AUTOMATIC_STORAGE_MANAGER_LAST_RUN =
7537                "automatic_storage_manager_last_run";
7538
7539        /**
7540         * If the automatic storage manager has been disabled by policy. Note that this doesn't
7541         * mean that the automatic storage manager is prevented from being re-enabled -- this only
7542         * means that it was turned off by policy at least once.
7543         *
7544         * @hide
7545         */
7546        public static final String AUTOMATIC_STORAGE_MANAGER_TURNED_OFF_BY_POLICY =
7547                "automatic_storage_manager_turned_off_by_policy";
7548
7549        /**
7550         * Whether SystemUI navigation keys is enabled.
7551         * @hide
7552         */
7553        public static final String SYSTEM_NAVIGATION_KEYS_ENABLED =
7554                "system_navigation_keys_enabled";
7555
7556        private static final Validator SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7557
7558        /**
7559         * Holds comma separated list of ordering of QS tiles.
7560         * @hide
7561         */
7562        public static final String QS_TILES = "sysui_qs_tiles";
7563
7564        private static final Validator QS_TILES_VALIDATOR = new Validator() {
7565            @Override
7566            public boolean validate(String value) {
7567                if (value == null) {
7568                    return false;
7569                }
7570                String[] tiles = value.split(",");
7571                boolean valid = true;
7572                for (String tile : tiles) {
7573                    // tile can be any non-empty string as specified by OEM
7574                    valid |= ((tile.length() > 0) && ANY_STRING_VALIDATOR.validate(tile));
7575                }
7576                return valid;
7577            }
7578        };
7579
7580        /**
7581         * Specifies whether the web action API is enabled.
7582         *
7583         * @hide
7584         */
7585        @SystemApi
7586        public static final String INSTANT_APPS_ENABLED = "instant_apps_enabled";
7587
7588        /**
7589         * Has this pairable device been paired or upgraded from a previously paired system.
7590         * @hide
7591         */
7592        public static final String DEVICE_PAIRED = "device_paired";
7593
7594        /**
7595         * Integer state indicating whether package verifier is enabled.
7596         * TODO(b/34259924): Remove this setting.
7597         *
7598         * @hide
7599         */
7600        public static final String PACKAGE_VERIFIER_STATE = "package_verifier_state";
7601
7602        /**
7603         * Specifies additional package name for broadcasting the CMAS messages.
7604         * @hide
7605         */
7606        public static final String CMAS_ADDITIONAL_BROADCAST_PKG = "cmas_additional_broadcast_pkg";
7607
7608        /**
7609         * Whether the launcher should show any notification badges.
7610         * The value is boolean (1 or 0).
7611         * @hide
7612         */
7613        public static final String NOTIFICATION_BADGING = "notification_badging";
7614
7615        private static final Validator NOTIFICATION_BADGING_VALIDATOR = BOOLEAN_VALIDATOR;
7616
7617        /**
7618         * Comma separated list of QS tiles that have been auto-added already.
7619         * @hide
7620         */
7621        public static final String QS_AUTO_ADDED_TILES = "qs_auto_tiles";
7622
7623        private static final Validator QS_AUTO_ADDED_TILES_VALIDATOR = new Validator() {
7624            @Override
7625            public boolean validate(String value) {
7626                if (value == null) {
7627                    return false;
7628                }
7629                String[] tiles = value.split(",");
7630                boolean valid = true;
7631                for (String tile : tiles) {
7632                    // tile can be any non-empty string as specified by OEM
7633                    valid |= ((tile.length() > 0) && ANY_STRING_VALIDATOR.validate(tile));
7634                }
7635                return valid;
7636            }
7637        };
7638
7639        /**
7640         * Whether the Lockdown button should be shown in the power menu.
7641         * @hide
7642         */
7643        public static final String LOCKDOWN_IN_POWER_MENU = "lockdown_in_power_menu";
7644
7645        private static final Validator LOCKDOWN_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
7646
7647        /**
7648         * Backup manager behavioral parameters.
7649         * This is encoded as a key=value list, separated by commas. Ex:
7650         *
7651         * "key_value_backup_interval_milliseconds=14400000,key_value_backup_require_charging=true"
7652         *
7653         * The following keys are supported:
7654         *
7655         * <pre>
7656         * key_value_backup_interval_milliseconds  (long)
7657         * key_value_backup_fuzz_milliseconds      (long)
7658         * key_value_backup_require_charging       (boolean)
7659         * key_value_backup_required_network_type  (int)
7660         * full_backup_interval_milliseconds       (long)
7661         * full_backup_require_charging            (boolean)
7662         * full_backup_required_network_type       (int)
7663         * backup_finished_notification_receivers  (String[])
7664         * </pre>
7665         *
7666         * backup_finished_notification_receivers uses ":" as delimeter for values.
7667         *
7668         * <p>
7669         * Type: string
7670         * @hide
7671         */
7672        public static final String BACKUP_MANAGER_CONSTANTS = "backup_manager_constants";
7673
7674
7675        /**
7676         * Local transport parameters so we can configure it for tests.
7677         * This is encoded as a key=value list, separated by commas.
7678         *
7679         * The following keys are supported:
7680         *
7681         * <pre>
7682         * fake_encryption_flag  (boolean)
7683         * </pre>
7684         *
7685         * <p>
7686         * Type: string
7687         * @hide
7688         */
7689        public static final String BACKUP_LOCAL_TRANSPORT_PARAMETERS =
7690                "backup_local_transport_parameters";
7691
7692        /**
7693         * Flag to set if the system should predictively attempt to re-enable Bluetooth while
7694         * the user is driving.
7695         * @hide
7696         */
7697        public static final String BLUETOOTH_ON_WHILE_DRIVING = "bluetooth_on_while_driving";
7698
7699        /**
7700         * This are the settings to be backed up.
7701         *
7702         * NOTE: Settings are backed up and restored in the order they appear
7703         *       in this array. If you have one setting depending on another,
7704         *       make sure that they are ordered appropriately.
7705         *
7706         * @hide
7707         */
7708        public static final String[] SETTINGS_TO_BACKUP = {
7709            BUGREPORT_IN_POWER_MENU,                            // moved to global
7710            ALLOW_MOCK_LOCATION,
7711            USB_MASS_STORAGE_ENABLED,                           // moved to global
7712            ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
7713            ACCESSIBILITY_DISPLAY_DALTONIZER,
7714            ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
7715            ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
7716            ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
7717            AUTOFILL_SERVICE,
7718            ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
7719            ENABLED_ACCESSIBILITY_SERVICES,
7720            ENABLED_VR_LISTENERS,
7721            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
7722            TOUCH_EXPLORATION_ENABLED,
7723            ACCESSIBILITY_ENABLED,
7724            ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
7725            ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
7726            ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
7727            ACCESSIBILITY_SHORTCUT_ENABLED,
7728            ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
7729            ACCESSIBILITY_SPEAK_PASSWORD,
7730            ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
7731            ACCESSIBILITY_CAPTIONING_PRESET,
7732            ACCESSIBILITY_CAPTIONING_ENABLED,
7733            ACCESSIBILITY_CAPTIONING_LOCALE,
7734            ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
7735            ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
7736            ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
7737            ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
7738            ACCESSIBILITY_CAPTIONING_TYPEFACE,
7739            ACCESSIBILITY_CAPTIONING_FONT_SCALE,
7740            ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
7741            TTS_DEFAULT_RATE,
7742            TTS_DEFAULT_PITCH,
7743            TTS_DEFAULT_SYNTH,
7744            TTS_ENABLED_PLUGINS,
7745            TTS_DEFAULT_LOCALE,
7746            SHOW_IME_WITH_HARD_KEYBOARD,
7747            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
7748            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
7749            WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
7750            SELECTED_SPELL_CHECKER,
7751            SELECTED_SPELL_CHECKER_SUBTYPE,
7752            SPELL_CHECKER_ENABLED,
7753            MOUNT_PLAY_NOTIFICATION_SND,
7754            MOUNT_UMS_AUTOSTART,
7755            MOUNT_UMS_PROMPT,
7756            MOUNT_UMS_NOTIFY_ENABLED,
7757            SLEEP_TIMEOUT,
7758            DOUBLE_TAP_TO_WAKE,
7759            WAKE_GESTURE_ENABLED,
7760            LONG_PRESS_TIMEOUT,
7761            CAMERA_GESTURE_DISABLED,
7762            ACCESSIBILITY_AUTOCLICK_ENABLED,
7763            ACCESSIBILITY_AUTOCLICK_DELAY,
7764            ACCESSIBILITY_LARGE_POINTER_ICON,
7765            PREFERRED_TTY_MODE,
7766            ENHANCED_VOICE_PRIVACY_ENABLED,
7767            TTY_MODE_ENABLED,
7768            INCALL_POWER_BUTTON_BEHAVIOR,
7769            NIGHT_DISPLAY_CUSTOM_START_TIME,
7770            NIGHT_DISPLAY_CUSTOM_END_TIME,
7771            NIGHT_DISPLAY_COLOR_TEMPERATURE,
7772            NIGHT_DISPLAY_AUTO_MODE,
7773            SYNC_PARENT_SOUNDS,
7774            CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
7775            CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
7776            SYSTEM_NAVIGATION_KEYS_ENABLED,
7777            QS_TILES,
7778            DOZE_ENABLED,
7779            DOZE_PULSE_ON_PICK_UP,
7780            DOZE_PULSE_ON_DOUBLE_TAP,
7781            NFC_PAYMENT_DEFAULT_COMPONENT,
7782            AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
7783            ASSIST_GESTURE_ENABLED,
7784            ASSIST_GESTURE_SENSITIVITY,
7785            ASSIST_GESTURE_SETUP_COMPLETE,
7786            ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
7787            ASSIST_GESTURE_WAKE_ENABLED,
7788            VR_DISPLAY_MODE,
7789            NOTIFICATION_BADGING,
7790            QS_AUTO_ADDED_TILES,
7791            SCREENSAVER_ENABLED,
7792            SCREENSAVER_COMPONENTS,
7793            SCREENSAVER_ACTIVATE_ON_DOCK,
7794            SCREENSAVER_ACTIVATE_ON_SLEEP,
7795            LOCKDOWN_IN_POWER_MENU,
7796            SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
7797        };
7798
7799        /**
7800         * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator,
7801         * otherwise they won't be restored.
7802         *
7803         * @hide
7804         */
7805        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
7806        static {
7807            VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR);
7808            VALIDATORS.put(ALLOW_MOCK_LOCATION, ALLOW_MOCK_LOCATION_VALIDATOR);
7809            VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR);
7810            VALIDATORS.put(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
7811                    ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR);
7812            VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER,
7813                    ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR);
7814            VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
7815                    ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR);
7816            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
7817                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR);
7818            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
7819                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR);
7820            VALIDATORS.put(AUTOFILL_SERVICE, AUTOFILL_SERVICE_VALIDATOR);
7821            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
7822                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR);
7823            VALIDATORS.put(ENABLED_ACCESSIBILITY_SERVICES,
7824                    ENABLED_ACCESSIBILITY_SERVICES_VALIDATOR);
7825            VALIDATORS.put(ENABLED_VR_LISTENERS, ENABLED_VR_LISTENERS_VALIDATOR);
7826            VALIDATORS.put(TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
7827                    TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES_VALIDATOR);
7828            VALIDATORS.put(TOUCH_EXPLORATION_ENABLED, TOUCH_EXPLORATION_ENABLED_VALIDATOR);
7829            VALIDATORS.put(ACCESSIBILITY_ENABLED, ACCESSIBILITY_ENABLED_VALIDATOR);
7830            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
7831                    ACCESSIBILITY_SHORTCUT_TARGET_SERVICE_VALIDATOR);
7832            VALIDATORS.put(ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
7833                    ACCESSIBILITY_BUTTON_TARGET_COMPONENT_VALIDATOR);
7834            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
7835                    ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN_VALIDATOR);
7836            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ENABLED,
7837                    ACCESSIBILITY_SHORTCUT_ENABLED_VALIDATOR);
7838            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
7839                    ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN_VALIDATOR);
7840            VALIDATORS.put(ACCESSIBILITY_SPEAK_PASSWORD, ACCESSIBILITY_SPEAK_PASSWORD_VALIDATOR);
7841            VALIDATORS.put(ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
7842                    ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR);
7843            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_PRESET,
7844                    ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR);
7845            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_ENABLED,
7846                    ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR);
7847            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_LOCALE,
7848                    ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR);
7849            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
7850                    ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR);
7851            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
7852                    ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR);
7853            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
7854                    ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR);
7855            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
7856                    ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR);
7857            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_TYPEFACE,
7858                    ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR);
7859            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FONT_SCALE,
7860                    ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR);
7861            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
7862                    ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR);
7863            VALIDATORS.put(TTS_DEFAULT_RATE, TTS_DEFAULT_RATE_VALIDATOR);
7864            VALIDATORS.put(TTS_DEFAULT_PITCH, TTS_DEFAULT_PITCH_VALIDATOR);
7865            VALIDATORS.put(TTS_DEFAULT_SYNTH, TTS_DEFAULT_SYNTH_VALIDATOR);
7866            VALIDATORS.put(TTS_ENABLED_PLUGINS, TTS_ENABLED_PLUGINS_VALIDATOR);
7867            VALIDATORS.put(TTS_DEFAULT_LOCALE, TTS_DEFAULT_LOCALE_VALIDATOR);
7868            VALIDATORS.put(SHOW_IME_WITH_HARD_KEYBOARD, SHOW_IME_WITH_HARD_KEYBOARD_VALIDATOR);
7869            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
7870                    WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
7871            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
7872                    WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR);
7873            VALIDATORS.put(WIFI_NUM_OPEN_NETWORKS_KEPT, WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR);
7874            VALIDATORS.put(SELECTED_SPELL_CHECKER, SELECTED_SPELL_CHECKER_VALIDATOR);
7875            VALIDATORS.put(SELECTED_SPELL_CHECKER_SUBTYPE,
7876                    SELECTED_SPELL_CHECKER_SUBTYPE_VALIDATOR);
7877            VALIDATORS.put(SPELL_CHECKER_ENABLED, SPELL_CHECKER_ENABLED_VALIDATOR);
7878            VALIDATORS.put(MOUNT_PLAY_NOTIFICATION_SND, MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR);
7879            VALIDATORS.put(MOUNT_UMS_AUTOSTART, MOUNT_UMS_AUTOSTART_VALIDATOR);
7880            VALIDATORS.put(MOUNT_UMS_PROMPT, MOUNT_UMS_PROMPT_VALIDATOR);
7881            VALIDATORS.put(MOUNT_UMS_NOTIFY_ENABLED, MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR);
7882            VALIDATORS.put(SLEEP_TIMEOUT, SLEEP_TIMEOUT_VALIDATOR);
7883            VALIDATORS.put(DOUBLE_TAP_TO_WAKE, DOUBLE_TAP_TO_WAKE_VALIDATOR);
7884            VALIDATORS.put(WAKE_GESTURE_ENABLED, WAKE_GESTURE_ENABLED_VALIDATOR);
7885            VALIDATORS.put(LONG_PRESS_TIMEOUT, LONG_PRESS_TIMEOUT_VALIDATOR);
7886            VALIDATORS.put(CAMERA_GESTURE_DISABLED, CAMERA_GESTURE_DISABLED_VALIDATOR);
7887            VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_ENABLED,
7888                    ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR);
7889            VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_DELAY, ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR);
7890            VALIDATORS.put(ACCESSIBILITY_LARGE_POINTER_ICON,
7891                    ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR);
7892            VALIDATORS.put(PREFERRED_TTY_MODE, PREFERRED_TTY_MODE_VALIDATOR);
7893            VALIDATORS.put(ENHANCED_VOICE_PRIVACY_ENABLED,
7894                    ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR);
7895            VALIDATORS.put(TTY_MODE_ENABLED, TTY_MODE_ENABLED_VALIDATOR);
7896            VALIDATORS.put(INCALL_POWER_BUTTON_BEHAVIOR, INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR);
7897            VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_START_TIME,
7898                    NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR);
7899            VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_END_TIME, NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR);
7900            VALIDATORS.put(NIGHT_DISPLAY_COLOR_TEMPERATURE,
7901                    NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR);
7902            VALIDATORS.put(NIGHT_DISPLAY_AUTO_MODE, NIGHT_DISPLAY_AUTO_MODE_VALIDATOR);
7903            VALIDATORS.put(SYNC_PARENT_SOUNDS, SYNC_PARENT_SOUNDS_VALIDATOR);
7904            VALIDATORS.put(CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
7905                    CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR);
7906            VALIDATORS.put(CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
7907                    CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR);
7908            VALIDATORS.put(SYSTEM_NAVIGATION_KEYS_ENABLED,
7909                    SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR);
7910            VALIDATORS.put(QS_TILES, QS_TILES_VALIDATOR);
7911            VALIDATORS.put(DOZE_ENABLED, DOZE_ENABLED_VALIDATOR);
7912            VALIDATORS.put(DOZE_PULSE_ON_PICK_UP, DOZE_PULSE_ON_PICK_UP_VALIDATOR);
7913            VALIDATORS.put(DOZE_PULSE_ON_DOUBLE_TAP, DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR);
7914            VALIDATORS.put(NFC_PAYMENT_DEFAULT_COMPONENT, NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR);
7915            VALIDATORS.put(AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
7916                    AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR);
7917            VALIDATORS.put(ASSIST_GESTURE_ENABLED, ASSIST_GESTURE_ENABLED_VALIDATOR);
7918            VALIDATORS.put(ASSIST_GESTURE_SENSITIVITY, ASSIST_GESTURE_SENSITIVITY_VALIDATOR);
7919            VALIDATORS.put(ASSIST_GESTURE_SETUP_COMPLETE, ASSIST_GESTURE_SETUP_COMPLETE_VALIDATOR);
7920            VALIDATORS.put(ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
7921                    ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR);
7922            VALIDATORS.put(ASSIST_GESTURE_WAKE_ENABLED, ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR);
7923            VALIDATORS.put(VR_DISPLAY_MODE, VR_DISPLAY_MODE_VALIDATOR);
7924            VALIDATORS.put(NOTIFICATION_BADGING, NOTIFICATION_BADGING_VALIDATOR);
7925            VALIDATORS.put(QS_AUTO_ADDED_TILES, QS_AUTO_ADDED_TILES_VALIDATOR);
7926            VALIDATORS.put(SCREENSAVER_ENABLED, SCREENSAVER_ENABLED_VALIDATOR);
7927            VALIDATORS.put(SCREENSAVER_COMPONENTS, SCREENSAVER_COMPONENTS_VALIDATOR);
7928            VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_DOCK, SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR);
7929            VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_SLEEP, SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR);
7930            VALIDATORS.put(LOCKDOWN_IN_POWER_MENU, LOCKDOWN_IN_POWER_MENU_VALIDATOR);
7931            VALIDATORS.put(SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
7932                    SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR);
7933            VALIDATORS.put(ENABLED_NOTIFICATION_LISTENERS,
7934                    ENABLED_NOTIFICATION_LISTENERS_VALIDATOR); //legacy restore setting
7935            VALIDATORS.put(ENABLED_NOTIFICATION_ASSISTANT,
7936                    ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR); //legacy restore setting
7937            VALIDATORS.put(ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
7938                    ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR); //legacy restore setting
7939        }
7940
7941        /**
7942         * Keys we no longer back up under the current schema, but want to continue to
7943         * process when restoring historical backup datasets.
7944         *
7945         * All settings in {@link LEGACY_RESTORE_SETTINGS} array *must* have a non-null validator,
7946         * otherwise they won't be restored.
7947         *
7948         * @hide
7949         */
7950        public static final String[] LEGACY_RESTORE_SETTINGS = {
7951                ENABLED_NOTIFICATION_LISTENERS,
7952                ENABLED_NOTIFICATION_ASSISTANT,
7953                ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES
7954        };
7955
7956        /**
7957         * These entries are considered common between the personal and the managed profile,
7958         * since the managed profile doesn't get to change them.
7959         */
7960        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
7961
7962        static {
7963            CLONE_TO_MANAGED_PROFILE.add(ACCESSIBILITY_ENABLED);
7964            CLONE_TO_MANAGED_PROFILE.add(ALLOW_MOCK_LOCATION);
7965            CLONE_TO_MANAGED_PROFILE.add(ALLOWED_GEOLOCATION_ORIGINS);
7966            CLONE_TO_MANAGED_PROFILE.add(AUTOFILL_SERVICE);
7967            CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD);
7968            CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES);
7969            CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS);
7970            CLONE_TO_MANAGED_PROFILE.add(LOCATION_CHANGER);
7971            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
7972            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED);
7973            CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE);
7974            if (TextServicesManager.DISABLE_PER_PROFILE_SPELL_CHECKER) {
7975                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER);
7976                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER_SUBTYPE);
7977            }
7978        }
7979
7980        /** @hide */
7981        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
7982            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
7983        }
7984
7985        /**
7986         * Secure settings which can be accessed by instant apps.
7987         * @hide
7988         */
7989        public static final Set<String> INSTANT_APP_SETTINGS = new ArraySet<>();
7990        static {
7991            INSTANT_APP_SETTINGS.add(ENABLED_ACCESSIBILITY_SERVICES);
7992            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_SPEAK_PASSWORD);
7993            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
7994            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_ENABLED);
7995            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_PRESET);
7996            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_EDGE_TYPE);
7997            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_EDGE_COLOR);
7998            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_LOCALE);
7999            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR);
8000            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR);
8001            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_TYPEFACE);
8002            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_FONT_SCALE);
8003            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_WINDOW_COLOR);
8004            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
8005            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_DALTONIZER);
8006            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_AUTOCLICK_DELAY);
8007            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_AUTOCLICK_ENABLED);
8008            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_LARGE_POINTER_ICON);
8009
8010            INSTANT_APP_SETTINGS.add(DEFAULT_INPUT_METHOD);
8011            INSTANT_APP_SETTINGS.add(ENABLED_INPUT_METHODS);
8012
8013            INSTANT_APP_SETTINGS.add(ANDROID_ID);
8014
8015            INSTANT_APP_SETTINGS.add(PACKAGE_VERIFIER_USER_CONSENT);
8016            INSTANT_APP_SETTINGS.add(ALLOW_MOCK_LOCATION);
8017        }
8018
8019        /**
8020         * Helper method for determining if a location provider is enabled.
8021         *
8022         * @param cr the content resolver to use
8023         * @param provider the location provider to query
8024         * @return true if the provider is enabled
8025         *
8026         * @deprecated use {@link LocationManager#isProviderEnabled(String)}
8027         */
8028        @Deprecated
8029        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
8030            return isLocationProviderEnabledForUser(cr, provider, cr.getUserId());
8031        }
8032
8033        /**
8034         * Helper method for determining if a location provider is enabled.
8035         * @param cr the content resolver to use
8036         * @param provider the location provider to query
8037         * @param userId the userId to query
8038         * @return true if the provider is enabled
8039         *
8040         * @deprecated use {@link LocationManager#isProviderEnabled(String)}
8041         * @hide
8042         */
8043        @Deprecated
8044        public static final boolean isLocationProviderEnabledForUser(
8045                ContentResolver cr, String provider, int userId) {
8046            String allowedProviders = Settings.Secure.getStringForUser(cr,
8047                    LOCATION_PROVIDERS_ALLOWED, userId);
8048            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
8049        }
8050
8051        /**
8052         * Thread-safe method for enabling or disabling a single location provider.
8053         * @param cr the content resolver to use
8054         * @param provider the location provider to enable or disable
8055         * @param enabled true if the provider should be enabled
8056         * @deprecated This API is deprecated. It requires WRITE_SECURE_SETTINGS permission to
8057         *             change location settings.
8058         */
8059        @Deprecated
8060        public static final void setLocationProviderEnabled(ContentResolver cr,
8061                String provider, boolean enabled) {
8062            setLocationProviderEnabledForUser(cr, provider, enabled, cr.getUserId());
8063        }
8064
8065        /**
8066         * Thread-safe method for enabling or disabling a single location provider.
8067         *
8068         * @param cr the content resolver to use
8069         * @param provider the location provider to enable or disable
8070         * @param enabled true if the provider should be enabled
8071         * @param userId the userId for which to enable/disable providers
8072         * @return true if the value was set, false on database errors
8073         *
8074         * @deprecated use {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}
8075         * @hide
8076         */
8077        @Deprecated
8078        public static final boolean setLocationProviderEnabledForUser(ContentResolver cr,
8079                String provider, boolean enabled, int userId) {
8080            synchronized (mLocationSettingsLock) {
8081                // to ensure thread safety, we write the provider name with a '+' or '-'
8082                // and let the SettingsProvider handle it rather than reading and modifying
8083                // the list of enabled providers.
8084                if (enabled) {
8085                    provider = "+" + provider;
8086                } else {
8087                    provider = "-" + provider;
8088                }
8089                return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
8090                        userId);
8091            }
8092        }
8093
8094        /**
8095         * Thread-safe method for setting the location mode to one of
8096         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
8097         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
8098         * Necessary because the mode is a composite of the underlying location provider
8099         * settings.
8100         *
8101         * @param cr the content resolver to use
8102         * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY}
8103         * @param userId the userId for which to change mode
8104         * @return true if the value was set, false on database errors
8105         *
8106         * @throws IllegalArgumentException if mode is not one of the supported values
8107         *
8108         * @deprecated To enable/disable location, use
8109         *             {@link LocationManager#setLocationEnabledForUser(boolean, int)}.
8110         *             To enable/disable a specific location provider, use
8111         *             {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}.
8112         */
8113        @Deprecated
8114        private static boolean setLocationModeForUser(
8115                ContentResolver cr, int mode, int userId) {
8116            synchronized (mLocationSettingsLock) {
8117                boolean gps = false;
8118                boolean network = false;
8119                switch (mode) {
8120                    case LOCATION_MODE_OFF:
8121                        break;
8122                    case LOCATION_MODE_SENSORS_ONLY:
8123                        gps = true;
8124                        break;
8125                    case LOCATION_MODE_BATTERY_SAVING:
8126                        network = true;
8127                        break;
8128                    case LOCATION_MODE_HIGH_ACCURACY:
8129                        gps = true;
8130                        network = true;
8131                        break;
8132                    default:
8133                        throw new IllegalArgumentException("Invalid location mode: " + mode);
8134                }
8135
8136                boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
8137                        cr, LocationManager.NETWORK_PROVIDER, network, userId);
8138                boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
8139                        cr, LocationManager.GPS_PROVIDER, gps, userId);
8140                return gpsSuccess && nlpSuccess;
8141            }
8142        }
8143
8144        /**
8145         * Thread-safe method for reading the location mode, returns one of
8146         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
8147         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. Necessary
8148         * because the mode is a composite of the underlying location provider settings.
8149         *
8150         * @param cr the content resolver to use
8151         * @param userId the userId for which to read the mode
8152         * @return the location mode
8153         */
8154        private static final int getLocationModeForUser(ContentResolver cr, int userId) {
8155            synchronized (mLocationSettingsLock) {
8156                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
8157                        cr, LocationManager.GPS_PROVIDER, userId);
8158                boolean networkEnabled = Settings.Secure.isLocationProviderEnabledForUser(
8159                        cr, LocationManager.NETWORK_PROVIDER, userId);
8160                if (gpsEnabled && networkEnabled) {
8161                    return LOCATION_MODE_HIGH_ACCURACY;
8162                } else if (gpsEnabled) {
8163                    return LOCATION_MODE_SENSORS_ONLY;
8164                } else if (networkEnabled) {
8165                    return LOCATION_MODE_BATTERY_SAVING;
8166                } else {
8167                    return LOCATION_MODE_OFF;
8168                }
8169            }
8170        }
8171    }
8172
8173    /**
8174     * Global system settings, containing preferences that always apply identically
8175     * to all defined users.  Applications can read these but are not allowed to write;
8176     * like the "Secure" settings, these are for preferences that the user must
8177     * explicitly modify through the system UI or specialized APIs for those values.
8178     */
8179    public static final class Global extends NameValueTable {
8180        // NOTE: If you add new settings here, be sure to add them to
8181        // com.android.providers.settings.SettingsProtoDumpUtil#dumpProtoGlobalSettingsLocked.
8182
8183        /**
8184         * The content:// style URL for global secure settings items.  Not public.
8185         */
8186        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
8187
8188        /**
8189         * Whether users are allowed to add more users or guest from lockscreen.
8190         * <p>
8191         * Type: int
8192         * @hide
8193         */
8194        public static final String ADD_USERS_WHEN_LOCKED = "add_users_when_locked";
8195
8196        /**
8197         * Setting whether the global gesture for enabling accessibility is enabled.
8198         * If this gesture is enabled the user will be able to perfrom it to enable
8199         * the accessibility state without visiting the settings app.
8200         *
8201         * @hide
8202         * No longer used. Should be removed once all dependencies have been updated.
8203         */
8204        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
8205                "enable_accessibility_global_gesture_enabled";
8206
8207        /**
8208         * Whether Airplane Mode is on.
8209         */
8210        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
8211
8212        /**
8213         * Whether Theater Mode is on.
8214         * {@hide}
8215         */
8216        @SystemApi
8217        public static final String THEATER_MODE_ON = "theater_mode_on";
8218
8219        /**
8220         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
8221         */
8222        public static final String RADIO_BLUETOOTH = "bluetooth";
8223
8224        /**
8225         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
8226         */
8227        public static final String RADIO_WIFI = "wifi";
8228
8229        /**
8230         * {@hide}
8231         */
8232        public static final String RADIO_WIMAX = "wimax";
8233        /**
8234         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
8235         */
8236        public static final String RADIO_CELL = "cell";
8237
8238        /**
8239         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
8240         */
8241        public static final String RADIO_NFC = "nfc";
8242
8243        /**
8244         * A comma separated list of radios that need to be disabled when airplane mode
8245         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
8246         * included in the comma separated list.
8247         */
8248        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
8249
8250        /**
8251         * A comma separated list of radios that should to be disabled when airplane mode
8252         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
8253         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
8254         * will be turned off when entering airplane mode, but the user will be able to reenable
8255         * Wifi in the Settings app.
8256         *
8257         * {@hide}
8258         */
8259        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
8260
8261        /**
8262         * An integer representing the Bluetooth Class of Device (CoD).
8263         *
8264         * @hide
8265         */
8266        public static final String BLUETOOTH_CLASS_OF_DEVICE = "bluetooth_class_of_device";
8267
8268        /**
8269         * A Long representing a bitmap of profiles that should be disabled when bluetooth starts.
8270         * See {@link android.bluetooth.BluetoothProfile}.
8271         * {@hide}
8272         */
8273        public static final String BLUETOOTH_DISABLED_PROFILES = "bluetooth_disabled_profiles";
8274
8275        /**
8276         * A semi-colon separated list of Bluetooth interoperability workarounds.
8277         * Each entry is a partial Bluetooth device address string and an integer representing
8278         * the feature to be disabled, separated by a comma. The integer must correspond
8279         * to a interoperability feature as defined in "interop.h" in /system/bt.
8280         * <p>
8281         * Example: <br/>
8282         *   "00:11:22,0;01:02:03:04,2"
8283         * @hide
8284         */
8285       public static final String BLUETOOTH_INTEROPERABILITY_LIST = "bluetooth_interoperability_list";
8286
8287        /**
8288         * The policy for deciding when Wi-Fi should go to sleep (which will in
8289         * turn switch to using the mobile data as an Internet connection).
8290         * <p>
8291         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
8292         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
8293         * {@link #WIFI_SLEEP_POLICY_NEVER}.
8294         */
8295        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
8296
8297        /**
8298         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
8299         * policy, which is to sleep shortly after the turning off
8300         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
8301         */
8302        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
8303
8304        /**
8305         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
8306         * the device is on battery, and never go to sleep when the device is
8307         * plugged in.
8308         */
8309        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
8310
8311        /**
8312         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
8313         */
8314        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
8315
8316        /**
8317         * Value to specify if the user prefers the date, time and time zone
8318         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
8319         */
8320        public static final String AUTO_TIME = "auto_time";
8321
8322        private static final Validator AUTO_TIME_VALIDATOR = BOOLEAN_VALIDATOR;
8323
8324        /**
8325         * Value to specify if the user prefers the time zone
8326         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
8327         */
8328        public static final String AUTO_TIME_ZONE = "auto_time_zone";
8329
8330        private static final Validator AUTO_TIME_ZONE_VALIDATOR = BOOLEAN_VALIDATOR;
8331
8332        /**
8333         * URI for the car dock "in" event sound.
8334         * @hide
8335         */
8336        public static final String CAR_DOCK_SOUND = "car_dock_sound";
8337
8338        /**
8339         * URI for the car dock "out" event sound.
8340         * @hide
8341         */
8342        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
8343
8344        /**
8345         * URI for the desk dock "in" event sound.
8346         * @hide
8347         */
8348        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
8349
8350        /**
8351         * URI for the desk dock "out" event sound.
8352         * @hide
8353         */
8354        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
8355
8356        /**
8357         * Whether to play a sound for dock events.
8358         * @hide
8359         */
8360        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
8361
8362        private static final Validator DOCK_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8363
8364        /**
8365         * Whether to play a sound for dock events, only when an accessibility service is on.
8366         * @hide
8367         */
8368        public static final String DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY = "dock_sounds_enabled_when_accessbility";
8369
8370        /**
8371         * URI for the "device locked" (keyguard shown) sound.
8372         * @hide
8373         */
8374        public static final String LOCK_SOUND = "lock_sound";
8375
8376        /**
8377         * URI for the "device unlocked" sound.
8378         * @hide
8379         */
8380        public static final String UNLOCK_SOUND = "unlock_sound";
8381
8382        /**
8383         * URI for the "device is trusted" sound, which is played when the device enters the trusted
8384         * state without unlocking.
8385         * @hide
8386         */
8387        public static final String TRUSTED_SOUND = "trusted_sound";
8388
8389        /**
8390         * URI for the low battery sound file.
8391         * @hide
8392         */
8393        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
8394
8395        /**
8396         * Whether to play a sound for low-battery alerts.
8397         * @hide
8398         */
8399        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
8400
8401        private static final Validator POWER_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8402
8403        /**
8404         * URI for the "wireless charging started" and "wired charging started" sound.
8405         * @hide
8406         */
8407        public static final String CHARGING_STARTED_SOUND =
8408                "wireless_charging_started_sound";
8409
8410        /**
8411         * Whether to play a sound for charging events.
8412         * @hide
8413         */
8414        public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled";
8415
8416        private static final Validator CHARGING_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8417
8418        /**
8419         * Whether we keep the device on while the device is plugged in.
8420         * Supported values are:
8421         * <ul>
8422         * <li>{@code 0} to never stay on while plugged in</li>
8423         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
8424         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
8425         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
8426         * </ul>
8427         * These values can be OR-ed together.
8428         */
8429        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
8430
8431        private static final Validator STAY_ON_WHILE_PLUGGED_IN_VALIDATOR = new Validator() {
8432            @Override
8433            public boolean validate(String value) {
8434                try {
8435                    int val = Integer.parseInt(value);
8436                    return (val == 0)
8437                            || (val == BatteryManager.BATTERY_PLUGGED_AC)
8438                            || (val == BatteryManager.BATTERY_PLUGGED_USB)
8439                            || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS)
8440                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8441                                    | BatteryManager.BATTERY_PLUGGED_USB))
8442                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8443                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
8444                            || (val == (BatteryManager.BATTERY_PLUGGED_USB
8445                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
8446                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8447                                    | BatteryManager.BATTERY_PLUGGED_USB
8448                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS));
8449                } catch (NumberFormatException e) {
8450                    return false;
8451                }
8452            }
8453        };
8454
8455        /**
8456         * When the user has enable the option to have a "bug report" command
8457         * in the power menu.
8458         * @hide
8459         */
8460        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
8461
8462        private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
8463
8464        /**
8465         * Whether ADB is enabled.
8466         */
8467        public static final String ADB_ENABLED = "adb_enabled";
8468
8469        /**
8470         * Whether Views are allowed to save their attribute data.
8471         * @hide
8472         */
8473        public static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
8474
8475        /**
8476         * Whether assisted GPS should be enabled or not.
8477         * @hide
8478         */
8479        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
8480
8481        /**
8482         * Whether bluetooth is enabled/disabled
8483         * 0=disabled. 1=enabled.
8484         */
8485        public static final String BLUETOOTH_ON = "bluetooth_on";
8486
8487        private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR;
8488
8489        /**
8490         * CDMA Cell Broadcast SMS
8491         *                            0 = CDMA Cell Broadcast SMS disabled
8492         *                            1 = CDMA Cell Broadcast SMS enabled
8493         * @hide
8494         */
8495        public static final String CDMA_CELL_BROADCAST_SMS =
8496                "cdma_cell_broadcast_sms";
8497
8498        /**
8499         * The CDMA roaming mode 0 = Home Networks, CDMA default
8500         *                       1 = Roaming on Affiliated networks
8501         *                       2 = Roaming on any networks
8502         * @hide
8503         */
8504        public static final String CDMA_ROAMING_MODE = "roaming_settings";
8505
8506        /**
8507         * The CDMA subscription mode 0 = RUIM/SIM (default)
8508         *                                1 = NV
8509         * @hide
8510         */
8511        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
8512
8513        /**
8514         * The default value for whether background data is enabled or not.
8515         *
8516         * Used by {@code NetworkPolicyManagerService}.
8517         *
8518         * @hide
8519         */
8520        public static final String DEFAULT_RESTRICT_BACKGROUND_DATA =
8521                "default_restrict_background_data";
8522
8523        /** Inactivity timeout to track mobile data activity.
8524        *
8525        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
8526        * infer the data activity of mobile network. After a period of no activity on mobile
8527        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
8528        * intent is fired to indicate a transition of network status from "active" to "idle". Any
8529        * subsequent activity on mobile networks triggers the firing of {@code
8530        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
8531        *
8532        * Network activity refers to transmitting or receiving data on the network interfaces.
8533        *
8534        * Tracking is disabled if set to zero or negative value.
8535        *
8536        * @hide
8537        */
8538       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
8539
8540       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
8541        * but for Wifi network.
8542        * @hide
8543        */
8544       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
8545
8546       /**
8547        * Whether or not data roaming is enabled. (0 = false, 1 = true)
8548        */
8549       public static final String DATA_ROAMING = "data_roaming";
8550
8551       /**
8552        * The value passed to a Mobile DataConnection via bringUp which defines the
8553        * number of retries to preform when setting up the initial connection. The default
8554        * value defined in DataConnectionTrackerBase#DEFAULT_MDC_INITIAL_RETRY is currently 1.
8555        * @hide
8556        */
8557       public static final String MDC_INITIAL_MAX_RETRY = "mdc_initial_max_retry";
8558
8559       /**
8560        * Whether any package can be on external storage. When this is true, any
8561        * package, regardless of manifest values, is a candidate for installing
8562        * or moving onto external storage. (0 = false, 1 = true)
8563        * @hide
8564        */
8565       public static final String FORCE_ALLOW_ON_EXTERNAL = "force_allow_on_external";
8566
8567        /**
8568         * The default SM-DP+ configured for this device.
8569         *
8570         * <p>An SM-DP+ is used by an LPA (see {@link android.service.euicc.EuiccService}) to
8571         * download profiles. If this value is set, the LPA will query this server for any profiles
8572         * available to this device. If any are available, they may be downloaded during device
8573         * provisioning or in settings without needing the user to enter an activation code.
8574         *
8575         * @see android.service.euicc.EuiccService
8576         * @hide
8577         */
8578        @SystemApi
8579        public static final String DEFAULT_SM_DP_PLUS = "default_sm_dp_plus";
8580
8581        /**
8582         * Whether any profile has ever been downloaded onto a eUICC on the device.
8583         *
8584         * <p>Used to hide eUICC UI from users who have never made use of it and would only be
8585         * confused by seeing references to it in settings.
8586         * (0 = false, 1 = true)
8587         * @hide
8588         */
8589        @SystemApi
8590        public static final String EUICC_PROVISIONED = "euicc_provisioned";
8591
8592        /**
8593         * Whether any activity can be resized. When this is true, any
8594         * activity, regardless of manifest values, can be resized for multi-window.
8595         * (0 = false, 1 = true)
8596         * @hide
8597         */
8598        public static final String DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES
8599                = "force_resizable_activities";
8600
8601        /**
8602         * Whether to enable experimental freeform support for windows.
8603         * @hide
8604         */
8605        public static final String DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT
8606                = "enable_freeform_support";
8607
8608       /**
8609        * Whether user has enabled development settings.
8610        */
8611       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
8612
8613       /**
8614        * Whether the device has been provisioned (0 = false, 1 = true).
8615        * <p>On a multiuser device with a separate system user, the screen may be locked
8616        * as soon as this is set to true and further activities cannot be launched on the
8617        * system user unless they are marked to show over keyguard.
8618        */
8619       public static final String DEVICE_PROVISIONED = "device_provisioned";
8620
8621       /**
8622        * Whether mobile data should be allowed while the device is being provisioned.
8623        * This allows the provisioning process to turn off mobile data before the user
8624        * has an opportunity to set things up, preventing other processes from burning
8625        * precious bytes before wifi is setup.
8626        * (0 = false, 1 = true)
8627        * @hide
8628        */
8629       public static final String DEVICE_PROVISIONING_MOBILE_DATA_ENABLED =
8630               "device_provisioning_mobile_data";
8631
8632       /**
8633        * The saved value for WindowManagerService.setForcedDisplaySize().
8634        * Two integers separated by a comma.  If unset, then use the real display size.
8635        * @hide
8636        */
8637       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
8638
8639       /**
8640        * The saved value for WindowManagerService.setForcedDisplayScalingMode().
8641        * 0 or unset if scaling is automatic, 1 if scaling is disabled.
8642        * @hide
8643        */
8644       public static final String DISPLAY_SCALING_FORCE = "display_scaling_force";
8645
8646       /**
8647        * The maximum size, in bytes, of a download that the download manager will transfer over
8648        * a non-wifi connection.
8649        * @hide
8650        */
8651       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
8652               "download_manager_max_bytes_over_mobile";
8653
8654       /**
8655        * The recommended maximum size, in bytes, of a download that the download manager should
8656        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
8657        * have the option to start the download over the mobile connection anyway.
8658        * @hide
8659        */
8660       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
8661               "download_manager_recommended_max_bytes_over_mobile";
8662
8663       /**
8664        * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
8665        */
8666       @Deprecated
8667       public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
8668
8669       /**
8670        * Whether HDMI control shall be enabled. If disabled, no CEC/MHL command will be
8671        * sent or processed. (0 = false, 1 = true)
8672        * @hide
8673        */
8674       public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled";
8675
8676       /**
8677        * Whether HDMI System Audio Control feature is enabled. If enabled, TV will try to turn on
8678        * system audio mode if there's a connected CEC-enabled AV Receiver. Then audio stream will
8679        * be played on AVR instead of TV spaeker. If disabled, the system audio mode will never be
8680        * activated.
8681        * @hide
8682        */
8683        public static final String HDMI_SYSTEM_AUDIO_CONTROL_ENABLED =
8684                "hdmi_system_audio_control_enabled";
8685
8686        /**
8687         * Whether TV will automatically turn on upon reception of the CEC command
8688         * &lt;Text View On&gt; or &lt;Image View On&gt;. (0 = false, 1 = true)
8689         *
8690         * @hide
8691         */
8692        public static final String HDMI_CONTROL_AUTO_WAKEUP_ENABLED =
8693                "hdmi_control_auto_wakeup_enabled";
8694
8695        /**
8696         * Whether TV will also turn off other CEC devices when it goes to standby mode.
8697         * (0 = false, 1 = true)
8698         *
8699         * @hide
8700         */
8701        public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
8702                "hdmi_control_auto_device_off_enabled";
8703
8704        /**
8705         * If <b>true</b>, enables out-of-the-box execution for priv apps.
8706         * Default: false
8707         * Values: 0 = false, 1 = true
8708         *
8709         * @hide
8710         */
8711        public static final String PRIV_APP_OOB_ENABLED = "priv_app_oob_enabled";
8712
8713        /**
8714         * The interval in milliseconds at which location requests will be throttled when they are
8715         * coming from the background.
8716         *
8717         * @hide
8718         */
8719        public static final String LOCATION_BACKGROUND_THROTTLE_INTERVAL_MS =
8720                "location_background_throttle_interval_ms";
8721
8722        /**
8723         * Most frequent location update interval in milliseconds that proximity alert is allowed
8724         * to request.
8725         * @hide
8726         */
8727        public static final String LOCATION_BACKGROUND_THROTTLE_PROXIMITY_ALERT_INTERVAL_MS =
8728                "location_background_throttle_proximity_alert_interval_ms";
8729
8730        /**
8731         * Packages that are whitelisted for background throttling (throttling will not be applied).
8732         * @hide
8733         */
8734        public static final String LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST =
8735            "location_background_throttle_package_whitelist";
8736
8737        /**
8738         * The interval in milliseconds at which wifi scan requests will be throttled when they are
8739         * coming from the background.
8740         * @hide
8741         */
8742        public static final String WIFI_SCAN_BACKGROUND_THROTTLE_INTERVAL_MS =
8743                "wifi_scan_background_throttle_interval_ms";
8744
8745        /**
8746         * Packages that are whitelisted to be exempt for wifi background throttling.
8747         * @hide
8748         */
8749        public static final String WIFI_SCAN_BACKGROUND_THROTTLE_PACKAGE_WHITELIST =
8750                "wifi_scan_background_throttle_package_whitelist";
8751
8752        /**
8753        * Whether TV will switch to MHL port when a mobile device is plugged in.
8754        * (0 = false, 1 = true)
8755        * @hide
8756        */
8757       public static final String MHL_INPUT_SWITCHING_ENABLED = "mhl_input_switching_enabled";
8758
8759       /**
8760        * Whether TV will charge the mobile device connected at MHL port. (0 = false, 1 = true)
8761        * @hide
8762        */
8763       public static final String MHL_POWER_CHARGE_ENABLED = "mhl_power_charge_enabled";
8764
8765       /**
8766        * Whether mobile data connections are allowed by the user.  See
8767        * ConnectivityManager for more info.
8768        * @hide
8769        */
8770       public static final String MOBILE_DATA = "mobile_data";
8771
8772       /**
8773        * Whether the mobile data connection should remain active even when higher
8774        * priority networks like WiFi are active, to help make network switching faster.
8775        *
8776        * See ConnectivityService for more info.
8777        *
8778        * (0 = disabled, 1 = enabled)
8779        * @hide
8780        */
8781       public static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
8782
8783        /**
8784         * Size of the event buffer for IP connectivity metrics.
8785         * @hide
8786         */
8787        public static final String CONNECTIVITY_METRICS_BUFFER_SIZE =
8788              "connectivity_metrics_buffer_size";
8789
8790       /** {@hide} */
8791       public static final String NETSTATS_ENABLED = "netstats_enabled";
8792       /** {@hide} */
8793       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
8794       /** {@hide} */
8795       @Deprecated
8796       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
8797       /** {@hide} */
8798       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
8799       /** {@hide} */
8800       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
8801       /** {@hide} */
8802       public static final String NETSTATS_AUGMENT_ENABLED = "netstats_augment_enabled";
8803
8804       /** {@hide} */
8805       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
8806       /** {@hide} */
8807       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
8808       /** {@hide} */
8809       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
8810       /** {@hide} */
8811       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
8812
8813       /** {@hide} */
8814       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
8815       /** {@hide} */
8816       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
8817       /** {@hide} */
8818       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
8819       /** {@hide} */
8820       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
8821
8822       /** {@hide} */
8823       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
8824       /** {@hide} */
8825       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
8826       /** {@hide} */
8827       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
8828       /** {@hide} */
8829       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
8830
8831       /**
8832        * User preference for which network(s) should be used. Only the
8833        * connectivity service should touch this.
8834        */
8835       public static final String NETWORK_PREFERENCE = "network_preference";
8836
8837       /**
8838        * Which package name to use for network scoring. If null, or if the package is not a valid
8839        * scorer app, external network scores will neither be requested nor accepted.
8840        * @hide
8841        */
8842       public static final String NETWORK_SCORER_APP = "network_scorer_app";
8843
8844        /**
8845         * Whether night display forced auto mode is available.
8846         * 0 = unavailable, 1 = available.
8847         * @hide
8848         */
8849        public static final String NIGHT_DISPLAY_FORCED_AUTO_MODE_AVAILABLE =
8850                "night_display_forced_auto_mode_available";
8851
8852       /**
8853        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
8854        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
8855        * exceeded.
8856        * @hide
8857        */
8858       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
8859
8860       /**
8861        * The length of time in milli-seconds that automatic small adjustments to
8862        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
8863        * @hide
8864        */
8865       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
8866
8867       /** Preferred NTP server. {@hide} */
8868       public static final String NTP_SERVER = "ntp_server";
8869       /** Timeout in milliseconds to wait for NTP server. {@hide} */
8870       public static final String NTP_TIMEOUT = "ntp_timeout";
8871
8872       /** {@hide} */
8873       public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval";
8874
8875       /**
8876        * Sample validity in seconds to configure for the system DNS resolver.
8877        * {@hide}
8878        */
8879       public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS =
8880               "dns_resolver_sample_validity_seconds";
8881
8882       /**
8883        * Success threshold in percent for use with the system DNS resolver.
8884        * {@hide}
8885        */
8886       public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT =
8887                "dns_resolver_success_threshold_percent";
8888
8889       /**
8890        * Minimum number of samples needed for statistics to be considered meaningful in the
8891        * system DNS resolver.
8892        * {@hide}
8893        */
8894       public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples";
8895
8896       /**
8897        * Maximum number taken into account for statistics purposes in the system DNS resolver.
8898        * {@hide}
8899        */
8900       public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples";
8901
8902       /**
8903        * Whether to disable the automatic scheduling of system updates.
8904        * 1 = system updates won't be automatically scheduled (will always
8905        * present notification instead).
8906        * 0 = system updates will be automatically scheduled. (default)
8907        * @hide
8908        */
8909       @SystemApi
8910       public static final String OTA_DISABLE_AUTOMATIC_UPDATE = "ota_disable_automatic_update";
8911
8912       /**
8913        * Whether the package manager should send package verification broadcasts for verifiers to
8914        * review apps prior to installation.
8915        * 1 = request apps to be verified prior to installation, if a verifier exists.
8916        * 0 = do not verify apps before installation
8917        * @hide
8918        */
8919       public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
8920
8921       /** Timeout for package verification.
8922        * @hide */
8923       public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
8924
8925       /** Default response code for package verification.
8926        * @hide */
8927       public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
8928
8929       /**
8930        * Show package verification setting in the Settings app.
8931        * 1 = show (default)
8932        * 0 = hide
8933        * @hide
8934        */
8935       public static final String PACKAGE_VERIFIER_SETTING_VISIBLE = "verifier_setting_visible";
8936
8937       /**
8938        * Run package verification on apps installed through ADB/ADT/USB
8939        * 1 = perform package verification on ADB installs (default)
8940        * 0 = bypass package verification on ADB installs
8941        * @hide
8942        */
8943       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
8944
8945       /**
8946        * Time since last fstrim (milliseconds) after which we force one to happen
8947        * during device startup.  If unset, the default is 3 days.
8948        * @hide
8949        */
8950       public static final String FSTRIM_MANDATORY_INTERVAL = "fstrim_mandatory_interval";
8951
8952       /**
8953        * The interval in milliseconds at which to check packet counts on the
8954        * mobile data interface when screen is on, to detect possible data
8955        * connection problems.
8956        * @hide
8957        */
8958       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
8959               "pdp_watchdog_poll_interval_ms";
8960
8961       /**
8962        * The interval in milliseconds at which to check packet counts on the
8963        * mobile data interface when screen is off, to detect possible data
8964        * connection problems.
8965        * @hide
8966        */
8967       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
8968               "pdp_watchdog_long_poll_interval_ms";
8969
8970       /**
8971        * The interval in milliseconds at which to check packet counts on the
8972        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
8973        * outgoing packets has been reached without incoming packets.
8974        * @hide
8975        */
8976       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
8977               "pdp_watchdog_error_poll_interval_ms";
8978
8979       /**
8980        * The number of outgoing packets sent without seeing an incoming packet
8981        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
8982        * device is logged to the event log
8983        * @hide
8984        */
8985       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
8986               "pdp_watchdog_trigger_packet_count";
8987
8988       /**
8989        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
8990        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
8991        * attempting data connection recovery.
8992        * @hide
8993        */
8994       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
8995               "pdp_watchdog_error_poll_count";
8996
8997       /**
8998        * The number of failed PDP reset attempts before moving to something more
8999        * drastic: re-registering to the network.
9000        * @hide
9001        */
9002       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
9003               "pdp_watchdog_max_pdp_reset_fail_count";
9004
9005       /**
9006        * URL to open browser on to allow user to manage a prepay account
9007        * @hide
9008        */
9009       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
9010               "setup_prepaid_data_service_url";
9011
9012       /**
9013        * URL to attempt a GET on to see if this is a prepay device
9014        * @hide
9015        */
9016       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
9017               "setup_prepaid_detection_target_url";
9018
9019       /**
9020        * Host to check for a redirect to after an attempt to GET
9021        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
9022        * this is a prepaid device with zero balance.)
9023        * @hide
9024        */
9025       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
9026               "setup_prepaid_detection_redir_host";
9027
9028       /**
9029        * The interval in milliseconds at which to check the number of SMS sent out without asking
9030        * for use permit, to limit the un-authorized SMS usage.
9031        *
9032        * @hide
9033        */
9034       public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
9035               "sms_outgoing_check_interval_ms";
9036
9037       /**
9038        * The number of outgoing SMS sent without asking for user permit (of {@link
9039        * #SMS_OUTGOING_CHECK_INTERVAL_MS}
9040        *
9041        * @hide
9042        */
9043       public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
9044               "sms_outgoing_check_max_count";
9045
9046       /**
9047        * Used to disable SMS short code confirmation - defaults to true.
9048        * True indcates we will do the check, etc.  Set to false to disable.
9049        * @see com.android.internal.telephony.SmsUsageMonitor
9050        * @hide
9051        */
9052       public static final String SMS_SHORT_CODE_CONFIRMATION = "sms_short_code_confirmation";
9053
9054        /**
9055         * Used to select which country we use to determine premium sms codes.
9056         * One of com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_SIM,
9057         * com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_NETWORK,
9058         * or com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_BOTH.
9059         * @hide
9060         */
9061        public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule";
9062
9063       /**
9064        * Used to select TCP's default initial receiver window size in segments - defaults to a build config value
9065        * @hide
9066        */
9067       public static final String TCP_DEFAULT_INIT_RWND = "tcp_default_init_rwnd";
9068
9069       /**
9070        * Used to disable Tethering on a device - defaults to true
9071        * @hide
9072        */
9073       public static final String TETHER_SUPPORTED = "tether_supported";
9074
9075       /**
9076        * Used to require DUN APN on the device or not - defaults to a build config value
9077        * which defaults to false
9078        * @hide
9079        */
9080       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
9081
9082       /**
9083        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
9084        * corresponding build config values are set it will override the APN DB
9085        * values.
9086        * Consists of a comma seperated list of strings:
9087        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
9088        * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
9089        * @hide
9090        */
9091       public static final String TETHER_DUN_APN = "tether_dun_apn";
9092
9093        /**
9094         * Used to disable trying to talk to any available tethering offload HAL.
9095         *
9096         * Integer values are interpreted as boolean, and the absence of an explicit setting
9097         * is interpreted as |false|.
9098         * @hide
9099         */
9100        public static final String TETHER_OFFLOAD_DISABLED = "tether_offload_disabled";
9101
9102        /**
9103         * List of certificate (hex string representation of the application's certificate - SHA-1
9104         * or SHA-256) and carrier app package pairs which are whitelisted to prompt the user for
9105         * install when a sim card with matching UICC carrier privilege rules is inserted.  The
9106         * certificate is used as a key, so the certificate encoding here must be the same as the
9107         * certificate encoding used on the SIM.
9108         *
9109         * The value is "cert1:package1;cert2:package2;..."
9110         * @hide
9111         */
9112        @SystemApi
9113        public static final String CARRIER_APP_WHITELIST = "carrier_app_whitelist";
9114
9115        /**
9116         * Map of package name to application names.  Package names must be lower cased as they are
9117         * used as a key in the map.  The application names cannot and will not be localized.
9118         *
9119         * The value is "packageName1:appName1;packageName2:appName2;..."
9120         * @hide
9121         */
9122        @SystemApi
9123        public static final String CARRIER_APP_NAMES = "carrier_app_names";
9124
9125       /**
9126        * USB Mass Storage Enabled
9127        */
9128       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
9129
9130       private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9131
9132       /**
9133        * If this setting is set (to anything), then all references
9134        * to Gmail on the device must change to Google Mail.
9135        */
9136       public static final String USE_GOOGLE_MAIL = "use_google_mail";
9137
9138        /**
9139         * Webview Data reduction proxy key.
9140         * @hide
9141         */
9142        public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
9143                "webview_data_reduction_proxy_key";
9144
9145       /**
9146        * Whether or not the WebView fallback mechanism should be enabled.
9147        * 0=disabled, 1=enabled.
9148        * @hide
9149        */
9150       public static final String WEBVIEW_FALLBACK_LOGIC_ENABLED =
9151               "webview_fallback_logic_enabled";
9152
9153       /**
9154        * Name of the package used as WebView provider (if unset the provider is instead determined
9155        * by the system).
9156        * @hide
9157        */
9158       public static final String WEBVIEW_PROVIDER = "webview_provider";
9159
9160       /**
9161        * Developer setting to enable WebView multiprocess rendering.
9162        * @hide
9163        */
9164       @SystemApi
9165       public static final String WEBVIEW_MULTIPROCESS = "webview_multiprocess";
9166
9167       /**
9168        * The maximum number of notifications shown in 24 hours when switching networks.
9169        * @hide
9170        */
9171       public static final String NETWORK_SWITCH_NOTIFICATION_DAILY_LIMIT =
9172              "network_switch_notification_daily_limit";
9173
9174       /**
9175        * The minimum time in milliseconds between notifications when switching networks.
9176        * @hide
9177        */
9178       public static final String NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS =
9179              "network_switch_notification_rate_limit_millis";
9180
9181       /**
9182        * Whether to automatically switch away from wifi networks that lose Internet access.
9183        * Only meaningful if config_networkAvoidBadWifi is set to 0, otherwise the system always
9184        * avoids such networks. Valid values are:
9185        *
9186        * 0: Don't avoid bad wifi, don't prompt the user. Get stuck on bad wifi like it's 2013.
9187        * null: Ask the user whether to switch away from bad wifi.
9188        * 1: Avoid bad wifi.
9189        *
9190        * @hide
9191        */
9192       public static final String NETWORK_AVOID_BAD_WIFI = "network_avoid_bad_wifi";
9193
9194       /**
9195        * User setting for ConnectivityManager.getMeteredMultipathPreference(). This value may be
9196        * overridden by the system based on device or application state. If null, the value
9197        * specified by config_networkMeteredMultipathPreference is used.
9198        *
9199        * @hide
9200        */
9201       public static final String NETWORK_METERED_MULTIPATH_PREFERENCE =
9202               "network_metered_multipath_preference";
9203
9204        /**
9205         * Network watchlist last report time.
9206         * @hide
9207         */
9208        public static final String NETWORK_WATCHLIST_LAST_REPORT_TIME =
9209                "network_watchlist_last_report_time";
9210
9211       /**
9212        * The thresholds of the wifi throughput badging (SD, HD etc.) as a comma-delimited list of
9213        * colon-delimited key-value pairs. The key is the badging enum value defined in
9214        * android.net.ScoredNetwork and the value is the minimum sustained network throughput in
9215        * kbps required for the badge. For example: "10:3000,20:5000,30:25000"
9216        *
9217        * @hide
9218        */
9219       @SystemApi
9220       public static final String WIFI_BADGING_THRESHOLDS = "wifi_badging_thresholds";
9221
9222       /**
9223        * Whether Wifi display is enabled/disabled
9224        * 0=disabled. 1=enabled.
9225        * @hide
9226        */
9227       public static final String WIFI_DISPLAY_ON = "wifi_display_on";
9228
9229       /**
9230        * Whether Wifi display certification mode is enabled/disabled
9231        * 0=disabled. 1=enabled.
9232        * @hide
9233        */
9234       public static final String WIFI_DISPLAY_CERTIFICATION_ON =
9235               "wifi_display_certification_on";
9236
9237       /**
9238        * WPS Configuration method used by Wifi display, this setting only
9239        * takes effect when WIFI_DISPLAY_CERTIFICATION_ON is 1 (enabled).
9240        *
9241        * Possible values are:
9242        *
9243        * WpsInfo.INVALID: use default WPS method chosen by framework
9244        * WpsInfo.PBC    : use Push button
9245        * WpsInfo.KEYPAD : use Keypad
9246        * WpsInfo.DISPLAY: use Display
9247        * @hide
9248        */
9249       public static final String WIFI_DISPLAY_WPS_CONFIG =
9250           "wifi_display_wps_config";
9251
9252       /**
9253        * Whether to notify the user of open networks.
9254        * <p>
9255        * If not connected and the scan results have an open network, we will
9256        * put this notification up. If we attempt to connect to a network or
9257        * the open network(s) disappear, we remove the notification. When we
9258        * show the notification, we will not show it again for
9259        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
9260        *
9261        * @deprecated This feature is no longer controlled by this setting in
9262        * {@link android.os.Build.VERSION_CODES#O}.
9263        */
9264       @Deprecated
9265       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9266               "wifi_networks_available_notification_on";
9267
9268       private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
9269               BOOLEAN_VALIDATOR;
9270
9271       /**
9272        * Whether to notify the user of carrier networks.
9273        * <p>
9274        * If not connected and the scan results have a carrier network, we will
9275        * put this notification up. If we attempt to connect to a network or
9276        * the carrier network(s) disappear, we remove the notification. When we
9277        * show the notification, we will not show it again for
9278        * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
9279        * @hide
9280        */
9281       public static final String WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9282               "wifi_carrier_networks_available_notification_on";
9283
9284       private static final Validator WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
9285               BOOLEAN_VALIDATOR;
9286
9287       /**
9288        * {@hide}
9289        */
9290       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9291               "wimax_networks_available_notification_on";
9292
9293       /**
9294        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
9295        * Connecting to a network will reset the timer.
9296        */
9297       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
9298               "wifi_networks_available_repeat_delay";
9299
9300       private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR =
9301               NON_NEGATIVE_INTEGER_VALIDATOR;
9302
9303       /**
9304        * 802.11 country code in ISO 3166 format
9305        * @hide
9306        */
9307       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
9308
9309       /**
9310        * The interval in milliseconds to issue wake up scans when wifi needs
9311        * to connect. This is necessary to connect to an access point when
9312        * device is on the move and the screen is off.
9313        * @hide
9314        */
9315       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
9316               "wifi_framework_scan_interval_ms";
9317
9318       /**
9319        * The interval in milliseconds after which Wi-Fi is considered idle.
9320        * When idle, it is possible for the device to be switched from Wi-Fi to
9321        * the mobile data network.
9322        * @hide
9323        */
9324       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
9325
9326       /**
9327        * When the number of open networks exceeds this number, the
9328        * least-recently-used excess networks will be removed.
9329        */
9330       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
9331
9332       private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR =
9333               NON_NEGATIVE_INTEGER_VALIDATOR;
9334
9335       /**
9336        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
9337        */
9338       public static final String WIFI_ON = "wifi_on";
9339
9340       /**
9341        * Setting to allow scans to be enabled even wifi is turned off for connectivity.
9342        * @hide
9343        */
9344       public static final String WIFI_SCAN_ALWAYS_AVAILABLE =
9345                "wifi_scan_always_enabled";
9346
9347        /**
9348         * Whether soft AP will shut down after a timeout period when no devices are connected.
9349         *
9350         * Type: int (0 for false, 1 for true)
9351         * @hide
9352         */
9353        public static final String SOFT_AP_TIMEOUT_ENABLED = "soft_ap_timeout_enabled";
9354
9355        private static final Validator SOFT_AP_TIMEOUT_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9356
9357        /**
9358         * Value to specify if Wi-Fi Wakeup feature is enabled.
9359         *
9360         * Type: int (0 for false, 1 for true)
9361         * @hide
9362         */
9363        @SystemApi
9364        public static final String WIFI_WAKEUP_ENABLED = "wifi_wakeup_enabled";
9365
9366        private static final Validator WIFI_WAKEUP_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9367
9368        /**
9369         * Value to specify whether network quality scores and badging should be shown in the UI.
9370         *
9371         * Type: int (0 for false, 1 for true)
9372         * @hide
9373         */
9374        public static final String NETWORK_SCORING_UI_ENABLED = "network_scoring_ui_enabled";
9375
9376        /**
9377         * Value to specify how long in milliseconds to retain seen score cache curves to be used
9378         * when generating SSID only bases score curves.
9379         *
9380         * Type: long
9381         * @hide
9382         */
9383        public static final String SPEED_LABEL_CACHE_EVICTION_AGE_MILLIS =
9384                "speed_label_cache_eviction_age_millis";
9385
9386        /**
9387         * Value to specify if network recommendations from
9388         * {@link com.android.server.NetworkScoreService} are enabled.
9389         *
9390         * Type: int
9391         * Valid values:
9392         *   -1 = Forced off
9393         *    0 = Disabled
9394         *    1 = Enabled
9395         *
9396         * Most readers of this setting should simply check if value == 1 to determined the
9397         * enabled state.
9398         * @hide
9399         */
9400        public static final String NETWORK_RECOMMENDATIONS_ENABLED =
9401                "network_recommendations_enabled";
9402
9403        private static final Validator NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR =
9404                new SettingsValidators.DiscreteValueValidator(new String[] {"-1", "0", "1"});
9405
9406        /**
9407         * Which package name to use for network recommendations. If null, network recommendations
9408         * will neither be requested nor accepted.
9409         *
9410         * Use {@link NetworkScoreManager#getActiveScorerPackage()} to read this value and
9411         * {@link NetworkScoreManager#setActiveScorer(String)} to write it.
9412         *
9413         * Type: string - package name
9414         * @hide
9415         */
9416        public static final String NETWORK_RECOMMENDATIONS_PACKAGE =
9417                "network_recommendations_package";
9418
9419        /**
9420         * The package name of the application that connect and secures high quality open wifi
9421         * networks automatically.
9422         *
9423         * Type: string package name or null if the feature is either not provided or disabled.
9424         * @hide
9425         */
9426        @TestApi
9427        public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package";
9428
9429        private static final Validator USE_OPEN_WIFI_PACKAGE_VALIDATOR = new Validator() {
9430            @Override
9431            public boolean validate(String value) {
9432                return (value == null) || PACKAGE_NAME_VALIDATOR.validate(value);
9433            }
9434        };
9435
9436        /**
9437         * The number of milliseconds the {@link com.android.server.NetworkScoreService}
9438         * will give a recommendation request to complete before returning a default response.
9439         *
9440         * Type: long
9441         * @hide
9442         * @deprecated to be removed
9443         */
9444        public static final String NETWORK_RECOMMENDATION_REQUEST_TIMEOUT_MS =
9445                "network_recommendation_request_timeout_ms";
9446
9447        /**
9448         * The expiration time in milliseconds for the {@link android.net.WifiKey} request cache in
9449         * {@link com.android.server.wifi.RecommendedNetworkEvaluator}.
9450         *
9451         * Type: long
9452         * @hide
9453         */
9454        public static final String RECOMMENDED_NETWORK_EVALUATOR_CACHE_EXPIRY_MS =
9455                "recommended_network_evaluator_cache_expiry_ms";
9456
9457        /**
9458        * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
9459        * connectivity.
9460        * @hide
9461        */
9462        public static final String BLE_SCAN_ALWAYS_AVAILABLE = "ble_scan_always_enabled";
9463
9464        /**
9465         * The length in milliseconds of a BLE scan window in a low-power scan mode.
9466         * @hide
9467         */
9468        public static final String BLE_SCAN_LOW_POWER_WINDOW_MS = "ble_scan_low_power_window_ms";
9469
9470        /**
9471         * The length in milliseconds of a BLE scan window in a balanced scan mode.
9472         * @hide
9473         */
9474        public static final String BLE_SCAN_BALANCED_WINDOW_MS = "ble_scan_balanced_window_ms";
9475
9476        /**
9477         * The length in milliseconds of a BLE scan window in a low-latency scan mode.
9478         * @hide
9479         */
9480        public static final String BLE_SCAN_LOW_LATENCY_WINDOW_MS =
9481                "ble_scan_low_latency_window_ms";
9482
9483        /**
9484         * The length in milliseconds of a BLE scan interval in a low-power scan mode.
9485         * @hide
9486         */
9487        public static final String BLE_SCAN_LOW_POWER_INTERVAL_MS =
9488                "ble_scan_low_power_interval_ms";
9489
9490        /**
9491         * The length in milliseconds of a BLE scan interval in a balanced scan mode.
9492         * @hide
9493         */
9494        public static final String BLE_SCAN_BALANCED_INTERVAL_MS =
9495                "ble_scan_balanced_interval_ms";
9496
9497        /**
9498         * The length in milliseconds of a BLE scan interval in a low-latency scan mode.
9499         * @hide
9500         */
9501        public static final String BLE_SCAN_LOW_LATENCY_INTERVAL_MS =
9502                "ble_scan_low_latency_interval_ms";
9503
9504       /**
9505        * Used to save the Wifi_ON state prior to tethering.
9506        * This state will be checked to restore Wifi after
9507        * the user turns off tethering.
9508        *
9509        * @hide
9510        */
9511       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
9512
9513       /**
9514        * The interval in milliseconds to scan as used by the wifi supplicant
9515        * @hide
9516        */
9517       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
9518               "wifi_supplicant_scan_interval_ms";
9519
9520        /**
9521         * whether frameworks handles wifi auto-join
9522         * @hide
9523         */
9524       public static final String WIFI_ENHANCED_AUTO_JOIN =
9525                "wifi_enhanced_auto_join";
9526
9527        /**
9528         * whether settings show RSSI
9529         * @hide
9530         */
9531        public static final String WIFI_NETWORK_SHOW_RSSI =
9532                "wifi_network_show_rssi";
9533
9534        /**
9535        * The interval in milliseconds to scan at supplicant when p2p is connected
9536        * @hide
9537        */
9538       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
9539               "wifi_scan_interval_p2p_connected_ms";
9540
9541       /**
9542        * Whether the Wi-Fi watchdog is enabled.
9543        */
9544       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
9545
9546       /**
9547        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
9548        * the setting needs to be set to 0 to disable it.
9549        * @hide
9550        */
9551       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
9552               "wifi_watchdog_poor_network_test_enabled";
9553
9554       private static final Validator WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR =
9555               ANY_STRING_VALIDATOR;
9556
9557       /**
9558        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
9559        * needs to be set to 0 to disable it.
9560        * @hide
9561        */
9562       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
9563               "wifi_suspend_optimizations_enabled";
9564
9565       /**
9566        * Setting to enable verbose logging in Wi-Fi; disabled by default, and setting to 1
9567        * will enable it. In the future, additional values may be supported.
9568        * @hide
9569        */
9570       public static final String WIFI_VERBOSE_LOGGING_ENABLED =
9571               "wifi_verbose_logging_enabled";
9572
9573        /**
9574         * Setting to enable connected MAC randomization in Wi-Fi; disabled by default, and
9575         * setting to 1 will enable it. In the future, additional values may be supported.
9576         * @hide
9577         */
9578        public static final String WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED =
9579                "wifi_connected_mac_randomization_enabled";
9580
9581       /**
9582        * The maximum number of times we will retry a connection to an access
9583        * point for which we have failed in acquiring an IP address from DHCP.
9584        * A value of N means that we will make N+1 connection attempts in all.
9585        */
9586       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
9587
9588       /**
9589        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
9590        * data connectivity to be established after a disconnect from Wi-Fi.
9591        */
9592       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
9593           "wifi_mobile_data_transition_wakelock_timeout_ms";
9594
9595       /**
9596        * This setting controls whether WiFi configurations created by a Device Owner app
9597        * should be locked down (that is, be editable or removable only by the Device Owner App,
9598        * not even by Settings app).
9599        * This setting takes integer values. Non-zero values mean DO created configurations
9600        * are locked down. Value of zero means they are not. Default value in the absence of
9601        * actual value to this setting is 0.
9602        */
9603       public static final String WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN =
9604               "wifi_device_owner_configs_lockdown";
9605
9606       /**
9607        * The operational wifi frequency band
9608        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
9609        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
9610        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
9611        *
9612        * @hide
9613        */
9614       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
9615
9616       /**
9617        * The Wi-Fi peer-to-peer device name
9618        * @hide
9619        */
9620       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
9621
9622       /**
9623        * The min time between wifi disable and wifi enable
9624        * @hide
9625        */
9626       public static final String WIFI_REENABLE_DELAY_MS = "wifi_reenable_delay";
9627
9628       /**
9629        * Timeout for ephemeral networks when all known BSSIDs go out of range. We will disconnect
9630        * from an ephemeral network if there is no BSSID for that network with a non-null score that
9631        * has been seen in this time period.
9632        *
9633        * If this is less than or equal to zero, we use a more conservative behavior and only check
9634        * for a non-null score from the currently connected or target BSSID.
9635        * @hide
9636        */
9637       public static final String WIFI_EPHEMERAL_OUT_OF_RANGE_TIMEOUT_MS =
9638               "wifi_ephemeral_out_of_range_timeout_ms";
9639
9640       /**
9641        * The number of milliseconds to delay when checking for data stalls during
9642        * non-aggressive detection. (screen is turned off.)
9643        * @hide
9644        */
9645       public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
9646               "data_stall_alarm_non_aggressive_delay_in_ms";
9647
9648       /**
9649        * The number of milliseconds to delay when checking for data stalls during
9650        * aggressive detection. (screen on or suspected data stall)
9651        * @hide
9652        */
9653       public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
9654               "data_stall_alarm_aggressive_delay_in_ms";
9655
9656       /**
9657        * The number of milliseconds to allow the provisioning apn to remain active
9658        * @hide
9659        */
9660       public static final String PROVISIONING_APN_ALARM_DELAY_IN_MS =
9661               "provisioning_apn_alarm_delay_in_ms";
9662
9663       /**
9664        * The interval in milliseconds at which to check gprs registration
9665        * after the first registration mismatch of gprs and voice service,
9666        * to detect possible data network registration problems.
9667        *
9668        * @hide
9669        */
9670       public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
9671               "gprs_register_check_period_ms";
9672
9673       /**
9674        * Nonzero causes Log.wtf() to crash.
9675        * @hide
9676        */
9677       public static final String WTF_IS_FATAL = "wtf_is_fatal";
9678
9679       /**
9680        * Ringer mode. This is used internally, changing this value will not
9681        * change the ringer mode. See AudioManager.
9682        */
9683       public static final String MODE_RINGER = "mode_ringer";
9684
9685       /**
9686        * Overlay display devices setting.
9687        * The associated value is a specially formatted string that describes the
9688        * size and density of simulated secondary display devices.
9689        * <p>
9690        * Format: {width}x{height}/{dpi};...
9691        * </p><p>
9692        * Example:
9693        * <ul>
9694        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
9695        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
9696        * at 1080p and the second at 720p.</li>
9697        * <li>If the value is empty, then no overlay display devices are created.</li>
9698        * </ul></p>
9699        *
9700        * @hide
9701        */
9702       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
9703
9704        /**
9705         * Threshold values for the duration and level of a discharge cycle,
9706         * under which we log discharge cycle info.
9707         *
9708         * @hide
9709         */
9710        public static final String
9711                BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold";
9712
9713        /** @hide */
9714        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
9715
9716        /**
9717         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR
9718         * intents on application crashes and ANRs. If this is disabled, the
9719         * crash/ANR dialog will never display the "Report" button.
9720         * <p>
9721         * Type: int (0 = disallow, 1 = allow)
9722         *
9723         * @hide
9724         */
9725        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
9726
9727        /**
9728         * Maximum age of entries kept by {@link DropBoxManager}.
9729         *
9730         * @hide
9731         */
9732        public static final String DROPBOX_AGE_SECONDS = "dropbox_age_seconds";
9733
9734        /**
9735         * Maximum number of entry files which {@link DropBoxManager} will keep
9736         * around.
9737         *
9738         * @hide
9739         */
9740        public static final String DROPBOX_MAX_FILES = "dropbox_max_files";
9741
9742        /**
9743         * Maximum amount of disk space used by {@link DropBoxManager} no matter
9744         * what.
9745         *
9746         * @hide
9747         */
9748        public static final String DROPBOX_QUOTA_KB = "dropbox_quota_kb";
9749
9750        /**
9751         * Percent of free disk (excluding reserve) which {@link DropBoxManager}
9752         * will use.
9753         *
9754         * @hide
9755         */
9756        public static final String DROPBOX_QUOTA_PERCENT = "dropbox_quota_percent";
9757
9758        /**
9759         * Percent of total disk which {@link DropBoxManager} will never dip
9760         * into.
9761         *
9762         * @hide
9763         */
9764        public static final String DROPBOX_RESERVE_PERCENT = "dropbox_reserve_percent";
9765
9766        /**
9767         * Prefix for per-tag dropbox disable/enable settings.
9768         *
9769         * @hide
9770         */
9771        public static final String DROPBOX_TAG_PREFIX = "dropbox:";
9772
9773        /**
9774         * Lines of logcat to include with system crash/ANR/etc. reports, as a
9775         * prefix of the dropbox tag of the report type. For example,
9776         * "logcat_for_system_server_anr" controls the lines of logcat captured
9777         * with system server ANR reports. 0 to disable.
9778         *
9779         * @hide
9780         */
9781        public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
9782
9783        /**
9784         * The interval in minutes after which the amount of free storage left
9785         * on the device is logged to the event log
9786         *
9787         * @hide
9788         */
9789        public static final String SYS_FREE_STORAGE_LOG_INTERVAL = "sys_free_storage_log_interval";
9790
9791        /**
9792         * Threshold for the amount of change in disk free space required to
9793         * report the amount of free space. Used to prevent spamming the logs
9794         * when the disk free space isn't changing frequently.
9795         *
9796         * @hide
9797         */
9798        public static final String
9799                DISK_FREE_CHANGE_REPORTING_THRESHOLD = "disk_free_change_reporting_threshold";
9800
9801        /**
9802         * Minimum percentage of free storage on the device that is used to
9803         * determine if the device is running low on storage. The default is 10.
9804         * <p>
9805         * Say this value is set to 10, the device is considered running low on
9806         * storage if 90% or more of the device storage is filled up.
9807         *
9808         * @hide
9809         */
9810        public static final String
9811                SYS_STORAGE_THRESHOLD_PERCENTAGE = "sys_storage_threshold_percentage";
9812
9813        /**
9814         * Maximum byte size of the low storage threshold. This is to ensure
9815         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in an
9816         * overly large threshold for large storage devices. Currently this must
9817         * be less than 2GB. This default is 500MB.
9818         *
9819         * @hide
9820         */
9821        public static final String
9822                SYS_STORAGE_THRESHOLD_MAX_BYTES = "sys_storage_threshold_max_bytes";
9823
9824        /**
9825         * Minimum bytes of free storage on the device before the data partition
9826         * is considered full. By default, 1 MB is reserved to avoid system-wide
9827         * SQLite disk full exceptions.
9828         *
9829         * @hide
9830         */
9831        public static final String
9832                SYS_STORAGE_FULL_THRESHOLD_BYTES = "sys_storage_full_threshold_bytes";
9833
9834        /**
9835         * Minimum percentage of storage on the device that is reserved for
9836         * cached data.
9837         *
9838         * @hide
9839         */
9840        public static final String
9841                SYS_STORAGE_CACHE_PERCENTAGE = "sys_storage_cache_percentage";
9842
9843        /**
9844         * Maximum bytes of storage on the device that is reserved for cached
9845         * data.
9846         *
9847         * @hide
9848         */
9849        public static final String
9850                SYS_STORAGE_CACHE_MAX_BYTES = "sys_storage_cache_max_bytes";
9851
9852        /**
9853         * The maximum reconnect delay for short network outages or when the
9854         * network is suspended due to phone use.
9855         *
9856         * @hide
9857         */
9858        public static final String
9859                SYNC_MAX_RETRY_DELAY_IN_SECONDS = "sync_max_retry_delay_in_seconds";
9860
9861        /**
9862         * The number of milliseconds to delay before sending out
9863         * {@link ConnectivityManager#CONNECTIVITY_ACTION} broadcasts. Ignored.
9864         *
9865         * @hide
9866         */
9867        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
9868
9869
9870        /**
9871         * Network sampling interval, in seconds. We'll generate link information
9872         * about bytes/packets sent and error rates based on data sampled in this interval
9873         *
9874         * @hide
9875         */
9876
9877        public static final String CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS =
9878                "connectivity_sampling_interval_in_seconds";
9879
9880        /**
9881         * The series of successively longer delays used in retrying to download PAC file.
9882         * Last delay is used between successful PAC downloads.
9883         *
9884         * @hide
9885         */
9886        public static final String PAC_CHANGE_DELAY = "pac_change_delay";
9887
9888        /**
9889         * Don't attempt to detect captive portals.
9890         *
9891         * @hide
9892         */
9893        public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0;
9894
9895        /**
9896         * When detecting a captive portal, display a notification that
9897         * prompts the user to sign in.
9898         *
9899         * @hide
9900         */
9901        public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1;
9902
9903        /**
9904         * When detecting a captive portal, immediately disconnect from the
9905         * network and do not reconnect to that network in the future.
9906         *
9907         * @hide
9908         */
9909        public static final int CAPTIVE_PORTAL_MODE_AVOID = 2;
9910
9911        /**
9912         * What to do when connecting a network that presents a captive portal.
9913         * Must be one of the CAPTIVE_PORTAL_MODE_* constants above.
9914         *
9915         * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT.
9916         * @hide
9917         */
9918        public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode";
9919
9920        /**
9921         * Setting to turn off captive portal detection. Feature is enabled by
9922         * default and the setting needs to be set to 0 to disable it.
9923         *
9924         * @deprecated use CAPTIVE_PORTAL_MODE_IGNORE to disable captive portal detection
9925         * @hide
9926         */
9927        @Deprecated
9928        public static final String
9929                CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled";
9930
9931        /**
9932         * The server used for captive portal detection upon a new conection. A
9933         * 204 response code from the server is used for validation.
9934         * TODO: remove this deprecated symbol.
9935         *
9936         * @hide
9937         */
9938        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
9939
9940        /**
9941         * The URL used for HTTPS captive portal detection upon a new connection.
9942         * A 204 response code from the server is used for validation.
9943         *
9944         * @hide
9945         */
9946        public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url";
9947
9948        /**
9949         * The URL used for HTTP captive portal detection upon a new connection.
9950         * A 204 response code from the server is used for validation.
9951         *
9952         * @hide
9953         */
9954        public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url";
9955
9956        /**
9957         * The URL used for fallback HTTP captive portal detection when previous HTTP
9958         * and HTTPS captive portal detection attemps did not return a conclusive answer.
9959         *
9960         * @hide
9961         */
9962        public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url";
9963
9964        /**
9965         * A comma separated list of URLs used for captive portal detection in addition to the
9966         * fallback HTTP url associated with the CAPTIVE_PORTAL_FALLBACK_URL settings.
9967         *
9968         * @hide
9969         */
9970        public static final String CAPTIVE_PORTAL_OTHER_FALLBACK_URLS =
9971                "captive_portal_other_fallback_urls";
9972
9973        /**
9974         * Whether to use HTTPS for network validation. This is enabled by default and the setting
9975         * needs to be set to 0 to disable it. This setting is a misnomer because captive portals
9976         * don't actually use HTTPS, but it's consistent with the other settings.
9977         *
9978         * @hide
9979         */
9980        public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https";
9981
9982        /**
9983         * Which User-Agent string to use in the header of the captive portal detection probes.
9984         * The User-Agent field is unset when this setting has no value (HttpUrlConnection default).
9985         *
9986         * @hide
9987         */
9988        public static final String CAPTIVE_PORTAL_USER_AGENT = "captive_portal_user_agent";
9989
9990        /**
9991         * Whether network service discovery is enabled.
9992         *
9993         * @hide
9994         */
9995        public static final String NSD_ON = "nsd_on";
9996
9997        /**
9998         * Let user pick default install location.
9999         *
10000         * @hide
10001         */
10002        public static final String SET_INSTALL_LOCATION = "set_install_location";
10003
10004        /**
10005         * Default install location value.
10006         * 0 = auto, let system decide
10007         * 1 = internal
10008         * 2 = sdcard
10009         * @hide
10010         */
10011        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
10012
10013        /**
10014         * ms during which to consume extra events related to Inet connection
10015         * condition after a transtion to fully-connected
10016         *
10017         * @hide
10018         */
10019        public static final String
10020                INET_CONDITION_DEBOUNCE_UP_DELAY = "inet_condition_debounce_up_delay";
10021
10022        /**
10023         * ms during which to consume extra events related to Inet connection
10024         * condtion after a transtion to partly-connected
10025         *
10026         * @hide
10027         */
10028        public static final String
10029                INET_CONDITION_DEBOUNCE_DOWN_DELAY = "inet_condition_debounce_down_delay";
10030
10031        /** {@hide} */
10032        public static final String
10033                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
10034
10035        /**
10036         * Host name and port for global http proxy. Uses ':' seperator for
10037         * between host and port.
10038         */
10039        public static final String HTTP_PROXY = "http_proxy";
10040
10041        /**
10042         * Host name for global http proxy. Set via ConnectivityManager.
10043         *
10044         * @hide
10045         */
10046        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
10047
10048        /**
10049         * Integer host port for global http proxy. Set via ConnectivityManager.
10050         *
10051         * @hide
10052         */
10053        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
10054
10055        /**
10056         * Exclusion list for global proxy. This string contains a list of
10057         * comma-separated domains where the global proxy does not apply.
10058         * Domains should be listed in a comma- separated list. Example of
10059         * acceptable formats: ".domain1.com,my.domain2.com" Use
10060         * ConnectivityManager to set/get.
10061         *
10062         * @hide
10063         */
10064        public static final String
10065                GLOBAL_HTTP_PROXY_EXCLUSION_LIST = "global_http_proxy_exclusion_list";
10066
10067        /**
10068         * The location PAC File for the proxy.
10069         * @hide
10070         */
10071        public static final String
10072                GLOBAL_HTTP_PROXY_PAC = "global_proxy_pac_url";
10073
10074        /**
10075         * Enables the UI setting to allow the user to specify the global HTTP
10076         * proxy and associated exclusion list.
10077         *
10078         * @hide
10079         */
10080        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
10081
10082        /**
10083         * Setting for default DNS in case nobody suggests one
10084         *
10085         * @hide
10086         */
10087        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
10088
10089        /**
10090         * The requested Private DNS mode (string), and an accompanying specifier (string).
10091         *
10092         * Currently, the specifier holds the chosen provider name when the mode requests
10093         * a specific provider. It may be used to store the provider name even when the
10094         * mode changes so that temporarily disabling and re-enabling the specific
10095         * provider mode does not necessitate retyping the provider hostname.
10096         *
10097         * @hide
10098         */
10099        public static final String PRIVATE_DNS_MODE = "private_dns_mode";
10100
10101        private static final Validator PRIVATE_DNS_MODE_VALIDATOR = ANY_STRING_VALIDATOR;
10102
10103        /**
10104         * @hide
10105         */
10106        public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier";
10107
10108        private static final Validator PRIVATE_DNS_SPECIFIER_VALIDATOR = ANY_STRING_VALIDATOR;
10109
10110        /** {@hide} */
10111        public static final String
10112                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
10113        /** {@hide} */
10114        public static final String
10115                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
10116        /** {@hide} */
10117        public static final String
10118                BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX = "bluetooth_a2dp_src_priority_";
10119        /** {@hide} */
10120        public static final String BLUETOOTH_A2DP_SUPPORTS_OPTIONAL_CODECS_PREFIX =
10121                "bluetooth_a2dp_supports_optional_codecs_";
10122        /** {@hide} */
10123        public static final String BLUETOOTH_A2DP_OPTIONAL_CODECS_ENABLED_PREFIX =
10124                "bluetooth_a2dp_optional_codecs_enabled_";
10125        /** {@hide} */
10126        public static final String
10127                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
10128        /** {@hide} */
10129        public static final String
10130                BLUETOOTH_MAP_PRIORITY_PREFIX = "bluetooth_map_priority_";
10131        /** {@hide} */
10132        public static final String
10133                BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX = "bluetooth_map_client_priority_";
10134        /** {@hide} */
10135        public static final String
10136                BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX = "bluetooth_pbap_client_priority_";
10137        /** {@hide} */
10138        public static final String
10139                BLUETOOTH_SAP_PRIORITY_PREFIX = "bluetooth_sap_priority_";
10140        /** {@hide} */
10141        public static final String
10142                BLUETOOTH_PAN_PRIORITY_PREFIX = "bluetooth_pan_priority_";
10143        /** {@hide} */
10144        public static final String
10145                BLUETOOTH_HEARING_AID_PRIORITY_PREFIX = "bluetooth_hearing_aid_priority_";
10146
10147        /**
10148         * Activity manager specific settings.
10149         * This is encoded as a key=value list, separated by commas. Ex:
10150         *
10151         * "gc_timeout=5000,max_cached_processes=24"
10152         *
10153         * The following keys are supported:
10154         *
10155         * <pre>
10156         * max_cached_processes                 (int)
10157         * background_settle_time               (long)
10158         * fgservice_min_shown_time             (long)
10159         * fgservice_min_report_time            (long)
10160         * fgservice_screen_on_before_time      (long)
10161         * fgservice_screen_on_after_time       (long)
10162         * content_provider_retain_time         (long)
10163         * gc_timeout                           (long)
10164         * gc_min_interval                      (long)
10165         * full_pss_min_interval                (long)
10166         * full_pss_lowered_interval            (long)
10167         * power_check_interval                 (long)
10168         * power_check_max_cpu_1                (int)
10169         * power_check_max_cpu_2                (int)
10170         * power_check_max_cpu_3                (int)
10171         * power_check_max_cpu_4                (int)
10172         * service_usage_interaction_time       (long)
10173         * usage_stats_interaction_interval     (long)
10174         * service_restart_duration             (long)
10175         * service_reset_run_duration           (long)
10176         * service_restart_duration_factor      (int)
10177         * service_min_restart_time_between     (long)
10178         * service_max_inactivity               (long)
10179         * service_bg_start_timeout             (long)
10180         * process_start_async                  (boolean)
10181         * </pre>
10182         *
10183         * <p>
10184         * Type: string
10185         * @hide
10186         * @see com.android.server.am.ActivityManagerConstants
10187         */
10188        public static final String ACTIVITY_MANAGER_CONSTANTS = "activity_manager_constants";
10189
10190        /**
10191         * Device Idle (Doze) specific settings.
10192         * This is encoded as a key=value list, separated by commas. Ex:
10193         *
10194         * "inactive_to=60000,sensing_to=400000"
10195         *
10196         * The following keys are supported:
10197         *
10198         * <pre>
10199         * inactive_to                      (long)
10200         * sensing_to                       (long)
10201         * motion_inactive_to               (long)
10202         * idle_after_inactive_to           (long)
10203         * idle_pending_to                  (long)
10204         * max_idle_pending_to              (long)
10205         * idle_pending_factor              (float)
10206         * idle_to                          (long)
10207         * max_idle_to                      (long)
10208         * idle_factor                      (float)
10209         * min_time_to_alarm                (long)
10210         * max_temp_app_whitelist_duration  (long)
10211         * notification_whitelist_duration  (long)
10212         * </pre>
10213         *
10214         * <p>
10215         * Type: string
10216         * @hide
10217         * @see com.android.server.DeviceIdleController.Constants
10218         */
10219        public static final String DEVICE_IDLE_CONSTANTS = "device_idle_constants";
10220
10221        /**
10222         * Battery Saver specific settings
10223         * This is encoded as a key=value list, separated by commas. Ex:
10224         *
10225         * "vibration_disabled=true,adjust_brightness_factor=0.5"
10226         *
10227         * The following keys are supported:
10228         *
10229         * <pre>
10230         * vibration_disabled                (boolean)
10231         * animation_disabled                (boolean)
10232         * soundtrigger_disabled             (boolean)
10233         * fullbackup_deferred               (boolean)
10234         * keyvaluebackup_deferred           (boolean)
10235         * firewall_disabled                 (boolean)
10236         * gps_mode                          (int)
10237         * adjust_brightness_disabled        (boolean)
10238         * adjust_brightness_factor          (float)
10239         * </pre>
10240         * @hide
10241         * @see com.android.server.power.BatterySaverPolicy
10242         */
10243        public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";
10244
10245        /**
10246         * Battery Saver device specific settings
10247         * This is encoded as a key=value list, separated by commas.
10248         * See {@link com.android.server.power.BatterySaverPolicy} for the details.
10249         *
10250         * @hide
10251         */
10252        public static final String BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS =
10253                "battery_saver_device_specific_constants";
10254
10255        /**
10256         * Battery anomaly detection specific settings
10257         * This is encoded as a key=value list, separated by commas.
10258         * wakeup_blacklisted_tags is a string, encoded as a set of tags, encoded via
10259         * {@link Uri#encode(String)}, separated by colons. Ex:
10260         *
10261         * "anomaly_detection_enabled=true,wakelock_threshold=2000,wakeup_alarm_enabled=true,"
10262         * "wakeup_alarm_threshold=10,wakeup_blacklisted_tags=tag1:tag2:with%2Ccomma:with%3Acolon"
10263         *
10264         * The following keys are supported:
10265         *
10266         * <pre>
10267         * anomaly_detection_enabled       (boolean)
10268         * wakelock_enabled                (boolean)
10269         * wakelock_threshold              (long)
10270         * wakeup_alarm_enabled            (boolean)
10271         * wakeup_alarm_threshold          (long)
10272         * wakeup_blacklisted_tags         (string)
10273         * bluetooth_scan_enabled          (boolean)
10274         * bluetooth_scan_threshold        (long)
10275         * </pre>
10276         * @hide
10277         */
10278        public static final String ANOMALY_DETECTION_CONSTANTS = "anomaly_detection_constants";
10279
10280        /**
10281         * Battery tip specific settings
10282         * This is encoded as a key=value list, separated by commas. Ex:
10283         *
10284         * "battery_tip_enabled=true,summary_enabled=true,high_usage_enabled=true,"
10285         * "high_usage_app_count=3,reduced_battery_enabled=false,reduced_battery_percent=50,"
10286         * "high_usage_battery_draining=25,high_usage_period_ms=3000"
10287         *
10288         * The following keys are supported:
10289         *
10290         * <pre>
10291         * battery_tip_enabled              (boolean)
10292         * summary_enabled                  (boolean)
10293         * battery_saver_tip_enabled        (boolean)
10294         * high_usage_enabled               (boolean)
10295         * high_usage_app_count             (int)
10296         * high_usage_period_ms             (long)
10297         * high_usage_battery_draining      (int)
10298         * app_restriction_enabled          (boolean)
10299         * reduced_battery_enabled          (boolean)
10300         * reduced_battery_percent          (int)
10301         * low_battery_enabled              (boolean)
10302         * low_battery_hour                 (int)
10303         * </pre>
10304         * @hide
10305         */
10306        public static final String BATTERY_TIP_CONSTANTS = "battery_tip_constants";
10307
10308        /**
10309         * An integer to show the version of the anomaly config. Ex: 1, which means
10310         * current version is 1.
10311         * @hide
10312         */
10313        public static final String ANOMALY_CONFIG_VERSION = "anomaly_config_version";
10314
10315        /**
10316         * A base64-encoded string represents anomaly stats config, used for
10317         * {@link android.app.StatsManager}.
10318         * @hide
10319         */
10320        public static final String ANOMALY_CONFIG = "anomaly_config";
10321
10322        /**
10323         * Always on display(AOD) specific settings
10324         * This is encoded as a key=value list, separated by commas. Ex:
10325         *
10326         * "prox_screen_off_delay=10000,screen_brightness_array=0:1:2:3:4"
10327         *
10328         * The following keys are supported:
10329         *
10330         * <pre>
10331         * screen_brightness_array         (int[])
10332         * dimming_scrim_array             (int[])
10333         * prox_screen_off_delay           (long)
10334         * prox_cooldown_trigger           (long)
10335         * prox_cooldown_period            (long)
10336         * </pre>
10337         * @hide
10338         */
10339        public static final String ALWAYS_ON_DISPLAY_CONSTANTS = "always_on_display_constants";
10340
10341        /**
10342        * System VDSO global setting. This links to the "sys.vdso" system property.
10343        * The following values are supported:
10344        * false  -> both 32 and 64 bit vdso disabled
10345        * 32     -> 32 bit vdso enabled
10346        * 64     -> 64 bit vdso enabled
10347        * Any other value defaults to both 32 bit and 64 bit true.
10348        * @hide
10349        */
10350        public static final String SYS_VDSO = "sys_vdso";
10351
10352        /**
10353        * UidCpuPower global setting. This links the sys.uidcpupower system property.
10354        * The following values are supported:
10355        * 0 -> /proc/uid_cpupower/* are disabled
10356        * 1 -> /proc/uid_cpupower/* are enabled
10357        * Any other value defaults to enabled.
10358        * @hide
10359        */
10360        public static final String SYS_UIDCPUPOWER = "sys_uidcpupower";
10361
10362        /**
10363         * An integer to reduce the FPS by this factor. Only for experiments. Need to reboot the
10364         * device for this setting to take full effect.
10365         *
10366         * @hide
10367         */
10368        public static final String FPS_DEVISOR = "fps_divisor";
10369
10370        /**
10371         * Flag to enable or disable display panel low power mode (lpm)
10372         * false -> Display panel power saving mode is disabled.
10373         * true  -> Display panel power saving mode is enabled.
10374         *
10375         * @hide
10376         */
10377        public static final String DISPLAY_PANEL_LPM = "display_panel_lpm";
10378
10379        /**
10380         * App standby (app idle) specific settings.
10381         * This is encoded as a key=value list, separated by commas. Ex:
10382         * <p>
10383         * "idle_duration=5000,parole_interval=4500"
10384         * <p>
10385         * All durations are in millis.
10386         * The following keys are supported:
10387         *
10388         * <pre>
10389         * idle_duration2       (long)
10390         * wallclock_threshold  (long)
10391         * parole_interval      (long)
10392         * parole_duration      (long)
10393         *
10394         * idle_duration        (long) // This is deprecated and used to circumvent b/26355386.
10395         * </pre>
10396         *
10397         * <p>
10398         * Type: string
10399         * @hide
10400         * @see com.android.server.usage.UsageStatsService.SettingsObserver
10401         */
10402        public static final String APP_IDLE_CONSTANTS = "app_idle_constants";
10403
10404        /**
10405         * Power manager specific settings.
10406         * This is encoded as a key=value list, separated by commas. Ex:
10407         *
10408         * "no_cached_wake_locks=1"
10409         *
10410         * The following keys are supported:
10411         *
10412         * <pre>
10413         * no_cached_wake_locks                 (boolean)
10414         * </pre>
10415         *
10416         * <p>
10417         * Type: string
10418         * @hide
10419         * @see com.android.server.power.PowerManagerConstants
10420         */
10421        public static final String POWER_MANAGER_CONSTANTS = "power_manager_constants";
10422
10423        /**
10424         * Alarm manager specific settings.
10425         * This is encoded as a key=value list, separated by commas. Ex:
10426         *
10427         * "min_futurity=5000,allow_while_idle_short_time=4500"
10428         *
10429         * The following keys are supported:
10430         *
10431         * <pre>
10432         * min_futurity                         (long)
10433         * min_interval                         (long)
10434         * allow_while_idle_short_time          (long)
10435         * allow_while_idle_long_time           (long)
10436         * allow_while_idle_whitelist_duration  (long)
10437         * </pre>
10438         *
10439         * <p>
10440         * Type: string
10441         * @hide
10442         * @see com.android.server.AlarmManagerService.Constants
10443         */
10444        public static final String ALARM_MANAGER_CONSTANTS = "alarm_manager_constants";
10445
10446        /**
10447         * Job scheduler specific settings.
10448         * This is encoded as a key=value list, separated by commas. Ex:
10449         *
10450         * "min_ready_jobs_count=2,moderate_use_factor=.5"
10451         *
10452         * The following keys are supported:
10453         *
10454         * <pre>
10455         * min_idle_count                       (int)
10456         * min_charging_count                   (int)
10457         * min_connectivity_count               (int)
10458         * min_content_count                    (int)
10459         * min_ready_jobs_count                 (int)
10460         * heavy_use_factor                     (float)
10461         * moderate_use_factor                  (float)
10462         * fg_job_count                         (int)
10463         * bg_normal_job_count                  (int)
10464         * bg_moderate_job_count                (int)
10465         * bg_low_job_count                     (int)
10466         * bg_critical_job_count                (int)
10467         * </pre>
10468         *
10469         * <p>
10470         * Type: string
10471         * @hide
10472         * @see com.android.server.job.JobSchedulerService.Constants
10473         */
10474        public static final String JOB_SCHEDULER_CONSTANTS = "job_scheduler_constants";
10475
10476        /**
10477         * ShortcutManager specific settings.
10478         * This is encoded as a key=value list, separated by commas. Ex:
10479         *
10480         * "reset_interval_sec=86400,max_updates_per_interval=1"
10481         *
10482         * The following keys are supported:
10483         *
10484         * <pre>
10485         * reset_interval_sec              (long)
10486         * max_updates_per_interval        (int)
10487         * max_icon_dimension_dp           (int, DP)
10488         * max_icon_dimension_dp_lowram    (int, DP)
10489         * max_shortcuts                   (int)
10490         * icon_quality                    (int, 0-100)
10491         * icon_format                     (String)
10492         * </pre>
10493         *
10494         * <p>
10495         * Type: string
10496         * @hide
10497         * @see com.android.server.pm.ShortcutService.ConfigConstants
10498         */
10499        public static final String SHORTCUT_MANAGER_CONSTANTS = "shortcut_manager_constants";
10500
10501        /**
10502         * DevicePolicyManager specific settings.
10503         * This is encoded as a key=value list, separated by commas. Ex:
10504         *
10505         * <pre>
10506         * das_died_service_reconnect_backoff_sec       (long)
10507         * das_died_service_reconnect_backoff_increase  (float)
10508         * das_died_service_reconnect_max_backoff_sec   (long)
10509         * </pre>
10510         *
10511         * <p>
10512         * Type: string
10513         * @hide
10514         * see also com.android.server.devicepolicy.DevicePolicyConstants
10515         */
10516        public static final String DEVICE_POLICY_CONSTANTS = "device_policy_constants";
10517
10518        /**
10519         * TextClassifier specific settings.
10520         * This is encoded as a key=value list, separated by commas. String[] types like
10521         * entity_list_default use ":" as delimiter for values. Ex:
10522         *
10523         * <pre>
10524         * smart_linkify_enabled                    (boolean)
10525         * system_textclassifier_enabled            (boolean)
10526         * model_dark_launch_enabled                (boolean)
10527         * smart_selection_enabled                  (boolean)
10528         * smart_text_share_enabled                 (boolean)
10529         * smart_linkify_enabled                    (boolean)
10530         * smart_select_animation_enabled           (boolean)
10531         * suggest_selection_max_range_length       (int)
10532         * classify_text_max_range_length           (int)
10533         * generate_links_max_text_length           (int)
10534         * generate_links_log_sample_rate           (int)
10535         * entity_list_default                      (String[])
10536         * entity_list_not_editable                 (String[])
10537         * entity_list_editable                     (String[])
10538         * </pre>
10539         *
10540         * <p>
10541         * Type: string
10542         * @hide
10543         * see also android.view.textclassifier.TextClassificationConstants
10544         */
10545        public static final String TEXT_CLASSIFIER_CONSTANTS = "text_classifier_constants";
10546
10547        /**
10548         * BatteryStats specific settings.
10549         * This is encoded as a key=value list, separated by commas. Ex: "foo=1,bar=true"
10550         *
10551         * The following keys are supported:
10552         * <pre>
10553         * track_cpu_times_by_proc_state (boolean)
10554         * track_cpu_active_cluster_time (boolean)
10555         * read_binary_cpu_time          (boolean)
10556         * proc_state_cpu_times_read_delay_ms (long)
10557         * </pre>
10558         *
10559         * <p>
10560         * Type: string
10561         * @hide
10562         * see also com.android.internal.os.BatteryStatsImpl.Constants
10563         */
10564        public static final String BATTERY_STATS_CONSTANTS = "battery_stats_constants";
10565
10566        /**
10567         * SyncManager specific settings.
10568         *
10569         * <p>
10570         * Type: string
10571         * @hide
10572         * @see com.android.server.content.SyncManagerConstants
10573         */
10574        public static final String SYNC_MANAGER_CONSTANTS = "sync_manager_constants";
10575
10576        /**
10577         * Whether or not App Standby feature is enabled. This controls throttling of apps
10578         * based on usage patterns and predictions.
10579         * Type: int (0 for false, 1 for true)
10580         * Default: 1
10581         * @hide
10582         */
10583        public static final java.lang.String APP_STANDBY_ENABLED = "app_standby_enabled";
10584
10585        /**
10586         * Whether or not app auto restriction is enabled. When it is enabled, settings app will
10587         * auto restrict the app if it has bad behavior(e.g. hold wakelock for long time).
10588         *
10589         * Type: boolean (0 for false, 1 for true)
10590         * Default: 1
10591         *
10592         * @hide
10593         */
10594        public static final java.lang.String APP_AUTO_RESTRICTION_ENABLED =
10595                "app_auto_restriction_enabled";
10596
10597        private static final Validator APP_AUTO_RESTRICTION_ENABLED_VALIDATOR =
10598                BOOLEAN_VALIDATOR;
10599
10600        /**
10601         * Feature flag to enable or disable the Forced App Standby feature.
10602         * Type: int (0 for false, 1 for true)
10603         * Default: 1
10604         * @hide
10605         */
10606        public static final String FORCED_APP_STANDBY_ENABLED = "forced_app_standby_enabled";
10607
10608        /**
10609         * Whether or not to enable Forced App Standby on small battery devices.
10610         * Type: int (0 for false, 1 for true)
10611         * Default: 0
10612         * @hide
10613         */
10614        public static final String FORCED_APP_STANDBY_FOR_SMALL_BATTERY_ENABLED
10615                = "forced_app_standby_for_small_battery_enabled";
10616
10617        /**
10618         * Whether or not to enable the Off Body, Radios Off feature on small battery devices.
10619         * Type: int (0 for false, 1 for true)
10620         * Default: 0
10621         * @hide
10622         */
10623        public static final String OFF_BODY_RADIOS_OFF_FOR_SMALL_BATTERY_ENABLED
10624                = "off_body_radios_off_for_small_battery_enabled";
10625
10626        /**
10627         * How long after the device goes off body to disable radios, in milliseconds.
10628         * Type: long
10629         * Default: 10 minutes
10630         * @hide
10631         */
10632        public static final String OFF_BODY_RADIOS_OFF_DELAY_MS = "off_body_radios_off_delay_ms";
10633
10634        /**
10635         * Whether or not to turn on Wifi when proxy is disconnected.
10636         * Type: int (0 for false, 1 for true)
10637         * Default: 1
10638         * @hide
10639         */
10640        public static final String WIFI_ON_WHEN_PROXY_DISCONNECTED
10641                = "wifi_on_when_proxy_disconnected";
10642
10643        /**
10644         * Whether or not to enable Time Only Mode for watch type devices.
10645         * Type: int (0 for false, 1 for true)
10646         * Default: 0
10647         * @hide
10648         */
10649        public static final String TIME_ONLY_MODE_ENABLED
10650                = "time_only_mode_enabled";
10651
10652        /**
10653         * Whether or not Network Watchlist feature is enabled.
10654         * Type: int (0 for false, 1 for true)
10655         * Default: 0
10656         * @hide
10657         */
10658        public static final String NETWORK_WATCHLIST_ENABLED = "network_watchlist_enabled";
10659
10660        /**
10661         * Flag to keep background restricted profiles running after exiting. If disabled,
10662         * the restricted profile can be put into stopped state as soon as the user leaves it.
10663         * Type: int (0 for false, 1 for true)
10664         *
10665         * Overridden by the system based on device information. If null, the value specified
10666         * by {@code config_keepRestrictedProfilesInBackground} is used.
10667         *
10668         * @hide
10669         */
10670        public static final String KEEP_PROFILE_IN_BACKGROUND = "keep_profile_in_background";
10671
10672        /**
10673         * Get the key that retrieves a bluetooth headset's priority.
10674         * @hide
10675         */
10676        public static final String getBluetoothHeadsetPriorityKey(String address) {
10677            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10678        }
10679
10680        /**
10681         * Get the key that retrieves a bluetooth a2dp sink's priority.
10682         * @hide
10683         */
10684        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
10685            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10686        }
10687
10688        /**
10689         * Get the key that retrieves a bluetooth a2dp src's priority.
10690         * @hide
10691         */
10692        public static final String getBluetoothA2dpSrcPriorityKey(String address) {
10693            return BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10694        }
10695
10696        /**
10697         * Get the key that retrieves a bluetooth a2dp device's ability to support optional codecs.
10698         * @hide
10699         */
10700        public static final String getBluetoothA2dpSupportsOptionalCodecsKey(String address) {
10701            return BLUETOOTH_A2DP_SUPPORTS_OPTIONAL_CODECS_PREFIX +
10702                    address.toUpperCase(Locale.ROOT);
10703        }
10704
10705        /**
10706         * Get the key that retrieves whether a bluetooth a2dp device should have optional codecs
10707         * enabled.
10708         * @hide
10709         */
10710        public static final String getBluetoothA2dpOptionalCodecsEnabledKey(String address) {
10711            return BLUETOOTH_A2DP_OPTIONAL_CODECS_ENABLED_PREFIX +
10712                    address.toUpperCase(Locale.ROOT);
10713        }
10714
10715        /**
10716         * Get the key that retrieves a bluetooth Input Device's priority.
10717         * @hide
10718         */
10719        public static final String getBluetoothHidHostPriorityKey(String address) {
10720            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10721        }
10722
10723        /**
10724         * Get the key that retrieves a bluetooth pan client priority.
10725         * @hide
10726         */
10727        public static final String getBluetoothPanPriorityKey(String address) {
10728            return BLUETOOTH_PAN_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10729        }
10730
10731        /**
10732         * Get the key that retrieves a bluetooth hearing aid priority.
10733         * @hide
10734         */
10735        public static final String getBluetoothHearingAidPriorityKey(String address) {
10736            return BLUETOOTH_HEARING_AID_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10737        }
10738
10739        /**
10740         * Get the key that retrieves a bluetooth map priority.
10741         * @hide
10742         */
10743        public static final String getBluetoothMapPriorityKey(String address) {
10744            return BLUETOOTH_MAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10745        }
10746
10747        /**
10748         * Get the key that retrieves a bluetooth map client priority.
10749         * @hide
10750         */
10751        public static final String getBluetoothMapClientPriorityKey(String address) {
10752            return BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10753        }
10754
10755        /**
10756         * Get the key that retrieves a bluetooth pbap client priority.
10757         * @hide
10758         */
10759        public static final String getBluetoothPbapClientPriorityKey(String address) {
10760            return BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10761        }
10762
10763        /**
10764         * Get the key that retrieves a bluetooth sap priority.
10765         * @hide
10766         */
10767        public static final String getBluetoothSapPriorityKey(String address) {
10768            return BLUETOOTH_SAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
10769        }
10770
10771        /**
10772         * Scaling factor for normal window animations. Setting to 0 will
10773         * disable window animations.
10774         */
10775        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
10776
10777        /**
10778         * Scaling factor for activity transition animations. Setting to 0 will
10779         * disable window animations.
10780         */
10781        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
10782
10783        /**
10784         * Scaling factor for Animator-based animations. This affects both the
10785         * start delay and duration of all such animations. Setting to 0 will
10786         * cause animations to end immediately. The default value is 1.
10787         */
10788        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
10789
10790        /**
10791         * Scaling factor for normal window animations. Setting to 0 will
10792         * disable window animations.
10793         *
10794         * @hide
10795         */
10796        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
10797
10798        /**
10799         * If 0, the compatibility mode is off for all applications.
10800         * If 1, older applications run under compatibility mode.
10801         * TODO: remove this settings before code freeze (bug/1907571)
10802         * @hide
10803         */
10804        public static final String COMPATIBILITY_MODE = "compatibility_mode";
10805
10806        /**
10807         * CDMA only settings
10808         * Emergency Tone  0 = Off
10809         *                 1 = Alert
10810         *                 2 = Vibrate
10811         * @hide
10812         */
10813        public static final String EMERGENCY_TONE = "emergency_tone";
10814
10815        private static final Validator EMERGENCY_TONE_VALIDATOR =
10816                new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1", "2"});
10817
10818        /**
10819         * CDMA only settings
10820         * Whether the auto retry is enabled. The value is
10821         * boolean (1 or 0).
10822         * @hide
10823         */
10824        public static final String CALL_AUTO_RETRY = "call_auto_retry";
10825
10826        private static final Validator CALL_AUTO_RETRY_VALIDATOR = BOOLEAN_VALIDATOR;
10827
10828        /**
10829         * A setting that can be read whether the emergency affordance is currently needed.
10830         * The value is a boolean (1 or 0).
10831         * @hide
10832         */
10833        public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed";
10834
10835        /**
10836         * See RIL_PreferredNetworkType in ril.h
10837         * @hide
10838         */
10839        public static final String PREFERRED_NETWORK_MODE =
10840                "preferred_network_mode";
10841
10842        /**
10843         * Name of an application package to be debugged.
10844         */
10845        public static final String DEBUG_APP = "debug_app";
10846
10847        /**
10848         * If 1, when launching DEBUG_APP it will wait for the debugger before
10849         * starting user code.  If 0, it will run normally.
10850         */
10851        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
10852
10853        /**
10854         * Allow GPU debug layers?
10855         * 0 = no
10856         * 1 = yes
10857         * @hide
10858         */
10859        public static final String ENABLE_GPU_DEBUG_LAYERS = "enable_gpu_debug_layers";
10860
10861        /**
10862         * App allowed to load GPU debug layers
10863         * @hide
10864         */
10865        public static final String GPU_DEBUG_APP = "gpu_debug_app";
10866
10867        /**
10868         * Ordered GPU debug layer list
10869         * i.e. <layer1>:<layer2>:...:<layerN>
10870         * @hide
10871         */
10872        public static final String GPU_DEBUG_LAYERS = "gpu_debug_layers";
10873
10874        /**
10875         * Control whether the process CPU usage meter should be shown.
10876         *
10877         * @deprecated This functionality is no longer available as of
10878         * {@link android.os.Build.VERSION_CODES#N_MR1}.
10879         */
10880        @Deprecated
10881        public static final String SHOW_PROCESSES = "show_processes";
10882
10883        /**
10884         * If 1 low power mode is enabled.
10885         * @hide
10886         */
10887        @TestApi
10888        public static final String LOW_POWER_MODE = "low_power";
10889
10890        /**
10891         * Battery level [1-100] at which low power mode automatically turns on.
10892         * If 0, it will not automatically turn on.
10893         * @hide
10894         */
10895        public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level";
10896
10897        private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR =
10898                new SettingsValidators.InclusiveIntegerRangeValidator(0, 100);
10899
10900         /**
10901         * If not 0, the activity manager will aggressively finish activities and
10902         * processes as soon as they are no longer needed.  If 0, the normal
10903         * extended lifetime is used.
10904         */
10905        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
10906
10907        /**
10908         * Use Dock audio output for media:
10909         *      0 = disabled
10910         *      1 = enabled
10911         * @hide
10912         */
10913        public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
10914
10915        private static final Validator DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
10916
10917        /**
10918         * The surround sound formats AC3, DTS or IEC61937 are
10919         * available for use if they are detected.
10920         * This is the default mode.
10921         *
10922         * Note that AUTO is equivalent to ALWAYS for Android TVs and other
10923         * devices that have an S/PDIF output. This is because S/PDIF
10924         * is unidirectional and the TV cannot know if a decoder is
10925         * connected. So it assumes they are always available.
10926         * @hide
10927         */
10928         public static final int ENCODED_SURROUND_OUTPUT_AUTO = 0;
10929
10930        /**
10931         * AC3, DTS or IEC61937 are NEVER available, even if they
10932         * are detected by the hardware. Those formats will not be
10933         * reported.
10934         *
10935         * An example use case would be an AVR reports that it is capable of
10936         * surround sound decoding but is broken. If NEVER is chosen
10937         * then apps must use PCM output instead of encoded output.
10938         * @hide
10939         */
10940         public static final int ENCODED_SURROUND_OUTPUT_NEVER = 1;
10941
10942        /**
10943         * AC3, DTS or IEC61937 are ALWAYS available, even if they
10944         * are not detected by the hardware. Those formats will be
10945         * reported as part of the HDMI output capability. Applications
10946         * are then free to use either PCM or encoded output.
10947         *
10948         * An example use case would be a when TV was connected over
10949         * TOS-link to an AVR. But the TV could not see it because TOS-link
10950         * is unidirectional.
10951         * @hide
10952         */
10953         public static final int ENCODED_SURROUND_OUTPUT_ALWAYS = 2;
10954
10955        /**
10956         * Set to ENCODED_SURROUND_OUTPUT_AUTO,
10957         * ENCODED_SURROUND_OUTPUT_NEVER or
10958         * ENCODED_SURROUND_OUTPUT_ALWAYS
10959         * @hide
10960         */
10961        public static final String ENCODED_SURROUND_OUTPUT = "encoded_surround_output";
10962
10963        private static final Validator ENCODED_SURROUND_OUTPUT_VALIDATOR =
10964                new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1", "2"});
10965
10966        /**
10967         * Persisted safe headphone volume management state by AudioService
10968         * @hide
10969         */
10970        public static final String AUDIO_SAFE_VOLUME_STATE = "audio_safe_volume_state";
10971
10972        /**
10973         * URL for tzinfo (time zone) updates
10974         * @hide
10975         */
10976        public static final String TZINFO_UPDATE_CONTENT_URL = "tzinfo_content_url";
10977
10978        /**
10979         * URL for tzinfo (time zone) update metadata
10980         * @hide
10981         */
10982        public static final String TZINFO_UPDATE_METADATA_URL = "tzinfo_metadata_url";
10983
10984        /**
10985         * URL for selinux (mandatory access control) updates
10986         * @hide
10987         */
10988        public static final String SELINUX_UPDATE_CONTENT_URL = "selinux_content_url";
10989
10990        /**
10991         * URL for selinux (mandatory access control) update metadata
10992         * @hide
10993         */
10994        public static final String SELINUX_UPDATE_METADATA_URL = "selinux_metadata_url";
10995
10996        /**
10997         * URL for sms short code updates
10998         * @hide
10999         */
11000        public static final String SMS_SHORT_CODES_UPDATE_CONTENT_URL =
11001                "sms_short_codes_content_url";
11002
11003        /**
11004         * URL for sms short code update metadata
11005         * @hide
11006         */
11007        public static final String SMS_SHORT_CODES_UPDATE_METADATA_URL =
11008                "sms_short_codes_metadata_url";
11009
11010        /**
11011         * URL for apn_db updates
11012         * @hide
11013         */
11014        public static final String APN_DB_UPDATE_CONTENT_URL = "apn_db_content_url";
11015
11016        /**
11017         * URL for apn_db update metadata
11018         * @hide
11019         */
11020        public static final String APN_DB_UPDATE_METADATA_URL = "apn_db_metadata_url";
11021
11022        /**
11023         * URL for cert pinlist updates
11024         * @hide
11025         */
11026        public static final String CERT_PIN_UPDATE_CONTENT_URL = "cert_pin_content_url";
11027
11028        /**
11029         * URL for cert pinlist updates
11030         * @hide
11031         */
11032        public static final String CERT_PIN_UPDATE_METADATA_URL = "cert_pin_metadata_url";
11033
11034        /**
11035         * URL for intent firewall updates
11036         * @hide
11037         */
11038        public static final String INTENT_FIREWALL_UPDATE_CONTENT_URL =
11039                "intent_firewall_content_url";
11040
11041        /**
11042         * URL for intent firewall update metadata
11043         * @hide
11044         */
11045        public static final String INTENT_FIREWALL_UPDATE_METADATA_URL =
11046                "intent_firewall_metadata_url";
11047
11048        /**
11049         * URL for lang id model updates
11050         * @hide
11051         */
11052        public static final String LANG_ID_UPDATE_CONTENT_URL = "lang_id_content_url";
11053
11054        /**
11055         * URL for lang id model update metadata
11056         * @hide
11057         */
11058        public static final String LANG_ID_UPDATE_METADATA_URL = "lang_id_metadata_url";
11059
11060        /**
11061         * URL for smart selection model updates
11062         * @hide
11063         */
11064        public static final String SMART_SELECTION_UPDATE_CONTENT_URL =
11065                "smart_selection_content_url";
11066
11067        /**
11068         * URL for smart selection model update metadata
11069         * @hide
11070         */
11071        public static final String SMART_SELECTION_UPDATE_METADATA_URL =
11072                "smart_selection_metadata_url";
11073
11074        /**
11075         * SELinux enforcement status. If 0, permissive; if 1, enforcing.
11076         * @hide
11077         */
11078        public static final String SELINUX_STATUS = "selinux_status";
11079
11080        /**
11081         * Developer setting to force RTL layout.
11082         * @hide
11083         */
11084        public static final String DEVELOPMENT_FORCE_RTL = "debug.force_rtl";
11085
11086        /**
11087         * Milliseconds after screen-off after which low battery sounds will be silenced.
11088         *
11089         * If zero, battery sounds will always play.
11090         * Defaults to @integer/def_low_battery_sound_timeout in SettingsProvider.
11091         *
11092         * @hide
11093         */
11094        public static final String LOW_BATTERY_SOUND_TIMEOUT = "low_battery_sound_timeout";
11095
11096        /**
11097         * Milliseconds to wait before bouncing Wi-Fi after settings is restored. Note that after
11098         * the caller is done with this, they should call {@link ContentResolver#delete} to
11099         * clean up any value that they may have written.
11100         *
11101         * @hide
11102         */
11103        public static final String WIFI_BOUNCE_DELAY_OVERRIDE_MS = "wifi_bounce_delay_override_ms";
11104
11105        /**
11106         * Defines global runtime overrides to window policy.
11107         *
11108         * See {@link com.android.server.policy.PolicyControl} for value format.
11109         *
11110         * @hide
11111         */
11112        public static final String POLICY_CONTROL = "policy_control";
11113
11114        /**
11115         * {@link android.view.DisplayCutout DisplayCutout} emulation mode.
11116         *
11117         * @hide
11118         */
11119        public static final String EMULATE_DISPLAY_CUTOUT = "emulate_display_cutout";
11120
11121        /** @hide */ public static final int EMULATE_DISPLAY_CUTOUT_OFF = 0;
11122        /** @hide */ public static final int EMULATE_DISPLAY_CUTOUT_ON = 1;
11123
11124        /**
11125         * Defines global zen mode.  ZEN_MODE_OFF, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
11126         * or ZEN_MODE_NO_INTERRUPTIONS.
11127         *
11128         * @hide
11129         */
11130        public static final String ZEN_MODE = "zen_mode";
11131
11132        /** @hide */ public static final int ZEN_MODE_OFF = 0;
11133        /** @hide */ public static final int ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
11134        /** @hide */ public static final int ZEN_MODE_NO_INTERRUPTIONS = 2;
11135        /** @hide */ public static final int ZEN_MODE_ALARMS = 3;
11136
11137        /** @hide */ public static String zenModeToString(int mode) {
11138            if (mode == ZEN_MODE_IMPORTANT_INTERRUPTIONS) return "ZEN_MODE_IMPORTANT_INTERRUPTIONS";
11139            if (mode == ZEN_MODE_ALARMS) return "ZEN_MODE_ALARMS";
11140            if (mode == ZEN_MODE_NO_INTERRUPTIONS) return "ZEN_MODE_NO_INTERRUPTIONS";
11141            return "ZEN_MODE_OFF";
11142        }
11143
11144        /** @hide */ public static boolean isValidZenMode(int value) {
11145            switch (value) {
11146                case Global.ZEN_MODE_OFF:
11147                case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
11148                case Global.ZEN_MODE_ALARMS:
11149                case Global.ZEN_MODE_NO_INTERRUPTIONS:
11150                    return true;
11151                default:
11152                    return false;
11153            }
11154        }
11155
11156        /**
11157         * Value of the ringer before entering zen mode.
11158         *
11159         * @hide
11160         */
11161        public static final String ZEN_MODE_RINGER_LEVEL = "zen_mode_ringer_level";
11162
11163        /**
11164         * Opaque value, changes when persisted zen mode configuration changes.
11165         *
11166         * @hide
11167         */
11168        public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
11169
11170        /**
11171         * Defines global heads up toggle.  One of HEADS_UP_OFF, HEADS_UP_ON.
11172         *
11173         * @hide
11174         */
11175        public static final String HEADS_UP_NOTIFICATIONS_ENABLED =
11176                "heads_up_notifications_enabled";
11177
11178        /** @hide */ public static final int HEADS_UP_OFF = 0;
11179        /** @hide */ public static final int HEADS_UP_ON = 1;
11180
11181        /**
11182         * The name of the device
11183         */
11184        public static final String DEVICE_NAME = "device_name";
11185
11186        /**
11187         * Whether the NetworkScoringService has been first initialized.
11188         * <p>
11189         * Type: int (0 for false, 1 for true)
11190         * @hide
11191         */
11192        public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned";
11193
11194        /**
11195         * Whether the user wants to be prompted for password to decrypt the device on boot.
11196         * This only matters if the storage is encrypted.
11197         * <p>
11198         * Type: int (0 for false, 1 for true)
11199         * @hide
11200         */
11201        public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt";
11202
11203        /**
11204         * Whether the Volte is enabled. If this setting is not set then we use the Carrier Config
11205         * value {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}.
11206         * <p>
11207         * Type: int (0 for false, 1 for true)
11208         * @hide
11209         * @deprecated Use {@link android.telephony.SubscriptionManager#ENHANCED_4G_MODE_ENABLED}
11210         * instead.
11211         */
11212        @Deprecated
11213        public static final String ENHANCED_4G_MODE_ENABLED =
11214                SubscriptionManager.ENHANCED_4G_MODE_ENABLED;
11215
11216        /**
11217         * Whether VT (Video Telephony over IMS) is enabled
11218         * <p>
11219         * Type: int (0 for false, 1 for true)
11220         *
11221         * @hide
11222         * @deprecated Use {@link android.telephony.SubscriptionManager#VT_IMS_ENABLED} instead.
11223         */
11224        @Deprecated
11225        public static final String VT_IMS_ENABLED = SubscriptionManager.VT_IMS_ENABLED;
11226
11227        /**
11228         * Whether WFC is enabled
11229         * <p>
11230         * Type: int (0 for false, 1 for true)
11231         *
11232         * @hide
11233         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ENABLED} instead.
11234         */
11235        @Deprecated
11236        public static final String WFC_IMS_ENABLED = SubscriptionManager.WFC_IMS_ENABLED;
11237
11238        /**
11239         * WFC mode on home/non-roaming network.
11240         * <p>
11241         * Type: int - 2=Wi-Fi preferred, 1=Cellular preferred, 0=Wi-Fi only
11242         *
11243         * @hide
11244         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_MODE} instead.
11245         */
11246        @Deprecated
11247        public static final String WFC_IMS_MODE = SubscriptionManager.WFC_IMS_MODE;
11248
11249        /**
11250         * WFC mode on roaming network.
11251         * <p>
11252         * Type: int - see {@link #WFC_IMS_MODE} for values
11253         *
11254         * @hide
11255         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ROAMING_MODE}
11256         * instead.
11257         */
11258        @Deprecated
11259        public static final String WFC_IMS_ROAMING_MODE = SubscriptionManager.WFC_IMS_ROAMING_MODE;
11260
11261        /**
11262         * Whether WFC roaming is enabled
11263         * <p>
11264         * Type: int (0 for false, 1 for true)
11265         *
11266         * @hide
11267         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ROAMING_ENABLED}
11268         * instead
11269         */
11270        @Deprecated
11271        public static final String WFC_IMS_ROAMING_ENABLED =
11272                SubscriptionManager.WFC_IMS_ROAMING_ENABLED;
11273
11274        /**
11275         * Whether user can enable/disable LTE as a preferred network. A carrier might control
11276         * this via gservices, OMA-DM, carrier app, etc.
11277         * <p>
11278         * Type: int (0 for false, 1 for true)
11279         * @hide
11280         */
11281        public static final String LTE_SERVICE_FORCED = "lte_service_forced";
11282
11283        /**
11284         * Ephemeral app cookie max size in bytes.
11285         * <p>
11286         * Type: int
11287         * @hide
11288         */
11289        public static final String EPHEMERAL_COOKIE_MAX_SIZE_BYTES =
11290                "ephemeral_cookie_max_size_bytes";
11291
11292        /**
11293         * Toggle to enable/disable the entire ephemeral feature. By default, ephemeral is
11294         * enabled. Set to zero to disable.
11295         * <p>
11296         * Type: int (0 for false, 1 for true)
11297         *
11298         * @hide
11299         */
11300        public static final String ENABLE_EPHEMERAL_FEATURE = "enable_ephemeral_feature";
11301
11302        /**
11303         * Toggle to enable/disable dexopt for instant applications. The default is for dexopt
11304         * to be disabled.
11305         * <p>
11306         * Type: int (0 to disable, 1 to enable)
11307         *
11308         * @hide
11309         */
11310        public static final String INSTANT_APP_DEXOPT_ENABLED = "instant_app_dexopt_enabled";
11311
11312        /**
11313         * The min period for caching installed instant apps in milliseconds.
11314         * <p>
11315         * Type: long
11316         * @hide
11317         */
11318        public static final String INSTALLED_INSTANT_APP_MIN_CACHE_PERIOD =
11319                "installed_instant_app_min_cache_period";
11320
11321        /**
11322         * The max period for caching installed instant apps in milliseconds.
11323         * <p>
11324         * Type: long
11325         * @hide
11326         */
11327        public static final String INSTALLED_INSTANT_APP_MAX_CACHE_PERIOD =
11328                "installed_instant_app_max_cache_period";
11329
11330        /**
11331         * The min period for caching uninstalled instant apps in milliseconds.
11332         * <p>
11333         * Type: long
11334         * @hide
11335         */
11336        public static final String UNINSTALLED_INSTANT_APP_MIN_CACHE_PERIOD =
11337                "uninstalled_instant_app_min_cache_period";
11338
11339        /**
11340         * The max period for caching uninstalled instant apps in milliseconds.
11341         * <p>
11342         * Type: long
11343         * @hide
11344         */
11345        public static final String UNINSTALLED_INSTANT_APP_MAX_CACHE_PERIOD =
11346                "uninstalled_instant_app_max_cache_period";
11347
11348        /**
11349         * The min period for caching unused static shared libs in milliseconds.
11350         * <p>
11351         * Type: long
11352         * @hide
11353         */
11354        public static final String UNUSED_STATIC_SHARED_LIB_MIN_CACHE_PERIOD =
11355                "unused_static_shared_lib_min_cache_period";
11356
11357        /**
11358         * Allows switching users when system user is locked.
11359         * <p>
11360         * Type: int
11361         * @hide
11362         */
11363        public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED =
11364                "allow_user_switching_when_system_user_locked";
11365
11366        /**
11367         * Boot count since the device starts running API level 24.
11368         * <p>
11369         * Type: int
11370         */
11371        public static final String BOOT_COUNT = "boot_count";
11372
11373        /**
11374         * Whether the safe boot is disallowed.
11375         *
11376         * <p>This setting should have the identical value as the corresponding user restriction.
11377         * The purpose of the setting is to make the restriction available in early boot stages
11378         * before the user restrictions are loaded.
11379         * @hide
11380         */
11381        public static final String SAFE_BOOT_DISALLOWED = "safe_boot_disallowed";
11382
11383        /**
11384         * Whether this device is currently in retail demo mode. If true, device
11385         * usage is severely limited.
11386         * <p>
11387         * Type: int (0 for false, 1 for true)
11388         * @hide
11389         */
11390        public static final String DEVICE_DEMO_MODE = "device_demo_mode";
11391
11392        /**
11393         * Indicates the maximum time that an app is blocked for the network rules to get updated.
11394         *
11395         * Type: long
11396         *
11397         * @hide
11398         */
11399        public static final String NETWORK_ACCESS_TIMEOUT_MS = "network_access_timeout_ms";
11400
11401        /**
11402         * The reason for the settings database being downgraded. This is only for
11403         * troubleshooting purposes and its value should not be interpreted in any way.
11404         *
11405         * Type: string
11406         *
11407         * @hide
11408         */
11409        public static final String DATABASE_DOWNGRADE_REASON = "database_downgrade_reason";
11410
11411        /**
11412         * The build id of when the settings database was first created (or re-created due it
11413         * being missing).
11414         *
11415         * Type: string
11416         *
11417         * @hide
11418         */
11419        public static final String DATABASE_CREATION_BUILDID = "database_creation_buildid";
11420
11421        /**
11422         * Flag to toggle journal mode WAL on or off for the contacts database. WAL is enabled by
11423         * default. Set to 0 to disable.
11424         *
11425         * @hide
11426         */
11427        public static final String CONTACTS_DATABASE_WAL_ENABLED = "contacts_database_wal_enabled";
11428
11429        /**
11430         * Flag to enable the link to location permissions in location setting. Set to 0 to disable.
11431         *
11432         * @hide
11433         */
11434        public static final String LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED =
11435                "location_settings_link_to_permissions_enabled";
11436
11437        /**
11438         * Flag to set the waiting time for euicc factory reset inside System > Settings
11439         * Type: long
11440         *
11441         * @hide
11442         */
11443        public static final String EUICC_FACTORY_RESET_TIMEOUT_MILLIS =
11444                "euicc_factory_reset_timeout_millis";
11445
11446        /**
11447         * Flag to set the timeout for when to refresh the storage settings cached data.
11448         * Type: long
11449         *
11450         * @hide
11451         */
11452        public static final String STORAGE_SETTINGS_CLOBBER_THRESHOLD =
11453                "storage_settings_clobber_threshold";
11454
11455        /**
11456         * If set to 1, {@link Secure#LOCATION_MODE} will be set to {@link Secure#LOCATION_MODE_OFF}
11457         * temporarily for all users.
11458         *
11459         * @hide
11460         */
11461        @TestApi
11462        public static final String LOCATION_GLOBAL_KILL_SWITCH =
11463                "location_global_kill_switch";
11464
11465        /**
11466         * If set to 1, SettingsProvider's restoreAnyVersion="true" attribute will be ignored
11467         * and restoring to lower version of platform API will be skipped.
11468         *
11469         * @hide
11470         */
11471        public static final String OVERRIDE_SETTINGS_PROVIDER_RESTORE_ANY_VERSION =
11472                "override_settings_provider_restore_any_version";
11473        /**
11474         * Flag to toggle whether system services report attribution chains when they attribute
11475         * battery use via a {@code WorkSource}.
11476         *
11477         * Type: int (0 to disable, 1 to enable)
11478         *
11479         * @hide
11480         */
11481        public static final String CHAINED_BATTERY_ATTRIBUTION_ENABLED =
11482                "chained_battery_attribution_enabled";
11483
11484        /**
11485         * The packages whitelisted to be run in autofill compatibility mode. The list
11486         * of packages is ":" colon delimited.
11487         *
11488         * @hide
11489         */
11490        @SystemApi
11491        @TestApi
11492        public static final String AUTOFILL_COMPAT_ALLOWED_PACKAGES =
11493                "autofill_compat_allowed_packages";
11494
11495        /**
11496         * Exemptions to the hidden API blacklist.
11497         *
11498         * @hide
11499         */
11500        @TestApi
11501        public static final String HIDDEN_API_BLACKLIST_EXEMPTIONS =
11502                "hidden_api_blacklist_exemptions";
11503
11504        /**
11505         * Settings to backup. This is here so that it's in the same place as the settings
11506         * keys and easy to update.
11507         *
11508         * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
11509         * and Secure as well.  This is because those tables drive both backup and
11510         * restore, and restore needs to properly whitelist keys that used to live
11511         * in those namespaces.  The keys will only actually be backed up / restored
11512         * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
11513         *
11514         * NOTE: Settings are backed up and restored in the order they appear
11515         *       in this array. If you have one setting depending on another,
11516         *       make sure that they are ordered appropriately.
11517         *
11518         * @hide
11519         */
11520        public static final String[] SETTINGS_TO_BACKUP = {
11521            BUGREPORT_IN_POWER_MENU,
11522            STAY_ON_WHILE_PLUGGED_IN,
11523            APP_AUTO_RESTRICTION_ENABLED,
11524            AUTO_TIME,
11525            AUTO_TIME_ZONE,
11526            POWER_SOUNDS_ENABLED,
11527            DOCK_SOUNDS_ENABLED,
11528            CHARGING_SOUNDS_ENABLED,
11529            USB_MASS_STORAGE_ENABLED,
11530            NETWORK_RECOMMENDATIONS_ENABLED,
11531            WIFI_WAKEUP_ENABLED,
11532            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
11533            WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON,
11534            USE_OPEN_WIFI_PACKAGE,
11535            WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
11536            EMERGENCY_TONE,
11537            CALL_AUTO_RETRY,
11538            DOCK_AUDIO_MEDIA_ENABLED,
11539            ENCODED_SURROUND_OUTPUT,
11540            LOW_POWER_MODE_TRIGGER_LEVEL,
11541            BLUETOOTH_ON,
11542            PRIVATE_DNS_MODE,
11543            PRIVATE_DNS_SPECIFIER,
11544            SOFT_AP_TIMEOUT_ENABLED
11545        };
11546
11547        /**
11548         * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator,
11549         * otherwise they won't be restored.
11550         *
11551         * @hide
11552         */
11553        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
11554        static {
11555            VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR);
11556            VALIDATORS.put(STAY_ON_WHILE_PLUGGED_IN, STAY_ON_WHILE_PLUGGED_IN_VALIDATOR);
11557            VALIDATORS.put(AUTO_TIME, AUTO_TIME_VALIDATOR);
11558            VALIDATORS.put(AUTO_TIME_ZONE, AUTO_TIME_ZONE_VALIDATOR);
11559            VALIDATORS.put(POWER_SOUNDS_ENABLED, POWER_SOUNDS_ENABLED_VALIDATOR);
11560            VALIDATORS.put(DOCK_SOUNDS_ENABLED, DOCK_SOUNDS_ENABLED_VALIDATOR);
11561            VALIDATORS.put(CHARGING_SOUNDS_ENABLED, CHARGING_SOUNDS_ENABLED_VALIDATOR);
11562            VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR);
11563            VALIDATORS.put(NETWORK_RECOMMENDATIONS_ENABLED,
11564                    NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR);
11565            VALIDATORS.put(WIFI_WAKEUP_ENABLED, WIFI_WAKEUP_ENABLED_VALIDATOR);
11566            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
11567                    WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
11568            VALIDATORS.put(USE_OPEN_WIFI_PACKAGE, USE_OPEN_WIFI_PACKAGE_VALIDATOR);
11569            VALIDATORS.put(WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
11570                    WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR);
11571            VALIDATORS.put(EMERGENCY_TONE, EMERGENCY_TONE_VALIDATOR);
11572            VALIDATORS.put(CALL_AUTO_RETRY, CALL_AUTO_RETRY_VALIDATOR);
11573            VALIDATORS.put(DOCK_AUDIO_MEDIA_ENABLED, DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR);
11574            VALIDATORS.put(ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_VALIDATOR);
11575            VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR);
11576            VALIDATORS.put(BLUETOOTH_ON, BLUETOOTH_ON_VALIDATOR);
11577            VALIDATORS.put(PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_VALIDATOR);
11578            VALIDATORS.put(PRIVATE_DNS_SPECIFIER, PRIVATE_DNS_SPECIFIER_VALIDATOR);
11579            VALIDATORS.put(SOFT_AP_TIMEOUT_ENABLED, SOFT_AP_TIMEOUT_ENABLED_VALIDATOR);
11580            VALIDATORS.put(WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON,
11581                    WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
11582            VALIDATORS.put(APP_AUTO_RESTRICTION_ENABLED, APP_AUTO_RESTRICTION_ENABLED_VALIDATOR);
11583        }
11584
11585        /**
11586         * Global settings that shouldn't be persisted.
11587         *
11588         * @hide
11589         */
11590        public static final String[] TRANSIENT_SETTINGS = {
11591                LOCATION_GLOBAL_KILL_SWITCH,
11592        };
11593
11594        /**
11595         * Keys we no longer back up under the current schema, but want to continue to
11596         * process when restoring historical backup datasets.
11597         *
11598         * All settings in {@link LEGACY_RESTORE_SETTINGS} array *must* have a non-null validator,
11599         * otherwise they won't be restored.
11600         *
11601         * @hide
11602         */
11603        public static final String[] LEGACY_RESTORE_SETTINGS = {
11604        };
11605
11606        private static final ContentProviderHolder sProviderHolder =
11607                new ContentProviderHolder(CONTENT_URI);
11608
11609        // Populated lazily, guarded by class object:
11610        private static final NameValueCache sNameValueCache = new NameValueCache(
11611                    CONTENT_URI,
11612                    CALL_METHOD_GET_GLOBAL,
11613                    CALL_METHOD_PUT_GLOBAL,
11614                    sProviderHolder);
11615
11616        // Certain settings have been moved from global to the per-user secure namespace
11617        private static final HashSet<String> MOVED_TO_SECURE;
11618        static {
11619            MOVED_TO_SECURE = new HashSet<>(1);
11620            MOVED_TO_SECURE.add(Settings.Global.INSTALL_NON_MARKET_APPS);
11621        }
11622
11623        /** @hide */
11624        public static void getMovedToSecureSettings(Set<String> outKeySet) {
11625            outKeySet.addAll(MOVED_TO_SECURE);
11626        }
11627
11628        /** @hide */
11629        public static void clearProviderForTest() {
11630            sProviderHolder.clearProviderForTest();
11631            sNameValueCache.clearGenerationTrackerForTest();
11632        }
11633
11634        /**
11635         * Look up a name in the database.
11636         * @param resolver to access the database with
11637         * @param name to look up in the table
11638         * @return the corresponding value, or null if not present
11639         */
11640        public static String getString(ContentResolver resolver, String name) {
11641            return getStringForUser(resolver, name, resolver.getUserId());
11642        }
11643
11644        /** @hide */
11645        public static String getStringForUser(ContentResolver resolver, String name,
11646                int userHandle) {
11647            if (MOVED_TO_SECURE.contains(name)) {
11648                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
11649                        + " to android.provider.Settings.Secure, returning read-only value.");
11650                return Secure.getStringForUser(resolver, name, userHandle);
11651            }
11652            return sNameValueCache.getStringForUser(resolver, name, userHandle);
11653        }
11654
11655        /**
11656         * Store a name/value pair into the database.
11657         * @param resolver to access the database with
11658         * @param name to store
11659         * @param value to associate with the name
11660         * @return true if the value was set, false on database errors
11661         */
11662        public static boolean putString(ContentResolver resolver,
11663                String name, String value) {
11664            return putStringForUser(resolver, name, value, null, false, resolver.getUserId());
11665        }
11666
11667        /**
11668         * Store a name/value pair into the database.
11669         * <p>
11670         * The method takes an optional tag to associate with the setting
11671         * which can be used to clear only settings made by your package and
11672         * associated with this tag by passing the tag to {@link
11673         * #resetToDefaults(ContentResolver, String)}. Anyone can override
11674         * the current tag. Also if another package changes the setting
11675         * then the tag will be set to the one specified in the set call
11676         * which can be null. Also any of the settings setters that do not
11677         * take a tag as an argument effectively clears the tag.
11678         * </p><p>
11679         * For example, if you set settings A and B with tags T1 and T2 and
11680         * another app changes setting A (potentially to the same value), it
11681         * can assign to it a tag T3 (note that now the package that changed
11682         * the setting is not yours). Now if you reset your changes for T1 and
11683         * T2 only setting B will be reset and A not (as it was changed by
11684         * another package) but since A did not change you are in the desired
11685         * initial state. Now if the other app changes the value of A (assuming
11686         * you registered an observer in the beginning) you would detect that
11687         * the setting was changed by another app and handle this appropriately
11688         * (ignore, set back to some value, etc).
11689         * </p><p>
11690         * Also the method takes an argument whether to make the value the
11691         * default for this setting. If the system already specified a default
11692         * value, then the one passed in here will <strong>not</strong>
11693         * be set as the default.
11694         * </p>
11695         *
11696         * @param resolver to access the database with.
11697         * @param name to store.
11698         * @param value to associate with the name.
11699         * @param tag to associated with the setting.
11700         * @param makeDefault whether to make the value the default one.
11701         * @return true if the value was set, false on database errors.
11702         *
11703         * @see #resetToDefaults(ContentResolver, String)
11704         *
11705         * @hide
11706         */
11707        @SystemApi
11708        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
11709        public static boolean putString(@NonNull ContentResolver resolver,
11710                @NonNull String name, @Nullable String value, @Nullable String tag,
11711                boolean makeDefault) {
11712            return putStringForUser(resolver, name, value, tag, makeDefault,
11713                    resolver.getUserId());
11714        }
11715
11716        /**
11717         * Reset the settings to their defaults. This would reset <strong>only</strong>
11718         * settings set by the caller's package. Think of it of a way to undo your own
11719         * changes to the secure settings. Passing in the optional tag will reset only
11720         * settings changed by your package and associated with this tag.
11721         *
11722         * @param resolver Handle to the content resolver.
11723         * @param tag Optional tag which should be associated with the settings to reset.
11724         *
11725         * @see #putString(ContentResolver, String, String, String, boolean)
11726         *
11727         * @hide
11728         */
11729        @SystemApi
11730        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
11731        public static void resetToDefaults(@NonNull ContentResolver resolver,
11732                @Nullable String tag) {
11733            resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
11734                    resolver.getUserId());
11735        }
11736
11737        /**
11738         * Reset the settings to their defaults for a given user with a specific mode. The
11739         * optional tag argument is valid only for {@link #RESET_MODE_PACKAGE_DEFAULTS}
11740         * allowing resetting the settings made by a package and associated with the tag.
11741         *
11742         * @param resolver Handle to the content resolver.
11743         * @param tag Optional tag which should be associated with the settings to reset.
11744         * @param mode The reset mode.
11745         * @param userHandle The user for which to reset to defaults.
11746         *
11747         * @see #RESET_MODE_PACKAGE_DEFAULTS
11748         * @see #RESET_MODE_UNTRUSTED_DEFAULTS
11749         * @see #RESET_MODE_UNTRUSTED_CHANGES
11750         * @see #RESET_MODE_TRUSTED_DEFAULTS
11751         *
11752         * @hide
11753         */
11754        public static void resetToDefaultsAsUser(@NonNull ContentResolver resolver,
11755                @Nullable String tag, @ResetMode int mode, @IntRange(from = 0) int userHandle) {
11756            try {
11757                Bundle arg = new Bundle();
11758                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
11759                if (tag != null) {
11760                    arg.putString(CALL_METHOD_TAG_KEY, tag);
11761                }
11762                arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode);
11763                IContentProvider cp = sProviderHolder.getProvider(resolver);
11764                cp.call(resolver.getPackageName(), CALL_METHOD_RESET_GLOBAL, null, arg);
11765            } catch (RemoteException e) {
11766                Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e);
11767            }
11768        }
11769
11770        /** @hide */
11771        public static boolean putStringForUser(ContentResolver resolver,
11772                String name, String value, int userHandle) {
11773            return putStringForUser(resolver, name, value, null, false, userHandle);
11774        }
11775
11776        /** @hide */
11777        public static boolean putStringForUser(@NonNull ContentResolver resolver,
11778                @NonNull String name, @Nullable String value, @Nullable String tag,
11779                boolean makeDefault, @UserIdInt int userHandle) {
11780            if (LOCAL_LOGV) {
11781                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
11782                        + " for " + userHandle);
11783            }
11784            // Global and Secure have the same access policy so we can forward writes
11785            if (MOVED_TO_SECURE.contains(name)) {
11786                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
11787                        + " to android.provider.Settings.Secure, value is unchanged.");
11788                return Secure.putStringForUser(resolver, name, value, tag,
11789                        makeDefault, userHandle);
11790            }
11791            return sNameValueCache.putStringForUser(resolver, name, value, tag,
11792                    makeDefault, userHandle);
11793        }
11794
11795        /**
11796         * Construct the content URI for a particular name/value pair,
11797         * useful for monitoring changes with a ContentObserver.
11798         * @param name to look up in the table
11799         * @return the corresponding content URI, or null if not present
11800         */
11801        public static Uri getUriFor(String name) {
11802            return getUriFor(CONTENT_URI, name);
11803        }
11804
11805        /**
11806         * Convenience function for retrieving a single secure settings value
11807         * as an integer.  Note that internally setting values are always
11808         * stored as strings; this function converts the string to an integer
11809         * for you.  The default value will be returned if the setting is
11810         * not defined or not an integer.
11811         *
11812         * @param cr The ContentResolver to access.
11813         * @param name The name of the setting to retrieve.
11814         * @param def Value to return if the setting is not defined.
11815         *
11816         * @return The setting's current value, or 'def' if it is not defined
11817         * or not a valid integer.
11818         */
11819        public static int getInt(ContentResolver cr, String name, int def) {
11820            String v = getString(cr, name);
11821            try {
11822                return v != null ? Integer.parseInt(v) : def;
11823            } catch (NumberFormatException e) {
11824                return def;
11825            }
11826        }
11827
11828        /**
11829         * Convenience function for retrieving a single secure settings value
11830         * as an integer.  Note that internally setting values are always
11831         * stored as strings; this function converts the string to an integer
11832         * for you.
11833         * <p>
11834         * This version does not take a default value.  If the setting has not
11835         * been set, or the string value is not a number,
11836         * it throws {@link SettingNotFoundException}.
11837         *
11838         * @param cr The ContentResolver to access.
11839         * @param name The name of the setting to retrieve.
11840         *
11841         * @throws SettingNotFoundException Thrown if a setting by the given
11842         * name can't be found or the setting value is not an integer.
11843         *
11844         * @return The setting's current value.
11845         */
11846        public static int getInt(ContentResolver cr, String name)
11847                throws SettingNotFoundException {
11848            String v = getString(cr, name);
11849            try {
11850                return Integer.parseInt(v);
11851            } catch (NumberFormatException e) {
11852                throw new SettingNotFoundException(name);
11853            }
11854        }
11855
11856        /**
11857         * Convenience function for updating a single settings value as an
11858         * integer. This will either create a new entry in the table if the
11859         * given name does not exist, or modify the value of the existing row
11860         * with that name.  Note that internally setting values are always
11861         * stored as strings, so this function converts the given value to a
11862         * string before storing it.
11863         *
11864         * @param cr The ContentResolver to access.
11865         * @param name The name of the setting to modify.
11866         * @param value The new value for the setting.
11867         * @return true if the value was set, false on database errors
11868         */
11869        public static boolean putInt(ContentResolver cr, String name, int value) {
11870            return putString(cr, name, Integer.toString(value));
11871        }
11872
11873        /**
11874         * Convenience function for retrieving a single secure settings value
11875         * as a {@code long}.  Note that internally setting values are always
11876         * stored as strings; this function converts the string to a {@code long}
11877         * for you.  The default value will be returned if the setting is
11878         * not defined or not a {@code long}.
11879         *
11880         * @param cr The ContentResolver to access.
11881         * @param name The name of the setting to retrieve.
11882         * @param def Value to return if the setting is not defined.
11883         *
11884         * @return The setting's current value, or 'def' if it is not defined
11885         * or not a valid {@code long}.
11886         */
11887        public static long getLong(ContentResolver cr, String name, long def) {
11888            String valString = getString(cr, name);
11889            long value;
11890            try {
11891                value = valString != null ? Long.parseLong(valString) : def;
11892            } catch (NumberFormatException e) {
11893                value = def;
11894            }
11895            return value;
11896        }
11897
11898        /**
11899         * Convenience function for retrieving a single secure settings value
11900         * as a {@code long}.  Note that internally setting values are always
11901         * stored as strings; this function converts the string to a {@code long}
11902         * for you.
11903         * <p>
11904         * This version does not take a default value.  If the setting has not
11905         * been set, or the string value is not a number,
11906         * it throws {@link SettingNotFoundException}.
11907         *
11908         * @param cr The ContentResolver to access.
11909         * @param name The name of the setting to retrieve.
11910         *
11911         * @return The setting's current value.
11912         * @throws SettingNotFoundException Thrown if a setting by the given
11913         * name can't be found or the setting value is not an integer.
11914         */
11915        public static long getLong(ContentResolver cr, String name)
11916                throws SettingNotFoundException {
11917            String valString = getString(cr, name);
11918            try {
11919                return Long.parseLong(valString);
11920            } catch (NumberFormatException e) {
11921                throw new SettingNotFoundException(name);
11922            }
11923        }
11924
11925        /**
11926         * Convenience function for updating a secure settings value as a long
11927         * integer. This will either create a new entry in the table if the
11928         * given name does not exist, or modify the value of the existing row
11929         * with that name.  Note that internally setting values are always
11930         * stored as strings, so this function converts the given value to a
11931         * string before storing it.
11932         *
11933         * @param cr The ContentResolver to access.
11934         * @param name The name of the setting to modify.
11935         * @param value The new value for the setting.
11936         * @return true if the value was set, false on database errors
11937         */
11938        public static boolean putLong(ContentResolver cr, String name, long value) {
11939            return putString(cr, name, Long.toString(value));
11940        }
11941
11942        /**
11943         * Convenience function for retrieving a single secure settings value
11944         * as a floating point number.  Note that internally setting values are
11945         * always stored as strings; this function converts the string to an
11946         * float for you. The default value will be returned if the setting
11947         * is not defined or not a valid float.
11948         *
11949         * @param cr The ContentResolver to access.
11950         * @param name The name of the setting to retrieve.
11951         * @param def Value to return if the setting is not defined.
11952         *
11953         * @return The setting's current value, or 'def' if it is not defined
11954         * or not a valid float.
11955         */
11956        public static float getFloat(ContentResolver cr, String name, float def) {
11957            String v = getString(cr, name);
11958            try {
11959                return v != null ? Float.parseFloat(v) : def;
11960            } catch (NumberFormatException e) {
11961                return def;
11962            }
11963        }
11964
11965        /**
11966         * Convenience function for retrieving a single secure settings value
11967         * as a float.  Note that internally setting values are always
11968         * stored as strings; this function converts the string to a float
11969         * for you.
11970         * <p>
11971         * This version does not take a default value.  If the setting has not
11972         * been set, or the string value is not a number,
11973         * it throws {@link SettingNotFoundException}.
11974         *
11975         * @param cr The ContentResolver to access.
11976         * @param name The name of the setting to retrieve.
11977         *
11978         * @throws SettingNotFoundException Thrown if a setting by the given
11979         * name can't be found or the setting value is not a float.
11980         *
11981         * @return The setting's current value.
11982         */
11983        public static float getFloat(ContentResolver cr, String name)
11984                throws SettingNotFoundException {
11985            String v = getString(cr, name);
11986            if (v == null) {
11987                throw new SettingNotFoundException(name);
11988            }
11989            try {
11990                return Float.parseFloat(v);
11991            } catch (NumberFormatException e) {
11992                throw new SettingNotFoundException(name);
11993            }
11994        }
11995
11996        /**
11997         * Convenience function for updating a single settings value as a
11998         * floating point number. This will either create a new entry in the
11999         * table if the given name does not exist, or modify the value of the
12000         * existing row with that name.  Note that internally setting values
12001         * are always stored as strings, so this function converts the given
12002         * value to a string before storing it.
12003         *
12004         * @param cr The ContentResolver to access.
12005         * @param name The name of the setting to modify.
12006         * @param value The new value for the setting.
12007         * @return true if the value was set, false on database errors
12008         */
12009        public static boolean putFloat(ContentResolver cr, String name, float value) {
12010            return putString(cr, name, Float.toString(value));
12011        }
12012
12013        /**
12014          * Subscription to be used for voice call on a multi sim device. The supported values
12015          * are 0 = SUB1, 1 = SUB2 and etc.
12016          * @hide
12017          */
12018        public static final String MULTI_SIM_VOICE_CALL_SUBSCRIPTION = "multi_sim_voice_call";
12019
12020        /**
12021          * Used to provide option to user to select subscription during dial.
12022          * The supported values are 0 = disable or 1 = enable prompt.
12023          * @hide
12024          */
12025        public static final String MULTI_SIM_VOICE_PROMPT = "multi_sim_voice_prompt";
12026
12027        /**
12028          * Subscription to be used for data call on a multi sim device. The supported values
12029          * are 0 = SUB1, 1 = SUB2 and etc.
12030          * @hide
12031          */
12032        public static final String MULTI_SIM_DATA_CALL_SUBSCRIPTION = "multi_sim_data_call";
12033
12034        /**
12035          * Subscription to be used for SMS on a multi sim device. The supported values
12036          * are 0 = SUB1, 1 = SUB2 and etc.
12037          * @hide
12038          */
12039        public static final String MULTI_SIM_SMS_SUBSCRIPTION = "multi_sim_sms";
12040
12041       /**
12042          * Used to provide option to user to select subscription during send SMS.
12043          * The value 1 - enable, 0 - disable
12044          * @hide
12045          */
12046        public static final String MULTI_SIM_SMS_PROMPT = "multi_sim_sms_prompt";
12047
12048        /** User preferred subscriptions setting.
12049          * This holds the details of the user selected subscription from the card and
12050          * the activation status. Each settings string have the comma separated values
12051          * iccId,appType,appId,activationStatus,3gppIndex,3gpp2Index
12052          * @hide
12053         */
12054        public static final String[] MULTI_SIM_USER_PREFERRED_SUBS = {"user_preferred_sub1",
12055                "user_preferred_sub2","user_preferred_sub3"};
12056
12057        /**
12058         * Whether to enable new contacts aggregator or not.
12059         * The value 1 - enable, 0 - disable
12060         * @hide
12061         */
12062        public static final String NEW_CONTACT_AGGREGATOR = "new_contact_aggregator";
12063
12064        /**
12065         * Whether to enable contacts metadata syncing or not
12066         * The value 1 - enable, 0 - disable
12067         *
12068         * @removed
12069         */
12070        @Deprecated
12071        public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
12072
12073        /**
12074         * Whether to enable contacts metadata syncing or not
12075         * The value 1 - enable, 0 - disable
12076         */
12077        public static final String CONTACT_METADATA_SYNC_ENABLED = "contact_metadata_sync_enabled";
12078
12079        /**
12080         * Whether to enable cellular on boot.
12081         * The value 1 - enable, 0 - disable
12082         * @hide
12083         */
12084        public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
12085
12086        /**
12087         * The maximum allowed notification enqueue rate in Hertz.
12088         *
12089         * Should be a float, and includes updates only.
12090         * @hide
12091         */
12092        public static final String MAX_NOTIFICATION_ENQUEUE_RATE = "max_notification_enqueue_rate";
12093
12094        /**
12095         * Displays toasts when an app posts a notification that does not specify a valid channel.
12096         *
12097         * The value 1 - enable, 0 - disable
12098         * @hide
12099         */
12100        public static final String SHOW_NOTIFICATION_CHANNEL_WARNINGS =
12101                "show_notification_channel_warnings";
12102
12103        /**
12104         * Whether cell is enabled/disabled
12105         * @hide
12106         */
12107        public static final String CELL_ON = "cell_on";
12108
12109        /**
12110         * Global settings which can be accessed by instant apps.
12111         * @hide
12112         */
12113        public static final Set<String> INSTANT_APP_SETTINGS = new ArraySet<>();
12114        static {
12115            INSTANT_APP_SETTINGS.add(WAIT_FOR_DEBUGGER);
12116            INSTANT_APP_SETTINGS.add(DEVICE_PROVISIONED);
12117            INSTANT_APP_SETTINGS.add(DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES);
12118            INSTANT_APP_SETTINGS.add(DEVELOPMENT_FORCE_RTL);
12119            INSTANT_APP_SETTINGS.add(EPHEMERAL_COOKIE_MAX_SIZE_BYTES);
12120            INSTANT_APP_SETTINGS.add(AIRPLANE_MODE_ON);
12121            INSTANT_APP_SETTINGS.add(WINDOW_ANIMATION_SCALE);
12122            INSTANT_APP_SETTINGS.add(TRANSITION_ANIMATION_SCALE);
12123            INSTANT_APP_SETTINGS.add(ANIMATOR_DURATION_SCALE);
12124            INSTANT_APP_SETTINGS.add(DEBUG_VIEW_ATTRIBUTES);
12125            INSTANT_APP_SETTINGS.add(WTF_IS_FATAL);
12126            INSTANT_APP_SETTINGS.add(SEND_ACTION_APP_ERROR);
12127            INSTANT_APP_SETTINGS.add(ZEN_MODE);
12128        }
12129
12130        /**
12131         * Whether to show the high temperature warning notification.
12132         * @hide
12133         */
12134        public static final String SHOW_TEMPERATURE_WARNING = "show_temperature_warning";
12135
12136        /**
12137         * Temperature at which the high temperature warning notification should be shown.
12138         * @hide
12139         */
12140        public static final String WARNING_TEMPERATURE = "warning_temperature";
12141
12142        /**
12143         * Whether the diskstats logging task is enabled/disabled.
12144         * @hide
12145         */
12146        public static final String ENABLE_DISKSTATS_LOGGING = "enable_diskstats_logging";
12147
12148        /**
12149         * Whether the cache quota calculation task is enabled/disabled.
12150         * @hide
12151         */
12152        public static final String ENABLE_CACHE_QUOTA_CALCULATION =
12153                "enable_cache_quota_calculation";
12154
12155        /**
12156         * Whether the Deletion Helper no threshold toggle is available.
12157         * @hide
12158         */
12159        public static final String ENABLE_DELETION_HELPER_NO_THRESHOLD_TOGGLE =
12160                "enable_deletion_helper_no_threshold_toggle";
12161
12162        /**
12163         * The list of snooze options for notifications
12164         * This is encoded as a key=value list, separated by commas. Ex:
12165         *
12166         * "default=60,options_array=15:30:60:120"
12167         *
12168         * The following keys are supported:
12169         *
12170         * <pre>
12171         * default               (int)
12172         * options_array         (int[])
12173         * </pre>
12174         *
12175         * All delays in integer minutes. Array order is respected.
12176         * Options will be used in order up to the maximum allowed by the UI.
12177         * @hide
12178         */
12179        public static final String NOTIFICATION_SNOOZE_OPTIONS =
12180                "notification_snooze_options";
12181
12182        /**
12183         * Configuration flags for SQLite Compatibility WAL. Encoded as a key-value list, separated
12184         * by commas. E.g.: compatibility_wal_supported=true, wal_syncmode=OFF
12185         *
12186         * Supported keys:
12187         * compatibility_wal_supported      (boolean)
12188         * wal_syncmode       (String)
12189         *
12190         * @hide
12191         */
12192        public static final String SQLITE_COMPATIBILITY_WAL_FLAGS =
12193                "sqlite_compatibility_wal_flags";
12194
12195        /**
12196         * Enable GNSS Raw Measurements Full Tracking?
12197         * 0 = no
12198         * 1 = yes
12199         * @hide
12200         */
12201        public static final String ENABLE_GNSS_RAW_MEAS_FULL_TRACKING =
12202                "enable_gnss_raw_meas_full_tracking";
12203
12204        /**
12205         * Whether the notification should be ongoing (persistent) when a carrier app install is
12206         * required.
12207         *
12208         * The value is a boolean (1 or 0).
12209         * @hide
12210         */
12211        @SystemApi
12212        public static final String INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT =
12213                "install_carrier_app_notification_persistent";
12214
12215        /**
12216         * The amount of time (ms) to hide the install carrier app notification after the user has
12217         * ignored it. After this time passes, the notification will be shown again
12218         *
12219         * The value is a long
12220         * @hide
12221         */
12222        @SystemApi
12223        public static final String INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS =
12224                "install_carrier_app_notification_sleep_millis";
12225
12226        /**
12227         * Whether we've enabled zram on this device. Takes effect on
12228         * reboot. The value "1" enables zram; "0" disables it, and
12229         * everything else is unspecified.
12230         * @hide
12231         */
12232        public static final String ZRAM_ENABLED =
12233                "zram_enabled";
12234
12235        /**
12236         * Configuration flags for smart replies in notifications.
12237         * This is encoded as a key=value list, separated by commas. Ex:
12238         *
12239         * "enabled=1,max_squeeze_remeasure_count=3"
12240         *
12241         * The following keys are supported:
12242         *
12243         * <pre>
12244         * enabled                         (boolean)
12245         * max_squeeze_remeasure_attempts  (int)
12246         * </pre>
12247         * @see com.android.systemui.statusbar.policy.SmartReplyConstants
12248         * @hide
12249         */
12250        public static final String SMART_REPLIES_IN_NOTIFICATIONS_FLAGS =
12251                "smart_replies_in_notifications_flags";
12252
12253        /**
12254         * If nonzero, crashes in foreground processes will bring up a dialog.
12255         * Otherwise, the process will be silently killed.
12256         * @hide
12257         */
12258        public static final String SHOW_FIRST_CRASH_DIALOG = "show_first_crash_dialog";
12259
12260        /**
12261         * If nonzero, crash dialogs will show an option to restart the app.
12262         * @hide
12263         */
12264        public static final String SHOW_RESTART_IN_CRASH_DIALOG = "show_restart_in_crash_dialog";
12265
12266        /**
12267         * If nonzero, crash dialogs will show an option to mute all future crash dialogs for
12268         * this app.
12269         * @hide
12270         */
12271        public static final String SHOW_MUTE_IN_CRASH_DIALOG = "show_mute_in_crash_dialog";
12272
12273        /**
12274         * If nonzero, will show the zen upgrade notification when the user toggles DND on/off.
12275         * @hide
12276         */
12277        public static final String SHOW_ZEN_UPGRADE_NOTIFICATION = "show_zen_upgrade_notification";
12278    }
12279
12280    /**
12281     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
12282     * Intent URL, allowing it to be either a web page or a particular
12283     * application activity.
12284     *
12285     * @hide
12286     */
12287    public static final class Bookmarks implements BaseColumns
12288    {
12289        private static final String TAG = "Bookmarks";
12290
12291        /**
12292         * The content:// style URL for this table
12293         */
12294        public static final Uri CONTENT_URI =
12295            Uri.parse("content://" + AUTHORITY + "/bookmarks");
12296
12297        /**
12298         * The row ID.
12299         * <p>Type: INTEGER</p>
12300         */
12301        public static final String ID = "_id";
12302
12303        /**
12304         * Descriptive name of the bookmark that can be displayed to the user.
12305         * If this is empty, the title should be resolved at display time (use
12306         * {@link #getTitle(Context, Cursor)} any time you want to display the
12307         * title of a bookmark.)
12308         * <P>
12309         * Type: TEXT
12310         * </P>
12311         */
12312        public static final String TITLE = "title";
12313
12314        /**
12315         * Arbitrary string (displayed to the user) that allows bookmarks to be
12316         * organized into categories.  There are some special names for
12317         * standard folders, which all start with '@'.  The label displayed for
12318         * the folder changes with the locale (via {@link #getLabelForFolder}) but
12319         * the folder name does not change so you can consistently query for
12320         * the folder regardless of the current locale.
12321         *
12322         * <P>Type: TEXT</P>
12323         *
12324         */
12325        public static final String FOLDER = "folder";
12326
12327        /**
12328         * The Intent URL of the bookmark, describing what it points to.  This
12329         * value is given to {@link android.content.Intent#getIntent} to create
12330         * an Intent that can be launched.
12331         * <P>Type: TEXT</P>
12332         */
12333        public static final String INTENT = "intent";
12334
12335        /**
12336         * Optional shortcut character associated with this bookmark.
12337         * <P>Type: INTEGER</P>
12338         */
12339        public static final String SHORTCUT = "shortcut";
12340
12341        /**
12342         * The order in which the bookmark should be displayed
12343         * <P>Type: INTEGER</P>
12344         */
12345        public static final String ORDERING = "ordering";
12346
12347        private static final String[] sIntentProjection = { INTENT };
12348        private static final String[] sShortcutProjection = { ID, SHORTCUT };
12349        private static final String sShortcutSelection = SHORTCUT + "=?";
12350
12351        /**
12352         * Convenience function to retrieve the bookmarked Intent for a
12353         * particular shortcut key.
12354         *
12355         * @param cr The ContentResolver to query.
12356         * @param shortcut The shortcut key.
12357         *
12358         * @return Intent The bookmarked URL, or null if there is no bookmark
12359         *         matching the given shortcut.
12360         */
12361        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
12362        {
12363            Intent intent = null;
12364
12365            Cursor c = cr.query(CONTENT_URI,
12366                    sIntentProjection, sShortcutSelection,
12367                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
12368            // Keep trying until we find a valid shortcut
12369            try {
12370                while (intent == null && c.moveToNext()) {
12371                    try {
12372                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
12373                        intent = Intent.parseUri(intentURI, 0);
12374                    } catch (java.net.URISyntaxException e) {
12375                        // The stored URL is bad...  ignore it.
12376                    } catch (IllegalArgumentException e) {
12377                        // Column not found
12378                        Log.w(TAG, "Intent column not found", e);
12379                    }
12380                }
12381            } finally {
12382                if (c != null) c.close();
12383            }
12384
12385            return intent;
12386        }
12387
12388        /**
12389         * Add a new bookmark to the system.
12390         *
12391         * @param cr The ContentResolver to query.
12392         * @param intent The desired target of the bookmark.
12393         * @param title Bookmark title that is shown to the user; null if none
12394         *            or it should be resolved to the intent's title.
12395         * @param folder Folder in which to place the bookmark; null if none.
12396         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
12397         *            this is non-zero and there is an existing bookmark entry
12398         *            with this same shortcut, then that existing shortcut is
12399         *            cleared (the bookmark is not removed).
12400         * @return The unique content URL for the new bookmark entry.
12401         */
12402        public static Uri add(ContentResolver cr,
12403                                           Intent intent,
12404                                           String title,
12405                                           String folder,
12406                                           char shortcut,
12407                                           int ordering)
12408        {
12409            // If a shortcut is supplied, and it is already defined for
12410            // another bookmark, then remove the old definition.
12411            if (shortcut != 0) {
12412                cr.delete(CONTENT_URI, sShortcutSelection,
12413                        new String[] { String.valueOf((int) shortcut) });
12414            }
12415
12416            ContentValues values = new ContentValues();
12417            if (title != null) values.put(TITLE, title);
12418            if (folder != null) values.put(FOLDER, folder);
12419            values.put(INTENT, intent.toUri(0));
12420            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
12421            values.put(ORDERING, ordering);
12422            return cr.insert(CONTENT_URI, values);
12423        }
12424
12425        /**
12426         * Return the folder name as it should be displayed to the user.  This
12427         * takes care of localizing special folders.
12428         *
12429         * @param r Resources object for current locale; only need access to
12430         *          system resources.
12431         * @param folder The value found in the {@link #FOLDER} column.
12432         *
12433         * @return CharSequence The label for this folder that should be shown
12434         *         to the user.
12435         */
12436        public static CharSequence getLabelForFolder(Resources r, String folder) {
12437            return folder;
12438        }
12439
12440        /**
12441         * Return the title as it should be displayed to the user. This takes
12442         * care of localizing bookmarks that point to activities.
12443         *
12444         * @param context A context.
12445         * @param cursor A cursor pointing to the row whose title should be
12446         *        returned. The cursor must contain at least the {@link #TITLE}
12447         *        and {@link #INTENT} columns.
12448         * @return A title that is localized and can be displayed to the user,
12449         *         or the empty string if one could not be found.
12450         */
12451        public static CharSequence getTitle(Context context, Cursor cursor) {
12452            int titleColumn = cursor.getColumnIndex(TITLE);
12453            int intentColumn = cursor.getColumnIndex(INTENT);
12454            if (titleColumn == -1 || intentColumn == -1) {
12455                throw new IllegalArgumentException(
12456                        "The cursor must contain the TITLE and INTENT columns.");
12457            }
12458
12459            String title = cursor.getString(titleColumn);
12460            if (!TextUtils.isEmpty(title)) {
12461                return title;
12462            }
12463
12464            String intentUri = cursor.getString(intentColumn);
12465            if (TextUtils.isEmpty(intentUri)) {
12466                return "";
12467            }
12468
12469            Intent intent;
12470            try {
12471                intent = Intent.parseUri(intentUri, 0);
12472            } catch (URISyntaxException e) {
12473                return "";
12474            }
12475
12476            PackageManager packageManager = context.getPackageManager();
12477            ResolveInfo info = packageManager.resolveActivity(intent, 0);
12478            return info != null ? info.loadLabel(packageManager) : "";
12479        }
12480    }
12481
12482    /**
12483     * Returns the device ID that we should use when connecting to the mobile gtalk server.
12484     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
12485     * from the GoogleLoginService.
12486     *
12487     * @param androidId The Android ID for this device.
12488     * @return The device ID that should be used when connecting to the mobile gtalk server.
12489     * @hide
12490     */
12491    public static String getGTalkDeviceId(long androidId) {
12492        return "android-" + Long.toHexString(androidId);
12493    }
12494
12495    private static final String[] PM_WRITE_SETTINGS = {
12496        android.Manifest.permission.WRITE_SETTINGS
12497    };
12498    private static final String[] PM_CHANGE_NETWORK_STATE = {
12499        android.Manifest.permission.CHANGE_NETWORK_STATE,
12500        android.Manifest.permission.WRITE_SETTINGS
12501    };
12502    private static final String[] PM_SYSTEM_ALERT_WINDOW = {
12503        android.Manifest.permission.SYSTEM_ALERT_WINDOW
12504    };
12505
12506    /**
12507     * Performs a strict and comprehensive check of whether a calling package is allowed to
12508     * write/modify system settings, as the condition differs for pre-M, M+, and
12509     * privileged/preinstalled apps. If the provided uid does not match the
12510     * callingPackage, a negative result will be returned.
12511     * @hide
12512     */
12513    public static boolean isCallingPackageAllowedToWriteSettings(Context context, int uid,
12514            String callingPackage, boolean throwException) {
12515        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
12516                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
12517                PM_WRITE_SETTINGS, false);
12518    }
12519
12520    /**
12521     * Performs a strict and comprehensive check of whether a calling package is allowed to
12522     * write/modify system settings, as the condition differs for pre-M, M+, and
12523     * privileged/preinstalled apps. If the provided uid does not match the
12524     * callingPackage, a negative result will be returned. The caller is expected to have
12525     * the WRITE_SETTINGS permission declared.
12526     *
12527     * Note: if the check is successful, the operation of this app will be updated to the
12528     * current time.
12529     * @hide
12530     */
12531    public static boolean checkAndNoteWriteSettingsOperation(Context context, int uid,
12532            String callingPackage, boolean throwException) {
12533        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
12534                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
12535                PM_WRITE_SETTINGS, true);
12536    }
12537
12538    /**
12539     * Performs a strict and comprehensive check of whether a calling package is allowed to
12540     * change the state of network, as the condition differs for pre-M, M+, and
12541     * privileged/preinstalled apps. The caller is expected to have either the
12542     * CHANGE_NETWORK_STATE or the WRITE_SETTINGS permission declared. Either of these
12543     * permissions allow changing network state; WRITE_SETTINGS is a runtime permission and
12544     * can be revoked, but (except in M, excluding M MRs), CHANGE_NETWORK_STATE is a normal
12545     * permission and cannot be revoked. See http://b/23597341
12546     *
12547     * Note: if the check succeeds because the application holds WRITE_SETTINGS, the operation
12548     * of this app will be updated to the current time.
12549     * @hide
12550     */
12551    public static boolean checkAndNoteChangeNetworkStateOperation(Context context, int uid,
12552            String callingPackage, boolean throwException) {
12553        if (context.checkCallingOrSelfPermission(android.Manifest.permission.CHANGE_NETWORK_STATE)
12554                == PackageManager.PERMISSION_GRANTED) {
12555            return true;
12556        }
12557        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
12558                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
12559                PM_CHANGE_NETWORK_STATE, true);
12560    }
12561
12562    /**
12563     * Performs a strict and comprehensive check of whether a calling package is allowed to
12564     * draw on top of other apps, as the conditions differs for pre-M, M+, and
12565     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
12566     * a negative result will be returned.
12567     * @hide
12568     */
12569    public static boolean isCallingPackageAllowedToDrawOverlays(Context context, int uid,
12570            String callingPackage, boolean throwException) {
12571        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
12572                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
12573                PM_SYSTEM_ALERT_WINDOW, false);
12574    }
12575
12576    /**
12577     * Performs a strict and comprehensive check of whether a calling package is allowed to
12578     * draw on top of other apps, as the conditions differs for pre-M, M+, and
12579     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
12580     * a negative result will be returned.
12581     *
12582     * Note: if the check is successful, the operation of this app will be updated to the
12583     * current time.
12584     * @hide
12585     */
12586    public static boolean checkAndNoteDrawOverlaysOperation(Context context, int uid, String
12587            callingPackage, boolean throwException) {
12588        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
12589                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
12590                PM_SYSTEM_ALERT_WINDOW, true);
12591    }
12592
12593    /**
12594     * Helper method to perform a general and comprehensive check of whether an operation that is
12595     * protected by appops can be performed by a caller or not. e.g. OP_SYSTEM_ALERT_WINDOW and
12596     * OP_WRITE_SETTINGS
12597     * @hide
12598     */
12599    public static boolean isCallingPackageAllowedToPerformAppOpsProtectedOperation(Context context,
12600            int uid, String callingPackage, boolean throwException, int appOpsOpCode, String[]
12601            permissions, boolean makeNote) {
12602        if (callingPackage == null) {
12603            return false;
12604        }
12605
12606        AppOpsManager appOpsMgr = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
12607        int mode = AppOpsManager.MODE_DEFAULT;
12608        if (makeNote) {
12609            mode = appOpsMgr.noteOpNoThrow(appOpsOpCode, uid, callingPackage);
12610        } else {
12611            mode = appOpsMgr.checkOpNoThrow(appOpsOpCode, uid, callingPackage);
12612        }
12613
12614        switch (mode) {
12615            case AppOpsManager.MODE_ALLOWED:
12616                return true;
12617
12618            case AppOpsManager.MODE_DEFAULT:
12619                // this is the default operating mode after an app's installation
12620                // In this case we will check all associated static permission to see
12621                // if it is granted during install time.
12622                for (String permission : permissions) {
12623                    if (context.checkCallingOrSelfPermission(permission) == PackageManager
12624                            .PERMISSION_GRANTED) {
12625                        // if either of the permissions are granted, we will allow it
12626                        return true;
12627                    }
12628                }
12629
12630            default:
12631                // this is for all other cases trickled down here...
12632                if (!throwException) {
12633                    return false;
12634                }
12635        }
12636
12637        // prepare string to throw SecurityException
12638        StringBuilder exceptionMessage = new StringBuilder();
12639        exceptionMessage.append(callingPackage);
12640        exceptionMessage.append(" was not granted ");
12641        if (permissions.length > 1) {
12642            exceptionMessage.append(" either of these permissions: ");
12643        } else {
12644            exceptionMessage.append(" this permission: ");
12645        }
12646        for (int i = 0; i < permissions.length; i++) {
12647            exceptionMessage.append(permissions[i]);
12648            exceptionMessage.append((i == permissions.length - 1) ? "." : ", ");
12649        }
12650
12651        throw new SecurityException(exceptionMessage.toString());
12652    }
12653
12654    /**
12655     * Retrieves a correponding package name for a given uid. It will query all
12656     * packages that are associated with the given uid, but it will return only
12657     * the zeroth result.
12658     * Note: If package could not be found, a null is returned.
12659     * @hide
12660     */
12661    public static String getPackageNameForUid(Context context, int uid) {
12662        String[] packages = context.getPackageManager().getPackagesForUid(uid);
12663        if (packages == null) {
12664            return null;
12665        }
12666        return packages[0];
12667    }
12668}
12669