diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index f70215b46a5e6..9008ddc75b094 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3444,11 +3444,13 @@ public class Intent implements Parcelable, Cloneable { "android.intent.extra.FORCE_FACTORY_RESET"; /** - * Broadcast action: report that a settings element is being restored from backup. The intent - * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting, - * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE - * is the value of that settings entry prior to the restore operation. All of these values are - * represented as strings. + * Broadcast action: report that a settings element is being restored from backup. The intent + * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, + * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE + * is the value of that settings entry prior to the restore operation, and + * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been + * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three + * values are represented as strings, the fourth one as int. * *
This broadcast is sent only for settings provider entries known to require special handling
* around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
@@ -3457,6 +3459,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #EXTRA_SETTING_NAME
* @see #EXTRA_SETTING_PREVIOUS_VALUE
* @see #EXTRA_SETTING_NEW_VALUE
+ * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
* {@hide}
*/
public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
@@ -3467,6 +3470,8 @@ public class Intent implements Parcelable, Cloneable {
public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
/** {@hide} */
public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
+ /** {@hide} */
+ public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
/**
* Activity Action: Process a piece of text.
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 533c52b20f4ef..f8701c40427a8 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -147,6 +147,10 @@ public class SettingsBackupAgent extends BackupAgentHelper {
private WifiManager mWifiManager;
+ // Version of the SDK that com.android.providers.settings package has been restored from.
+ // Populated in onRestore().
+ private int mRestoredFromSdkInt;
+
@Override
public void onCreate() {
if (DEBUG_BACKUP) Log.d(TAG, "onCreate() invoked");
@@ -201,6 +205,9 @@ public class SettingsBackupAgent extends BackupAgentHelper {
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
+ // versionCode of com.android.providers.settings corresponds to SDK_INT
+ mRestoredFromSdkInt = appVersionCode;
+
HashSet