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