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

Commit 5fe47535 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Reintroduce internal variant of getComponentEnabledSetting

The *Internal variant of the getComponentEnabledSetting call was removed
in ag/16176950, which was an oversight. This change adds it back to
avoid unnecessary permission checks on calls to
PackageManagerInternal#getComponentEnabledSetting.

Fixes: 206734531
Change-Id: Ifab64bb18960cc504c97a63f46d621bdb812732a
parent 33f9db92
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -514,6 +514,11 @@ public interface Computer {
    int getComponentEnabledSetting(@NonNull ComponentName component, int callingUid,
            @UserIdInt int userId);

    @Computer.LiveImplementation(override = LiveImplementation.MANDATORY)
    @PackageManager.EnabledState
    int getComponentEnabledSettingInternal(@NonNull ComponentName component, int callingUid,
            @UserIdInt int userId);

    /**
     * @return true if the runtime app user enabled state, runtime component user enabled state,
     * install-time app manifest enabled state, and install-time component manifest enabled state
+15 −9
Original line number Diff line number Diff line
@@ -5015,7 +5015,13 @@ public class ComputerEngine implements Computer {
            @UserIdInt int userId) {
        enforceCrossUserPermission(callingUid, userId, false /*requireFullPermission*/,
                false /*checkShell*/, "getComponentEnabled");
        return getComponentEnabledSettingInternal(component, callingUid, userId);
    }

    @PackageManager.EnabledState
    @Override
    public int getComponentEnabledSettingInternal(@NonNull ComponentName component, int callingUid,
            @UserIdInt int userId) {
        if (component == null) return COMPONENT_ENABLED_STATE_DEFAULT;
        if (!mUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;

+8 −0
Original line number Diff line number Diff line
@@ -649,6 +649,14 @@ public final class ComputerLocked extends ComputerEngine {
        }
    }

    @Override
    public int getComponentEnabledSettingInternal(@NonNull ComponentName component, int callingUid,
            @UserIdInt int userId) {
        synchronized (mLock) {
            return super.getComponentEnabledSettingInternal(component, callingUid, userId);
        }
    }

    @Override
    public boolean isComponentEffectivelyEnabled(@NonNull ComponentInfo componentInfo,
            @UserIdInt int userId) {
+9 −0
Original line number Diff line number Diff line
@@ -1089,6 +1089,15 @@ public final class ComputerTracker implements Computer {
        }
    }

    @Override
    public int getComponentEnabledSettingInternal(@NonNull ComponentName component, int callingUid,
            @UserIdInt int userId) {
        try (ThreadComputer current = snapshot()) {
            return current.mComputer.getComponentEnabledSettingInternal(
                    component, callingUid, userId);
        }
    }

    @Override
    public boolean isComponentEffectivelyEnabled(@NonNull ComponentInfo componentInfo,
            @UserIdInt int userId) {
+2 −2
Original line number Diff line number Diff line
@@ -8195,8 +8195,8 @@ public class PackageManagerService extends IPackageManager.Stub
        @Override
        public @PackageManager.EnabledState int getComponentEnabledSetting(
                @NonNull ComponentName componentName, int callingUid, int userId) {
            return PackageManagerService.this.mComputer.getComponentEnabledSetting(componentName,
                    callingUid, userId);
            return PackageManagerService.this.mComputer.getComponentEnabledSettingInternal(
                    componentName, callingUid, userId);
        }

        @Override