From 6ce4a30b1cd643ee12194b1716e2abfea6f695df Mon Sep 17 00:00:00 2001 From: Yining Liu Date: Tue, 7 Jan 2025 22:30:25 +0000 Subject: Improve accessibility for notification shelf on lock screen We added the "Expand" action before to make it clear that the user can expand the Shelf. But the action didn't have any affect at the time of addition. This change links the action to the clicking action, which expands the notification shade. Note that both click and expand actions have the same effect, which is as intended. Fix: 378385684 Flag: EXEMPT bugfix Test: atest Manual, disable "Auto-select" for the Switch Access and enable Switch Access, select the NotificationShelf on lockscreen. The action "Expand" should expand the notification shade. Change-Id: I5b020dbe7c4d79b24b869eb6209b4a59852ba323 --- .../systemui/statusbar/NotificationShelf.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 48cf7a83c324..155049f512d8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; +import android.os.Bundle; import android.util.AttributeSet; import android.util.IndentingPrintWriter; import android.util.MathUtils; @@ -30,6 +31,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; @@ -1014,12 +1016,24 @@ public class NotificationShelf extends ActivatableNotificationView { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (mInteractive) { + // Add two accessibility actions that both performs expanding the notification shade info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); - AccessibilityNodeInfo.AccessibilityAction unlock - = new AccessibilityNodeInfo.AccessibilityAction( + + AccessibilityAction seeAll = new AccessibilityAction( AccessibilityNodeInfo.ACTION_CLICK, - getContext().getString(R.string.accessibility_overflow_action)); - info.addAction(unlock); + getContext().getString(R.string.accessibility_overflow_action) + ); + info.addAction(seeAll); + } + } + + @Override + public boolean performAccessibilityAction(int action, Bundle args) { + // override ACTION_EXPAND with ACTION_CLICK + if (action == AccessibilityNodeInfo.ACTION_EXPAND) { + return super.performAccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, args); + } else { + return super.performAccessibilityAction(action, args); } } -- cgit v1.2.3-59-g8ed1b