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

Commit bbf39c43 authored by Wonyoung Kwak's avatar Wonyoung Kwak Committed by Automerger Merge Worker
Browse files

Revert "Modifying Backup code to support HSUM mode." am: 91e98fcb am: c687b625

parents 7f174397 c687b625
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -253,7 +253,7 @@ public class Bmgr {


        try {
        try {
            boolean enable = Boolean.parseBoolean(arg);
            boolean enable = Boolean.parseBoolean(arg);
            mBmgr.setAutoRestoreForUser(userId, enable);
            mBmgr.setAutoRestore(enable);
            System.out.println(
            System.out.println(
                    "Auto restore is now "
                    "Auto restore is now "
                            + (enable ? "enabled" : "disabled")
                            + (enable ? "enabled" : "disabled")
+0 −3
Original line number Original line Diff line number Diff line
@@ -56,7 +56,6 @@ public final class Backup {
    }
    }


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


        Log.d(TAG, "UserId : " + userId);

        String arg = nextArg();
        String arg = nextArg();
        if (arg.equals("backup")) {
        if (arg.equals("backup")) {
            doBackup(OsConstants.STDOUT_FILENO, userId);
            doBackup(OsConstants.STDOUT_FILENO, userId);
+1 −1
Original line number Original line Diff line number Diff line
@@ -813,7 +813,7 @@ public class BackupManagerService extends IBackupManager.Stub {
        }
        }
        UserBackupManagerService userBackupManagerService =
        UserBackupManagerService userBackupManagerService =
                getServiceForUserIfCallerHasPermission(
                getServiceForUserIfCallerHasPermission(
                        userId, "hasBackupPassword()");
                        UserHandle.USER_SYSTEM, "hasBackupPassword()");


        return userBackupManagerService != null && userBackupManagerService.hasBackupPassword();
        return userBackupManagerService != null && userBackupManagerService.hasBackupPassword();
    }
    }
+11 −1
Original line number Original line Diff line number Diff line
@@ -2797,6 +2797,11 @@ public class UserBackupManagerService {
            boolean includeSystem, boolean compress, boolean doKeyValue, String[] pkgList) {
            boolean includeSystem, boolean compress, boolean doKeyValue, String[] pkgList) {
        mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "adbBackup");
        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
        // Validate
        if (!doAllApps) {
        if (!doAllApps) {
            if (!includeShared) {
            if (!includeShared) {
@@ -2967,6 +2972,11 @@ public class UserBackupManagerService {
    public void adbRestore(ParcelFileDescriptor fd) {
    public void adbRestore(ParcelFileDescriptor fd) {
        mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "adbRestore");
        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();
        final long oldId = Binder.clearCallingIdentity();


        try {
        try {
@@ -3075,7 +3085,7 @@ public class UserBackupManagerService {
                    "com.android.backupconfirm.BackupRestoreConfirmation");
                    "com.android.backupconfirm.BackupRestoreConfirmation");
            confIntent.putExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, token);
            confIntent.putExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, token);
            confIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            confIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            mContext.startActivityAsUser(confIntent, UserHandle.of(mUserId));
            mContext.startActivityAsUser(confIntent, UserHandle.SYSTEM);
        } catch (ActivityNotFoundException e) {
        } catch (ActivityNotFoundException e) {
            return false;
            return false;
        }
        }
+2 −7
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.Shadows.shadowOf;
import static org.testng.Assert.expectThrows;
import static org.testng.Assert.expectThrows;


@@ -119,10 +118,6 @@ public class BackupManagerServiceRoboTest {
        mShadowUserManager.addUser(mUserOneId, "mUserOneId", 0);
        mShadowUserManager.addUser(mUserOneId, "mUserOneId", 0);
        mShadowUserManager.addUser(mUserTwoId, "mUserTwoId", 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(BACKUP);
        mShadowContext.grantPermissions(INTERACT_ACROSS_USERS_FULL);
        mShadowContext.grantPermissions(INTERACT_ACROSS_USERS_FULL);


@@ -1474,9 +1469,9 @@ public class BackupManagerServiceRoboTest {
        File testFile = createTestFile();
        File testFile = createTestFile();
        FileDescriptor fileDescriptor = new FileDescriptor();
        FileDescriptor fileDescriptor = new FileDescriptor();
        PrintWriter printWriter = new PrintWriter(testFile);
        PrintWriter printWriter = new PrintWriter(testFile);
        String[] args = {"1", "2"};
        ShadowBinder.setCallingUserHandle(UserHandle.of(UserHandle.USER_SYSTEM));
        ShadowBinder.setCallingUserHandle(UserHandle.of(UserHandle.USER_SYSTEM));


        String[] args = {"--user", "0"};
        backupManagerService.dump(fileDescriptor, printWriter, args);
        backupManagerService.dump(fileDescriptor, printWriter, args);


        verify(mUserSystemService).dump(fileDescriptor, printWriter, args);
        verify(mUserSystemService).dump(fileDescriptor, printWriter, args);
@@ -1490,8 +1485,8 @@ public class BackupManagerServiceRoboTest {
        File testFile = createTestFile();
        File testFile = createTestFile();
        FileDescriptor fileDescriptor = new FileDescriptor();
        FileDescriptor fileDescriptor = new FileDescriptor();
        PrintWriter printWriter = new PrintWriter(testFile);
        PrintWriter printWriter = new PrintWriter(testFile);
        String[] args = {"1", "2"};


        String[] args = {"--user", "10"};
        backupManagerService.dump(fileDescriptor, printWriter, args);
        backupManagerService.dump(fileDescriptor, printWriter, args);


        verify(mUserOneService, never()).dump(fileDescriptor, printWriter, args);
        verify(mUserOneService, never()).dump(fileDescriptor, printWriter, args);
Loading