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

Commit 2094a139 authored by David Lin's avatar David Lin Committed by Android (Google) Code Review
Browse files

Merge "Use current user id when invoking omnient." into 24D1-dev

parents 7cd76af0 1fa0a3f4
Loading
Loading
Loading
Loading
+13 −6
Original line number Original line Diff line number Diff line
@@ -1053,15 +1053,22 @@ public class VoiceInteractionManagerService extends SystemService {
                if (sessionArgs != null && sessionArgs.containsKey(csKey)) {
                if (sessionArgs != null && sessionArgs.containsKey(csKey)) {
                    if (sessionArgs.getBoolean(csEnabledKey, true)) {
                    if (sessionArgs.getBoolean(csEnabledKey, true)) {
                        // If Contextual Search is enabled, try to follow that path.
                        // 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) {
                        if (launchIntent != null) {
                            // Hand over to contextual search helper.
                            // Hand over to contextual search helper.
                            Slog.d(TAG, "Handed 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 {
                            try {
                                return startContextualSearch(launchIntent);
                                return startContextualSearch(launchIntent, userId);
                            } finally {
                            } finally {
                                Binder.restoreCallingIdentity(caller);
                                Binder.restoreCallingIdentity(startSearchCaller);
                            }
                            }
                        }
                        }
                    }
                    }
@@ -2762,7 +2769,7 @@ public class VoiceInteractionManagerService extends SystemService {
        }
        }


        @RequiresPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS)
        @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
            // Contextual search starts with a frozen screen - so we launch without
            // any system animations or starting window.
            // any system animations or starting window.
            final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext,
            final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext,
@@ -2770,7 +2777,7 @@ public class VoiceInteractionManagerService extends SystemService {
            opts.setDisableStartingWindow(true);
            opts.setDisableStartingWindow(true);
            int resultCode = mAtmInternal.startActivityWithScreenshot(launchIntent,
            int resultCode = mAtmInternal.startActivityWithScreenshot(launchIntent,
                    mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null,
                    mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null,
                    opts.toBundle(), Binder.getCallingUserHandle().getIdentifier());
                    opts.toBundle(), userId);
            return resultCode == ActivityManager.START_SUCCESS;
            return resultCode == ActivityManager.START_SUCCESS;
        }
        }