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

Commit b14de00b authored by Eric Jeong's avatar Eric Jeong Committed by Android (Google) Code Review
Browse files

Merge "Prevent the thread unsafe operation during the user switching"

parents 6358897a 9e345b68
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    private static final int MSG_UPDATE_RBC = 11;
    private static final int MSG_BRIGHTNESS_RAMP_DONE = 12;
    private static final int MSG_STATSD_HBM_BRIGHTNESS = 13;
    private static final int MSG_SWITCH_USER = 14;

    private static final int PROXIMITY_UNKNOWN = -1;
    private static final int PROXIMITY_NEGATIVE = 0;
@@ -714,6 +715,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

    @Override
    public void onSwitchUser(@UserIdInt int newUserId) {
        Message msg = mHandler.obtainMessage(MSG_SWITCH_USER, newUserId);
        mHandler.sendMessage(msg);
    }

    private void handleOnSwitchUser(@UserIdInt int newUserId) {
        handleSettingsChange(true /* userSwitch */);
        handleBrightnessModeChange();
        if (mBrightnessTracker != null) {
@@ -3073,6 +3079,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                case MSG_STATSD_HBM_BRIGHTNESS:
                    logHbmBrightnessStats(Float.intBitsToFloat(msg.arg1), msg.arg2);
                    break;

                case MSG_SWITCH_USER:
                    handleOnSwitchUser(msg.arg1);
                    break;
            }
        }
    }
+10 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
    private static final int MSG_UPDATE_RBC = 9;
    private static final int MSG_BRIGHTNESS_RAMP_DONE = 10;
    private static final int MSG_STATSD_HBM_BRIGHTNESS = 11;
    private static final int MSG_SWITCH_USER = 12;

    private static final int BRIGHTNESS_CHANGE_STATSD_REPORT_INTERVAL_MS = 500;

@@ -605,6 +606,11 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal

    @Override
    public void onSwitchUser(@UserIdInt int newUserId) {
        Message msg = mHandler.obtainMessage(MSG_SWITCH_USER, newUserId);
        mHandler.sendMessage(msg);
    }

    private void handleOnSwitchUser(@UserIdInt int newUserId) {
        handleSettingsChange(true /* userSwitch */);
        handleBrightnessModeChange();
        if (mBrightnessTracker != null) {
@@ -2573,6 +2579,10 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
                case MSG_STATSD_HBM_BRIGHTNESS:
                    logHbmBrightnessStats(Float.intBitsToFloat(msg.arg1), msg.arg2);
                    break;

                case MSG_SWITCH_USER:
                    handleOnSwitchUser(msg.arg1);
                    break;
            }
        }
    }