Settings.java revision 19841794096e7c9f7112ba25af9bfda04403f791
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         * Uri of the slice that's presented on the keyguard.
6005         * Defaults to a slice with the date and next alarm.
6006         *
6007         * @hide
6008         */
6009        public static final String KEYGUARD_SLICE_URI = "keyguard_slice_uri";
6010
6011        /**
6012         * Whether to speak passwords while in accessibility mode.
6013         *
6014         * @deprecated The speaking of passwords is controlled by individual accessibility services.
6015         * Apps should ignore this setting and provide complete information to accessibility
6016         * at all times, which was the behavior when this value was {@code true}.
6017         */
6018        @Deprecated
6019        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
6020
6021        private static final Validator ACCESSIBILITY_SPEAK_PASSWORD_VALIDATOR = BOOLEAN_VALIDATOR;
6022
6023        /**
6024         * Whether to draw text with high contrast while in accessibility mode.
6025         *
6026         * @hide
6027         */
6028        public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED =
6029                "high_text_contrast_enabled";
6030
6031        private static final Validator ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR =
6032                BOOLEAN_VALIDATOR;
6033
6034        /**
6035         * Setting that specifies whether the display magnification is enabled via a system-wide
6036         * triple tap gesture. Display magnifications allows the user to zoom in the display content
6037         * and is targeted to low vision users. The current magnification scale is controlled by
6038         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
6039         *
6040         * @hide
6041         */
6042        @TestApi
6043        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED =
6044                "accessibility_display_magnification_enabled";
6045
6046        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR =
6047                BOOLEAN_VALIDATOR;
6048
6049        /**
6050         * Setting that specifies whether the display magnification is enabled via a shortcut
6051         * affordance within the system's navigation area. Display magnifications allows the user to
6052         * zoom in the display content and is targeted to low vision users. The current
6053         * magnification scale is controlled by {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
6054         *
6055         * @hide
6056         */
6057        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED =
6058                "accessibility_display_magnification_navbar_enabled";
6059
6060        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR
6061                = BOOLEAN_VALIDATOR;
6062
6063        /**
6064         * Setting that specifies what the display magnification scale is.
6065         * Display magnifications allows the user to zoom in the display
6066         * content and is targeted to low vision users. Whether a display
6067         * magnification is performed is controlled by
6068         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED} and
6069         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED}
6070         *
6071         * @hide
6072         */
6073        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE =
6074                "accessibility_display_magnification_scale";
6075
6076        private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR =
6077                new SettingsValidators.InclusiveFloatRangeValidator(1.0f, Float.MAX_VALUE);
6078
6079        /**
6080         * Unused mangnification setting
6081         *
6082         * @hide
6083         * @deprecated
6084         */
6085        @Deprecated
6086        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE =
6087                "accessibility_display_magnification_auto_update";
6088
6089        /**
6090         * Setting that specifies what mode the soft keyboard is in (default or hidden). Can be
6091         * modified from an AccessibilityService using the SoftKeyboardController.
6092         *
6093         * @hide
6094         */
6095        public static final String ACCESSIBILITY_SOFT_KEYBOARD_MODE =
6096                "accessibility_soft_keyboard_mode";
6097
6098        /**
6099         * Default soft keyboard behavior.
6100         *
6101         * @hide
6102         */
6103        public static final int SHOW_MODE_AUTO = 0;
6104
6105        /**
6106         * Soft keyboard is never shown.
6107         *
6108         * @hide
6109         */
6110        public static final int SHOW_MODE_HIDDEN = 1;
6111
6112        /**
6113         * Setting that specifies whether timed text (captions) should be
6114         * displayed in video content. Text display properties are controlled by
6115         * the following settings:
6116         * <ul>
6117         * <li>{@link #ACCESSIBILITY_CAPTIONING_LOCALE}
6118         * <li>{@link #ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR}
6119         * <li>{@link #ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR}
6120         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_COLOR}
6121         * <li>{@link #ACCESSIBILITY_CAPTIONING_EDGE_TYPE}
6122         * <li>{@link #ACCESSIBILITY_CAPTIONING_TYPEFACE}
6123         * <li>{@link #ACCESSIBILITY_CAPTIONING_FONT_SCALE}
6124         * </ul>
6125         *
6126         * @hide
6127         */
6128        public static final String ACCESSIBILITY_CAPTIONING_ENABLED =
6129                "accessibility_captioning_enabled";
6130
6131        private static final Validator ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR =
6132                BOOLEAN_VALIDATOR;
6133
6134        /**
6135         * Setting that specifies the language for captions as a locale string,
6136         * e.g. en_US.
6137         *
6138         * @see java.util.Locale#toString
6139         * @hide
6140         */
6141        public static final String ACCESSIBILITY_CAPTIONING_LOCALE =
6142                "accessibility_captioning_locale";
6143
6144        private static final Validator ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR = LOCALE_VALIDATOR;
6145
6146        /**
6147         * Integer property that specifies the preset style for captions, one
6148         * of:
6149         * <ul>
6150         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESET_CUSTOM}
6151         * <li>a valid index of {@link android.view.accessibility.CaptioningManager.CaptionStyle#PRESETS}
6152         * </ul>
6153         *
6154         * @see java.util.Locale#toString
6155         * @hide
6156         */
6157        public static final String ACCESSIBILITY_CAPTIONING_PRESET =
6158                "accessibility_captioning_preset";
6159
6160        private static final Validator ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR =
6161                new SettingsValidators.DiscreteValueValidator(new String[]{"-1", "0", "1", "2",
6162                        "3", "4"});
6163
6164        /**
6165         * Integer property that specifes the background color for captions as a
6166         * packed 32-bit color.
6167         *
6168         * @see android.graphics.Color#argb
6169         * @hide
6170         */
6171        public static final String ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR =
6172                "accessibility_captioning_background_color";
6173
6174        private static final Validator ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR =
6175                ANY_INTEGER_VALIDATOR;
6176
6177        /**
6178         * Integer property that specifes the foreground color for captions as a
6179         * packed 32-bit color.
6180         *
6181         * @see android.graphics.Color#argb
6182         * @hide
6183         */
6184        public static final String ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR =
6185                "accessibility_captioning_foreground_color";
6186
6187        private static final Validator ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR =
6188                ANY_INTEGER_VALIDATOR;
6189
6190        /**
6191         * Integer property that specifes the edge type for captions, one of:
6192         * <ul>
6193         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_NONE}
6194         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_OUTLINE}
6195         * <li>{@link android.view.accessibility.CaptioningManager.CaptionStyle#EDGE_TYPE_DROP_SHADOW}
6196         * </ul>
6197         *
6198         * @see #ACCESSIBILITY_CAPTIONING_EDGE_COLOR
6199         * @hide
6200         */
6201        public static final String ACCESSIBILITY_CAPTIONING_EDGE_TYPE =
6202                "accessibility_captioning_edge_type";
6203
6204        private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR =
6205                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1", "2"});
6206
6207        /**
6208         * Integer property that specifes the edge color for captions as a
6209         * packed 32-bit color.
6210         *
6211         * @see #ACCESSIBILITY_CAPTIONING_EDGE_TYPE
6212         * @see android.graphics.Color#argb
6213         * @hide
6214         */
6215        public static final String ACCESSIBILITY_CAPTIONING_EDGE_COLOR =
6216                "accessibility_captioning_edge_color";
6217
6218        private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR =
6219                ANY_INTEGER_VALIDATOR;
6220
6221        /**
6222         * Integer property that specifes the window color for captions as a
6223         * packed 32-bit color.
6224         *
6225         * @see android.graphics.Color#argb
6226         * @hide
6227         */
6228        public static final String ACCESSIBILITY_CAPTIONING_WINDOW_COLOR =
6229                "accessibility_captioning_window_color";
6230
6231        private static final Validator ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR =
6232                ANY_INTEGER_VALIDATOR;
6233
6234        /**
6235         * String property that specifies the typeface for captions, one of:
6236         * <ul>
6237         * <li>DEFAULT
6238         * <li>MONOSPACE
6239         * <li>SANS_SERIF
6240         * <li>SERIF
6241         * </ul>
6242         *
6243         * @see android.graphics.Typeface
6244         * @hide
6245         */
6246        public static final String ACCESSIBILITY_CAPTIONING_TYPEFACE =
6247                "accessibility_captioning_typeface";
6248
6249        private static final Validator ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR =
6250                new SettingsValidators.DiscreteValueValidator(new String[]{"DEFAULT",
6251                        "MONOSPACE", "SANS_SERIF", "SERIF"});
6252
6253        /**
6254         * Floating point property that specifies font scaling for captions.
6255         *
6256         * @hide
6257         */
6258        public static final String ACCESSIBILITY_CAPTIONING_FONT_SCALE =
6259                "accessibility_captioning_font_scale";
6260
6261        private static final Validator ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR =
6262                new SettingsValidators.InclusiveFloatRangeValidator(0.5f, 2.0f);
6263
6264        /**
6265         * Setting that specifies whether display color inversion is enabled.
6266         */
6267        public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED =
6268                "accessibility_display_inversion_enabled";
6269
6270        private static final Validator ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR =
6271                BOOLEAN_VALIDATOR;
6272
6273        /**
6274         * Setting that specifies whether display color space adjustment is
6275         * enabled.
6276         *
6277         * @hide
6278         */
6279        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED =
6280                "accessibility_display_daltonizer_enabled";
6281
6282        private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR =
6283                BOOLEAN_VALIDATOR;
6284
6285        /**
6286         * Integer property that specifies the type of color space adjustment to
6287         * perform. Valid values are defined in AccessibilityManager and Settings arrays.xml:
6288         * - AccessibilityManager.DALTONIZER_DISABLED = -1
6289         * - AccessibilityManager.DALTONIZER_SIMULATE_MONOCHROMACY = 0
6290         * - <item>@string/daltonizer_mode_protanomaly</item> = 11
6291         * - AccessibilityManager.DALTONIZER_CORRECT_DEUTERANOMALY and
6292         *       <item>@string/daltonizer_mode_deuteranomaly</item> = 12
6293         * - <item>@string/daltonizer_mode_tritanomaly</item> = 13
6294         *
6295         * @hide
6296         */
6297        public static final String ACCESSIBILITY_DISPLAY_DALTONIZER =
6298                "accessibility_display_daltonizer";
6299
6300        private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR =
6301                new SettingsValidators.DiscreteValueValidator(
6302                        new String[] {"-1", "0", "11", "12", "13"});
6303
6304        /**
6305         * Setting that specifies whether automatic click when the mouse pointer stops moving is
6306         * enabled.
6307         *
6308         * @hide
6309         */
6310        public static final String ACCESSIBILITY_AUTOCLICK_ENABLED =
6311                "accessibility_autoclick_enabled";
6312
6313        private static final Validator ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR =
6314                BOOLEAN_VALIDATOR;
6315
6316        /**
6317         * Integer setting specifying amount of time in ms the mouse pointer has to stay still
6318         * before performing click when {@link #ACCESSIBILITY_AUTOCLICK_ENABLED} is set.
6319         *
6320         * @see #ACCESSIBILITY_AUTOCLICK_ENABLED
6321         * @hide
6322         */
6323        public static final String ACCESSIBILITY_AUTOCLICK_DELAY =
6324                "accessibility_autoclick_delay";
6325
6326        private static final Validator ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR =
6327                NON_NEGATIVE_INTEGER_VALIDATOR;
6328
6329        /**
6330         * Whether or not larger size icons are used for the pointer of mouse/trackpad for
6331         * accessibility.
6332         * (0 = false, 1 = true)
6333         * @hide
6334         */
6335        public static final String ACCESSIBILITY_LARGE_POINTER_ICON =
6336                "accessibility_large_pointer_icon";
6337
6338        private static final Validator ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR =
6339                BOOLEAN_VALIDATOR;
6340
6341        /**
6342         * The timeout for considering a press to be a long press in milliseconds.
6343         * @hide
6344         */
6345        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
6346
6347        private static final Validator LONG_PRESS_TIMEOUT_VALIDATOR =
6348                NON_NEGATIVE_INTEGER_VALIDATOR;
6349
6350        /**
6351         * The duration in milliseconds between the first tap's up event and the second tap's
6352         * down event for an interaction to be considered part of the same multi-press.
6353         * @hide
6354         */
6355        public static final String MULTI_PRESS_TIMEOUT = "multi_press_timeout";
6356
6357        /**
6358         * List of the enabled print services.
6359         *
6360         * N and beyond uses {@link #DISABLED_PRINT_SERVICES}. But this might be used in an upgrade
6361         * from pre-N.
6362         *
6363         * @hide
6364         */
6365        public static final String ENABLED_PRINT_SERVICES =
6366            "enabled_print_services";
6367
6368        /**
6369         * List of the disabled print services.
6370         *
6371         * @hide
6372         */
6373        @TestApi
6374        public static final String DISABLED_PRINT_SERVICES =
6375            "disabled_print_services";
6376
6377        /**
6378         * The saved value for WindowManagerService.setForcedDisplayDensity()
6379         * formatted as a single integer representing DPI. If unset, then use
6380         * the real display density.
6381         *
6382         * @hide
6383         */
6384        public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
6385
6386        /**
6387         * Setting to always use the default text-to-speech settings regardless
6388         * of the application settings.
6389         * 1 = override application settings,
6390         * 0 = use application settings (if specified).
6391         *
6392         * @deprecated  The value of this setting is no longer respected by
6393         * the framework text to speech APIs as of the Ice Cream Sandwich release.
6394         */
6395        @Deprecated
6396        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
6397
6398        /**
6399         * Default text-to-speech engine speech rate. 100 = 1x
6400         */
6401        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
6402
6403        private static final Validator TTS_DEFAULT_RATE_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR;
6404
6405        /**
6406         * Default text-to-speech engine pitch. 100 = 1x
6407         */
6408        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
6409
6410        private static final Validator TTS_DEFAULT_PITCH_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR;
6411
6412        /**
6413         * Default text-to-speech engine.
6414         */
6415        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
6416
6417        private static final Validator TTS_DEFAULT_SYNTH_VALIDATOR = PACKAGE_NAME_VALIDATOR;
6418
6419        /**
6420         * Default text-to-speech language.
6421         *
6422         * @deprecated this setting is no longer in use, as of the Ice Cream
6423         * Sandwich release. Apps should never need to read this setting directly,
6424         * instead can query the TextToSpeech framework classes for the default
6425         * locale. {@link TextToSpeech#getLanguage()}.
6426         */
6427        @Deprecated
6428        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
6429
6430        /**
6431         * Default text-to-speech country.
6432         *
6433         * @deprecated this setting is no longer in use, as of the Ice Cream
6434         * Sandwich release. Apps should never need to read this setting directly,
6435         * instead can query the TextToSpeech framework classes for the default
6436         * locale. {@link TextToSpeech#getLanguage()}.
6437         */
6438        @Deprecated
6439        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
6440
6441        /**
6442         * Default text-to-speech locale variant.
6443         *
6444         * @deprecated this setting is no longer in use, as of the Ice Cream
6445         * Sandwich release. Apps should never need to read this setting directly,
6446         * instead can query the TextToSpeech framework classes for the
6447         * locale that is in use {@link TextToSpeech#getLanguage()}.
6448         */
6449        @Deprecated
6450        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
6451
6452        /**
6453         * Stores the default tts locales on a per engine basis. Stored as
6454         * a comma seperated list of values, each value being of the form
6455         * {@code engine_name:locale} for example,
6456         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
6457         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
6458         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
6459         * setting directly, and can query the TextToSpeech framework classes
6460         * for the locale that is in use.
6461         *
6462         * @hide
6463         */
6464        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
6465
6466        private static final Validator TTS_DEFAULT_LOCALE_VALIDATOR = new Validator() {
6467            @Override
6468            public boolean validate(String value) {
6469                if (value == null || value.length() == 0) {
6470                    return false;
6471                }
6472                String[] ttsLocales = value.split(",");
6473                boolean valid = true;
6474                for (String ttsLocale : ttsLocales) {
6475                    String[] parts = ttsLocale.split(":");
6476                    valid |= ((parts.length == 2)
6477                            && (parts[0].length() > 0)
6478                            && ANY_STRING_VALIDATOR.validate(parts[0])
6479                            && LOCALE_VALIDATOR.validate(parts[1]));
6480                }
6481                return valid;
6482            }
6483        };
6484
6485        /**
6486         * Space delimited list of plugin packages that are enabled.
6487         */
6488        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
6489
6490        private static final Validator TTS_ENABLED_PLUGINS_VALIDATOR =
6491                new SettingsValidators.PackageNameListValidator(" ");
6492
6493        /**
6494         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
6495         * instead.
6496         */
6497        @Deprecated
6498        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
6499                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
6500
6501        private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
6502                BOOLEAN_VALIDATOR;
6503
6504        /**
6505         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
6506         * instead.
6507         */
6508        @Deprecated
6509        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
6510                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
6511
6512        private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR =
6513                NON_NEGATIVE_INTEGER_VALIDATOR;
6514
6515        /**
6516         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
6517         * instead.
6518         */
6519        @Deprecated
6520        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
6521                Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
6522
6523        private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR =
6524                NON_NEGATIVE_INTEGER_VALIDATOR;
6525
6526        /**
6527         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
6528         * instead.
6529         */
6530        @Deprecated
6531        public static final String WIFI_ON = Global.WIFI_ON;
6532
6533        /**
6534         * The acceptable packet loss percentage (range 0 - 100) before trying
6535         * another AP on the same network.
6536         * @deprecated This setting is not used.
6537         */
6538        @Deprecated
6539        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
6540                "wifi_watchdog_acceptable_packet_loss_percentage";
6541
6542        /**
6543         * The number of access points required for a network in order for the
6544         * watchdog to monitor it.
6545         * @deprecated This setting is not used.
6546         */
6547        @Deprecated
6548        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
6549
6550        /**
6551         * The delay between background checks.
6552         * @deprecated This setting is not used.
6553         */
6554        @Deprecated
6555        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
6556                "wifi_watchdog_background_check_delay_ms";
6557
6558        /**
6559         * Whether the Wi-Fi watchdog is enabled for background checking even
6560         * after it thinks the user has connected to a good access point.
6561         * @deprecated This setting is not used.
6562         */
6563        @Deprecated
6564        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
6565                "wifi_watchdog_background_check_enabled";
6566
6567        /**
6568         * The timeout for a background ping
6569         * @deprecated This setting is not used.
6570         */
6571        @Deprecated
6572        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
6573                "wifi_watchdog_background_check_timeout_ms";
6574
6575        /**
6576         * The number of initial pings to perform that *may* be ignored if they
6577         * fail. Again, if these fail, they will *not* be used in packet loss
6578         * calculation. For example, one network always seemed to time out for
6579         * the first couple pings, so this is set to 3 by default.
6580         * @deprecated This setting is not used.
6581         */
6582        @Deprecated
6583        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
6584            "wifi_watchdog_initial_ignored_ping_count";
6585
6586        /**
6587         * The maximum number of access points (per network) to attempt to test.
6588         * If this number is reached, the watchdog will no longer monitor the
6589         * initial connection state for the network. This is a safeguard for
6590         * networks containing multiple APs whose DNS does not respond to pings.
6591         * @deprecated This setting is not used.
6592         */
6593        @Deprecated
6594        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
6595
6596        /**
6597         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
6598         */
6599        @Deprecated
6600        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
6601
6602        /**
6603         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
6604         * @deprecated This setting is not used.
6605         */
6606        @Deprecated
6607        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
6608
6609        /**
6610         * The number of pings to test if an access point is a good connection.
6611         * @deprecated This setting is not used.
6612         */
6613        @Deprecated
6614        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
6615
6616        /**
6617         * The delay between pings.
6618         * @deprecated This setting is not used.
6619         */
6620        @Deprecated
6621        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
6622
6623        /**
6624         * The timeout per ping.
6625         * @deprecated This setting is not used.
6626         */
6627        @Deprecated
6628        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
6629
6630        /**
6631         * @deprecated Use
6632         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
6633         */
6634        @Deprecated
6635        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
6636
6637        /**
6638         * @deprecated Use
6639         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
6640         */
6641        @Deprecated
6642        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
6643                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
6644
6645        /**
6646         * The number of milliseconds to hold on to a PendingIntent based request. This delay gives
6647         * the receivers of the PendingIntent an opportunity to make a new network request before
6648         * the Network satisfying the request is potentially removed.
6649         *
6650         * @hide
6651         */
6652        public static final String CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS =
6653                "connectivity_release_pending_intent_delay_ms";
6654
6655        /**
6656         * Whether background data usage is allowed.
6657         *
6658         * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH},
6659         *             availability of background data depends on several
6660         *             combined factors. When background data is unavailable,
6661         *             {@link ConnectivityManager#getActiveNetworkInfo()} will
6662         *             now appear disconnected.
6663         */
6664        @Deprecated
6665        public static final String BACKGROUND_DATA = "background_data";
6666
6667        /**
6668         * Origins for which browsers should allow geolocation by default.
6669         * The value is a space-separated list of origins.
6670         */
6671        public static final String ALLOWED_GEOLOCATION_ORIGINS
6672                = "allowed_geolocation_origins";
6673
6674        /**
6675         * The preferred TTY mode     0 = TTy Off, CDMA default
6676         *                            1 = TTY Full
6677         *                            2 = TTY HCO
6678         *                            3 = TTY VCO
6679         * @hide
6680         */
6681        public static final String PREFERRED_TTY_MODE =
6682                "preferred_tty_mode";
6683
6684        private static final Validator PREFERRED_TTY_MODE_VALIDATOR =
6685                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1", "2", "3"});
6686
6687        /**
6688         * Whether the enhanced voice privacy mode is enabled.
6689         * 0 = normal voice privacy
6690         * 1 = enhanced voice privacy
6691         * @hide
6692         */
6693        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
6694
6695        private static final Validator ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6696
6697        /**
6698         * Whether the TTY mode mode is enabled.
6699         * 0 = disabled
6700         * 1 = enabled
6701         * @hide
6702         */
6703        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
6704
6705        private static final Validator TTY_MODE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6706
6707        /**
6708         * User-selected RTT mode. When on, outgoing and incoming calls will be answered as RTT
6709         * calls when supported by the device and carrier. Boolean value.
6710         * 0 = OFF
6711         * 1 = ON
6712         */
6713        public static final String RTT_CALLING_MODE = "rtt_calling_mode";
6714
6715        private static final Validator RTT_CALLING_MODE_VALIDATOR = BOOLEAN_VALIDATOR;
6716
6717        /**
6718        /**
6719         * Controls whether settings backup is enabled.
6720         * Type: int ( 0 = disabled, 1 = enabled )
6721         * @hide
6722         */
6723        public static final String BACKUP_ENABLED = "backup_enabled";
6724
6725        /**
6726         * Controls whether application data is automatically restored from backup
6727         * at install time.
6728         * Type: int ( 0 = disabled, 1 = enabled )
6729         * @hide
6730         */
6731        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
6732
6733        /**
6734         * Indicates whether settings backup has been fully provisioned.
6735         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
6736         * @hide
6737         */
6738        public static final String BACKUP_PROVISIONED = "backup_provisioned";
6739
6740        /**
6741         * Component of the transport to use for backup/restore.
6742         * @hide
6743         */
6744        public static final String BACKUP_TRANSPORT = "backup_transport";
6745
6746        /**
6747         * Version for which the setup wizard was last shown.  Bumped for
6748         * each release when there is new setup information to show.
6749         * @hide
6750         */
6751        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
6752
6753        /**
6754         * The interval in milliseconds after which Wi-Fi is considered idle.
6755         * When idle, it is possible for the device to be switched from Wi-Fi to
6756         * the mobile data network.
6757         * @hide
6758         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
6759         * instead.
6760         */
6761        @Deprecated
6762        public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
6763
6764        /**
6765         * The global search provider chosen by the user (if multiple global
6766         * search providers are installed). This will be the provider returned
6767         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
6768         * installed. This setting is stored as a flattened component name as
6769         * per {@link ComponentName#flattenToString()}.
6770         *
6771         * @hide
6772         */
6773        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
6774                "search_global_search_activity";
6775
6776        /**
6777         * The number of promoted sources in GlobalSearch.
6778         * @hide
6779         */
6780        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
6781        /**
6782         * The maximum number of suggestions returned by GlobalSearch.
6783         * @hide
6784         */
6785        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
6786        /**
6787         * The number of suggestions GlobalSearch will ask each non-web search source for.
6788         * @hide
6789         */
6790        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
6791        /**
6792         * The number of suggestions the GlobalSearch will ask the web search source for.
6793         * @hide
6794         */
6795        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
6796                "search_web_results_override_limit";
6797        /**
6798         * The number of milliseconds that GlobalSearch will wait for suggestions from
6799         * promoted sources before continuing with all other sources.
6800         * @hide
6801         */
6802        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
6803                "search_promoted_source_deadline_millis";
6804        /**
6805         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
6806         * @hide
6807         */
6808        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
6809        /**
6810         * The maximum number of milliseconds that GlobalSearch shows the previous results
6811         * after receiving a new query.
6812         * @hide
6813         */
6814        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
6815        /**
6816         * The maximum age of log data used for shortcuts in GlobalSearch.
6817         * @hide
6818         */
6819        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
6820        /**
6821         * The maximum age of log data used for source ranking in GlobalSearch.
6822         * @hide
6823         */
6824        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
6825                "search_max_source_event_age_millis";
6826        /**
6827         * The minimum number of impressions needed to rank a source in GlobalSearch.
6828         * @hide
6829         */
6830        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
6831                "search_min_impressions_for_source_ranking";
6832        /**
6833         * The minimum number of clicks needed to rank a source in GlobalSearch.
6834         * @hide
6835         */
6836        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
6837                "search_min_clicks_for_source_ranking";
6838        /**
6839         * The maximum number of shortcuts shown by GlobalSearch.
6840         * @hide
6841         */
6842        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
6843        /**
6844         * The size of the core thread pool for suggestion queries in GlobalSearch.
6845         * @hide
6846         */
6847        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
6848                "search_query_thread_core_pool_size";
6849        /**
6850         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
6851         * @hide
6852         */
6853        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
6854                "search_query_thread_max_pool_size";
6855        /**
6856         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
6857         * @hide
6858         */
6859        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
6860                "search_shortcut_refresh_core_pool_size";
6861        /**
6862         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
6863         * @hide
6864         */
6865        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
6866                "search_shortcut_refresh_max_pool_size";
6867        /**
6868         * The maximun time that excess threads in the GlobalSeach thread pools will
6869         * wait before terminating.
6870         * @hide
6871         */
6872        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
6873                "search_thread_keepalive_seconds";
6874        /**
6875         * The maximum number of concurrent suggestion queries to each source.
6876         * @hide
6877         */
6878        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
6879                "search_per_source_concurrent_query_limit";
6880
6881        /**
6882         * Whether or not alert sounds are played on StorageManagerService events.
6883         * (0 = false, 1 = true)
6884         * @hide
6885         */
6886        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
6887
6888        private static final Validator MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR = BOOLEAN_VALIDATOR;
6889
6890        /**
6891         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
6892         * @hide
6893         */
6894        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
6895
6896        private static final Validator MOUNT_UMS_AUTOSTART_VALIDATOR = BOOLEAN_VALIDATOR;
6897
6898        /**
6899         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
6900         * @hide
6901         */
6902        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
6903
6904        private static final Validator MOUNT_UMS_PROMPT_VALIDATOR = BOOLEAN_VALIDATOR;
6905
6906        /**
6907         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
6908         * @hide
6909         */
6910        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
6911
6912        private static final Validator MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6913
6914        /**
6915         * If nonzero, ANRs in invisible background processes bring up a dialog.
6916         * Otherwise, the process will be silently killed.
6917         *
6918         * Also prevents ANRs and crash dialogs from being suppressed.
6919         * @hide
6920         */
6921        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
6922
6923        /**
6924         * If nonzero, crashes in foreground processes will bring up a dialog.
6925         * Otherwise, the process will be silently killed.
6926         * @hide
6927         */
6928        public static final String SHOW_FIRST_CRASH_DIALOG_DEV_OPTION =
6929                "show_first_crash_dialog_dev_option";
6930
6931        private static final Validator SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR =
6932                BOOLEAN_VALIDATOR;
6933
6934        /**
6935         * The {@link ComponentName} string of the service to be used as the voice recognition
6936         * service.
6937         *
6938         * @hide
6939         */
6940        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
6941
6942        /**
6943         * Stores whether an user has consented to have apps verified through PAM.
6944         * The value is boolean (1 or 0).
6945         *
6946         * @hide
6947         */
6948        public static final String PACKAGE_VERIFIER_USER_CONSENT =
6949            "package_verifier_user_consent";
6950
6951        /**
6952         * The {@link ComponentName} string of the selected spell checker service which is
6953         * one of the services managed by the text service manager.
6954         *
6955         * @hide
6956         */
6957        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
6958
6959        private static final Validator SELECTED_SPELL_CHECKER_VALIDATOR = COMPONENT_NAME_VALIDATOR;
6960
6961        /**
6962         * The {@link ComponentName} string of the selected subtype of the selected spell checker
6963         * service which is one of the services managed by the text service manager.
6964         *
6965         * @hide
6966         */
6967        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
6968                "selected_spell_checker_subtype";
6969
6970        private static final Validator SELECTED_SPELL_CHECKER_SUBTYPE_VALIDATOR =
6971                COMPONENT_NAME_VALIDATOR;
6972
6973        /**
6974         * Whether spell checker is enabled or not.
6975         *
6976         * @hide
6977         */
6978        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
6979
6980        private static final Validator SPELL_CHECKER_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
6981
6982        /**
6983         * What happens when the user presses the Power button while in-call
6984         * and the screen is on.<br/>
6985         * <b>Values:</b><br/>
6986         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
6987         * 2 - The Power button hangs up the current call.<br/>
6988         *
6989         * @hide
6990         */
6991        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
6992
6993        private static final Validator INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR =
6994                new SettingsValidators.DiscreteValueValidator(new String[]{"1", "2"});
6995
6996        /**
6997         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
6998         * @hide
6999         */
7000        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
7001
7002        /**
7003         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
7004         * @hide
7005         */
7006        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
7007
7008        /**
7009         * INCALL_POWER_BUTTON_BEHAVIOR default value.
7010         * @hide
7011         */
7012        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
7013                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
7014
7015        /**
7016         * What happens when the user presses the Back button while in-call
7017         * and the screen is on.<br/>
7018         * <b>Values:</b><br/>
7019         * 0 - The Back buttons does nothing different.<br/>
7020         * 1 - The Back button hangs up the current call.<br/>
7021         *
7022         * @hide
7023         */
7024        public static final String INCALL_BACK_BUTTON_BEHAVIOR = "incall_back_button_behavior";
7025
7026        /**
7027         * INCALL_BACK_BUTTON_BEHAVIOR value for no action.
7028         * @hide
7029         */
7030        public static final int INCALL_BACK_BUTTON_BEHAVIOR_NONE = 0x0;
7031
7032        /**
7033         * INCALL_BACK_BUTTON_BEHAVIOR value for "hang up".
7034         * @hide
7035         */
7036        public static final int INCALL_BACK_BUTTON_BEHAVIOR_HANGUP = 0x1;
7037
7038        /**
7039         * INCALL_POWER_BUTTON_BEHAVIOR default value.
7040         * @hide
7041         */
7042        public static final int INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT =
7043                INCALL_BACK_BUTTON_BEHAVIOR_NONE;
7044
7045        /**
7046         * Whether the device should wake when the wake gesture sensor detects motion.
7047         * @hide
7048         */
7049        public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";
7050
7051        private static final Validator WAKE_GESTURE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7052
7053        /**
7054         * Whether the device should doze if configured.
7055         * @hide
7056         */
7057        public static final String DOZE_ENABLED = "doze_enabled";
7058
7059        private static final Validator DOZE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7060
7061        /**
7062         * Whether doze should be always on.
7063         * @hide
7064         */
7065        public static final String DOZE_ALWAYS_ON = "doze_always_on";
7066
7067        /**
7068         * Whether the device should pulse on pick up gesture.
7069         * @hide
7070         */
7071        public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
7072
7073        private static final Validator DOZE_PULSE_ON_PICK_UP_VALIDATOR = BOOLEAN_VALIDATOR;
7074
7075        /**
7076         * Whether the device should pulse on long press gesture.
7077         * @hide
7078         */
7079        public static final String DOZE_PULSE_ON_LONG_PRESS = "doze_pulse_on_long_press";
7080
7081        /**
7082         * Whether the device should pulse on double tap gesture.
7083         * @hide
7084         */
7085        public static final String DOZE_PULSE_ON_DOUBLE_TAP = "doze_pulse_on_double_tap";
7086
7087        private static final Validator DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR = BOOLEAN_VALIDATOR;
7088
7089        /**
7090         * The current night mode that has been selected by the user.  Owned
7091         * and controlled by UiModeManagerService.  Constants are as per
7092         * UiModeManager.
7093         * @hide
7094         */
7095        public static final String UI_NIGHT_MODE = "ui_night_mode";
7096
7097        /**
7098         * Whether screensavers are enabled.
7099         * @hide
7100         */
7101        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
7102
7103        private static final Validator SCREENSAVER_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7104
7105        /**
7106         * The user's chosen screensaver components.
7107         *
7108         * These will be launched by the PhoneWindowManager after a timeout when not on
7109         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
7110         * @hide
7111         */
7112        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
7113
7114        private static final Validator SCREENSAVER_COMPONENTS_VALIDATOR =
7115                new SettingsValidators.ComponentNameListValidator(",");
7116
7117        /**
7118         * If screensavers are enabled, whether the screensaver should be automatically launched
7119         * when the device is inserted into a (desk) dock.
7120         * @hide
7121         */
7122        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
7123
7124        private static final Validator SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR = BOOLEAN_VALIDATOR;
7125
7126        /**
7127         * If screensavers are enabled, whether the screensaver should be automatically launched
7128         * when the screen times out when not on battery.
7129         * @hide
7130         */
7131        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
7132
7133        private static final Validator SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR = BOOLEAN_VALIDATOR;
7134
7135        /**
7136         * If screensavers are enabled, the default screensaver component.
7137         * @hide
7138         */
7139        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
7140
7141        /**
7142         * The default NFC payment component
7143         * @hide
7144         */
7145        public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
7146
7147        private static final Validator NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR =
7148                COMPONENT_NAME_VALIDATOR;
7149
7150        /**
7151         * Whether NFC payment is handled by the foreground application or a default.
7152         * @hide
7153         */
7154        public static final String NFC_PAYMENT_FOREGROUND = "nfc_payment_foreground";
7155
7156        /**
7157         * Specifies the package name currently configured to be the primary sms application
7158         * @hide
7159         */
7160        public static final String SMS_DEFAULT_APPLICATION = "sms_default_application";
7161
7162        /**
7163         * Specifies the package name currently configured to be the default dialer application
7164         * @hide
7165         */
7166        public static final String DIALER_DEFAULT_APPLICATION = "dialer_default_application";
7167
7168        /**
7169         * Specifies the package name currently configured to be the emergency assistance application
7170         *
7171         * @see android.telephony.TelephonyManager#ACTION_EMERGENCY_ASSISTANCE
7172         *
7173         * @hide
7174         */
7175        public static final String EMERGENCY_ASSISTANCE_APPLICATION = "emergency_assistance_application";
7176
7177        /**
7178         * Specifies whether the current app context on scren (assist data) will be sent to the
7179         * assist application (active voice interaction service).
7180         *
7181         * @hide
7182         */
7183        public static final String ASSIST_STRUCTURE_ENABLED = "assist_structure_enabled";
7184
7185        /**
7186         * Specifies whether a screenshot of the screen contents will be sent to the assist
7187         * application (active voice interaction service).
7188         *
7189         * @hide
7190         */
7191        public static final String ASSIST_SCREENSHOT_ENABLED = "assist_screenshot_enabled";
7192
7193        /**
7194         * Specifies whether the screen will show an animation if screen contents are sent to the
7195         * assist application (active voice interaction service).
7196         *
7197         * Note that the disclosure will be forced for third-party assistants or if the device
7198         * does not support disabling it.
7199         *
7200         * @hide
7201         */
7202        public static final String ASSIST_DISCLOSURE_ENABLED = "assist_disclosure_enabled";
7203
7204        /**
7205         * Control if rotation suggestions are sent to System UI when in rotation locked mode.
7206         * Done to enable screen rotation while the the screen rotation is locked. Enabling will
7207         * poll the accelerometer in rotation locked mode.
7208         *
7209         * If 0, then rotation suggestions are not sent to System UI. If 1, suggestions are sent.
7210         *
7211         * @hide
7212         */
7213
7214        public static final String SHOW_ROTATION_SUGGESTIONS = "show_rotation_suggestions";
7215
7216        /**
7217         * The disabled state of SHOW_ROTATION_SUGGESTIONS.
7218         * @hide
7219         */
7220        public static final int SHOW_ROTATION_SUGGESTIONS_DISABLED = 0x0;
7221
7222        /**
7223         * The enabled state of SHOW_ROTATION_SUGGESTIONS.
7224         * @hide
7225         */
7226        public static final int SHOW_ROTATION_SUGGESTIONS_ENABLED = 0x1;
7227
7228        /**
7229         * The default state of SHOW_ROTATION_SUGGESTIONS.
7230         * @hide
7231         */
7232        public static final int SHOW_ROTATION_SUGGESTIONS_DEFAULT =
7233                SHOW_ROTATION_SUGGESTIONS_ENABLED;
7234
7235        /**
7236         * The number of accepted rotation suggestions. Used to determine if the user has been
7237         * introduced to rotation suggestions.
7238         * @hide
7239         */
7240        public static final String NUM_ROTATION_SUGGESTIONS_ACCEPTED =
7241                "num_rotation_suggestions_accepted";
7242
7243        /**
7244         * Read only list of the service components that the current user has explicitly allowed to
7245         * see and assist with all of the user's notifications.
7246         *
7247         * @deprecated Use
7248         * {@link NotificationManager#isNotificationListenerAccessGranted(ComponentName)}.
7249         * @hide
7250         */
7251        @Deprecated
7252        public static final String ENABLED_NOTIFICATION_ASSISTANT =
7253                "enabled_notification_assistant";
7254
7255        private static final Validator ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR =
7256                new SettingsValidators.ComponentNameListValidator(":");
7257
7258        /**
7259         * Read only list of the service components that the current user has explicitly allowed to
7260         * see all of the user's notifications, separated by ':'.
7261         *
7262         * @hide
7263         * @deprecated Use
7264         * {@link NotificationManager#isNotificationAssistantAccessGranted(ComponentName)}.
7265         */
7266        @Deprecated
7267        public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
7268
7269        private static final Validator ENABLED_NOTIFICATION_LISTENERS_VALIDATOR =
7270                new SettingsValidators.ComponentNameListValidator(":");
7271
7272        /**
7273         * Read only list of the packages that the current user has explicitly allowed to
7274         * manage do not disturb, separated by ':'.
7275         *
7276         * @deprecated Use {@link NotificationManager#isNotificationPolicyAccessGranted()}.
7277         * @hide
7278         */
7279        @Deprecated
7280        @TestApi
7281        public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES =
7282                "enabled_notification_policy_access_packages";
7283
7284        private static final Validator ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR =
7285                new SettingsValidators.PackageNameListValidator(":");
7286
7287        /**
7288         * Defines whether managed profile ringtones should be synced from it's parent profile
7289         * <p>
7290         * 0 = ringtones are not synced
7291         * 1 = ringtones are synced from the profile's parent (default)
7292         * <p>
7293         * This value is only used for managed profiles.
7294         * @hide
7295         */
7296        @TestApi
7297        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
7298        public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
7299
7300        private static final Validator SYNC_PARENT_SOUNDS_VALIDATOR = BOOLEAN_VALIDATOR;
7301
7302        /** @hide */
7303        public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
7304
7305        /**
7306         * This is the query URI for finding a print service to install.
7307         *
7308         * @hide
7309         */
7310        public static final String PRINT_SERVICE_SEARCH_URI = "print_service_search_uri";
7311
7312        /**
7313         * This is the query URI for finding a NFC payment service to install.
7314         *
7315         * @hide
7316         */
7317        public static final String PAYMENT_SERVICE_SEARCH_URI = "payment_service_search_uri";
7318
7319        /**
7320         * This is the query URI for finding a auto fill service to install.
7321         *
7322         * @hide
7323         */
7324        public static final String AUTOFILL_SERVICE_SEARCH_URI = "autofill_service_search_uri";
7325
7326        /**
7327         * If enabled, apps should try to skip any introductory hints on first launch. This might
7328         * apply to users that are already familiar with the environment or temporary users.
7329         * <p>
7330         * Type : int (0 to show hints, 1 to skip showing hints)
7331         */
7332        public static final String SKIP_FIRST_USE_HINTS = "skip_first_use_hints";
7333
7334        /**
7335         * Persisted playback time after a user confirmation of an unsafe volume level.
7336         *
7337         * @hide
7338         */
7339        public static final String UNSAFE_VOLUME_MUSIC_ACTIVE_MS = "unsafe_volume_music_active_ms";
7340
7341        /**
7342         * This preference enables notification display on the lockscreen.
7343         * @hide
7344         */
7345        public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
7346                "lock_screen_show_notifications";
7347
7348        /**
7349         * List of TV inputs that are currently hidden. This is a string
7350         * containing the IDs of all hidden TV inputs. Each ID is encoded by
7351         * {@link android.net.Uri#encode(String)} and separated by ':'.
7352         * @hide
7353         */
7354        public static final String TV_INPUT_HIDDEN_INPUTS = "tv_input_hidden_inputs";
7355
7356        /**
7357         * List of custom TV input labels. This is a string containing <TV input id, custom name>
7358         * pairs. TV input id and custom name are encoded by {@link android.net.Uri#encode(String)}
7359         * and separated by ','. Each pair is separated by ':'.
7360         * @hide
7361         */
7362        public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels";
7363
7364        /**
7365         * Whether automatic routing of system audio to USB audio peripheral is disabled.
7366         * The value is boolean (1 or 0), where 1 means automatic routing is disabled,
7367         * and 0 means automatic routing is enabled.
7368         *
7369         * @hide
7370         */
7371        public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
7372                "usb_audio_automatic_routing_disabled";
7373
7374        /**
7375         * The timeout in milliseconds before the device fully goes to sleep after
7376         * a period of inactivity.  This value sets an upper bound on how long the device
7377         * will stay awake or dreaming without user activity.  It should generally
7378         * be longer than {@link Settings.System#SCREEN_OFF_TIMEOUT} as otherwise the device
7379         * will sleep before it ever has a chance to dream.
7380         * <p>
7381         * Use -1 to disable this timeout.
7382         * </p>
7383         *
7384         * @hide
7385         */
7386        public static final String SLEEP_TIMEOUT = "sleep_timeout";
7387
7388        private static final Validator SLEEP_TIMEOUT_VALIDATOR =
7389                new SettingsValidators.InclusiveIntegerRangeValidator(-1, Integer.MAX_VALUE);
7390
7391        /**
7392         * Controls whether double tap to wake is enabled.
7393         * @hide
7394         */
7395        public static final String DOUBLE_TAP_TO_WAKE = "double_tap_to_wake";
7396
7397        private static final Validator DOUBLE_TAP_TO_WAKE_VALIDATOR = BOOLEAN_VALIDATOR;
7398
7399        /**
7400         * The current assistant component. It could be a voice interaction service,
7401         * or an activity that handles ACTION_ASSIST, or empty which means using the default
7402         * handling.
7403         *
7404         * @hide
7405         */
7406        public static final String ASSISTANT = "assistant";
7407
7408        /**
7409         * Whether the camera launch gesture should be disabled.
7410         *
7411         * @hide
7412         */
7413        public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled";
7414
7415        private static final Validator CAMERA_GESTURE_DISABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7416
7417        /**
7418         * Whether the camera launch gesture to double tap the power button when the screen is off
7419         * should be disabled.
7420         *
7421         * @hide
7422         */
7423        public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
7424                "camera_double_tap_power_gesture_disabled";
7425
7426        private static final Validator CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR =
7427                BOOLEAN_VALIDATOR;
7428
7429        /**
7430         * Whether the camera double twist gesture to flip between front and back mode should be
7431         * enabled.
7432         *
7433         * @hide
7434         */
7435        public static final String CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED =
7436                "camera_double_twist_to_flip_enabled";
7437
7438        private static final Validator CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR =
7439                BOOLEAN_VALIDATOR;
7440
7441        /**
7442         * Whether the swipe up gesture to switch apps should be enabled.
7443         *
7444         * @hide
7445         */
7446        public static final String SWIPE_UP_TO_SWITCH_APPS_ENABLED =
7447                "swipe_up_to_switch_apps_enabled";
7448
7449        private static final Validator SWIPE_UP_TO_SWITCH_APPS_ENABLED_VALIDATOR =
7450                BOOLEAN_VALIDATOR;
7451
7452        /**
7453         * Whether or not the smart camera lift trigger that launches the camera when the user moves
7454         * the phone into a position for taking photos should be enabled.
7455         *
7456         * @hide
7457         */
7458        public static final String CAMERA_LIFT_TRIGGER_ENABLED = "camera_lift_trigger_enabled";
7459
7460        /**
7461         * The default enable state of the camera lift trigger.
7462         *
7463         * @hide
7464         */
7465        public static final int CAMERA_LIFT_TRIGGER_ENABLED_DEFAULT = 1;
7466
7467        /**
7468         * Whether the assist gesture should be enabled.
7469         *
7470         * @hide
7471         */
7472        public static final String ASSIST_GESTURE_ENABLED = "assist_gesture_enabled";
7473
7474        private static final Validator ASSIST_GESTURE_ENABLED_VALIDATOR =
7475                BOOLEAN_VALIDATOR;
7476
7477        /**
7478         * Sensitivity control for the assist gesture.
7479         *
7480         * @hide
7481         */
7482        public static final String ASSIST_GESTURE_SENSITIVITY = "assist_gesture_sensitivity";
7483
7484        private static final Validator ASSIST_GESTURE_SENSITIVITY_VALIDATOR =
7485                new SettingsValidators.InclusiveFloatRangeValidator(0.0f, 1.0f);
7486
7487        /**
7488         * Whether the assist gesture should silence alerts.
7489         *
7490         * @hide
7491         */
7492        public static final String ASSIST_GESTURE_SILENCE_ALERTS_ENABLED =
7493                "assist_gesture_silence_alerts_enabled";
7494
7495        private static final Validator ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR =
7496                BOOLEAN_VALIDATOR;
7497
7498        /**
7499         * Whether the assist gesture should wake the phone.
7500         *
7501         * @hide
7502         */
7503        public static final String ASSIST_GESTURE_WAKE_ENABLED =
7504                "assist_gesture_wake_enabled";
7505
7506        private static final Validator ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR =
7507                BOOLEAN_VALIDATOR;
7508
7509        /**
7510         * Whether Assist Gesture Deferred Setup has been completed
7511         *
7512         * @hide
7513         */
7514        public static final String ASSIST_GESTURE_SETUP_COMPLETE = "assist_gesture_setup_complete";
7515
7516        private static final Validator ASSIST_GESTURE_SETUP_COMPLETE_VALIDATOR = BOOLEAN_VALIDATOR;
7517
7518        /**
7519         * Control whether Night display is currently activated.
7520         * @hide
7521         */
7522        public static final String NIGHT_DISPLAY_ACTIVATED = "night_display_activated";
7523
7524        /**
7525         * Control whether Night display will automatically activate/deactivate.
7526         * @hide
7527         */
7528        public static final String NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode";
7529
7530        private static final Validator NIGHT_DISPLAY_AUTO_MODE_VALIDATOR =
7531                new SettingsValidators.InclusiveIntegerRangeValidator(0, 2);
7532
7533        /**
7534         * Control the color temperature of Night Display, represented in Kelvin.
7535         * @hide
7536         */
7537        public static final String NIGHT_DISPLAY_COLOR_TEMPERATURE =
7538                "night_display_color_temperature";
7539
7540        private static final Validator NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR =
7541                NON_NEGATIVE_INTEGER_VALIDATOR;
7542
7543        /**
7544         * Custom time when Night display is scheduled to activate.
7545         * Represented as milliseconds from midnight (e.g. 79200000 == 10pm).
7546         * @hide
7547         */
7548        public static final String NIGHT_DISPLAY_CUSTOM_START_TIME =
7549                "night_display_custom_start_time";
7550
7551        private static final Validator NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR =
7552                NON_NEGATIVE_INTEGER_VALIDATOR;
7553
7554        /**
7555         * Custom time when Night display is scheduled to deactivate.
7556         * Represented as milliseconds from midnight (e.g. 21600000 == 6am).
7557         * @hide
7558         */
7559        public static final String NIGHT_DISPLAY_CUSTOM_END_TIME = "night_display_custom_end_time";
7560
7561        private static final Validator NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR =
7562                NON_NEGATIVE_INTEGER_VALIDATOR;
7563
7564        /**
7565         * A String representing the LocalDateTime when Night display was last activated. Use to
7566         * decide whether to apply the current activated state after a reboot or user change. In
7567         * legacy cases, this is represented by the time in milliseconds (since epoch).
7568         * @hide
7569         */
7570        public static final String NIGHT_DISPLAY_LAST_ACTIVATED_TIME =
7571                "night_display_last_activated_time";
7572
7573        /**
7574         * Names of the service components that the current user has explicitly allowed to
7575         * be a VR mode listener, separated by ':'.
7576         *
7577         * @hide
7578         */
7579        public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
7580
7581        private static final Validator ENABLED_VR_LISTENERS_VALIDATOR =
7582                new SettingsValidators.ComponentNameListValidator(":");
7583
7584        /**
7585         * Behavior of the display while in VR mode.
7586         *
7587         * One of {@link #VR_DISPLAY_MODE_LOW_PERSISTENCE} or {@link #VR_DISPLAY_MODE_OFF}.
7588         *
7589         * @hide
7590         */
7591        public static final String VR_DISPLAY_MODE = "vr_display_mode";
7592
7593        private static final Validator VR_DISPLAY_MODE_VALIDATOR =
7594                new SettingsValidators.DiscreteValueValidator(new String[]{"0", "1"});
7595
7596        /**
7597         * Lower the display persistence while the system is in VR mode.
7598         *
7599         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
7600         *
7601         * @hide.
7602         */
7603        public static final int VR_DISPLAY_MODE_LOW_PERSISTENCE = 0;
7604
7605        /**
7606         * Do not alter the display persistence while the system is in VR mode.
7607         *
7608         * @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
7609         *
7610         * @hide.
7611         */
7612        public static final int VR_DISPLAY_MODE_OFF = 1;
7613
7614        /**
7615         * Whether CarrierAppUtils#disableCarrierAppsUntilPrivileged has been executed at least
7616         * once.
7617         *
7618         * <p>This is used to ensure that we only take one pass which will disable apps that are not
7619         * privileged (if any). From then on, we only want to enable apps (when a matching SIM is
7620         * inserted), to avoid disabling an app that the user might actively be using.
7621         *
7622         * <p>Will be set to 1 once executed.
7623         *
7624         * @hide
7625         */
7626        public static final String CARRIER_APPS_HANDLED = "carrier_apps_handled";
7627
7628        /**
7629         * Whether parent user can access remote contact in managed profile.
7630         *
7631         * @hide
7632         */
7633        public static final String MANAGED_PROFILE_CONTACT_REMOTE_SEARCH =
7634                "managed_profile_contact_remote_search";
7635
7636        /**
7637         * Whether or not the automatic storage manager is enabled and should run on the device.
7638         *
7639         * @hide
7640         */
7641        public static final String AUTOMATIC_STORAGE_MANAGER_ENABLED =
7642                "automatic_storage_manager_enabled";
7643
7644        /**
7645         * How many days of information for the automatic storage manager to retain on the device.
7646         *
7647         * @hide
7648         */
7649        public static final String AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN =
7650                "automatic_storage_manager_days_to_retain";
7651
7652        private static final Validator AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR =
7653                NON_NEGATIVE_INTEGER_VALIDATOR;
7654
7655        /**
7656         * Default number of days of information for the automatic storage manager to retain.
7657         *
7658         * @hide
7659         */
7660        public static final int AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT = 90;
7661
7662        /**
7663         * How many bytes the automatic storage manager has cleared out.
7664         *
7665         * @hide
7666         */
7667        public static final String AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED =
7668                "automatic_storage_manager_bytes_cleared";
7669
7670
7671        /**
7672         * Last run time for the automatic storage manager.
7673         *
7674         * @hide
7675         */
7676        public static final String AUTOMATIC_STORAGE_MANAGER_LAST_RUN =
7677                "automatic_storage_manager_last_run";
7678
7679        /**
7680         * If the automatic storage manager has been disabled by policy. Note that this doesn't
7681         * mean that the automatic storage manager is prevented from being re-enabled -- this only
7682         * means that it was turned off by policy at least once.
7683         *
7684         * @hide
7685         */
7686        public static final String AUTOMATIC_STORAGE_MANAGER_TURNED_OFF_BY_POLICY =
7687                "automatic_storage_manager_turned_off_by_policy";
7688
7689        /**
7690         * Whether SystemUI navigation keys is enabled.
7691         * @hide
7692         */
7693        public static final String SYSTEM_NAVIGATION_KEYS_ENABLED =
7694                "system_navigation_keys_enabled";
7695
7696        private static final Validator SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
7697
7698        /**
7699         * Holds comma separated list of ordering of QS tiles.
7700         * @hide
7701         */
7702        public static final String QS_TILES = "sysui_qs_tiles";
7703
7704        private static final Validator QS_TILES_VALIDATOR = new Validator() {
7705            @Override
7706            public boolean validate(String value) {
7707                if (value == null) {
7708                    return false;
7709                }
7710                String[] tiles = value.split(",");
7711                boolean valid = true;
7712                for (String tile : tiles) {
7713                    // tile can be any non-empty string as specified by OEM
7714                    valid |= ((tile.length() > 0) && ANY_STRING_VALIDATOR.validate(tile));
7715                }
7716                return valid;
7717            }
7718        };
7719
7720        /**
7721         * Specifies whether the web action API is enabled.
7722         *
7723         * @hide
7724         */
7725        @SystemApi
7726        public static final String INSTANT_APPS_ENABLED = "instant_apps_enabled";
7727
7728        /**
7729         * Has this pairable device been paired or upgraded from a previously paired system.
7730         * @hide
7731         */
7732        public static final String DEVICE_PAIRED = "device_paired";
7733
7734        /**
7735         * Integer state indicating whether package verifier is enabled.
7736         * TODO(b/34259924): Remove this setting.
7737         *
7738         * @hide
7739         */
7740        public static final String PACKAGE_VERIFIER_STATE = "package_verifier_state";
7741
7742        /**
7743         * Specifies additional package name for broadcasting the CMAS messages.
7744         * @hide
7745         */
7746        public static final String CMAS_ADDITIONAL_BROADCAST_PKG = "cmas_additional_broadcast_pkg";
7747
7748        /**
7749         * Whether the launcher should show any notification badges.
7750         * The value is boolean (1 or 0).
7751         * @hide
7752         */
7753        public static final String NOTIFICATION_BADGING = "notification_badging";
7754
7755        private static final Validator NOTIFICATION_BADGING_VALIDATOR = BOOLEAN_VALIDATOR;
7756
7757        /**
7758         * Comma separated list of QS tiles that have been auto-added already.
7759         * @hide
7760         */
7761        public static final String QS_AUTO_ADDED_TILES = "qs_auto_tiles";
7762
7763        private static final Validator QS_AUTO_ADDED_TILES_VALIDATOR = new Validator() {
7764            @Override
7765            public boolean validate(String value) {
7766                if (value == null) {
7767                    return false;
7768                }
7769                String[] tiles = value.split(",");
7770                boolean valid = true;
7771                for (String tile : tiles) {
7772                    // tile can be any non-empty string as specified by OEM
7773                    valid |= ((tile.length() > 0) && ANY_STRING_VALIDATOR.validate(tile));
7774                }
7775                return valid;
7776            }
7777        };
7778
7779        /**
7780         * Whether the Lockdown button should be shown in the power menu.
7781         * @hide
7782         */
7783        public static final String LOCKDOWN_IN_POWER_MENU = "lockdown_in_power_menu";
7784
7785        private static final Validator LOCKDOWN_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
7786
7787        /**
7788         * Backup manager behavioral parameters.
7789         * This is encoded as a key=value list, separated by commas. Ex:
7790         *
7791         * "key_value_backup_interval_milliseconds=14400000,key_value_backup_require_charging=true"
7792         *
7793         * The following keys are supported:
7794         *
7795         * <pre>
7796         * key_value_backup_interval_milliseconds  (long)
7797         * key_value_backup_fuzz_milliseconds      (long)
7798         * key_value_backup_require_charging       (boolean)
7799         * key_value_backup_required_network_type  (int)
7800         * full_backup_interval_milliseconds       (long)
7801         * full_backup_require_charging            (boolean)
7802         * full_backup_required_network_type       (int)
7803         * backup_finished_notification_receivers  (String[])
7804         * </pre>
7805         *
7806         * backup_finished_notification_receivers uses ":" as delimeter for values.
7807         *
7808         * <p>
7809         * Type: string
7810         * @hide
7811         */
7812        public static final String BACKUP_MANAGER_CONSTANTS = "backup_manager_constants";
7813
7814
7815        /**
7816         * Local transport parameters so we can configure it for tests.
7817         * This is encoded as a key=value list, separated by commas.
7818         *
7819         * The following keys are supported:
7820         *
7821         * <pre>
7822         * fake_encryption_flag  (boolean)
7823         * </pre>
7824         *
7825         * <p>
7826         * Type: string
7827         * @hide
7828         */
7829        public static final String BACKUP_LOCAL_TRANSPORT_PARAMETERS =
7830                "backup_local_transport_parameters";
7831
7832        /**
7833         * Flag to set if the system should predictively attempt to re-enable Bluetooth while
7834         * the user is driving.
7835         * @hide
7836         */
7837        public static final String BLUETOOTH_ON_WHILE_DRIVING = "bluetooth_on_while_driving";
7838
7839        /**
7840         * What behavior should be invoked when the volume hush gesture is triggered
7841         * One of VOLUME_HUSH_OFF, VOLUME_HUSH_VIBRATE, VOLUME_HUSH_MUTE.
7842         *
7843         * @hide
7844         */
7845        public static final String VOLUME_HUSH_GESTURE = "volume_hush_gesture";
7846
7847        /** @hide */ public static final int VOLUME_HUSH_OFF = 0;
7848        /** @hide */ public static final int VOLUME_HUSH_VIBRATE = 1;
7849        /** @hide */ public static final int VOLUME_HUSH_MUTE = 2;
7850
7851        private static final Validator VOLUME_HUSH_GESTURE_VALIDATOR =
7852                NON_NEGATIVE_INTEGER_VALIDATOR;
7853
7854        /**
7855         * The number of times (integer) the user has manually enabled battery saver.
7856         * @hide
7857         */
7858        public static final String LOW_POWER_MANUAL_ACTIVATION_COUNT =
7859                "low_power_manual_activation_count";
7860
7861        /**
7862         * Whether the "first time battery saver warning" dialog needs to be shown (0: default)
7863         * or not (1).
7864         *
7865         * @hide
7866         */
7867        public static final String LOW_POWER_WARNING_ACKNOWLEDGED =
7868                "low_power_warning_acknowledged";
7869
7870        /**
7871         * 0 (default) Auto battery saver suggestion has not been suppressed. 1) it has been
7872         * suppressed.
7873         * @hide
7874         */
7875        public static final String SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION =
7876                "suppress_auto_battery_saver_suggestion";
7877
7878        /**
7879         * List of packages, which data need to be unconditionally cleared before full restore.
7880         * Type: string
7881         * @hide
7882         */
7883        public static final String PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE =
7884                "packages_to_clear_data_before_full_restore";
7885
7886        /**
7887         * This are the settings to be backed up.
7888         *
7889         * NOTE: Settings are backed up and restored in the order they appear
7890         *       in this array. If you have one setting depending on another,
7891         *       make sure that they are ordered appropriately.
7892         *
7893         * @hide
7894         */
7895        public static final String[] SETTINGS_TO_BACKUP = {
7896            BUGREPORT_IN_POWER_MENU,                            // moved to global
7897            ALLOW_MOCK_LOCATION,
7898            USB_MASS_STORAGE_ENABLED,                           // moved to global
7899            ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
7900            ACCESSIBILITY_DISPLAY_DALTONIZER,
7901            ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
7902            ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
7903            ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
7904            AUTOFILL_SERVICE,
7905            ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
7906            ENABLED_ACCESSIBILITY_SERVICES,
7907            ENABLED_VR_LISTENERS,
7908            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
7909            TOUCH_EXPLORATION_ENABLED,
7910            ACCESSIBILITY_ENABLED,
7911            ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
7912            ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
7913            ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
7914            ACCESSIBILITY_SHORTCUT_ENABLED,
7915            ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
7916            ACCESSIBILITY_SPEAK_PASSWORD,
7917            ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
7918            ACCESSIBILITY_CAPTIONING_PRESET,
7919            ACCESSIBILITY_CAPTIONING_ENABLED,
7920            ACCESSIBILITY_CAPTIONING_LOCALE,
7921            ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
7922            ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
7923            ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
7924            ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
7925            ACCESSIBILITY_CAPTIONING_TYPEFACE,
7926            ACCESSIBILITY_CAPTIONING_FONT_SCALE,
7927            ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
7928            TTS_DEFAULT_RATE,
7929            TTS_DEFAULT_PITCH,
7930            TTS_DEFAULT_SYNTH,
7931            TTS_ENABLED_PLUGINS,
7932            TTS_DEFAULT_LOCALE,
7933            SHOW_IME_WITH_HARD_KEYBOARD,
7934            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
7935            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
7936            WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
7937            SELECTED_SPELL_CHECKER,
7938            SELECTED_SPELL_CHECKER_SUBTYPE,
7939            SPELL_CHECKER_ENABLED,
7940            MOUNT_PLAY_NOTIFICATION_SND,
7941            MOUNT_UMS_AUTOSTART,
7942            MOUNT_UMS_PROMPT,
7943            MOUNT_UMS_NOTIFY_ENABLED,
7944            SLEEP_TIMEOUT,
7945            DOUBLE_TAP_TO_WAKE,
7946            WAKE_GESTURE_ENABLED,
7947            LONG_PRESS_TIMEOUT,
7948            CAMERA_GESTURE_DISABLED,
7949            ACCESSIBILITY_AUTOCLICK_ENABLED,
7950            ACCESSIBILITY_AUTOCLICK_DELAY,
7951            ACCESSIBILITY_LARGE_POINTER_ICON,
7952            PREFERRED_TTY_MODE,
7953            ENHANCED_VOICE_PRIVACY_ENABLED,
7954            TTY_MODE_ENABLED,
7955            RTT_CALLING_MODE,
7956            INCALL_POWER_BUTTON_BEHAVIOR,
7957            NIGHT_DISPLAY_CUSTOM_START_TIME,
7958            NIGHT_DISPLAY_CUSTOM_END_TIME,
7959            NIGHT_DISPLAY_COLOR_TEMPERATURE,
7960            NIGHT_DISPLAY_AUTO_MODE,
7961            SYNC_PARENT_SOUNDS,
7962            CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
7963            SWIPE_UP_TO_SWITCH_APPS_ENABLED,
7964            CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
7965            SYSTEM_NAVIGATION_KEYS_ENABLED,
7966            QS_TILES,
7967            DOZE_ENABLED,
7968            DOZE_PULSE_ON_PICK_UP,
7969            DOZE_PULSE_ON_DOUBLE_TAP,
7970            NFC_PAYMENT_DEFAULT_COMPONENT,
7971            AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
7972            ASSIST_GESTURE_ENABLED,
7973            ASSIST_GESTURE_SENSITIVITY,
7974            ASSIST_GESTURE_SETUP_COMPLETE,
7975            ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
7976            ASSIST_GESTURE_WAKE_ENABLED,
7977            VR_DISPLAY_MODE,
7978            NOTIFICATION_BADGING,
7979            QS_AUTO_ADDED_TILES,
7980            SCREENSAVER_ENABLED,
7981            SCREENSAVER_COMPONENTS,
7982            SCREENSAVER_ACTIVATE_ON_DOCK,
7983            SCREENSAVER_ACTIVATE_ON_SLEEP,
7984            LOCKDOWN_IN_POWER_MENU,
7985            SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
7986            VOLUME_HUSH_GESTURE
7987        };
7988
7989        /**
7990         * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator,
7991         * otherwise they won't be restored.
7992         *
7993         * @hide
7994         */
7995        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
7996        static {
7997            VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR);
7998            VALIDATORS.put(ALLOW_MOCK_LOCATION, ALLOW_MOCK_LOCATION_VALIDATOR);
7999            VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR);
8000            VALIDATORS.put(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
8001                    ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR);
8002            VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER,
8003                    ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR);
8004            VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
8005                    ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR);
8006            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
8007                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR);
8008            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
8009                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR);
8010            VALIDATORS.put(AUTOFILL_SERVICE, AUTOFILL_SERVICE_VALIDATOR);
8011            VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
8012                    ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR);
8013            VALIDATORS.put(ENABLED_ACCESSIBILITY_SERVICES,
8014                    ENABLED_ACCESSIBILITY_SERVICES_VALIDATOR);
8015            VALIDATORS.put(ENABLED_VR_LISTENERS, ENABLED_VR_LISTENERS_VALIDATOR);
8016            VALIDATORS.put(TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
8017                    TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES_VALIDATOR);
8018            VALIDATORS.put(TOUCH_EXPLORATION_ENABLED, TOUCH_EXPLORATION_ENABLED_VALIDATOR);
8019            VALIDATORS.put(ACCESSIBILITY_ENABLED, ACCESSIBILITY_ENABLED_VALIDATOR);
8020            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
8021                    ACCESSIBILITY_SHORTCUT_TARGET_SERVICE_VALIDATOR);
8022            VALIDATORS.put(ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
8023                    ACCESSIBILITY_BUTTON_TARGET_COMPONENT_VALIDATOR);
8024            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
8025                    ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN_VALIDATOR);
8026            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ENABLED,
8027                    ACCESSIBILITY_SHORTCUT_ENABLED_VALIDATOR);
8028            VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
8029                    ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN_VALIDATOR);
8030            VALIDATORS.put(ACCESSIBILITY_SPEAK_PASSWORD, ACCESSIBILITY_SPEAK_PASSWORD_VALIDATOR);
8031            VALIDATORS.put(ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
8032                    ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR);
8033            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_PRESET,
8034                    ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR);
8035            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_ENABLED,
8036                    ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR);
8037            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_LOCALE,
8038                    ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR);
8039            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
8040                    ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR);
8041            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
8042                    ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR);
8043            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
8044                    ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR);
8045            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
8046                    ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR);
8047            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_TYPEFACE,
8048                    ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR);
8049            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FONT_SCALE,
8050                    ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR);
8051            VALIDATORS.put(ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
8052                    ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR);
8053            VALIDATORS.put(TTS_DEFAULT_RATE, TTS_DEFAULT_RATE_VALIDATOR);
8054            VALIDATORS.put(TTS_DEFAULT_PITCH, TTS_DEFAULT_PITCH_VALIDATOR);
8055            VALIDATORS.put(TTS_DEFAULT_SYNTH, TTS_DEFAULT_SYNTH_VALIDATOR);
8056            VALIDATORS.put(TTS_ENABLED_PLUGINS, TTS_ENABLED_PLUGINS_VALIDATOR);
8057            VALIDATORS.put(TTS_DEFAULT_LOCALE, TTS_DEFAULT_LOCALE_VALIDATOR);
8058            VALIDATORS.put(SHOW_IME_WITH_HARD_KEYBOARD, SHOW_IME_WITH_HARD_KEYBOARD_VALIDATOR);
8059            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
8060                    WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
8061            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
8062                    WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR);
8063            VALIDATORS.put(WIFI_NUM_OPEN_NETWORKS_KEPT, WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR);
8064            VALIDATORS.put(SELECTED_SPELL_CHECKER, SELECTED_SPELL_CHECKER_VALIDATOR);
8065            VALIDATORS.put(SELECTED_SPELL_CHECKER_SUBTYPE,
8066                    SELECTED_SPELL_CHECKER_SUBTYPE_VALIDATOR);
8067            VALIDATORS.put(SPELL_CHECKER_ENABLED, SPELL_CHECKER_ENABLED_VALIDATOR);
8068            VALIDATORS.put(MOUNT_PLAY_NOTIFICATION_SND, MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR);
8069            VALIDATORS.put(MOUNT_UMS_AUTOSTART, MOUNT_UMS_AUTOSTART_VALIDATOR);
8070            VALIDATORS.put(MOUNT_UMS_PROMPT, MOUNT_UMS_PROMPT_VALIDATOR);
8071            VALIDATORS.put(MOUNT_UMS_NOTIFY_ENABLED, MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR);
8072            VALIDATORS.put(SLEEP_TIMEOUT, SLEEP_TIMEOUT_VALIDATOR);
8073            VALIDATORS.put(DOUBLE_TAP_TO_WAKE, DOUBLE_TAP_TO_WAKE_VALIDATOR);
8074            VALIDATORS.put(WAKE_GESTURE_ENABLED, WAKE_GESTURE_ENABLED_VALIDATOR);
8075            VALIDATORS.put(LONG_PRESS_TIMEOUT, LONG_PRESS_TIMEOUT_VALIDATOR);
8076            VALIDATORS.put(CAMERA_GESTURE_DISABLED, CAMERA_GESTURE_DISABLED_VALIDATOR);
8077            VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_ENABLED,
8078                    ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR);
8079            VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_DELAY, ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR);
8080            VALIDATORS.put(ACCESSIBILITY_LARGE_POINTER_ICON,
8081                    ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR);
8082            VALIDATORS.put(PREFERRED_TTY_MODE, PREFERRED_TTY_MODE_VALIDATOR);
8083            VALIDATORS.put(ENHANCED_VOICE_PRIVACY_ENABLED,
8084                    ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR);
8085            VALIDATORS.put(TTY_MODE_ENABLED, TTY_MODE_ENABLED_VALIDATOR);
8086            VALIDATORS.put(RTT_CALLING_MODE, RTT_CALLING_MODE_VALIDATOR);
8087            VALIDATORS.put(INCALL_POWER_BUTTON_BEHAVIOR, INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR);
8088            VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_START_TIME,
8089                    NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR);
8090            VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_END_TIME, NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR);
8091            VALIDATORS.put(NIGHT_DISPLAY_COLOR_TEMPERATURE,
8092                    NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR);
8093            VALIDATORS.put(NIGHT_DISPLAY_AUTO_MODE, NIGHT_DISPLAY_AUTO_MODE_VALIDATOR);
8094            VALIDATORS.put(SYNC_PARENT_SOUNDS, SYNC_PARENT_SOUNDS_VALIDATOR);
8095            VALIDATORS.put(CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
8096                    CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR);
8097            VALIDATORS.put(SWIPE_UP_TO_SWITCH_APPS_ENABLED,
8098                    SWIPE_UP_TO_SWITCH_APPS_ENABLED_VALIDATOR);
8099            VALIDATORS.put(CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
8100                    CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR);
8101            VALIDATORS.put(SYSTEM_NAVIGATION_KEYS_ENABLED,
8102                    SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR);
8103            VALIDATORS.put(QS_TILES, QS_TILES_VALIDATOR);
8104            VALIDATORS.put(DOZE_ENABLED, DOZE_ENABLED_VALIDATOR);
8105            VALIDATORS.put(DOZE_PULSE_ON_PICK_UP, DOZE_PULSE_ON_PICK_UP_VALIDATOR);
8106            VALIDATORS.put(DOZE_PULSE_ON_DOUBLE_TAP, DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR);
8107            VALIDATORS.put(NFC_PAYMENT_DEFAULT_COMPONENT, NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR);
8108            VALIDATORS.put(AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
8109                    AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR);
8110            VALIDATORS.put(ASSIST_GESTURE_ENABLED, ASSIST_GESTURE_ENABLED_VALIDATOR);
8111            VALIDATORS.put(ASSIST_GESTURE_SENSITIVITY, ASSIST_GESTURE_SENSITIVITY_VALIDATOR);
8112            VALIDATORS.put(ASSIST_GESTURE_SETUP_COMPLETE, ASSIST_GESTURE_SETUP_COMPLETE_VALIDATOR);
8113            VALIDATORS.put(ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
8114                    ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR);
8115            VALIDATORS.put(ASSIST_GESTURE_WAKE_ENABLED, ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR);
8116            VALIDATORS.put(VR_DISPLAY_MODE, VR_DISPLAY_MODE_VALIDATOR);
8117            VALIDATORS.put(NOTIFICATION_BADGING, NOTIFICATION_BADGING_VALIDATOR);
8118            VALIDATORS.put(QS_AUTO_ADDED_TILES, QS_AUTO_ADDED_TILES_VALIDATOR);
8119            VALIDATORS.put(SCREENSAVER_ENABLED, SCREENSAVER_ENABLED_VALIDATOR);
8120            VALIDATORS.put(SCREENSAVER_COMPONENTS, SCREENSAVER_COMPONENTS_VALIDATOR);
8121            VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_DOCK, SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR);
8122            VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_SLEEP, SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR);
8123            VALIDATORS.put(LOCKDOWN_IN_POWER_MENU, LOCKDOWN_IN_POWER_MENU_VALIDATOR);
8124            VALIDATORS.put(SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
8125                    SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR);
8126            VALIDATORS.put(VOLUME_HUSH_GESTURE, VOLUME_HUSH_GESTURE_VALIDATOR);
8127            VALIDATORS.put(ENABLED_NOTIFICATION_LISTENERS,
8128                    ENABLED_NOTIFICATION_LISTENERS_VALIDATOR); //legacy restore setting
8129            VALIDATORS.put(ENABLED_NOTIFICATION_ASSISTANT,
8130                    ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR); //legacy restore setting
8131            VALIDATORS.put(ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
8132                    ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR); //legacy restore setting
8133        }
8134
8135        /**
8136         * Keys we no longer back up under the current schema, but want to continue to
8137         * process when restoring historical backup datasets.
8138         *
8139         * All settings in {@link LEGACY_RESTORE_SETTINGS} array *must* have a non-null validator,
8140         * otherwise they won't be restored.
8141         *
8142         * @hide
8143         */
8144        public static final String[] LEGACY_RESTORE_SETTINGS = {
8145                ENABLED_NOTIFICATION_LISTENERS,
8146                ENABLED_NOTIFICATION_ASSISTANT,
8147                ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES
8148        };
8149
8150        /**
8151         * These entries are considered common between the personal and the managed profile,
8152         * since the managed profile doesn't get to change them.
8153         */
8154        private static final Set<String> CLONE_TO_MANAGED_PROFILE = new ArraySet<>();
8155
8156        static {
8157            CLONE_TO_MANAGED_PROFILE.add(ACCESSIBILITY_ENABLED);
8158            CLONE_TO_MANAGED_PROFILE.add(ALLOW_MOCK_LOCATION);
8159            CLONE_TO_MANAGED_PROFILE.add(ALLOWED_GEOLOCATION_ORIGINS);
8160            CLONE_TO_MANAGED_PROFILE.add(AUTOFILL_SERVICE);
8161            CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD);
8162            CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES);
8163            CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS);
8164            CLONE_TO_MANAGED_PROFILE.add(LOCATION_CHANGER);
8165            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
8166            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED);
8167            CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE);
8168            if (TextServicesManager.DISABLE_PER_PROFILE_SPELL_CHECKER) {
8169                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER);
8170                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER_SUBTYPE);
8171            }
8172        }
8173
8174        /** @hide */
8175        public static void getCloneToManagedProfileSettings(Set<String> outKeySet) {
8176            outKeySet.addAll(CLONE_TO_MANAGED_PROFILE);
8177        }
8178
8179        /**
8180         * Secure settings which can be accessed by instant apps.
8181         * @hide
8182         */
8183        public static final Set<String> INSTANT_APP_SETTINGS = new ArraySet<>();
8184        static {
8185            INSTANT_APP_SETTINGS.add(ENABLED_ACCESSIBILITY_SERVICES);
8186            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_SPEAK_PASSWORD);
8187            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
8188            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_ENABLED);
8189            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_PRESET);
8190            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_EDGE_TYPE);
8191            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_EDGE_COLOR);
8192            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_LOCALE);
8193            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR);
8194            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR);
8195            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_TYPEFACE);
8196            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_FONT_SCALE);
8197            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_CAPTIONING_WINDOW_COLOR);
8198            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
8199            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_DISPLAY_DALTONIZER);
8200            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_AUTOCLICK_DELAY);
8201            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_AUTOCLICK_ENABLED);
8202            INSTANT_APP_SETTINGS.add(ACCESSIBILITY_LARGE_POINTER_ICON);
8203
8204            INSTANT_APP_SETTINGS.add(DEFAULT_INPUT_METHOD);
8205            INSTANT_APP_SETTINGS.add(ENABLED_INPUT_METHODS);
8206
8207            INSTANT_APP_SETTINGS.add(ANDROID_ID);
8208
8209            INSTANT_APP_SETTINGS.add(PACKAGE_VERIFIER_USER_CONSENT);
8210            INSTANT_APP_SETTINGS.add(ALLOW_MOCK_LOCATION);
8211        }
8212
8213        /**
8214         * Helper method for determining if a location provider is enabled.
8215         *
8216         * @param cr the content resolver to use
8217         * @param provider the location provider to query
8218         * @return true if the provider is enabled
8219         *
8220         * @deprecated use {@link LocationManager#isProviderEnabled(String)}
8221         */
8222        @Deprecated
8223        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
8224            return isLocationProviderEnabledForUser(cr, provider, cr.getUserId());
8225        }
8226
8227        /**
8228         * Helper method for determining if a location provider is enabled.
8229         * @param cr the content resolver to use
8230         * @param provider the location provider to query
8231         * @param userId the userId to query
8232         * @return true if the provider is enabled
8233         *
8234         * @deprecated use {@link LocationManager#isProviderEnabled(String)}
8235         * @hide
8236         */
8237        @Deprecated
8238        public static final boolean isLocationProviderEnabledForUser(
8239                ContentResolver cr, String provider, int userId) {
8240            String allowedProviders = Settings.Secure.getStringForUser(cr,
8241                    LOCATION_PROVIDERS_ALLOWED, userId);
8242            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
8243        }
8244
8245        /**
8246         * Thread-safe method for enabling or disabling a single location provider.
8247         * @param cr the content resolver to use
8248         * @param provider the location provider to enable or disable
8249         * @param enabled true if the provider should be enabled
8250         * @deprecated This API is deprecated. It requires WRITE_SECURE_SETTINGS permission to
8251         *             change location settings.
8252         */
8253        @Deprecated
8254        public static final void setLocationProviderEnabled(ContentResolver cr,
8255                String provider, boolean enabled) {
8256            setLocationProviderEnabledForUser(cr, provider, enabled, cr.getUserId());
8257        }
8258
8259        /**
8260         * Thread-safe method for enabling or disabling a single location provider.
8261         *
8262         * @param cr the content resolver to use
8263         * @param provider the location provider to enable or disable
8264         * @param enabled true if the provider should be enabled
8265         * @param userId the userId for which to enable/disable providers
8266         * @return true if the value was set, false on database errors
8267         *
8268         * @deprecated use {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}
8269         * @hide
8270         */
8271        @Deprecated
8272        public static final boolean setLocationProviderEnabledForUser(ContentResolver cr,
8273                String provider, boolean enabled, int userId) {
8274            synchronized (mLocationSettingsLock) {
8275                // to ensure thread safety, we write the provider name with a '+' or '-'
8276                // and let the SettingsProvider handle it rather than reading and modifying
8277                // the list of enabled providers.
8278                if (enabled) {
8279                    provider = "+" + provider;
8280                } else {
8281                    provider = "-" + provider;
8282                }
8283                return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
8284                        userId);
8285            }
8286        }
8287
8288        /**
8289         * Thread-safe method for setting the location mode to one of
8290         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
8291         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
8292         * Necessary because the mode is a composite of the underlying location provider
8293         * settings.
8294         *
8295         * @param cr the content resolver to use
8296         * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY}
8297         * @param userId the userId for which to change mode
8298         * @return true if the value was set, false on database errors
8299         *
8300         * @throws IllegalArgumentException if mode is not one of the supported values
8301         *
8302         * @deprecated To enable/disable location, use
8303         *             {@link LocationManager#setLocationEnabledForUser(boolean, int)}.
8304         *             To enable/disable a specific location provider, use
8305         *             {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}.
8306         */
8307        @Deprecated
8308        private static boolean setLocationModeForUser(
8309                ContentResolver cr, int mode, int userId) {
8310            synchronized (mLocationSettingsLock) {
8311                boolean gps = false;
8312                boolean network = false;
8313                switch (mode) {
8314                    case LOCATION_MODE_OFF:
8315                        break;
8316                    case LOCATION_MODE_SENSORS_ONLY:
8317                        gps = true;
8318                        break;
8319                    case LOCATION_MODE_BATTERY_SAVING:
8320                        network = true;
8321                        break;
8322                    case LOCATION_MODE_HIGH_ACCURACY:
8323                        gps = true;
8324                        network = true;
8325                        break;
8326                    default:
8327                        throw new IllegalArgumentException("Invalid location mode: " + mode);
8328                }
8329
8330                boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
8331                        cr, LocationManager.NETWORK_PROVIDER, network, userId);
8332                boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
8333                        cr, LocationManager.GPS_PROVIDER, gps, userId);
8334                return gpsSuccess && nlpSuccess;
8335            }
8336        }
8337
8338        /**
8339         * Thread-safe method for reading the location mode, returns one of
8340         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
8341         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. Necessary
8342         * because the mode is a composite of the underlying location provider settings.
8343         *
8344         * @param cr the content resolver to use
8345         * @param userId the userId for which to read the mode
8346         * @return the location mode
8347         */
8348        private static final int getLocationModeForUser(ContentResolver cr, int userId) {
8349            synchronized (mLocationSettingsLock) {
8350                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
8351                        cr, LocationManager.GPS_PROVIDER, userId);
8352                boolean networkEnabled = Settings.Secure.isLocationProviderEnabledForUser(
8353                        cr, LocationManager.NETWORK_PROVIDER, userId);
8354                if (gpsEnabled && networkEnabled) {
8355                    return LOCATION_MODE_HIGH_ACCURACY;
8356                } else if (gpsEnabled) {
8357                    return LOCATION_MODE_SENSORS_ONLY;
8358                } else if (networkEnabled) {
8359                    return LOCATION_MODE_BATTERY_SAVING;
8360                } else {
8361                    return LOCATION_MODE_OFF;
8362                }
8363            }
8364        }
8365    }
8366
8367    /**
8368     * Global system settings, containing preferences that always apply identically
8369     * to all defined users.  Applications can read these but are not allowed to write;
8370     * like the "Secure" settings, these are for preferences that the user must
8371     * explicitly modify through the system UI or specialized APIs for those values.
8372     */
8373    public static final class Global extends NameValueTable {
8374        // NOTE: If you add new settings here, be sure to add them to
8375        // com.android.providers.settings.SettingsProtoDumpUtil#dumpProtoGlobalSettingsLocked.
8376
8377        /**
8378         * The content:// style URL for global secure settings items.  Not public.
8379         */
8380        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
8381
8382        /**
8383         * Whether users are allowed to add more users or guest from lockscreen.
8384         * <p>
8385         * Type: int
8386         * @hide
8387         */
8388        public static final String ADD_USERS_WHEN_LOCKED = "add_users_when_locked";
8389
8390        /**
8391         * Setting whether the global gesture for enabling accessibility is enabled.
8392         * If this gesture is enabled the user will be able to perfrom it to enable
8393         * the accessibility state without visiting the settings app.
8394         *
8395         * @hide
8396         * No longer used. Should be removed once all dependencies have been updated.
8397         */
8398        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
8399                "enable_accessibility_global_gesture_enabled";
8400
8401        /**
8402         * Whether Airplane Mode is on.
8403         */
8404        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
8405
8406        /**
8407         * Whether Theater Mode is on.
8408         * {@hide}
8409         */
8410        @SystemApi
8411        public static final String THEATER_MODE_ON = "theater_mode_on";
8412
8413        /**
8414         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
8415         */
8416        public static final String RADIO_BLUETOOTH = "bluetooth";
8417
8418        /**
8419         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
8420         */
8421        public static final String RADIO_WIFI = "wifi";
8422
8423        /**
8424         * {@hide}
8425         */
8426        public static final String RADIO_WIMAX = "wimax";
8427        /**
8428         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
8429         */
8430        public static final String RADIO_CELL = "cell";
8431
8432        /**
8433         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
8434         */
8435        public static final String RADIO_NFC = "nfc";
8436
8437        /**
8438         * A comma separated list of radios that need to be disabled when airplane mode
8439         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
8440         * included in the comma separated list.
8441         */
8442        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
8443
8444        /**
8445         * A comma separated list of radios that should to be disabled when airplane mode
8446         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
8447         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
8448         * will be turned off when entering airplane mode, but the user will be able to reenable
8449         * Wifi in the Settings app.
8450         *
8451         * {@hide}
8452         */
8453        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
8454
8455        /**
8456         * An integer representing the Bluetooth Class of Device (CoD).
8457         *
8458         * @hide
8459         */
8460        public static final String BLUETOOTH_CLASS_OF_DEVICE = "bluetooth_class_of_device";
8461
8462        /**
8463         * A Long representing a bitmap of profiles that should be disabled when bluetooth starts.
8464         * See {@link android.bluetooth.BluetoothProfile}.
8465         * {@hide}
8466         */
8467        public static final String BLUETOOTH_DISABLED_PROFILES = "bluetooth_disabled_profiles";
8468
8469        /**
8470         * A semi-colon separated list of Bluetooth interoperability workarounds.
8471         * Each entry is a partial Bluetooth device address string and an integer representing
8472         * the feature to be disabled, separated by a comma. The integer must correspond
8473         * to a interoperability feature as defined in "interop.h" in /system/bt.
8474         * <p>
8475         * Example: <br/>
8476         *   "00:11:22,0;01:02:03:04,2"
8477         * @hide
8478         */
8479       public static final String BLUETOOTH_INTEROPERABILITY_LIST = "bluetooth_interoperability_list";
8480
8481        /**
8482         * The policy for deciding when Wi-Fi should go to sleep (which will in
8483         * turn switch to using the mobile data as an Internet connection).
8484         * <p>
8485         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
8486         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
8487         * {@link #WIFI_SLEEP_POLICY_NEVER}.
8488         */
8489        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
8490
8491        /**
8492         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
8493         * policy, which is to sleep shortly after the turning off
8494         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
8495         */
8496        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
8497
8498        /**
8499         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
8500         * the device is on battery, and never go to sleep when the device is
8501         * plugged in.
8502         */
8503        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
8504
8505        /**
8506         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
8507         */
8508        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
8509
8510        /**
8511         * Value to specify if the user prefers the date, time and time zone
8512         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
8513         */
8514        public static final String AUTO_TIME = "auto_time";
8515
8516        private static final Validator AUTO_TIME_VALIDATOR = BOOLEAN_VALIDATOR;
8517
8518        /**
8519         * Value to specify if the user prefers the time zone
8520         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
8521         */
8522        public static final String AUTO_TIME_ZONE = "auto_time_zone";
8523
8524        private static final Validator AUTO_TIME_ZONE_VALIDATOR = BOOLEAN_VALIDATOR;
8525
8526        /**
8527         * URI for the car dock "in" event sound.
8528         * @hide
8529         */
8530        public static final String CAR_DOCK_SOUND = "car_dock_sound";
8531
8532        /**
8533         * URI for the car dock "out" event sound.
8534         * @hide
8535         */
8536        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
8537
8538        /**
8539         * URI for the desk dock "in" event sound.
8540         * @hide
8541         */
8542        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
8543
8544        /**
8545         * URI for the desk dock "out" event sound.
8546         * @hide
8547         */
8548        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
8549
8550        /**
8551         * Whether to play a sound for dock events.
8552         * @hide
8553         */
8554        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
8555
8556        private static final Validator DOCK_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8557
8558        /**
8559         * Whether to play a sound for dock events, only when an accessibility service is on.
8560         * @hide
8561         */
8562        public static final String DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY = "dock_sounds_enabled_when_accessbility";
8563
8564        /**
8565         * URI for the "device locked" (keyguard shown) sound.
8566         * @hide
8567         */
8568        public static final String LOCK_SOUND = "lock_sound";
8569
8570        /**
8571         * URI for the "device unlocked" sound.
8572         * @hide
8573         */
8574        public static final String UNLOCK_SOUND = "unlock_sound";
8575
8576        /**
8577         * URI for the "device is trusted" sound, which is played when the device enters the trusted
8578         * state without unlocking.
8579         * @hide
8580         */
8581        public static final String TRUSTED_SOUND = "trusted_sound";
8582
8583        /**
8584         * URI for the low battery sound file.
8585         * @hide
8586         */
8587        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
8588
8589        /**
8590         * Whether to play a sound for low-battery alerts.
8591         * @hide
8592         */
8593        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
8594
8595        private static final Validator POWER_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8596
8597        /**
8598         * URI for the "wireless charging started" and "wired charging started" sound.
8599         * @hide
8600         */
8601        public static final String CHARGING_STARTED_SOUND =
8602                "wireless_charging_started_sound";
8603
8604        /**
8605         * Whether to play a sound for charging events.
8606         * @hide
8607         */
8608        public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled";
8609
8610        private static final Validator CHARGING_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
8611
8612        /**
8613         * Whether we keep the device on while the device is plugged in.
8614         * Supported values are:
8615         * <ul>
8616         * <li>{@code 0} to never stay on while plugged in</li>
8617         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
8618         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
8619         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
8620         * </ul>
8621         * These values can be OR-ed together.
8622         */
8623        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
8624
8625        private static final Validator STAY_ON_WHILE_PLUGGED_IN_VALIDATOR = new Validator() {
8626            @Override
8627            public boolean validate(String value) {
8628                try {
8629                    int val = Integer.parseInt(value);
8630                    return (val == 0)
8631                            || (val == BatteryManager.BATTERY_PLUGGED_AC)
8632                            || (val == BatteryManager.BATTERY_PLUGGED_USB)
8633                            || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS)
8634                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8635                                    | BatteryManager.BATTERY_PLUGGED_USB))
8636                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8637                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
8638                            || (val == (BatteryManager.BATTERY_PLUGGED_USB
8639                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS))
8640                            || (val == (BatteryManager.BATTERY_PLUGGED_AC
8641                                    | BatteryManager.BATTERY_PLUGGED_USB
8642                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS));
8643                } catch (NumberFormatException e) {
8644                    return false;
8645                }
8646            }
8647        };
8648
8649        /**
8650         * When the user has enable the option to have a "bug report" command
8651         * in the power menu.
8652         * @hide
8653         */
8654        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
8655
8656        private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
8657
8658        /**
8659         * Whether ADB is enabled.
8660         */
8661        public static final String ADB_ENABLED = "adb_enabled";
8662
8663        /**
8664         * Whether Views are allowed to save their attribute data.
8665         * @hide
8666         */
8667        public static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
8668
8669        /**
8670         * Whether assisted GPS should be enabled or not.
8671         * @hide
8672         */
8673        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
8674
8675        /**
8676         * Whether bluetooth is enabled/disabled
8677         * 0=disabled. 1=enabled.
8678         */
8679        public static final String BLUETOOTH_ON = "bluetooth_on";
8680
8681        private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR;
8682
8683        /**
8684         * CDMA Cell Broadcast SMS
8685         *                            0 = CDMA Cell Broadcast SMS disabled
8686         *                            1 = CDMA Cell Broadcast SMS enabled
8687         * @hide
8688         */
8689        public static final String CDMA_CELL_BROADCAST_SMS =
8690                "cdma_cell_broadcast_sms";
8691
8692        /**
8693         * The CDMA roaming mode 0 = Home Networks, CDMA default
8694         *                       1 = Roaming on Affiliated networks
8695         *                       2 = Roaming on any networks
8696         * @hide
8697         */
8698        public static final String CDMA_ROAMING_MODE = "roaming_settings";
8699
8700        /**
8701         * The CDMA subscription mode 0 = RUIM/SIM (default)
8702         *                                1 = NV
8703         * @hide
8704         */
8705        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
8706
8707        /**
8708         * The default value for whether background data is enabled or not.
8709         *
8710         * Used by {@code NetworkPolicyManagerService}.
8711         *
8712         * @hide
8713         */
8714        public static final String DEFAULT_RESTRICT_BACKGROUND_DATA =
8715                "default_restrict_background_data";
8716
8717        /** Inactivity timeout to track mobile data activity.
8718        *
8719        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
8720        * infer the data activity of mobile network. After a period of no activity on mobile
8721        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
8722        * intent is fired to indicate a transition of network status from "active" to "idle". Any
8723        * subsequent activity on mobile networks triggers the firing of {@code
8724        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
8725        *
8726        * Network activity refers to transmitting or receiving data on the network interfaces.
8727        *
8728        * Tracking is disabled if set to zero or negative value.
8729        *
8730        * @hide
8731        */
8732       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
8733
8734       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
8735        * but for Wifi network.
8736        * @hide
8737        */
8738       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
8739
8740       /**
8741        * Whether or not data roaming is enabled. (0 = false, 1 = true)
8742        */
8743       public static final String DATA_ROAMING = "data_roaming";
8744
8745       /**
8746        * The value passed to a Mobile DataConnection via bringUp which defines the
8747        * number of retries to preform when setting up the initial connection. The default
8748        * value defined in DataConnectionTrackerBase#DEFAULT_MDC_INITIAL_RETRY is currently 1.
8749        * @hide
8750        */
8751       public static final String MDC_INITIAL_MAX_RETRY = "mdc_initial_max_retry";
8752
8753       /**
8754        * Whether any package can be on external storage. When this is true, any
8755        * package, regardless of manifest values, is a candidate for installing
8756        * or moving onto external storage. (0 = false, 1 = true)
8757        * @hide
8758        */
8759       public static final String FORCE_ALLOW_ON_EXTERNAL = "force_allow_on_external";
8760
8761        /**
8762         * The default SM-DP+ configured for this device.
8763         *
8764         * <p>An SM-DP+ is used by an LPA (see {@link android.service.euicc.EuiccService}) to
8765         * download profiles. If this value is set, the LPA will query this server for any profiles
8766         * available to this device. If any are available, they may be downloaded during device
8767         * provisioning or in settings without needing the user to enter an activation code.
8768         *
8769         * @see android.service.euicc.EuiccService
8770         * @hide
8771         */
8772        @SystemApi
8773        public static final String DEFAULT_SM_DP_PLUS = "default_sm_dp_plus";
8774
8775        /**
8776         * Whether any profile has ever been downloaded onto a eUICC on the device.
8777         *
8778         * <p>Used to hide eUICC UI from users who have never made use of it and would only be
8779         * confused by seeing references to it in settings.
8780         * (0 = false, 1 = true)
8781         * @hide
8782         */
8783        @SystemApi
8784        public static final String EUICC_PROVISIONED = "euicc_provisioned";
8785
8786        /**
8787         * List of ISO country codes in which eUICC UI is shown. Country codes should be separated
8788         * by comma.
8789         *
8790         * <p>Used to hide eUICC UI from users who are currently in countries no carriers support
8791         * eUICC.
8792         * @hide
8793         */
8794        //TODO(b/77914569) Changes this to System Api.
8795        public static final String EUICC_SUPPORTED_COUNTRIES = "euicc_supported_countries";
8796
8797        /**
8798         * Whether any activity can be resized. When this is true, any
8799         * activity, regardless of manifest values, can be resized for multi-window.
8800         * (0 = false, 1 = true)
8801         * @hide
8802         */
8803        public static final String DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES
8804                = "force_resizable_activities";
8805
8806        /**
8807         * Whether to enable experimental freeform support for windows.
8808         * @hide
8809         */
8810        public static final String DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT
8811                = "enable_freeform_support";
8812
8813       /**
8814        * Whether user has enabled development settings.
8815        */
8816       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
8817
8818       /**
8819        * Whether the device has been provisioned (0 = false, 1 = true).
8820        * <p>On a multiuser device with a separate system user, the screen may be locked
8821        * as soon as this is set to true and further activities cannot be launched on the
8822        * system user unless they are marked to show over keyguard.
8823        */
8824       public static final String DEVICE_PROVISIONED = "device_provisioned";
8825
8826       /**
8827        * Whether mobile data should be allowed while the device is being provisioned.
8828        * This allows the provisioning process to turn off mobile data before the user
8829        * has an opportunity to set things up, preventing other processes from burning
8830        * precious bytes before wifi is setup.
8831        * (0 = false, 1 = true)
8832        * @hide
8833        */
8834       public static final String DEVICE_PROVISIONING_MOBILE_DATA_ENABLED =
8835               "device_provisioning_mobile_data";
8836
8837       /**
8838        * The saved value for WindowManagerService.setForcedDisplaySize().
8839        * Two integers separated by a comma.  If unset, then use the real display size.
8840        * @hide
8841        */
8842       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
8843
8844       /**
8845        * The saved value for WindowManagerService.setForcedDisplayScalingMode().
8846        * 0 or unset if scaling is automatic, 1 if scaling is disabled.
8847        * @hide
8848        */
8849       public static final String DISPLAY_SCALING_FORCE = "display_scaling_force";
8850
8851       /**
8852        * The maximum size, in bytes, of a download that the download manager will transfer over
8853        * a non-wifi connection.
8854        * @hide
8855        */
8856       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
8857               "download_manager_max_bytes_over_mobile";
8858
8859       /**
8860        * The recommended maximum size, in bytes, of a download that the download manager should
8861        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
8862        * have the option to start the download over the mobile connection anyway.
8863        * @hide
8864        */
8865       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
8866               "download_manager_recommended_max_bytes_over_mobile";
8867
8868       /**
8869        * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
8870        */
8871       @Deprecated
8872       public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
8873
8874       /**
8875        * Whether HDMI control shall be enabled. If disabled, no CEC/MHL command will be
8876        * sent or processed. (0 = false, 1 = true)
8877        * @hide
8878        */
8879       public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled";
8880
8881       /**
8882        * Whether HDMI System Audio Control feature is enabled. If enabled, TV will try to turn on
8883        * system audio mode if there's a connected CEC-enabled AV Receiver. Then audio stream will
8884        * be played on AVR instead of TV spaeker. If disabled, the system audio mode will never be
8885        * activated.
8886        * @hide
8887        */
8888        public static final String HDMI_SYSTEM_AUDIO_CONTROL_ENABLED =
8889                "hdmi_system_audio_control_enabled";
8890
8891        /**
8892         * Whether TV will automatically turn on upon reception of the CEC command
8893         * &lt;Text View On&gt; or &lt;Image View On&gt;. (0 = false, 1 = true)
8894         *
8895         * @hide
8896         */
8897        public static final String HDMI_CONTROL_AUTO_WAKEUP_ENABLED =
8898                "hdmi_control_auto_wakeup_enabled";
8899
8900        /**
8901         * Whether TV will also turn off other CEC devices when it goes to standby mode.
8902         * (0 = false, 1 = true)
8903         *
8904         * @hide
8905         */
8906        public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
8907                "hdmi_control_auto_device_off_enabled";
8908
8909        /**
8910         * If <b>true</b>, enables out-of-the-box execution for priv apps.
8911         * Default: false
8912         * Values: 0 = false, 1 = true
8913         *
8914         * @hide
8915         */
8916        public static final String PRIV_APP_OOB_ENABLED = "priv_app_oob_enabled";
8917
8918        /**
8919         * Comma separated list of privileged package names, which will be running out-of-box APK.
8920         * Default: "ALL"
8921         *
8922         * @hide
8923         */
8924        public static final String PRIV_APP_OOB_LIST = "priv_app_oob_list";
8925
8926        /**
8927         * The interval in milliseconds at which location requests will be throttled when they are
8928         * coming from the background.
8929         *
8930         * @hide
8931         */
8932        public static final String LOCATION_BACKGROUND_THROTTLE_INTERVAL_MS =
8933                "location_background_throttle_interval_ms";
8934
8935        /**
8936         * Most frequent location update interval in milliseconds that proximity alert is allowed
8937         * to request.
8938         * @hide
8939         */
8940        public static final String LOCATION_BACKGROUND_THROTTLE_PROXIMITY_ALERT_INTERVAL_MS =
8941                "location_background_throttle_proximity_alert_interval_ms";
8942
8943        /**
8944         * Packages that are whitelisted for background throttling (throttling will not be applied).
8945         * @hide
8946         */
8947        public static final String LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST =
8948            "location_background_throttle_package_whitelist";
8949
8950        /**
8951        * Whether TV will switch to MHL port when a mobile device is plugged in.
8952        * (0 = false, 1 = true)
8953        * @hide
8954        */
8955       public static final String MHL_INPUT_SWITCHING_ENABLED = "mhl_input_switching_enabled";
8956
8957       /**
8958        * Whether TV will charge the mobile device connected at MHL port. (0 = false, 1 = true)
8959        * @hide
8960        */
8961       public static final String MHL_POWER_CHARGE_ENABLED = "mhl_power_charge_enabled";
8962
8963       /**
8964        * Whether mobile data connections are allowed by the user.  See
8965        * ConnectivityManager for more info.
8966        * @hide
8967        */
8968       public static final String MOBILE_DATA = "mobile_data";
8969
8970       /**
8971        * Whether the mobile data connection should remain active even when higher
8972        * priority networks like WiFi are active, to help make network switching faster.
8973        *
8974        * See ConnectivityService for more info.
8975        *
8976        * (0 = disabled, 1 = enabled)
8977        * @hide
8978        */
8979       public static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
8980
8981        /**
8982         * Size of the event buffer for IP connectivity metrics.
8983         * @hide
8984         */
8985        public static final String CONNECTIVITY_METRICS_BUFFER_SIZE =
8986              "connectivity_metrics_buffer_size";
8987
8988       /** {@hide} */
8989       public static final String NETSTATS_ENABLED = "netstats_enabled";
8990       /** {@hide} */
8991       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
8992       /** {@hide} */
8993       @Deprecated
8994       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
8995       /** {@hide} */
8996       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
8997       /** {@hide} */
8998       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
8999       /** {@hide} */
9000       public static final String NETSTATS_AUGMENT_ENABLED = "netstats_augment_enabled";
9001
9002       /** {@hide} */
9003       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
9004       /** {@hide} */
9005       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
9006       /** {@hide} */
9007       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
9008       /** {@hide} */
9009       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
9010
9011       /** {@hide} */
9012       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
9013       /** {@hide} */
9014       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
9015       /** {@hide} */
9016       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
9017       /** {@hide} */
9018       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
9019
9020       /** {@hide} */
9021       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
9022       /** {@hide} */
9023       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
9024       /** {@hide} */
9025       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
9026       /** {@hide} */
9027       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
9028
9029       /** {@hide} */
9030       public static final String NETPOLICY_QUOTA_ENABLED = "netpolicy_quota_enabled";
9031       /** {@hide} */
9032       public static final String NETPOLICY_QUOTA_UNLIMITED = "netpolicy_quota_unlimited";
9033       /** {@hide} */
9034       public static final String NETPOLICY_QUOTA_LIMITED = "netpolicy_quota_limited";
9035       /** {@hide} */
9036       public static final String NETPOLICY_QUOTA_FRAC_JOBS = "netpolicy_quota_frac_jobs";
9037       /** {@hide} */
9038       public static final String NETPOLICY_QUOTA_FRAC_MULTIPATH = "netpolicy_quota_frac_multipath";
9039
9040       /** {@hide} */
9041       public static final String NETPOLICY_OVERRIDE_ENABLED = "netpolicy_override_enabled";
9042
9043       /**
9044        * User preference for which network(s) should be used. Only the
9045        * connectivity service should touch this.
9046        */
9047       public static final String NETWORK_PREFERENCE = "network_preference";
9048
9049       /**
9050        * Which package name to use for network scoring. If null, or if the package is not a valid
9051        * scorer app, external network scores will neither be requested nor accepted.
9052        * @hide
9053        */
9054       public static final String NETWORK_SCORER_APP = "network_scorer_app";
9055
9056        /**
9057         * Whether night display forced auto mode is available.
9058         * 0 = unavailable, 1 = available.
9059         * @hide
9060         */
9061        public static final String NIGHT_DISPLAY_FORCED_AUTO_MODE_AVAILABLE =
9062                "night_display_forced_auto_mode_available";
9063
9064       /**
9065        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
9066        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
9067        * exceeded.
9068        * @hide
9069        */
9070       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
9071
9072       /**
9073        * The length of time in milli-seconds that automatic small adjustments to
9074        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
9075        * @hide
9076        */
9077       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
9078
9079       /** Preferred NTP server. {@hide} */
9080       public static final String NTP_SERVER = "ntp_server";
9081       /** Timeout in milliseconds to wait for NTP server. {@hide} */
9082       public static final String NTP_TIMEOUT = "ntp_timeout";
9083
9084       /** {@hide} */
9085       public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval";
9086
9087       /**
9088        * Sample validity in seconds to configure for the system DNS resolver.
9089        * {@hide}
9090        */
9091       public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS =
9092               "dns_resolver_sample_validity_seconds";
9093
9094       /**
9095        * Success threshold in percent for use with the system DNS resolver.
9096        * {@hide}
9097        */
9098       public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT =
9099                "dns_resolver_success_threshold_percent";
9100
9101       /**
9102        * Minimum number of samples needed for statistics to be considered meaningful in the
9103        * system DNS resolver.
9104        * {@hide}
9105        */
9106       public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples";
9107
9108       /**
9109        * Maximum number taken into account for statistics purposes in the system DNS resolver.
9110        * {@hide}
9111        */
9112       public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples";
9113
9114       /**
9115        * Whether to disable the automatic scheduling of system updates.
9116        * 1 = system updates won't be automatically scheduled (will always
9117        * present notification instead).
9118        * 0 = system updates will be automatically scheduled. (default)
9119        * @hide
9120        */
9121       @SystemApi
9122       public static final String OTA_DISABLE_AUTOMATIC_UPDATE = "ota_disable_automatic_update";
9123
9124       /**
9125        * Whether the package manager should send package verification broadcasts for verifiers to
9126        * review apps prior to installation.
9127        * 1 = request apps to be verified prior to installation, if a verifier exists.
9128        * 0 = do not verify apps before installation
9129        * @hide
9130        */
9131       public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
9132
9133       /** Timeout for package verification.
9134        * @hide */
9135       public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
9136
9137       /** Default response code for package verification.
9138        * @hide */
9139       public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
9140
9141       /**
9142        * Show package verification setting in the Settings app.
9143        * 1 = show (default)
9144        * 0 = hide
9145        * @hide
9146        */
9147       public static final String PACKAGE_VERIFIER_SETTING_VISIBLE = "verifier_setting_visible";
9148
9149       /**
9150        * Run package verification on apps installed through ADB/ADT/USB
9151        * 1 = perform package verification on ADB installs (default)
9152        * 0 = bypass package verification on ADB installs
9153        * @hide
9154        */
9155       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
9156
9157       /**
9158        * Time since last fstrim (milliseconds) after which we force one to happen
9159        * during device startup.  If unset, the default is 3 days.
9160        * @hide
9161        */
9162       public static final String FSTRIM_MANDATORY_INTERVAL = "fstrim_mandatory_interval";
9163
9164       /**
9165        * The interval in milliseconds at which to check packet counts on the
9166        * mobile data interface when screen is on, to detect possible data
9167        * connection problems.
9168        * @hide
9169        */
9170       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
9171               "pdp_watchdog_poll_interval_ms";
9172
9173       /**
9174        * The interval in milliseconds at which to check packet counts on the
9175        * mobile data interface when screen is off, to detect possible data
9176        * connection problems.
9177        * @hide
9178        */
9179       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
9180               "pdp_watchdog_long_poll_interval_ms";
9181
9182       /**
9183        * The interval in milliseconds at which to check packet counts on the
9184        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
9185        * outgoing packets has been reached without incoming packets.
9186        * @hide
9187        */
9188       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
9189               "pdp_watchdog_error_poll_interval_ms";
9190
9191       /**
9192        * The number of outgoing packets sent without seeing an incoming packet
9193        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
9194        * device is logged to the event log
9195        * @hide
9196        */
9197       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
9198               "pdp_watchdog_trigger_packet_count";
9199
9200       /**
9201        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
9202        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
9203        * attempting data connection recovery.
9204        * @hide
9205        */
9206       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
9207               "pdp_watchdog_error_poll_count";
9208
9209       /**
9210        * The number of failed PDP reset attempts before moving to something more
9211        * drastic: re-registering to the network.
9212        * @hide
9213        */
9214       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
9215               "pdp_watchdog_max_pdp_reset_fail_count";
9216
9217       /**
9218        * URL to open browser on to allow user to manage a prepay account
9219        * @hide
9220        */
9221       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
9222               "setup_prepaid_data_service_url";
9223
9224       /**
9225        * URL to attempt a GET on to see if this is a prepay device
9226        * @hide
9227        */
9228       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
9229               "setup_prepaid_detection_target_url";
9230
9231       /**
9232        * Host to check for a redirect to after an attempt to GET
9233        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
9234        * this is a prepaid device with zero balance.)
9235        * @hide
9236        */
9237       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
9238               "setup_prepaid_detection_redir_host";
9239
9240       /**
9241        * The interval in milliseconds at which to check the number of SMS sent out without asking
9242        * for use permit, to limit the un-authorized SMS usage.
9243        *
9244        * @hide
9245        */
9246       public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
9247               "sms_outgoing_check_interval_ms";
9248
9249       /**
9250        * The number of outgoing SMS sent without asking for user permit (of {@link
9251        * #SMS_OUTGOING_CHECK_INTERVAL_MS}
9252        *
9253        * @hide
9254        */
9255       public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
9256               "sms_outgoing_check_max_count";
9257
9258       /**
9259        * Used to disable SMS short code confirmation - defaults to true.
9260        * True indcates we will do the check, etc.  Set to false to disable.
9261        * @see com.android.internal.telephony.SmsUsageMonitor
9262        * @hide
9263        */
9264       public static final String SMS_SHORT_CODE_CONFIRMATION = "sms_short_code_confirmation";
9265
9266        /**
9267         * Used to select which country we use to determine premium sms codes.
9268         * One of com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_SIM,
9269         * com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_NETWORK,
9270         * or com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_BOTH.
9271         * @hide
9272         */
9273        public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule";
9274
9275       /**
9276        * Used to select TCP's default initial receiver window size in segments - defaults to a build config value
9277        * @hide
9278        */
9279       public static final String TCP_DEFAULT_INIT_RWND = "tcp_default_init_rwnd";
9280
9281       /**
9282        * Used to disable Tethering on a device - defaults to true
9283        * @hide
9284        */
9285       public static final String TETHER_SUPPORTED = "tether_supported";
9286
9287       /**
9288        * Used to require DUN APN on the device or not - defaults to a build config value
9289        * which defaults to false
9290        * @hide
9291        */
9292       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
9293
9294       /**
9295        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
9296        * corresponding build config values are set it will override the APN DB
9297        * values.
9298        * Consists of a comma seperated list of strings:
9299        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
9300        * note that empty fields can be omitted: "name,apn,,,,,,,,,310,260,,DUN"
9301        * @hide
9302        */
9303       public static final String TETHER_DUN_APN = "tether_dun_apn";
9304
9305        /**
9306         * Used to disable trying to talk to any available tethering offload HAL.
9307         *
9308         * Integer values are interpreted as boolean, and the absence of an explicit setting
9309         * is interpreted as |false|.
9310         * @hide
9311         */
9312        public static final String TETHER_OFFLOAD_DISABLED = "tether_offload_disabled";
9313
9314        /**
9315         * List of certificate (hex string representation of the application's certificate - SHA-1
9316         * or SHA-256) and carrier app package pairs which are whitelisted to prompt the user for
9317         * install when a sim card with matching UICC carrier privilege rules is inserted.  The
9318         * certificate is used as a key, so the certificate encoding here must be the same as the
9319         * certificate encoding used on the SIM.
9320         *
9321         * The value is "cert1:package1;cert2:package2;..."
9322         * @hide
9323         */
9324        @SystemApi
9325        public static final String CARRIER_APP_WHITELIST = "carrier_app_whitelist";
9326
9327        /**
9328         * Map of package name to application names. The application names cannot and will not be
9329         * localized. App names may not contain colons or semicolons.
9330         *
9331         * The value is "packageName1:appName1;packageName2:appName2;..."
9332         * @hide
9333         */
9334        @SystemApi
9335        public static final String CARRIER_APP_NAMES = "carrier_app_names";
9336
9337       /**
9338        * USB Mass Storage Enabled
9339        */
9340       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
9341
9342       private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9343
9344       /**
9345        * If this setting is set (to anything), then all references
9346        * to Gmail on the device must change to Google Mail.
9347        */
9348       public static final String USE_GOOGLE_MAIL = "use_google_mail";
9349
9350        /**
9351         * Webview Data reduction proxy key.
9352         * @hide
9353         */
9354        public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
9355                "webview_data_reduction_proxy_key";
9356
9357       /**
9358        * Whether or not the WebView fallback mechanism should be enabled.
9359        * 0=disabled, 1=enabled.
9360        * @hide
9361        */
9362       public static final String WEBVIEW_FALLBACK_LOGIC_ENABLED =
9363               "webview_fallback_logic_enabled";
9364
9365       /**
9366        * Name of the package used as WebView provider (if unset the provider is instead determined
9367        * by the system).
9368        * @hide
9369        */
9370       public static final String WEBVIEW_PROVIDER = "webview_provider";
9371
9372       /**
9373        * Developer setting to enable WebView multiprocess rendering.
9374        * @hide
9375        */
9376       @SystemApi
9377       public static final String WEBVIEW_MULTIPROCESS = "webview_multiprocess";
9378
9379       /**
9380        * The maximum number of notifications shown in 24 hours when switching networks.
9381        * @hide
9382        */
9383       public static final String NETWORK_SWITCH_NOTIFICATION_DAILY_LIMIT =
9384              "network_switch_notification_daily_limit";
9385
9386       /**
9387        * The minimum time in milliseconds between notifications when switching networks.
9388        * @hide
9389        */
9390       public static final String NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS =
9391              "network_switch_notification_rate_limit_millis";
9392
9393       /**
9394        * Whether to automatically switch away from wifi networks that lose Internet access.
9395        * Only meaningful if config_networkAvoidBadWifi is set to 0, otherwise the system always
9396        * avoids such networks. Valid values are:
9397        *
9398        * 0: Don't avoid bad wifi, don't prompt the user. Get stuck on bad wifi like it's 2013.
9399        * null: Ask the user whether to switch away from bad wifi.
9400        * 1: Avoid bad wifi.
9401        *
9402        * @hide
9403        */
9404       public static final String NETWORK_AVOID_BAD_WIFI = "network_avoid_bad_wifi";
9405
9406       /**
9407        * User setting for ConnectivityManager.getMeteredMultipathPreference(). This value may be
9408        * overridden by the system based on device or application state. If null, the value
9409        * specified by config_networkMeteredMultipathPreference is used.
9410        *
9411        * @hide
9412        */
9413       public static final String NETWORK_METERED_MULTIPATH_PREFERENCE =
9414               "network_metered_multipath_preference";
9415
9416        /**
9417         * Default daily multipath budget used by ConnectivityManager.getMultipathPreference()
9418         * on metered networks. This default quota is only used if quota could not be determined
9419         * from data plan or data limit/warning set by the user.
9420         * @hide
9421         */
9422        public static final String NETWORK_DEFAULT_DAILY_MULTIPATH_QUOTA_BYTES =
9423                "network_default_daily_multipath_quota_bytes";
9424
9425        /**
9426         * Network watchlist last report time.
9427         * @hide
9428         */
9429        public static final String NETWORK_WATCHLIST_LAST_REPORT_TIME =
9430                "network_watchlist_last_report_time";
9431
9432       /**
9433        * The thresholds of the wifi throughput badging (SD, HD etc.) as a comma-delimited list of
9434        * colon-delimited key-value pairs. The key is the badging enum value defined in
9435        * android.net.ScoredNetwork and the value is the minimum sustained network throughput in
9436        * kbps required for the badge. For example: "10:3000,20:5000,30:25000"
9437        *
9438        * @hide
9439        */
9440       @SystemApi
9441       public static final String WIFI_BADGING_THRESHOLDS = "wifi_badging_thresholds";
9442
9443       /**
9444        * Whether Wifi display is enabled/disabled
9445        * 0=disabled. 1=enabled.
9446        * @hide
9447        */
9448       public static final String WIFI_DISPLAY_ON = "wifi_display_on";
9449
9450       /**
9451        * Whether Wifi display certification mode is enabled/disabled
9452        * 0=disabled. 1=enabled.
9453        * @hide
9454        */
9455       public static final String WIFI_DISPLAY_CERTIFICATION_ON =
9456               "wifi_display_certification_on";
9457
9458       /**
9459        * WPS Configuration method used by Wifi display, this setting only
9460        * takes effect when WIFI_DISPLAY_CERTIFICATION_ON is 1 (enabled).
9461        *
9462        * Possible values are:
9463        *
9464        * WpsInfo.INVALID: use default WPS method chosen by framework
9465        * WpsInfo.PBC    : use Push button
9466        * WpsInfo.KEYPAD : use Keypad
9467        * WpsInfo.DISPLAY: use Display
9468        * @hide
9469        */
9470       public static final String WIFI_DISPLAY_WPS_CONFIG =
9471           "wifi_display_wps_config";
9472
9473       /**
9474        * Whether to notify the user of open networks.
9475        * <p>
9476        * If not connected and the scan results have an open network, we will
9477        * put this notification up. If we attempt to connect to a network or
9478        * the open network(s) disappear, we remove the notification. When we
9479        * show the notification, we will not show it again for
9480        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
9481        *
9482        * @deprecated This feature is no longer controlled by this setting in
9483        * {@link android.os.Build.VERSION_CODES#O}.
9484        */
9485       @Deprecated
9486       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9487               "wifi_networks_available_notification_on";
9488
9489       private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
9490               BOOLEAN_VALIDATOR;
9491
9492       /**
9493        * Whether to notify the user of carrier networks.
9494        * <p>
9495        * If not connected and the scan results have a carrier network, we will
9496        * put this notification up. If we attempt to connect to a network or
9497        * the carrier network(s) disappear, we remove the notification. When we
9498        * show the notification, we will not show it again for
9499        * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
9500        * @hide
9501        */
9502       public static final String WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9503               "wifi_carrier_networks_available_notification_on";
9504
9505       private static final Validator WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR =
9506               BOOLEAN_VALIDATOR;
9507
9508       /**
9509        * {@hide}
9510        */
9511       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
9512               "wimax_networks_available_notification_on";
9513
9514       /**
9515        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
9516        * Connecting to a network will reset the timer.
9517        */
9518       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
9519               "wifi_networks_available_repeat_delay";
9520
9521       private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR =
9522               NON_NEGATIVE_INTEGER_VALIDATOR;
9523
9524       /**
9525        * 802.11 country code in ISO 3166 format
9526        * @hide
9527        */
9528       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
9529
9530       /**
9531        * The interval in milliseconds to issue wake up scans when wifi needs
9532        * to connect. This is necessary to connect to an access point when
9533        * device is on the move and the screen is off.
9534        * @hide
9535        */
9536       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
9537               "wifi_framework_scan_interval_ms";
9538
9539       /**
9540        * The interval in milliseconds after which Wi-Fi is considered idle.
9541        * When idle, it is possible for the device to be switched from Wi-Fi to
9542        * the mobile data network.
9543        * @hide
9544        */
9545       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
9546
9547       /**
9548        * When the number of open networks exceeds this number, the
9549        * least-recently-used excess networks will be removed.
9550        */
9551       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
9552
9553       private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR =
9554               NON_NEGATIVE_INTEGER_VALIDATOR;
9555
9556       /**
9557        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
9558        */
9559       public static final String WIFI_ON = "wifi_on";
9560
9561       /**
9562        * Setting to allow scans to be enabled even wifi is turned off for connectivity.
9563        * @hide
9564        */
9565       public static final String WIFI_SCAN_ALWAYS_AVAILABLE =
9566                "wifi_scan_always_enabled";
9567
9568        /**
9569         * The interval in milliseconds at which wifi rtt ranging requests will be throttled when
9570         * they are coming from the background.
9571         *
9572         * @hide
9573         */
9574        public static final String WIFI_RTT_BACKGROUND_EXEC_GAP_MS =
9575                "wifi_rtt_background_exec_gap_ms";
9576
9577        /**
9578         * Whether soft AP will shut down after a timeout period when no devices are connected.
9579         *
9580         * Type: int (0 for false, 1 for true)
9581         * @hide
9582         */
9583        public static final String SOFT_AP_TIMEOUT_ENABLED = "soft_ap_timeout_enabled";
9584
9585        private static final Validator SOFT_AP_TIMEOUT_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9586
9587        /**
9588         * Value to specify if Wi-Fi Wakeup feature is enabled.
9589         *
9590         * Type: int (0 for false, 1 for true)
9591         * @hide
9592         */
9593        @SystemApi
9594        public static final String WIFI_WAKEUP_ENABLED = "wifi_wakeup_enabled";
9595
9596        private static final Validator WIFI_WAKEUP_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
9597
9598        /**
9599         * Value to specify whether network quality scores and badging should be shown in the UI.
9600         *
9601         * Type: int (0 for false, 1 for true)
9602         * @hide
9603         */
9604        public static final String NETWORK_SCORING_UI_ENABLED = "network_scoring_ui_enabled";
9605
9606        /**
9607         * Value to specify how long in milliseconds to retain seen score cache curves to be used
9608         * when generating SSID only bases score curves.
9609         *
9610         * Type: long
9611         * @hide
9612         */
9613        public static final String SPEED_LABEL_CACHE_EVICTION_AGE_MILLIS =
9614                "speed_label_cache_eviction_age_millis";
9615
9616        /**
9617         * Value to specify if network recommendations from
9618         * {@link com.android.server.NetworkScoreService} are enabled.
9619         *
9620         * Type: int
9621         * Valid values:
9622         *   -1 = Forced off
9623         *    0 = Disabled
9624         *    1 = Enabled
9625         *
9626         * Most readers of this setting should simply check if value == 1 to determined the
9627         * enabled state.
9628         * @hide
9629         */
9630        public static final String NETWORK_RECOMMENDATIONS_ENABLED =
9631                "network_recommendations_enabled";
9632
9633        private static final Validator NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR =
9634                new SettingsValidators.DiscreteValueValidator(new String[] {"-1", "0", "1"});
9635
9636        /**
9637         * Which package name to use for network recommendations. If null, network recommendations
9638         * will neither be requested nor accepted.
9639         *
9640         * Use {@link NetworkScoreManager#getActiveScorerPackage()} to read this value and
9641         * {@link NetworkScoreManager#setActiveScorer(String)} to write it.
9642         *
9643         * Type: string - package name
9644         * @hide
9645         */
9646        public static final String NETWORK_RECOMMENDATIONS_PACKAGE =
9647                "network_recommendations_package";
9648
9649        /**
9650         * The package name of the application that connect and secures high quality open wifi
9651         * networks automatically.
9652         *
9653         * Type: string package name or null if the feature is either not provided or disabled.
9654         * @hide
9655         */
9656        @TestApi
9657        public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package";
9658
9659        private static final Validator USE_OPEN_WIFI_PACKAGE_VALIDATOR = new Validator() {
9660            @Override
9661            public boolean validate(String value) {
9662                return (value == null) || PACKAGE_NAME_VALIDATOR.validate(value);
9663            }
9664        };
9665
9666        /**
9667         * The number of milliseconds the {@link com.android.server.NetworkScoreService}
9668         * will give a recommendation request to complete before returning a default response.
9669         *
9670         * Type: long
9671         * @hide
9672         * @deprecated to be removed
9673         */
9674        public static final String NETWORK_RECOMMENDATION_REQUEST_TIMEOUT_MS =
9675                "network_recommendation_request_timeout_ms";
9676
9677        /**
9678         * The expiration time in milliseconds for the {@link android.net.WifiKey} request cache in
9679         * {@link com.android.server.wifi.RecommendedNetworkEvaluator}.
9680         *
9681         * Type: long
9682         * @hide
9683         */
9684        public static final String RECOMMENDED_NETWORK_EVALUATOR_CACHE_EXPIRY_MS =
9685                "recommended_network_evaluator_cache_expiry_ms";
9686
9687        /**
9688        * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
9689        * connectivity.
9690        * @hide
9691        */
9692        public static final String BLE_SCAN_ALWAYS_AVAILABLE = "ble_scan_always_enabled";
9693
9694        /**
9695         * The length in milliseconds of a BLE scan window in a low-power scan mode.
9696         * @hide
9697         */
9698        public static final String BLE_SCAN_LOW_POWER_WINDOW_MS = "ble_scan_low_power_window_ms";
9699
9700        /**
9701         * The length in milliseconds of a BLE scan window in a balanced scan mode.
9702         * @hide
9703         */
9704        public static final String BLE_SCAN_BALANCED_WINDOW_MS = "ble_scan_balanced_window_ms";
9705
9706        /**
9707         * The length in milliseconds of a BLE scan window in a low-latency scan mode.
9708         * @hide
9709         */
9710        public static final String BLE_SCAN_LOW_LATENCY_WINDOW_MS =
9711                "ble_scan_low_latency_window_ms";
9712
9713        /**
9714         * The length in milliseconds of a BLE scan interval in a low-power scan mode.
9715         * @hide
9716         */
9717        public static final String BLE_SCAN_LOW_POWER_INTERVAL_MS =
9718                "ble_scan_low_power_interval_ms";
9719
9720        /**
9721         * The length in milliseconds of a BLE scan interval in a balanced scan mode.
9722         * @hide
9723         */
9724        public static final String BLE_SCAN_BALANCED_INTERVAL_MS =
9725                "ble_scan_balanced_interval_ms";
9726
9727        /**
9728         * The length in milliseconds of a BLE scan interval in a low-latency scan mode.
9729         * @hide
9730         */
9731        public static final String BLE_SCAN_LOW_LATENCY_INTERVAL_MS =
9732                "ble_scan_low_latency_interval_ms";
9733
9734        /**
9735         * The mode that BLE scanning clients will be moved to when in the background.
9736         * @hide
9737         */
9738        public static final String BLE_SCAN_BACKGROUND_MODE = "ble_scan_background_mode";
9739
9740       /**
9741        * Used to save the Wifi_ON state prior to tethering.
9742        * This state will be checked to restore Wifi after
9743        * the user turns off tethering.
9744        *
9745        * @hide
9746        */
9747       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
9748
9749       /**
9750        * The interval in milliseconds to scan as used by the wifi supplicant
9751        * @hide
9752        */
9753       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
9754               "wifi_supplicant_scan_interval_ms";
9755
9756        /**
9757         * whether frameworks handles wifi auto-join
9758         * @hide
9759         */
9760       public static final String WIFI_ENHANCED_AUTO_JOIN =
9761                "wifi_enhanced_auto_join";
9762
9763        /**
9764         * whether settings show RSSI
9765         * @hide
9766         */
9767        public static final String WIFI_NETWORK_SHOW_RSSI =
9768                "wifi_network_show_rssi";
9769
9770        /**
9771        * The interval in milliseconds to scan at supplicant when p2p is connected
9772        * @hide
9773        */
9774       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
9775               "wifi_scan_interval_p2p_connected_ms";
9776
9777       /**
9778        * Whether the Wi-Fi watchdog is enabled.
9779        */
9780       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
9781
9782       /**
9783        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
9784        * the setting needs to be set to 0 to disable it.
9785        * @hide
9786        */
9787       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
9788               "wifi_watchdog_poor_network_test_enabled";
9789
9790       private static final Validator WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR =
9791               ANY_STRING_VALIDATOR;
9792
9793       /**
9794        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
9795        * needs to be set to 0 to disable it.
9796        * @hide
9797        */
9798       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
9799               "wifi_suspend_optimizations_enabled";
9800
9801       /**
9802        * Setting to enable verbose logging in Wi-Fi; disabled by default, and setting to 1
9803        * will enable it. In the future, additional values may be supported.
9804        * @hide
9805        */
9806       public static final String WIFI_VERBOSE_LOGGING_ENABLED =
9807               "wifi_verbose_logging_enabled";
9808
9809        /**
9810         * Setting to enable connected MAC randomization in Wi-Fi; disabled by default, and
9811         * setting to 1 will enable it. In the future, additional values may be supported.
9812         * @hide
9813         */
9814        public static final String WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED =
9815                "wifi_connected_mac_randomization_enabled";
9816
9817        /**
9818         * Parameters to adjust the performance of framework wifi scoring methods.
9819         * <p>
9820         * Encoded as a comma-separated key=value list, for example:
9821         *   "rssi5=-80:-77:-70:-57,rssi2=-83:-80:-73:-60,horizon=15"
9822         * This is intended for experimenting with new parameter values,
9823         * and is normally unset or empty. The example does not include all
9824         * parameters that may be honored.
9825         * Default values are provided by code or device configurations.
9826         * Errors in the parameters will cause the entire setting to be ignored.
9827         * @hide
9828         */
9829        public static final String WIFI_SCORE_PARAMS =
9830                "wifi_score_params";
9831
9832       /**
9833        * The maximum number of times we will retry a connection to an access
9834        * point for which we have failed in acquiring an IP address from DHCP.
9835        * A value of N means that we will make N+1 connection attempts in all.
9836        */
9837       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
9838
9839       /**
9840        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
9841        * data connectivity to be established after a disconnect from Wi-Fi.
9842        */
9843       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
9844           "wifi_mobile_data_transition_wakelock_timeout_ms";
9845
9846       /**
9847        * This setting controls whether WiFi configurations created by a Device Owner app
9848        * should be locked down (that is, be editable or removable only by the Device Owner App,
9849        * not even by Settings app).
9850        * This setting takes integer values. Non-zero values mean DO created configurations
9851        * are locked down. Value of zero means they are not. Default value in the absence of
9852        * actual value to this setting is 0.
9853        */
9854       public static final String WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN =
9855               "wifi_device_owner_configs_lockdown";
9856
9857       /**
9858        * The operational wifi frequency band
9859        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
9860        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
9861        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
9862        *
9863        * @hide
9864        */
9865       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
9866
9867       /**
9868        * The Wi-Fi peer-to-peer device name
9869        * @hide
9870        */
9871       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
9872
9873       /**
9874        * The min time between wifi disable and wifi enable
9875        * @hide
9876        */
9877       public static final String WIFI_REENABLE_DELAY_MS = "wifi_reenable_delay";
9878
9879       /**
9880        * Timeout for ephemeral networks when all known BSSIDs go out of range. We will disconnect
9881        * from an ephemeral network if there is no BSSID for that network with a non-null score that
9882        * has been seen in this time period.
9883        *
9884        * If this is less than or equal to zero, we use a more conservative behavior and only check
9885        * for a non-null score from the currently connected or target BSSID.
9886        * @hide
9887        */
9888       public static final String WIFI_EPHEMERAL_OUT_OF_RANGE_TIMEOUT_MS =
9889               "wifi_ephemeral_out_of_range_timeout_ms";
9890
9891       /**
9892        * The number of milliseconds to delay when checking for data stalls during
9893        * non-aggressive detection. (screen is turned off.)
9894        * @hide
9895        */
9896       public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
9897               "data_stall_alarm_non_aggressive_delay_in_ms";
9898
9899       /**
9900        * The number of milliseconds to delay when checking for data stalls during
9901        * aggressive detection. (screen on or suspected data stall)
9902        * @hide
9903        */
9904       public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
9905               "data_stall_alarm_aggressive_delay_in_ms";
9906
9907       /**
9908        * The number of milliseconds to allow the provisioning apn to remain active
9909        * @hide
9910        */
9911       public static final String PROVISIONING_APN_ALARM_DELAY_IN_MS =
9912               "provisioning_apn_alarm_delay_in_ms";
9913
9914       /**
9915        * The interval in milliseconds at which to check gprs registration
9916        * after the first registration mismatch of gprs and voice service,
9917        * to detect possible data network registration problems.
9918        *
9919        * @hide
9920        */
9921       public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
9922               "gprs_register_check_period_ms";
9923
9924       /**
9925        * Nonzero causes Log.wtf() to crash.
9926        * @hide
9927        */
9928       public static final String WTF_IS_FATAL = "wtf_is_fatal";
9929
9930       /**
9931        * Ringer mode. This is used internally, changing this value will not
9932        * change the ringer mode. See AudioManager.
9933        */
9934       public static final String MODE_RINGER = "mode_ringer";
9935
9936       /**
9937        * Overlay display devices setting.
9938        * The associated value is a specially formatted string that describes the
9939        * size and density of simulated secondary display devices.
9940        * <p>
9941        * Format: {width}x{height}/{dpi};...
9942        * </p><p>
9943        * Example:
9944        * <ul>
9945        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
9946        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
9947        * at 1080p and the second at 720p.</li>
9948        * <li>If the value is empty, then no overlay display devices are created.</li>
9949        * </ul></p>
9950        *
9951        * @hide
9952        */
9953       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
9954
9955        /**
9956         * Threshold values for the duration and level of a discharge cycle,
9957         * under which we log discharge cycle info.
9958         *
9959         * @hide
9960         */
9961        public static final String
9962                BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold";
9963
9964        /** @hide */
9965        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
9966
9967        /**
9968         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR
9969         * intents on application crashes and ANRs. If this is disabled, the
9970         * crash/ANR dialog will never display the "Report" button.
9971         * <p>
9972         * Type: int (0 = disallow, 1 = allow)
9973         *
9974         * @hide
9975         */
9976        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
9977
9978        /**
9979         * Maximum age of entries kept by {@link DropBoxManager}.
9980         *
9981         * @hide
9982         */
9983        public static final String DROPBOX_AGE_SECONDS = "dropbox_age_seconds";
9984
9985        /**
9986         * Maximum number of entry files which {@link DropBoxManager} will keep
9987         * around.
9988         *
9989         * @hide
9990         */
9991        public static final String DROPBOX_MAX_FILES = "dropbox_max_files";
9992
9993        /**
9994         * Maximum amount of disk space used by {@link DropBoxManager} no matter
9995         * what.
9996         *
9997         * @hide
9998         */
9999        public static final String DROPBOX_QUOTA_KB = "dropbox_quota_kb";
10000
10001        /**
10002         * Percent of free disk (excluding reserve) which {@link DropBoxManager}
10003         * will use.
10004         *
10005         * @hide
10006         */
10007        public static final String DROPBOX_QUOTA_PERCENT = "dropbox_quota_percent";
10008
10009        /**
10010         * Percent of total disk which {@link DropBoxManager} will never dip
10011         * into.
10012         *
10013         * @hide
10014         */
10015        public static final String DROPBOX_RESERVE_PERCENT = "dropbox_reserve_percent";
10016
10017        /**
10018         * Prefix for per-tag dropbox disable/enable settings.
10019         *
10020         * @hide
10021         */
10022        public static final String DROPBOX_TAG_PREFIX = "dropbox:";
10023
10024        /**
10025         * Lines of logcat to include with system crash/ANR/etc. reports, as a
10026         * prefix of the dropbox tag of the report type. For example,
10027         * "logcat_for_system_server_anr" controls the lines of logcat captured
10028         * with system server ANR reports. 0 to disable.
10029         *
10030         * @hide
10031         */
10032        public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
10033
10034        /**
10035         * The interval in minutes after which the amount of free storage left
10036         * on the device is logged to the event log
10037         *
10038         * @hide
10039         */
10040        public static final String SYS_FREE_STORAGE_LOG_INTERVAL = "sys_free_storage_log_interval";
10041
10042        /**
10043         * Threshold for the amount of change in disk free space required to
10044         * report the amount of free space. Used to prevent spamming the logs
10045         * when the disk free space isn't changing frequently.
10046         *
10047         * @hide
10048         */
10049        public static final String
10050                DISK_FREE_CHANGE_REPORTING_THRESHOLD = "disk_free_change_reporting_threshold";
10051
10052        /**
10053         * Minimum percentage of free storage on the device that is used to
10054         * determine if the device is running low on storage. The default is 10.
10055         * <p>
10056         * Say this value is set to 10, the device is considered running low on
10057         * storage if 90% or more of the device storage is filled up.
10058         *
10059         * @hide
10060         */
10061        public static final String
10062                SYS_STORAGE_THRESHOLD_PERCENTAGE = "sys_storage_threshold_percentage";
10063
10064        /**
10065         * Maximum byte size of the low storage threshold. This is to ensure
10066         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in an
10067         * overly large threshold for large storage devices. Currently this must
10068         * be less than 2GB. This default is 500MB.
10069         *
10070         * @hide
10071         */
10072        public static final String
10073                SYS_STORAGE_THRESHOLD_MAX_BYTES = "sys_storage_threshold_max_bytes";
10074
10075        /**
10076         * Minimum bytes of free storage on the device before the data partition
10077         * is considered full. By default, 1 MB is reserved to avoid system-wide
10078         * SQLite disk full exceptions.
10079         *
10080         * @hide
10081         */
10082        public static final String
10083                SYS_STORAGE_FULL_THRESHOLD_BYTES = "sys_storage_full_threshold_bytes";
10084
10085        /**
10086         * Minimum percentage of storage on the device that is reserved for
10087         * cached data.
10088         *
10089         * @hide
10090         */
10091        public static final String
10092                SYS_STORAGE_CACHE_PERCENTAGE = "sys_storage_cache_percentage";
10093
10094        /**
10095         * Maximum bytes of storage on the device that is reserved for cached
10096         * data.
10097         *
10098         * @hide
10099         */
10100        public static final String
10101                SYS_STORAGE_CACHE_MAX_BYTES = "sys_storage_cache_max_bytes";
10102
10103        /**
10104         * The maximum reconnect delay for short network outages or when the
10105         * network is suspended due to phone use.
10106         *
10107         * @hide
10108         */
10109        public static final String
10110                SYNC_MAX_RETRY_DELAY_IN_SECONDS = "sync_max_retry_delay_in_seconds";
10111
10112        /**
10113         * The number of milliseconds to delay before sending out
10114         * {@link ConnectivityManager#CONNECTIVITY_ACTION} broadcasts. Ignored.
10115         *
10116         * @hide
10117         */
10118        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
10119
10120
10121        /**
10122         * Network sampling interval, in seconds. We'll generate link information
10123         * about bytes/packets sent and error rates based on data sampled in this interval
10124         *
10125         * @hide
10126         */
10127
10128        public static final String CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS =
10129                "connectivity_sampling_interval_in_seconds";
10130
10131        /**
10132         * The series of successively longer delays used in retrying to download PAC file.
10133         * Last delay is used between successful PAC downloads.
10134         *
10135         * @hide
10136         */
10137        public static final String PAC_CHANGE_DELAY = "pac_change_delay";
10138
10139        /**
10140         * Don't attempt to detect captive portals.
10141         *
10142         * @hide
10143         */
10144        public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0;
10145
10146        /**
10147         * When detecting a captive portal, display a notification that
10148         * prompts the user to sign in.
10149         *
10150         * @hide
10151         */
10152        public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1;
10153
10154        /**
10155         * When detecting a captive portal, immediately disconnect from the
10156         * network and do not reconnect to that network in the future.
10157         *
10158         * @hide
10159         */
10160        public static final int CAPTIVE_PORTAL_MODE_AVOID = 2;
10161
10162        /**
10163         * What to do when connecting a network that presents a captive portal.
10164         * Must be one of the CAPTIVE_PORTAL_MODE_* constants above.
10165         *
10166         * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT.
10167         * @hide
10168         */
10169        public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode";
10170
10171        /**
10172         * Setting to turn off captive portal detection. Feature is enabled by
10173         * default and the setting needs to be set to 0 to disable it.
10174         *
10175         * @deprecated use CAPTIVE_PORTAL_MODE_IGNORE to disable captive portal detection
10176         * @hide
10177         */
10178        @Deprecated
10179        public static final String
10180                CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled";
10181
10182        /**
10183         * The server used for captive portal detection upon a new conection. A
10184         * 204 response code from the server is used for validation.
10185         * TODO: remove this deprecated symbol.
10186         *
10187         * @hide
10188         */
10189        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
10190
10191        /**
10192         * The URL used for HTTPS captive portal detection upon a new connection.
10193         * A 204 response code from the server is used for validation.
10194         *
10195         * @hide
10196         */
10197        public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url";
10198
10199        /**
10200         * The URL used for HTTP captive portal detection upon a new connection.
10201         * A 204 response code from the server is used for validation.
10202         *
10203         * @hide
10204         */
10205        public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url";
10206
10207        /**
10208         * The URL used for fallback HTTP captive portal detection when previous HTTP
10209         * and HTTPS captive portal detection attemps did not return a conclusive answer.
10210         *
10211         * @hide
10212         */
10213        public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url";
10214
10215        /**
10216         * A comma separated list of URLs used for captive portal detection in addition to the
10217         * fallback HTTP url associated with the CAPTIVE_PORTAL_FALLBACK_URL settings.
10218         *
10219         * @hide
10220         */
10221        public static final String CAPTIVE_PORTAL_OTHER_FALLBACK_URLS =
10222                "captive_portal_other_fallback_urls";
10223
10224        /**
10225         * Whether to use HTTPS for network validation. This is enabled by default and the setting
10226         * needs to be set to 0 to disable it. This setting is a misnomer because captive portals
10227         * don't actually use HTTPS, but it's consistent with the other settings.
10228         *
10229         * @hide
10230         */
10231        public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https";
10232
10233        /**
10234         * Which User-Agent string to use in the header of the captive portal detection probes.
10235         * The User-Agent field is unset when this setting has no value (HttpUrlConnection default).
10236         *
10237         * @hide
10238         */
10239        public static final String CAPTIVE_PORTAL_USER_AGENT = "captive_portal_user_agent";
10240
10241        /**
10242         * Whether network service discovery is enabled.
10243         *
10244         * @hide
10245         */
10246        public static final String NSD_ON = "nsd_on";
10247
10248        /**
10249         * Let user pick default install location.
10250         *
10251         * @hide
10252         */
10253        public static final String SET_INSTALL_LOCATION = "set_install_location";
10254
10255        /**
10256         * Default install location value.
10257         * 0 = auto, let system decide
10258         * 1 = internal
10259         * 2 = sdcard
10260         * @hide
10261         */
10262        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
10263
10264        /**
10265         * ms during which to consume extra events related to Inet connection
10266         * condition after a transtion to fully-connected
10267         *
10268         * @hide
10269         */
10270        public static final String
10271                INET_CONDITION_DEBOUNCE_UP_DELAY = "inet_condition_debounce_up_delay";
10272
10273        /**
10274         * ms during which to consume extra events related to Inet connection
10275         * condtion after a transtion to partly-connected
10276         *
10277         * @hide
10278         */
10279        public static final String
10280                INET_CONDITION_DEBOUNCE_DOWN_DELAY = "inet_condition_debounce_down_delay";
10281
10282        /** {@hide} */
10283        public static final String
10284                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
10285
10286        /**
10287         * Host name and port for global http proxy. Uses ':' seperator for
10288         * between host and port.
10289         */
10290        public static final String HTTP_PROXY = "http_proxy";
10291
10292        /**
10293         * Host name for global http proxy. Set via ConnectivityManager.
10294         *
10295         * @hide
10296         */
10297        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
10298
10299        /**
10300         * Integer host port for global http proxy. Set via ConnectivityManager.
10301         *
10302         * @hide
10303         */
10304        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
10305
10306        /**
10307         * Exclusion list for global proxy. This string contains a list of
10308         * comma-separated domains where the global proxy does not apply.
10309         * Domains should be listed in a comma- separated list. Example of
10310         * acceptable formats: ".domain1.com,my.domain2.com" Use
10311         * ConnectivityManager to set/get.
10312         *
10313         * @hide
10314         */
10315        public static final String
10316                GLOBAL_HTTP_PROXY_EXCLUSION_LIST = "global_http_proxy_exclusion_list";
10317
10318        /**
10319         * The location PAC File for the proxy.
10320         * @hide
10321         */
10322        public static final String
10323                GLOBAL_HTTP_PROXY_PAC = "global_proxy_pac_url";
10324
10325        /**
10326         * Enables the UI setting to allow the user to specify the global HTTP
10327         * proxy and associated exclusion list.
10328         *
10329         * @hide
10330         */
10331        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
10332
10333        /**
10334         * Setting for default DNS in case nobody suggests one
10335         *
10336         * @hide
10337         */
10338        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
10339
10340        /**
10341         * The requested Private DNS mode (string), and an accompanying specifier (string).
10342         *
10343         * Currently, the specifier holds the chosen provider name when the mode requests
10344         * a specific provider. It may be used to store the provider name even when the
10345         * mode changes so that temporarily disabling and re-enabling the specific
10346         * provider mode does not necessitate retyping the provider hostname.
10347         *
10348         * @hide
10349         */
10350        public static final String PRIVATE_DNS_MODE = "private_dns_mode";
10351
10352        private static final Validator PRIVATE_DNS_MODE_VALIDATOR = ANY_STRING_VALIDATOR;
10353
10354        /**
10355         * @hide
10356         */
10357        public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier";
10358
10359        private static final Validator PRIVATE_DNS_SPECIFIER_VALIDATOR = ANY_STRING_VALIDATOR;
10360
10361        /**
10362          * Forced override of the default mode (hardcoded as "automatic", nee "opportunistic").
10363          * This allows changing the default mode without effectively disabling other modes,
10364          * all of which require explicit user action to enable/configure. See also b/79719289.
10365          *
10366          * Value is a string, suitable for assignment to PRIVATE_DNS_MODE above.
10367          *
10368          * {@hide}
10369          */
10370        public static final String PRIVATE_DNS_DEFAULT_MODE = "private_dns_default_mode";
10371
10372        /** {@hide} */
10373        public static final String
10374                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
10375        /** {@hide} */
10376        public static final String
10377                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
10378        /** {@hide} */
10379        public static final String
10380                BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX = "bluetooth_a2dp_src_priority_";
10381        /** {@hide} */
10382        public static final String BLUETOOTH_A2DP_SUPPORTS_OPTIONAL_CODECS_PREFIX =
10383                "bluetooth_a2dp_supports_optional_codecs_";
10384        /** {@hide} */
10385        public static final String BLUETOOTH_A2DP_OPTIONAL_CODECS_ENABLED_PREFIX =
10386                "bluetooth_a2dp_optional_codecs_enabled_";
10387        /** {@hide} */
10388        public static final String
10389                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
10390        /** {@hide} */
10391        public static final String
10392                BLUETOOTH_MAP_PRIORITY_PREFIX = "bluetooth_map_priority_";
10393        /** {@hide} */
10394        public static final String
10395                BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX = "bluetooth_map_client_priority_";
10396        /** {@hide} */
10397        public static final String
10398                BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX = "bluetooth_pbap_client_priority_";
10399        /** {@hide} */
10400        public static final String
10401                BLUETOOTH_SAP_PRIORITY_PREFIX = "bluetooth_sap_priority_";
10402        /** {@hide} */
10403        public static final String
10404                BLUETOOTH_PAN_PRIORITY_PREFIX = "bluetooth_pan_priority_";
10405        /** {@hide} */
10406        public static final String
10407                BLUETOOTH_HEARING_AID_PRIORITY_PREFIX = "bluetooth_hearing_aid_priority_";
10408
10409        /**
10410         * Activity manager specific settings.
10411         * This is encoded as a key=value list, separated by commas. Ex:
10412         *
10413         * "gc_timeout=5000,max_cached_processes=24"
10414         *
10415         * The following keys are supported:
10416         *
10417         * <pre>
10418         * max_cached_processes                 (int)
10419         * background_settle_time               (long)
10420         * fgservice_min_shown_time             (long)
10421         * fgservice_min_report_time            (long)
10422         * fgservice_screen_on_before_time      (long)
10423         * fgservice_screen_on_after_time       (long)
10424         * content_provider_retain_time         (long)
10425         * gc_timeout                           (long)
10426         * gc_min_interval                      (long)
10427         * full_pss_min_interval                (long)
10428         * full_pss_lowered_interval            (long)
10429         * power_check_interval                 (long)
10430         * power_check_max_cpu_1                (int)
10431         * power_check_max_cpu_2                (int)
10432         * power_check_max_cpu_3                (int)
10433         * power_check_max_cpu_4                (int)
10434         * service_usage_interaction_time       (long)
10435         * usage_stats_interaction_interval     (long)
10436         * service_restart_duration             (long)
10437         * service_reset_run_duration           (long)
10438         * service_restart_duration_factor      (int)
10439         * service_min_restart_time_between     (long)
10440         * service_max_inactivity               (long)
10441         * service_bg_start_timeout             (long)
10442         * process_start_async                  (boolean)
10443         * </pre>
10444         *
10445         * <p>
10446         * Type: string
10447         * @hide
10448         * @see com.android.server.am.ActivityManagerConstants
10449         */
10450        public static final String ACTIVITY_MANAGER_CONSTANTS = "activity_manager_constants";
10451
10452        /**
10453         * App ops specific settings.
10454         * This is encoded as a key=value list, separated by commas. Ex:
10455         *
10456         * "state_settle_time=10000"
10457         *
10458         * The following keys are supported:
10459         *
10460         * <pre>
10461         * top_state_settle_time                (long)
10462         * fg_service_state_settle_time         (long)
10463         * bg_state_settle_time                 (long)
10464         * </pre>
10465         *
10466         * <p>
10467         * Type: string
10468         * @hide
10469         * @see com.android.server.AppOpsService.Constants
10470         */
10471        public static final String APP_OPS_CONSTANTS = "app_ops_constants";
10472
10473        /**
10474         * Device Idle (Doze) specific settings.
10475         * This is encoded as a key=value list, separated by commas. Ex:
10476         *
10477         * "inactive_to=60000,sensing_to=400000"
10478         *
10479         * The following keys are supported:
10480         *
10481         * <pre>
10482         * inactive_to                      (long)
10483         * sensing_to                       (long)
10484         * motion_inactive_to               (long)
10485         * idle_after_inactive_to           (long)
10486         * idle_pending_to                  (long)
10487         * max_idle_pending_to              (long)
10488         * idle_pending_factor              (float)
10489         * idle_to                          (long)
10490         * max_idle_to                      (long)
10491         * idle_factor                      (float)
10492         * min_time_to_alarm                (long)
10493         * max_temp_app_whitelist_duration  (long)
10494         * notification_whitelist_duration  (long)
10495         * </pre>
10496         *
10497         * <p>
10498         * Type: string
10499         * @hide
10500         * @see com.android.server.DeviceIdleController.Constants
10501         */
10502        public static final String DEVICE_IDLE_CONSTANTS = "device_idle_constants";
10503
10504        /**
10505         * Battery Saver specific settings
10506         * This is encoded as a key=value list, separated by commas. Ex:
10507         *
10508         * "vibration_disabled=true,adjust_brightness_factor=0.5"
10509         *
10510         * The following keys are supported:
10511         *
10512         * <pre>
10513         * vibration_disabled                (boolean)
10514         * animation_disabled                (boolean)
10515         * soundtrigger_disabled             (boolean)
10516         * fullbackup_deferred               (boolean)
10517         * keyvaluebackup_deferred           (boolean)
10518         * firewall_disabled                 (boolean)
10519         * gps_mode                          (int)
10520         * adjust_brightness_disabled        (boolean)
10521         * adjust_brightness_factor          (float)
10522         * </pre>
10523         * @hide
10524         * @see com.android.server.power.BatterySaverPolicy
10525         */
10526        public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";
10527
10528        /**
10529         * Battery Saver device specific settings
10530         * This is encoded as a key=value list, separated by commas.
10531         * See {@link com.android.server.power.BatterySaverPolicy} for the details.
10532         *
10533         * @hide
10534         */
10535        public static final String BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS =
10536                "battery_saver_device_specific_constants";
10537
10538        /**
10539         * Battery tip specific settings
10540         * This is encoded as a key=value list, separated by commas. Ex:
10541         *
10542         * "battery_tip_enabled=true,summary_enabled=true,high_usage_enabled=true,"
10543         * "high_usage_app_count=3,reduced_battery_enabled=false,reduced_battery_percent=50,"
10544         * "high_usage_battery_draining=25,high_usage_period_ms=3000"
10545         *
10546         * The following keys are supported:
10547         *
10548         * <pre>
10549         * battery_tip_enabled              (boolean)
10550         * summary_enabled                  (boolean)
10551         * battery_saver_tip_enabled        (boolean)
10552         * high_usage_enabled               (boolean)
10553         * high_usage_app_count             (int)
10554         * high_usage_period_ms             (long)
10555         * high_usage_battery_draining      (int)
10556         * app_restriction_enabled          (boolean)
10557         * reduced_battery_enabled          (boolean)
10558         * reduced_battery_percent          (int)
10559         * low_battery_enabled              (boolean)
10560         * low_battery_hour                 (int)
10561         * </pre>
10562         * @hide
10563         */
10564        public static final String BATTERY_TIP_CONSTANTS = "battery_tip_constants";
10565
10566        /**
10567         * Battery anomaly detection specific settings
10568         * This is encoded as a key=value list, separated by commas.
10569         * wakeup_blacklisted_tags is a string, encoded as a set of tags, encoded via
10570         * {@link Uri#encode(String)}, separated by colons. Ex:
10571         *
10572         * "anomaly_detection_enabled=true,wakelock_threshold=2000,wakeup_alarm_enabled=true,"
10573         * "wakeup_alarm_threshold=10,wakeup_blacklisted_tags=tag1:tag2:with%2Ccomma:with%3Acolon"
10574         *
10575         * The following keys are supported:
10576         *
10577         * <pre>
10578         * anomaly_detection_enabled       (boolean)
10579         * wakelock_enabled                (boolean)
10580         * wakelock_threshold              (long)
10581         * wakeup_alarm_enabled            (boolean)
10582         * wakeup_alarm_threshold          (long)
10583         * wakeup_blacklisted_tags         (string)
10584         * bluetooth_scan_enabled          (boolean)
10585         * bluetooth_scan_threshold        (long)
10586         * </pre>
10587         * @hide
10588         */
10589        public static final String ANOMALY_DETECTION_CONSTANTS = "anomaly_detection_constants";
10590
10591        /**
10592         * An integer to show the version of the anomaly config. Ex: 1, which means
10593         * current version is 1.
10594         * @hide
10595         */
10596        public static final String ANOMALY_CONFIG_VERSION = "anomaly_config_version";
10597
10598        /**
10599         * A base64-encoded string represents anomaly stats config, used for
10600         * {@link android.app.StatsManager}.
10601         * @hide
10602         */
10603        public static final String ANOMALY_CONFIG = "anomaly_config";
10604
10605        /**
10606         * Always on display(AOD) specific settings
10607         * This is encoded as a key=value list, separated by commas. Ex:
10608         *
10609         * "prox_screen_off_delay=10000,screen_brightness_array=0:1:2:3:4"
10610         *
10611         * The following keys are supported:
10612         *
10613         * <pre>
10614         * screen_brightness_array         (int[])
10615         * dimming_scrim_array             (int[])
10616         * prox_screen_off_delay           (long)
10617         * prox_cooldown_trigger           (long)
10618         * prox_cooldown_period            (long)
10619         * </pre>
10620         * @hide
10621         */
10622        public static final String ALWAYS_ON_DISPLAY_CONSTANTS = "always_on_display_constants";
10623
10624        /**
10625        * System VDSO global setting. This links to the "sys.vdso" system property.
10626        * The following values are supported:
10627        * false  -> both 32 and 64 bit vdso disabled
10628        * 32     -> 32 bit vdso enabled
10629        * 64     -> 64 bit vdso enabled
10630        * Any other value defaults to both 32 bit and 64 bit true.
10631        * @hide
10632        */
10633        public static final String SYS_VDSO = "sys_vdso";
10634
10635        /**
10636        * UidCpuPower global setting. This links the sys.uidcpupower system property.
10637        * The following values are supported:
10638        * 0 -> /proc/uid_cpupower/* are disabled
10639        * 1 -> /proc/uid_cpupower/* are enabled
10640        * Any other value defaults to enabled.
10641        * @hide
10642        */
10643        public static final String SYS_UIDCPUPOWER = "sys_uidcpupower";
10644
10645        /**
10646        * traced global setting. This controls weather the deamons: traced and
10647        * traced_probes run. This links the sys.traced system property.
10648        * The following values are supported:
10649        * 0 -> traced and traced_probes are disabled
10650        * 1 -> traced and traced_probes are enabled
10651        * Any other value defaults to disabled.
10652        * @hide
10653        */
10654        public static final String SYS_TRACED = "sys_traced";
10655
10656        /**
10657         * An integer to reduce the FPS by this factor. Only for experiments. Need to reboot the
10658         * device for this setting to take full effect.
10659         *
10660         * @hide
10661         */
10662        public static final String FPS_DEVISOR = "fps_divisor";
10663
10664        /**
10665         * Flag to enable or disable display panel low power mode (lpm)
10666         * false -> Display panel power saving mode is disabled.
10667         * true  -> Display panel power saving mode is enabled.
10668         *
10669         * @hide
10670         */
10671        public static final String DISPLAY_PANEL_LPM = "display_panel_lpm";
10672
10673        /**
10674         * App standby (app idle) specific settings.
10675         * This is encoded as a key=value list, separated by commas. Ex:
10676         * <p>
10677         * "idle_duration=5000,parole_interval=4500,screen_thresholds=0/0/60000/120000"
10678         * <p>
10679         * All durations are in millis.
10680         * Array values are separated by forward slashes
10681         * The following keys are supported:
10682         *
10683         * <pre>
10684         * parole_interval                  (long)
10685         * parole_window                    (long)
10686         * parole_duration                  (long)
10687         * screen_thresholds                (long[4])
10688         * elapsed_thresholds               (long[4])
10689         * strong_usage_duration            (long)
10690         * notification_seen_duration       (long)
10691         * system_update_usage_duration     (long)
10692         * prediction_timeout               (long)
10693         * sync_adapter_duration            (long)
10694         * exempted_sync_duration           (long)
10695         * system_interaction_duration      (long)
10696         * stable_charging_threshold        (long)
10697         *
10698         * idle_duration        (long) // This is deprecated and used to circumvent b/26355386.
10699         * idle_duration2       (long) // deprecated
10700         * wallclock_threshold  (long) // deprecated
10701         * </pre>
10702         *
10703         * <p>
10704         * Type: string
10705         * @hide
10706         * @see com.android.server.usage.UsageStatsService.SettingsObserver
10707         */
10708        public static final String APP_IDLE_CONSTANTS = "app_idle_constants";
10709
10710        /**
10711         * Power manager specific settings.
10712         * This is encoded as a key=value list, separated by commas. Ex:
10713         *
10714         * "no_cached_wake_locks=1"
10715         *
10716         * The following keys are supported:
10717         *
10718         * <pre>
10719         * no_cached_wake_locks                 (boolean)
10720         * </pre>
10721         *
10722         * <p>
10723         * Type: string
10724         * @hide
10725         * @see com.android.server.power.PowerManagerConstants
10726         */
10727        public static final String POWER_MANAGER_CONSTANTS = "power_manager_constants";
10728
10729        /**
10730         * Alarm manager specific settings.
10731         * This is encoded as a key=value list, separated by commas. Ex:
10732         *
10733         * "min_futurity=5000,allow_while_idle_short_time=4500"
10734         *
10735         * The following keys are supported:
10736         *
10737         * <pre>
10738         * min_futurity                         (long)
10739         * min_interval                         (long)
10740         * allow_while_idle_short_time          (long)
10741         * allow_while_idle_long_time           (long)
10742         * allow_while_idle_whitelist_duration  (long)
10743         * </pre>
10744         *
10745         * <p>
10746         * Type: string
10747         * @hide
10748         * @see com.android.server.AlarmManagerService.Constants
10749         */
10750        public static final String ALARM_MANAGER_CONSTANTS = "alarm_manager_constants";
10751
10752        /**
10753         * Job scheduler specific settings.
10754         * This is encoded as a key=value list, separated by commas. Ex:
10755         *
10756         * "min_ready_jobs_count=2,moderate_use_factor=.5"
10757         *
10758         * The following keys are supported:
10759         *
10760         * <pre>
10761         * min_idle_count                       (int)
10762         * min_charging_count                   (int)
10763         * min_connectivity_count               (int)
10764         * min_content_count                    (int)
10765         * min_ready_jobs_count                 (int)
10766         * heavy_use_factor                     (float)
10767         * moderate_use_factor                  (float)
10768         * fg_job_count                         (int)
10769         * bg_normal_job_count                  (int)
10770         * bg_moderate_job_count                (int)
10771         * bg_low_job_count                     (int)
10772         * bg_critical_job_count                (int)
10773         * </pre>
10774         *
10775         * <p>
10776         * Type: string
10777         * @hide
10778         * @see com.android.server.job.JobSchedulerService.Constants
10779         */
10780        public static final String JOB_SCHEDULER_CONSTANTS = "job_scheduler_constants";
10781
10782        /**
10783         * ShortcutManager specific settings.
10784         * This is encoded as a key=value list, separated by commas. Ex:
10785         *
10786         * "reset_interval_sec=86400,max_updates_per_interval=1"
10787         *
10788         * The following keys are supported:
10789         *
10790         * <pre>
10791         * reset_interval_sec              (long)
10792         * max_updates_per_interval        (int)
10793         * max_icon_dimension_dp           (int, DP)
10794         * max_icon_dimension_dp_lowram    (int, DP)
10795         * max_shortcuts                   (int)
10796         * icon_quality                    (int, 0-100)
10797         * icon_format                     (String)
10798         * </pre>
10799         *
10800         * <p>
10801         * Type: string
10802         * @hide
10803         * @see com.android.server.pm.ShortcutService.ConfigConstants
10804         */
10805        public static final String SHORTCUT_MANAGER_CONSTANTS = "shortcut_manager_constants";
10806
10807        /**
10808         * DevicePolicyManager specific settings.
10809         * This is encoded as a key=value list, separated by commas. Ex:
10810         *
10811         * <pre>
10812         * das_died_service_reconnect_backoff_sec       (long)
10813         * das_died_service_reconnect_backoff_increase  (float)
10814         * das_died_service_reconnect_max_backoff_sec   (long)
10815         * </pre>
10816         *
10817         * <p>
10818         * Type: string
10819         * @hide
10820         * see also com.android.server.devicepolicy.DevicePolicyConstants
10821         */
10822        public static final String DEVICE_POLICY_CONSTANTS = "device_policy_constants";
10823
10824        /**
10825         * TextClassifier specific settings.
10826         * This is encoded as a key=value list, separated by commas. String[] types like
10827         * entity_list_default use ":" as delimiter for values. Ex:
10828         *
10829         * <pre>
10830         * smart_linkify_enabled                    (boolean)
10831         * system_textclassifier_enabled            (boolean)
10832         * model_dark_launch_enabled                (boolean)
10833         * smart_selection_enabled                  (boolean)
10834         * smart_text_share_enabled                 (boolean)
10835         * smart_linkify_enabled                    (boolean)
10836         * smart_select_animation_enabled           (boolean)
10837         * suggest_selection_max_range_length       (int)
10838         * classify_text_max_range_length           (int)
10839         * generate_links_max_text_length           (int)
10840         * generate_links_log_sample_rate           (int)
10841         * entity_list_default                      (String[])
10842         * entity_list_not_editable                 (String[])
10843         * entity_list_editable                     (String[])
10844         * </pre>
10845         *
10846         * <p>
10847         * Type: string
10848         * @hide
10849         * see also android.view.textclassifier.TextClassificationConstants
10850         */
10851        public static final String TEXT_CLASSIFIER_CONSTANTS = "text_classifier_constants";
10852
10853        /**
10854         * BatteryStats specific settings.
10855         * This is encoded as a key=value list, separated by commas. Ex: "foo=1,bar=true"
10856         *
10857         * The following keys are supported:
10858         * <pre>
10859         * track_cpu_times_by_proc_state (boolean)
10860         * track_cpu_active_cluster_time (boolean)
10861         * read_binary_cpu_time          (boolean)
10862         * proc_state_cpu_times_read_delay_ms (long)
10863         * external_stats_collection_rate_limit_ms (long)
10864         * battery_level_collection_delay_ms (long)
10865         * </pre>
10866         *
10867         * <p>
10868         * Type: string
10869         * @hide
10870         * see also com.android.internal.os.BatteryStatsImpl.Constants
10871         */
10872        public static final String BATTERY_STATS_CONSTANTS = "battery_stats_constants";
10873
10874        /**
10875         * SyncManager specific settings.
10876         *
10877         * <p>
10878         * Type: string
10879         * @hide
10880         * @see com.android.server.content.SyncManagerConstants
10881         */
10882        public static final String SYNC_MANAGER_CONSTANTS = "sync_manager_constants";
10883
10884        /**
10885         * Whether or not App Standby feature is enabled by system. This controls throttling of apps
10886         * based on usage patterns and predictions. Platform will turn on this feature if both this
10887         * flag and {@link #ADAPTIVE_BATTERY_MANAGEMENT_ENABLED} is on.
10888         * Type: int (0 for false, 1 for true)
10889         * Default: 1
10890         * @hide
10891         * @see #ADAPTIVE_BATTERY_MANAGEMENT_ENABLED
10892         */
10893        public static final String APP_STANDBY_ENABLED = "app_standby_enabled";
10894
10895        /**
10896         * Whether or not adaptive battery feature is enabled by user. Platform will turn on this
10897         * feature if both this flag and {@link #APP_STANDBY_ENABLED} is on.
10898         * Type: int (0 for false, 1 for true)
10899         * Default: 1
10900         * @hide
10901         * @see #APP_STANDBY_ENABLED
10902         */
10903        public static final String ADAPTIVE_BATTERY_MANAGEMENT_ENABLED =
10904                "adaptive_battery_management_enabled";
10905
10906        /**
10907         * Whether or not app auto restriction is enabled. When it is enabled, settings app will
10908         * auto restrict the app if it has bad behavior(e.g. hold wakelock for long time).
10909         *
10910         * Type: boolean (0 for false, 1 for true)
10911         * Default: 1
10912         *
10913         * @hide
10914         */
10915        public static final String APP_AUTO_RESTRICTION_ENABLED =
10916                "app_auto_restriction_enabled";
10917
10918        private static final Validator APP_AUTO_RESTRICTION_ENABLED_VALIDATOR =
10919                BOOLEAN_VALIDATOR;
10920
10921        /**
10922         * Feature flag to enable or disable the Forced App Standby feature.
10923         * Type: int (0 for false, 1 for true)
10924         * Default: 1
10925         * @hide
10926         */
10927        public static final String FORCED_APP_STANDBY_ENABLED = "forced_app_standby_enabled";
10928
10929        /**
10930         * Whether or not to enable Forced App Standby on small battery devices.
10931         * Type: int (0 for false, 1 for true)
10932         * Default: 0
10933         * @hide
10934         */
10935        public static final String FORCED_APP_STANDBY_FOR_SMALL_BATTERY_ENABLED
10936                = "forced_app_standby_for_small_battery_enabled";
10937
10938        /**
10939         * Whether or not to enable the User Absent, Radios Off feature on small battery devices.
10940         * Type: int (0 for false, 1 for true)
10941         * Default: 0
10942         * @hide
10943         */
10944        public static final String USER_ABSENT_RADIOS_OFF_FOR_SMALL_BATTERY_ENABLED
10945                = "user_absent_radios_off_for_small_battery_enabled";
10946
10947        /**
10948         * Whether or not to turn on Wifi when proxy is disconnected.
10949         * Type: int (0 for false, 1 for true)
10950         * Default: 1
10951         * @hide
10952         */
10953        public static final String WIFI_ON_WHEN_PROXY_DISCONNECTED
10954                = "wifi_on_when_proxy_disconnected";
10955
10956        /**
10957         * Time Only Mode specific settings.
10958         * This is encoded as a key=value list, separated by commas. Ex: "foo=1,bar=true"
10959         *
10960         * The following keys are supported:
10961         *
10962         * <pre>
10963         * enabled                  (boolean)
10964         * disable_tilt_to_wake     (boolean)
10965         * disable_touch_to_wake    (boolean)
10966         * </pre>
10967         * Type: string
10968         * @hide
10969         */
10970        public static final String TIME_ONLY_MODE_CONSTANTS
10971                = "time_only_mode_constants";
10972
10973        /**
10974         * Whether of not to send keycode sleep for ungaze when Home is the foreground activity on
10975         * watch type devices.
10976         * Type: int (0 for false, 1 for true)
10977         * Default: 0
10978         * @hide
10979         */
10980        public static final String UNGAZE_SLEEP_ENABLED = "ungaze_sleep_enabled";
10981
10982        /**
10983         * Whether or not Network Watchlist feature is enabled.
10984         * Type: int (0 for false, 1 for true)
10985         * Default: 0
10986         * @hide
10987         */
10988        public static final String NETWORK_WATCHLIST_ENABLED = "network_watchlist_enabled";
10989
10990        /**
10991         * Flag to keep background restricted profiles running after exiting. If disabled,
10992         * the restricted profile can be put into stopped state as soon as the user leaves it.
10993         * Type: int (0 for false, 1 for true)
10994         *
10995         * Overridden by the system based on device information. If null, the value specified
10996         * by {@code config_keepRestrictedProfilesInBackground} is used.
10997         *
10998         * @hide
10999         */
11000        public static final String KEEP_PROFILE_IN_BACKGROUND = "keep_profile_in_background";
11001
11002        /**
11003         * Get the key that retrieves a bluetooth headset's priority.
11004         * @hide
11005         */
11006        public static final String getBluetoothHeadsetPriorityKey(String address) {
11007            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11008        }
11009
11010        /**
11011         * Get the key that retrieves a bluetooth a2dp sink's priority.
11012         * @hide
11013         */
11014        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
11015            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11016        }
11017
11018        /**
11019         * Get the key that retrieves a bluetooth a2dp src's priority.
11020         * @hide
11021         */
11022        public static final String getBluetoothA2dpSrcPriorityKey(String address) {
11023            return BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11024        }
11025
11026        /**
11027         * Get the key that retrieves a bluetooth a2dp device's ability to support optional codecs.
11028         * @hide
11029         */
11030        public static final String getBluetoothA2dpSupportsOptionalCodecsKey(String address) {
11031            return BLUETOOTH_A2DP_SUPPORTS_OPTIONAL_CODECS_PREFIX +
11032                    address.toUpperCase(Locale.ROOT);
11033        }
11034
11035        /**
11036         * Get the key that retrieves whether a bluetooth a2dp device should have optional codecs
11037         * enabled.
11038         * @hide
11039         */
11040        public static final String getBluetoothA2dpOptionalCodecsEnabledKey(String address) {
11041            return BLUETOOTH_A2DP_OPTIONAL_CODECS_ENABLED_PREFIX +
11042                    address.toUpperCase(Locale.ROOT);
11043        }
11044
11045        /**
11046         * Get the key that retrieves a bluetooth Input Device's priority.
11047         * @hide
11048         */
11049        public static final String getBluetoothHidHostPriorityKey(String address) {
11050            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11051        }
11052
11053        /**
11054         * Get the key that retrieves a bluetooth pan client priority.
11055         * @hide
11056         */
11057        public static final String getBluetoothPanPriorityKey(String address) {
11058            return BLUETOOTH_PAN_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11059        }
11060
11061        /**
11062         * Get the key that retrieves a bluetooth hearing aid priority.
11063         * @hide
11064         */
11065        public static final String getBluetoothHearingAidPriorityKey(String address) {
11066            return BLUETOOTH_HEARING_AID_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11067        }
11068
11069        /**
11070         * Get the key that retrieves a bluetooth map priority.
11071         * @hide
11072         */
11073        public static final String getBluetoothMapPriorityKey(String address) {
11074            return BLUETOOTH_MAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11075        }
11076
11077        /**
11078         * Get the key that retrieves a bluetooth map client priority.
11079         * @hide
11080         */
11081        public static final String getBluetoothMapClientPriorityKey(String address) {
11082            return BLUETOOTH_MAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11083        }
11084
11085        /**
11086         * Get the key that retrieves a bluetooth pbap client priority.
11087         * @hide
11088         */
11089        public static final String getBluetoothPbapClientPriorityKey(String address) {
11090            return BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11091        }
11092
11093        /**
11094         * Get the key that retrieves a bluetooth sap priority.
11095         * @hide
11096         */
11097        public static final String getBluetoothSapPriorityKey(String address) {
11098            return BLUETOOTH_SAP_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
11099        }
11100
11101        /**
11102         * Scaling factor for normal window animations. Setting to 0 will
11103         * disable window animations.
11104         */
11105        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
11106
11107        /**
11108         * Scaling factor for activity transition animations. Setting to 0 will
11109         * disable window animations.
11110         */
11111        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
11112
11113        /**
11114         * Scaling factor for Animator-based animations. This affects both the
11115         * start delay and duration of all such animations. Setting to 0 will
11116         * cause animations to end immediately. The default value is 1.
11117         */
11118        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
11119
11120        /**
11121         * Scaling factor for normal window animations. Setting to 0 will
11122         * disable window animations.
11123         *
11124         * @hide
11125         */
11126        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
11127
11128        /**
11129         * If 0, the compatibility mode is off for all applications.
11130         * If 1, older applications run under compatibility mode.
11131         * TODO: remove this settings before code freeze (bug/1907571)
11132         * @hide
11133         */
11134        public static final String COMPATIBILITY_MODE = "compatibility_mode";
11135
11136        /**
11137         * CDMA only settings
11138         * Emergency Tone  0 = Off
11139         *                 1 = Alert
11140         *                 2 = Vibrate
11141         * @hide
11142         */
11143        public static final String EMERGENCY_TONE = "emergency_tone";
11144
11145        private static final Validator EMERGENCY_TONE_VALIDATOR =
11146                new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1", "2"});
11147
11148        /**
11149         * CDMA only settings
11150         * Whether the auto retry is enabled. The value is
11151         * boolean (1 or 0).
11152         * @hide
11153         */
11154        public static final String CALL_AUTO_RETRY = "call_auto_retry";
11155
11156        private static final Validator CALL_AUTO_RETRY_VALIDATOR = BOOLEAN_VALIDATOR;
11157
11158        /**
11159         * A setting that can be read whether the emergency affordance is currently needed.
11160         * The value is a boolean (1 or 0).
11161         * @hide
11162         */
11163        public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed";
11164
11165        /**
11166         * See RIL_PreferredNetworkType in ril.h
11167         * @hide
11168         */
11169        public static final String PREFERRED_NETWORK_MODE =
11170                "preferred_network_mode";
11171
11172        /**
11173         * Name of an application package to be debugged.
11174         */
11175        public static final String DEBUG_APP = "debug_app";
11176
11177        /**
11178         * If 1, when launching DEBUG_APP it will wait for the debugger before
11179         * starting user code.  If 0, it will run normally.
11180         */
11181        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
11182
11183        /**
11184         * Allow GPU debug layers?
11185         * 0 = no
11186         * 1 = yes
11187         * @hide
11188         */
11189        public static final String ENABLE_GPU_DEBUG_LAYERS = "enable_gpu_debug_layers";
11190
11191        /**
11192         * App allowed to load GPU debug layers
11193         * @hide
11194         */
11195        public static final String GPU_DEBUG_APP = "gpu_debug_app";
11196
11197        /**
11198         * Ordered GPU debug layer list
11199         * i.e. <layer1>:<layer2>:...:<layerN>
11200         * @hide
11201         */
11202        public static final String GPU_DEBUG_LAYERS = "gpu_debug_layers";
11203
11204        /**
11205         * Control whether the process CPU usage meter should be shown.
11206         *
11207         * @deprecated This functionality is no longer available as of
11208         * {@link android.os.Build.VERSION_CODES#N_MR1}.
11209         */
11210        @Deprecated
11211        public static final String SHOW_PROCESSES = "show_processes";
11212
11213        /**
11214         * If 1 low power mode (aka battery saver) is enabled.
11215         * @hide
11216         */
11217        @TestApi
11218        public static final String LOW_POWER_MODE = "low_power";
11219
11220        /**
11221         * If 1, battery saver ({@link #LOW_POWER_MODE}) will be re-activated after the device
11222         * is unplugged from a charger or rebooted.
11223         * @hide
11224         */
11225        @TestApi
11226        public static final String LOW_POWER_MODE_STICKY = "low_power_sticky";
11227
11228        /**
11229         * Battery level [1-100] at which low power mode automatically turns on.
11230         * If 0, it will not automatically turn on.
11231         * @hide
11232         */
11233        public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level";
11234
11235        private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR =
11236                new SettingsValidators.InclusiveIntegerRangeValidator(0, 100);
11237
11238
11239        /**
11240         * The max value for {@link #LOW_POWER_MODE_TRIGGER_LEVEL}. If this setting is not set
11241         * or the value is 0, the default max will be used.
11242         *
11243         * @hide
11244         */
11245        public static final String LOW_POWER_MODE_TRIGGER_LEVEL_MAX = "low_power_trigger_level_max";
11246
11247        /**
11248         * See com.android.settingslib.fuelgauge.BatterySaverUtils.
11249         * @hide
11250         */
11251        public static final String LOW_POWER_MODE_SUGGESTION_PARAMS =
11252                "low_power_mode_suggestion_params";
11253
11254        /**
11255         * If not 0, the activity manager will aggressively finish activities and
11256         * processes as soon as they are no longer needed.  If 0, the normal
11257         * extended lifetime is used.
11258         */
11259        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
11260
11261        /**
11262         * If nonzero, all system error dialogs will be hidden.  For example, the
11263         * crash and ANR dialogs will not be shown, and the system will just proceed
11264         * as if they had been accepted by the user.
11265         * @hide
11266         */
11267        public static final String HIDE_ERROR_DIALOGS = "hide_error_dialogs";
11268
11269        /**
11270         * Use Dock audio output for media:
11271         *      0 = disabled
11272         *      1 = enabled
11273         * @hide
11274         */
11275        public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
11276
11277        private static final Validator DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
11278
11279        /**
11280         * The surround sound formats AC3, DTS or IEC61937 are
11281         * available for use if they are detected.
11282         * This is the default mode.
11283         *
11284         * Note that AUTO is equivalent to ALWAYS for Android TVs and other
11285         * devices that have an S/PDIF output. This is because S/PDIF
11286         * is unidirectional and the TV cannot know if a decoder is
11287         * connected. So it assumes they are always available.
11288         * @hide
11289         */
11290         public static final int ENCODED_SURROUND_OUTPUT_AUTO = 0;
11291
11292        /**
11293         * AC3, DTS or IEC61937 are NEVER available, even if they
11294         * are detected by the hardware. Those formats will not be
11295         * reported.
11296         *
11297         * An example use case would be an AVR reports that it is capable of
11298         * surround sound decoding but is broken. If NEVER is chosen
11299         * then apps must use PCM output instead of encoded output.
11300         * @hide
11301         */
11302         public static final int ENCODED_SURROUND_OUTPUT_NEVER = 1;
11303
11304        /**
11305         * AC3, DTS or IEC61937 are ALWAYS available, even if they
11306         * are not detected by the hardware. Those formats will be
11307         * reported as part of the HDMI output capability. Applications
11308         * are then free to use either PCM or encoded output.
11309         *
11310         * An example use case would be a when TV was connected over
11311         * TOS-link to an AVR. But the TV could not see it because TOS-link
11312         * is unidirectional.
11313         * @hide
11314         */
11315         public static final int ENCODED_SURROUND_OUTPUT_ALWAYS = 2;
11316
11317        /**
11318         * Surround sound formats are available according to the choice
11319         * of user, even if they are not detected by the hardware. Those
11320         * formats will be reported as part of the HDMI output capability.
11321         * Applications are then free to use either PCM or encoded output.
11322         *
11323         * An example use case would be an AVR that doesn't report a surround
11324         * format while the user knows the AVR does support it.
11325         * @hide
11326         */
11327        public static final int ENCODED_SURROUND_OUTPUT_MANUAL = 3;
11328
11329        /**
11330         * Set to ENCODED_SURROUND_OUTPUT_AUTO,
11331         * ENCODED_SURROUND_OUTPUT_NEVER,
11332         * ENCODED_SURROUND_OUTPUT_ALWAYS or
11333         * ENCODED_SURROUND_OUTPUT_MANUAL
11334         * @hide
11335         */
11336        public static final String ENCODED_SURROUND_OUTPUT = "encoded_surround_output";
11337
11338        private static final Validator ENCODED_SURROUND_OUTPUT_VALIDATOR =
11339                new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1", "2", "3"});
11340
11341        /**
11342         * Surround sounds formats that are enabled when ENCODED_SURROUND_OUTPUT is set to
11343         * ENCODED_SURROUND_OUTPUT_MANUAL. Encoded as comma separated list. Allowed values
11344         * are the format constants defined in AudioFormat.java. Ex:
11345         *
11346         * "5,6"
11347         *
11348         * @hide
11349         */
11350        public static final String ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS =
11351                "encoded_surround_output_enabled_formats";
11352
11353        private static final Validator ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR =
11354                new Validator() {
11355            @Override
11356            public boolean validate(String value) {
11357                try {
11358                    String[] surroundFormats = TextUtils.split(value, ",");
11359                    for (String format : surroundFormats) {
11360                        int audioFormat = Integer.valueOf(format);
11361                        boolean isSurroundFormat = false;
11362                        for (int sf : AudioFormat.SURROUND_SOUND_ENCODING) {
11363                            if (sf == audioFormat) {
11364                                isSurroundFormat = true;
11365                                break;
11366                            }
11367                        }
11368                        if (!isSurroundFormat) {
11369                            return false;
11370                        }
11371                    }
11372                    return true;
11373                } catch (NumberFormatException e) {
11374                    return false;
11375                }
11376            }
11377        };
11378
11379        /**
11380         * Persisted safe headphone volume management state by AudioService
11381         * @hide
11382         */
11383        public static final String AUDIO_SAFE_VOLUME_STATE = "audio_safe_volume_state";
11384
11385        /**
11386         * URL for tzinfo (time zone) updates
11387         * @hide
11388         */
11389        public static final String TZINFO_UPDATE_CONTENT_URL = "tzinfo_content_url";
11390
11391        /**
11392         * URL for tzinfo (time zone) update metadata
11393         * @hide
11394         */
11395        public static final String TZINFO_UPDATE_METADATA_URL = "tzinfo_metadata_url";
11396
11397        /**
11398         * URL for selinux (mandatory access control) updates
11399         * @hide
11400         */
11401        public static final String SELINUX_UPDATE_CONTENT_URL = "selinux_content_url";
11402
11403        /**
11404         * URL for selinux (mandatory access control) update metadata
11405         * @hide
11406         */
11407        public static final String SELINUX_UPDATE_METADATA_URL = "selinux_metadata_url";
11408
11409        /**
11410         * URL for sms short code updates
11411         * @hide
11412         */
11413        public static final String SMS_SHORT_CODES_UPDATE_CONTENT_URL =
11414                "sms_short_codes_content_url";
11415
11416        /**
11417         * URL for sms short code update metadata
11418         * @hide
11419         */
11420        public static final String SMS_SHORT_CODES_UPDATE_METADATA_URL =
11421                "sms_short_codes_metadata_url";
11422
11423        /**
11424         * URL for apn_db updates
11425         * @hide
11426         */
11427        public static final String APN_DB_UPDATE_CONTENT_URL = "apn_db_content_url";
11428
11429        /**
11430         * URL for apn_db update metadata
11431         * @hide
11432         */
11433        public static final String APN_DB_UPDATE_METADATA_URL = "apn_db_metadata_url";
11434
11435        /**
11436         * URL for cert pinlist updates
11437         * @hide
11438         */
11439        public static final String CERT_PIN_UPDATE_CONTENT_URL = "cert_pin_content_url";
11440
11441        /**
11442         * URL for cert pinlist updates
11443         * @hide
11444         */
11445        public static final String CERT_PIN_UPDATE_METADATA_URL = "cert_pin_metadata_url";
11446
11447        /**
11448         * URL for intent firewall updates
11449         * @hide
11450         */
11451        public static final String INTENT_FIREWALL_UPDATE_CONTENT_URL =
11452                "intent_firewall_content_url";
11453
11454        /**
11455         * URL for intent firewall update metadata
11456         * @hide
11457         */
11458        public static final String INTENT_FIREWALL_UPDATE_METADATA_URL =
11459                "intent_firewall_metadata_url";
11460
11461        /**
11462         * URL for lang id model updates
11463         * @hide
11464         */
11465        public static final String LANG_ID_UPDATE_CONTENT_URL = "lang_id_content_url";
11466
11467        /**
11468         * URL for lang id model update metadata
11469         * @hide
11470         */
11471        public static final String LANG_ID_UPDATE_METADATA_URL = "lang_id_metadata_url";
11472
11473        /**
11474         * URL for smart selection model updates
11475         * @hide
11476         */
11477        public static final String SMART_SELECTION_UPDATE_CONTENT_URL =
11478                "smart_selection_content_url";
11479
11480        /**
11481         * URL for smart selection model update metadata
11482         * @hide
11483         */
11484        public static final String SMART_SELECTION_UPDATE_METADATA_URL =
11485                "smart_selection_metadata_url";
11486
11487        /**
11488         * SELinux enforcement status. If 0, permissive; if 1, enforcing.
11489         * @hide
11490         */
11491        public static final String SELINUX_STATUS = "selinux_status";
11492
11493        /**
11494         * Developer setting to force RTL layout.
11495         * @hide
11496         */
11497        public static final String DEVELOPMENT_FORCE_RTL = "debug.force_rtl";
11498
11499        /**
11500         * Milliseconds after screen-off after which low battery sounds will be silenced.
11501         *
11502         * If zero, battery sounds will always play.
11503         * Defaults to @integer/def_low_battery_sound_timeout in SettingsProvider.
11504         *
11505         * @hide
11506         */
11507        public static final String LOW_BATTERY_SOUND_TIMEOUT = "low_battery_sound_timeout";
11508
11509        /**
11510         * Milliseconds to wait before bouncing Wi-Fi after settings is restored. Note that after
11511         * the caller is done with this, they should call {@link ContentResolver#delete} to
11512         * clean up any value that they may have written.
11513         *
11514         * @hide
11515         */
11516        public static final String WIFI_BOUNCE_DELAY_OVERRIDE_MS = "wifi_bounce_delay_override_ms";
11517
11518        /**
11519         * Defines global runtime overrides to window policy.
11520         *
11521         * See {@link com.android.server.policy.PolicyControl} for value format.
11522         *
11523         * @hide
11524         */
11525        public static final String POLICY_CONTROL = "policy_control";
11526
11527        /**
11528         * {@link android.view.DisplayCutout DisplayCutout} emulation mode.
11529         *
11530         * @hide
11531         */
11532        public static final String EMULATE_DISPLAY_CUTOUT = "emulate_display_cutout";
11533
11534        /** @hide */ public static final int EMULATE_DISPLAY_CUTOUT_OFF = 0;
11535        /** @hide */ public static final int EMULATE_DISPLAY_CUTOUT_ON = 1;
11536
11537        /**
11538         * Defines global zen mode.  ZEN_MODE_OFF, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
11539         * or ZEN_MODE_NO_INTERRUPTIONS.
11540         *
11541         * @hide
11542         */
11543        public static final String ZEN_MODE = "zen_mode";
11544
11545        /** @hide */ public static final int ZEN_MODE_OFF = 0;
11546        /** @hide */ public static final int ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
11547        /** @hide */ public static final int ZEN_MODE_NO_INTERRUPTIONS = 2;
11548        /** @hide */ public static final int ZEN_MODE_ALARMS = 3;
11549
11550        /** @hide */ public static String zenModeToString(int mode) {
11551            if (mode == ZEN_MODE_IMPORTANT_INTERRUPTIONS) return "ZEN_MODE_IMPORTANT_INTERRUPTIONS";
11552            if (mode == ZEN_MODE_ALARMS) return "ZEN_MODE_ALARMS";
11553            if (mode == ZEN_MODE_NO_INTERRUPTIONS) return "ZEN_MODE_NO_INTERRUPTIONS";
11554            return "ZEN_MODE_OFF";
11555        }
11556
11557        /** @hide */ public static boolean isValidZenMode(int value) {
11558            switch (value) {
11559                case Global.ZEN_MODE_OFF:
11560                case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
11561                case Global.ZEN_MODE_ALARMS:
11562                case Global.ZEN_MODE_NO_INTERRUPTIONS:
11563                    return true;
11564                default:
11565                    return false;
11566            }
11567        }
11568
11569        /**
11570         * Value of the ringer before entering zen mode.
11571         *
11572         * @hide
11573         */
11574        public static final String ZEN_MODE_RINGER_LEVEL = "zen_mode_ringer_level";
11575
11576        /**
11577         * Opaque value, changes when persisted zen mode configuration changes.
11578         *
11579         * @hide
11580         */
11581        public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
11582
11583        /**
11584         * If 0, turning on dnd manually will last indefinitely.
11585         * Else if non-negative, turning on dnd manually will last for this many minutes.
11586         * Else (if negative), turning on dnd manually will surface a dialog that prompts
11587         * user to specify a duration.
11588         * @hide
11589         */
11590        public static final String ZEN_DURATION = "zen_duration";
11591
11592        private static final Validator ZEN_DURATION_VALIDATOR = ANY_INTEGER_VALIDATOR;
11593
11594        /** @hide */ public static final int ZEN_DURATION_PROMPT = -1;
11595        /** @hide */ public static final int ZEN_DURATION_FOREVER = 0;
11596
11597        /**
11598         * Defines global heads up toggle.  One of HEADS_UP_OFF, HEADS_UP_ON.
11599         *
11600         * @hide
11601         */
11602        public static final String HEADS_UP_NOTIFICATIONS_ENABLED =
11603                "heads_up_notifications_enabled";
11604
11605        /** @hide */ public static final int HEADS_UP_OFF = 0;
11606        /** @hide */ public static final int HEADS_UP_ON = 1;
11607
11608        /**
11609         * The name of the device
11610         */
11611        public static final String DEVICE_NAME = "device_name";
11612
11613        /**
11614         * Whether the NetworkScoringService has been first initialized.
11615         * <p>
11616         * Type: int (0 for false, 1 for true)
11617         * @hide
11618         */
11619        public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned";
11620
11621        /**
11622         * Whether the user wants to be prompted for password to decrypt the device on boot.
11623         * This only matters if the storage is encrypted.
11624         * <p>
11625         * Type: int (0 for false, 1 for true)
11626         * @hide
11627         */
11628        public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt";
11629
11630        /**
11631         * Whether the Volte is enabled. If this setting is not set then we use the Carrier Config
11632         * value {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}.
11633         * <p>
11634         * Type: int (0 for false, 1 for true)
11635         * @hide
11636         * @deprecated Use {@link android.telephony.SubscriptionManager#ENHANCED_4G_MODE_ENABLED}
11637         * instead.
11638         */
11639        @Deprecated
11640        public static final String ENHANCED_4G_MODE_ENABLED =
11641                SubscriptionManager.ENHANCED_4G_MODE_ENABLED;
11642
11643        /**
11644         * Whether VT (Video Telephony over IMS) is enabled
11645         * <p>
11646         * Type: int (0 for false, 1 for true)
11647         *
11648         * @hide
11649         * @deprecated Use {@link android.telephony.SubscriptionManager#VT_IMS_ENABLED} instead.
11650         */
11651        @Deprecated
11652        public static final String VT_IMS_ENABLED = SubscriptionManager.VT_IMS_ENABLED;
11653
11654        /**
11655         * Whether WFC is enabled
11656         * <p>
11657         * Type: int (0 for false, 1 for true)
11658         *
11659         * @hide
11660         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ENABLED} instead.
11661         */
11662        @Deprecated
11663        public static final String WFC_IMS_ENABLED = SubscriptionManager.WFC_IMS_ENABLED;
11664
11665        /**
11666         * WFC mode on home/non-roaming network.
11667         * <p>
11668         * Type: int - 2=Wi-Fi preferred, 1=Cellular preferred, 0=Wi-Fi only
11669         *
11670         * @hide
11671         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_MODE} instead.
11672         */
11673        @Deprecated
11674        public static final String WFC_IMS_MODE = SubscriptionManager.WFC_IMS_MODE;
11675
11676        /**
11677         * WFC mode on roaming network.
11678         * <p>
11679         * Type: int - see {@link #WFC_IMS_MODE} for values
11680         *
11681         * @hide
11682         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ROAMING_MODE}
11683         * instead.
11684         */
11685        @Deprecated
11686        public static final String WFC_IMS_ROAMING_MODE = SubscriptionManager.WFC_IMS_ROAMING_MODE;
11687
11688        /**
11689         * Whether WFC roaming is enabled
11690         * <p>
11691         * Type: int (0 for false, 1 for true)
11692         *
11693         * @hide
11694         * @deprecated Use {@link android.telephony.SubscriptionManager#WFC_IMS_ROAMING_ENABLED}
11695         * instead
11696         */
11697        @Deprecated
11698        public static final String WFC_IMS_ROAMING_ENABLED =
11699                SubscriptionManager.WFC_IMS_ROAMING_ENABLED;
11700
11701        /**
11702         * Whether user can enable/disable LTE as a preferred network. A carrier might control
11703         * this via gservices, OMA-DM, carrier app, etc.
11704         * <p>
11705         * Type: int (0 for false, 1 for true)
11706         * @hide
11707         */
11708        public static final String LTE_SERVICE_FORCED = "lte_service_forced";
11709
11710        /**
11711         * Ephemeral app cookie max size in bytes.
11712         * <p>
11713         * Type: int
11714         * @hide
11715         */
11716        public static final String EPHEMERAL_COOKIE_MAX_SIZE_BYTES =
11717                "ephemeral_cookie_max_size_bytes";
11718
11719        /**
11720         * Toggle to enable/disable the entire ephemeral feature. By default, ephemeral is
11721         * enabled. Set to zero to disable.
11722         * <p>
11723         * Type: int (0 for false, 1 for true)
11724         *
11725         * @hide
11726         */
11727        public static final String ENABLE_EPHEMERAL_FEATURE = "enable_ephemeral_feature";
11728
11729        /**
11730         * Toggle to enable/disable dexopt for instant applications. The default is for dexopt
11731         * to be disabled.
11732         * <p>
11733         * Type: int (0 to disable, 1 to enable)
11734         *
11735         * @hide
11736         */
11737        public static final String INSTANT_APP_DEXOPT_ENABLED = "instant_app_dexopt_enabled";
11738
11739        /**
11740         * The min period for caching installed instant apps in milliseconds.
11741         * <p>
11742         * Type: long
11743         * @hide
11744         */
11745        public static final String INSTALLED_INSTANT_APP_MIN_CACHE_PERIOD =
11746                "installed_instant_app_min_cache_period";
11747
11748        /**
11749         * The max period for caching installed instant apps in milliseconds.
11750         * <p>
11751         * Type: long
11752         * @hide
11753         */
11754        public static final String INSTALLED_INSTANT_APP_MAX_CACHE_PERIOD =
11755                "installed_instant_app_max_cache_period";
11756
11757        /**
11758         * The min period for caching uninstalled instant apps in milliseconds.
11759         * <p>
11760         * Type: long
11761         * @hide
11762         */
11763        public static final String UNINSTALLED_INSTANT_APP_MIN_CACHE_PERIOD =
11764                "uninstalled_instant_app_min_cache_period";
11765
11766        /**
11767         * The max period for caching uninstalled instant apps in milliseconds.
11768         * <p>
11769         * Type: long
11770         * @hide
11771         */
11772        public static final String UNINSTALLED_INSTANT_APP_MAX_CACHE_PERIOD =
11773                "uninstalled_instant_app_max_cache_period";
11774
11775        /**
11776         * The min period for caching unused static shared libs in milliseconds.
11777         * <p>
11778         * Type: long
11779         * @hide
11780         */
11781        public static final String UNUSED_STATIC_SHARED_LIB_MIN_CACHE_PERIOD =
11782                "unused_static_shared_lib_min_cache_period";
11783
11784        /**
11785         * Allows switching users when system user is locked.
11786         * <p>
11787         * Type: int
11788         * @hide
11789         */
11790        public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED =
11791                "allow_user_switching_when_system_user_locked";
11792
11793        /**
11794         * Boot count since the device starts running API level 24.
11795         * <p>
11796         * Type: int
11797         */
11798        public static final String BOOT_COUNT = "boot_count";
11799
11800        /**
11801         * Whether the safe boot is disallowed.
11802         *
11803         * <p>This setting should have the identical value as the corresponding user restriction.
11804         * The purpose of the setting is to make the restriction available in early boot stages
11805         * before the user restrictions are loaded.
11806         * @hide
11807         */
11808        public static final String SAFE_BOOT_DISALLOWED = "safe_boot_disallowed";
11809
11810        /**
11811         * Whether this device is currently in retail demo mode. If true, device
11812         * usage is severely limited.
11813         * <p>
11814         * Type: int (0 for false, 1 for true)
11815         * @hide
11816         */
11817        public static final String DEVICE_DEMO_MODE = "device_demo_mode";
11818
11819        /**
11820         * Indicates the maximum time that an app is blocked for the network rules to get updated.
11821         *
11822         * Type: long
11823         *
11824         * @hide
11825         */
11826        public static final String NETWORK_ACCESS_TIMEOUT_MS = "network_access_timeout_ms";
11827
11828        /**
11829         * The reason for the settings database being downgraded. This is only for
11830         * troubleshooting purposes and its value should not be interpreted in any way.
11831         *
11832         * Type: string
11833         *
11834         * @hide
11835         */
11836        public static final String DATABASE_DOWNGRADE_REASON = "database_downgrade_reason";
11837
11838        /**
11839         * The build id of when the settings database was first created (or re-created due it
11840         * being missing).
11841         *
11842         * Type: string
11843         *
11844         * @hide
11845         */
11846        public static final String DATABASE_CREATION_BUILDID = "database_creation_buildid";
11847
11848        /**
11849         * Flag to toggle journal mode WAL on or off for the contacts database. WAL is enabled by
11850         * default. Set to 0 to disable.
11851         *
11852         * @hide
11853         */
11854        public static final String CONTACTS_DATABASE_WAL_ENABLED = "contacts_database_wal_enabled";
11855
11856        /**
11857         * Flag to enable the link to location permissions in location setting. Set to 0 to disable.
11858         *
11859         * @hide
11860         */
11861        public static final String LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED =
11862                "location_settings_link_to_permissions_enabled";
11863
11864        /**
11865         * Flag to set the waiting time for euicc factory reset inside System > Settings
11866         * Type: long
11867         *
11868         * @hide
11869         */
11870        public static final String EUICC_FACTORY_RESET_TIMEOUT_MILLIS =
11871                "euicc_factory_reset_timeout_millis";
11872
11873        /**
11874         * Flag to set the timeout for when to refresh the storage settings cached data.
11875         * Type: long
11876         *
11877         * @hide
11878         */
11879        public static final String STORAGE_SETTINGS_CLOBBER_THRESHOLD =
11880                "storage_settings_clobber_threshold";
11881
11882        /**
11883         * If set to 1, {@link Secure#LOCATION_MODE} will be set to {@link Secure#LOCATION_MODE_OFF}
11884         * temporarily for all users.
11885         *
11886         * @hide
11887         */
11888        @TestApi
11889        public static final String LOCATION_GLOBAL_KILL_SWITCH =
11890                "location_global_kill_switch";
11891
11892        /**
11893         * If set to 1, SettingsProvider's restoreAnyVersion="true" attribute will be ignored
11894         * and restoring to lower version of platform API will be skipped.
11895         *
11896         * @hide
11897         */
11898        public static final String OVERRIDE_SETTINGS_PROVIDER_RESTORE_ANY_VERSION =
11899                "override_settings_provider_restore_any_version";
11900        /**
11901         * Flag to toggle whether system services report attribution chains when they attribute
11902         * battery use via a {@code WorkSource}.
11903         *
11904         * Type: int (0 to disable, 1 to enable)
11905         *
11906         * @hide
11907         */
11908        public static final String CHAINED_BATTERY_ATTRIBUTION_ENABLED =
11909                "chained_battery_attribution_enabled";
11910
11911        /**
11912         * The packages whitelisted to be run in autofill compatibility mode. The list
11913         * of packages is {@code ":"} colon delimited, and each entry has the name of the
11914         * package and an optional list of url bar resource ids (the list is delimited by
11915         * brackets&mdash{@code [} and {@code ]}&mdash and is also comma delimited).
11916         *
11917         * <p>For example, a list with 3 packages {@code p1}, {@code p2}, and {@code p3}, where
11918         * package {@code p1} have one id ({@code url_bar}, {@code p2} has none, and {@code p3 }
11919         * have 2 ids {@code url_foo} and {@code url_bas}) would be
11920         * {@code p1[url_bar]:p2:p3[url_foo,url_bas]}
11921         *
11922         * @hide
11923         */
11924        @SystemApi
11925        @TestApi
11926        public static final String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES =
11927                "autofill_compat_mode_allowed_packages";
11928
11929        /**
11930         * Exemptions to the hidden API blacklist.
11931         *
11932         * @hide
11933         */
11934        @TestApi
11935        public static final String HIDDEN_API_BLACKLIST_EXEMPTIONS =
11936                "hidden_api_blacklist_exemptions";
11937
11938        /**
11939         * Sampling rate for hidden API access event logs, as an integer in the range 0 to 0x10000
11940         * inclusive.
11941         *
11942         * @hide
11943         */
11944        public static final String HIDDEN_API_ACCESS_LOG_SAMPLING_RATE =
11945                "hidden_api_access_log_sampling_rate";
11946
11947        /**
11948         * Hidden API enforcement policy for apps targeting SDK versions prior to the latest
11949         * version.
11950         *
11951         * Values correspond to @{@link
11952         * android.content.pm.ApplicationInfo.HiddenApiEnforcementPolicy}
11953         *
11954         * @hide
11955         */
11956        public static final String HIDDEN_API_POLICY_PRE_P_APPS =
11957                "hidden_api_policy_pre_p_apps";
11958
11959        /**
11960         * Hidden API enforcement policy for apps targeting the current SDK version.
11961         *
11962         * Values correspond to @{@link
11963         * android.content.pm.ApplicationInfo.HiddenApiEnforcementPolicy}
11964         *
11965         * @hide
11966         */
11967        public static final String HIDDEN_API_POLICY_P_APPS =
11968                "hidden_api_policy_p_apps";
11969
11970        /**
11971         * Timeout for a single {@link android.media.soundtrigger.SoundTriggerDetectionService}
11972         * operation (in ms).
11973         *
11974         * @hide
11975         */
11976        public static final String SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT =
11977                "sound_trigger_detection_service_op_timeout";
11978
11979        /**
11980         * Maximum number of {@link android.media.soundtrigger.SoundTriggerDetectionService}
11981         * operations per day.
11982         *
11983         * @hide
11984         */
11985        public static final String MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY =
11986                "max_sound_trigger_detection_service_ops_per_day";
11987
11988        /**
11989         * Settings to backup. This is here so that it's in the same place as the settings
11990         * keys and easy to update.
11991         *
11992         * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
11993         * and Secure as well.  This is because those tables drive both backup and
11994         * restore, and restore needs to properly whitelist keys that used to live
11995         * in those namespaces.  The keys will only actually be backed up / restored
11996         * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
11997         *
11998         * NOTE: Settings are backed up and restored in the order they appear
11999         *       in this array. If you have one setting depending on another,
12000         *       make sure that they are ordered appropriately.
12001         *
12002         * @hide
12003         */
12004        public static final String[] SETTINGS_TO_BACKUP = {
12005            BUGREPORT_IN_POWER_MENU,
12006            STAY_ON_WHILE_PLUGGED_IN,
12007            APP_AUTO_RESTRICTION_ENABLED,
12008            AUTO_TIME,
12009            AUTO_TIME_ZONE,
12010            POWER_SOUNDS_ENABLED,
12011            DOCK_SOUNDS_ENABLED,
12012            CHARGING_SOUNDS_ENABLED,
12013            USB_MASS_STORAGE_ENABLED,
12014            NETWORK_RECOMMENDATIONS_ENABLED,
12015            WIFI_WAKEUP_ENABLED,
12016            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
12017            WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON,
12018            USE_OPEN_WIFI_PACKAGE,
12019            WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
12020            EMERGENCY_TONE,
12021            CALL_AUTO_RETRY,
12022            DOCK_AUDIO_MEDIA_ENABLED,
12023            ENCODED_SURROUND_OUTPUT,
12024            ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS,
12025            LOW_POWER_MODE_TRIGGER_LEVEL,
12026            BLUETOOTH_ON,
12027            PRIVATE_DNS_MODE,
12028            PRIVATE_DNS_SPECIFIER,
12029            SOFT_AP_TIMEOUT_ENABLED,
12030            ZEN_DURATION,
12031        };
12032
12033        /**
12034         * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator,
12035         * otherwise they won't be restored.
12036         *
12037         * @hide
12038         */
12039        public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();
12040        static {
12041            VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR);
12042            VALIDATORS.put(STAY_ON_WHILE_PLUGGED_IN, STAY_ON_WHILE_PLUGGED_IN_VALIDATOR);
12043            VALIDATORS.put(AUTO_TIME, AUTO_TIME_VALIDATOR);
12044            VALIDATORS.put(AUTO_TIME_ZONE, AUTO_TIME_ZONE_VALIDATOR);
12045            VALIDATORS.put(POWER_SOUNDS_ENABLED, POWER_SOUNDS_ENABLED_VALIDATOR);
12046            VALIDATORS.put(DOCK_SOUNDS_ENABLED, DOCK_SOUNDS_ENABLED_VALIDATOR);
12047            VALIDATORS.put(CHARGING_SOUNDS_ENABLED, CHARGING_SOUNDS_ENABLED_VALIDATOR);
12048            VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR);
12049            VALIDATORS.put(NETWORK_RECOMMENDATIONS_ENABLED,
12050                    NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR);
12051            VALIDATORS.put(WIFI_WAKEUP_ENABLED, WIFI_WAKEUP_ENABLED_VALIDATOR);
12052            VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
12053                    WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
12054            VALIDATORS.put(USE_OPEN_WIFI_PACKAGE, USE_OPEN_WIFI_PACKAGE_VALIDATOR);
12055            VALIDATORS.put(WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
12056                    WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR);
12057            VALIDATORS.put(EMERGENCY_TONE, EMERGENCY_TONE_VALIDATOR);
12058            VALIDATORS.put(CALL_AUTO_RETRY, CALL_AUTO_RETRY_VALIDATOR);
12059            VALIDATORS.put(DOCK_AUDIO_MEDIA_ENABLED, DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR);
12060            VALIDATORS.put(ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_VALIDATOR);
12061            VALIDATORS.put(ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS,
12062                    ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR);
12063            VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR);
12064            VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL_MAX,
12065                    LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR);
12066            VALIDATORS.put(BLUETOOTH_ON, BLUETOOTH_ON_VALIDATOR);
12067            VALIDATORS.put(PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_VALIDATOR);
12068            VALIDATORS.put(PRIVATE_DNS_SPECIFIER, PRIVATE_DNS_SPECIFIER_VALIDATOR);
12069            VALIDATORS.put(SOFT_AP_TIMEOUT_ENABLED, SOFT_AP_TIMEOUT_ENABLED_VALIDATOR);
12070            VALIDATORS.put(WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON,
12071                    WIFI_CARRIER_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR);
12072            VALIDATORS.put(APP_AUTO_RESTRICTION_ENABLED, APP_AUTO_RESTRICTION_ENABLED_VALIDATOR);
12073            VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR);
12074        }
12075
12076        /**
12077         * Global settings that shouldn't be persisted.
12078         *
12079         * @hide
12080         */
12081        public static final String[] TRANSIENT_SETTINGS = {
12082                LOCATION_GLOBAL_KILL_SWITCH,
12083        };
12084
12085        /**
12086         * Keys we no longer back up under the current schema, but want to continue to
12087         * process when restoring historical backup datasets.
12088         *
12089         * All settings in {@link LEGACY_RESTORE_SETTINGS} array *must* have a non-null validator,
12090         * otherwise they won't be restored.
12091         *
12092         * @hide
12093         */
12094        public static final String[] LEGACY_RESTORE_SETTINGS = {
12095        };
12096
12097        private static final ContentProviderHolder sProviderHolder =
12098                new ContentProviderHolder(CONTENT_URI);
12099
12100        // Populated lazily, guarded by class object:
12101        private static final NameValueCache sNameValueCache = new NameValueCache(
12102                    CONTENT_URI,
12103                    CALL_METHOD_GET_GLOBAL,
12104                    CALL_METHOD_PUT_GLOBAL,
12105                    sProviderHolder);
12106
12107        // Certain settings have been moved from global to the per-user secure namespace
12108        private static final HashSet<String> MOVED_TO_SECURE;
12109        static {
12110            MOVED_TO_SECURE = new HashSet<>(1);
12111            MOVED_TO_SECURE.add(Settings.Global.INSTALL_NON_MARKET_APPS);
12112        }
12113
12114        /** @hide */
12115        public static void getMovedToSecureSettings(Set<String> outKeySet) {
12116            outKeySet.addAll(MOVED_TO_SECURE);
12117        }
12118
12119        /** @hide */
12120        public static void clearProviderForTest() {
12121            sProviderHolder.clearProviderForTest();
12122            sNameValueCache.clearGenerationTrackerForTest();
12123        }
12124
12125        /**
12126         * Look up a name in the database.
12127         * @param resolver to access the database with
12128         * @param name to look up in the table
12129         * @return the corresponding value, or null if not present
12130         */
12131        public static String getString(ContentResolver resolver, String name) {
12132            return getStringForUser(resolver, name, resolver.getUserId());
12133        }
12134
12135        /** @hide */
12136        public static String getStringForUser(ContentResolver resolver, String name,
12137                int userHandle) {
12138            if (MOVED_TO_SECURE.contains(name)) {
12139                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
12140                        + " to android.provider.Settings.Secure, returning read-only value.");
12141                return Secure.getStringForUser(resolver, name, userHandle);
12142            }
12143            return sNameValueCache.getStringForUser(resolver, name, userHandle);
12144        }
12145
12146        /**
12147         * Store a name/value pair into the database.
12148         * @param resolver to access the database with
12149         * @param name to store
12150         * @param value to associate with the name
12151         * @return true if the value was set, false on database errors
12152         */
12153        public static boolean putString(ContentResolver resolver,
12154                String name, String value) {
12155            return putStringForUser(resolver, name, value, null, false, resolver.getUserId());
12156        }
12157
12158        /**
12159         * Store a name/value pair into the database.
12160         * <p>
12161         * The method takes an optional tag to associate with the setting
12162         * which can be used to clear only settings made by your package and
12163         * associated with this tag by passing the tag to {@link
12164         * #resetToDefaults(ContentResolver, String)}. Anyone can override
12165         * the current tag. Also if another package changes the setting
12166         * then the tag will be set to the one specified in the set call
12167         * which can be null. Also any of the settings setters that do not
12168         * take a tag as an argument effectively clears the tag.
12169         * </p><p>
12170         * For example, if you set settings A and B with tags T1 and T2 and
12171         * another app changes setting A (potentially to the same value), it
12172         * can assign to it a tag T3 (note that now the package that changed
12173         * the setting is not yours). Now if you reset your changes for T1 and
12174         * T2 only setting B will be reset and A not (as it was changed by
12175         * another package) but since A did not change you are in the desired
12176         * initial state. Now if the other app changes the value of A (assuming
12177         * you registered an observer in the beginning) you would detect that
12178         * the setting was changed by another app and handle this appropriately
12179         * (ignore, set back to some value, etc).
12180         * </p><p>
12181         * Also the method takes an argument whether to make the value the
12182         * default for this setting. If the system already specified a default
12183         * value, then the one passed in here will <strong>not</strong>
12184         * be set as the default.
12185         * </p>
12186         *
12187         * @param resolver to access the database with.
12188         * @param name to store.
12189         * @param value to associate with the name.
12190         * @param tag to associated with the setting.
12191         * @param makeDefault whether to make the value the default one.
12192         * @return true if the value was set, false on database errors.
12193         *
12194         * @see #resetToDefaults(ContentResolver, String)
12195         *
12196         * @hide
12197         */
12198        @SystemApi
12199        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
12200        public static boolean putString(@NonNull ContentResolver resolver,
12201                @NonNull String name, @Nullable String value, @Nullable String tag,
12202                boolean makeDefault) {
12203            return putStringForUser(resolver, name, value, tag, makeDefault,
12204                    resolver.getUserId());
12205        }
12206
12207        /**
12208         * Reset the settings to their defaults. This would reset <strong>only</strong>
12209         * settings set by the caller's package. Think of it of a way to undo your own
12210         * changes to the secure settings. Passing in the optional tag will reset only
12211         * settings changed by your package and associated with this tag.
12212         *
12213         * @param resolver Handle to the content resolver.
12214         * @param tag Optional tag which should be associated with the settings to reset.
12215         *
12216         * @see #putString(ContentResolver, String, String, String, boolean)
12217         *
12218         * @hide
12219         */
12220        @SystemApi
12221        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
12222        public static void resetToDefaults(@NonNull ContentResolver resolver,
12223                @Nullable String tag) {
12224            resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
12225                    resolver.getUserId());
12226        }
12227
12228        /**
12229         * Reset the settings to their defaults for a given user with a specific mode. The
12230         * optional tag argument is valid only for {@link #RESET_MODE_PACKAGE_DEFAULTS}
12231         * allowing resetting the settings made by a package and associated with the tag.
12232         *
12233         * @param resolver Handle to the content resolver.
12234         * @param tag Optional tag which should be associated with the settings to reset.
12235         * @param mode The reset mode.
12236         * @param userHandle The user for which to reset to defaults.
12237         *
12238         * @see #RESET_MODE_PACKAGE_DEFAULTS
12239         * @see #RESET_MODE_UNTRUSTED_DEFAULTS
12240         * @see #RESET_MODE_UNTRUSTED_CHANGES
12241         * @see #RESET_MODE_TRUSTED_DEFAULTS
12242         *
12243         * @hide
12244         */
12245        public static void resetToDefaultsAsUser(@NonNull ContentResolver resolver,
12246                @Nullable String tag, @ResetMode int mode, @IntRange(from = 0) int userHandle) {
12247            try {
12248                Bundle arg = new Bundle();
12249                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
12250                if (tag != null) {
12251                    arg.putString(CALL_METHOD_TAG_KEY, tag);
12252                }
12253                arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode);
12254                IContentProvider cp = sProviderHolder.getProvider(resolver);
12255                cp.call(resolver.getPackageName(), CALL_METHOD_RESET_GLOBAL, null, arg);
12256            } catch (RemoteException e) {
12257                Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e);
12258            }
12259        }
12260
12261        /** @hide */
12262        public static boolean putStringForUser(ContentResolver resolver,
12263                String name, String value, int userHandle) {
12264            return putStringForUser(resolver, name, value, null, false, userHandle);
12265        }
12266
12267        /** @hide */
12268        public static boolean putStringForUser(@NonNull ContentResolver resolver,
12269                @NonNull String name, @Nullable String value, @Nullable String tag,
12270                boolean makeDefault, @UserIdInt int userHandle) {
12271            if (LOCAL_LOGV) {
12272                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
12273                        + " for " + userHandle);
12274            }
12275            // Global and Secure have the same access policy so we can forward writes
12276            if (MOVED_TO_SECURE.contains(name)) {
12277                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Global"
12278                        + " to android.provider.Settings.Secure, value is unchanged.");
12279                return Secure.putStringForUser(resolver, name, value, tag,
12280                        makeDefault, userHandle);
12281            }
12282            return sNameValueCache.putStringForUser(resolver, name, value, tag,
12283                    makeDefault, userHandle);
12284        }
12285
12286        /**
12287         * Construct the content URI for a particular name/value pair,
12288         * useful for monitoring changes with a ContentObserver.
12289         * @param name to look up in the table
12290         * @return the corresponding content URI, or null if not present
12291         */
12292        public static Uri getUriFor(String name) {
12293            return getUriFor(CONTENT_URI, name);
12294        }
12295
12296        /**
12297         * Convenience function for retrieving a single secure settings value
12298         * as an integer.  Note that internally setting values are always
12299         * stored as strings; this function converts the string to an integer
12300         * for you.  The default value will be returned if the setting is
12301         * not defined or not an integer.
12302         *
12303         * @param cr The ContentResolver to access.
12304         * @param name The name of the setting to retrieve.
12305         * @param def Value to return if the setting is not defined.
12306         *
12307         * @return The setting's current value, or 'def' if it is not defined
12308         * or not a valid integer.
12309         */
12310        public static int getInt(ContentResolver cr, String name, int def) {
12311            String v = getString(cr, name);
12312            try {
12313                return v != null ? Integer.parseInt(v) : def;
12314            } catch (NumberFormatException e) {
12315                return def;
12316            }
12317        }
12318
12319        /**
12320         * Convenience function for retrieving a single secure settings value
12321         * as an integer.  Note that internally setting values are always
12322         * stored as strings; this function converts the string to an integer
12323         * for you.
12324         * <p>
12325         * This version does not take a default value.  If the setting has not
12326         * been set, or the string value is not a number,
12327         * it throws {@link SettingNotFoundException}.
12328         *
12329         * @param cr The ContentResolver to access.
12330         * @param name The name of the setting to retrieve.
12331         *
12332         * @throws SettingNotFoundException Thrown if a setting by the given
12333         * name can't be found or the setting value is not an integer.
12334         *
12335         * @return The setting's current value.
12336         */
12337        public static int getInt(ContentResolver cr, String name)
12338                throws SettingNotFoundException {
12339            String v = getString(cr, name);
12340            try {
12341                return Integer.parseInt(v);
12342            } catch (NumberFormatException e) {
12343                throw new SettingNotFoundException(name);
12344            }
12345        }
12346
12347        /**
12348         * Convenience function for updating a single settings value as an
12349         * integer. This will either create a new entry in the table if the
12350         * given name does not exist, or modify the value of the existing row
12351         * with that name.  Note that internally setting values are always
12352         * stored as strings, so this function converts the given value to a
12353         * string before storing it.
12354         *
12355         * @param cr The ContentResolver to access.
12356         * @param name The name of the setting to modify.
12357         * @param value The new value for the setting.
12358         * @return true if the value was set, false on database errors
12359         */
12360        public static boolean putInt(ContentResolver cr, String name, int value) {
12361            return putString(cr, name, Integer.toString(value));
12362        }
12363
12364        /**
12365         * Convenience function for retrieving a single secure settings value
12366         * as a {@code long}.  Note that internally setting values are always
12367         * stored as strings; this function converts the string to a {@code long}
12368         * for you.  The default value will be returned if the setting is
12369         * not defined or not a {@code long}.
12370         *
12371         * @param cr The ContentResolver to access.
12372         * @param name The name of the setting to retrieve.
12373         * @param def Value to return if the setting is not defined.
12374         *
12375         * @return The setting's current value, or 'def' if it is not defined
12376         * or not a valid {@code long}.
12377         */
12378        public static long getLong(ContentResolver cr, String name, long def) {
12379            String valString = getString(cr, name);
12380            long value;
12381            try {
12382                value = valString != null ? Long.parseLong(valString) : def;
12383            } catch (NumberFormatException e) {
12384                value = def;
12385            }
12386            return value;
12387        }
12388
12389        /**
12390         * Convenience function for retrieving a single secure settings value
12391         * as a {@code long}.  Note that internally setting values are always
12392         * stored as strings; this function converts the string to a {@code long}
12393         * for you.
12394         * <p>
12395         * This version does not take a default value.  If the setting has not
12396         * been set, or the string value is not a number,
12397         * it throws {@link SettingNotFoundException}.
12398         *
12399         * @param cr The ContentResolver to access.
12400         * @param name The name of the setting to retrieve.
12401         *
12402         * @return The setting's current value.
12403         * @throws SettingNotFoundException Thrown if a setting by the given
12404         * name can't be found or the setting value is not an integer.
12405         */
12406        public static long getLong(ContentResolver cr, String name)
12407                throws SettingNotFoundException {
12408            String valString = getString(cr, name);
12409            try {
12410                return Long.parseLong(valString);
12411            } catch (NumberFormatException e) {
12412                throw new SettingNotFoundException(name);
12413            }
12414        }
12415
12416        /**
12417         * Convenience function for updating a secure settings value as a long
12418         * integer. This will either create a new entry in the table if the
12419         * given name does not exist, or modify the value of the existing row
12420         * with that name.  Note that internally setting values are always
12421         * stored as strings, so this function converts the given value to a
12422         * string before storing it.
12423         *
12424         * @param cr The ContentResolver to access.
12425         * @param name The name of the setting to modify.
12426         * @param value The new value for the setting.
12427         * @return true if the value was set, false on database errors
12428         */
12429        public static boolean putLong(ContentResolver cr, String name, long value) {
12430            return putString(cr, name, Long.toString(value));
12431        }
12432
12433        /**
12434         * Convenience function for retrieving a single secure settings value
12435         * as a floating point number.  Note that internally setting values are
12436         * always stored as strings; this function converts the string to an
12437         * float for you. The default value will be returned if the setting
12438         * is not defined or not a valid float.
12439         *
12440         * @param cr The ContentResolver to access.
12441         * @param name The name of the setting to retrieve.
12442         * @param def Value to return if the setting is not defined.
12443         *
12444         * @return The setting's current value, or 'def' if it is not defined
12445         * or not a valid float.
12446         */
12447        public static float getFloat(ContentResolver cr, String name, float def) {
12448            String v = getString(cr, name);
12449            try {
12450                return v != null ? Float.parseFloat(v) : def;
12451            } catch (NumberFormatException e) {
12452                return def;
12453            }
12454        }
12455
12456        /**
12457         * Convenience function for retrieving a single secure settings value
12458         * as a float.  Note that internally setting values are always
12459         * stored as strings; this function converts the string to a float
12460         * for you.
12461         * <p>
12462         * This version does not take a default value.  If the setting has not
12463         * been set, or the string value is not a number,
12464         * it throws {@link SettingNotFoundException}.
12465         *
12466         * @param cr The ContentResolver to access.
12467         * @param name The name of the setting to retrieve.
12468         *
12469         * @throws SettingNotFoundException Thrown if a setting by the given
12470         * name can't be found or the setting value is not a float.
12471         *
12472         * @return The setting's current value.
12473         */
12474        public static float getFloat(ContentResolver cr, String name)
12475                throws SettingNotFoundException {
12476            String v = getString(cr, name);
12477            if (v == null) {
12478                throw new SettingNotFoundException(name);
12479            }
12480            try {
12481                return Float.parseFloat(v);
12482            } catch (NumberFormatException e) {
12483                throw new SettingNotFoundException(name);
12484            }
12485        }
12486
12487        /**
12488         * Convenience function for updating a single settings value as a
12489         * floating point number. This will either create a new entry in the
12490         * table if the given name does not exist, or modify the value of the
12491         * existing row with that name.  Note that internally setting values
12492         * are always stored as strings, so this function converts the given
12493         * value to a string before storing it.
12494         *
12495         * @param cr The ContentResolver to access.
12496         * @param name The name of the setting to modify.
12497         * @param value The new value for the setting.
12498         * @return true if the value was set, false on database errors
12499         */
12500        public static boolean putFloat(ContentResolver cr, String name, float value) {
12501            return putString(cr, name, Float.toString(value));
12502        }
12503
12504        /**
12505          * Subscription to be used for voice call on a multi sim device. The supported values
12506          * are 0 = SUB1, 1 = SUB2 and etc.
12507          * @hide
12508          */
12509        public static final String MULTI_SIM_VOICE_CALL_SUBSCRIPTION = "multi_sim_voice_call";
12510
12511        /**
12512          * Used to provide option to user to select subscription during dial.
12513          * The supported values are 0 = disable or 1 = enable prompt.
12514          * @hide
12515          */
12516        public static final String MULTI_SIM_VOICE_PROMPT = "multi_sim_voice_prompt";
12517
12518        /**
12519          * Subscription to be used for data call on a multi sim device. The supported values
12520          * are 0 = SUB1, 1 = SUB2 and etc.
12521          * @hide
12522          */
12523        public static final String MULTI_SIM_DATA_CALL_SUBSCRIPTION = "multi_sim_data_call";
12524
12525        /**
12526          * Subscription to be used for SMS 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_SMS_SUBSCRIPTION = "multi_sim_sms";
12531
12532        /**
12533          * Used to provide option to user to select subscription during send SMS.
12534          * The value 1 - enable, 0 - disable
12535          * @hide
12536          */
12537        public static final String MULTI_SIM_SMS_PROMPT = "multi_sim_sms_prompt";
12538
12539        /** User preferred subscriptions setting.
12540          * This holds the details of the user selected subscription from the card and
12541          * the activation status. Each settings string have the comma separated values
12542          * iccId,appType,appId,activationStatus,3gppIndex,3gpp2Index
12543          * @hide
12544         */
12545        public static final String[] MULTI_SIM_USER_PREFERRED_SUBS = {"user_preferred_sub1",
12546                "user_preferred_sub2","user_preferred_sub3"};
12547
12548        /**
12549         * Whether to enable new contacts aggregator or not.
12550         * The value 1 - enable, 0 - disable
12551         * @hide
12552         */
12553        public static final String NEW_CONTACT_AGGREGATOR = "new_contact_aggregator";
12554
12555        /**
12556         * Whether to enable contacts metadata syncing or not
12557         * The value 1 - enable, 0 - disable
12558         *
12559         * @removed
12560         */
12561        @Deprecated
12562        public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
12563
12564        /**
12565         * Whether to enable contacts metadata syncing or not
12566         * The value 1 - enable, 0 - disable
12567         */
12568        public static final String CONTACT_METADATA_SYNC_ENABLED = "contact_metadata_sync_enabled";
12569
12570        /**
12571         * Whether to enable cellular on boot.
12572         * The value 1 - enable, 0 - disable
12573         * @hide
12574         */
12575        public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
12576
12577        /**
12578         * The maximum allowed notification enqueue rate in Hertz.
12579         *
12580         * Should be a float, and includes updates only.
12581         * @hide
12582         */
12583        public static final String MAX_NOTIFICATION_ENQUEUE_RATE = "max_notification_enqueue_rate";
12584
12585        /**
12586         * Displays toasts when an app posts a notification that does not specify a valid channel.
12587         *
12588         * The value 1 - enable, 0 - disable
12589         * @hide
12590         */
12591        public static final String SHOW_NOTIFICATION_CHANNEL_WARNINGS =
12592                "show_notification_channel_warnings";
12593
12594        /**
12595         * Whether cell is enabled/disabled
12596         * @hide
12597         */
12598        public static final String CELL_ON = "cell_on";
12599
12600        /**
12601         * Global settings which can be accessed by instant apps.
12602         * @hide
12603         */
12604        public static final Set<String> INSTANT_APP_SETTINGS = new ArraySet<>();
12605        static {
12606            INSTANT_APP_SETTINGS.add(WAIT_FOR_DEBUGGER);
12607            INSTANT_APP_SETTINGS.add(DEVICE_PROVISIONED);
12608            INSTANT_APP_SETTINGS.add(DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES);
12609            INSTANT_APP_SETTINGS.add(DEVELOPMENT_FORCE_RTL);
12610            INSTANT_APP_SETTINGS.add(EPHEMERAL_COOKIE_MAX_SIZE_BYTES);
12611            INSTANT_APP_SETTINGS.add(AIRPLANE_MODE_ON);
12612            INSTANT_APP_SETTINGS.add(WINDOW_ANIMATION_SCALE);
12613            INSTANT_APP_SETTINGS.add(TRANSITION_ANIMATION_SCALE);
12614            INSTANT_APP_SETTINGS.add(ANIMATOR_DURATION_SCALE);
12615            INSTANT_APP_SETTINGS.add(DEBUG_VIEW_ATTRIBUTES);
12616            INSTANT_APP_SETTINGS.add(WTF_IS_FATAL);
12617            INSTANT_APP_SETTINGS.add(SEND_ACTION_APP_ERROR);
12618            INSTANT_APP_SETTINGS.add(ZEN_MODE);
12619        }
12620
12621        /**
12622         * Whether to show the high temperature warning notification.
12623         * @hide
12624         */
12625        public static final String SHOW_TEMPERATURE_WARNING = "show_temperature_warning";
12626
12627        /**
12628         * Temperature at which the high temperature warning notification should be shown.
12629         * @hide
12630         */
12631        public static final String WARNING_TEMPERATURE = "warning_temperature";
12632
12633        /**
12634         * Whether the diskstats logging task is enabled/disabled.
12635         * @hide
12636         */
12637        public static final String ENABLE_DISKSTATS_LOGGING = "enable_diskstats_logging";
12638
12639        /**
12640         * Whether the cache quota calculation task is enabled/disabled.
12641         * @hide
12642         */
12643        public static final String ENABLE_CACHE_QUOTA_CALCULATION =
12644                "enable_cache_quota_calculation";
12645
12646        /**
12647         * Whether the Deletion Helper no threshold toggle is available.
12648         * @hide
12649         */
12650        public static final String ENABLE_DELETION_HELPER_NO_THRESHOLD_TOGGLE =
12651                "enable_deletion_helper_no_threshold_toggle";
12652
12653        /**
12654         * The list of snooze options for notifications
12655         * This is encoded as a key=value list, separated by commas. Ex:
12656         *
12657         * "default=60,options_array=15:30:60:120"
12658         *
12659         * The following keys are supported:
12660         *
12661         * <pre>
12662         * default               (int)
12663         * options_array         (int[])
12664         * </pre>
12665         *
12666         * All delays in integer minutes. Array order is respected.
12667         * Options will be used in order up to the maximum allowed by the UI.
12668         * @hide
12669         */
12670        public static final String NOTIFICATION_SNOOZE_OPTIONS =
12671                "notification_snooze_options";
12672
12673        /**
12674         * Settings key for the ratio of notification dismissals to notification views - one of the
12675         * criteria for showing the notification blocking helper.
12676         *
12677         * <p>The value is a float ranging from 0.0 to 1.0 (the closer to 0.0, the more intrusive
12678         * the blocking helper will be).
12679         *
12680         * @hide
12681         */
12682        public static final String BLOCKING_HELPER_DISMISS_TO_VIEW_RATIO_LIMIT =
12683                "blocking_helper_dismiss_to_view_ratio";
12684
12685        /**
12686         * Settings key for the longest streak of dismissals  - one of the criteria for showing the
12687         * notification blocking helper.
12688         *
12689         * <p>The value is an integer greater than 0.
12690         *
12691         * @hide
12692         */
12693        public static final String BLOCKING_HELPER_STREAK_LIMIT = "blocking_helper_streak_limit";
12694
12695        /**
12696         * Configuration flags for SQLite Compatibility WAL. Encoded as a key-value list, separated
12697         * by commas. E.g.: compatibility_wal_supported=true, wal_syncmode=OFF
12698         *
12699         * Supported keys:
12700         * compatibility_wal_supported      (boolean)
12701         * wal_syncmode       (String)
12702         *
12703         * @hide
12704         */
12705        public static final String SQLITE_COMPATIBILITY_WAL_FLAGS =
12706                "sqlite_compatibility_wal_flags";
12707
12708        /**
12709         * Enable GNSS Raw Measurements Full Tracking?
12710         * 0 = no
12711         * 1 = yes
12712         * @hide
12713         */
12714        public static final String ENABLE_GNSS_RAW_MEAS_FULL_TRACKING =
12715                "enable_gnss_raw_meas_full_tracking";
12716
12717        /**
12718         * Whether the notification should be ongoing (persistent) when a carrier app install is
12719         * required.
12720         *
12721         * The value is a boolean (1 or 0).
12722         * @hide
12723         */
12724        @SystemApi
12725        public static final String INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT =
12726                "install_carrier_app_notification_persistent";
12727
12728        /**
12729         * The amount of time (ms) to hide the install carrier app notification after the user has
12730         * ignored it. After this time passes, the notification will be shown again
12731         *
12732         * The value is a long
12733         * @hide
12734         */
12735        @SystemApi
12736        public static final String INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS =
12737                "install_carrier_app_notification_sleep_millis";
12738
12739        /**
12740         * Whether we've enabled zram on this device. Takes effect on
12741         * reboot. The value "1" enables zram; "0" disables it, and
12742         * everything else is unspecified.
12743         * @hide
12744         */
12745        public static final String ZRAM_ENABLED =
12746                "zram_enabled";
12747
12748        /**
12749         * Whether we have enable CPU frequency scaling for this device.
12750         * For Wear, default is disable.
12751         *
12752         * The value is "1" for enable, "0" for disable.
12753         * @hide
12754         */
12755        public static final String CPU_SCALING_ENABLED =
12756                "cpu_frequency_scaling_enabled";
12757
12758        /**
12759         * Configuration flags for smart replies in notifications.
12760         * This is encoded as a key=value list, separated by commas. Ex:
12761         *
12762         * "enabled=1,max_squeeze_remeasure_count=3"
12763         *
12764         * The following keys are supported:
12765         *
12766         * <pre>
12767         * enabled                         (boolean)
12768         * requires_targeting_p            (boolean)
12769         * max_squeeze_remeasure_attempts  (int)
12770         * </pre>
12771         * @see com.android.systemui.statusbar.policy.SmartReplyConstants
12772         * @hide
12773         */
12774        public static final String SMART_REPLIES_IN_NOTIFICATIONS_FLAGS =
12775                "smart_replies_in_notifications_flags";
12776
12777        /**
12778         * If nonzero, crashes in foreground processes will bring up a dialog.
12779         * Otherwise, the process will be silently killed.
12780         * @hide
12781         */
12782        public static final String SHOW_FIRST_CRASH_DIALOG = "show_first_crash_dialog";
12783
12784        /**
12785         * If nonzero, crash dialogs will show an option to restart the app.
12786         * @hide
12787         */
12788        public static final String SHOW_RESTART_IN_CRASH_DIALOG = "show_restart_in_crash_dialog";
12789
12790        /**
12791         * If nonzero, crash dialogs will show an option to mute all future crash dialogs for
12792         * this app.
12793         * @hide
12794         */
12795        public static final String SHOW_MUTE_IN_CRASH_DIALOG = "show_mute_in_crash_dialog";
12796
12797        /**
12798         * If nonzero, will show the zen upgrade notification when the user toggles DND on/off.
12799         * @hide
12800         */
12801        public static final String SHOW_ZEN_UPGRADE_NOTIFICATION = "show_zen_upgrade_notification";
12802
12803        /**
12804         * If nonzero, will show the zen update settings suggestion.
12805         * @hide
12806         */
12807        public static final String SHOW_ZEN_SETTINGS_SUGGESTION = "show_zen_settings_suggestion";
12808
12809        /**
12810         * If nonzero, zen has not been updated to reflect new changes.
12811         * @hide
12812         */
12813        public static final String ZEN_SETTINGS_UPDATED = "zen_settings_updated";
12814
12815        /**
12816         * If nonzero, zen setting suggestion has beem viewed by user
12817         * @hide
12818         */
12819        public static final String ZEN_SETTINGS_SUGGESTION_VIEWED =
12820                "zen_settings_suggestion_viewed";
12821
12822        /**
12823         * Backup and restore agent timeout parameters.
12824         * These parameters are represented by a comma-delimited key-value list.
12825         *
12826         * The following strings are supported as keys:
12827         * <pre>
12828         *     kv_backup_agent_timeout_millis         (long)
12829         *     full_backup_agent_timeout_millis       (long)
12830         *     shared_backup_agent_timeout_millis     (long)
12831         *     restore_agent_timeout_millis           (long)
12832         *     restore_agent_finished_timeout_millis  (long)
12833         * </pre>
12834         *
12835         * They map to milliseconds represented as longs.
12836         *
12837         * Ex: "kv_backup_agent_timeout_millis=30000,full_backup_agent_timeout_millis=300000"
12838         *
12839         * @hide
12840         */
12841        public static final String BACKUP_AGENT_TIMEOUT_PARAMETERS =
12842                "backup_agent_timeout_parameters";
12843
12844        /**
12845         * Whether we have enabled swapping on this device. For Wear, default is
12846         * enabled.
12847         *
12848         * The value is "1" for enable, "0" for disable.
12849         * @hide
12850         */
12851         public static final String SWAP_ENABLED = "swap_enabled";
12852
12853        /**
12854         * Blacklist of GNSS satellites.
12855         *
12856         * This is a list of integers separated by commas to represent pairs of (constellation,
12857         * svid). Thus, the number of integers should be even.
12858         *
12859         * E.g.: "3,0,5,24" denotes (constellation=3, svid=0) and (constellation=5, svid=24) are
12860         * blacklisted. Note that svid=0 denotes all svids in the
12861         * constellation are blacklisted.
12862         *
12863         * @hide
12864         */
12865        public static final String GNSS_SATELLITE_BLACKLIST = "gnss_satellite_blacklist";
12866
12867        /**
12868         * Duration of updates in millisecond for GNSS location request from HAL to framework.
12869         *
12870         * If zero, the GNSS location request feature is disabled.
12871         *
12872         * The value is a non-negative long.
12873         *
12874         * @hide
12875         */
12876        public static final String GNSS_HAL_LOCATION_REQUEST_DURATION_MILLIS =
12877                "gnss_hal_location_request_duration_millis";
12878    }
12879
12880    /**
12881     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
12882     * Intent URL, allowing it to be either a web page or a particular
12883     * application activity.
12884     *
12885     * @hide
12886     */
12887    public static final class Bookmarks implements BaseColumns
12888    {
12889        private static final String TAG = "Bookmarks";
12890
12891        /**
12892         * The content:// style URL for this table
12893         */
12894        public static final Uri CONTENT_URI =
12895            Uri.parse("content://" + AUTHORITY + "/bookmarks");
12896
12897        /**
12898         * The row ID.
12899         * <p>Type: INTEGER</p>
12900         */
12901        public static final String ID = "_id";
12902
12903        /**
12904         * Descriptive name of the bookmark that can be displayed to the user.
12905         * If this is empty, the title should be resolved at display time (use
12906         * {@link #getTitle(Context, Cursor)} any time you want to display the
12907         * title of a bookmark.)
12908         * <P>
12909         * Type: TEXT
12910         * </P>
12911         */
12912        public static final String TITLE = "title";
12913
12914        /**
12915         * Arbitrary string (displayed to the user) that allows bookmarks to be
12916         * organized into categories.  There are some special names for
12917         * standard folders, which all start with '@'.  The label displayed for
12918         * the folder changes with the locale (via {@link #getLabelForFolder}) but
12919         * the folder name does not change so you can consistently query for
12920         * the folder regardless of the current locale.
12921         *
12922         * <P>Type: TEXT</P>
12923         *
12924         */
12925        public static final String FOLDER = "folder";
12926
12927        /**
12928         * The Intent URL of the bookmark, describing what it points to.  This
12929         * value is given to {@link android.content.Intent#getIntent} to create
12930         * an Intent that can be launched.
12931         * <P>Type: TEXT</P>
12932         */
12933        public static final String INTENT = "intent";
12934
12935        /**
12936         * Optional shortcut character associated with this bookmark.
12937         * <P>Type: INTEGER</P>
12938         */
12939        public static final String SHORTCUT = "shortcut";
12940
12941        /**
12942         * The order in which the bookmark should be displayed
12943         * <P>Type: INTEGER</P>
12944         */
12945        public static final String ORDERING = "ordering";
12946
12947        private static final String[] sIntentProjection = { INTENT };
12948        private static final String[] sShortcutProjection = { ID, SHORTCUT };
12949        private static final String sShortcutSelection = SHORTCUT + "=?";
12950
12951        /**
12952         * Convenience function to retrieve the bookmarked Intent for a
12953         * particular shortcut key.
12954         *
12955         * @param cr The ContentResolver to query.
12956         * @param shortcut The shortcut key.
12957         *
12958         * @return Intent The bookmarked URL, or null if there is no bookmark
12959         *         matching the given shortcut.
12960         */
12961        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
12962        {
12963            Intent intent = null;
12964
12965            Cursor c = cr.query(CONTENT_URI,
12966                    sIntentProjection, sShortcutSelection,
12967                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
12968            // Keep trying until we find a valid shortcut
12969            try {
12970                while (intent == null && c.moveToNext()) {
12971                    try {
12972                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
12973                        intent = Intent.parseUri(intentURI, 0);
12974                    } catch (java.net.URISyntaxException e) {
12975                        // The stored URL is bad...  ignore it.
12976                    } catch (IllegalArgumentException e) {
12977                        // Column not found
12978                        Log.w(TAG, "Intent column not found", e);
12979                    }
12980                }
12981            } finally {
12982                if (c != null) c.close();
12983            }
12984
12985            return intent;
12986        }
12987
12988        /**
12989         * Add a new bookmark to the system.
12990         *
12991         * @param cr The ContentResolver to query.
12992         * @param intent The desired target of the bookmark.
12993         * @param title Bookmark title that is shown to the user; null if none
12994         *            or it should be resolved to the intent's title.
12995         * @param folder Folder in which to place the bookmark; null if none.
12996         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
12997         *            this is non-zero and there is an existing bookmark entry
12998         *            with this same shortcut, then that existing shortcut is
12999         *            cleared (the bookmark is not removed).
13000         * @return The unique content URL for the new bookmark entry.
13001         */
13002        public static Uri add(ContentResolver cr,
13003                                           Intent intent,
13004                                           String title,
13005                                           String folder,
13006                                           char shortcut,
13007                                           int ordering)
13008        {
13009            // If a shortcut is supplied, and it is already defined for
13010            // another bookmark, then remove the old definition.
13011            if (shortcut != 0) {
13012                cr.delete(CONTENT_URI, sShortcutSelection,
13013                        new String[] { String.valueOf((int) shortcut) });
13014            }
13015
13016            ContentValues values = new ContentValues();
13017            if (title != null) values.put(TITLE, title);
13018            if (folder != null) values.put(FOLDER, folder);
13019            values.put(INTENT, intent.toUri(0));
13020            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
13021            values.put(ORDERING, ordering);
13022            return cr.insert(CONTENT_URI, values);
13023        }
13024
13025        /**
13026         * Return the folder name as it should be displayed to the user.  This
13027         * takes care of localizing special folders.
13028         *
13029         * @param r Resources object for current locale; only need access to
13030         *          system resources.
13031         * @param folder The value found in the {@link #FOLDER} column.
13032         *
13033         * @return CharSequence The label for this folder that should be shown
13034         *         to the user.
13035         */
13036        public static CharSequence getLabelForFolder(Resources r, String folder) {
13037            return folder;
13038        }
13039
13040        /**
13041         * Return the title as it should be displayed to the user. This takes
13042         * care of localizing bookmarks that point to activities.
13043         *
13044         * @param context A context.
13045         * @param cursor A cursor pointing to the row whose title should be
13046         *        returned. The cursor must contain at least the {@link #TITLE}
13047         *        and {@link #INTENT} columns.
13048         * @return A title that is localized and can be displayed to the user,
13049         *         or the empty string if one could not be found.
13050         */
13051        public static CharSequence getTitle(Context context, Cursor cursor) {
13052            int titleColumn = cursor.getColumnIndex(TITLE);
13053            int intentColumn = cursor.getColumnIndex(INTENT);
13054            if (titleColumn == -1 || intentColumn == -1) {
13055                throw new IllegalArgumentException(
13056                        "The cursor must contain the TITLE and INTENT columns.");
13057            }
13058
13059            String title = cursor.getString(titleColumn);
13060            if (!TextUtils.isEmpty(title)) {
13061                return title;
13062            }
13063
13064            String intentUri = cursor.getString(intentColumn);
13065            if (TextUtils.isEmpty(intentUri)) {
13066                return "";
13067            }
13068
13069            Intent intent;
13070            try {
13071                intent = Intent.parseUri(intentUri, 0);
13072            } catch (URISyntaxException e) {
13073                return "";
13074            }
13075
13076            PackageManager packageManager = context.getPackageManager();
13077            ResolveInfo info = packageManager.resolveActivity(intent, 0);
13078            return info != null ? info.loadLabel(packageManager) : "";
13079        }
13080    }
13081
13082    /**
13083     * Returns the device ID that we should use when connecting to the mobile gtalk server.
13084     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
13085     * from the GoogleLoginService.
13086     *
13087     * @param androidId The Android ID for this device.
13088     * @return The device ID that should be used when connecting to the mobile gtalk server.
13089     * @hide
13090     */
13091    public static String getGTalkDeviceId(long androidId) {
13092        return "android-" + Long.toHexString(androidId);
13093    }
13094
13095    private static final String[] PM_WRITE_SETTINGS = {
13096        android.Manifest.permission.WRITE_SETTINGS
13097    };
13098    private static final String[] PM_CHANGE_NETWORK_STATE = {
13099        android.Manifest.permission.CHANGE_NETWORK_STATE,
13100        android.Manifest.permission.WRITE_SETTINGS
13101    };
13102    private static final String[] PM_SYSTEM_ALERT_WINDOW = {
13103        android.Manifest.permission.SYSTEM_ALERT_WINDOW
13104    };
13105
13106    /**
13107     * Performs a strict and comprehensive check of whether a calling package is allowed to
13108     * write/modify system settings, as the condition differs for pre-M, M+, and
13109     * privileged/preinstalled apps. If the provided uid does not match the
13110     * callingPackage, a negative result will be returned.
13111     * @hide
13112     */
13113    public static boolean isCallingPackageAllowedToWriteSettings(Context context, int uid,
13114            String callingPackage, boolean throwException) {
13115        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
13116                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
13117                PM_WRITE_SETTINGS, false);
13118    }
13119
13120    /**
13121     * Performs a strict and comprehensive check of whether a calling package is allowed to
13122     * write/modify system settings, as the condition differs for pre-M, M+, and
13123     * privileged/preinstalled apps. If the provided uid does not match the
13124     * callingPackage, a negative result will be returned. The caller is expected to have
13125     * the WRITE_SETTINGS permission declared.
13126     *
13127     * Note: if the check is successful, the operation of this app will be updated to the
13128     * current time.
13129     * @hide
13130     */
13131    public static boolean checkAndNoteWriteSettingsOperation(Context context, int uid,
13132            String callingPackage, boolean throwException) {
13133        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
13134                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
13135                PM_WRITE_SETTINGS, true);
13136    }
13137
13138    /**
13139     * Performs a strict and comprehensive check of whether a calling package is allowed to
13140     * change the state of network, as the condition differs for pre-M, M+, and
13141     * privileged/preinstalled apps. The caller is expected to have either the
13142     * CHANGE_NETWORK_STATE or the WRITE_SETTINGS permission declared. Either of these
13143     * permissions allow changing network state; WRITE_SETTINGS is a runtime permission and
13144     * can be revoked, but (except in M, excluding M MRs), CHANGE_NETWORK_STATE is a normal
13145     * permission and cannot be revoked. See http://b/23597341
13146     *
13147     * Note: if the check succeeds because the application holds WRITE_SETTINGS, the operation
13148     * of this app will be updated to the current time.
13149     * @hide
13150     */
13151    public static boolean checkAndNoteChangeNetworkStateOperation(Context context, int uid,
13152            String callingPackage, boolean throwException) {
13153        if (context.checkCallingOrSelfPermission(android.Manifest.permission.CHANGE_NETWORK_STATE)
13154                == PackageManager.PERMISSION_GRANTED) {
13155            return true;
13156        }
13157        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
13158                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
13159                PM_CHANGE_NETWORK_STATE, true);
13160    }
13161
13162    /**
13163     * Performs a strict and comprehensive check of whether a calling package is allowed to
13164     * draw on top of other apps, as the conditions differs for pre-M, M+, and
13165     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
13166     * a negative result will be returned.
13167     * @hide
13168     */
13169    public static boolean isCallingPackageAllowedToDrawOverlays(Context context, int uid,
13170            String callingPackage, boolean throwException) {
13171        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
13172                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
13173                PM_SYSTEM_ALERT_WINDOW, false);
13174    }
13175
13176    /**
13177     * Performs a strict and comprehensive check of whether a calling package is allowed to
13178     * draw on top of other apps, as the conditions differs for pre-M, M+, and
13179     * privileged/preinstalled apps. If the provided uid does not match the callingPackage,
13180     * a negative result will be returned.
13181     *
13182     * Note: if the check is successful, the operation of this app will be updated to the
13183     * current time.
13184     * @hide
13185     */
13186    public static boolean checkAndNoteDrawOverlaysOperation(Context context, int uid, String
13187            callingPackage, boolean throwException) {
13188        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
13189                callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
13190                PM_SYSTEM_ALERT_WINDOW, true);
13191    }
13192
13193    /**
13194     * Helper method to perform a general and comprehensive check of whether an operation that is
13195     * protected by appops can be performed by a caller or not. e.g. OP_SYSTEM_ALERT_WINDOW and
13196     * OP_WRITE_SETTINGS
13197     * @hide
13198     */
13199    public static boolean isCallingPackageAllowedToPerformAppOpsProtectedOperation(Context context,
13200            int uid, String callingPackage, boolean throwException, int appOpsOpCode, String[]
13201            permissions, boolean makeNote) {
13202        if (callingPackage == null) {
13203            return false;
13204        }
13205
13206        AppOpsManager appOpsMgr = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
13207        int mode = AppOpsManager.MODE_DEFAULT;
13208        if (makeNote) {
13209            mode = appOpsMgr.noteOpNoThrow(appOpsOpCode, uid, callingPackage);
13210        } else {
13211            mode = appOpsMgr.checkOpNoThrow(appOpsOpCode, uid, callingPackage);
13212        }
13213
13214        switch (mode) {
13215            case AppOpsManager.MODE_ALLOWED:
13216                return true;
13217
13218            case AppOpsManager.MODE_DEFAULT:
13219                // this is the default operating mode after an app's installation
13220                // In this case we will check all associated static permission to see
13221                // if it is granted during install time.
13222                for (String permission : permissions) {
13223                    if (context.checkCallingOrSelfPermission(permission) == PackageManager
13224                            .PERMISSION_GRANTED) {
13225                        // if either of the permissions are granted, we will allow it
13226                        return true;
13227                    }
13228                }
13229
13230            default:
13231                // this is for all other cases trickled down here...
13232                if (!throwException) {
13233                    return false;
13234                }
13235        }
13236
13237        // prepare string to throw SecurityException
13238        StringBuilder exceptionMessage = new StringBuilder();
13239        exceptionMessage.append(callingPackage);
13240        exceptionMessage.append(" was not granted ");
13241        if (permissions.length > 1) {
13242            exceptionMessage.append(" either of these permissions: ");
13243        } else {
13244            exceptionMessage.append(" this permission: ");
13245        }
13246        for (int i = 0; i < permissions.length; i++) {
13247            exceptionMessage.append(permissions[i]);
13248            exceptionMessage.append((i == permissions.length - 1) ? "." : ", ");
13249        }
13250
13251        throw new SecurityException(exceptionMessage.toString());
13252    }
13253
13254    /**
13255     * Retrieves a correponding package name for a given uid. It will query all
13256     * packages that are associated with the given uid, but it will return only
13257     * the zeroth result.
13258     * Note: If package could not be found, a null is returned.
13259     * @hide
13260     */
13261    public static String getPackageNameForUid(Context context, int uid) {
13262        String[] packages = context.getPackageManager().getPackagesForUid(uid);
13263        if (packages == null) {
13264            return null;
13265        }
13266        return packages[0];
13267    }
13268}
13269