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

Commit 2f5811dc authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Per user setting for instant app

The same application can run as either an instant app or an installed
app. Store this setting per-user instead of based upon the install
location.

Bug: 25119046
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Iff565bb1ac10d631499f0bd0f69b401cb073c10e
parent 710a2851
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -553,8 +553,12 @@ public final class Pm {
                    sessionParams.abiOverride = checkAbiArgument(nextOptionData());
                    break;
                case "--ephemeral":
                case "--instant":
                    sessionParams.setInstallAsInstantApp(true /*isInstantApp*/);
                    break;
                case "--full":
                    sessionParams.setInstallAsInstantApp(false /*isInstantApp*/);
                    break;
                case "--user":
                    params.userId = UserHandle.parseUserArg(nextOptionData());
                    break;
+1 −1
Original line number Diff line number Diff line
@@ -1677,7 +1677,7 @@ public class ApplicationPackageManager extends PackageManager {
    public int installExistingPackageAsUser(String packageName, int userId)
            throws NameNotFoundException {
        try {
            int res = mPM.installExistingPackageAsUser(packageName, userId,
            int res = mPM.installExistingPackageAsUser(packageName, userId, 0 /*installFlags*/,
                    PackageManager.INSTALL_REASON_UNKNOWN);
            if (res == INSTALL_FAILED_INVALID_URI) {
                throw new NameNotFoundException("Package " + packageName + " doesn't exist");
+1 −12
Original line number Diff line number Diff line
@@ -284,8 +284,6 @@ public class IntentFilter implements Parcelable {

    /** Whether or not the intent filter is visible to ephemeral apps. */
    private boolean mVisibleToEphemeral;
    /** Whether or not the intent filter is part of an ephemeral app. */
    private boolean mEphemeral;
    // These functions are the start of more optimized code for managing
    // the string sets...  not yet implemented.

@@ -656,19 +654,10 @@ public class IntentFilter implements Parcelable {
        mVisibleToEphemeral = visibleToEmphemeral;
    }
    /** @hide */
    public boolean isVisibleToEphemeral() {
    public boolean isVisibleToInstantApp() {
        return mVisibleToEphemeral;
    }

    /** @hide */
    public void setEphemeral(boolean ephemeral) {
        mEphemeral = ephemeral;
    }
    /** @hide */
    public boolean isEphemeral() {
        return mEphemeral;
    }

    /**
     * Add a new Intent action to match against.  If any actions are included
     * in the filter, then an Intent's action must be one of those values for
+30 −12
Original line number Diff line number Diff line
@@ -498,11 +498,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;

    /**
     * Value for {@link #flags}: {@code true} if the application is blocked via restrictions
     * and for most purposes is considered as not installed.
     * {@hide}
     * Value for {@link #privateFlags}: {@code true} if the application is installed
     * as instant app.
     *
     * @hide
     */
    public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 7;
    public static final int PRIVATE_FLAG_INSTANT = 1 << 7;

    /**
     * When set, at least one component inside this application is direct boot
@@ -681,7 +682,21 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public String seinfo = "default";
    public String seInfo = "default";

    /**
     * The seinfo tag generated per-user. This value may change based upon the
     * user's configuration. For example, when an instant app is installed for
     * a user. It is an error if this field is ever {@code null} when trying to
     * start a new process.
     * <p>NOTE: We need to separate this out because we modify per-user values
     * multiple times. This needs to be refactored since we're performing more
     * work than necessary and these values should only be set once. When that
     * happens, we can merge the per-user value with the seInfo state above.
     *
     * {@hide}
     */
    public String seInfoUser;

    /**
     * Paths to all shared libraries this application is linked against.  This
@@ -1009,8 +1024,9 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        if (resourceDirs != null) {
            pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
        }
        if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
            pw.println(prefix + "seinfo=" + seinfo);
        if ((flags&DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
            pw.println(prefix + "seinfo=" + seInfo);
            pw.println(prefix + "seinfoUser=" + seInfoUser);
        }
        pw.println(prefix + "dataDir=" + dataDir);
        if ((flags&DUMP_FLAG_DETAILS) != 0) {
@@ -1120,7 +1136,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        primaryCpuAbi = orig.primaryCpuAbi;
        secondaryCpuAbi = orig.secondaryCpuAbi;
        resourceDirs = orig.resourceDirs;
        seinfo = orig.seinfo;
        seInfo = orig.seInfo;
        seInfoUser = orig.seInfoUser;
        sharedLibraryFiles = orig.sharedLibraryFiles;
        dataDir = orig.dataDir;
        deviceEncryptedDataDir = deviceProtectedDataDir = orig.deviceProtectedDataDir;
@@ -1181,7 +1198,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeString(primaryCpuAbi);
        dest.writeString(secondaryCpuAbi);
        dest.writeStringArray(resourceDirs);
        dest.writeString(seinfo);
        dest.writeString(seInfo);
        dest.writeString(seInfoUser);
        dest.writeStringArray(sharedLibraryFiles);
        dest.writeString(dataDir);
        dest.writeString(deviceProtectedDataDir);
@@ -1242,7 +1260,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        primaryCpuAbi = source.readString();
        secondaryCpuAbi = source.readString();
        resourceDirs = source.readStringArray();
        seinfo = source.readString();
        seInfo = source.readString();
        seInfoUser = source.readString();
        sharedLibraryFiles = source.readStringArray();
        dataDir = source.readString();
        deviceEncryptedDataDir = deviceProtectedDataDir = source.readString();
@@ -1330,7 +1349,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        } else {
            dataDir = credentialProtectedDataDir;
        }
        // TODO: modify per-user ephemerality
    }

    /**
@@ -1415,7 +1433,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     * @hide
     */
    public boolean isInstantApp() {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -552,7 +552,8 @@ interface IPackageManager {
    boolean setInstallLocation(int loc);
    int getInstallLocation();

    int installExistingPackageAsUser(String packageName, int userId, int installReason);
    int installExistingPackageAsUser(String packageName, int userId, int installFlags,
            int installReason);

    void verifyPendingInstall(int id, int verificationCode);
    void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay);
Loading