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

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

Merge "Fix work profile shortcut launch"

parents 7d07ad1e 7041c4b9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -219,6 +219,9 @@ public abstract class ActivityManagerInternal {
    /**
     * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
     *
     * - DO NOT call it with the calling UID cleared.
     * - All the necessary caller permission checks must be done at callsites.
     *
     * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
     */
    public abstract int startActivitiesAsPackage(String packageName,
+4 −2
Original line number Diff line number Diff line
@@ -25683,9 +25683,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            synchronized (ActivityManagerService.this) {
                return mActivityStartController.startActivitiesInPackage(packageUid, packageName,
                return mActivityStartController.startActivitiesInPackage(
                        packageUid, packageName,
                        intents, resolvedTypes, null /* resultTo */,
                        SafeActivityOptions.fromBundle(bOptions), userId);
                        SafeActivityOptions.fromBundle(bOptions), userId,
                        false /* validateIncomingUser */);
            }
        }
+17 −3
Original line number Diff line number Diff line
@@ -245,11 +245,25 @@ public class ActivityStartController {
                .execute();
    }

    /**
     * Start intents as a package.
     *
     * @param uid make a call as if this UID did.
     * @param callingPackage make a call as if this package did.
     * @param intents intents to start.
     * @param userId start the intents on this user.
     * @param validateIncomingUser set true to skip checking {@code userId} with the calling UID.
     */
    final int startActivitiesInPackage(int uid, String callingPackage, Intent[] intents,
            String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId) {
            String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
            boolean validateIncomingUser) {
        final String reason = "startActivityInPackage";
        if (validateIncomingUser) {
            userId = mService.mUserController.handleIncomingUser(Binder.getCallingPid(),
                    Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY, reason, null);
        } else {
            mService.mUserController.ensureNotSpecialUser(userId);
        }
        // TODO: Switch to user app stacks here.
        return startActivities(null, uid, callingPackage, intents, resolvedTypes, resultTo, options,
                userId, reason);
+2 −1
Original line number Diff line number Diff line
@@ -335,7 +335,8 @@ final class PendingIntentRecord extends IIntentSender.Stub {
                                allResolvedTypes[allResolvedTypes.length-1] = resolvedType;
                                res = owner.getActivityStartController().startActivitiesInPackage(
                                        uid, key.packageName, allIntents, allResolvedTypes,
                                        resultTo, mergedOptions, userId);
                                        resultTo, mergedOptions, userId,
                                        true /* validateIncomingUser */);
                            } else {
                                res = owner.getActivityStartController().startActivityInPackage(uid,
                                        callingPid, callingUid, key.packageName, finalIntent,
+9 −3
Original line number Diff line number Diff line
@@ -1489,9 +1489,8 @@ class UserController implements Handler.Callback {
                }
            }
        }
        if (!allowAll && targetUserId < 0) {
            throw new IllegalArgumentException(
                    "Call does not support special user #" + targetUserId);
        if (!allowAll) {
            ensureNotSpecialUser(targetUserId);
        }
        // Check shell permission
        if (callingUid == Process.SHELL_UID && targetUserId >= UserHandle.USER_SYSTEM) {
@@ -1508,6 +1507,13 @@ class UserController implements Handler.Callback {
                ? getCurrentUserId(): userId;
    }

    void ensureNotSpecialUser(int userId) {
        if (userId >= 0) {
            return;
        }
        throw new IllegalArgumentException("Call does not support special user #" + userId);
    }

    void registerUserSwitchObserver(IUserSwitchObserver observer, String name) {
        Preconditions.checkNotNull(name, "Observer name cannot be null");
        if (mInjector.checkCallingPermission(INTERACT_ACROSS_USERS_FULL)