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

Commit 676b7f3c authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Simplify exposing external interfaces to Launcher"

parents 1b3db4d5 6d089c12
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ filegroup {
    srcs: [
        "src/com/android/wm/shell/util/**/*.java",
        "src/com/android/wm/shell/common/split/SplitScreenConstants.java",
        "src/com/android/wm/shell/sysui/ShellSharedConstants.java",
    ],
    path: "src",
}
+0 −7
Original line number Diff line number Diff line
@@ -28,13 +28,6 @@ import com.android.wm.shell.common.annotations.ExternalThread;
@ExternalThread
public interface BackAnimation {

    /**
     * Returns a binder that can be passed to an external process to update back animations.
     */
    default IBackAnimation createExternalInterface() {
        return null;
    }

    /**
     * Called when a {@link MotionEvent} is generated by a back gesture.
     *
+19 −15
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.back;

import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_BACK_ANIMATION;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -53,10 +54,12 @@ import android.window.IOnBackInvokedCallback;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ExternalInterfaceBinder;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;

@@ -102,6 +105,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    private final IActivityTaskManager mActivityTaskManager;
    private final Context mContext;
    private final ContentResolver mContentResolver;
    private final ShellController mShellController;
    private final ShellExecutor mShellExecutor;
    private final Handler mBgHandler;
    private final Runnable mResetTransitionRunnable = () -> {
@@ -188,11 +192,12 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

    public BackAnimationController(
            @NonNull ShellInit shellInit,
            @NonNull ShellController shellController,
            @NonNull @ShellMainThread ShellExecutor shellExecutor,
            @NonNull @ShellBackgroundThread Handler backgroundHandler,
            Context context,
            Transitions transitions) {
        this(shellInit, shellExecutor, backgroundHandler,
        this(shellInit, shellController, shellExecutor, backgroundHandler,
                ActivityTaskManager.getService(), context, context.getContentResolver(),
                transitions);
    }
@@ -200,11 +205,13 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    @VisibleForTesting
    BackAnimationController(
            @NonNull ShellInit shellInit,
            @NonNull ShellController shellController,
            @NonNull @ShellMainThread ShellExecutor shellExecutor,
            @NonNull @ShellBackgroundThread Handler bgHandler,
            @NonNull IActivityTaskManager activityTaskManager,
            Context context, ContentResolver contentResolver,
            Transitions transitions) {
        mShellController = shellController;
        mShellExecutor = shellExecutor;
        mActivityTaskManager = activityTaskManager;
        mContext = context;
@@ -221,6 +228,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            mBackTransitionHandler = new BackTransitionHandler(this);
            mTransitions.addHandler(mBackTransitionHandler);
        }
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_BACK_ANIMATION,
                this::createExternalInterface, this);
    }

    private void setupAnimationDeveloperSettingsObserver(
@@ -253,7 +262,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        return mBackAnimation;
    }

    private final BackAnimation mBackAnimation = new BackAnimationImpl();
    private ExternalInterfaceBinder createExternalInterface() {
        return new IBackAnimationImpl(this);
    }

    private final BackAnimationImpl mBackAnimation = new BackAnimationImpl();

    @Override
    public Context getContext() {
@@ -266,17 +279,6 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    }

    private class BackAnimationImpl implements BackAnimation {
        private IBackAnimationImpl mBackAnimation;

        @Override
        public IBackAnimation createExternalInterface() {
            if (mBackAnimation != null) {
                mBackAnimation.invalidate();
            }
            mBackAnimation = new IBackAnimationImpl(BackAnimationController.this);
            return mBackAnimation;
        }

        @Override
        public void onBackMotion(
                float touchX, float touchY, int keyAction, @BackEvent.SwipeEdge int swipeEdge) {
@@ -295,7 +297,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        }
    }

    private static class IBackAnimationImpl extends IBackAnimation.Stub {
    private static class IBackAnimationImpl extends IBackAnimation.Stub
            implements ExternalInterfaceBinder {
        private BackAnimationController mController;

        IBackAnimationImpl(BackAnimationController controller) {
@@ -315,7 +318,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                    (controller) -> controller.clearBackToLauncherCallback());
        }

        void invalidate() {
        @Override
        public void invalidate() {
            mController = null;
        }
    }
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.wm.shell.common;

import android.os.IBinder;

/**
 * An interface for binders which can be registered to be sent to other processes.
 */
public interface ExternalInterfaceBinder {
    /**
     * Invalidates this binder (detaches it from the controller it would call).
     */
    void invalidate();

    /**
     * Returns the IBinder to send.
     */
    IBinder asBinder();
}
+14 −9
Original line number Diff line number Diff line
@@ -261,14 +261,15 @@ public abstract class WMShellBaseModule {
    static Optional<BackAnimationController> provideBackAnimationController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            @ShellMainThread ShellExecutor shellExecutor,
            @ShellBackgroundThread Handler backgroundHandler,
            Transitions transitions
    ) {
        if (BackAnimationController.IS_ENABLED) {
            return Optional.of(
                    new BackAnimationController(shellInit, shellExecutor, backgroundHandler,
                            context, transitions));
                    new BackAnimationController(shellInit, shellController, shellExecutor,
                            backgroundHandler, context, transitions));
        }
        return Optional.empty();
    }
@@ -472,6 +473,7 @@ public abstract class WMShellBaseModule {
    static Optional<RecentTasksController> provideRecentTasksController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            ShellCommandHandler shellCommandHandler,
            TaskStackListenerImpl taskStackListener,
            ActivityTaskManager activityTaskManager,
@@ -479,9 +481,9 @@ public abstract class WMShellBaseModule {
            @ShellMainThread ShellExecutor mainExecutor
    ) {
        return Optional.ofNullable(
                RecentTasksController.create(context, shellInit, shellCommandHandler,
                        taskStackListener, activityTaskManager, desktopModeTaskRepository,
                        mainExecutor));
                RecentTasksController.create(context, shellInit, shellController,
                        shellCommandHandler, taskStackListener, activityTaskManager,
                        desktopModeTaskRepository, mainExecutor));
    }

    //
@@ -498,14 +500,15 @@ public abstract class WMShellBaseModule {
    @Provides
    static Transitions provideTransitions(Context context,
            ShellInit shellInit,
            ShellController shellController,
            ShellTaskOrganizer organizer,
            TransactionPool pool,
            DisplayController displayController,
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread Handler mainHandler,
            @ShellAnimationThread ShellExecutor animExecutor) {
        return new Transitions(context, shellInit, organizer, pool, displayController, mainExecutor,
                mainHandler, animExecutor);
        return new Transitions(context, shellInit, shellController, organizer, pool,
                displayController, mainExecutor, mainHandler, animExecutor);
    }

    @WMSingleton
@@ -622,13 +625,15 @@ public abstract class WMShellBaseModule {

    @WMSingleton
    @Provides
    static StartingWindowController provideStartingWindowController(Context context,
    static StartingWindowController provideStartingWindowController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            ShellTaskOrganizer shellTaskOrganizer,
            @ShellSplashscreenThread ShellExecutor splashScreenExecutor,
            StartingWindowTypeAlgorithm startingWindowTypeAlgorithm, IconProvider iconProvider,
            TransactionPool pool) {
        return new StartingWindowController(context, shellInit, shellTaskOrganizer,
        return new StartingWindowController(context, shellInit, shellController, shellTaskOrganizer,
                splashScreenExecutor, startingWindowTypeAlgorithm, iconProvider, pool);
    }

Loading