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

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

Merge "Use new AssistUtils(Base) to override SysUI Assist invocations." into udc-qpr-dev

parents 51ba9a60 f7554ff7
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,8 @@


  <string name="nav_handle_long_press_handler_class" translatable="false"></string>
  <string name="nav_handle_long_press_handler_class" translatable="false"></string>


  <string name="assist_utils_class" translatable="false"></string>

  <string name="secondary_display_predictions_class" translatable="false">com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl</string>
  <string name="secondary_display_predictions_class" translatable="false">com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl</string>


  <string name="taskbar_model_callbacks_factory_class" translatable="false">com.android.launcher3.taskbar.TaskbarModelCallbacksFactory</string>
  <string name="taskbar_model_callbacks_factory_class" translatable="false">com.android.launcher3.taskbar.TaskbarModelCallbacksFactory</string>
+10 −5
Original line number Original line Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.quickstep.OverviewCommandHelper;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.util.AssistUtilsBase;
import com.android.quickstep.views.DesktopTaskView;
import com.android.quickstep.views.DesktopTaskView;


import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -158,7 +159,7 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
        switch (buttonType) {
        switch (buttonType) {
            case BUTTON_HOME:
            case BUTTON_HOME:
                logEvent(LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS);
                logEvent(LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS);
                startAssistant();
                onLongPressHome();
                return true;
                return true;
            case BUTTON_A11Y:
            case BUTTON_A11Y:
                logEvent(LAUNCHER_TASKBAR_A11Y_BUTTON_LONGPRESS);
                logEvent(LAUNCHER_TASKBAR_A11Y_BUTTON_LONGPRESS);
@@ -307,14 +308,18 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
        }
        }
    }
    }


    private void startAssistant() {
    private void onLongPressHome() {
        if (mScreenPinned || !mAssistantLongPressEnabled) {
        if (mScreenPinned || !mAssistantLongPressEnabled) {
            return;
            return;
        }
        }
        // Attempt to start Assist with AssistUtils, otherwise fall back to SysUi's implementation.
        if (!AssistUtilsBase.newInstance(mService.getApplicationContext()).tryStartAssistOverride(
                INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS)) {
            Bundle args = new Bundle();
            Bundle args = new Bundle();
            args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS);
            args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS);
            mSystemUiProxy.startAssistant(args);
            mSystemUiProxy.startAssistant(args);
        }
        }
    }


    private void showQuickSettings() {
    private void showQuickSettings() {
        mSystemUiProxy.toggleNotificationPanel();
        mSystemUiProxy.toggleNotificationPanel();
+14 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.internal.view.AppearanceRegion;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.util.AssistUtilsBase;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
@@ -250,6 +251,8 @@ public class SystemUiProxy implements ISystemUiProxy {
        setBackToLauncherCallback(mBackToLauncherCallback, mBackToLauncherRunner);
        setBackToLauncherCallback(mBackToLauncherCallback, mBackToLauncherRunner);
        setUnfoldAnimationListener(mUnfoldAnimationListener);
        setUnfoldAnimationListener(mUnfoldAnimationListener);
        setDesktopTaskListener(mDesktopTaskListener);
        setDesktopTaskListener(mDesktopTaskListener);
        setAssistantOverridesRequested(
                AssistUtilsBase.newInstance(mContext).getSysUiAssistOverrideInvocationTypes());
    }
    }


    /**
    /**
@@ -373,6 +376,17 @@ public class SystemUiProxy implements ISystemUiProxy {
        }
        }
    }
    }


    @Override
    public void setAssistantOverridesRequested(int[] invocationTypes) {
        if (mSystemUiProxy != null) {
            try {
                mSystemUiProxy.setAssistantOverridesRequested(invocationTypes);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call setAssistantOverridesRequested", e);
            }
        }
    }

    @Override
    @Override
    public void notifyAccessibilityButtonClicked(int displayId) {
    public void notifyAccessibilityButtonClicked(int displayId) {
        if (mSystemUiProxy != null) {
        if (mSystemUiProxy != null) {
+15 −0
Original line number Original line Diff line number Diff line
@@ -117,6 +117,7 @@ import com.android.quickstep.inputconsumers.TaskbarUnstashInputConsumer;
import com.android.quickstep.inputconsumers.TrackpadStatusBarInputConsumer;
import com.android.quickstep.inputconsumers.TrackpadStatusBarInputConsumer;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActiveGestureLog.CompoundString;
import com.android.quickstep.util.ActiveGestureLog.CompoundString;
import com.android.quickstep.util.AssistUtilsBase;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -280,6 +281,20 @@ public class TouchInteractionService extends Service {
            }));
            }));
        }
        }


        /**
         * Sent when the assistant has been invoked with the given type (defined in AssistManager)
         * and should be shown. This method is used if SystemUiProxy#setAssistantOverridesRequested
         * was previously called including this invocation type.
         */
        @Override
        public void onAssistantOverrideInvoked(int invocationType) {
            executeForTouchInteractionService(tis -> {
                if (!AssistUtilsBase.newInstance(tis).tryStartAssistOverride(invocationType)) {
                    Log.w(TAG, "Failed to invoke Assist override");
                }
            });
        }

        @Override
        @Override
        public void onNavigationBarSurface(SurfaceControl surface) {
        public void onNavigationBarSurface(SurfaceControl surface) {
            // TODO: implement
            // TODO: implement
+45 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.quickstep.util;

import android.content.Context;

import com.android.launcher3.R;
import com.android.launcher3.util.ResourceBasedOverride;

/** Utilities to work with Assistant functionality. */
public class AssistUtilsBase implements ResourceBasedOverride {

    public AssistUtilsBase() {}

    /** Creates AssistUtils as specified by overrides */
    public static AssistUtilsBase newInstance(Context context) {
        return Overrides.getObject(AssistUtilsBase.class, context, R.string.assist_utils_class);
    }

    /** @return Array of AssistUtils.INVOCATION_TYPE_* that we want to handle instead of SysUI. */
    public int[] getSysUiAssistOverrideInvocationTypes() {
        return new int[0];
    }

    /**
     * @return {@code true} if the override was handled, i.e. an assist surface was shown or the
     * request should be ignored. {@code false} means the caller should start assist another way.
     */
    public boolean tryStartAssistOverride(int invocationType) {
        return false;
    }
}
Loading