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

Commit 60847812 authored by Long Ling's avatar Long Ling
Browse files

display: move hbm stats report to handler thread

And check the null mPowerState.

Bug: 222769254
Test: Can not reproduce. Monitor the dash board.
Change-Id: Ic9c598ff7947e1e202985e960b746e4e2b309d59
parent f16b5fb3
Loading
Loading
Loading
Loading
+21 −4
Original line number Original line Diff line number Diff line
@@ -129,7 +129,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    private static final int MSG_STOP = 9;
    private static final int MSG_STOP = 9;
    private static final int MSG_UPDATE_BRIGHTNESS = 10;
    private static final int MSG_UPDATE_BRIGHTNESS = 10;
    private static final int MSG_UPDATE_RBC = 11;
    private static final int MSG_UPDATE_RBC = 11;
    private static final int MSG_STATSD_HBM_BRIGHTNESS = 12;
    private static final int MSG_BRIGHTNESS_RAMP_DONE = 12;
    private static final int MSG_STATSD_HBM_BRIGHTNESS = 13;


    private static final int PROXIMITY_UNKNOWN = -1;
    private static final int PROXIMITY_UNKNOWN = -1;
    private static final int PROXIMITY_NEGATIVE = 0;
    private static final int PROXIMITY_NEGATIVE = 0;
@@ -1050,9 +1051,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        @Override
        @Override
        public void onAnimationEnd() {
        public void onAnimationEnd() {
            sendUpdatePowerState();
            sendUpdatePowerState();

            Message msg = mHandler.obtainMessage(MSG_BRIGHTNESS_RAMP_DONE);
            final float brightness = mPowerState.getScreenBrightness();
            mHandler.sendMessage(msg);
            reportStats(brightness);
        }
        }
    };
    };


@@ -1066,6 +1066,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mCallbacks.releaseSuspendBlocker();
            mCallbacks.releaseSuspendBlocker();
            mUnfinishedBusiness = false;
            mUnfinishedBusiness = false;
        }
        }

        final float brightness = mPowerState != null
            ? mPowerState.getScreenBrightness()
            : PowerManager.BRIGHTNESS_MIN;
        reportStats(brightness);

        if (mPowerState != null) {
        if (mPowerState != null) {
            mPowerState.stop();
            mPowerState.stop();
            mPowerState = null;
            mPowerState = null;
@@ -2580,6 +2586,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    }
    }


    private void reportStats(float brightness) {
    private void reportStats(float brightness) {
        if (mLastStatsBrightness == brightness) {
            return;
        }

        float hbmTransitionPoint = PowerManager.BRIGHTNESS_MAX;
        float hbmTransitionPoint = PowerManager.BRIGHTNESS_MAX;
        synchronized(mCachedBrightnessInfo) {
        synchronized(mCachedBrightnessInfo) {
            if (mCachedBrightnessInfo.hbmTransitionPoint == null) {
            if (mCachedBrightnessInfo.hbmTransitionPoint == null) {
@@ -2680,6 +2690,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    handleRbcChanged(strengthChanged == 1, justActivated == 1);
                    handleRbcChanged(strengthChanged == 1, justActivated == 1);
                    break;
                    break;


                case MSG_BRIGHTNESS_RAMP_DONE:
                    if (mPowerState != null)  {
                        final float brightness = mPowerState.getScreenBrightness();
                        reportStats(brightness);
                    }
                    break;

                case MSG_STATSD_HBM_BRIGHTNESS:
                case MSG_STATSD_HBM_BRIGHTNESS:
                    logHbmBrightnessStats(Float.intBitsToFloat(msg.arg1), msg.arg2);
                    logHbmBrightnessStats(Float.intBitsToFloat(msg.arg1), msg.arg2);
                    break;
                    break;