Ims: Clean-up old ConfURI implementation

Clean-up old ConfURI implementation

Change-Id: I33436b07abe3fce55843c50642a5c3508d9759a4
CRs-Fixed: 2645592
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 8162789..df5ac45 100755
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -1120,10 +1120,6 @@
                 mCallDirection == CALL_DIRECTION_INCOMING);
     }
 
-    public void setPostDialDigits(String postDialDigits) {
-        mPostDialDigits = postDialDigits;
-    }
-
     public String getPostDialDigits() {
         return mPostDialDigits;
     }
@@ -1996,9 +1992,6 @@
                     listener.onFailedUnknownCall(this);
                 }
                 break;
-            case CALL_DIRECTION_UNDEFINED:
-                mCallsManager.markCallAsRemoved(this);
-                break;
         }
     }
 
@@ -2562,14 +2555,6 @@
         }
     }
 
-    void addParticipantWithConference(String recipients) {
-        if (mConnectionService == null) {
-            Log.w(this, "conference requested on a call without a connection service.");
-        } else {
-            mConnectionService.addParticipantWithConference(this, recipients);
-        }
-    }
-
     @VisibleForTesting
     public void mergeConference() {
         if (mConnectionService == null) {
diff --git a/src/com/android/server/telecom/CallAudioManager.java b/src/com/android/server/telecom/CallAudioManager.java
index 5ee4555..e4cd1be 100644
--- a/src/com/android/server/telecom/CallAudioManager.java
+++ b/src/com/android/server/telecom/CallAudioManager.java
@@ -16,12 +16,9 @@
 
 package com.android.server.telecom;
 
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_DIAL_CONFERENCE_URI;
-
 import android.annotation.NonNull;
 import android.media.IAudioService;
 import android.media.ToneGenerator;
-import android.os.Bundle;
 import android.telecom.CallAudioState;
 import android.telecom.Log;
 import android.telecom.VideoProfile;
@@ -125,10 +122,9 @@
             playToneForDisconnectedCall(call);
         }
 
-        if (!isIntermediateConfURICallDisconnected(call)) {
-            onCallLeavingState(call, oldState);
-            onCallEnteringState(call, newState);
-        }
+
+        onCallLeavingState(call, oldState);
+        onCallEnteringState(call, newState);
     }
 
     @Override
@@ -376,19 +372,6 @@
                 CallAudioRouteStateMachine.TOGGLE_MUTE);
     }
 
-    private boolean isIntermediateConfURICallDisconnected(Call disconnectedCall) {
-        if(disconnectedCall.getState() != CallState.DISCONNECTED) {
-            return false;
-        }
-        Bundle callExtra = (disconnectedCall != null) ? disconnectedCall.getIntentExtras() : null;
-        final boolean isMoConfURICallDisconnected = (callExtra == null) ? false :
-                !disconnectedCall.isIncoming() &&
-                callExtra.getBoolean(EXTRA_DIAL_CONFERENCE_URI, false);
-        Log.i(this, "is ConfURI call disconnected = " + isMoConfURICallDisconnected + " call = "
-                + disconnectedCall);
-        return isMoConfURICallDisconnected && !mCallsManager.hasOnlyDisconnectedCalls();
-    }
-
     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
     public void onRingerModeChange() {
         mCallAudioModeStateMachine.sendMessageWithArgs(
@@ -593,7 +576,6 @@
                 onCallLeavingActiveDialingOrConnecting();
                 break;
             case CallState.DIALING:
-            case CallState.NEW:
                 stopRingbackForCall(call);
                 onCallLeavingActiveDialingOrConnecting();
                 break;
diff --git a/src/com/android/server/telecom/CallIntentProcessor.java b/src/com/android/server/telecom/CallIntentProcessor.java
index 09b06c6..ceaec2e 100644
--- a/src/com/android/server/telecom/CallIntentProcessor.java
+++ b/src/com/android/server/telecom/CallIntentProcessor.java
@@ -1,9 +1,5 @@
 package com.android.server.telecom;
 
-import static com.android.internal.telephony.TelephonyIntents.ADD_PARTICIPANT_KEY;
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_DIAL_CONFERENCE_URI;
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_SKIP_SCHEMA_PARSING;
-
 import com.android.server.telecom.components.ErrorDialogActivity;
 
 import android.content.Context;
@@ -118,12 +114,9 @@
         Uri handle = intent.getData();
         String scheme = handle.getScheme();
         String uriString = handle.getSchemeSpecificPart();
-        boolean isSkipSchemaParsing = intent.getBooleanExtra(
-                EXTRA_SKIP_SCHEMA_PARSING, false);
-        Log.d(CallIntentProcessor.class, "isSkipSchemaParsing = " + isSkipSchemaParsing);
 
         // Ensure sip URIs dialed using TEL scheme get converted to SIP scheme.
-        if (PhoneAccount.SCHEME_TEL.equals(scheme) && PhoneNumberUtils.isUriNumber(uriString) && !isSkipSchemaParsing) {
+        if (PhoneAccount.SCHEME_TEL.equals(scheme) && PhoneNumberUtils.isUriNumber(uriString)) {
             handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null);
         }
 
@@ -137,23 +130,6 @@
         if (clientExtras == null) {
             clientExtras = new Bundle();
         }
-        if (isSkipSchemaParsing) {
-            clientExtras.putBoolean(EXTRA_SKIP_SCHEMA_PARSING,
-                    isSkipSchemaParsing);
-            handle = Uri.fromParts(PhoneAccount.SCHEME_TEL, handle.toString(), null);
-        }
-        boolean isConferenceUri = intent.getBooleanExtra(
-                EXTRA_DIAL_CONFERENCE_URI, false);
-        Log.d(CallIntentProcessor.class, "isConferenceUri = "+isConferenceUri);
-        if (isConferenceUri) {
-            clientExtras.putBoolean(EXTRA_DIAL_CONFERENCE_URI, isConferenceUri);
-        }
-        boolean isAddParticipant = intent.getBooleanExtra(
-                ADD_PARTICIPANT_KEY, false);
-        Log.d(CallIntentProcessor.class, "isAddparticipant = "+isAddParticipant);
-        if (isAddParticipant) {
-            clientExtras.putBoolean(ADD_PARTICIPANT_KEY, isAddParticipant);
-        }
         if (intent.hasExtra(TelecomManager.EXTRA_START_CALL_WITH_RTT)) {
             boolean isStartRttCall = intent.getBooleanExtra(
                     TelecomManager.EXTRA_START_CALL_WITH_RTT, false);
@@ -199,11 +175,6 @@
                     "processOutgoingCallIntent: skip initiating user check");
         }
 
-        Log.d(CallIntentProcessor.class, " processOutgoingCallIntent handle = " + handle
-                + ", scheme = " + scheme + ", uriString = " + uriString
-                + ", isSkipSchemaParsing = " + isSkipSchemaParsing
-                + ", isAddParticipant = " + isAddParticipant);
-
         UserHandle initiatingUser = intent.getParcelableExtra(KEY_INITIATING_USER);
 
         boolean isPrivilegedDialer = defaultDialerCache.isDefaultOrSystemDialer(callingPackage,
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 765152c..009a90e 100755
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -28,10 +28,6 @@
 import static android.telecom.TelecomManager.SHORT_CALL_TIME_MS;
 import static android.telecom.TelecomManager.VERY_SHORT_CALL_TIME_MS;
 
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_DIAL_CONFERENCE_URI;
-import static com.android.internal.telephony.TelephonyIntents.ADD_PARTICIPANT_KEY;
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_SKIP_SCHEMA_PARSING;
-
 import android.Manifest;
 import android.annotation.NonNull;
 import android.app.ActivityManager;
@@ -1507,11 +1503,6 @@
                     isConference, /* isConference */
                     mClockProxy,
                     mToastFactory);
-            if ((extras != null) &&
-                    extras.getBoolean(EXTRA_DIAL_CONFERENCE_URI, false)) {
-                //Reset PostDialDigits with empty string for ConfURI call.
-                call.setPostDialDigits("");
-            }
             call.initAnalytics(callingPackage);
 
             // Ensure new calls related to self-managed calls/connections are set as such.  This
@@ -1561,27 +1552,6 @@
             call.setVideoState(videoState);
         }
 
