From cabd5d559259c69e6b5b86e2151876941fe2f5b2 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 17 Nov 2022 17:22:26 -0800 Subject: [PATCH] Ensure SysUI gets VIS callback when session's over There are chances that SysUI does not get the onVoiceSessionWindowVisibilityChanged(false) callback if the voice interaction window was visible then the connection is closed. This could cause issue for TaskBar since TaskBar relies on the callback to clear its intermediate state. Video: http://recall/-/b1EZhgUkQcpML5OwZekLBN/giEfwSaYA9saSOfGQwCAus Bug: 254070601 Test: follow the reproduce steps in bug, see also video Change-Id: I0222eea38179620c36253f47f332536ffb9e434c --- .../android/internal/app/IVoiceInteractionSessionListener.aidl | 2 ++ .../voiceinteraction/VoiceInteractionManagerServiceImpl.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl b/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl index 6e409885fa136..46f78e2ee8a2f 100644 --- a/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl +++ b/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl @@ -31,6 +31,8 @@ /** * Called when a voice session window is shown/hidden. + * Caution that there could be duplicated visibility change callbacks, it's up to the listener + * to dedup those events. */ void onVoiceSessionWindowVisibilityChanged(boolean visible); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index f90fbb249f5dc..2f92bb3baa9bc 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -880,5 +880,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne @Override public void onSessionHidden(VoiceInteractionSessionConnection connection) { mServiceStub.onSessionHidden(); + // Notifies visibility change here can cause duplicate events, it is added to make sure + // client always get the callback even if session is unexpectedly closed. + mServiceStub.setSessionWindowVisible(connection.mToken, false); } }