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

Commit 7eea305c authored by Omar Eissa's avatar Omar Eissa
Browse files

Add new attribute for private compute core apks

The newly added attribute will be used by apps that want to run in pcc
sandbox.

Context: go/pcc-apk

Test: atest AndroidPackageTest
Flag: android.app.privatecompute.flags.enable_pcc_framework_support
Bug: 430201829
Bug: 437280042
Change-Id: I1239a5b9b461a18f53f2681ba6c6f48070fb4417
parent 434ddbc6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1455,6 +1455,7 @@ package android {
    field @Deprecated public static final int rowEdgeFlags = 16843329; // 0x1010241
    field public static final int rowHeight = 16843058; // 0x1010132
    field public static final int rowOrderPreserved = 16843638; // 0x1010376
    field @FlaggedApi("android.app.privatecompute.flags.enable_pcc_framework_support") public static final int runInPccSandbox;
    field public static final int saveEnabled = 16842983; // 0x10100e7
    field public static final int scaleGravity = 16843262; // 0x10101fe
    field public static final int scaleHeight = 16843261; // 0x10101fd
+17 −0
Original line number Diff line number Diff line
@@ -858,6 +858,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_EXT_NOT_LAUNCHED = 1 << 6;

    /**
     * Whether the app should run in the Private Compute Core sandbox
     * @hide
     * @see android.R.styleable.AndroidManifestApplication_runInPccSandbox
     */
    public static final int PRIVATE_FLAG_EXT_RUN_IN_PCC_SANDBOX = 1 << 7;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
            PRIVATE_FLAG_EXT_PROFILEABLE,
@@ -867,6 +874,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
            PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS,
            PRIVATE_FLAG_EXT_CPU_OVERRIDE,
            PRIVATE_FLAG_EXT_NOT_LAUNCHED,
            PRIVATE_FLAG_EXT_RUN_IN_PCC_SANDBOX,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ApplicationInfoPrivateFlagsExt {}
@@ -2808,6 +2816,15 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        return (privateFlagsExt & ApplicationInfo.PRIVATE_FLAG_EXT_NOT_LAUNCHED) != 0;
    }

    /**
     * Returns whether the app should run in the Private Compute Core sandbox.
     * @hide
     * @see android.R.styleable#AndroidManifestApplication_runInPccSandbox
     */
    public boolean shouldRunInPccSandbox() {
        return (privateFlagsExt & ApplicationInfo.PRIVATE_FLAG_EXT_RUN_IN_PCC_SANDBOX) != 0;
    }

    /**
     * Checks if a changeId is enabled for the current user
     * @param changeId The changeId to verify
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import android.annotation.CheckResult;
import android.content.pm.ApplicationInfo;

import com.android.internal.pm.parsing.pkg.AndroidPackageLegacyUtils;
import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
import com.android.server.pm.pkg.AndroidPackage;

public class AppInfoUtils {
@@ -112,6 +111,7 @@ public class AppInfoUtils {
                | flag(pkg.hasRequestForegroundServiceExemption(), ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION)
                | flag(pkg.isAttributionsUserVisible(), ApplicationInfo.PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE)
                | flag(pkg.isOnBackInvokedCallbackEnabled(), ApplicationInfo.PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK)
                | flag(pkg.shouldRunInPccSandbox(), ApplicationInfo.PRIVATE_FLAG_EXT_RUN_IN_PCC_SANDBOX)
                | flag(isAllowlistedForHiddenApis, ApplicationInfo.PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS);
        return pkgWithoutStateFlags;
        // @formatter:on
+13 −0
Original line number Diff line number Diff line
@@ -1731,6 +1731,11 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
        return getBoolean(Booleans.ENABLE_ON_BACK_INVOKED_CALLBACK);
    }

    @Override
    public boolean shouldRunInPccSandbox() {
        return getBoolean2(Booleans2.RUN_IN_PCC_SANDBOX);
    }

    @Override
    public boolean isResourceOverlay() {
        return getBoolean(Booleans.OVERLAY);
@@ -2243,6 +2248,12 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
        return this;
    }

    @Override
    public ParsingPackage setRunInPccSandbox(boolean value) {
        setBoolean2(Booleans2.RUN_IN_PCC_SANDBOX, value);
        return this;
    }

    @Override
    public ParsingPackage setAllowCrossUidActivitySwitchFromBelow(boolean value) {
        mAllowCrossUidActivitySwitchFromBelow = value;
@@ -3936,11 +3947,13 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
                STUB,
                APEX,
                UPDATABLE_SYSTEM,
                RUN_IN_PCC_SANDBOX,
        })
        public @interface Flags {}

        private static final long STUB = 1L;
        private static final long APEX = 1L << 1;
        private static final long UPDATABLE_SYSTEM = 1L << 2;
        private static final long RUN_IN_PCC_SANDBOX = 1L << 3;
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -427,6 +427,12 @@ public interface ParsingPackage {
     */
    ParsingPackage setAlternateLauncherLabelResIds(int[] alternateLauncherLabelResIds);

    /**
     * Sets whether this application should run in the Private Compute Core sandbox.
     * @see android.R.styleable#AndroidManifestApplication_runInPccSandbox
     */
    ParsingPackage setRunInPccSandbox(boolean runInPccSandbox);

    @CallSuper
    ParsedPackage hideAsParsed();

Loading