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