From 7c5d31ea93d6f6770c34f7a2a364522d8cc4b5d8 Mon Sep 17 00:00:00 2001 From: Yuncheol Heo Date: Wed, 3 Sep 2014 16:28:54 +0900 Subject: [PATCH] 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 --- .../java/com/android/server/hdmi/HdmiControlService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index d13e1dec84f49..2abb6992ddfcc 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -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);