OSDN Git Service

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