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