Merge "Move set speakerphone out of async task executor." into udc-dev am: 623b05cc8f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/24027039
Change-Id: Iedb57c8ff97932b10f7eed9cc1ef928326fd5dc5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/server/telecom/CallAudioRouteStateMachine.java b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
index c5423c2..4a03726 100644
--- a/src/com/android/server/telecom/CallAudioRouteStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
@@ -1741,28 +1741,30 @@
final boolean hasAnyCalls = mCallsManager.hasAnyCalls();
// These APIs are all via two-way binder calls so can potentially block Telecom. Since none
// of this has to happen in the Telecom lock we'll offload it to the async executor.
+
+ AudioDeviceInfo speakerDevice = null;
+ for (AudioDeviceInfo info : mAudioManager.getAvailableCommunicationDevices()) {
+ if (info.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
+ speakerDevice = info;
+ break;
+ }
+ }
+ boolean speakerOn = false;
+ if (speakerDevice != null && on) {
+ boolean result = mAudioManager.setCommunicationDevice(speakerDevice);
+ if (result) {
+ speakerOn = true;
+ }
+ } else {
+ AudioDeviceInfo curDevice = mAudioManager.getCommunicationDevice();
+ if (curDevice != null
+ && curDevice.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
+ mAudioManager.clearCommunicationDevice();
+ }
+ }
+ final boolean isSpeakerOn = speakerOn;
mAsyncTaskExecutor.execute(() -> {
- AudioDeviceInfo speakerDevice = null;
- for (AudioDeviceInfo info : mAudioManager.getAvailableCommunicationDevices()) {
- if (info.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
- speakerDevice = info;
- break;
- }
- }
- boolean speakerOn = false;
- if (speakerDevice != null && on) {
- boolean result = mAudioManager.setCommunicationDevice(speakerDevice);
- if (result) {
- speakerOn = true;
- }
- } else {
- AudioDeviceInfo curDevice = mAudioManager.getCommunicationDevice();
- if (curDevice != null
- && curDevice.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
- mAudioManager.clearCommunicationDevice();
- }
- }
- mStatusBarNotifier.notifySpeakerphone(hasAnyCalls && speakerOn);
+ mStatusBarNotifier.notifySpeakerphone(hasAnyCalls && isSpeakerOn);
});
}