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