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