Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 728a1c4d authored by Christopher Tate's avatar Christopher Tate
Browse files

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
parent 80df829e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -185,7 +185,8 @@ interface IBackupManager {
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     */
    void acknowledgeFullBackupOrRestore(int token, boolean allow, in String password,
    void acknowledgeFullBackupOrRestore(int token, boolean allow,
            in String curPassword, in String encryptionPassword,
            IFullBackupRestoreObserver observer);

    /**
+17 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:padding="10dp" >
                android:padding="16dp" >

    <TextView android:id="@+id/confirm_text"
              android:layout_width="match_parent" 
@@ -34,12 +34,26 @@
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:text="@string/backup_password_text" />
              android:text="@string/current_password_text" />

    <EditText android:id="@+id/password"
              android:layout_below="@id/password_desc"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:password="true" />

    <TextView android:id="@+id/enc_password_desc"
              android:layout_below="@id/password"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:text="@string/backup_enc_password_text" />

    <EditText android:id="@+id/enc_password"
              android:layout_below="@id/enc_password_desc"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="30dp"
              android:password="true" />

@@ -47,7 +61,7 @@
              android:layout_width="match_parent"
              android:layout_height="20dp"
              android:layout_marginLeft="30dp"
              android:layout_below="@id/password"
              android:layout_below="@id/enc_password"
              android:layout_marginBottom="30dp" />

    <Button android:id="@+id/button_allow"
+17 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:padding="10dp" >
                android:padding="16dp" >

    <TextView android:id="@+id/confirm_text"
              android:layout_width="match_parent" 
@@ -34,7 +34,7 @@
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:text="@string/restore_password_text" />
              android:text="@string/current_password_text" />

    <EditText android:id="@+id/password"
              android:layout_below="@id/password_desc"
@@ -43,11 +43,25 @@
              android:layout_marginBottom="30dp"
              android:password="true" />

    <TextView android:id="@+id/enc_password_desc"
              android:layout_below="@id/password"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:text="@string/restore_enc_password_text" />

    <EditText android:id="@+id/enc_password"
              android:layout_below="@id/enc_password_desc"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="30dp"
              android:password="true" />

    <TextView android:id="@+id/package_name"
              android:layout_width="match_parent"
              android:layout_height="20dp"
              android:layout_marginLeft="30dp"
              android:layout_below="@id/password"
              android:layout_below="@id/enc_password"
              android:layout_marginBottom="30dp" />

    <Button android:id="@+id/button_allow"
+6 −3
Original line number Diff line number Diff line
@@ -30,10 +30,13 @@
    <string name="deny_restore_button_label">Do not restore</string>

    <!-- Text for message to user that they must enter their predefined backup password in order to perform this operation. -->
    <string name="backup_password_text">Please enter your predefined backup password below. The full backup will also be encrypted using this password:</string>
    <string name="current_password_text">Please enter your current backup password below:</string>

    <!-- Text for message to user that they can must enter an encryption password to use for the full backup operation. -->
    <string name="backup_enc_password_text">Please enter a password to use for encrypting the full backup data. If this is left blank, your current backup password will be used:</string>
    <!-- Text for message to user that they may optionally supply an encryption password to use for a full backup operation. -->
    <string name="backup_password_optional">If you wish to encrypt the full backup data, enter a password below:</string>
    <string name="backup_enc_password_optional">If you wish to encrypt the full backup data, enter a password below:</string>

    <!-- Text for message to user when performing a full restore operation, explaining that they must enter the password originally used to encrypt the full backup data. -->
    <string name="restore_password_text">If the backup data is encrypted, please enter the password below:</string>
    <string name="restore_enc_password_text">If the restore data is encrypted, please enter the password below:</string>
</resources>
+26 −14
Original line number Diff line number Diff line
@@ -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
        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 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
                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.
Loading