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

Commit 079495ac authored by jiayongqiang's avatar jiayongqiang
Browse files

Fix thread safety issues;



There are two threads can modify "mLastChanged" and "mScreenState" variables:
1. onFinishedWakingUp()/onFinishedGoingToSleep() are called from main thread in system_server;
2. setDeviceFolded() is called from android.display thread in
system_server.

Otherwise, NullPointerException might be throw when invoke method 'long java.lang.Long.longValue()'.

Test: press power key to wake up the device and fold the device at the
same time.

Change-Id: I3a0f1862548f2e567baa8a4a615906dbf87a8243
Signed-off-by: default avatarjiayongqiang <jiayongqiang@xiaomi.com>
parent 5a5c3d75
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ class DisplayFoldDurationLogger {
    @Retention(RetentionPolicy.SOURCE)
    public @interface ScreenState {}

    private @ScreenState int mScreenState = SCREEN_STATE_UNKNOWN;
    private Long mLastChanged = null;
    private volatile @ScreenState int mScreenState = SCREEN_STATE_UNKNOWN;
    private volatile Long mLastChanged = null;

    private static final int LOG_SUBTYPE_UNFOLDED = 0;
    private static final int LOG_SUBTYPE_FOLDED = 1;