From e96481776f5fb3427afe501e938c65fcae220f70 Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Thu, 1 Apr 2021 09:55:41 +0200 Subject: [PATCH] Fix StorageVolume creation for clone users. The StorageVolume should be created with the actual mount user id, not the user id of the MediaProvider that we're using to host it. Bug: 182396009 Test: inspect StorageVolume state after starting a clone user Change-Id: I9644eb85376e8ffdddf77bec0d06867118cd16b8 --- .../android/server/storage/StorageSessionController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/storage/StorageSessionController.java b/services/core/java/com/android/server/storage/StorageSessionController.java index ff6c2f551bb38..5f5e6a3e6f462 100644 --- a/services/core/java/com/android/server/storage/StorageSessionController.java +++ b/services/core/java/com/android/server/storage/StorageSessionController.java @@ -147,17 +147,18 @@ public final class StorageSessionController { return; } String sessionId = vol.getId(); - int userId = getConnectionUserIdForVolume(vol); + int connectionUserId = getConnectionUserIdForVolume(vol); StorageUserConnection connection = null; synchronized (mLock) { - connection = mConnections.get(userId); + connection = mConnections.get(connectionUserId); if (connection != null) { Slog.i(TAG, "Notifying volume state changed for session with id: " + sessionId); connection.notifyVolumeStateChanged(sessionId, - vol.buildStorageVolume(mContext, userId, false)); + vol.buildStorageVolume(mContext, vol.getMountUserId(), false)); } else { - Slog.w(TAG, "No available storage user connection for userId : " + userId); + Slog.w(TAG, "No available storage user connection for userId : " + + connectionUserId); } } }