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

Commit 4aab5e40 authored by William Escande's avatar William Escande
Browse files

Hap: various cleanup in avatar

Test: atest avatar:HapTest
Bug: 311772251
Flag: TEST_ONLY
Change-Id: I8f73b215af6592328c739d49b0676ab663c2b13a
parent 5145e1af
Loading
Loading
Loading
Loading
+5 −10
Original line number Original line Diff line number Diff line
@@ -156,8 +156,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable {
    ) {
    ) {
        grpcUnary<GetPresetRecordResponse>(scope, responseObserver) {
        grpcUnary<GetPresetRecordResponse>(scope, responseObserver) {
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)

            Log.i(TAG, "getPresetRecord($device, ${request.index})")
            Log.i(TAG, "getPresetRecord device=${device.address} index=${request.index}")


            val presetInfo: BluetoothHapPresetInfo? =
            val presetInfo: BluetoothHapPresetInfo? =
                bluetoothHapClient.getPresetInfo(device, request.index)
                bluetoothHapClient.getPresetInfo(device, request.index)
@@ -211,8 +210,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable {
    ) {
    ) {
        grpcUnary<Empty>(scope, responseObserver) {
        grpcUnary<Empty>(scope, responseObserver) {
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)

            Log.i(TAG, "writePresetName($device, ${request.index}, ${request.name})")
            Log.i(TAG, "writePresetName index=${request.index} name=${request.name}")


            bluetoothHapClient.setPresetName(device, request.index, request.name)
            bluetoothHapClient.setPresetName(device, request.index, request.name)


@@ -226,8 +224,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable {
    ) {
    ) {
        grpcUnary<Empty>(scope, responseObserver) {
        grpcUnary<Empty>(scope, responseObserver) {
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)

            Log.i(TAG, "SetActivePreset($device, ${request.index})")
            Log.i(TAG, "SetActivePreset")


            bluetoothHapClient.selectPreset(device, request.index)
            bluetoothHapClient.selectPreset(device, request.index)


@@ -241,8 +238,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable {
    ) {
    ) {
        grpcUnary<Empty>(scope, responseObserver) {
        grpcUnary<Empty>(scope, responseObserver) {
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)

            Log.i(TAG, "setNextPreset($device)")
            Log.i(TAG, "setNextPreset")


            bluetoothHapClient.switchToNextPreset(device)
            bluetoothHapClient.switchToNextPreset(device)


@@ -256,8 +252,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable {
    ) {
    ) {
        grpcUnary<Empty>(scope, responseObserver) {
        grpcUnary<Empty>(scope, responseObserver) {
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)
            val device = request.connection.toBluetoothDevice(bluetoothAdapter)

            Log.i(TAG, "setPreviousPreset($device)")
            Log.i(TAG, "setPreviousPreset")


            bluetoothHapClient.switchToPreviousPreset(device)
            bluetoothHapClient.switchToPreviousPreset(device)


+5 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ from bumble.gatt import GATT_HEARING_ACCESS_SERVICE, GATT_AUDIO_STREAM_CONTROL_S
from bumble.profiles import hap
from bumble.profiles import hap
from bumble.profiles.hap import DynamicPresets, HearingAccessService, HearingAidFeatures, HearingAidType, IndependentPresets, PresetRecord, PresetSynchronizationSupport, WritablePresetsSupport
from bumble.profiles.hap import DynamicPresets, HearingAccessService, HearingAidFeatures, HearingAidType, IndependentPresets, PresetRecord, PresetSynchronizationSupport, WritablePresetsSupport


from pandora_experimental.os_grpc_aio import Os as OsAio
from pandora_experimental.gatt_grpc_aio import GATT
from pandora_experimental.gatt_grpc_aio import GATT
from pandora_experimental.hap_grpc_aio import HAP
from pandora_experimental.hap_grpc_aio import HAP
from pandora_experimental.hap_pb2 import PresetRecord as grpcPresetRecord  # type: ignore
from pandora_experimental.hap_pb2 import PresetRecord as grpcPresetRecord  # type: ignore
@@ -84,6 +85,8 @@ class HapTest(base_test.BaseTestClass):
    @asynchronous
    @asynchronous
    async def setup_test(self) -> None:
    async def setup_test(self) -> None:
        await asyncio.gather(self.dut.reset(), self.ref_left.reset())
        await asyncio.gather(self.dut.reset(), self.ref_left.reset())
        self.logcat = OsAio(channel=self.dut.aio.channel)
        await self.logcat.Log("setup test")
        self.hap_grpc = HAP(channel=self.dut.aio.channel)
        self.hap_grpc = HAP(channel=self.dut.aio.channel)
        device_features = HearingAidFeatures(HearingAidType.MONAURAL_HEARING_AID,
        device_features = HearingAidFeatures(HearingAidType.MONAURAL_HEARING_AID,
                                             PresetSynchronizationSupport.PRESET_SYNCHRONIZATION_IS_NOT_SUPPORTED,
                                             PresetSynchronizationSupport.PRESET_SYNCHRONIZATION_IS_NOT_SUPPORTED,
@@ -162,6 +165,7 @@ class HapTest(base_test.BaseTestClass):


    @asynchronous
    @asynchronous
    async def test_get_features(self) -> None:
    async def test_get_features(self) -> None:
        await self.logcat.Log("test_get_features")
        dut_connection_to_ref = await self.setupHapConnection()
        dut_connection_to_ref = await self.setupHapConnection()


        features = hap.HearingAidFeatures_from_bytes(
        features = hap.HearingAidFeatures_from_bytes(
@@ -170,6 +174,7 @@ class HapTest(base_test.BaseTestClass):


    @asynchronous
    @asynchronous
    async def test_get_preset(self) -> None:
    async def test_get_preset(self) -> None:
        await self.logcat.Log("test_get_preset")
        dut_connection_to_ref = await self.setupHapConnection()
        dut_connection_to_ref = await self.setupHapConnection()


        await self.assertIdentiqPresetInDutAndRef(dut_connection_to_ref)
        await self.assertIdentiqPresetInDutAndRef(dut_connection_to_ref)