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

Commit ccb9dc19 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

Themes: Include ThemeConfig for ResourceKey hash

This patch will help guarantee we retrieve the correct resources
including any themed assets that need to be attached.

This fixes a bug with SystemUI no longer accepting theme changes
because it was returning a cached version of the Resources object
from mActiveResources.

Change-Id: Icabc2edc6a8a839e459076374db55296e5b21a13
parent 0b2765ee
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -171,8 +171,9 @@ public class ResourcesManager {
            Context context) {
        final float scale = compatInfo.applicationScale;
        final boolean isThemeable = compatInfo.isThemeable;
        final ThemeConfig themeConfig = getThemeConfig();
        ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale,
                isThemeable, token);
                isThemeable, themeConfig, token);
        Resources r;
        synchronized (this) {
            // Resources is app scale dependent.
@@ -721,4 +722,12 @@ public class ResourcesManager {
        assets.getThemeCookies().clear();
        assets.setThemePackageName(null);
    }

    private ThemeConfig getThemeConfig() {
        Configuration config = getConfiguration();
        if (config != null) {
            return config.themeConfig;
        }
        return null;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public final class ResourcesKey {
    public final Configuration mOverrideConfiguration = new Configuration();

    public ResourcesKey(String resDir, int displayId, Configuration overrideConfiguration,
            float scale, boolean isThemeable, IBinder token) {
            float scale, boolean isThemeable, ThemeConfig themeConfig, IBinder token) {
        mResDir = resDir;
        mDisplayId = displayId;
        if (overrideConfiguration != null) {
@@ -47,6 +47,7 @@ public final class ResourcesKey {
                ? mOverrideConfiguration.hashCode() : 0);
        hash = 31 * hash + Float.floatToIntBits(mScale);
        hash = 31 * hash + (mIsThemeable ? 1 : 0);
        hash = 31 * hash + (themeConfig != null ? themeConfig.hashCode() : 0);
        mHash = hash;
    }

+8 −0
Original line number Diff line number Diff line
@@ -146,6 +146,14 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
        return result.toString();
    }

    @Override
    public int hashCode() {
        int hash = 17;
        hash = 31 * hash + mThemes.hashCode();
        hash = 31 * hash + (int) mThemeChangeTimestamp;
        return hash;
    }

    public String toJson() {
        return JsonSerializer.toJson(this);
    }