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

Commit 41612609 authored by Robin Lee's avatar Robin Lee Committed by Android Build Coastguard Worker
Browse files

Use callingUserId instead of system userId

Test: atest ContextualSearchManagerTest # in a secondary user
Bug: 343426174
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:de177d49bfed634a357b4b55c92a1b66cd0457f0)
Merged-In: I0f8766448fa2f412b7cb590403e042f9cec9c5c9
Change-Id: I0f8766448fa2f412b7cb590403e042f9cec9c5c9
parent 6b42c39b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -364,7 +364,7 @@ public class ContextualSearchManagerService extends SystemService {
    }

    @RequiresPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS)
    private int invokeContextualSearchIntent(Intent launchIntent) {
    private int invokeContextualSearchIntent(Intent launchIntent, final int userId) {
        // Contextual search starts with a frozen screen - so we launch without
        // any system animations or starting window.
        final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext,
@@ -372,7 +372,7 @@ public class ContextualSearchManagerService extends SystemService {
        opts.setDisableStartingWindow(true);
        return mAtmInternal.startActivityWithScreenshot(launchIntent,
                mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null,
                opts.toBundle(), Binder.getCallingUserHandle().getIdentifier());
                opts.toBundle(), userId);
    }

    private void enforcePermission(@NonNull final String func) {
@@ -446,6 +446,8 @@ public class ContextualSearchManagerService extends SystemService {
            synchronized (this) {
                if (DEBUG_USER) Log.d(TAG, "startContextualSearch");
                enforcePermission("startContextualSearch");
                final int callingUserId = Binder.getCallingUserHandle().getIdentifier();

                mAssistDataRequester.cancel();
                // Creates a new CallbackToken at mToken and an expiration handler.
                issueToken();
@@ -455,7 +457,7 @@ public class ContextualSearchManagerService extends SystemService {
                Binder.withCleanCallingIdentity(() -> {
                    Intent launchIntent = getContextualSearchIntent(entrypoint, mToken);
                    if (launchIntent != null) {
                        int result = invokeContextualSearchIntent(launchIntent);
                        int result = invokeContextualSearchIntent(launchIntent, callingUserId);
                        if (DEBUG_USER) Log.d(TAG, "Launch result: " + result);
                    }
                });