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

Commit 6d9ea8ec authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Prevent showing voice session when it is already queued to be hidden." into oc-dev

am: c672cb5e

Change-Id: I983396208aa1364884f6b90939c04ef58c2f432c
parents 1f06e458 c672cb5e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -300,6 +300,19 @@ public class ActivityManager {
     */
    public static final int START_INTENT_NOT_RESOLVED = FIRST_START_FATAL_ERROR_CODE + 9;

    /**
     * Result for IActivityManager.startAssistantActivity: active session is currently hidden.
     * @hide
     */
    public static final int START_ASSISTANT_HIDDEN_SESSION = FIRST_START_FATAL_ERROR_CODE + 10;

    /**
     * Result for IActivityManager.startAssistantActivity: active session does not match
     * the requesting token.
     * @hide
     */
    public static final int START_ASSISTANT_NOT_ACTIVE_SESSION = FIRST_START_FATAL_ERROR_CODE + 11;

    /**
     * Result for IActivityManaqer.startActivity: the activity was started
     * successfully as normal.
+6 −0
Original line number Diff line number Diff line
@@ -1953,6 +1953,12 @@ public class Instrumentation {
            case ActivityManager.START_VOICE_HIDDEN_SESSION:
                throw new IllegalStateException(
                        "Cannot start voice activity on a hidden session");
            case ActivityManager.START_ASSISTANT_NOT_ACTIVE_SESSION:
                throw new IllegalStateException(
                        "Session calling startAssistantActivity does not match active session");
            case ActivityManager.START_ASSISTANT_HIDDEN_SESSION:
                throw new IllegalStateException(
                        "Cannot start assistant activity on a hidden session");
            case ActivityManager.START_CANCELED:
                throw new AndroidRuntimeException("Activity could not be started for "
                        + intent);
+2 −0
Original line number Diff line number Diff line
@@ -235,6 +235,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall

        @Override
        public void hide() {
            // Remove any pending messages to show the session
            mHandlerCaller.removeMessages(MSG_SHOW);
            mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_HIDE));
        }

+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.voiceinteraction;

import static android.app.ActivityManager.START_ASSISTANT_HIDDEN_SESSION;
import static android.app.ActivityManager.START_ASSISTANT_NOT_ACTIVE_SESSION;
import static android.app.ActivityManager.START_VOICE_HIDDEN_SESSION;
import static android.app.ActivityManager.START_VOICE_NOT_ACTIVE_SESSION;

@@ -212,11 +214,11 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        try {
            if (mActiveSession == null || token != mActiveSession.mToken) {
                Slog.w(TAG, "startAssistantActivity does not match active session");
                return START_VOICE_NOT_ACTIVE_SESSION;
                return START_ASSISTANT_NOT_ACTIVE_SESSION;
            }
            if (!mActiveSession.mShown) {
                Slog.w(TAG, "startAssistantActivity not allowed on hidden session");
                return START_VOICE_HIDDEN_SESSION;
                return START_ASSISTANT_HIDDEN_SESSION;
            }
            intent = new Intent(intent);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+1 −0
Original line number Diff line number Diff line
@@ -453,6 +453,7 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
                mShowFlags = 0;
                mHaveAssistData = false;
                mAssistData.clear();
                mPendingShowCallbacks.clear();
                if (mSession != null) {
                    try {
                        mSession.hide();