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