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