Loading core/java/android/content/pm/PackageInfo.java +22 −4 Original line number Original line Diff line number Diff line Loading @@ -286,8 +286,26 @@ public class PackageInfo implements Parcelable { /** @hide */ /** @hide */ public int overlayPriority; public int overlayPriority; /** @hide */ public boolean isStaticOverlay; /** * Flag for use with {@link #overlayFlags}. Marks the overlay as static, meaning it cannot * be enabled/disabled at runtime. * @hide */ public static final int FLAG_OVERLAY_STATIC = 1 << 1; /** * Flag for use with {@link #overlayFlags}. Marks the overlay as trusted (not 3rd party). * @hide */ public static final int FLAG_OVERLAY_TRUSTED = 1 << 2; /** * Modifiers that affect the state of this overlay. See {@link #FLAG_OVERLAY_STATIC}, * {@link #FLAG_OVERLAY_TRUSTED}. * @hide */ public int overlayFlags; public PackageInfo() { public PackageInfo() { } } Loading Loading @@ -342,8 +360,8 @@ public class PackageInfo implements Parcelable { dest.writeString(restrictedAccountType); dest.writeString(restrictedAccountType); dest.writeString(requiredAccountType); dest.writeString(requiredAccountType); dest.writeString(overlayTarget); dest.writeString(overlayTarget); dest.writeInt(isStaticOverlay ? 1 : 0); dest.writeInt(overlayPriority); dest.writeInt(overlayPriority); dest.writeInt(overlayFlags); } } public static final Parcelable.Creator<PackageInfo> CREATOR public static final Parcelable.Creator<PackageInfo> CREATOR Loading Loading @@ -394,8 +412,8 @@ public class PackageInfo implements Parcelable { restrictedAccountType = source.readString(); restrictedAccountType = source.readString(); requiredAccountType = source.readString(); requiredAccountType = source.readString(); overlayTarget = source.readString(); overlayTarget = source.readString(); isStaticOverlay = source.readInt() != 0; overlayPriority = source.readInt(); overlayPriority = source.readInt(); overlayFlags = source.readInt(); // The component lists were flattened with the redundant ApplicationInfo // The component lists were flattened with the redundant ApplicationInfo // instances omitted. Distribute the canonical one here as appropriate. // instances omitted. Distribute the canonical one here as appropriate. Loading core/java/android/content/pm/PackageParser.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -678,7 +678,15 @@ public class PackageParser { pi.requiredAccountType = p.mRequiredAccountType; pi.requiredAccountType = p.mRequiredAccountType; pi.overlayTarget = p.mOverlayTarget; pi.overlayTarget = p.mOverlayTarget; pi.overlayPriority = p.mOverlayPriority; pi.overlayPriority = p.mOverlayPriority; pi.isStaticOverlay = p.mIsStaticOverlay; if (p.mIsStaticOverlay) { pi.overlayFlags |= PackageInfo.FLAG_OVERLAY_STATIC; } if (p.mTrustedOverlay) { pi.overlayFlags |= PackageInfo.FLAG_OVERLAY_TRUSTED; } pi.firstInstallTime = firstInstallTime; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; pi.lastUpdateTime = lastUpdateTime; if ((flags&PackageManager.GET_GIDS) != 0) { if ((flags&PackageManager.GET_GIDS) != 0) { Loading services/core/java/com/android/server/om/OverlayManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -669,7 +669,8 @@ public final class OverlayManagerService extends SystemService { }; }; private boolean isOverlayPackage(@NonNull final PackageInfo pi) { private boolean isOverlayPackage(@NonNull final PackageInfo pi) { return pi != null && pi.overlayTarget != null; return pi != null && pi.overlayTarget != null && (pi.overlayFlags & PackageInfo.FLAG_OVERLAY_TRUSTED) != 0; } } private final class OverlayChangeListener private final class OverlayChangeListener Loading services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +14 −8 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,11 @@ final class OverlayManagerServiceImpl { mListener = listener; mListener = listener; } } private static boolean isPackageStaticOverlay(final PackageInfo packageInfo) { return packageInfo.overlayTarget != null && (packageInfo.overlayFlags & PackageInfo.FLAG_OVERLAY_STATIC) != 0; } /** /** * Call this to synchronize the Settings for a user with what PackageManager knows about a user. * Call this to synchronize the Settings for a user with what PackageManager knows about a user. * Returns a list of target packages that must refresh their overlays. This list is the union * Returns a list of target packages that must refresh their overlays. This list is the union Loading Loading @@ -102,11 +107,11 @@ final class OverlayManagerServiceImpl { mSettings.init(overlayPackage.packageName, newUserId, mSettings.init(overlayPackage.packageName, newUserId, overlayPackage.overlayTarget, overlayPackage.overlayTarget, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.isStaticOverlay, overlayPackage.overlayPriority); isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority); if (oi == null) { if (oi == null) { // This overlay does not exist in our settings. // This overlay does not exist in our settings. if (overlayPackage.isStaticOverlay || if (isPackageStaticOverlay(overlayPackage) || mDefaultOverlays.contains(overlayPackage.packageName)) { mDefaultOverlays.contains(overlayPackage.packageName)) { // Enable this overlay by default. // Enable this overlay by default. if (DEBUG) { if (DEBUG) { Loading Loading @@ -255,8 +260,8 @@ final class OverlayManagerServiceImpl { mPackageManager.getPackageInfo(overlayPackage.overlayTarget, userId); mPackageManager.getPackageInfo(overlayPackage.overlayTarget, userId); mSettings.init(packageName, userId, overlayPackage.overlayTarget, mSettings.init(packageName, userId, overlayPackage.overlayTarget, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.isStaticOverlay, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.overlayPriority); isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority); try { try { if (updateState(targetPackage, overlayPackage, userId)) { if (updateState(targetPackage, overlayPackage, userId)) { mListener.onOverlaysChanged(overlayPackage.overlayTarget, userId); mListener.onOverlaysChanged(overlayPackage.overlayTarget, userId); Loading Loading @@ -313,7 +318,7 @@ final class OverlayManagerServiceImpl { } } // Ignore static overlays. // Ignore static overlays. if (overlayPackage.isStaticOverlay) { if (isPackageStaticOverlay(overlayPackage)) { return false; return false; } } Loading Loading @@ -363,7 +368,7 @@ final class OverlayManagerServiceImpl { continue; continue; } } if (disabledOverlayPackageInfo.isStaticOverlay) { if (isPackageStaticOverlay(disabledOverlayPackageInfo)) { // Don't touch static overlays. // Don't touch static overlays. continue; continue; } } Loading @@ -388,7 +393,7 @@ final class OverlayManagerServiceImpl { private boolean isPackageUpdatableOverlay(@NonNull final String packageName, final int userId) { private boolean isPackageUpdatableOverlay(@NonNull final String packageName, final int userId) { final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId); final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId); if (overlayPackage == null || overlayPackage.isStaticOverlay) { if (overlayPackage == null || isPackageStaticOverlay(overlayPackage)) { return false; return false; } } return true; return true; Loading Loading @@ -483,7 +488,8 @@ final class OverlayManagerServiceImpl { throws OverlayManagerSettings.BadKeyException { throws OverlayManagerSettings.BadKeyException { // Static RROs targeting to "android", ie framework-res.apk, are handled by native layers. // Static RROs targeting to "android", ie framework-res.apk, are handled by native layers. if (targetPackage != null && if (targetPackage != null && !("android".equals(targetPackage.packageName) && overlayPackage.isStaticOverlay)) { !("android".equals(targetPackage.packageName) && isPackageStaticOverlay(overlayPackage))) { mIdmapManager.createIdmap(targetPackage, overlayPackage, userId); mIdmapManager.createIdmap(targetPackage, overlayPackage, userId); } } Loading Loading
core/java/android/content/pm/PackageInfo.java +22 −4 Original line number Original line Diff line number Diff line Loading @@ -286,8 +286,26 @@ public class PackageInfo implements Parcelable { /** @hide */ /** @hide */ public int overlayPriority; public int overlayPriority; /** @hide */ public boolean isStaticOverlay; /** * Flag for use with {@link #overlayFlags}. Marks the overlay as static, meaning it cannot * be enabled/disabled at runtime. * @hide */ public static final int FLAG_OVERLAY_STATIC = 1 << 1; /** * Flag for use with {@link #overlayFlags}. Marks the overlay as trusted (not 3rd party). * @hide */ public static final int FLAG_OVERLAY_TRUSTED = 1 << 2; /** * Modifiers that affect the state of this overlay. See {@link #FLAG_OVERLAY_STATIC}, * {@link #FLAG_OVERLAY_TRUSTED}. * @hide */ public int overlayFlags; public PackageInfo() { public PackageInfo() { } } Loading Loading @@ -342,8 +360,8 @@ public class PackageInfo implements Parcelable { dest.writeString(restrictedAccountType); dest.writeString(restrictedAccountType); dest.writeString(requiredAccountType); dest.writeString(requiredAccountType); dest.writeString(overlayTarget); dest.writeString(overlayTarget); dest.writeInt(isStaticOverlay ? 1 : 0); dest.writeInt(overlayPriority); dest.writeInt(overlayPriority); dest.writeInt(overlayFlags); } } public static final Parcelable.Creator<PackageInfo> CREATOR public static final Parcelable.Creator<PackageInfo> CREATOR Loading Loading @@ -394,8 +412,8 @@ public class PackageInfo implements Parcelable { restrictedAccountType = source.readString(); restrictedAccountType = source.readString(); requiredAccountType = source.readString(); requiredAccountType = source.readString(); overlayTarget = source.readString(); overlayTarget = source.readString(); isStaticOverlay = source.readInt() != 0; overlayPriority = source.readInt(); overlayPriority = source.readInt(); overlayFlags = source.readInt(); // The component lists were flattened with the redundant ApplicationInfo // The component lists were flattened with the redundant ApplicationInfo // instances omitted. Distribute the canonical one here as appropriate. // instances omitted. Distribute the canonical one here as appropriate. Loading
core/java/android/content/pm/PackageParser.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -678,7 +678,15 @@ public class PackageParser { pi.requiredAccountType = p.mRequiredAccountType; pi.requiredAccountType = p.mRequiredAccountType; pi.overlayTarget = p.mOverlayTarget; pi.overlayTarget = p.mOverlayTarget; pi.overlayPriority = p.mOverlayPriority; pi.overlayPriority = p.mOverlayPriority; pi.isStaticOverlay = p.mIsStaticOverlay; if (p.mIsStaticOverlay) { pi.overlayFlags |= PackageInfo.FLAG_OVERLAY_STATIC; } if (p.mTrustedOverlay) { pi.overlayFlags |= PackageInfo.FLAG_OVERLAY_TRUSTED; } pi.firstInstallTime = firstInstallTime; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; pi.lastUpdateTime = lastUpdateTime; if ((flags&PackageManager.GET_GIDS) != 0) { if ((flags&PackageManager.GET_GIDS) != 0) { Loading
services/core/java/com/android/server/om/OverlayManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -669,7 +669,8 @@ public final class OverlayManagerService extends SystemService { }; }; private boolean isOverlayPackage(@NonNull final PackageInfo pi) { private boolean isOverlayPackage(@NonNull final PackageInfo pi) { return pi != null && pi.overlayTarget != null; return pi != null && pi.overlayTarget != null && (pi.overlayFlags & PackageInfo.FLAG_OVERLAY_TRUSTED) != 0; } } private final class OverlayChangeListener private final class OverlayChangeListener Loading
services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +14 −8 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,11 @@ final class OverlayManagerServiceImpl { mListener = listener; mListener = listener; } } private static boolean isPackageStaticOverlay(final PackageInfo packageInfo) { return packageInfo.overlayTarget != null && (packageInfo.overlayFlags & PackageInfo.FLAG_OVERLAY_STATIC) != 0; } /** /** * Call this to synchronize the Settings for a user with what PackageManager knows about a user. * Call this to synchronize the Settings for a user with what PackageManager knows about a user. * Returns a list of target packages that must refresh their overlays. This list is the union * Returns a list of target packages that must refresh their overlays. This list is the union Loading Loading @@ -102,11 +107,11 @@ final class OverlayManagerServiceImpl { mSettings.init(overlayPackage.packageName, newUserId, mSettings.init(overlayPackage.packageName, newUserId, overlayPackage.overlayTarget, overlayPackage.overlayTarget, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.isStaticOverlay, overlayPackage.overlayPriority); isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority); if (oi == null) { if (oi == null) { // This overlay does not exist in our settings. // This overlay does not exist in our settings. if (overlayPackage.isStaticOverlay || if (isPackageStaticOverlay(overlayPackage) || mDefaultOverlays.contains(overlayPackage.packageName)) { mDefaultOverlays.contains(overlayPackage.packageName)) { // Enable this overlay by default. // Enable this overlay by default. if (DEBUG) { if (DEBUG) { Loading Loading @@ -255,8 +260,8 @@ final class OverlayManagerServiceImpl { mPackageManager.getPackageInfo(overlayPackage.overlayTarget, userId); mPackageManager.getPackageInfo(overlayPackage.overlayTarget, userId); mSettings.init(packageName, userId, overlayPackage.overlayTarget, mSettings.init(packageName, userId, overlayPackage.overlayTarget, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.isStaticOverlay, overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.overlayPriority); isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority); try { try { if (updateState(targetPackage, overlayPackage, userId)) { if (updateState(targetPackage, overlayPackage, userId)) { mListener.onOverlaysChanged(overlayPackage.overlayTarget, userId); mListener.onOverlaysChanged(overlayPackage.overlayTarget, userId); Loading Loading @@ -313,7 +318,7 @@ final class OverlayManagerServiceImpl { } } // Ignore static overlays. // Ignore static overlays. if (overlayPackage.isStaticOverlay) { if (isPackageStaticOverlay(overlayPackage)) { return false; return false; } } Loading Loading @@ -363,7 +368,7 @@ final class OverlayManagerServiceImpl { continue; continue; } } if (disabledOverlayPackageInfo.isStaticOverlay) { if (isPackageStaticOverlay(disabledOverlayPackageInfo)) { // Don't touch static overlays. // Don't touch static overlays. continue; continue; } } Loading @@ -388,7 +393,7 @@ final class OverlayManagerServiceImpl { private boolean isPackageUpdatableOverlay(@NonNull final String packageName, final int userId) { private boolean isPackageUpdatableOverlay(@NonNull final String packageName, final int userId) { final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId); final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId); if (overlayPackage == null || overlayPackage.isStaticOverlay) { if (overlayPackage == null || isPackageStaticOverlay(overlayPackage)) { return false; return false; } } return true; return true; Loading Loading @@ -483,7 +488,8 @@ final class OverlayManagerServiceImpl { throws OverlayManagerSettings.BadKeyException { throws OverlayManagerSettings.BadKeyException { // Static RROs targeting to "android", ie framework-res.apk, are handled by native layers. // Static RROs targeting to "android", ie framework-res.apk, are handled by native layers. if (targetPackage != null && if (targetPackage != null && !("android".equals(targetPackage.packageName) && overlayPackage.isStaticOverlay)) { !("android".equals(targetPackage.packageName) && isPackageStaticOverlay(overlayPackage))) { mIdmapManager.createIdmap(targetPackage, overlayPackage, userId); mIdmapManager.createIdmap(targetPackage, overlayPackage, userId); } } Loading