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

View file

@ -67,8 +67,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mInterfaceLoaded = false; mInterfaceLoaded = false;
mIsTransfer = false;
// Uses the fragment container layout to inflate the dialer view instead of using a fragment // Uses the fragment container layout to inflate the dialer view instead of using a fragment
new AsyncLayoutInflater(this) new AsyncLayoutInflater(this)
.inflate( .inflate(
@ -124,8 +122,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
setIntent(intent);
handleIntentParams(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); setUpNumpad(view);
updateLayout(); updateLayout();
enableVideoPreviewIfTablet(true); 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); mBackToCall.setVisibility(atLeastOneCall ? View.VISIBLE : View.GONE);
mAddCall.setVisibility(atLeastOneCall && !mIsTransfer ? View.VISIBLE : View.GONE); mAddCall.setVisibility(atLeastOneCall && !mIsTransfer ? View.VISIBLE : View.GONE);
mTransferCall.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; import org.linphone.core.tools.Log;
public class BluetoothReceiver extends BroadcastReceiver { public class BluetoothReceiver extends BroadcastReceiver {
public BluetoothReceiver() {
super();
Log.i("[Bluetooth] Bluetooth receiver created");
}
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
Log.i("[Bluetooth] Bluetooth broadcast received");
if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) { if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
int state = int state =
intent.getIntExtra( intent.getIntExtra(
@ -55,6 +62,8 @@ public class BluetoothReceiver extends BroadcastReceiver {
} else if (state == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { } else if (state == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
Log.i("[Bluetooth] Bluetooth headset audio disconnected"); Log.i("[Bluetooth] Bluetooth headset audio disconnected");
LinphoneManager.getAudioManager().bluetoothHeadetAudioConnectionChanged(false); LinphoneManager.getAudioManager().bluetoothHeadetAudioConnectionChanged(false);
} else if (state == BluetoothHeadset.STATE_AUDIO_CONNECTING) {
Log.i("[Bluetooth] Bluetooth headset audio connecting");
} else { } else {
Log.w("[Bluetooth] Bluetooth headset unknown audio state changed: " + state); Log.w("[Bluetooth] Bluetooth headset unknown audio state changed: " + state);
} }