diff options
author | Qi Wang <wangqi@google.com> | 2016-04-22 21:41:05 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-22 21:41:05 +0000 |
commit | 06bc5dad0dfd46e4506228f129f2f7da3b14142a (patch) | |
tree | 0f9083fd682cdb8ee809db0288f500fccffcb36f | |
parent | d0db4f8941e13766b78c90432b92b4eaccf71e2c (diff) | |
parent | 02bf9ac96cc3cc63c1ddd8cad76bdd92b07b1f6b (diff) |
Fix crash on accessibility service.
am: 02bf9ac
* commit '02bf9ac96cc3cc63c1ddd8cad76bdd92b07b1f6b':
Fix crash on accessibility service.
Change-Id: I339401055726ec1510ef99563154db26f6b024ce
-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); } |