diff options
author | yueg <yueg@google.com> | 2018-04-06 14:34:59 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-06 16:36:11 -0700 |
commit | 8e5448639a84efbd39c7bd20738d41edb86b0e83 (patch) | |
tree | e36a5cad7542df73beea902fcd11df4e37a3080c /java | |
parent | 7c4d9bb81e738698ff5fd2392c62b547190fc7d9 (diff) |
Use sensible audio route for bubble mode.
Bug: 74022483
Test: InCallPresenterTest
PiperOrigin-RevId: 191941513
Change-Id: If2090c6dae63981a46586d785e2836edbdf8a729
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/incallui/InCallPresenter.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index b5e76ee76..7ea2fadf3 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -271,6 +271,7 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud private SpeakEasyCallManager speakEasyCallManager; private boolean shouldStartInBubbleMode; + private boolean audioRouteSetForBubbleMode; /** Inaccessible constructor. Must use getRunningInstance() to get this singleton. */ @VisibleForTesting @@ -1498,6 +1499,7 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud showInCall(false /* showDialpad */, !showAccountPicker /* newOutgoingCall */); } else if (newState == InCallState.NO_CALLS) { // The new state is the no calls state. Tear everything down. + inCallState = newState; attemptFinishActivity(); attemptCleanup(); } @@ -1554,6 +1556,7 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud isChangingConfigurations = false; shouldStartInBubbleMode = false; + audioRouteSetForBubbleMode = false; // blow away stale contact info so that we get fresh data on // the next set of calls @@ -1834,11 +1837,41 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud @Override public void onAudioStateChanged(CallAudioState audioState) { + // Set sensible audio route for bubble mode when we get real audio state for the first time + // During the first time this function is called, supportedRouteMask is set to + // SUPPORTED_AUDIO_ROUTE_ALL, but it's OK since shouldStartInBubbleMode is not set at that time. + if (!audioRouteSetForBubbleMode && shouldStartInBubbleMode) { + setAudioRouteForBubbleMode(audioState); + audioRouteSetForBubbleMode = true; + } + if (statusBarNotifier != null) { statusBarNotifier.updateNotification(); } } + /** + * Set audio route to make audio sensible. According to availability, set audio route to Bluetooth + * or wired headset or speaker. + */ + private void setAudioRouteForBubbleMode(CallAudioState audioState) { + if ((audioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH) + == CallAudioState.ROUTE_BLUETOOTH) { + // Use Bluetooth if available + TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_BLUETOOTH); + LogUtil.i("InCallPrenter.setAudioRouteForBubbleMode", "bluetooth"); + } else if ((audioState.getSupportedRouteMask() & CallAudioState.ROUTE_WIRED_HEADSET) + == CallAudioState.ROUTE_WIRED_HEADSET) { + // Use wired headset if available + TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_WIRED_HEADSET); + LogUtil.i("InCallPrenter.setAudioRouteForBubbleMode", "wired headset"); + } else { + // Use speaker + TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_SPEAKER); + LogUtil.i("InCallPrenter.setAudioRouteForBubbleMode", "speaker"); + } + } + /** All the main states of InCallActivity. */ public enum InCallState { // InCall Screen is off and there are no calls |