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

Commit eee822c2 authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Simplify exposing external interfaces to Launcher" into tm-qpr-dev am: dc06f11e

parents e4f6802d dc06f11e
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.
     *
+21 −16
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.RemoteAnimationTarget.MODE_OPENING;

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;
@@ -57,10 +58,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 java.util.concurrent.atomic.AtomicBoolean;
@@ -105,6 +108,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;
    @Nullable
@@ -231,21 +235,25 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

    public BackAnimationController(
            @NonNull ShellInit shellInit,
            @NonNull ShellController shellController,
            @NonNull @ShellMainThread ShellExecutor shellExecutor,
            @NonNull @ShellBackgroundThread Handler backgroundHandler,
            Context context) {
        this(shellInit, shellExecutor, backgroundHandler, new SurfaceControl.Transaction(),
                ActivityTaskManager.getService(), context, context.getContentResolver());
        this(shellInit, shellController, shellExecutor, backgroundHandler,
                new SurfaceControl.Transaction(), ActivityTaskManager.getService(),
                context, context.getContentResolver());
    }

    @VisibleForTesting
    BackAnimationController(
            @NonNull ShellInit shellInit,
            @NonNull ShellController shellController,
            @NonNull @ShellMainThread ShellExecutor shellExecutor,
            @NonNull @ShellBackgroundThread Handler bgHandler,
            @NonNull SurfaceControl.Transaction transaction,
            @NonNull IActivityTaskManager activityTaskManager,
            Context context, ContentResolver contentResolver) {
        mShellController = shellController;
        mShellExecutor = shellExecutor;
        mTransaction = transaction;
        mActivityTaskManager = activityTaskManager;
@@ -257,6 +265,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

    private void onInit() {
        setupAnimationDeveloperSettingsObserver(mContentResolver, mBgHandler);
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_BACK_ANIMATION,
                this::createExternalInterface, this);
    }

    private void setupAnimationDeveloperSettingsObserver(
@@ -289,7 +299,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() {
@@ -302,17 +316,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) {
@@ -331,7 +334,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) {
@@ -356,7 +360,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                    (controller) -> controller.onBackToLauncherAnimationFinished());
        }

        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,13 +261,14 @@ public abstract class WMShellBaseModule {
    static Optional<BackAnimationController> provideBackAnimationController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            @ShellMainThread ShellExecutor shellExecutor,
            @ShellBackgroundThread Handler backgroundHandler
    ) {
        if (BackAnimationController.IS_ENABLED) {
            return Optional.of(
                    new BackAnimationController(shellInit, shellExecutor, backgroundHandler,
                            context));
                    new BackAnimationController(shellInit, shellController, shellExecutor,
                            backgroundHandler, context));
        }
        return Optional.empty();
    }
@@ -471,6 +472,7 @@ public abstract class WMShellBaseModule {
    static Optional<RecentTasksController> provideRecentTasksController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            ShellCommandHandler shellCommandHandler,
            TaskStackListenerImpl taskStackListener,
            ActivityTaskManager activityTaskManager,
@@ -478,9 +480,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));
    }

    //
@@ -497,14 +499,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
@@ -621,13 +624,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