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

Commit 787f5eee authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Make BackAnimationController dumpable" into main

parents a8dc1426 43502aa7
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -70,9 +70,11 @@ 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.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;

import java.io.PrintWriter;
import java.util.concurrent.atomic.AtomicBoolean;

/**
@@ -124,6 +126,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    private final Context mContext;
    private final ContentResolver mContentResolver;
    private final ShellController mShellController;
    private final ShellCommandHandler mShellCommandHandler;
    private final ShellExecutor mShellExecutor;
    private final Handler mBgHandler;

@@ -180,7 +183,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            @NonNull @ShellBackgroundThread Handler backgroundHandler,
            Context context,
            @NonNull BackAnimationBackground backAnimationBackground,
            ShellBackAnimationRegistry shellBackAnimationRegistry) {
            ShellBackAnimationRegistry shellBackAnimationRegistry,
            ShellCommandHandler shellCommandHandler) {
        this(
                shellInit,
                shellController,
@@ -190,7 +194,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                context,
                context.getContentResolver(),
                backAnimationBackground,
                shellBackAnimationRegistry);
                shellBackAnimationRegistry,
                shellCommandHandler);
    }

    @VisibleForTesting
@@ -203,7 +208,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            Context context,
            ContentResolver contentResolver,
            @NonNull BackAnimationBackground backAnimationBackground,
            ShellBackAnimationRegistry shellBackAnimationRegistry) {
            ShellBackAnimationRegistry shellBackAnimationRegistry,
            ShellCommandHandler shellCommandHandler) {
        mShellController = shellController;
        mShellExecutor = shellExecutor;
        mActivityTaskManager = activityTaskManager;
@@ -219,6 +225,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                .build();
        mShellBackAnimationRegistry = shellBackAnimationRegistry;
        mLatencyTracker = LatencyTracker.getInstance(mContext);
        mShellCommandHandler = shellCommandHandler;
    }

    private void onInit() {
@@ -227,6 +234,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        createAdapter();
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_BACK_ANIMATION,
                this::createExternalInterface, this);
        mShellCommandHandler.addDumpCallback(this::dump, this);
    }

    private void setupAnimationDeveloperSettingsObserver(
@@ -968,4 +976,20 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                };
        mBackAnimationAdapter = new BackAnimationAdapter(runner);
    }

    /**
     * Description of current BackAnimationController state.
     */
    private void dump(PrintWriter pw, String prefix) {
        pw.println(prefix + "BackAnimationController state:");
        pw.println(prefix + "  mEnableAnimations=" + mEnableAnimations.get());
        pw.println(prefix + "  mBackGestureStarted=" + mBackGestureStarted);
        pw.println(prefix + "  mPostCommitAnimationInProgress=" + mPostCommitAnimationInProgress);
        pw.println(prefix + "  mShouldStartOnNextMoveEvent=" + mShouldStartOnNextMoveEvent);
        pw.println(prefix + "  mCurrentTracker state:");
        mCurrentTracker.dump(pw, prefix + "    ");
        pw.println(prefix + "  mQueuedTracker state:");
        mQueuedTracker.dump(pw, prefix + "    ");
    }

}
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.view.RemoteAnimationTarget;
import android.window.BackEvent;
import android.window.BackMotionEvent;

import java.io.PrintWriter;

/**
 * Helper class to record the touch location for gesture and generate back events.
 */
@@ -221,6 +223,12 @@ class TouchTracker {
        mNonLinearFactor = nonLinearFactor;
    }

    void dump(PrintWriter pw, String prefix) {
        pw.println(prefix + "TouchTracker state:");
        pw.println(prefix + "  mState=" + mState);
        pw.println(prefix + "  mTriggerBack=" + mTriggerBack);
    }

    enum TouchTrackerState {
        INITIAL, ACTIVE, FINISHED
    }
+4 −2
Original line number Diff line number Diff line
@@ -363,7 +363,8 @@ public abstract class WMShellBaseModule {
            @ShellMainThread ShellExecutor shellExecutor,
            @ShellBackgroundThread Handler backgroundHandler,
            BackAnimationBackground backAnimationBackground,
            Optional<ShellBackAnimationRegistry> shellBackAnimationRegistry) {
            Optional<ShellBackAnimationRegistry> shellBackAnimationRegistry,
            ShellCommandHandler shellCommandHandler) {
        if (BackAnimationController.IS_ENABLED) {
            return shellBackAnimationRegistry.map(
                    (animations) ->
@@ -374,7 +375,8 @@ public abstract class WMShellBaseModule {
                                    backgroundHandler,
                                    context,
                                    backAnimationBackground,
                                    animations));
                                    animations,
                                    shellCommandHandler));
        }
        return Optional.empty();
    }
+7 −2
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.util.test.FakeSettingsProvider;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellSharedConstants;
@@ -110,6 +111,8 @@ public class BackAnimationControllerTest extends ShellTestCase {

    @Mock
    private InputManager mInputManager;
    @Mock
    private ShellCommandHandler mShellCommandHandler;

    private BackAnimationController mController;
    private TestableContentResolver mContentResolver;
@@ -145,7 +148,8 @@ public class BackAnimationControllerTest extends ShellTestCase {
                        mContext,
                        mContentResolver,
                        mAnimationBackground,
                        mShellBackAnimationRegistry);
                        mShellBackAnimationRegistry,
                        mShellCommandHandler);
        mShellInit.init();
        mShellExecutor.flushAll();
    }
@@ -298,7 +302,8 @@ public class BackAnimationControllerTest extends ShellTestCase {
                        mContext,
                        mContentResolver,
                        mAnimationBackground,
                        mShellBackAnimationRegistry);
                        mShellBackAnimationRegistry,
                        mShellCommandHandler);
        shellInit.init();
        registerAnimation(BackNavigationInfo.TYPE_RETURN_TO_HOME);