Invoke the callback only when DeviceInfo is available.

- There is possibility that DeviceInfo can be null when unplugging MHL cable,
  if the capability register event is missed. and we should not invoke
  the callback in this case.
- In addition, we'd better use the portId of HdmiMhlLocalDevice directly,
  not one of DeviceInfo.

Bug: 17366541
Change-Id: I40d71e27d82c5f3a4c7aabda32119856c0bde83d
This commit is contained in:
Yuncheol Heo
2014-09-03 16:28:54 +09:00
parent c0f394e866
commit 7c5d31ea93

View File

@@ -825,8 +825,11 @@ public final class HdmiControlService extends SystemService {
device.onDeviceRemoved();
// There is no explicit event for device removal unlike capability register event
// used for device addition . Hence we remove the device on hotplug event.
invokeDeviceEventListeners(device.getInfo(), DEVICE_EVENT_REMOVE_DEVICE);
updateSafeMhlInput();
HdmiDeviceInfo deviceInfo = device.getInfo();
if (deviceInfo != null) {
invokeDeviceEventListeners(deviceInfo, DEVICE_EVENT_REMOVE_DEVICE);
updateSafeMhlInput();
}
} else {
Slog.w(TAG, "No device to remove:[portId=" + portId);
}
@@ -1051,7 +1054,7 @@ public final class HdmiControlService extends SystemService {
// the connected mobile device, start routing control to switch ports.
// callback is handled by MHL action.
device.turnOn(callback);
tv.doManualPortSwitching(device.getInfo().getPortId(), null);
tv.doManualPortSwitching(device.getPortId(), null);
return;
}
tv.deviceSelect(deviceId, callback);