Merge "Fix SysUI NPE crash during the boot/init progress" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-22 07:27:24 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 1 deletions

View File

@@ -482,7 +482,9 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
@VisibleForTesting
void notifyExpandNotification() {
mMainExecutor.execute(() -> mEventCallback.notifyExpandNotification());
if (mEventCallback != null) {
mMainExecutor.execute(() -> mEventCallback.notifyExpandNotification());
}
}
@VisibleForTesting

View File

@@ -435,4 +435,17 @@ public class OneHandedControllerTest extends OneHandedTestCase {
verify(mSpiedOneHandedController).notifyShortcutState(anyInt());
}
@Test
public void testNotifyExpandNotification_withNullCheckProtection() {
when(mSpiedOneHandedController.isOneHandedEnabled()).thenReturn(false);
when(mSpiedTransitionState.getState()).thenReturn(STATE_NONE);
when(mSpiedTransitionState.isTransitioning()).thenReturn(false);
when(mSpiedOneHandedController.isSwipeToNotificationEnabled()).thenReturn(true);
mSpiedOneHandedController.setOneHandedEnabled(true);
mSpiedOneHandedController.notifyExpandNotification();
// Verify no NPE crash and mMockShellMainExecutor never be execute.
verify(mMockShellMainExecutor, never()).execute(any());
}
}