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

Commit 9ac5f83a authored by Rhed Jao's avatar Rhed Jao
Browse files

Apply package visibility to the LauncherApps#isActivityEnabled

Bug: 180417374
Test: atest AppEnumerationTests
Change-Id: I23ad6515ca7a8235290809c390f2527bd0b3c987
parent c7469537
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -824,6 +824,12 @@ public abstract class PackageManagerInternal {
    public abstract @PackageManager.EnabledState int getApplicationEnabledState(
            String packageName, int userId);

    /**
     * Return the enabled setting for a package component (activity, receiver, service, provider).
     */
    public abstract @PackageManager.EnabledState int getComponentEnabledSetting(
            @NonNull ComponentName componentName, int callingUid, int userId);

    /**
     * Extra field name for the token of a request to enable rollback for a
     * package.
+15 −13
Original line number Diff line number Diff line
@@ -1028,10 +1028,11 @@ public class LauncherAppsService extends SystemService {
                return false;
            }

            final PackageManagerInternal pmInt =
                    LocalServices.getService(PackageManagerInternal.class);
            final int callingUid = injectBinderCallingUid();
            final long ident = Binder.clearCallingIdentity();
            try {
                final int state = mIPM.getComponentEnabledSetting(component, user.getIdentifier());
            final int state = pmInt.getComponentEnabledSetting(component, callingUid,
                    user.getIdentifier());
            switch (state) {
                case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
                    break; // Need to check the manifest's enabled state.
@@ -1042,8 +1043,9 @@ public class LauncherAppsService extends SystemService {
                case PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED:
                    return false;
            }
                final PackageManagerInternal pmInt =
                        LocalServices.getService(PackageManagerInternal.class);

            final long ident = Binder.clearCallingIdentity();
            try {
                ActivityInfo info = pmInt.getActivityInfo(component,
                        PackageManager.MATCH_DIRECT_BOOT_AWARE
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
+15 −2
Original line number Diff line number Diff line
@@ -23695,11 +23695,17 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    public int getComponentEnabledSetting(@NonNull ComponentName component, int userId) {
        if (component == null) return COMPONENT_ENABLED_STATE_DEFAULT;
        if (!mUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
        int callingUid = Binder.getCallingUid();
        enforceCrossUserPermission(callingUid, userId, false /*requireFullPermission*/,
                false /*checkShell*/, "getComponentEnabled");
        return getComponentEnabledSettingInternal(component, callingUid, userId);
    }
    private int getComponentEnabledSettingInternal(ComponentName component, int callingUid,
            int userId) {
        if (component == null) return COMPONENT_ENABLED_STATE_DEFAULT;
        if (!mUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
        synchronized (mLock) {
            try {
                if (shouldFilterApplicationLocked(
@@ -27125,6 +27131,13 @@ public class PackageManagerService extends IPackageManager.Stub
            }
        }
        @Override
        public @PackageManager.EnabledState int getComponentEnabledSetting(
                @NonNull ComponentName componentName, int callingUid, int userId) {
            return PackageManagerService.this.getComponentEnabledSettingInternal(componentName,
                    callingUid, userId);
        }
        @Override
        public void setEnableRollbackCode(int token, int enableRollbackCode) {
            PackageManagerService.this.setEnableRollbackCode(token, enableRollbackCode);