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