Settings.java revision ebd8416fad86aad10f8724a02437d27c473169bd
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 com.google.android.collect.Maps;
20
21import org.apache.commons.codec.binary.Base64;
22
23import android.annotation.SdkConstant;
24import android.annotation.SdkConstant.SdkConstantType;
25import android.content.ContentQueryMap;
26import android.content.ContentResolver;
27import android.content.ContentValues;
28import android.content.Context;
29import android.content.Intent;
30import android.content.pm.PackageManager;
31import android.content.pm.ResolveInfo;
32import android.content.res.Configuration;
33import android.content.res.Resources;
34import android.database.Cursor;
35import android.database.SQLException;
36import android.net.Uri;
37import android.os.*;
38import android.telephony.TelephonyManager;
39import android.text.TextUtils;
40import android.util.AndroidException;
41import android.util.Log;
42
43import java.net.URISyntaxException;
44import java.security.MessageDigest;
45import java.security.NoSuchAlgorithmException;
46import java.util.HashMap;
47import java.util.HashSet;
48
49
50/**
51 * The Settings provider contains global system-level device preferences.
52 */
53public final class Settings {
54
55    // Intent actions for Settings
56
57    /**
58     * Activity Action: Show system settings.
59     * <p>
60     * Input: Nothing.
61     * <p>
62     * Output: nothing.
63     */
64    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
65    public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
66
67    /**
68     * Activity Action: Show settings to allow configuration of APNs.
69     * <p>
70     * Input: Nothing.
71     * <p>
72     * Output: nothing.
73     */
74    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
75    public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS";
76
77    /**
78     * Activity Action: Show settings to allow configuration of current location
79     * sources.
80     * <p>
81     * In some cases, a matching Activity may not exist, so ensure you
82     * safeguard against this.
83     * <p>
84     * Input: Nothing.
85     * <p>
86     * Output: Nothing.
87     */
88    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
89    public static final String ACTION_LOCATION_SOURCE_SETTINGS =
90            "android.settings.LOCATION_SOURCE_SETTINGS";
91
92    /**
93     * Activity Action: Show settings to allow configuration of wireless controls
94     * such as Wi-Fi, Bluetooth and Mobile networks.
95     * <p>
96     * In some cases, a matching Activity may not exist, so ensure you
97     * safeguard against this.
98     * <p>
99     * Input: Nothing.
100     * <p>
101     * Output: Nothing.
102     */
103    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
104    public static final String ACTION_WIRELESS_SETTINGS =
105            "android.settings.WIRELESS_SETTINGS";
106
107    /**
108     * Activity Action: Show settings to allow entering/exiting airplane mode.
109     * <p>
110     * In some cases, a matching Activity may not exist, so ensure you
111     * safeguard against this.
112     * <p>
113     * Input: Nothing.
114     * <p>
115     * Output: Nothing.
116     */
117    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
118    public static final String ACTION_AIRPLANE_MODE_SETTINGS =
119            "android.settings.AIRPLANE_MODE_SETTINGS";
120
121    /**
122     * Activity Action: Show settings to allow configuration of security and
123     * location privacy.
124     * <p>
125     * In some cases, a matching Activity may not exist, so ensure you
126     * safeguard against this.
127     * <p>
128     * Input: Nothing.
129     * <p>
130     * Output: Nothing.
131     */
132    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
133    public static final String ACTION_SECURITY_SETTINGS =
134            "android.settings.SECURITY_SETTINGS";
135
136    /**
137     * Activity Action: Show settings to allow configuration of Wi-Fi.
138
139     * <p>
140     * In some cases, a matching Activity may not exist, so ensure you
141     * safeguard against this.
142     * <p>
143     * Input: Nothing.
144     * <p>
145     * Output: Nothing.
146
147     */
148    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
149    public static final String ACTION_WIFI_SETTINGS =
150            "android.settings.WIFI_SETTINGS";
151
152    /**
153     * Activity Action: Show settings to allow configuration of a static IP
154     * address for Wi-Fi.
155     * <p>
156     * In some cases, a matching Activity may not exist, so ensure you safeguard
157     * against this.
158     * <p>
159     * Input: Nothing.
160     * <p>
161     * Output: Nothing.
162     */
163    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
164    public static final String ACTION_WIFI_IP_SETTINGS =
165            "android.settings.WIFI_IP_SETTINGS";
166
167    /**
168     * Activity Action: Show settings to allow configuration of Bluetooth.
169     * <p>
170     * In some cases, a matching Activity may not exist, so ensure you
171     * safeguard against this.
172     * <p>
173     * Input: Nothing.
174     * <p>
175     * Output: Nothing.
176     */
177    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
178    public static final String ACTION_BLUETOOTH_SETTINGS =
179            "android.settings.BLUETOOTH_SETTINGS";
180
181    /**
182     * Activity Action: Show settings to allow configuration of date and time.
183     * <p>
184     * In some cases, a matching Activity may not exist, so ensure you
185     * safeguard against this.
186     * <p>
187     * Input: Nothing.
188     * <p>
189     * Output: Nothing.
190     */
191    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
192    public static final String ACTION_DATE_SETTINGS =
193            "android.settings.DATE_SETTINGS";
194
195    /**
196     * Activity Action: Show settings to allow configuration of sound and volume.
197     * <p>
198     * In some cases, a matching Activity may not exist, so ensure you
199     * safeguard against this.
200     * <p>
201     * Input: Nothing.
202     * <p>
203     * Output: Nothing.
204     */
205    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
206    public static final String ACTION_SOUND_SETTINGS =
207            "android.settings.SOUND_SETTINGS";
208
209    /**
210     * Activity Action: Show settings to allow configuration of display.
211     * <p>
212     * In some cases, a matching Activity may not exist, so ensure you
213     * safeguard against this.
214     * <p>
215     * Input: Nothing.
216     * <p>
217     * Output: Nothing.
218     */
219    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
220    public static final String ACTION_DISPLAY_SETTINGS =
221            "android.settings.DISPLAY_SETTINGS";
222
223    /**
224     * Activity Action: Show settings to allow configuration of locale.
225     * <p>
226     * In some cases, a matching Activity may not exist, so ensure you
227     * safeguard against this.
228     * <p>
229     * Input: Nothing.
230     * <p>
231     * Output: Nothing.
232     */
233    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
234    public static final String ACTION_LOCALE_SETTINGS =
235            "android.settings.LOCALE_SETTINGS";
236
237    /**
238     * Activity Action: Show settings to configure input methods, in particular
239     * allowing the user to enable input methods.
240     * <p>
241     * In some cases, a matching Activity may not exist, so ensure you
242     * safeguard against this.
243     * <p>
244     * Input: Nothing.
245     * <p>
246     * Output: Nothing.
247     */
248    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
249    public static final String ACTION_INPUT_METHOD_SETTINGS =
250            "android.settings.INPUT_METHOD_SETTINGS";
251
252    /**
253     * Activity Action: Show settings to manage the user input dictionary.
254     * <p>
255     * In some cases, a matching Activity may not exist, so ensure you
256     * safeguard against this.
257     * <p>
258     * Input: Nothing.
259     * <p>
260     * Output: Nothing.
261     */
262    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
263    public static final String ACTION_USER_DICTIONARY_SETTINGS =
264            "android.settings.USER_DICTIONARY_SETTINGS";
265
266    /**
267     * Activity Action: Show settings to allow configuration of application-related settings.
268     * <p>
269     * In some cases, a matching Activity may not exist, so ensure you
270     * safeguard against this.
271     * <p>
272     * Input: Nothing.
273     * <p>
274     * Output: Nothing.
275     */
276    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
277    public static final String ACTION_APPLICATION_SETTINGS =
278            "android.settings.APPLICATION_SETTINGS";
279
280    /**
281     * Activity Action: Show settings to allow configuration of application
282     * development-related settings.
283     * <p>
284     * In some cases, a matching Activity may not exist, so ensure you safeguard
285     * against this.
286     * <p>
287     * Input: Nothing.
288     * <p>
289     * Output: Nothing.
290     */
291    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
292    public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
293            "android.settings.APPLICATION_DEVELOPMENT_SETTINGS";
294
295    /**
296     * Activity Action: Show settings to allow configuration of quick launch shortcuts.
297     * <p>
298     * In some cases, a matching Activity may not exist, so ensure you
299     * safeguard against this.
300     * <p>
301     * Input: Nothing.
302     * <p>
303     * Output: Nothing.
304     */
305    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
306    public static final String ACTION_QUICK_LAUNCH_SETTINGS =
307            "android.settings.QUICK_LAUNCH_SETTINGS";
308
309    /**
310     * Activity Action: Show settings to manage installed applications.
311     * <p>
312     * In some cases, a matching Activity may not exist, so ensure you
313     * safeguard against this.
314     * <p>
315     * Input: Nothing.
316     * <p>
317     * Output: Nothing.
318     */
319    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
320    public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS =
321            "android.settings.MANAGE_APPLICATIONS_SETTINGS";
322
323    /**
324     * Activity Action: Show settings for system update functionality.
325     * <p>
326     * In some cases, a matching Activity may not exist, so ensure you
327     * safeguard against this.
328     * <p>
329     * Input: Nothing.
330     * <p>
331     * Output: Nothing.
332     *
333     * @hide
334     */
335    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
336    public static final String ACTION_SYSTEM_UPDATE_SETTINGS =
337            "android.settings.SYSTEM_UPDATE_SETTINGS";
338
339    /**
340     * Activity Action: Show settings to allow configuration of sync settings.
341     * <p>
342     * In some cases, a matching Activity may not exist, so ensure you
343     * safeguard against this.
344     * <p>
345     * Input: Nothing.
346     * <p>
347     * Output: Nothing.
348     */
349    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
350    public static final String ACTION_SYNC_SETTINGS =
351            "android.settings.SYNC_SETTINGS";
352
353    /**
354     * Activity Action: Show settings for selecting the network operator.
355     * <p>
356     * In some cases, a matching Activity may not exist, so ensure you
357     * safeguard against this.
358     * <p>
359     * Input: Nothing.
360     * <p>
361     * Output: Nothing.
362     */
363    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
364    public static final String ACTION_NETWORK_OPERATOR_SETTINGS =
365            "android.settings.NETWORK_OPERATOR_SETTINGS";
366
367    /**
368     * Activity Action: Show settings for selection of 2G/3G.
369     * <p>
370     * In some cases, a matching Activity may not exist, so ensure you
371     * safeguard against this.
372     * <p>
373     * Input: Nothing.
374     * <p>
375     * Output: Nothing.
376     */
377    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
378    public static final String ACTION_DATA_ROAMING_SETTINGS =
379            "android.settings.DATA_ROAMING_SETTINGS";
380
381    /**
382     * Activity Action: Show settings for internal storage.
383     * <p>
384     * In some cases, a matching Activity may not exist, so ensure you
385     * safeguard against this.
386     * <p>
387     * Input: Nothing.
388     * <p>
389     * Output: Nothing.
390     */
391    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
392    public static final String ACTION_INTERNAL_STORAGE_SETTINGS =
393            "android.settings.INTERNAL_STORAGE_SETTINGS";
394    /**
395     * Activity Action: Show settings for memory card storage.
396     * <p>
397     * In some cases, a matching Activity may not exist, so ensure you
398     * safeguard against this.
399     * <p>
400     * Input: Nothing.
401     * <p>
402     * Output: Nothing.
403     */
404    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
405    public static final String ACTION_MEMORY_CARD_SETTINGS =
406            "android.settings.MEMORY_CARD_SETTINGS";
407
408    // End of Intent actions for Settings
409
410    private static final String JID_RESOURCE_PREFIX = "android";
411
412    public static final String AUTHORITY = "settings";
413
414    private static final String TAG = "Settings";
415
416    public static class SettingNotFoundException extends AndroidException {
417        public SettingNotFoundException(String msg) {
418            super(msg);
419        }
420    }
421
422    /**
423     * Common base for tables of name/value settings.
424     */
425    public static class NameValueTable implements BaseColumns {
426        public static final String NAME = "name";
427        public static final String VALUE = "value";
428
429        protected static boolean putString(ContentResolver resolver, Uri uri,
430                String name, String value) {
431            // The database will take care of replacing duplicates.
432            try {
433                ContentValues values = new ContentValues();
434                values.put(NAME, name);
435                values.put(VALUE, value);
436                resolver.insert(uri, values);
437                return true;
438            } catch (SQLException e) {
439                Log.e(TAG, "Can't set key " + name + " in " + uri, e);
440                return false;
441            }
442        }
443
444        public static Uri getUriFor(Uri uri, String name) {
445            return Uri.withAppendedPath(uri, name);
446        }
447    }
448
449    private static class NameValueCache {
450        private final String mVersionSystemProperty;
451        private final HashMap<String, String> mValues = Maps.newHashMap();
452        private long mValuesVersion = 0;
453        private final Uri mUri;
454
455        NameValueCache(String versionSystemProperty, Uri uri) {
456            mVersionSystemProperty = versionSystemProperty;
457            mUri = uri;
458        }
459
460        String getString(ContentResolver cr, String name) {
461            long newValuesVersion = SystemProperties.getLong(mVersionSystemProperty, 0);
462            if (mValuesVersion != newValuesVersion) {
463                mValues.clear();
464                mValuesVersion = newValuesVersion;
465            }
466            if (!mValues.containsKey(name)) {
467                String value = null;
468                Cursor c = null;
469                try {
470                    c = cr.query(mUri, new String[] { Settings.NameValueTable.VALUE },
471                            Settings.NameValueTable.NAME + "=?", new String[]{name}, null);
472                    if (c != null && c.moveToNext()) value = c.getString(0);
473                    mValues.put(name, value);
474                } catch (SQLException e) {
475                    // SQL error: return null, but don't cache it.
476                    Log.e(TAG, "Can't get key " + name + " from " + mUri, e);
477                } finally {
478                    if (c != null) c.close();
479                }
480                return value;
481            } else {
482                return mValues.get(name);
483            }
484        }
485    }
486
487    /**
488     * System settings, containing miscellaneous system preferences.  This
489     * table holds simple name/value pairs.  There are convenience
490     * functions for accessing individual settings entries.
491     */
492    public static final class System extends NameValueTable {
493        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version";
494
495        private static volatile NameValueCache mNameValueCache = null;
496
497        private static final HashSet<String> MOVED_TO_SECURE;
498        static {
499            MOVED_TO_SECURE = new HashSet<String>(30);
500            MOVED_TO_SECURE.add(Secure.ADB_ENABLED);
501            MOVED_TO_SECURE.add(Secure.ANDROID_ID);
502            MOVED_TO_SECURE.add(Secure.BLUETOOTH_ON);
503            MOVED_TO_SECURE.add(Secure.DATA_ROAMING);
504            MOVED_TO_SECURE.add(Secure.DEVICE_PROVISIONED);
505            MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
506            MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
507            MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
508            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
509            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
510            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
511            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL);
512            MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME);
513            MOVED_TO_SECURE.add(Secure.USB_MASS_STORAGE_ENABLED);
514            MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL);
515            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
516            MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY);
517            MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT);
518            MOVED_TO_SECURE.add(Secure.WIFI_ON);
519            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE);
520            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT);
521            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS);
522            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED);
523            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS);
524            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT);
525            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS);
526            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON);
527            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT);
528            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS);
529            MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS);
530        }
531
532        /**
533         * Look up a name in the database.
534         * @param resolver to access the database with
535         * @param name to look up in the table
536         * @return the corresponding value, or null if not present
537         */
538        public synchronized static String getString(ContentResolver resolver, String name) {
539            if (MOVED_TO_SECURE.contains(name)) {
540                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
541                        + " to android.provider.Settings.Secure, returning read-only value.");
542                return Secure.getString(resolver, name);
543            }
544            if (mNameValueCache == null) {
545                mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
546            }
547            return mNameValueCache.getString(resolver, name);
548        }
549
550        /**
551         * Store a name/value pair into the database.
552         * @param resolver to access the database with
553         * @param name to store
554         * @param value to associate with the name
555         * @return true if the value was set, false on database errors
556         */
557        public static boolean putString(ContentResolver resolver, String name, String value) {
558            if (MOVED_TO_SECURE.contains(name)) {
559                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
560                        + " to android.provider.Settings.Secure, value is unchanged.");
561                return false;
562            }
563            return putString(resolver, CONTENT_URI, name, value);
564        }
565
566        /**
567         * Construct the content URI for a particular name/value pair,
568         * useful for monitoring changes with a ContentObserver.
569         * @param name to look up in the table
570         * @return the corresponding content URI, or null if not present
571         */
572        public static Uri getUriFor(String name) {
573            if (MOVED_TO_SECURE.contains(name)) {
574                Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
575                    + " to android.provider.Settings.Secure, returning Secure URI.");
576                return Secure.getUriFor(Secure.CONTENT_URI, name);
577            }
578            return getUriFor(CONTENT_URI, name);
579        }
580
581        /**
582         * Convenience function for retrieving a single system settings value
583         * as an integer.  Note that internally setting values are always
584         * stored as strings; this function converts the string to an integer
585         * for you.  The default value will be returned if the setting is
586         * not defined or not an integer.
587         *
588         * @param cr The ContentResolver to access.
589         * @param name The name of the setting to retrieve.
590         * @param def Value to return if the setting is not defined.
591         *
592         * @return The setting's current value, or 'def' if it is not defined
593         * or not a valid integer.
594         */
595        public static int getInt(ContentResolver cr, String name, int def) {
596            String v = getString(cr, name);
597            try {
598                return v != null ? Integer.parseInt(v) : def;
599            } catch (NumberFormatException e) {
600                return def;
601            }
602        }
603
604        /**
605         * Convenience function for retrieving a single system settings value
606         * as an integer.  Note that internally setting values are always
607         * stored as strings; this function converts the string to an integer
608         * for you.
609         * <p>
610         * This version does not take a default value.  If the setting has not
611         * been set, or the string value is not a number,
612         * it throws {@link SettingNotFoundException}.
613         *
614         * @param cr The ContentResolver to access.
615         * @param name The name of the setting to retrieve.
616         *
617         * @throws SettingNotFoundException Thrown if a setting by the given
618         * name can't be found or the setting value is not an integer.
619         *
620         * @return The setting's current value.
621         */
622        public static int getInt(ContentResolver cr, String name)
623                throws SettingNotFoundException {
624            String v = getString(cr, name);
625            try {
626                return Integer.parseInt(v);
627            } catch (NumberFormatException e) {
628                throw new SettingNotFoundException(name);
629            }
630        }
631
632        /**
633         * Convenience function for updating a single settings value as an
634         * integer. This will either create a new entry in the table if the
635         * given name does not exist, or modify the value of the existing row
636         * with that name.  Note that internally setting values are always
637         * stored as strings, so this function converts the given value to a
638         * string before storing it.
639         *
640         * @param cr The ContentResolver to access.
641         * @param name The name of the setting to modify.
642         * @param value The new value for the setting.
643         * @return true if the value was set, false on database errors
644         */
645        public static boolean putInt(ContentResolver cr, String name, int value) {
646            return putString(cr, name, Integer.toString(value));
647        }
648
649        /**
650         * Convenience function for retrieving a single system settings value
651         * as a {@code long}.  Note that internally setting values are always
652         * stored as strings; this function converts the string to a {@code long}
653         * for you.  The default value will be returned if the setting is
654         * not defined or not a {@code long}.
655         *
656         * @param cr The ContentResolver to access.
657         * @param name The name of the setting to retrieve.
658         * @param def Value to return if the setting is not defined.
659         *
660         * @return The setting's current value, or 'def' if it is not defined
661         * or not a valid {@code long}.
662         */
663        public static long getLong(ContentResolver cr, String name, long def) {
664            String valString = getString(cr, name);
665            long value;
666            try {
667                value = valString != null ? Long.parseLong(valString) : def;
668            } catch (NumberFormatException e) {
669                value = def;
670            }
671            return value;
672        }
673
674        /**
675         * Convenience function for retrieving a single system settings value
676         * as a {@code long}.  Note that internally setting values are always
677         * stored as strings; this function converts the string to a {@code long}
678         * for you.
679         * <p>
680         * This version does not take a default value.  If the setting has not
681         * been set, or the string value is not a number,
682         * it throws {@link SettingNotFoundException}.
683         *
684         * @param cr The ContentResolver to access.
685         * @param name The name of the setting to retrieve.
686         *
687         * @return The setting's current value.
688         * @throws SettingNotFoundException Thrown if a setting by the given
689         * name can't be found or the setting value is not an integer.
690         */
691        public static long getLong(ContentResolver cr, String name)
692                throws SettingNotFoundException {
693            String valString = getString(cr, name);
694            try {
695                return Long.parseLong(valString);
696            } catch (NumberFormatException e) {
697                throw new SettingNotFoundException(name);
698            }
699        }
700
701        /**
702         * Convenience function for updating a single settings value as a long
703         * integer. This will either create a new entry in the table if the
704         * given name does not exist, or modify the value of the existing row
705         * with that name.  Note that internally setting values are always
706         * stored as strings, so this function converts the given value to a
707         * string before storing it.
708         *
709         * @param cr The ContentResolver to access.
710         * @param name The name of the setting to modify.
711         * @param value The new value for the setting.
712         * @return true if the value was set, false on database errors
713         */
714        public static boolean putLong(ContentResolver cr, String name, long value) {
715            return putString(cr, name, Long.toString(value));
716        }
717
718        /**
719         * Convenience function for retrieving a single system settings value
720         * as a floating point number.  Note that internally setting values are
721         * always stored as strings; this function converts the string to an
722         * float for you. The default value will be returned if the setting
723         * is not defined or not a valid float.
724         *
725         * @param cr The ContentResolver to access.
726         * @param name The name of the setting to retrieve.
727         * @param def Value to return if the setting is not defined.
728         *
729         * @return The setting's current value, or 'def' if it is not defined
730         * or not a valid float.
731         */
732        public static float getFloat(ContentResolver cr, String name, float def) {
733            String v = getString(cr, name);
734            try {
735                return v != null ? Float.parseFloat(v) : def;
736            } catch (NumberFormatException e) {
737                return def;
738            }
739        }
740
741        /**
742         * Convenience function for retrieving a single system settings value
743         * as a float.  Note that internally setting values are always
744         * stored as strings; this function converts the string to a float
745         * for you.
746         * <p>
747         * This version does not take a default value.  If the setting has not
748         * been set, or the string value is not a number,
749         * it throws {@link SettingNotFoundException}.
750         *
751         * @param cr The ContentResolver to access.
752         * @param name The name of the setting to retrieve.
753         *
754         * @throws SettingNotFoundException Thrown if a setting by the given
755         * name can't be found or the setting value is not a float.
756         *
757         * @return The setting's current value.
758         */
759        public static float getFloat(ContentResolver cr, String name)
760                throws SettingNotFoundException {
761            String v = getString(cr, name);
762            try {
763                return Float.parseFloat(v);
764            } catch (NumberFormatException e) {
765                throw new SettingNotFoundException(name);
766            }
767        }
768
769        /**
770         * Convenience function for updating a single settings value as a
771         * floating point number. This will either create a new entry in the
772         * table if the given name does not exist, or modify the value of the
773         * existing row with that name.  Note that internally setting values
774         * are always stored as strings, so this function converts the given
775         * value to a string before storing it.
776         *
777         * @param cr The ContentResolver to access.
778         * @param name The name of the setting to modify.
779         * @param value The new value for the setting.
780         * @return true if the value was set, false on database errors
781         */
782        public static boolean putFloat(ContentResolver cr, String name, float value) {
783            return putString(cr, name, Float.toString(value));
784        }
785
786        /**
787         * Convenience function to read all of the current
788         * configuration-related settings into a
789         * {@link Configuration} object.
790         *
791         * @param cr The ContentResolver to access.
792         * @param outConfig Where to place the configuration settings.
793         */
794        public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
795            outConfig.fontScale = Settings.System.getFloat(
796                cr, FONT_SCALE, outConfig.fontScale);
797            if (outConfig.fontScale < 0) {
798                outConfig.fontScale = 1;
799            }
800        }
801
802        /**
803         * Convenience function to write a batch of configuration-related
804         * settings from a {@link Configuration} object.
805         *
806         * @param cr The ContentResolver to access.
807         * @param config The settings to write.
808         * @return true if the values were set, false on database errors
809         */
810        public static boolean putConfiguration(ContentResolver cr, Configuration config) {
811            return Settings.System.putFloat(cr, FONT_SCALE, config.fontScale);
812        }
813
814        public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
815            return getInt(cr, SHOW_GTALK_SERVICE_STATUS, 0) != 0;
816        }
817
818        public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
819            putInt(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0);
820        }
821
822        /**
823         * The content:// style URL for this table
824         */
825        public static final Uri CONTENT_URI =
826            Uri.parse("content://" + AUTHORITY + "/system");
827
828        /**
829         * Whether we keep the device on while the device is plugged in.
830         * Supported values are:
831         * <ul>
832         * <li>{@code 0} to never stay on while plugged in</li>
833         * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
834         * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
835         * </ul>
836         * These values can be OR-ed together.
837         */
838        public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
839
840        /**
841         * What happens when the user presses the end call button if they're not
842         * on a call.<br/>
843         * <b>Values:</b><br/>
844         * 0 - The end button does nothing.<br/>
845         * 1 - The end button goes to the home screen.<br/>
846         * 2 - The end button puts the device to sleep and locks the keyguard.<br/>
847         * 3 - The end button goes to the home screen.  If the user is already on the
848         * home screen, it puts the device to sleep.
849         */
850        public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
851
852        /**
853         * Whether Airplane Mode is on.
854         */
855        public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
856
857        /**
858         * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
859         */
860        public static final String RADIO_BLUETOOTH = "bluetooth";
861
862        /**
863         * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
864         */
865        public static final String RADIO_WIFI = "wifi";
866
867        /**
868         * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
869         */
870        public static final String RADIO_CELL = "cell";
871
872        /**
873         * A comma separated list of radios that need to be disabled when airplane mode
874         * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
875         * included in the comma separated list.
876         */
877        public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
878
879        /**
880         * A comma separated list of radios that should to be disabled when airplane mode
881         * is on, but can be manually reenabled by the user.  For example, if RADIO_WIFI is
882         * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
883         * will be turned off when entering airplane mode, but the user will be able to reenable
884         * Wifi in the Settings app.
885         *
886         * {@hide}
887         */
888        public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
889
890        /**
891         * The policy for deciding when Wi-Fi should go to sleep (which will in
892         * turn switch to using the mobile data as an Internet connection).
893         * <p>
894         * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
895         * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
896         * {@link #WIFI_SLEEP_POLICY_NEVER}.
897         */
898        public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
899
900        /**
901         * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
902         * policy, which is to sleep shortly after the turning off
903         * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
904         */
905        public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
906
907        /**
908         * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
909         * the device is on battery, and never go to sleep when the device is
910         * plugged in.
911         */
912        public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
913
914        /**
915         * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
916         */
917        public static final int WIFI_SLEEP_POLICY_NEVER = 2;
918
919        /**
920         * Whether to use static IP and other static network attributes.
921         * <p>
922         * Set to 1 for true and 0 for false.
923         */
924        public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
925
926        /**
927         * The static IP address.
928         * <p>
929         * Example: "192.168.1.51"
930         */
931        public static final String WIFI_STATIC_IP = "wifi_static_ip";
932
933        /**
934         * If using static IP, the gateway's IP address.
935         * <p>
936         * Example: "192.168.1.1"
937         */
938        public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
939
940        /**
941         * If using static IP, the net mask.
942         * <p>
943         * Example: "255.255.255.0"
944         */
945        public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
946
947        /**
948         * If using static IP, the primary DNS's IP address.
949         * <p>
950         * Example: "192.168.1.1"
951         */
952        public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
953
954        /**
955         * If using static IP, the secondary DNS's IP address.
956         * <p>
957         * Example: "192.168.1.2"
958         */
959        public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
960
961        /**
962         * The number of radio channels that are allowed in the local
963         * 802.11 regulatory domain.
964         * @hide
965         */
966        public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels";
967
968        /**
969         * Determines whether remote devices may discover and/or connect to
970         * this device.
971         * <P>Type: INT</P>
972         * 2 -- discoverable and connectable
973         * 1 -- connectable but not discoverable
974         * 0 -- neither connectable nor discoverable
975         */
976        public static final String BLUETOOTH_DISCOVERABILITY =
977            "bluetooth_discoverability";
978
979        /**
980         * Bluetooth discoverability timeout.  If this value is nonzero, then
981         * Bluetooth becomes discoverable for a certain number of seconds,
982         * after which is becomes simply connectable.  The value is in seconds.
983         */
984        public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
985            "bluetooth_discoverability_timeout";
986
987        /**
988         * Whether autolock is enabled (0 = false, 1 = true)
989         */
990        public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
991
992        /**
993         * Whether lock pattern is visible as user enters (0 = false, 1 = true)
994         */
995        public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
996
997        /**
998         * Whether lock pattern will vibrate as user enters (0 = false, 1 = true)
999         */
1000        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
1001            "lock_pattern_tactile_feedback_enabled";
1002
1003
1004        /**
1005         * A formatted string of the next alarm that is set, or the empty string
1006         * if there is no alarm set.
1007         */
1008        public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
1009
1010        /**
1011         * Scaling factor for fonts, float.
1012         */
1013        public static final String FONT_SCALE = "font_scale";
1014
1015        /**
1016         * Name of an application package to be debugged.
1017         */
1018        public static final String DEBUG_APP = "debug_app";
1019
1020        /**
1021         * If 1, when launching DEBUG_APP it will wait for the debugger before
1022         * starting user code.  If 0, it will run normally.
1023         */
1024        public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
1025
1026        /**
1027         * Whether or not to dim the screen. 0=no  1=yes
1028         */
1029        public static final String DIM_SCREEN = "dim_screen";
1030
1031        /**
1032         * The timeout before the screen turns off.
1033         */
1034        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
1035
1036        /**
1037         * If 0, the compatibility mode is off for all applications.
1038         * If 1, older applications run under compatibility mode.
1039         * TODO: remove this settings before code freeze (bug/1907571)
1040         * @hide
1041         */
1042        public static final String COMPATIBILITY_MODE = "compatibility_mode";
1043
1044        /**
1045         * The screen backlight brightness between 0 and 255.
1046         */
1047        public static final String SCREEN_BRIGHTNESS = "screen_brightness";
1048
1049        /**
1050         * Control whether the process CPU usage meter should be shown.
1051         */
1052        public static final String SHOW_PROCESSES = "show_processes";
1053
1054        /**
1055         * If 1, the activity manager will aggressively finish activities and
1056         * processes as soon as they are no longer needed.  If 0, the normal
1057         * extended lifetime is used.
1058         */
1059        public static final String ALWAYS_FINISH_ACTIVITIES =
1060                "always_finish_activities";
1061
1062
1063        /**
1064         * Ringer mode. This is used internally, changing this value will not
1065         * change the ringer mode. See AudioManager.
1066         */
1067        public static final String MODE_RINGER = "mode_ringer";
1068
1069        /**
1070         * Determines which streams are affected by ringer mode changes. The
1071         * stream type's bit should be set to 1 if it should be muted when going
1072         * into an inaudible ringer mode.
1073         */
1074        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
1075
1076         /**
1077          * Determines which streams are affected by mute. The
1078          * stream type's bit should be set to 1 if it should be muted when a mute request
1079          * is received.
1080          */
1081         public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
1082
1083        /**
1084         * Whether vibrate is on for different events. This is used internally,
1085         * changing this value will not change the vibrate. See AudioManager.
1086         */
1087        public static final String VIBRATE_ON = "vibrate_on";
1088
1089        /**
1090         * Ringer volume. This is used internally, changing this value will not
1091         * change the volume. See AudioManager.
1092         */
1093        public static final String VOLUME_RING = "volume_ring";
1094
1095        /**
1096         * System/notifications volume. This is used internally, changing this
1097         * value will not change the volume. See AudioManager.
1098         */
1099        public static final String VOLUME_SYSTEM = "volume_system";
1100
1101        /**
1102         * Voice call volume. This is used internally, changing this value will
1103         * not change the volume. See AudioManager.
1104         */
1105        public static final String VOLUME_VOICE = "volume_voice";
1106
1107        /**
1108         * Music/media/gaming volume. This is used internally, changing this
1109         * value will not change the volume. See AudioManager.
1110         */
1111        public static final String VOLUME_MUSIC = "volume_music";
1112
1113        /**
1114         * Alarm volume. This is used internally, changing this
1115         * value will not change the volume. See AudioManager.
1116         */
1117        public static final String VOLUME_ALARM = "volume_alarm";
1118
1119        /**
1120         * Notification volume. This is used internally, changing this
1121         * value will not change the volume. See AudioManager.
1122         */
1123        public static final String VOLUME_NOTIFICATION = "volume_notification";
1124
1125        /**
1126         * Whether the notifications should use the ring volume (value of 1) or
1127         * a separate notification volume (value of 0). In most cases, users
1128         * will have this enabled so the notification and ringer volumes will be
1129         * the same. However, power users can disable this and use the separate
1130         * notification volume control.
1131         * <p>
1132         * Note: This is a one-off setting that will be removed in the future
1133         * when there is profile support. For this reason, it is kept hidden
1134         * from the public APIs.
1135         *
1136         * @hide
1137         */
1138        public static final String NOTIFICATIONS_USE_RING_VOLUME =
1139            "notifications_use_ring_volume";
1140
1141        /**
1142         * The mapping of stream type (integer) to its setting.
1143         */
1144        public static final String[] VOLUME_SETTINGS = {
1145            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
1146            VOLUME_ALARM, VOLUME_NOTIFICATION
1147        };
1148
1149        /**
1150         * Appended to various volume related settings to record the previous
1151         * values before they the settings were affected by a silent/vibrate
1152         * ringer mode change.
1153         */
1154        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
1155
1156        /**
1157         * Persistent store for the system-wide default ringtone URI.
1158         * <p>
1159         * If you need to play the default ringtone at any given time, it is recommended
1160         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
1161         * to the set default ringtone at the time of playing.
1162         *
1163         * @see #DEFAULT_RINGTONE_URI
1164         */
1165        public static final String RINGTONE = "ringtone";
1166
1167        /**
1168         * A {@link Uri} that will point to the current default ringtone at any
1169         * given time.
1170         * <p>
1171         * If the current default ringtone is in the DRM provider and the caller
1172         * does not have permission, the exception will be a
1173         * FileNotFoundException.
1174         */
1175        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
1176
1177        /**
1178         * Persistent store for the system-wide default notification sound.
1179         *
1180         * @see #RINGTONE
1181         * @see #DEFAULT_NOTIFICATION_URI
1182         */
1183        public static final String NOTIFICATION_SOUND = "notification_sound";
1184
1185        /**
1186         * A {@link Uri} that will point to the current default notification
1187         * sound at any given time.
1188         *
1189         * @see #DEFAULT_RINGTONE_URI
1190         */
1191        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
1192
1193        /**
1194         * Persistent store for the system-wide default alarm alert.
1195         *
1196         * @see #RINGTONE
1197         * @see #DEFAULT_ALARM_ALERT_URI
1198         */
1199        public static final String ALARM_ALERT = "alarm_alert";
1200
1201        /**
1202         * A {@link Uri} that will point to the current default alarm alert at
1203         * any given time.
1204         *
1205         * @see #DEFAULT_ALARM_ALERT_URI
1206         */
1207        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
1208
1209        /**
1210         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
1211         */
1212        public static final String TEXT_AUTO_REPLACE = "auto_replace";
1213
1214        /**
1215         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
1216         */
1217        public static final String TEXT_AUTO_CAPS = "auto_caps";
1218
1219        /**
1220         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
1221         * feature converts two spaces to a "." and space.
1222         */
1223        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
1224
1225        /**
1226         * Setting to showing password characters in text editors. 1 = On, 0 = Off
1227         */
1228        public static final String TEXT_SHOW_PASSWORD = "show_password";
1229
1230        public static final String SHOW_GTALK_SERVICE_STATUS =
1231                "SHOW_GTALK_SERVICE_STATUS";
1232
1233        /**
1234         * Name of activity to use for wallpaper on the home screen.
1235         */
1236        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
1237
1238        /**
1239         * Value to specify if the user prefers the date, time and time zone
1240         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
1241         */
1242        public static final String AUTO_TIME = "auto_time";
1243
1244        /**
1245         * Display times as 12 or 24 hours
1246         *   12
1247         *   24
1248         */
1249        public static final String TIME_12_24 = "time_12_24";
1250
1251        /**
1252         * Date format string
1253         *   mm/dd/yyyy
1254         *   dd/mm/yyyy
1255         *   yyyy/mm/dd
1256         */
1257        public static final String DATE_FORMAT = "date_format";
1258
1259        /**
1260         * Whether the setup wizard has been run before (on first boot), or if
1261         * it still needs to be run.
1262         *
1263         * nonzero = it has been run in the past
1264         * 0 = it has not been run in the past
1265         */
1266        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
1267
1268        /**
1269         * Scaling factor for normal window animations. Setting to 0 will disable window
1270         * animations.
1271         */
1272        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
1273
1274        /**
1275         * Scaling factor for activity transition animations. Setting to 0 will disable window
1276         * animations.
1277         */
1278        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
1279
1280        /**
1281         * Scaling factor for normal window animations. Setting to 0 will disable window
1282         * animations.
1283         * @hide
1284         */
1285        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
1286
1287        /**
1288         * Control whether the accelerometer will be used to change screen
1289         * orientation.  If 0, it will not be used unless explicitly requested
1290         * by the application; if 1, it will be used by default unless explicitly
1291         * disabled by the application.
1292         */
1293        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
1294
1295        /**
1296         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
1297         * boolean (1 or 0).
1298         */
1299        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
1300
1301        /**
1302         * CDMA only settings
1303         * DTMF tone type played by the dialer when dialing.
1304         *                 0 = Normal
1305         *                 1 = Long
1306         * @hide
1307         */
1308        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
1309
1310        /**
1311         * CDMA only settings
1312         * Emergency Tone  0 = Off
1313         *                 1 = Alert
1314         *                 2 = Vibrate
1315         * @hide
1316         */
1317        public static final String EMERGENCY_TONE = "emergency_tone";
1318
1319        /**
1320         * CDMA only settings
1321         * Whether the auto retry is enabled. The value is
1322         * boolean (1 or 0).
1323         * @hide
1324         */
1325        public static final String CALL_AUTO_RETRY = "call_auto_retry";
1326
1327        /**
1328         * Whether the hearing aid is enabled. The value is
1329         * boolean (1 or 0).
1330         * @hide
1331         */
1332        public static final String HEARING_AID = "hearing_aid";
1333
1334        /**
1335         * CDMA only settings
1336         * TTY Mode
1337         * 0 = OFF
1338         * 1 = FULL
1339         * 2 = VCO
1340         * 3 = HCO
1341         * @hide
1342         */
1343        public static final String TTY_MODE = "tty_mode";
1344
1345        /**
1346         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
1347         * boolean (1 or 0).
1348         */
1349        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
1350
1351        /**
1352         * Whether the haptic feedback (long presses, ...) are enabled. The value is
1353         * boolean (1 or 0).
1354         */
1355        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
1356
1357        /**
1358         * Whether live web suggestions while the user types into search dialogs are
1359         * enabled. Browsers and other search UIs should respect this, as it allows
1360         * a user to avoid sending partial queries to a search engine, if it poses
1361         * any privacy concern. The value is boolean (1 or 0).
1362         */
1363        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
1364
1365        /**
1366         * Settings to backup. This is here so that it's in the same place as the settings
1367         * keys and easy to update.
1368         * @hide
1369         */
1370        public static final String[] SETTINGS_TO_BACKUP = {
1371            STAY_ON_WHILE_PLUGGED_IN,
1372            END_BUTTON_BEHAVIOR,
1373            WIFI_SLEEP_POLICY,
1374            WIFI_USE_STATIC_IP,
1375            WIFI_STATIC_IP,
1376            WIFI_STATIC_GATEWAY,
1377            WIFI_STATIC_NETMASK,
1378            WIFI_STATIC_DNS1,
1379            WIFI_STATIC_DNS2,
1380            BLUETOOTH_DISCOVERABILITY,
1381            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
1382            DIM_SCREEN,
1383            SCREEN_OFF_TIMEOUT,
1384            SCREEN_BRIGHTNESS,
1385            VIBRATE_ON,
1386            NOTIFICATIONS_USE_RING_VOLUME,
1387            MODE_RINGER,
1388            MODE_RINGER_STREAMS_AFFECTED,
1389            MUTE_STREAMS_AFFECTED,
1390            VOLUME_VOICE,
1391            VOLUME_SYSTEM,
1392            VOLUME_RING,
1393            VOLUME_MUSIC,
1394            VOLUME_ALARM,
1395            VOLUME_NOTIFICATION,
1396            VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE,
1397            VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE,
1398            VOLUME_RING + APPEND_FOR_LAST_AUDIBLE,
1399            VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE,
1400            VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
1401            VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
1402            TEXT_AUTO_REPLACE,
1403            TEXT_AUTO_CAPS,
1404            TEXT_AUTO_PUNCTUATE,
1405            TEXT_SHOW_PASSWORD,
1406            AUTO_TIME,
1407            TIME_12_24,
1408            DATE_FORMAT,
1409            ACCELEROMETER_ROTATION,
1410            DTMF_TONE_WHEN_DIALING,
1411            DTMF_TONE_TYPE_WHEN_DIALING,
1412            EMERGENCY_TONE,
1413            CALL_AUTO_RETRY,
1414            HEARING_AID,
1415            TTY_MODE,
1416            SOUND_EFFECTS_ENABLED,
1417            HAPTIC_FEEDBACK_ENABLED,
1418            SHOW_WEB_SUGGESTIONS
1419        };
1420
1421        // Settings moved to Settings.Secure
1422
1423        /**
1424         * @deprecated Use {@link android.provider.Settings.Secure#ADB_ENABLED}
1425         * instead
1426         */
1427        @Deprecated
1428        public static final String ADB_ENABLED = Secure.ADB_ENABLED;
1429
1430        /**
1431         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
1432         */
1433        @Deprecated
1434        public static final String ANDROID_ID = Secure.ANDROID_ID;
1435
1436        /**
1437         * @deprecated Use {@link android.provider.Settings.Secure#BLUETOOTH_ON} instead
1438         */
1439        @Deprecated
1440        public static final String BLUETOOTH_ON = Secure.BLUETOOTH_ON;
1441
1442        /**
1443         * @deprecated Use {@link android.provider.Settings.Secure#DATA_ROAMING} instead
1444         */
1445        @Deprecated
1446        public static final String DATA_ROAMING = Secure.DATA_ROAMING;
1447
1448        /**
1449         * @deprecated Use {@link android.provider.Settings.Secure#DEVICE_PROVISIONED} instead
1450         */
1451        @Deprecated
1452        public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED;
1453
1454        /**
1455         * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead
1456         */
1457        @Deprecated
1458        public static final String HTTP_PROXY = Secure.HTTP_PROXY;
1459
1460        /**
1461         * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
1462         */
1463        @Deprecated
1464        public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
1465
1466        /**
1467         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
1468         * instead
1469         */
1470        @Deprecated
1471        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
1472
1473        /**
1474         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
1475         */
1476        @Deprecated
1477        public static final String LOGGING_ID = Secure.LOGGING_ID;
1478
1479        /**
1480         * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead
1481         */
1482        @Deprecated
1483        public static final String NETWORK_PREFERENCE = Secure.NETWORK_PREFERENCE;
1484
1485        /**
1486         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
1487         * instead
1488         */
1489        @Deprecated
1490        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
1491
1492        /**
1493         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
1494         * instead
1495         */
1496        @Deprecated
1497        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
1498
1499        /**
1500         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
1501         * instead
1502         */
1503        @Deprecated
1504        public static final String PARENTAL_CONTROL_REDIRECT_URL =
1505            Secure.PARENTAL_CONTROL_REDIRECT_URL;
1506
1507        /**
1508         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
1509         */
1510        @Deprecated
1511        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
1512
1513        /**
1514         * @deprecated Use {@link android.provider.Settings.Secure#USB_MASS_STORAGE_ENABLED} instead
1515         */
1516        @Deprecated
1517        public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED;
1518
1519        /**
1520         * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead
1521         */
1522        @Deprecated
1523        public static final String USE_GOOGLE_MAIL = Secure.USE_GOOGLE_MAIL;
1524
1525       /**
1526         * @deprecated Use
1527         * {@link android.provider.Settings.Secure#WIFI_MAX_DHCP_RETRY_COUNT} instead
1528         */
1529        @Deprecated
1530        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Secure.WIFI_MAX_DHCP_RETRY_COUNT;
1531
1532        /**
1533         * @deprecated Use
1534         * {@link android.provider.Settings.Secure#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
1535         */
1536        @Deprecated
1537        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
1538                Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
1539
1540        /**
1541         * @deprecated Use
1542         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
1543         */
1544        @Deprecated
1545        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
1546            Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
1547
1548        /**
1549         * @deprecated Use
1550         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
1551         */
1552        @Deprecated
1553        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
1554            Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
1555
1556        /**
1557         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT}
1558         * instead
1559         */
1560        @Deprecated
1561        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Secure.WIFI_NUM_OPEN_NETWORKS_KEPT;
1562
1563        /**
1564         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_ON} instead
1565         */
1566        @Deprecated
1567        public static final String WIFI_ON = Secure.WIFI_ON;
1568
1569        /**
1570         * @deprecated Use
1571         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
1572         * instead
1573         */
1574        @Deprecated
1575        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
1576                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
1577
1578        /**
1579         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
1580         */
1581        @Deprecated
1582        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
1583
1584        /**
1585         * @deprecated Use
1586         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
1587         */
1588        @Deprecated
1589        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
1590                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
1591
1592        /**
1593         * @deprecated Use
1594         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
1595         */
1596        @Deprecated
1597        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
1598                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
1599
1600        /**
1601         * @deprecated Use
1602         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
1603         * instead
1604         */
1605        @Deprecated
1606        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
1607                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
1608
1609        /**
1610         * @deprecated Use
1611         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
1612         */
1613        @Deprecated
1614        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
1615            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
1616
1617        /**
1618         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
1619         * instead
1620         */
1621        @Deprecated
1622        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
1623
1624        /**
1625         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ON} instead
1626         */
1627        @Deprecated
1628        public static final String WIFI_WATCHDOG_ON = Secure.WIFI_WATCHDOG_ON;
1629
1630        /**
1631         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
1632         */
1633        @Deprecated
1634        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
1635
1636        /**
1637         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
1638         * instead
1639         */
1640        @Deprecated
1641        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
1642
1643        /**
1644         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
1645         * instead
1646         */
1647        @Deprecated
1648        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
1649            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
1650    }
1651
1652    /**
1653     * Secure system settings, containing system preferences that applications
1654     * can read but are not allowed to write.  These are for preferences that
1655     * the user must explicitly modify through the system UI or specialized
1656     * APIs for those values, not modified directly by applications.
1657     */
1658    public static final class Secure extends NameValueTable {
1659        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
1660
1661        private static volatile NameValueCache mNameValueCache = null;
1662
1663        /**
1664         * Look up a name in the database.
1665         * @param resolver to access the database with
1666         * @param name to look up in the table
1667         * @return the corresponding value, or null if not present
1668         */
1669        public synchronized static String getString(ContentResolver resolver, String name) {
1670            if (mNameValueCache == null) {
1671                mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
1672            }
1673            return mNameValueCache.getString(resolver, name);
1674        }
1675
1676        /**
1677         * Store a name/value pair into the database.
1678         * @param resolver to access the database with
1679         * @param name to store
1680         * @param value to associate with the name
1681         * @return true if the value was set, false on database errors
1682         */
1683        public static boolean putString(ContentResolver resolver,
1684                String name, String value) {
1685            return putString(resolver, CONTENT_URI, name, value);
1686        }
1687
1688        /**
1689         * Construct the content URI for a particular name/value pair,
1690         * useful for monitoring changes with a ContentObserver.
1691         * @param name to look up in the table
1692         * @return the corresponding content URI, or null if not present
1693         */
1694        public static Uri getUriFor(String name) {
1695            return getUriFor(CONTENT_URI, name);
1696        }
1697
1698        /**
1699         * Convenience function for retrieving a single secure settings value
1700         * as an integer.  Note that internally setting values are always
1701         * stored as strings; this function converts the string to an integer
1702         * for you.  The default value will be returned if the setting is
1703         * not defined or not an integer.
1704         *
1705         * @param cr The ContentResolver to access.
1706         * @param name The name of the setting to retrieve.
1707         * @param def Value to return if the setting is not defined.
1708         *
1709         * @return The setting's current value, or 'def' if it is not defined
1710         * or not a valid integer.
1711         */
1712        public static int getInt(ContentResolver cr, String name, int def) {
1713            String v = getString(cr, name);
1714            try {
1715                return v != null ? Integer.parseInt(v) : def;
1716            } catch (NumberFormatException e) {
1717                return def;
1718            }
1719        }
1720
1721        /**
1722         * Convenience function for retrieving a single secure settings value
1723         * as an integer.  Note that internally setting values are always
1724         * stored as strings; this function converts the string to an integer
1725         * for you.
1726         * <p>
1727         * This version does not take a default value.  If the setting has not
1728         * been set, or the string value is not a number,
1729         * it throws {@link SettingNotFoundException}.
1730         *
1731         * @param cr The ContentResolver to access.
1732         * @param name The name of the setting to retrieve.
1733         *
1734         * @throws SettingNotFoundException Thrown if a setting by the given
1735         * name can't be found or the setting value is not an integer.
1736         *
1737         * @return The setting's current value.
1738         */
1739        public static int getInt(ContentResolver cr, String name)
1740                throws SettingNotFoundException {
1741            String v = getString(cr, name);
1742            try {
1743                return Integer.parseInt(v);
1744            } catch (NumberFormatException e) {
1745                throw new SettingNotFoundException(name);
1746            }
1747        }
1748
1749        /**
1750         * Convenience function for updating a single settings value as an
1751         * integer. This will either create a new entry in the table if the
1752         * given name does not exist, or modify the value of the existing row
1753         * with that name.  Note that internally setting values are always
1754         * stored as strings, so this function converts the given value to a
1755         * string before storing it.
1756         *
1757         * @param cr The ContentResolver to access.
1758         * @param name The name of the setting to modify.
1759         * @param value The new value for the setting.
1760         * @return true if the value was set, false on database errors
1761         */
1762        public static boolean putInt(ContentResolver cr, String name, int value) {
1763            return putString(cr, name, Integer.toString(value));
1764        }
1765
1766        /**
1767         * Convenience function for retrieving a single secure settings value
1768         * as a {@code long}.  Note that internally setting values are always
1769         * stored as strings; this function converts the string to a {@code long}
1770         * for you.  The default value will be returned if the setting is
1771         * not defined or not a {@code long}.
1772         *
1773         * @param cr The ContentResolver to access.
1774         * @param name The name of the setting to retrieve.
1775         * @param def Value to return if the setting is not defined.
1776         *
1777         * @return The setting's current value, or 'def' if it is not defined
1778         * or not a valid {@code long}.
1779         */
1780        public static long getLong(ContentResolver cr, String name, long def) {
1781            String valString = getString(cr, name);
1782            long value;
1783            try {
1784                value = valString != null ? Long.parseLong(valString) : def;
1785            } catch (NumberFormatException e) {
1786                value = def;
1787            }
1788            return value;
1789        }
1790
1791        /**
1792         * Convenience function for retrieving a single secure settings value
1793         * as a {@code long}.  Note that internally setting values are always
1794         * stored as strings; this function converts the string to a {@code long}
1795         * for you.
1796         * <p>
1797         * This version does not take a default value.  If the setting has not
1798         * been set, or the string value is not a number,
1799         * it throws {@link SettingNotFoundException}.
1800         *
1801         * @param cr The ContentResolver to access.
1802         * @param name The name of the setting to retrieve.
1803         *
1804         * @return The setting's current value.
1805         * @throws SettingNotFoundException Thrown if a setting by the given
1806         * name can't be found or the setting value is not an integer.
1807         */
1808        public static long getLong(ContentResolver cr, String name)
1809                throws SettingNotFoundException {
1810            String valString = getString(cr, name);
1811            try {
1812                return Long.parseLong(valString);
1813            } catch (NumberFormatException e) {
1814                throw new SettingNotFoundException(name);
1815            }
1816        }
1817
1818        /**
1819         * Convenience function for updating a secure settings value as a long
1820         * integer. This will either create a new entry in the table if the
1821         * given name does not exist, or modify the value of the existing row
1822         * with that name.  Note that internally setting values are always
1823         * stored as strings, so this function converts the given value to a
1824         * string before storing it.
1825         *
1826         * @param cr The ContentResolver to access.
1827         * @param name The name of the setting to modify.
1828         * @param value The new value for the setting.
1829         * @return true if the value was set, false on database errors
1830         */
1831        public static boolean putLong(ContentResolver cr, String name, long value) {
1832            return putString(cr, name, Long.toString(value));
1833        }
1834
1835        /**
1836         * Convenience function for retrieving a single secure settings value
1837         * as a floating point number.  Note that internally setting values are
1838         * always stored as strings; this function converts the string to an
1839         * float for you. The default value will be returned if the setting
1840         * is not defined or not a valid float.
1841         *
1842         * @param cr The ContentResolver to access.
1843         * @param name The name of the setting to retrieve.
1844         * @param def Value to return if the setting is not defined.
1845         *
1846         * @return The setting's current value, or 'def' if it is not defined
1847         * or not a valid float.
1848         */
1849        public static float getFloat(ContentResolver cr, String name, float def) {
1850            String v = getString(cr, name);
1851            try {
1852                return v != null ? Float.parseFloat(v) : def;
1853            } catch (NumberFormatException e) {
1854                return def;
1855            }
1856        }
1857
1858        /**
1859         * Convenience function for retrieving a single secure settings value
1860         * as a float.  Note that internally setting values are always
1861         * stored as strings; this function converts the string to a float
1862         * for you.
1863         * <p>
1864         * This version does not take a default value.  If the setting has not
1865         * been set, or the string value is not a number,
1866         * it throws {@link SettingNotFoundException}.
1867         *
1868         * @param cr The ContentResolver to access.
1869         * @param name The name of the setting to retrieve.
1870         *
1871         * @throws SettingNotFoundException Thrown if a setting by the given
1872         * name can't be found or the setting value is not a float.
1873         *
1874         * @return The setting's current value.
1875         */
1876        public static float getFloat(ContentResolver cr, String name)
1877                throws SettingNotFoundException {
1878            String v = getString(cr, name);
1879            try {
1880                return Float.parseFloat(v);
1881            } catch (NumberFormatException e) {
1882                throw new SettingNotFoundException(name);
1883            }
1884        }
1885
1886        /**
1887         * Convenience function for updating a single settings value as a
1888         * floating point number. This will either create a new entry in the
1889         * table if the given name does not exist, or modify the value of the
1890         * existing row with that name.  Note that internally setting values
1891         * are always stored as strings, so this function converts the given
1892         * value to a string before storing it.
1893         *
1894         * @param cr The ContentResolver to access.
1895         * @param name The name of the setting to modify.
1896         * @param value The new value for the setting.
1897         * @return true if the value was set, false on database errors
1898         */
1899        public static boolean putFloat(ContentResolver cr, String name, float value) {
1900            return putString(cr, name, Float.toString(value));
1901        }
1902
1903        /**
1904         * The content:// style URL for this table
1905         */
1906        public static final Uri CONTENT_URI =
1907            Uri.parse("content://" + AUTHORITY + "/secure");
1908
1909        /**
1910         * Whether ADB is enabled.
1911         */
1912        public static final String ADB_ENABLED = "adb_enabled";
1913
1914        /**
1915         * Setting to allow mock locations and location provider status to be injected into the
1916         * LocationManager service for testing purposes during application development.  These
1917         * locations and status values  override actual location and status information generated
1918         * by network, gps, or other location providers.
1919         */
1920        public static final String ALLOW_MOCK_LOCATION = "mock_location";
1921
1922        /**
1923         * The Android ID (a unique 64-bit value) as a hex string.
1924         * Identical to that obtained by calling
1925         * GoogleLoginService.getAndroidId(); it is also placed here
1926         * so you can get it without binding to a service.
1927         */
1928        public static final String ANDROID_ID = "android_id";
1929
1930        /**
1931         * Whether bluetooth is enabled/disabled
1932         * 0=disabled. 1=enabled.
1933         */
1934        public static final String BLUETOOTH_ON = "bluetooth_on";
1935
1936        /**
1937         * Get the key that retrieves a bluetooth headset's priority.
1938         * @hide
1939         */
1940        public static final String getBluetoothHeadsetPriorityKey(String address) {
1941            return ("bluetooth_headset_priority_" + address.toUpperCase());
1942        }
1943
1944        /**
1945         * Get the key that retrieves a bluetooth a2dp sink's priority.
1946         * @hide
1947         */
1948        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
1949            return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
1950        }
1951
1952        /**
1953         * Whether or not data roaming is enabled. (0 = false, 1 = true)
1954         */
1955        public static final String DATA_ROAMING = "data_roaming";
1956
1957        /**
1958         * Setting to record the input method used by default, holding the ID
1959         * of the desired method.
1960         */
1961        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
1962
1963        /**
1964         * Whether the device has been provisioned (0 = false, 1 = true)
1965         */
1966        public static final String DEVICE_PROVISIONED = "device_provisioned";
1967
1968        /**
1969         * List of input methods that are currently enabled.  This is a string
1970         * containing the IDs of all enabled input methods, each ID separated
1971         * by ':'.
1972         */
1973        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
1974
1975        /**
1976         * Host name and port for a user-selected proxy.
1977         */
1978        public static final String HTTP_PROXY = "http_proxy";
1979
1980        /**
1981         * Whether the package installer should allow installation of apps downloaded from
1982         * sources other than the Android Market (vending machine).
1983         *
1984         * 1 = allow installing from other sources
1985         * 0 = only allow installing from the Android Market
1986         */
1987        public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
1988
1989        /**
1990         * Comma-separated list of location providers that activities may access.
1991         */
1992        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
1993
1994        /**
1995         * Whether assisted GPS should be enabled or not.
1996         * @hide
1997         */
1998        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
1999
2000        /**
2001         * The Logging ID (a unique 64-bit value) as a hex string.
2002         * Used as a pseudonymous identifier for logging.
2003         * @deprecated This identifier is poorly initialized and has
2004         * many collisions.  It should not be used.
2005         */
2006        @Deprecated
2007        public static final String LOGGING_ID = "logging_id";
2008
2009        /**
2010         * The Logging ID (a unique 64-bit value) as a hex string.
2011         * Used as a pseudonymous identifier for logging.
2012         * @hide
2013         */
2014        public static final String LOGGING_ID2 = "logging_id2";
2015
2016        /**
2017         * User preference for which network(s) should be used. Only the
2018         * connectivity service should touch this.
2019         */
2020        public static final String NETWORK_PREFERENCE = "network_preference";
2021
2022        /**
2023         */
2024        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
2025
2026        /**
2027         */
2028        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
2029
2030        /**
2031         */
2032        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
2033
2034        /**
2035         * Settings classname to launch when Settings is clicked from All
2036         * Applications.  Needed because of user testing between the old
2037         * and new Settings apps.
2038         */
2039        // TODO: 881807
2040        public static final String SETTINGS_CLASSNAME = "settings_classname";
2041
2042        /**
2043         * USB Mass Storage Enabled
2044         */
2045        public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
2046
2047        /**
2048         * If this setting is set (to anything), then all references
2049         * to Gmail on the device must change to Google Mail.
2050         */
2051        public static final String USE_GOOGLE_MAIL = "use_google_mail";
2052
2053        /**
2054         * If accessibility is enabled.
2055         */
2056        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
2057
2058        /**
2059         * List of the enabled accessibility providers.
2060         */
2061        public static final String ENABLED_ACCESSIBILITY_SERVICES =
2062            "enabled_accessibility_services";
2063
2064        /**
2065         * Setting to always use the default text-to-speech settings regardless
2066         * of the application settings.
2067         * 1 = override application settings,
2068         * 0 = use application settings (if specified).
2069         */
2070        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
2071
2072        /**
2073         * Default text-to-speech engine speech rate. 100 = 1x
2074         */
2075        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
2076
2077        /**
2078         * Default text-to-speech engine pitch. 100 = 1x
2079         */
2080        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
2081
2082        /**
2083         * Default text-to-speech engine.
2084         */
2085        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
2086
2087        /**
2088         * Default text-to-speech language.
2089         */
2090        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
2091
2092        /**
2093         * Default text-to-speech country.
2094         */
2095        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
2096
2097        /**
2098         * Default text-to-speech locale variant.
2099         */
2100        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
2101
2102        /**
2103         * Whether to notify the user of open networks.
2104         * <p>
2105         * If not connected and the scan results have an open network, we will
2106         * put this notification up. If we attempt to connect to a network or
2107         * the open network(s) disappear, we remove the notification. When we
2108         * show the notification, we will not show it again for
2109         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
2110         */
2111        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
2112                "wifi_networks_available_notification_on";
2113
2114        /**
2115         * Delay (in seconds) before repeating the Wi-Fi networks available notification.
2116         * Connecting to a network will reset the timer.
2117         */
2118        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
2119                "wifi_networks_available_repeat_delay";
2120
2121        /**
2122         * The number of radio channels that are allowed in the local
2123         * 802.11 regulatory domain.
2124         * @hide
2125         */
2126        public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels";
2127
2128        /**
2129         * When the number of open networks exceeds this number, the
2130         * least-recently-used excess networks will be removed.
2131         */
2132        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
2133
2134        /**
2135         * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
2136         */
2137        public static final String WIFI_ON = "wifi_on";
2138
2139        /**
2140         * The acceptable packet loss percentage (range 0 - 100) before trying
2141         * another AP on the same network.
2142         */
2143        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
2144                "wifi_watchdog_acceptable_packet_loss_percentage";
2145
2146        /**
2147         * The number of access points required for a network in order for the
2148         * watchdog to monitor it.
2149         */
2150        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
2151
2152        /**
2153         * The delay between background checks.
2154         */
2155        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
2156                "wifi_watchdog_background_check_delay_ms";
2157
2158        /**
2159         * Whether the Wi-Fi watchdog is enabled for background checking even
2160         * after it thinks the user has connected to a good access point.
2161         */
2162        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
2163                "wifi_watchdog_background_check_enabled";
2164
2165        /**
2166         * The timeout for a background ping
2167         */
2168        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
2169                "wifi_watchdog_background_check_timeout_ms";
2170
2171        /**
2172         * The number of initial pings to perform that *may* be ignored if they
2173         * fail. Again, if these fail, they will *not* be used in packet loss
2174         * calculation. For example, one network always seemed to time out for
2175         * the first couple pings, so this is set to 3 by default.
2176         */
2177        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
2178            "wifi_watchdog_initial_ignored_ping_count";
2179
2180        /**
2181         * The maximum number of access points (per network) to attempt to test.
2182         * If this number is reached, the watchdog will no longer monitor the
2183         * initial connection state for the network. This is a safeguard for
2184         * networks containing multiple APs whose DNS does not respond to pings.
2185         */
2186        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
2187
2188        /**
2189         * Whether the Wi-Fi watchdog is enabled.
2190         */
2191        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
2192
2193        /**
2194         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
2195         */
2196        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
2197
2198        /**
2199         * The number of pings to test if an access point is a good connection.
2200         */
2201        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
2202
2203        /**
2204         * The delay between pings.
2205         */
2206        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
2207
2208        /**
2209         * The timeout per ping.
2210         */
2211        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
2212
2213        /**
2214         * The maximum number of times we will retry a connection to an access
2215         * point for which we have failed in acquiring an IP address from DHCP.
2216         * A value of N means that we will make N+1 connection attempts in all.
2217         */
2218        public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
2219
2220        /**
2221         * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
2222         * data connectivity to be established after a disconnect from Wi-Fi.
2223         */
2224        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
2225            "wifi_mobile_data_transition_wakelock_timeout_ms";
2226
2227        /**
2228         * Whether background data usage is allowed by the user. See
2229         * ConnectivityManager for more info.
2230         */
2231        public static final String BACKGROUND_DATA = "background_data";
2232
2233        /**
2234         * The CDMA roaming mode 0 = Home Networks, CDMA default
2235         *                       1 = Roaming on Affiliated networks
2236         *                       2 = Roaming on any networks
2237         * @hide
2238         */
2239        public static final String CDMA_ROAMING_MODE = "roaming_settings";
2240
2241        /**
2242         * The CDMA subscription mode 0 = RUIM/SIM (default)
2243         *                                1 = NV
2244         * @hide
2245         */
2246        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
2247
2248        /**
2249         * The preferred network mode   7 = Global
2250         *                              6 = EvDo only
2251         *                              5 = CDMA w/o EvDo
2252         *                              4 = CDMA / EvDo auto
2253         *                              3 = GSM / WCDMA auto
2254         *                              2 = WCDMA only
2255         *                              1 = GSM only
2256         *                              0 = GSM / WCDMA preferred
2257         * @hide
2258         */
2259        public static final String PREFERRED_NETWORK_MODE =
2260                "preferred_network_mode";
2261
2262        /**
2263         * The preferred TTY mode     0 = TTy Off, CDMA default
2264         *                            1 = TTY Full
2265         *                            2 = TTY HCO
2266         *                            3 = TTY VCO
2267         * @hide
2268         */
2269        public static final String PREFERRED_TTY_MODE =
2270                "preferred_tty_mode";
2271
2272
2273        /**
2274         * CDMA Cell Broadcast SMS
2275         *                            0 = CDMA Cell Broadcast SMS disabled
2276         *                            1 = CDMA Cell Broadcast SMS enabled
2277         * @hide
2278         */
2279        public static final String CDMA_CELL_BROADCAST_SMS =
2280                "cdma_cell_broadcast_sms";
2281
2282        /**
2283         * The cdma subscription 0 = Subscription from RUIM, when available
2284         *                       1 = Subscription from NV
2285         * @hide
2286         */
2287        public static final String PREFERRED_CDMA_SUBSCRIPTION =
2288                "preferred_cdma_subscription";
2289
2290        /**
2291         * Whether the enhanced voice privacy mode is enabled.
2292         * 0 = normal voice privacy
2293         * 1 = enhanced voice privacy
2294         * @hide
2295         */
2296        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
2297
2298        /**
2299         * Whether the TTY mode mode is enabled.
2300         * 0 = disabled
2301         * 1 = enabled
2302         * @hide
2303         */
2304        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
2305
2306        /**
2307         * Flag for allowing service provider to use location information to improve products and
2308         * services.
2309         * Type: int ( 0 = disallow, 1 = allow )
2310         * @hide
2311         */
2312        public static final String USE_LOCATION_FOR_SERVICES = "use_location";
2313
2314        /**
2315         * Controls whether settings backup is enabled.
2316         * Type: int ( 0 = disabled, 1 = enabled )
2317         * @hide
2318         */
2319        public static final String BACKUP_ENABLED = "backup_enabled";
2320
2321        /**
2322         * Indicates whether settings backup has been fully provisioned.
2323         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
2324         * @hide
2325         */
2326        public static final String BACKUP_PROVISIONED = "backup_provisioned";
2327
2328        /**
2329         * Component of the transport to use for backup/restore.
2330         * @hide
2331         */
2332        public static final String BACKUP_TRANSPORT = "backup_transport";
2333
2334        /**
2335         * Version for which the setup wizard was last shown.  Bumped for
2336         * each release when there is new setup information to show.
2337         * @hide
2338         */
2339        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
2340
2341        /**
2342         * @hide
2343         */
2344        public static final String[] SETTINGS_TO_BACKUP = {
2345            ADB_ENABLED,
2346            ALLOW_MOCK_LOCATION,
2347            INSTALL_NON_MARKET_APPS,
2348            PARENTAL_CONTROL_ENABLED,
2349            PARENTAL_CONTROL_REDIRECT_URL,
2350            USB_MASS_STORAGE_ENABLED,
2351            ACCESSIBILITY_ENABLED,
2352            ENABLED_ACCESSIBILITY_SERVICES,
2353            TTS_USE_DEFAULTS,
2354            TTS_DEFAULT_RATE,
2355            TTS_DEFAULT_PITCH,
2356            TTS_DEFAULT_SYNTH,
2357            TTS_DEFAULT_LANG,
2358            TTS_DEFAULT_COUNTRY,
2359            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
2360            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
2361            WIFI_NUM_ALLOWED_CHANNELS,
2362            WIFI_NUM_OPEN_NETWORKS_KEPT,
2363            BACKGROUND_DATA,
2364            PREFERRED_NETWORK_MODE,
2365            PREFERRED_TTY_MODE,
2366            CDMA_CELL_BROADCAST_SMS,
2367            PREFERRED_CDMA_SUBSCRIPTION,
2368            ENHANCED_VOICE_PRIVACY_ENABLED
2369        };
2370
2371        /**
2372         * Helper method for determining if a location provider is enabled.
2373         * @param cr the content resolver to use
2374         * @param provider the location provider to query
2375         * @return true if the provider is enabled
2376         *
2377         * @hide
2378         */
2379        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
2380            String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED);
2381            if (allowedProviders != null) {
2382                return (allowedProviders.equals(provider) ||
2383                        allowedProviders.contains("," + provider + ",") ||
2384                        allowedProviders.startsWith(provider + ",") ||
2385                        allowedProviders.endsWith("," + provider));
2386            }
2387            return false;
2388        }
2389
2390        /**
2391         * Thread-safe method for enabling or disabling a single location provider.
2392         * @param cr the content resolver to use
2393         * @param provider the location provider to enable or disable
2394         * @param enabled true if the provider should be enabled
2395         *
2396         * @hide
2397         */
2398        public static final void setLocationProviderEnabled(ContentResolver cr,
2399                String provider, boolean enabled) {
2400            // to ensure thread safety, we write the provider name with a '+' or '-'
2401            // and let the SettingsProvider handle it rather than reading and modifying
2402            // the list of enabled providers.
2403            if (enabled) {
2404                provider = "+" + provider;
2405            } else {
2406                provider = "-" + provider;
2407            }
2408            putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider);
2409        }
2410    }
2411
2412    /**
2413     * Gservices settings, containing the network names for Google's
2414     * various services. This table holds simple name/addr pairs.
2415     * Addresses can be accessed through the getString() method.
2416     *
2417     * TODO: This should move to partner/google/... somewhere.
2418     *
2419     * @hide
2420     */
2421    public static final class Gservices extends NameValueTable {
2422        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_gservices_version";
2423
2424        /**
2425         * Intent action broadcast when the Gservices table is updated by the server.
2426         * This is broadcast once after settings change (so many values may have been updated).
2427         */
2428        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2429        public static final String CHANGED_ACTION =
2430            "com.google.gservices.intent.action.GSERVICES_CHANGED";
2431
2432        /**
2433         * Intent action to override Gservices for testing.  (Requires WRITE_GSERVICES permission.)
2434         */
2435        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2436        public static final String OVERRIDE_ACTION =
2437            "com.google.gservices.intent.action.GSERVICES_OVERRIDE";
2438
2439        private static volatile NameValueCache mNameValueCache = null;
2440        private static final Object mNameValueCacheLock = new Object();
2441
2442        /**
2443         * Look up a name in the database.
2444         * @param resolver to access the database with
2445         * @param name to look up in the table
2446         * @return the corresponding value, or null if not present
2447         */
2448        public static String getString(ContentResolver resolver, String name) {
2449            synchronized (mNameValueCacheLock) {
2450                if (mNameValueCache == null) {
2451                    mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
2452                }
2453                return mNameValueCache.getString(resolver, name);
2454            }
2455        }
2456
2457        /**
2458         * Store a name/value pair into the database.
2459         * @param resolver to access the database with
2460         * @param name to store
2461         * @param value to associate with the name
2462         * @return true if the value was set, false on database errors
2463         */
2464        public static boolean putString(ContentResolver resolver,
2465                String name, String value) {
2466            return putString(resolver, CONTENT_URI, name, value);
2467        }
2468
2469        /**
2470         * Look up the value for name in the database, convert it to an int using Integer.parseInt
2471         * and return it. If it is null or if a NumberFormatException is caught during the
2472         * conversion then return defValue.
2473         */
2474        public static int getInt(ContentResolver resolver, String name, int defValue) {
2475            String valString = getString(resolver, name);
2476            int value;
2477            try {
2478                value = valString != null ? Integer.parseInt(valString) : defValue;
2479            } catch (NumberFormatException e) {
2480                value = defValue;
2481            }
2482            return value;
2483        }
2484
2485        /**
2486         * Look up the value for name in the database, convert it to a long using Long.parseLong
2487         * and return it. If it is null or if a NumberFormatException is caught during the
2488         * conversion then return defValue.
2489         */
2490        public static long getLong(ContentResolver resolver, String name, long defValue) {
2491            String valString = getString(resolver, name);
2492            long value;
2493            try {
2494                value = valString != null ? Long.parseLong(valString) : defValue;
2495            } catch (NumberFormatException e) {
2496                value = defValue;
2497            }
2498            return value;
2499        }
2500
2501        /**
2502         * Construct the content URI for a particular name/value pair,
2503         * useful for monitoring changes with a ContentObserver.
2504         * @param name to look up in the table
2505         * @return the corresponding content URI, or null if not present
2506         */
2507        public static Uri getUriFor(String name) {
2508            return getUriFor(CONTENT_URI, name);
2509        }
2510
2511        /**
2512         * The content:// style URL for this table
2513         */
2514        public static final Uri CONTENT_URI =
2515                Uri.parse("content://" + AUTHORITY + "/gservices");
2516
2517        /**
2518         * MMS - URL to use for HTTP "x-wap-profile" header
2519         */
2520        public static final String MMS_X_WAP_PROFILE_URL
2521                = "mms_x_wap_profile_url";
2522
2523        /**
2524         * YouTube - the flag to indicate whether to use proxy
2525         */
2526        public static final String YOUTUBE_USE_PROXY
2527                = "youtube_use_proxy";
2528
2529        /**
2530         * MMS - maximum message size in bytes for a MMS message.
2531         */
2532        public static final String MMS_MAXIMUM_MESSAGE_SIZE
2533                = "mms_maximum_message_size";
2534
2535        /**
2536         * Event tags from the kernel event log to upload during checkin.
2537         */
2538        public static final String CHECKIN_EVENTS = "checkin_events";
2539
2540        /**
2541         * Comma-separated list of service names to dump and upload during checkin.
2542         */
2543        public static final String CHECKIN_DUMPSYS_LIST = "checkin_dumpsys_list";
2544
2545        /**
2546         * Comma-separated list of packages to specify for each service that is
2547         * dumped (currently only meaningful for user activity).
2548         */
2549        public static final String CHECKIN_PACKAGE_LIST = "checkin_package_list";
2550
2551        /**
2552         * The interval (in seconds) between periodic checkin attempts.
2553         */
2554        public static final String CHECKIN_INTERVAL = "checkin_interval";
2555
2556        /**
2557         * Boolean indicating if the market app should force market only checkins on
2558         * install/uninstall. Any non-0 value is considered true.
2559         */
2560        public static final String MARKET_FORCE_CHECKIN = "market_force_checkin";
2561
2562        /**
2563         * How frequently (in seconds) to check the memory status of the
2564         * device.
2565         */
2566        public static final String MEMCHECK_INTERVAL = "memcheck_interval";
2567
2568        /**
2569         * Max frequency (in seconds) to log memory check stats, in realtime
2570         * seconds.  This allows for throttling of logs when the device is
2571         * running for large amounts of time.
2572         */
2573        public static final String MEMCHECK_LOG_REALTIME_INTERVAL =
2574                "memcheck_log_realtime_interval";
2575
2576        /**
2577         * Boolean indicating whether rebooting due to system memory checks
2578         * is enabled.
2579         */
2580        public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled";
2581
2582        /**
2583         * How many bytes the system process must be below to avoid scheduling
2584         * a soft reboot.  This reboot will happen when it is next determined
2585         * to be a good time.
2586         */
2587        public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft";
2588
2589        /**
2590         * How many bytes the system process must be below to avoid scheduling
2591         * a hard reboot.  This reboot will happen immediately.
2592         */
2593        public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard";
2594
2595        /**
2596         * How many bytes the phone process must be below to avoid scheduling
2597         * a soft restart.  This restart will happen when it is next determined
2598         * to be a good time.
2599         */
2600        public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft";
2601
2602        /**
2603         * How many bytes the phone process must be below to avoid scheduling
2604         * a hard restart.  This restart will happen immediately.
2605         */
2606        public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard";
2607
2608        /**
2609         * Boolean indicating whether restarting the phone process due to
2610         * memory checks is enabled.
2611         */
2612        public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled";
2613
2614        /**
2615         * First time during the day it is okay to kill processes
2616         * or reboot the device due to low memory situations.  This number is
2617         * in seconds since midnight.
2618         */
2619        public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time";
2620
2621        /**
2622         * Last time during the day it is okay to kill processes
2623         * or reboot the device due to low memory situations.  This number is
2624         * in seconds since midnight.
2625         */
2626        public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time";
2627
2628        /**
2629         * How long the screen must have been off in order to kill processes
2630         * or reboot.  This number is in seconds.  A value of -1 means to
2631         * entirely disregard whether the screen is on.
2632         */
2633        public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off";
2634
2635        /**
2636         * How much time there must be until the next alarm in order to kill processes
2637         * or reboot.  This number is in seconds.  Note: this value must be
2638         * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will
2639         * always see an alarm scheduled within its time.
2640         */
2641        public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm";
2642
2643        /**
2644         * How frequently to check whether it is a good time to restart things,
2645         * if the device is in a bad state.  This number is in seconds.  Note:
2646         * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else
2647         * the alarm to schedule the recheck will always appear within the
2648         * minimum "do not execute now" time.
2649         */
2650        public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval";
2651
2652        /**
2653         * How frequently (in DAYS) to reboot the device.  If 0, no reboots
2654         * will occur.
2655         */
2656        public static final String REBOOT_INTERVAL = "reboot_interval";
2657
2658        /**
2659         * First time during the day it is okay to force a reboot of the
2660         * device (if REBOOT_INTERVAL is set).  This number is
2661         * in seconds since midnight.
2662         */
2663        public static final String REBOOT_START_TIME = "reboot_start_time";
2664
2665        /**
2666         * The window of time (in seconds) after each REBOOT_INTERVAL in which
2667         * a reboot can be executed.  If 0, a reboot will always be executed at
2668         * exactly the given time.  Otherwise, it will only be executed if
2669         * the device is idle within the window.
2670         */
2671        public static final String REBOOT_WINDOW = "reboot_window";
2672
2673        /**
2674         * The minimum version of the server that is required in order for the device to accept
2675         * the server's recommendations about the initial sync settings to use. When this is unset,
2676         * blank or can't be interpreted as an integer then we will not ask the server for a
2677         * recommendation.
2678         */
2679        public static final String GMAIL_CONFIG_INFO_MIN_SERVER_VERSION =
2680                "gmail_config_info_min_server_version";
2681
2682        /**
2683         * Controls whether Gmail offers a preview button for images.
2684         */
2685        public static final String GMAIL_DISALLOW_IMAGE_PREVIEWS = "gmail_disallow_image_previews";
2686
2687        /**
2688         * The maximal size in bytes allowed for attachments when composing messages in Gmail
2689         */
2690        public static final String GMAIL_MAX_ATTACHMENT_SIZE = "gmail_max_attachment_size_bytes";
2691
2692        /**
2693         * The timeout in milliseconds that Gmail uses when opening a connection and reading
2694         * from it. A missing value or a value of -1 instructs Gmail to use the defaults provided
2695         * by GoogleHttpClient.
2696         */
2697        public static final String GMAIL_TIMEOUT_MS = "gmail_timeout_ms";
2698
2699        /**
2700         * Controls whether Gmail will request an expedited sync when a message is sent. Value must
2701         * be an integer where non-zero means true. Defaults to 1.
2702         */
2703        public static final String GMAIL_SEND_IMMEDIATELY = "gmail_send_immediately";
2704
2705        /**
2706         * Controls whether gmail buffers server responses.  Possible values are "memory", for a
2707         * memory-based buffer, or "file", for a temp-file-based buffer.  All other values
2708         * (including not set) disable buffering.
2709         */
2710        public static final String GMAIL_BUFFER_SERVER_RESPONSE = "gmail_buffer_server_response";
2711
2712        /**
2713         * The maximum size in bytes allowed for the provider to gzip a protocol buffer uploaded to
2714         * the server.
2715         */
2716        public static final String GMAIL_MAX_GZIP_SIZE = "gmail_max_gzip_size_bytes";
2717
2718        /**
2719         * Controls whether Gmail will discard uphill operations that repeatedly fail. Value must be
2720         * an integer where non-zero means true. Defaults to 1.
2721         */
2722        public static final String GMAIL_DISCARD_ERROR_UPHILL_OP = "gmail_discard_error_uphill_op";
2723
2724        /**
2725         * Controls how many attempts Gmail will try to upload an uphill operations before it
2726         * abandons the operation. Defaults to 20.
2727         */
2728        public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_num_retry_uphill_op";
2729
2730        /**
2731         * How much time in seconds Gmail will try to upload an uphill operations before it
2732         * abandons the operation. Defaults to 36400 (one day).
2733         */
2734        public static final String GMAIL_WAIT_TIME_RETRY_UPHILL_OP =
2735                "gmail_wait_time_retry_uphill_op";
2736
2737        /**
2738         * Controls if the protocol buffer version of the protocol will use a multipart request for
2739         * attachment uploads. Value must be an integer where non-zero means true. Defaults to 0.
2740         */
2741        public static final String GMAIL_USE_MULTIPART_PROTOBUF = "gmail_use_multipart_protobuf";
2742
2743        /**
2744         * the transcoder URL for mobile devices.
2745         */
2746        public static final String TRANSCODER_URL = "mobile_transcoder_url";
2747
2748        /**
2749         * URL that points to the privacy terms of the Google Talk service.
2750         */
2751        public static final String GTALK_TERMS_OF_SERVICE_URL = "gtalk_terms_of_service_url";
2752
2753        /**
2754         * Hostname of the GTalk server.
2755         */
2756        public static final String GTALK_SERVICE_HOSTNAME = "gtalk_hostname";
2757
2758        /**
2759         * Secure port of the GTalk server.
2760         */
2761        public static final String GTALK_SERVICE_SECURE_PORT = "gtalk_secure_port";
2762
2763        /**
2764         * The server configurable RMQ acking interval
2765         */
2766        public static final String GTALK_SERVICE_RMQ_ACK_INTERVAL = "gtalk_rmq_ack_interval";
2767
2768        /**
2769         * The minimum reconnect delay for short network outages or when the network is suspended
2770         * due to phone use.
2771         */
2772        public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT =
2773                "gtalk_min_reconnect_delay_short";
2774
2775        /**
2776         * The reconnect variant range for short network outages or when the network is suspended
2777         * due to phone use. A random number between 0 and this constant is computed and
2778         * added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT} to form the initial reconnect
2779         * delay.
2780         */
2781        public static final String GTALK_SERVICE_RECONNECT_VARIANT_SHORT =
2782                "gtalk_reconnect_variant_short";
2783
2784        /**
2785         * The minimum reconnect delay for long network outages
2786         */
2787        public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG =
2788                "gtalk_min_reconnect_delay_long";
2789
2790        /**
2791         * The reconnect variant range for long network outages.  A random number between 0 and this
2792         * constant is computed and added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG} to
2793         * form the initial reconnect delay.
2794         */
2795        public static final String GTALK_SERVICE_RECONNECT_VARIANT_LONG =
2796                "gtalk_reconnect_variant_long";
2797
2798        /**
2799         * The maximum reconnect delay time, in milliseconds.
2800         */
2801        public static final String GTALK_SERVICE_MAX_RECONNECT_DELAY =
2802                "gtalk_max_reconnect_delay";
2803
2804        /**
2805         * The network downtime that is considered "short" for the above calculations,
2806         * in milliseconds.
2807         */
2808        public static final String GTALK_SERVICE_SHORT_NETWORK_DOWNTIME =
2809                "gtalk_short_network_downtime";
2810
2811        /**
2812         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2813         * will reset the heartbeat timer. The away heartbeat should be used when the user is
2814         * logged into the GTalk app, but not actively using it.
2815         */
2816        public static final String GTALK_SERVICE_AWAY_HEARTBEAT_INTERVAL_MS =
2817                "gtalk_heartbeat_ping_interval_ms";  // keep the string backward compatible
2818
2819        /**
2820         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2821         * will reset the heartbeat timer. The active heartbeat should be used when the user is
2822         * actively using the GTalk app.
2823         */
2824        public static final String GTALK_SERVICE_ACTIVE_HEARTBEAT_INTERVAL_MS =
2825                "gtalk_active_heartbeat_ping_interval_ms";
2826
2827        /**
2828         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2829         * will reset the heartbeat timer. The sync heartbeat should be used when the user isn't
2830         * logged into the GTalk app, but auto-sync is enabled.
2831         */
2832        public static final String GTALK_SERVICE_SYNC_HEARTBEAT_INTERVAL_MS =
2833                "gtalk_sync_heartbeat_ping_interval_ms";
2834
2835        /**
2836         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2837         * will reset the heartbeat timer. The no sync heartbeat should be used when the user isn't
2838         * logged into the GTalk app, and auto-sync is not enabled.
2839         */
2840        public static final String GTALK_SERVICE_NOSYNC_HEARTBEAT_INTERVAL_MS =
2841                "gtalk_nosync_heartbeat_ping_interval_ms";
2842
2843        /**
2844         * The maximum heartbeat interval used while on the WIFI network.
2845         */
2846        public static final String GTALK_SERVICE_WIFI_MAX_HEARTBEAT_INTERVAL_MS =
2847                "gtalk_wifi_max_heartbeat_ping_interval_ms";
2848
2849        /**
2850         * How long we wait to receive a heartbeat ping acknowledgement (or another packet)
2851         * from the GTalk server, before deeming the connection dead.
2852         */
2853        public static final String GTALK_SERVICE_HEARTBEAT_ACK_TIMEOUT_MS =
2854                "gtalk_heartbeat_ack_timeout_ms";
2855
2856        /**
2857         * How long after screen is turned off before we consider the user to be idle.
2858         */
2859        public static final String GTALK_SERVICE_IDLE_TIMEOUT_MS =
2860                "gtalk_idle_timeout_ms";
2861
2862        /**
2863         * By default, GTalkService will always connect to the server regardless of the auto-sync
2864         * setting. However, if this parameter is true, then GTalkService will only connect
2865         * if auto-sync is enabled. Using the GTalk app will trigger the connection too.
2866         */
2867        public static final String GTALK_SERVICE_CONNECT_ON_AUTO_SYNC =
2868                "gtalk_connect_on_auto_sync";
2869
2870        /**
2871         * GTalkService holds a wakelock while broadcasting the intent for data message received.
2872         * It then automatically release the wakelock after a timeout. This setting controls what
2873         * the timeout should be.
2874         */
2875        public static final String GTALK_DATA_MESSAGE_WAKELOCK_MS =
2876                "gtalk_data_message_wakelock_ms";
2877
2878        /**
2879         * The socket read timeout used to control how long ssl handshake wait for reads before
2880         * timing out. This is needed so the ssl handshake doesn't hang for a long time in some
2881         * circumstances.
2882         */
2883        public static final String GTALK_SSL_HANDSHAKE_TIMEOUT_MS =
2884                "gtalk_ssl_handshake_timeout_ms";
2885
2886        /**
2887         * Compress the gtalk stream.
2888         */
2889        public static final String GTALK_COMPRESS = "gtalk_compress";
2890
2891        /**
2892         * This is the timeout for which Google Talk will send the message using bareJID. In a
2893         * established chat between two XMPP endpoints, Google Talk uses fullJID in the format
2894         * of user@domain/resource in order to send the message to the specific client. However,
2895         * if Google Talk hasn't received a message from that client after some time, it would
2896         * fall back to use the bareJID, which would broadcast the message to all clients for
2897         * the other user.
2898         */
2899        public static final String GTALK_USE_BARE_JID_TIMEOUT_MS = "gtalk_use_barejid_timeout_ms";
2900
2901        /**
2902         * This is the threshold of retry number when there is an authentication expired failure
2903         * for Google Talk. In some situation, e.g. when a Google Apps account is disabled chat
2904         * service, the connection keeps failing. This threshold controls when we should stop
2905         * the retrying.
2906         */
2907        public static final String GTALK_MAX_RETRIES_FOR_AUTH_EXPIRED =
2908                "gtalk_max_retries_for_auth_expired";
2909
2910        /**
2911         * a boolean setting indicating whether the GTalkService should use RMQ2 protocol or not.
2912         */
2913        public static final String GTALK_USE_RMQ2_PROTOCOL =
2914                "gtalk_use_rmq2";
2915
2916        /**
2917         * a boolean setting indicating whether the GTalkService should support both RMQ and
2918         * RMQ2 protocols. This setting is true for the transitional period when we need to
2919         * support both protocols.
2920         */
2921        public static final String GTALK_SUPPORT_RMQ_AND_RMQ2_PROTOCOLS =
2922                "gtalk_support_rmq_and_rmq2";
2923
2924        /**
2925         * a boolean setting controlling whether the rmq2 protocol will include stream ids in
2926         * the protobufs. This is used for debugging.
2927         */
2928        public static final String GTALK_RMQ2_INCLUDE_STREAM_ID =
2929                "gtalk_rmq2_include_stream_id";
2930
2931        /**
2932         * when receiving a chat message from the server, the message could be an older message
2933         * whose "time sent" is x seconds from now. If x is significant enough, we want to flag
2934         * it so the UI can give it some special treatment when displaying the "time sent" for
2935         * it. This setting is to control what x is.
2936         */
2937        public static final String GTALK_OLD_CHAT_MESSAGE_THRESHOLD_IN_SEC =
2938                "gtalk_old_chat_msg_threshold_in_sec";
2939
2940        /**
2941         * a setting to control the max connection history record GTalkService stores.
2942         */
2943        public static final String GTALK_MAX_CONNECTION_HISTORY_RECORDS =
2944                "gtalk_max_conn_history_records";
2945
2946        /**
2947         * This is gdata url to lookup album and picture info from picasa web.
2948         */
2949        public static final String GTALK_PICASA_ALBUM_URL =
2950                "gtalk_picasa_album_url";
2951
2952        /**
2953         * This is the url to lookup picture info from flickr.
2954         */
2955        public static final String GTALK_FLICKR_PHOTO_INFO_URL =
2956                "gtalk_flickr_photo_info_url";
2957
2958        /**
2959         * This is the url to lookup an actual picture from flickr.
2960         */
2961        public static final String GTALK_FLICKR_PHOTO_URL =
2962                "gtalk_flickr_photo_url";
2963
2964        /**
2965         * This is the gdata url to lookup info on a youtube video.
2966         */
2967        public static final String GTALK_YOUTUBE_VIDEO_URL =
2968                "gtalk_youtube_video_url";
2969
2970        /**
2971         * This is the url for getting the app token for server-to-device push messaging.
2972         */
2973        public static final String PUSH_MESSAGING_REGISTRATION_URL =
2974                "push_messaging_registration_url";
2975
2976	/**
2977	 * Use android://&lt;it&gt; routing infos for Google Sync Server subcriptions.
2978	 */
2979	public static final String GSYNC_USE_RMQ2_ROUTING_INFO = "gsync_use_rmq2_routing_info";
2980
2981        /**
2982         * Enable use of ssl session caching.
2983         * 'db' - save each session in a (per process) database
2984         * 'file' - save each session in a (per process) file
2985         * not set or any other value - normal java in-memory caching
2986         */
2987        public static final String SSL_SESSION_CACHE = "ssl_session_cache";
2988
2989        /**
2990         * How many bytes long a message has to be, in order to be gzipped.
2991         */
2992        public static final String SYNC_MIN_GZIP_BYTES =
2993                "sync_min_gzip_bytes";
2994
2995        /**
2996         * The hash value of the current provisioning settings
2997         */
2998        public static final String PROVISIONING_DIGEST = "digest";
2999
3000        /**
3001         * Provisioning keys to block from server update
3002         */
3003        public static final String PROVISIONING_OVERRIDE = "override";
3004
3005        /**
3006         * "Generic" service name for  authentication requests.
3007         */
3008        public static final String GOOGLE_LOGIN_GENERIC_AUTH_SERVICE
3009                = "google_login_generic_auth_service";
3010
3011        /**
3012         * Frequency in milliseconds at which we should sync the locally installed Vending Machine
3013         * content with the server.
3014         */
3015        public static final String VENDING_SYNC_FREQUENCY_MS = "vending_sync_frequency_ms";
3016
3017        /**
3018         * Support URL that is opened in a browser when user clicks on 'Help and Info' in Vending
3019         * Machine.
3020         */
3021        public static final String VENDING_SUPPORT_URL = "vending_support_url";
3022
3023        /**
3024         * Indicates if Vending Machine requires a SIM to be in the phone to allow a purchase.
3025         *
3026         * true = SIM is required
3027         * false = SIM is not required
3028         */
3029        public static final String VENDING_REQUIRE_SIM_FOR_PURCHASE =
3030                "vending_require_sim_for_purchase";
3031
3032        /**
3033         * Indicates the Vending Machine backup state. It is set if the
3034         * Vending application has been backed up at least once.
3035         */
3036        public static final String VENDING_BACKUP_STATE = "vending_backup_state";
3037
3038        /**
3039         * The current version id of the Vending Machine terms of service.
3040         */
3041        public static final String VENDING_TOS_VERSION = "vending_tos_version";
3042
3043        /**
3044         * URL that points to the terms of service for Vending Machine.
3045         */
3046        public static final String VENDING_TOS_URL = "vending_tos_url";
3047
3048        /**
3049         * URL to navigate to in browser (not Market) when the terms of service
3050         * for Vending Machine could not be accessed due to bad network
3051         * connection.
3052         */
3053        public static final String VENDING_TOS_MISSING_URL = "vending_tos_missing_url";
3054
3055        /**
3056         * Whether to use sierraqa instead of sierra tokens for the purchase flow in
3057         * Vending Machine.
3058         *
3059         * true = use sierraqa
3060         * false = use sierra (default)
3061         */
3062        public static final String VENDING_USE_CHECKOUT_QA_SERVICE =
3063                "vending_use_checkout_qa_service";
3064
3065        /**
3066         * Default value to use for all/free/priced filter in Market.
3067         * Valid values: ALL, FREE, PAID (case insensitive)
3068         */
3069        public static final String VENDING_DEFAULT_FILTER = "vending_default_filter";
3070        /**
3071         * Ranking type value to use for the first category tab (currently popular)
3072         */
3073        public static final String VENDING_TAB_1_RANKING_TYPE = "vending_tab_1_ranking_type";
3074
3075        /**
3076         * Title string to use for first category tab.
3077         */
3078        public static final String VENDING_TAB_1_TITLE = "vending_tab_1_title";
3079
3080        /**
3081         * Ranking type value to use for the second category tab (currently newest)
3082         */
3083        public static final String VENDING_TAB_2_RANKING_TYPE = "vending_tab_2_ranking_type";
3084
3085        /**
3086         * Title string to use for second category tab.
3087         */
3088        public static final String VENDING_TAB_2_TITLE = "vending_tab_2_title";
3089
3090        /**
3091         * Frequency in milliseconds at which we should request MCS heartbeats
3092         * from the Vending Machine client.
3093         */
3094        public static final String VENDING_HEARTBEAT_FREQUENCY_MS =
3095                "vending_heartbeat_frequency_ms";
3096
3097        /**
3098         * Frequency in milliseconds at which we should resend pending download
3099         * requests to the API Server from the Vending Machine client.
3100         */
3101        public static final String VENDING_PENDING_DOWNLOAD_RESEND_FREQUENCY_MS =
3102                "vending_pd_resend_frequency_ms";
3103
3104        /**
3105         * Size of buffer in bytes for Vending to use when reading cache files.
3106         */
3107        public static final String VENDING_DISK_INPUT_BUFFER_BYTES =
3108                "vending_disk_input_buffer_bytes";
3109
3110        /**
3111         * Size of buffer in bytes for Vending to use when writing cache files.
3112         */
3113        public static final String VENDING_DISK_OUTPUT_BUFFER_BYTES =
3114                "vending_disk_output_buffer_bytes";
3115
3116        /**
3117         * Frequency in milliseconds at which we should cycle through the promoted applications
3118         * on the home screen or the categories page.
3119         */
3120        public static final String VENDING_PROMO_REFRESH_FREQUENCY_MS =
3121                "vending_promo_refresh_freq_ms";
3122
3123        /**
3124         * Frequency in milliseconds when we should refresh the provisioning information from
3125         * the carrier backend.
3126         */
3127        public static final String VENDING_CARRIER_PROVISIONING_REFRESH_FREQUENCY_MS =
3128                "vending_carrier_ref_freq_ms";
3129
3130        /**
3131         * URL that points to the legal terms of service to display in Settings.
3132         * <p>
3133         * This should be a https URL. For a pretty user-friendly URL, use
3134         * {@link #SETTINGS_TOS_PRETTY_URL}.
3135         */
3136        public static final String SETTINGS_TOS_URL = "settings_tos_url";
3137
3138        /**
3139         * URL that points to the legal terms of service to display in Settings.
3140         * <p>
3141         * This should be a pretty http URL. For the URL the device will access
3142         * via Settings, use {@link #SETTINGS_TOS_URL}.
3143         */
3144        public static final String SETTINGS_TOS_PRETTY_URL = "settings_tos_pretty_url";
3145
3146        /**
3147         * URL that points to the contributors to display in Settings.
3148         * <p>
3149         * This should be a https URL. For a pretty user-friendly URL, use
3150         * {@link #SETTINGS_CONTRIBUTORS_PRETTY_URL}.
3151         */
3152        public static final String SETTINGS_CONTRIBUTORS_URL = "settings_contributors_url";
3153
3154        /**
3155         * URL that points to the contributors to display in Settings.
3156         * <p>
3157         * This should be a pretty http URL. For the URL the device will access
3158         * via Settings, use {@link #SETTINGS_CONTRIBUTORS_URL}.
3159         */
3160        public static final String SETTINGS_CONTRIBUTORS_PRETTY_URL =
3161                "settings_contributors_pretty_url";
3162
3163        /**
3164         * URL that points to the Terms Of Service for the device.
3165         * <p>
3166         * This should be a pretty http URL.
3167         */
3168        public static final String SETUP_GOOGLE_TOS_URL = "setup_google_tos_url";
3169
3170        /**
3171         * URL that points to the Android privacy policy for the device.
3172         * <p>
3173         * This should be a pretty http URL.
3174         */
3175        public static final String SETUP_ANDROID_PRIVACY_URL = "setup_android_privacy_url";
3176
3177        /**
3178         * URL that points to the Google privacy policy for the device.
3179         * <p>
3180         * This should be a pretty http URL.
3181         */
3182        public static final String SETUP_GOOGLE_PRIVACY_URL = "setup_google_privacy_url";
3183
3184        /**
3185         * Request an MSISDN token for various Google services.
3186         */
3187        public static final String USE_MSISDN_TOKEN = "use_msisdn_token";
3188
3189        /**
3190         * RSA public key used to encrypt passwords stored in the database.
3191         */
3192        public static final String GLS_PUBLIC_KEY = "google_login_public_key";
3193
3194        /**
3195         * Only check parental control status if this is set to "true".
3196         */
3197        public static final String PARENTAL_CONTROL_CHECK_ENABLED =
3198                "parental_control_check_enabled";
3199
3200        /**
3201         * The list of applications we need to block if parental control is
3202         * enabled.
3203         */
3204        public static final String PARENTAL_CONTROL_APPS_LIST =
3205                "parental_control_apps_list";
3206
3207        /**
3208         * Duration in which parental control status is valid.
3209         */
3210        public static final String PARENTAL_CONTROL_TIMEOUT_IN_MS =
3211                "parental_control_timeout_in_ms";
3212
3213        /**
3214         * When parental control is off, we expect to get this string from the
3215         * litmus url.
3216         */
3217        public static final String PARENTAL_CONTROL_EXPECTED_RESPONSE =
3218                "parental_control_expected_response";
3219
3220        /**
3221         * When the litmus url returns a 302, declare parental control to be on
3222         * only if the redirect url matches this regular expression.
3223         */
3224        public static final String PARENTAL_CONTROL_REDIRECT_REGEX =
3225                "parental_control_redirect_regex";
3226
3227        /**
3228         * Threshold for the amount of change in disk free space required to report the amount of
3229         * free space. Used to prevent spamming the logs when the disk free space isn't changing
3230         * frequently.
3231         */
3232        public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD =
3233                "disk_free_change_reporting_threshold";
3234
3235        /**
3236         * Prefix for new Google services published by the checkin
3237         * server.
3238         */
3239        public static final String GOOGLE_SERVICES_PREFIX
3240                = "google_services:";
3241
3242        /**
3243         * The maximum reconnect delay for short network outages or when the network is suspended
3244         * due to phone use.
3245         */
3246        public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
3247                "sync_max_retry_delay_in_seconds";
3248
3249        /**
3250         * Minimum percentage of free storage on the device that is used to determine if
3251         * the device is running low on storage.
3252         * Say this value is set to 10, the device is considered running low on storage
3253         * if 90% or more of the device storage is filled up.
3254         */
3255        public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE =
3256                "sys_storage_threshold_percentage";
3257
3258        /**
3259         * The interval in minutes after which the amount of free storage left on the
3260         * device is logged to the event log
3261         */
3262        public static final String SYS_FREE_STORAGE_LOG_INTERVAL =
3263                "sys_free_storage_log_interval";
3264
3265        /**
3266         * The interval in milliseconds at which to check the number of SMS sent
3267         * out without asking for use permit, to limit the un-authorized SMS
3268         * usage.
3269         */
3270        public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
3271                "sms_outgoing_check_interval_ms";
3272
3273        /**
3274         * The number of outgoing SMS sent without asking for user permit
3275         * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
3276         */
3277        public static final String SMS_OUTGOING_CEHCK_MAX_COUNT =
3278                "sms_outgoing_check_max_count";
3279
3280        /**
3281         * The interval in milliseconds at which to check packet counts on the
3282         * mobile data interface when screen is on, to detect possible data
3283         * connection problems.
3284         */
3285        public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
3286                "pdp_watchdog_poll_interval_ms";
3287
3288        /**
3289         * The interval in milliseconds at which to check packet counts on the
3290         * mobile data interface when screen is off, to detect possible data
3291         * connection problems.
3292         */
3293        public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
3294                "pdp_watchdog_long_poll_interval_ms";
3295
3296        /**
3297         * The interval in milliseconds at which to check packet counts on the
3298         * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
3299         * outgoing packets has been reached without incoming packets.
3300         */
3301        public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
3302                "pdp_watchdog_error_poll_interval_ms";
3303
3304        /**
3305         * The number of outgoing packets sent without seeing an incoming packet
3306         * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
3307         * device is logged to the event log
3308         */
3309        public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
3310                "pdp_watchdog_trigger_packet_count";
3311
3312        /**
3313         * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
3314         * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
3315         * attempting data connection recovery.
3316         */
3317        public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
3318                "pdp_watchdog_error_poll_count";
3319
3320        /**
3321         * The number of failed PDP reset attempts before moving to something more
3322         * drastic: re-registering to the network.
3323         */
3324        public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
3325                "pdp_watchdog_max_pdp_reset_fail_count";
3326
3327        /**
3328         * Address to ping as a last sanity check before attempting any recovery.
3329         * Unset or set to "0.0.0.0" to skip this check.
3330         */
3331        public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";
3332
3333        /**
3334         * The "-w deadline" parameter for the ping, ie, the max time in
3335         * seconds to spend pinging.
3336         */
3337        public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";
3338
3339        /**
3340         * The interval in milliseconds at which to check gprs registration
3341         * after the first registration mismatch of gprs and voice service,
3342         * to detect possible data network registration problems.
3343         *
3344         */
3345        public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
3346                "gprs_register_check_period_ms";
3347
3348        /**
3349         * The interval in milliseconds after which Wi-Fi is considered idle.
3350         * When idle, it is possible for the device to be switched from Wi-Fi to
3351         * the mobile data network.
3352         */
3353        public static final String WIFI_IDLE_MS = "wifi_idle_ms";
3354
3355        /**
3356         * Screen timeout in milliseconds corresponding to the
3357         * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest
3358         * possible screen timeout behavior.)
3359         */
3360        public static final String SHORT_KEYLIGHT_DELAY_MS =
3361                "short_keylight_delay_ms";
3362
3363        /**
3364         * List of test suites (local disk filename) for the automatic instrumentation test runner.
3365         * The file format is similar to automated_suites.xml, see AutoTesterService.
3366         * If this setting is missing or empty, the automatic test runner will not start.
3367         */
3368        public static final String AUTOTEST_SUITES_FILE = "autotest_suites_file";
3369
3370        /**
3371         * Interval between synchronous checkins forced by the automatic test runner.
3372         * If you set this to a value smaller than CHECKIN_INTERVAL, then the test runner's
3373         * frequent checkins will prevent asynchronous background checkins from interfering
3374         * with any performance measurements.
3375         */
3376        public static final String AUTOTEST_CHECKIN_SECONDS = "autotest_checkin_seconds";
3377
3378        /**
3379         * Interval between reboots forced by the automatic test runner.
3380         */
3381        public static final String AUTOTEST_REBOOT_SECONDS = "autotest_reboot_seconds";
3382
3383
3384        /**
3385         * Threshold values for the duration and level of a discharge cycle, under
3386         * which we log discharge cycle info.
3387         */
3388        public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD =
3389                "battery_discharge_duration_threshold";
3390        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
3391
3392        /**
3393         * An email address that anr bugreports should be sent to.
3394         */
3395        public static final String ANR_BUGREPORT_RECIPIENT = "anr_bugreport_recipient";
3396
3397        /**
3398         * Flag for allowing service provider to use location information to improve products and
3399         * services.
3400         * Type: int ( 0 = disallow, 1 = allow )
3401         * @deprecated
3402         */
3403        public static final String USE_LOCATION_FOR_SERVICES = "use_location";
3404
3405        /**
3406         * The length of the calendar sync window into the future.
3407         * This specifies the number of days into the future for the sliding window sync.
3408         * Setting this to zero will disable sliding sync.
3409         */
3410        public static final String GOOGLE_CALENDAR_SYNC_WINDOW_DAYS =
3411                "google_calendar_sync_window_days";
3412
3413        /**
3414         * How often to update the calendar sync window.
3415         * The window will be advanced every n days.
3416         */
3417        public static final String GOOGLE_CALENDAR_SYNC_WINDOW_UPDATE_DAYS =
3418                "google_calendar_sync_window_update_days";
3419
3420        /**
3421         * @deprecated
3422         * @hide
3423         */
3424        @Deprecated  // Obviated by NameValueCache: just fetch the value directly.
3425        public static class QueryMap extends ContentQueryMap {
3426
3427            public QueryMap(ContentResolver contentResolver, Cursor cursor, boolean keepUpdated,
3428                    Handler handlerForUpdateNotifications) {
3429                super(cursor, NAME, keepUpdated, handlerForUpdateNotifications);
3430            }
3431
3432            public QueryMap(ContentResolver contentResolver, boolean keepUpdated,
3433                    Handler handlerForUpdateNotifications) {
3434                this(contentResolver,
3435                        contentResolver.query(CONTENT_URI, null, null, null, null),
3436                        keepUpdated, handlerForUpdateNotifications);
3437            }
3438
3439            public String getString(String name) {
3440                ContentValues cv = getValues(name);
3441                if (cv == null) return null;
3442                return cv.getAsString(VALUE);
3443            }
3444        }
3445
3446    }
3447
3448    /**
3449     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
3450     * Intent URL, allowing it to be either a web page or a particular
3451     * application activity.
3452     *
3453     * @hide
3454     */
3455    public static final class Bookmarks implements BaseColumns
3456    {
3457        private static final String TAG = "Bookmarks";
3458
3459        /**
3460         * The content:// style URL for this table
3461         */
3462        public static final Uri CONTENT_URI =
3463            Uri.parse("content://" + AUTHORITY + "/bookmarks");
3464
3465        /**
3466         * The row ID.
3467         * <p>Type: INTEGER</p>
3468         */
3469        public static final String ID = "_id";
3470
3471        /**
3472         * Descriptive name of the bookmark that can be displayed to the user.
3473         * If this is empty, the title should be resolved at display time (use
3474         * {@link #getTitle(Context, Cursor)} any time you want to display the
3475         * title of a bookmark.)
3476         * <P>
3477         * Type: TEXT
3478         * </P>
3479         */
3480        public static final String TITLE = "title";
3481
3482        /**
3483         * Arbitrary string (displayed to the user) that allows bookmarks to be
3484         * organized into categories.  There are some special names for
3485         * standard folders, which all start with '@'.  The label displayed for
3486         * the folder changes with the locale (via {@link #getLabelForFolder}) but
3487         * the folder name does not change so you can consistently query for
3488         * the folder regardless of the current locale.
3489         *
3490         * <P>Type: TEXT</P>
3491         *
3492         */
3493        public static final String FOLDER = "folder";
3494
3495        /**
3496         * The Intent URL of the bookmark, describing what it points to.  This
3497         * value is given to {@link android.content.Intent#getIntent} to create
3498         * an Intent that can be launched.
3499         * <P>Type: TEXT</P>
3500         */
3501        public static final String INTENT = "intent";
3502
3503        /**
3504         * Optional shortcut character associated with this bookmark.
3505         * <P>Type: INTEGER</P>
3506         */
3507        public static final String SHORTCUT = "shortcut";
3508
3509        /**
3510         * The order in which the bookmark should be displayed
3511         * <P>Type: INTEGER</P>
3512         */
3513        public static final String ORDERING = "ordering";
3514
3515        private static final String[] sIntentProjection = { INTENT };
3516        private static final String[] sShortcutProjection = { ID, SHORTCUT };
3517        private static final String sShortcutSelection = SHORTCUT + "=?";
3518
3519        /**
3520         * Convenience function to retrieve the bookmarked Intent for a
3521         * particular shortcut key.
3522         *
3523         * @param cr The ContentResolver to query.
3524         * @param shortcut The shortcut key.
3525         *
3526         * @return Intent The bookmarked URL, or null if there is no bookmark
3527         *         matching the given shortcut.
3528         */
3529        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
3530        {
3531            Intent intent = null;
3532
3533            Cursor c = cr.query(CONTENT_URI,
3534                    sIntentProjection, sShortcutSelection,
3535                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
3536            // Keep trying until we find a valid shortcut
3537            try {
3538                while (intent == null && c.moveToNext()) {
3539                    try {
3540                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
3541                        intent = Intent.getIntent(intentURI);
3542                    } catch (java.net.URISyntaxException e) {
3543                        // The stored URL is bad...  ignore it.
3544                    } catch (IllegalArgumentException e) {
3545                        // Column not found
3546                        Log.e(TAG, "Intent column not found", e);
3547                    }
3548                }
3549            } finally {
3550                if (c != null) c.close();
3551            }
3552
3553            return intent;
3554        }
3555
3556        /**
3557         * Add a new bookmark to the system.
3558         *
3559         * @param cr The ContentResolver to query.
3560         * @param intent The desired target of the bookmark.
3561         * @param title Bookmark title that is shown to the user; null if none
3562         *            or it should be resolved to the intent's title.
3563         * @param folder Folder in which to place the bookmark; null if none.
3564         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
3565         *            this is non-zero and there is an existing bookmark entry
3566         *            with this same shortcut, then that existing shortcut is
3567         *            cleared (the bookmark is not removed).
3568         * @return The unique content URL for the new bookmark entry.
3569         */
3570        public static Uri add(ContentResolver cr,
3571                                           Intent intent,
3572                                           String title,
3573                                           String folder,
3574                                           char shortcut,
3575                                           int ordering)
3576        {
3577            // If a shortcut is supplied, and it is already defined for
3578            // another bookmark, then remove the old definition.
3579            if (shortcut != 0) {
3580                Cursor c = cr.query(CONTENT_URI,
3581                        sShortcutProjection, sShortcutSelection,
3582                        new String[] { String.valueOf((int) shortcut) }, null);
3583                try {
3584                    if (c.moveToFirst()) {
3585                        while (c.getCount() > 0) {
3586                            if (!c.deleteRow()) {
3587                                Log.w(TAG, "Could not delete existing shortcut row");
3588                            }
3589                        }
3590                    }
3591                } finally {
3592                    if (c != null) c.close();
3593                }
3594            }
3595
3596            ContentValues values = new ContentValues();
3597            if (title != null) values.put(TITLE, title);
3598            if (folder != null) values.put(FOLDER, folder);
3599            values.put(INTENT, intent.toURI());
3600            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
3601            values.put(ORDERING, ordering);
3602            return cr.insert(CONTENT_URI, values);
3603        }
3604
3605        /**
3606         * Return the folder name as it should be displayed to the user.  This
3607         * takes care of localizing special folders.
3608         *
3609         * @param r Resources object for current locale; only need access to
3610         *          system resources.
3611         * @param folder The value found in the {@link #FOLDER} column.
3612         *
3613         * @return CharSequence The label for this folder that should be shown
3614         *         to the user.
3615         */
3616        public static CharSequence getLabelForFolder(Resources r, String folder) {
3617            return folder;
3618        }
3619
3620        /**
3621         * Return the title as it should be displayed to the user. This takes
3622         * care of localizing bookmarks that point to activities.
3623         *
3624         * @param context A context.
3625         * @param cursor A cursor pointing to the row whose title should be
3626         *        returned. The cursor must contain at least the {@link #TITLE}
3627         *        and {@link #INTENT} columns.
3628         * @return A title that is localized and can be displayed to the user,
3629         *         or the empty string if one could not be found.
3630         */
3631        public static CharSequence getTitle(Context context, Cursor cursor) {
3632            int titleColumn = cursor.getColumnIndex(TITLE);
3633            int intentColumn = cursor.getColumnIndex(INTENT);
3634            if (titleColumn == -1 || intentColumn == -1) {
3635                throw new IllegalArgumentException(
3636                        "The cursor must contain the TITLE and INTENT columns.");
3637            }
3638
3639            String title = cursor.getString(titleColumn);
3640            if (!TextUtils.isEmpty(title)) {
3641                return title;
3642            }
3643
3644            String intentUri = cursor.getString(intentColumn);
3645            if (TextUtils.isEmpty(intentUri)) {
3646                return "";
3647            }
3648
3649            Intent intent;
3650            try {
3651                intent = Intent.getIntent(intentUri);
3652            } catch (URISyntaxException e) {
3653                return "";
3654            }
3655
3656            PackageManager packageManager = context.getPackageManager();
3657            ResolveInfo info = packageManager.resolveActivity(intent, 0);
3658            return info != null ? info.loadLabel(packageManager) : "";
3659        }
3660    }
3661
3662    /**
3663     * Returns the device ID that we should use when connecting to the mobile gtalk server.
3664     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
3665     * from the GoogleLoginService.
3666     *
3667     * @param androidId The Android ID for this device.
3668     * @return The device ID that should be used when connecting to the mobile gtalk server.
3669     * @hide
3670     */
3671    public static String getGTalkDeviceId(long androidId) {
3672        return "android-" + Long.toHexString(androidId);
3673    }
3674}
3675