diff options
author | Qi Wang <wangqi@google.com> | 2016-04-22 21:44:15 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-22 21:44:15 +0000 |
commit | 08276eeb1f121b06c65c6e6b837e6fc6655d2e63 (patch) | |
tree | dcc095eaa54a6bd31637b7ca01bab0370e07b3b6 | |
parent | 9b99a1d83194666a3e134f7a53401060604b15f3 (diff) | |
parent | fe3157c3143c19375dbcf68e6876ef8bd8191f26 (diff) |
Fix crash on accessibility service. am: 02bf9ac
am: fe3157c
* commit 'fe3157c3143c19375dbcf68e6876ef8bd8191f26':
Fix crash on accessibility service.
Change-Id: I7f1f1b4bde2bea0ff2b00b1330a5c4b8a9a367ba
-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); } |