-        boolean isAddParticipant = ((extras != null) && (extras.getBoolean(
-                ADD_PARTICIPANT_KEY, false)));
-        boolean isSkipSchemaOrConfUri = ((extras != null) && (extras.getBoolean(
-                EXTRA_SKIP_SCHEMA_PARSING, false) ||
-                extras.getBoolean(EXTRA_DIAL_CONFERENCE_URI, false)));
-
-        if (isAddParticipant) {
-            String number = handle.getSchemeSpecificPart();
-            if (!isSkipSchemaOrConfUri) {
-                number = PhoneNumberUtils.stripSeparators(number);
-            }
-            addParticipant(number);
-            mInCallController.bringToForeground(false);
-            return CompletableFuture.completedFuture(null);
-        }
-        // Force tel scheme for ims conf uri/skip schema calls to avoid selection of sip accounts
-        String scheme = (isSkipSchemaOrConfUri? PhoneAccount.SCHEME_TEL: handle.getScheme());
-
-        Log.d(this, "startOutgoingCall :: isAddParticipant=" + isAddParticipant
-                + " isSkipSchemaOrConfUri=" + isSkipSchemaOrConfUri + " scheme=" + scheme);
-
         final int finalVideoState = videoState;
         final Call finalCall = call;
         Handler outgoingCallHandler = new Handler(Looper.getMainLooper());
@@ -1595,7 +1565,7 @@
                                 findOutgoingCallPhoneAccount(requestedAccountHandle, handle,
                                         VideoProfile.isVideo(finalVideoState),
                                         finalCall.isEmergencyCall(), initiatingUser,
-                                        isConference, scheme),
+                                        isConference),
                         new LoggedHandlerExecutor(outgoingCallHandler, "CM.fOCP", mLock));
 
         // This is a block of code that executes after the list of potential phone accts has been
@@ -1932,12 +1902,12 @@
             PhoneAccountHandle targetPhoneAccountHandle, Uri handle, boolean isVideo,
             boolean isEmergency, UserHandle initiatingUser) {
        return findOutgoingCallPhoneAccount(targetPhoneAccountHandle, handle, isVideo,
-               isEmergency, initiatingUser, false/* isConference */, null/* scheme */);
+               isEmergency, initiatingUser, false/* isConference */);
     }
 
     public CompletableFuture<List<PhoneAccountHandle>> findOutgoingCallPhoneAccount(
             PhoneAccountHandle targetPhoneAccountHandle, Uri handle, boolean isVideo,
-            boolean isEmergency, UserHandle initiatingUser, boolean isConference, String scheme) {
+            boolean isEmergency, UserHandle initiatingUser, boolean isConference) {
 
         if (isSelfManaged(targetPhoneAccountHandle, initiatingUser)) {
             return CompletableFuture.completedFuture(Arrays.asList(targetPhoneAccountHandle));
@@ -1947,12 +1917,12 @@
         // Try to find a potential phone account, taking into account whether this is a video
         // call.
         accounts = constructPossiblePhoneAccounts(handle, initiatingUser, isVideo, isEmergency,
-                isConference, scheme);
+                isConference);
         if (isVideo && accounts.size() == 0) {
             // Placing a video call but no video capable accounts were found, so consider any
             // call capable accounts (we can fallback to audio).
             accounts = constructPossiblePhoneAccounts(handle, initiatingUser,
-                    false /* isVideo */, isEmergency /* isEmergency */, isConference, scheme);
+                    false /* isVideo */, isEmergency /* isEmergency */, isConference);
         }
         Log.v(this, "findOutgoingCallPhoneAccount: accounts = " + accounts);
 
