Skip to content
Commit 6118857c authored by Paul Hadfield's avatar Paul Hadfield
Browse files

Trigger unbindBackupAgent if app dies during backup

This is to fix a bug where, if an app crashes in restricted mode,
when the user restarts the app, it would be launched still in
restricted mode. That happens because ActivityManager still has
a BackupRecord indicating that the app should be in restricted
mode, so next time the app launches, attachApplicationLocked()
calls IApplicationThread.bindApplication() with the restricted
mode flag set.

To avoid this we must complete the clean up actions done when
backup agents report errors. UserBackupManagerService has a
call-back method agentDisconnected() that is notified if an
agent dies. In that method we call handleCancel() on all
outstanding operations that are linked to the package name,
according to OperationStorage.  The result is a call to the
Activity Manager's unbindBackupAgent() which then removes the
obsolete BackupRecord.

Two new tests for agentDisconnected() verify that appropriate
calls are made to OperationStore.

BUG: 161089758
Test: atest FrameworksServicesTests:com.android.server.backup
      atest BackupFrameworksServicesRoboTests
      atest CtsBackupHostTestCases
      atest CtsBackupTestCases
      atest GtsBackupTestCase
      Also, manual testing with an app that deliberately dies
      during full backup: the lifecycle operation storage is
      used to cancel the backup; the app restarts in normal
      and not restricted mode.
Change-Id: Ic4cf3875d59e3580b026340e884093f3aa1b09b9
parent 789acb12
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment