From fdca2fb83b3ca3a1ce842fd10c595bf2199ff08b Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Thu, 22 Dec 2022 08:18:14 +0000 Subject: Do not dismiss session ui if the close dialog reason is assist When assistant is launched from the hardware button, it will try to close system dialog with assist reason and launch a new UI again. From the current logic, the voice system service doesn't filter the assist reason to hide itself. If the session already exists, it will hide itself and get another onShow immediately. This causes unnecessary ui animations for hide/show from the user perspective. To fix it, this change will filter the assist reason to hide the session. Bug: 257275314 Test: atest CtsVoiceInteractionTestCases Test: use hotware button to trigger assistant and monitor the animation status Change-Id: Ibe636ad0b6776a1dbdf7f709a9ef5e804c6b015a --- .../voiceinteraction/VoiceInteractionManagerServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index f041adcc7d77..964328271866 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -22,6 +22,8 @@ import static android.app.ActivityManager.START_VOICE_HIDDEN_SESSION; import static android.app.ActivityManager.START_VOICE_NOT_ACTIVE_SESSION; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; +import static com.android.server.policy.PhoneWindowManager.SYSTEM_DIALOG_REASON_ASSIST; + import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; @@ -62,6 +64,7 @@ import android.service.voice.IVoiceInteractionSession; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionServiceInfo; import android.system.OsConstants; +import android.text.TextUtils; import android.util.PrintWriterPrinter; import android.util.Slog; import android.view.IWindowManager; @@ -118,7 +121,9 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne public void onReceive(Context context, Intent intent) { if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) { String reason = intent.getStringExtra("reason"); - if (!CLOSE_REASON_VOICE_INTERACTION.equals(reason) && !"dream".equals(reason)) { + if (!CLOSE_REASON_VOICE_INTERACTION.equals(reason) + && !TextUtils.equals("dream", reason) + && !SYSTEM_DIALOG_REASON_ASSIST.equals(reason)) { synchronized (mServiceStub) { if (mActiveSession != null && mActiveSession.mSession != null) { try { -- cgit v1.2.3-59-g8ed1b