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

Commit 6dc967b4 authored by Vlad Popa's avatar Vlad Popa
Browse files

Use constants when Bt flag is not enabled

Using the exported Bt flag supported_metadata_device_types_apis to
determine whether to use the BtDevice constants. We are duplicating the
constants for clients that have written values with the given metadata
keys (see FastPair initial implementation)

Flag: com.android.bluetooth.flags.Flags.supportMetadataDeviceTypesApis
Test: manual device type change
Bug: 335936458
Change-Id: I582e12967bbc4787d278964beb7a450518bc93f9
parent 8fddc47b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ aconfig_declarations_group {
        "android.widget.flags-aconfig-java",
        "backstage_power_flags_lib",
        "backup_flags_lib",
        "bluetooth_exported_flags_java_lib",
        "camera_platform_flags_core_java_lib",
        "com.android.hardware.input-aconfig-java",
        "com.android.input.flags-aconfig-java",
+40 −15
Original line number Diff line number Diff line
@@ -1198,6 +1198,8 @@ public class BtHelper {
            return AUDIO_DEVICE_CATEGORY_UNKNOWN;
        }
        String deviceCategory = new String(deviceType);

        if (com.android.bluetooth.flags.Flags.supportMetadataDeviceTypesApis()) {
            switch (deviceCategory) {
                case DEVICE_TYPE_HEARING_AID:
                    return AUDIO_DEVICE_CATEGORY_HEARING_AID;
@@ -1211,8 +1213,31 @@ public class BtHelper {
                case DEVICE_TYPE_WATCH:
                    return AUDIO_DEVICE_CATEGORY_WATCH;
                case DEVICE_TYPE_DEFAULT:
                    // fall through
                default:
                    break;
            }
        } else {
            // Duplicate switch for now to cover the cases when the flag is not rolled out
            // This will cover the cases in which clients could write directly to these
            // metadata keys
            switch (deviceCategory) {
                case "HearingAid":
                    return AUDIO_DEVICE_CATEGORY_HEARING_AID;
                case "Carkit":
                    return AUDIO_DEVICE_CATEGORY_CARKIT;
                case "Headset":
                case DEVICE_TYPE_UNTETHERED_HEADSET:
                    return AUDIO_DEVICE_CATEGORY_HEADPHONES;
                case "Speaker":
                    return AUDIO_DEVICE_CATEGORY_SPEAKER;
                case "Watch":
                    return AUDIO_DEVICE_CATEGORY_WATCH;
                case "Default":
                    // fall through
                default:
                    break;
            }
        }

        BluetoothClass deviceClass = device.getBluetoothClass();