Fix NPE when passing displayId through handler

NPE was thrown when calling getPendingFrameRateOverrideUids. This is
because the LogicalDisplay array could change before the message is
handled. This fix ensures that the logical display is valid before
continuing with the method.

Bug: 198359227
Bug: 198159201
Bug: 199027886

Test: Verify it doesn't crash
Change-Id: I11adf67478d7a6f81512aa3cd4bc568056dfa80a
This commit is contained in:
Fiona Campbell
2021-09-09 17:10:52 +00:00
parent 20c69e3978
commit 489b25e7e9

View File

@@ -2252,6 +2252,9 @@ public final class DisplayManagerService extends SystemService {
int displayId = msg.arg1;
final LogicalDisplay display =
mLogicalDisplayMapper.getDisplayLocked(displayId);
if (display == null) {
break;
}
uids = display.getPendingFrameRateOverrideUids();
display.clearPendingFrameRateOverrideUids();
}