Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d9d0b9d authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Automerger Merge Worker
Browse files

Merge "Attempt at fixing race condition during boot." into rvc-dev am:...

Merge "Attempt at fixing race condition during boot." into rvc-dev am: e3a6cb22 am: 52a5225d am: fa9209fe am: e06c89fa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11898403

Change-Id: If8b1669abd19613c055bf7fe7435fb226bf59ae8
parents 228eeacd e06c89fa
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -3536,6 +3536,13 @@ class StorageManagerService extends IStorageManager.Stub
        // point
        final boolean systemUserUnlocked = isSystemUnlocked(UserHandle.USER_SYSTEM);

        // When the caller is the app actually hosting external storage, we
        // should never attempt to augment the actual storage volume state,
        // otherwise we risk confusing it with race conditions as users go
        // through various unlocked states
        final boolean callerIsMediaStore = UserHandle.isSameApp(Binder.getCallingUid(),
                mMediaStoreAuthorityAppId);

        final boolean userIsDemo;
        final boolean userKeyUnlocked;
        final boolean storagePermission;
@@ -3555,6 +3562,7 @@ class StorageManagerService extends IStorageManager.Stub
        final ArraySet<String> resUuids = new ArraySet<>();
        synchronized (mLock) {
            for (int i = 0; i < mVolumes.size(); i++) {
                final String volId = mVolumes.keyAt(i);
                final VolumeInfo vol = mVolumes.valueAt(i);
                switch (vol.getType()) {
                    case VolumeInfo.TYPE_PUBLIC:
@@ -3579,11 +3587,19 @@ class StorageManagerService extends IStorageManager.Stub
                if (!match) continue;

                boolean reportUnmounted = false;
                if (!systemUserUnlocked) {
                if (callerIsMediaStore) {
                    // When the caller is the app actually hosting external storage, we
                    // should never attempt to augment the actual storage volume state,
                    // otherwise we risk confusing it with race conditions as users go
                    // through various unlocked states
                } else if (!systemUserUnlocked) {
                    reportUnmounted = true;
                    Slog.w(TAG, "Reporting " + volId + " unmounted due to system locked");
                } else if ((vol.getType() == VolumeInfo.TYPE_EMULATED) && !userKeyUnlocked) {
                    reportUnmounted = true;
                    Slog.w(TAG, "Reporting " + volId + "unmounted due to " + userId + " locked");
                } else if (!storagePermission && !realState) {
                    Slog.w(TAG, "Reporting " + volId + "unmounted due to missing permissions");
                    reportUnmounted = true;
                }