diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index 3b8368380ddad..d80d2300dbce4 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -605,7 +605,10 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par /** * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: * state description of the node as returned by - * {@link AccessibilityNodeInfo#getStateDescription} changed. + * {@link AccessibilityNodeInfo#getStateDescription} changed. If part of the state description + * changes, the changed part can be put into event text. For example, if state description + * changed from "on, wifi signal full" to "on, wifi three bars", "wifi three bars" can be put + * into the event text. */ public static final int CONTENT_CHANGE_TYPE_STATE_DESCRIPTION = 0x00000040; diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java index 8feee10c7e834..314b4425efb57 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java @@ -13,6 +13,8 @@ */ package com.android.systemui.qs.tileimpl; +import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_STATE_DESCRIPTION; + import static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH; import android.animation.ValueAnimator; @@ -73,6 +75,10 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { private int mCircleColor; private int mBgSize; + private static final int INVALID = -1; + private CharSequence mStateDescriptionDeltas = null; + private CharSequence mLastStateDescription; + private int mLastState = INVALID; public QSTileBaseView(Context context, QSIconView icon) { this(context, icon, false); @@ -250,8 +256,14 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { if (!TextUtils.isEmpty(state.stateDescription)) { stateDescription.append(", "); stateDescription.append(state.stateDescription); + if (mLastState != INVALID && state.state == mLastState + && !state.stateDescription.equals(mLastStateDescription)) { + mStateDescriptionDeltas = state.stateDescription; + } } setStateDescription(stateDescription.toString()); + mLastState = state.state; + mLastStateDescription = state.stateDescription; mAccessibilityClass = state.state == Tile.STATE_UNAVAILABLE ? null : state.expandedAccessibilityClassName; @@ -314,6 +326,11 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { if (!TextUtils.isEmpty(mAccessibilityClass)) { event.setClassName(mAccessibilityClass); } + if (event.getContentChangeTypes() == CONTENT_CHANGE_TYPE_STATE_DESCRIPTION + && mStateDescriptionDeltas != null) { + event.getText().add(mStateDescriptionDeltas); + mStateDescriptionDeltas = null; + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index 361b6c1b12600..cf82ed194241b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -134,7 +134,8 @@ public class BluetoothTile extends QSTileImpl { state.label = mContext.getString(R.string.quick_settings_bluetooth_label); state.secondaryLabel = TextUtils.emptyIfNull( getSecondaryLabel(enabled, connecting, connected, state.isTransient)); - state.contentDescription = state.label; + state.contentDescription = mContext.getString( + R.string.accessibility_quick_settings_bluetooth); state.stateDescription = ""; if (enabled) { if (connected) { @@ -152,15 +153,11 @@ public class BluetoothTile extends QSTileImpl { } else { state.icon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_bluetooth); - state.contentDescription = mContext.getString( - R.string.accessibility_quick_settings_bluetooth); state.stateDescription = mContext.getString(R.string.accessibility_not_connected); } state.state = Tile.STATE_ACTIVE; } else { state.icon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_bluetooth); - state.contentDescription = mContext.getString( - R.string.accessibility_quick_settings_bluetooth); state.state = Tile.STATE_INACTIVE; }