From 728a1c4d5ed3b808172013a7f5bb5065d1e964f6 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 28 Jul 2011 18:03:03 -0700 Subject: Require the current backup pw in all backup/restore operations Specifically, we now also require the current password to confirm any restore operation. Bug 4901637 Change-Id: I39ecce7837f70cd05778cb7e0e6390ad8f6fe3f3 --- .../backupconfirm/BackupRestoreConfirmation.java | 40 ++++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'packages/BackupRestoreConfirmation/src/com/android/backupconfirm') diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java index fad58b9..f65a62f 100644 --- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -63,6 +63,8 @@ public class BackupRestoreConfirmation extends Activity { boolean mDidAcknowledge; TextView mStatusView; + TextView mCurPassword; + TextView mEncPassword; Button mAllowButton; Button mDenyButton; @@ -156,17 +158,17 @@ public class BackupRestoreConfirmation extends Activity { mAllowButton = (Button) findViewById(R.id.button_allow); mDenyButton = (Button) findViewById(R.id.button_deny); - // For full backup, we vary the password prompt text depending on whether one is predefined - if (layoutId == R.layout.confirm_backup) { - TextView pwDesc = (TextView) findViewById(R.id.password_desc); - try { - if (mBackupManager.hasBackupPassword()) { - pwDesc.setText(R.string.backup_password_text); - } else { - pwDesc.setText(R.string.backup_password_optional); - } - } catch (RemoteException e) { - // TODO: bail gracefully + mCurPassword = (TextView) findViewById(R.id.password); + mEncPassword = (TextView) findViewById(R.id.enc_password); + TextView curPwDesc = (TextView) findViewById(R.id.password_desc); + + // We vary the password prompt depending on whether one is predefined + if (!haveBackupPassword()) { + curPwDesc.setVisibility(View.GONE); + mCurPassword.setVisibility(View.GONE); + if (layoutId == R.layout.confirm_backup) { + TextView encPwDesc = (TextView) findViewById(R.id.enc_password_desc); + encPwDesc.setText(R.string.backup_enc_password_optional); } } @@ -204,15 +206,25 @@ public class BackupRestoreConfirmation extends Activity { mDidAcknowledge = true; try { - TextView pwView = (TextView) findViewById(R.id.password); - mBackupManager.acknowledgeFullBackupOrRestore(mToken, allow, - String.valueOf(pwView.getText()), mObserver); + mBackupManager.acknowledgeFullBackupOrRestore(mToken, + allow, + String.valueOf(mCurPassword.getText()), + String.valueOf(mEncPassword.getText()), + mObserver); } catch (RemoteException e) { // TODO: bail gracefully if we can't contact the backup manager } } } + boolean haveBackupPassword() { + try { + return mBackupManager.hasBackupPassword(); + } catch (RemoteException e) { + return true; // in the failure case, assume we need one + } + } + /** * The observer binder for showing backup/restore progress. This binder just bounces * the notifications onto the main thread. -- cgit v1.1