Settings.java revision dc3494e3d8e17aeb0dbbe41953a5ef763d95ff78
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.w(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.w(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         * SCREEN_BRIGHTNESS_MODE value for manual mode.
1085         * @hide
1086         */
1087        public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
1088
1089        /**
1090         * SCREEN_BRIGHTNESS_MODE value for manual mode.
1091         * @hide
1092         */
1093        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
1094
1095        /**
1096         * Control whether the process CPU usage meter should be shown.
1097         */
1098        public static final String SHOW_PROCESSES = "show_processes";
1099
1100        /**
1101         * If 1, the activity manager will aggressively finish activities and
1102         * processes as soon as they are no longer needed.  If 0, the normal
1103         * extended lifetime is used.
1104         */
1105        public static final String ALWAYS_FINISH_ACTIVITIES =
1106                "always_finish_activities";
1107
1108
1109        /**
1110         * Ringer mode. This is used internally, changing this value will not
1111         * change the ringer mode. See AudioManager.
1112         */
1113        public static final String MODE_RINGER = "mode_ringer";
1114
1115        /**
1116         * Determines which streams are affected by ringer mode changes. The
1117         * stream type's bit should be set to 1 if it should be muted when going
1118         * into an inaudible ringer mode.
1119         */
1120        public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
1121
1122         /**
1123          * Determines which streams are affected by mute. The
1124          * stream type's bit should be set to 1 if it should be muted when a mute request
1125          * is received.
1126          */
1127         public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
1128
1129        /**
1130         * Whether vibrate is on for different events. This is used internally,
1131         * changing this value will not change the vibrate. See AudioManager.
1132         */
1133        public static final String VIBRATE_ON = "vibrate_on";
1134
1135        /**
1136         * Ringer volume. This is used internally, changing this value will not
1137         * change the volume. See AudioManager.
1138         */
1139        public static final String VOLUME_RING = "volume_ring";
1140
1141        /**
1142         * System/notifications volume. This is used internally, changing this
1143         * value will not change the volume. See AudioManager.
1144         */
1145        public static final String VOLUME_SYSTEM = "volume_system";
1146
1147        /**
1148         * Voice call volume. This is used internally, changing this value will
1149         * not change the volume. See AudioManager.
1150         */
1151        public static final String VOLUME_VOICE = "volume_voice";
1152
1153        /**
1154         * Music/media/gaming volume. This is used internally, changing this
1155         * value will not change the volume. See AudioManager.
1156         */
1157        public static final String VOLUME_MUSIC = "volume_music";
1158
1159        /**
1160         * Alarm volume. This is used internally, changing this
1161         * value will not change the volume. See AudioManager.
1162         */
1163        public static final String VOLUME_ALARM = "volume_alarm";
1164
1165        /**
1166         * Notification volume. This is used internally, changing this
1167         * value will not change the volume. See AudioManager.
1168         */
1169        public static final String VOLUME_NOTIFICATION = "volume_notification";
1170
1171        /**
1172         * Whether the notifications should use the ring volume (value of 1) or
1173         * a separate notification volume (value of 0). In most cases, users
1174         * will have this enabled so the notification and ringer volumes will be
1175         * the same. However, power users can disable this and use the separate
1176         * notification volume control.
1177         * <p>
1178         * Note: This is a one-off setting that will be removed in the future
1179         * when there is profile support. For this reason, it is kept hidden
1180         * from the public APIs.
1181         *
1182         * @hide
1183         */
1184        public static final String NOTIFICATIONS_USE_RING_VOLUME =
1185            "notifications_use_ring_volume";
1186
1187        /**
1188         * The mapping of stream type (integer) to its setting.
1189         */
1190        public static final String[] VOLUME_SETTINGS = {
1191            VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
1192            VOLUME_ALARM, VOLUME_NOTIFICATION
1193        };
1194
1195        /**
1196         * Appended to various volume related settings to record the previous
1197         * values before they the settings were affected by a silent/vibrate
1198         * ringer mode change.
1199         */
1200        public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
1201
1202        /**
1203         * Persistent store for the system-wide default ringtone URI.
1204         * <p>
1205         * If you need to play the default ringtone at any given time, it is recommended
1206         * you give {@link #DEFAULT_RINGTONE_URI} to the media player.  It will resolve
1207         * to the set default ringtone at the time of playing.
1208         *
1209         * @see #DEFAULT_RINGTONE_URI
1210         */
1211        public static final String RINGTONE = "ringtone";
1212
1213        /**
1214         * A {@link Uri} that will point to the current default ringtone at any
1215         * given time.
1216         * <p>
1217         * If the current default ringtone is in the DRM provider and the caller
1218         * does not have permission, the exception will be a
1219         * FileNotFoundException.
1220         */
1221        public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
1222
1223        /**
1224         * Persistent store for the system-wide default notification sound.
1225         *
1226         * @see #RINGTONE
1227         * @see #DEFAULT_NOTIFICATION_URI
1228         */
1229        public static final String NOTIFICATION_SOUND = "notification_sound";
1230
1231        /**
1232         * A {@link Uri} that will point to the current default notification
1233         * sound at any given time.
1234         *
1235         * @see #DEFAULT_RINGTONE_URI
1236         */
1237        public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
1238
1239        /**
1240         * Persistent store for the system-wide default alarm alert.
1241         *
1242         * @see #RINGTONE
1243         * @see #DEFAULT_ALARM_ALERT_URI
1244         */
1245        public static final String ALARM_ALERT = "alarm_alert";
1246
1247        /**
1248         * A {@link Uri} that will point to the current default alarm alert at
1249         * any given time.
1250         *
1251         * @see #DEFAULT_ALARM_ALERT_URI
1252         */
1253        public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
1254
1255        /**
1256         * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
1257         */
1258        public static final String TEXT_AUTO_REPLACE = "auto_replace";
1259
1260        /**
1261         * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
1262         */
1263        public static final String TEXT_AUTO_CAPS = "auto_caps";
1264
1265        /**
1266         * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
1267         * feature converts two spaces to a "." and space.
1268         */
1269        public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
1270
1271        /**
1272         * Setting to showing password characters in text editors. 1 = On, 0 = Off
1273         */
1274        public static final String TEXT_SHOW_PASSWORD = "show_password";
1275
1276        public static final String SHOW_GTALK_SERVICE_STATUS =
1277                "SHOW_GTALK_SERVICE_STATUS";
1278
1279        /**
1280         * Name of activity to use for wallpaper on the home screen.
1281         */
1282        public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
1283
1284        /**
1285         * Value to specify if the user prefers the date, time and time zone
1286         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
1287         */
1288        public static final String AUTO_TIME = "auto_time";
1289
1290        /**
1291         * Display times as 12 or 24 hours
1292         *   12
1293         *   24
1294         */
1295        public static final String TIME_12_24 = "time_12_24";
1296
1297        /**
1298         * Date format string
1299         *   mm/dd/yyyy
1300         *   dd/mm/yyyy
1301         *   yyyy/mm/dd
1302         */
1303        public static final String DATE_FORMAT = "date_format";
1304
1305        /**
1306         * Whether the setup wizard has been run before (on first boot), or if
1307         * it still needs to be run.
1308         *
1309         * nonzero = it has been run in the past
1310         * 0 = it has not been run in the past
1311         */
1312        public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
1313
1314        /**
1315         * Scaling factor for normal window animations. Setting to 0 will disable window
1316         * animations.
1317         */
1318        public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
1319
1320        /**
1321         * Scaling factor for activity transition animations. Setting to 0 will disable window
1322         * animations.
1323         */
1324        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
1325
1326        /**
1327         * Scaling factor for normal window animations. Setting to 0 will disable window
1328         * animations.
1329         * @hide
1330         */
1331        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
1332
1333        /**
1334         * Control whether the accelerometer will be used to change screen
1335         * orientation.  If 0, it will not be used unless explicitly requested
1336         * by the application; if 1, it will be used by default unless explicitly
1337         * disabled by the application.
1338         */
1339        public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
1340
1341        /**
1342         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
1343         * boolean (1 or 0).
1344         */
1345        public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
1346
1347        /**
1348         * CDMA only settings
1349         * DTMF tone type played by the dialer when dialing.
1350         *                 0 = Normal
1351         *                 1 = Long
1352         * @hide
1353         */
1354        public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
1355
1356        /**
1357         * CDMA only settings
1358         * Emergency Tone  0 = Off
1359         *                 1 = Alert
1360         *                 2 = Vibrate
1361         * @hide
1362         */
1363        public static final String EMERGENCY_TONE = "emergency_tone";
1364
1365        /**
1366         * CDMA only settings
1367         * Whether the auto retry is enabled. The value is
1368         * boolean (1 or 0).
1369         * @hide
1370         */
1371        public static final String CALL_AUTO_RETRY = "call_auto_retry";
1372
1373        /**
1374         * Whether the hearing aid is enabled. The value is
1375         * boolean (1 or 0).
1376         * @hide
1377         */
1378        public static final String HEARING_AID = "hearing_aid";
1379
1380        /**
1381         * CDMA only settings
1382         * TTY Mode
1383         * 0 = OFF
1384         * 1 = FULL
1385         * 2 = VCO
1386         * 3 = HCO
1387         * @hide
1388         */
1389        public static final String TTY_MODE = "tty_mode";
1390
1391        /**
1392         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
1393         * boolean (1 or 0).
1394         */
1395        public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
1396
1397        /**
1398         * Whether the haptic feedback (long presses, ...) are enabled. The value is
1399         * boolean (1 or 0).
1400         */
1401        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
1402
1403        /**
1404         * Whether live web suggestions while the user types into search dialogs are
1405         * enabled. Browsers and other search UIs should respect this, as it allows
1406         * a user to avoid sending partial queries to a search engine, if it poses
1407         * any privacy concern. The value is boolean (1 or 0).
1408         */
1409        public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
1410
1411        /**
1412         * Settings to backup. This is here so that it's in the same place as the settings
1413         * keys and easy to update.
1414         * @hide
1415         */
1416        public static final String[] SETTINGS_TO_BACKUP = {
1417            STAY_ON_WHILE_PLUGGED_IN,
1418            END_BUTTON_BEHAVIOR,
1419            WIFI_SLEEP_POLICY,
1420            WIFI_USE_STATIC_IP,
1421            WIFI_STATIC_IP,
1422            WIFI_STATIC_GATEWAY,
1423            WIFI_STATIC_NETMASK,
1424            WIFI_STATIC_DNS1,
1425            WIFI_STATIC_DNS2,
1426            BLUETOOTH_DISCOVERABILITY,
1427            BLUETOOTH_DISCOVERABILITY_TIMEOUT,
1428            DIM_SCREEN,
1429            SCREEN_OFF_TIMEOUT,
1430            SCREEN_BRIGHTNESS,
1431            SCREEN_BRIGHTNESS_MODE,
1432            VIBRATE_ON,
1433            NOTIFICATIONS_USE_RING_VOLUME,
1434            MODE_RINGER,
1435            MODE_RINGER_STREAMS_AFFECTED,
1436            MUTE_STREAMS_AFFECTED,
1437            VOLUME_VOICE,
1438            VOLUME_SYSTEM,
1439            VOLUME_RING,
1440            VOLUME_MUSIC,
1441            VOLUME_ALARM,
1442            VOLUME_NOTIFICATION,
1443            VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE,
1444            VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE,
1445            VOLUME_RING + APPEND_FOR_LAST_AUDIBLE,
1446            VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE,
1447            VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
1448            VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
1449            TEXT_AUTO_REPLACE,
1450            TEXT_AUTO_CAPS,
1451            TEXT_AUTO_PUNCTUATE,
1452            TEXT_SHOW_PASSWORD,
1453            AUTO_TIME,
1454            TIME_12_24,
1455            DATE_FORMAT,
1456            ACCELEROMETER_ROTATION,
1457            DTMF_TONE_WHEN_DIALING,
1458            DTMF_TONE_TYPE_WHEN_DIALING,
1459            EMERGENCY_TONE,
1460            CALL_AUTO_RETRY,
1461            HEARING_AID,
1462            TTY_MODE,
1463            SOUND_EFFECTS_ENABLED,
1464            HAPTIC_FEEDBACK_ENABLED,
1465            SHOW_WEB_SUGGESTIONS
1466        };
1467
1468        // Settings moved to Settings.Secure
1469
1470        /**
1471         * @deprecated Use {@link android.provider.Settings.Secure#ADB_ENABLED}
1472         * instead
1473         */
1474        @Deprecated
1475        public static final String ADB_ENABLED = Secure.ADB_ENABLED;
1476
1477        /**
1478         * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
1479         */
1480        @Deprecated
1481        public static final String ANDROID_ID = Secure.ANDROID_ID;
1482
1483        /**
1484         * @deprecated Use {@link android.provider.Settings.Secure#BLUETOOTH_ON} instead
1485         */
1486        @Deprecated
1487        public static final String BLUETOOTH_ON = Secure.BLUETOOTH_ON;
1488
1489        /**
1490         * @deprecated Use {@link android.provider.Settings.Secure#DATA_ROAMING} instead
1491         */
1492        @Deprecated
1493        public static final String DATA_ROAMING = Secure.DATA_ROAMING;
1494
1495        /**
1496         * @deprecated Use {@link android.provider.Settings.Secure#DEVICE_PROVISIONED} instead
1497         */
1498        @Deprecated
1499        public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED;
1500
1501        /**
1502         * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead
1503         */
1504        @Deprecated
1505        public static final String HTTP_PROXY = Secure.HTTP_PROXY;
1506
1507        /**
1508         * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
1509         */
1510        @Deprecated
1511        public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
1512
1513        /**
1514         * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
1515         * instead
1516         */
1517        @Deprecated
1518        public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
1519
1520        /**
1521         * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
1522         */
1523        @Deprecated
1524        public static final String LOGGING_ID = Secure.LOGGING_ID;
1525
1526        /**
1527         * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead
1528         */
1529        @Deprecated
1530        public static final String NETWORK_PREFERENCE = Secure.NETWORK_PREFERENCE;
1531
1532        /**
1533         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
1534         * instead
1535         */
1536        @Deprecated
1537        public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
1538
1539        /**
1540         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
1541         * instead
1542         */
1543        @Deprecated
1544        public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
1545
1546        /**
1547         * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
1548         * instead
1549         */
1550        @Deprecated
1551        public static final String PARENTAL_CONTROL_REDIRECT_URL =
1552            Secure.PARENTAL_CONTROL_REDIRECT_URL;
1553
1554        /**
1555         * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
1556         */
1557        @Deprecated
1558        public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
1559
1560        /**
1561         * @deprecated Use {@link android.provider.Settings.Secure#USB_MASS_STORAGE_ENABLED} instead
1562         */
1563        @Deprecated
1564        public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED;
1565
1566        /**
1567         * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead
1568         */
1569        @Deprecated
1570        public static final String USE_GOOGLE_MAIL = Secure.USE_GOOGLE_MAIL;
1571
1572       /**
1573         * @deprecated Use
1574         * {@link android.provider.Settings.Secure#WIFI_MAX_DHCP_RETRY_COUNT} instead
1575         */
1576        @Deprecated
1577        public static final String WIFI_MAX_DHCP_RETRY_COUNT = Secure.WIFI_MAX_DHCP_RETRY_COUNT;
1578
1579        /**
1580         * @deprecated Use
1581         * {@link android.provider.Settings.Secure#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
1582         */
1583        @Deprecated
1584        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
1585                Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
1586
1587        /**
1588         * @deprecated Use
1589         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
1590         */
1591        @Deprecated
1592        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
1593            Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
1594
1595        /**
1596         * @deprecated Use
1597         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
1598         */
1599        @Deprecated
1600        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
1601            Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
1602
1603        /**
1604         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT}
1605         * instead
1606         */
1607        @Deprecated
1608        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Secure.WIFI_NUM_OPEN_NETWORKS_KEPT;
1609
1610        /**
1611         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_ON} instead
1612         */
1613        @Deprecated
1614        public static final String WIFI_ON = Secure.WIFI_ON;
1615
1616        /**
1617         * @deprecated Use
1618         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
1619         * instead
1620         */
1621        @Deprecated
1622        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
1623                Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
1624
1625        /**
1626         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
1627         */
1628        @Deprecated
1629        public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
1630
1631        /**
1632         * @deprecated Use
1633         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
1634         */
1635        @Deprecated
1636        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
1637                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
1638
1639        /**
1640         * @deprecated Use
1641         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
1642         */
1643        @Deprecated
1644        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
1645                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
1646
1647        /**
1648         * @deprecated Use
1649         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
1650         * instead
1651         */
1652        @Deprecated
1653        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
1654                Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
1655
1656        /**
1657         * @deprecated Use
1658         * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
1659         */
1660        @Deprecated
1661        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
1662            Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
1663
1664        /**
1665         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
1666         * instead
1667         */
1668        @Deprecated
1669        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
1670
1671        /**
1672         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ON} instead
1673         */
1674        @Deprecated
1675        public static final String WIFI_WATCHDOG_ON = Secure.WIFI_WATCHDOG_ON;
1676
1677        /**
1678         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
1679         */
1680        @Deprecated
1681        public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
1682
1683        /**
1684         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
1685         * instead
1686         */
1687        @Deprecated
1688        public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
1689
1690        /**
1691         * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
1692         * instead
1693         */
1694        @Deprecated
1695        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
1696            Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
1697    }
1698
1699    /**
1700     * Secure system settings, containing system preferences that applications
1701     * can read but are not allowed to write.  These are for preferences that
1702     * the user must explicitly modify through the system UI or specialized
1703     * APIs for those values, not modified directly by applications.
1704     */
1705    public static final class Secure extends NameValueTable {
1706        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
1707
1708        private static volatile NameValueCache mNameValueCache = null;
1709
1710        /**
1711         * Look up a name in the database.
1712         * @param resolver to access the database with
1713         * @param name to look up in the table
1714         * @return the corresponding value, or null if not present
1715         */
1716        public synchronized static String getString(ContentResolver resolver, String name) {
1717            if (mNameValueCache == null) {
1718                mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
1719            }
1720            return mNameValueCache.getString(resolver, name);
1721        }
1722
1723        /**
1724         * Store a name/value pair into the database.
1725         * @param resolver to access the database with
1726         * @param name to store
1727         * @param value to associate with the name
1728         * @return true if the value was set, false on database errors
1729         */
1730        public static boolean putString(ContentResolver resolver,
1731                String name, String value) {
1732            return putString(resolver, CONTENT_URI, name, value);
1733        }
1734
1735        /**
1736         * Construct the content URI for a particular name/value pair,
1737         * useful for monitoring changes with a ContentObserver.
1738         * @param name to look up in the table
1739         * @return the corresponding content URI, or null if not present
1740         */
1741        public static Uri getUriFor(String name) {
1742            return getUriFor(CONTENT_URI, name);
1743        }
1744
1745        /**
1746         * Convenience function for retrieving a single secure settings value
1747         * as an integer.  Note that internally setting values are always
1748         * stored as strings; this function converts the string to an integer
1749         * for you.  The default value will be returned if the setting is
1750         * not defined or not an integer.
1751         *
1752         * @param cr The ContentResolver to access.
1753         * @param name The name of the setting to retrieve.
1754         * @param def Value to return if the setting is not defined.
1755         *
1756         * @return The setting's current value, or 'def' if it is not defined
1757         * or not a valid integer.
1758         */
1759        public static int getInt(ContentResolver cr, String name, int def) {
1760            String v = getString(cr, name);
1761            try {
1762                return v != null ? Integer.parseInt(v) : def;
1763            } catch (NumberFormatException e) {
1764                return def;
1765            }
1766        }
1767
1768        /**
1769         * Convenience function for retrieving a single secure settings value
1770         * as an integer.  Note that internally setting values are always
1771         * stored as strings; this function converts the string to an integer
1772         * for you.
1773         * <p>
1774         * This version does not take a default value.  If the setting has not
1775         * been set, or the string value is not a number,
1776         * it throws {@link SettingNotFoundException}.
1777         *
1778         * @param cr The ContentResolver to access.
1779         * @param name The name of the setting to retrieve.
1780         *
1781         * @throws SettingNotFoundException Thrown if a setting by the given
1782         * name can't be found or the setting value is not an integer.
1783         *
1784         * @return The setting's current value.
1785         */
1786        public static int getInt(ContentResolver cr, String name)
1787                throws SettingNotFoundException {
1788            String v = getString(cr, name);
1789            try {
1790                return Integer.parseInt(v);
1791            } catch (NumberFormatException e) {
1792                throw new SettingNotFoundException(name);
1793            }
1794        }
1795
1796        /**
1797         * Convenience function for updating a single settings value as an
1798         * integer. This will either create a new entry in the table if the
1799         * given name does not exist, or modify the value of the existing row
1800         * with that name.  Note that internally setting values are always
1801         * stored as strings, so this function converts the given value to a
1802         * string before storing it.
1803         *
1804         * @param cr The ContentResolver to access.
1805         * @param name The name of the setting to modify.
1806         * @param value The new value for the setting.
1807         * @return true if the value was set, false on database errors
1808         */
1809        public static boolean putInt(ContentResolver cr, String name, int value) {
1810            return putString(cr, name, Integer.toString(value));
1811        }
1812
1813        /**
1814         * Convenience function for retrieving a single secure settings value
1815         * as a {@code long}.  Note that internally setting values are always
1816         * stored as strings; this function converts the string to a {@code long}
1817         * for you.  The default value will be returned if the setting is
1818         * not defined or not a {@code long}.
1819         *
1820         * @param cr The ContentResolver to access.
1821         * @param name The name of the setting to retrieve.
1822         * @param def Value to return if the setting is not defined.
1823         *
1824         * @return The setting's current value, or 'def' if it is not defined
1825         * or not a valid {@code long}.
1826         */
1827        public static long getLong(ContentResolver cr, String name, long def) {
1828            String valString = getString(cr, name);
1829            long value;
1830            try {
1831                value = valString != null ? Long.parseLong(valString) : def;
1832            } catch (NumberFormatException e) {
1833                value = def;
1834            }
1835            return value;
1836        }
1837
1838        /**
1839         * Convenience function for retrieving a single secure settings value
1840         * as a {@code long}.  Note that internally setting values are always
1841         * stored as strings; this function converts the string to a {@code long}
1842         * for you.
1843         * <p>
1844         * This version does not take a default value.  If the setting has not
1845         * been set, or the string value is not a number,
1846         * it throws {@link SettingNotFoundException}.
1847         *
1848         * @param cr The ContentResolver to access.
1849         * @param name The name of the setting to retrieve.
1850         *
1851         * @return The setting's current value.
1852         * @throws SettingNotFoundException Thrown if a setting by the given
1853         * name can't be found or the setting value is not an integer.
1854         */
1855        public static long getLong(ContentResolver cr, String name)
1856                throws SettingNotFoundException {
1857            String valString = getString(cr, name);
1858            try {
1859                return Long.parseLong(valString);
1860            } catch (NumberFormatException e) {
1861                throw new SettingNotFoundException(name);
1862            }
1863        }
1864
1865        /**
1866         * Convenience function for updating a secure settings value as a long
1867         * integer. This will either create a new entry in the table if the
1868         * given name does not exist, or modify the value of the existing row
1869         * with that name.  Note that internally setting values are always
1870         * stored as strings, so this function converts the given value to a
1871         * string before storing it.
1872         *
1873         * @param cr The ContentResolver to access.
1874         * @param name The name of the setting to modify.
1875         * @param value The new value for the setting.
1876         * @return true if the value was set, false on database errors
1877         */
1878        public static boolean putLong(ContentResolver cr, String name, long value) {
1879            return putString(cr, name, Long.toString(value));
1880        }
1881
1882        /**
1883         * Convenience function for retrieving a single secure settings value
1884         * as a floating point number.  Note that internally setting values are
1885         * always stored as strings; this function converts the string to an
1886         * float for you. The default value will be returned if the setting
1887         * is not defined or not a valid float.
1888         *
1889         * @param cr The ContentResolver to access.
1890         * @param name The name of the setting to retrieve.
1891         * @param def Value to return if the setting is not defined.
1892         *
1893         * @return The setting's current value, or 'def' if it is not defined
1894         * or not a valid float.
1895         */
1896        public static float getFloat(ContentResolver cr, String name, float def) {
1897            String v = getString(cr, name);
1898            try {
1899                return v != null ? Float.parseFloat(v) : def;
1900            } catch (NumberFormatException e) {
1901                return def;
1902            }
1903        }
1904
1905        /**
1906         * Convenience function for retrieving a single secure settings value
1907         * as a float.  Note that internally setting values are always
1908         * stored as strings; this function converts the string to a float
1909         * for you.
1910         * <p>
1911         * This version does not take a default value.  If the setting has not
1912         * been set, or the string value is not a number,
1913         * it throws {@link SettingNotFoundException}.
1914         *
1915         * @param cr The ContentResolver to access.
1916         * @param name The name of the setting to retrieve.
1917         *
1918         * @throws SettingNotFoundException Thrown if a setting by the given
1919         * name can't be found or the setting value is not a float.
1920         *
1921         * @return The setting's current value.
1922         */
1923        public static float getFloat(ContentResolver cr, String name)
1924                throws SettingNotFoundException {
1925            String v = getString(cr, name);
1926            try {
1927                return Float.parseFloat(v);
1928            } catch (NumberFormatException e) {
1929                throw new SettingNotFoundException(name);
1930            }
1931        }
1932
1933        /**
1934         * Convenience function for updating a single settings value as a
1935         * floating point number. This will either create a new entry in the
1936         * table if the given name does not exist, or modify the value of the
1937         * existing row with that name.  Note that internally setting values
1938         * are always stored as strings, so this function converts the given
1939         * value to a string before storing it.
1940         *
1941         * @param cr The ContentResolver to access.
1942         * @param name The name of the setting to modify.
1943         * @param value The new value for the setting.
1944         * @return true if the value was set, false on database errors
1945         */
1946        public static boolean putFloat(ContentResolver cr, String name, float value) {
1947            return putString(cr, name, Float.toString(value));
1948        }
1949
1950        /**
1951         * The content:// style URL for this table
1952         */
1953        public static final Uri CONTENT_URI =
1954            Uri.parse("content://" + AUTHORITY + "/secure");
1955
1956        /**
1957         * Whether ADB is enabled.
1958         */
1959        public static final String ADB_ENABLED = "adb_enabled";
1960
1961        /**
1962         * Setting to allow mock locations and location provider status to be injected into the
1963         * LocationManager service for testing purposes during application development.  These
1964         * locations and status values  override actual location and status information generated
1965         * by network, gps, or other location providers.
1966         */
1967        public static final String ALLOW_MOCK_LOCATION = "mock_location";
1968
1969        /**
1970         * The Android ID (a unique 64-bit value) as a hex string.
1971         * Identical to that obtained by calling
1972         * GoogleLoginService.getAndroidId(); it is also placed here
1973         * so you can get it without binding to a service.
1974         */
1975        public static final String ANDROID_ID = "android_id";
1976
1977        /**
1978         * Whether bluetooth is enabled/disabled
1979         * 0=disabled. 1=enabled.
1980         */
1981        public static final String BLUETOOTH_ON = "bluetooth_on";
1982
1983        /**
1984         * Get the key that retrieves a bluetooth headset's priority.
1985         * @hide
1986         */
1987        public static final String getBluetoothHeadsetPriorityKey(String address) {
1988            return ("bluetooth_headset_priority_" + address.toUpperCase());
1989        }
1990
1991        /**
1992         * Get the key that retrieves a bluetooth a2dp sink's priority.
1993         * @hide
1994         */
1995        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
1996            return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
1997        }
1998
1999        /**
2000         * Whether or not data roaming is enabled. (0 = false, 1 = true)
2001         */
2002        public static final String DATA_ROAMING = "data_roaming";
2003
2004        /**
2005         * Setting to record the input method used by default, holding the ID
2006         * of the desired method.
2007         */
2008        public static final String DEFAULT_INPUT_METHOD = "default_input_method";
2009
2010        /**
2011         * Whether the device has been provisioned (0 = false, 1 = true)
2012         */
2013        public static final String DEVICE_PROVISIONED = "device_provisioned";
2014
2015        /**
2016         * List of input methods that are currently enabled.  This is a string
2017         * containing the IDs of all enabled input methods, each ID separated
2018         * by ':'.
2019         */
2020        public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
2021
2022        /**
2023         * Host name and port for a user-selected proxy.
2024         */
2025        public static final String HTTP_PROXY = "http_proxy";
2026
2027        /**
2028         * Whether the package installer should allow installation of apps downloaded from
2029         * sources other than the Android Market (vending machine).
2030         *
2031         * 1 = allow installing from other sources
2032         * 0 = only allow installing from the Android Market
2033         */
2034        public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
2035
2036        /**
2037         * Comma-separated list of location providers that activities may access.
2038         */
2039        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
2040
2041        /**
2042         * Whether assisted GPS should be enabled or not.
2043         * @hide
2044         */
2045        public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
2046
2047        /**
2048         * The Logging ID (a unique 64-bit value) as a hex string.
2049         * Used as a pseudonymous identifier for logging.
2050         * @deprecated This identifier is poorly initialized and has
2051         * many collisions.  It should not be used.
2052         */
2053        @Deprecated
2054        public static final String LOGGING_ID = "logging_id";
2055
2056        /**
2057         * The Logging ID (a unique 64-bit value) as a hex string.
2058         * Used as a pseudonymous identifier for logging.
2059         * @hide
2060         */
2061        public static final String LOGGING_ID2 = "logging_id2";
2062
2063        /**
2064         * User preference for which network(s) should be used. Only the
2065         * connectivity service should touch this.
2066         */
2067        public static final String NETWORK_PREFERENCE = "network_preference";
2068
2069        /**
2070         */
2071        public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
2072
2073        /**
2074         */
2075        public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
2076
2077        /**
2078         */
2079        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
2080
2081        /**
2082         * Settings classname to launch when Settings is clicked from All
2083         * Applications.  Needed because of user testing between the old
2084         * and new Settings apps.
2085         */
2086        // TODO: 881807
2087        public static final String SETTINGS_CLASSNAME = "settings_classname";
2088
2089        /**
2090         * USB Mass Storage Enabled
2091         */
2092        public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
2093
2094        /**
2095         * If this setting is set (to anything), then all references
2096         * to Gmail on the device must change to Google Mail.
2097         */
2098        public static final String USE_GOOGLE_MAIL = "use_google_mail";
2099
2100        /**
2101         * If accessibility is enabled.
2102         */
2103        public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
2104
2105        /**
2106         * List of the enabled accessibility providers.
2107         */
2108        public static final String ENABLED_ACCESSIBILITY_SERVICES =
2109            "enabled_accessibility_services";
2110
2111        /**
2112         * Setting to always use the default text-to-speech settings regardless
2113         * of the application settings.
2114         * 1 = override application settings,
2115         * 0 = use application settings (if specified).
2116         */
2117        public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
2118
2119        /**
2120         * Default text-to-speech engine speech rate. 100 = 1x
2121         */
2122        public static final String TTS_DEFAULT_RATE = "tts_default_rate";
2123
2124        /**
2125         * Default text-to-speech engine pitch. 100 = 1x
2126         */
2127        public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
2128
2129        /**
2130         * Default text-to-speech engine.
2131         */
2132        public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
2133
2134        /**
2135         * Default text-to-speech language.
2136         */
2137        public static final String TTS_DEFAULT_LANG = "tts_default_lang";
2138
2139        /**
2140         * Default text-to-speech country.
2141         */
2142        public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
2143
2144        /**
2145         * Default text-to-speech locale variant.
2146         */
2147        public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
2148
2149        /**
2150         * Whether to notify the user of open networks.
2151         * <p>
2152         * If not connected and the scan results have an open network, we will
2153         * put this notification up. If we attempt to connect to a network or
2154         * the open network(s) disappear, we remove the notification. When we
2155         * show the notification, we will not show it again for
2156         * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
2157         */
2158        public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
2159                "wifi_networks_available_notification_on";
2160
2161        /**
2162         * Delay (in seconds) before repeating the Wi-Fi networks available notification.
2163         * Connecting to a network will reset the timer.
2164         */
2165        public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
2166                "wifi_networks_available_repeat_delay";
2167
2168        /**
2169         * The number of radio channels that are allowed in the local
2170         * 802.11 regulatory domain.
2171         * @hide
2172         */
2173        public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels";
2174
2175        /**
2176         * When the number of open networks exceeds this number, the
2177         * least-recently-used excess networks will be removed.
2178         */
2179        public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
2180
2181        /**
2182         * Whether the Wi-Fi should be on.  Only the Wi-Fi service should touch this.
2183         */
2184        public static final String WIFI_ON = "wifi_on";
2185
2186        /**
2187         * The acceptable packet loss percentage (range 0 - 100) before trying
2188         * another AP on the same network.
2189         */
2190        public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
2191                "wifi_watchdog_acceptable_packet_loss_percentage";
2192
2193        /**
2194         * The number of access points required for a network in order for the
2195         * watchdog to monitor it.
2196         */
2197        public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
2198
2199        /**
2200         * The delay between background checks.
2201         */
2202        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
2203                "wifi_watchdog_background_check_delay_ms";
2204
2205        /**
2206         * Whether the Wi-Fi watchdog is enabled for background checking even
2207         * after it thinks the user has connected to a good access point.
2208         */
2209        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
2210                "wifi_watchdog_background_check_enabled";
2211
2212        /**
2213         * The timeout for a background ping
2214         */
2215        public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
2216                "wifi_watchdog_background_check_timeout_ms";
2217
2218        /**
2219         * The number of initial pings to perform that *may* be ignored if they
2220         * fail. Again, if these fail, they will *not* be used in packet loss
2221         * calculation. For example, one network always seemed to time out for
2222         * the first couple pings, so this is set to 3 by default.
2223         */
2224        public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
2225            "wifi_watchdog_initial_ignored_ping_count";
2226
2227        /**
2228         * The maximum number of access points (per network) to attempt to test.
2229         * If this number is reached, the watchdog will no longer monitor the
2230         * initial connection state for the network. This is a safeguard for
2231         * networks containing multiple APs whose DNS does not respond to pings.
2232         */
2233        public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
2234
2235        /**
2236         * Whether the Wi-Fi watchdog is enabled.
2237         */
2238        public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
2239
2240        /**
2241         * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
2242         */
2243        public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
2244
2245        /**
2246         * The number of pings to test if an access point is a good connection.
2247         */
2248        public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
2249
2250        /**
2251         * The delay between pings.
2252         */
2253        public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
2254
2255        /**
2256         * The timeout per ping.
2257         */
2258        public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
2259
2260        /**
2261         * The maximum number of times we will retry a connection to an access
2262         * point for which we have failed in acquiring an IP address from DHCP.
2263         * A value of N means that we will make N+1 connection attempts in all.
2264         */
2265        public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
2266
2267        /**
2268         * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
2269         * data connectivity to be established after a disconnect from Wi-Fi.
2270         */
2271        public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
2272            "wifi_mobile_data_transition_wakelock_timeout_ms";
2273
2274        /**
2275         * Whether background data usage is allowed by the user. See
2276         * ConnectivityManager for more info.
2277         */
2278        public static final String BACKGROUND_DATA = "background_data";
2279
2280        /**
2281         * The time in msec, when the LAST_KMSG file was send to the checkin server.
2282         * We will only send the LAST_KMSG file if it was modified after this time.
2283         *
2284         * @hide
2285         */
2286        public static final String CHECKIN_SEND_LAST_KMSG_TIME = "checkin_kmsg_time";
2287
2288        /**
2289         * The time in msec, when the apanic_console file was send to the checkin server.
2290         * We will only send the apanic_console file if it was modified after this time.
2291         *
2292         * @hide
2293         */
2294        public static final String CHECKIN_SEND_APANIC_CONSOLE_TIME =
2295            "checkin_apanic_console_time";
2296
2297        /**
2298         * The time in msec, when the apanic_thread file was send to the checkin server.
2299         * We will only send the apanic_thread file if it was modified after this time.
2300         *
2301         * @hide
2302         */
2303        public static final String CHECKIN_SEND_APANIC_THREAD_TIME =
2304            "checkin_apanic_thread_time";
2305
2306        /**
2307         * The CDMA roaming mode 0 = Home Networks, CDMA default
2308         *                       1 = Roaming on Affiliated networks
2309         *                       2 = Roaming on any networks
2310         * @hide
2311         */
2312        public static final String CDMA_ROAMING_MODE = "roaming_settings";
2313
2314        /**
2315         * The CDMA subscription mode 0 = RUIM/SIM (default)
2316         *                                1 = NV
2317         * @hide
2318         */
2319        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
2320
2321        /**
2322         * The preferred network mode   7 = Global
2323         *                              6 = EvDo only
2324         *                              5 = CDMA w/o EvDo
2325         *                              4 = CDMA / EvDo auto
2326         *                              3 = GSM / WCDMA auto
2327         *                              2 = WCDMA only
2328         *                              1 = GSM only
2329         *                              0 = GSM / WCDMA preferred
2330         * @hide
2331         */
2332        public static final String PREFERRED_NETWORK_MODE =
2333                "preferred_network_mode";
2334
2335        /**
2336         * The preferred TTY mode     0 = TTy Off, CDMA default
2337         *                            1 = TTY Full
2338         *                            2 = TTY HCO
2339         *                            3 = TTY VCO
2340         * @hide
2341         */
2342        public static final String PREFERRED_TTY_MODE =
2343                "preferred_tty_mode";
2344
2345
2346        /**
2347         * CDMA Cell Broadcast SMS
2348         *                            0 = CDMA Cell Broadcast SMS disabled
2349         *                            1 = CDMA Cell Broadcast SMS enabled
2350         * @hide
2351         */
2352        public static final String CDMA_CELL_BROADCAST_SMS =
2353                "cdma_cell_broadcast_sms";
2354
2355        /**
2356         * The cdma subscription 0 = Subscription from RUIM, when available
2357         *                       1 = Subscription from NV
2358         * @hide
2359         */
2360        public static final String PREFERRED_CDMA_SUBSCRIPTION =
2361                "preferred_cdma_subscription";
2362
2363        /**
2364         * Whether the enhanced voice privacy mode is enabled.
2365         * 0 = normal voice privacy
2366         * 1 = enhanced voice privacy
2367         * @hide
2368         */
2369        public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
2370
2371        /**
2372         * Whether the TTY mode mode is enabled.
2373         * 0 = disabled
2374         * 1 = enabled
2375         * @hide
2376         */
2377        public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
2378
2379        /**
2380         * Flag for allowing service provider to use location information to improve products and
2381         * services.
2382         * Type: int ( 0 = disallow, 1 = allow )
2383         * @hide
2384         */
2385        public static final String USE_LOCATION_FOR_SERVICES = "use_location";
2386
2387        /**
2388         * Controls whether settings backup is enabled.
2389         * Type: int ( 0 = disabled, 1 = enabled )
2390         * @hide
2391         */
2392        public static final String BACKUP_ENABLED = "backup_enabled";
2393
2394        /**
2395         * Indicates whether settings backup has been fully provisioned.
2396         * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
2397         * @hide
2398         */
2399        public static final String BACKUP_PROVISIONED = "backup_provisioned";
2400
2401        /**
2402         * Component of the transport to use for backup/restore.
2403         * @hide
2404         */
2405        public static final String BACKUP_TRANSPORT = "backup_transport";
2406
2407        /**
2408         * Version for which the setup wizard was last shown.  Bumped for
2409         * each release when there is new setup information to show.
2410         * @hide
2411         */
2412        public static final String LAST_SETUP_SHOWN = "last_setup_shown";
2413
2414        /**
2415         * @hide
2416         */
2417        public static final String[] SETTINGS_TO_BACKUP = {
2418            ADB_ENABLED,
2419            ALLOW_MOCK_LOCATION,
2420            PARENTAL_CONTROL_ENABLED,
2421            PARENTAL_CONTROL_REDIRECT_URL,
2422            USB_MASS_STORAGE_ENABLED,
2423            ACCESSIBILITY_ENABLED,
2424            ENABLED_ACCESSIBILITY_SERVICES,
2425            TTS_USE_DEFAULTS,
2426            TTS_DEFAULT_RATE,
2427            TTS_DEFAULT_PITCH,
2428            TTS_DEFAULT_SYNTH,
2429            TTS_DEFAULT_LANG,
2430            TTS_DEFAULT_COUNTRY,
2431            WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
2432            WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
2433            WIFI_NUM_ALLOWED_CHANNELS,
2434            WIFI_NUM_OPEN_NETWORKS_KEPT,
2435        };
2436
2437        /**
2438         * Helper method for determining if a location provider is enabled.
2439         * @param cr the content resolver to use
2440         * @param provider the location provider to query
2441         * @return true if the provider is enabled
2442         *
2443         * @hide
2444         */
2445        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
2446            String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED);
2447            if (allowedProviders != null) {
2448                return (allowedProviders.equals(provider) ||
2449                        allowedProviders.contains("," + provider + ",") ||
2450                        allowedProviders.startsWith(provider + ",") ||
2451                        allowedProviders.endsWith("," + provider));
2452            }
2453            return false;
2454        }
2455
2456        /**
2457         * Thread-safe method for enabling or disabling a single location provider.
2458         * @param cr the content resolver to use
2459         * @param provider the location provider to enable or disable
2460         * @param enabled true if the provider should be enabled
2461         *
2462         * @hide
2463         */
2464        public static final void setLocationProviderEnabled(ContentResolver cr,
2465                String provider, boolean enabled) {
2466            // to ensure thread safety, we write the provider name with a '+' or '-'
2467            // and let the SettingsProvider handle it rather than reading and modifying
2468            // the list of enabled providers.
2469            if (enabled) {
2470                provider = "+" + provider;
2471            } else {
2472                provider = "-" + provider;
2473            }
2474            putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider);
2475        }
2476    }
2477
2478    /**
2479     * Gservices settings, containing the network names for Google's
2480     * various services. This table holds simple name/addr pairs.
2481     * Addresses can be accessed through the getString() method.
2482     *
2483     * TODO: This should move to partner/google/... somewhere.
2484     *
2485     * @hide
2486     */
2487    public static final class Gservices extends NameValueTable {
2488        public static final String SYS_PROP_SETTING_VERSION = "sys.settings_gservices_version";
2489
2490        /**
2491         * Intent action broadcast when the Gservices table is updated by the server.
2492         * This is broadcast once after settings change (so many values may have been updated).
2493         */
2494        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2495        public static final String CHANGED_ACTION =
2496            "com.google.gservices.intent.action.GSERVICES_CHANGED";
2497
2498        /**
2499         * Intent action to override Gservices for testing.  (Requires WRITE_GSERVICES permission.)
2500         */
2501        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2502        public static final String OVERRIDE_ACTION =
2503            "com.google.gservices.intent.action.GSERVICES_OVERRIDE";
2504
2505        private static volatile NameValueCache mNameValueCache = null;
2506        private static final Object mNameValueCacheLock = new Object();
2507
2508        /**
2509         * Look up a name in the database.
2510         * @param resolver to access the database with
2511         * @param name to look up in the table
2512         * @return the corresponding value, or null if not present
2513         */
2514        public static String getString(ContentResolver resolver, String name) {
2515            synchronized (mNameValueCacheLock) {
2516                if (mNameValueCache == null) {
2517                    mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
2518                }
2519                return mNameValueCache.getString(resolver, name);
2520            }
2521        }
2522
2523        /**
2524         * Store a name/value pair into the database.
2525         * @param resolver to access the database with
2526         * @param name to store
2527         * @param value to associate with the name
2528         * @return true if the value was set, false on database errors
2529         */
2530        public static boolean putString(ContentResolver resolver,
2531                String name, String value) {
2532            return putString(resolver, CONTENT_URI, name, value);
2533        }
2534
2535        /**
2536         * Look up the value for name in the database, convert it to an int using Integer.parseInt
2537         * and return it. If it is null or if a NumberFormatException is caught during the
2538         * conversion then return defValue.
2539         */
2540        public static int getInt(ContentResolver resolver, String name, int defValue) {
2541            String valString = getString(resolver, name);
2542            int value;
2543            try {
2544                value = valString != null ? Integer.parseInt(valString) : defValue;
2545            } catch (NumberFormatException e) {
2546                value = defValue;
2547            }
2548            return value;
2549        }
2550
2551        /**
2552         * Look up the value for name in the database, convert it to a long using Long.parseLong
2553         * and return it. If it is null or if a NumberFormatException is caught during the
2554         * conversion then return defValue.
2555         */
2556        public static long getLong(ContentResolver resolver, String name, long defValue) {
2557            String valString = getString(resolver, name);
2558            long value;
2559            try {
2560                value = valString != null ? Long.parseLong(valString) : defValue;
2561            } catch (NumberFormatException e) {
2562                value = defValue;
2563            }
2564            return value;
2565        }
2566
2567        /**
2568         * Construct the content URI for a particular name/value pair,
2569         * useful for monitoring changes with a ContentObserver.
2570         * @param name to look up in the table
2571         * @return the corresponding content URI, or null if not present
2572         */
2573        public static Uri getUriFor(String name) {
2574            return getUriFor(CONTENT_URI, name);
2575        }
2576
2577        /**
2578         * The content:// style URL for this table
2579         */
2580        public static final Uri CONTENT_URI =
2581                Uri.parse("content://" + AUTHORITY + "/gservices");
2582
2583        /**
2584         * MMS - URL to use for HTTP "x-wap-profile" header
2585         */
2586        public static final String MMS_X_WAP_PROFILE_URL
2587                = "mms_x_wap_profile_url";
2588
2589        /**
2590         * YouTube - the flag to indicate whether to use proxy
2591         */
2592        public static final String YOUTUBE_USE_PROXY
2593                = "youtube_use_proxy";
2594
2595        /**
2596         * MMS - maximum message size in bytes for a MMS message.
2597         */
2598        public static final String MMS_MAXIMUM_MESSAGE_SIZE
2599                = "mms_maximum_message_size";
2600
2601        /**
2602         * Event tags from the kernel event log to upload during checkin.
2603         */
2604        public static final String CHECKIN_EVENTS = "checkin_events";
2605
2606        /**
2607         * Comma-separated list of service names to dump and upload during checkin.
2608         */
2609        public static final String CHECKIN_DUMPSYS_LIST = "checkin_dumpsys_list";
2610
2611        /**
2612         * Comma-separated list of packages to specify for each service that is
2613         * dumped (currently only meaningful for user activity).
2614         */
2615        public static final String CHECKIN_PACKAGE_LIST = "checkin_package_list";
2616
2617        /**
2618         * The interval (in seconds) between periodic checkin attempts.
2619         */
2620        public static final String CHECKIN_INTERVAL = "checkin_interval";
2621
2622        /**
2623         * Boolean indicating if the market app should force market only checkins on
2624         * install/uninstall. Any non-0 value is considered true.
2625         */
2626        public static final String MARKET_FORCE_CHECKIN = "market_force_checkin";
2627
2628        /**
2629         * How frequently (in seconds) to check the memory status of the
2630         * device.
2631         */
2632        public static final String MEMCHECK_INTERVAL = "memcheck_interval";
2633
2634        /**
2635         * Max frequency (in seconds) to log memory check stats, in realtime
2636         * seconds.  This allows for throttling of logs when the device is
2637         * running for large amounts of time.
2638         */
2639        public static final String MEMCHECK_LOG_REALTIME_INTERVAL =
2640                "memcheck_log_realtime_interval";
2641
2642        /**
2643         * Boolean indicating whether rebooting due to system memory checks
2644         * is enabled.
2645         */
2646        public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled";
2647
2648        /**
2649         * How many bytes the system process must be below to avoid scheduling
2650         * a soft reboot.  This reboot will happen when it is next determined
2651         * to be a good time.
2652         */
2653        public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft";
2654
2655        /**
2656         * How many bytes the system process must be below to avoid scheduling
2657         * a hard reboot.  This reboot will happen immediately.
2658         */
2659        public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard";
2660
2661        /**
2662         * How many bytes the phone process must be below to avoid scheduling
2663         * a soft restart.  This restart will happen when it is next determined
2664         * to be a good time.
2665         */
2666        public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft";
2667
2668        /**
2669         * How many bytes the phone process must be below to avoid scheduling
2670         * a hard restart.  This restart will happen immediately.
2671         */
2672        public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard";
2673
2674        /**
2675         * Boolean indicating whether restarting the phone process due to
2676         * memory checks is enabled.
2677         */
2678        public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled";
2679
2680        /**
2681         * First time during the day it is okay to kill processes
2682         * or reboot the device due to low memory situations.  This number is
2683         * in seconds since midnight.
2684         */
2685        public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time";
2686
2687        /**
2688         * Last time during the day it is okay to kill processes
2689         * or reboot the device due to low memory situations.  This number is
2690         * in seconds since midnight.
2691         */
2692        public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time";
2693
2694        /**
2695         * How long the screen must have been off in order to kill processes
2696         * or reboot.  This number is in seconds.  A value of -1 means to
2697         * entirely disregard whether the screen is on.
2698         */
2699        public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off";
2700
2701        /**
2702         * How much time there must be until the next alarm in order to kill processes
2703         * or reboot.  This number is in seconds.  Note: this value must be
2704         * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will
2705         * always see an alarm scheduled within its time.
2706         */
2707        public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm";
2708
2709        /**
2710         * How frequently to check whether it is a good time to restart things,
2711         * if the device is in a bad state.  This number is in seconds.  Note:
2712         * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else
2713         * the alarm to schedule the recheck will always appear within the
2714         * minimum "do not execute now" time.
2715         */
2716        public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval";
2717
2718        /**
2719         * How frequently (in DAYS) to reboot the device.  If 0, no reboots
2720         * will occur.
2721         */
2722        public static final String REBOOT_INTERVAL = "reboot_interval";
2723
2724        /**
2725         * First time during the day it is okay to force a reboot of the
2726         * device (if REBOOT_INTERVAL is set).  This number is
2727         * in seconds since midnight.
2728         */
2729        public static final String REBOOT_START_TIME = "reboot_start_time";
2730
2731        /**
2732         * The window of time (in seconds) after each REBOOT_INTERVAL in which
2733         * a reboot can be executed.  If 0, a reboot will always be executed at
2734         * exactly the given time.  Otherwise, it will only be executed if
2735         * the device is idle within the window.
2736         */
2737        public static final String REBOOT_WINDOW = "reboot_window";
2738
2739        /**
2740         * The minimum version of the server that is required in order for the device to accept
2741         * the server's recommendations about the initial sync settings to use. When this is unset,
2742         * blank or can't be interpreted as an integer then we will not ask the server for a
2743         * recommendation.
2744         */
2745        public static final String GMAIL_CONFIG_INFO_MIN_SERVER_VERSION =
2746                "gmail_config_info_min_server_version";
2747
2748        /**
2749         * Controls whether Gmail offers a preview button for images.
2750         */
2751        public static final String GMAIL_DISALLOW_IMAGE_PREVIEWS = "gmail_disallow_image_previews";
2752
2753        /**
2754         * The maximal size in bytes allowed for attachments when composing messages in Gmail
2755         */
2756        public static final String GMAIL_MAX_ATTACHMENT_SIZE = "gmail_max_attachment_size_bytes";
2757
2758        /**
2759         * The timeout in milliseconds that Gmail uses when opening a connection and reading
2760         * from it. A missing value or a value of -1 instructs Gmail to use the defaults provided
2761         * by GoogleHttpClient.
2762         */
2763        public static final String GMAIL_TIMEOUT_MS = "gmail_timeout_ms";
2764
2765        /**
2766         * Controls whether Gmail will request an expedited sync when a message is sent. Value must
2767         * be an integer where non-zero means true. Defaults to 1.
2768         */
2769        public static final String GMAIL_SEND_IMMEDIATELY = "gmail_send_immediately";
2770
2771        /**
2772         * Controls whether gmail buffers server responses.  Possible values are "memory", for a
2773         * memory-based buffer, or "file", for a temp-file-based buffer.  All other values
2774         * (including not set) disable buffering.
2775         */
2776        public static final String GMAIL_BUFFER_SERVER_RESPONSE = "gmail_buffer_server_response";
2777
2778        /**
2779         * The maximum size in bytes allowed for the provider to gzip a protocol buffer uploaded to
2780         * the server.
2781         */
2782        public static final String GMAIL_MAX_GZIP_SIZE = "gmail_max_gzip_size_bytes";
2783
2784        /**
2785         * Controls whether Gmail will discard uphill operations that repeatedly fail. Value must be
2786         * an integer where non-zero means true. Defaults to 1. This flag controls Donut devices.
2787         */
2788        public static final String GMAIL_DISCARD_ERROR_UPHILL_OP = "gmail_discard_error_uphill_op";
2789
2790        /**
2791         * Controls whether Gmail will discard uphill operations that repeatedly fail. Value must be
2792         * an integer where non-zero means true. Defaults to 1. This flag controls Eclair and
2793         * future devices.
2794         */
2795        public static final String GMAIL_DISCARD_ERROR_UPHILL_OP_NEW =
2796            "gmail_discard_error_uphill_op_new";
2797
2798        /**
2799         * Controls how many attempts Gmail will try to upload an uphill operations before it
2800         * abandons the operation. Defaults to 20.
2801         */
2802        public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_num_retry_uphill_op";
2803
2804        /**
2805         * How much time in seconds Gmail will try to upload an uphill operations before it
2806         * abandons the operation. Defaults to 36400 (one day).
2807         */
2808        public static final String GMAIL_WAIT_TIME_RETRY_UPHILL_OP =
2809                "gmail_wait_time_retry_uphill_op";
2810
2811        /**
2812         * Controls if the protocol buffer version of the protocol will use a multipart request for
2813         * attachment uploads. Value must be an integer where non-zero means true. Defaults to 0.
2814         */
2815        public static final String GMAIL_USE_MULTIPART_PROTOBUF = "gmail_use_multipart_protobuf";
2816
2817        /**
2818         * the transcoder URL for mobile devices.
2819         */
2820        public static final String TRANSCODER_URL = "mobile_transcoder_url";
2821
2822        /**
2823         * URL that points to the privacy terms of the Google Talk service.
2824         */
2825        public static final String GTALK_TERMS_OF_SERVICE_URL = "gtalk_terms_of_service_url";
2826
2827        /**
2828         * Hostname of the GTalk server.
2829         */
2830        public static final String GTALK_SERVICE_HOSTNAME = "gtalk_hostname";
2831
2832        /**
2833         * Secure port of the GTalk server.
2834         */
2835        public static final String GTALK_SERVICE_SECURE_PORT = "gtalk_secure_port";
2836
2837        /**
2838         * The server configurable RMQ acking interval
2839         */
2840        public static final String GTALK_SERVICE_RMQ_ACK_INTERVAL = "gtalk_rmq_ack_interval";
2841
2842        /**
2843         * The minimum reconnect delay for short network outages or when the network is suspended
2844         * due to phone use.
2845         */
2846        public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT =
2847                "gtalk_min_reconnect_delay_short";
2848
2849        /**
2850         * The reconnect variant range for short network outages or when the network is suspended
2851         * due to phone use. A random number between 0 and this constant is computed and
2852         * added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT} to form the initial reconnect
2853         * delay.
2854         */
2855        public static final String GTALK_SERVICE_RECONNECT_VARIANT_SHORT =
2856                "gtalk_reconnect_variant_short";
2857
2858        /**
2859         * The minimum reconnect delay for long network outages
2860         */
2861        public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG =
2862                "gtalk_min_reconnect_delay_long";
2863
2864        /**
2865         * The reconnect variant range for long network outages.  A random number between 0 and this
2866         * constant is computed and added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG} to
2867         * form the initial reconnect delay.
2868         */
2869        public static final String GTALK_SERVICE_RECONNECT_VARIANT_LONG =
2870                "gtalk_reconnect_variant_long";
2871
2872        /**
2873         * The maximum reconnect delay time, in milliseconds.
2874         */
2875        public static final String GTALK_SERVICE_MAX_RECONNECT_DELAY =
2876                "gtalk_max_reconnect_delay";
2877
2878        /**
2879         * The network downtime that is considered "short" for the above calculations,
2880         * in milliseconds.
2881         */
2882        public static final String GTALK_SERVICE_SHORT_NETWORK_DOWNTIME =
2883                "gtalk_short_network_downtime";
2884
2885        /**
2886         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2887         * will reset the heartbeat timer. The away heartbeat should be used when the user is
2888         * logged into the GTalk app, but not actively using it.
2889         */
2890        public static final String GTALK_SERVICE_AWAY_HEARTBEAT_INTERVAL_MS =
2891                "gtalk_heartbeat_ping_interval_ms";  // keep the string backward compatible
2892
2893        /**
2894         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2895         * will reset the heartbeat timer. The active heartbeat should be used when the user is
2896         * actively using the GTalk app.
2897         */
2898        public static final String GTALK_SERVICE_ACTIVE_HEARTBEAT_INTERVAL_MS =
2899                "gtalk_active_heartbeat_ping_interval_ms";
2900
2901        /**
2902         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2903         * will reset the heartbeat timer. The sync heartbeat should be used when the user isn't
2904         * logged into the GTalk app, but auto-sync is enabled.
2905         */
2906        public static final String GTALK_SERVICE_SYNC_HEARTBEAT_INTERVAL_MS =
2907                "gtalk_sync_heartbeat_ping_interval_ms";
2908
2909        /**
2910         * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2911         * will reset the heartbeat timer. The no sync heartbeat should be used when the user isn't
2912         * logged into the GTalk app, and auto-sync is not enabled.
2913         */
2914        public static final String GTALK_SERVICE_NOSYNC_HEARTBEAT_INTERVAL_MS =
2915                "gtalk_nosync_heartbeat_ping_interval_ms";
2916
2917        /**
2918         * The maximum heartbeat interval used while on the WIFI network.
2919         */
2920        public static final String GTALK_SERVICE_WIFI_MAX_HEARTBEAT_INTERVAL_MS =
2921                "gtalk_wifi_max_heartbeat_ping_interval_ms";
2922
2923        /**
2924         * How long we wait to receive a heartbeat ping acknowledgement (or another packet)
2925         * from the GTalk server, before deeming the connection dead.
2926         */
2927        public static final String GTALK_SERVICE_HEARTBEAT_ACK_TIMEOUT_MS =
2928                "gtalk_heartbeat_ack_timeout_ms";
2929
2930        /**
2931         * How long after screen is turned off before we consider the user to be idle.
2932         */
2933        public static final String GTALK_SERVICE_IDLE_TIMEOUT_MS =
2934                "gtalk_idle_timeout_ms";
2935
2936        /**
2937         * By default, GTalkService will always connect to the server regardless of the auto-sync
2938         * setting. However, if this parameter is true, then GTalkService will only connect
2939         * if auto-sync is enabled. Using the GTalk app will trigger the connection too.
2940         */
2941        public static final String GTALK_SERVICE_CONNECT_ON_AUTO_SYNC =
2942                "gtalk_connect_on_auto_sync";
2943
2944        /**
2945         * GTalkService holds a wakelock while broadcasting the intent for data message received.
2946         * It then automatically release the wakelock after a timeout. This setting controls what
2947         * the timeout should be.
2948         */
2949        public static final String GTALK_DATA_MESSAGE_WAKELOCK_MS =
2950                "gtalk_data_message_wakelock_ms";
2951
2952        /**
2953         * The socket read timeout used to control how long ssl handshake wait for reads before
2954         * timing out. This is needed so the ssl handshake doesn't hang for a long time in some
2955         * circumstances.
2956         */
2957        public static final String GTALK_SSL_HANDSHAKE_TIMEOUT_MS =
2958                "gtalk_ssl_handshake_timeout_ms";
2959
2960        /**
2961         * Compress the gtalk stream.
2962         */
2963        public static final String GTALK_COMPRESS = "gtalk_compress";
2964
2965        /**
2966         * This is the timeout for which Google Talk will send the message using bareJID. In a
2967         * established chat between two XMPP endpoints, Google Talk uses fullJID in the format
2968         * of user@domain/resource in order to send the message to the specific client. However,
2969         * if Google Talk hasn't received a message from that client after some time, it would
2970         * fall back to use the bareJID, which would broadcast the message to all clients for
2971         * the other user.
2972         */
2973        public static final String GTALK_USE_BARE_JID_TIMEOUT_MS = "gtalk_use_barejid_timeout_ms";
2974
2975        /**
2976         * This is the threshold of retry number when there is an authentication expired failure
2977         * for Google Talk. In some situation, e.g. when a Google Apps account is disabled chat
2978         * service, the connection keeps failing. This threshold controls when we should stop
2979         * the retrying.
2980         */
2981        public static final String GTALK_MAX_RETRIES_FOR_AUTH_EXPIRED =
2982                "gtalk_max_retries_for_auth_expired";
2983
2984        /**
2985         * a boolean setting indicating whether the GTalkService should use RMQ2 protocol or not.
2986         */
2987        public static final String GTALK_USE_RMQ2_PROTOCOL =
2988                "gtalk_use_rmq2";
2989
2990        /**
2991         * a boolean setting indicating whether the GTalkService should support both RMQ and
2992         * RMQ2 protocols. This setting is true for the transitional period when we need to
2993         * support both protocols.
2994         */
2995        public static final String GTALK_SUPPORT_RMQ_AND_RMQ2_PROTOCOLS =
2996                "gtalk_support_rmq_and_rmq2";
2997
2998        /**
2999         * a boolean setting controlling whether the rmq2 protocol will include stream ids in
3000         * the protobufs. This is used for debugging.
3001         */
3002        public static final String GTALK_RMQ2_INCLUDE_STREAM_ID =
3003                "gtalk_rmq2_include_stream_id";
3004
3005        /**
3006         * when receiving a chat message from the server, the message could be an older message
3007         * whose "time sent" is x seconds from now. If x is significant enough, we want to flag
3008         * it so the UI can give it some special treatment when displaying the "time sent" for
3009         * it. This setting is to control what x is.
3010         */
3011        public static final String GTALK_OLD_CHAT_MESSAGE_THRESHOLD_IN_SEC =
3012                "gtalk_old_chat_msg_threshold_in_sec";
3013
3014        /**
3015         * a setting to control the max connection history record GTalkService stores.
3016         */
3017        public static final String GTALK_MAX_CONNECTION_HISTORY_RECORDS =
3018                "gtalk_max_conn_history_records";
3019
3020        /**
3021         * This is gdata url to lookup album and picture info from picasa web. It also controls
3022         * whether url scraping for picasa is enabled (NULL to disable).
3023         */
3024        public static final String GTALK_PICASA_ALBUM_URL =
3025                "gtalk_picasa_album_url";
3026
3027        /**
3028         * This is the url to lookup picture info from flickr. It also controls
3029         * whether url scraping for flickr is enabled (NULL to disable).
3030         */
3031        public static final String GTALK_FLICKR_PHOTO_INFO_URL =
3032                "gtalk_flickr_photo_info_url";
3033
3034        /**
3035         * This is the url to lookup an actual picture from flickr.
3036         */
3037        public static final String GTALK_FLICKR_PHOTO_URL =
3038                "gtalk_flickr_photo_url";
3039
3040        /**
3041         * This is the gdata url to lookup info on a youtube video. It also controls
3042         * whether url scraping for youtube is enabled (NULL to disable).
3043         */
3044        public static final String GTALK_YOUTUBE_VIDEO_URL =
3045                "gtalk_youtube_video_url";
3046
3047        /**
3048         * Enable/disable GTalk URL scraping for JPG images ("true" to enable).
3049         */
3050        public static final String GTALK_URL_SCRAPING_FOR_JPG =
3051                "gtalk_url_scraping_for_jpg";
3052
3053        /**
3054         * Chat message lifetime (for pruning old chat messages).
3055         */
3056        public static final String GTALK_CHAT_MESSAGE_LIFETIME =
3057                "gtalk_chat_message_lifetime";
3058
3059        /**
3060         * OTR message lifetime (for pruning old otr messages).
3061         */
3062        public static final String GTALK_OTR_MESSAGE_LIFETIME =
3063                "gtalk_otr_message_lifetime";
3064
3065        /**
3066         * Chat expiration time, i.e., time since last message in the chat (for pruning old chats).
3067         */
3068        public static final String GTALK_CHAT_EXPIRATION_TIME =
3069                "gtalk_chat_expiration_time";
3070
3071        /**
3072         * This is the url for getting the app token for server-to-device push messaging.
3073         */
3074        public static final String PUSH_MESSAGING_REGISTRATION_URL =
3075                "push_messaging_registration_url";
3076
3077        /**
3078         * Use android://&lt;it&gt; routing infos for Google Sync Server subcriptions.
3079         */
3080        public static final String GSYNC_USE_RMQ2_ROUTING_INFO = "gsync_use_rmq2_routing_info";
3081
3082        /**
3083         * Enable use of ssl session caching.
3084         * 'db' - save each session in a (per process) database
3085         * 'file' - save each session in a (per process) file
3086         * not set or any other value - normal java in-memory caching
3087         */
3088        public static final String SSL_SESSION_CACHE = "ssl_session_cache";
3089
3090        /**
3091         * How many bytes long a message has to be, in order to be gzipped.
3092         */
3093        public static final String SYNC_MIN_GZIP_BYTES =
3094                "sync_min_gzip_bytes";
3095
3096        /**
3097         * The hash value of the current provisioning settings
3098         */
3099        public static final String PROVISIONING_DIGEST = "digest";
3100
3101        /**
3102         * Provisioning keys to block from server update
3103         */
3104        public static final String PROVISIONING_OVERRIDE = "override";
3105
3106        /**
3107         * "Generic" service name for  authentication requests.
3108         */
3109        public static final String GOOGLE_LOGIN_GENERIC_AUTH_SERVICE
3110                = "google_login_generic_auth_service";
3111
3112        /**
3113         * Frequency in milliseconds at which we should sync the locally installed Vending Machine
3114         * content with the server.
3115         */
3116        public static final String VENDING_SYNC_FREQUENCY_MS = "vending_sync_frequency_ms";
3117
3118        /**
3119         * Support URL that is opened in a browser when user clicks on 'Help and Info' in Vending
3120         * Machine.
3121         */
3122        public static final String VENDING_SUPPORT_URL = "vending_support_url";
3123
3124        /**
3125         * Indicates if Vending Machine requires a SIM to be in the phone to allow a purchase.
3126         *
3127         * true = SIM is required
3128         * false = SIM is not required
3129         */
3130        public static final String VENDING_REQUIRE_SIM_FOR_PURCHASE =
3131                "vending_require_sim_for_purchase";
3132
3133        /**
3134         * Indicates the Vending Machine backup state. It is set if the
3135         * Vending application has been backed up at least once.
3136         */
3137        public static final String VENDING_BACKUP_STATE = "vending_backup_state";
3138
3139        /**
3140         * The current version id of the Vending Machine terms of service.
3141         */
3142        public static final String VENDING_TOS_VERSION = "vending_tos_version";
3143
3144        /**
3145         * URL that points to the terms of service for Vending Machine.
3146         */
3147        public static final String VENDING_TOS_URL = "vending_tos_url";
3148
3149        /**
3150         * URL to navigate to in browser (not Market) when the terms of service
3151         * for Vending Machine could not be accessed due to bad network
3152         * connection.
3153         */
3154        public static final String VENDING_TOS_MISSING_URL = "vending_tos_missing_url";
3155
3156        /**
3157         * Whether to use sierraqa instead of sierra tokens for the purchase flow in
3158         * Vending Machine.
3159         *
3160         * true = use sierraqa
3161         * false = use sierra (default)
3162         */
3163        public static final String VENDING_USE_CHECKOUT_QA_SERVICE =
3164                "vending_use_checkout_qa_service";
3165
3166        /**
3167         * Default value to use for all/free/priced filter in Market.
3168         * Valid values: ALL, FREE, PAID (case insensitive)
3169         */
3170        public static final String VENDING_DEFAULT_FILTER = "vending_default_filter";
3171        /**
3172         * Ranking type value to use for the first category tab (currently popular)
3173         */
3174        public static final String VENDING_TAB_1_RANKING_TYPE = "vending_tab_1_ranking_type";
3175
3176        /**
3177         * Title string to use for first category tab.
3178         */
3179        public static final String VENDING_TAB_1_TITLE = "vending_tab_1_title";
3180
3181        /**
3182         * Ranking type value to use for the second category tab (currently newest)
3183         */
3184        public static final String VENDING_TAB_2_RANKING_TYPE = "vending_tab_2_ranking_type";
3185
3186        /**
3187         * Title string to use for second category tab.
3188         */
3189        public static final String VENDING_TAB_2_TITLE = "vending_tab_2_title";
3190
3191        /**
3192         * Frequency in milliseconds at which we should request MCS heartbeats
3193         * from the Vending Machine client.
3194         */
3195        public static final String VENDING_HEARTBEAT_FREQUENCY_MS =
3196                "vending_heartbeat_frequency_ms";
3197
3198        /**
3199         * Frequency in milliseconds at which we should resend pending download
3200         * requests to the API Server from the Vending Machine client.
3201         */
3202        public static final String VENDING_PENDING_DOWNLOAD_RESEND_FREQUENCY_MS =
3203                "vending_pd_resend_frequency_ms";
3204
3205        /**
3206         * Time before an asset in the 'DOWNLOADING' state is considered ready
3207         * for an install kick on the client.
3208         */
3209        public static final String VENDING_DOWNLOADING_KICK_TIMEOUT_MS =
3210                "vending_downloading_kick_ms";
3211
3212        /**
3213         * Size of buffer in bytes for Vending to use when reading cache files.
3214         */
3215        public static final String VENDING_DISK_INPUT_BUFFER_BYTES =
3216                "vending_disk_input_buffer_bytes";
3217
3218        /**
3219         * Size of buffer in bytes for Vending to use when writing cache files.
3220         */
3221        public static final String VENDING_DISK_OUTPUT_BUFFER_BYTES =
3222                "vending_disk_output_buffer_bytes";
3223
3224        /**
3225         * Frequency in milliseconds at which we should cycle through the promoted applications
3226         * on the home screen or the categories page.
3227         */
3228        public static final String VENDING_PROMO_REFRESH_FREQUENCY_MS =
3229                "vending_promo_refresh_freq_ms";
3230
3231        /**
3232         * Frequency in milliseconds when we should refresh the provisioning information from
3233         * the carrier backend.
3234         */
3235        public static final String VENDING_CARRIER_PROVISIONING_REFRESH_FREQUENCY_MS =
3236                "vending_carrier_ref_freq_ms";
3237
3238        /**
3239         * Interval in milliseconds after which a failed provisioning request should be retried.
3240         */
3241        public static final String VENDING_CARRIER_PROVISIONING_RETRY_MS =
3242            "vending_carrier_prov_retry_ms";
3243
3244        /**
3245         * Buffer in milliseconds for carrier credentials to be considered valid.
3246         */
3247        public static final String VENDING_CARRIER_CREDENTIALS_BUFFER_MS =
3248            "vending_carrier_cred_buf_ms";
3249
3250        /**
3251         * URL that points to the legal terms of service to display in Settings.
3252         * <p>
3253         * This should be a https URL. For a pretty user-friendly URL, use
3254         * {@link #SETTINGS_TOS_PRETTY_URL}.
3255         */
3256        public static final String SETTINGS_TOS_URL = "settings_tos_url";
3257
3258        /**
3259         * URL that points to the legal terms of service to display in Settings.
3260         * <p>
3261         * This should be a pretty http URL. For the URL the device will access
3262         * via Settings, use {@link #SETTINGS_TOS_URL}.
3263         */
3264        public static final String SETTINGS_TOS_PRETTY_URL = "settings_tos_pretty_url";
3265
3266        /**
3267         * URL that points to the contributors to display in Settings.
3268         * <p>
3269         * This should be a https URL. For a pretty user-friendly URL, use
3270         * {@link #SETTINGS_CONTRIBUTORS_PRETTY_URL}.
3271         */
3272        public static final String SETTINGS_CONTRIBUTORS_URL = "settings_contributors_url";
3273
3274        /**
3275         * URL that points to the contributors to display in Settings.
3276         * <p>
3277         * This should be a pretty http URL. For the URL the device will access
3278         * via Settings, use {@link #SETTINGS_CONTRIBUTORS_URL}.
3279         */
3280        public static final String SETTINGS_CONTRIBUTORS_PRETTY_URL =
3281                "settings_contributors_pretty_url";
3282
3283        /**
3284         * URL that points to the Terms Of Service for the device.
3285         * <p>
3286         * This should be a pretty http URL.
3287         */
3288        public static final String SETUP_GOOGLE_TOS_URL = "setup_google_tos_url";
3289
3290        /**
3291         * URL that points to the Android privacy policy for the device.
3292         * <p>
3293         * This should be a pretty http URL.
3294         */
3295        public static final String SETUP_ANDROID_PRIVACY_URL = "setup_android_privacy_url";
3296
3297        /**
3298         * URL that points to the Google privacy policy for the device.
3299         * <p>
3300         * This should be a pretty http URL.
3301         */
3302        public static final String SETUP_GOOGLE_PRIVACY_URL = "setup_google_privacy_url";
3303
3304        /**
3305         * Request an MSISDN token for various Google services.
3306         */
3307        public static final String USE_MSISDN_TOKEN = "use_msisdn_token";
3308
3309        /**
3310         * RSA public key used to encrypt passwords stored in the database.
3311         */
3312        public static final String GLS_PUBLIC_KEY = "google_login_public_key";
3313
3314        /**
3315         * Only check parental control status if this is set to "true".
3316         */
3317        public static final String PARENTAL_CONTROL_CHECK_ENABLED =
3318                "parental_control_check_enabled";
3319
3320        /**
3321         * The list of applications we need to block if parental control is
3322         * enabled.
3323         */
3324        public static final String PARENTAL_CONTROL_APPS_LIST =
3325                "parental_control_apps_list";
3326
3327        /**
3328         * Duration in which parental control status is valid.
3329         */
3330        public static final String PARENTAL_CONTROL_TIMEOUT_IN_MS =
3331                "parental_control_timeout_in_ms";
3332
3333        /**
3334         * When parental control is off, we expect to get this string from the
3335         * litmus url.
3336         */
3337        public static final String PARENTAL_CONTROL_EXPECTED_RESPONSE =
3338                "parental_control_expected_response";
3339
3340        /**
3341         * When the litmus url returns a 302, declare parental control to be on
3342         * only if the redirect url matches this regular expression.
3343         */
3344        public static final String PARENTAL_CONTROL_REDIRECT_REGEX =
3345                "parental_control_redirect_regex";
3346
3347        /**
3348         * Threshold for the amount of change in disk free space required to report the amount of
3349         * free space. Used to prevent spamming the logs when the disk free space isn't changing
3350         * frequently.
3351         */
3352        public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD =
3353                "disk_free_change_reporting_threshold";
3354
3355        /**
3356         * Prefix for new Google services published by the checkin
3357         * server.
3358         */
3359        public static final String GOOGLE_SERVICES_PREFIX
3360                = "google_services:";
3361
3362        /**
3363         * The maximum reconnect delay for short network outages or when the network is suspended
3364         * due to phone use.
3365         */
3366        public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
3367                "sync_max_retry_delay_in_seconds";
3368
3369        /**
3370         * Minimum percentage of free storage on the device that is used to determine if
3371         * the device is running low on storage.
3372         * Say this value is set to 10, the device is considered running low on storage
3373         * if 90% or more of the device storage is filled up.
3374         */
3375        public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE =
3376                "sys_storage_threshold_percentage";
3377
3378        /**
3379         * The interval in minutes after which the amount of free storage left on the
3380         * device is logged to the event log
3381         */
3382        public static final String SYS_FREE_STORAGE_LOG_INTERVAL =
3383                "sys_free_storage_log_interval";
3384
3385        /**
3386         * The interval in milliseconds at which to check the number of SMS sent
3387         * out without asking for use permit, to limit the un-authorized SMS
3388         * usage.
3389         */
3390        public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
3391                "sms_outgoing_check_interval_ms";
3392
3393        /**
3394         * The number of outgoing SMS sent without asking for user permit
3395         * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
3396         */
3397        public static final String SMS_OUTGOING_CEHCK_MAX_COUNT =
3398                "sms_outgoing_check_max_count";
3399
3400        /**
3401         * The interval in milliseconds at which to check packet counts on the
3402         * mobile data interface when screen is on, to detect possible data
3403         * connection problems.
3404         */
3405        public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
3406                "pdp_watchdog_poll_interval_ms";
3407
3408        /**
3409         * The interval in milliseconds at which to check packet counts on the
3410         * mobile data interface when screen is off, to detect possible data
3411         * connection problems.
3412         */
3413        public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
3414                "pdp_watchdog_long_poll_interval_ms";
3415
3416        /**
3417         * The interval in milliseconds at which to check packet counts on the
3418         * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
3419         * outgoing packets has been reached without incoming packets.
3420         */
3421        public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
3422                "pdp_watchdog_error_poll_interval_ms";
3423
3424        /**
3425         * The number of outgoing packets sent without seeing an incoming packet
3426         * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
3427         * device is logged to the event log
3428         */
3429        public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
3430                "pdp_watchdog_trigger_packet_count";
3431
3432        /**
3433         * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
3434         * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
3435         * attempting data connection recovery.
3436         */
3437        public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
3438                "pdp_watchdog_error_poll_count";
3439
3440        /**
3441         * The number of failed PDP reset attempts before moving to something more
3442         * drastic: re-registering to the network.
3443         */
3444        public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
3445                "pdp_watchdog_max_pdp_reset_fail_count";
3446
3447        /**
3448         * Address to ping as a last sanity check before attempting any recovery.
3449         * Unset or set to "0.0.0.0" to skip this check.
3450         */
3451        public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";
3452
3453        /**
3454         * The "-w deadline" parameter for the ping, ie, the max time in
3455         * seconds to spend pinging.
3456         */
3457        public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";
3458
3459        /**
3460         * The interval in milliseconds at which to check gprs registration
3461         * after the first registration mismatch of gprs and voice service,
3462         * to detect possible data network registration problems.
3463         *
3464         */
3465        public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
3466                "gprs_register_check_period_ms";
3467
3468        /**
3469         * The interval in milliseconds after which Wi-Fi is considered idle.
3470         * When idle, it is possible for the device to be switched from Wi-Fi to
3471         * the mobile data network.
3472         */
3473        public static final String WIFI_IDLE_MS = "wifi_idle_ms";
3474
3475        /**
3476         * Screen timeout in milliseconds corresponding to the
3477         * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest
3478         * possible screen timeout behavior.)
3479         */
3480        public static final String SHORT_KEYLIGHT_DELAY_MS =
3481                "short_keylight_delay_ms";
3482
3483        /**
3484         * List of test suites (local disk filename) for the automatic instrumentation test runner.
3485         * The file format is similar to automated_suites.xml, see AutoTesterService.
3486         * If this setting is missing or empty, the automatic test runner will not start.
3487         */
3488        public static final String AUTOTEST_SUITES_FILE = "autotest_suites_file";
3489
3490        /**
3491         * Interval between synchronous checkins forced by the automatic test runner.
3492         * If you set this to a value smaller than CHECKIN_INTERVAL, then the test runner's
3493         * frequent checkins will prevent asynchronous background checkins from interfering
3494         * with any performance measurements.
3495         */
3496        public static final String AUTOTEST_CHECKIN_SECONDS = "autotest_checkin_seconds";
3497
3498        /**
3499         * Interval between reboots forced by the automatic test runner.
3500         */
3501        public static final String AUTOTEST_REBOOT_SECONDS = "autotest_reboot_seconds";
3502
3503
3504        /**
3505         * Threshold values for the duration and level of a discharge cycle, under
3506         * which we log discharge cycle info.
3507         */
3508        public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD =
3509                "battery_discharge_duration_threshold";
3510        public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
3511
3512        /**
3513         * An email address that anr bugreports should be sent to.
3514         */
3515        public static final String ANR_BUGREPORT_RECIPIENT = "anr_bugreport_recipient";
3516
3517        /**
3518         * Flag for allowing service provider to use location information to improve products and
3519         * services.
3520         * Type: int ( 0 = disallow, 1 = allow )
3521         * @deprecated
3522         */
3523        public static final String USE_LOCATION_FOR_SERVICES = "use_location";
3524
3525        /**
3526         * The length of the calendar sync window into the future.
3527         * This specifies the number of days into the future for the sliding window sync.
3528         * Setting this to zero will disable sliding sync.
3529         */
3530        public static final String GOOGLE_CALENDAR_SYNC_WINDOW_DAYS =
3531                "google_calendar_sync_window_days";
3532
3533        /**
3534         * How often to update the calendar sync window.
3535         * The window will be advanced every n days.
3536         */
3537        public static final String GOOGLE_CALENDAR_SYNC_WINDOW_UPDATE_DAYS =
3538                "google_calendar_sync_window_update_days";
3539
3540        /**
3541         * The number of promoted sources in GlobalSearch.
3542         */
3543        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
3544        /**
3545         * The maximum number of suggestions returned by GlobalSearch.
3546         */
3547        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
3548        /**
3549         * The number of suggestions GlobalSearch will ask each non-web search source for.
3550         */
3551        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
3552        /**
3553         * The number of suggestions the GlobalSearch will ask the web search source for.
3554         */
3555        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
3556                "search_web_results_override_limit";
3557        /**
3558         * The number of milliseconds that GlobalSearch will wait for suggestions from
3559         * promoted sources before continuing with all other sources.
3560         */
3561        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
3562                "search_promoted_source_deadline_millis";
3563        /**
3564         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
3565         */
3566        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
3567        /**
3568         * The maximum number of milliseconds that GlobalSearch shows the previous results
3569         * after receiving a new query.
3570         */
3571        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
3572        /**
3573         * The maximum age of log data used for shortcuts in GlobalSearch.
3574         */
3575        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
3576        /**
3577         * The maximum age of log data used for source ranking in GlobalSearch.
3578         */
3579        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
3580                "search_max_source_event_age_millis";
3581        /**
3582         * The minimum number of impressions needed to rank a source in GlobalSearch.
3583         */
3584        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
3585                "search_min_impressions_for_source_ranking";
3586        /**
3587         * The minimum number of clicks needed to rank a source in GlobalSearch.
3588         */
3589        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
3590                "search_min_clicks_for_source_ranking";
3591        /**
3592         * The maximum number of shortcuts shown by GlobalSearch.
3593         */
3594        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
3595        /**
3596         * The size of the core thread pool for suggestion queries in GlobalSearch.
3597         */
3598        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
3599                "search_query_thread_core_pool_size";
3600        /**
3601         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
3602         */
3603        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
3604                "search_query_thread_max_pool_size";
3605        /**
3606         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
3607         */
3608        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
3609                "search_shortcut_refresh_core_pool_size";
3610        /**
3611         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
3612         */
3613        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
3614                "search_shortcut_refresh_max_pool_size";
3615        /**
3616         * The maximun time that excess threads in the GlobalSeach thread pools will
3617         * wait before terminating.
3618         */
3619        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
3620                "search_thread_keepalive_seconds";
3621        /**
3622         * The maximum number of concurrent suggestion queries to each source.
3623         */
3624        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
3625                "search_per_source_concurrent_query_limit";
3626
3627        /**
3628         * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents
3629         * on application crashes and ANRs. If this is disabled, the crash/ANR dialog
3630         * will never display the "Report" button.
3631         * Type: int ( 0 = disallow, 1 = allow )
3632         */
3633        public static final String SEND_ACTION_APP_ERROR = "send_action_app_error";
3634
3635        /**
3636         * Maximum size of /proc/last_kmsg content to upload after reboot.
3637         */
3638        public static final String LAST_KMSG_KB = "last_kmsg_kb";
3639
3640        /**
3641         * @deprecated
3642         * @hide
3643         */
3644        @Deprecated  // Obviated by NameValueCache: just fetch the value directly.
3645        public static class QueryMap extends ContentQueryMap {
3646
3647            public QueryMap(ContentResolver contentResolver, Cursor cursor, boolean keepUpdated,
3648                    Handler handlerForUpdateNotifications) {
3649                super(cursor, NAME, keepUpdated, handlerForUpdateNotifications);
3650            }
3651
3652            public QueryMap(ContentResolver contentResolver, boolean keepUpdated,
3653                    Handler handlerForUpdateNotifications) {
3654                this(contentResolver,
3655                        contentResolver.query(CONTENT_URI, null, null, null, null),
3656                        keepUpdated, handlerForUpdateNotifications);
3657            }
3658
3659            public String getString(String name) {
3660                ContentValues cv = getValues(name);
3661                if (cv == null) return null;
3662                return cv.getAsString(VALUE);
3663            }
3664        }
3665
3666    }
3667
3668    /**
3669     * User-defined bookmarks and shortcuts.  The target of each bookmark is an
3670     * Intent URL, allowing it to be either a web page or a particular
3671     * application activity.
3672     *
3673     * @hide
3674     */
3675    public static final class Bookmarks implements BaseColumns
3676    {
3677        private static final String TAG = "Bookmarks";
3678
3679        /**
3680         * The content:// style URL for this table
3681         */
3682        public static final Uri CONTENT_URI =
3683            Uri.parse("content://" + AUTHORITY + "/bookmarks");
3684
3685        /**
3686         * The row ID.
3687         * <p>Type: INTEGER</p>
3688         */
3689        public static final String ID = "_id";
3690
3691        /**
3692         * Descriptive name of the bookmark that can be displayed to the user.
3693         * If this is empty, the title should be resolved at display time (use
3694         * {@link #getTitle(Context, Cursor)} any time you want to display the
3695         * title of a bookmark.)
3696         * <P>
3697         * Type: TEXT
3698         * </P>
3699         */
3700        public static final String TITLE = "title";
3701
3702        /**
3703         * Arbitrary string (displayed to the user) that allows bookmarks to be
3704         * organized into categories.  There are some special names for
3705         * standard folders, which all start with '@'.  The label displayed for
3706         * the folder changes with the locale (via {@link #getLabelForFolder}) but
3707         * the folder name does not change so you can consistently query for
3708         * the folder regardless of the current locale.
3709         *
3710         * <P>Type: TEXT</P>
3711         *
3712         */
3713        public static final String FOLDER = "folder";
3714
3715        /**
3716         * The Intent URL of the bookmark, describing what it points to.  This
3717         * value is given to {@link android.content.Intent#getIntent} to create
3718         * an Intent that can be launched.
3719         * <P>Type: TEXT</P>
3720         */
3721        public static final String INTENT = "intent";
3722
3723        /**
3724         * Optional shortcut character associated with this bookmark.
3725         * <P>Type: INTEGER</P>
3726         */
3727        public static final String SHORTCUT = "shortcut";
3728
3729        /**
3730         * The order in which the bookmark should be displayed
3731         * <P>Type: INTEGER</P>
3732         */
3733        public static final String ORDERING = "ordering";
3734
3735        private static final String[] sIntentProjection = { INTENT };
3736        private static final String[] sShortcutProjection = { ID, SHORTCUT };
3737        private static final String sShortcutSelection = SHORTCUT + "=?";
3738
3739        /**
3740         * Convenience function to retrieve the bookmarked Intent for a
3741         * particular shortcut key.
3742         *
3743         * @param cr The ContentResolver to query.
3744         * @param shortcut The shortcut key.
3745         *
3746         * @return Intent The bookmarked URL, or null if there is no bookmark
3747         *         matching the given shortcut.
3748         */
3749        public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
3750        {
3751            Intent intent = null;
3752
3753            Cursor c = cr.query(CONTENT_URI,
3754                    sIntentProjection, sShortcutSelection,
3755                    new String[] { String.valueOf((int) shortcut) }, ORDERING);
3756            // Keep trying until we find a valid shortcut
3757            try {
3758                while (intent == null && c.moveToNext()) {
3759                    try {
3760                        String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
3761                        intent = Intent.getIntent(intentURI);
3762                    } catch (java.net.URISyntaxException e) {
3763                        // The stored URL is bad...  ignore it.
3764                    } catch (IllegalArgumentException e) {
3765                        // Column not found
3766                        Log.w(TAG, "Intent column not found", e);
3767                    }
3768                }
3769            } finally {
3770                if (c != null) c.close();
3771            }
3772
3773            return intent;
3774        }
3775
3776        /**
3777         * Add a new bookmark to the system.
3778         *
3779         * @param cr The ContentResolver to query.
3780         * @param intent The desired target of the bookmark.
3781         * @param title Bookmark title that is shown to the user; null if none
3782         *            or it should be resolved to the intent's title.
3783         * @param folder Folder in which to place the bookmark; null if none.
3784         * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
3785         *            this is non-zero and there is an existing bookmark entry
3786         *            with this same shortcut, then that existing shortcut is
3787         *            cleared (the bookmark is not removed).
3788         * @return The unique content URL for the new bookmark entry.
3789         */
3790        public static Uri add(ContentResolver cr,
3791                                           Intent intent,
3792                                           String title,
3793                                           String folder,
3794                                           char shortcut,
3795                                           int ordering)
3796        {
3797            // If a shortcut is supplied, and it is already defined for
3798            // another bookmark, then remove the old definition.
3799            if (shortcut != 0) {
3800                Cursor c = cr.query(CONTENT_URI,
3801                        sShortcutProjection, sShortcutSelection,
3802                        new String[] { String.valueOf((int) shortcut) }, null);
3803                try {
3804                    if (c.moveToFirst()) {
3805                        while (c.getCount() > 0) {
3806                            if (!c.deleteRow()) {
3807                                Log.w(TAG, "Could not delete existing shortcut row");
3808                            }
3809                        }
3810                    }
3811                } finally {
3812                    if (c != null) c.close();
3813                }
3814            }
3815
3816            ContentValues values = new ContentValues();
3817            if (title != null) values.put(TITLE, title);
3818            if (folder != null) values.put(FOLDER, folder);
3819            values.put(INTENT, intent.toURI());
3820            if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
3821            values.put(ORDERING, ordering);
3822            return cr.insert(CONTENT_URI, values);
3823        }
3824
3825        /**
3826         * Return the folder name as it should be displayed to the user.  This
3827         * takes care of localizing special folders.
3828         *
3829         * @param r Resources object for current locale; only need access to
3830         *          system resources.
3831         * @param folder The value found in the {@link #FOLDER} column.
3832         *
3833         * @return CharSequence The label for this folder that should be shown
3834         *         to the user.
3835         */
3836        public static CharSequence getLabelForFolder(Resources r, String folder) {
3837            return folder;
3838        }
3839
3840        /**
3841         * Return the title as it should be displayed to the user. This takes
3842         * care of localizing bookmarks that point to activities.
3843         *
3844         * @param context A context.
3845         * @param cursor A cursor pointing to the row whose title should be
3846         *        returned. The cursor must contain at least the {@link #TITLE}
3847         *        and {@link #INTENT} columns.
3848         * @return A title that is localized and can be displayed to the user,
3849         *         or the empty string if one could not be found.
3850         */
3851        public static CharSequence getTitle(Context context, Cursor cursor) {
3852            int titleColumn = cursor.getColumnIndex(TITLE);
3853            int intentColumn = cursor.getColumnIndex(INTENT);
3854            if (titleColumn == -1 || intentColumn == -1) {
3855                throw new IllegalArgumentException(
3856                        "The cursor must contain the TITLE and INTENT columns.");
3857            }
3858
3859            String title = cursor.getString(titleColumn);
3860            if (!TextUtils.isEmpty(title)) {
3861                return title;
3862            }
3863
3864            String intentUri = cursor.getString(intentColumn);
3865            if (TextUtils.isEmpty(intentUri)) {
3866                return "";
3867            }
3868
3869            Intent intent;
3870            try {
3871                intent = Intent.getIntent(intentUri);
3872            } catch (URISyntaxException e) {
3873                return "";
3874            }
3875
3876            PackageManager packageManager = context.getPackageManager();
3877            ResolveInfo info = packageManager.resolveActivity(intent, 0);
3878            return info != null ? info.loadLabel(packageManager) : "";
3879        }
3880    }
3881
3882    /**
3883     * Returns the device ID that we should use when connecting to the mobile gtalk server.
3884     * This is a string like "android-0x1242", where the hex string is the Android ID obtained
3885     * from the GoogleLoginService.
3886     *
3887     * @param androidId The Android ID for this device.
3888     * @return The device ID that should be used when connecting to the mobile gtalk server.
3889     * @hide
3890     */
3891    public static String getGTalkDeviceId(long androidId) {
3892        return "android-" + Long.toHexString(androidId);
3893    }
3894}
3895