Add port number to hot plug event handler.

This is to remove a TODO about adding port number to
jni interface.

Bug: 15844074
Change-Id: I4dba0879527035a4cabad6cc80e359e6c1fd39b0
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecController.java b/services/core/java/com/android/server/hdmi/HdmiCecController.java
index c860673..a5a502a 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecController.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecController.java
@@ -57,7 +57,7 @@
          *
          * @param deviceType requested device type to allocate logical address
          * @param logicalAddress allocated logical address. If it is
-         *                       {@link Constants.ADDR_UNREGISTERED}, it means that
+         *                       {@link Constants#ADDR_UNREGISTERED}, it means that
          *                       it failed to allocate logical address for the given device type
          */
         void onAllocated(int deviceType, int logicalAddress);
@@ -158,7 +158,7 @@
      *
      * @param deviceType type of device to used to determine logical address
      * @param preferredAddress a logical address preferred to be allocated.
-     *                         If sets {@link Constants.ADDR_UNREGISTERED}, scans
+     *                         If sets {@link Constants#ADDR_UNREGISTERED}, scans
      *                         the smallest logical address matched with the given device type.
      *                         Otherwise, scan address will start from {@code preferredAddress}
      * @param callback callback interface to report allocated logical address to caller
@@ -559,10 +559,10 @@
     /**
      * Called by native when a hotplug event issues.
      */
-    private void handleHotplug(boolean connected) {
-        // TODO: once add port number to cec HAL interface, pass port number
-        // to the service.
-        mService.onHotplug(0, connected);
+    @ServiceThreadOnly
+    private void handleHotplug(int port, boolean connected) {
+        assertRunOnServiceThread();
+        mService.onHotplug(port, connected);
     }
 
     private static native long nativeInit(HdmiCecController handler, MessageQueue messageQueue);
diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
index d275e4d..71a7aa6 100644
--- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
+++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
@@ -162,8 +162,10 @@
     void propagateHotplugEvent(const hotplug_event_t& event) {
         // Note that this method should be called in service thread.
         JNIEnv* env = AndroidRuntime::getJNIEnv();
+        jint port = event.port;
+        jboolean connected = (jboolean) event.connected;
         env->CallVoidMethod(mController->getCallbacksObj(),
-                gHdmiCecControllerClassInfo.handleHotplug, event.connected);
+                gHdmiCecControllerClassInfo.handleHotplug, port, connected);
 
         checkAndClearExceptionFromCallback(env, __FUNCTION__);
     }
@@ -314,7 +316,7 @@
     GET_METHOD_ID(gHdmiCecControllerClassInfo.handleIncomingCecCommand, clazz,
             "handleIncomingCecCommand", "(II[B)V");
     GET_METHOD_ID(gHdmiCecControllerClassInfo.handleHotplug, clazz,
-            "handleHotplug", "(Z)V");
+            "handleHotplug", "(IZ)V");
 
     return reinterpret_cast<jlong>(controller);
 }