From 169716063f3163dca4b03becb6acf8c02b3447ce Mon Sep 17 00:00:00 2001 From: Janusz Kolarczyk Date: Wed, 15 Jan 2025 19:58:58 +0100 Subject: [PATCH] Bluetooth handled in jitsi --- ios/RNCallKeep/RNCallKeep.m | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 694ff9c4..a3950ec2 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -61,7 +61,6 @@ - (instancetype)init NSLog(@"[RNCallKeep][init]"); #endif if (self = [super init]) { - _shouldForceBluetooth = TRUE; _isStartCallActionEventListenerAdded = NO; _isReachable = NO; if (_delayedEvents == nil) _delayedEvents = [NSMutableArray array]; @@ -151,12 +150,6 @@ - (void)onAudioRouteChange:(NSNotification *)notification @"output": output, @"reason": @(reason), }]; - - if (_shouldForceBluetooth) { - // Force Bluetooth as soon as possible once onAudioRouteChange event handler finishes - _forceBluetoothTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(forceBluetoothPreferredInput:) userInfo:nil repeats:YES]; - [_forceBluetoothTimer fire]; - } } - (void)sendEventWithNameWrapper:(NSString *)name body:(id)body { @@ -390,9 +383,6 @@ + (void)setup:(NSDictionary *)options { _isAudioSessionActive = NO; [self requestTransaction:transaction]; } - - // We are ready to force the Bluetooth for new calls - _shouldForceBluetooth = true; } RCT_EXPORT_METHOD(setOnHold:(NSString *)uuidString :(BOOL)shouldHold) @@ -554,10 +544,6 @@ + (void)setup:(NSDictionary *)options { if ([inputName isEqualToString:@"Speaker"]) { BOOL isOverrided = [myAudioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err]; - if (isOverrided) { - _shouldForceBluetooth = FALSE; - } - if(!isOverrided){ [NSException raise:@"overrideOutputAudioPort failed" format:@"error: %@", err]; } @@ -584,17 +570,7 @@ + (void)setup:(NSDictionary *)options { for (AVAudioSessionPortDescription *port in ports) { if ([port.portName isEqualToString:inputName]) { BOOL isSetted = [myAudioSession setPreferredInput:(AVAudioSessionPortDescription *)port error:&err]; - - if (isSetted) { - if ([port.portType isEqualToString:AVAudioSessionPortBluetoothHFP] || - [port.portType isEqualToString:AVAudioSessionPortBluetoothA2DP]) { - _shouldForceBluetooth = TRUE; - } else { - _shouldForceBluetooth = FALSE; - } - } - - if(!isSetted){ + if(!isSetted) { [NSException raise:@"setPreferredInput failed" format:@"error: %@", err]; } resolve(inputName); @@ -971,7 +947,7 @@ - (void) forceBluetoothPreferredInput:(id)sender if (!isSetted) { [NSException raise:@"forceBluetoothPreferredInput failed" format:@"error: %@", err]; - } + } break; } @catch (NSException *e) {