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

Commit 5454a0dd authored by Selim Cinek's avatar Selim Cinek
Browse files

Improved the experience with bypass and dynamic privacy

The user can now use the expand buttons and also clear
all is invisible while locked down.
The can also drag down normally to reveal the
contents of a notification.
Also, the section clear button is also properly updated
once dynamic privacy changes.

Fixes: 138671060
Fixes: 138669307
Test: drag down with notif hidden and bypass on on a sensitive notification
Change-Id: I8743400d0b46583802a8663f6723dfa6beee95c9
parent 1665ee54
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class DragDownHelper implements Gefingerpoken {
                    mInitialTouchY = y;
                    mInitialTouchX = x;
                    mDragDownCallback.onTouchSlopExceeded();
                    return true;
                    return mStartingChild != null || mDragDownCallback.isDragDownAnywhereEnabled();
                }
                break;
        }
@@ -162,7 +162,11 @@ public class DragDownHelper implements Gefingerpoken {
        if (mStartingChild == null) {
            mStartingChild = findView(x, y);
            if (mStartingChild != null) {
                if (mDragDownCallback.isDragDownEnabledForView(mStartingChild)) {
                    mCallback.setUserLockedChild(mStartingChild, true);
                } else {
                    mStartingChild = null;
                }
            }
        }
    }
@@ -237,6 +241,10 @@ public class DragDownHelper implements Gefingerpoken {
        return mDraggingDown;
    }

    public boolean isDragDownEnabled() {
        return mDragDownCallback.isDragDownEnabledForView(null);
    }

    public interface DragDownCallback {

        /**
@@ -253,5 +261,16 @@ public class DragDownHelper implements Gefingerpoken {
        void onTouchSlopExceeded();
        void setEmptyDragAmount(float amount);
        boolean isFalsingCheckNeeded();

        /**
         * Is dragging down enabled on a given view
         * @param view The view to check or {@code null} to check if it's enabled at all
         */
        boolean isDragDownEnabledForView(ExpandableView view);

        /**
         * @return if drag down is enabled anywhere, not just on selected views.
         */
        boolean isDragDownAnywhereEnabled();
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -62,11 +62,6 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
     */
    int getMaxNotificationsWhileLocked(boolean recompute);

    /**
     * True if the presenter is currently locked.
     */
    boolean isPresenterLocked();

    /**
     * Called when the row states are updated by {@link NotificationViewHierarchyManager}.
     */
+36 −3
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ import android.content.Context;
import android.util.ArraySet;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.UnlockMethodCache;

import javax.inject.Inject;
@@ -34,21 +37,27 @@ public class DynamicPrivacyController implements UnlockMethodCache.OnUnlockMetho

    private final UnlockMethodCache mUnlockMethodCache;
    private final NotificationLockscreenUserManager mLockscreenUserManager;
    private final StatusBarStateController mStateController;
    private ArraySet<Listener> mListeners = new ArraySet<>();

    private boolean mLastDynamicUnlocked;
    private boolean mCacheInvalid;
    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;

    @Inject
    DynamicPrivacyController(Context context,
            NotificationLockscreenUserManager notificationLockscreenUserManager) {
        this(notificationLockscreenUserManager, UnlockMethodCache.getInstance(context));
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            StatusBarStateController stateController) {
        this(notificationLockscreenUserManager, UnlockMethodCache.getInstance(context),
                stateController);
    }

    @VisibleForTesting
    DynamicPrivacyController(NotificationLockscreenUserManager notificationLockscreenUserManager,
            UnlockMethodCache unlockMethodCache) {
            UnlockMethodCache unlockMethodCache,
            StatusBarStateController stateController) {
        mLockscreenUserManager = notificationLockscreenUserManager;
        mStateController = stateController;
        mUnlockMethodCache = unlockMethodCache;
        mUnlockMethodCache.addListener(this);
        mLastDynamicUnlocked = isDynamicallyUnlocked();
@@ -84,6 +93,30 @@ public class DynamicPrivacyController implements UnlockMethodCache.OnUnlockMetho
        mListeners.add(listener);
    }

    /**
     * Is the notification shade currently in a locked down mode where it's fully showing but the
     * contents aren't revealed yet?
     */
    public boolean isInLockedDownShade() {
        if (!mStatusBarKeyguardViewManager.isShowing()
                || !mStatusBarKeyguardViewManager.isSecure()) {
            return false;
        }
        int state = mStateController.getState();
        if (state != StatusBarState.SHADE && state != StatusBarState.SHADE_LOCKED) {
            return false;
        }
        if (!isDynamicPrivacyEnabled() || isDynamicallyUnlocked()) {
            return false;
        }
        return true;
    }

    public void setStatusBarKeyguardViewManager(
            StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
    }

    public interface Listener {
        void onDynamicPrivacyChanged();
    }
+40 −1
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
     */
    private static final int DISTANCE_BETWEEN_ADJACENT_SECTIONS_PX = 1;
    private final KeyguardBypassController mKeyguardBypassController;
    private final DynamicPrivacyController mDynamicPrivacyController;
    private final SysuiStatusBarStateController mStatusbarStateController;

    private ExpandHelper mExpandHelper;
    private final NotificationSwipeHelper mSwipeHelper;
@@ -605,6 +607,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            }
        });
        dynamicPrivacyController.addListener(this);
        mDynamicPrivacyController = dynamicPrivacyController;
        mStatusbarStateController = (SysuiStatusBarStateController) statusBarStateController;
    }

    private void updateDismissRtlSetting(boolean dismissRtl) {
@@ -695,6 +699,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
     */
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public boolean hasActiveClearableNotifications(@SelectedRows int selection) {
        if (mDynamicPrivacyController.isInLockedDownShade()) {
            return false;
        }
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
@@ -5700,7 +5707,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            mAnimateBottomOnLayout = true;
        }
        // Let's update the footer once the notifications have been updated (in the next frame)
        post(this::updateFooter);
        post(() -> {
            updateFooter();
            updateSectionBoundaries();
        });
    }

    public void setOnPulseHeightChangedListener(Runnable listener) {
@@ -6356,6 +6366,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                }

                return true;
            } else if (mDynamicPrivacyController.isInLockedDownShade()) {
                mStatusbarStateController.setLeaveOpenOnKeyguardHide(true);
                mStatusBar.dismissKeyguardThenExecute(() -> false /* dismissAction */,
                        null /* cancelRunnable */, false /* afterKeyguardGone */);
                return true;
            } else {
                // abort gesture.
                return false;
@@ -6389,6 +6404,30 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        public boolean isFalsingCheckNeeded() {
            return mStatusBarState == StatusBarState.KEYGUARD;
        }

        @Override
        public boolean isDragDownEnabledForView(ExpandableView view) {
            if (isDragDownAnywhereEnabled()) {
                return true;
            }
            if (mDynamicPrivacyController.isInLockedDownShade()) {
                if (view == null) {
                    // Dragging down is allowed in general
                    return true;
                }
                if (view instanceof ExpandableNotificationRow) {
                    // Only drag down on sensitive views, otherwise the ExpandHelper will take this
                    return ((ExpandableNotificationRow) view).getEntry().isSensitive();
                }
            }
            return false;
        }

        @Override
        public boolean isDragDownAnywhereEnabled() {
            return mStatusbarStateController.getState() == StatusBarState.KEYGUARD
                    && !mKeyguardBypassController.getBypassEnabled();
        }
    };

    public DragDownCallback getDragDownCallback() { return mDragDownCallback; }
