diff options
Diffstat (limited to 'InCallUI/src/com/android')
6 files changed, 45 insertions, 57 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 9897d3744..9fedc95b1 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -258,7 +258,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto new VideoProfile(VideoProfile.VideoState.BIDIRECTIONAL); videoCall.sendSessionModifyRequest(videoProfile); - mCall.setSessionModificationState(Call.SessionModificationState.REQUEST_FAILED); + mCall.setSessionModificationState(Call.SessionModificationState.WAITING_FOR_RESPONSE); } /** diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 5f5146e19..94e4ef161 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -491,10 +491,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr DisconnectCause disconnectCause, String connectionLabel, Drawable callStateIcon, - String gatewayNumber) { + String gatewayNumber, + boolean isWifi) { boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber); CharSequence callStateLabel = getCallStateLabelFromState(state, videoState, - sessionModificationState, disconnectCause, connectionLabel, isGatewayCall); + sessionModificationState, disconnectCause, connectionLabel, isGatewayCall, isWifi); Log.v(this, "setCallState " + callStateLabel); Log.v(this, "DisconnectCause " + disconnectCause.toString()); @@ -502,6 +503,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr if (TextUtils.equals(callStateLabel, mCallStateLabel.getText())) { // Nothing to do if the labels are the same + if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) { + mCallStateLabel.clearAnimation(); + mCallStateIcon.clearAnimation(); + } return; } @@ -655,10 +660,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr * 2. Ongoing calls will display the name of the provider. * 3. Incoming calls will only display "Incoming via..." for accounts. * 4. Video calls, and session modification states (eg. requesting video). + * 5. Incoming and active Wi-Fi calls will show label provided by hint. */ private CharSequence getCallStateLabelFromState(int state, int videoState, int sessionModificationState, DisconnectCause disconnectCause, String label, - boolean isGatewayCall) { + boolean isGatewayCall, boolean isWifi) { final Context context = getView().getContext(); CharSequence callStateLabel = null; // Label to display as part of the call banner @@ -672,7 +678,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr case Call.State.ACTIVE: // We normally don't show a "call state label" at all in this state // (but we can use the call state label to display the provider name). - if (isAccount) { + if (isAccount || isWifi) { callStateLabel = label; } else if (sessionModificationState == Call.SessionModificationState.REQUEST_FAILED) { @@ -689,7 +695,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr break; case Call.State.CONNECTING: case Call.State.DIALING: - if (isSpecialCall) { + if (isSpecialCall && !isWifi) { callStateLabel = context.getString(R.string.calling_via_template, label); } else { callStateLabel = context.getString(R.string.card_title_dialing); @@ -700,7 +706,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr break; case Call.State.INCOMING: case Call.State.CALL_WAITING: - if (isAccount) { + if (isWifi) { + callStateLabel = label; + } else if (isAccount) { callStateLabel = context.getString(R.string.incoming_via_template, label); } else if (VideoProfile.VideoState.isBidirectional(videoState)) { callStateLabel = context.getString(R.string.notification_incoming_video_call); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 690e2470d..59263270d 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -25,7 +25,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.net.wifi.WifiManager; import android.os.Bundle; import android.telecom.Call.Details; import android.telecom.DisconnectCause; @@ -71,7 +70,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> private CallTimer mCallTimer; private Context mContext; - private WifiManager mWifiManager; public static class ContactLookupCallback implements ContactInfoCacheCallback { private final WeakReference<CallCardPresenter> mCallCardPresenter; @@ -112,7 +110,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> public void init(Context context, Call call) { mContext = Preconditions.checkNotNull(context); - mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); // Call may be null if disconnect happened already. if (call != null) { @@ -251,7 +248,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> new DisconnectCause(DisconnectCause.UNKNOWN), null, null, - null); + null, + false /* isWifi */); getUi().showHdAudioIndicator(false); } @@ -298,7 +296,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> mPrimary.getDisconnectCause(), getConnectionLabel(), getCallStateIcon(), - getGatewayNumber()); + getGatewayNumber(), + primaryCallCan(Details.CAPABILITY_WIFI)); boolean showHdAudioIndicator = isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_HIGH_DEF_AUDIO); @@ -604,13 +603,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> return statusHints.getLabel().toString(); } - // Assume the SSID of the connection reported by the WifiManager is the name of the wifi - // network used for calling, since currently a phone only connects to a single wifi network. - if (isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_WIFI) - && mWifiManager.getConnectionInfo() != null) { - return formatWifiSSID(mWifiManager.getConnectionInfo().getSSID()); - } - if (hasOutgoingGatewayCall() && getUi() != null) { // Return the label for the gateway app on outgoing calls. final PackageManager pm = mContext.getPackageManager(); @@ -636,11 +628,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } - if (primaryCallCan(Details.CAPABILITY_WIFI) && (isPrimaryCallActive() - || (mPrimary != null && mPrimary.getState() == Call.State.INCOMING))) { - return mContext.getResources().getDrawable(R.drawable.ic_signal_wifi_4_bar_18dp); - } - return null; } @@ -747,34 +734,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> return photo; } - /** - * Strip quotations off the outside of a Wifi SSID identifier. For example, \"GoogleGuest\" - * becomes GoogleGuest. - * - * TODO: Move into utility class. - * TODO: Add unit tests. - * - * @param ssid The ssid of the wifi network. - */ - private String formatWifiSSID(String ssid) { - if (TextUtils.isEmpty(ssid)) { - return ""; - } - - // Trim quotation if first character. - if (ssid.charAt(0) == '\"') { - ssid = ssid.substring(1); - } - - // Trim quotation if last character. - int lastIndex = ssid.length() - 1; - if (lastIndex >= 0 && ssid.charAt(lastIndex) == '\"') { - ssid = ssid.substring(0, lastIndex); - } - - return ssid; - } - public interface CallCardUi extends Ui { void setVisible(boolean on); void setCallCardVisible(boolean visible); @@ -784,7 +743,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> String providerLabel, boolean isConference); void setCallState(int state, int videoState, int sessionModificationState, DisconnectCause disconnectCause, String connectionLabel, - Drawable connectionIcon, String gatewayNumber); + Drawable connectionIcon, String gatewayNumber, boolean isWifi); void setPrimaryCallElapsedTime(boolean show, long duration); void setPrimaryName(String name, boolean nameIsNumber); void setPrimaryImage(Drawable image); diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java index 3d975dbb7..4ba2bd993 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java @@ -86,9 +86,14 @@ public class InCallVideoCallListener extends VideoCall.Listener { VideoProfile.VideoState.isBidirectional(responseProfile.getVideoState()); if (modifySucceeded && isVideoCall) { + // Local Upgrade success InCallVideoCallListenerNotifier.getInstance().upgradeToVideoSuccess(mCall); } else if (!modifySucceeded || status != Connection.VideoProvider.SESSION_MODIFY_REQUEST_SUCCESS) { + // Remote didn't accept invitation in bidirectional state or failure InCallVideoCallListenerNotifier.getInstance().upgradeToVideoFail(mCall); + } else if (modifySucceeded && !isVideoCall) { + // Local Downgrade success (should always be successful) + InCallVideoCallListenerNotifier.getInstance().downgradeToAudio(mCall); } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index bdc27691b..c5a0b7f4c 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -207,6 +207,14 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { (!isOutgoingWithoutIncallUi || mNotificationTimer.getState() == NotificationTimer.State.FIRED); + // For call upgrade + if ((call != null) + && (call.getSessionModificationState() + == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST)) { + Log.d(this, "updateInCallNotification, notify of callupgrade to video!"); + showNotificationNow = true; + } + if (showNotificationNow) { showNotification(call); } else { @@ -556,16 +564,16 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { Log.i(this, "Will show \"accept\" action in the incoming call Notification"); PendingIntent acceptVideoPendingIntent = createNotificationPendingIntent( - mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + mContext, InCallApp.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST); builder.addAction(0, mContext.getText(R.string.notification_action_accept), - acceptVideoPendingIntent); + acceptVideoPendingIntent); } private void addDismissUpgradeRequestAction(Notification.Builder builder) { Log.i(this, "Will show \"dismiss\" action in the incoming call Notification"); PendingIntent declineVideoPendingIntent = createNotificationPendingIntent( - mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + mContext, InCallApp.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST); builder.addAction(0, mContext.getText(R.string.notification_action_dismiss), declineVideoPendingIntent); } diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 04d304b21..d63c6e8b1 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -177,6 +177,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addIncomingCallListener(this); InCallPresenter.getInstance().addOrientationListener(this); + // To get updates of video call details changes + InCallPresenter.getInstance().addDetailsListener(this); // Register for surface and video events from {@link InCallVideoCallListener}s. InCallVideoCallListenerNotifier.getInstance().addSurfaceChangeListener(this); @@ -455,6 +457,11 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().setInCallAllowsOrientationChange(false); ui.showVideoUi(false); + if (mVideoCall != null) { + // Also disable camera otherwise it will be already in use for next upgrade + mVideoCall.setCamera(null); + } + if (mPreVideoAudioMode != AudioModeProvider.AUDIO_MODE_INVALID) { TelecomAdapter.getInstance().setAudioRoute(mPreVideoAudioMode); mPreVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; @@ -573,7 +580,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi @Override public void onDowngradeToAudio(Call call) { - // Implementing to satisfy interface. + // exit video mode + exitVideoMode(); } /** |