Loading core/java/android/app/ActivityThread.java +19 −2 Original line number Diff line number Diff line Loading @@ -221,6 +221,7 @@ public final class ActivityThread { private long mNetworkBlockSeq = INVALID_PROC_STATE_SEQ; private ContextImpl mSystemContext; private ContextImpl mSystemUiContext; static volatile IPackageManager sPackageManager; Loading Loading @@ -2190,9 +2191,19 @@ public final class ActivityThread { } } public ContextImpl getSystemUiContext() { synchronized (this) { if (mSystemUiContext == null) { mSystemUiContext = ContextImpl.createSystemUiContext(this); } return mSystemUiContext; } } public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { synchronized (this) { getSystemContext().installSystemApplicationInfo(info, classLoader); getSystemUiContext().installSystemApplicationInfo(info, classLoader); // give ourselves a default profiler mProfiler = new Profiler(); Loading Loading @@ -5031,6 +5042,11 @@ public final class ActivityThread { if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { systemTheme.rebase(); } final Theme systemUiTheme = getSystemUiContext().getTheme(); if ((systemUiTheme.getChangingConfigurations() & configDiff) != 0) { systemUiTheme.rebase(); } } ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config); Loading Loading @@ -5086,9 +5102,10 @@ public final class ActivityThread { // Trigger a regular Configuration change event, only with a different assetsSeq number // so that we actually call through to all components. // TODO(adamlesinski): Change this to make use of ActivityManager's upcoming ability to // store configurations per-process. Configuration newConfig = new Configuration(); newConfig.unset(); newConfig.assetsSeq = mConfiguration.assetsSeq + 1; newConfig.assetsSeq = (mConfiguration != null ? mConfiguration.assetsSeq : 0) + 1; handleConfigurationChanged(newConfig, null); // Schedule all activities to reload Loading core/java/android/app/ApplicationPackageManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1352,7 +1352,7 @@ public class ApplicationPackageManager extends PackageManager { public Resources getResourcesForApplication(@NonNull ApplicationInfo app) throws NameNotFoundException { if (app.packageName.equals("system")) { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemUiContext().getResources(); } final boolean sameUid = (app.uid == Process.myUid()); final Resources r = mContext.mMainThread.getTopLevelResources( Loading Loading @@ -1383,7 +1383,7 @@ public class ApplicationPackageManager extends PackageManager { "Call does not support special user #" + userId); } if ("system".equals(appPackageName)) { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemUiContext().getResources(); } try { ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, sDefaultFlags, userId); Loading core/java/android/app/ContextImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -2218,6 +2218,18 @@ class ContextImpl extends Context { return context; } /** * System Context to be used for UI. This Context has resources that can be themed. */ static ContextImpl createSystemUiContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0, null); context.setResources(createResources(null, packageInfo, null, Display.DEFAULT_DISPLAY, null, packageInfo.getCompatibilityInfo())); return context; } static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) { if (packageInfo == null) throw new IllegalArgumentException("packageInfo"); ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0, Loading core/java/android/app/ResourcesManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -984,7 +984,7 @@ public class ResourcesManager { final ResourcesKey key = mResourceImpls.keyAt(i); final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i); final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null; if (impl != null && key.mResDir != null && key.mResDir.equals(baseCodePath)) { if (impl != null && (key.mResDir == null || key.mResDir.equals(baseCodePath))) { updatedResourceKeys.put(impl, new ResourcesKey( key.mResDir, key.mSplitResDirs, Loading core/java/android/content/Context.java +14 −0 Original line number Diff line number Diff line Loading @@ -4631,4 +4631,18 @@ public abstract class Context { public Handler getMainThreadHandler() { throw new RuntimeException("Not implemented. Must override in a subclass."); } /** * Throws an exception if the Context is using system resources, * which are non-runtime-overlay-themable and may show inconsistent UI. * @hide */ public void assertRuntimeOverlayThemable() { // Resources.getSystem() is a singleton and the only Resources not managed by // ResourcesManager; therefore Resources.getSystem() is not themable. if (getResources() == Resources.getSystem()) { throw new IllegalArgumentException("Non-UI context used to display UI; " + "get a UI context from ActivityThread#getSystemUiContext()"); } } } Loading
core/java/android/app/ActivityThread.java +19 −2 Original line number Diff line number Diff line Loading @@ -221,6 +221,7 @@ public final class ActivityThread { private long mNetworkBlockSeq = INVALID_PROC_STATE_SEQ; private ContextImpl mSystemContext; private ContextImpl mSystemUiContext; static volatile IPackageManager sPackageManager; Loading Loading @@ -2190,9 +2191,19 @@ public final class ActivityThread { } } public ContextImpl getSystemUiContext() { synchronized (this) { if (mSystemUiContext == null) { mSystemUiContext = ContextImpl.createSystemUiContext(this); } return mSystemUiContext; } } public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { synchronized (this) { getSystemContext().installSystemApplicationInfo(info, classLoader); getSystemUiContext().installSystemApplicationInfo(info, classLoader); // give ourselves a default profiler mProfiler = new Profiler(); Loading Loading @@ -5031,6 +5042,11 @@ public final class ActivityThread { if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { systemTheme.rebase(); } final Theme systemUiTheme = getSystemUiContext().getTheme(); if ((systemUiTheme.getChangingConfigurations() & configDiff) != 0) { systemUiTheme.rebase(); } } ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config); Loading Loading @@ -5086,9 +5102,10 @@ public final class ActivityThread { // Trigger a regular Configuration change event, only with a different assetsSeq number // so that we actually call through to all components. // TODO(adamlesinski): Change this to make use of ActivityManager's upcoming ability to // store configurations per-process. Configuration newConfig = new Configuration(); newConfig.unset(); newConfig.assetsSeq = mConfiguration.assetsSeq + 1; newConfig.assetsSeq = (mConfiguration != null ? mConfiguration.assetsSeq : 0) + 1; handleConfigurationChanged(newConfig, null); // Schedule all activities to reload Loading
core/java/android/app/ApplicationPackageManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1352,7 +1352,7 @@ public class ApplicationPackageManager extends PackageManager { public Resources getResourcesForApplication(@NonNull ApplicationInfo app) throws NameNotFoundException { if (app.packageName.equals("system")) { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemUiContext().getResources(); } final boolean sameUid = (app.uid == Process.myUid()); final Resources r = mContext.mMainThread.getTopLevelResources( Loading Loading @@ -1383,7 +1383,7 @@ public class ApplicationPackageManager extends PackageManager { "Call does not support special user #" + userId); } if ("system".equals(appPackageName)) { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemUiContext().getResources(); } try { ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, sDefaultFlags, userId); Loading
core/java/android/app/ContextImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -2218,6 +2218,18 @@ class ContextImpl extends Context { return context; } /** * System Context to be used for UI. This Context has resources that can be themed. */ static ContextImpl createSystemUiContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0, null); context.setResources(createResources(null, packageInfo, null, Display.DEFAULT_DISPLAY, null, packageInfo.getCompatibilityInfo())); return context; } static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) { if (packageInfo == null) throw new IllegalArgumentException("packageInfo"); ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0, Loading
core/java/android/app/ResourcesManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -984,7 +984,7 @@ public class ResourcesManager { final ResourcesKey key = mResourceImpls.keyAt(i); final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i); final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null; if (impl != null && key.mResDir != null && key.mResDir.equals(baseCodePath)) { if (impl != null && (key.mResDir == null || key.mResDir.equals(baseCodePath))) { updatedResourceKeys.put(impl, new ResourcesKey( key.mResDir, key.mSplitResDirs, Loading
core/java/android/content/Context.java +14 −0 Original line number Diff line number Diff line Loading @@ -4631,4 +4631,18 @@ public abstract class Context { public Handler getMainThreadHandler() { throw new RuntimeException("Not implemented. Must override in a subclass."); } /** * Throws an exception if the Context is using system resources, * which are non-runtime-overlay-themable and may show inconsistent UI. * @hide */ public void assertRuntimeOverlayThemable() { // Resources.getSystem() is a singleton and the only Resources not managed by // ResourcesManager; therefore Resources.getSystem() is not themable. if (getResources() == Resources.getSystem()) { throw new IllegalArgumentException("Non-UI context used to display UI; " + "get a UI context from ActivityThread#getSystemUiContext()"); } } }