Held Conference call should not be automatically resumed

While removing call, if the forground call is in hold, then
CallsManager in Telecom is trying to resume the call.
foreground call should not be resumed when the disconnected
call was one of the conference call. So, other calls state
will remain same as before.

Change-Id: I27a1d4fa09d4dd8e6dbb78d2fe60efe1b230e0e6
CRs-Fixed: 1002700
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 2badabf..a9625d4 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -272,6 +272,8 @@
 
     private boolean mSpeakerphoneOn;
 
+    private boolean mIsHoldInConference = false;
+
     /**
      * Tracks the video states which were applicable over the duration of a call.
      * See {@link VideoProfile} for a list of valid video states.
@@ -613,6 +615,14 @@
             mState = newState;
             maybeLoadCannedSmsResponses();
 
+            if (mState == CallState.ON_HOLD && getParentCall() != null) {
+                Log.v(this, "setState is conference hold, %s", mState);
+                mIsHoldInConference = true;
+            } else if (mState != CallState.DISCONNECTED) {
+                Log.v(this, "setState is not conference hold, %s", mState);
+                mIsHoldInConference = false;
+            }
+
             if (mState == CallState.ACTIVE || mState == CallState.ON_HOLD) {
                 if (mConnectTimeMillis == 0) {
                     // We check to see if mConnectTime is already set to prevent the
@@ -1030,6 +1040,10 @@
         return mWasConferencePreviouslyMerged;
     }
 
+    boolean isHoldInConference() {
+        return mIsHoldInConference;
+    }
+
     @VisibleForTesting
     public Call getConferenceLevelActiveCall() {
         return mConferenceLevelActiveCall;
@@ -1326,6 +1340,9 @@
         if (mState == CallState.ACTIVE) {
             mConnectionService.hold(this);
             Log.event(this, Log.Events.REQUEST_HOLD);
+            if (getParentCall() != null) {
+                mIsHoldInConference = true;
+            }
         }
     }
 
@@ -1338,6 +1355,7 @@
         if (mState == CallState.ON_HOLD) {
             mConnectionService.unhold(this);
             Log.event(this, Log.Events.REQUEST_UNHOLD);
+            mIsHoldInConference = false;
         }
     }
 
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 9b90196..6ecb12e 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1535,6 +1535,10 @@
      * Removes an existing disconnected call, and notifies the in-call app.
      */
     void markCallAsRemoved(Call call) {
+        boolean isHoldInConference = call.isHoldInConference();
+        Log.v(this, "markCallAsRemoved: isHoldInConference = "
+                + isHoldInConference + "call -> %s", call);
+
         removeCall(call);
         if (!hasAnyCalls()) {
             updateLchStatus(null);
@@ -1544,7 +1548,8 @@
         if (mLocallyDisconnectingCalls.contains(call)) {
             mLocallyDisconnectingCalls.remove(call);
             Call foregroundCall = mCallAudioManager.getPossiblyHeldForegroundCall();
-            if (foregroundCall != null && foregroundCall.getState() == CallState.ON_HOLD) {
+            if (!isHoldInConference && foregroundCall != null
+                    && foregroundCall.getState() == CallState.ON_HOLD) {
                 foregroundCall.unhold();
             }
         }