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

Commit 9352af2a authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Remove dependencies on the package installer's package name" into mnc-dev

parents 6b96de8d f1b7f20b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ final class ApplicationPackageManager extends PackageManager {
    @GuardedBy("mDelegates")
    private final ArrayList<MoveCallbackDelegate> mDelegates = new ArrayList<>();

    @GuardedBy("mLock")
    private String mPermissionsControllerPackageName;

    UserManager getUserManager() {
        synchronized (mLock) {
            if (mUserManager == null) {
@@ -429,6 +432,23 @@ final class ApplicationPackageManager extends PackageManager {
        }
    }

    /**
     * @hide
     */
    @Override
    public String getPermissionControllerPackageName() {
        synchronized (mLock) {
            if (mPermissionsControllerPackageName == null) {
                try {
                    mPermissionsControllerPackageName = mPM.getPermissionControllerPackageName();
                } catch (RemoteException e) {
                    throw new RuntimeException("Package manager has died", e);
                }
            }
            return mPermissionsControllerPackageName;
        }
    }

    @Override
    public boolean addPermission(PermissionInfo info) {
        try {
+2 −0
Original line number Diff line number Diff line
@@ -505,4 +505,6 @@ interface IPackageManager {
    void grantDefaultPermissionsToEnabledCarrierApps(in String[] packageNames, int userId);

    boolean isPermissionRevokedByPolicy(String permission, String packageName, int userId);

    String getPermissionControllerPackageName();
}
+12 −10
Original line number Diff line number Diff line
@@ -1875,14 +1875,6 @@ public abstract class PackageManager {
    public static final String ACTION_REQUEST_PERMISSIONS =
            "android.content.pm.action.REQUEST_PERMISSIONS";

    /**
     * The component name handling runtime permission grants.
     *
     * @hide
     */
    public static final String GRANT_PERMISSIONS_PACKAGE_NAME =
            "com.android.packageinstaller";

    /**
     * The names of the requested permissions.
     * <p>
@@ -2431,7 +2423,17 @@ public abstract class PackageManager {
     * @return Whether the permission is restricted by policy.
     */
    @CheckResult
    public abstract boolean isPermissionRevokedByPolicy(String permName, String pkgName);
    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
            @NonNull String pkgName);

    /**
     * Gets the package name of the component controlling runtime permissions.
     *
     * @return The package name.
     *
     * @hide
     */
    public abstract String getPermissionControllerPackageName();

    /**
     * Add a new dynamic permission to the system.  For this to work, your
@@ -2615,7 +2617,7 @@ public abstract class PackageManager {
        }
        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
        intent.setPackage(GRANT_PERMISSIONS_PACKAGE_NAME);
        intent.setPackage(getPermissionControllerPackageName());
        return intent;
    }

+1 −1
Original line number Diff line number Diff line
@@ -489,7 +489,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            // User needs to accept permissions; give installer an intent they
            // can use to involve user.
            final Intent intent = new Intent(PackageInstaller.ACTION_CONFIRM_PERMISSIONS);
            intent.setPackage("com.android.packageinstaller");
            intent.setPackage(mContext.getPackageManager().getPermissionControllerPackageName());
            intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
            try {
                mRemoteObserver.onUserActionRequired(intent);
+7 −0
Original line number Diff line number Diff line
@@ -3195,6 +3195,13 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    @Override
    public String getPermissionControllerPackageName() {
        synchronized (mPackages) {
            return mRequiredInstallerPackage;
        }
    }
    /**
     * Checks if the request is from the system or an app that has INTERACT_ACROSS_USERS
     * or INTERACT_ACROSS_USERS_FULL permissions, if the userid is not for the caller.
Loading