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