diff options
author | Qi Wang <wangqi@google.com> | 2016-04-22 21:41:04 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-22 21:41:04 +0000 |
commit | fe3157c3143c19375dbcf68e6876ef8bd8191f26 (patch) | |
tree | dcc095eaa54a6bd31637b7ca01bab0370e07b3b6 /InCallUI | |
parent | 9b99a1d83194666a3e134f7a53401060604b15f3 (diff) | |
parent | 02bf9ac96cc3cc63c1ddd8cad76bdd92b07b1f6b (diff) |
Fix crash on accessibility service.
am: 02bf9ac
* commit '02bf9ac96cc3cc63c1ddd8cad76bdd92b07b1f6b':
Fix crash on accessibility service.
Change-Id: I1bc0fdcf1055bf162bb18a6b0ed152ba1ab7604c
Diffstat (limited to 'InCallUI')
-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); } |