summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/sound
diff options
context:
space:
mode:
authorryanywlin <ryanywlin@google.com>2018-04-17 16:48:30 +0800
committercaxtonchan <caxtonchan@google.com>2018-04-18 05:57:27 +0800
commitdca308e56d33c113f19e70fc718311aa38b8aab6 (patch)
treea505dfddbfd00379791a961991c4a61e41862feb /src/com/android/settings/sound
parentf99a4a3e068ff9e908e970938685c9d110c32e14 (diff)
downloadpackages_apps_Settings-dca308e56d33c113f19e70fc718311aa38b8aab6.tar.gz
packages_apps_Settings-dca308e56d33c113f19e70fc718311aa38b8aab6.tar.bz2
packages_apps_Settings-dca308e56d33c113f19e70fc718311aa38b8aab6.zip
Replace deprecated APIs in audio switcher.
- Remove isWiredHeadsetOn() and isBluetoothA2dpOn() in MediaOutputPreferenceController. - Remove isWiredHeadsetOn() and isBluetoothScoOn() in HandsFreeProfileOutputPreferenceController. - Replace with AudioManager.getDevicesForStream(). - Update test cases. Bug: 78141441 Test: make RunSettingsRoboTests ROBOTEST_FILTER="MediaOutputPreferenceControllerTest" -j40 Test: make RunSettingsRoboTests ROBOTEST_FILTER="HandsFreeProfileOutputPreferenceControllerTest" -j40 Test: make RunSettingsRoboTests ROBOTEST_FILTER="AudioOutputSwitchPreferenceControllerTest" -j40 Change-Id: Ic57c40badf0fd5633f1b7412d63a0b5417d0f47a
Diffstat (limited to 'src/com/android/settings/sound')
-rw-r--r--src/com/android/settings/sound/AudioSwitchPreferenceController.java6
-rw-r--r--src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java5
-rw-r--r--src/com/android/settings/sound/MediaOutputPreferenceController.java4
3 files changed, 12 insertions, 3 deletions
diff --git a/src/com/android/settings/sound/AudioSwitchPreferenceController.java b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
index 25a0518a3f..28ad3f5f3d 100644
--- a/src/com/android/settings/sound/AudioSwitchPreferenceController.java
+++ b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
@@ -193,8 +193,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
}
+ protected boolean isStreamFromOutputDevice(int streamType, int device) {
+ return mAudioManager.getDevicesForStream(streamType) == device;
+ }
+
protected boolean isOngoingCallStatus() {
- int audioMode = mAudioManager.getMode();
+ final int audioMode = mAudioManager.getMode();
return audioMode == AudioManager.MODE_RINGTONE
|| audioMode == AudioManager.MODE_IN_CALL
|| audioMode == AudioManager.MODE_IN_COMMUNICATION;
diff --git a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
index b0b3dc503d..2f21f1b002 100644
--- a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
+++ b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
@@ -16,6 +16,9 @@
package com.android.settings.sound;
+import static android.media.AudioManager.STREAM_VOICE_CALL;
+import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
+
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.support.v7.preference.Preference;
@@ -76,7 +79,7 @@ public class HandsFreeProfileOutputPreferenceController extends
// Setup devices entries, select active connected device
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
- if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothScoOn()) {
+ if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) {
// If wired headset is plugged in and active, select to default device.
mSelectedIndex = getDefaultDeviceIndex();
}
diff --git a/src/com/android/settings/sound/MediaOutputPreferenceController.java b/src/com/android/settings/sound/MediaOutputPreferenceController.java
index 2e52f77b06..74c77cd23f 100644
--- a/src/com/android/settings/sound/MediaOutputPreferenceController.java
+++ b/src/com/android/settings/sound/MediaOutputPreferenceController.java
@@ -16,6 +16,8 @@
package com.android.settings.sound;
+import static android.media.AudioManager.STREAM_VOICE_CALL;
+import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
import android.bluetooth.BluetoothDevice;
@@ -91,7 +93,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
// Setup devices entries, select active connected device
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
- if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothA2dpOn()) {
+ if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) {
// If wired headset is plugged in and active, select to default device.
mSelectedIndex = getDefaultDeviceIndex();
}