Loading core/java/com/android/internal/app/AssistUtils.java +29 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,35 @@ public class AssistUtils { } } /** * Enables visual detection service. * * @param listener to receive visual attention gained/lost events. */ public void enableVisualQueryDetection( IVisualQueryDetectionAttentionListener listener) { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService.enableVisualQueryDetection(listener); } } catch (RemoteException e) { Log.w(TAG, "Failed to register visual query detection attention listener", e); } } /** * Disables visual query detection. */ public void disableVisualQueryDetection() { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService.disableVisualQueryDetection(); } } catch (RemoteException e) { Log.w(TAG, "Failed to register visual query detection attention listener", e); } } @UnsupportedAppUsage public ComponentName getAssistComponentForUser(int userId) { final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Loading core/java/com/android/internal/app/IVisualQueryDetectionAttentionListener.aidl 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.app; /** * Allows sysui to notify users the assistant is ready to take a query without notifying the * assistant app. */ oneway interface IVisualQueryDetectionAttentionListener { /** * Called when attention signal is sent. */ void onAttentionGained(); /** * Called when a attention signal is lost. */ void onAttentionLost(); } No newline at end of file core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.internal.app.IVoiceInteractionSessionListener; import com.android.internal.app.IVoiceInteractionSessionShowCallback; import com.android.internal.app.IVoiceInteractionSoundTriggerSession; import com.android.internal.app.IVoiceInteractor; import com.android.internal.app.IVisualQueryDetectionAttentionListener; interface IVoiceInteractionManagerService { void showSession(in Bundle sessionArgs, int flags, String attributionTag); Loading Loading @@ -300,6 +301,12 @@ interface IVoiceInteractionManagerService { */ void shutdownHotwordDetectionService(); @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE") void enableVisualQueryDetection(in IVisualQueryDetectionAttentionListener Listener); @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE") void disableVisualQueryDetection(); void startPerceiving(in IVisualQueryDetectionVoiceInteractionCallback callback); void stopPerceiving(); Loading services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +10 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.view.contentcapture.IContentCaptureManager; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVisualQueryDetectionAttentionListener; import com.android.internal.infra.ServiceConnector; import com.android.server.LocalServices; import com.android.server.pm.permission.PermissionManagerServiceInternal; Loading Loading @@ -328,6 +329,15 @@ final class HotwordDetectionConnection { session.startListeningFromMicLocked(audioFormat, callback); } public void setVisualQueryDetectionAttentionListenerLocked( @Nullable IVisualQueryDetectionAttentionListener listener) { final VisualQueryDetectorSession session = getVisualQueryDetectorSessionLocked(); if (session == null) { return; } session.setVisualQueryDetectionAttentionListenerLocked(listener); } /** * This method is only used by VisualQueryDetector. */ Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java +26 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.service.voice.IVisualQueryDetectionVoiceInteractionCallback; import android.util.Slog; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVisualQueryDetectionAttentionListener; import java.io.PrintWriter; import java.util.Objects; Loading @@ -49,6 +50,7 @@ import java.util.concurrent.ScheduledExecutorService; final class VisualQueryDetectorSession extends DetectorSession { private static final String TAG = "VisualQueryDetectorSession"; private IVisualQueryDetectionAttentionListener mAttentionListener; private boolean mEgressingData; private boolean mQueryStreaming; Loading @@ -64,6 +66,7 @@ final class VisualQueryDetectorSession extends DetectorSession { logging); mEgressingData = false; mQueryStreaming = false; mAttentionListener = null; } @Override Loading @@ -74,6 +77,11 @@ final class VisualQueryDetectorSession extends DetectorSession { //TODO(b/261783819): Starts detection in VisualQueryDetectionService. } void setVisualQueryDetectionAttentionListenerLocked( @Nullable IVisualQueryDetectionAttentionListener listener) { mAttentionListener = listener; } @SuppressWarnings("GuardedBy") void startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) { if (DEBUG) { Loading @@ -86,15 +94,31 @@ final class VisualQueryDetectorSession extends DetectorSession { @Override public void onAttentionGained() { Slog.v(TAG, "BinderCallback#onAttentionGained"); //TODO check to see if there is an active SysUI listener registered mEgressingData = true; if (mAttentionListener == null) { return; } try { mAttentionListener.onAttentionGained(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention gained event.", e); return; } } @Override public void onAttentionLost() { Slog.v(TAG, "BinderCallback#onAttentionLost"); //TODO check to see if there is an active SysUI listener registered mEgressingData = false; if (mAttentionListener == null) { return; } try { mAttentionListener.onAttentionLost(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention lost event.", e); return; } } @Override Loading Loading
core/java/com/android/internal/app/AssistUtils.java +29 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,35 @@ public class AssistUtils { } } /** * Enables visual detection service. * * @param listener to receive visual attention gained/lost events. */ public void enableVisualQueryDetection( IVisualQueryDetectionAttentionListener listener) { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService.enableVisualQueryDetection(listener); } } catch (RemoteException e) { Log.w(TAG, "Failed to register visual query detection attention listener", e); } } /** * Disables visual query detection. */ public void disableVisualQueryDetection() { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService.disableVisualQueryDetection(); } } catch (RemoteException e) { Log.w(TAG, "Failed to register visual query detection attention listener", e); } } @UnsupportedAppUsage public ComponentName getAssistComponentForUser(int userId) { final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Loading
core/java/com/android/internal/app/IVisualQueryDetectionAttentionListener.aidl 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.app; /** * Allows sysui to notify users the assistant is ready to take a query without notifying the * assistant app. */ oneway interface IVisualQueryDetectionAttentionListener { /** * Called when attention signal is sent. */ void onAttentionGained(); /** * Called when a attention signal is lost. */ void onAttentionLost(); } No newline at end of file
core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.internal.app.IVoiceInteractionSessionListener; import com.android.internal.app.IVoiceInteractionSessionShowCallback; import com.android.internal.app.IVoiceInteractionSoundTriggerSession; import com.android.internal.app.IVoiceInteractor; import com.android.internal.app.IVisualQueryDetectionAttentionListener; interface IVoiceInteractionManagerService { void showSession(in Bundle sessionArgs, int flags, String attributionTag); Loading Loading @@ -300,6 +301,12 @@ interface IVoiceInteractionManagerService { */ void shutdownHotwordDetectionService(); @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE") void enableVisualQueryDetection(in IVisualQueryDetectionAttentionListener Listener); @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE") void disableVisualQueryDetection(); void startPerceiving(in IVisualQueryDetectionVoiceInteractionCallback callback); void stopPerceiving(); Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +10 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.view.contentcapture.IContentCaptureManager; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVisualQueryDetectionAttentionListener; import com.android.internal.infra.ServiceConnector; import com.android.server.LocalServices; import com.android.server.pm.permission.PermissionManagerServiceInternal; Loading Loading @@ -328,6 +329,15 @@ final class HotwordDetectionConnection { session.startListeningFromMicLocked(audioFormat, callback); } public void setVisualQueryDetectionAttentionListenerLocked( @Nullable IVisualQueryDetectionAttentionListener listener) { final VisualQueryDetectorSession session = getVisualQueryDetectorSessionLocked(); if (session == null) { return; } session.setVisualQueryDetectionAttentionListenerLocked(listener); } /** * This method is only used by VisualQueryDetector. */ Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java +26 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.service.voice.IVisualQueryDetectionVoiceInteractionCallback; import android.util.Slog; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVisualQueryDetectionAttentionListener; import java.io.PrintWriter; import java.util.Objects; Loading @@ -49,6 +50,7 @@ import java.util.concurrent.ScheduledExecutorService; final class VisualQueryDetectorSession extends DetectorSession { private static final String TAG = "VisualQueryDetectorSession"; private IVisualQueryDetectionAttentionListener mAttentionListener; private boolean mEgressingData; private boolean mQueryStreaming; Loading @@ -64,6 +66,7 @@ final class VisualQueryDetectorSession extends DetectorSession { logging); mEgressingData = false; mQueryStreaming = false; mAttentionListener = null; } @Override Loading @@ -74,6 +77,11 @@ final class VisualQueryDetectorSession extends DetectorSession { //TODO(b/261783819): Starts detection in VisualQueryDetectionService. } void setVisualQueryDetectionAttentionListenerLocked( @Nullable IVisualQueryDetectionAttentionListener listener) { mAttentionListener = listener; } @SuppressWarnings("GuardedBy") void startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) { if (DEBUG) { Loading @@ -86,15 +94,31 @@ final class VisualQueryDetectorSession extends DetectorSession { @Override public void onAttentionGained() { Slog.v(TAG, "BinderCallback#onAttentionGained"); //TODO check to see if there is an active SysUI listener registered mEgressingData = true; if (mAttentionListener == null) { return; } try { mAttentionListener.onAttentionGained(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention gained event.", e); return; } } @Override public void onAttentionLost() { Slog.v(TAG, "BinderCallback#onAttentionLost"); //TODO check to see if there is an active SysUI listener registered mEgressingData = false; if (mAttentionListener == null) { return; } try { mAttentionListener.onAttentionLost(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention lost event.", e); return; } } @Override Loading