Add null check to sendCustomAccessibilityEvent()
ag/10273975 caused a regression where launcher crashes if RecentsView is
empty.
Change-Id: I1607627be0a9748fd552adc757296d7b6bbfd1e2
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index db4bef0..1d32d1d 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -40,8 +40,16 @@
return isAccessibilityEnabled(context);
}
- public static void sendCustomAccessibilityEvent(View target, int type, @Nullable String text) {
- if (isObservedEventType(target.getContext(), type)) {
+ /**
+ *
+ * @param target The view the accessibility event is initialized on.
+ * If null, this method has no effect.
+ * @param type See TYPE_ constants defined in {@link AccessibilityEvent}.
+ * @param text Optional text to add to the event, which will be announced to the user.
+ */
+ public static void sendCustomAccessibilityEvent(@Nullable View target, int type,
+ @Nullable String text) {
+ if (target != null && isObservedEventType(target.getContext(), type)) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
target.onInitializeAccessibilityEvent(event);
if (!TextUtils.isEmpty(text)) {