summaryrefslogtreecommitdiff
path: root/packages/BackupRestoreConfirmation/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/BackupRestoreConfirmation/src')
-rw-r--r--packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java87
1 files changed, 65 insertions, 22 deletions
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
index 9fa7a6646c9c..d6b6bf8d1e56 100644
--- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
+++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
@@ -52,7 +52,9 @@ public class BackupRestoreConfirmation extends Activity {
static final String TAG = "BackupRestoreConfirmation";
static final boolean DEBUG = true;
- static final String DID_ACKNOWLEDGE = "did_acknowledge";
+ static final String KEY_DID_ACKNOWLEDGE = "did_acknowledge";
+ static final String KEY_TOKEN = "token";
+ static final String KEY_ACTION = "action";
static final int MSG_START_BACKUP = 1;
static final int MSG_BACKUP_PACKAGE = 2;
@@ -69,6 +71,7 @@ public class BackupRestoreConfirmation extends Activity {
int mToken;
boolean mIsEncrypted;
boolean mDidAcknowledge;
+ String mAction;
TextView mStatusView;
TextView mCurPassword;
@@ -134,26 +137,9 @@ public class BackupRestoreConfirmation extends Activity {
super.onCreate(icicle);
final Intent intent = getIntent();
- final String action = intent.getAction();
- final int layoutId;
- final int titleId;
- if (action.equals(FullBackup.FULL_BACKUP_INTENT_ACTION)) {
- layoutId = R.layout.confirm_backup;
- titleId = R.string.backup_confirm_title;
- } else if (action.equals(FullBackup.FULL_RESTORE_INTENT_ACTION)) {
- layoutId = R.layout.confirm_restore;
- titleId = R.string.restore_confirm_title;
- } else {
- Slog.w(TAG, "Backup/restore confirmation activity launched with invalid action!");
- finish();
- return;
- }
-
- mToken = intent.getIntExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, -1);
- if (mToken < 0) {
- Slog.e(TAG, "Backup/restore confirmation requested but no token passed!");
- finish();
+ boolean tokenValid = setTokenOrFinish(intent, icicle);
+ if (!tokenValid) { // already called finish()
return;
}
@@ -169,6 +155,61 @@ public class BackupRestoreConfirmation extends Activity {
mObserver.setHandler(mHandler);
}
+ setViews(intent, icicle);
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ setIntent(intent);
+
+ boolean tokenValid = setTokenOrFinish(intent, null);
+ if (!tokenValid) { // already called finish()
+ return;
+ }
+
+ setViews(intent, null);
+ }
+
+ private boolean setTokenOrFinish(Intent intent, Bundle icicle) {
+ mToken = intent.getIntExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, -1);
+
+ // for relaunch, we try to use the last token before exit
+ if (icicle != null) {
+ mToken = icicle.getInt(KEY_TOKEN, mToken);
+ }
+
+ if (mToken < 0) {
+ Slog.e(TAG, "Backup/restore confirmation requested but no token passed!");
+ finish();
+ return false;
+ }
+
+ return true;
+ }
+
+ private void setViews(Intent intent, Bundle icicle) {
+ mAction = intent.getAction();
+
+ // for relaunch, we try to use the last action before exit
+ if (icicle != null) {
+ mAction = icicle.getString(KEY_ACTION, mAction);
+ }
+
+ final int layoutId;
+ final int titleId;
+ if (mAction.equals(FullBackup.FULL_BACKUP_INTENT_ACTION)) {
+ layoutId = R.layout.confirm_backup;
+ titleId = R.string.backup_confirm_title;
+ } else if (mAction.equals(FullBackup.FULL_RESTORE_INTENT_ACTION)) {
+ layoutId = R.layout.confirm_restore;
+ titleId = R.string.restore_confirm_title;
+ } else {
+ Slog.w(TAG, "Backup/restore confirmation activity launched with invalid action!");
+ finish();
+ return;
+ }
+
setTitle(titleId);
setContentView(layoutId);
@@ -202,7 +243,7 @@ public class BackupRestoreConfirmation extends Activity {
// if we're a relaunch we may need to adjust button enable state
if (icicle != null) {
- mDidAcknowledge = icicle.getBoolean(DID_ACKNOWLEDGE, false);
+ mDidAcknowledge = icicle.getBoolean(KEY_DID_ACKNOWLEDGE, false);
mAllowButton.setEnabled(!mDidAcknowledge);
mDenyButton.setEnabled(!mDidAcknowledge);
}
@@ -249,7 +290,9 @@ public class BackupRestoreConfirmation extends Activity {
@Override
protected void onSaveInstanceState(Bundle outState) {
- outState.putBoolean(DID_ACKNOWLEDGE, mDidAcknowledge);
+ outState.putBoolean(KEY_DID_ACKNOWLEDGE, mDidAcknowledge);
+ outState.putInt(KEY_TOKEN, mToken);
+ outState.putString(KEY_ACTION, mAction);
}
void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) {