Merge "OMS: Only allow trusted overlays to be registered." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a06854e77a
@@ -286,8 +286,26 @@ public class PackageInfo implements Parcelable {
|
||||
/** @hide */
|
||||
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() {
|
||||
}
|
||||
@@ -342,8 +360,8 @@ public class PackageInfo implements Parcelable {
|
||||
dest.writeString(restrictedAccountType);
|
||||
dest.writeString(requiredAccountType);
|
||||
dest.writeString(overlayTarget);
|
||||
dest.writeInt(isStaticOverlay ? 1 : 0);
|
||||
dest.writeInt(overlayPriority);
|
||||
dest.writeInt(overlayFlags);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<PackageInfo> CREATOR
|
||||
@@ -394,8 +412,8 @@ public class PackageInfo implements Parcelable {
|
||||
restrictedAccountType = source.readString();
|
||||
requiredAccountType = source.readString();
|
||||
overlayTarget = source.readString();
|
||||
isStaticOverlay = source.readInt() != 0;
|
||||
overlayPriority = source.readInt();
|
||||
overlayFlags = source.readInt();
|
||||
|
||||
// The component lists were flattened with the redundant ApplicationInfo
|
||||
// instances omitted. Distribute the canonical one here as appropriate.
|
||||
|
||||
@@ -678,7 +678,15 @@ public class PackageParser {
|
||||
pi.requiredAccountType = p.mRequiredAccountType;
|
||||
pi.overlayTarget = p.mOverlayTarget;
|
||||
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.lastUpdateTime = lastUpdateTime;
|
||||
if ((flags&PackageManager.GET_GIDS) != 0) {
|
||||
|
||||
@@ -669,7 +669,8 @@ public final class OverlayManagerService extends SystemService {
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
@@ -68,6 +68,11 @@ final class OverlayManagerServiceImpl {
|
||||
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.
|
||||
* Returns a list of target packages that must refresh their overlays. This list is the union
|
||||
@@ -102,11 +107,11 @@ final class OverlayManagerServiceImpl {
|
||||
mSettings.init(overlayPackage.packageName, newUserId,
|
||||
overlayPackage.overlayTarget,
|
||||
overlayPackage.applicationInfo.getBaseCodePath(),
|
||||
overlayPackage.isStaticOverlay, overlayPackage.overlayPriority);
|
||||
isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority);
|
||||
|
||||
if (oi == null) {
|
||||
// This overlay does not exist in our settings.
|
||||
if (overlayPackage.isStaticOverlay ||
|
||||
if (isPackageStaticOverlay(overlayPackage) ||
|
||||
mDefaultOverlays.contains(overlayPackage.packageName)) {
|
||||
// Enable this overlay by default.
|
||||
if (DEBUG) {
|
||||
@@ -255,8 +260,8 @@ final class OverlayManagerServiceImpl {
|
||||
mPackageManager.getPackageInfo(overlayPackage.overlayTarget, userId);
|
||||
|
||||
mSettings.init(packageName, userId, overlayPackage.overlayTarget,
|
||||
overlayPackage.applicationInfo.getBaseCodePath(), overlayPackage.isStaticOverlay,
|
||||
overlayPackage.overlayPriority);
|
||||
overlayPackage.applicationInfo.getBaseCodePath(),
|
||||
isPackageStaticOverlay(overlayPackage), overlayPackage.overlayPriority);
|
||||
try {
|
||||
if (updateState(targetPackage, overlayPackage, userId)) {
|
||||
mListener.onOverlaysChanged(overlayPackage.overlayTarget, userId);
|
||||
@@ -313,7 +318,7 @@ final class OverlayManagerServiceImpl {
|
||||
}
|
||||
|
||||
// Ignore static overlays.
|
||||
if (overlayPackage.isStaticOverlay) {
|
||||
if (isPackageStaticOverlay(overlayPackage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -363,7 +368,7 @@ final class OverlayManagerServiceImpl {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (disabledOverlayPackageInfo.isStaticOverlay) {
|
||||
if (isPackageStaticOverlay(disabledOverlayPackageInfo)) {
|
||||
// Don't touch static overlays.
|
||||
continue;
|
||||
}
|
||||
@@ -388,7 +393,7 @@ final class OverlayManagerServiceImpl {
|
||||
|
||||
private boolean isPackageUpdatableOverlay(@NonNull final String packageName, final int userId) {
|
||||
final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId);
|
||||
if (overlayPackage == null || overlayPackage.isStaticOverlay) {
|
||||
if (overlayPackage == null || isPackageStaticOverlay(overlayPackage)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -483,7 +488,8 @@ final class OverlayManagerServiceImpl {
|
||||
throws OverlayManagerSettings.BadKeyException {
|
||||
// Static RROs targeting to "android", ie framework-res.apk, are handled by native layers.
|
||||
if (targetPackage != null &&
|
||||
!("android".equals(targetPackage.packageName) && overlayPackage.isStaticOverlay)) {
|
||||
!("android".equals(targetPackage.packageName)
|
||||
&& isPackageStaticOverlay(overlayPackage))) {
|
||||
mIdmapManager.createIdmap(targetPackage, overlayPackage, userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user