Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 160ec50c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5480946 from 5183c962 to rvc-release

Change-Id: I44145aadb5239ac59548eb850335c8e0a12cf6e8
parents 6ebf3cdd 5183c962
Loading
Loading
Loading
Loading
+52 −43
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.incallui.audiomode.AudioModeProvider.AudioModeListener;
import com.android.incallui.call.CallList;
import com.android.incallui.call.DialerCall;
import com.android.incallui.call.DialerCall.CameraDirection;
import com.android.incallui.call.DialerCallListener;
import com.android.incallui.call.TelecomAdapter;
import com.android.incallui.call.state.DialerCallState;
import com.android.incallui.incall.protocol.InCallButtonIds;
@@ -58,17 +59,12 @@ public class CallButtonPresenter
        InCallDetailsListener,
        CanAddCallListener,
        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";
        InCallButtonUiDelegate,
        DialerCallListener {

  private final Context context;
  private InCallButtonUi inCallButtonUi;
  private DialerCall call;
  private boolean automaticallyMutedByAddCall = false;
  private boolean previousMuteState = false;
  private boolean isInCallButtonUiReady;
  private PhoneAccountHandle otherAccount;

@@ -106,11 +102,18 @@ public class CallButtonPresenter
    InCallPresenter.getInstance().getInCallCameraManager().removeCameraSelectionListener(this);
    InCallPresenter.getInstance().removeCanAddCallListener(this);
    isInCallButtonUiReady = false;

    if (call != null) {
      call.removeListener(this);
    }
  }

  @Override
  public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
    Trace.beginSection("CallButtonPresenter.onStateChange");
    if (call != null) {
      call.removeListener(this);
    }
    if (newState == InCallState.OUTGOING) {
      call = callList.getOutgoingCall();
    } else if (newState == InCallState.INCALL) {
@@ -133,6 +136,10 @@ public class CallButtonPresenter
    } else {
      call = null;
    }

    if (call != null) {
      call.addListener(this);
    }
    updateUi(newState, call);
    Trace.endSection();
  }
@@ -275,18 +282,7 @@ 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
    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
@@ -393,7 +389,6 @@ public class CallButtonPresenter
            call.getTimeAddedMs());

    if (pause) {
      call.getVideoTech().setCamera(null);
      call.getVideoTech().stopTransmission();
    } else {
      updateCamera(
@@ -542,31 +537,10 @@ public class CallButtonPresenter
  }

  @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() {
@@ -583,6 +557,41 @@ public class CallButtonPresenter
    inCallButtonUi.setCameraSwitched(!isUsingFrontFacingCamera);
  }

  @Override
  public void onDialerCallSessionModificationStateChange() {
    if (inCallButtonUi != null && call != null) {
      inCallButtonUi.enableButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, true);
      updateButtonsState(call);
    }
  }

  @Override
  public void onDialerCallDisconnect() {}

  @Override
  public void onDialerCallUpdate() {}

  @Override
  public void onDialerCallChildNumberChange() {}

  @Override
  public void onDialerCallLastForwardedNumberChange() {}

  @Override
  public void onDialerCallUpgradeToVideo() {}

  @Override
  public void onWiFiToLteHandover() {}

  @Override
  public void onHandoverToWifiFailure() {}

  @Override
  public void onInternationalCallOnWifi() {}

  @Override
  public void onEnrichedCallSessionUpdate() {}

  @Override
  public Context getContext() {
    return context;
+39 −1
Original line number Diff line number Diff line
@@ -273,6 +273,9 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud

  private SpeakEasyCallManager speakEasyCallManager;

  private boolean addCallClicked = false;
  private boolean automaticallyMutedByAddCall = false;

  /** Inaccessible constructor. Must use getRunningInstance() to get this singleton. */
  @VisibleForTesting
  InCallPresenter() {}
@@ -1226,7 +1229,9 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud
      proximitySensor.onInCallShowing(showing);
    }

    if (!showing) {
    if (showing) {
      refreshMuteState();
    } else {
      updateIsChangingConfigurations();
    }

@@ -2033,5 +2038,38 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud
    return true;
  }

  public void addCallClicked() {
    if (addCallClicked) {
      // 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.
      return;
    }
    addCallClicked = true;
    if (!AudioModeProvider.getInstance().getAudioState().isMuted()) {
      // Automatically mute the current call
      TelecomAdapter.getInstance().mute(true);
      automaticallyMutedByAddCall = true;
    }
    TelecomAdapter.getInstance().addCall();
  }

  /** Refresh mute state after call UI resuming from add call screen. */
  public void refreshMuteState() {
    LogUtil.i(
        "InCallPresenter.refreshMuteState",
        "refreshMuteStateAfterAddCall: %b addCallClicked: %b",
        automaticallyMutedByAddCall,
        addCallClicked);
    if (!addCallClicked) {
      return;
    }
    if (automaticallyMutedByAddCall) {
      // Restore the previous mute state
      TelecomAdapter.getInstance().mute(false);
      automaticallyMutedByAddCall = false;
    }
    addCallClicked = false;
  }

  private final Set<InCallUiLock> inCallUiLocks = new ArraySet<>();
}
+5 −0
Original line number Diff line number Diff line
@@ -431,6 +431,11 @@ public class VideoCallPresenter
    InCallPresenter.getInstance().getInCallCameraManager().onCameraPermissionGranted();
  }

  @Override
  public boolean isFullscreen() {
    return InCallPresenter.getInstance().isFullscreen();
  }

  /**
   * Called when the user interacts with the UI. If a fullscreen timer is pending then we start the
   * timer from scratch to avoid having the UI disappear while the user is interacting with it.
+0 −3
Original line number Diff line number Diff line
@@ -231,9 +231,6 @@ public class CallPendingActivity extends FragmentActivity
          @Override
          public void onRestoreInstanceState(Bundle savedInstanceState) {}

          @Override
          public void refreshMuteState() {}

          @Override
          public void addCallClicked() {}

+2 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ public class TopRow {
    } else if (VideoUtils.hasSentVideoUpgradeRequest(state.sessionModificationState())
        || VideoUtils.hasReceivedVideoUpgradeRequest(state.sessionModificationState())) {
      label = getLabelForVideoRequest(context, state);
    } else if (state.sessionModificationState() == SessionModificationState.REQUEST_FAILED) {
      label = context.getString(R.string.incall_video_call_operation_failed);
    } else if (state.state() == DialerCallState.PULLING) {
      label = context.getString(R.string.incall_transferring);
    } else if (state.state() == DialerCallState.DIALING
Loading