From 09c03ec912419f4e1fe3fbc5980843b4dbd73599 Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Tue, 19 Oct 2021 21:21:49 +0800 Subject: [PATCH] Fix ClassLoader issue of WindowContext The root cause of this issue is that we pass mClassLoader to new created Resources, but it may be null if we don't set ClassLoader from container. This CL fixes this issue by use ContextImpl#getClassLoader instead. Bug: 203027987 Test: reproducible steps mentioned in bug Change-Id: Ic88a351b3e9bbcf8382b9aefea63e2be2f190cb6 --- core/java/android/app/ContextImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 7114d73ae1683..b5ed1717496ed 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -2743,7 +2743,7 @@ class ContextImpl extends Context { */ private static Resources createWindowContextResources(@NonNull ContextImpl windowContextBase) { final LoadedApk packageInfo = windowContextBase.mPackageInfo; - final ClassLoader classLoader = windowContextBase.mClassLoader; + final ClassLoader classLoader = windowContextBase.getClassLoader(); final IBinder token = windowContextBase.getWindowContextToken(); final String resDir = packageInfo.getResDir();