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

Commit ffeecb1b authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Rework voice interaction session lifecycle.

We now have a formal concept of the session being shown and
hidden, with it being able to continue running while hidden
as long as there is enough RAM.

This changes the flow that a VoiceInteractionSession will
see: onCreate() is when it is first created, onCreateContentView()
is when its UI first needs to be built, onShow() is called each
time it needs to be shown and has the arguments given when the
show request was made (which has been renamed from startSession to
showSession), and then onHide() will be called when the UI is
no longer shown.

The methods show() and hide() now allow a VoiceInteractionSession
subclass to control when it is shown and hidden, working with the
shown state being maintained by the system.

Change-Id: Ic4a430ec7e8bf76a5441fd0425e2932806170fcc
parent 6e53931f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -27656,7 +27656,7 @@ package android.service.voice {
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onReady();
    method public void onShutdown();
    method public void startSession(android.os.Bundle, int);
    method public void showSession(android.os.Bundle, int);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
    field public static final java.lang.String SERVICE_META_DATA = "android.voice_interaction";
    field public static final int START_WITH_ASSIST = 1; // 0x1
@@ -27668,6 +27668,7 @@ package android.service.voice {
    method public void finish();
    method public android.view.LayoutInflater getLayoutInflater();
    method public android.app.Dialog getWindow();
    method public void hide();
    method public void hideWindow();
    method public void onAbortVoice(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onBackPressed();
@@ -27682,14 +27683,17 @@ package android.service.voice {
    method public void onDestroy();
    method public boolean[] onGetSupportedCommands(android.service.voice.VoiceInteractionSession.Caller, java.lang.String[]);
    method public void onHandleAssist(android.os.Bundle);
    method public void onHide();
    method public boolean onKeyDown(int, android.view.KeyEvent);
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
    method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
    method public boolean onKeyUp(int, android.view.KeyEvent);
    method public void onShow(android.os.Bundle, int);
    method public void onTaskFinished(android.content.Intent, int);
    method public void onTaskStarted(android.content.Intent, int);
    method public void setContentView(android.view.View);
    method public void setTheme(int);
    method public void show();
    method public void showWindow();
    method public void startVoiceActivity(android.content.Intent);
  }
+5 −1
Original line number Diff line number Diff line
@@ -29345,7 +29345,7 @@ package android.service.voice {
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onReady();
    method public void onShutdown();
    method public void startSession(android.os.Bundle, int);
    method public void showSession(android.os.Bundle, int);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
    field public static final java.lang.String SERVICE_META_DATA = "android.voice_interaction";
    field public static final int START_WITH_ASSIST = 1; // 0x1
@@ -29357,6 +29357,7 @@ package android.service.voice {
    method public void finish();
    method public android.view.LayoutInflater getLayoutInflater();
    method public android.app.Dialog getWindow();
    method public void hide();
    method public void hideWindow();
    method public void onAbortVoice(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onBackPressed();
@@ -29371,14 +29372,17 @@ package android.service.voice {
    method public void onDestroy();
    method public boolean[] onGetSupportedCommands(android.service.voice.VoiceInteractionSession.Caller, java.lang.String[]);
    method public void onHandleAssist(android.os.Bundle);
    method public void onHide();
    method public boolean onKeyDown(int, android.view.KeyEvent);
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
    method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
    method public boolean onKeyUp(int, android.view.KeyEvent);
    method public void onShow(android.os.Bundle, int);
    method public void onTaskFinished(android.content.Intent, int);
    method public void onTaskStarted(android.content.Intent, int);
    method public void setContentView(android.view.View);
    method public void setTheme(int);
    method public void show();
    method public void showWindow();
    method public void startVoiceActivity(android.content.Intent);
  }
+2 −2
Original line number Diff line number Diff line
@@ -156,8 +156,8 @@ public class VoiceInteractor {

        @Override
        public void deliverCancel(IVoiceInteractorRequest request) throws RemoteException {
            mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(
                    MSG_CANCEL_RESULT, request));
            mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageOO(
                    MSG_CANCEL_RESULT, request, null));
        }
    };

+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.os.Bundle;
 * @hide
 */
oneway interface IVoiceInteractionSession {
    void show(in Bundle sessionArgs, int flags);
    void hide();
    void handleAssist(in Bundle assistData);
    void taskStarted(in Intent intent, int taskId);
    void taskFinished(in Intent intent, int taskId);
+10 −5
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class VoiceInteractionService extends Service {
    public static final String SERVICE_META_DATA = "android.voice_interaction";

    /**
     * Flag for use with {@link #startSession}: request that the session be started with
     * Flag for use with {@link #showSession: request that the session be started with
     * assist data from the currently focused activity.
     */
    public static final int START_WITH_ASSIST = 1<<0;
@@ -139,19 +139,24 @@ public class VoiceInteractionService extends Service {
    }

    /**
     * Initiate the execution of a new {@link android.service.voice.VoiceInteractionSession}.
     * Request that the associated {@link android.service.voice.VoiceInteractionSession} be
     * shown to the user, starting it if necessary.
     * @param args Arbitrary arguments that will be propagated to the session.
     */
    public void startSession(Bundle args, int flags) {
    public void showSession(Bundle args, int flags) {
        if (mSystemService == null) {
            throw new IllegalStateException("Not available until onReady() is called");
        }
        try {
            mSystemService.startSession(mInterface, args, flags);
            mSystemService.showSession(mInterface, args, flags);
        } catch (RemoteException e) {
        }
    }

    /** @hide */
    public void startSession(Bundle args, int flags) {
        showSession(args, flags);
    }
    /** @hide */
    public void startSession(Bundle args) {
        startSession(args, 0);
@@ -174,7 +179,7 @@ public class VoiceInteractionService extends Service {
    /**
     * Called during service initialization to tell you when the system is ready
     * to receive interaction from it. You should generally do initialization here
     * rather than in {@link #onCreate}. Methods such as {@link #startSession} and
     * rather than in {@link #onCreate}. Methods such as {@link #showSession} and
     * {@link #createAlwaysOnHotwordDetector}
     * will not be operational until this point.
     */
Loading