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