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
This commit is contained in:
Selim Cinek
2018-02-22 09:39:41 -08:00
parent 3d529f764e
commit bdbf458844
2 changed files with 8 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}