From 0175dc9a647e1b9b013ad5c3b855a7594d7fbedb Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Sun, 6 Dec 2015 21:49:50 -0800 Subject: Code cleanup. 1. Renamed some Call methods and cleaned up comments. 2. Renamed Incall CallUtils to VideoUtils. 3. Fixed some improper licenses. Bug: 20089489 Change-Id: Ia503db3b65d9aa990e562411de783f38dd08a9c2 --- .../src/com/android/incallui/AnswerPresenter.java | 4 +- InCallUI/src/com/android/incallui/Call.java | 60 ++++++----- .../com/android/incallui/CallButtonPresenter.java | 4 +- .../src/com/android/incallui/CallCardFragment.java | 6 +- InCallUI/src/com/android/incallui/CallList.java | 3 +- InCallUI/src/com/android/incallui/CallUtils.java | 113 --------------------- .../src/com/android/incallui/InCallPresenter.java | 11 +- .../android/incallui/InCallVideoCallCallback.java | 10 +- .../com/android/incallui/VideoCallPresenter.java | 44 ++++---- .../com/android/incallui/VideoPauseController.java | 49 ++++----- InCallUI/src/com/android/incallui/VideoUtils.java | 101 ++++++++++++++++++ 11 files changed, 204 insertions(+), 201 deletions(-) delete mode 100644 InCallUI/src/com/android/incallui/CallUtils.java create mode 100644 InCallUI/src/com/android/incallui/VideoUtils.java diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index a44249b2c..76ca4a90d 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -176,7 +176,7 @@ public class AnswerPresenter extends Presenter CallList.getInstance().addCallUpdateListener(mCallId, this); final int currentVideoState = call.getVideoState(); - final int modifyToVideoState = call.getModifyToVideoState(); + final int modifyToVideoState = call.getRequestedVideoState(); if (currentVideoState == modifyToVideoState) { Log.w(this, "processVideoUpgradeRequestCall: Video states are same. Return."); @@ -282,7 +282,7 @@ public class AnswerPresenter extends Presenter // Only present the user with the option to answer as a video call if the incoming call is // a bi-directional video call. - if (CallUtils.isBidirectionalVideoCall(call)) { + if (VideoUtils.isBidirectionalVideoCall(call)) { if (withSms) { getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); getUi().configureMessageDialog(textMsgs); diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index e866b4b63..9526e7d5e 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -367,9 +367,9 @@ public class Call { private int mVideoState; /** - * mModifyToVideoState is used to store requested upgrade / downgrade video state + * mRequestedVideoState is used to store requested upgrade / downgrade video state */ - private int mModifyToVideoState = VideoProfile.STATE_AUDIO_ONLY; + private int mRequestedVideoState = VideoProfile.STATE_AUDIO_ONLY; private InCallVideoCallCallback mVideoCallCallback; private String mChildNumber; @@ -742,35 +742,41 @@ public class Call { public boolean isVideoCall(Context context) { return CallUtil.isVideoEnabled(context) && - CallUtils.isVideoCall(getVideoState()); + VideoUtils.isVideoCall(getVideoState()); } /** - * This method is called when we request for a video upgrade or downgrade. This handles the - * session modification state RECEIVED_UPGRADE_TO_VIDEO_REQUEST and sets the video state we - * want to upgrade/downgrade to. + * Handles incoming session modification requests. Stores the pending video request and sets + * the session modification state to + * {@link SessionModificationState#RECEIVED_UPGRADE_TO_VIDEO_REQUEST} so that we can keep track + * of the fact the request was received. Only upgrade requests require user confirmation and + * will be handled by this method. The remote user can turn off their own camera without + * confirmation. + * + * @param videoState The requested video state. */ - public void setSessionModificationTo(int videoState) { - Log.d(this, "setSessionModificationTo - video state= " + videoState); + public void setRequestedVideoState(int videoState) { + Log.d(this, "setRequestedVideoState - video state= " + videoState); if (videoState == getVideoState()) { mSessionModificationState = Call.SessionModificationState.NO_REQUEST; - Log.w(this,"setSessionModificationTo - Clearing session modification state"); - } else { - mSessionModificationState = - Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST; - setModifyToVideoState(videoState); - CallList.getInstance().onUpgradeToVideo(this); + Log.w(this,"setRequestedVideoState - Clearing session modification state"); + return; } - Log.d(this, "setSessionModificationTo - mSessionModificationState=" + mSessionModificationState = Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST; + mRequestedVideoState = videoState; + CallList.getInstance().onUpgradeToVideo(this); + + Log.d(this, "setRequestedVideoState - mSessionModificationState=" + mSessionModificationState + " video state= " + videoState); update(); } /** - * This method is called to handle any other session modification states other than - * RECEIVED_UPGRADE_TO_VIDEO_REQUEST. We set the modification state and reset the video state - * when an upgrade request has been completed or failed. + * Set the session modification state. Used to keep track of pending video session modification + * operations and to inform listeners of these changes. + * + * @param state the new session modification state. */ public void setSessionModificationState(int state) { boolean hasChanged = mSessionModificationState != state; @@ -790,12 +796,13 @@ public class Call { mIsEmergencyCall = TelecomCallUtil.isEmergencyCall(mTelecomCall); } - private void setModifyToVideoState(int newVideoState) { - mModifyToVideoState = newVideoState; - } - - public int getModifyToVideoState() { - return mModifyToVideoState; + /** + * Gets the video state which was requested via a session modification request. + * + * @return The video state. + */ + public int getRequestedVideoState() { + return mRequestedVideoState; } public static boolean areSame(Call call1, Call call2) { @@ -820,6 +827,11 @@ public class Call { return TextUtils.equals(call1.getNumber(), call2.getNumber()); } + /** + * Gets the current video session modification state. + * + * @return The session modification state. + */ public int getSessionModificationState() { return mSessionModificationState; } diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index ca186b34d..b0adafdb9 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -266,7 +266,7 @@ public class CallButtonPresenter extends Presenter