summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/CallButtonPresenter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/incallui/CallButtonPresenter.java')
-rw-r--r--java/com/android/incallui/CallButtonPresenter.java231
1 files changed, 115 insertions, 116 deletions
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java
index c20642b59..88aeaf581 100644
--- a/java/com/android/incallui/CallButtonPresenter.java
+++ b/java/com/android/incallui/CallButtonPresenter.java
@@ -62,22 +62,22 @@ public class CallButtonPresenter
private static final String KEY_AUTOMATICALLY_MUTED = "incall_key_automatically_muted";
private static final String KEY_PREVIOUS_MUTE_STATE = "incall_key_previous_mute_state";
- private final Context mContext;
- private InCallButtonUi mInCallButtonUi;
- private DialerCall mCall;
- private boolean mAutomaticallyMuted = false;
- private boolean mPreviousMuteState = false;
+ private final Context context;
+ private InCallButtonUi inCallButtonUi;
+ private DialerCall call;
+ private boolean automaticallyMuted = false;
+ private boolean previousMuteState = false;
private boolean isInCallButtonUiReady;
- private PhoneAccountHandle mOtherAccount;
+ private PhoneAccountHandle otherAccount;
public CallButtonPresenter(Context context) {
- mContext = context.getApplicationContext();
+ this.context = context.getApplicationContext();
}
@Override
public void onInCallButtonUiReady(InCallButtonUi ui) {
Assert.checkState(!isInCallButtonUiReady);
- mInCallButtonUi = ui;
+ inCallButtonUi = ui;
AudioModeProvider.getInstance().addListener(this);
// register for call state changes last
@@ -96,7 +96,7 @@ public class CallButtonPresenter
@Override
public void onInCallButtonUiUnready() {
Assert.checkState(isInCallButtonUiReady);
- mInCallButtonUi = null;
+ inCallButtonUi = null;
InCallPresenter.getInstance().removeListener(this);
AudioModeProvider.getInstance().removeListener(this);
InCallPresenter.getInstance().removeIncomingCallListener(this);
@@ -110,16 +110,16 @@ public class CallButtonPresenter
public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
Trace.beginSection("CallButtonPresenter.onStateChange");
if (newState == InCallState.OUTGOING) {
- mCall = callList.getOutgoingCall();
+ call = callList.getOutgoingCall();
} else if (newState == InCallState.INCALL) {
- mCall = callList.getActiveOrBackgroundCall();
+ call = callList.getActiveOrBackgroundCall();
// When connected to voice mail, automatically shows the dialpad.
// (On previous releases we showed it when in-call shows up, before waiting for
// OUTGOING. We may want to do that once we start showing "Voice mail" label on
// the dialpad too.)
- if (oldState == InCallState.OUTGOING && mCall != null) {
- if (mCall.isVoiceMailNumber() && getActivity() != null) {
+ if (oldState == InCallState.OUTGOING && call != null) {
+ if (call.isVoiceMailNumber() && getActivity() != null) {
getActivity().showDialpadFragment(true /* show */, true /* animate */);
}
}
@@ -127,11 +127,11 @@ public class CallButtonPresenter
if (getActivity() != null) {
getActivity().showDialpadFragment(false /* show */, true /* animate */);
}
- mCall = callList.getIncomingCall();
+ call = callList.getIncomingCall();
} else {
- mCall = null;
+ call = null;
}
- updateUi(newState, mCall);
+ updateUi(newState, call);
Trace.endSection();
}
@@ -146,7 +146,7 @@ public class CallButtonPresenter
@Override
public void onDetailsChanged(DialerCall call, android.telecom.Call.Details details) {
// Only update if the changes are for the currently active call
- if (mInCallButtonUi != null && call != null && call.equals(mCall)) {
+ if (inCallButtonUi != null && call != null && call.equals(this.call)) {
updateButtonsState(call);
}
}
@@ -158,15 +158,15 @@ public class CallButtonPresenter
@Override
public void onCanAddCallChanged(boolean canAddCall) {
- if (mInCallButtonUi != null && mCall != null) {
- updateButtonsState(mCall);
+ if (inCallButtonUi != null && call != null) {
+ updateButtonsState(call);
}
}
@Override
public void onAudioStateChanged(CallAudioState audioState) {
- if (mInCallButtonUi != null) {
- mInCallButtonUi.setAudioState(audioState);
+ if (inCallButtonUi != null) {
+ inCallButtonUi.setAudioState(audioState);
}
}
@@ -192,25 +192,25 @@ public class CallButtonPresenter
// It's clear the UI is wrong, so update the supported mode once again.
LogUtil.e(
"CallButtonPresenter", "toggling speakerphone not allowed when bluetooth supported.");
- mInCallButtonUi.setAudioState(audioState);
+ inCallButtonUi.setAudioState(audioState);
return;
}
int newRoute;
if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_WIRED_OR_EARPIECE,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
} else {
newRoute = CallAudioState.ROUTE_SPEAKER;
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_SPEAKERPHONE,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
}
setAudioRoute(newRoute);
@@ -221,61 +221,61 @@ public class CallButtonPresenter
LogUtil.i(
"CallButtonPresenter", "turning on mute: %s, clicked by user: %s", checked, clickedByUser);
if (clickedByUser) {
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
checked
? DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_MUTE
: DialerImpression.Type.IN_CALL_SCREEN_TURN_OFF_MUTE,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
}
TelecomAdapter.getInstance().mute(checked);
}
@Override
public void holdClicked(boolean checked) {
- if (mCall == null) {
+ if (call == null) {
return;
}
if (checked) {
- LogUtil.i("CallButtonPresenter", "putting the call on hold: " + mCall);
- mCall.hold();
+ LogUtil.i("CallButtonPresenter", "putting the call on hold: " + call);
+ call.hold();
} else {
- LogUtil.i("CallButtonPresenter", "removing the call from hold: " + mCall);
- mCall.unhold();
+ LogUtil.i("CallButtonPresenter", "removing the call from hold: " + call);
+ call.unhold();
}
}
@Override
public void swapClicked() {
- if (mCall == null) {
+ if (call == null) {
return;
}
- LogUtil.i("CallButtonPresenter", "swapping the call: " + mCall);
- TelecomAdapter.getInstance().swap(mCall.getId());
+ LogUtil.i("CallButtonPresenter", "swapping the call: " + call);
+ TelecomAdapter.getInstance().swap(call.getId());
}
@Override
public void mergeClicked() {
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_MERGE_BUTTON_PRESSED,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
- TelecomAdapter.getInstance().merge(mCall.getId());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
+ TelecomAdapter.getInstance().merge(call.getId());
}
@Override
public void addCallClicked() {
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_ADD_CALL_BUTTON_PRESSED,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
// Automatically mute the current call
- mAutomaticallyMuted = true;
- mPreviousMuteState = AudioModeProvider.getInstance().getAudioState().isMuted();
+ automaticallyMuted = true;
+ previousMuteState = AudioModeProvider.getInstance().getAudioState().isMuted();
// Simulate a click on the mute button
muteClicked(true /* checked */, false /* clickedByUser */);
TelecomAdapter.getInstance().addCall();
@@ -283,11 +283,11 @@ public class CallButtonPresenter
@Override
public void showDialpadClicked(boolean checked) {
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_SHOW_DIALPAD_BUTTON_PRESSED,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
LogUtil.v("CallButtonPresenter", "show dialpad " + String.valueOf(checked));
getActivity().showDialpadFragment(checked /* show */, true /* animate */);
}
@@ -295,25 +295,25 @@ public class CallButtonPresenter
@Override
public void changeToVideoClicked() {
LogUtil.enterBlock("CallButtonPresenter.changeToVideoClicked");
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.VIDEO_CALL_UPGRADE_REQUESTED,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
- mCall.getVideoTech().upgradeToVideo(mContext);
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
+ call.getVideoTech().upgradeToVideo(context);
}
@Override
public void onEndCallClicked() {
- LogUtil.i("CallButtonPresenter.onEndCallClicked", "call: " + mCall);
- if (mCall != null) {
- mCall.disconnect();
+ LogUtil.i("CallButtonPresenter.onEndCallClicked", "call: " + call);
+ if (call != null) {
+ call.disconnect();
}
}
@Override
public void showAudioRouteSelector() {
- mInCallButtonUi.showAudioRouteSelector();
+ inCallButtonUi.showAudioRouteSelector();
}
@Override
@@ -323,9 +323,9 @@ public class CallButtonPresenter
SwapSimWorker worker =
new SwapSimWorker(
getContext(),
- mCall,
+ call,
InCallPresenter.getInstance().getCallList(),
- mOtherAccount,
+ otherAccount,
InCallPresenter.getInstance().acquireInCallUiLock("swapSim"));
DialerExecutorComponent.get(getContext())
.dialerExecutorFactory()
@@ -348,14 +348,14 @@ public class CallButtonPresenter
@Override
public void toggleCameraClicked() {
LogUtil.i("CallButtonPresenter.toggleCameraClicked", "");
- if (mCall == null) {
+ if (call == null) {
return;
}
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
DialerImpression.Type.IN_CALL_SCREEN_SWAP_CAMERA,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
switchCameraClicked(
!InCallPresenter.getInstance().getInCallCameraManager().isUsingFrontFacingCamera());
}
@@ -370,25 +370,25 @@ public class CallButtonPresenter
public void pauseVideoClicked(boolean pause) {
LogUtil.i("CallButtonPresenter.pauseVideoClicked", "%s", pause ? "pause" : "unpause");
- Logger.get(mContext)
+ Logger.get(context)
.logCallImpression(
pause
? DialerImpression.Type.IN_CALL_SCREEN_TURN_OFF_VIDEO
: DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_VIDEO,
- mCall.getUniqueCallId(),
- mCall.getTimeAddedMs());
+ call.getUniqueCallId(),
+ call.getTimeAddedMs());
if (pause) {
- mCall.getVideoTech().setCamera(null);
- mCall.getVideoTech().stopTransmission();
+ call.getVideoTech().setCamera(null);
+ call.getVideoTech().stopTransmission();
} else {
updateCamera(
InCallPresenter.getInstance().getInCallCameraManager().isUsingFrontFacingCamera());
- mCall.getVideoTech().resumeTransmission(mContext);
+ call.getVideoTech().resumeTransmission(context);
}
- mInCallButtonUi.setVideoPaused(pause);
- mInCallButtonUi.enableButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, false);
+ inCallButtonUi.setVideoPaused(pause);
+ inCallButtonUi.enableButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, false);
}
private void updateCamera(boolean useFrontFacingCamera) {
@@ -401,26 +401,26 @@ public class CallButtonPresenter
cameraManager.isUsingFrontFacingCamera()
? CameraDirection.CAMERA_DIRECTION_FRONT_FACING
: CameraDirection.CAMERA_DIRECTION_BACK_FACING;
- mCall.setCameraDir(cameraDir);
- mCall.getVideoTech().setCamera(cameraId);
+ call.setCameraDir(cameraDir);
+ call.getVideoTech().setCamera(cameraId);
}
}
private void updateUi(InCallState state, DialerCall call) {
LogUtil.v("CallButtonPresenter", "updating call UI for call: %s", call);
- if (mInCallButtonUi == null) {
+ if (inCallButtonUi == null) {
return;
}
if (call != null) {
- mInCallButtonUi.updateInCallButtonUiColors(
+ inCallButtonUi.updateInCallButtonUiColors(
InCallPresenter.getInstance().getThemeColorManager().getSecondaryColor());
}
final boolean isEnabled =
state.isConnectingOrConnected() && !state.isIncoming() && call != null;
- mInCallButtonUi.setEnabled(isEnabled);
+ inCallButtonUi.setEnabled(isEnabled);
if (call == null) {
return;
@@ -451,53 +451,53 @@ public class CallButtonPresenter
final boolean isCallOnHold = call.getState() == DialerCall.State.ONHOLD;
final boolean showAddCall =
- TelecomAdapter.getInstance().canAddCall() && UserManagerCompat.isUserUnlocked(mContext);
+ TelecomAdapter.getInstance().canAddCall() && UserManagerCompat.isUserUnlocked(context);
final boolean showMerge = call.can(android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE);
final boolean showUpgradeToVideo = !isVideo && (hasVideoCallCapabilities(call));
final boolean showDowngradeToAudio = isVideo && isDowngradeToAudioSupported(call);
final boolean showMute = call.can(android.telecom.Call.Details.CAPABILITY_MUTE);
final boolean hasCameraPermission =
- isVideo && VideoUtils.hasCameraPermissionAndShownPrivacyToast(mContext);
+ isVideo && VideoUtils.hasCameraPermissionAndShownPrivacyToast(context);
// Disabling local video doesn't seem to work when dialing. See a bug.
final boolean showPauseVideo =
isVideo
&& call.getState() != DialerCall.State.DIALING
&& call.getState() != DialerCall.State.CONNECTING;
- mOtherAccount = TelecomUtil.getOtherAccount(getContext(), call.getAccountHandle());
+ otherAccount = TelecomUtil.getOtherAccount(getContext(), call.getAccountHandle());
boolean showSwapSim =
- mOtherAccount != null
+ otherAccount != null
&& !call.isVoiceMailNumber()
&& DialerCall.State.isDialing(call.getState())
// Most devices cannot make calls on 2 SIMs at the same time.
&& InCallPresenter.getInstance().getCallList().getAllCalls().size() == 1;
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_AUDIO, true);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP, showSwap);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_HOLD, showHold);
- mInCallButtonUi.setHold(isCallOnHold);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_MUTE, showMute);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP_SIM, showSwapSim);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_ADD_CALL, true);
- mInCallButtonUi.enableButton(InCallButtonIds.BUTTON_ADD_CALL, showAddCall);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_DOWNGRADE_TO_AUDIO, showDowngradeToAudio);
- mInCallButtonUi.showButton(
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_AUDIO, true);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP, showSwap);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_HOLD, showHold);
+ inCallButtonUi.setHold(isCallOnHold);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_MUTE, showMute);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP_SIM, showSwapSim);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_ADD_CALL, true);
+ inCallButtonUi.enableButton(InCallButtonIds.BUTTON_ADD_CALL, showAddCall);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_DOWNGRADE_TO_AUDIO, showDowngradeToAudio);
+ inCallButtonUi.showButton(
InCallButtonIds.BUTTON_SWITCH_CAMERA,
isVideo && hasCameraPermission && call.getVideoTech().isTransmitting());
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, showPauseVideo);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, showPauseVideo);
if (isVideo) {
- mInCallButtonUi.setVideoPaused(!call.getVideoTech().isTransmitting() || !hasCameraPermission);
+ inCallButtonUi.setVideoPaused(!call.getVideoTech().isTransmitting() || !hasCameraPermission);
}
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_DIALPAD, true);
- mInCallButtonUi.showButton(InCallButtonIds.BUTTON_MERGE, showMerge);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_DIALPAD, true);
+ inCallButtonUi.showButton(InCallButtonIds.BUTTON_MERGE, showMerge);
- mInCallButtonUi.updateButtonStates();
+ inCallButtonUi.updateButtonStates();
}
private boolean hasVideoCallCapabilities(DialerCall call) {
- return call.getVideoTech().isAvailable(mContext);
+ return call.getVideoTech().isAvailable(context);
}
/**
@@ -516,52 +516,51 @@ public class CallButtonPresenter
@Override
public void refreshMuteState() {
// Restore the previous mute state
- if (mAutomaticallyMuted
- && AudioModeProvider.getInstance().getAudioState().isMuted() != mPreviousMuteState) {
- if (mInCallButtonUi == null) {
+ if (automaticallyMuted
+ && AudioModeProvider.getInstance().getAudioState().isMuted() != previousMuteState) {
+ if (inCallButtonUi == null) {
return;
}
- muteClicked(mPreviousMuteState, false /* clickedByUser */);
+ muteClicked(previousMuteState, false /* clickedByUser */);
}
- mAutomaticallyMuted = false;
+ automaticallyMuted = false;
}
@Override
public void onSaveInstanceState(Bundle outState) {
- outState.putBoolean(KEY_AUTOMATICALLY_MUTED, mAutomaticallyMuted);
- outState.putBoolean(KEY_PREVIOUS_MUTE_STATE, mPreviousMuteState);
+ outState.putBoolean(KEY_AUTOMATICALLY_MUTED, automaticallyMuted);
+ outState.putBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
- mAutomaticallyMuted =
- savedInstanceState.getBoolean(KEY_AUTOMATICALLY_MUTED, mAutomaticallyMuted);
- mPreviousMuteState = savedInstanceState.getBoolean(KEY_PREVIOUS_MUTE_STATE, mPreviousMuteState);
+ automaticallyMuted = savedInstanceState.getBoolean(KEY_AUTOMATICALLY_MUTED, automaticallyMuted);
+ previousMuteState = savedInstanceState.getBoolean(KEY_PREVIOUS_MUTE_STATE, previousMuteState);
}
@Override
public void onCameraPermissionGranted() {
- if (mCall != null) {
- updateButtonsState(mCall);
+ if (call != null) {
+ updateButtonsState(call);
}
}
@Override
public void onActiveCameraSelectionChanged(boolean isUsingFrontFacingCamera) {
- if (mInCallButtonUi == null) {
+ if (inCallButtonUi == null) {
return;
}
- mInCallButtonUi.setCameraSwitched(!isUsingFrontFacingCamera);
+ inCallButtonUi.setCameraSwitched(!isUsingFrontFacingCamera);
}
@Override
public Context getContext() {
- return mContext;
+ return context;
}
private InCallActivity getActivity() {
- if (mInCallButtonUi != null) {
- Fragment fragment = mInCallButtonUi.getInCallButtonUiFragment();
+ if (inCallButtonUi != null) {
+ Fragment fragment = inCallButtonUi.getInCallButtonUiFragment();
if (fragment != null) {
return (InCallActivity) fragment.getActivity();
}