Settings.java revision c99a1107c0d4fdf47595e5072192d647a01e13b3
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.app.SearchManager;
22import android.app.WallpaperManager;
23import android.content.ComponentName;
24import android.content.ContentResolver;
25import android.content.ContentValues;
26import android.content.Context;
27import android.content.IContentProvider;
28import android.content.Intent;
29import android.content.pm.ActivityInfo;
30import android.content.pm.PackageManager;
31import android.content.pm.ResolveInfo;
32import android.content.res.Configuration;
33import android.content.res.Resources;
34import android.database.Cursor;
35import android.database.SQLException;
36import android.net.ConnectivityManager;
37import android.net.Uri;
38import android.net.wifi.WifiManager;
39import android.os.BatteryManager;
40import android.os.Bundle;
41import android.os.DropBoxManager;
42import android.os.IBinder;
43import android.os.Process;
44import android.os.RemoteException;
45import android.os.ServiceManager;
46import android.os.SystemProperties;
47import android.os.UserHandle;
48import android.os.Build.VERSION_CODES;
49import android.speech.tts.TextToSpeech;
50import android.text.TextUtils;
51import android.util.AndroidException;
52import android.util.Log;
53import android.view.WindowOrientationListener;
54
55import com.android.internal.widget.ILockSettings;
56
57import java.net.URISyntaxException;
58import java.util.HashMap;
59import java.util.HashSet;
60
61/**
62 * The Settings provider contains global system-level device preferences.
63 */
64public final class Settings {
65
66    // Intent actions for Settings
67
68    /**
69     * Activity Action: Show system settings.
70     * <p>
71     * Input: Nothing.
72     * <p>
73     * Output: Nothing.
74     */
75    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
76    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
77
78    /**
79     * Activity Action: Show settings to allow configuration of APNs.
80     * <p>
81     * Input: Nothing.
82     * <p>
83     * Output: Nothing.
84     */
85    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
86    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
87
88    /**
89     * Activity Action: Show settings to allow configuration of current location
90     * sources.
91     * <p>
92     * In some cases, a matching Activity may not exist, so ensure you
93     * safeguard against this.
94     * <p>
95     * Input: Nothing.
96     * <p>
97     * Output: Nothing.
98     */
99    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
100    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
101            "android.settings.LOCATION_SOURCE_SETTINGS";
102
103    /**
104     * Activity Action: Show settings to allow configuration of wireless controls
105     * such as Wi-Fi, Bluetooth and Mobile networks.
106     * <p>
107     * In some cases, a matching Activity may not exist, so ensure you
108     * safeguard against this.
109     * <p>
110     * Input: Nothing.
111     * <p>
112     * Output: Nothing.
113     */
114    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
115    public static final String ACTION_WIRELESS_SETTINGS =
116            "android.settings.WIRELESS_SETTINGS";
117
118    /**
119     * Activity Action: Show settings to allow entering/exiting airplane mode.
120     * <p>
121     * In some cases, a matching Activity may not exist, so ensure you
122     * safeguard against this.
123     * <p>
124     * Input: Nothing.
125     * <p>
126     * Output: Nothing.
127     */
128    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
129    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
130            "android.settings.AIRPLANE_MODE_SETTINGS";
131
132    /**
133     * Activity Action: Show settings for accessibility modules.
134     * <p>
135     * In some cases, a matching Activity may not exist, so ensure you
136     * safeguard against this.
137     * <p>
138     * Input: Nothing.
139     * <p>
140     * Output: Nothing.
141     */
142    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
143    public static final String ACTION_ACCESSIBILITY_SETTINGS =
144            "android.settings.ACCESSIBILITY_SETTINGS";
145
146    /**
147     * Activity Action: Show settings to allow configuration of security and
148     * location privacy.
149     * <p>
150     * In some cases, a matching Activity may not exist, so ensure you
151     * safeguard against this.
152     * <p>
153     * Input: Nothing.
154     * <p>
155     * Output: Nothing.
156     */
157    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
158    public static final String ACTION_SECURITY_SETTINGS =
159            "android.settings.SECURITY_SETTINGS";
160
161    /**
162     * Activity Action: Show settings to allow configuration of privacy options.
163     * <p>
164     * In some cases, a matching Activity may not exist, so ensure you
165     * safeguard against this.
166     * <p>
167     * Input: Nothing.
168     * <p>
169     * Output: Nothing.
170     */
171    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
172    public static final String ACTION_PRIVACY_SETTINGS =
173            "android.settings.PRIVACY_SETTINGS";
174
175    /**
176     * Activity Action: Show settings to allow configuration of Wi-Fi.
177
178     * <p>
179     * In some cases, a matching Activity may not exist, so ensure you
180     * safeguard against this.
181     * <p>
182     * Input: Nothing.
183     * <p>
184     * Output: Nothing.
185
186     */
187    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
188    public static final String ACTION_WIFI_SETTINGS =
189            "android.settings.WIFI_SETTINGS";
190
191    /**
192     * Activity Action: Show settings to allow configuration of a static IP
193     * address for Wi-Fi.
194     * <p>
195     * In some cases, a matching Activity may not exist, so ensure you safeguard
196     * against this.
197     * <p>
198     * Input: Nothing.
199     * <p>
200     * Output: Nothing.
201     */
202    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
203    public static final String ACTION_WIFI_IP_SETTINGS =
204            "android.settings.WIFI_IP_SETTINGS";
205
206    /**
207     * Activity Action: Show settings to allow configuration of Bluetooth.
208     * <p>
209     * In some cases, a matching Activity may not exist, so ensure you
210     * safeguard against this.
211     * <p>
212     * Input: Nothing.
213     * <p>
214     * Output: Nothing.
215     */
216    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
217    public static final String ACTION_BLUETOOTH_SETTINGS =
218            "android.settings.BLUETOOTH_SETTINGS";
219
220    /**
221     * Activity Action: Show settings to allow configuration of Wifi Displays.
222     * <p>
223     * In some cases, a matching Activity may not exist, so ensure you
224     * safeguard against this.
225     * <p>
226     * Input: Nothing.
227     * <p>
228     * Output: Nothing.
229     * @hide
230     */
231    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
232    public static final String ACTION_WIFI_DISPLAY_SETTINGS =
233            "android.settings.WIFI_DISPLAY_SETTINGS";
234
235    /**
236     * Activity Action: Show settings to allow configuration of date and time.
237     * <p>
238     * In some cases, a matching Activity may not exist, so ensure you
239     * safeguard against this.
240     * <p>
241     * Input: Nothing.
242     * <p>
243     * Output: Nothing.
244     */
245    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
246    public static final String ACTION_DATE_SETTINGS =
247            "android.settings.DATE_SETTINGS";
248
249    /**
250     * Activity Action: Show settings to allow configuration of sound and volume.
251     * <p>
252     * In some cases, a matching Activity may not exist, so ensure you
253     * safeguard against this.
254     * <p>
255     * Input: Nothing.
256     * <p>
257     * Output: Nothing.
258     */
259    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
260    public static final String ACTION_SOUND_SETTINGS =
261            "android.settings.SOUND_SETTINGS";
262
263    /**
264     * Activity Action: Show settings to allow configuration of display.
265     * <p>
266     * In some cases, a matching Activity may not exist, so ensure you
267     * safeguard against this.
268     * <p>
269     * Input: Nothing.
270     * <p>
271     * Output: Nothing.
272     */
273    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
274    public static final String ACTION_DISPLAY_SETTINGS =
275            "android.settings.DISPLAY_SETTINGS";
276
277    /**
278     * Activity Action: Show settings to allow configuration of locale.
279     * <p>
280     * In some cases, a matching Activity may not exist, so ensure you
281     * safeguard against this.
282     * <p>
283     * Input: Nothing.
284     * <p>
285     * Output: Nothing.
286     */
287    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
288    public static final String ACTION_LOCALE_SETTINGS =
289            "android.settings.LOCALE_SETTINGS";
290
291    /**
292     * Activity Action: Show settings to configure input methods, in particular
293     * allowing the user to enable input methods.
294     * <p>
295     * In some cases, a matching Activity may not exist, so ensure you
296     * safeguard against this.
297     * <p>
298     * Input: Nothing.
299     * <p>
300     * Output: Nothing.
301     */
302    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
303    public static final String ACTION_INPUT_METHOD_SETTINGS =
304            "android.settings.INPUT_METHOD_SETTINGS";
305
306    /**
307     * Activity Action: Show settings to enable/disable input method subtypes.
308     * <p>
309     * In some cases, a matching Activity may not exist, so ensure you
310     * safeguard against this.
311     * <p>
312     * To tell which input method's subtypes are displayed in the settings, add
313     * {@link #EXTRA_INPUT_METHOD_ID} extra to this Intent with the input method id.
314     * If there is no extra in this Intent, subtypes from all installed input methods
315     * will be displayed in the settings.
316     *
317     * @see android.view.inputmethod.InputMethodInfo#getId
318     * <p>
319     * Input: Nothing.
320     * <p>
321     * Output: Nothing.
322     */
323    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
324    public static final String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
325            "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
326
327    /**
328     * Activity Action: Show a dialog to select input method.
329     * <p>
330     * In some cases, a matching Activity may not exist, so ensure you
331     * safeguard against this.
332     * <p>
333     * Input: Nothing.
334     * <p>
335     * Output: Nothing.
336     * @hide
337     */
338    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
339    public static final String ACTION_SHOW_INPUT_METHOD_PICKER =
340            "android.settings.SHOW_INPUT_METHOD_PICKER";
341
342    /**
343     * Activity Action: Show settings to manage the user input dictionary.
344     * <p>
345     * In some cases, a matching Activity may not exist, so ensure you
346     * safeguard against this.
347     * <p>
348     * Input: Nothing.
349     * <p>
350     * Output: Nothing.
351     */
352    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
353    public static final String ACTION_USER_DICTIONARY_SETTINGS =
354            "android.settings.USER_DICTIONARY_SETTINGS";
355
356    /**
357     * Activity Action: Adds a word to the user dictionary.
358     * <p>
359     * In some cases, a matching Activity may not exist, so ensure you
360     * safeguard against this.
361     * <p>
362     * Input: An extra with key <code>word</code> that contains the word
363     * that should be added to the dictionary.
364     * <p>
365     * Output: Nothing.
366     *
367     * @hide
368     */
369    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
370    public static final String ACTION_USER_DICTIONARY_INSERT =
371            "com.android.settings.USER_DICTIONARY_INSERT";
372
373    /**
374     * Activity Action: Show settings to allow configuration of application-related settings.
375     * <p>
376     * In some cases, a matching Activity may not exist, so ensure you
377     * safeguard against this.
378     * <p>
379     * Input: Nothing.
380     * <p>
381     * Output: Nothing.
382     */
383    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
384    public static final String ACTION_APPLICATION_SETTINGS =
385            "android.settings.APPLICATION_SETTINGS";
386
387    /**
388     * Activity Action: Show settings to allow configuration of application
389     * development-related settings.  As of
390     * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} this action is
391     * a required part of the platform.
392     * <p>
393     * Input: Nothing.
394     * <p>
395     * Output: Nothing.
396     */
397    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
398    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
399            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
400
401    /**
402     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
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_QUICK_LAUNCH_SETTINGS =
413            "android.settings.QUICK_LAUNCH_SETTINGS";
414
415    /**
416     * Activity Action: Show settings to manage installed applications.
417     * <p>
418     * In some cases, a matching Activity may not exist, so ensure you
419     * safeguard against this.
420     * <p>
421     * Input: Nothing.
422     * <p>
423     * Output: Nothing.
424     */
425    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
426    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
427            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
428
429    /**
430     * Activity Action: Show settings to manage all applications.
431     * <p>
432     * In some cases, a matching Activity may not exist, so ensure you
433     * safeguard against this.
434     * <p>
435     * Input: Nothing.
436     * <p>
437     * Output: Nothing.
438     */
439    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
440    public static final String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
441            "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS";
442
443    /**
444     * Activity Action: Show screen of details about a particular application.
445     * <p>
446     * In some cases, a matching Activity may not exist, so ensure you
447     * safeguard against this.
448     * <p>
449     * Input: The Intent's data URI specifies the application package name
450     * to be shown, with the "package" scheme.  That is "package:com.my.app".
451     * <p>
452     * Output: Nothing.
453     */
454    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
455    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
456            "android.settings.APPLICATION_DETAILS_SETTINGS";
457
458    /**
459     * Activity Action: Show settings for system update functionality.
460     * <p>
461     * In some cases, a matching Activity may not exist, so ensure you
462     * safeguard against this.
463     * <p>
464     * Input: Nothing.
465     * <p>
466     * Output: Nothing.
467     *
468     * @hide
469     */
470    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
471    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
472            "android.settings.SYSTEM_UPDATE_SETTINGS";
473
474    /**
475     * Activity Action: Show settings to allow configuration of sync settings.
476     * <p>
477     * In some cases, a matching Activity may not exist, so ensure you
478     * safeguard against this.
479     * <p>
480     * The account types available to add via the add account button may be restricted by adding an
481     * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's
482     * authorities. Only account types which can sync with that content provider will be offered to
483     * the user.
484     * <p>
485     * Input: Nothing.
486     * <p>
487     * Output: Nothing.
488     */
489    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
490    public static final String ACTION_SYNC_SETTINGS =
491            "android.settings.SYNC_SETTINGS";
492
493    /**
494     * Activity Action: Show add account screen for creating a new account.
495     * <p>
496     * In some cases, a matching Activity may not exist, so ensure you
497     * safeguard against this.
498     * <p>
499     * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES}
500     * extra to the Intent with one or more syncable content provider's authorities.  Only account
501     * types which can sync with that content provider will be offered to the user.
502     * <p>
503     * Input: Nothing.
504     * <p>
505     * Output: Nothing.
506     */
507    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
508    public static final String ACTION_ADD_ACCOUNT =
509            "android.settings.ADD_ACCOUNT_SETTINGS";
510
511    /**
512     * Activity Action: Show settings for selecting the network operator.
513     * <p>
514     * In some cases, a matching Activity may not exist, so ensure you
515     * safeguard against this.
516     * <p>
517     * Input: Nothing.
518     * <p>
519     * Output: Nothing.
520     */
521    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
522    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
523            "android.settings.NETWORK_OPERATOR_SETTINGS";
524
525    /**
526     * Activity Action: Show settings for selection of 2G/3G.
527     * <p>
528     * In some cases, a matching Activity may not exist, so ensure you
529     * safeguard against this.
530     * <p>
531     * Input: Nothing.
532     * <p>
533     * Output: Nothing.
534     */
535    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
536    public static final String ACTION_DATA_ROAMING_SETTINGS =
537            "android.settings.DATA_ROAMING_SETTINGS";
538
539    /**
540     * Activity Action: Show settings for internal storage.
541     * <p>
542     * In some cases, a matching Activity may not exist, so ensure you
543     * safeguard against this.
544     * <p>
545     * Input: Nothing.
546     * <p>
547     * Output: Nothing.
548     */
549    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
550    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
551            "android.settings.INTERNAL_STORAGE_SETTINGS";
552    /**
553     * Activity Action: Show settings for memory card storage.
554     * <p>
555     * In some cases, a matching Activity may not exist, so ensure you
556     * safeguard against this.
557     * <p>
558     * Input: Nothing.
559     * <p>
560     * Output: Nothing.
561     */
562    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
563    public static final String ACTION_MEMORY_CARD_SETTINGS =
564            "android.settings.MEMORY_CARD_SETTINGS";
565
566    /**
567     * Activity Action: Show settings for global search.
568     * <p>
569     * In some cases, a matching Activity may not exist, so ensure you
570     * safeguard against this.
571     * <p>
572     * Input: Nothing.
573     * <p>
574     * Output: Nothing
575     */
576    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
577    public static final String ACTION_SEARCH_SETTINGS =
578        "android.search.action.SEARCH_SETTINGS";
579
580    /**
581     * Activity Action: Show general device information settings (serial
582     * number, software version, phone number, etc.).
583     * <p>
584     * In some cases, a matching Activity may not exist, so ensure you
585     * safeguard against this.
586     * <p>
587     * Input: Nothing.
588     * <p>
589     * Output: Nothing
590     */
591    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
592    public static final String ACTION_DEVICE_INFO_SETTINGS =
593        "android.settings.DEVICE_INFO_SETTINGS";
594
595    /**
596     * Activity Action: Show NFC settings.
597     * <p>
598     * This shows UI that allows NFC to be turned on or off.
599     * <p>
600     * In some cases, a matching Activity may not exist, so ensure you
601     * safeguard against this.
602     * <p>
603     * Input: Nothing.
604     * <p>
605     * Output: Nothing
606     * @see android.nfc.NfcAdapter#isEnabled()
607     */
608    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
609    public static final String ACTION_NFC_SETTINGS = "android.settings.NFC_SETTINGS";
610
611    /**
612     * Activity Action: Show NFC Sharing settings.
613     * <p>
614     * This shows UI that allows NDEF Push (Android Beam) to be turned on or
615     * off.
616     * <p>
617     * In some cases, a matching Activity may not exist, so ensure you
618     * safeguard against this.
619     * <p>
620     * Input: Nothing.
621     * <p>
622     * Output: Nothing
623     * @see android.nfc.NfcAdapter#isNdefPushEnabled()
624     */
625    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
626    public static final String ACTION_NFCSHARING_SETTINGS =
627        "android.settings.NFCSHARING_SETTINGS";
628
629    // End of Intent actions for Settings
630
631    /**
632     * @hide - Private call() method on SettingsProvider to read from 'system' table.
633     */
634    public static final String CALL_METHOD_GET_SYSTEM = "GET_system";
635
636    /**
637     * @hide - Private call() method on SettingsProvider to read from 'secure' table.
638     */
639    public static final String CALL_METHOD_GET_SECURE = "GET_secure";
640
641    /**
642     * @hide - Private call() method on SettingsProvider to read from 'global' table.
643     */
644    public static final String CALL_METHOD_GET_GLOBAL = "GET_global";
645
646    /**
647     * @hide - User handle argument extra to the fast-path call()-based requests
648     */
649    public static final String CALL_METHOD_USER_KEY = "_user";
650
651    /** @hide - Private call() method to write to 'system' table */
652    public static final String CALL_METHOD_PUT_SYSTEM = "PUT_system";
653
654    /** @hide - Private call() method to write to 'secure' table */
655    public static final String CALL_METHOD_PUT_SECURE = "PUT_secure";
656
657    /** @hide - Private call() method to write to 'global' table */
658    public static final String CALL_METHOD_PUT_GLOBAL= "PUT_global";
659
660    /**
661     * Activity Extra: Limit available options in launched activity based on the given authority.
662     * <p>
663     * This can be passed as an extra field in an Activity Intent with one or more syncable content
664     * provider's authorities as a String[]. This field is used by some intents to alter the
665     * behavior of the called activity.
666     * <p>
667     * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based
668     * on the authority given.
669     */
670    public static final String EXTRA_AUTHORITIES =
671            "authorities";
672
673    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
674
675    private static final String JID_RESOURCE_PREFIX = "android";
676
677    public static final String AUTHORITY = "settings";
678
679    private static final String TAG = "Settings";
680    private static final boolean LOCAL_LOGV = false;
681
682    public static class SettingNotFoundException extends AndroidException {
683        public SettingNotFoundException(String msg) {
684            super(msg);
685        }
686    }
687
688    /**
689     * Common base for tables of name/value settings.
690     */
691    public static class NameValueTable implements BaseColumns {
692        public static final String NAME = "name";
693        public static final String VALUE = "value";
694
695        protected static boolean putString(ContentResolver resolver, Uri uri,
696                String name, String value) {
697            // The database will take care of replacing duplicates.
698            try {
699                ContentValues values = new ContentValues();
700                values.put(NAME, name);
701                values.put(VALUE, value);
702                resolver.insert(uri, values);
703                return true;
704            } catch (SQLException e) {
705                Log.w(TAG, "Can't set key " + name + " in " + uri, e);
706                return false;
707            }
708        }
709
710        public static Uri getUriFor(Uri uri, String name) {
711            return Uri.withAppendedPath(uri, name);
712        }
713    }
714
715    // Thread-safe.
716    private static class NameValueCache {
717        private final String mVersionSystemProperty;
718        private final Uri mUri;
719
720        private static final String[] SELECT_VALUE =
721            new String[] { Settings.NameValueTable.VALUE };
722        private static final String NAME_EQ_PLACEHOLDER = "name=?";
723
724        // Must synchronize on 'this' to access mValues and mValuesVersion.
725        private final HashMap<String, String> mValues = new HashMap<String, String>();
726        private long mValuesVersion = 0;
727
728        // Initially null; set lazily and held forever.  Synchronized on 'this'.
729        private IContentProvider mContentProvider = null;
730
731        // The method we'll call (or null, to not use) on the provider
732        // for the fast path of retrieving settings.
733        private final String mCallGetCommand;
734        private final String mCallSetCommand;
735
736        public NameValueCache(String versionSystemProperty, Uri uri,
737                String getCommand, String setCommand) {
738            mVersionSystemProperty = versionSystemProperty;
739            mUri = uri;
740            mCallGetCommand = getCommand;
741            mCallSetCommand = setCommand;
742        }
743
744        private IContentProvider lazyGetProvider(ContentResolver cr) {
745            IContentProvider cp = null;
746            synchronized (this) {
747                cp = mContentProvider;
748                if (cp == null) {
749                    cp = mContentProvider = cr.acquireProvider(mUri.getAuthority());
750                }
751            }
752            return cp;
753        }
754
755        public boolean putStringForUser(ContentResolver cr, String name, String value,
756                final int userHandle) {
757            try {
758                Bundle arg = new Bundle();
759                arg.putString(Settings.NameValueTable.VALUE, value);
760                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
761                IContentProvider cp = lazyGetProvider(cr);
762                cp.call(mCallSetCommand, name, arg);
763            } catch (RemoteException e) {
764                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
765                return false;
766            }
767            return true;
768        }
769
770        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
771            final boolean isSelf = (userHandle == UserHandle.myUserId());
772            if (isSelf) {
773                long newValuesVersion = SystemProperties.getLong(mVersionSystemProperty, 0);
774
775                // Our own user's settings data uses a client-side cache
776                synchronized (this) {
777                    if (mValuesVersion != newValuesVersion) {
778                        if (LOCAL_LOGV || false) {
779                            Log.v(TAG, "invalidate [" + mUri.getLastPathSegment() + "]: current "
780                                    + newValuesVersion + " != cached " + mValuesVersion);
781                        }
782
783                        mValues.clear();
784                        mValuesVersion = newValuesVersion;
785                    }
786
787                    if (mValues.containsKey(name)) {
788                        return mValues.get(name);  // Could be null, that's OK -- negative caching
789                    }
790                }
791            } else {
792                if (LOCAL_LOGV) Log.v(TAG, "get setting for user " + userHandle
793                        + " by user " + UserHandle.myUserId() + " so skipping cache");
794            }
795
796            IContentProvider cp = lazyGetProvider(cr);
797
798            // Try the fast path first, not using query().  If this
799            // fails (alternate Settings provider that doesn't support
800            // this interface?) then we fall back to the query/table
801            // interface.
802            if (mCallGetCommand != null) {
803                try {
804                    Bundle args = null;
805                    if (!isSelf) {
806                        args = new Bundle();
807                        args.putInt(CALL_METHOD_USER_KEY, userHandle);
808                    }
809                    Bundle b = cp.call(mCallGetCommand, name, args);
810                    if (b != null) {
811                        String value = b.getPairValue();
812                        // Don't update our cache for reads of other users' data
813                        if (isSelf) {
814                            synchronized (this) {
815                                mValues.put(name, value);
816                            }
817                        } else {
818                            if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
819                                    + " by " + UserHandle.myUserId()
820                                    + " so not updating cache");
821                        }
822                        return value;
823                    }
824                    // If the response Bundle is null, we fall through
825                    // to the query interface below.
826                } catch (RemoteException e) {
827                    // Not supported by the remote side?  Fall through
828                    // to query().
829                }
830            }
831
832            Cursor c = null;
833            try {
834                c = cp.query(mUri, SELECT_VALUE, NAME_EQ_PLACEHOLDER,
835                             new String[]{name}, null, null);
836                if (c == null) {
837                    Log.w(TAG, "Can't get key " + name + " from " + mUri);
838                    return null;
839                }
840
841                String value = c.moveToNext() ? c.getString(0) : null;
842                synchronized (this) {
843                    mValues.put(name, value);
844                }
845                if (LOCAL_LOGV) {
846                    Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +
847                            name + " = " + (value == null ? "(null)" : value));
848                }
849                return value;
850            } catch (RemoteException e) {
851                Log.w(TAG, "Can't get key " + name + " from " + mUri, e);
852                return null;  // Return null, but don't cache it.
853            } finally {
854                if (c != null) c.close();
855            }
856        }
857    }
858
859    /**
860     * System settings, containing miscellaneous system preferences.  This
861     * table holds simple name/value pairs.  There are convenience
862     * functions for accessing individual settings entries.
863     */
864    public static final class System extends NameValueTable {
865        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version";
866
867        /**
868         * The content:// style URL for this table
869         */
870        public static final Uri CONTENT_URI =
871            Uri.parse("content://" + AUTHORITY + "/system");
872
873        private static final NameValueCache sNameValueCache = new NameValueCache(
874                SYS_PROP_SETTING_VERSION,
875                CONTENT_URI,
876                CALL_METHOD_GET_SYSTEM,
877                CALL_METHOD_PUT_SYSTEM);
878
879        private static final HashSet<String> MOVED_TO_SECURE;
880        static {
881            MOVED_TO_SECURE = new HashSet<String>(30);
882            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
883            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
884            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
885            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
886            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
887            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
888            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
889            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
890            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
891            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
892            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
893            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
894            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
895            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
896            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
897            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
898            MOVED_TO_SECURE.add(Secure.WIFI_ON);
899            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
900            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
901            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
902            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
903            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
904            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
905            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
906            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
907            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
908            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
909            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
910        }
911
912        private static final HashSet<String> MOVED_TO_GLOBAL;
913        private static final HashSet<String> MOVED_TO_SECURE_THEN_GLOBAL;
914        static {
915            MOVED_TO_GLOBAL = new HashSet<String>();
916            MOVED_TO_SECURE_THEN_GLOBAL = new HashSet<String>();
917
918            // these were originally in system but migrated to secure in the past,
919            // so are duplicated in the Secure.* namespace
920            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.ADB_ENABLED);
921            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.BLUETOOTH_ON);
922            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DATA_ROAMING);
923            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.DEVICE_PROVISIONED);
924            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.INSTALL_NON_MARKET_APPS);
925            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.USB_MASS_STORAGE_ENABLED);
926            MOVED_TO_SECURE_THEN_GLOBAL.add(Global.HTTP_PROXY);
927
928            // these are moving directly from system to global
929            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_ON);
930            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_RADIOS);
931            MOVED_TO_GLOBAL.add(Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
932            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME);
933            MOVED_TO_GLOBAL.add(Settings.Global.AUTO_TIME_ZONE);
934            MOVED_TO_GLOBAL.add(Settings.Global.CAR_DOCK_SOUND);
935            MOVED_TO_GLOBAL.add(Settings.Global.CAR_UNDOCK_SOUND);
936            MOVED_TO_GLOBAL.add(Settings.Global.DESK_DOCK_SOUND);
937            MOVED_TO_GLOBAL.add(Settings.Global.DESK_UNDOCK_SOUND);
938            MOVED_TO_GLOBAL.add(Settings.Global.DOCK_SOUNDS_ENABLED);
939            MOVED_TO_GLOBAL.add(Settings.Global.LOCK_SOUND);
940            MOVED_TO_GLOBAL.add(Settings.Global.UNLOCK_SOUND);
941            MOVED_TO_GLOBAL.add(Settings.Global.LOW_BATTERY_SOUND);
942            MOVED_TO_GLOBAL.add(Settings.Global.POWER_SOUNDS_ENABLED);
943            MOVED_TO_GLOBAL.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
944            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SLEEP_POLICY);
945            MOVED_TO_GLOBAL.add(Settings.Global.MODE_RINGER);
946            MOVED_TO_GLOBAL.add(Settings.Global.WINDOW_ANIMATION_SCALE);
947            MOVED_TO_GLOBAL.add(Settings.Global.TRANSITION_ANIMATION_SCALE);
948            MOVED_TO_GLOBAL.add(Settings.Global.ANIMATOR_DURATION_SCALE);
949            MOVED_TO_GLOBAL.add(Settings.Global.FANCY_IME_ANIMATIONS);
950            MOVED_TO_GLOBAL.add(Settings.Global.COMPATIBILITY_MODE);
951            MOVED_TO_GLOBAL.add(Settings.Global.EMERGENCY_TONE);
952            MOVED_TO_GLOBAL.add(Settings.Global.CALL_AUTO_RETRY);
953            MOVED_TO_GLOBAL.add(Settings.Global.DEBUG_APP);
954            MOVED_TO_GLOBAL.add(Settings.Global.WAIT_FOR_DEBUGGER);
955            MOVED_TO_GLOBAL.add(Settings.Global.SHOW_PROCESSES);
956            MOVED_TO_GLOBAL.add(Settings.Global.ALWAYS_FINISH_ACTIVITIES);
957        }
958
959        /** @hide */
960        public static void getMovedKeys(HashSet<String> outKeySet) {
961            outKeySet.addAll(MOVED_TO_GLOBAL);
962            outKeySet.addAll(MOVED_TO_SECURE_THEN_GLOBAL);
963        }
964
965        /** @hide */
966        public static void getNonLegacyMovedKeys(HashSet<String> outKeySet) {
967            outKeySet.addAll(MOVED_TO_GLOBAL);
968        }
969
970        /**
971         * Look up a name in the database.
972         * @param resolver to access the database with
973         * @param name to look up in the table
974         * @return the corresponding value, or null if not present
975         */
976        public static String getString(ContentResolver resolver, String name) {
977            return getStringForUser(resolver, name, UserHandle.myUserId());
978        }
979
980        /** @hide */
981        public static String getStringForUser(ContentResolver resolver, String name,
982                int userHandle) {
983            if (MOVED_TO_SECURE.contains(name)) {
984                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
985                        + " to android.provider.Settings.Secure, returning read-only value.");
986                return Secure.getStringForUser(resolver, name, userHandle);
987            }
988            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
989                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
990                        + " to android.provider.Settings.Global, returning read-only value.");
991                return Global.getStringForUser(resolver, name, userHandle);
992            }
993            return sNameValueCache.getStringForUser(resolver, name, userHandle);
994        }
995
996        /**
997         * Store a name/value pair into the database.
998         * @param resolver to access the database with
999         * @param name to store
1000         * @param value to associate with the name
1001         * @return true if the value was set, false on database errors
1002         */
1003        public static boolean putString(ContentResolver resolver, String name, String value) {
1004            return putStringForUser(resolver, name, value, UserHandle.myUserId());
1005        }
1006
1007        /** @hide */
1008        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
1009                int userHandle) {
1010            if (MOVED_TO_SECURE.contains(name)) {
1011                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1012                        + " to android.provider.Settings.Secure, value is unchanged.");
1013                return false;
1014            }
1015            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
1016                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1017                        + " to android.provider.Settings.Global, value is unchanged.");
1018                return false;
1019            }
1020            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
1021        }
1022
1023        /**
1024         * Construct the content URI for a particular name/value pair,
1025         * useful for monitoring changes with a ContentObserver.
1026         * @param name to look up in the table
1027         * @return the corresponding content URI, or null if not present
1028         */
1029        public static Uri getUriFor(String name) {
1030            if (MOVED_TO_SECURE.contains(name)) {
1031                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1032                    + " to android.provider.Settings.Secure, returning Secure URI.");
1033                return Secure.getUriFor(Secure.CONTENT_URI, name);
1034            }
1035            if (MOVED_TO_GLOBAL.contains(name) || MOVED_TO_SECURE_THEN_GLOBAL.contains(name)) {
1036                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
1037                        + " to android.provider.Settings.Global, returning read-only global URI.");
1038                return Global.getUriFor(Global.CONTENT_URI, name);
1039            }
1040            return getUriFor(CONTENT_URI, name);
1041        }
1042
1043        /**
1044         * Convenience function for retrieving a single system settings value
1045         * as an integer.  Note that internally setting values are always
1046         * stored as strings; this function converts the string to an integer
1047         * for you.  The default value will be returned if the setting is
1048         * not defined or not an integer.
1049         *
1050         * @param cr The ContentResolver to access.
1051         * @param name The name of the setting to retrieve.
1052         * @param def Value to return if the setting is not defined.
1053         *
1054         * @return The setting's current value, or 'def' if it is not defined
1055         * or not a valid integer.
1056         */
1057        public static int getInt(ContentResolver cr, String name, int def) {
1058            return getIntForUser(cr, name, def, UserHandle.myUserId());
1059        }
1060
1061        /** @hide */
1062        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
1063            String v = getStringForUser(cr, name, userHandle);
1064            try {
1065                return v != null ? Integer.parseInt(v) : def;
1066            } catch (NumberFormatException e) {
1067                return def;
1068            }
1069        }
1070
1071        /**
1072         * Convenience function for retrieving a single system settings value
1073         * as an integer.  Note that internally setting values are always
1074         * stored as strings; this function converts the string to an integer
1075         * for you.
1076         * <p>
1077         * This version does not take a default value.  If the setting has not
1078         * been set, or the string value is not a number,
1079         * it throws {@link SettingNotFoundException}.
1080         *
1081         * @param cr The ContentResolver to access.
1082         * @param name The name of the setting to retrieve.
1083         *
1084         * @throws SettingNotFoundException Thrown if a setting by the given
1085         * name can't be found or the setting value is not an integer.
1086         *
1087         * @return The setting's current value.
1088         */
1089        public static int getInt(ContentResolver cr, String name)
1090                throws SettingNotFoundException {
1091            return getIntForUser(cr, name, UserHandle.myUserId());
1092        }
1093
1094        /** @hide */
1095        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
1096                throws SettingNotFoundException {
1097            String v = getStringForUser(cr, name, userHandle);
1098            try {
1099                return Integer.parseInt(v);
1100            } catch (NumberFormatException e) {
1101                throw new SettingNotFoundException(name);
1102            }
1103        }
1104
1105        /**
1106         * Convenience function for updating a single settings value as an
1107         * integer. This will either create a new entry in the table if the
1108         * given name does not exist, or modify the value of the existing row
1109         * with that name.  Note that internally setting values are always
1110         * stored as strings, so this function converts the given value to a
1111         * string before storing it.
1112         *
1113         * @param cr The ContentResolver to access.
1114         * @param name The name of the setting to modify.
1115         * @param value The new value for the setting.
1116         * @return true if the value was set, false on database errors
1117         */
1118        public static boolean putInt(ContentResolver cr, String name, int value) {
1119            return putIntForUser(cr, name, value, UserHandle.myUserId());
1120        }
1121
1122        /** @hide */
1123        public static boolean putIntForUser(ContentResolver cr, String name, int value,
1124                int userHandle) {
1125            return putStringForUser(cr, name, Integer.toString(value), userHandle);
1126        }
1127
1128        /**
1129         * Convenience function for retrieving a single system settings value
1130         * as a {@code long}.  Note that internally setting values are always
1131         * stored as strings; this function converts the string to a {@code long}
1132         * for you.  The default value will be returned if the setting is
1133         * not defined or not a {@code long}.
1134         *
1135         * @param cr The ContentResolver to access.
1136         * @param name The name of the setting to retrieve.
1137         * @param def Value to return if the setting is not defined.
1138         *
1139         * @return The setting's current value, or 'def' if it is not defined
1140         * or not a valid {@code long}.
1141         */
1142        public static long getLong(ContentResolver cr, String name, long def) {
1143            return getLongForUser(cr, name, def, UserHandle.myUserId());
1144        }
1145
1146        /** @hide */
1147        public static long getLongForUser(ContentResolver cr, String name, long def,
1148                int userHandle) {
1149            String valString = getStringForUser(cr, name, userHandle);
1150            long value;
1151            try {
1152                value = valString != null ? Long.parseLong(valString) : def;
1153            } catch (NumberFormatException e) {
1154                value = def;
1155            }
1156            return value;
1157        }
1158
1159        /**
1160         * Convenience function for retrieving a single system settings value
1161         * as a {@code long}.  Note that internally setting values are always
1162         * stored as strings; this function converts the string to a {@code long}
1163         * for you.
1164         * <p>
1165         * This version does not take a default value.  If the setting has not
1166         * been set, or the string value is not a number,
1167         * it throws {@link SettingNotFoundException}.
1168         *
1169         * @param cr The ContentResolver to access.
1170         * @param name The name of the setting to retrieve.
1171         *
1172         * @return The setting's current value.
1173         * @throws SettingNotFoundException Thrown if a setting by the given
1174         * name can't be found or the setting value is not an integer.
1175         */
1176        public static long getLong(ContentResolver cr, String name)
1177                throws SettingNotFoundException {
1178            return getLongForUser(cr, name, UserHandle.myUserId());
1179        }
1180
1181        /** @hide */
1182        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
1183                throws SettingNotFoundException {
1184            String valString = getStringForUser(cr, name, userHandle);
1185            try {
1186                return Long.parseLong(valString);
1187            } catch (NumberFormatException e) {
1188                throw new SettingNotFoundException(name);
1189            }
1190        }
1191
1192        /**
1193         * Convenience function for updating a single settings value as a long
1194         * integer. This will either create a new entry in the table if the
1195         * given name does not exist, or modify the value of the existing row
1196         * with that name.  Note that internally setting values are always
1197         * stored as strings, so this function converts the given value to a
1198         * string before storing it.
1199         *
1200         * @param cr The ContentResolver to access.
1201         * @param name The name of the setting to modify.
1202         * @param value The new value for the setting.
1203         * @return true if the value was set, false on database errors
1204         */
1205        public static boolean putLong(ContentResolver cr, String name, long value) {
1206            return putLongForUser(cr, name, value, UserHandle.myUserId());
1207        }
1208
1209        /** @hide */
1210        public static boolean putLongForUser(ContentResolver cr, String name, long value,
1211                int userHandle) {
1212            return putStringForUser(cr, name, Long.toString(value), userHandle);
1213        }
1214
1215        /**
1216         * Convenience function for retrieving a single system settings value
1217         * as a floating point number.  Note that internally setting values are
1218         * always stored as strings; this function converts the string to an
1219         * float for you. The default value will be returned if the setting
1220         * is not defined or not a valid float.
1221         *
1222         * @param cr The ContentResolver to access.
1223         * @param name The name of the setting to retrieve.
1224         * @param def Value to return if the setting is not defined.
1225         *
1226         * @return The setting's current value, or 'def' if it is not defined
1227         * or not a valid float.
1228         */
1229        public static float getFloat(ContentResolver cr, String name, float def) {
1230            return getFloatForUser(cr, name, def, UserHandle.myUserId());
1231        }
1232
1233        /** @hide */
1234        public static float getFloatForUser(ContentResolver cr, String name, float def,
1235                int userHandle) {
1236            String v = getStringForUser(cr, name, userHandle);
1237            try {
1238                return v != null ? Float.parseFloat(v) : def;
1239            } catch (NumberFormatException e) {
1240                return def;
1241            }
1242        }
1243
1244        /**
1245         * Convenience function for retrieving a single system settings value
1246         * as a float.  Note that internally setting values are always
1247         * stored as strings; this function converts the string to a float
1248         * for you.
1249         * <p>
1250         * This version does not take a default value.  If the setting has not
1251         * been set, or the string value is not a number,
1252         * it throws {@link SettingNotFoundException}.
1253         *
1254         * @param cr The ContentResolver to access.
1255         * @param name The name of the setting to retrieve.
1256         *
1257         * @throws SettingNotFoundException Thrown if a setting by the given
1258         * name can't be found or the setting value is not a float.
1259         *
1260         * @return The setting's current value.
1261         */
1262        public static float getFloat(ContentResolver cr, String name)
1263                throws SettingNotFoundException {
1264            return getFloatForUser(cr, name, UserHandle.myUserId());
1265        }
1266
1267        /** @hide */
1268        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
1269                throws SettingNotFoundException {
1270            String v = getStringForUser(cr, name, userHandle);
1271            if (v == null) {
1272                throw new SettingNotFoundException(name);
1273            }
1274            try {
1275                return Float.parseFloat(v);
1276            } catch (NumberFormatException e) {
1277                throw new SettingNotFoundException(name);
1278            }
1279        }
1280
1281        /**
1282         * Convenience function for updating a single settings value as a
1283         * floating point number. This will either create a new entry in the
1284         * table if the given name does not exist, or modify the value of the
1285         * existing row with that name.  Note that internally setting values
1286         * are always stored as strings, so this function converts the given
1287         * value to a string before storing it.
1288         *
1289         * @param cr The ContentResolver to access.
1290         * @param name The name of the setting to modify.
1291         * @param value The new value for the setting.
1292         * @return true if the value was set, false on database errors
1293         */
1294        public static boolean putFloat(ContentResolver cr, String name, float value) {
1295            return putFloatForUser(cr, name, value, UserHandle.myUserId());
1296        }
1297
1298        /** @hide */
1299        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
1300                int userHandle) {
1301            return putStringForUser(cr, name, Float.toString(value), userHandle);
1302        }
1303
1304        /**
1305         * Convenience function to read all of the current
1306         * configuration-related settings into a
1307         * {@link Configuration} object.
1308         *
1309         * @param cr The ContentResolver to access.
1310         * @param outConfig Where to place the configuration settings.
1311         */
1312        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
1313            getConfigurationForUser(cr, outConfig, UserHandle.myUserId());
1314        }
1315
1316        /** @hide */
1317        public static void getConfigurationForUser(ContentResolver cr, Configuration outConfig,
1318                int userHandle) {
1319            outConfig.fontScale = Settings.System.getFloatForUser(
1320                cr, FONT_SCALE, outConfig.fontScale, userHandle);
1321            if (outConfig.fontScale < 0) {
1322                outConfig.fontScale = 1;
1323            }
1324        }
1325
1326        /**
1327         * @hide Erase the fields in the Configuration that should be applied
1328         * by the settings.
1329         */
1330        public static void clearConfiguration(Configuration inoutConfig) {
1331            inoutConfig.fontScale = 0;
1332        }
1333
1334        /**
1335         * Convenience function to write a batch of configuration-related
1336         * settings from a {@link Configuration} object.
1337         *
1338         * @param cr The ContentResolver to access.
1339         * @param config The settings to write.
1340         * @return true if the values were set, false on database errors
1341         */
1342        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
1343            return putConfigurationForUser(cr, config, UserHandle.myUserId());
1344        }
1345
1346        /** @hide */
1347        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
1348                int userHandle) {
1349            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle);
1350        }
1351
1352        /** @hide */
1353        public static boolean hasInterestingConfigurationChanges(int changes) {
1354            return (changes&ActivityInfo.CONFIG_FONT_SCALE) != 0;
1355        }
1356
1357        /** @deprecated - Do not use */
1358        @Deprecated
1359        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
1360            return getShowGTalkServiceStatusForUser(cr, UserHandle.myUserId());
1361        }
1362
1363        /**
1364         * @hide
1365         * @deprecated - Do not use
1366         */
1367        public static boolean getShowGTalkServiceStatusForUser(ContentResolver cr,
1368                int userHandle) {
1369            return getIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, 0, userHandle) != 0;
1370        }
1371
1372        /** @deprecated - Do not use */
1373        @Deprecated
1374        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
1375            setShowGTalkServiceStatusForUser(cr, flag, UserHandle.myUserId());
1376        }
1377
1378        /**
1379         * @hide
1380         * @deprecated - Do not use
1381         */
1382        @Deprecated
1383        public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean flag,
1384                int userHandle) {
1385            putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
1386        }
1387
1388        /**
1389         * @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
1390         */
1391        @Deprecated
1392        public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN;
1393
1394        /**
1395         * What happens when the user presses the end call button if they're not
1396         * on a call.<br/>
1397         * <b>Values:</b><br/>
1398         * 0 - The end button does nothing.<br/>
1399         * 1 - The end button goes to the home screen.<br/>
1400         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
1401         * 3 - The end button goes to the home screen.  If the user is already on the
1402         * home screen, it puts the device to sleep.
1403         */
1404        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
1405
1406        /**
1407         * END_BUTTON_BEHAVIOR value for "go home".
1408         * @hide
1409         */
1410        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
1411
1412        /**
1413         * END_BUTTON_BEHAVIOR value for "go to sleep".
1414         * @hide
1415         */
1416        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
1417
1418        /**
1419         * END_BUTTON_BEHAVIOR default value.
1420         * @hide
1421         */
1422        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
1423
1424        /**
1425         * Is advanced settings mode turned on. 0 == no, 1 == yes
1426         * @hide
1427         */
1428        public static final String ADVANCED_SETTINGS = "advanced_settings";
1429
1430        /**
1431         * ADVANCED_SETTINGS default value.
1432         * @hide
1433         */
1434        public static final int ADVANCED_SETTINGS_DEFAULT = 0;
1435
1436        /**
1437         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
1438         */
1439        @Deprecated
1440        public static final String AIRPLANE_MODE_ON = Global.AIRPLANE_MODE_ON;
1441
1442        /**
1443         * @deprecated Use {@link android.provider.Settings.Global#RADIO_BLUETOOTH} instead
1444         */
1445        @Deprecated
1446        public static final String RADIO_BLUETOOTH = Global.RADIO_BLUETOOTH;
1447
1448        /**
1449         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIFI} instead
1450         */
1451        @Deprecated
1452        public static final String RADIO_WIFI = Global.RADIO_WIFI;
1453
1454        /**
1455         * @deprecated Use {@link android.provider.Settings.Global#RADIO_WIMAX} instead
1456         * {@hide}
1457         */
1458        @Deprecated
1459        public static final String RADIO_WIMAX = Global.RADIO_WIMAX;
1460
1461        /**
1462         * @deprecated Use {@link android.provider.Settings.Global#RADIO_CELL} instead
1463         */
1464        @Deprecated
1465        public static final String RADIO_CELL = Global.RADIO_CELL;
1466
1467        /**
1468         * @deprecated Use {@link android.provider.Settings.Global#RADIO_NFC} instead
1469         */
1470        @Deprecated
1471        public static final String RADIO_NFC = Global.RADIO_NFC;
1472
1473        /**
1474         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_RADIOS} instead
1475         */
1476        @Deprecated
1477        public static final String AIRPLANE_MODE_RADIOS = Global.AIRPLANE_MODE_RADIOS;
1478
1479        /**
1480         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_TOGGLEABLE_RADIOS} instead
1481         *
1482         * {@hide}
1483         */
1484        @Deprecated
1485        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS =
1486                Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS;
1487
1488        /**
1489         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY} instead
1490         */
1491        @Deprecated
1492        public static final String WIFI_SLEEP_POLICY = Global.WIFI_SLEEP_POLICY;
1493
1494        /**
1495         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_DEFAULT} instead
1496         */
1497        @Deprecated
1498        public static final int WIFI_SLEEP_POLICY_DEFAULT = Global.WIFI_SLEEP_POLICY_DEFAULT;
1499
1500        /**
1501         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED} instead
1502         */
1503        @Deprecated
1504        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED =
1505                Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
1506
1507        /**
1508         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SLEEP_POLICY_NEVER} instead
1509         */
1510        @Deprecated
1511        public static final int WIFI_SLEEP_POLICY_NEVER = Global.WIFI_SLEEP_POLICY_NEVER;
1512
1513        /**
1514         * @deprecated Use {@link android.provider.Settings.Global#MODE_RINGER} instead
1515         */
1516        @Deprecated
1517        public static final String MODE_RINGER = Global.MODE_RINGER;
1518
1519        /**
1520         * Whether to use static IP and other static network attributes.
1521         * <p>
1522         * Set to 1 for true and 0 for false.
1523         *
1524         * @deprecated Use {@link WifiManager} instead
1525         */
1526        @Deprecated
1527        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
1528
1529        /**
1530         * The static IP address.
1531         * <p>
1532         * Example: "192.168.1.51"
1533         *
1534         * @deprecated Use {@link WifiManager} instead
1535         */
1536        @Deprecated
1537        public static final String WIFI_STATIC_IP = "wifi_static_ip";
1538
1539        /**
1540         * If using static IP, the gateway's IP address.
1541         * <p>
1542         * Example: "192.168.1.1"
1543         *
1544         * @deprecated Use {@link WifiManager} instead
1545         */
1546        @Deprecated
1547        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
1548
1549        /**
1550         * If using static IP, the net mask.
1551         * <p>
1552         * Example: "255.255.255.0"
1553         *
1554         * @deprecated Use {@link WifiManager} instead
1555         */
1556        @Deprecated
1557        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
1558
1559        /**
1560         * If using static IP, the primary DNS's IP address.
1561         * <p>
1562         * Example: "192.168.1.1"
1563         *
1564         * @deprecated Use {@link WifiManager} instead
1565         */
1566        @Deprecated
1567        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
1568
1569        /**
1570         * If using static IP, the secondary DNS's IP address.
1571         * <p>
1572         * Example: "192.168.1.2"
1573         *
1574         * @deprecated Use {@link WifiManager} instead
1575         */
1576        @Deprecated
1577        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
1578
1579
1580        /**
1581         * Determines whether remote devices may discover and/or connect to
1582         * this device.
1583         * <P>Type: INT</P>
1584         * 2 -- discoverable and connectable
1585         * 1 -- connectable but not discoverable
1586         * 0 -- neither connectable nor discoverable
1587         */
1588        public static final String BLUETOOTH_DISCOVERABILITY =
1589            "bluetooth_discoverability";
1590
1591        /**
1592         * Bluetooth discoverability timeout.  If this value is nonzero, then
1593         * Bluetooth becomes discoverable for a certain number of seconds,
1594         * after which is becomes simply connectable.  The value is in seconds.
1595         */
1596        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
1597            "bluetooth_discoverability_timeout";
1598
1599        /**
1600         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
1601         * instead
1602         */
1603        @Deprecated
1604        public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
1605
1606        /**
1607         * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
1608         * instead
1609         */
1610        @Deprecated
1611        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
1612
1613        /**
1614         * @deprecated Use
1615         * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
1616         * instead
1617         */
1618        @Deprecated
1619        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
1620            "lock_pattern_tactile_feedback_enabled";
1621
1622
1623        /**
1624         * A formatted string of the next alarm that is set, or the empty string
1625         * if there is no alarm set.
1626         */
1627        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
1628
1629        /**
1630         * Scaling factor for fonts, float.
1631         */
1632        public static final String FONT_SCALE = "font_scale";
1633
1634        /**
1635         * Name of an application package to be debugged.
1636         *
1637         * @deprecated Use {@link Global#DEBUG_APP} instead
1638         */
1639        @Deprecated
1640        public static final String DEBUG_APP = Global.DEBUG_APP;
1641
1642        /**
1643         * If 1, when launching DEBUG_APP it will wait for the debugger before
1644         * starting user code.  If 0, it will run normally.
1645         *
1646         * @deprecated Use {@link Global#WAIT_FOR_DEBUGGER} instead
1647         */
1648        @Deprecated
1649        public static final String WAIT_FOR_DEBUGGER = Global.WAIT_FOR_DEBUGGER;
1650
1651        /**
1652         * Whether or not to dim the screen. 0=no  1=yes
1653         * @deprecated This setting is no longer used.
1654         */
1655        @Deprecated
1656        public static final String DIM_SCREEN = "dim_screen";
1657
1658        /**
1659         * The timeout before the screen turns off.
1660         */
1661        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
1662
1663        /**
1664         * The screen backlight brightness between 0 and 255.
1665         */
1666        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
1667
1668        /**
1669         * Control whether to enable automatic brightness mode.
1670         */
1671        public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
1672
1673        /**
1674         * Adjustment to auto-brightness to make it generally more (>0.0 <1.0)
1675         * or less (<0.0 >-1.0) bright.
1676         * @hide
1677         */
1678        public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj";
1679
1680        /**
1681         * SCREEN_BRIGHTNESS_MODE value for manual mode.
1682         */
1683        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
1684
1685        /**
1686         * SCREEN_BRIGHTNESS_MODE value for automatic mode.
1687         */
1688        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
1689
1690        /**
1691         * Control whether the process CPU usage meter should be shown.
1692         *
1693         * @deprecated Use {@link Global#SHOW_PROCESSES} instead
1694         */
1695        @Deprecated
1696        public static final String SHOW_PROCESSES = Global.SHOW_PROCESSES;
1697
1698        /**
1699         * If 1, the activity manager will aggressively finish activities and
1700         * processes as soon as they are no longer needed.  If 0, the normal
1701         * extended lifetime is used.
1702         *
1703         * @deprecated Use {@link Global#ALWAYS_FINISH_ACTIVITIES} instead
1704         */
1705        @Deprecated
1706        public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
1707
1708        /**
1709         * Determines which streams are affected by ringer mode changes. The
1710         * stream type's bit should be set to 1 if it should be muted when going
1711         * into an inaudible ringer mode.
1712         */
1713        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
1714
1715         /**
1716          * Determines which streams are affected by mute. The
1717          * stream type's bit should be set to 1 if it should be muted when a mute request
1718          * is received.
1719          */
1720         public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
1721
1722        /**
1723         * Whether vibrate is on for different events. This is used internally,
1724         * changing this value will not change the vibrate. See AudioManager.
1725         */
1726        public static final String VIBRATE_ON = "vibrate_on";
1727
1728        /**
1729         * If 1, redirects the system vibrator to all currently attached input devices
1730         * that support vibration.  If there are no such input devices, then the system
1731         * vibrator is used instead.
1732         * If 0, does not register the system vibrator.
1733         *
1734         * This setting is mainly intended to provide a compatibility mechanism for
1735         * applications that only know about the system vibrator and do not use the
1736         * input device vibrator API.
1737         *
1738         * @hide
1739         */
1740        public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices";
1741
1742        /**
1743         * Ringer volume. This is used internally, changing this value will not
1744         * change the volume. See AudioManager.
1745         */
1746        public static final String VOLUME_RING = "volume_ring";
1747
1748        /**
1749         * System/notifications volume. This is used internally, changing this
1750         * value will not change the volume. See AudioManager.
1751         */
1752        public static final String VOLUME_SYSTEM = "volume_system";
1753
1754        /**
1755         * Voice call volume. This is used internally, changing this value will
1756         * not change the volume. See AudioManager.
1757         */
1758        public static final String VOLUME_VOICE = "volume_voice";
1759
1760        /**
1761         * Music/media/gaming volume. This is used internally, changing this
1762         * value will not change the volume. See AudioManager.
1763         */
1764        public static final String VOLUME_MUSIC = "volume_music";
1765
1766        /**
1767         * Alarm volume. This is used internally, changing this
1768         * value will not change the volume. See AudioManager.
1769         */
1770        public static final String VOLUME_ALARM = "volume_alarm";
1771
1772        /**
1773         * Notification volume. This is used internally, changing this
1774         * value will not change the volume. See AudioManager.
1775         */
1776        public static final String VOLUME_NOTIFICATION = "volume_notification";
1777
1778        /**
1779         * Bluetooth Headset volume. This is used internally, changing this value will
1780         * not change the volume. See AudioManager.
1781         */
1782        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";
1783
1784        /**
1785         * Master volume (float in the range 0.0f to 1.0f).
1786         * @hide
1787         */
1788        public static final String VOLUME_MASTER = "volume_master";
1789
1790        /**
1791         * Master volume mute (int 1 = mute, 0 = not muted).
1792         *
1793         * @hide
1794         */
1795        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";
1796
1797        /**
1798         * Whether the notifications should use the ring volume (value of 1) or
1799         * a separate notification volume (value of 0). In most cases, users
1800         * will have this enabled so the notification and ringer volumes will be
1801         * the same. However, power users can disable this and use the separate
1802         * notification volume control.
1803         * <p>
1804         * Note: This is a one-off setting that will be removed in the future
1805         * when there is profile support. For this reason, it is kept hidden
1806         * from the public APIs.
1807         *
1808         * @hide
1809         * @deprecated
1810         */
1811        @Deprecated
1812        public static final String NOTIFICATIONS_USE_RING_VOLUME =
1813            "notifications_use_ring_volume";
1814
1815        /**
1816         * Whether silent mode should allow vibration feedback. This is used
1817         * internally in AudioService and the Sound settings activity to
1818         * coordinate decoupling of vibrate and silent modes. This setting
1819         * will likely be removed in a future release with support for
1820         * audio/vibe feedback profiles.
1821         *
1822         * Not used anymore. On devices with vibrator, the user explicitly selects
1823         * silent or vibrate mode.
1824         * Kept for use by legacy database upgrade code in DatabaseHelper.
1825         * @hide
1826         */
1827        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
1828
1829        /**
1830         * The mapping of stream type (integer) to its setting.
1831         */
1832        public static final String[] VOLUME_SETTINGS = {
1833            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
1834            VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO
1835        };
1836
1837        /**
1838         * Appended to various volume related settings to record the previous
1839         * values before they the settings were affected by a silent/vibrate
1840         * ringer mode change.
1841         */
1842        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
1843
1844        /**
1845         * Persistent store for the system-wide default ringtone URI.
1846         * <p>
1847         * If you need to play the default ringtone at any given time, it is recommended
1848         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
1849         * to the set default ringtone at the time of playing.
1850         *
1851         * @see #DEFAULT_RINGTONE_URI
1852         */
1853        public static final String RINGTONE = "ringtone";
1854
1855        /**
1856         * A {@link Uri} that will point to the current default ringtone at any
1857         * given time.
1858         * <p>
1859         * If the current default ringtone is in the DRM provider and the caller
1860         * does not have permission, the exception will be a
1861         * FileNotFoundException.
1862         */
1863        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
1864
1865        /**
1866         * Persistent store for the system-wide default notification sound.
1867         *
1868         * @see #RINGTONE
1869         * @see #DEFAULT_NOTIFICATION_URI
1870         */
1871        public static final String NOTIFICATION_SOUND = "notification_sound";
1872
1873        /**
1874         * A {@link Uri} that will point to the current default notification
1875         * sound at any given time.
1876         *
1877         * @see #DEFAULT_RINGTONE_URI
1878         */
1879        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
1880
1881        /**
1882         * Persistent store for the system-wide default alarm alert.
1883         *
1884         * @see #RINGTONE
1885         * @see #DEFAULT_ALARM_ALERT_URI
1886         */
1887        public static final String ALARM_ALERT = "alarm_alert";
1888
1889        /**
1890         * A {@link Uri} that will point to the current default alarm alert at
1891         * any given time.
1892         *
1893         * @see #DEFAULT_ALARM_ALERT_URI
1894         */
1895        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
1896
1897        /**
1898         * Persistent store for the system default media button event receiver.
1899         *
1900         * @hide
1901         */
1902        public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver";
1903
1904        /**
1905         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
1906         */
1907        public static final String TEXT_AUTO_REPLACE = "auto_replace";
1908
1909        /**
1910         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
1911         */
1912        public static final String TEXT_AUTO_CAPS = "auto_caps";
1913
1914        /**
1915         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
1916         * feature converts two spaces to a "." and space.
1917         */
1918        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
1919
1920        /**
1921         * Setting to showing password characters in text editors. 1 = On, 0 = Off
1922         */
1923        public static final String TEXT_SHOW_PASSWORD = "show_password";
1924
1925        public static final String SHOW_GTALK_SERVICE_STATUS =
1926                "SHOW_GTALK_SERVICE_STATUS";
1927
1928        /**
1929         * Name of activity to use for wallpaper on the home screen.
1930         *
1931         * @deprecated Use {@link WallpaperManager} instead.
1932         */
1933        @Deprecated
1934        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
1935
1936        /**
1937         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME}
1938         * instead
1939         */
1940        @Deprecated
1941        public static final String AUTO_TIME = Global.AUTO_TIME;
1942
1943        /**
1944         * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE}
1945         * instead
1946         */
1947        @Deprecated
1948        public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE;
1949
1950        /**
1951         * Display times as 12 or 24 hours
1952         *   12
1953         *   24
1954         */
1955        public static final String TIME_12_24 = "time_12_24";
1956
1957        /**
1958         * Date format string
1959         *   mm/dd/yyyy
1960         *   dd/mm/yyyy
1961         *   yyyy/mm/dd
1962         */
1963        public static final String DATE_FORMAT = "date_format";
1964
1965        /**
1966         * Whether the setup wizard has been run before (on first boot), or if
1967         * it still needs to be run.
1968         *
1969         * nonzero = it has been run in the past
1970         * 0 = it has not been run in the past
1971         */
1972        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
1973
1974        /**
1975         * Scaling factor for normal window animations. Setting to 0 will disable window
1976         * animations.
1977         *
1978         * @deprecated Use {@link Global#WINDOW_ANIMATION_SCALE} instead
1979         */
1980        @Deprecated
1981        public static final String WINDOW_ANIMATION_SCALE = Global.WINDOW_ANIMATION_SCALE;
1982
1983        /**
1984         * Scaling factor for activity transition animations. Setting to 0 will disable window
1985         * animations.
1986         *
1987         * @deprecated Use {@link Global#TRANSITION_ANIMATION_SCALE} instead
1988         */
1989        @Deprecated
1990        public static final String TRANSITION_ANIMATION_SCALE = Global.TRANSITION_ANIMATION_SCALE;
1991
1992        /**
1993         * Scaling factor for Animator-based animations. This affects both the start delay and
1994         * duration of all such animations. Setting to 0 will cause animations to end immediately.
1995         * The default value is 1.
1996         *
1997         * @deprecated Use {@link Global#ANIMATOR_DURATION_SCALE} instead
1998         */
1999        @Deprecated
2000        public static final String ANIMATOR_DURATION_SCALE = Global.ANIMATOR_DURATION_SCALE;
2001
2002        /**
2003         * Control whether the accelerometer will be used to change screen
2004         * orientation.  If 0, it will not be used unless explicitly requested
2005         * by the application; if 1, it will be used by default unless explicitly
2006         * disabled by the application.
2007         */
2008        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
2009
2010        /**
2011         * Default screen rotation when no other policy applies.
2012         * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
2013         * preference, this rotation value will be used. Must be one of the
2014         * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
2015         *
2016         * @see Display#getRotation
2017         */
2018        public static final String USER_ROTATION = "user_rotation";
2019
2020        /**
2021         * Control whether the rotation lock toggle in the System UI should be hidden.
2022         * Typically this is done for accessibility purposes to make it harder for
2023         * the user to accidentally toggle the rotation lock while the display rotation
2024         * has been locked for accessibility.
2025         *
2026         * If 0, then rotation lock toggle is not hidden for accessibility (although it may be
2027         * unavailable for other reasons).  If 1, then the rotation lock toggle is hidden.
2028         *
2029         * @hide
2030         */
2031        public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY =
2032                "hide_rotation_lock_toggle_for_accessibility";
2033
2034        /**
2035         * Whether the phone vibrates when it is ringing due to an incoming call. This will
2036         * be used by Phone and Setting apps; it shouldn't affect other apps.
2037         * The value is boolean (1 or 0).
2038         *
2039         * Note: this is not same as "vibrate on ring", which had been available until ICS.
2040         * It was about AudioManager's setting and thus affected all the applications which
2041         * relied on the setting, while this is purely about the vibration setting for incoming
2042         * calls.
2043         *
2044         * @hide
2045         */
2046        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
2047
2048        /**
2049         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
2050         * boolean (1 or 0).
2051         */
2052        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
2053
2054        /**
2055         * CDMA only settings
2056         * DTMF tone type played by the dialer when dialing.
2057         *                 0 = Normal
2058         *                 1 = Long
2059         * @hide
2060         */
2061        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
2062
2063        /**
2064         * Whether the hearing aid is enabled. The value is
2065         * boolean (1 or 0).
2066         * @hide
2067         */
2068        public static final String HEARING_AID = "hearing_aid";
2069
2070        /**
2071         * CDMA only settings
2072         * TTY Mode
2073         * 0 = OFF
2074         * 1 = FULL
2075         * 2 = VCO
2076         * 3 = HCO
2077         * @hide
2078         */
2079        public static final String TTY_MODE = "tty_mode";
2080
2081        /**
2082         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
2083         * boolean (1 or 0).
2084         */
2085        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
2086
2087        /**
2088         * Whether the haptic feedback (long presses, ...) are enabled. The value is
2089         * boolean (1 or 0).
2090         */
2091        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
2092
2093        /**
2094         * @deprecated Each application that shows web suggestions should have its own
2095         * setting for this.
2096         */
2097        @Deprecated
2098        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
2099
2100        /**
2101         * Whether the notification LED should repeatedly flash when a notification is
2102         * pending. The value is boolean (1 or 0).
2103         * @hide
2104         */
2105        public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse";
2106
2107        /**
2108         * Show pointer location on screen?
2109         * 0 = no
2110         * 1 = yes
2111         * @hide
2112         */
2113        public static final String POINTER_LOCATION = "pointer_location";
2114
2115        /**
2116         * Show touch positions on screen?
2117         * 0 = no
2118         * 1 = yes
2119         * @hide
2120         */
2121        public static final String SHOW_TOUCHES = "show_touches";
2122
2123        /**
2124         * Log raw orientation data from {@link WindowOrientationListener} for use with the
2125         * orientationplot.py tool.
2126         * 0 = no
2127         * 1 = yes
2128         * @hide
2129         */
2130        public static final String WINDOW_ORIENTATION_LISTENER_LOG =
2131                "window_orientation_listener_log";
2132
2133        /**
2134         * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED}
2135         * instead
2136         * @hide
2137         */
2138        @Deprecated
2139        public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED;
2140
2141        /**
2142         * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED}
2143         * instead
2144         * @hide
2145         */
2146        @Deprecated
2147        public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED;
2148
2149        /**
2150         * Whether to play sounds when the keyguard is shown and dismissed.
2151         * @hide
2152         */
2153        public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled";
2154
2155        /**
2156         * Whether the lockscreen should be completely disabled.
2157         * @hide
2158         */
2159        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";
2160
2161        /**
2162         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
2163         * instead
2164         * @hide
2165         */
2166        @Deprecated
2167        public static final String LOW_BATTERY_SOUND = Global.LOW_BATTERY_SOUND;
2168
2169        /**
2170         * @deprecated Use {@link android.provider.Settings.Global#DESK_DOCK_SOUND}
2171         * instead
2172         * @hide
2173         */
2174        @Deprecated
2175        public static final String DESK_DOCK_SOUND = Global.DESK_DOCK_SOUND;
2176
2177        /**
2178         * @deprecated Use {@link android.provider.Settings.Global#DESK_UNDOCK_SOUND}
2179         * instead
2180         * @hide
2181         */
2182        @Deprecated
2183        public static final String DESK_UNDOCK_SOUND = Global.DESK_UNDOCK_SOUND;
2184
2185        /**
2186         * @deprecated Use {@link android.provider.Settings.Global#CAR_DOCK_SOUND}
2187         * instead
2188         * @hide
2189         */
2190        @Deprecated
2191        public static final String CAR_DOCK_SOUND = Global.CAR_DOCK_SOUND;
2192
2193        /**
2194         * @deprecated Use {@link android.provider.Settings.Global#CAR_UNDOCK_SOUND}
2195         * instead
2196         * @hide
2197         */
2198        @Deprecated
2199        public static final String CAR_UNDOCK_SOUND = Global.CAR_UNDOCK_SOUND;
2200
2201        /**
2202         * @deprecated Use {@link android.provider.Settings.Global#LOCK_SOUND}
2203         * instead
2204         * @hide
2205         */
2206        @Deprecated
2207        public static final String LOCK_SOUND = Global.LOCK_SOUND;
2208
2209        /**
2210         * @deprecated Use {@link android.provider.Settings.Global#UNLOCK_SOUND}
2211         * instead
2212         * @hide
2213         */
2214        @Deprecated
2215        public static final String UNLOCK_SOUND = Global.UNLOCK_SOUND;
2216
2217        /**
2218         * Receive incoming SIP calls?
2219         * 0 = no
2220         * 1 = yes
2221         * @hide
2222         */
2223        public static final String SIP_RECEIVE_CALLS = "sip_receive_calls";
2224
2225        /**
2226         * Call Preference String.
2227         * "SIP_ALWAYS" : Always use SIP with network access
2228         * "SIP_ADDRESS_ONLY" : Only if destination is a SIP address
2229         * "SIP_ASK_ME_EACH_TIME" : Always ask me each time
2230         * @hide
2231         */
2232        public static final String SIP_CALL_OPTIONS = "sip_call_options";
2233
2234        /**
2235         * One of the sip call options: Always use SIP with network access.
2236         * @hide
2237         */
2238        public static final String SIP_ALWAYS = "SIP_ALWAYS";
2239
2240        /**
2241         * One of the sip call options: Only if destination is a SIP address.
2242         * @hide
2243         */
2244        public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY";
2245
2246        /**
2247         * One of the sip call options: Always ask me each time.
2248         * @hide
2249         */
2250        public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME";
2251
2252        /**
2253         * Pointer speed setting.
2254         * This is an integer value in a range between -7 and +7, so there are 15 possible values.
2255         *   -7 = slowest
2256         *    0 = default speed
2257         *   +7 = fastest
2258         * @hide
2259         */
2260        public static final String POINTER_SPEED = "pointer_speed";
2261
2262        /**
2263         * Settings to backup. This is here so that it's in the same place as the settings
2264         * keys and easy to update.
2265         *
2266         * NOTE: Settings are backed up and restored in the order they appear
2267         *       in this array. If you have one setting depending on another,
2268         *       make sure that they are ordered appropriately.
2269         *
2270         * @hide
2271         */
2272        public static final String[] SETTINGS_TO_BACKUP = {
2273            STAY_ON_WHILE_PLUGGED_IN,   // moved to global
2274            WIFI_USE_STATIC_IP,
2275            WIFI_STATIC_IP,
2276            WIFI_STATIC_GATEWAY,
2277            WIFI_STATIC_NETMASK,
2278            WIFI_STATIC_DNS1,
2279            WIFI_STATIC_DNS2,
2280            BLUETOOTH_DISCOVERABILITY,
2281            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
2282            DIM_SCREEN,
2283            SCREEN_OFF_TIMEOUT,
2284            SCREEN_BRIGHTNESS,
2285            SCREEN_BRIGHTNESS_MODE,
2286            SCREEN_AUTO_BRIGHTNESS_ADJ,
2287            VIBRATE_INPUT_DEVICES,
2288            MODE_RINGER,                // moved to global
2289            MODE_RINGER_STREAMS_AFFECTED,
2290            MUTE_STREAMS_AFFECTED,
2291            VOLUME_VOICE,
2292            VOLUME_SYSTEM,
2293            VOLUME_RING,
2294            VOLUME_MUSIC,
2295            VOLUME_ALARM,
2296            VOLUME_NOTIFICATION,
2297            VOLUME_BLUETOOTH_SCO,
2298            VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE,
2299            VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE,
2300            VOLUME_RING + APPEND_FOR_LAST_AUDIBLE,
2301            VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE,
2302            VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
2303            VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
2304            VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE,
2305            TEXT_AUTO_REPLACE,
2306            TEXT_AUTO_CAPS,
2307            TEXT_AUTO_PUNCTUATE,
2308            TEXT_SHOW_PASSWORD,
2309            AUTO_TIME,                  // moved to global
2310            AUTO_TIME_ZONE,             // moved to global
2311            TIME_12_24,
2312            DATE_FORMAT,
2313            DTMF_TONE_WHEN_DIALING,
2314            DTMF_TONE_TYPE_WHEN_DIALING,
2315            HEARING_AID,
2316            TTY_MODE,
2317            SOUND_EFFECTS_ENABLED,
2318            HAPTIC_FEEDBACK_ENABLED,
2319            POWER_SOUNDS_ENABLED,       // moved to global
2320            DOCK_SOUNDS_ENABLED,        // moved to global
2321            LOCKSCREEN_SOUNDS_ENABLED,
2322            SHOW_WEB_SUGGESTIONS,
2323            NOTIFICATION_LIGHT_PULSE,
2324            SIP_CALL_OPTIONS,
2325            SIP_RECEIVE_CALLS,
2326            POINTER_SPEED,
2327            VIBRATE_WHEN_RINGING
2328        };
2329
2330        // Settings moved to Settings.Secure
2331
2332        /**
2333         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED}
2334         * instead
2335         */
2336        @Deprecated
2337        public static final String ADB_ENABLED = Global.ADB_ENABLED;
2338
2339        /**
2340         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
2341         */
2342        @Deprecated
2343        public static final String ANDROID_ID = Secure.ANDROID_ID;
2344
2345        /**
2346         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
2347         */
2348        @Deprecated
2349        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
2350
2351        /**
2352         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
2353         */
2354        @Deprecated
2355        public static final String DATA_ROAMING = Global.DATA_ROAMING;
2356
2357        /**
2358         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
2359         */
2360        @Deprecated
2361        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
2362
2363        /**
2364         * @deprecated Use {@link android.provider.Settings.Global#HTTP_PROXY} instead
2365         */
2366        @Deprecated
2367        public static final String HTTP_PROXY = Global.HTTP_PROXY;
2368
2369        /**
2370         * @deprecated Use {@link android.provider.Settings.Global#INSTALL_NON_MARKET_APPS} instead
2371         */
2372        @Deprecated
2373        public static final String INSTALL_NON_MARKET_APPS = Global.INSTALL_NON_MARKET_APPS;
2374
2375        /**
2376         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
2377         * instead
2378         */
2379        @Deprecated
2380        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
2381
2382        /**
2383         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
2384         */
2385        @Deprecated
2386        public static final String LOGGING_ID = Secure.LOGGING_ID;
2387
2388        /**
2389         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
2390         */
2391        @Deprecated
2392        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
2393
2394        /**
2395         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
2396         * instead
2397         */
2398        @Deprecated
2399        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
2400
2401        /**
2402         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
2403         * instead
2404         */
2405        @Deprecated
2406        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
2407
2408        /**
2409         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
2410         * instead
2411         */
2412        @Deprecated
2413        public static final String PARENTAL_CONTROL_REDIRECT_URL =
2414            Secure.PARENTAL_CONTROL_REDIRECT_URL;
2415
2416        /**
2417         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
2418         */
2419        @Deprecated
2420        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
2421
2422        /**
2423         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
2424         */
2425        @Deprecated
2426        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
2427
2428        /**
2429         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
2430         */
2431        @Deprecated
2432        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
2433
2434       /**
2435         * @deprecated Use
2436         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
2437         */
2438        @Deprecated
2439        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
2440
2441        /**
2442         * @deprecated Use
2443         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
2444         */
2445        @Deprecated
2446        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
2447                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
2448
2449        /**
2450         * @deprecated Use
2451         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
2452         */
2453        @Deprecated
2454        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
2455                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
2456
2457        /**
2458         * @deprecated Use
2459         * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
2460         */
2461        @Deprecated
2462        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
2463                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
2464
2465        /**
2466         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
2467         * instead
2468         */
2469        @Deprecated
2470        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
2471
2472        /**
2473         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead
2474         */
2475        @Deprecated
2476        public static final String WIFI_ON = Global.WIFI_ON;
2477
2478        /**
2479         * @deprecated Use
2480         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
2481         * instead
2482         */
2483        @Deprecated
2484        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
2485                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
2486
2487        /**
2488         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
2489         */
2490        @Deprecated
2491        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
2492
2493        /**
2494         * @deprecated Use
2495         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
2496         */
2497        @Deprecated
2498        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
2499                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
2500
2501        /**
2502         * @deprecated Use
2503         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
2504         */
2505        @Deprecated
2506        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
2507                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
2508
2509        /**
2510         * @deprecated Use
2511         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
2512         * instead
2513         */
2514        @Deprecated
2515        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
2516                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
2517
2518        /**
2519         * @deprecated Use
2520         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
2521         */
2522        @Deprecated
2523        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
2524            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
2525
2526        /**
2527         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
2528         * instead
2529         */
2530        @Deprecated
2531        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
2532
2533        /**
2534         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
2535         */
2536        @Deprecated
2537        public static final String WIFI_WATCHDOG_ON = Global.WIFI_WATCHDOG_ON;
2538
2539        /**
2540         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
2541         */
2542        @Deprecated
2543        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
2544
2545        /**
2546         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
2547         * instead
2548         */
2549        @Deprecated
2550        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
2551
2552        /**
2553         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
2554         * instead
2555         */
2556        @Deprecated
2557        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
2558            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
2559    }
2560
2561    /**
2562     * Secure system settings, containing system preferences that applications
2563     * can read but are not allowed to write.  These are for preferences that
2564     * the user must explicitly modify through the system UI or specialized
2565     * APIs for those values, not modified directly by applications.
2566     */
2567    public static final class Secure extends NameValueTable {
2568        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
2569
2570        /**
2571         * The content:// style URL for this table
2572         */
2573        public static final Uri CONTENT_URI =
2574            Uri.parse("content://" + AUTHORITY + "/secure");
2575
2576        // Populated lazily, guarded by class object:
2577        private static final NameValueCache sNameValueCache = new NameValueCache(
2578                SYS_PROP_SETTING_VERSION,
2579                CONTENT_URI,
2580                CALL_METHOD_GET_SECURE,
2581                CALL_METHOD_PUT_SECURE);
2582
2583        private static ILockSettings sLockSettings = null;
2584
2585        private static boolean sIsSystemProcess;
2586        private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
2587        private static final HashSet<String> MOVED_TO_GLOBAL;
2588        static {
2589            MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
2590            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
2591            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
2592            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
2593
2594            MOVED_TO_GLOBAL = new HashSet<String>();
2595            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
2596            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
2597            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
2598            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
2599            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
2600            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
2601            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE);
2602            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI);
2603            MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
2604            MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
2605            MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
2606            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_DENSITY_FORCED);
2607            MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
2608            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
2609            MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
2610            MOVED_TO_GLOBAL.add(Settings.Global.INSTALL_NON_MARKET_APPS);
2611            MOVED_TO_GLOBAL.add(Settings.Global.MOBILE_DATA);
2612            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION);
2613            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_DELETE_AGE);
2614            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES);
2615            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE);
2616            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_ENABLED);
2617            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES);
2618            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_POLL_INTERVAL);
2619            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_REPORT_XT_OVER_DEV);
2620            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_SAMPLE_ENABLED);
2621            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE);
2622            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION);
2623            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_DELETE_AGE);
2624            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES);
2625            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_ROTATE_AGE);
2626            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION);
2627            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE);
2628            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES);
2629            MOVED_TO_GLOBAL.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE);
2630            MOVED_TO_GLOBAL.add(Settings.Global.NETWORK_PREFERENCE);
2631            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_DIFF);
2632            MOVED_TO_GLOBAL.add(Settings.Global.NITZ_UPDATE_SPACING);
2633            MOVED_TO_GLOBAL.add(Settings.Global.NTP_SERVER);
2634            MOVED_TO_GLOBAL.add(Settings.Global.NTP_TIMEOUT);
2635            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT);
2636            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS);
2637            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT);
2638            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS);
2639            MOVED_TO_GLOBAL.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT);
2640            MOVED_TO_GLOBAL.add(Settings.Global.SAMPLING_PROFILER_MS);
2641            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
2642            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST);
2643            MOVED_TO_GLOBAL.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL);
2644            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_APN);
2645            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_DUN_REQUIRED);
2646            MOVED_TO_GLOBAL.add(Settings.Global.TETHER_SUPPORTED);
2647            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_HELP_URI);
2648            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC);
2649            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_NOTIFICATION_TYPE);
2650            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_POLLING_SEC);
2651            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_RESET_DAY);
2652            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_THRESHOLD_BYTES);
2653            MOVED_TO_GLOBAL.add(Settings.Global.THROTTLE_VALUE_KBITSPS);
2654            MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED);
2655            MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL);
2656            MOVED_TO_GLOBAL.add(Settings.Global.WEB_AUTOFILL_QUERY_URL);
2657            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE);
2658            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS);
2659            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND);
2660            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS);
2661            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT);
2662            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS);
2663            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
2664            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
2665            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT);
2666            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
2667            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
2668            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
2669            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
2670            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
2671            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
2672            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
2673            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
2674            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_ENABLE);
2675            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT);
2676            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE);
2677            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS);
2678            MOVED_TO_GLOBAL.add(Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS);
2679            MOVED_TO_GLOBAL.add(Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS);
2680            MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
2681            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD);
2682            MOVED_TO_GLOBAL.add(Settings.Global.BATTERY_DISCHARGE_THRESHOLD);
2683            MOVED_TO_GLOBAL.add(Settings.Global.SEND_ACTION_APP_ERROR);
2684            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_AGE_SECONDS);
2685            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_MAX_FILES);
2686            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_KB);
2687            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_QUOTA_PERCENT);
2688            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_RESERVE_PERCENT);
2689            MOVED_TO_GLOBAL.add(Settings.Global.DROPBOX_TAG_PREFIX);
2690            MOVED_TO_GLOBAL.add(Settings.Global.ERROR_LOGCAT_PREFIX);
2691            MOVED_TO_GLOBAL.add(Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL);
2692            MOVED_TO_GLOBAL.add(Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD);
2693            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE);
2694            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES);
2695            MOVED_TO_GLOBAL.add(Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES);
2696            MOVED_TO_GLOBAL.add(Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS);
2697            MOVED_TO_GLOBAL.add(Settings.Global.CONNECTIVITY_CHANGE_DELAY);
2698            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED);
2699            MOVED_TO_GLOBAL.add(Settings.Global.CAPTIVE_PORTAL_SERVER);
2700            MOVED_TO_GLOBAL.add(Settings.Global.NSD_ON);
2701            MOVED_TO_GLOBAL.add(Settings.Global.SET_INSTALL_LOCATION);
2702            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_INSTALL_LOCATION);
2703            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY);
2704            MOVED_TO_GLOBAL.add(Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY);
2705            MOVED_TO_GLOBAL.add(Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT);
2706            MOVED_TO_GLOBAL.add(Settings.Global.HTTP_PROXY);
2707            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_HOST);
2708            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_PORT);
2709            MOVED_TO_GLOBAL.add(Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
2710            MOVED_TO_GLOBAL.add(Settings.Global.SET_GLOBAL_HTTP_PROXY);
2711            MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_DNS_SERVER);
2712            MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_NETWORK_MODE);
2713            MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_CDMA_SUBSCRIPTION);
2714        }
2715
2716        /** @hide */
2717        public static void getMovedKeys(HashSet<String> outKeySet) {
2718            outKeySet.addAll(MOVED_TO_GLOBAL);
2719        }
2720
2721        /**
2722         * Look up a name in the database.
2723         * @param resolver to access the database with
2724         * @param name to look up in the table
2725         * @return the corresponding value, or null if not present
2726         */
2727        public static String getString(ContentResolver resolver, String name) {
2728            return getStringForUser(resolver, name, UserHandle.myUserId());
2729        }
2730
2731        /** @hide */
2732        public static String getStringForUser(ContentResolver resolver, String name,
2733                int userHandle) {
2734            if (MOVED_TO_GLOBAL.contains(name)) {
2735                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
2736                        + " to android.provider.Settings.Global.");
2737                return Global.getStringForUser(resolver, name, userHandle);
2738            }
2739
2740            if (MOVED_TO_LOCK_SETTINGS.contains(name)) {
2741                synchronized (Secure.class) {
2742                    if (sLockSettings == null) {
2743                        sLockSettings = ILockSettings.Stub.asInterface(
2744                                (IBinder) ServiceManager.getService("lock_settings"));
2745                        sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
2746                    }
2747                }
2748                if (sLockSettings != null && !sIsSystemProcess) {
2749                    try {
2750                        return sLockSettings.getString(name, "0", userHandle);
2751                    } catch (RemoteException re) {
2752                        // Fall through
2753                    }
2754                }
2755            }
2756
2757            return sNameValueCache.getStringForUser(resolver, name, userHandle);
2758        }
2759
2760        /**
2761         * Store a name/value pair into the database.
2762         * @param resolver to access the database with
2763         * @param name to store
2764         * @param value to associate with the name
2765         * @return true if the value was set, false on database errors
2766         */
2767        public static boolean putString(ContentResolver resolver, String name, String value) {
2768            return putStringForUser(resolver, name, value, UserHandle.myUserId());
2769        }
2770
2771        /** @hide */
2772        public static boolean putStringForUser(ContentResolver resolver, String name, String value,
2773                int userHandle) {
2774            if (MOVED_TO_GLOBAL.contains(name)) {
2775                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
2776                        + " to android.provider.Settings.Global");
2777                return Global.putStringForUser(resolver, name, value, userHandle);
2778            }
2779            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
2780        }
2781
2782        /**
2783         * Construct the content URI for a particular name/value pair,
2784         * useful for monitoring changes with a ContentObserver.
2785         * @param name to look up in the table
2786         * @return the corresponding content URI, or null if not present
2787         */
2788        public static Uri getUriFor(String name) {
2789            if (MOVED_TO_GLOBAL.contains(name)) {
2790                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
2791                        + " to android.provider.Settings.Global, returning global URI.");
2792                return Global.getUriFor(Global.CONTENT_URI, name);
2793            }
2794            return getUriFor(CONTENT_URI, name);
2795        }
2796
2797        /**
2798         * Convenience function for retrieving a single secure settings value
2799         * as an integer.  Note that internally setting values are always
2800         * stored as strings; this function converts the string to an integer
2801         * for you.  The default value will be returned if the setting is
2802         * not defined or not an integer.
2803         *
2804         * @param cr The ContentResolver to access.
2805         * @param name The name of the setting to retrieve.
2806         * @param def Value to return if the setting is not defined.
2807         *
2808         * @return The setting's current value, or 'def' if it is not defined
2809         * or not a valid integer.
2810         */
2811        public static int getInt(ContentResolver cr, String name, int def) {
2812            return getIntForUser(cr, name, def, UserHandle.myUserId());
2813        }
2814
2815        /** @hide */
2816        public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
2817            String v = getStringForUser(cr, name, userHandle);
2818            try {
2819                return v != null ? Integer.parseInt(v) : def;
2820            } catch (NumberFormatException e) {
2821                return def;
2822            }
2823        }
2824
2825        /**
2826         * Convenience function for retrieving a single secure settings value
2827         * as an integer.  Note that internally setting values are always
2828         * stored as strings; this function converts the string to an integer
2829         * for you.
2830         * <p>
2831         * This version does not take a default value.  If the setting has not
2832         * been set, or the string value is not a number,
2833         * it throws {@link SettingNotFoundException}.
2834         *
2835         * @param cr The ContentResolver to access.
2836         * @param name The name of the setting to retrieve.
2837         *
2838         * @throws SettingNotFoundException Thrown if a setting by the given
2839         * name can't be found or the setting value is not an integer.
2840         *
2841         * @return The setting's current value.
2842         */
2843        public static int getInt(ContentResolver cr, String name)
2844                throws SettingNotFoundException {
2845            return getIntForUser(cr, name, UserHandle.myUserId());
2846        }
2847
2848        /** @hide */
2849        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
2850                throws SettingNotFoundException {
2851            String v = getStringForUser(cr, name, userHandle);
2852            try {
2853                return Integer.parseInt(v);
2854            } catch (NumberFormatException e) {
2855                throw new SettingNotFoundException(name);
2856            }
2857        }
2858
2859        /**
2860         * Convenience function for updating a single settings value as an
2861         * integer. This will either create a new entry in the table if the
2862         * given name does not exist, or modify the value of the existing row
2863         * with that name.  Note that internally setting values are always
2864         * stored as strings, so this function converts the given value to a
2865         * string before storing it.
2866         *
2867         * @param cr The ContentResolver to access.
2868         * @param name The name of the setting to modify.
2869         * @param value The new value for the setting.
2870         * @return true if the value was set, false on database errors
2871         */
2872        public static boolean putInt(ContentResolver cr, String name, int value) {
2873            return putIntForUser(cr, name, value, UserHandle.myUserId());
2874        }
2875
2876        /** @hide */
2877        public static boolean putIntForUser(ContentResolver cr, String name, int value,
2878                int userHandle) {
2879            return putStringForUser(cr, name, Integer.toString(value), userHandle);
2880        }
2881
2882        /**
2883         * Convenience function for retrieving a single secure settings value
2884         * as a {@code long}.  Note that internally setting values are always
2885         * stored as strings; this function converts the string to a {@code long}
2886         * for you.  The default value will be returned if the setting is
2887         * not defined or not a {@code long}.
2888         *
2889         * @param cr The ContentResolver to access.
2890         * @param name The name of the setting to retrieve.
2891         * @param def Value to return if the setting is not defined.
2892         *
2893         * @return The setting's current value, or 'def' if it is not defined
2894         * or not a valid {@code long}.
2895         */
2896        public static long getLong(ContentResolver cr, String name, long def) {
2897            return getLongForUser(cr, name, def, UserHandle.myUserId());
2898        }
2899
2900        /** @hide */
2901        public static long getLongForUser(ContentResolver cr, String name, long def,
2902                int userHandle) {
2903            String valString = getStringForUser(cr, name, userHandle);
2904            long value;
2905            try {
2906                value = valString != null ? Long.parseLong(valString) : def;
2907            } catch (NumberFormatException e) {
2908                value = def;
2909            }
2910            return value;
2911        }
2912
2913        /**
2914         * Convenience function for retrieving a single secure settings value
2915         * as a {@code long}.  Note that internally setting values are always
2916         * stored as strings; this function converts the string to a {@code long}
2917         * for you.
2918         * <p>
2919         * This version does not take a default value.  If the setting has not
2920         * been set, or the string value is not a number,
2921         * it throws {@link SettingNotFoundException}.
2922         *
2923         * @param cr The ContentResolver to access.
2924         * @param name The name of the setting to retrieve.
2925         *
2926         * @return The setting's current value.
2927         * @throws SettingNotFoundException Thrown if a setting by the given
2928         * name can't be found or the setting value is not an integer.
2929         */
2930        public static long getLong(ContentResolver cr, String name)
2931                throws SettingNotFoundException {
2932            return getLongForUser(cr, name, UserHandle.myUserId());
2933        }
2934
2935        /** @hide */
2936        public static long getLongForUser(ContentResolver cr, String name, int userHandle)
2937                throws SettingNotFoundException {
2938            String valString = getStringForUser(cr, name, userHandle);
2939            try {
2940                return Long.parseLong(valString);
2941            } catch (NumberFormatException e) {
2942                throw new SettingNotFoundException(name);
2943            }
2944        }
2945
2946        /**
2947         * Convenience function for updating a secure settings value as a long
2948         * integer. This will either create a new entry in the table if the
2949         * given name does not exist, or modify the value of the existing row
2950         * with that name.  Note that internally setting values are always
2951         * stored as strings, so this function converts the given value to a
2952         * string before storing it.
2953         *
2954         * @param cr The ContentResolver to access.
2955         * @param name The name of the setting to modify.
2956         * @param value The new value for the setting.
2957         * @return true if the value was set, false on database errors
2958         */
2959        public static boolean putLong(ContentResolver cr, String name, long value) {
2960            return putLongForUser(cr, name, value, UserHandle.myUserId());
2961        }
2962
2963        /** @hide */
2964        public static boolean putLongForUser(ContentResolver cr, String name, long value,
2965                int userHandle) {
2966            return putStringForUser(cr, name, Long.toString(value), userHandle);
2967        }
2968
2969        /**
2970         * Convenience function for retrieving a single secure settings value
2971         * as a floating point number.  Note that internally setting values are
2972         * always stored as strings; this function converts the string to an
2973         * float for you. The default value will be returned if the setting
2974         * is not defined or not a valid float.
2975         *
2976         * @param cr The ContentResolver to access.
2977         * @param name The name of the setting to retrieve.
2978         * @param def Value to return if the setting is not defined.
2979         *
2980         * @return The setting's current value, or 'def' if it is not defined
2981         * or not a valid float.
2982         */
2983        public static float getFloat(ContentResolver cr, String name, float def) {
2984            return getFloatForUser(cr, name, def, UserHandle.myUserId());
2985        }
2986
2987        /** @hide */
2988        public static float getFloatForUser(ContentResolver cr, String name, float def,
2989                int userHandle) {
2990            String v = getStringForUser(cr, name, userHandle);
2991            try {
2992                return v != null ? Float.parseFloat(v) : def;
2993            } catch (NumberFormatException e) {
2994                return def;
2995            }
2996        }
2997
2998        /**
2999         * Convenience function for retrieving a single secure settings value
3000         * as a float.  Note that internally setting values are always
3001         * stored as strings; this function converts the string to a float
3002         * for you.
3003         * <p>
3004         * This version does not take a default value.  If the setting has not
3005         * been set, or the string value is not a number,
3006         * it throws {@link SettingNotFoundException}.
3007         *
3008         * @param cr The ContentResolver to access.
3009         * @param name The name of the setting to retrieve.
3010         *
3011         * @throws SettingNotFoundException Thrown if a setting by the given
3012         * name can't be found or the setting value is not a float.
3013         *
3014         * @return The setting's current value.
3015         */
3016        public static float getFloat(ContentResolver cr, String name)
3017                throws SettingNotFoundException {
3018            return getFloatForUser(cr, name, UserHandle.myUserId());
3019        }
3020
3021        /** @hide */
3022        public static float getFloatForUser(ContentResolver cr, String name, int userHandle)
3023                throws SettingNotFoundException {
3024            String v = getStringForUser(cr, name, userHandle);
3025            if (v == null) {
3026                throw new SettingNotFoundException(name);
3027            }
3028            try {
3029                return Float.parseFloat(v);
3030            } catch (NumberFormatException e) {
3031                throw new SettingNotFoundException(name);
3032            }
3033        }
3034
3035        /**
3036         * Convenience function for updating a single settings value as a
3037         * floating point number. This will either create a new entry in the
3038         * table if the given name does not exist, or modify the value of the
3039         * existing row with that name.  Note that internally setting values
3040         * are always stored as strings, so this function converts the given
3041         * value to a string before storing it.
3042         *
3043         * @param cr The ContentResolver to access.
3044         * @param name The name of the setting to modify.
3045         * @param value The new value for the setting.
3046         * @return true if the value was set, false on database errors
3047         */
3048        public static boolean putFloat(ContentResolver cr, String name, float value) {
3049            return putFloatForUser(cr, name, value, UserHandle.myUserId());
3050        }
3051
3052        /** @hide */
3053        public static boolean putFloatForUser(ContentResolver cr, String name, float value,
3054                int userHandle) {
3055            return putStringForUser(cr, name, Float.toString(value), userHandle);
3056        }
3057
3058        /**
3059         * @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
3060         * instead
3061         */
3062        @Deprecated
3063        public static final String DEVELOPMENT_SETTINGS_ENABLED =
3064                Global.DEVELOPMENT_SETTINGS_ENABLED;
3065
3066        /**
3067         * When the user has enable the option to have a "bug report" command
3068         * in the power menu.
3069         * @hide
3070         */
3071        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
3072
3073        /**
3074         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
3075         */
3076        @Deprecated
3077        public static final String ADB_ENABLED = Global.ADB_ENABLED;
3078
3079        /**
3080         * Setting to allow mock locations and location provider status to be injected into the
3081         * LocationManager service for testing purposes during application development.  These
3082         * locations and status values  override actual location and status information generated
3083         * by network, gps, or other location providers.
3084         */
3085        public static final String ALLOW_MOCK_LOCATION = "mock_location";
3086
3087        /**
3088         * A 64-bit number (as a hex string) that is randomly
3089         * generated on the device's first boot and should remain
3090         * constant for the lifetime of the device.  (The value may
3091         * change if a factory reset is performed on the device.)
3092         */
3093        public static final String ANDROID_ID = "android_id";
3094
3095        /**
3096         * @deprecated Use {@link android.provider.Settings.Global#BLUETOOTH_ON} instead
3097         */
3098        @Deprecated
3099        public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
3100
3101        /**
3102         * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
3103         */
3104        @Deprecated
3105        public static final String DATA_ROAMING = Global.DATA_ROAMING;
3106
3107        /**
3108         * Setting to record the input method used by default, holding the ID
3109         * of the desired method.
3110         */
3111        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
3112
3113        /**
3114         * Setting to record the input method subtype used by default, holding the ID
3115         * of the desired method.
3116         */
3117        public static final String SELECTED_INPUT_METHOD_SUBTYPE =
3118                "selected_input_method_subtype";
3119
3120        /**
3121         * Setting to record the history of input method subtype, holding the pair of ID of IME
3122         * and its last used subtype.
3123         * @hide
3124         */
3125        public static final String INPUT_METHODS_SUBTYPE_HISTORY =
3126                "input_methods_subtype_history";
3127
3128        /**
3129         * Setting to record the visibility of input method selector
3130         */
3131        public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
3132                "input_method_selector_visibility";
3133
3134        /**
3135         * @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
3136         */
3137        @Deprecated
3138        public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED;
3139
3140        /**
3141         * Whether the current user has been set up via setup wizard (0 = false, 1 = true)
3142         * @hide
3143         */
3144        public static final String USER_SETUP_COMPLETE = "user_setup_complete";
3145
3146        /**
3147         * List of input methods that are currently enabled.  This is a string
3148         * containing the IDs of all enabled input methods, each ID separated
3149         * by ':'.
3150         */
3151        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
3152
3153        /**
3154         * List of system input methods that are currently disabled.  This is a string
3155         * containing the IDs of all disabled input methods, each ID separated
3156         * by ':'.
3157         * @hide
3158         */
3159        public static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
3160
3161        /**
3162         * Host name and port for global http proxy. Uses ':' seperator for
3163         * between host and port.
3164         *
3165         * @deprecated Use {@link Global#HTTP_PROXY}
3166         */
3167        @Deprecated
3168        public static final String HTTP_PROXY = Global.HTTP_PROXY;
3169
3170        /**
3171         * @deprecated Use {@link android.provider.Settings.Global#INSTALL_NON_MARKET_APPS} instead
3172         */
3173        @Deprecated
3174        public static final String INSTALL_NON_MARKET_APPS = Global.INSTALL_NON_MARKET_APPS;
3175
3176        /**
3177         * Comma-separated list of location providers that activities may access.
3178         */
3179        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
3180
3181        /**
3182         * A flag containing settings used for biometric weak
3183         * @hide
3184         */
3185        public static final String LOCK_BIOMETRIC_WEAK_FLAGS =
3186                "lock_biometric_weak_flags";
3187
3188        /**
3189         * Whether autolock is enabled (0 = false, 1 = true)
3190         */
3191        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
3192
3193        /**
3194         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
3195         */
3196        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
3197
3198        /**
3199         * Whether lock pattern will vibrate as user enters (0 = false, 1 =
3200         * true)
3201         *
3202         * @deprecated Starting in {@link VERSION_CODES#JELLY_BEAN_MR1} the
3203         *             lockscreen uses
3204         *             {@link Settings.System#HAPTIC_FEEDBACK_ENABLED}.
3205         */
3206        @Deprecated
3207        public static final String
3208                LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
3209
3210        /**
3211         * This preference allows the device to be locked given time after screen goes off,
3212         * subject to current DeviceAdmin policy limits.
3213         * @hide
3214         */
3215        public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout";
3216
3217
3218        /**
3219         * This preference contains the string that shows for owner info on LockScren.
3220         * @hide
3221         */
3222        public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
3223
3224        /**
3225         * Id of the user-selected appwidget on the lockscreen, or -1 if none
3226         * @hide
3227         */
3228        public static final String LOCK_SCREEN_APPWIDGET_IDS =
3229            "lock_screen_appwidget_ids";
3230
3231        /**
3232         * This preference enables showing the owner info on LockScren.
3233         * @hide
3234         */
3235        public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
3236            "lock_screen_owner_info_enabled";
3237
3238        /**
3239         * The Logging ID (a unique 64-bit value) as a hex string.
3240         * Used as a pseudonymous identifier for logging.
3241         * @deprecated This identifier is poorly initialized and has
3242         * many collisions.  It should not be used.
3243         */
3244        @Deprecated
3245        public static final String LOGGING_ID = "logging_id";
3246
3247        /**
3248         * @deprecated Use {@link android.provider.Settings.Global#NETWORK_PREFERENCE} instead
3249         */
3250        @Deprecated
3251        public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE;
3252
3253        /**
3254         * No longer supported.
3255         */
3256        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
3257
3258        /**
3259         * No longer supported.
3260         */
3261        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
3262
3263        /**
3264         * No longer supported.
3265         */
3266        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
3267
3268        /**
3269         * Settings classname to launch when Settings is clicked from All
3270         * Applications.  Needed because of user testing between the old
3271         * and new Settings apps.
3272         */
3273        // TODO: 881807
3274        public static final String SETTINGS_CLASSNAME = "settings_classname";
3275
3276        /**
3277         * @deprecated Use {@link android.provider.Settings.Global#USB_MASS_STORAGE_ENABLED} instead
3278         */
3279        @Deprecated
3280        public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED;
3281
3282        /**
3283         * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead
3284         */
3285        @Deprecated
3286        public static final String USE_GOOGLE_MAIL = Global.USE_GOOGLE_MAIL;
3287
3288        /**
3289         * If accessibility is enabled.
3290         */
3291        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
3292
3293        /**
3294         * If touch exploration is enabled.
3295         */
3296        public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled";
3297
3298        /**
3299         * List of the enabled accessibility providers.
3300         */
3301        public static final String ENABLED_ACCESSIBILITY_SERVICES =
3302            "enabled_accessibility_services";
3303
3304        /**
3305         * List of the accessibility services to which the user has granted
3306         * permission to put the device into touch exploration mode.
3307         *
3308         * @hide
3309         */
3310        public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES =
3311            "touch_exploration_granted_accessibility_services";
3312
3313        /**
3314         * Whether to speak passwords while in accessibility mode.
3315         */
3316        public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
3317
3318        /**
3319         * If injection of accessibility enhancing JavaScript screen-reader
3320         * is enabled.
3321         * <p>
3322         *   Note: The JavaScript based screen-reader is served by the
3323         *   Google infrastructure and enable users with disabilities to
3324         *   efficiently navigate in and explore web content.
3325         * </p>
3326         * <p>
3327         *   This property represents a boolean value.
3328         * </p>
3329         * @hide
3330         */
3331        public static final String ACCESSIBILITY_SCRIPT_INJECTION =
3332            "accessibility_script_injection";
3333
3334        /**
3335         * The URL for the injected JavaScript based screen-reader used
3336         * for providing accessibility of content in WebView.
3337         * <p>
3338         *   Note: The JavaScript based screen-reader is served by the
3339         *   Google infrastructure and enable users with disabilities to
3340         *   efficiently navigate in and explore web content.
3341         * </p>
3342         * <p>
3343         *   This property represents a string value.
3344         * </p>
3345         * @hide
3346         */
3347        public static final String ACCESSIBILITY_SCREEN_READER_URL =
3348            "accessibility_script_injection_url";
3349
3350        /**
3351         * Key bindings for navigation in built-in accessibility support for web content.
3352         * <p>
3353         *   Note: These key bindings are for the built-in accessibility navigation for
3354         *   web content which is used as a fall back solution if JavaScript in a WebView
3355         *   is not enabled or the user has not opted-in script injection from Google.
3356         * </p>
3357         * <p>
3358         *   The bindings are separated by semi-colon. A binding is a mapping from
3359         *   a key to a sequence of actions (for more details look at
3360         *   android.webkit.AccessibilityInjector). A key is represented as the hexademical
3361         *   string representation of an integer obtained from a meta state (optional) shifted
3362         *   sixteen times left and bitwise ored with a key code. An action is represented
3363         *   as a hexademical string representation of an integer where the first two digits
3364         *   are navigation action index, the second, the third, and the fourth digit pairs
3365         *   represent the action arguments. The separate actions in a binding are colon
3366         *   separated. The key and the action sequence it maps to are separated by equals.
3367         * </p>
3368         * <p>
3369         *   For example, the binding below maps the DPAD right button to traverse the
3370         *   current navigation axis once without firing an accessibility event and to
3371         *   perform the same traversal again but to fire an event:
3372         *   <code>
3373         *     0x16=0x01000100:0x01000101;
3374         *   </code>
3375         * </p>
3376         * <p>
3377         *   The goal of this binding is to enable dynamic rebinding of keys to
3378         *   navigation actions for web content without requiring a framework change.
3379         * </p>
3380         * <p>
3381         *   This property represents a string value.
3382         * </p>
3383         * @hide
3384         */
3385        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
3386            "accessibility_web_content_key_bindings";
3387
3388        /**
3389         * Setting that specifies whether the display magnification is enabled.
3390         * Display magnifications allows the user to zoom in the display content
3391         * and is targeted to low vision users. The current magnification scale
3392         * is controlled by {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE}.
3393         *
3394         * @hide
3395         */
3396        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED =
3397                "accessibility_display_magnification_enabled";
3398
3399        /**
3400         * Setting that specifies what the display magnification scale is.
3401         * Display magnifications allows the user to zoom in the display
3402         * content and is targeted to low vision users. Whether a display
3403         * magnification is performed is controlled by
3404         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED}
3405         *
3406         * @hide
3407         */
3408        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE =
3409                "accessibility_display_magnification_scale";
3410
3411        /**
3412         * Setting that specifies whether the display magnification should be
3413         * automatically updated. If this fearture is enabled the system will
3414         * exit magnification mode or pan the viewport when a context change
3415         * occurs. For example, on staring a new activity or rotating the screen,
3416         * the system may zoom out so the user can see the new context he is in.
3417         * Another example is on showing a window that is not visible in the
3418         * magnified viewport the system may pan the viewport to make the window
3419         * the has popped up so the user knows that the context has changed.
3420         * Whether a screen magnification is performed is controlled by
3421         * {@link #ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED}
3422         *
3423         * @hide
3424         */
3425        public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE =
3426                "accessibility_display_magnification_auto_update";
3427
3428        /**
3429         * The timout for considering a press to be a long press in milliseconds.
3430         * @hide
3431         */
3432        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";
3433
3434        /**
3435         * Setting to always use the default text-to-speech settings regardless
3436         * of the application settings.
3437         * 1 = override application settings,
3438         * 0 = use application settings (if specified).
3439         *
3440         * @deprecated  The value of this setting is no longer respected by
3441         * the framework text to speech APIs as of the Ice Cream Sandwich release.
3442         */
3443        @Deprecated
3444        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
3445
3446        /**
3447         * Default text-to-speech engine speech rate. 100 = 1x
3448         */
3449        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
3450
3451        /**
3452         * Default text-to-speech engine pitch. 100 = 1x
3453         */
3454        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
3455
3456        /**
3457         * Default text-to-speech engine.
3458         */
3459        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
3460
3461        /**
3462         * Default text-to-speech language.
3463         *
3464         * @deprecated this setting is no longer in use, as of the Ice Cream
3465         * Sandwich release. Apps should never need to read this setting directly,
3466         * instead can query the TextToSpeech framework classes for the default
3467         * locale. {@link TextToSpeech#getLanguage()}.
3468         */
3469        @Deprecated
3470        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
3471
3472        /**
3473         * Default text-to-speech country.
3474         *
3475         * @deprecated this setting is no longer in use, as of the Ice Cream
3476         * Sandwich release. Apps should never need to read this setting directly,
3477         * instead can query the TextToSpeech framework classes for the default
3478         * locale. {@link TextToSpeech#getLanguage()}.
3479         */
3480        @Deprecated
3481        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
3482
3483        /**
3484         * Default text-to-speech locale variant.
3485         *
3486         * @deprecated this setting is no longer in use, as of the Ice Cream
3487         * Sandwich release. Apps should never need to read this setting directly,
3488         * instead can query the TextToSpeech framework classes for the
3489         * locale that is in use {@link TextToSpeech#getLanguage()}.
3490         */
3491        @Deprecated
3492        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
3493
3494        /**
3495         * Stores the default tts locales on a per engine basis. Stored as
3496         * a comma seperated list of values, each value being of the form
3497         * {@code engine_name:locale} for example,
3498         * {@code com.foo.ttsengine:eng-USA,com.bar.ttsengine:esp-ESP}. This
3499         * supersedes {@link #TTS_DEFAULT_LANG}, {@link #TTS_DEFAULT_COUNTRY} and
3500         * {@link #TTS_DEFAULT_VARIANT}. Apps should never need to read this
3501         * setting directly, and can query the TextToSpeech framework classes
3502         * for the locale that is in use.
3503         *
3504         * @hide
3505         */
3506        public static final String TTS_DEFAULT_LOCALE = "tts_default_locale";
3507
3508        /**
3509         * Space delimited list of plugin packages that are enabled.
3510         */
3511        public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins";
3512
3513        /**
3514         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON}
3515         * instead.
3516         */
3517        @Deprecated
3518        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
3519                Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
3520
3521        /**
3522         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY}
3523         * instead.
3524         */
3525        @Deprecated
3526        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
3527                Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
3528
3529        /**
3530         * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT}
3531         * instead.
3532         */
3533        @Deprecated
3534        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT =
3535                Global.WIFI_NUM_OPEN_NETWORKS_KEPT;
3536
3537        /**
3538         * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON}
3539         * instead.
3540         */
3541        @Deprecated
3542        public static final String WIFI_ON = Global.WIFI_ON;
3543
3544        /**
3545         * The acceptable packet loss percentage (range 0 - 100) before trying
3546         * another AP on the same network.
3547         * @deprecated This setting is not used.
3548         */
3549        @Deprecated
3550        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
3551                "wifi_watchdog_acceptable_packet_loss_percentage";
3552
3553        /**
3554         * The number of access points required for a network in order for the
3555         * watchdog to monitor it.
3556         * @deprecated This setting is not used.
3557         */
3558        @Deprecated
3559        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
3560
3561        /**
3562         * The delay between background checks.
3563         * @deprecated This setting is not used.
3564         */
3565        @Deprecated
3566        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
3567                "wifi_watchdog_background_check_delay_ms";
3568
3569        /**
3570         * Whether the Wi-Fi watchdog is enabled for background checking even
3571         * after it thinks the user has connected to a good access point.
3572         * @deprecated This setting is not used.
3573         */
3574        @Deprecated
3575        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
3576                "wifi_watchdog_background_check_enabled";
3577
3578        /**
3579         * The timeout for a background ping
3580         * @deprecated This setting is not used.
3581         */
3582        @Deprecated
3583        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
3584                "wifi_watchdog_background_check_timeout_ms";
3585
3586        /**
3587         * The number of initial pings to perform that *may* be ignored if they
3588         * fail. Again, if these fail, they will *not* be used in packet loss
3589         * calculation. For example, one network always seemed to time out for
3590         * the first couple pings, so this is set to 3 by default.
3591         * @deprecated This setting is not used.
3592         */
3593        @Deprecated
3594        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
3595            "wifi_watchdog_initial_ignored_ping_count";
3596
3597        /**
3598         * The maximum number of access points (per network) to attempt to test.
3599         * If this number is reached, the watchdog will no longer monitor the
3600         * initial connection state for the network. This is a safeguard for
3601         * networks containing multiple APs whose DNS does not respond to pings.
3602         * @deprecated This setting is not used.
3603         */
3604        @Deprecated
3605        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
3606
3607        /**
3608         * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead
3609         */
3610        @Deprecated
3611        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
3612
3613        /**
3614         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
3615         * @deprecated This setting is not used.
3616         */
3617        @Deprecated
3618        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
3619
3620        /**
3621         * The number of pings to test if an access point is a good connection.
3622         * @deprecated This setting is not used.
3623         */
3624        @Deprecated
3625        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
3626
3627        /**
3628         * The delay between pings.
3629         * @deprecated This setting is not used.
3630         */
3631        @Deprecated
3632        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
3633
3634        /**
3635         * The timeout per ping.
3636         * @deprecated This setting is not used.
3637         */
3638        @Deprecated
3639        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
3640
3641        /**
3642         * @deprecated Use
3643         * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead
3644         */
3645        @Deprecated
3646        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT;
3647
3648        /**
3649         * @deprecated Use
3650         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
3651         */
3652        @Deprecated
3653        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
3654                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
3655
3656        /**
3657         * Whether background data usage is allowed.
3658         *
3659         * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH},
3660         *             availability of background data depends on several
3661         *             combined factors. When background data is unavailable,
3662         *             {@link ConnectivityManager#getActiveNetworkInfo()} will
3663         *             now appear disconnected.
3664         */
3665        @Deprecated
3666        public static final String BACKGROUND_DATA = "background_data";
3667
3668        /**
3669         * Origins for which browsers should allow geolocation by default.
3670         * The value is a space-separated list of origins.
3671         */
3672        public static final String ALLOWED_GEOLOCATION_ORIGINS
3673                = "allowed_geolocation_origins";
3674
3675        /**
3676         * The preferred TTY mode     0 = TTy Off, CDMA default
3677         *                            1 = TTY Full
3678         *                            2 = TTY HCO
3679         *                            3 = TTY VCO
3680         * @hide
3681         */
3682        public static final String PREFERRED_TTY_MODE =
3683                "preferred_tty_mode";
3684
3685        /**
3686         * Whether the enhanced voice privacy mode is enabled.
3687         * 0 = normal voice privacy
3688         * 1 = enhanced voice privacy
3689         * @hide
3690         */
3691        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
3692
3693        /**
3694         * Whether the TTY mode mode is enabled.
3695         * 0 = disabled
3696         * 1 = enabled
3697         * @hide
3698         */
3699        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
3700
3701        /**
3702         * Controls whether settings backup is enabled.
3703         * Type: int ( 0 = disabled, 1 = enabled )
3704         * @hide
3705         */
3706        public static final String BACKUP_ENABLED = "backup_enabled";
3707
3708        /**
3709         * Controls whether application data is automatically restored from backup
3710         * at install time.
3711         * Type: int ( 0 = disabled, 1 = enabled )
3712         * @hide
3713         */
3714        public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore";
3715
3716        /**
3717         * Indicates whether settings backup has been fully provisioned.
3718         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
3719         * @hide
3720         */
3721        public static final String BACKUP_PROVISIONED = "backup_provisioned";
3722
3723        /**
3724         * Component of the transport to use for backup/restore.
3725         * @hide
3726         */
3727        public static final String BACKUP_TRANSPORT = "backup_transport";
3728
3729        /**
3730         * Version for which the setup wizard was last shown.  Bumped for
3731         * each release when there is new setup information to show.
3732         * @hide
3733         */
3734        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
3735
3736        /**
3737         * The interval in milliseconds after which Wi-Fi is considered idle.
3738         * When idle, it is possible for the device to be switched from Wi-Fi to
3739         * the mobile data network.
3740         * @hide
3741         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
3742         * instead.
3743         */
3744        @Deprecated
3745        public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
3746
3747        /**
3748         * The global search provider chosen by the user (if multiple global
3749         * search providers are installed). This will be the provider returned
3750         * by {@link SearchManager#getGlobalSearchActivity()} if it's still
3751         * installed. This setting is stored as a flattened component name as
3752         * per {@link ComponentName#flattenToString()}.
3753         *
3754         * @hide
3755         */
3756        public static final String SEARCH_GLOBAL_SEARCH_ACTIVITY =
3757                "search_global_search_activity";
3758
3759        /**
3760         * The number of promoted sources in GlobalSearch.
3761         * @hide
3762         */
3763        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
3764        /**
3765         * The maximum number of suggestions returned by GlobalSearch.
3766         * @hide
3767         */
3768        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
3769        /**
3770         * The number of suggestions GlobalSearch will ask each non-web search source for.
3771         * @hide
3772         */
3773        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
3774        /**
3775         * The number of suggestions the GlobalSearch will ask the web search source for.
3776         * @hide
3777         */
3778        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
3779                "search_web_results_override_limit";
3780        /**
3781         * The number of milliseconds that GlobalSearch will wait for suggestions from
3782         * promoted sources before continuing with all other sources.
3783         * @hide
3784         */
3785        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
3786                "search_promoted_source_deadline_millis";
3787        /**
3788         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
3789         * @hide
3790         */
3791        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
3792        /**
3793         * The maximum number of milliseconds that GlobalSearch shows the previous results
3794         * after receiving a new query.
3795         * @hide
3796         */
3797        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
3798        /**
3799         * The maximum age of log data used for shortcuts in GlobalSearch.
3800         * @hide
3801         */
3802        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
3803        /**
3804         * The maximum age of log data used for source ranking in GlobalSearch.
3805         * @hide
3806         */
3807        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
3808                "search_max_source_event_age_millis";
3809        /**
3810         * The minimum number of impressions needed to rank a source in GlobalSearch.
3811         * @hide
3812         */
3813        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
3814                "search_min_impressions_for_source_ranking";
3815        /**
3816         * The minimum number of clicks needed to rank a source in GlobalSearch.
3817         * @hide
3818         */
3819        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
3820                "search_min_clicks_for_source_ranking";
3821        /**
3822         * The maximum number of shortcuts shown by GlobalSearch.
3823         * @hide
3824         */
3825        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
3826        /**
3827         * The size of the core thread pool for suggestion queries in GlobalSearch.
3828         * @hide
3829         */
3830        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
3831                "search_query_thread_core_pool_size";
3832        /**
3833         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
3834         * @hide
3835         */
3836        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
3837                "search_query_thread_max_pool_size";
3838        /**
3839         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
3840         * @hide
3841         */
3842        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
3843                "search_shortcut_refresh_core_pool_size";
3844        /**
3845         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
3846         * @hide
3847         */
3848        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
3849                "search_shortcut_refresh_max_pool_size";
3850        /**
3851         * The maximun time that excess threads in the GlobalSeach thread pools will
3852         * wait before terminating.
3853         * @hide
3854         */
3855        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
3856                "search_thread_keepalive_seconds";
3857        /**
3858         * The maximum number of concurrent suggestion queries to each source.
3859         * @hide
3860         */
3861        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
3862                "search_per_source_concurrent_query_limit";
3863
3864        /**
3865         * Whether or not alert sounds are played on MountService events. (0 = false, 1 = true)
3866         * @hide
3867         */
3868        public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd";
3869
3870        /**
3871         * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true)
3872         * @hide
3873         */
3874        public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart";
3875
3876        /**
3877         * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true)
3878         * @hide
3879         */
3880        public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt";
3881
3882        /**
3883         * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true)
3884         * @hide
3885         */
3886        public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled";
3887
3888        /**
3889         * If nonzero, ANRs in invisible background processes bring up a dialog.
3890         * Otherwise, the process will be silently killed.
3891         * @hide
3892         */
3893        public static final String ANR_SHOW_BACKGROUND = "anr_show_background";
3894
3895        /**
3896         * The {@link ComponentName} string of the service to be used as the voice recognition
3897         * service.
3898         *
3899         * @hide
3900         */
3901        public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
3902
3903
3904        /**
3905         * The {@link ComponentName} string of the selected spell checker service which is
3906         * one of the services managed by the text service manager.
3907         *
3908         * @hide
3909         */
3910        public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
3911
3912        /**
3913         * The {@link ComponentName} string of the selected subtype of the selected spell checker
3914         * service which is one of the services managed by the text service manager.
3915         *
3916         * @hide
3917         */
3918        public static final String SELECTED_SPELL_CHECKER_SUBTYPE =
3919                "selected_spell_checker_subtype";
3920
3921        /**
3922         * The {@link ComponentName} string whether spell checker is enabled or not.
3923         *
3924         * @hide
3925         */
3926        public static final String SPELL_CHECKER_ENABLED = "spell_checker_enabled";
3927
3928        /**
3929         * What happens when the user presses the Power button while in-call
3930         * and the screen is on.<br/>
3931         * <b>Values:</b><br/>
3932         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
3933         * 2 - The Power button hangs up the current call.<br/>
3934         *
3935         * @hide
3936         */
3937        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
3938
3939        /**
3940         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
3941         * @hide
3942         */
3943        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
3944
3945        /**
3946         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
3947         * @hide
3948         */
3949        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
3950
3951        /**
3952         * INCALL_POWER_BUTTON_BEHAVIOR default value.
3953         * @hide
3954         */
3955        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
3956                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
3957
3958        /**
3959         * The current night mode that has been selected by the user.  Owned
3960         * and controlled by UiModeManagerService.  Constants are as per
3961         * UiModeManager.
3962         * @hide
3963         */
3964        public static final String UI_NIGHT_MODE = "ui_night_mode";
3965
3966        /**
3967         * Whether screensavers are enabled.
3968         * @hide
3969         */
3970        public static final String SCREENSAVER_ENABLED = "screensaver_enabled";
3971
3972        /**
3973         * The user's chosen screensaver components.
3974         *
3975         * These will be launched by the PhoneWindowManager after a timeout when not on
3976         * battery, or upon dock insertion (if SCREENSAVER_ACTIVATE_ON_DOCK is set to 1).
3977         * @hide
3978         */
3979        public static final String SCREENSAVER_COMPONENTS = "screensaver_components";
3980
3981        /**
3982         * If screensavers are enabled, whether the screensaver should be automatically launched
3983         * when the device is inserted into a (desk) dock.
3984         * @hide
3985         */
3986        public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock";
3987
3988        /**
3989         * If screensavers are enabled, whether the screensaver should be automatically launched
3990         * when the screen times out when not on battery.
3991         * @hide
3992         */
3993        public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep";
3994
3995        /**
3996         * If screensavers are enabled, the default screensaver component.
3997         * @hide
3998         */
3999        public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
4000
4001        /**
4002         * This are the settings to be backed up.
4003         *
4004         * NOTE: Settings are backed up and restored in the order they appear
4005         *       in this array. If you have one setting depending on another,
4006         *       make sure that they are ordered appropriately.
4007         *
4008         * @hide
4009         */
4010        public static final String[] SETTINGS_TO_BACKUP = {
4011            BUGREPORT_IN_POWER_MENU,
4012            ALLOW_MOCK_LOCATION,
4013            PARENTAL_CONTROL_ENABLED,
4014            PARENTAL_CONTROL_REDIRECT_URL,
4015            USB_MASS_STORAGE_ENABLED,                           // moved to global
4016            ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
4017            ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
4018            ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
4019            ACCESSIBILITY_SCRIPT_INJECTION,
4020            BACKUP_AUTO_RESTORE,
4021            ENABLED_ACCESSIBILITY_SERVICES,
4022            TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
4023            TOUCH_EXPLORATION_ENABLED,
4024            ACCESSIBILITY_ENABLED,
4025            ACCESSIBILITY_SPEAK_PASSWORD,
4026            TTS_USE_DEFAULTS,
4027            TTS_DEFAULT_RATE,
4028            TTS_DEFAULT_PITCH,
4029            TTS_DEFAULT_SYNTH,
4030            TTS_DEFAULT_LANG,
4031            TTS_DEFAULT_COUNTRY,
4032            TTS_ENABLED_PLUGINS,
4033            TTS_DEFAULT_LOCALE,
4034            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
4035            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
4036            WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
4037            MOUNT_PLAY_NOTIFICATION_SND,
4038            MOUNT_UMS_AUTOSTART,
4039            MOUNT_UMS_PROMPT,
4040            MOUNT_UMS_NOTIFY_ENABLED,
4041            UI_NIGHT_MODE,
4042            LOCK_SCREEN_OWNER_INFO,
4043            LOCK_SCREEN_OWNER_INFO_ENABLED
4044        };
4045
4046        /**
4047         * Helper method for determining if a location provider is enabled.
4048         * @param cr the content resolver to use
4049         * @param provider the location provider to query
4050         * @return true if the provider is enabled
4051         */
4052        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
4053            return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId());
4054        }
4055
4056        /**
4057         * Helper method for determining if a location provider is enabled.
4058         * @param cr the content resolver to use
4059         * @param provider the location provider to query
4060         * @param userId the userId to query
4061         * @return true if the provider is enabled
4062         * @hide
4063         */
4064        public static final boolean isLocationProviderEnabledForUser(ContentResolver cr, String provider, int userId) {
4065            String allowedProviders = Settings.Secure.getStringForUser(cr,
4066                    LOCATION_PROVIDERS_ALLOWED, userId);
4067            return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
4068        }
4069
4070        /**
4071         * Thread-safe method for enabling or disabling a single location provider.
4072         * @param cr the content resolver to use
4073         * @param provider the location provider to enable or disable
4074         * @param enabled true if the provider should be enabled
4075         */
4076        public static final void setLocationProviderEnabled(ContentResolver cr,
4077                String provider, boolean enabled) {
4078            setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId());
4079        }
4080
4081        /**
4082         * Thread-safe method for enabling or disabling a single location provider.
4083         * @param cr the content resolver to use
4084         * @param provider the location provider to enable or disable
4085         * @param enabled true if the provider should be enabled
4086         * @param userId the userId for which to enable/disable providers
4087         * @hide
4088         */
4089        public static final void setLocationProviderEnabledForUser(ContentResolver cr,
4090                String provider, boolean enabled, int userId) {
4091            // to ensure thread safety, we write the provider name with a '+' or '-'
4092            // and let the SettingsProvider handle it rather than reading and modifying
4093            // the list of enabled providers.
4094            if (enabled) {
4095                provider = "+" + provider;
4096            } else {
4097                provider = "-" + provider;
4098            }
4099            putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
4100                    userId);
4101        }
4102    }
4103
4104    /**
4105     * Global system settings, containing preferences that always apply identically
4106     * to all defined users.  Applications can read these but are not allowed to write;
4107     * like the "Secure" settings, these are for preferences that the user must
4108     * explicitly modify through the system UI or specialized APIs for those values.
4109     */
4110    public static final class Global extends NameValueTable {
4111        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_global_version";
4112
4113        /**
4114         * The content:// style URL for global secure settings items.  Not public.
4115         */
4116        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
4117
4118        /**
4119         * Setting whether the global gesture for enabling accessibility is enabled.
4120         * If this gesture is enabled the user will be able to perfrom it to enable
4121         * the accessibility state without visiting the settings app.
4122         * @hide
4123         */
4124        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
4125                "enable_accessibility_global_gesture_enabled";
4126
4127        /**
4128         * Whether Airplane Mode is on.
4129         */
4130        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
4131
4132        /**
4133         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
4134         */
4135        public static final String RADIO_BLUETOOTH = "bluetooth";
4136
4137        /**
4138         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
4139         */
4140        public static final String RADIO_WIFI = "wifi";
4141
4142        /**
4143         * {@hide}
4144         */
4145        public static final String RADIO_WIMAX = "wimax";
4146        /**
4147         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
4148         */
4149        public static final String RADIO_CELL = "cell";
4150
4151        /**
4152         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
4153         */
4154        public static final String RADIO_NFC = "nfc";
4155
4156        /**
4157         * A comma separated list of radios that need to be disabled when airplane mode
4158         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
4159         * included in the comma separated list.
4160         */
4161        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
4162
4163        /**
4164         * A comma separated list of radios that should to be disabled when airplane mode
4165         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
4166         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
4167         * will be turned off when entering airplane mode, but the user will be able to reenable
4168         * Wifi in the Settings app.
4169         *
4170         * {@hide}
4171         */
4172        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
4173
4174        /**
4175         * The policy for deciding when Wi-Fi should go to sleep (which will in
4176         * turn switch to using the mobile data as an Internet connection).
4177         * <p>
4178         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
4179         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
4180         * {@link #WIFI_SLEEP_POLICY_NEVER}.
4181         */
4182        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
4183
4184        /**
4185         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
4186         * policy, which is to sleep shortly after the turning off
4187         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
4188         */
4189        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
4190
4191        /**
4192         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
4193         * the device is on battery, and never go to sleep when the device is
4194         * plugged in.
4195         */
4196        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
4197
4198        /**
4199         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
4200         */
4201        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
4202
4203        /**
4204         * Value to specify if the user prefers the date, time and time zone
4205         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
4206         */
4207        public static final String AUTO_TIME = "auto_time";
4208
4209        /**
4210         * Value to specify if the user prefers the time zone
4211         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
4212         */
4213        public static final String AUTO_TIME_ZONE = "auto_time_zone";
4214
4215        /**
4216         * URI for the car dock "in" event sound.
4217         * @hide
4218         */
4219        public static final String CAR_DOCK_SOUND = "car_dock_sound";
4220
4221        /**
4222         * URI for the car dock "out" event sound.
4223         * @hide
4224         */
4225        public static final String CAR_UNDOCK_SOUND = "car_undock_sound";
4226
4227        /**
4228         * URI for the desk dock "in" event sound.
4229         * @hide
4230         */
4231        public static final String DESK_DOCK_SOUND = "desk_dock_sound";
4232
4233        /**
4234         * URI for the desk dock "out" event sound.
4235         * @hide
4236         */
4237        public static final String DESK_UNDOCK_SOUND = "desk_undock_sound";
4238
4239        /**
4240         * Whether to play a sound for dock events.
4241         * @hide
4242         */
4243        public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
4244
4245        /**
4246         * URI for the "device locked" (keyguard shown) sound.
4247         * @hide
4248         */
4249        public static final String LOCK_SOUND = "lock_sound";
4250
4251        /**
4252         * URI for the "device unlocked" sound.
4253         * @hide
4254         */
4255        public static final String UNLOCK_SOUND = "unlock_sound";
4256
4257        /**
4258         * URI for the low battery sound file.
4259         * @hide
4260         */
4261        public static final String LOW_BATTERY_SOUND = "low_battery_sound";
4262
4263        /**
4264         * Whether to play a sound for low-battery alerts.
4265         * @hide
4266         */
4267        public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
4268
4269        /**
4270         * Whether we keep the device on while the device is plugged in.
4271         * Supported values are:
4272         * <ul>
4273         * <li>{@code 0} to never stay on while plugged in</li>
4274         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
4275         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
4276         * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
4277         * </ul>
4278         * These values can be OR-ed together.
4279         */
4280        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
4281
4282        /**
4283         * Whether ADB is enabled.
4284         */
4285        public static final String ADB_ENABLED = "adb_enabled";
4286
4287        /**
4288         * Whether assisted GPS should be enabled or not.
4289         * @hide
4290         */
4291        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
4292
4293        /**
4294         * Whether bluetooth is enabled/disabled
4295         * 0=disabled. 1=enabled.
4296         */
4297        public static final String BLUETOOTH_ON = "bluetooth_on";
4298
4299        /**
4300         * CDMA Cell Broadcast SMS
4301         *                            0 = CDMA Cell Broadcast SMS disabled
4302         *                            1 = CDMA Cell Broadcast SMS enabled
4303         * @hide
4304         */
4305        public static final String CDMA_CELL_BROADCAST_SMS =
4306                "cdma_cell_broadcast_sms";
4307
4308        /**
4309         * The CDMA roaming mode 0 = Home Networks, CDMA default
4310         *                       1 = Roaming on Affiliated networks
4311         *                       2 = Roaming on any networks
4312         * @hide
4313         */
4314        public static final String CDMA_ROAMING_MODE = "roaming_settings";
4315
4316        /**
4317         * The CDMA subscription mode 0 = RUIM/SIM (default)
4318         *                                1 = NV
4319         * @hide
4320         */
4321        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
4322
4323        /** Inactivity timeout to track mobile data activity.
4324        *
4325        * If set to a positive integer, it indicates the inactivity timeout value in seconds to
4326        * infer the data activity of mobile network. After a period of no activity on mobile
4327        * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE}
4328        * intent is fired to indicate a transition of network status from "active" to "idle". Any
4329        * subsequent activity on mobile networks triggers the firing of {@code
4330        * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active".
4331        *
4332        * Network activity refers to transmitting or receiving data on the network interfaces.
4333        *
4334        * Tracking is disabled if set to zero or negative value.
4335        *
4336        * @hide
4337        */
4338       public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile";
4339
4340       /** Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE}
4341        * but for Wifi network.
4342        * @hide
4343        */
4344       public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi";
4345
4346       /**
4347        * Whether or not data roaming is enabled. (0 = false, 1 = true)
4348        */
4349       public static final String DATA_ROAMING = "data_roaming";
4350
4351       /**
4352        * Whether user has enabled development settings.
4353        */
4354       public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
4355
4356       /**
4357        * Whether the device has been provisioned (0 = false, 1 = true)
4358        */
4359       public static final String DEVICE_PROVISIONED = "device_provisioned";
4360
4361       /**
4362        * The saved value for WindowManagerService.setForcedDisplayDensity().
4363        * One integer in dpi.  If unset, then use the real display density.
4364        * @hide
4365        */
4366       public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
4367
4368       /**
4369        * The saved value for WindowManagerService.setForcedDisplaySize().
4370        * Two integers separated by a comma.  If unset, then use the real display size.
4371        * @hide
4372        */
4373       public static final String DISPLAY_SIZE_FORCED = "display_size_forced";
4374
4375       /**
4376        * The maximum size, in bytes, of a download that the download manager will transfer over
4377        * a non-wifi connection.
4378        * @hide
4379        */
4380       public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE =
4381               "download_manager_max_bytes_over_mobile";
4382
4383       /**
4384        * The recommended maximum size, in bytes, of a download that the download manager should
4385        * transfer over a non-wifi connection. Over this size, the use will be warned, but will
4386        * have the option to start the download over the mobile connection anyway.
4387        * @hide
4388        */
4389       public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE =
4390               "download_manager_recommended_max_bytes_over_mobile";
4391
4392       /**
4393        * Whether the package installer should allow installation of apps downloaded from
4394        * sources other than Google Play.
4395        *
4396        * 1 = allow installing from other sources
4397        * 0 = only allow installing from Google Play
4398        */
4399       public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
4400
4401       /**
4402        * Whether mobile data connections are allowed by the user.  See
4403        * ConnectivityManager for more info.
4404        * @hide
4405        */
4406       public static final String MOBILE_DATA = "mobile_data";
4407
4408       /** {@hide} */
4409       public static final String NETSTATS_ENABLED = "netstats_enabled";
4410       /** {@hide} */
4411       public static final String NETSTATS_POLL_INTERVAL = "netstats_poll_interval";
4412       /** {@hide} */
4413       public static final String NETSTATS_TIME_CACHE_MAX_AGE = "netstats_time_cache_max_age";
4414       /** {@hide} */
4415       public static final String NETSTATS_GLOBAL_ALERT_BYTES = "netstats_global_alert_bytes";
4416       /** {@hide} */
4417       public static final String NETSTATS_SAMPLE_ENABLED = "netstats_sample_enabled";
4418       /** {@hide} */
4419       public static final String NETSTATS_REPORT_XT_OVER_DEV = "netstats_report_xt_over_dev";
4420
4421       /** {@hide} */
4422       public static final String NETSTATS_DEV_BUCKET_DURATION = "netstats_dev_bucket_duration";
4423       /** {@hide} */
4424       public static final String NETSTATS_DEV_PERSIST_BYTES = "netstats_dev_persist_bytes";
4425       /** {@hide} */
4426       public static final String NETSTATS_DEV_ROTATE_AGE = "netstats_dev_rotate_age";
4427       /** {@hide} */
4428       public static final String NETSTATS_DEV_DELETE_AGE = "netstats_dev_delete_age";
4429
4430       /** {@hide} */
4431       public static final String NETSTATS_UID_BUCKET_DURATION = "netstats_uid_bucket_duration";
4432       /** {@hide} */
4433       public static final String NETSTATS_UID_PERSIST_BYTES = "netstats_uid_persist_bytes";
4434       /** {@hide} */
4435       public static final String NETSTATS_UID_ROTATE_AGE = "netstats_uid_rotate_age";
4436       /** {@hide} */
4437       public static final String NETSTATS_UID_DELETE_AGE = "netstats_uid_delete_age";
4438
4439       /** {@hide} */
4440       public static final String NETSTATS_UID_TAG_BUCKET_DURATION = "netstats_uid_tag_bucket_duration";
4441       /** {@hide} */
4442       public static final String NETSTATS_UID_TAG_PERSIST_BYTES = "netstats_uid_tag_persist_bytes";
4443       /** {@hide} */
4444       public static final String NETSTATS_UID_TAG_ROTATE_AGE = "netstats_uid_tag_rotate_age";
4445       /** {@hide} */
4446       public static final String NETSTATS_UID_TAG_DELETE_AGE = "netstats_uid_tag_delete_age";
4447
4448       /**
4449        * User preference for which network(s) should be used. Only the
4450        * connectivity service should touch this.
4451        */
4452       public static final String NETWORK_PREFERENCE = "network_preference";
4453
4454       /**
4455        * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
4456        * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
4457        * exceeded.
4458        * @hide
4459        */
4460       public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
4461
4462       /**
4463        * The length of time in milli-seconds that automatic small adjustments to
4464        * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
4465        * @hide
4466        */
4467       public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
4468
4469       /** Preferred NTP server. {@hide} */
4470       public static final String NTP_SERVER = "ntp_server";
4471       /** Timeout in milliseconds to wait for NTP server. {@hide} */
4472       public static final String NTP_TIMEOUT = "ntp_timeout";
4473
4474       /**
4475        * Whether the package manager should send package verification broadcasts for verifiers to
4476        * review apps prior to installation.
4477        * 1 = request apps to be verified prior to installation, if a verifier exists.
4478        * 0 = do not verify apps before installation
4479        * @hide
4480        */
4481       public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable";
4482
4483       /** Timeout for package verification.
4484        * @hide */
4485       public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
4486
4487       /** Default response code for package verification.
4488        * @hide */
4489       public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
4490
4491       /**
4492        * Show package verification setting in the Settings app.
4493        * 1 = show (default)
4494        * 0 = hide
4495        * @hide
4496        */
4497       public static final String PACKAGE_VERIFIER_SETTING_VISIBLE = "verifier_setting_visible";
4498
4499       /**
4500        * Run package verificaiton on apps installed through ADB/ADT/USB
4501        * 1 = perform package verification on ADB installs (default)
4502        * 0 = bypass package verification on ADB installs
4503        * @hide
4504        */
4505       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
4506
4507       /**
4508        * The interval in milliseconds at which to check packet counts on the
4509        * mobile data interface when screen is on, to detect possible data
4510        * connection problems.
4511        * @hide
4512        */
4513       public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
4514               "pdp_watchdog_poll_interval_ms";
4515
4516       /**
4517        * The interval in milliseconds at which to check packet counts on the
4518        * mobile data interface when screen is off, to detect possible data
4519        * connection problems.
4520        * @hide
4521        */
4522       public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
4523               "pdp_watchdog_long_poll_interval_ms";
4524
4525       /**
4526        * The interval in milliseconds at which to check packet counts on the
4527        * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
4528        * outgoing packets has been reached without incoming packets.
4529        * @hide
4530        */
4531       public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
4532               "pdp_watchdog_error_poll_interval_ms";
4533
4534       /**
4535        * The number of outgoing packets sent without seeing an incoming packet
4536        * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
4537        * device is logged to the event log
4538        * @hide
4539        */
4540       public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
4541               "pdp_watchdog_trigger_packet_count";
4542
4543       /**
4544        * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
4545        * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
4546        * attempting data connection recovery.
4547        * @hide
4548        */
4549       public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
4550               "pdp_watchdog_error_poll_count";
4551
4552       /**
4553        * The number of failed PDP reset attempts before moving to something more
4554        * drastic: re-registering to the network.
4555        * @hide
4556        */
4557       public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
4558               "pdp_watchdog_max_pdp_reset_fail_count";
4559
4560       /**
4561        * A positive value indicates how often the SamplingProfiler
4562        * should take snapshots. Zero value means SamplingProfiler
4563        * is disabled.
4564        *
4565        * @hide
4566        */
4567       public static final String SAMPLING_PROFILER_MS = "sampling_profiler_ms";
4568
4569       /**
4570        * URL to open browser on to allow user to manage a prepay account
4571        * @hide
4572        */
4573       public static final String SETUP_PREPAID_DATA_SERVICE_URL =
4574               "setup_prepaid_data_service_url";
4575
4576       /**
4577        * URL to attempt a GET on to see if this is a prepay device
4578        * @hide
4579        */
4580       public static final String SETUP_PREPAID_DETECTION_TARGET_URL =
4581               "setup_prepaid_detection_target_url";
4582
4583       /**
4584        * Host to check for a redirect to after an attempt to GET
4585        * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there,
4586        * this is a prepaid device with zero balance.)
4587        * @hide
4588        */
4589       public static final String SETUP_PREPAID_DETECTION_REDIR_HOST =
4590               "setup_prepaid_detection_redir_host";
4591
4592       /**
4593        * The interval in milliseconds at which to check the number of SMS sent out without asking
4594        * for use permit, to limit the un-authorized SMS usage.
4595        *
4596        * @hide
4597        */
4598       public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
4599               "sms_outgoing_check_interval_ms";
4600
4601       /**
4602        * The number of outgoing SMS sent without asking for user permit (of {@link
4603        * #SMS_OUTGOING_CHECK_INTERVAL_MS}
4604        *
4605        * @hide
4606        */
4607       public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
4608               "sms_outgoing_check_max_count";
4609
4610       /**
4611        * Used to disable SMS short code confirmation - defaults to true.
4612        * True indcates we will do the check, etc.  Set to false to disable.
4613        * @see com.android.internal.telephony.SmsUsageMonitor
4614        * @hide
4615        */
4616       public static final String SMS_SHORT_CODE_CONFIRMATION = "sms_short_code_confirmation";
4617
4618        /**
4619         * Used to select which country we use to determine premium sms codes.
4620         * One of com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_SIM,
4621         * com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_NETWORK,
4622         * or com.android.internal.telephony.SMSDispatcher.PREMIUM_RULE_USE_BOTH.
4623         * @hide
4624         */
4625        public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule";
4626
4627       /**
4628        * Used to disable Tethering on a device - defaults to true
4629        * @hide
4630        */
4631       public static final String TETHER_SUPPORTED = "tether_supported";
4632
4633       /**
4634        * Used to require DUN APN on the device or not - defaults to a build config value
4635        * which defaults to false
4636        * @hide
4637        */
4638       public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
4639
4640       /**
4641        * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
4642        * corresponding build config values are set it will override the APN DB
4643        * values.
4644        * Consists of a comma seperated list of strings:
4645        * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
4646        * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
4647        * @hide
4648        */
4649       public static final String TETHER_DUN_APN = "tether_dun_apn";
4650
4651       /**
4652        * The bandwidth throttle polling freqency in seconds
4653        * @hide
4654        */
4655       public static final String THROTTLE_POLLING_SEC = "throttle_polling_sec";
4656
4657       /**
4658        * The bandwidth throttle threshold (long)
4659        * @hide
4660        */
4661       public static final String THROTTLE_THRESHOLD_BYTES = "throttle_threshold_bytes";
4662
4663       /**
4664        * The bandwidth throttle value (kbps)
4665        * @hide
4666        */
4667       public static final String THROTTLE_VALUE_KBITSPS = "throttle_value_kbitsps";
4668
4669       /**
4670        * The bandwidth throttle reset calendar day (1-28)
4671        * @hide
4672        */
4673       public static final String THROTTLE_RESET_DAY = "throttle_reset_day";
4674
4675       /**
4676        * The throttling notifications we should send
4677        * @hide
4678        */
4679       public static final String THROTTLE_NOTIFICATION_TYPE = "throttle_notification_type";
4680
4681       /**
4682        * Help URI for data throttling policy
4683        * @hide
4684        */
4685       public static final String THROTTLE_HELP_URI = "throttle_help_uri";
4686
4687       /**
4688        * The length of time in Sec that we allow our notion of NTP time
4689        * to be cached before we refresh it
4690        * @hide
4691        */
4692       public static final String THROTTLE_MAX_NTP_CACHE_AGE_SEC =
4693               "throttle_max_ntp_cache_age_sec";
4694
4695       /**
4696        * USB Mass Storage Enabled
4697        */
4698       public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
4699
4700       /**
4701        * If this setting is set (to anything), then all references
4702        * to Gmail on the device must change to Google Mail.
4703        */
4704       public static final String USE_GOOGLE_MAIL = "use_google_mail";
4705
4706       /** Autofill server address (Used in WebView/browser).
4707        * {@hide} */
4708       public static final String WEB_AUTOFILL_QUERY_URL =
4709           "web_autofill_query_url";
4710
4711       /**
4712        * Whether Wifi display is enabled/disabled
4713        * 0=disabled. 1=enabled.
4714        * @hide
4715        */
4716       public static final String WIFI_DISPLAY_ON = "wifi_display_on";
4717
4718       /**
4719        * Whether to notify the user of open networks.
4720        * <p>
4721        * If not connected and the scan results have an open network, we will
4722        * put this notification up. If we attempt to connect to a network or
4723        * the open network(s) disappear, we remove the notification. When we
4724        * show the notification, we will not show it again for
4725        * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
4726        */
4727       public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
4728               "wifi_networks_available_notification_on";
4729       /**
4730        * {@hide}
4731        */
4732       public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON =
4733               "wimax_networks_available_notification_on";
4734
4735       /**
4736        * Delay (in seconds) before repeating the Wi-Fi networks available notification.
4737        * Connecting to a network will reset the timer.
4738        */
4739       public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
4740               "wifi_networks_available_repeat_delay";
4741
4742       /**
4743        * 802.11 country code in ISO 3166 format
4744        * @hide
4745        */
4746       public static final String WIFI_COUNTRY_CODE = "wifi_country_code";
4747
4748       /**
4749        * The interval in milliseconds to issue wake up scans when wifi needs
4750        * to connect. This is necessary to connect to an access point when
4751        * device is on the move and the screen is off.
4752        * @hide
4753        */
4754       public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
4755               "wifi_framework_scan_interval_ms";
4756
4757       /**
4758        * The interval in milliseconds after which Wi-Fi is considered idle.
4759        * When idle, it is possible for the device to be switched from Wi-Fi to
4760        * the mobile data network.
4761        * @hide
4762        */
4763       public static final String WIFI_IDLE_MS = "wifi_idle_ms";
4764
4765       /**
4766        * When the number of open networks exceeds this number, the
4767        * least-recently-used excess networks will be removed.
4768        */
4769       public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
4770
4771       /**
4772        * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
4773        */
4774       public static final String WIFI_ON = "wifi_on";
4775
4776       /**
4777        * Used to save the Wifi_ON state prior to tethering.
4778        * This state will be checked to restore Wifi after
4779        * the user turns off tethering.
4780        *
4781        * @hide
4782        */
4783       public static final String WIFI_SAVED_STATE = "wifi_saved_state";
4784
4785       /**
4786        * The interval in milliseconds to scan as used by the wifi supplicant
4787        * @hide
4788        */
4789       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
4790               "wifi_supplicant_scan_interval_ms";
4791
4792       /**
4793        * The interval in milliseconds to scan at supplicant when p2p is connected
4794        * @hide
4795        */
4796       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
4797               "wifi_scan_interval_p2p_connected_ms";
4798
4799       /**
4800        * Whether the Wi-Fi watchdog is enabled.
4801        */
4802       public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
4803
4804       /**
4805        * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and
4806        * the setting needs to be set to 0 to disable it.
4807        * @hide
4808        */
4809       public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
4810               "wifi_watchdog_poor_network_test_enabled";
4811
4812       /**
4813        * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
4814        * needs to be set to 0 to disable it.
4815        * @hide
4816        */
4817       public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
4818               "wifi_suspend_optimizations_enabled";
4819
4820       /**
4821        * The maximum number of times we will retry a connection to an access
4822        * point for which we have failed in acquiring an IP address from DHCP.
4823        * A value of N means that we will make N+1 connection attempts in all.
4824        */
4825       public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
4826
4827       /**
4828        * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
4829        * data connectivity to be established after a disconnect from Wi-Fi.
4830        */
4831       public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
4832           "wifi_mobile_data_transition_wakelock_timeout_ms";
4833
4834       /**
4835        * The operational wifi frequency band
4836        * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO},
4837        * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or
4838        * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ}
4839        *
4840        * @hide
4841        */
4842       public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band";
4843
4844       /**
4845        * The Wi-Fi peer-to-peer device name
4846        * @hide
4847        */
4848       public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name";
4849
4850       /**
4851        * The number of milliseconds to delay when checking for data stalls during
4852        * non-aggressive detection. (screen is turned off.)
4853        * @hide
4854        */
4855       public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
4856               "data_stall_alarm_non_aggressive_delay_in_ms";
4857
4858       /**
4859        * The number of milliseconds to delay when checking for data stalls during
4860        * aggressive detection. (screen on or suspected data stall)
4861        * @hide
4862        */
4863       public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
4864               "data_stall_alarm_aggressive_delay_in_ms";
4865
4866       /**
4867        * The interval in milliseconds at which to check gprs registration
4868        * after the first registration mismatch of gprs and voice service,
4869        * to detect possible data network registration problems.
4870        *
4871        * @hide
4872        */
4873       public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
4874               "gprs_register_check_period_ms";
4875
4876       /**
4877        * Nonzero causes Log.wtf() to crash.
4878        * @hide
4879        */
4880       public static final String WTF_IS_FATAL = "wtf_is_fatal";
4881
4882       /**
4883        * Ringer mode. This is used internally, changing this value will not
4884        * change the ringer mode. See AudioManager.
4885        */
4886       public static final String MODE_RINGER = "mode_ringer";
4887
4888       /**
4889        * Overlay display devices setting.
4890        * The associated value is a specially formatted string that describes the
4891        * size and density of simulated secondary display devices.
4892        * <p>
4893        * Format: {width}x{height}/{dpi};...
4894        * </p><p>
4895        * Example:
4896        * <ul>
4897        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
4898        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
4899        * at 1080p and the second at 720p.</li>
4900        * <li>If the value is empty, then no overlay display devices are created.</li>
4901        * </ul></p>
4902        *
4903        * @hide
4904        */
4905       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
4906
4907        /**
4908         * Threshold values for the duration and level of a discharge cycle,
4909         * under which we log discharge cycle info.
4910         *
4911         * @hide
4912         */
4913        public static final String
4914                BATTERY_DISCHARGE_DURATION_THRESHOLD = "battery_discharge_duration_threshold";
4915
4916        /** @hide */
4917        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
4918
4919        /**
4920         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR
4921         * intents on application crashes and ANRs. If this is disabled, the
4922         * crash/ANR dialog will never display the "Report" button.
4923         * <p>
4924         * Type: int (0 = disallow, 1 = allow)
4925         *
4926         * @hide
4927         */
4928        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
4929
4930        /**
4931         * Maximum age of entries kept by {@link DropBoxManager}.
4932         *
4933         * @hide
4934         */
4935        public static final String DROPBOX_AGE_SECONDS = "dropbox_age_seconds";
4936
4937        /**
4938         * Maximum number of entry files which {@link DropBoxManager} will keep
4939         * around.
4940         *
4941         * @hide
4942         */
4943        public static final String DROPBOX_MAX_FILES = "dropbox_max_files";
4944
4945        /**
4946         * Maximum amount of disk space used by {@link DropBoxManager} no matter
4947         * what.
4948         *
4949         * @hide
4950         */
4951        public static final String DROPBOX_QUOTA_KB = "dropbox_quota_kb";
4952
4953        /**
4954         * Percent of free disk (excluding reserve) which {@link DropBoxManager}
4955         * will use.
4956         *
4957         * @hide
4958         */
4959        public static final String DROPBOX_QUOTA_PERCENT = "dropbox_quota_percent";
4960
4961        /**
4962         * Percent of total disk which {@link DropBoxManager} will never dip
4963         * into.
4964         *
4965         * @hide
4966         */
4967        public static final String DROPBOX_RESERVE_PERCENT = "dropbox_reserve_percent";
4968
4969        /**
4970         * Prefix for per-tag dropbox disable/enable settings.
4971         *
4972         * @hide
4973         */
4974        public static final String DROPBOX_TAG_PREFIX = "dropbox:";
4975
4976        /**
4977         * Lines of logcat to include with system crash/ANR/etc. reports, as a
4978         * prefix of the dropbox tag of the report type. For example,
4979         * "logcat_for_system_server_anr" controls the lines of logcat captured
4980         * with system server ANR reports. 0 to disable.
4981         *
4982         * @hide
4983         */
4984        public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
4985
4986        /**
4987         * The interval in minutes after which the amount of free storage left
4988         * on the device is logged to the event log
4989         *
4990         * @hide
4991         */
4992        public static final String SYS_FREE_STORAGE_LOG_INTERVAL = "sys_free_storage_log_interval";
4993
4994        /**
4995         * Threshold for the amount of change in disk free space required to
4996         * report the amount of free space. Used to prevent spamming the logs
4997         * when the disk free space isn't changing frequently.
4998         *
4999         * @hide
5000         */
5001        public static final String
5002                DISK_FREE_CHANGE_REPORTING_THRESHOLD = "disk_free_change_reporting_threshold";
5003
5004        /**
5005         * Minimum percentage of free storage on the device that is used to
5006         * determine if the device is running low on storage. The default is 10.
5007         * <p>
5008         * Say this value is set to 10, the device is considered running low on
5009         * storage if 90% or more of the device storage is filled up.
5010         *
5011         * @hide
5012         */
5013        public static final String
5014                SYS_STORAGE_THRESHOLD_PERCENTAGE = "sys_storage_threshold_percentage";
5015
5016        /**
5017         * Maximum byte size of the low storage threshold. This is to ensure
5018         * that {@link #SYS_STORAGE_THRESHOLD_PERCENTAGE} does not result in an
5019         * overly large threshold for large storage devices. Currently this must
5020         * be less than 2GB. This default is 500MB.
5021         *
5022         * @hide
5023         */
5024        public static final String
5025                SYS_STORAGE_THRESHOLD_MAX_BYTES = "sys_storage_threshold_max_bytes";
5026
5027        /**
5028         * Minimum bytes of free storage on the device before the data partition
5029         * is considered full. By default, 1 MB is reserved to avoid system-wide
5030         * SQLite disk full exceptions.
5031         *
5032         * @hide
5033         */
5034        public static final String
5035                SYS_STORAGE_FULL_THRESHOLD_BYTES = "sys_storage_full_threshold_bytes";
5036
5037        /**
5038         * The maximum reconnect delay for short network outages or when the
5039         * network is suspended due to phone use.
5040         *
5041         * @hide
5042         */
5043        public static final String
5044                SYNC_MAX_RETRY_DELAY_IN_SECONDS = "sync_max_retry_delay_in_seconds";
5045
5046        /**
5047         * The number of milliseconds to delay before sending out
5048         * {@link ConnectivityManager#CONNECTIVITY_ACTION} broadcasts.
5049         *
5050         * @hide
5051         */
5052        public static final String CONNECTIVITY_CHANGE_DELAY = "connectivity_change_delay";
5053
5054        /**
5055         * Setting to turn off captive portal detection. Feature is enabled by
5056         * default and the setting needs to be set to 0 to disable it.
5057         *
5058         * @hide
5059         */
5060        public static final String
5061                CAPTIVE_PORTAL_DETECTION_ENABLED = "captive_portal_detection_enabled";
5062
5063        /**
5064         * The server used for captive portal detection upon a new conection. A
5065         * 204 response code from the server is used for validation.
5066         *
5067         * @hide
5068         */
5069        public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
5070
5071        /**
5072         * Whether network service discovery is enabled.
5073         *
5074         * @hide
5075         */
5076        public static final String NSD_ON = "nsd_on";
5077
5078        /**
5079         * Let user pick default install location.
5080         *
5081         * @hide
5082         */
5083        public static final String SET_INSTALL_LOCATION = "set_install_location";
5084
5085        /**
5086         * Default install location value.
5087         * 0 = auto, let system decide
5088         * 1 = internal
5089         * 2 = sdcard
5090         * @hide
5091         */
5092        public static final String DEFAULT_INSTALL_LOCATION = "default_install_location";
5093
5094        /**
5095         * ms during which to consume extra events related to Inet connection
5096         * condition after a transtion to fully-connected
5097         *
5098         * @hide
5099         */
5100        public static final String
5101                INET_CONDITION_DEBOUNCE_UP_DELAY = "inet_condition_debounce_up_delay";
5102
5103        /**
5104         * ms during which to consume extra events related to Inet connection
5105         * condtion after a transtion to partly-connected
5106         *
5107         * @hide
5108         */
5109        public static final String
5110                INET_CONDITION_DEBOUNCE_DOWN_DELAY = "inet_condition_debounce_down_delay";
5111
5112        /** {@hide} */
5113        public static final String
5114                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
5115
5116        /**
5117         * Host name and port for global http proxy. Uses ':' seperator for
5118         * between host and port.
5119         */
5120        public static final String HTTP_PROXY = "http_proxy";
5121
5122        /**
5123         * Host name for global http proxy. Set via ConnectivityManager.
5124         *
5125         * @hide
5126         */
5127        public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host";
5128
5129        /**
5130         * Integer host port for global http proxy. Set via ConnectivityManager.
5131         *
5132         * @hide
5133         */
5134        public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port";
5135
5136        /**
5137         * Exclusion list for global proxy. This string contains a list of
5138         * comma-separated domains where the global proxy does not apply.
5139         * Domains should be listed in a comma- separated list. Example of
5140         * acceptable formats: ".domain1.com,my.domain2.com" Use
5141         * ConnectivityManager to set/get.
5142         *
5143         * @hide
5144         */
5145        public static final String
5146                GLOBAL_HTTP_PROXY_EXCLUSION_LIST = "global_http_proxy_exclusion_list";
5147
5148        /**
5149         * Enables the UI setting to allow the user to specify the global HTTP
5150         * proxy and associated exclusion list.
5151         *
5152         * @hide
5153         */
5154        public static final String SET_GLOBAL_HTTP_PROXY = "set_global_http_proxy";
5155
5156        /**
5157         * Setting for default DNS in case nobody suggests one
5158         *
5159         * @hide
5160         */
5161        public static final String DEFAULT_DNS_SERVER = "default_dns_server";
5162
5163        /** {@hide} */
5164        public static final String
5165                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
5166        /** {@hide} */
5167        public static final String
5168                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
5169        /** {@hide} */
5170        public static final String
5171                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
5172
5173        /**
5174         * Get the key that retrieves a bluetooth headset's priority.
5175         * @hide
5176         */
5177        public static final String getBluetoothHeadsetPriorityKey(String address) {
5178            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase();
5179        }
5180
5181        /**
5182         * Get the key that retrieves a bluetooth a2dp sink's priority.
5183         * @hide
5184         */
5185        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
5186            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase();
5187        }
5188
5189        /**
5190         * Get the key that retrieves a bluetooth Input Device's priority.
5191         * @hide
5192         */
5193        public static final String getBluetoothInputDevicePriorityKey(String address) {
5194            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase();
5195        }
5196
5197        /**
5198         * Scaling factor for normal window animations. Setting to 0 will
5199         * disable window animations.
5200         */
5201        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
5202
5203        /**
5204         * Scaling factor for activity transition animations. Setting to 0 will
5205         * disable window animations.
5206         */
5207        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
5208
5209        /**
5210         * Scaling factor for Animator-based animations. This affects both the
5211         * start delay and duration of all such animations. Setting to 0 will
5212         * cause animations to end immediately. The default value is 1.
5213         */
5214        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
5215
5216        /**
5217         * Scaling factor for normal window animations. Setting to 0 will
5218         * disable window animations.
5219         *
5220         * @hide
5221         */
5222        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
5223
5224        /**
5225         * If 0, the compatibility mode is off for all applications.
5226         * If 1, older applications run under compatibility mode.
5227         * TODO: remove this settings before code freeze (bug/1907571)
5228         * @hide
5229         */
5230        public static final String COMPATIBILITY_MODE = "compatibility_mode";
5231
5232        /**
5233         * CDMA only settings
5234         * Emergency Tone  0 = Off
5235         *                 1 = Alert
5236         *                 2 = Vibrate
5237         * @hide
5238         */
5239        public static final String EMERGENCY_TONE = "emergency_tone";
5240
5241        /**
5242         * CDMA only settings
5243         * Whether the auto retry is enabled. The value is
5244         * boolean (1 or 0).
5245         * @hide
5246         */
5247        public static final String CALL_AUTO_RETRY = "call_auto_retry";
5248
5249        /**
5250         * The preferred network mode   7 = Global
5251         *                              6 = EvDo only
5252         *                              5 = CDMA w/o EvDo
5253         *                              4 = CDMA / EvDo auto
5254         *                              3 = GSM / WCDMA auto
5255         *                              2 = WCDMA only
5256         *                              1 = GSM only
5257         *                              0 = GSM / WCDMA preferred
5258         * @hide
5259         */
5260        public static final String PREFERRED_NETWORK_MODE =
5261                "preferred_network_mode";
5262
5263        /**
5264         * The cdma subscription 0 = Subscription from RUIM, when available
5265         *                       1 = Subscription from NV
5266         * @hide
5267         */
5268        public static final String PREFERRED_CDMA_SUBSCRIPTION =
5269                "preferred_cdma_subscription";
5270
5271        /**
5272         * Name of an application package to be debugged.
5273         */
5274        public static final String DEBUG_APP = "debug_app";
5275
5276        /**
5277         * If 1, when launching DEBUG_APP it will wait for the debugger before
5278         * starting user code.  If 0, it will run normally.
5279         */
5280        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
5281
5282        /**
5283         * Control whether the process CPU usage meter should be shown.
5284         */
5285        public static final String SHOW_PROCESSES = "show_processes";
5286
5287        /**
5288         * If 1, the activity manager will aggressively finish activities and
5289         * processes as soon as they are no longer needed.  If 0, the normal
5290         * extended lifetime is used.
5291         */
5292        public static final String ALWAYS_FINISH_ACTIVITIES =
5293                "always_finish_activities";
5294
5295        /**
5296         * Use Dock audio output for media:
5297         *      0 = disabled
5298         *      1 = enabled
5299         * @hide
5300         */
5301        public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
5302
5303        /**
5304         * Settings to backup. This is here so that it's in the same place as the settings
5305         * keys and easy to update.
5306         *
5307         * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
5308         * and Secure as well.  This is because those tables drive both backup and
5309         * restore, and restore needs to properly whitelist keys that used to live
5310         * in those namespaces.  The keys will only actually be backed up / restored
5311         * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
5312         *
5313         * NOTE: Settings are backed up and restored in the order they appear
5314         *       in this array. If you have one setting depending on another,
5315         *       make sure that they are ordered appropriately.
5316         *
5317         * @hide
5318         */
5319        public static final String[] SETTINGS_TO_BACKUP = {
5320            STAY_ON_WHILE_PLUGGED_IN,
5321            MODE_RINGER,
5322            AUTO_TIME,
5323            AUTO_TIME_ZONE,
5324            POWER_SOUNDS_ENABLED,
5325            DOCK_SOUNDS_ENABLED,
5326            USB_MASS_STORAGE_ENABLED,
5327            ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED,
5328            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
5329            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
5330            WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
5331            WIFI_NUM_OPEN_NETWORKS_KEPT,
5332            EMERGENCY_TONE,
5333            CALL_AUTO_RETRY,
5334            DOCK_AUDIO_MEDIA_ENABLED
5335        };
5336
5337        // Populated lazily, guarded by class object:
5338        private static NameValueCache sNameValueCache = new NameValueCache(
5339                    SYS_PROP_SETTING_VERSION,
5340                    CONTENT_URI,
5341                    CALL_METHOD_GET_GLOBAL,
5342                    CALL_METHOD_PUT_GLOBAL);
5343
5344        /**
5345         * Look up a name in the database.
5346         * @param resolver to access the database with
5347         * @param name to look up in the table
5348         * @return the corresponding value, or null if not present
5349         */
5350        public static String getString(ContentResolver resolver, String name) {
5351            return getStringForUser(resolver, name, UserHandle.myUserId());
5352        }
5353
5354        /** @hide */
5355        public static String getStringForUser(ContentResolver resolver, String name,
5356                int userHandle) {
5357            return sNameValueCache.getStringForUser(resolver, name, userHandle);
5358        }
5359
5360        /**
5361         * Store a name/value pair into the database.
5362         * @param resolver to access the database with
5363         * @param name to store
5364         * @param value to associate with the name
5365         * @return true if the value was set, false on database errors
5366         */
5367        public static boolean putString(ContentResolver resolver,
5368                String name, String value) {
5369            return putStringForUser(resolver, name, value, UserHandle.myUserId());
5370        }
5371
5372        /** @hide */
5373        public static boolean putStringForUser(ContentResolver resolver,
5374                String name, String value, int userHandle) {
5375            if (LOCAL_LOGV) {
5376                Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
5377                        + " for " + userHandle);
5378            }
5379            return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
5380        }
5381
5382        /**
5383         * Construct the content URI for a particular name/value pair,
5384         * useful for monitoring changes with a ContentObserver.
5385         * @param name to look up in the table
5386         * @return the corresponding content URI, or null if not present
5387         */
5388        public static Uri getUriFor(String name) {
5389            return getUriFor(CONTENT_URI, name);
5390        }
5391
5392        /**
5393         * Convenience function for retrieving a single secure settings value
5394         * as an integer.  Note that internally setting values are always
5395         * stored as strings; this function converts the string to an integer
5396         * for you.  The default value will be returned if the setting is
5397         * not defined or not an integer.
5398         *
5399         * @param cr The ContentResolver to access.
5400         * @param name The name of the setting to retrieve.
5401         * @param def Value to return if the setting is not defined.
5402         *
5403         * @return The setting's current value, or 'def' if it is not defined
5404         * or not a valid integer.
5405         */
5406        public static int getInt(ContentResolver cr, String name, int def) {
5407            String v = getString(cr, name);
5408            try {
5409                return v != null ? Integer.parseInt(v) : def;
5410            } catch (NumberFormatException e) {
5411                return def;
5412            }
5413        }
5414
5415        /**
5416         * Convenience function for retrieving a single secure settings value
5417         * as an integer.  Note that internally setting values are always
5418         * stored as strings; this function converts the string to an integer
5419         * for you.
5420         * <p>
5421         * This version does not take a default value.  If the setting has not
5422         * been set, or the string value is not a number,
5423         * it throws {@link SettingNotFoundException}.
5424         *
5425         * @param cr The ContentResolver to access.
5426         * @param name The name of the setting to retrieve.
5427         *
5428         * @throws SettingNotFoundException Thrown if a setting by the given
5429         * name can't be found or the setting value is not an integer.
5430         *
5431         * @return The setting's current value.
5432         */
5433        public static int getInt(ContentResolver cr, String name)
5434                throws SettingNotFoundException {
5435            String v = getString(cr, name);
5436            try {
5437                return Integer.parseInt(v);
5438            } catch (NumberFormatException e) {
5439                throw new SettingNotFoundException(name);
5440            }
5441        }
5442
5443        /**
5444         * Convenience function for updating a single settings value as an
5445         * integer. This will either create a new entry in the table if the
5446         * given name does not exist, or modify the value of the existing row
5447         * with that name.  Note that internally setting values are always
5448         * stored as strings, so this function converts the given value to a
5449         * string before storing it.
5450         *
5451         * @param cr The ContentResolver to access.
5452         * @param name The name of the setting to modify.
5453         * @param value The new value for the setting.
5454         * @return true if the value was set, false on database errors
5455         */
5456        public static boolean putInt(ContentResolver cr, String name, int value) {
5457            return putString(cr, name, Integer.toString(value));
5458        }
5459
5460        /**
5461         * Convenience function for retrieving a single secure settings value
5462         * as a {@code long}.  Note that internally setting values are always
5463         * stored as strings; this function converts the string to a {@code long}
5464         * for you.  The default value will be returned if the setting is
5465         * not defined or not a {@code long}.
5466         *
5467         * @param cr The ContentResolver to access.
5468         * @param name The name of the setting to retrieve.
5469         * @param def Value to return if the setting is not defined.
5470         *
5471         * @return The setting's current value, or 'def' if it is not defined
5472         * or not a valid {@code long}.
5473         */
5474        public static long getLong(ContentResolver cr, String name, long def) {
5475            String valString = getString(cr, name);
5476            long value;
5477            try {
5478                value = valString != null ? Long.parseLong(valString) : def;
5479            } catch (NumberFormatException e) {
5480                value = def;
5481            }
5482            return value;
5483        }
5484
5485        /**
5486         * Convenience function for retrieving a single secure settings value
5487         * as a {@code long}.  Note that internally setting values are always
5488         * stored as strings; this function converts the string to a {@code long}
5489         * for you.
5490         * <p>
5491         * This version does not take a default value.  If the setting has not
5492         * been set, or the string value is not a number,
5493         * it throws {@link SettingNotFoundException}.
5494         *
5495         * @param cr The ContentResolver to access.
5496         * @param name The name of the setting to retrieve.
5497         *
5498         * @return The setting's current value.
5499         * @throws SettingNotFoundException Thrown if a setting by the given
5500         * name can't be found or the setting value is not an integer.
5501         */
5502        public static long getLong(ContentResolver cr, String name)
5503                throws SettingNotFoundException {
5504            String valString = getString(cr, name);
5505            try {
5506                return Long.parseLong(valString);
5507            } catch (NumberFormatException e) {
5508                throw new SettingNotFoundException(name);
5509            }
5510        }
5511
5512        /**
5513         * Convenience function for updating a secure settings value as a long
5514         * integer. This will either create a new entry in the table if the
5515         * given name does not exist, or modify the value of the existing row
5516         * with that name.  Note that internally setting values are always
5517         * stored as strings, so this function converts the given value to a
5518         * string before storing it.
5519         *
5520         * @param cr The ContentResolver to access.
5521         * @param name The name of the setting to modify.
5522         * @param value The new value for the setting.
5523         * @return true if the value was set, false on database errors
5524         */
5525        public static boolean putLong(ContentResolver cr, String name, long value) {
5526            return putString(cr, name, Long.toString(value));
5527        }
5528
5529        /**
5530         * Convenience function for retrieving a single secure settings value
5531         * as a floating point number.  Note that internally setting values are
5532         * always stored as strings; this function converts the string to an
5533         * float for you. The default value will be returned if the setting
5534         * is not defined or not a valid float.
5535         *
5536         * @param cr The ContentResolver to access.
5537         * @param name The name of the setting to retrieve.
5538         * @param def Value to return if the setting is not defined.
5539         *
5540         * @return The setting's current value, or 'def' if it is not defined
5541         * or not a valid float.
5542         */
5543        public static float getFloat(ContentResolver cr, String name, float def) {
5544            String v = getString(cr, name);
5545            try {
5546                return v != null ? Float.parseFloat(v) : def;
5547            } catch (NumberFormatException e) {
5548                return def;
5549            }
5550        }
5551
5552        /**
5553         * Convenience function for retrieving a single secure settings value
5554         * as a float.  Note that internally setting values are always
5555         * stored as strings; this function converts the string to a float
5556         * for you.
5557         * <p>
5558         * This version does not take a default value.  If the setting has not
5559         * been set, or the string value is not a number,
5560         * it throws {@link SettingNotFoundException}.
5561         *
5562         * @param cr The ContentResolver to access.
5563         * @param name The name of the setting to retrieve.
5564         *
5565         * @throws SettingNotFoundException Thrown if a setting by the given
5566         * name can't be found or the setting value is not a float.
5567         *
5568         * @return The setting's current value.
5569         */
5570        public static float getFloat(ContentResolver cr, String name)
5571                throws SettingNotFoundException {
5572            String v = getString(cr, name);
5573            if (v == null) {
5574                throw new SettingNotFoundException(name);
5575            }
5576            try {
5577                return Float.parseFloat(v);
5578            } catch (NumberFormatException e) {
5579                throw new SettingNotFoundException(name);
5580            }
5581        }
5582
5583        /**
5584         * Convenience function for updating a single settings value as a
5585         * floating point number. This will either create a new entry in the
5586         * table if the given name does not exist, or modify the value of the
5587         * existing row with that name.  Note that internally setting values
5588         * are always stored as strings, so this function converts the given
5589         * value to a string before storing it.
5590         *
5591         * @param cr The ContentResolver to access.
5592         * @param name The name of the setting to modify.
5593         * @param value The new value for the setting.
5594         * @return true if the value was set, false on database errors
5595         */
5596        public static boolean putFloat(ContentResolver cr, String name, float value) {
5597            return putString(cr, name, Float.toString(value));
5598        }
5599    }
5600
5601    /**
5602     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
5603     * Intent URL, allowing it to be either a web page or a particular
5604     * application activity.
5605     *
5606     * @hide
5607     */
5608    public static final class Bookmarks implements BaseColumns
5609    {
5610        private static final String TAG = "Bookmarks";
5611
5612        /**
5613         * The content:// style URL for this table
5614         */
5615        public static final Uri CONTENT_URI =
5616            Uri.parse("content://" + AUTHORITY + "/bookmarks");
5617
5618        /**
5619         * The row ID.
5620         * <p>Type: INTEGER</p>
5621         */
5622        public static final String ID = "_id";
5623
5624        /**
5625         * Descriptive name of the bookmark that can be displayed to the user.
5626         * If this is empty, the title should be resolved at display time (use
5627         * {@link #getTitle(Context, Cursor)} any time you want to display the
5628         * title of a bookmark.)
5629         * <P>
5630         * Type: TEXT
5631         * </P>
5632         */
5633        public static final String TITLE = "title";
5634
5635        /**
5636         * Arbitrary string (displayed to the user) that allows bookmarks to be
5637         * organized into categories.  There are some special names for
5638         * standard folders, which all start with '@'.  The label displayed for
5639         * the folder changes with the locale (via {@link #getLabelForFolder}) but
5640         * the folder name does not change so you can consistently query for
5641         * the folder regardless of the current locale.
5642         *
5643         * <P>Type: TEXT</P>
5644         *
5645         */
5646        public static final String FOLDER = "folder";
5647
5648        /**
5649         * The Intent URL of the bookmark, describing what it points to.  This
5650         * value is given to {@link android.content.Intent#getIntent} to create
5651         * an Intent that can be launched.
5652         * <P>Type: TEXT</P>
5653         */
5654        public static final String INTENT = "intent";
5655
5656        /**
5657         * Optional shortcut character associated with this bookmark.
5658         * <P>Type: INTEGER</P>
5659         */
5660        public static final String SHORTCUT = "shortcut";
5661
5662        /**
5663         * The order in which the bookmark should be displayed
5664         * <P>Type: INTEGER</P>
5665         */
5666        public static final String ORDERING = "ordering";
5667
5668        private static final String[] sIntentProjection = { INTENT };
5669        private static final String[] sShortcutProjection = { ID, SHORTCUT };
5670        private static final String sShortcutSelection = SHORTCUT + "=?";
5671
5672        /**
5673         * Convenience function to retrieve the bookmarked Intent for a
5674         * particular shortcut key.
5675         *
5676         * @param cr The ContentResolver to query.
5677         * @param shortcut The shortcut key.
5678         *
5679         * @return Intent The bookmarked URL, or null if there is no bookmark
5680         *         matching the given shortcut.
5681         */
5682        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
5683        {
5684            Intent intent = null;
5685
5686            Cursor c = cr.query(CONTENT_URI,
5687                    sIntentProjection, sShortcutSelection,
5688                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
5689            // Keep trying until we find a valid shortcut
5690            try {
5691                while (intent == null && c.moveToNext()) {
5692                    try {
5693                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
5694                        intent = Intent.parseUri(intentURI, 0);
5695                    } catch (java.net.URISyntaxException e) {
5696                        // The stored URL is bad...  ignore it.
5697                    } catch (IllegalArgumentException e) {
5698                        // Column not found
5699                        Log.w(TAG, "Intent column not found", e);
5700                    }
5701                }
5702            } finally {
5703                if (c != null) c.close();
5704            }
5705
5706            return intent;
5707        }
5708
5709        /**
5710         * Add a new bookmark to the system.
5711         *
5712         * @param cr The ContentResolver to query.
5713         * @param intent The desired target of the bookmark.
5714         * @param title Bookmark title that is shown to the user; null if none
5715         *            or it should be resolved to the intent's title.
5716         * @param folder Folder in which to place the bookmark; null if none.
5717         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
5718         *            this is non-zero and there is an existing bookmark entry
5719         *            with this same shortcut, then that existing shortcut is
5720         *            cleared (the bookmark is not removed).
5721         * @return The unique content URL for the new bookmark entry.
5722         */
5723        public static Uri add(ContentResolver cr,
5724                                           Intent intent,
5725                                           String title,
5726                                           String folder,
5727                                           char shortcut,
5728                                           int ordering)
5729        {
5730            // If a shortcut is supplied, and it is already defined for
5731            // another bookmark, then remove the old definition.
5732            if (shortcut != 0) {
5733                cr.delete(CONTENT_URI, sShortcutSelection,
5734                        new String[] { String.valueOf((int) shortcut) });
5735            }
5736
5737            ContentValues values = new ContentValues();
5738            if (title != null) values.put(TITLE, title);
5739            if (folder != null) values.put(FOLDER, folder);
5740            values.put(INTENT, intent.toUri(0));
5741            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
5742            values.put(ORDERING, ordering);
5743            return cr.insert(CONTENT_URI, values);
5744        }
5745
5746        /**
5747         * Return the folder name as it should be displayed to the user.  This
5748         * takes care of localizing special folders.
5749         *
5750         * @param r Resources object for current locale; only need access to
5751         *          system resources.
5752         * @param folder The value found in the {@link #FOLDER} column.
5753         *
5754         * @return CharSequence The label for this folder that should be shown
5755         *         to the user.
5756         */
5757        public static CharSequence getLabelForFolder(Resources r, String folder) {
5758            return folder;
5759        }
5760
5761        /**
5762         * Return the title as it should be displayed to the user. This takes
5763         * care of localizing bookmarks that point to activities.
5764         *
5765         * @param context A context.
5766         * @param cursor A cursor pointing to the row whose title should be
5767         *        returned. The cursor must contain at least the {@link #TITLE}
5768         *        and {@link #INTENT} columns.
5769         * @return A title that is localized and can be displayed to the user,
5770         *         or the empty string if one could not be found.
5771         */
5772        public static CharSequence getTitle(Context context, Cursor cursor) {
5773            int titleColumn = cursor.getColumnIndex(TITLE);
5774            int intentColumn = cursor.getColumnIndex(INTENT);
5775            if (titleColumn == -1 || intentColumn == -1) {
5776                throw new IllegalArgumentException(
5777                        "The cursor must contain the TITLE and INTENT columns.");
5778            }
5779
5780            String title = cursor.getString(titleColumn);
5781            if (!TextUtils.isEmpty(title)) {
5782                return title;
5783            }
5784
5785            String intentUri = cursor.getString(intentColumn);
5786            if (TextUtils.isEmpty(intentUri)) {
5787                return "";
5788            }
5789
5790            Intent intent;
5791            try {
5792                intent = Intent.parseUri(intentUri, 0);
5793            } catch (URISyntaxException e) {
5794                return "";
5795            }
5796
5797            PackageManager packageManager = context.getPackageManager();
5798            ResolveInfo info = packageManager.resolveActivity(intent, 0);
5799            return info != null ? info.loadLabel(packageManager) : "";
5800        }
5801    }
5802
5803    /**
5804     * Returns the device ID that we should use when connecting to the mobile gtalk server.
5805     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
5806     * from the GoogleLoginService.
5807     *
5808     * @param androidId The Android ID for this device.
5809     * @return The device ID that should be used when connecting to the mobile gtalk server.
5810     * @hide
5811     */
5812    public static String getGTalkDeviceId(long androidId) {
5813        return "android-" + Long.toHexString(androidId);
5814    }
5815}
5816