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

Commit 43502aa7 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Make BackAnimationController dumpable

Bug: 308144338
Flag: NONE
Test: Manual, i.e. testing dump by running `adb shell dumpsys activity service SystemUIService WMShell`
Change-Id: I1faea319dd5c7d285d68a24808a5bb6a3012751b
parent 7277d7e3
Loading
Loading
Loading
Loading
+27 −3
Original line number Original line 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.ShellExecutor;
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
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.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellInit;


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


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


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


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


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


    private void setupAnimationDeveloperSettingsObserver(
    private void setupAnimationDeveloperSettingsObserver(
@@ -945,4 +953,20 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                };
                };
        mBackAnimationAdapter = new BackAnimationAdapter(runner);
        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 Original line Diff line number Diff line
@@ -24,6 +24,8 @@ import android.view.RemoteAnimationTarget;
import android.window.BackEvent;
import android.window.BackEvent;
import android.window.BackMotionEvent;
import android.window.BackMotionEvent;


import java.io.PrintWriter;

/**
/**
 * Helper class to record the touch location for gesture and generate back events.
 * Helper class to record the touch location for gesture and generate back events.
 */
 */
@@ -212,6 +214,12 @@ class TouchTracker {
        mNonLinearFactor = nonLinearFactor;
        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 {
    enum TouchTrackerState {
        INITIAL, ACTIVE, FINISHED
        INITIAL, ACTIVE, FINISHED
    }
    }
+4 −2
Original line number Original line Diff line number Diff line
@@ -363,7 +363,8 @@ public abstract class WMShellBaseModule {
            @ShellMainThread ShellExecutor shellExecutor,
            @ShellMainThread ShellExecutor shellExecutor,
            @ShellBackgroundThread Handler backgroundHandler,
            @ShellBackgroundThread Handler backgroundHandler,
            BackAnimationBackground backAnimationBackground,
            BackAnimationBackground backAnimationBackground,
            Optional<ShellBackAnimationRegistry> shellBackAnimationRegistry) {
            Optional<ShellBackAnimationRegistry> shellBackAnimationRegistry,
            ShellCommandHandler shellCommandHandler) {
        if (BackAnimationController.IS_ENABLED) {
        if (BackAnimationController.IS_ENABLED) {
            return shellBackAnimationRegistry.map(
            return shellBackAnimationRegistry.map(
                    (animations) ->
                    (animations) ->
@@ -374,7 +375,8 @@ public abstract class WMShellBaseModule {
                                    backgroundHandler,
                                    backgroundHandler,
                                    context,
                                    context,
                                    backAnimationBackground,
                                    backAnimationBackground,
                                    animations));
                                    animations,
                                    shellCommandHandler));
        }
        }
        return Optional.empty();
        return Optional.empty();
    }
    }
+7 −2
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.util.test.FakeSettingsProvider;
import com.android.internal.util.test.FakeSettingsProvider;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
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.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellSharedConstants;
import com.android.wm.shell.sysui.ShellSharedConstants;
@@ -110,6 +111,8 @@ public class BackAnimationControllerTest extends ShellTestCase {


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


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