+6 −2
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.NotificationAlertingManager;
import com.android.systemui.statusbar.notification.NotificationClicker;
@@ -376,6 +377,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    @Inject
    protected HeadsUpManagerPhone mHeadsUpManager;
    @Inject
    DynamicPrivacyController mDynamicPrivacyController;
    @Inject
    BypassHeadsUpNotifier mBypassHeadsUpNotifier;
    @Nullable
    @Inject
@@ -592,7 +595,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private boolean mVibrateOnOpening;
    private VibratorHelper mVibratorHelper;
    private ActivityLaunchAnimator mActivityLaunchAnimator;
    protected NotificationPresenter mPresenter;
    protected StatusBarNotificationPresenter mPresenter;
    private NotificationActivityStarter mNotificationActivityStarter;
    private boolean mPulsing;
    protected BubbleController mBubbleController;
@@ -1067,7 +1070,7 @@ public class StatusBar extends SystemUI implements DemoMode,

        mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanel,
                mHeadsUpManager, mStatusBarWindow, mStackScroller, mDozeScrimController,
                mScrimController, mActivityLaunchAnimator, mStatusBarKeyguardViewManager,
                mScrimController, mActivityLaunchAnimator, mDynamicPrivacyController,
                mNotificationAlertingManager, rowBinder);

        mNotificationListController =
@@ -1244,6 +1247,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
        mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
        mRemoteInputManager.getController().addCallback(mStatusBarKeyguardViewManager);
        mDynamicPrivacyController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);

        mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
        mLightBarController.setBiometricUnlockController(mBiometricUnlockController);
Loading