Loading android/pandora/server/src/Hap.kt +5 −10 Original line number Diff line number Diff line Loading @@ -156,8 +156,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<GetPresetRecordResponse>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "getPresetRecord device=${device.address} index=${request.index}") Log.i(TAG, "getPresetRecord($device, ${request.index})") val presetInfo: BluetoothHapPresetInfo? = bluetoothHapClient.getPresetInfo(device, request.index) Loading Loading @@ -211,8 +210,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "writePresetName index=${request.index} name=${request.name}") Log.i(TAG, "writePresetName($device, ${request.index}, ${request.name})") bluetoothHapClient.setPresetName(device, request.index, request.name) Loading @@ -226,8 +224,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "SetActivePreset") Log.i(TAG, "SetActivePreset($device, ${request.index})") bluetoothHapClient.selectPreset(device, request.index) Loading @@ -241,8 +238,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "setNextPreset") Log.i(TAG, "setNextPreset($device)") bluetoothHapClient.switchToNextPreset(device) Loading @@ -256,8 +252,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "setPreviousPreset") Log.i(TAG, "setPreviousPreset($device)") bluetoothHapClient.switchToPreviousPreset(device) Loading android/pandora/test/hap_test.py +5 −0 Original line number Diff line number Diff line Loading @@ -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.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.hap_grpc_aio import HAP from pandora_experimental.hap_pb2 import PresetRecord as grpcPresetRecord # type: ignore Loading Loading @@ -84,6 +85,8 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def setup_test(self) -> None: 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) device_features = HearingAidFeatures(HearingAidType.MONAURAL_HEARING_AID, PresetSynchronizationSupport.PRESET_SYNCHRONIZATION_IS_NOT_SUPPORTED, Loading Loading @@ -162,6 +165,7 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def test_get_features(self) -> None: await self.logcat.Log("test_get_features") dut_connection_to_ref = await self.setupHapConnection() features = hap.HearingAidFeatures_from_bytes( Loading @@ -170,6 +174,7 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def test_get_preset(self) -> None: await self.logcat.Log("test_get_preset") dut_connection_to_ref = await self.setupHapConnection() await self.assertIdentiqPresetInDutAndRef(dut_connection_to_ref) Loading system/bta/has/has_client.cc +18 −5 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ private: break; } if (!device.has_presets.contains(nt.index)) { log::error("Unknown preset. Notification is discarded: {}", nt); device.has_journal_.Append(HasJournalRecord(nt)); device.ctp_notifications_.pop_front(); continue; } auto preset = device.has_presets.extract(nt.index).value(); auto new_props = preset.GetProperties(); Loading Loading @@ -1560,7 +1566,15 @@ private: /* Get the active preset value */ auto* pp = value; STREAM_TO_UINT8(device->currently_active_preset, pp); uint8_t active_preset_index; STREAM_TO_UINT8(active_preset_index, pp); if (active_preset_index != 0 && device->isGattServiceValid() && !device->has_presets.contains(active_preset_index)) { log::error("Unknown preset {}. Active preset change is discarded", active_preset_index); device->has_journal_.Append(HasJournalRecord(active_preset_index, false)); return; } device->currently_active_preset = active_preset_index; if (device->isGattServiceValid()) { btif_storage_set_leaudio_has_active_preset(device->addr, device->currently_active_preset); Loading @@ -1573,7 +1587,9 @@ private: MarkDeviceValidIfInInitialDiscovery(*device); if (device->isGattServiceValid()) { if (!pending_group_operation_timeouts_.empty()) { if (pending_group_operation_timeouts_.empty()) { callbacks_->OnActivePresetSelected(device->addr, device->currently_active_preset); } else { for (auto it = pending_group_operation_timeouts_.rbegin(); it != pending_group_operation_timeouts_.rend(); ++it) { auto& group_op_coordinator = it->second; Loading Loading @@ -1609,9 +1625,6 @@ private: break; } } } else { callbacks_->OnActivePresetSelected(device->addr, device->currently_active_preset); } } } Loading Loading
android/pandora/server/src/Hap.kt +5 −10 Original line number Diff line number Diff line Loading @@ -156,8 +156,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<GetPresetRecordResponse>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "getPresetRecord device=${device.address} index=${request.index}") Log.i(TAG, "getPresetRecord($device, ${request.index})") val presetInfo: BluetoothHapPresetInfo? = bluetoothHapClient.getPresetInfo(device, request.index) Loading Loading @@ -211,8 +210,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "writePresetName index=${request.index} name=${request.name}") Log.i(TAG, "writePresetName($device, ${request.index}, ${request.name})") bluetoothHapClient.setPresetName(device, request.index, request.name) Loading @@ -226,8 +224,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "SetActivePreset") Log.i(TAG, "SetActivePreset($device, ${request.index})") bluetoothHapClient.selectPreset(device, request.index) Loading @@ -241,8 +238,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "setNextPreset") Log.i(TAG, "setNextPreset($device)") bluetoothHapClient.switchToNextPreset(device) Loading @@ -256,8 +252,7 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) { grpcUnary<Empty>(scope, responseObserver) { val device = request.connection.toBluetoothDevice(bluetoothAdapter) Log.i(TAG, "setPreviousPreset") Log.i(TAG, "setPreviousPreset($device)") bluetoothHapClient.switchToPreviousPreset(device) Loading
android/pandora/test/hap_test.py +5 −0 Original line number Diff line number Diff line Loading @@ -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.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.hap_grpc_aio import HAP from pandora_experimental.hap_pb2 import PresetRecord as grpcPresetRecord # type: ignore Loading Loading @@ -84,6 +85,8 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def setup_test(self) -> None: 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) device_features = HearingAidFeatures(HearingAidType.MONAURAL_HEARING_AID, PresetSynchronizationSupport.PRESET_SYNCHRONIZATION_IS_NOT_SUPPORTED, Loading Loading @@ -162,6 +165,7 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def test_get_features(self) -> None: await self.logcat.Log("test_get_features") dut_connection_to_ref = await self.setupHapConnection() features = hap.HearingAidFeatures_from_bytes( Loading @@ -170,6 +174,7 @@ class HapTest(base_test.BaseTestClass): @asynchronous async def test_get_preset(self) -> None: await self.logcat.Log("test_get_preset") dut_connection_to_ref = await self.setupHapConnection() await self.assertIdentiqPresetInDutAndRef(dut_connection_to_ref) Loading
system/bta/has/has_client.cc +18 −5 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ private: break; } if (!device.has_presets.contains(nt.index)) { log::error("Unknown preset. Notification is discarded: {}", nt); device.has_journal_.Append(HasJournalRecord(nt)); device.ctp_notifications_.pop_front(); continue; } auto preset = device.has_presets.extract(nt.index).value(); auto new_props = preset.GetProperties(); Loading Loading @@ -1560,7 +1566,15 @@ private: /* Get the active preset value */ auto* pp = value; STREAM_TO_UINT8(device->currently_active_preset, pp); uint8_t active_preset_index; STREAM_TO_UINT8(active_preset_index, pp); if (active_preset_index != 0 && device->isGattServiceValid() && !device->has_presets.contains(active_preset_index)) { log::error("Unknown preset {}. Active preset change is discarded", active_preset_index); device->has_journal_.Append(HasJournalRecord(active_preset_index, false)); return; } device->currently_active_preset = active_preset_index; if (device->isGattServiceValid()) { btif_storage_set_leaudio_has_active_preset(device->addr, device->currently_active_preset); Loading @@ -1573,7 +1587,9 @@ private: MarkDeviceValidIfInInitialDiscovery(*device); if (device->isGattServiceValid()) { if (!pending_group_operation_timeouts_.empty()) { if (pending_group_operation_timeouts_.empty()) { callbacks_->OnActivePresetSelected(device->addr, device->currently_active_preset); } else { for (auto it = pending_group_operation_timeouts_.rbegin(); it != pending_group_operation_timeouts_.rend(); ++it) { auto& group_op_coordinator = it->second; Loading Loading @@ -1609,9 +1625,6 @@ private: break; } } } else { callbacks_->OnActivePresetSelected(device->addr, device->currently_active_preset); } } } Loading