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

Commit da9ee140 authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

Add overlayPaths to ApplicationInfo

RROs have historically been APK packages. We now have the ability to
generate RROs on-the-fly. These "fabricated" RROs are not APKs.
ApplicationInfo#resourceDirs documentation states that it only contains
paths to packages. To prevent changing the behavior of resourceDirs
until we can deprecate and remove it, a new overlayPaths field has been
added to ApplicationInfo. This new field contains APK overlay paths as
well as non-APK overlay paths.

Bug: 172471315
Test: boot enable/disable overlays and examine overlays working as well
      as package manager dumpsys
Change-Id: I78c5eeef73b7d8bada61edc0f64a12a3cdc1ce16
parent c9efb465
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class ResourcesManagerPerfTest {
    }

    private void getResourcesForPath(String path) {
        ResourcesManager.getInstance().getResources(null, path, null, null, null,
        ResourcesManager.getInstance().getResources(null, path, null, null, null, null,
                Display.DEFAULT_DISPLAY, null, sContext.getResources().getCompatibilityInfo(),
                null, null);
    }
+3 −2
Original line number Diff line number Diff line
@@ -95,8 +95,9 @@ public class ResourcesThemePerfTest {
                ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT;

        Resources destResources = resourcesManager.getResources(null, ai.sourceDir,
                ai.splitSourceDirs, ai.resourceDirs, ai.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
                c, mContext.getResources().getCompatibilityInfo(), null, null);
                ai.splitSourceDirs, ai.resourceDirs, ai.overlayPaths, ai.sharedLibraryFiles,
                Display.DEFAULT_DISPLAY, c, mContext.getResources().getCompatibilityInfo(),
                null, null);
        Assert.assertNotEquals(destResources.getAssets(), mContext.getAssets());

        Resources.Theme destTheme = destResources.newTheme();
+13 −9
Original line number Diff line number Diff line
@@ -2289,11 +2289,12 @@ public final class ActivityThread extends ClientTransactionHandler {
     * Creates the top level resources for the given package. Will return an existing
     * Resources if one has already been created.
     */
    Resources getTopLevelResources(String resDir, String[] splitResDirs, String[] overlayDirs,
            String[] libDirs, LoadedApk pkgInfo, Configuration overrideConfig) {
        return mResourcesManager.getResources(null, resDir, splitResDirs, overlayDirs, libDirs,
                null, overrideConfig, pkgInfo.getCompatibilityInfo(), pkgInfo.getClassLoader(),
                null);
    Resources getTopLevelResources(String resDir, String[] splitResDirs, String[] legacyOverlayDirs,
                    String[] overlayPaths, String[] libDirs, LoadedApk pkgInfo,
                    Configuration overrideConfig) {
        return mResourcesManager.getResources(null, resDir, splitResDirs, legacyOverlayDirs,
                overlayPaths, libDirs, null, overrideConfig, pkgInfo.getCompatibilityInfo(),
                pkgInfo.getClassLoader(), null);
    }

    @UnsupportedAppUsage
@@ -2462,12 +2463,15 @@ public final class ActivityThread extends ClientTransactionHandler {
    private static boolean isLoadedApkResourceDirsUpToDate(LoadedApk loadedApk,
            ApplicationInfo appInfo) {
        Resources packageResources = loadedApk.mResources;
        String[] overlayDirs = ArrayUtils.defeatNullable(loadedApk.getOverlayDirs());
        String[] resourceDirs = ArrayUtils.defeatNullable(appInfo.resourceDirs);
        boolean resourceDirsUpToDate = Arrays.equals(
                ArrayUtils.defeatNullable(appInfo.resourceDirs),
                ArrayUtils.defeatNullable(loadedApk.getOverlayDirs()));
        boolean overlayPathsUpToDate = Arrays.equals(
                ArrayUtils.defeatNullable(appInfo.overlayPaths),
                ArrayUtils.defeatNullable(loadedApk.getOverlayPaths()));

        return (packageResources == null || packageResources.getAssets().isUpToDate())
                && overlayDirs.length == resourceDirs.length
                && ArrayUtils.containsAll(overlayDirs, resourceDirs);
                && resourceDirsUpToDate && overlayPathsUpToDate;
    }

    @UnsupportedAppUsage
+1 −1
Original line number Diff line number Diff line
@@ -1728,7 +1728,7 @@ public class ApplicationPackageManager extends PackageManager {
        final Resources r = mContext.mMainThread.getTopLevelResources(
                sameUid ? app.sourceDir : app.publicSourceDir,
                sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs,
                app.resourceDirs, app.sharedLibraryFiles,
                app.resourceDirs, app.overlayPaths, app.sharedLibraryFiles,
                mContext.mPackageInfo, configuration);
        if (r != null) {
            return r;
+6 −2
Original line number Diff line number Diff line
@@ -2345,6 +2345,7 @@ class ContextImpl extends Context {
                pi.getResDir(),
                splitResDirs,
                pi.getOverlayDirs(),
                pi.getOverlayPaths(),
                pi.getApplicationInfo().sharedLibraryFiles,
                overrideDisplayId,
                overrideConfig,
@@ -2442,6 +2443,7 @@ class ContextImpl extends Context {
                mPackageInfo.getResDir(),
                paths,
                mPackageInfo.getOverlayDirs(),
                mPackageInfo.getOverlayPaths(),
                mPackageInfo.getApplicationInfo().sharedLibraryFiles,
                mForceDisplayOverrideInResources ? getDisplayId() : null,
                null,
@@ -2558,7 +2560,8 @@ class ContextImpl extends Context {
    Resources createWindowContextResources() {
        final String resDir = mPackageInfo.getResDir();
        final String[] splitResDirs = mPackageInfo.getSplitResDirs();
        final String[] overlayDirs = mPackageInfo.getOverlayDirs();
        final String[] legacyOverlayDirs = mPackageInfo.getOverlayDirs();
        final String[] overlayPaths = mPackageInfo.getOverlayPaths();
        final String[] libDirs = mPackageInfo.getApplicationInfo().sharedLibraryFiles;
        final int displayId = getDisplayId();
        final CompatibilityInfo compatInfo = (displayId == Display.DEFAULT_DISPLAY)
@@ -2567,7 +2570,7 @@ class ContextImpl extends Context {
        final List<ResourcesLoader> loaders = mResources.getLoaders();

        return mResourcesManager.createBaseTokenResources(mToken, resDir, splitResDirs,
                overlayDirs, libDirs, displayId, null /* overrideConfig */,
                legacyOverlayDirs, overlayPaths, libDirs, displayId, null /* overrideConfig */,
                compatInfo, mClassLoader, loaders);
    }

@@ -2855,6 +2858,7 @@ class ContextImpl extends Context {
                packageInfo.getResDir(),
                splitDirs,
                packageInfo.getOverlayDirs(),
                packageInfo.getOverlayPaths(),
                packageInfo.getApplicationInfo().sharedLibraryFiles,
                displayId,
                overrideConfiguration,
Loading