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

Commit 1fa0a3f4 authored by Andy Wickham's avatar Andy Wickham
Browse files

Use current user id when invoking omnient.

This is the CS Helper version of the change for u-patch.

Original fix in main: ag/27873355

Bug: 343426174
Test: Manual in guest and retail demo mode
Flag: exempt bugfix
Change-Id: Ida0a72c513129c0225a0da90c67c1d584dd34610
parent 01ea3448
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -1053,15 +1053,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);
                            }
                        }
                    }
@@ -2762,7 +2769,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,
@@ -2770,7 +2777,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;
        }