diff options
author | 2024-11-25 18:37:00 +0000 | |
---|---|---|
committer | 2024-11-27 15:35:53 +0000 | |
commit | b87b97921307a0476f017aec2ae42bbcb58995bd (patch) | |
tree | 1f1d1e5429e1a3b49de07e09e2ef84a611af2023 /services/robotests/backup | |
parent | 00ea92a596fd031730828dd2b0b5fd9b3beee865 (diff) |
Don't kill apps if they are not in restricted mode
Also respect the killAfterRestore flag for them.
Before this change, the android:killAfterRestore attribute was only
respected for apps that do Key/Value backups. This was because Full
backup apps used to always be started in restricted mode for B&R
operations and the framework needed to kill the app to reset the
restricted mode state.
Now, full backup apps may not be started in restricted mode
(after ag/30155472) so there's no need to kill them unless if they set
killAfterRestore.
For this to work, we need to keep track of whether an app is in
restricted mode. I've moved all connection/disconnection logic to the
new connection manager class so this is now fairly easy.
Note that apps will only not be in restricted mode if they are K/V or if
enable_restricted_mode_changes is enabled and they opted out. So I think
all the new behavior is guarded by the same flag.
Flag: com.android.server.backup.enable_restricted_mode_changes
Bug: 376661510
Test: atest BackupAgentConnectionManagerTest & atest CtsBackupHostTestCases
Change-Id: I1e94fb3b794961904a6c603ac34b00f3878f4e3e
Diffstat (limited to 'services/robotests/backup')
-rw-r--r-- | services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java index aeb1ba93f049..de16b7ee8126 100644 --- a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +++ b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java @@ -865,7 +865,8 @@ public class KeyValueBackupTaskTest { runTask(task); verify(mBackupManagerService).setWorkSource(null); - verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(PACKAGE_1))); + verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(PACKAGE_1)), + eq(false)); } @Test @@ -1101,7 +1102,8 @@ public class KeyValueBackupTaskTest { runTask(task); verify(agentMock.agentBinder).fail(any()); - verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(PACKAGE_1))); + verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(PACKAGE_1)), + eq(false)); } @Test @@ -1423,7 +1425,7 @@ public class KeyValueBackupTaskTest { assertCleansUpFiles(mTransport, PM_PACKAGE); // We don't unbind PM verify(mBackupAgentConnectionManager, never()).unbindAgent( - argThat(applicationInfo(PM_PACKAGE))); + argThat(applicationInfo(PM_PACKAGE)), eq(false)); } @Test @@ -1445,7 +1447,7 @@ public class KeyValueBackupTaskTest { runTask(task); verify(mBackupAgentConnectionManager, never()).unbindAgent( - argThat(applicationInfo(PM_PACKAGE))); + argThat(applicationInfo(PM_PACKAGE)), eq(false)); } @Test @@ -1651,7 +1653,7 @@ public class KeyValueBackupTaskTest { InOrder inOrder = inOrder(agentMock.agent, mBackupAgentConnectionManager); inOrder.verify(agentMock.agent).onQuotaExceeded(anyLong(), eq(1234L)); inOrder.verify(mBackupAgentConnectionManager).unbindAgent( - argThat(applicationInfo(PACKAGE_1))); + argThat(applicationInfo(PACKAGE_1)), eq(false)); } @Test @@ -2983,7 +2985,8 @@ public class KeyValueBackupTaskTest { private void assertCleansUpFilesAndAgent(TransportData transport, PackageData packageData) { assertCleansUpFiles(transport, packageData); - verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(packageData))); + verify(mBackupAgentConnectionManager).unbindAgent(argThat(applicationInfo(packageData)), + eq(false)); } private void assertCleansUpFiles(TransportData transport, PackageData packageData) { |