Add physical port to DisplayViewport

DisplayViewport now contains the information about the physical port
that the corresponding display is connected to (for example, HDMI1,
HDMI2, etc).
This information is needed in order to determine which input device is
associated with which display.

Add a new config file to vendor directory that will contain the actual
associations.

Bug: 116239493
Test: atest ConfigurationProcessorTest
Change-Id: I679203747753803e9635a4eaf74287ce7e69dc3f
diff --git a/core/jni/android_hardware_display_DisplayViewport.cpp b/core/jni/android_hardware_display_DisplayViewport.cpp
index 05f6556..e74aafe 100644
--- a/core/jni/android_hardware_display_DisplayViewport.cpp
+++ b/core/jni/android_hardware_display_DisplayViewport.cpp
@@ -40,6 +40,7 @@
     jfieldID deviceWidth;
     jfieldID deviceHeight;
     jfieldID uniqueId;
+    jfieldID physicalPort;
     jfieldID type;
 } gDisplayViewportClassInfo;
 
@@ -54,6 +55,9 @@
 
 status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject viewportObj,
         DisplayViewport* viewport) {
+    static const jclass byteClass = FindClassOrDie(env, "java/lang/Byte");
+    static const jmethodID byteValue = env->GetMethodID(byteClass, "byteValue", "()B");
+
     viewport->displayId = env->GetIntField(viewportObj, gDisplayViewportClassInfo.displayId);
     viewport->orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
     viewport->deviceWidth = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceWidth);
@@ -65,6 +69,12 @@
         viewport->uniqueId = ScopedUtfChars(env, uniqueId).c_str();
     }
 
+    viewport->physicalPort = std::nullopt;
+    jobject physicalPort = env->GetObjectField(viewportObj, gDisplayViewportClassInfo.physicalPort);
+    if (physicalPort != nullptr) {
+        viewport->physicalPort = std::make_optional(env->CallByteMethod(physicalPort, byteValue));
+    }
+
     viewport->type = static_cast<ViewportType>(env->GetIntField(viewportObj,
                 gDisplayViewportClassInfo.type));
 
@@ -112,6 +122,9 @@
     gDisplayViewportClassInfo.uniqueId = GetFieldIDOrDie(env,
             gDisplayViewportClassInfo.clazz, "uniqueId", "Ljava/lang/String;");
 
+    gDisplayViewportClassInfo.physicalPort = GetFieldIDOrDie(env,
+            gDisplayViewportClassInfo.clazz, "physicalPort", "Ljava/lang/Byte;");
+
     gDisplayViewportClassInfo.type = GetFieldIDOrDie(env,
             gDisplayViewportClassInfo.clazz, "type", "I");