diff options
author | Christopher Tate <ctate@google.com> | 2015-01-27 15:33:40 -0800 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2015-01-27 15:58:36 -0800 |
commit | 14d0e1a4e14c1180b813d4932ba4f70ca1c8e185 (patch) | |
tree | 1ac112b60c1b85e00c442022383175b5c752f479 /packages/BackupRestoreConfirmation | |
parent | be3731f028cf815d51e7c49b7415d7d1e8ac3639 (diff) | |
download | frameworks_base-14d0e1a4e14c1180b813d4932ba4f70ca1c8e185.zip frameworks_base-14d0e1a4e14c1180b813d4932ba4f70ca1c8e185.tar.gz frameworks_base-14d0e1a4e14c1180b813d4932ba4f70ca1c8e185.tar.bz2 |
Enforce backup encryption in the UI, not just in effect
Encryption is required when using 'adb backup' on encrypted devices,
but the UI has not been enforcing this. The failure mode is quite
confusing: the user can tap "back up my data" with no encryption
phrase supplied, and the confirmation activity disappears, but
the backup doesn't actually happen.
We now disallow confirming the backup unless a non-empty passphrase
has been entered into the UI.
In addition, tapping "do not back up my data" now finishes
the confirmation activity instead of just leaving it in a
confusing "dead" state.
Bug 19081192
Change-Id: I9ca69a08ff4322fe25129f9ca880b066c31525d0
Diffstat (limited to 'packages/BackupRestoreConfirmation')
-rw-r--r-- | packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java index c2bb90c..0b7b99f 100644 --- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -29,7 +29,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.storage.IMountService; import android.os.storage.StorageManager; -import android.util.Log; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Slog; import android.view.View; import android.widget.Button; @@ -180,20 +181,6 @@ public class BackupRestoreConfirmation extends Activity { 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, and whether - // the device is encrypted. - mIsEncrypted = deviceIsEncrypted(); - 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(mIsEncrypted - ? R.string.backup_enc_password_required - : R.string.backup_enc_password_optional); - } - } - mAllowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -209,6 +196,7 @@ public class BackupRestoreConfirmation extends Activity { sendAcknowledgement(mToken, false, mObserver); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); + finish(); } }); @@ -218,6 +206,39 @@ public class BackupRestoreConfirmation extends Activity { mAllowButton.setEnabled(!mDidAcknowledge); mDenyButton.setEnabled(!mDidAcknowledge); } + + // We vary the password prompt depending on whether one is predefined, and whether + // the device is encrypted. + mIsEncrypted = deviceIsEncrypted(); + 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); + if (mIsEncrypted) { + encPwDesc.setText(R.string.backup_enc_password_required); + monitorEncryptionPassword(); + } else { + encPwDesc.setText(R.string.backup_enc_password_optional); + } + } + } + } + + private void monitorEncryptionPassword() { + mAllowButton.setEnabled(false); + mEncPassword.addTextChangedListener(new TextWatcher() { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } + + @Override + public void afterTextChanged(Editable s) { + mAllowButton.setEnabled(mEncPassword.getText().length() > 0); + } + }); } // Preserve the restore observer callback binder across activity relaunch |