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