diff options
author | Qi Wang <wangqi@google.com> | 2016-04-14 17:40:23 -0700 |
---|---|---|
committer | Usman Abdullah <uabdullah@google.com> | 2016-04-20 17:44:03 +0000 |
commit | 02bf9ac96cc3cc63c1ddd8cad76bdd92b07b1f6b (patch) | |
tree | 0f9083fd682cdb8ee809db0288f500fccffcb36f /InCallUI/src/com | |
parent | d0db4f8941e13766b78c90432b92b4eaccf71e2c (diff) |
Fix crash on accessibility service.
Change-Id: If35d4744c3ada3a3d0ae6063dd1150e309ee5c59
Fix: 27926006
(cherry picked from commit e61465686d1ee1be8297c1e758c63ca0bff8ef47)
Diffstat (limited to 'InCallUI/src/com')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 785d3d3aa..39dd5eae2 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -45,6 +45,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; @@ -1154,13 +1155,21 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mHandler.postDelayed(new Runnable() { @Override public void run() { - if (getView() != null && getView().getParent() != null) { + if (getView() != null && getView().getParent() != null && + isAccessibilityEnabled(getContext())) { AccessibilityEvent event = AccessibilityEvent.obtain( AccessibilityEvent.TYPE_ANNOUNCEMENT); dispatchPopulateAccessibilityEvent(event); getView().getParent().requestSendAccessibilityEvent(getView(), event); } } + + private boolean isAccessibilityEnabled(Context context) { + AccessibilityManager accessibilityManager = + (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); + return accessibilityManager != null && accessibilityManager.isEnabled(); + + } }, ACCESSIBILITY_ANNOUNCEMENT_DELAY_MS); } |