Try to prevent BT crash that happen for some people
This commit is contained in:
parent
8c0d2fc51d
commit
c208d3e377
2 changed files with 16 additions and 4 deletions
|
@ -147,7 +147,7 @@
|
||||||
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>
|
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name="org.linphone.BluetoothManager">
|
<receiver android:name="org.linphone.BluetoothManager" android:enabled="false">
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name="org.linphone.BootReceiver">
|
<receiver android:name="org.linphone.BootReceiver">
|
||||||
|
|
|
@ -66,14 +66,26 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BluetoothManager() {
|
private BluetoothManager() {
|
||||||
isBluetoothConnected = false;
|
isBluetoothConnected = false;
|
||||||
mContext = LinphoneService.instance().getApplicationContext();
|
if (LinphoneService.isReady()) {
|
||||||
mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
|
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;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initBluetooth() {
|
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();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addCategory(BluetoothHeadset.VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY + "." + BluetoothAssignedNumbers.PLANTRONICS);
|
filter.addCategory(BluetoothHeadset.VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY + "." + BluetoothAssignedNumbers.PLANTRONICS);
|
||||||
filter.addAction(Compatibility.getAudioManagerEventForBluetoothConnectionStateChangedEvent());
|
filter.addAction(Compatibility.getAudioManagerEventForBluetoothConnectionStateChangedEvent());
|
||||||
|
|
Loading…
Reference in a new issue