Fix bluetooth detection
This commit is contained in:
parent
e1b9471fe2
commit
cfd9280e4a
2 changed files with 25 additions and 11 deletions
|
@ -117,7 +117,7 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
mBluetoothHeadset = null;
|
mBluetoothHeadset = null;
|
||||||
isBluetoothConnected = false;
|
isBluetoothConnected = false;
|
||||||
Log.d("Bluetooth headset disconnected");
|
Log.d("Bluetooth headset disconnected");
|
||||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -200,7 +200,6 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
|
|
||||||
public boolean isBluetoothHeadsetAvailable() {
|
public boolean isBluetoothHeadsetAvailable() {
|
||||||
ensureInit();
|
ensureInit();
|
||||||
|
|
||||||
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled() && mAudioManager != null && mAudioManager.isBluetoothScoAvailableOffCall()) {
|
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled() && mAudioManager != null && mAudioManager.isBluetoothScoAvailableOffCall()) {
|
||||||
boolean isHeadsetConnected = false;
|
boolean isHeadsetConnected = false;
|
||||||
if (mBluetoothHeadset != null) {
|
if (mBluetoothHeadset != null) {
|
||||||
|
@ -234,7 +233,7 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {}
|
||||||
|
|
||||||
mAudioManager.stopBluetoothSco();
|
mAudioManager.stopBluetoothSco();
|
||||||
mAudioManager.setBluetoothScoOn(false);
|
mAudioManager.setBluetoothScoOn(false);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +256,7 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
Log.w("Bluetooth stopped!");
|
Log.w("Bluetooth stopped!");
|
||||||
|
|
||||||
if (LinphoneManager.isInstanciated()) {
|
if (LinphoneManager.isInstanciated()) {
|
||||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphonePlayer;
|
import org.linphone.core.LinphonePlayer;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import org.linphone.ui.Numpad;
|
import org.linphone.ui.Numpad;
|
||||||
|
@ -120,7 +121,15 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
||||||
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
||||||
isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();
|
isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();
|
||||||
|
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
||||||
|
if(!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
|
||||||
|
BluetoothManager.getInstance().initBluetooth();
|
||||||
|
} else {
|
||||||
|
isSpeakerEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
||||||
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
|
|
||||||
|
@ -222,6 +231,7 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
};
|
};
|
||||||
|
|
||||||
if (findViewById(R.id.fragmentContainer) != null) {
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||||
|
@ -255,6 +265,11 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
audioCallFragment = (AudioCallFragment) callFragment;
|
audioCallFragment = (AudioCallFragment) callFragment;
|
||||||
switchCamera.setVisibility(View.INVISIBLE);
|
switchCamera.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()){
|
||||||
|
BluetoothManager.getInstance().routeAudioToBluetooth();
|
||||||
|
}
|
||||||
|
|
||||||
callFragment.setArguments(getIntent().getExtras());
|
callFragment.setArguments(getIntent().getExtras());
|
||||||
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
|
||||||
|
|
||||||
|
@ -357,7 +372,7 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
slideOutBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom_to_top);
|
slideOutBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom_to_top);
|
||||||
slideOutTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
slideOutTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
|
if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
|
||||||
try {
|
try {
|
||||||
if (routeLayout != null)
|
if (routeLayout != null)
|
||||||
|
@ -507,8 +522,8 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on);
|
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on);
|
||||||
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
|
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
|
||||||
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
|
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
|
||||||
hideOrDisplayAudioRoutes();
|
|
||||||
}
|
}
|
||||||
|
hideOrDisplayAudioRoutes();
|
||||||
}
|
}
|
||||||
else if (id == R.id.routeReceiver) {
|
else if (id == R.id.routeReceiver) {
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
|
@ -1049,11 +1064,11 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
private void hideOrDisplayAudioRoutes()
|
private void hideOrDisplayAudioRoutes()
|
||||||
{
|
{
|
||||||
if (routeSpeaker.getVisibility() == View.VISIBLE) {
|
if (routeSpeaker.getVisibility() == View.VISIBLE) {
|
||||||
routeSpeaker.setVisibility(View.INVISIBLE);
|
routeSpeaker.setVisibility(View.GONE);
|
||||||
routeBluetooth.setVisibility(View.INVISIBLE);
|
routeBluetooth.setVisibility(View.GONE);
|
||||||
routeReceiver.setVisibility(View.INVISIBLE);
|
routeReceiver.setVisibility(View.GONE);
|
||||||
audioRoute.setSelected(false);
|
audioRoute.setSelected(false);
|
||||||
} else {
|
} else {
|
||||||
routeSpeaker.setVisibility(View.VISIBLE);
|
routeSpeaker.setVisibility(View.VISIBLE);
|
||||||
routeBluetooth.setVisibility(View.VISIBLE);
|
routeBluetooth.setVisibility(View.VISIBLE);
|
||||||
routeReceiver.setVisibility(View.VISIBLE);
|
routeReceiver.setVisibility(View.VISIBLE);
|
||||||
|
|
Loading…
Reference in a new issue