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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15052835

Change-Id: Iab832312eaa2af14c0c767163b2f1bc52871192c
This commit is contained in:
TreeHugger Robot
2021-06-22 07:40:36 +00:00
committed by Automerger Merge Worker
2 changed files with 16 additions and 1 deletions

View File

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

View File

@@ -435,4 +435,17 @@ public class OneHandedControllerTest extends OneHandedTestCase {
verify(mSpiedOneHandedController).notifyShortcutState(anyInt()); 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());
}
} }