Do not use isAudioOn hidden API
Instead we can use BluetoothHeadset.getConnectedDevices and check the
size of the list. This is the same behavior (actually isAudioOn would
have included connecting devices, but we don't include that because we
shouldn't)
Bug: 137202333
Test: manual
Change-Id: I928c5a2e944b74559304ad9337a8d02a59721492
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 3796e64..f9013c6 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -392,7 +392,7 @@
try {
int stream;
if (mBluetoothHeadset != null) {
- stream = mBluetoothHeadset.isAudioOn() ? AudioManager.STREAM_BLUETOOTH_SCO:
+ stream = isBluetoothAudioOn() ? AudioManager.STREAM_BLUETOOTH_SCO :
AudioManager.STREAM_VOICE_CALL;
} else {
stream = AudioManager.STREAM_VOICE_CALL;
@@ -479,6 +479,11 @@
}
}
+ // Returns whether there are any connected Bluetooth audio devices
+ private boolean isBluetoothAudioOn() {
+ return mBluetoothHeadset.getConnectedDevices().size() > 0;
+ }
+
/**
* Displays a notification when the phone receives a DisplayInfo record.
*/