diff options
author | yueg <yueg@google.com> | 2018-05-14 16:57:37 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-15 11:17:06 -0700 |
commit | d1a269ba4e9649cb1a0941433a3684d9e39a2fe6 (patch) | |
tree | c497e55ed39cde6efd2092d55a63143dc9fcb7d1 /java | |
parent | c876815dca5f701190b36c3b734bb8ae468e1cb3 (diff) |
Fix add call button behavior.
Double clicking add call button mutes the call, and going back to in call UI doesn't unmute the call. It's because previousMuteState is set twice. We shouldn't do anything for the second click since the first click makes you leave in call UI.
Also change automaticallyMuted to automaticallyMutedByAddCall to clearly indicate the value is for add call button only.
Test: CallButtonPresenterTest
PiperOrigin-RevId: 196590319
Change-Id: I9f41b1a75ced3900ae0c4fa787f3defaf7f1cbe6
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/incallui/CallButtonPresenter.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index 3fd3ee64b..a8b060daa 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -62,13 +62,14 @@ public class CallButtonPresenter Listener, InCallButtonUiDelegate { - private static final String KEY_AUTOMATICALLY_MUTED = "incall_key_automatically_muted"; + private static final String KEY_AUTOMATICALLY_MUTED_BY_ADD_CALL = + "incall_key_automatically_muted_by_add_call"; private static final String KEY_PREVIOUS_MUTE_STATE = "incall_key_previous_mute_state"; private final Context context; private InCallButtonUi inCallButtonUi; private DialerCall call; - private boolean automaticallyMuted = false; + private boolean automaticallyMutedByAddCall = false; private boolean previousMuteState = false; private boolean isInCallButtonUiReady; private PhoneAccountHandle otherAccount; @@ -276,8 +277,14 @@ public class CallButtonPresenter DialerImpression.Type.IN_CALL_ADD_CALL_BUTTON_PRESSED, call.getUniqueCallId(), call.getTimeAddedMs()); + if (automaticallyMutedByAddCall) { + // Since clicking add call button brings user to MainActivity and coming back refreshes mute + // state, add call button should only be clicked once during InCallActivity shows. Otherwise, + // we set previousMuteState wrong. + return; + } // Automatically mute the current call - automaticallyMuted = true; + automaticallyMutedByAddCall = true; previousMuteState = AudioModeProvider.getInstance().getAudioState().isMuted(); // Simulate a click on the mute button muteClicked(true /* checked */, false /* clickedByUser */); @@ -540,25 +547,27 @@ public class CallButtonPresenter @Override public void refreshMuteState() { // Restore the previous mute state - if (automaticallyMuted + if (automaticallyMutedByAddCall && AudioModeProvider.getInstance().getAudioState().isMuted() != previousMuteState) { if (inCallButtonUi == null) { return; } muteClicked(previousMuteState, false /* clickedByUser */); } - automaticallyMuted = false; + automaticallyMutedByAddCall = false; } @Override public void onSaveInstanceState(Bundle outState) { - outState.putBoolean(KEY_AUTOMATICALLY_MUTED, automaticallyMuted); + outState.putBoolean(KEY_AUTOMATICALLY_MUTED_BY_ADD_CALL, automaticallyMutedByAddCall); outState.putBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState); } @Override public void onRestoreInstanceState(Bundle savedInstanceState) { - automaticallyMuted = savedInstanceState.getBoolean(KEY_AUTOMATICALLY_MUTED, automaticallyMuted); + automaticallyMutedByAddCall = + savedInstanceState.getBoolean( + KEY_AUTOMATICALLY_MUTED_BY_ADD_CALL, automaticallyMutedByAddCall); previousMuteState = savedInstanceState.getBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState); } |