From 8583ae8a6af11bedbb00a4eb9efd2565da2fecbb Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Tue, 13 Feb 2018 11:01:24 -0800 Subject: Add a11y titles for a few sysui windows Adding for status bar, nav bar, and global actions dialog. Also removing some extra code from global actions dialog that populated window state changes. Apps in general don't need this extra information, so we don't need to maintain it in SysUi either. In verifying the fix, I noticed that all windows were considered anchored because of a mismatch between long and int. Fixing that too. Bug: 73131182 Test: With the testback a11y service, verified that these titles do indeed appear in the window information provided to accessibility services. Also noted that windows are no longer reporting themselves as anchored. Change-Id: Ie09fbb88250b3c9663d6c28001e0ce9f70c67954 --- core/java/android/view/WindowInfo.java | 7 ++++--- core/java/android/view/WindowManager.java | 7 ++++--- core/res/res/values/symbols.xml | 1 + .../systemui/globalactions/GlobalActionsDialog.java | 15 +-------------- .../systemui/statusbar/phone/NavigationBarFragment.java | 1 + .../systemui/statusbar/phone/StatusBarWindowManager.java | 1 + 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/core/java/android/view/WindowInfo.java b/core/java/android/view/WindowInfo.java index bb9e391ddcb4..7bae28a4e817 100644 --- a/core/java/android/view/WindowInfo.java +++ b/core/java/android/view/WindowInfo.java @@ -21,6 +21,7 @@ import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; import android.util.Pools; +import android.view.accessibility.AccessibilityNodeInfo; import java.util.ArrayList; import java.util.List; @@ -46,7 +47,7 @@ public class WindowInfo implements Parcelable { public final Rect boundsInScreen = new Rect(); public List childTokens; public CharSequence title; - public int accessibilityIdOfAnchor = View.NO_ID; + public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; public boolean inPictureInPicture; private WindowInfo() { @@ -105,7 +106,7 @@ public class WindowInfo implements Parcelable { parcel.writeInt(focused ? 1 : 0); boundsInScreen.writeToParcel(parcel, flags); parcel.writeCharSequence(title); - parcel.writeInt(accessibilityIdOfAnchor); + parcel.writeLong(accessibilityIdOfAnchor); parcel.writeInt(inPictureInPicture ? 1 : 0); if (childTokens != null && !childTokens.isEmpty()) { @@ -142,7 +143,7 @@ public class WindowInfo implements Parcelable { focused = (parcel.readInt() == 1); boundsInScreen.readFromParcel(parcel); title = parcel.readCharSequence(); - accessibilityIdOfAnchor = parcel.readInt(); + accessibilityIdOfAnchor = parcel.readLong(); inPictureInPicture = (parcel.readInt() == 1); final boolean hasChildren = (parcel.readInt() == 1); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 1c5e87197750..c0a966602b0a 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -63,6 +63,7 @@ import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; import android.util.proto.ProtoOutputStream; +import android.view.accessibility.AccessibilityNodeInfo; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -2344,7 +2345,7 @@ public interface WindowManager extends ViewManager { * * @hide */ - public int accessibilityIdOfAnchor = -1; + public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; /** * The window title isn't kept in sync with what is displayed in the title bar, so we @@ -2538,7 +2539,7 @@ public interface WindowManager extends ViewManager { out.writeInt(hasManualSurfaceInsets ? 1 : 0); out.writeInt(preservePreviousSurfaceInsets ? 1 : 0); out.writeInt(needsMenuKey); - out.writeInt(accessibilityIdOfAnchor); + out.writeLong(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeInt(mColorMode); out.writeLong(hideTimeoutMilliseconds); @@ -2594,7 +2595,7 @@ public interface WindowManager extends ViewManager { hasManualSurfaceInsets = in.readInt() != 0; preservePreviousSurfaceInsets = in.readInt() != 0; needsMenuKey = in.readInt(); - accessibilityIdOfAnchor = in.readInt(); + accessibilityIdOfAnchor = in.readLong(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mColorMode = in.readInt(); hideTimeoutMilliseconds = in.readLong(); diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ca698ef2b55b..30e826b11443 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1716,6 +1716,7 @@ + diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index c28b7eed1614..1aea5e7f4a80 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -1369,6 +1369,7 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, mListView = findViewById(android.R.id.list); mHardwareLayout = HardwareUiLayout.get(mListView); mHardwareLayout.setOutsideTouchListener(view -> dismiss()); + setTitle(R.string.global_actions); } private void updateList() { @@ -1463,20 +1464,6 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, com.android.systemui.R.dimen.global_actions_panel_width) / 2; } - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - for (int i = 0; i < mAdapter.getCount(); ++i) { - CharSequence label = - mAdapter.getItem(i).getLabelForAccessibility(getContext()); - if (label != null) { - event.getText().add(label); - } - } - } - return super.dispatchPopulateAccessibilityEvent(event); - } - @Override public void onColorsChanged(ColorExtractor extractor, int which) { if (mKeyguardShowing) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 1239a9ea0240..2a0cb21363a4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -960,6 +960,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks { PixelFormat.TRANSLUCENT); lp.token = new Binder(); lp.setTitle("NavigationBar"); + lp.accessibilityTitle = context.getString(R.string.nav_bar); lp.windowAnimations = 0; View navigationBarView = LayoutInflater.from(context).inflate( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java index c30f6339f8da..948f524bb188 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java @@ -106,6 +106,7 @@ public class StatusBarWindowManager implements RemoteInputController.Callback, D mLp.gravity = Gravity.TOP; mLp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; mLp.setTitle("StatusBar"); + mLp.accessibilityTitle = mContext.getString(R.string.status_bar); mLp.packageName = mContext.getPackageName(); mStatusBarView = statusBarView; mBarHeight = barHeight; -- cgit v1.2.3-59-g8ed1b