Merge "Rename of session APIs"
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 63be538..08edc91 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -494,8 +494,7 @@
             callHandlerServiceProxy = new CallHandlerServiceProxy(this, callModeler,
                     callCommandService, audioRouter);
 
-            phoneMgr = PhoneInterfaceManager.init(this, phone, callHandlerServiceProxy, callModeler,
-                    dtmfTonePlayer);
+            phoneMgr = PhoneInterfaceManager.init(this, phone, callHandlerServiceProxy);
 
             // Create the CallNotifer singleton, which handles
             // asynchronous events from the telephony layer (like
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 61b26f8..3354687 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -48,7 +48,6 @@
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.DefaultPhoneNotifier;
 import com.android.internal.telephony.ITelephony;
-import com.android.internal.telephony.ITelephonyListener;
 import com.android.internal.telephony.IccCard;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
@@ -67,7 +66,7 @@
 /**
  * Implementation of the ITelephony interface.
  */
-public class PhoneInterfaceManager extends ITelephony.Stub implements CallModeler.Listener {
+public class PhoneInterfaceManager extends ITelephony.Stub {
     private static final String LOG_TAG = "PhoneInterfaceManager";
     private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
     private static final boolean DBG_LOC = false;
@@ -109,14 +108,6 @@
     AppOpsManager mAppOps;
     MainThreadHandler mMainThreadHandler;
     CallHandlerServiceProxy mCallHandlerService;
-    CallModeler mCallModeler;
-    DTMFTonePlayer mDtmfTonePlayer;
-    Handler mDtmfStopHandler = new Handler();
-    Runnable mDtmfStopRunnable;
-
-    private final List<ITelephonyListener> mListeners = new ArrayList<ITelephonyListener>();
-    private final Map<IBinder, TelephonyListenerDeathRecipient> mDeathRecipients =
-            new HashMap<IBinder, TelephonyListenerDeathRecipient>();
 
     /**
      * A request object to use for transmitting data to an ICC.
@@ -519,12 +510,10 @@
      * This is only done once, at startup, from PhoneApp.onCreate().
      */
     /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone,
-                CallHandlerServiceProxy callHandlerService, CallModeler callModeler,
-                DTMFTonePlayer dtmfTonePlayer) {
+                CallHandlerServiceProxy callHandlerService) {
         synchronized (PhoneInterfaceManager.class) {
             if (sInstance == null) {
-                sInstance = new PhoneInterfaceManager(app, phone, callHandlerService, callModeler,
-                        dtmfTonePlayer);
+                sInstance = new PhoneInterfaceManager(app, phone, callHandlerService);
             } else {
                 Log.wtf(LOG_TAG, "init() called multiple times!  sInstance = " + sInstance);
             }
@@ -534,17 +523,13 @@
 
     /** Private constructor; @see init() */
     private PhoneInterfaceManager(PhoneGlobals app, Phone phone,
-            CallHandlerServiceProxy callHandlerService, CallModeler callModeler,
-            DTMFTonePlayer dtmfTonePlayer) {
+            CallHandlerServiceProxy callHandlerService) {
         mApp = app;
         mPhone = phone;
         mCM = PhoneGlobals.getInstance().mCM;
         mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE);
         mMainThreadHandler = new MainThreadHandler();
         mCallHandlerService = callHandlerService;
-        mCallModeler = callModeler;
-        mCallModeler.addListener(this);
-        mDtmfTonePlayer = dtmfTonePlayer;
         publish();
     }
 
@@ -1296,6 +1281,22 @@
         return s;
     }
 
+    @Override
+    public String sendEnvelopeWithStatus(String content) {
+        enforceSimCommunicationPermission();
+
+        IccIoResult response = (IccIoResult)sendRequest(CMD_SEND_ENVELOPE, content);
+        if (response.payload == null) {
+          return "";
+        }
+
+        // Append the returned status code to the end of the response payload.
+        String s = Integer.toHexString(
+                (response.sw1 << 8) + response.sw2 + 0x10000).substring(1);
+        s = IccUtils.bytesToHexString(response.payload) + s;
+        return s;
+    }
+
     /**
      * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}
      * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators.
@@ -1393,248 +1394,4 @@
         if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail"));
         return success;
     }
-
-    @Override
-    public void toggleHold() {
-        enforceModifyPermission();
-
-        try {
-            PhoneUtils.switchHoldingAndActive(mCM.getFirstActiveBgCall());
-        } catch (Exception e) {
-            Log.e(LOG_TAG, "Error during toggleHold().", e);
-        }
-    }
-
-    @Override
-    public void merge() {
-        enforceModifyPermission();
-
-        try {
-            if (PhoneUtils.okToMergeCalls(mCM)) {
-                PhoneUtils.mergeCalls(mCM);
-            }
-        } catch (Exception e) {
-            Log.e(LOG_TAG, "Error during merge().", e);
-        }
-    }
-
-    @Override
-    public void swap() {
-        enforceModifyPermission();
-
-        try {
-            PhoneUtils.swap();
-        } catch (Exception e) {
-            Log.e(LOG_TAG, "Error during swap().", e);
-        }
-    }
-
-    @Override
-    public void mute(boolean onOff) {
-        enforceModifyPermission();
-
-        try {
-            PhoneUtils.setMute(onOff);
-        } catch (Exception e) {
-            Log.e(LOG_TAG, "Error during mute().", e);
-        }
-    }
-
-    @Override
-    public void playDtmfTone(char digit, boolean timedShortTone) {
-        enforceModifyPermission();
-
-        synchronized (mDtmfStopHandler) {
-            try {
-                mDtmfTonePlayer.playDtmfTone(digit, timedShortTone);
-            } catch (Exception e) {
-                Log.e(LOG_TAG, "Error playing DTMF tone.", e);
-            }
-
-            if (mDtmfStopRunnable != null) {
-                mDtmfStopHandler.removeCallbacks(mDtmfStopRunnable);
-            }
-            mDtmfStopRunnable = new Runnable() {
-                @Override
-                public void run() {
-                    synchronized (mDtmfStopHandler) {
-                        if (mDtmfStopRunnable == this) {
-                            mDtmfTonePlayer.stopDtmfTone();
-                            mDtmfStopRunnable = null;
-                        }
-                    }
-                }
-            };
-            mDtmfStopHandler.postDelayed(mDtmfStopRunnable, 5000);
-        }
-    }
-
-    @Override
-    public void stopDtmfTone() {
-        enforceModifyPermission();
-
-        synchronized (mDtmfStopHandler) {
-            try {
-                mDtmfTonePlayer.stopDtmfTone();
-            } catch (Exception e) {
-                Log.e(LOG_TAG, "Error stopping DTMF tone.", e);
-            }
-
-            if (mDtmfStopRunnable != null) {
-                mDtmfStopHandler.removeCallbacks(mDtmfStopRunnable);
-                mDtmfStopRunnable = null;
-            }
-        }
-    }
-
-    @Override
-    public void addListener(ITelephonyListener listener) {
-        enforcePrivilegedPhoneStatePermission();
-
-        if (listener == null) {
-            throw new IllegalArgumentException("Listener must not be null.");
-        }
-
-        synchronized (mListeners) {
-            IBinder listenerBinder = listener.asBinder();
-            for (ITelephonyListener l : mListeners) {
-                if (l.asBinder().equals(listenerBinder)) {
-                    Log.w(LOG_TAG, "Listener already registered. Ignoring.");
-                    return;
-                }
-            }
-            mListeners.add(listener);
-            mDeathRecipients.put(listener.asBinder(),
-                    new TelephonyListenerDeathRecipient(listener.asBinder()));
-
-            // update the new listener so they get the full call state immediately
-            for (Call call : mCallModeler.getFullList()) {
-                try {
-                    notifyListenerOfCallLocked(call, listener);
-                } catch (RemoteException e) {
-                    Log.e(LOG_TAG, "Error updating new listener. Ignoring.");
-                    removeListenerInternal(listener);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void removeListener(ITelephonyListener listener) {
-        enforcePrivilegedPhoneStatePermission();
-
-        if (listener == null) {
-            throw new IllegalArgumentException("Listener must not be null.");
-        }
-
-        removeListenerInternal(listener);
-    }
-
-    private void removeListenerInternal(ITelephonyListener listener) {
-        IBinder listenerBinder = listener.asBinder();
-
-        synchronized (mListeners) {
-            for (Iterator<ITelephonyListener> it = mListeners.iterator(); it.hasNext(); ) {
-                ITelephonyListener nextListener = it.next();
-                if (nextListener.asBinder().equals(listenerBinder)) {
-                    TelephonyListenerDeathRecipient dr = mDeathRecipients.get(listener.asBinder());
-                    if (dr != null) {
-                        dr.unlinkDeathRecipient();
-                    }
-                    it.remove();
-                }
-            }
-        }
-    }
-
-    /** CallModeler.Listener implementation **/
-
-    @Override
-    public void onDisconnect(Call call) {
-        notifyListenersOfCall(call);
-    }
-
-    @Override
-    public void onIncoming(Call call) {
-        notifyListenersOfCall(call);
-    }
-
-    @Override
-    public void onUpdate(List<Call> calls) {
-        for (Call call : calls) {
-            notifyListenersOfCall(call);
-        }
-    }
-
-    @Override
-    public void onPostDialAction(
-            Connection.PostDialState state, int callId, String remainingChars, char c) { }
-
-    private void notifyListenersOfCall(Call call) {
-        synchronized (mListeners) {
-            for (Iterator<ITelephonyListener> it = mListeners.iterator(); it.hasNext(); ) {
-                ITelephonyListener listener = it.next();
-                try {
-                    notifyListenerOfCallLocked(call, listener);
-                } catch (RemoteException e) {
-                    TelephonyListenerDeathRecipient deathRecipient =
-                            mDeathRecipients.get(listener.asBinder());
-                    if (deathRecipient != null) {
-                        deathRecipient.unlinkDeathRecipient();
-                    }
-                    it.remove();
-                }
-            }
-        }
-    }
-
-    private void notifyListenerOfCallLocked(final Call call,final ITelephonyListener listener)
-            throws RemoteException {
-        if (Binder.isProxy(listener)) {
-            listener.onUpdate(call.getCallId(), call.getState(), call.getNumber());
-        } else {
-            mMainThreadHandler.post(new Runnable() {
-
-                @Override
-                public void run() {
-                    try {
-                        listener.onUpdate(call.getCallId(), call.getState(), call.getNumber());
-                    } catch (RemoteException e) {
-                        Log.wtf(LOG_TAG, "Local binder call failed with RemoteException.", e);
-                    }
-                }
-            });
-        }
-
-    }
-
-    private class TelephonyListenerDeathRecipient implements Binder.DeathRecipient {
-        private final IBinder mBinder;
-
-        public TelephonyListenerDeathRecipient(IBinder listener) {
-            mBinder = listener;
-            try {
-                mBinder.linkToDeath(this, 0);
-            } catch (RemoteException e) {
-                unlinkDeathRecipient();
-            }
-        }
-
-        @Override
-        public void binderDied() {
-            synchronized (mListeners) {
-                if (mListeners.contains(mBinder)) {
-                    mListeners.remove(mBinder);
-                    Log.w(LOG_TAG, "ITelephonyListener died. Removing.");
-                } else {
-                    Log.w(LOG_TAG, "TelephonyListener binder died but the listener " +
-                            "is not registered.");
-                }
-            }
-        }
-
-        public void unlinkDeathRecipient() {
-            mBinder.unlinkToDeath(this, 0);
-        }
-    }
 }
