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