From 63e4503991b52862efb17d42950d986dca90976b Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Thu, 11 May 2017 10:54:37 -0700 Subject: [PATCH] Add null check to a11y call. No good will come from posting that a null View has changed. Adding a null check so the failure will happen when the bad call is made, rather than later when we try to act on it in a handler. Bug: 38122973 Test: Ran accessibility unit and cts tests. Change-Id: I1e9aaf2a18180fcdfd0fbc0e5b716eb96446af33 --- core/java/android/view/ViewParent.java | 5 +++-- core/java/android/view/ViewRootImpl.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java index cc11cb8205d5d..572e69b1a78c4 100644 --- a/core/java/android/view/ViewParent.java +++ b/core/java/android/view/ViewParent.java @@ -402,7 +402,7 @@ public interface ViewParent { * descendants has changed and that the structure of the subtree is * different. * @param child The direct child whose subtree has changed. - * @param source The descendant view that changed. + * @param source The descendant view that changed. May not be {@code null}. * @param changeType A bit mask of the types of changes that occurred. One * or more of: * */ - public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType); + public void notifySubtreeAccessibilityStateChanged( + View child, @NonNull View source, int changeType); /** * Tells if this view parent can resolve the layout direction. diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 1f13220289c21..109cac0bab126 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -98,6 +98,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.os.IResultReceiver; import com.android.internal.os.SomeArgs; import com.android.internal.policy.PhoneFallbackEventHandler; +import com.android.internal.util.Preconditions; import com.android.internal.view.BaseSurfaceHolder; import com.android.internal.view.RootViewSurfaceTaker; import com.android.internal.view.SurfaceCallbackHelper; @@ -7195,7 +7196,7 @@ public final class ViewRootImpl implements ViewParent, @Override public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType) { - postSendWindowContentChangedCallback(source, changeType); + postSendWindowContentChangedCallback(Preconditions.checkNotNull(source), changeType); } @Override