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

Commit 1104d1a8 authored by Andy Wickham's avatar Andy Wickham Committed by Android (Google) Code Review
Browse files

Merge "Adds path for Launcher to request Assist override." into udc-qpr-dev

parents 45c6070a 4c334f60
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.MotionEvent;
import android.view.SurfaceControl;
import com.android.systemui.shared.recents.ISystemUiProxy;

// Next ID: 29
oneway interface IOverviewProxy {

    void onActiveNavBarRegionChanges(in Region activeRegion) = 11;
@@ -55,6 +56,13 @@ oneway interface IOverviewProxy {
     */
    void onAssistantVisibilityChanged(float visibility) = 14;

    /**
     * Sent when the assistant has been invoked with the given type (defined in AssistManager) and
     * should be shown. This method should be used if SystemUiProxy#setAssistantOverridesRequested
     * was previously called including this invocation type.
     */
    void onAssistantOverrideInvoked(int invocationType) = 28;

    /**
     * Sent when some system ui state changes.
     */
+10 −1
Original line number Diff line number Diff line
@@ -66,6 +66,15 @@ interface ISystemUiProxy {
     */
    oneway void startAssistant(in Bundle bundle) = 13;

    /**
     * Indicates that the given Assist invocation types should be handled by Launcher via
     * OverviewProxy#onAssistantOverrideInvoked and should not be invoked by SystemUI.
     *
     * @param invocationTypes The invocation types that will henceforth be handled via
     *         OverviewProxy (Launcher); other invocation types should be handled by SysUI.
     */
    oneway void setAssistantOverridesRequested(in int[] invocationTypes) = 53;

    /**
     * Notifies that the accessibility button in the system's navigation area has been clicked
     */
@@ -135,5 +144,5 @@ interface ISystemUiProxy {
     */
    oneway void onStatusBarTrackpadEvent(in MotionEvent event) = 52;

    // Next id = 53
    // Next id = 54
}
+39 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.systemui.util.settings.SecureSettings;
import dagger.Lazy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;
@@ -136,6 +137,7 @@ public class AssistManager {
    protected final Context mContext;
    private final AssistDisclosure mAssistDisclosure;
    private final PhoneStateMonitor mPhoneStateMonitor;
    private final OverviewProxyService mOverviewProxyService;
    private final UiController mUiController;
    protected final Lazy<SysUiState> mSysUiState;
    protected final AssistLogger mAssistLogger;
@@ -164,6 +166,9 @@ public class AssistManager {
    private final CommandQueue mCommandQueue;
    protected final AssistUtils mAssistUtils;

    // Invocation types that should be sent over OverviewProxy instead of handled here.
    private int[] mAssistOverrideInvocationTypes;

    @Inject
    public AssistManager(
            DeviceProvisionedController controller,
@@ -184,6 +189,7 @@ public class AssistManager {
        mCommandQueue = commandQueue;
        mAssistUtils = assistUtils;
        mAssistDisclosure = new AssistDisclosure(context, uiHandler);
        mOverviewProxyService = overviewProxyService;
        mPhoneStateMonitor = phoneStateMonitor;
        mAssistLogger = assistLogger;
        mUserTracker = userTracker;
@@ -197,7 +203,7 @@ public class AssistManager {

        mSysUiState = sysUiState;

        overviewProxyService.addCallback(new OverviewProxyService.OverviewProxyListener() {
        mOverviewProxyService.addCallback(new OverviewProxyService.OverviewProxyListener() {
            @Override
            public void onAssistantProgress(float progress) {
                // Progress goes from 0 to 1 to indicate how close the assist gesture is to
@@ -260,6 +266,20 @@ public class AssistManager {
    }

    public void startAssist(Bundle args) {
        if (shouldOverrideAssist(args)) {
            try {
                if (mOverviewProxyService.getProxy() == null) {
                    Log.w(TAG, "No OverviewProxyService to invoke assistant override");
                    return;
                }
                mOverviewProxyService.getProxy().onAssistantOverrideInvoked(
                        args.getInt(INVOCATION_TYPE_KEY));
            } catch (RemoteException e) {
                Log.w(TAG, "Unable to invoke assistant via OverviewProxyService override", e);
            }
            return;
        }

        final ComponentName assistComponent = getAssistInfo();
        if (assistComponent == null) {
            return;
@@ -283,6 +303,24 @@ public class AssistManager {
        startAssistInternal(args, assistComponent, isService);
    }

    private boolean shouldOverrideAssist(Bundle args) {
        if (args == null || !args.containsKey(INVOCATION_TYPE_KEY)) {
            return false;
        }

        int invocationType = args.getInt(INVOCATION_TYPE_KEY);
        return mAssistOverrideInvocationTypes != null && Arrays.stream(
                mAssistOverrideInvocationTypes).anyMatch(override -> override == invocationType);
    }

    /**
     * @param invocationTypes The invocation types that will henceforth be handled via
     *         OverviewProxy (Launcher); other invocation types should be handled by this class.
     */
    public void setAssistantOverridesRequested(int[] invocationTypes) {
        mAssistOverrideInvocationTypes = invocationTypes;
    }

    /** Called when the user is performing an assistant invocation action (e.g. Active Edge) */
    public void onInvocationProgress(int type, float progress) {
        mUiController.onInvocationProgress(type, progress);
+5 −0
Original line number Diff line number Diff line
@@ -452,6 +452,11 @@ public final class NavBarHelper implements
        mAssistManagerLazy.get().startAssist(bundle);
    }

    @Override
    public void setAssistantOverridesRequested(int[] invocationTypes) {
        mAssistManagerLazy.get().setAssistantOverridesRequested(invocationTypes);
    }

    @Override
    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
+5 −0
Original line number Diff line number Diff line
@@ -393,6 +393,11 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            mAssistManagerLazy.get().startAssist(bundle);
        }

        @Override
        public void setAssistantOverridesRequested(int[] invocationTypes) {
            mAssistManagerLazy.get().setAssistantOverridesRequested(invocationTypes);
        }

        @Override
        public void onHomeRotationEnabled(boolean enabled) {
            mView.getRotationButtonController().setHomeRotationEnabled(enabled);
Loading