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

Commit 85795f3f authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Allow swipe up on unlocked dream."

parents f0f201ad 73dee54d
Loading
Loading
Loading
Loading
+31 −1
Original line number Original line Diff line number Diff line
@@ -37,8 +37,10 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.complication.ComplicationHostViewController;
import com.android.systemui.dreams.complication.ComplicationHostViewController;
import com.android.systemui.dreams.dagger.DreamOverlayComponent;
import com.android.systemui.dreams.dagger.DreamOverlayComponent;
import com.android.systemui.dreams.dagger.DreamOverlayModule;
import com.android.systemui.dreams.dagger.DreamOverlayModule;
import com.android.systemui.dreams.touch.scrim.BouncerlessScrimController;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
@@ -85,6 +87,22 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
    private long mJitterStartTimeMillis;
    private long mJitterStartTimeMillis;


    private boolean mBouncerAnimating;
    private boolean mBouncerAnimating;
    private boolean mWakingUpFromSwipe;

    private final BouncerlessScrimController mBouncerlessScrimController;

    private final BouncerlessScrimController.Callback mBouncerlessExpansionCallback =
            new BouncerlessScrimController.Callback() {
        @Override
        public void onExpansion(ShadeExpansionChangeEvent event) {
            updateTransitionState(event.getFraction());
        }

        @Override
        public void onWakeup() {
            mWakingUpFromSwipe = true;
        }
    };


    private final PrimaryBouncerExpansionCallback
    private final PrimaryBouncerExpansionCallback
            mBouncerExpansionCallback =
            mBouncerExpansionCallback =
