Don\'t show SSID for Wi-Fi calls.
automerge: 1a3d05d

* commit '1a3d05dc126773f0e0d32135f9b1018f1a4c8b5e':
  Don't show SSID for Wi-Fi calls.
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index 663c412..fd06e53 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -371,8 +371,12 @@
     }
 
     public boolean isVideoCall(Context context) {
-        return CallUtil.isVideoEnabled(context) &&
-                VideoProfile.VideoState.isBidirectional(getVideoState());
+        // We want to show Video call buttons even if only one direction is enabled
+        // (That is what is happening when we receive a video call for example)
+        return CallUtil.isVideoEnabled(context) && (
+            VideoProfile.VideoState.isBidirectional(getVideoState()) ||
+            VideoProfile.VideoState.isReceptionEnabled(getVideoState()) ||
+            VideoProfile.VideoState.isTransmissionEnabled(getVideoState()));
     }
 
     public void setSessionModificationState(int state) {
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 9897d37..9fedc95 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -258,7 +258,7 @@
                 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 28f449b..6550eec 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -796,16 +796,6 @@
     }
 
     /**
-     * Changes the visibility of the contact photo.
-     *
-     * @param isVisible {@code True} if the UI should show the contact photo.
-     */
-    @Override
-    public void setPhotoVisible(boolean isVisible) {
-        mPhoto.setVisibility(isVisible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
      * Changes the visibility of the HD audio icon.
      *
      * @param visible {@code true} if the UI should show the HD audio icon.
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index d7e39d8..3a4c46a 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -248,14 +248,6 @@
             getUi().showHdAudioIndicator(false);
         }
 
-        // Hide/show the contact photo based on the video state.
-        // If the primary call is a video call on hold, still show the contact photo.
-        // If the primary call is an active video call, hide the contact photo.
-        if (mPrimary != null) {
-            getUi().setPhotoVisible(!(mPrimary.isVideoCall(mContext) &&
-                    callState != Call.State.ONHOLD));
-        }
-
         maybeShowManageConferenceCallButton();
 
         final boolean enableEndCallButton = Call.State.isConnectingOrConnected(callState) &&
@@ -334,9 +326,15 @@
     private void setCallbackNumber() {
         String callbackNumber = null;
 
+        // Show the emergency callback number if either:
+        // 1. This is an emergency call.
+        // 2. The phone is in Emergency Callback Mode, which means we should show the callback
+        //    number.
         boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber(
                 getNumberFromHandle(mPrimary.getHandle()));
-        if (isEmergencyCall) {
+        boolean showCallbackNumber = mPrimary.can(Details.CAPABILITY_SHOW_CALLBACK_NUMBER);
+
+        if (isEmergencyCall || showCallbackNumber) {
             callbackNumber = getSubscriptionNumber();
         } else {
             StatusHints statusHints = mPrimary.getTelecommCall().getDetails().getStatusHints();
@@ -350,12 +348,13 @@
 
         TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
         String simNumber = mgr.getLine1Number(mPrimary.getAccountHandle());
-        if (PhoneNumberUtils.compare(callbackNumber, simNumber)) {
-            Log.d(this, "Numbers are the same; not showing the callback number");
+        if (!showCallbackNumber && PhoneNumberUtils.compare(callbackNumber, simNumber)) {
+            Log.d(this, "Numbers are the same (and callback number is not being forced to show);" +
+                            " not showing the callback number");
             callbackNumber = null;
         }
 
-        getUi().setCallbackNumber(callbackNumber, isEmergencyCall);
+        getUi().setCallbackNumber(callbackNumber, isEmergencyCall || showCallbackNumber);
     }
 
     public void updateCallTime() {
@@ -746,7 +745,6 @@
         void setPrimaryLabel(String label);
         void setEndCallButtonEnabled(boolean enabled, boolean animate);
         void setCallbackNumber(String number, boolean isEmergencyCalls);
-        void setPhotoVisible(boolean isVisible);
         void setProgressSpinnerVisible(boolean visible);
         void showHdAudioIndicator(boolean visible);
         void showManageConferenceCallButton(boolean visible);
diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
index 4754712..b50fdd8 100644
--- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java
+++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
@@ -124,6 +124,7 @@
                 mTargetTriggered = true;
                 break;
             case R.drawable.ic_videocam:
+            case R.drawable.ic_lockscreen_answer_video:
                 mAnswerListener.onAnswer(VideoProfile.VideoState.BIDIRECTIONAL, getContext());
                 mTargetTriggered = true;
                 break;
diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java
index 363bd41..245fc73 100644
--- a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java
+++ b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java
@@ -86,9 +86,14 @@
                 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 4a02160..006339c 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -207,6 +207,14 @@
                 (!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 @@
         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/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java
index 0b5bb4b..7859a17 100644
--- a/InCallUI/src/com/android/incallui/VideoCallFragment.java
+++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java
@@ -164,7 +164,7 @@
             // orientation change.
             if (mSavedSurfaceTexture == null) {
                 mSavedSurfaceTexture = surfaceTexture;
-                surfaceCreated = createSurface();
+                surfaceCreated = createSurface(width, height);
             } else {
                 // A saved SurfaceTexture was found.
                 surfaceCreated = true;
@@ -266,18 +266,20 @@
             mHeight = height;
 
             if (mSavedSurfaceTexture != null) {
-                createSurface();
+                createSurface(width, height);
             }
         }
 
         /**
          * Creates the {@link Surface}, adjusting the {@link SurfaceTexture} buffer size.
+         * @param width The width of the surface to create.
+         * @param height The height of the surface to create.
          */
-        private boolean createSurface() {
-            if (mWidth != DIMENSIONS_NOT_SET && mHeight != DIMENSIONS_NOT_SET &&
-                    mSavedSurfaceTexture != null) {
+        private boolean createSurface(int width, int height) {
+            if (width != DIMENSIONS_NOT_SET && height != DIMENSIONS_NOT_SET
+                    && mSavedSurfaceTexture != null) {
 
-                mSavedSurfaceTexture.setDefaultBufferSize(mWidth, mHeight);
+                mSavedSurfaceTexture.setDefaultBufferSize(width, height);
                 mSavedSurface = new Surface(mSavedSurfaceTexture);
                 return true;
             }
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index ed00241..38d7c95 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -173,6 +173,8 @@
         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);
@@ -256,6 +258,8 @@
             mVideoCall.setDisplaySurface(null);
         } else if (surface == VideoCallFragment.SURFACE_PREVIEW) {
             mVideoCall.setPreviewSurface(null);
+            // Also disable camera as preview is closed
+            mVideoCall.setCamera(null);
         }
     }
 
@@ -441,6 +445,11 @@
         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;
@@ -559,7 +568,8 @@
 
     @Override
     public void onDowngradeToAudio(Call call) {
-        // Implementing to satsify interface.
+        // exit video mode
+        exitVideoMode();
     }
 
     /**