Loading core/api/system-current.txt +6 −10 Original line number Original line Diff line number Diff line Loading @@ -13263,22 +13263,18 @@ package android.service.voice { public abstract class VisualQueryDetectionService extends android.app.Service implements android.service.voice.SandboxedDetectionServiceBase { public abstract class VisualQueryDetectionService extends android.app.Service implements android.service.voice.SandboxedDetectionServiceBase { ctor public VisualQueryDetectionService(); ctor public VisualQueryDetectionService(); method public final void finishQuery() throws java.lang.IllegalStateException; method public final void gainedAttention(); method public final void lostAttention(); method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); method public void onStartDetection(@NonNull android.service.voice.VisualQueryDetectionService.Callback); method public void onStartDetection(); method public void onStopDetection(); method public void onStopDetection(); method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer); method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer); method public final void rejectQuery() throws java.lang.IllegalStateException; method public final void streamQuery(@NonNull String) throws java.lang.IllegalStateException; field public static final String SERVICE_INTERFACE = "android.service.voice.VisualQueryDetectionService"; field public static final String SERVICE_INTERFACE = "android.service.voice.VisualQueryDetectionService"; } } public static final class VisualQueryDetectionService.Callback { ctor public VisualQueryDetectionService.Callback(); method public void onAttentionGained(); method public void onAttentionLost(); method public void onQueryDetected(@NonNull String) throws java.lang.IllegalStateException; method public void onQueryFinished() throws java.lang.IllegalStateException; method public void onQueryRejected() throws java.lang.IllegalStateException; } public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { method public int getErrorCode(); method public int getErrorCode(); method public int getSuggestedAction(); method public int getSuggestedAction(); core/java/android/service/voice/VisualQueryDetectionService.java +101 −113 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,7 @@ import java.util.function.IntConsumer; * {@link VoiceInteractionService#createVisualQueryDetector(PersistableBundle, SharedMemory, * {@link VoiceInteractionService#createVisualQueryDetector(PersistableBundle, SharedMemory, * Executor, VisualQueryDetector.Callback)} is called, the system will bind the application's * Executor, VisualQueryDetector.Callback)} is called, the system will bind the application's * {@link VisualQueryDetectionService}. When requested from {@link VoiceInteractionService}, the * {@link VisualQueryDetectionService}. When requested from {@link VoiceInteractionService}, the * system calls into the {@link VisualQueryDetectionService#onStartDetection(Callback)} to enable * system calls into the {@link VisualQueryDetectionService#onStartDetection()} to enable * detection. This method MUST be implemented to support visual query detection service. * detection. This method MUST be implemented to support visual query detection service. * * * Note: Methods in this class may be called concurrently. * Note: Methods in this class may be called concurrently. Loading Loading @@ -78,6 +78,8 @@ public abstract class VisualQueryDetectionService extends Service /** @hide */ /** @hide */ public static final String KEY_INITIALIZATION_STATUS = "initialization_status"; public static final String KEY_INITIALIZATION_STATUS = "initialization_status"; private IDetectorSessionVisualQueryDetectionCallback mRemoteCallback = null; private final ISandboxedDetectionService mInterface = new ISandboxedDetectionService.Stub() { private final ISandboxedDetectionService mInterface = new ISandboxedDetectionService.Stub() { Loading @@ -85,7 +87,8 @@ public abstract class VisualQueryDetectionService extends Service public void detectWithVisualSignals( public void detectWithVisualSignals( IDetectorSessionVisualQueryDetectionCallback callback) { IDetectorSessionVisualQueryDetectionCallback callback) { Log.v(TAG, "#detectWithVisualSignals"); Log.v(TAG, "#detectWithVisualSignals"); VisualQueryDetectionService.this.onStartDetection(new Callback(callback)); mRemoteCallback = callback; VisualQueryDetectionService.this.onStartDetection(); } } @Override @Override Loading Loading @@ -178,69 +181,55 @@ public abstract class VisualQueryDetectionService extends Service /** /** * This is called after the service is set up and the client should open the camera and the * This is called after the service is set up and the client should open the camera and the * microphone to start recognition. * microphone to start recognition. When the {@link VoiceInteractionService} requests that this * * service {@link HotwordDetector#startRecognition()} start recognition on audio coming directly * Called when the {@link VoiceInteractionService} requests that this service * {@link HotwordDetector#startRecognition()} start recognition on audio coming directly * from the device microphone. * from the device microphone. * * @param callback The callback to use for responding to the detection request. * */ public void onStartDetection(@NonNull Callback callback) { throw new UnsupportedOperationException(); } /** * Called when the {@link VoiceInteractionService} * {@link HotwordDetector#stopRecognition()} requests that recognition be stopped. */ public void onStopDetection() { } /** * Callback for sending out signals and returning query results. * * On successful user attention, developers should call {@link Callback#onAttentionGained()} * to enable the streaming of the query. * <p> * <p> * On user attention is lost, developers should call {@link Callback#onAttentionLost()} to * Signal senders that return attention and query results are also expected to be called in this * disable the streaming of the query. * method according to the detection outcomes. * <p> * On successful user attention, developers should call * {@link VisualQueryDetectionService#gainedAttention()} to enable the streaming of the query. * <p> * On user attention is lost, developers should call * {@link VisualQueryDetectionService#lostAttention()} to disable the streaming of the query. * <p> * <p> * On query is detected and ready to stream, developers should call * On query is detected and ready to stream, developers should call * {@link Callback#onQueryDetected(String)} to return detected query to the * {@link VisualQueryDetectionService#streamQuery(String)} to return detected query to the * {@link VisualQueryDetector}. * {@link VisualQueryDetector}. * <p> * <p> * On streamed query should be rejected, clients should call {@link Callback#onQueryRejected()} * On streamed query should be rejected, clients should call * to abandon query streamed to the {@link VisualQueryDetector}. * {@link VisualQueryDetectionService#rejectQuery()} to abandon query streamed to the * {@link VisualQueryDetector}. * <p> * <p> * On streamed query is finished, clients should call {@link Callback#onQueryFinished()} to * On streamed query is finished, clients should call * complete query streamed to {@link VisualQueryDetector}. * {@link VisualQueryDetectionService#finishQuery()} to complete query streamed to * {@link VisualQueryDetector}. * <p> * <p> * Before a call for {@link Callback#onQueryDetected(String)} is triggered, * Before a call for {@link VisualQueryDetectionService#streamQuery(String)} is triggered, * {@link Callback#onAttentionGained()} MUST be called to enable the streaming of query. A query * {@link VisualQueryDetectionService#gainedAttention()} MUST be called to enable the streaming * streaming is also expected to be finished by calling either * of query. A query streaming is also expected to be finished by calling either * {@link Callback#onQueryFinished()} or {@link Callback#onQueryRejected()} before a new query * {@link VisualQueryDetectionService#finishQuery()} or * should start streaming. When the service enters the state where query streaming should be * {@link VisualQueryDetectionService#rejectQuery()} before a new query should start streaming. * disabled, {@link Callback#onAttentionLost()} MUST be called to block unnecessary streaming. * When the service enters the state where query streaming should be disabled, * {@link VisualQueryDetectionService#lostAttention()} MUST be called to block unnecessary * streaming. */ */ public static final class Callback { public void onStartDetection() { throw new UnsupportedOperationException(); // TODO: consider making the constructor a test api for testing purpose public Callback() { mRemoteCallback = null; } } private final IDetectorSessionVisualQueryDetectionCallback mRemoteCallback; /** * Called when the {@link VoiceInteractionService} private Callback(IDetectorSessionVisualQueryDetectionCallback remoteCallback) { * {@link HotwordDetector#stopRecognition()} requests that recognition be stopped. mRemoteCallback = remoteCallback; */ public void onStopDetection() { } } /** /** * Informs attention listener that the user attention is gained. * Informs the system that the user attention is gained so queries can be streamed. */ */ public void onAttentionGained() { public final void gainedAttention() { try { try { mRemoteCallback.onAttentionGained(); mRemoteCallback.onAttentionGained(); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -249,9 +238,9 @@ public abstract class VisualQueryDetectionService extends Service } } /** /** * Informs attention listener that the user attention is lost. * Informs the system that the user attention is lost to stop streaming. */ */ public void onAttentionLost() { public final void lostAttention() { try { try { mRemoteCallback.onAttentionLost(); mRemoteCallback.onAttentionLost(); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -263,54 +252,53 @@ public abstract class VisualQueryDetectionService extends Service * Informs the {@link VisualQueryDetector} with the text content being captured about the * Informs the {@link VisualQueryDetector} with the text content being captured about the * query from the audio source. {@code partialQuery} is provided to the * query from the audio source. {@code partialQuery} is provided to the * {@link VisualQueryDetector}. This method is expected to be only triggered if * {@link VisualQueryDetector}. This method is expected to be only triggered if * {@link Callback#onAttentionGained()} is called to put the service into the attention * {@link VisualQueryDetectionService#gainedAttention()} is called to put the service into the * gained state. * attention gained state. * * * @param partialQuery Partially detected query in string. * @param partialQuery Partially detected query in string. * @throws IllegalStateException if method called without attention gained. * @throws IllegalStateException if method called without attention gained. */ */ public void onQueryDetected(@NonNull String partialQuery) throws IllegalStateException { public final void streamQuery(@NonNull String partialQuery) throws IllegalStateException { Objects.requireNonNull(partialQuery); Objects.requireNonNull(partialQuery); try { try { mRemoteCallback.onQueryDetected(partialQuery); mRemoteCallback.onQueryDetected(partialQuery); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryDetected must be only be triggered after " throw new IllegalStateException("#streamQuery must be only be triggered after " + "calling #onAttentionGained to be in the attention gained state."); + "calling #gainedAttention to be in the attention gained state."); } } } } /** /** * Informs the {@link VisualQueryDetector} to abandon the streamed partial query that has * Informs the {@link VisualQueryDetector} to abandon the streamed partial query that has * been sent to {@link VisualQueryDetector}.This method is expected to be only triggered if * been sent to {@link VisualQueryDetector}.This method is expected to be only triggered if * {@link Callback#onQueryDetected()} is called to put the service into the query streaming * {@link VisualQueryDetectionService#streamQuery(String)} is called to put the service into * state. * the query streaming state. * * * @throws IllegalStateException if method called without query streamed. * @throws IllegalStateException if method called without query streamed. */ */ public void onQueryRejected() throws IllegalStateException { public final void rejectQuery() throws IllegalStateException { try { try { mRemoteCallback.onQueryRejected(); mRemoteCallback.onQueryRejected(); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryRejected must be only be triggered after " throw new IllegalStateException("#rejectQuery must be only be triggered after " + "calling #onQueryDetected to be in the query streaming state."); + "calling #streamQuery to be in the query streaming state."); } } } } /** /** * Informs {@link VisualQueryDetector} with the metadata to complete the streamed partial * Informs {@link VisualQueryDetector} with the metadata to complete the streamed partial * query that has been sent to {@link VisualQueryDetector}. This method is expected to be * query that has been sent to {@link VisualQueryDetector}. This method is expected to be * only triggered if {@link Callback#onQueryDetected()} is called to put the service into * only triggered if {@link VisualQueryDetectionService#streamQuery(String)} is called to put * the query streaming state. * the service into the query streaming state. * * * @throws IllegalStateException if method called without query streamed. * @throws IllegalStateException if method called without query streamed. */ */ public void onQueryFinished() throws IllegalStateException { public final void finishQuery() throws IllegalStateException { try { try { mRemoteCallback.onQueryFinished(); mRemoteCallback.onQueryFinished(); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryFinished must be only be triggered after " throw new IllegalStateException("#finishQuery must be only be triggered after " + "calling #onQueryDetected to be in the query streaming state."); + "calling #streamQuery to be in the query streaming state."); } } } } } Loading core/java/android/service/voice/VisualQueryDetector.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -177,7 +177,8 @@ public class VisualQueryDetector { public interface Callback { public interface Callback { /** /** * Called when the {@link VisualQueryDetectionService} starts to stream partial queries. * Called when the {@link VisualQueryDetectionService} starts to stream partial queries * with {@link VisualQueryDetectionService#streamQuery(String)}. * * * @param partialQuery The partial query in a text form being streamed. * @param partialQuery The partial query in a text form being streamed. */ */ Loading @@ -185,12 +186,13 @@ public class VisualQueryDetector { /** /** * Called when the {@link VisualQueryDetectionService} decides to abandon the streamed * Called when the {@link VisualQueryDetectionService} decides to abandon the streamed * partial queries. * partial queries with {@link VisualQueryDetectionService#rejectQuery()}. */ */ void onQueryRejected(); void onQueryRejected(); /** /** * Called when the {@link VisualQueryDetectionService} finishes streaming partial queries. * Called when the {@link VisualQueryDetectionService} finishes streaming partial queries * with {@link VisualQueryDetectionService#finishQuery()}. */ */ void onQueryFinished(); void onQueryFinished(); Loading Loading
core/api/system-current.txt +6 −10 Original line number Original line Diff line number Diff line Loading @@ -13263,22 +13263,18 @@ package android.service.voice { public abstract class VisualQueryDetectionService extends android.app.Service implements android.service.voice.SandboxedDetectionServiceBase { public abstract class VisualQueryDetectionService extends android.app.Service implements android.service.voice.SandboxedDetectionServiceBase { ctor public VisualQueryDetectionService(); ctor public VisualQueryDetectionService(); method public final void finishQuery() throws java.lang.IllegalStateException; method public final void gainedAttention(); method public final void lostAttention(); method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); method public void onStartDetection(@NonNull android.service.voice.VisualQueryDetectionService.Callback); method public void onStartDetection(); method public void onStopDetection(); method public void onStopDetection(); method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer); method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer); method public final void rejectQuery() throws java.lang.IllegalStateException; method public final void streamQuery(@NonNull String) throws java.lang.IllegalStateException; field public static final String SERVICE_INTERFACE = "android.service.voice.VisualQueryDetectionService"; field public static final String SERVICE_INTERFACE = "android.service.voice.VisualQueryDetectionService"; } } public static final class VisualQueryDetectionService.Callback { ctor public VisualQueryDetectionService.Callback(); method public void onAttentionGained(); method public void onAttentionLost(); method public void onQueryDetected(@NonNull String) throws java.lang.IllegalStateException; method public void onQueryFinished() throws java.lang.IllegalStateException; method public void onQueryRejected() throws java.lang.IllegalStateException; } public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { method public int getErrorCode(); method public int getErrorCode(); method public int getSuggestedAction(); method public int getSuggestedAction();
core/java/android/service/voice/VisualQueryDetectionService.java +101 −113 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,7 @@ import java.util.function.IntConsumer; * {@link VoiceInteractionService#createVisualQueryDetector(PersistableBundle, SharedMemory, * {@link VoiceInteractionService#createVisualQueryDetector(PersistableBundle, SharedMemory, * Executor, VisualQueryDetector.Callback)} is called, the system will bind the application's * Executor, VisualQueryDetector.Callback)} is called, the system will bind the application's * {@link VisualQueryDetectionService}. When requested from {@link VoiceInteractionService}, the * {@link VisualQueryDetectionService}. When requested from {@link VoiceInteractionService}, the * system calls into the {@link VisualQueryDetectionService#onStartDetection(Callback)} to enable * system calls into the {@link VisualQueryDetectionService#onStartDetection()} to enable * detection. This method MUST be implemented to support visual query detection service. * detection. This method MUST be implemented to support visual query detection service. * * * Note: Methods in this class may be called concurrently. * Note: Methods in this class may be called concurrently. Loading Loading @@ -78,6 +78,8 @@ public abstract class VisualQueryDetectionService extends Service /** @hide */ /** @hide */ public static final String KEY_INITIALIZATION_STATUS = "initialization_status"; public static final String KEY_INITIALIZATION_STATUS = "initialization_status"; private IDetectorSessionVisualQueryDetectionCallback mRemoteCallback = null; private final ISandboxedDetectionService mInterface = new ISandboxedDetectionService.Stub() { private final ISandboxedDetectionService mInterface = new ISandboxedDetectionService.Stub() { Loading @@ -85,7 +87,8 @@ public abstract class VisualQueryDetectionService extends Service public void detectWithVisualSignals( public void detectWithVisualSignals( IDetectorSessionVisualQueryDetectionCallback callback) { IDetectorSessionVisualQueryDetectionCallback callback) { Log.v(TAG, "#detectWithVisualSignals"); Log.v(TAG, "#detectWithVisualSignals"); VisualQueryDetectionService.this.onStartDetection(new Callback(callback)); mRemoteCallback = callback; VisualQueryDetectionService.this.onStartDetection(); } } @Override @Override Loading Loading @@ -178,69 +181,55 @@ public abstract class VisualQueryDetectionService extends Service /** /** * This is called after the service is set up and the client should open the camera and the * This is called after the service is set up and the client should open the camera and the * microphone to start recognition. * microphone to start recognition. When the {@link VoiceInteractionService} requests that this * * service {@link HotwordDetector#startRecognition()} start recognition on audio coming directly * Called when the {@link VoiceInteractionService} requests that this service * {@link HotwordDetector#startRecognition()} start recognition on audio coming directly * from the device microphone. * from the device microphone. * * @param callback The callback to use for responding to the detection request. * */ public void onStartDetection(@NonNull Callback callback) { throw new UnsupportedOperationException(); } /** * Called when the {@link VoiceInteractionService} * {@link HotwordDetector#stopRecognition()} requests that recognition be stopped. */ public void onStopDetection() { } /** * Callback for sending out signals and returning query results. * * On successful user attention, developers should call {@link Callback#onAttentionGained()} * to enable the streaming of the query. * <p> * <p> * On user attention is lost, developers should call {@link Callback#onAttentionLost()} to * Signal senders that return attention and query results are also expected to be called in this * disable the streaming of the query. * method according to the detection outcomes. * <p> * On successful user attention, developers should call * {@link VisualQueryDetectionService#gainedAttention()} to enable the streaming of the query. * <p> * On user attention is lost, developers should call * {@link VisualQueryDetectionService#lostAttention()} to disable the streaming of the query. * <p> * <p> * On query is detected and ready to stream, developers should call * On query is detected and ready to stream, developers should call * {@link Callback#onQueryDetected(String)} to return detected query to the * {@link VisualQueryDetectionService#streamQuery(String)} to return detected query to the * {@link VisualQueryDetector}. * {@link VisualQueryDetector}. * <p> * <p> * On streamed query should be rejected, clients should call {@link Callback#onQueryRejected()} * On streamed query should be rejected, clients should call * to abandon query streamed to the {@link VisualQueryDetector}. * {@link VisualQueryDetectionService#rejectQuery()} to abandon query streamed to the * {@link VisualQueryDetector}. * <p> * <p> * On streamed query is finished, clients should call {@link Callback#onQueryFinished()} to * On streamed query is finished, clients should call * complete query streamed to {@link VisualQueryDetector}. * {@link VisualQueryDetectionService#finishQuery()} to complete query streamed to * {@link VisualQueryDetector}. * <p> * <p> * Before a call for {@link Callback#onQueryDetected(String)} is triggered, * Before a call for {@link VisualQueryDetectionService#streamQuery(String)} is triggered, * {@link Callback#onAttentionGained()} MUST be called to enable the streaming of query. A query * {@link VisualQueryDetectionService#gainedAttention()} MUST be called to enable the streaming * streaming is also expected to be finished by calling either * of query. A query streaming is also expected to be finished by calling either * {@link Callback#onQueryFinished()} or {@link Callback#onQueryRejected()} before a new query * {@link VisualQueryDetectionService#finishQuery()} or * should start streaming. When the service enters the state where query streaming should be * {@link VisualQueryDetectionService#rejectQuery()} before a new query should start streaming. * disabled, {@link Callback#onAttentionLost()} MUST be called to block unnecessary streaming. * When the service enters the state where query streaming should be disabled, * {@link VisualQueryDetectionService#lostAttention()} MUST be called to block unnecessary * streaming. */ */ public static final class Callback { public void onStartDetection() { throw new UnsupportedOperationException(); // TODO: consider making the constructor a test api for testing purpose public Callback() { mRemoteCallback = null; } } private final IDetectorSessionVisualQueryDetectionCallback mRemoteCallback; /** * Called when the {@link VoiceInteractionService} private Callback(IDetectorSessionVisualQueryDetectionCallback remoteCallback) { * {@link HotwordDetector#stopRecognition()} requests that recognition be stopped. mRemoteCallback = remoteCallback; */ public void onStopDetection() { } } /** /** * Informs attention listener that the user attention is gained. * Informs the system that the user attention is gained so queries can be streamed. */ */ public void onAttentionGained() { public final void gainedAttention() { try { try { mRemoteCallback.onAttentionGained(); mRemoteCallback.onAttentionGained(); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -249,9 +238,9 @@ public abstract class VisualQueryDetectionService extends Service } } /** /** * Informs attention listener that the user attention is lost. * Informs the system that the user attention is lost to stop streaming. */ */ public void onAttentionLost() { public final void lostAttention() { try { try { mRemoteCallback.onAttentionLost(); mRemoteCallback.onAttentionLost(); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -263,54 +252,53 @@ public abstract class VisualQueryDetectionService extends Service * Informs the {@link VisualQueryDetector} with the text content being captured about the * Informs the {@link VisualQueryDetector} with the text content being captured about the * query from the audio source. {@code partialQuery} is provided to the * query from the audio source. {@code partialQuery} is provided to the * {@link VisualQueryDetector}. This method is expected to be only triggered if * {@link VisualQueryDetector}. This method is expected to be only triggered if * {@link Callback#onAttentionGained()} is called to put the service into the attention * {@link VisualQueryDetectionService#gainedAttention()} is called to put the service into the * gained state. * attention gained state. * * * @param partialQuery Partially detected query in string. * @param partialQuery Partially detected query in string. * @throws IllegalStateException if method called without attention gained. * @throws IllegalStateException if method called without attention gained. */ */ public void onQueryDetected(@NonNull String partialQuery) throws IllegalStateException { public final void streamQuery(@NonNull String partialQuery) throws IllegalStateException { Objects.requireNonNull(partialQuery); Objects.requireNonNull(partialQuery); try { try { mRemoteCallback.onQueryDetected(partialQuery); mRemoteCallback.onQueryDetected(partialQuery); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryDetected must be only be triggered after " throw new IllegalStateException("#streamQuery must be only be triggered after " + "calling #onAttentionGained to be in the attention gained state."); + "calling #gainedAttention to be in the attention gained state."); } } } } /** /** * Informs the {@link VisualQueryDetector} to abandon the streamed partial query that has * Informs the {@link VisualQueryDetector} to abandon the streamed partial query that has * been sent to {@link VisualQueryDetector}.This method is expected to be only triggered if * been sent to {@link VisualQueryDetector}.This method is expected to be only triggered if * {@link Callback#onQueryDetected()} is called to put the service into the query streaming * {@link VisualQueryDetectionService#streamQuery(String)} is called to put the service into * state. * the query streaming state. * * * @throws IllegalStateException if method called without query streamed. * @throws IllegalStateException if method called without query streamed. */ */ public void onQueryRejected() throws IllegalStateException { public final void rejectQuery() throws IllegalStateException { try { try { mRemoteCallback.onQueryRejected(); mRemoteCallback.onQueryRejected(); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryRejected must be only be triggered after " throw new IllegalStateException("#rejectQuery must be only be triggered after " + "calling #onQueryDetected to be in the query streaming state."); + "calling #streamQuery to be in the query streaming state."); } } } } /** /** * Informs {@link VisualQueryDetector} with the metadata to complete the streamed partial * Informs {@link VisualQueryDetector} with the metadata to complete the streamed partial * query that has been sent to {@link VisualQueryDetector}. This method is expected to be * query that has been sent to {@link VisualQueryDetector}. This method is expected to be * only triggered if {@link Callback#onQueryDetected()} is called to put the service into * only triggered if {@link VisualQueryDetectionService#streamQuery(String)} is called to put * the query streaming state. * the service into the query streaming state. * * * @throws IllegalStateException if method called without query streamed. * @throws IllegalStateException if method called without query streamed. */ */ public void onQueryFinished() throws IllegalStateException { public final void finishQuery() throws IllegalStateException { try { try { mRemoteCallback.onQueryFinished(); mRemoteCallback.onQueryFinished(); } catch (RemoteException e) { } catch (RemoteException e) { throw new IllegalStateException("#onQueryFinished must be only be triggered after " throw new IllegalStateException("#finishQuery must be only be triggered after " + "calling #onQueryDetected to be in the query streaming state."); + "calling #streamQuery to be in the query streaming state."); } } } } } Loading
core/java/android/service/voice/VisualQueryDetector.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -177,7 +177,8 @@ public class VisualQueryDetector { public interface Callback { public interface Callback { /** /** * Called when the {@link VisualQueryDetectionService} starts to stream partial queries. * Called when the {@link VisualQueryDetectionService} starts to stream partial queries * with {@link VisualQueryDetectionService#streamQuery(String)}. * * * @param partialQuery The partial query in a text form being streamed. * @param partialQuery The partial query in a text form being streamed. */ */ Loading @@ -185,12 +186,13 @@ public class VisualQueryDetector { /** /** * Called when the {@link VisualQueryDetectionService} decides to abandon the streamed * Called when the {@link VisualQueryDetectionService} decides to abandon the streamed * partial queries. * partial queries with {@link VisualQueryDetectionService#rejectQuery()}. */ */ void onQueryRejected(); void onQueryRejected(); /** /** * Called when the {@link VisualQueryDetectionService} finishes streaming partial queries. * Called when the {@link VisualQueryDetectionService} finishes streaming partial queries * with {@link VisualQueryDetectionService#finishQuery()}. */ */ void onQueryFinished(); void onQueryFinished(); Loading