diff options
author | Vasyl Gello <vasek.gello@gmail.com> | 2018-05-30 16:25:24 +0300 |
---|---|---|
committer | Vasyl Gello <vasek.gello@gmail.com> | 2018-06-01 15:51:26 +0300 |
commit | 6841e717e64d284aa51c2045f2f026208366cbae (patch) | |
tree | 16583c110c7d2f8d3a5922f0b48a1b4fa5c24015 | |
parent | d4a6cea1519ff3ee8375c45d972589a235841b35 (diff) | |
download | android_packages_apps_Dialer-6841e717e64d284aa51c2045f2f026208366cbae.tar.gz android_packages_apps_Dialer-6841e717e64d284aa51c2045f2f026208366cbae.tar.bz2 android_packages_apps_Dialer-6841e717e64d284aa51c2045f2f026208366cbae.zip |
InCallUI: improve in-call UI for different supported routes
On some devices, there is no earpiece route available, and the speaker
is the default audio output. To make in-call UI correctly operate on
such devices, the following changes are introduced:
* the "earpiece handset" output icon becomes hidden from the list of
choices in the audio button if no earpiece route is supported
* if device does not support earpiece route but wired headset is
plugged in, the "earpiece handset" output icon becomes visible
to reflect the wired headset as an actual call audio output
* the text option of earpiece becomes hidden from choices if the
device does not support earpiece route
* audio button is shown only if there are more than one route is
present on the device, otherwise it stays hidden
Test:
* On devices with speaker and earpiece routes present, the audio
button is visible and acts like a speaker toggle
* On devices with speaker and earpiece routes present and wired
headset plugged in, the audio button is visible and acts as
a speaker toggle
* On devices with speaker-only or earpiece-only routes present
and wired headset plugged in, the audio button is visible and
acts as a speaker toggle
* On devices with speaker and earpiece routes present and
Bluetooth headset paired, the audio button is visible and acts
as a multi-state toggle allowing user to choose Bluetooth
(by default), speaker or handset earpiece
* On devices with speaker-only or earpiece-only routes present
and Bluetooth headset paired, the audio button is visible and
acts as a multi-state toggle allowing user to choose Bluetooth
(by default) and speaker or handset earpiece
* On devices with speaker-only or earpiece-only routes present,
the audio button is invisible
Change-Id: I9359aaaa44b89f5937cc1a7d9fbd5fe25c71133d
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonFragment.java | 9 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonPresenter.java | 41 |
2 files changed, 46 insertions, 4 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 9601ac20d..8b8829bde 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -734,6 +734,8 @@ public class CallButtonFragment private void updateAudioButtons() { final boolean bluetoothSupported = isSupported(CallAudioState.ROUTE_BLUETOOTH); final boolean speakerSupported = isSupported(CallAudioState.ROUTE_SPEAKER); + final boolean earpieceOrWiredHeadsetSupported = + isSupported(CallAudioState.ROUTE_WIRED_OR_EARPIECE); boolean audioButtonEnabled = false; boolean audioButtonChecked = false; @@ -757,7 +759,7 @@ public class CallButtonFragment showBluetoothIcon = true; } else if (isAudio(CallAudioState.ROUTE_SPEAKER)) { showSpeakerphoneIcon = true; - } else { + } else if (earpieceOrWiredHeadsetSupported) { showHandsetIcon = true; // TODO: if a wired headset is plugged in, that takes precedence // over the handset earpiece. If so, maybe we should show some @@ -888,8 +890,9 @@ public class CallButtonFragment final MenuItem wiredHeadsetItem = menu.findItem(R.id.audio_mode_wired_headset); final boolean usingHeadset = isSupported(CallAudioState.ROUTE_WIRED_HEADSET); - earpieceItem.setVisible(!usingHeadset); - earpieceItem.setEnabled(!usingHeadset); + final boolean earpieceSupported = isSupported(CallAudioState.ROUTE_EARPIECE); + earpieceItem.setVisible(!usingHeadset && earpieceSupported); + earpieceItem.setEnabled(!usingHeadset && earpieceSupported); wiredHeadsetItem.setVisible(usingHeadset); wiredHeadsetItem.setEnabled(usingHeadset); // TODO: Show the above item (either earpieceItem or wiredHeadsetItem) diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index a73819678..621281610 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -194,6 +194,11 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto public void onSupportedAudioMode(int mask) { if (getUi() != null) { getUi().setSupportedAudio(mask); + + // toggle the visibility of audio button + getUi().showButton(BUTTON_AUDIO, shouldAudioButtonShow()); + getUi().updateButtonStates(); + getUi().updateColors(); } } @@ -533,6 +538,40 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto } /** + * Checks if audio route is supported on device + * + */ + private boolean isAudioRouteSupported(int route) { + return (getSupportedAudio() & route) > 0; + } + + /** + * Counts number of supported routes and disables audio button if there is only one + * route supported (i.e nothing to choose from) + */ + private boolean shouldAudioButtonShow() { + int numSupportedRoutes = 0; + + int routes[] = { + CallAudioState.ROUTE_BLUETOOTH, + CallAudioState.ROUTE_WIRED_OR_EARPIECE, + CallAudioState.ROUTE_SPEAKER + }; + + for (int i = 0; i < routes.length; i++) { + if (isAudioRouteSupported(routes[i])) { + numSupportedRoutes++; + } + } + + if (numSupportedRoutes == 0) { + Log.e(this, "numSupportedRoutes = 0"); + } + + return (numSupportedRoutes > 1); + } + + /** * Updates the buttons applicable for the UI. * * @param call The active call. @@ -603,7 +642,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto boolean showCallRecordOption = recorder.isEnabled() && !isVideo && call.getState() == Call.State.ACTIVE; - ui.showButton(BUTTON_AUDIO, true); + ui.showButton(BUTTON_AUDIO, shouldAudioButtonShow()); ui.showButton(BUTTON_SWAP, showSwap); ui.showButton(BUTTON_HOLD, showHold); ui.setHold(isCallOnHold); |