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

Commit 225d3b54 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Add more internal API's for assist

- When starting a voice interaction session from SysUI, a callback
can be passed to know when voice interaction has successfully started
- Add a new window type for the voice interaction starting window,
which resides behind the voice interaction layer.
- SystemUI now also inspects the voice interaction service to get the
logo asset for the starting window.
- Make VoiceInteractionSession window fullscreen, to accomodate for
the visuals.

Change-Id: If8c3c445e8b39841f48e8d153e6d1ba81e447286
parent 25e12abc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -267,6 +267,7 @@ LOCAL_SRC_FILES += \
	core/java/com/android/internal/app/IBatteryStats.aidl \
	core/java/com/android/internal/app/IProcessStats.aidl \
	core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl \
	core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl \
	core/java/com/android/internal/app/IVoiceInteractor.aidl \
	core/java/com/android/internal/app/IVoiceInteractorCallback.aidl \
	core/java/com/android/internal/app/IVoiceInteractorRequest.aidl \
+3 −1
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;

import com.android.internal.app.IVoiceInteractionSessionShowCallback;

/**
 * @hide
 */
oneway interface IVoiceInteractionSession {
    void show(in Bundle sessionArgs, int flags);
    void show(in Bundle sessionArgs, int flags, IVoiceInteractionSessionShowCallback showCallback);
    void hide();
    void handleAssist(in Bundle assistData);
    void handleScreenshot(in Bitmap screenshot);
+33 −9
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.FrameLayout;
import com.android.internal.app.IVoiceInteractionManagerService;
import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.IVoiceInteractorCallback;
import com.android.internal.app.IVoiceInteractorRequest;
@@ -163,9 +164,10 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {

    final IVoiceInteractionSession mSession = new IVoiceInteractionSession.Stub() {
        @Override
        public void show(Bundle sessionArgs, int flags) {
            mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIO(MSG_SHOW,
                    flags, sessionArgs));
        public void show(Bundle sessionArgs, int flags,
                IVoiceInteractionSessionShowCallback showCallback) {
            mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIOO(MSG_SHOW,
                    flags, sessionArgs, showCallback));
        }

        @Override
@@ -412,9 +414,12 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
                    onHandleScreenshot((Bitmap) msg.obj);
                    break;
                case MSG_SHOW:
                    if (DEBUG) Log.d(TAG, "doShow: args=" + msg.obj
                            + " flags=" + msg.arg1);
                    doShow((Bundle) msg.obj, msg.arg1);
                    args = (SomeArgs)msg.obj;
                    if (DEBUG) Log.d(TAG, "doShow: args=" + args.arg1
                            + " flags=" + msg.arg1
                            + " showCallback=" + args.arg2);
                    doShow((Bundle) args.arg1, msg.arg1,
                            (IVoiceInteractionSessionShowCallback) args.arg2);
                    break;
                case MSG_HIDE:
                    if (DEBUG) Log.d(TAG, "doHide");
@@ -523,7 +528,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
        onCreate(args, startFlags);
    }

    void doShow(Bundle args, int flags) {
    void doShow(Bundle args, int flags, final IVoiceInteractionSessionShowCallback showCallback) {
        if (DEBUG) Log.v(TAG, "Showing window: mWindowAdded=" + mWindowAdded
                + " mWindowVisible=" + mWindowVisible);

@@ -548,6 +553,22 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
                mWindowVisible = true;
                mWindow.show();
            }
            if (showCallback != null) {
                mRootView.invalidate();
                mRootView.getViewTreeObserver().addOnPreDrawListener(
                        new ViewTreeObserver.OnPreDrawListener() {
                            @Override
                            public boolean onPreDraw() {
                                mRootView.getViewTreeObserver().removeOnPreDrawListener(this);
                                try {
                                    showCallback.onShown();
                                } catch (RemoteException e) {
                                    Log.w(TAG, "Error calling onShown", e);
                                }
                                return true;
                            }
                        });
            }
        } finally {
            mWindowWasVisible = true;
            mInShowWindow = false;
@@ -582,7 +603,8 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
        mRootView = mInflater.inflate(
                com.android.internal.R.layout.voice_interaction_session, null);
        mRootView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        mWindow.setContentView(mRootView);
        mRootView.getViewTreeObserver().addOnComputeInternalInsetsListener(mInsetsComputer);

@@ -716,7 +738,9 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
        mWindow = new SoftInputWindow(mContext, "VoiceInteractionSession", mTheme,
                mCallbacks, this, mDispatcherState,
                WindowManager.LayoutParams.TYPE_VOICE_INTERACTION, Gravity.BOTTOM, true);
        mWindow.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        mWindow.getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED |
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        initViews();
        mWindow.getWindow().setLayout(MATCH_PARENT, MATCH_PARENT);
        mWindow.setToken(mToken);
+7 −0
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ public interface WindowManager extends ViewManager {
            @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY"),
            @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION, to = "TYPE_PRIVATE_PRESENTATION"),
            @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION, to = "TYPE_VOICE_INTERACTION"),
            @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING, to = "TYPE_VOICE_INTERACTION_STARTING"),
        })
        public int type;
    
@@ -548,6 +549,12 @@ public interface WindowManager extends ViewManager {
         */
        public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;

        /**
         * Window type: Starting window for voice interaction layer.
         * @hide
         */
        public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;

        /**
         * End of types of system windows.
         */
+10 −1
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.internal.app;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;

import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractor;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
import android.hardware.soundtrigger.SoundTrigger;
@@ -86,11 +88,18 @@ interface IVoiceInteractionManagerService {
     */
    boolean isServiceActive();

    /**
     * @return the component name for the currently active voice interaction service
     */
    ComponentName getActiveServiceComponentName();

    /**
     * Shows the session for the currently active service. Used to start a new session from system
     * affordances.
     *
     * @param showCallback callback to be notified when the session was shown
     */
    void showSessionForActiveService();
    void showSessionForActiveService(IVoiceInteractionSessionShowCallback showCallback);

    /**
     * Indicates whether there is a voice session running (but not necessarily showing).
Loading