Merge "Prevent showing voice session when it is already queued to be hidden." into oc-dev
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -453,6 +453,7 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
|
||||
mShowFlags = 0;
|
||||
mHaveAssistData = false;
|
||||
mAssistData.clear();
|
||||
mPendingShowCallbacks.clear();
|
||||
if (mSession != null) {
|
||||
try {
|
||||
mSession.hide();
|
||||
|
||||
Reference in New Issue
Block a user