Try to prevent BT crash that happen for some people

This commit is contained in:
Sylvain Berfini 2014-10-29 14:54:39 +01:00
parent 8c0d2fc51d
commit c208d3e377
2 changed files with 16 additions and 4 deletions

View file

@ -147,7 +147,7 @@
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>
</receiver>
<receiver android:name="org.linphone.BluetoothManager">
<receiver android:name="org.linphone.BluetoothManager" android:enabled="false">
</receiver>
<receiver android:name="org.linphone.BootReceiver">

View file

@ -66,14 +66,26 @@ public class BluetoothManager extends BroadcastReceiver {
return instance;
}
public BluetoothManager() {
private BluetoothManager() {
isBluetoothConnected = false;
if (LinphoneService.isReady()) {
mContext = LinphoneService.instance().getApplicationContext();
mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
} else {
Log.w("BluetoothManager tried to init but LinphoneService not ready yet...");
}
instance = this;
}
public void initBluetooth() {
if (mContext == null && LinphoneService.isReady()) {
mContext = LinphoneService.instance().getApplicationContext();
mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
} else if (mContext == null) {
Log.w("BluetoothManager tried to init bluetooth but LinphoneService not ready yet...");
return;
}
IntentFilter filter = new IntentFilter();
filter.addCategory(BluetoothHeadset.VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY + "." + BluetoothAssignedNumbers.PLANTRONICS);
filter.addAction(Compatibility.getAudioManagerEventForBluetoothConnectionStateChangedEvent());