summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src
diff options
context:
space:
mode:
author chelseahao <chelseahao@google.com> 2025-01-14 18:11:14 +0800
committer chelseahao <chelseahao@google.com> 2025-02-12 18:39:52 +0800
commitef136b446bd5e6522efc4e8911477bcc99ea37e4 (patch)
treebdf12f246c5c1f0c2c76e971091efc881824c17c /packages/SettingsLib/src
parent645fcbaedc684d78a811d88a44fd89041a14cef2 (diff)
Pass in `isOngoingCall` to avoid calling `AudioManager.getMode` for better performance
Test: atest Bug: b/363193254 Flag: EXEMPT bug fix Change-Id: Ifd631cd888ab3db1d51798cc152c5e38dcc3575c
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
index a00484ac28ab..522a436b0732 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
@@ -555,22 +555,17 @@ public class BluetoothUtils {
* connected 2) is Hearing Aid or LE Audio OR 3) connected profile matches currentAudioProfile
*
* @param cachedDevice the CachedBluetoothDevice
- * @param audioManager audio manager to get the current audio profile
+ * @param isOngoingCall get the current audio profile based on if in phone call
* @return if the device is AvailableMediaBluetoothDevice
*/
@WorkerThread
public static boolean isAvailableMediaBluetoothDevice(
- CachedBluetoothDevice cachedDevice, AudioManager audioManager) {
- int audioMode = audioManager.getMode();
+ CachedBluetoothDevice cachedDevice, boolean isOngoingCall) {
int currentAudioProfile;
- if (audioMode == AudioManager.MODE_RINGTONE
- || audioMode == AudioManager.MODE_IN_CALL
- || audioMode == AudioManager.MODE_IN_COMMUNICATION) {
- // in phone call
+ if (isOngoingCall) {
currentAudioProfile = BluetoothProfile.HEADSET;
} else {
- // without phone call
currentAudioProfile = BluetoothProfile.A2DP;
}
@@ -859,22 +854,17 @@ public class BluetoothUtils {
* currentAudioProfile
*
* @param cachedDevice the CachedBluetoothDevice
- * @param audioManager audio manager to get the current audio profile
+ * @param isOngoingCall get the current audio profile based on if in phone call
* @return if the device is AvailableMediaBluetoothDevice
*/
@WorkerThread
public static boolean isConnectedBluetoothDevice(
- CachedBluetoothDevice cachedDevice, AudioManager audioManager) {
- int audioMode = audioManager.getMode();
+ CachedBluetoothDevice cachedDevice, boolean isOngoingCall) {
int currentAudioProfile;
- if (audioMode == AudioManager.MODE_RINGTONE
- || audioMode == AudioManager.MODE_IN_CALL
- || audioMode == AudioManager.MODE_IN_COMMUNICATION) {
- // in phone call
+ if (isOngoingCall) {
currentAudioProfile = BluetoothProfile.HEADSET;
} else {
- // without phone call
currentAudioProfile = BluetoothProfile.A2DP;
}