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