From 7fa150d568ba84f3885a19a3d6712b989b0f16bb Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Tue, 20 Dec 2022 10:36:45 -0800 Subject: [PATCH] Adds user id on exception thrown by getSharedPreferences() Test: m Bug: 263264229 Change-Id: I3cd2f7213c88fd59aa69c0d4c40fd77d898345e8 --- core/java/android/app/ContextImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 39f71539b380b..9da044ce06bfb 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -573,7 +573,8 @@ class ContextImpl extends Context { && !getSystemService(UserManager.class) .isUserUnlockingOrUnlocked(UserHandle.myUserId())) { throw new IllegalStateException("SharedPreferences in credential encrypted " - + "storage are not available until after user is unlocked"); + + "storage are not available until after user (id " + + UserHandle.myUserId() + ") is unlocked"); } } sp = new SharedPreferencesImpl(file, mode); @@ -3193,7 +3194,6 @@ class ContextImpl extends Context { @Nullable String splitName, @Nullable IBinder token, @Nullable UserHandle user, int flags, @Nullable ClassLoader classLoader, @Nullable String overrideOpPackageName) { mOuterContext = this; - // If creator didn't specify which storage to use, use the default // location for application. if ((flags & (Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE