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