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
This commit is contained in:
Long Ling
2022-03-07 09:42:40 -08:00
parent f16b5fb33f
commit 60847812e4

View File

@@ -129,7 +129,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private static final int MSG_STOP = 9;
private static final int MSG_UPDATE_BRIGHTNESS = 10;
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_NEGATIVE = 0;
@@ -1050,9 +1051,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
@Override
public void onAnimationEnd() {
sendUpdatePowerState();
final float brightness = mPowerState.getScreenBrightness();
reportStats(brightness);
Message msg = mHandler.obtainMessage(MSG_BRIGHTNESS_RAMP_DONE);
mHandler.sendMessage(msg);
}
};
@@ -1066,6 +1066,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mCallbacks.releaseSuspendBlocker();
mUnfinishedBusiness = false;
}
final float brightness = mPowerState != null
? mPowerState.getScreenBrightness()
: PowerManager.BRIGHTNESS_MIN;
reportStats(brightness);
if (mPowerState != null) {
mPowerState.stop();
mPowerState = null;
@@ -2580,6 +2586,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
}
private void reportStats(float brightness) {
if (mLastStatsBrightness == brightness) {
return;
}
float hbmTransitionPoint = PowerManager.BRIGHTNESS_MAX;
synchronized(mCachedBrightnessInfo) {
if (mCachedBrightnessInfo.hbmTransitionPoint == null) {
@@ -2680,6 +2690,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
handleRbcChanged(strengthChanged == 1, justActivated == 1);
break;
case MSG_BRIGHTNESS_RAMP_DONE:
if (mPowerState != null) {
final float brightness = mPowerState.getScreenBrightness();
reportStats(brightness);
}
break;
case MSG_STATSD_HBM_BRIGHTNESS:
logHbmBrightnessStats(Float.intBitsToFloat(msg.arg1), msg.arg2);
break;