Loading services/core/java/com/android/server/display/DisplayPowerController.java +5 −0 Original line number Diff line number Diff line Loading @@ -906,6 +906,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mLogicalDisplay.getPowerThrottlingDataIdLocked(); mHandler.postAtTime(() -> { if (mStopped) { // DPC has already stopped, don't execute any more. return; } boolean changed = false; if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) { Loading services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -2471,6 +2471,26 @@ public final class DisplayPowerControllerTest { eq(false)); } @Test public void onDisplayChange_canceledAfterStop() { mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID); // stop the dpc (turn it down) mHolder.dpc.stop(); advanceTime(1); // To trigger all the changes that can happen, we will completely change the underlying // display device. setUpDisplay(DISPLAY_ID, "new_unique_id", mHolder.display, mock(DisplayDevice.class), mock(DisplayDeviceConfig.class), /* isEnabled= */ true); // Call onDisplayChange after we stopped DPC and make sure it doesn't crash mHolder.dpc.onDisplayChanged(mHolder.hbmMetadata, Layout.NO_LEAD_DISPLAY); advanceTime(1); // No crash = success } /** * Creates a mock and registers it to {@link LocalServices}. */ Loading Loading
services/core/java/com/android/server/display/DisplayPowerController.java +5 −0 Original line number Diff line number Diff line Loading @@ -906,6 +906,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mLogicalDisplay.getPowerThrottlingDataIdLocked(); mHandler.postAtTime(() -> { if (mStopped) { // DPC has already stopped, don't execute any more. return; } boolean changed = false; if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) { Loading
services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -2471,6 +2471,26 @@ public final class DisplayPowerControllerTest { eq(false)); } @Test public void onDisplayChange_canceledAfterStop() { mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID); // stop the dpc (turn it down) mHolder.dpc.stop(); advanceTime(1); // To trigger all the changes that can happen, we will completely change the underlying // display device. setUpDisplay(DISPLAY_ID, "new_unique_id", mHolder.display, mock(DisplayDevice.class), mock(DisplayDeviceConfig.class), /* isEnabled= */ true); // Call onDisplayChange after we stopped DPC and make sure it doesn't crash mHolder.dpc.onDisplayChanged(mHolder.hbmMetadata, Layout.NO_LEAD_DISPLAY); advanceTime(1); // No crash = success } /** * Creates a mock and registers it to {@link LocalServices}. */ Loading