From 7d847b037525075cdff92d5e52665d9a9761a8e9 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Tue, 13 Feb 2018 16:02:35 -0800 Subject: [PATCH] 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 --- core/java/android/view/View.java | 2 +- core/res/res/values/strings.xml | 4 ++++ core/res/res/values/symbols.xml | 5 +++++ .../com/android/keyguard/KeyguardHostView.java | 14 ++++---------- .../android/keyguard/KeyguardPasswordView.java | 6 ++++++ .../com/android/keyguard/KeyguardPatternView.java | 6 ++++++ .../keyguard/KeyguardPinBasedInputView.java | 6 ++++++ .../keyguard/KeyguardSecurityContainer.java | 15 ++------------- .../android/keyguard/KeyguardSecurityView.java | 8 ++++++++ .../keyguard/KeyguardSecurityViewFlipper.java | 9 +++++++++ .../com/android/keyguard/KeyguardSimPinView.java | 6 ++++++ .../com/android/keyguard/KeyguardSimPukView.java | 6 ++++++ .../systemui/statusbar/phone/KeyguardBouncer.java | 2 +- 13 files changed, 64 insertions(+), 25 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2af2467588125..9db84b6e3ac04 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -7309,7 +7309,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } private boolean isAccessibilityPane() { - return !TextUtils.isEmpty(mAccessibilityPaneTitle); + return mAccessibilityPaneTitle != null; } /** diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index ec81df7b89e21..f692df7c368b2 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -2104,6 +2104,10 @@ Face unlock. Pin unlock. + + Sim Pin unlock. + + Sim Puk unlock. Password unlock. diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index a86f58a526858..e37a57616b602 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3226,6 +3226,11 @@ + + + + + diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java index f1a5ca9fba937..474fc90a1c3f6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java @@ -197,16 +197,6 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback { 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 class KeyguardHostView extends FrameLayout implements SecurityCallback { } } + 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 ff5f5e77b3f91..75c52d8ead659 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java @@ -361,4 +361,10 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView } 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 cb066a10a9c94..651831eea5173 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java @@ -491,4 +491,10 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit 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 6539ccffc61b8..1d3f9a13c631a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java @@ -252,4 +252,10 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView } 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 8dc4609f1b9db..c3413d9d76bb3 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -119,19 +119,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe 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 360dba3bc0ea3..6e445ff0e26d2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityView.java @@ -127,4 +127,12 @@ public interface KeyguardSecurityView { * 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 a2ff8f7896aae..3aede569147a7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java @@ -172,6 +172,15 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard } } + @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 703b20531390a..c71c433bb0163 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java @@ -390,5 +390,11 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { 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 347c9792ec95b..1b61568276ce6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -460,6 +460,12 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { 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 699e8cf145bce..380c08eb17382 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 @@ public class KeyguardBouncer { mKeyguardView.requestLayout(); } mShowingSoon = false; - mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } }; @@ -264,6 +263,7 @@ public class KeyguardBouncer { 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) {