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

Commit cd65448c authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Even more PackageManager caller triage.

Finish moving all UID/GID callers to single AIDL method that requires
callers to provide flags.

Triage AppWidgets and PrintServices, which currently can only live on
internal storage; we should revisit that later.

Fix two bugs where we'd drop pending install sessions and persisted
Uri grants for apps installed on external storage.

Bug: 26471205
Change-Id: I66fdfc737fda0042050d81ff8839de55c2b4effd
parent 629f9846
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ public class ApplicationPackageManager extends PackageManager {
    public int[] getPackageGids(String packageName, int flags)
            throws NameNotFoundException {
        try {
            int[] gids = mPM.getPackageGidsEtc(packageName, flags, mContext.getUserId());
            int[] gids = mPM.getPackageGids(packageName, flags, mContext.getUserId());
            if (gids != null) {
                return gids;
            }
@@ -246,7 +246,7 @@ public class ApplicationPackageManager extends PackageManager {
    public int getPackageUidAsUser(String packageName, int flags, int userId)
            throws NameNotFoundException {
        try {
            int uid = mPM.getPackageUidEtc(packageName, flags, userId);
            int uid = mPM.getPackageUid(packageName, flags, userId);
            if (uid >= 0) {
                return uid;
            }
@@ -314,8 +314,14 @@ public class ApplicationPackageManager extends PackageManager {
    @Override
    public ApplicationInfo getApplicationInfo(String packageName, int flags)
            throws NameNotFoundException {
        return getApplicationInfoAsUser(packageName, flags, mContext.getUserId());
    }

    @Override
    public ApplicationInfo getApplicationInfoAsUser(String packageName, int flags, int userId)
            throws NameNotFoundException {
        try {
            ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, mContext.getUserId());
            ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, userId);
            if (ai != null) {
                // This is a temporary hack. Callers must use
                // createPackageContext(packageName).getApplicationInfo() to
@@ -352,7 +358,6 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }


    @Override
    public ActivityInfo getActivityInfo(ComponentName className, int flags)
            throws NameNotFoundException {
@@ -1169,8 +1174,10 @@ public class ApplicationPackageManager extends PackageManager {
        throw new NameNotFoundException("Package " + appPackageName + " doesn't exist");
    }

    int mCachedSafeMode = -1;
    @Override public boolean isSafeMode() {
    volatile int mCachedSafeMode = -1;

    @Override
    public boolean isSafeMode() {
        try {
            if (mCachedSafeMode < 0) {
                mCachedSafeMode = mPM.isSafeMode() ? 1 : 0;
+2 −4
Original line number Diff line number Diff line
@@ -64,10 +64,8 @@ interface IPackageManager {
    void checkPackageStartable(String packageName, int userId);
    boolean isPackageAvailable(String packageName, int userId);
    PackageInfo getPackageInfo(String packageName, int flags, int userId);
    int getPackageUid(String packageName, int userId);
    int getPackageUidEtc(String packageName, int flags, int userId);
    int[] getPackageGids(String packageName, int userId);
    int[] getPackageGidsEtc(String packageName, int flags, int userId);
    int getPackageUid(String packageName, int flags, int userId);
    int[] getPackageGids(String packageName, int flags, int userId);

    String[] currentToCanonicalPackageNames(in String[] names);
    String[] canonicalToCurrentPackageNames(in String[] names);
+4 −0
Original line number Diff line number Diff line
@@ -2541,6 +2541,10 @@ public abstract class PackageManager {
    public abstract ApplicationInfo getApplicationInfo(String packageName,
            @ApplicationInfoFlags int flags) throws NameNotFoundException;

    /** {@hide} */
    public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
            @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;

    /**
     * Retrieve all of the information we know about a particular activity
     * class.
+6 −6
Original line number Diff line number Diff line
@@ -33,13 +33,13 @@ public final class UserHandle implements Parcelable {
    public static final int PER_USER_RANGE = 100000;

    /** @hide A user id to indicate all users on the device */
    public static final int USER_ALL = -1;
    public static final @UserIdInt int USER_ALL = -1;

    /** @hide A user handle to indicate all users on the device */
    public static final UserHandle ALL = new UserHandle(USER_ALL);

    /** @hide A user id to indicate the currently active user */
    public static final int USER_CURRENT = -2;
    public static final @UserIdInt int USER_CURRENT = -2;

    /** @hide A user handle to indicate the current user of the device */
    public static final UserHandle CURRENT = new UserHandle(USER_CURRENT);
@@ -47,7 +47,7 @@ public final class UserHandle implements Parcelable {
    /** @hide A user id to indicate that we would like to send to the current
     *  user, but if this is calling from a user process then we will send it
     *  to the caller's user instead of failing with a security exception */
    public static final int USER_CURRENT_OR_SELF = -3;
    public static final @UserIdInt int USER_CURRENT_OR_SELF = -3;

    /** @hide A user handle to indicate that we would like to send to the current
     *  user, but if this is calling from a user process then we will send it
@@ -55,14 +55,14 @@ public final class UserHandle implements Parcelable {
    public static final UserHandle CURRENT_OR_SELF = new UserHandle(USER_CURRENT_OR_SELF);

    /** @hide An undefined user id */
    public static final int USER_NULL = -10000;
    public static final @UserIdInt int USER_NULL = -10000;

    /**
     * @hide A user id constant to indicate the "owner" user of the device
     * @deprecated Consider using either {@link UserHandle#USER_SYSTEM} constant or
     * check the target user's flag {@link android.content.pm.UserInfo#isAdmin}.
     */
    public static final int USER_OWNER = 0;
    public static final @UserIdInt int USER_OWNER = 0;

    /**
     * @hide A user handle to indicate the primary/owner user of the device
@@ -72,7 +72,7 @@ public final class UserHandle implements Parcelable {
    public static final UserHandle OWNER = new UserHandle(USER_OWNER);

    /** @hide A user id constant to indicate the "system" user of the device */
    public static final int USER_SYSTEM = 0;
    public static final @UserIdInt int USER_SYSTEM = 0;

    /** @hide A user handle to indicate the "system" user of the device */
    public static final UserHandle SYSTEM = new UserHandle(USER_SYSTEM);
+1 −1
Original line number Diff line number Diff line
@@ -882,7 +882,7 @@ public class StorageManager {
                }
                packageName = packageNames[0];
            }
            final int uid = ActivityThread.getPackageManager().getPackageUidEtc(packageName,
            final int uid = ActivityThread.getPackageManager().getPackageUid(packageName,
                    PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId);
            if (uid <= 0) {
                return new StorageVolume[0];
Loading