Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11ed62b5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "display: Report HBM off due to low requested brightness"

parents 6da02b55 e8d957b1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -521,6 +521,10 @@ class HighBrightnessModeController {
            } else if (mIsBlockedByLowPowerMode) {
                reason = FrameworkStatsLog
                                 .DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_BATTERY_SAVE_ON;
            } else if (mBrightness <= mHbmData.transitionPoint) {
                // This must be after external thermal check.
                reason = FrameworkStatsLog
                            .DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LOW_REQUESTED_BRIGHTNESS;
            }
        }

+24 −0
Original line number Diff line number Diff line
@@ -663,6 +663,30 @@ public class HighBrightnessModeControllerTest {
            eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_HDR_PLAYING));
    }

    @Test
    public void tetHbmStats_LowRequestedBrightness() {
        final HighBrightnessModeController hbmc = createDefaultHbm(new OffsettableClock());
        final int displayStatsId = mDisplayUniqueId.hashCode();

        hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_ENABLED);
        hbmc.onAmbientLuxChange(MINIMUM_LUX + 1);
        hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
        advanceTime(0);
        // verify in HBM sunlight mode
        assertEquals(HIGH_BRIGHTNESS_MODE_SUNLIGHT, hbmc.getHighBrightnessMode());
        // verify HBM_ON_SUNLIGHT
        verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
            eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
            eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));

        hbmcOnBrightnessChanged(hbmc, DEFAULT_MIN);
        // verify HBM_SV_OFF due to LOW_REQUESTED_BRIGHTNESS
        verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
            eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
            eq(FrameworkStatsLog
                      .DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LOW_REQUESTED_BRIGHTNESS));
    }

    private void assertState(HighBrightnessModeController hbmc,
            float brightnessMin, float brightnessMax, int hbmMode) {
        assertEquals(brightnessMin, hbmc.getCurrentBrightnessMin(), EPSILON);