Added more logs for BT SCO process + refresh audio routes while in call if BT headset connects/disconnects

This commit is contained in:
Sylvain Berfini 2019-11-22 16:32:59 +01:00
parent 7d5ead8ba0
commit 9a928fbb41
3 changed files with 25 additions and 12 deletions

View file

@ -438,6 +438,7 @@ public class AndroidAudioManager {
public synchronized void bluetoothHeadetConnectionChanged(boolean connected) {
mIsBluetoothHeadsetConnected = connected;
mAudioManager.setBluetoothScoOn(connected);
LinphoneManager.getCallManager().refreshInCallActions();
}
public synchronized void bluetoothHeadetAudioConnectionChanged(boolean connected) {
@ -485,8 +486,10 @@ public class AndroidAudioManager {
new Thread() {
@Override
public void run() {
boolean resultAcknoledged;
Log.i("[Audio Manager] [Bluetooth] SCO start/stop thread started");
boolean resultAcknowledged;
int retries = 0;
do {
try {
Thread.sleep(200);
@ -506,10 +509,10 @@ public class AndroidAudioManager {
+ retries);
mAudioManager.stopBluetoothSco();
}
resultAcknoledged = isUsingBluetoothAudioRoute() == enable;
resultAcknowledged = isUsingBluetoothAudioRoute() == enable;
retries++;
}
} while (!resultAcknoledged && retries < 10);
} while (!resultAcknowledged && retries < 10);
}
}.start();
}
@ -523,6 +526,7 @@ public class AndroidAudioManager {
} else {
Log.w("[Audio Manager] [Bluetooth] SCO not available off call !");
}
if (mBluetoothAdapter.isEnabled()) {
Log.i("[Audio Manager] [Bluetooth] Adapter enabled");
mBluetoothReceiver = new BluetoothReceiver();
@ -557,6 +561,8 @@ public class AndroidAudioManager {
Intent sticky =
mContext.registerReceiver(mBluetoothReceiver, filter);
Log.i(
"[Audio Manager] [Bluetooth] Bluetooth receiver registered");
int state =
sticky.getIntExtra(
AudioManager.EXTRA_SCO_AUDIO_STATE,
@ -593,6 +599,7 @@ public class AndroidAudioManager {
}
}
};
mBluetoothAdapter.getProfileProxy(
mContext, bluetoothServiceListener, BluetoothProfile.HEADSET);
}

View file

@ -67,8 +67,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
super.onCreate(savedInstanceState);
mInterfaceLoaded = false;
mIsTransfer = false;
// Uses the fragment container layout to inflate the dialer view instead of using a fragment
new AsyncLayoutInflater(this)
.inflate(
@ -124,8 +122,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
handleIntentParams(intent);
}
@ -211,6 +207,12 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
}
});
mIsTransfer = false;
if (getIntent() != null) {
mIsTransfer = getIntent().getBooleanExtra("Transfer", false);
mAddress.setText(getIntent().getStringExtra("SipUri"));
}
setUpNumpad(view);
updateLayout();
enableVideoPreviewIfTablet(true);
@ -280,11 +282,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
}
}
if (getIntent() != null) {
mIsTransfer = getIntent().getBooleanExtra("Transfer", false);
mAddress.setText(getIntent().getStringExtra("SipUri"));
}
mBackToCall.setVisibility(atLeastOneCall ? View.VISIBLE : View.GONE);
mAddCall.setVisibility(atLeastOneCall && !mIsTransfer ? View.VISIBLE : View.GONE);
mTransferCall.setVisibility(atLeastOneCall && mIsTransfer ? View.VISIBLE : View.GONE);

View file

@ -28,9 +28,16 @@ import org.linphone.LinphoneManager;
import org.linphone.core.tools.Log;
public class BluetoothReceiver extends BroadcastReceiver {
public BluetoothReceiver() {
super();
Log.i("[Bluetooth] Bluetooth receiver created");
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i("[Bluetooth] Bluetooth broadcast received");
if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
int state =
intent.getIntExtra(
@ -55,6 +62,8 @@ public class BluetoothReceiver extends BroadcastReceiver {
} else if (state == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
Log.i("[Bluetooth] Bluetooth headset audio disconnected");
LinphoneManager.getAudioManager().bluetoothHeadetAudioConnectionChanged(false);
} else if (state == BluetoothHeadset.STATE_AUDIO_CONNECTING) {
Log.i("[Bluetooth] Bluetooth headset audio connecting");
} else {
Log.w("[Bluetooth] Bluetooth headset unknown audio state changed: " + state);
}