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

Commit 4b56a300 authored by Rhed Jao's avatar Rhed Jao Committed by Automerger Merge Worker
Browse files

Merge "Apply package visibility to the LauncherApps#isActivityEnabled" into sc-dev am: b8a482b0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14150475

Change-Id: Ic7557d59fe96f183e4487b68f206fc40d8a6fc97
parents 2478cb70 b8a482b0
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -825,6 +825,12 @@ public abstract class PackageManagerInternal {
    public abstract @PackageManager.EnabledState int getApplicationEnabledState(
    public abstract @PackageManager.EnabledState int getApplicationEnabledState(
            String packageName, int userId);
            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
     * Extra field name for the token of a request to enable rollback for a
     * package.
     * package.
+15 −13
Original line number Original line Diff line number Diff line
@@ -1043,10 +1043,11 @@ public class LauncherAppsService extends SystemService {
                return false;
                return false;
            }
            }


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

                        LocalServices.getService(PackageManagerInternal.class);
            final long ident = Binder.clearCallingIdentity();
            try {
                ActivityInfo info = pmInt.getActivityInfo(component,
                ActivityInfo info = pmInt.getActivityInfo(component,
                        PackageManager.MATCH_DIRECT_BOOT_AWARE
                        PackageManager.MATCH_DIRECT_BOOT_AWARE
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
+15 −2
Original line number Original line Diff line number Diff line
@@ -23618,11 +23618,17 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    @Override
    public int getComponentEnabledSetting(@NonNull ComponentName component, int userId) {
    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();
        int callingUid = Binder.getCallingUid();
        enforceCrossUserPermission(callingUid, userId, false /*requireFullPermission*/,
        enforceCrossUserPermission(callingUid, userId, false /*requireFullPermission*/,
                false /*checkShell*/, "getComponentEnabled");
                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) {
        synchronized (mLock) {
            try {
            try {
                if (shouldFilterApplicationLocked(
                if (shouldFilterApplicationLocked(
@@ -27106,6 +27112,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
        @Override
        public void setEnableRollbackCode(int token, int enableRollbackCode) {
        public void setEnableRollbackCode(int token, int enableRollbackCode) {
            PackageManagerService.this.setEnableRollbackCode(token, enableRollbackCode);
            PackageManagerService.this.setEnableRollbackCode(token, enableRollbackCode);