From bdbf458844e07b9af57e2f707cce24de126d27d1 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 22 Feb 2018 09:39:41 -0800 Subject: [PATCH] Fixed a NP when replying to a message The visbilityChanged listener is only set up later, so we'll have to add a nullcheck for it. Change-Id: I1f5843f02fd9c8fc20e26f1de47911e5eb533471 Fixes: 73758799 Test: runtest -x packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java --- .../android/systemui/statusbar/policy/RemoteInputView.java | 2 +- .../systemui/statusbar/policy/RemoteInputViewTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index d74a59e75933b..a794e1977891f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -461,7 +461,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene @Override protected void onVisibilityChanged(View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); - if (changedView == this) { + if (changedView == this && mOnVisibilityChangedListener != null) { mOnVisibilityChangedListener.accept(visibility == VISIBLE); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java index 63920a4f36e27..7d4d31e348650 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java @@ -24,6 +24,7 @@ import android.content.pm.ShortcutManager; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; +import android.view.View; import android.widget.EditText; import android.widget.ImageButton; @@ -88,4 +89,10 @@ public class RemoteInputViewTest extends SysuiTestCase { assertEquals(RemoteInput.SOURCE_FREE_FORM_INPUT, RemoteInput.getResultsSource(resultIntent)); } + + @Test + public void testNoCrashWithoutVisibilityListener() { + mView.setOnVisibilityChangedListener(null); + mView.onVisibilityChanged(mView, View.VISIBLE); + } }