@@ -2005,7 +1975,7 @@
             // handle and verify it can be used.
             PhoneAccountHandle defaultPhoneAccountHandle =
                     mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(
-                            scheme == null ? handle.getScheme() : scheme, initiatingUser);
+                            handle.getScheme(), initiatingUser);
             if (defaultPhoneAccountHandle != null &&
                     possibleAccounts.contains(defaultPhoneAccountHandle)) {
                 return Collections.singletonList(defaultPhoneAccountHandle);
@@ -2333,22 +2303,6 @@
     }
 
     /**
-     * Attempts to add participant in a call.
-     *
-     * @param number number to connect the call with.
-     */
-    private void addParticipant(String number) {
-        Log.i(this, "addParticipant number ="+number);
-        if (getForegroundCall() == null) {
-            // don't do anything if the call no longer exists
-            Log.i(this, "Canceling unknown call.");
-            return;
-        } else {
-            getForegroundCall().addParticipantWithConference(number);
-        }
-    }
-
-    /**
      * Attempts to start a conference call for the specified call.
      *
      * @param call The call to conference.
@@ -2781,20 +2735,16 @@
     @VisibleForTesting
     public List<PhoneAccountHandle> constructPossiblePhoneAccounts(Uri handle, UserHandle user,
             boolean isVideo, boolean isEmergency) {
-        return constructPossiblePhoneAccounts(handle, user, isVideo, isEmergency, false, null);
+        return constructPossiblePhoneAccounts(handle, user, isVideo, isEmergency, false);
     }
 
     public List<PhoneAccountHandle> constructPossiblePhoneAccounts(Uri handle, UserHandle user,
-            boolean isVideo, boolean isEmergency, boolean isConference, String scheme) {
+            boolean isVideo, boolean isEmergency, boolean isConference) {
 
         if (handle == null) {
             return Collections.emptyList();
         }
 
-        if (scheme == null) {
-            scheme = handle.getScheme();
-        }
-
         // If we're specifically looking for video capable accounts, then include that capability,
         // otherwise specify no additional capability constraints. When handling the emergency call,
         // it also needs to find the phone accounts excluded by CAPABILITY_EMERGENCY_CALLS_ONLY.
@@ -2809,7 +2759,8 @@
         // That is happening while emergency account has capability CAPABILITY_EMERGENCY_CALLS_ONLY.
         if (isEmergency && allAccounts.size() == 0) {
             Log.v(this, "Try to find an emergency call only phone account");
-            allAccounts =  mPhoneAccountRegistrar.getEmergencyCallOnlyPhoneAccounts(scheme, user);
+            allAccounts =  mPhoneAccountRegistrar.
+                    getEmergencyCallOnlyPhoneAccounts(handle.getScheme(), user);
         }
 
         if (mMaxNumberOfSimultaneouslyActiveSims < 0) {
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index 43014c8..2a884f6 100755
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -1735,17 +1735,6 @@
         }
     }
 
-    void addParticipantWithConference(Call call, String recipients) {
-        final String callId = mCallIdMapper.getCallId(call);
-            if (isServiceValid("addParticipantWithConference")) {
-                try {
-                    logOutgoing("addParticipantWithConference %s, %s", recipients, callId);
-                    mServiceInterface.addParticipantWithConference(callId, recipients);
-                } catch (RemoteException ignored) {
-                }
-        }
-    }
-
     void mergeConference(Call call) {
         final String callId = mCallIdMapper.getCallId(call);
         if (callId != null && isServiceValid("mergeConference")) {
diff --git a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
index c163bfb..7f71ad2 100644
--- a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
@@ -16,9 +16,6 @@
 
 package com.android.server.telecom;
 
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_DIAL_CONFERENCE_URI;
-import static com.android.internal.telephony.TelephonyIntents.EXTRA_SKIP_SCHEMA_PARSING;
-
 import android.app.AppOpsManager;
 
 import android.app.Activity;
@@ -163,24 +160,16 @@
                                         " ignore the broadcast Call %s", mCall);
                         return;
                     }
-                    boolean isSkipSchemaParsing = mIntent.getBooleanExtra(
-                            EXTRA_SKIP_SCHEMA_PARSING, false);
-                    Uri resultHandleUri = null;
+
+                    // TODO: Remove the assumption that phone numbers are either SIP or TEL.
+                    // This does not impact self-managed ConnectionServices as they do not use the
+                    // NewOutgoingCallIntentBroadcaster.
+                    Uri resultHandleUri = Uri.fromParts(
+                            mPhoneNumberUtilsAdapter.isUriNumber(resultNumber) ?
+                                    PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL,
+                            resultNumber, null);
+
                     Uri originalUri = mIntent.getData();
-                    if (isSkipSchemaParsing) {
-                        // resultNumber does not have the schema present
-                        // hence use originalUri which is same as handle
-                        resultHandleUri = Uri.fromParts(PhoneAccount.SCHEME_TEL,
-                                originalUri.toString(), null);
-                    } else {
-                        // TODO: Remove the assumption that phone numbers are either SIP or TEL.
-                        // This does not impact self-managed ConnectionServices as they do not use the
-                        // NewOutgoingCallIntentBroadcaster.
-                        resultHandleUri = Uri.fromParts(
-                                mPhoneNumberUtilsAdapter.isUriNumber(resultNumber) ?
-                                        PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL,
-                                resultNumber, null);
-                    }
 
                     if (originalUri.getSchemeSpecificPart().equals(resultNumber)) {
                         Log.v(this, "Call number unmodified after" +
@@ -328,20 +317,13 @@
     private String getNumberFromCallIntent(Intent intent) {
         String number;
         number = mPhoneNumberUtilsAdapter.getNumberFromIntent(intent, mContext);
-        boolean isConferenceUri = intent.getBooleanExtra(
-                EXTRA_DIAL_CONFERENCE_URI, false);
-        if (!isConferenceUri && TextUtils.isEmpty(number)) {
+        if (TextUtils.isEmpty(number)) {
             Log.w(this, "Empty number obtained from the call intent.");
             return null;
         }
 
-        boolean isSkipSchemaParsing = intent.getBooleanExtra(
-                EXTRA_SKIP_SCHEMA_PARSING, false);
-
         boolean isUriNumber = mPhoneNumberUtilsAdapter.isUriNumber(number);
-        Log.v(this,"processIntent isConferenceUri: " + isConferenceUri +
-                " isSkipSchemaParsing = " + isSkipSchemaParsing);
-        if (!isUriNumber && !isConferenceUri && !isSkipSchemaParsing) {
+        if (!isUriNumber) {
             number = mPhoneNumberUtilsAdapter.convertKeypadLettersToDigits(number);
             number = mPhoneNumberUtilsAdapter.stripSeparators(number);
         }
@@ -389,12 +371,7 @@
         if (disposition.sendBroadcast) {
             UserHandle targetUser = mCall.getInitiatingUser();
             Log.i(this, "Sending NewOutgoingCallBroadcast for %s to %s", mCall, targetUser);
-            boolean isSkipSchemaParsing = mIntent.getBooleanExtra(
-                    EXTRA_SKIP_SCHEMA_PARSING, false);
-            String number = isSkipSchemaParsing
-                ? disposition.callingAddress.toString()
-                : disposition.number;
-            broadcastIntent(mIntent, number,
+            broadcastIntent(mIntent, disposition.number,
                     !disposition.callImmediately && !callRedirectionWithService, targetUser);
         }
     }
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
index f82192d..c1a3b80 100755
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
@@ -407,9 +407,6 @@
         }
 
         @Override
-        public void addParticipantWithConference(String callId, String recipients) {}
-
-        @Override
         public void connectionServiceFocusLost(Session.Info sessionInfo) throws RemoteException {
         }