Remove checks for FDE in 'adb backup' am: bd03d7606d am: 615f824f8c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2016255

Change-Id: Iff7df7f2a50640cc95dc71f93993bb1039ffce40
This commit is contained in:
Eric Biggers
2022-03-15 17:52:39 +00:00
committed by Automerger Merge Worker
4 changed files with 2 additions and 61 deletions

View File

@@ -44,8 +44,6 @@
<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> <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. --> <!-- Text for message to user that they may optionally supply an encryption password to use for a full backup operation. -->
<string name="backup_enc_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 that they must supply an encryption password to use for a full backup operation because their phone is locked. -->
<string name="backup_enc_password_required">Since your device is encrypted, you are required to encrypt your backup. Please 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. --> <!-- 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_enc_password_text">If the restore 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>

View File

@@ -27,8 +27,6 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.os.storage.IStorageManager;
import android.os.storage.StorageManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Slog; import android.util.Slog;
@@ -66,10 +64,8 @@ public class BackupRestoreConfirmation extends Activity {
Handler mHandler; Handler mHandler;
IBackupManager mBackupManager; IBackupManager mBackupManager;
IStorageManager mStorageManager;
FullObserver mObserver; FullObserver mObserver;
int mToken; int mToken;
boolean mIsEncrypted;
boolean mDidAcknowledge; boolean mDidAcknowledge;
String mAction; String mAction;
@@ -144,7 +140,6 @@ public class BackupRestoreConfirmation extends Activity {
} }
mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE)); mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
mStorageManager = IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
mHandler = new ObserverHandler(getApplicationContext()); mHandler = new ObserverHandler(getApplicationContext());
final Object oldObserver = getLastNonConfigurationInstance(); final Object oldObserver = getLastNonConfigurationInstance();
@@ -248,20 +243,13 @@ public class BackupRestoreConfirmation extends Activity {
mDenyButton.setEnabled(!mDidAcknowledge); mDenyButton.setEnabled(!mDidAcknowledge);
} }
// We vary the password prompt depending on whether one is predefined, and whether // We vary the password prompt depending on whether one is predefined.
// the device is encrypted.
mIsEncrypted = deviceIsEncrypted();
if (!haveBackupPassword()) { if (!haveBackupPassword()) {
curPwDesc.setVisibility(View.GONE); curPwDesc.setVisibility(View.GONE);
mCurPassword.setVisibility(View.GONE); mCurPassword.setVisibility(View.GONE);
if (layoutId == R.layout.confirm_backup) { if (layoutId == R.layout.confirm_backup) {
TextView encPwDesc = findViewById(R.id.enc_password_desc); TextView encPwDesc = findViewById(R.id.enc_password_desc);
if (mIsEncrypted) { encPwDesc.setText(R.string.backup_enc_password_optional);
encPwDesc.setText(R.string.backup_enc_password_required);
monitorEncryptionPassword();
} else {
encPwDesc.setText(R.string.backup_enc_password_optional);
}
} }
} }
} }
@@ -312,20 +300,6 @@ public class BackupRestoreConfirmation extends Activity {
} }
} }
boolean deviceIsEncrypted() {
try {
return mStorageManager.getEncryptionState()
!= StorageManager.ENCRYPTION_STATE_NONE
&& mStorageManager.getPasswordType()
!= StorageManager.CRYPT_TYPE_DEFAULT;
} catch (Exception e) {
// If we can't talk to the storagemanager service we have a serious problem; fail
// "secure" i.e. assuming that the device is encrypted.
Slog.e(TAG, "Unable to communicate with storagemanager service: " + e.getMessage());
return true;
}
}
boolean haveBackupPassword() { boolean haveBackupPassword() {
try { try {
return mBackupManager.hasBackupPassword(); return mBackupManager.hasBackupPassword();

View File

@@ -89,8 +89,6 @@ import android.os.ServiceManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.WorkSource; import android.os.WorkSource;
import android.os.storage.IStorageManager;
import android.os.storage.StorageManager;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.ArraySet; import android.util.ArraySet;
@@ -336,7 +334,6 @@ public class UserBackupManagerService {
private final ActivityManagerInternal mActivityManagerInternal; private final ActivityManagerInternal mActivityManagerInternal;
private PowerManager mPowerManager; private PowerManager mPowerManager;
private final AlarmManager mAlarmManager; private final AlarmManager mAlarmManager;
private final IStorageManager mStorageManager;
private final BackupManagerConstants mConstants; private final BackupManagerConstants mConstants;
private final BackupWakeLock mWakelock; private final BackupWakeLock mWakelock;
private final BackupHandler mBackupHandler; private final BackupHandler mBackupHandler;
@@ -567,7 +564,6 @@ public class UserBackupManagerService {
mBackupPasswordManager = null; mBackupPasswordManager = null;
mPackageManagerBinder = null; mPackageManagerBinder = null;
mActivityManager = null; mActivityManager = null;
mStorageManager = null;
mBackupManagerBinder = null; mBackupManagerBinder = null;
mScheduledBackupEligibility = null; mScheduledBackupEligibility = null;
} }
@@ -591,7 +587,6 @@ public class UserBackupManagerService {
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mStorageManager = IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
Objects.requireNonNull(parent, "parent cannot be null"); Objects.requireNonNull(parent, "parent cannot be null");
mBackupManagerBinder = BackupManagerService.asInterface(parent.asBinder()); mBackupManagerBinder = BackupManagerService.asInterface(parent.asBinder());
@@ -2252,26 +2247,6 @@ public class UserBackupManagerService {
} }
} }
/** For adb backup/restore. */
public boolean deviceIsEncrypted() {
try {
return mStorageManager.getEncryptionState()
!= StorageManager.ENCRYPTION_STATE_NONE
&& mStorageManager.getPasswordType()
!= StorageManager.CRYPT_TYPE_DEFAULT;
} catch (Exception e) {
// If we can't talk to the storagemanager service we have a serious problem; fail
// "secure" i.e. assuming that the device is encrypted.
Slog.e(
TAG,
addUserIdToLogMessage(
mUserId,
"Unable to communicate with storagemanager service: "
+ e.getMessage()));
return true;
}
}
// ----- Full-data backup scheduling ----- // ----- Full-data backup scheduling -----
/** /**

View File

@@ -316,12 +316,6 @@ public class PerformAdbBackupTask extends FullBackupTask implements BackupRestor
try { try {
boolean encrypting = (mEncryptPassword != null && mEncryptPassword.length() > 0); boolean encrypting = (mEncryptPassword != null && mEncryptPassword.length() > 0);
// Only allow encrypted backups of encrypted devices
if (mUserBackupManagerService.deviceIsEncrypted() && !encrypting) {
Slog.e(TAG, "Unencrypted backup of encrypted device; aborting");
return;
}
OutputStream finalOutput = ofstream; OutputStream finalOutput = ofstream;
// Verify that the given password matches the currently-active // Verify that the given password matches the currently-active