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

Commit 7f3f4998 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Allow multiple Resources associated with an Activity

Previously it was assumed that one Resources object per Activity would be fine.
This proved to be incorrect, as methods like Context#createConfigurationContext()
expect to create a new Resources object that gets updated whenever the Activity Resources
get updated.

To fix this issue, there exists a master override configuration for each Activity. Subsequent
Resources created for an Activity will be based off that master override configuration, and
will be updated accordingly.

Bug:27644297
Bug:27604953
Change-Id: Idb3d851f55ee7981eec4e3fe28e2ea8d55f1192d
parent 0ade7ff3
Loading
Loading
Loading
Loading
+29 −11
Original line number Original line Diff line number Diff line
@@ -1993,7 +1993,7 @@ class ContextImpl extends Context {
        ContextImpl context = new ContextImpl(null, mainThread,
        ContextImpl context = new ContextImpl(null, mainThread,
                packageInfo, null, null, 0, null, null, Display.INVALID_DISPLAY);
                packageInfo, null, null, 0, null, null, Display.INVALID_DISPLAY);
        context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
        context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
                context.mResourcesManager.getDisplayMetricsLocked());
                context.mResourcesManager.getDisplayMetrics());
        return context;
        return context;
    }
    }


@@ -2065,6 +2065,10 @@ class ContextImpl extends Context {
                    || overrideConfiguration != null
                    || overrideConfiguration != null
                    || (compatInfo != null && compatInfo.applicationScale
                    || (compatInfo != null && compatInfo.applicationScale
                            != resources.getCompatibilityInfo().applicationScale)) {
                            != resources.getCompatibilityInfo().applicationScale)) {

                if (container != null) {
                    // This is a nested Context, so it can't be a base Activity context.
                    // Just create a regular Resources object associated with the Activity.
                    resources = mResourcesManager.getResources(
                    resources = mResourcesManager.getResources(
                            activityToken,
                            activityToken,
                            packageInfo.getResDir(),
                            packageInfo.getResDir(),
@@ -2075,6 +2079,20 @@ class ContextImpl extends Context {
                            overrideConfiguration,
                            overrideConfiguration,
                            compatInfo,
                            compatInfo,
                            packageInfo.getClassLoader());
                            packageInfo.getClassLoader());
                } else {
                    // This is not a nested Context, so it must be the root Activity context.
                    // All other nested Contexts will inherit the configuration set here.
                    resources = mResourcesManager.createBaseActivityResources(
                            activityToken,
                            packageInfo.getResDir(),
                            packageInfo.getSplitResDirs(),
                            packageInfo.getOverlayDirs(),
                            packageInfo.getApplicationInfo().sharedLibraryFiles,
                            displayId,
                            overrideConfiguration,
                            compatInfo,
                            packageInfo.getClassLoader());
                }
            }
            }
        }
        }
        mResources = resources;
        mResources = resources;
+227 −73

File changed.

Preview size limit exceeded, changes collapsed.

+9 −0
Original line number Original line Diff line number Diff line
@@ -1251,6 +1251,15 @@
        <service android:name="android.os.BinderThreadPriorityService"
        <service android:name="android.os.BinderThreadPriorityService"
                android:process=":BinderThreadPriorityService" />
                android:process=":BinderThreadPriorityService" />


        <!-- Used by ApplyOverrideConfigurationTest -->
        <activity android:name="android.app.activity.ApplyOverrideConfigurationActivity"
                  android:configChanges="orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
            </intent-filter>
        </activity>

        <!-- Application components used for search manager tests -->
        <!-- Application components used for search manager tests -->


        <activity android:name="android.app.activity.SearchableActivity"
        <activity android:name="android.app.activity.SearchableActivity"
+32 −0

File added.

Preview size limit exceeded, changes collapsed.

+66 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading