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

Commit 929de7a4 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Fetch roundIcon|icon depending on RRO overlayed config_useRoundIcon

Bug: 120286623

Test: adb shell cmd overlay enable --user 0 com.android.theme.icon.square
Test: builds, manual, used themepicker and checked on launcher, settings

Change-Id: Iafa13bea77f6f035bf6e21565571c5f77f8ef0a1
parent cbc79698
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -1092,6 +1092,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public String appComponentFactory;

    /**
     * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_icon}
     * @hide
     */
    public int iconRes;

    /**
     * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_roundIcon}
     * @hide
     */
    public int roundIconRes;

    /**
     * The category of this app. Categories are used to cluster multiple apps
     * together into meaningful groups, such as when summarizing battery,
@@ -1571,6 +1583,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        classLoaderName = orig.classLoaderName;
        splitClassLoaderNames = orig.splitClassLoaderNames;
        appComponentFactory = orig.appComponentFactory;
        iconRes = orig.iconRes;
        roundIconRes = orig.roundIconRes;
        compileSdkVersion = orig.compileSdkVersion;
        compileSdkVersionCodename = orig.compileSdkVersionCodename;
        mHiddenApiPolicy = orig.mHiddenApiPolicy;
@@ -1650,6 +1664,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(compileSdkVersion);
        dest.writeString(compileSdkVersionCodename);
        dest.writeString(appComponentFactory);
        dest.writeInt(iconRes);
        dest.writeInt(roundIconRes);
        dest.writeInt(mHiddenApiPolicy);
        dest.writeInt(hiddenUntilInstalled ? 1 : 0);
        dest.writeString(zygotePreloadName);
@@ -1724,6 +1740,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        compileSdkVersion = source.readInt();
        compileSdkVersionCodename = source.readString();
        appComponentFactory = source.readString();
        iconRes = source.readInt();
        roundIconRes = source.readInt();
        mHiddenApiPolicy = source.readInt();
        hiddenUntilInstalled = source.readInt() != 0;
        zygotePreloadName = source.readString();
+47 −6
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import android.annotation.StringRes;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.ResourcesManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -69,6 +71,7 @@ import android.os.FileUtils;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PatternMatcher;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
@@ -92,6 +95,7 @@ import android.util.Slog;
import android.util.SparseArray;
import android.util.TypedValue;
import android.util.apk.ApkSignatureVerifier;
import android.view.Display;
import android.view.Gravity;

import com.android.internal.R;
@@ -320,6 +324,8 @@ public class PackageParser {
    private int mParseError = PackageManager.INSTALL_SUCCEEDED;

    private static boolean sCompatibilityModeEnabled = true;
    private static boolean sUseRoundIcon = false;

    private static final int PARSE_DEFAULT_INSTALL_LOCATION =
            PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
    private static final int PARSE_DEFAULT_TARGET_SANDBOX = 1;
@@ -3457,6 +3463,11 @@ public class PackageParser {
        TypedArray sa = res.obtainAttributes(parser,
                com.android.internal.R.styleable.AndroidManifestApplication);

        ai.iconRes = sa.getResourceId(
            com.android.internal.R.styleable.AndroidManifestApplication_icon, 0);
        ai.roundIconRes = sa.getResourceId(
            com.android.internal.R.styleable.AndroidManifestApplication_roundIcon, 0);

        if (!parsePackageItemInfo(owner, ai, outError,
                "<application>", sa, false /*nameRequired*/,
                com.android.internal.R.styleable.AndroidManifestApplication_name,
@@ -4260,9 +4271,7 @@ public class PackageParser {
            }
        }

        final boolean useRoundIcon =
                Resources.getSystem().getBoolean(com.android.internal.R.bool.config_useRoundIcon);
        int roundIconVal = useRoundIcon ? sa.getResourceId(roundIconRes, 0) : 0;
        int roundIconVal = sUseRoundIcon ? sa.getResourceId(roundIconRes, 0) : 0;
        if (roundIconVal != 0) {
            outInfo.icon = roundIconVal;
            outInfo.nonLocalizedLabel = null;
@@ -5770,9 +5779,7 @@ public class PackageParser {
            outInfo.nonLocalizedLabel = v.coerceToString();
        }

        final boolean useRoundIcon =
                Resources.getSystem().getBoolean(com.android.internal.R.bool.config_useRoundIcon);
        int roundIconVal = useRoundIcon ? sa.getResourceId(
        int roundIconVal = sUseRoundIcon ? sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestIntentFilter_roundIcon, 0) : 0;
        if (roundIconVal != 0) {
            outInfo.icon = roundIconVal;
@@ -7759,6 +7766,7 @@ public class PackageParser {
        }
        ai.seInfoUser = SELinuxUtil.assignSeinfoUser(state);
        ai.resourceDirs = state.overlayPaths;
        ai.icon = (sUseRoundIcon && ai.roundIconRes != 0) ? ai.roundIconRes : ai.iconRes;
    }

    @UnsupportedAppUsage
@@ -8364,6 +8372,39 @@ public class PackageParser {
        sCompatibilityModeEnabled = compatibilityModeEnabled;
    }

    /**
     * @hide
     */
    public static void readConfigUseRoundIcon(Resources r) {
        if (r != null) {
            sUseRoundIcon = r.getBoolean(com.android.internal.R.bool.config_useRoundIcon);
            return;
        }

        ApplicationInfo androidAppInfo;
        try {
            androidAppInfo = ActivityThread.getPackageManager().getApplicationInfo(
                    "android", 0 /* flags */,
                UserHandle.myUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        Resources systemResources = Resources.getSystem();

        // Create in-flight as this overlayable resource is only used when config changes
        Resources overlayableRes = ResourcesManager.getInstance().getResources(null,
                null,
                null,
                androidAppInfo.resourceDirs,
                androidAppInfo.sharedLibraryFiles,
                Display.DEFAULT_DISPLAY,
                null,
                systemResources.getCompatibilityInfo(),
                systemResources.getClassLoader());

        sUseRoundIcon = overlayableRes.getBoolean(com.android.internal.R.bool.config_useRoundIcon);
    }

    public static class PackageParserException extends Exception {
        public final int error;

+4 −1
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageManagerInternal.CheckPermissionDelegate;
import android.content.pm.PackageParser;
import android.content.pm.ParceledListSlice;
import android.content.pm.PathPermission;
import android.content.pm.PermissionInfo;
@@ -18465,7 +18466,9 @@ public class ActivityManagerService extends IActivityManager.Stub
    void updateApplicationInfoLocked(@NonNull List<String> packagesToUpdate, int userId) {
        final boolean updateFrameworkRes = packagesToUpdate.contains("android");
        if (updateFrameworkRes) {
            PackageParser.readConfigUseRoundIcon(null);
        }
        mProcessList.updateApplicationInfoLocked(packagesToUpdate, userId, updateFrameworkRes);
        if (updateFrameworkRes) {
+3 −0
Original line number Diff line number Diff line
@@ -3226,6 +3226,8 @@ public class PackageManagerService extends IPackageManager.Stub
        // once we have a booted system.
        mInstaller.setWarnIfHeld(mPackages);
        PackageParser.readConfigUseRoundIcon(mContext.getResources());
        mServiceStartWithDelay = SystemClock.uptimeMillis() + (60 * 1000L);
        Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
@@ -20843,6 +20845,7 @@ public class PackageManagerService extends IPackageManager.Stub
                mContext.getContentResolver(),
                android.provider.Settings.Global.COMPATIBILITY_MODE, 1) == 1;
        PackageParser.setCompatibilityModeEnabled(compatibilityModeEnabled);
        if (DEBUG_SETTINGS) {
            Log.d(TAG, "compatibility mode:" + compatibilityModeEnabled);
        }