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

Commit 94bb876e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removes direct use of LocalServices.getService"

parents 846c219d 2f2fd718
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -221,4 +221,7 @@ public abstract class UserManagerInternal {
     */
    public abstract boolean isSettingRestrictedForUser(String setting, int userId, String value,
            int callingUid);

    /** @return a specific user restriction that's in effect currently. */
    public abstract boolean hasUserRestriction(String restriction, int userId);
}
+1 −1
Original line number Diff line number Diff line
@@ -686,7 +686,7 @@ class InstantAppRegistry {

        // Prune first installed instant apps
        synchronized (mService.mLock) {
            allUsers = PackageManagerService.sUserManager.getUserIds();
            allUsers = mService.mUserManager.getUserIds();

            final int packageCount = mService.mPackages.size();
            for (int i = 0; i < packageCount; i++) {
+224 −171

File changed.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManagerInternal;
import android.service.pm.PackageServiceDumpProto;
import android.system.ErrnoException;
import android.system.Os;
@@ -375,10 +376,12 @@ public class PackageManagerServiceUtils {
        }
    }

    public static void enforceShellRestriction(String restriction, int callingUid, int userHandle) {
    /** Enforces that if the caller is shell, it does not have the provided user restriction. */
    public static void enforceShellRestriction(
            UserManagerInternal userManager, String restriction, int callingUid, int userHandle) {
        if (callingUid == Process.SHELL_UID) {
            if (userHandle >= 0
                    && PackageManagerService.sUserManager.hasUserRestriction(
                    && userManager.hasUserRestriction(
                            restriction, userHandle)) {
                throw new SecurityException("Shell does not have permission to access user "
                        + userHandle);
+10 −5
Original line number Diff line number Diff line
@@ -1557,11 +1557,7 @@ public class UserManagerService extends IUserManager.Stub {
    /** @return a specific user restriction that's in effect currently. */
    @Override
    public boolean hasUserRestriction(String restrictionKey, int userId) {
        if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) {
            return false;
        }
        Bundle restrictions = getEffectiveUserRestrictions(userId);
        return restrictions != null && restrictions.getBoolean(restrictionKey);
        return mLocalService.hasUserRestriction(restrictionKey, userId);
    }

    /** @return if any user has the given restriction. */
@@ -4128,6 +4124,15 @@ public class UserManagerService extends IUserManager.Stub {
            return UserRestrictionsUtils.isSettingRestrictedForUser(mContext, setting, userId,
                    value, callingUid);
        }

        @Override
        public boolean hasUserRestriction(String restrictionKey, int userId) {
            if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) {
                return false;
            }
            Bundle restrictions = getEffectiveUserRestrictions(userId);
            return restrictions != null && restrictions.getBoolean(restrictionKey);
        }
    }

    /* Remove all the users except of the system one. */
Loading