Ensure that VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP doesn't cause NPEs

Test: atest WindoFocusTests against ag/20678587
Bug: 261822020
Change-Id: I6c97e441272658b0ab01f7832a12bccc1b392820
This commit is contained in:
Phill Hayers
2022-12-09 11:15:31 +00:00
parent 4d625116b2
commit edddc6be3e

View File

@@ -1414,12 +1414,20 @@ public final class DisplayManagerService extends SystemService {
// LogicalDisplayMapper aware of the link between the new display and its associated virtual
// device before triggering DISPLAY_DEVICE_EVENT_ADDED.
if ((flags & VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP) != 0) {
try {
final int virtualDeviceId = virtualDevice.getDeviceId();
mLogicalDisplayMapper.associateDisplayDeviceWithVirtualDevice(
device, virtualDeviceId);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
if (virtualDevice != null) {
try {
final int virtualDeviceId = virtualDevice.getDeviceId();
mLogicalDisplayMapper.associateDisplayDeviceWithVirtualDevice(
device, virtualDeviceId);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
} else {
Slog.i(
TAG,
"Display created with VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP set, but no"
+ " virtual device. The display will not be added to a device display"
+ " group.");
}
}