@@ -143,7 +161,8 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
            @Named(DreamOverlayModule.MILLIS_UNTIL_FULL_JITTER) long millisUntilFullJitter,
            @Named(DreamOverlayModule.MILLIS_UNTIL_FULL_JITTER) long millisUntilFullJitter,
            PrimaryBouncerCallbackInteractor primaryBouncerCallbackInteractor,
            PrimaryBouncerCallbackInteractor primaryBouncerCallbackInteractor,
            DreamOverlayAnimationsController animationsController,
            DreamOverlayAnimationsController animationsController,
            DreamOverlayStateController stateController) {
            DreamOverlayStateController stateController,
            BouncerlessScrimController bouncerlessScrimController) {
        super(containerView);
        super(containerView);
        mDreamOverlayContentView = contentView;
        mDreamOverlayContentView = contentView;
        mStatusBarViewController = statusBarViewController;
        mStatusBarViewController = statusBarViewController;
@@ -152,6 +171,9 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
        mDreamOverlayAnimationsController = animationsController;
        mDreamOverlayAnimationsController = animationsController;
        mStateController = stateController;
        mStateController = stateController;


        mBouncerlessScrimController = bouncerlessScrimController;
        mBouncerlessScrimController.addCallback(mBouncerlessExpansionCallback);

        mComplicationHostViewController = complicationHostViewController;
        mComplicationHostViewController = complicationHostViewController;
        mDreamOverlayMaxTranslationY = resources.getDimensionPixelSize(
        mDreamOverlayMaxTranslationY = resources.getDimensionPixelSize(
                R.dimen.dream_overlay_y_offset);
                R.dimen.dream_overlay_y_offset);
@@ -177,6 +199,7 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve


    @Override
    @Override
    protected void onViewAttached() {
    protected void onViewAttached() {
        mWakingUpFromSwipe = false;
        mJitterStartTimeMillis = System.currentTimeMillis();
        mJitterStartTimeMillis = System.currentTimeMillis();
        mHandler.postDelayed(this::updateBurnInOffsets, mBurnInProtectionUpdateInterval);
        mHandler.postDelayed(this::updateBurnInOffsets, mBurnInProtectionUpdateInterval);
        final KeyguardBouncer bouncer = mStatusBarKeyguardViewManager.getPrimaryBouncer();
        final KeyguardBouncer bouncer = mStatusBarKeyguardViewManager.getPrimaryBouncer();
@@ -266,6 +289,13 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
     */
     */
    public void wakeUp(@NonNull Runnable onAnimationEnd,
    public void wakeUp(@NonNull Runnable onAnimationEnd,
            @NonNull DelayableExecutor callbackExecutor) {
            @NonNull DelayableExecutor callbackExecutor) {
        // When swiping causes wakeup, do not run any animations as the dream should exit as soon
        // as possible.
        if (mWakingUpFromSwipe) {
            onAnimationEnd.run();
            return;
        }

        mDreamOverlayAnimationsController.wakeUp(onAnimationEnd, callbackExecutor);
        mDreamOverlayAnimationsController.wakeUp(onAnimationEnd, callbackExecutor);
    }
    }
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.dreams.DreamOverlayNotificationCountProvider;
import com.android.systemui.dreams.DreamOverlayService;
import com.android.systemui.dreams.DreamOverlayService;
import com.android.systemui.dreams.complication.dagger.RegisteredComplicationsModule;
import com.android.systemui.dreams.complication.dagger.RegisteredComplicationsModule;
import com.android.systemui.dreams.dreamcomplication.dagger.ComplicationComponent;
import com.android.systemui.dreams.dreamcomplication.dagger.ComplicationComponent;
import com.android.systemui.dreams.touch.scrim.dagger.ScrimModule;


import dagger.Module;
import dagger.Module;
import dagger.Provides;
import dagger.Provides;
@@ -44,6 +45,7 @@ import javax.inject.Named;
@Module(includes = {
@Module(includes = {
            RegisteredComplicationsModule.class,
            RegisteredComplicationsModule.class,
            LowLightDreamModule.class,
            LowLightDreamModule.class,
            ScrimModule.class
        },
        },
        subcomponents = {
        subcomponents = {
            ComplicationComponent.class,
            ComplicationComponent.class,
+31 −11
Original line number Original line Diff line number Diff line
@@ -36,11 +36,12 @@ import androidx.annotation.VisibleForTesting;


import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.dreams.touch.scrim.ScrimController;
import com.android.systemui.dreams.touch.scrim.ScrimManager;
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.wm.shell.animation.FlingAnimationUtils;
import com.android.wm.shell.animation.FlingAnimationUtils;


import java.util.Optional;
import java.util.Optional;
@@ -78,7 +79,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final float mBouncerZoneScreenPercentage;
    private final float mBouncerZoneScreenPercentage;


    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
    private final ScrimManager mScrimManager;
    private ScrimController mCurrentScrimController;
    private float mCurrentExpansion;
    private float mCurrentExpansion;
    private final Optional<CentralSurfaces> mCentralSurfaces;
    private final Optional<CentralSurfaces> mCentralSurfaces;


@@ -90,6 +92,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
    private final DisplayMetrics mDisplayMetrics;
    private final DisplayMetrics mDisplayMetrics;


    private Boolean mCapture;
    private Boolean mCapture;
    private Boolean mExpanded;


    private boolean mBouncerInitiallyShowing;
    private boolean mBouncerInitiallyShowing;


@@ -101,6 +104,17 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {


    private final UiEventLogger mUiEventLogger;
    private final UiEventLogger mUiEventLogger;


    private final ScrimManager.Callback mScrimManagerCallback = new ScrimManager.Callback() {
        @Override
        public void onScrimControllerChanged(ScrimController controller) {
            if (mCurrentScrimController != null) {
                mCurrentScrimController.reset();
            }

            mCurrentScrimController = controller;
        }
    };

    private final GestureDetector.OnGestureListener mOnGestureListener =
    private final GestureDetector.OnGestureListener mOnGestureListener =
            new GestureDetector.SimpleOnGestureListener() {
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                @Override
@@ -115,8 +129,10 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
                                .orElse(false);
                                .orElse(false);


                        if (mCapture) {
                        if (mCapture) {
                            // reset expanding
                            mExpanded = false;
                            // Since the user is dragging the bouncer up, set scrimmed to false.
                            // Since the user is dragging the bouncer up, set scrimmed to false.
                            mStatusBarKeyguardViewManager.showPrimaryBouncer(false);
                            mCurrentScrimController.show();
                        }
                        }
                    }
                    }


@@ -157,10 +173,10 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
        ShadeExpansionChangeEvent event =
        ShadeExpansionChangeEvent event =
                new ShadeExpansionChangeEvent(
                new ShadeExpansionChangeEvent(
                        /* fraction= */ mCurrentExpansion,
                        /* fraction= */ mCurrentExpansion,
                        /* expanded= */ false,
                        /* expanded= */ mExpanded,
                        /* tracking= */ true,
                        /* tracking= */ true,
                        /* dragDownPxAmount= */ dragDownAmount);
                        /* dragDownPxAmount= */ dragDownAmount);
        mStatusBarKeyguardViewManager.onPanelExpansionChanged(event);
        mCurrentScrimController.expand(event);
    }
    }




@@ -187,7 +203,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
    @Inject
    @Inject
    public BouncerSwipeTouchHandler(
    public BouncerSwipeTouchHandler(
            DisplayMetrics displayMetrics,
            DisplayMetrics displayMetrics,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            ScrimManager scrimManager,
            Optional<CentralSurfaces> centralSurfaces,
            Optional<CentralSurfaces> centralSurfaces,
            NotificationShadeWindowController notificationShadeWindowController,
            NotificationShadeWindowController notificationShadeWindowController,
            ValueAnimatorCreator valueAnimatorCreator,
            ValueAnimatorCreator valueAnimatorCreator,
@@ -200,7 +216,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
            UiEventLogger uiEventLogger) {
            UiEventLogger uiEventLogger) {
        mDisplayMetrics = displayMetrics;
        mDisplayMetrics = displayMetrics;
        mCentralSurfaces = centralSurfaces;
        mCentralSurfaces = centralSurfaces;
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
        mScrimManager = scrimManager;
        mNotificationShadeWindowController = notificationShadeWindowController;
        mNotificationShadeWindowController = notificationShadeWindowController;
        mBouncerZoneScreenPercentage = swipeRegionPercentage;
        mBouncerZoneScreenPercentage = swipeRegionPercentage;
        mFlingAnimationUtils = flingAnimationUtils;
        mFlingAnimationUtils = flingAnimationUtils;
@@ -234,9 +250,12 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
        mTouchSession = session;
        mTouchSession = session;
        mVelocityTracker.clear();
        mVelocityTracker.clear();
        mNotificationShadeWindowController.setForcePluginOpen(true, this);
        mNotificationShadeWindowController.setForcePluginOpen(true, this);
        mScrimManager.addCallback(mScrimManagerCallback);
        mCurrentScrimController = mScrimManager.getCurrentController();


        session.registerCallback(() -> {
        session.registerCallback(() -> {
            mVelocityTracker.recycle();
            mVelocityTracker.recycle();
            mScrimManager.removeCallback(mScrimManagerCallback);
            mCapture = null;
            mCapture = null;
            mNotificationShadeWindowController.setForcePluginOpen(false, this);
            mNotificationShadeWindowController.setForcePluginOpen(false, this);
        });
        });
@@ -273,9 +292,10 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
                final float velocityVector =
                final float velocityVector =
                        (float) Math.hypot(horizontalVelocity, verticalVelocity);
                        (float) Math.hypot(horizontalVelocity, verticalVelocity);


                final float expansion = flingRevealsOverlay(verticalVelocity, velocityVector)
                mExpanded = !flingRevealsOverlay(verticalVelocity, velocityVector);
                        ? KeyguardBouncerConstants.EXPANSION_HIDDEN
                final float expansion = mExpanded
                        : KeyguardBouncerConstants.EXPANSION_VISIBLE;
                        ? KeyguardBouncerConstants.EXPANSION_VISIBLE
                        : KeyguardBouncerConstants.EXPANSION_HIDDEN;


                // Log the swiping up to show Bouncer event.
                // Log the swiping up to show Bouncer event.
                if (!mBouncerInitiallyShowing
                if (!mBouncerInitiallyShowing
@@ -286,7 +306,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
                flingToExpansion(verticalVelocity, expansion);
                flingToExpansion(verticalVelocity, expansion);


                if (expansion == KeyguardBouncerConstants.EXPANSION_HIDDEN) {
                if (expansion == KeyguardBouncerConstants.EXPANSION_HIDDEN) {
                    mStatusBarKeyguardViewManager.reset(false);
                    mCurrentScrimController.reset();
                }
                }
                break;
                break;
            default:
            default:
+49 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 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.systemui.dreams.touch.scrim;

import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;

import javax.inject.Inject;

/**
 * Implementation for handling swipe movements on the overlay when the keyguard is present.
 */
public class BouncerScrimController implements ScrimController {
    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;

    @Inject
    BouncerScrimController(StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
    }

    @Override
    public void show() {
        mStatusBarKeyguardViewManager.showBouncer(false);
    }

    @Override
    public void expand(ShadeExpansionChangeEvent event) {
        mStatusBarKeyguardViewManager.onPanelExpansionChanged(event);
    }

    @Override
    public void reset() {
        mStatusBarKeyguardViewManager.reset(false);
    }
}
+91 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 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.systemui.dreams.touch.scrim;

import android.os.PowerManager;
import android.os.SystemClock;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.unfold.util.CallbackController;

import java.util.HashSet;
import java.util.concurrent.Executor;

import javax.inject.Inject;

/**
 * {@link BouncerlessScrimController} handles scrim progression when no keyguard is set. When
 * fully expanded, the controller dismisses the dream.
 */
@SysUISingleton
public class BouncerlessScrimController implements ScrimController,
        CallbackController<BouncerlessScrimController.Callback> {
    private static final String TAG = "BLScrimController";

    /**
     * {@link Callback} allows {@link BouncerlessScrimController} clients to be informed of
     * expansion progression and wakeup
     */
    public interface Callback {
        /**
         * Invoked when there is a change to the scrim expansion.
         */
        void onExpansion(ShadeExpansionChangeEvent event);

        /**
         * Invoked after {@link BouncerlessScrimController} has started waking up the device.
         */
        void onWakeup();
    }

    private final Executor mExecutor;
    private final PowerManager mPowerManager;

    @Override
    public void addCallback(Callback listener) {
        mExecutor.execute(() -> mCallbacks.add(listener));
    }

    @Override
    public void removeCallback(Callback listener) {
        mExecutor.execute(() -> mCallbacks.remove(listener));
    }

    private final HashSet<Callback> mCallbacks;


    @Inject
    public BouncerlessScrimController(@Main Executor executor,
            PowerManager powerManager) {
        mExecutor = executor;
        mPowerManager = powerManager;
        mCallbacks = new HashSet<>();
    }

    @Override
    public void expand(ShadeExpansionChangeEvent event) {
        if (event.getExpanded())  {
            mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                    "com.android.systemui:SwipeUp");
            mExecutor.execute(() -> mCallbacks.forEach(callback -> callback.onWakeup()));
        } else {
            mExecutor.execute(() -> mCallbacks.forEach(callback -> callback.onExpansion(event)));
        }
    }
}
Loading