summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2022-10-31 23:19:02 +0000
committerEric Biggers <ebiggers@google.com>2022-11-03 02:15:08 +0000
commit94d84f0f5f76a7826c30bb27e8d423512e9ef4df (patch)
treeaa2773d3fdc74cd57793b0181960edd8318ff064
parent0fdfd7d196da0a01331429f00524df3f037cc519 (diff)
downloadbase-94d84f0f5f76a7826c30bb27e8d423512e9ef4df.tar.gz
Catch exceptions from prepareUserStorage() in loadPrivatePackagesInner()
There is a race condition where loadPrivatePackagesInner() can run after the volume has already been unmounted, and even reformatted as a public volume. This race can be triggered by AdoptableHostTest in CTS. Until the volume state change handling logic is fixed, it is necessary to ignore the RuntimeException that sm.prepareUserStorage() can throw after commit 9d2bb776ed13 (https://r.android.com/1959519). Bug: 253711749 Bug: 253868095 Change-Id: I9985eb5e410a5a5ff41935c806370826c6e4117d Merged-In: I9985eb5e410a5a5ff41935c806370826c6e4117d (cherry picked from commit 415ed9afd69787a41cbe51c8827034eb21fdd88a)
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index be9496ecc663..a61e210a18fa 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -22616,8 +22616,11 @@ public class PackageManagerService extends IPackageManager.Stub
synchronized (mInstallLock) {
reconcileAppsDataLI(volumeUuid, user.id, flags, true /* migrateAppData */);
}
- } catch (IllegalStateException e) {
- // Device was probably ejected, and we'll process that event momentarily
+ } catch (RuntimeException e) {
+ // The volume was probably already unmounted. We'll probably process the unmount
+ // event momentarily. TODO(b/256909937): ignoring errors from prepareUserStorage()
+ // is very dangerous. Instead, we should fix the race condition that allows this
+ // code to run on an unmounted volume in the first place.
Slog.w(TAG, "Failed to prepare storage: " + e);
}
}