From f6ba4f85f75aa9a435c8253f681f7b32c09250f6 Mon Sep 17 00:00:00 2001 From: Dominik Laskowski Date: Tue, 12 Nov 2024 15:50:04 -0500 Subject: Fix getConnectionToSinkType for internal displays The relative address is only populated for HDMI displays, which caused the API to return UNKNOWN for other (e.g. DSI, eDP) internal displays. Report CONNECTION_TO_SINK_BUILT_IN for a matching HAL connection type. Fixes: 376046748 Flag: EXEMPT bugfix Test: manual Change-Id: I0dde33d31f17753a2a1bf4ce421dc0d002bed108 --- core/jni/android_view_SurfaceControl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index d3bf36e60345..e227304092b5 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -1332,8 +1332,9 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, } } -static jobject convertDeviceProductInfoToJavaObject( - JNIEnv* env, const std::optional& info) { +static jobject convertDeviceProductInfoToJavaObject(JNIEnv* env, + const std::optional& info, + bool isInternal) { using ModelYear = android::DeviceProductInfo::ModelYear; using ManufactureYear = android::DeviceProductInfo::ManufactureYear; using ManufactureWeekAndYear = android::DeviceProductInfo::ManufactureWeekAndYear; @@ -1368,7 +1369,8 @@ static jobject convertDeviceProductInfoToJavaObject( // Section 8.7 - Physical Address of HDMI Specification Version 1.3a using android::hardware::display::IDeviceProductInfoConstants; if (info->relativeAddress.size() != 4) { - connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_UNKNOWN; + connectionToSinkType = isInternal ? IDeviceProductInfoConstants::CONNECTION_TO_SINK_BUILT_IN + : IDeviceProductInfoConstants::CONNECTION_TO_SINK_UNKNOWN; } else if (info->relativeAddress[0] == 0) { connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_BUILT_IN; } else if (info->relativeAddress[1] == 0) { @@ -1390,12 +1392,14 @@ static jobject nativeGetStaticDisplayInfo(JNIEnv* env, jclass clazz, jlong id) { jobject object = env->NewObject(gStaticDisplayInfoClassInfo.clazz, gStaticDisplayInfoClassInfo.ctor); - env->SetBooleanField(object, gStaticDisplayInfoClassInfo.isInternal, - info.connectionType == ui::DisplayConnectionType::Internal); + + const bool isInternal = info.connectionType == ui::DisplayConnectionType::Internal; + env->SetBooleanField(object, gStaticDisplayInfoClassInfo.isInternal, isInternal); env->SetFloatField(object, gStaticDisplayInfoClassInfo.density, info.density); env->SetBooleanField(object, gStaticDisplayInfoClassInfo.secure, info.secure); env->SetObjectField(object, gStaticDisplayInfoClassInfo.deviceProductInfo, - convertDeviceProductInfoToJavaObject(env, info.deviceProductInfo)); + convertDeviceProductInfoToJavaObject(env, info.deviceProductInfo, + isInternal)); env->SetIntField(object, gStaticDisplayInfoClassInfo.installOrientation, static_cast(info.installOrientation)); return object; -- cgit v1.2.3-59-g8ed1b