diff options
author | Qi Wang <wangqi@google.com> | 2016-04-22 22:15:57 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-22 22:15:57 +0000 |
commit | 4dfe1be35b1736aa7398c7774ad6c111e65a0b3a (patch) | |
tree | 73cb9e4ff54d43e06b97ce7a271b386cf5bf0ef7 /InCallUI/src | |
parent | dabf0ae37eb37eede35e767924ed720ad9defa4a (diff) | |
parent | 08276eeb1f121b06c65c6e6b837e6fc6655d2e63 (diff) |
Fix crash on accessibility service. am: 02bf9ac am: fe3157c
am: 08276ee
* commit '08276eeb1f121b06c65c6e6b837e6fc6655d2e63':
Fix crash on accessibility service.
Change-Id: I0499acc592278242cf8625d59cd7c071b9958002
Diffstat (limited to 'InCallUI/src')
-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 54b37e578..506feb572 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; @@ -1156,13 +1157,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); } |