TIF: fix NPE at onHdmiDeviceUpdated()

The input ID of HDMI input may not be initialized at the time
HdmiDeviceEventListener.onStatusChanged() is called. Retrieve the
input ID at the time of operation instead.

Bug: 17887925
Change-Id: I7517247294a4467feb334170b19ce2a7987dc495
diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
index 48ac228..7d72a2e 100644
--- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java
+++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
@@ -914,11 +914,18 @@
                     break;
                 }
                 case HDMI_DEVICE_UPDATED: {
-                    SomeArgs args = (SomeArgs) msg.obj;
-                    String inputId = (String) args.arg1;
-                    HdmiDeviceInfo info = (HdmiDeviceInfo) args.arg2;
-                    args.recycle();
-                    mListener.onHdmiDeviceUpdated(inputId, info);
+                    HdmiDeviceInfo info = (HdmiDeviceInfo) msg.obj;
+                    String inputId = null;
+                    synchronized (mLock) {
+                        inputId = mHdmiInputIdMap.get(info.getId());
+                    }
+                    if (inputId != null) {
+                        mListener.onHdmiDeviceUpdated(inputId, info);
+                    } else {
+                        Slog.w(TAG, "Could not resolve input ID matching the device info; "
+                                + "ignoring.");
+                    }
+                    break;
                 }
                 default: {
                     Slog.w(TAG, "Unhandled message: " + msg);
@@ -986,11 +993,7 @@
                         }
                         mHdmiDeviceList.add(deviceInfo);
                         messageType = ListenerHandler.HDMI_DEVICE_UPDATED;
-                        String inputId = mHdmiInputIdMap.get(deviceInfo.getId());
-                        SomeArgs args = SomeArgs.obtain();
-                        args.arg1 = inputId;
-                        args.arg2 = deviceInfo;
-                        obj = args;
+                        obj = deviceInfo;
                         break;
                     }
                 }