Fix for bluetooth NPE lollipop bug

Fixes #4141
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-09-28 13:32:08 -07:00
parent 0402b45480
commit 7f59983ce4

View File

@ -135,8 +135,12 @@ public class OutgoingRinger implements MediaPlayer.OnCompletionListener, MediaPl
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (am.isBluetoothScoAvailableOffCall()) { if (am.isBluetoothScoAvailableOffCall()) {
am.startBluetoothSco(); try {
am.setBluetoothScoOn(true); am.startBluetoothSco();
am.setBluetoothScoOn(true);
} catch (NullPointerException e) {
// Lollipop bug (https://stackoverflow.com/questions/26642218/audiomanager-startbluetoothsco-crashes-on-android-lollipop)
}
} }
mediaPlayer.start(); mediaPlayer.start();