Merge "display: move hbm stats report to handler thread" into tm-dev

This commit is contained in:
Long Ling
2022-03-21 20:09:54 +00:00
committed by Android (Google) Code Review

View File

@@ -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;