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

Commit 9c9dd98e authored by James O'Leary's avatar James O'Leary
Browse files

Encapsulate state & transcription in hints bundle

Continuation of ag/6226654; edits made per Svetoslav's last comments.

Bug: 122740752
Bug: 123080754
Test: blueline-userdebug build completes successfully.

Change-Id: I3e43137eb6e0d8cae77e14d331150d5a05ede07c
parent 2b00ad1e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -41955,7 +41955,6 @@ package android.service.voice {
  public class VoiceInteractionService extends android.app.Service {
    ctor public VoiceInteractionService();
    method public final void clearTranscription(boolean);
    method public final android.service.voice.AlwaysOnHotwordDetector createAlwaysOnHotwordDetector(String, java.util.Locale, android.service.voice.AlwaysOnHotwordDetector.Callback);
    method public int getDisabledShowContext();
    method public static boolean isActiveService(android.content.Context, android.content.ComponentName);
@@ -41965,8 +41964,7 @@ package android.service.voice {
    method public void onReady();
    method public void onShutdown();
    method public void setDisabledShowContext(int);
    method public final void setTranscription(@NonNull String);
    method public final void setVoiceState(int);
    method public final void setUiHints(@NonNull android.os.Bundle);
    method public void showSession(android.os.Bundle, int);
    field public static final String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
    field public static final String SERVICE_META_DATA = "android.voice_interaction";
+6 −26
Original line number Diff line number Diff line
@@ -342,37 +342,17 @@ public class VoiceInteractionService extends Service {
    }

    /**
     * Requests that the voice state UI indicate the given state.
     * Provide hints to be reflected in the system UI.
     *
     * @param state value indicating whether the assistant is listening, fulfilling, etc.
     * @param hints Arguments used to show UI.
     */
    public final void setVoiceState(int state) {
        try {
            mSystemService.setVoiceState(mInterface, state);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    public final void setUiHints(@NonNull Bundle hints) {
        if (hints == null) {
            throw new IllegalArgumentException("Hints must be non-null");
        }

    /**
     * Displays the given voice transcription contents.
     */
    public final void setTranscription(@NonNull String transcription) {
        try {
            mSystemService.setTranscription(mInterface, transcription);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Hides transcription.
     *
     * @param immediate if {@code true}, remove before transcription animation completes.
     */
    public final void clearTranscription(boolean immediate) {
        try {
            mSystemService.clearTranscription(mInterface, immediate);
            mSystemService.setUiHints(mInterface, hints);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −12
Original line number Diff line number Diff line
@@ -153,17 +153,7 @@ interface IVoiceInteractionManagerService {
     in IVoiceActionCheckCallback callback);

    /**
     * Sets the transcribed voice to the given string.
     * Provide hints for showing UI.
     */
    void setTranscription(IVoiceInteractionService service, String transcription);

    /**
     * Indicates that the transcription session is finished.
     */
    void clearTranscription(IVoiceInteractionService service, boolean immediate);

    /**
     * Sets the voice state indication based upon the given value.
     */
    void setVoiceState(IVoiceInteractionService service, int state);
    void setUiHints(in IVoiceInteractionService service, in Bundle hints);
}
+4 −13
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

 package com.android.internal.app;

 import android.os.Bundle;

 oneway interface IVoiceInteractionSessionListener {
    /**
     * Called when a voice session is shown.
@@ -28,18 +30,7 @@
    void onVoiceSessionHidden();

    /**
     * Called when voice assistant transcription has been updated to the given string.
     */
    void onTranscriptionUpdate(in String transcription);

    /**
     * Called when voice transcription is completed.
     */
    void onTranscriptionComplete(in boolean immediate);

    /**
     * Called when the voice assistant's state has changed. Values are from
     * VoiceInteractionService's VOICE_STATE* constants.
     * Called when UI hints were received.
     */
    void onVoiceStateChange(in int state);
    void onSetUiHints(in Bundle args);
 }
 No newline at end of file
+2 −16
Original line number Diff line number Diff line
@@ -122,23 +122,9 @@ public class AssistManager implements ConfigurationChangedReceiver {
                    }

                    @Override
                    public void onTranscriptionUpdate(String transcription) {
                    public void onSetUiHints(Bundle hints) {
                        if (VERBOSE) {
                            Log.v(TAG, "Transcription Updated: \"" + transcription + "\"");
                        }
                    }

                    @Override
                    public void onTranscriptionComplete(boolean immediate) {
                        if (VERBOSE) {
                            Log.v(TAG, "Transcription complete (immediate=" + immediate + ")");
                        }
                    }

                    @Override
                    public void onVoiceStateChange(int state) {
                        if (VERBOSE) {
                            Log.v(TAG, "Voice state is now " + state);
                            Log.v(TAG, "UI hints received");
                        }
                    }
                });
Loading