Fix the issue that automatic mute state remains ON after adding VT call
An issue occurs because InCallFragment#onResume() that release the
automatic mute state is not called when switching fragments by adding
call.
To resolve this issue, handle automatic mute state in InCallActivity.
Bug: 110815828
Test: Checked that the mute state is turned OFF when add a video call
during a voice call.
Change-Id: Ided7c58e1148f6ee12bdfeaa813d596a4716c1d6
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java
index 7d12d52..8bf2348 100644
--- a/java/com/android/incallui/CallButtonPresenter.java
+++ b/java/com/android/incallui/CallButtonPresenter.java
@@ -60,15 +60,9 @@
Listener,
InCallButtonUiDelegate {
- 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 automaticallyMutedByAddCall = false;
- private boolean previousMuteState = false;
private boolean isInCallButtonUiReady;
private PhoneAccountHandle otherAccount;
@@ -275,18 +269,7 @@
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
- automaticallyMutedByAddCall = true;
- previousMuteState = AudioModeProvider.getInstance().getAudioState().isMuted();
- // Simulate a click on the mute button
- muteClicked(true /* checked */, false /* clickedByUser */);
- TelecomAdapter.getInstance().addCall();
+ InCallPresenter.getInstance().addCallClicked();
}
@Override
@@ -542,31 +525,10 @@
}
@Override
- public void refreshMuteState() {
- // Restore the previous mute state
- if (automaticallyMutedByAddCall
- && AudioModeProvider.getInstance().getAudioState().isMuted() != previousMuteState) {
- if (inCallButtonUi == null) {
- return;
- }
- muteClicked(previousMuteState, false /* clickedByUser */);
- }
- automaticallyMutedByAddCall = false;
- }
+ public void onSaveInstanceState(Bundle outState) {}
@Override
- public void onSaveInstanceState(Bundle outState) {
- outState.putBoolean(KEY_AUTOMATICALLY_MUTED_BY_ADD_CALL, automaticallyMutedByAddCall);
- outState.putBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState);
- }
-
- @Override
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- automaticallyMutedByAddCall =
- savedInstanceState.getBoolean(
- KEY_AUTOMATICALLY_MUTED_BY_ADD_CALL, automaticallyMutedByAddCall);
- previousMuteState = savedInstanceState.getBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState);
- }
+ public void onRestoreInstanceState(Bundle savedInstanceState) {}
@Override
public void onCameraPermissionGranted() {