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

Commit dc5d527d authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Use AudioDeviceInfo.getPort().name() instead of getProductName

getProductName replaces the absence of a name with the name of
the device (example: Pixel 8). In that case we want to derive
a name from the device type ourselves.

Bug: 305199571
Test: atest MediaRouterServiceTests # Added in same topic
Change-Id: Ifc6b75d33af004f35f219aa73d91aadeb2444586
parent b5deb18e
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -330,8 +330,11 @@ import java.util.Objects;
                TextUtils.isEmpty(address)
                        ? null
                        : mBluetoothRouteController.getRouteIdForBluetoothAddress(address);
        return createMediaRoute2Info(
                routeId, audioDeviceInfo.getType(), audioDeviceInfo.getProductName(), address);
        // We use the name from the port instead AudioDeviceInfo#getProductName because the latter
        // replaces empty names with the name of the device (example: Pixel 8). In that case we want
        // to derive a name ourselves from the type instead.
        String deviceName = audioDeviceInfo.getPort().name();
        return createMediaRoute2Info(routeId, audioDeviceInfo.getType(), deviceName, address);
    }

    /**
@@ -339,8 +342,8 @@ import java.util.Objects;
     *
     * @param routeId A route id, or null to use an id pre-defined for the given {@code type}.
     * @param audioDeviceInfoType The type as obtained from {@link AudioDeviceInfo#getType}.
     * @param productName The product name as obtained from {@link
     *     AudioDeviceInfo#getProductName()}, or null to use a predefined name for the given {@code
     * @param deviceName A human readable name to populate the route's {@link
     *     MediaRoute2Info#getName name}, or null to use a predefined name for the given {@code
     *     type}.
     * @param address The type as obtained from {@link AudioDeviceInfo#getAddress()} or {@link
     *     BluetoothDevice#getAddress()}.
@@ -350,7 +353,7 @@ import java.util.Objects;
    private MediaRoute2Info createMediaRoute2Info(
            @Nullable String routeId,
            int audioDeviceInfoType,
            @Nullable CharSequence productName,
            @Nullable CharSequence deviceName,
            @Nullable String address) {
        SystemRouteInfo systemRouteInfo =
                AUDIO_DEVICE_INFO_TYPE_TO_ROUTE_INFO.get(audioDeviceInfoType);
@@ -359,7 +362,7 @@ import java.util.Objects;
            // earpiece.
            return null;
        }
        CharSequence humanReadableName = productName;
        CharSequence humanReadableName = deviceName;
        if (TextUtils.isEmpty(humanReadableName)) {
            humanReadableName = mContext.getResources().getText(systemRouteInfo.mNameResource);
        }