Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fdb60c8 authored by Charles Chen's avatar Charles Chen Committed by Automerger Merge Worker
Browse files

Merge "Provides VisualQueryDetection start recognition signal for SysUI" into...

Merge "Provides VisualQueryDetection start recognition signal for SysUI" into udc-qpr-dev am: cb8ddff0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24315052



Change-Id: I4345d4a2ca4a746561d46d184f5d70b84a41d501
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c4eeaaee cb8ddff0
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -233,6 +233,23 @@ public class AssistUtils {
        }
    }

    /**
     * Allows subscription to {@link android.service.voice.VisualQueryDetectionService} service
     * status.
     *
     * @param listener to receive visual service start/stop events.
     */
    public void subscribeVisualQueryRecognitionStatus(IVisualQueryRecognitionStatusListener
            listener) {
        try {
            if (mVoiceInteractionManagerService != null) {
                mVoiceInteractionManagerService.subscribeVisualQueryRecognitionStatus(listener);
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to register visual query detection start listener", e);
        }
    }

    /**
     * Enables visual detection service.
     *
+32 −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;


 oneway interface IVisualQueryRecognitionStatusListener {
    /**
     * Called when {@link VisualQueryDetectionService#onStartDetection} is scheduled from the system
     * server via {@link VoiceInteractionManagerService#StartPerceiving}.
     */
    void onStartPerceiving();

    /**
     * Called when {@link VisualQueryDetectionService#onStopDetection} is scheduled from the system
     * server via {@link VoiceInteractionManagerService#StopPerceiving}.
     */
    void onStopPerceiving();
 }
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractionSoundTriggerSession;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.IVisualQueryDetectionAttentionListener;
import com.android.internal.app.IVisualQueryRecognitionStatusListener;

interface IVoiceInteractionManagerService {
    void showSession(in Bundle sessionArgs, int flags, String attributionTag);
@@ -324,6 +325,9 @@ interface IVoiceInteractionManagerService {
     */
    void shutdownHotwordDetectionService();

    @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE")
    void subscribeVisualQueryRecognitionStatus(in IVisualQueryRecognitionStatusListener listener);

    @EnforcePermission("ACCESS_VOICE_INTERACTION_SERVICE")
    void enableVisualQueryDetection(in IVisualQueryDetectionAttentionListener Listener);

+6 −6
Original line number Diff line number Diff line
@@ -368,29 +368,29 @@ final class HotwordDetectionConnection {
    /**
     * This method is only used by VisualQueryDetector.
     */
    void startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) {
    boolean startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) {
        if (DEBUG) {
            Slog.d(TAG, "startPerceivingLocked");
        }
        final VisualQueryDetectorSession session = getVisualQueryDetectorSessionLocked();
        if (session == null) {
            return;
            return false;
        }
        session.startPerceivingLocked(callback);
        return session.startPerceivingLocked(callback);
    }

    /**
     * This method is only used by VisaulQueryDetector.
     */
    void stopPerceivingLocked() {
    boolean stopPerceivingLocked() {
        if (DEBUG) {
            Slog.d(TAG, "stopPerceivingLocked");
        }
        final VisualQueryDetectorSession session = getVisualQueryDetectorSessionLocked();
        if (session == null) {
            return;
            return false;
        }
        session.stopPerceivingLocked();
        return session.stopPerceivingLocked();
    }

    public void startListeningFromExternalSourceLocked(
+5 −4
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ final class VisualQueryDetectorSession extends DetectorSession {
    }

    @SuppressWarnings("GuardedBy")
    void startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) {
    boolean startPerceivingLocked(IVisualQueryDetectionVoiceInteractionCallback callback) {
        if (DEBUG) {
            Slog.d(TAG, "startPerceivingLocked");
        }
@@ -198,15 +198,16 @@ final class VisualQueryDetectorSession extends DetectorSession {
                mQueryStreaming = false;
            }
        };
        mRemoteDetectionService.run(service -> service.detectWithVisualSignals(internalCallback));
        return mRemoteDetectionService.run(
                service -> service.detectWithVisualSignals(internalCallback));
    }

    @SuppressWarnings("GuardedBy")
    void stopPerceivingLocked() {
    boolean stopPerceivingLocked() {
        if (DEBUG) {
            Slog.d(TAG, "stopPerceivingLocked");
        }
        mRemoteDetectionService.run(ISandboxedDetectionService::stopDetection);
        return mRemoteDetectionService.run(ISandboxedDetectionService::stopDetection);
    }

    @Override
Loading