diff --git a/src/com/android/services/telecomm/Connection.java b/src/com/android/services/telecomm/Connection.java
deleted file mode 100644
index 072d97d..0000000
--- a/src/com/android/services/telecomm/Connection.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telecomm;
-
-import com.google.android.collect.Sets;
-
-import com.android.services.telephony.Log;
-
-import android.net.Uri;
-import android.os.Bundle;
-import android.telecomm.CallAudioState;
-
-import java.util.Set;
-
-/**
- * Represents a connection to a remote endpoint that carries voice traffic.
- */
-public abstract class Connection {
-
-    public interface Listener {
-        void onStateChanged(Connection c, int state);
-        void onAudioStateChanged(Connection c, CallAudioState state);
-        void onHandleChanged(Connection c, Uri newHandle);
-        void onSignalChanged(Connection c, Bundle details);
-        void onDisconnected(Connection c, int cause, String message);
-        void onDestroyed(Connection c);
-    }
-
-    public static class ListenerBase implements Listener {
-        /** {@inheritDoc} */
-        @Override
-        public void onStateChanged(Connection c, int state) {}
-
-        /** {@inheritDoc} */
-         @Override
-        public void onAudioStateChanged(Connection c, CallAudioState state) {}
-
-        /** {@inheritDoc} */
-        @Override
-        public void onHandleChanged(Connection c, Uri newHandle) {}
-
-        /** {@inheritDoc} */
-        @Override
-        public void onSignalChanged(Connection c, Bundle details) {}
-
-        /** {@inheritDoc} */
-        @Override
-        public void onDisconnected(Connection c, int cause, String message) {}
-
-        /** {@inheritDoc} */
-        @Override
-        public void onDestroyed(Connection c) {}
-    }
-
-    public final class State {
-        private State() {}
-
-        public static final int NEW = 0;
-        public static final int RINGING = 1;
-        public static final int DIALING = 2;
-        public static final int ACTIVE = 3;
-        public static final int HOLDING = 4;
-        public static final int DISCONNECTED = 5;
-    }
-
-    private final Set<Listener> mListeners = Sets.newHashSet();
-    private int mState = State.NEW;
-    private CallAudioState mCallAudioState;
-    private Uri mHandle;
-
-    /**
-     * Create a new Connection.
-     */
-    protected Connection() {}
-
-    /**
-     * @return The handle (e.g., phone number) to which this Connection
-     *         is currently communicating.
-     *
-     * @hide
-     */
-    public final Uri getHandle() {
-        return mHandle;
-    }
-
-    /**
-     * @return The state of this Connection.
-     *
-     * @hide
-     */
-    public final int getState() {
-        return mState;
-    }
-
-    /**
-     * @return The audio state of the call, describing how its audio is currently
-     *         being routed by the system. This is {@code null} if this Connection
-     *         does not directly know about its audio state.
-     *
-     * @hide
-     */
-    public final CallAudioState getCallAudioState() {
-        return mCallAudioState;
-    }
-
-    /**
-     * Assign a listener to be notified of state changes.
-     *
-     * @param l A listener.
-     * @return This Connection.
-     *
-     * @hide
-     */
-    public final Connection addConnectionListener(Listener l) {
-        mListeners.add(l);
-        return this;
-    }
-
-    /**
-     * Remove a previously assigned listener that was being notified of state changes.
-     *
-     * @param l A Listener.
-     * @return This Connection.
-     *
-     * @hide
-     */
-    public final Connection removeConnectionListener(Listener l) {
-        mListeners.remove(l);
-        return this;
-    }
-
-    /**
-     * Play a DTMF tone in this Connection.
-     *
-     * @param c A DTMF character.
-     *
-     * @hide
-     */
-    public final void playDtmfTone(char c) {
-        Log.d(this, "playDtmfTone %c", c);
-        onPlayDtmfTone(c);
-    }
-
-    /**
-     * Stop any DTMF tones which may be playing in this Connection.
-     *
-     * @hide
-     */
-    public final void stopDtmfTone() {
-        Log.d(this, "stopDtmfTone");
-        onStopDtmfTone();
-    }
-
-    /**
-     * Disconnect this Connection. If and when the Connection can comply with
-     * this request, it will transition to the {@link State#DISCONNECTED}
-     * state and notify its listeners.
-     *
-     * @hide
-     */
-    public final void disconnect() {
-        Log.d(this, "disconnect");
-        onDisconnect();
-    }
-
-    /**
-     * Abort this Connection. The Connection will immediately transition to
-     * the {@link State#DISCONNECTED} state, and send no notifications of this
-     * or any other future events.
-     *
-     * @hide
-     */
-    public final void abort() {
-        Log.d(this, "abort");
-        onAbort();
-    }
-
-    /**
-     * Place this Connection on hold. If and when the Connection can comply with
-     * this request, it will transition to the {@link State#HOLDING}
-     * state and notify its listeners.
-     *
-     * @hide
-     */
-    public final void hold() {
-        Log.d(this, "hold");
-        onHold();
-    }
-
-    /**
-     * Un-hold this Connection. If and when the Connection can comply with
-     * this request, it will transition to the {@link State#ACTIVE}
-     * state and notify its listeners.
-     *
-     * @hide
-     */
-    public final void unhold() {
-        Log.d(this, "unhold");
-        onUnhold();
-    }
-
-    /**
-     * Accept a {@link State#RINGING} Connection. If and when the Connection
-     * can comply with this request, it will transition to the {@link State#ACTIVE}
-     * state and notify its listeners.
-     *
-     * @hide
-     */
-    public final void answer() {
-        Log.d(this, "answer");
-        if (mState == State.RINGING) {
-            onAnswer();
-        }
-    }
-
-    /**
-     * Reject a {@link State#RINGING} Connection. If and when the Connection
-     * can comply with this request, it will transition to the {@link State#ACTIVE}
-     * state and notify its listeners.
-     *
-     * @hide
-     */
-    public final void reject() {
-        Log.d(this, "reject");
-        if (mState == State.RINGING) {
-            onReject();
-        }
-    }
-
-    /**
-     * Inform this Connection that the state of its audio output has been changed externally.
-     *
-     * @param state The new audio state.
-     */
-    public void setAudioState(CallAudioState state) {
-        Log.d(this, "setAudioState %s", state);
-        onSetAudioState(state);
-    }
-
-    /**
-     * @param state An integer value from {@link State}.
-     * @return A string representation of the value.
-     */
-    public static String stateToString(int state) {
-        switch (state) {
-            case State.NEW:
-                return "NEW";
-            case State.RINGING:
-                return "RINGING";
-            case State.DIALING:
-                return "DIALING";
-            case State.ACTIVE:
-                return "ACTIVE";
-            case State.HOLDING:
-                return "HOLDING";
-            case State.DISCONNECTED:
-                return "DISCONNECTED";
-            default:
-                Log.wtf(Connection.class, "Unknown state %d", state);
-                return "UNKNOWN";
-        }
-    }
-
-    /**
-     * Sets the value of the {@link #getHandle()} property and notifies listeners.
-     *
-     * @param handle The new handle.
-     */
-    protected void setHandle(Uri handle) {
-        Log.d(this, "setHandle %s", handle);
-        // TODO: Enforce super called
-        mHandle = handle;
-        for (Listener l : mListeners) {
-            l.onHandleChanged(this, handle);
-        }
-    }
-
-    /**
-     * Sets state to active (e.g., an ongoing call where two or more parties can actively
-     * communicate).
-     */
-    protected void setActive() {
-        setState(State.ACTIVE);
-    }
-
-    /**
-     * Sets state to ringing (e.g., an inbound ringing call).
-     */
-    protected void setRinging() {
-        setState(State.RINGING);
-    }
-
-    /**
-     * Sets state to dialing (e.g., dialing an outbound call).
-     */
-    protected void setDialing() {
-        setState(State.DIALING);
-    }
-
-    /**
-     * Sets state to be on hold.
-     */
-    protected void setOnHold() {
-        setState(State.HOLDING);
-    }
-
-    /**
-     * Sets state to disconnected. This will first notify listeners with an
-     * {@link Listener#onStateChanged(Connection, int)} event, then will fire an
-     * {@link Listener#onDisconnected(Connection, int, String)} event with additional
-     * details.
-     *
-     * @param cause The reason for the disconnection, any of
-     *         {@link android.telephony.DisconnectCause}.
-     * @param message Optional call-service-provided message about the disconnect.
-     */
-    protected void setDisconnected(int cause, String message) {
-        setState(State.DISCONNECTED);
-        Log.d(this, "Disconnected with cause %d, message \"%s\"", cause, message);
-        for (Listener l : mListeners) {
-            l.onDisconnected(this, cause, message);
-        }
-    }
-
-    /**
-     * Notifies this Connection and listeners that the {@link #getCallAudioState()} property
-     * has a new value.
-     *
-     * @param state The new call audio state.
-     */
-    protected void onSetAudioState(CallAudioState state) {
-        // TODO: Enforce super called
-        this.mCallAudioState = state;
-        for (Listener l : mListeners) {
-            l.onAudioStateChanged(this, state);
-        }
-    }
-
-    /**
-     * Notifies this Connection and listeners of a change in the current signal levels
-     * for the underlying data transport.
-     *
-     * @param details A {@link android.os.Bundle} containing details of the current level.
-     */
-    protected void onSetSignal(Bundle details) {
-        // TODO: Enforce super called
-        for (Listener l : mListeners) {
-            l.onSignalChanged(this, details);
-        }
-    }
-
-    /**
-     * Notifies this Connection of a request to play a DTMF tone.
-     *
-     * @param c A DTMF character.
-     */
-    protected void onPlayDtmfTone(char c) {}
-
-    /**
-     * Notifies this Connection of a request to stop any currently playing DTMF tones.
-     */
-    protected void onStopDtmfTone() {}
-
-    /**
-     * Notifies this Connection of a request to disconnect.
-     */
-    protected void onDisconnect() {}
-
-    /**
-     * Notifies this Connection of a request to abort.
-     */
-    protected void onAbort() {}
-
-    /**
-     * Notifies this Connection of a request to hold.
-     */
-    protected void onHold() {}
-
-    /**
-     * Notifies this Connection of a request to exit a hold state.
-     */
-    protected void onUnhold() {}
-
-    /**
-     * Notifies this Connection, which is in {@link State#RINGING}, of
-     * a request to accept.
-     */
-    protected void onAnswer() {}
-
-    /**
-     * Notifies this Connection, which is in {@link State#RINGING}, of
-     * a request to reject.
-     */
-    protected void onReject() {}
-
-    private void setState(int state) {
-        Log.d(this, "setState: %s", stateToString(state));
-        this.mState = state;
-        for (Listener l : mListeners) {
-            l.onStateChanged(this, state);
-        }
-    }
-}
diff --git a/src/com/android/services/telecomm/ConnectionRequest.java b/src/com/android/services/telecomm/ConnectionRequest.java
deleted file mode 100644
index 2027330..0000000
--- a/src/com/android/services/telecomm/ConnectionRequest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telecomm;
-
-import android.os.Bundle;
-import android.net.Uri;
-
-/**
- * Simple data container encapsulating a request to some entity to
- * create a new {@link Connection}.
- */
-public final class ConnectionRequest {
-
-    // TODO: Token to limit recursive invocations
-
-    private final Uri mHandle;
-    private final Bundle mExtras;
-
-    public ConnectionRequest(Uri handle, Bundle extras) {
-        mHandle = handle; mExtras = extras;
-    }
-
-    /**
-     * The handle (e.g., phone number) to which the {@link Connection} is to connect.
-     */
-    public Uri getHandle() { return mHandle; }
-
-    /**
-     * Application-specific extra data. Used for passing back information from an incoming
-     * call {@code Intent}, and for any proprietary extensions arranged between a client
-     * and servant {@code ConnectionService} which agree on a vocabulary for such data.
-     */
-    public Bundle getExtras() { return mExtras; }
-
-    public String toString() {
-        return String.format("PhoneConnectionRequest %s %s",
-                mHandle == null
-                        ? Uri.EMPTY
-                        : ConnectionService.toLogSafePhoneNumber(mHandle.toString()),
-                mExtras == null ? "" : mExtras);
-    }
-}
diff --git a/src/com/android/services/telecomm/ConnectionService.java b/src/com/android/services/telecomm/ConnectionService.java
deleted file mode 100644
index 5f2389e..0000000
--- a/src/com/android/services/telecomm/ConnectionService.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telecomm;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-
-import android.net.Uri;
-import android.os.Bundle;
-import android.telecomm.CallAudioState;
-import android.telecomm.CallInfo;
-import android.telecomm.CallService;
-import android.telecomm.CallState;
-import android.util.Log;
-
-/**
- * A {@link android.app.Service} that provides telephone connections to
- * processes running on an Android device.
- */
-public abstract class ConnectionService extends CallService {
-    private static final String TAG = ConnectionService.class.getSimpleName();
-
-    // Flag controlling whether PII is emitted into the logs
-    private static final boolean PII_DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
-    private static final Connection NULL_CONNECTION = new Connection() {};
-
-    // Mappings from Connections to IDs as understood by the current CallService implementation
-    private final BiMap<String, Connection> mConnectionById = HashBiMap.create();
-
-    private final Connection.Listener mConnectionListener = new Connection.Listener() {
-        @Override
-        public void onStateChanged(Connection c, int state) {
-            String id = mConnectionById.inverse().get(c);
-            Log.d(TAG, "Adapter set state " + id + " " + Connection.stateToString(state));
-            switch (state) {
-                case Connection.State.ACTIVE:
-                    getAdapter().setActive(id);
-                    break;
-                case Connection.State.DIALING:
-                    getAdapter().setDialing(id);
-                    break;
-                case Connection.State.DISCONNECTED:
-                    // Handled in onDisconnected()
-                    break;
-                case Connection.State.HOLDING:
-                    getAdapter().setOnHold(id);
-                    break;
-                case Connection.State.NEW:
-                    // Nothing to tell Telecomm
-                    break;
-                case Connection.State.RINGING:
-                    getAdapter().setRinging(id);
-                    break;
-            }
-        }
-
-        @Override
-        public void onDisconnected(Connection c, int cause, String message) {
-            String id = mConnectionById.inverse().get(c);
-            Log.d(TAG, "Adapter set disconnected " + cause + " " + message);
-            getAdapter().setDisconnected(id, cause, message);
-        }
-
-        @Override
-        public void onHandleChanged(Connection c, Uri newHandle) {
-            // TODO: Unsupported yet
-        }
-
-        @Override
-        public void onAudioStateChanged(Connection c, CallAudioState state) {
-            // TODO: Unsupported yet
-        }
-
-        @Override
-        public void onSignalChanged(Connection c, Bundle details) {
-            // TODO: Unsupported yet
-        }
-
-        @Override
-        public void onDestroyed(Connection c) {
-            removeConnection(c);
-        }
-    };
-
-    @Override
-    public final void isCompatibleWith(final CallInfo callInfo) {
-        Log.d(TAG, "isCompatibleWith " + callInfo);
-        onFindSubscriptions(
-                callInfo.getHandle(),
-                new Response<Uri, Subscription>() {
-                    @Override
-                    public void onResult(Uri handle, Subscription... result) {
-                        boolean isCompatible = result.length > 0;
-                        Log.d(TAG, "adapter setIsCompatibleWith "
-                                + callInfo.getId() + " " + isCompatible);
-                        getAdapter().setIsCompatibleWith(callInfo.getId(), isCompatible);
-                    }
-
-                    @Override
-                    public void onError(Uri handle, String reason) {
-                        Log.wtf(TAG, "Error in onFindSubscriptions " + callInfo.getHandle()
-                                + " error: " + reason);
-                        getAdapter().setIsCompatibleWith(callInfo.getId(), false);
-                    }
-                }
-        );
-    }
-
-    @Override
-    public final void call(final CallInfo callInfo) {
-        Log.d(TAG, "call " + callInfo);
-        onCreateConnections(
-                new ConnectionRequest(
-                        callInfo.getHandle(),
-                        callInfo.getExtras()),
-                new Response<ConnectionRequest, Connection>() {
-                    @Override
-                    public void onResult(ConnectionRequest request, Connection... result) {
-                        if (result.length != 1) {
-                            Log.d(TAG, "adapter handleFailedOutgoingCall " + callInfo);
-                            getAdapter().handleFailedOutgoingCall(
-                                    callInfo.getId(),
-                                    "Created " + result.length + " Connections, expected 1");
-                            for (Connection c : result) {
-                                c.abort();
-                            }
-                        } else {
-                            addConnection(callInfo.getId(), result[0]);
-                            Log.d(TAG, "adapter handleSuccessfulOutgoingCall "
-                                    + callInfo.getId());
-                            getAdapter().handleSuccessfulOutgoingCall(callInfo.getId());
-                        }
-                    }
-
-                    @Override
-                    public void onError(ConnectionRequest request, String reason) {
-                        getAdapter().handleFailedOutgoingCall(callInfo.getId(), reason);
-                    }
-                }
-        );
-    }
-
-    @Override
-    public final void abort(String callId) {
-        Log.d(TAG, "abort " + callId);
-        findConnectionForAction(callId, "abort").abort();
-    }
-
-    @Override
-    public final void setIncomingCallId(final String callId, Bundle extras) {
-        Log.d(TAG, "setIncomingCallId " + callId + " " + extras);
-        onCreateIncomingConnection(
-                new ConnectionRequest(
-                        null,  // TODO: Can we obtain this from "extras"?
-                        extras),
-                new Response<ConnectionRequest, Connection>() {
-                    @Override
-                    public void onResult(ConnectionRequest request, Connection... result) {
-                        if (result.length != 1) {
-                            Log.d(TAG, "adapter handleFailedOutgoingCall " + callId);
-                            getAdapter().handleFailedOutgoingCall(
-                                    callId,
-                                    "Created " + result.length + " Connections, expected 1");
-                            for (Connection c : result) {
-                                c.abort();
-                            }
-                        } else {
-                            addConnection(callId, result[0]);
-                            Log.d(TAG, "adapter notifyIncomingCall " + callId);
-                            // TODO: Uri.EMPTY is because CallInfo crashes when Parceled with a
-                            // null URI ... need to fix that at its cause!
-                            getAdapter().notifyIncomingCall(new CallInfo(
-                                    callId,
-                                    connectionStateToCallState(result[0].getState()),
-                                    request.getHandle() /* result[0].getHandle() == null
-                                            ? Uri.EMPTY : result[0].getHandle() */));
-                        }
-                    }
-
-                    @Override
-                    public void onError(ConnectionRequest request, String reason) {
-                        Log.d(TAG, "adapter failed setIncomingCallId " + request + " " + reason);
-                    }
-                }
-        );
-    }
-
-    @Override
-    public final void answer(String callId) {
-        Log.d(TAG, "answer " + callId);
-        findConnectionForAction(callId, "answer").answer();
-    }
-
-    @Override
-    public final void reject(String callId) {
-        Log.d(TAG, "reject " + callId);
-        findConnectionForAction(callId, "reject").reject();
-    }
-
-    @Override
-    public final void disconnect(String callId) {
-        Log.d(TAG, "disconnect " + callId);
-        findConnectionForAction(callId, "disconnect").disconnect();
-    }
-
-    @Override
-    public final void hold(String callId) {
-        Log.d(TAG, "hold " + callId);
-        findConnectionForAction(callId, "hold").hold();
-    }
-
-    @Override
-    public final void unhold(String callId) {
-        Log.d(TAG, "unhold " + callId);
-        findConnectionForAction(callId, "unhold").unhold();
-    }
-
-    @Override
-    public final void playDtmfTone(String callId, char digit) {
-        Log.d(TAG, "playDtmfTone " + callId + " " + Character.toString(digit));
-        findConnectionForAction(callId, "playDtmfTone").playDtmfTone(digit);
-    }
-
-    @Override
-    public final void stopDtmfTone(String callId) {
-        Log.d(TAG, "stopDtmfTone " + callId);
-        findConnectionForAction(callId, "stopDtmfTone").stopDtmfTone();
-    }
-
-    @Override
-    public final void onAudioStateChanged(String callId, CallAudioState audioState) {
-        Log.d(TAG, "onAudioStateChanged " + callId + " " + audioState);
-        findConnectionForAction(callId, "onAudioStateChanged").setAudioState(audioState);
-    }
-
-    /**
-     * Find a set of Subscriptions matching a given handle (e.g. phone number).
-     *
-     * @param handle A handle (e.g. phone number) with which to connect.
-     * @param callback A callback for providing the result.
-     */
-    public void onFindSubscriptions(
-            Uri handle,
-            Response<Uri, Subscription> callback) {}
-
-    /**
-     * Create a Connection given a request.
-     *
-     * @param request Data encapsulating details of the desired Connection.
-     * @param callback A callback for providing the result.
-     */
-    public void onCreateConnections(
-            ConnectionRequest request,
-            Response<ConnectionRequest, Connection> callback) {}
-
-    /**
-     * Create a Connection to match an incoming connection notification.
-     *
-     * @param request Data encapsulating details of the desired Connection.
-     * @param callback A callback for providing the result.
-     */
-    public void onCreateIncomingConnection(
-            ConnectionRequest request,
-            Response<ConnectionRequest, Connection> callback) {}
-
-    static String toLogSafePhoneNumber(String number) {
-        // For unknown number, log empty string.
-        if (number == null) {
-            return "";
-        }
-
-        if (PII_DEBUG) {
-            // When PII_DEBUG is true we emit PII.
-            return number;
-        }
-
-        // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
-        // sanitized phone numbers.
-        StringBuilder builder = new StringBuilder();
-        for (int i = 0; i < number.length(); i++) {
-            char c = number.charAt(i);
-            if (c == '-' || c == '@' || c == '.') {
-                builder.append(c);
-            } else {
-                builder.append('x');
-            }
-        }
-        return builder.toString();
-    }
-
-    private CallState connectionStateToCallState(int connectionState) {
-        switch (connectionState) {
-            case Connection.State.NEW:
-                return CallState.NEW;
-            case Connection.State.RINGING:
-                return CallState.RINGING;
-            case Connection.State.DIALING:
-                return CallState.DIALING;
-            case Connection.State.ACTIVE:
-                return CallState.ACTIVE;
-            case Connection.State.HOLDING:
-                return CallState.ON_HOLD;
-            case Connection.State.DISCONNECTED:
-                return CallState.DISCONNECTED;
-            default:
-                Log.wtf(TAG, "Unknown PhoneConnection.State " + connectionState);
-                return CallState.NEW;
-        }
-    }
-
-    private void addConnection(String callId, Connection connection) {
-        mConnectionById.put(callId, connection);
-        connection.addConnectionListener(mConnectionListener);
-    }
-
-    private void removeConnection(Connection connection) {
-        connection.removeConnectionListener(mConnectionListener);
-        mConnectionById.inverse().remove(connection);
-    }
-
-    private Connection findConnectionForAction(String callId, String action) {
-        if (mConnectionById.containsKey(callId)) {
-            return mConnectionById.get(callId);
-        }
-        Log.wtf(TAG, action + " - Cannot find Connection \"" + callId + "\"");
-        return NULL_CONNECTION;
-    }
-}
\ No newline at end of file
diff --git a/src/com/android/services/telecomm/Response.java b/src/com/android/services/telecomm/Response.java
deleted file mode 100644
index aa7eed5..0000000
--- a/src/com/android/services/telecomm/Response.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telecomm;
-
-/**
- * Used to inform a client of asynchronously returned results.
- */
-public interface Response<IN, OUT> {
-
-    /**
-     * Provide a set of results.
-     *
-     * @param request The original request.
-     * @param result The results.
-     */
-    void onResult(IN request, OUT... result);
-
-    /**
-     * Indicates the inability to provide results.
-     *
-     * @param request The original request.
-     * @param reason The reason for the failure.
-     */
-    void onError(IN request, String reason);
-}
diff --git a/src/com/android/services/telecomm/Subscription.java b/src/com/android/services/telecomm/Subscription.java
deleted file mode 100644
index 1cf02f1..0000000
--- a/src/com/android/services/telecomm/Subscription.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telecomm;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Represents a distinct subscription, line of service or call placement method that
- * a {@link ConnectionService} can use to place phone calls.
- */
-public class Subscription implements Parcelable {
-
-    public Subscription() {}
-
-    public int describeContents() {
-        return 0;
-    }
-
-    public void writeToParcel(Parcel out, int flags) {}
-
-    public static final Parcelable.Creator<Subscription> CREATOR
-            = new Parcelable.Creator<Subscription>() {
-        public Subscription createFromParcel(Parcel in) {
-            return new Subscription(in);
-        }
-
-        public Subscription[] newArray(int size) {
-            return new Subscription[size];
-        }
-    };
-
-    private Subscription(Parcel in) {}
-}
diff --git a/src/com/android/services/telephony/CachedPhoneFactory.java b/src/com/android/services/telephony/CachedPhoneFactory.java
deleted file mode 100644
index 34a1fc0..0000000
--- a/src/com/android/services/telephony/CachedPhoneFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telephony;
-
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
-
-/**
- * Creates and caches phone objects for use with call services. Incoming call listening and the call
- * service itself exist independently (and across threads) but need to share their references to the
- * {@link Phone} objects that they use. This class is used to provide those cached references.
- * TODO(santoscordon): Investigate if this functionality can be folded into PhoneFactory once
- * PhoneFactory is no longer being used by the old system.
- */
-class CachedPhoneFactory {
-    private static Phone sCdmaPhone;
-    private static Phone sGsmPhone;
-
-    /**
-     * @return The GSM Phone instance.
-     */
-    public static synchronized Phone getGsmPhone() {
-        if (sGsmPhone == null) {
-            sGsmPhone = PhoneFactory.getGsmPhone();
-        }
-        return sGsmPhone;
-    }
-
-    /**
-     * @return The CDMA Phone instance.
-     */
-    public static synchronized Phone getCdmaPhone() {
-        if (sCdmaPhone == null) {
-            sCdmaPhone = PhoneFactory.getCdmaPhone();
-        }
-        return sCdmaPhone;
-    }
-}
diff --git a/src/com/android/services/telephony/CdmaConnectionService.java b/src/com/android/services/telephony/CdmaConnectionService.java
index 06add1b..75bd12b 100644
--- a/src/com/android/services/telephony/CdmaConnectionService.java
+++ b/src/com/android/services/telephony/CdmaConnectionService.java
@@ -22,8 +22,9 @@
 
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
 import com.android.phone.Constants;
