Revert "Modifying Backup code to support HSUM mode."

Revert submission 22327091-br-cts-hsum

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_udc-dev&target=aosp_bramble-userdebug&lkgb=10098913&lkbb=10101009&fkbb=10098962, bug 281753581.

Bug: 281753581

Reverted changes: /q/submissionid:22327091-br-cts-hsum

Change-Id: I4de169440f587d5a458300a5f360ba974239e530
This commit is contained in:
Wonyoung Kwak
2023-05-10 05:16:08 +00:00
committed by Android (Google) Code Review
parent 6cf0c3038b
commit 91e98fcb5a
6 changed files with 15 additions and 16 deletions

View File

@@ -253,7 +253,7 @@ public class Bmgr {
try {
boolean enable = Boolean.parseBoolean(arg);
mBmgr.setAutoRestoreForUser(userId, enable);
mBmgr.setAutoRestore(enable);
System.out.println(
"Auto restore is now "
+ (enable ? "enabled" : "disabled")

View File

@@ -56,7 +56,6 @@ public final class Backup {
}
public void run(String[] args) {
Log.d(TAG, "Called run() with args: " + String.join(" ", args));
if (mBackupManager == null) {
Log.e(TAG, "Can't obtain Backup Manager binder");
return;
@@ -71,8 +70,6 @@ public final class Backup {
return;
}
Log.d(TAG, "UserId : " + userId);
String arg = nextArg();
if (arg.equals("backup")) {
doBackup(OsConstants.STDOUT_FILENO, userId);

View File

@@ -813,7 +813,7 @@ public class BackupManagerService extends IBackupManager.Stub {
}
UserBackupManagerService userBackupManagerService =
getServiceForUserIfCallerHasPermission(
userId, "hasBackupPassword()");
UserHandle.USER_SYSTEM, "hasBackupPassword()");
return userBackupManagerService != null && userBackupManagerService.hasBackupPassword();
}

View File

@@ -2797,6 +2797,11 @@ public class UserBackupManagerService {
boolean includeSystem, boolean compress, boolean doKeyValue, String[] pkgList) {
mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "adbBackup");
final int callingUserHandle = UserHandle.getCallingUserId();
if (callingUserHandle != UserHandle.USER_SYSTEM) {
throw new IllegalStateException("Backup supported only for the device owner");
}
// Validate
if (!doAllApps) {
if (!includeShared) {
@@ -2967,6 +2972,11 @@ public class UserBackupManagerService {
public void adbRestore(ParcelFileDescriptor fd) {
mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "adbRestore");
final int callingUserHandle = UserHandle.getCallingUserId();
if (callingUserHandle != UserHandle.USER_SYSTEM) {
throw new IllegalStateException("Restore supported only for the device owner");
}
final long oldId = Binder.clearCallingIdentity();
try {
@@ -3075,7 +3085,7 @@ public class UserBackupManagerService {
"com.android.backupconfirm.BackupRestoreConfirmation");
confIntent.putExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, token);
confIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
mContext.startActivityAsUser(confIntent, UserHandle.of(mUserId));
mContext.startActivityAsUser(confIntent, UserHandle.SYSTEM);
} catch (ActivityNotFoundException e) {
return false;
}

View File

@@ -33,7 +33,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import static org.testng.Assert.expectThrows;
@@ -119,10 +118,6 @@ public class BackupManagerServiceRoboTest {
mShadowUserManager.addUser(mUserOneId, "mUserOneId", 0);
mShadowUserManager.addUser(mUserTwoId, "mUserTwoId", 0);
when(mUserSystemService.getUserId()).thenReturn(UserHandle.USER_SYSTEM);
when(mUserOneService.getUserId()).thenReturn(mUserOneId);
when(mUserTwoService.getUserId()).thenReturn(mUserTwoId);
mShadowContext.grantPermissions(BACKUP);
mShadowContext.grantPermissions(INTERACT_ACROSS_USERS_FULL);
@@ -1474,9 +1469,9 @@ public class BackupManagerServiceRoboTest {
File testFile = createTestFile();
FileDescriptor fileDescriptor = new FileDescriptor();
PrintWriter printWriter = new PrintWriter(testFile);
String[] args = {"1", "2"};
ShadowBinder.setCallingUserHandle(UserHandle.of(UserHandle.USER_SYSTEM));
String[] args = {"--user", "0"};
backupManagerService.dump(fileDescriptor, printWriter, args);
verify(mUserSystemService).dump(fileDescriptor, printWriter, args);
@@ -1490,8 +1485,8 @@ public class BackupManagerServiceRoboTest {
File testFile = createTestFile();
FileDescriptor fileDescriptor = new FileDescriptor();
PrintWriter printWriter = new PrintWriter(testFile);
String[] args = {"1", "2"};
String[] args = {"--user", "10"};
backupManagerService.dump(fileDescriptor, printWriter, args);
verify(mUserOneService, never()).dump(fileDescriptor, printWriter, args);

View File

@@ -618,7 +618,6 @@ public class BackupManagerServiceTest {
@Test
public void testDumpForOneUser_callerDoesNotHaveInteractAcrossUsersFullPermission_ignored() {
createBackupManagerServiceAndUnlockSystemUser();
mService.setBackupServiceActive(NON_SYSTEM_USER, true);
simulateUserUnlocked(NON_SYSTEM_USER);
@@ -638,7 +637,6 @@ public class BackupManagerServiceTest {
@Test
public void
testDumpForOneUser_callerHasInteractAcrossUsersFullPermission_dumpsOnlySpecifiedUser() {
createBackupManagerServiceAndUnlockSystemUser();
mService.setBackupServiceActive(NON_SYSTEM_USER, true);
simulateUserUnlocked(NON_SYSTEM_USER);
@@ -650,7 +648,6 @@ public class BackupManagerServiceTest {
@Test
public void testDumpForAllUsers_callerHasInteractAcrossUsersFullPermission_dumpsAllUsers() {
createBackupManagerServiceAndUnlockSystemUser();
mService.setBackupServiceActive(NON_SYSTEM_USER, true);
simulateUserUnlocked(NON_SYSTEM_USER);