@@ -911,17 +911,20 @@ public static final class System extends NameValueTable {
911911 }
912912
913913 private static final HashSet <String > MOVED_TO_GLOBAL ;
914+ private static final HashSet <String > MOVED_TO_SECURE_THEN_GLOBAL ;
914915 static {
915916 MOVED_TO_GLOBAL = new HashSet <String >();
917+ MOVED_TO_SECURE_THEN_GLOBAL = new HashSet <String >();
918+
916919 // these were originally in system but migrated to secure in the past,
917920 // so are duplicated in the Secure.* namespace
918- MOVED_TO_GLOBAL .add (Global .ADB_ENABLED );
919- MOVED_TO_GLOBAL .add (Global .BLUETOOTH_ON );
920- MOVED_TO_GLOBAL .add (Global .DATA_ROAMING );
921- MOVED_TO_GLOBAL .add (Global .DEVICE_PROVISIONED );
922- MOVED_TO_GLOBAL .add (Global .INSTALL_NON_MARKET_APPS );
923- MOVED_TO_GLOBAL .add (Global .USB_MASS_STORAGE_ENABLED );
924- MOVED_TO_GLOBAL .add (Global .HTTP_PROXY );
921+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .ADB_ENABLED );
922+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .BLUETOOTH_ON );
923+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .DATA_ROAMING );
924+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .DEVICE_PROVISIONED );
925+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .INSTALL_NON_MARKET_APPS );
926+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .USB_MASS_STORAGE_ENABLED );
927+ MOVED_TO_SECURE_THEN_GLOBAL .add (Global .HTTP_PROXY );
925928
926929 // these are moving directly from system to global
927930 MOVED_TO_GLOBAL .add (Settings .Global .AIRPLANE_MODE_ON );
@@ -954,6 +957,17 @@ public static final class System extends NameValueTable {
954957 MOVED_TO_GLOBAL .add (Settings .Global .ALWAYS_FINISH_ACTIVITIES );
955958 }
956959
960+ /** @hide */
961+ public static void getMovedKeys (HashSet <String > outKeySet ) {
962+ outKeySet .addAll (MOVED_TO_GLOBAL );
963+ outKeySet .addAll (MOVED_TO_SECURE_THEN_GLOBAL );
964+ }
965+
966+ /** @hide */
967+ public static void getNonLegacyMovedKeys (HashSet <String > outKeySet ) {
968+ outKeySet .addAll (MOVED_TO_GLOBAL );
969+ }
970+
957971 /**
958972 * Look up a name in the database.
959973 * @param resolver to access the database with
@@ -972,7 +986,7 @@ public static String getStringForUser(ContentResolver resolver, String name,
972986 + " to android.provider.Settings.Secure, returning read-only value." );
973987 return Secure .getStringForUser (resolver , name , userHandle );
974988 }
975- if (MOVED_TO_GLOBAL .contains (name )) {
989+ if (MOVED_TO_GLOBAL .contains (name ) || MOVED_TO_SECURE_THEN_GLOBAL . contains ( name ) ) {
976990 Log .w (TAG , "Setting " + name + " has moved from android.provider.Settings.System"
977991 + " to android.provider.Settings.Global, returning read-only value." );
978992 return Global .getStringForUser (resolver , name , userHandle );
@@ -999,7 +1013,7 @@ public static boolean putStringForUser(ContentResolver resolver, String name, St
9991013 + " to android.provider.Settings.Secure, value is unchanged." );
10001014 return false ;
10011015 }
1002- if (MOVED_TO_GLOBAL .contains (name )) {
1016+ if (MOVED_TO_GLOBAL .contains (name ) || MOVED_TO_SECURE_THEN_GLOBAL . contains ( name ) ) {
10031017 Log .w (TAG , "Setting " + name + " has moved from android.provider.Settings.System"
10041018 + " to android.provider.Settings.Global, value is unchanged." );
10051019 return false ;
@@ -1019,7 +1033,7 @@ public static Uri getUriFor(String name) {
10191033 + " to android.provider.Settings.Secure, returning Secure URI." );
10201034 return Secure .getUriFor (Secure .CONTENT_URI , name );
10211035 }
1022- if (MOVED_TO_GLOBAL .contains (name )) {
1036+ if (MOVED_TO_GLOBAL .contains (name ) || MOVED_TO_SECURE_THEN_GLOBAL . contains ( name ) ) {
10231037 Log .w (TAG , "Setting " + name + " has moved from android.provider.Settings.System"
10241038 + " to android.provider.Settings.Global, returning read-only global URI." );
10251039 return Global .getUriFor (Global .CONTENT_URI , name );
@@ -2257,7 +2271,7 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
22572271 * @hide
22582272 */
22592273 public static final String [] SETTINGS_TO_BACKUP = {
2260- STAY_ON_WHILE_PLUGGED_IN ,
2274+ STAY_ON_WHILE_PLUGGED_IN , // moved to global
22612275 WIFI_USE_STATIC_IP ,
22622276 WIFI_STATIC_IP ,
22632277 WIFI_STATIC_GATEWAY ,
@@ -2272,7 +2286,7 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
22722286 SCREEN_BRIGHTNESS_MODE ,
22732287 SCREEN_AUTO_BRIGHTNESS_ADJ ,
22742288 VIBRATE_INPUT_DEVICES ,
2275- MODE_RINGER ,
2289+ MODE_RINGER , // moved to global
22762290 MODE_RINGER_STREAMS_AFFECTED ,
22772291 MUTE_STREAMS_AFFECTED ,
22782292 VOLUME_VOICE ,
@@ -2293,20 +2307,18 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
22932307 TEXT_AUTO_CAPS ,
22942308 TEXT_AUTO_PUNCTUATE ,
22952309 TEXT_SHOW_PASSWORD ,
2296- AUTO_TIME ,
2297- AUTO_TIME_ZONE ,
2310+ AUTO_TIME , // moved to global
2311+ AUTO_TIME_ZONE , // moved to global
22982312 TIME_12_24 ,
22992313 DATE_FORMAT ,
23002314 DTMF_TONE_WHEN_DIALING ,
23012315 DTMF_TONE_TYPE_WHEN_DIALING ,
2302- Global .EMERGENCY_TONE ,
2303- Global .CALL_AUTO_RETRY ,
23042316 HEARING_AID ,
23052317 TTY_MODE ,
23062318 SOUND_EFFECTS_ENABLED ,
23072319 HAPTIC_FEEDBACK_ENABLED ,
2308- POWER_SOUNDS_ENABLED ,
2309- DOCK_SOUNDS_ENABLED ,
2320+ POWER_SOUNDS_ENABLED , // moved to global
2321+ DOCK_SOUNDS_ENABLED , // moved to global
23102322 LOCKSCREEN_SOUNDS_ENABLED ,
23112323 SHOW_WEB_SUGGESTIONS ,
23122324 NOTIFICATION_LIGHT_PULSE ,
@@ -2702,6 +2714,11 @@ public static final class Secure extends NameValueTable {
27022714 MOVED_TO_GLOBAL .add (Settings .Global .PREFERRED_CDMA_SUBSCRIPTION );
27032715 }
27042716
2717+ /** @hide */
2718+ public static void getMovedKeys (HashSet <String > outKeySet ) {
2719+ outKeySet .addAll (MOVED_TO_GLOBAL );
2720+ }
2721+
27052722 /**
27062723 * Look up a name in the database.
27072724 * @param resolver to access the database with
@@ -3993,12 +4010,11 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
39934010 * @hide
39944011 */
39954012 public static final String [] SETTINGS_TO_BACKUP = {
3996- ADB_ENABLED ,
39974013 BUGREPORT_IN_POWER_MENU ,
39984014 ALLOW_MOCK_LOCATION ,
39994015 PARENTAL_CONTROL_ENABLED ,
40004016 PARENTAL_CONTROL_REDIRECT_URL ,
4001- USB_MASS_STORAGE_ENABLED ,
4017+ USB_MASS_STORAGE_ENABLED , // moved to global
40024018 ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED ,
40034019 ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE ,
40044020 ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE ,
@@ -4017,9 +4033,9 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
40174033 TTS_DEFAULT_COUNTRY ,
40184034 TTS_ENABLED_PLUGINS ,
40194035 TTS_DEFAULT_LOCALE ,
4020- WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON ,
4021- WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY ,
4022- WIFI_NUM_OPEN_NETWORKS_KEPT ,
4036+ WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON , // moved to global
4037+ WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY , // moved to global
4038+ WIFI_NUM_OPEN_NETWORKS_KEPT , // moved to global
40234039 MOUNT_PLAY_NOTIFICATION_SND ,
40244040 MOUNT_UMS_AUTOSTART ,
40254041 MOUNT_UMS_PROMPT ,
@@ -5251,6 +5267,38 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
52515267 public static final String ALWAYS_FINISH_ACTIVITIES =
52525268 "always_finish_activities" ;
52535269
5270+ /**
5271+ * Settings to backup. This is here so that it's in the same place as the settings
5272+ * keys and easy to update.
5273+ *
5274+ * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
5275+ * and Secure as well. This is because those tables drive both backup and
5276+ * restore, and restore needs to properly whitelist keys that used to live
5277+ * in those namespaces. The keys will only actually be backed up / restored
5278+ * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
5279+ *
5280+ * NOTE: Settings are backed up and restored in the order they appear
5281+ * in this array. If you have one setting depending on another,
5282+ * make sure that they are ordered appropriately.
5283+ *
5284+ * @hide
5285+ */
5286+ public static final String [] SETTINGS_TO_BACKUP = {
5287+ STAY_ON_WHILE_PLUGGED_IN ,
5288+ MODE_RINGER ,
5289+ AUTO_TIME ,
5290+ AUTO_TIME_ZONE ,
5291+ POWER_SOUNDS_ENABLED ,
5292+ DOCK_SOUNDS_ENABLED ,
5293+ USB_MASS_STORAGE_ENABLED ,
5294+ ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED ,
5295+ WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON ,
5296+ WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY ,
5297+ WIFI_NUM_OPEN_NETWORKS_KEPT ,
5298+ EMERGENCY_TONE ,
5299+ CALL_AUTO_RETRY ,
5300+ };
5301+
52545302 // Populated lazily, guarded by class object:
52555303 private static NameValueCache sNameValueCache = new NameValueCache (
52565304 SYS_PROP_SETTING_VERSION ,
0 commit comments