Use accessibility pane API in keyguard
Using the new accessibility pane title API
to identify the pattern, pin, and password unlock
screens.
Bug: 73131182
Test: Verified that accessibility events are properly
sent when unlocking the phone with each of the lock
methods.
Change-Id: I32594f4736b503e7f9e3be96e9f77a84ffcadc54
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
index f1a5ca9..474fc90 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
@@ -197,16 +197,6 @@
return false;
}
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
- event.getText().add(mSecurityContainer.getCurrentSecurityModeContentDescription());
- return true;
- } else {
- return super.dispatchPopulateAccessibilityEvent(event);
- }
- }
-
protected KeyguardSecurityContainer getSecurityContainer() {
return mSecurityContainer;
}
@@ -255,6 +245,10 @@
}
}
+ public CharSequence getAccessibilityTitleForCurrentMode() {
+ return mSecurityContainer.getTitle();
+ }
+
public void userActivity() {
if (mViewMediatorCallback != null) {
mViewMediatorCallback.userActivity();
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
index ff5f5e7..75c52d8 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
@@ -361,4 +361,10 @@
}
return false;
}
+
+ @Override
+ public CharSequence getTitle() {
+ return getContext().getString(
+ com.android.internal.R.string.keyguard_accessibility_password_unlock);
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
index cb066a1..651831e 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
@@ -491,4 +491,10 @@
public boolean hasOverlappingRendering() {
return false;
}
+
+ @Override
+ public CharSequence getTitle() {
+ return getContext().getString(
+ com.android.internal.R.string.keyguard_accessibility_pattern_unlock);
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
index 6539ccf..1d3f9a1 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -252,4 +252,10 @@
}
return false;
}
+
+ @Override
+ public CharSequence getTitle() {
+ return getContext().getString(
+ com.android.internal.R.string.keyguard_accessibility_pin_unlock);
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index 8dc4609..c3413d9 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -119,19 +119,8 @@
return false;
}
- public void announceCurrentSecurityMethod() {
- View v = (View) getSecurityView(mCurrentSecuritySelection);
- if (v != null) {
- v.announceForAccessibility(v.getContentDescription());
- }
- }
-
- public CharSequence getCurrentSecurityModeContentDescription() {
- View v = (View) getSecurityView(mCurrentSecuritySelection);
- if (v != null) {
- return v.getContentDescription();
- }
- return "";
+ public CharSequence getTitle() {
+ return mSecurityViewFlipper.getTitle();
}
private KeyguardSecurityView getSecurityView(SecurityMode securityMode) {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java
index 360dba3b..6e445ff 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java
@@ -127,4 +127,12 @@
* animation started and {@code finishRunnable} will not be run
*/
boolean startDisappearAnimation(Runnable finishRunnable);
+
+ /**
+ * The localized name of the security view, provided to accessibility. This may be the content
+ * description, but content descriptions have other implications, so the title is kept separate.
+ *
+ * @return The View's title.
+ */
+ CharSequence getTitle();
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
index a2ff8f7..3aede56 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
@@ -173,6 +173,15 @@
}
@Override
+ public CharSequence getTitle() {
+ KeyguardSecurityView ksv = getSecurityView();
+ if (ksv != null) {
+ return ksv.getTitle();
+ }
+ return "";
+ }
+
+ @Override
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
return p instanceof LayoutParams;
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index 703b205..c71c433 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -390,5 +390,11 @@
public boolean startDisappearAnimation(Runnable finishRunnable) {
return false;
}
+
+ @Override
+ public CharSequence getTitle() {
+ return getContext().getString(
+ com.android.internal.R.string.keyguard_accessibility_sim_pin_unlock);
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index 347c979..1b61568 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
@@ -460,6 +460,12 @@
public boolean startDisappearAnimation(Runnable finishRunnable) {
return false;
}
+
+ @Override
+ public CharSequence getTitle() {
+ return getContext().getString(
+ com.android.internal.R.string.keyguard_accessibility_sim_puk_unlock);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index 699e8cf..380c08e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -152,7 +152,6 @@
mKeyguardView.requestLayout();
}
mShowingSoon = false;
- mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
};
@@ -264,6 +263,7 @@
mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset(
com.android.systemui.R.dimen.status_bar_height);
mRoot.setVisibility(View.INVISIBLE);
+ mRoot.setAccessibilityPaneTitle(mKeyguardView.getAccessibilityTitleForCurrentMode());
final WindowInsets rootInsets = mRoot.getRootWindowInsets();
if (rootInsets != null) {