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
diff --git a/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl b/core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl
index 6e40988..46f78e2 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 f90fbb2..2f92bb3 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 @@
     @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);
     }
 }