From df8a24d96685db845592e035674b137155a91752 Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Thu, 19 Jan 2023 19:07:30 +0000 Subject: [PATCH] Make Notification long clickable Our ENR View is not marked long-clickable in terms of accessibility( see b/264948201 ). It does not mean that the view is not long clickable. Currently ENR handles long click from both interaction and accessibility perspective. It is always on in terms of accessibility. However, it is not marked as long-clickable. This PR marks AccessibilityNode info long clickable in terms of accessibility according to Notification State(Notification View, GUT and LeaveBehind). Address the NotificationSnooze integration test to verify this change. Test: atest PlatformScenarioTests:android.platform.test.scenario.sysui.notification.NotificationSnooze Bug: b/264948201 Change-Id: I713f103149c53d694193aaeef5dc309efe3f322e --- .../row/ExpandableNotificationRow.java | 27 ++++++++++++++++++- .../row/NotificationGutsManager.java | 4 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 9275e2b603c3d..64c1a595483e6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -1196,6 +1196,22 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return getShowingLayout().getVisibleWrapper(); } + /** + * @return whether the notification row is long clickable or not. + */ + public boolean isNotificationRowLongClickable() { + if (mLongPressListener == null) { + return false; + } + + if (!areGutsExposed()) { // guts is not opened + return true; + } + + // if it is leave behind, it shouldn't be long clickable. + return !isGutsLeaveBehind(); + } + public void setLongPressListener(LongPressListener longPressListener) { mLongPressListener = longPressListener; } @@ -2947,6 +2963,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return (mGuts != null && mGuts.isExposed()); } + private boolean isGutsLeaveBehind() { + return (mGuts != null && mGuts.isLeavebehind()); + } + @Override public boolean isContentExpandable() { if (mIsSummaryWithChildren && !shouldShowPublic()) { @@ -3394,7 +3414,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK); + final boolean isLongClickable = isNotificationRowLongClickable(); + if (isLongClickable) { + info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK); + } + info.setLongClickable(isLongClickable); + if (canViewBeDismissed() && !mIsSnoozed) { info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 37ff11db81e3f..06d40803052ea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -586,7 +586,9 @@ public class NotificationGutsManager implements NotifGutsViewManager { } final ExpandableNotificationRow row = (ExpandableNotificationRow) view; - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + if (row.isNotificationRowLongClickable()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } if (row.areGutsExposed()) { closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */,