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

Commit 361ac94d authored by Charles Chen's avatar Charles Chen
Browse files

Update javadoc for executor accepted for VQDS

The callbacks can never be called simutaneously - dev better use
sequential executors.

Test: atest android.voiceinteraction.cts.VisualQueryDetectionServiceBasicTest
Bug: 321997330
Change-Id: Ia46b98ab4c6b6f8393d8aac66a951cd96138d175
parent cb4a7bd1
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -301,8 +301,15 @@ public class VisualQueryDetector {
    }

    /**
     * A class that lets a VoiceInteractionService implementation interact with
     * visual query detection APIs.
     * A class that lets a VoiceInteractionService implementation interact with visual query
     * detection APIs.
     *
     * Note that methods in this callbacks are not thread-safe so the invocation of each
     * methods will have different order from how they are called in the
     * {@link VisualQueryDetectionService}. It is expected to pass a single thread executor or a
     * serial executor as the callback executor when creating the {@link VisualQueryDetector}
     * with {@link VoiceInteractionService#createVisualQueryDetector(
     * PersistableBundle, SharedMemory, Executor, Callback)}.
     */
    public interface Callback {

@@ -456,7 +463,7 @@ public class VisualQueryDetector {
            Slog.v(TAG, "BinderCallback#onResultDetected");
            Binder.withCleanCallingIdentity(() -> {
                synchronized (mLock) {
                    mCallback.onQueryDetected(partialResult);
                    mExecutor.execute(()->mCallback.onQueryDetected(partialResult));
                }
            });
        }
+4 −1
Original line number Diff line number Diff line
@@ -932,7 +932,10 @@ public class VoiceInteractionService extends Service {
     * @param sharedMemory The unrestricted data blob to be provided to the
     * {@link VisualQueryDetectionService}. Use this to provide models or other such data to the
     * sandboxed process.
     * @param callback The callback to notify of detection events.
     * @param callback The callback to notify of detection events. Single threaded or sequential
     *                 executors are recommended for the callback are not guaranteed to be executed
     *                 in the order of how they were called from the
     *                 {@link VisualQueryDetectionService}.
     * @return An instanece of {@link VisualQueryDetector}.
     * @throws IllegalStateException when there is an existing {@link VisualQueryDetector}, or when
     * there is a non-trusted hotword detector running.