diff options
author | 2024-12-19 22:06:38 +0000 | |
---|---|---|
committer | 2024-12-23 16:54:10 +0000 | |
commit | bb80de0b84e607a07be352f0820fdd179432b808 (patch) | |
tree | eb50389ed193e4b9db897a509a5bc5aec45cea55 /services/robotests/backup | |
parent | 75929fcf5b46c310035a080709a612fb80273516 (diff) |
Acquire the backup wakelock with a timeout
There have been a few reports of the backup service failing to call
release() on the wakelock and draining battery for hours. These are rare
failures and hard to debug individually but with the timeout we will
limit the worst case significantly.
I am setting the default timeout to 30 minutes. This should be more than
enough time for a backup or restore operation. If in the future these
operation get longer, the timeout is configurable by a setting.
Test: atest CtsBackupTestCases
Fixes: 364931501
Fixes: 357769443
Fixes: 289789401
Flag: EXEMPT bugfix
Change-Id: Iaac0218d5258031b6f67c3c56c776ce098e8a8c4
Diffstat (limited to 'services/robotests/backup')
-rw-r--r-- | services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java b/services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java index fc3ec7b44f4f..4d04c8b76fc7 100644 --- a/services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java +++ b/services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java @@ -37,6 +37,7 @@ import android.os.Process; import android.util.Log; import com.android.server.backup.BackupAgentTimeoutParameters; +import com.android.server.backup.BackupManagerConstants; import com.android.server.backup.BackupManagerService; import com.android.server.backup.TransportManager; import com.android.server.backup.UserBackupManagerService; @@ -162,10 +163,10 @@ public class BackupManagerServiceTestUtils { public static UserBackupManagerService.BackupWakeLock createBackupWakeLock( Application application) { - PowerManager powerManager = - (PowerManager) application.getSystemService(Context.POWER_SERVICE); + PowerManager powerManager = application.getSystemService(PowerManager.class); return new UserBackupManagerService.BackupWakeLock( - powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*backup*"), 0); + powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*backup*"), 0, + new BackupManagerConstants(Handler.getMain(), application.getContentResolver())); } /** |