Fix NPE when store brightness and displayDevice is null

This issue can cause a phone reboot, we have to make sure displayDevice is not null before getting its unique id.

Bug: 249782095
Test: manual
Change-Id: Iec57f44798820ac741bd2e6843874fb2b1aaef12
This commit is contained in:
Shen Lin
2022-09-30 17:02:37 +08:00
parent 6216ab81c1
commit efcb4ff256

View File

@@ -300,8 +300,11 @@ final class PersistentDataStore {
}
public boolean setBrightness(DisplayDevice displayDevice, float brightness) {
if (displayDevice == null || !displayDevice.hasStableUniqueId()) {
return false;
}
final String displayDeviceUniqueId = displayDevice.getUniqueId();
if (!displayDevice.hasStableUniqueId() || displayDeviceUniqueId == null) {
if (displayDeviceUniqueId == null) {
return false;
}
final DisplayState state = getDisplayState(displayDeviceUniqueId, true);