-import com.android.services.telecomm.ConnectionRequest;
+import android.telecomm.ConnectionRequest;
 
 /**
  * Connection service that uses CDMA.
@@ -33,7 +34,7 @@
     /** {@inheritDoc} */
     @Override
     protected Phone getPhone() {
-        return CachedPhoneFactory.getCdmaPhone();
+        return PhoneFactory.getDefaultPhone();
     }
 
     /** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/GsmConnectionService.java b/src/com/android/services/telephony/GsmConnectionService.java
index bf4fe7d..3fa59db 100644
--- a/src/com/android/services/telephony/GsmConnectionService.java
+++ b/src/com/android/services/telephony/GsmConnectionService.java
@@ -22,8 +22,9 @@
 
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
 import com.android.phone.Constants;
-import com.android.services.telecomm.ConnectionRequest;
+import android.telecomm.ConnectionRequest;
 
 /**
  * Connnection service that uses GSM.
@@ -32,7 +33,7 @@
     /** {@inheritDoc} */
     @Override
     protected Phone getPhone() {
-        return CachedPhoneFactory.getGsmPhone();
+        return PhoneFactory.getDefaultPhone();
     }
 
     /** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/PstnConnectionService.java b/src/com/android/services/telephony/PstnConnectionService.java
index fc59bda..b692e73 100644
--- a/src/com/android/services/telephony/PstnConnectionService.java
+++ b/src/com/android/services/telephony/PstnConnectionService.java
@@ -23,12 +23,11 @@
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.Phone;
 import com.android.phone.Constants;
-import com.android.services.telecomm.Connection;
-import com.android.services.telecomm.ConnectionRequest;
-import com.android.services.telecomm.Response;
+import android.telecomm.Connection;
+import android.telecomm.ConnectionRequest;
+import android.telecomm.Response;
 
-import com.google.android.collect.Sets;
-
+import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -37,7 +36,7 @@
  */
 public abstract class PstnConnectionService extends TelephonyConnectionService {
     private EmergencyCallHelper mEmergencyCallHelper;
-    private final Set<ConnectionRequest> mPendingOutgoingEmergencyCalls = Sets.newHashSet();
+    private final Set<ConnectionRequest> mPendingOutgoingEmergencyCalls = new HashSet<>();
 
     @Override
     public void onCreate() {
diff --git a/src/com/android/services/telephony/SipConnection.java b/src/com/android/services/telephony/SipConnection.java
index 0545613..34d734a 100644
--- a/src/com/android/services/telephony/SipConnection.java
+++ b/src/com/android/services/telephony/SipConnection.java
@@ -16,7 +16,7 @@
 
 package com.android.services.telephony;
 
-import com.android.services.telecomm.Connection;
+import android.telecomm.Connection;
 
 /**
  * A {@link Connection} object for SIP calls.
diff --git a/src/com/android/services/telephony/SipConnectionService.java b/src/com/android/services/telephony/SipConnectionService.java
index 8a61acf..7824274 100644
--- a/src/com/android/services/telephony/SipConnectionService.java
+++ b/src/com/android/services/telephony/SipConnectionService.java
@@ -31,9 +31,9 @@
 import com.android.phone.PhoneUtils;
 import com.android.phone.sip.SipProfileDb;
 import com.android.phone.sip.SipSharedPreferences;
-import com.android.services.telecomm.Connection;
-import com.android.services.telecomm.ConnectionRequest;
-import com.android.services.telecomm.Response;
+import android.telecomm.Connection;
+import android.telecomm.ConnectionRequest;
+import android.telecomm.Response;
 
 import java.util.HashMap;
 
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index e11e3ef..5f2de83 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -24,7 +24,7 @@
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Phone;
-import com.android.services.telecomm.Connection;
+import android.telecomm.Connection;
 
 /**
  * Manages a single phone call in Telephony.
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index d575f05..24d11fb 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -21,14 +21,13 @@
 
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Phone;
-import com.android.services.telecomm.Connection;
-import com.android.services.telecomm.ConnectionRequest;
-import com.android.services.telecomm.ConnectionService;
-import com.android.services.telecomm.Response;
-import com.android.services.telecomm.Subscription;
+import android.telecomm.Connection;
+import android.telecomm.ConnectionRequest;
+import android.telecomm.ConnectionService;
+import android.telecomm.Response;
+import android.telecomm.Subscription;
 
-import com.google.android.collect.Sets;
-
+import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -37,7 +36,7 @@
  */
 public abstract class TelephonyConnectionService extends ConnectionService {
     private static final Set<com.android.internal.telephony.Connection> sKnownConnections
-            = Sets.newHashSet();
+            = new HashSet<>();
 
     /** {@inheritDoc} */
     @Override
diff --git a/src/com/android/services/telephony/TelephonyGlobals.java b/src/com/android/services/telephony/TelephonyGlobals.java
index 8ca7e03..2830e26 100644
--- a/src/com/android/services/telephony/TelephonyGlobals.java
+++ b/src/com/android/services/telephony/TelephonyGlobals.java
@@ -66,12 +66,12 @@
         if (TelephonyManager.PHONE_TYPE_GSM == phoneType) {
             Log.d(this, "Phone type GSM found");
             mGsmIncomingCallNotifier = new IncomingCallNotifier(
-                    GsmConnectionService.class, CachedPhoneFactory.getGsmPhone());
+                    GsmConnectionService.class, PhoneFactory.getDefaultPhone());
 
         } else if (TelephonyManager.PHONE_TYPE_CDMA == phoneType) {
             Log.d(this, "Phone type CDMA found");
             mCdmaIncomingCallNotifier = new IncomingCallNotifier(
-                    CdmaConnectionService.class, CachedPhoneFactory.getCdmaPhone());
+                    CdmaConnectionService.class, PhoneFactory.getDefaultPhone());
         }
 
         // TODO(santoscordon): Do SIP.  SIP will require a slightly different solution since it