From 6a43e4ada7f8ff51654ece963cdbe8ee53ccf221 Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Tue, 11 May 2021 12:14:36 +0200 Subject: [PATCH] StorageManagerService: remove automotive special casing. The race issues that this intends to solve also come up on regular devices (see the linked bug); since our partners also rely on this change to work, let's have it on by default, and make sure it's tested properly. Bug: 178446470 Test: boot device Change-Id: I0c49c84ca116cfaa09a584d41ce7403fabea8de1 --- .../android/server/StorageManagerService.java | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 976fd7ddeebf6..a95e1fed4dcfd 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -444,12 +444,6 @@ class StorageManagerService extends IStorageManager.Stub "(?i)(^/storage/[^/]+/(?:([0-9]+)/)?Android/(?:data|media|obb|sandbox)/)([^/]+)(/.*)?"); - /** Automotive device unlockes users before system boot complete and this requires special - * handling as vold reset can lead into race conditions. When this is set, all users unlocked - * in {@code UserManager} level are unlocked after vold reset. - */ - private final boolean mIsAutomotive; - private VolumeInfo findVolumeByIdOrThrow(String id) { synchronized (mLock) { final VolumeInfo vol = mVolumes.get(id); @@ -1122,9 +1116,7 @@ class StorageManagerService extends IStorageManager.Stub mVold.onUserStarted(userId); mStoraged.onUserStarted(userId); } - if (mIsAutomotive) { - restoreSystemUnlockedUsers(userManager, users, systemUnlockedUsers); - } + restoreSystemUnlockedUsers(userManager, users, systemUnlockedUsers); mVold.onSecureKeyguardStateChanged(mSecureKeyguardShowing); mStorageManagerInternal.onReset(mVold); } catch (Exception e) { @@ -1204,13 +1196,11 @@ class StorageManagerService extends IStorageManager.Stub // Record user as started so newly mounted volumes kick off events // correctly, then synthesize events for any already-mounted volumes. synchronized (mLock) { - if (mIsAutomotive) { - for (int unlockedUser : mSystemUnlockedUsers) { - if (unlockedUser == userId) { - // This can happen as restoreAllUnlockedUsers can double post the message. - Log.i(TAG, "completeUnlockUser called for already unlocked user:" + userId); - return; - } + for (int unlockedUser : mSystemUnlockedUsers) { + if (unlockedUser == userId) { + // This can happen as restoreAllUnlockedUsers can double post the message. + Log.i(TAG, "completeUnlockUser called for already unlocked user:" + userId); + return; } } for (int i = 0; i < mVolumes.size(); i++) { @@ -1906,9 +1896,6 @@ class StorageManagerService extends IStorageManager.Stub if (WATCHDOG_ENABLE) { Watchdog.getInstance().addMonitor(this); } - - mIsAutomotive = context.getPackageManager().hasSystemFeature( - PackageManager.FEATURE_AUTOMOTIVE); } private void start() { @@ -4581,7 +4568,6 @@ class StorageManagerService extends IStorageManager.Stub pw.println(); pw.println("Local unlocked users: " + mLocalUnlockedUsers); pw.println("System unlocked users: " + Arrays.toString(mSystemUnlockedUsers)); - pw.println("isAutomotive:" + mIsAutomotive); } synchronized (mObbMounts) {