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

Commit 0f2df53f authored by Jakob Schneider's avatar Jakob Schneider Committed by Android (Google) Code Review
Browse files

Merge "Fix a crash in the LauncherApps Api for the work profile." into main

parents f5423b1d 6a4fc06f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -221,6 +221,14 @@ public abstract class PackageManagerInternal {
            @PackageManager.ApplicationInfoFlagsBits long flags, @UserIdInt int userId,
            int callingUid);

    /**
     * Like {@link #getInstalledApplications}, but allows the fetching of apps
     * cross user.
     */
    public abstract List<ApplicationInfo> getInstalledApplicationsCrossUser(
            @PackageManager.ApplicationInfoFlagsBits long flags, @UserIdInt int userId,
            int callingUid);

    /**
     * Retrieve launcher extras for a suspended package provided to the system in
     * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ public interface Computer extends PackageDataSnapshot {
    @NonNull
    List<ApplicationInfo> getInstalledApplications(
            @PackageManager.ApplicationInfoFlagsBits long flags, @UserIdInt int userId,
            int callingUid);
            int callingUid, boolean forceAllowCrossUser);

    @Nullable
    ProviderInfo resolveContentProvider(@NonNull String name,
+9 −7
Original line number Diff line number Diff line
@@ -4640,7 +4640,7 @@ public class ComputerEngine implements Computer {
    @Override
    public List<ApplicationInfo> getInstalledApplications(
            @PackageManager.ApplicationInfoFlagsBits long flags, @UserIdInt int userId,
            int callingUid) {
            int callingUid, boolean forceAllowCrossUser) {
        if (getInstantAppPackageName(callingUid) != null) {
            return Collections.emptyList();
        }
@@ -4650,12 +4650,14 @@ public class ComputerEngine implements Computer {
        final boolean listApex = (flags & MATCH_APEX) != 0;
        final boolean listArchivedOnly = !listUninstalled && (flags & MATCH_ARCHIVED_PACKAGES) != 0;

        if (!forceAllowCrossUser) {
            enforceCrossUserPermission(
                    callingUid,
                    userId,
                    false /* requireFullPermission */,
                    false /* checkShell */,
                    "get installed application info");
        }

        ArrayList<ApplicationInfo> list;
        final ArrayMap<String, ? extends PackageStateInternal> packageStates =
+2 −1
Original line number Diff line number Diff line
@@ -476,7 +476,8 @@ public abstract class IPackageManagerBase extends IPackageManager.Stub {
            @PackageManager.ApplicationInfoFlagsBits long flags, int userId) {
        final int callingUid = Binder.getCallingUid();
        return new ParceledListSlice<>(
                snapshot().getInstalledApplications(flags, userId, callingUid));
                snapshot().getInstalledApplications(flags, userId, callingUid,
                        /* forceAllowCrossUser= */ false));
    }

    @Override
+10 −6
Original line number Diff line number Diff line
@@ -769,6 +769,9 @@ public class LauncherAppsService extends SystemService {
        @NonNull
        private List<LauncherActivityInfoInternal> generateLauncherActivitiesForArchivedApp(
                @Nullable String packageName, UserHandle user) {
            if (!canAccessProfile(user.getIdentifier(), "Cannot retrieve activities")) {
                return List.of();
            }
            List<ApplicationInfo> applicationInfoList =
                    (packageName == null)
                            ? getApplicationInfoListForAllArchivedApps(user)
@@ -827,7 +830,7 @@ public class LauncherAppsService extends SystemService {
        private List<ApplicationInfo> getApplicationInfoListForAllArchivedApps(UserHandle user) {
            final int callingUid = injectBinderCallingUid();
            List<ApplicationInfo> installedApplicationInfoList =
                    mPackageManagerInternal.getInstalledApplications(
                    mPackageManagerInternal.getInstalledApplicationsCrossUser(
                            PackageManager.MATCH_ARCHIVED_PACKAGES,
                            user.getIdentifier(),
                            callingUid);
@@ -845,11 +848,12 @@ public class LauncherAppsService extends SystemService {
        private List<ApplicationInfo> getApplicationInfoForArchivedApp(
                @NonNull String packageName, UserHandle user) {
            final int callingUid = injectBinderCallingUid();
            ApplicationInfo applicationInfo = mPackageManagerInternal.getApplicationInfo(
            ApplicationInfo applicationInfo = Binder.withCleanCallingIdentity(() ->
                    mPackageManagerInternal.getApplicationInfo(
                            packageName,
                            PackageManager.MATCH_ARCHIVED_PACKAGES,
                            callingUid,
                    user.getIdentifier());
                            user.getIdentifier()));
            if (applicationInfo == null || !applicationInfo.isArchived) {
                return Collections.EMPTY_LIST;
            }
Loading