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

Commit 11e490f3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use main executor to run remote animation from notification" into...

Merge "Use main executor to run remote animation from notification" into rvc-dev am: e6c5d04a am: 5310f00c am: 6baf5047 am: c82a132a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11788493

Change-Id: I5d81502bef1c5b77a3226d56cdf0eeba691364f3
parents f0088ba2 c82a132a
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -41,6 +41,8 @@ import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.phone.NotificationPanelViewController;
import com.android.systemui.statusbar.phone.NotificationPanelViewController;
import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController;
import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController;


import java.util.concurrent.Executor;

/**
/**
 * A class that allows activities to be launched in a seamless way where the notification
 * A class that allows activities to be launched in a seamless way where the notification
 * transforms nicely into the starting window.
 * transforms nicely into the starting window.
@@ -59,6 +61,7 @@ public class ActivityLaunchAnimator {
    private final float mWindowCornerRadius;
    private final float mWindowCornerRadius;
    private final NotificationShadeWindowViewController mNotificationShadeWindowViewController;
    private final NotificationShadeWindowViewController mNotificationShadeWindowViewController;
    private final NotificationShadeDepthController mDepthController;
    private final NotificationShadeDepthController mDepthController;
    private final Executor mMainExecutor;
    private Callback mCallback;
    private Callback mCallback;
    private final Runnable mTimeoutRunnable = () -> {
    private final Runnable mTimeoutRunnable = () -> {
        setAnimationPending(false);
        setAnimationPending(false);
@@ -73,12 +76,14 @@ public class ActivityLaunchAnimator {
            Callback callback,
            Callback callback,
            NotificationPanelViewController notificationPanel,
            NotificationPanelViewController notificationPanel,
            NotificationShadeDepthController depthController,
            NotificationShadeDepthController depthController,
            NotificationListContainer container) {
            NotificationListContainer container,
            Executor mainExecutor) {
        mNotificationPanel = notificationPanel;
        mNotificationPanel = notificationPanel;
        mNotificationContainer = container;
        mNotificationContainer = container;
        mDepthController = depthController;
        mDepthController = depthController;
        mNotificationShadeWindowViewController = notificationShadeWindowViewController;
        mNotificationShadeWindowViewController = notificationShadeWindowViewController;
        mCallback = callback;
        mCallback = callback;
        mMainExecutor = mainExecutor;
        mWindowCornerRadius = ScreenDecorationsUtils
        mWindowCornerRadius = ScreenDecorationsUtils
                .getWindowCornerRadius(mNotificationShadeWindowViewController.getView()
                .getWindowCornerRadius(mNotificationShadeWindowViewController.getView()
                        .getResources());
                        .getResources());
@@ -155,7 +160,7 @@ public class ActivityLaunchAnimator {
                RemoteAnimationTarget[] remoteAnimationWallpaperTargets,
                RemoteAnimationTarget[] remoteAnimationWallpaperTargets,
                IRemoteAnimationFinishedCallback iRemoteAnimationFinishedCallback)
                IRemoteAnimationFinishedCallback iRemoteAnimationFinishedCallback)
                    throws RemoteException {
                    throws RemoteException {
            mSourceNotification.post(() -> {
            mMainExecutor.execute(() -> {
                RemoteAnimationTarget primary = getPrimaryRemoteAnimationTarget(
                RemoteAnimationTarget primary = getPrimaryRemoteAnimationTarget(
                        remoteAnimationTargets);
                        remoteAnimationTargets);
                if (primary == null) {
                if (primary == null) {
@@ -191,8 +196,9 @@ public class ActivityLaunchAnimator {
                    }
                    }
                }
                }
                int targetWidth = primary.sourceContainerBounds.width();
                int targetWidth = primary.sourceContainerBounds.width();
                int notificationHeight = mSourceNotification.getActualHeight()
                // If the notification panel is collapsed, the clip may be larger than the height.
                        - mSourceNotification.getClipBottomAmount();
                int notificationHeight = Math.max(mSourceNotification.getActualHeight()
                        - mSourceNotification.getClipBottomAmount(), 0);
                int notificationWidth = mSourceNotification.getWidth();
                int notificationWidth = mSourceNotification.getWidth();
                anim.setDuration(ANIMATION_DURATION);
                anim.setDuration(ANIMATION_DURATION);
                anim.setInterpolator(Interpolators.LINEAR);
                anim.setInterpolator(Interpolators.LINEAR);
@@ -292,7 +298,7 @@ public class ActivityLaunchAnimator {


        @Override
        @Override
        public void onAnimationCancelled() throws RemoteException {
        public void onAnimationCancelled() throws RemoteException {
            mSourceNotification.post(() -> {
            mMainExecutor.execute(() -> {
                setAnimationPending(false);
                setAnimationPending(false);
                mCallback.onLaunchAnimationCancelled();
                mCallback.onLaunchAnimationCancelled();
            });
            });
+1 −1
Original line number Original line Diff line number Diff line
@@ -1291,7 +1291,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        mActivityLaunchAnimator = new ActivityLaunchAnimator(
        mActivityLaunchAnimator = new ActivityLaunchAnimator(
                mNotificationShadeWindowViewController, this, mNotificationPanelViewController,
                mNotificationShadeWindowViewController, this, mNotificationPanelViewController,
                mNotificationShadeDepthControllerLazy.get(),
                mNotificationShadeDepthControllerLazy.get(),
                (NotificationListContainer) mStackScroller);
                (NotificationListContainer) mStackScroller, mContext.getMainExecutor());


        // TODO: inject this.
        // TODO: inject this.
        mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController,
        mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController,
+5 −2
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@ import com.android.systemui.statusbar.notification.stack.NotificationListContain
import com.android.systemui.statusbar.phone.NotificationPanelViewController;
import com.android.systemui.statusbar.phone.NotificationPanelViewController;
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController;
import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;


import org.junit.Assert;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Before;
@@ -51,6 +53,7 @@ import org.mockito.junit.MockitoRule;
@TestableLooper.RunWithLooper
@TestableLooper.RunWithLooper
public class ActivityLaunchAnimatorTest extends SysuiTestCase {
public class ActivityLaunchAnimatorTest extends SysuiTestCase {


    private final FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
    private ActivityLaunchAnimator mLaunchAnimator;
    private ActivityLaunchAnimator mLaunchAnimator;
    @Mock
    @Mock
    private ActivityLaunchAnimator.Callback mCallback;
    private ActivityLaunchAnimator.Callback mCallback;
@@ -80,8 +83,8 @@ public class ActivityLaunchAnimatorTest extends SysuiTestCase {
                mCallback,
                mCallback,
                mNotificationPanelViewController,
                mNotificationPanelViewController,
                mNotificationShadeDepthController,
                mNotificationShadeDepthController,
                mNotificationContainer);
                mNotificationContainer,

                mExecutor);
    }
    }


    @Test
    @Test