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