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