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

Commit 5eb72139 authored by David Lin's avatar David Lin Committed by Automerger Merge Worker
Browse files

Merge "Use current user id when invoking omnient." into 24D1-dev am: 2094a139

parents 2641c67b 2094a139
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -1055,15 +1055,22 @@ public class VoiceInteractionManagerService extends SystemService {
                if (sessionArgs != null && sessionArgs.containsKey(csKey)) {
                    if (sessionArgs.getBoolean(csEnabledKey, true)) {
                        // If Contextual Search is enabled, try to follow that path.
                        Intent launchIntent = getContextualSearchIntent(sessionArgs);
                        Intent launchIntent;
                        final long getSearchIntentCaller = Binder.clearCallingIdentity();
                        try {
                            launchIntent = getContextualSearchIntent(sessionArgs);
                        } finally {
                            Binder.restoreCallingIdentity(getSearchIntentCaller);
                        }
                        if (launchIntent != null) {
                            // Hand over to contextual search helper.
                            Slog.d(TAG, "Handed over to contextual search helper.");
                            final long caller = Binder.clearCallingIdentity();
                            final int userId = Binder.getCallingUserHandle().getIdentifier();
                            final long startSearchCaller = Binder.clearCallingIdentity();
                            try {
                                return startContextualSearch(launchIntent);
                                return startContextualSearch(launchIntent, userId);
                            } finally {
                                Binder.restoreCallingIdentity(caller);
                                Binder.restoreCallingIdentity(startSearchCaller);
                            }
                        }
                    }
@@ -2761,7 +2768,7 @@ public class VoiceInteractionManagerService extends SystemService {
        }

        @RequiresPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS)
        private boolean startContextualSearch(Intent launchIntent) {
        private boolean startContextualSearch(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,
@@ -2769,7 +2776,7 @@ public class VoiceInteractionManagerService extends SystemService {
            opts.setDisableStartingWindow(true);
            int resultCode = mAtmInternal.startActivityWithScreenshot(launchIntent,
                    mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null,
                    opts.toBundle(), Binder.getCallingUserHandle().getIdentifier());
                    opts.toBundle(), userId);
            return resultCode == ActivityManager.START_SUCCESS;
        }