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

Commit 26050dbd authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Make PackageManagerInternal#getPackageUid internal

Previous implementation was a direct callthrough to the public facing
method. This change deprecates the original method and introduces a new
method with the "Internal" suffix until we can clean up all uses of the
existing method.

Test: boots
Bug: 142386643
Change-Id: I86f92508f0236dbe611ac895fec0ad94f8e80afe
parent cf66c12e
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -250,12 +250,24 @@ public abstract class PackageManagerInternal {
    public abstract @PackageManager.DistractionRestriction int getDistractingPackageRestrictions(
            String packageName, int userId);

    /**
     * Do a straight uid lookup for the given package/application in the given user. This enforces
     * app visibility rules and permissions. Call {@link #getPackageUidInternal} for the internal
     * implementation.
     * @deprecated Use {@link PackageManager#getPackageUid(String, int)}
     * @return The app's uid, or < 0 if the package was not found in that user
     */
    @Deprecated
    public abstract int getPackageUid(String packageName,
            @PackageInfoFlags int flags, int userId);

    /**
     * Do a straight uid lookup for the given package/application in the given user.
     * @see PackageManager#getPackageUidAsUser(String, int, int)
     * @return The app's uid, or < 0 if the package was not found in that user
     * TODO(b/148235092): rename this to getPackageUid
     */
    public abstract int getPackageUid(String packageName,
    public abstract int getPackageUidInternal(String packageName,
            @PackageInfoFlags int flags, int userId);

    /**
+10 −1
Original line number Diff line number Diff line
@@ -124,8 +124,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ApplicationPackageManager;
import android.app.AppOpsManager;
import android.app.ApplicationPackageManager;
import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.ResourcesManager;
@@ -4552,7 +4552,10 @@ public class PackageManagerService extends IPackageManager.Stub
        flags = updateFlagsForPackage(flags, userId);
        mPermissionManager.enforceCrossUserPermission(callingUid, userId,
                false /*requireFullPermission*/, false /*checkShell*/, "getPackageUid");
        return getPackageUidInternal(packageName, flags, userId, callingUid);
    }
    private int getPackageUidInternal(String packageName, int flags, int userId, int callingUid) {
        // reader
        synchronized (mLock) {
            final AndroidPackage p = mPackages.get(packageName);
@@ -23095,6 +23098,12 @@ public class PackageManagerService extends IPackageManager.Stub
                    .getPackageUid(packageName, flags, userId);
        }
        @Override
        public int getPackageUidInternal(String packageName, int flags, int userId) {
            return PackageManagerService.this
                    .getPackageUidInternal(packageName, flags, userId, Process.SYSTEM_UID);
        }
        @Override
        public ApplicationInfo getApplicationInfo(
                String packageName, int flags, int filterCallingUid, int userId) {