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