Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6ba4f85 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

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
parent e6a2f840
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -1332,8 +1332,9 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz,
    }
}

static jobject convertDeviceProductInfoToJavaObject(
        JNIEnv* env, const std::optional<DeviceProductInfo>& info) {
static jobject convertDeviceProductInfoToJavaObject(JNIEnv* env,
                                                    const std::optional<DeviceProductInfo>& 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<uint32_t>(info.installOrientation));
    return object;