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