Add NPE check for refreshUi
The reason for NPE is that callback is registered too early, so one callback is invoked before controller is fully inited. This cl fix it in two ways: 1. Add NPE check in refreshUi, since this method in InstalledAppDetail is robost to NPE 2. Move the callback to the end of constructor. Bug: 37913054 Test: RunSettingsRoboTests Change-Id: I54b03fb51a958a8e63bfe8a7ccfda79be1fa1956
This commit is contained in:
@@ -344,6 +344,14 @@ public class AppButtonsPreferenceControllerTest {
|
||||
assertThat(controllable).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshUi_packageNull_shouldNotCrash() {
|
||||
mController.mPackageName = null;
|
||||
|
||||
// Should not crash in this method
|
||||
assertThat(mController.refreshUi()).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* The test fragment which implements
|
||||
* {@link ButtonActionDialogFragment.AppButtonsDialogListener}
|
||||
|
Reference in New Issue
Block a user