Guard mRearDisplayPendingOverrideRequest with mLock

mRearDisplayPendingOverrideRequest was null checked before acquiring the lock, which potentially caused the NullPointerException because the value might have changed while waiting on the lock.

Bug: 287264582
Change-Id: Ia14ca58a7d608ae95e1804dbcc5ab141f6f3b27c
Test: Manual
This commit is contained in:
Jiaming Liu
2023-06-20 19:36:45 +00:00
parent 439d52f91d
commit 21e913fae8

View File

@@ -172,6 +172,7 @@ public final class DeviceStateManagerService extends SystemService {
private DeviceState mRearDisplayState;
// TODO(259328837) Generalize for all pending feature requests in the future
@GuardedBy("mLock")
@Nullable
private OverrideRequest mRearDisplayPendingOverrideRequest;
@@ -779,7 +780,7 @@ public final class DeviceStateManagerService extends SystemService {
* {@link StatusBarManagerInternal} to notify SystemUI to display the educational dialog.
*/
@GuardedBy("mLock")
private void showRearDisplayEducationalOverlayLocked(OverrideRequest request) {
private void showRearDisplayEducationalOverlayLocked(@NonNull OverrideRequest request) {
mRearDisplayPendingOverrideRequest = request;
StatusBarManagerInternal statusBar =
@@ -844,8 +845,8 @@ public final class DeviceStateManagerService extends SystemService {
* request if it was dismissed in a way that should cancel the feature.
*/
private void onStateRequestOverlayDismissedInternal(boolean shouldCancelRequest) {
if (mRearDisplayPendingOverrideRequest != null) {
synchronized (mLock) {
synchronized (mLock) {
if (mRearDisplayPendingOverrideRequest != null) {
if (shouldCancelRequest) {
ProcessRecord processRecord = mProcessRecords.get(
mRearDisplayPendingOverrideRequest.getPid());