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