From 0dbdccd2aa0e6828e1332adf83e630a74527a248 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 26 Jun 2015 18:48:14 -0700 Subject: Correctly handle accessibility for incoming/outgoing calls The previous behavior relied on WINDOW_STATE_CHANGED events to announce outgoing/incoming calls, at which point in time the CallCardFragment was not guaranteed to be non-null. Bug: 20172391 Change-Id: I65bf86bc1a5edf5430ae5aabcb3535f42d1ccb08 --- .../src/com/android/incallui/CallCardFragment.java | 35 +++++++++++++++------- .../com/android/incallui/CallCardPresenter.java | 21 +++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 02a1802cf..d58310cfc 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -42,6 +42,7 @@ import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageButton; @@ -92,6 +93,13 @@ public class CallCardFragment extends BaseFragment // Hide the end call button instantly if we're receiving an incoming call. getUi().setEndCallButtonEnabled(shouldShowEndCallButton(mPrimary, callState), callState != Call.State.INCOMING /* animate */); + + maybeSendAccessibilityEvent(oldState, newState); } @Override @@ -828,6 +831,23 @@ public class CallCardPresenter extends Presenter return true; } + private void maybeSendAccessibilityEvent(InCallState oldState, InCallState newState) { + if (mContext == null) { + return; + } + final AccessibilityManager am = (AccessibilityManager) mContext.getSystemService( + Context.ACCESSIBILITY_SERVICE); + if (!am.isEnabled()) { + return; + } + if ((oldState != InCallState.OUTGOING && newState == InCallState.OUTGOING) + || (oldState != InCallState.INCOMING && newState == InCallState.INCOMING)) { + if (getUi() != null) { + getUi().sendAccessibilityAnnouncement(); + } + } + } + public interface CallCardUi extends Ui { void setVisible(boolean on); void setCallCardVisible(boolean visible); @@ -851,5 +871,6 @@ public class CallCardPresenter extends Presenter void showManageConferenceCallButton(boolean visible); boolean isManageConferenceVisible(); void animateForNewOutgoingCall(); + void sendAccessibilityAnnouncement(); } } -- cgit v1.2.3