Final structural tweaks to Telecomm API (4/8)

Bug: 16416927
Bug: 16494880
Change-Id: Ic3def04d1cd14ec3c7c5e4eeb3bbd6ac62147421
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 6cfaeda..20bf353 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -22,23 +22,23 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
-import android.telecomm.CallCapabilities;
-import android.telecomm.CallPropertyPresentation;
-import android.telecomm.CallState;
 import android.telecomm.Connection;
+import android.telecomm.PhoneCapabilities;
+import android.telecomm.PropertyPresentation;
+import android.telecomm.CallState;
 import android.telecomm.ConnectionRequest;
-import android.telecomm.ConnectionService.VideoCallProvider;
 import android.telecomm.GatewayInfo;
 import android.telecomm.ParcelableConnection;
 import android.telecomm.PhoneAccount;
 import android.telecomm.PhoneAccountHandle;
 import android.telecomm.Response;
 import android.telecomm.StatusHints;
+import android.telecomm.VideoProfile;
 import android.telephony.DisconnectCause;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 
-import com.android.internal.telecomm.IVideoCallProvider;
+import com.android.internal.telecomm.IVideoProvider;
 import com.android.internal.telephony.CallerInfo;
 import com.android.internal.telephony.CallerInfoAsyncQuery;
 import com.android.internal.telephony.CallerInfoAsyncQuery.OnQueryCompleteListener;
@@ -65,7 +65,7 @@
      * Listener for events on the call.
      */
     interface Listener {
-        void onSuccessfulOutgoingCall(Call call, CallState callState);
+        void onSuccessfulOutgoingCall(Call call, int callState);
         void onFailedOutgoingCall(Call call, int errorCode, String errorMsg);
         void onCancelledOutgoingCall(Call call);
         void onSuccessfulIncomingCall(Call call);
@@ -94,7 +94,7 @@
 
     abstract static class ListenerBase implements Listener {
         @Override
-        public void onSuccessfulOutgoingCall(Call call, CallState callState) {}
+        public void onSuccessfulOutgoingCall(Call call, int callState) {}
         @Override
         public void onFailedOutgoingCall(Call call, int errorCode, String errorMsg) {}
         @Override
@@ -203,18 +203,18 @@
     private long mConnectTimeMillis;
 
     /** The state of the call. */
-    private CallState mState;
+    private int mState;
 
     /** The handle with which to establish this call. */
     private Uri mHandle;
 
-    /** The {@link CallPropertyPresentation} that controls how the handle is shown. */
+    /** The {@link PropertyPresentation} that controls how the handle is shown. */
     private int mHandlePresentation;
 
     /** The caller display name (CNAP) set by the connection service. */
     private String mCallerDisplayName;
 
-    /** The {@link CallPropertyPresentation} that controls how the caller display name is shown. */
+    /** The {@link PropertyPresentation} that controls how the caller display name is shown. */
     private int mCallerDisplayNamePresentation;
 
     /**
@@ -228,14 +228,14 @@
 
     /**
      * Tracks the video states which were applicable over the duration of a call.
-     * See {@link android.telecomm.VideoCallProfile} for a list of valid video states.
+     * See {@link VideoProfile} for a list of valid video states.
      */
     private int mVideoStateHistory;
 
     private int mVideoState;
 
     /**
-     * Disconnect cause for the call. Only valid if the state of the call is DISCONNECTED.
+     * Disconnect cause for the call. Only valid if the state of the call is STATE_DISCONNECTED.
      * See {@link android.telephony.DisconnectCause}.
      */
     private int mDisconnectCause = DisconnectCause.NOT_VALID;
@@ -279,7 +279,7 @@
     /** Whether an attempt has been made to load the text message responses. */
     private boolean mCannedSmsResponsesLoadingStarted = false;
 
-    private IVideoCallProvider mVideoCallProvider;
+    private IVideoProvider mVideoProvider;
 
     private boolean mAudioModeIsVoip;
     private StatusHints mStatusHints;
@@ -308,6 +308,7 @@
         mState = isConference ? CallState.ACTIVE : CallState.NEW;
         mRepository = repository;
         setHandle(handle);
+        setHandle(handle, PropertyPresentation.ALLOWED);
         mGatewayInfo = gatewayInfo;
         mConnectionManagerPhoneAccountHandle = connectionManagerPhoneAccountHandle;
         mTargetPhoneAccountHandle = targetPhoneAccountHandle;
@@ -336,7 +337,7 @@
                 Log.piiHandle(mHandle), getVideoState());
     }
 
-    CallState getState() {
+    int getState() {
         if (mIsConference) {
             if (!mChildCalls.isEmpty()) {
                 // If we have child calls, just return the child call.
@@ -354,7 +355,7 @@
      * misbehave and they do this very often. The result is that we do not enforce state transitions
      * and instead keep the code resilient to unexpected state changes.
      */
-    void setState(CallState newState) {
+    void setState(int newState) {
         Preconditions.checkState(newState != CallState.DISCONNECTED ||
                 mDisconnectCause != DisconnectCause.NOT_VALID);
         if (mState != newState) {
@@ -385,7 +386,7 @@
 
 
     void setHandle(Uri handle) {
-        setHandle(handle, CallPropertyPresentation.ALLOWED);
+        setHandle(handle, PropertyPresentation.ALLOWED);
     }
 
     void setHandle(Uri handle, int presentation) {
@@ -536,7 +537,7 @@
     }
 
     void setCallCapabilities(int callCapabilities) {
-        Log.v(this, "setCallCapabilities: %s", CallCapabilities.toString(callCapabilities));
+        Log.v(this, "setCallCapabilities: %s", PhoneCapabilities.toString(callCapabilities));
         if (mCallCapabilities != callCapabilities) {
            mCallCapabilities = callCapabilities;
             for (Listener l : mListeners) {
@@ -591,14 +592,14 @@
             if (mCallerInfo != null && mCallerInfo.shouldSendToVoicemail) {
                 Log.i(this, "Directing call to voicemail: %s.", this);
                 // TODO: Once we move State handling from CallsManager to Call, we
-                // will not need to set RINGING state prior to calling reject.
+                // will not need to set STATE_RINGING state prior to calling reject.
                 setState(CallState.RINGING);
                 reject(false, null);
             } else {
                 // TODO: Make this class (not CallsManager) responsible for changing
-                // the call state to RINGING.
+                // the call state to STATE_RINGING.
 
-                // TODO: Replace this with state transition to RINGING.
+                // TODO: Replace this with state transition to STATE_RINGING.
                 for (Listener l : mListeners) {
                     l.onSuccessfulIncomingCall(this);
                 }
@@ -628,7 +629,7 @@
         setCallerDisplayName(
                 connection.getCallerDisplayName(), connection.getCallerDisplayNamePresentation());
 
-        setVideoCallProvider(connection.getVideoCallProvider());
+        setVideoProvider(connection.getVideoProvider());
         setVideoState(connection.getVideoState());
 
         if (mIsIncoming) {
@@ -753,7 +754,7 @@
         if (isRinging("answer")) {
             // At this point, we are asking the connection service to answer but we don't assume
             // that it will work. Instead, we wait until confirmation from the connectino service
-            // that the call is in a non-RINGING state before changing the UI. See
+            // that the call is in a non-STATE_RINGING state before changing the UI. See
             // {@link ConnectionServiceAdapter#setActive} and other set* methods.
             mConnectionService.answer(this, videoState);
         }
@@ -800,10 +801,10 @@
     /** Checks if this is a live call or not. */
     boolean isAlive() {
         switch (mState) {
-            case NEW:
-            case RINGING:
-            case DISCONNECTED:
-            case ABORTED:
+            case CallState.NEW:
+            case CallState.RINGING:
+            case CallState.DISCONNECTED:
+            case CallState.ABORTED:
                 return false;
             default:
                 return true;
@@ -868,10 +869,6 @@
         // TODO: todo
     }
 
-    void swapWithBackgroundCall() {
-        mConnectionService.swapWithBackgroundCall(this);
-    }
-
     void setParentCall(Call parentCall) {
         if (parentCall == this) {
             Log.e(this, new Exception(), "setting the parent to self");
@@ -1122,28 +1119,23 @@
     /**
      * Sets a video call provider for the call.
      */
-    public void setVideoCallProvider(IVideoCallProvider videoCallProvider) {
-        mVideoCallProvider = videoCallProvider;
+    public void setVideoProvider(IVideoProvider videoProvider) {
+        mVideoProvider = videoProvider;
         for (Listener l : mListeners) {
             l.onVideoCallProviderChanged(Call.this);
         }
     }
 
     /**
-     * @return Return the {@link VideoCallProvider} binder.
+     * @return Return the {@link Connection.VideoProvider} binder.
      */
-    public IVideoCallProvider getVideoCallProvider() {
-        return mVideoCallProvider;
+    public IVideoProvider getVideoProvider() {
+        return mVideoProvider;
     }
 
     /**
      * The current video state for the call.
-     * Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}.
-     *
-     * @return True if video is enabled.
+     * Valid values: see {@link VideoProfile.VideoState}.
      */
     public int getVideoState() {
         return mVideoState;
@@ -1151,7 +1143,7 @@
 
     /**
      * Returns the video states which were applicable over the duration of a call.
-     * See {@link android.telecomm.VideoCallProfile} for a list of valid video states.
+     * See {@link VideoProfile} for a list of valid video states.
      *
      * @return The video states applicable over the duration of the call.
      */
@@ -1162,10 +1154,7 @@
     /**
      * Determines the current video state for the call.
      * For an outgoing call determines the desired video state for the call.
-     * Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED},
-     * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}.
+     * Valid values: see {@link VideoProfile.VideoState}
      *
      * @param videoState The video state for the call.
      */
@@ -1211,19 +1200,19 @@
         }
     }
 
-    private CallState getStateFromConnectionState(int state) {
+    private int getStateFromConnectionState(int state) {
         switch (state) {
-            case Connection.State.ACTIVE:
+            case Connection.STATE_ACTIVE:
                 return CallState.ACTIVE;
-            case Connection.State.DIALING:
+            case Connection.STATE_DIALING:
                 return CallState.DIALING;
-            case Connection.State.DISCONNECTED:
+            case Connection.STATE_DISCONNECTED:
                 return CallState.DISCONNECTED;
-            case Connection.State.HOLDING:
+            case Connection.STATE_HOLDING:
                 return CallState.ON_HOLD;
-            case Connection.State.NEW:
+            case Connection.STATE_NEW:
                 return CallState.NEW;
-            case Connection.State.RINGING:
+            case Connection.STATE_RINGING:
                 return CallState.RINGING;
         }
         return CallState.DISCONNECTED;
diff --git a/src/com/android/telecomm/CallAudioManager.java b/src/com/android/telecomm/CallAudioManager.java
index 1e15559..b42f5d8 100644
--- a/src/com/android/telecomm/CallAudioManager.java
+++ b/src/com/android/telecomm/CallAudioManager.java
@@ -18,7 +18,7 @@
 
 import android.content.Context;
 import android.media.AudioManager;
-import android.telecomm.CallAudioState;
+import android.telecomm.AudioState;
 import android.telecomm.CallState;
 
 import com.google.common.base.Preconditions;
@@ -37,7 +37,7 @@
     private final BluetoothManager mBluetoothManager;
     private final WiredHeadsetManager mWiredHeadsetManager;
 
-    private CallAudioState mAudioState;
+    private AudioState mAudioState;
     private int mAudioFocusStreamType;
     private boolean mIsRinging;
     private boolean mIsTonePlaying;
@@ -56,7 +56,7 @@
         mAudioFocusStreamType = STREAM_NONE;
     }
 
-    CallAudioState getAudioState() {
+    AudioState getAudioState() {
         return mAudioState;
     }
 
@@ -86,7 +86,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         onCallUpdated(call);
     }
 
@@ -100,7 +100,7 @@
         boolean isOnlyCall = CallsManager.getInstance().getCalls().size() == 1;
         if (isOnlyCall && mBluetoothManager.isBluetoothAvailable()) {
             mBluetoothManager.connectBluetoothAudio();
-            route = CallAudioState.ROUTE_BLUETOOTH;
+            route = AudioState.ROUTE_BLUETOOTH;
         }
 
         setSystemAudioState(false /* isMute */, route, mAudioState.supportedRouteMask);
@@ -129,14 +129,14 @@
             return;
         }
 
-        int newRoute = CallAudioState.ROUTE_EARPIECE;
+        int newRoute = AudioState.ROUTE_EARPIECE;
         if (newIsPluggedIn) {
-            newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
+            newRoute = AudioState.ROUTE_WIRED_HEADSET;
         } else if (mWasSpeakerOn) {
             Call call = getForegroundCall();
             if (call != null && call.isAlive()) {
                 // Restore the speaker state.
-                newRoute = CallAudioState.ROUTE_SPEAKER;
+                newRoute = AudioState.ROUTE_SPEAKER;
             }
         }
         setSystemAudioState(mAudioState.isMuted, newRoute, calculateSupportedRoutes());
@@ -167,7 +167,7 @@
     /**
      * Changed the audio route, for example from earpiece to speaker phone.
      *
-     * @param route The new audio route to use. See {@link CallAudioState}.
+     * @param route The new audio route to use. See {@link AudioState}.
      */
     void setAudioRoute(int route) {
         // This can happen even when there are no calls and we don't have focus.
@@ -175,7 +175,7 @@
             return;
         }
 
-        Log.v(this, "setAudioRoute, route: %s", CallAudioState.audioRouteToString(route));
+        Log.v(this, "setAudioRoute, route: %s", AudioState.audioRouteToString(route));
 
         // Change ROUTE_WIRED_OR_EARPIECE to a single entry.
         int newRoute = selectWiredOrEarpiece(route, mAudioState.supportedRouteMask);
@@ -189,7 +189,7 @@
         if (mAudioState.route != newRoute) {
             // Remember the new speaker state so it can be restored when the user plugs and unplugs
             // a headset.
-            mWasSpeakerOn = newRoute == CallAudioState.ROUTE_SPEAKER;
+            mWasSpeakerOn = newRoute == AudioState.ROUTE_SPEAKER;
             setSystemAudioState(mAudioState.isMuted, newRoute, mAudioState.supportedRouteMask);
         }
     }
@@ -230,9 +230,9 @@
 
         int newRoute = mAudioState.route;
         if (bluetoothManager.isBluetoothAudioConnectedOrPending()) {
-            newRoute = CallAudioState.ROUTE_BLUETOOTH;
-        } else if (mAudioState.route == CallAudioState.ROUTE_BLUETOOTH) {
-            newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
+            newRoute = AudioState.ROUTE_BLUETOOTH;
+        } else if (mAudioState.route == AudioState.ROUTE_BLUETOOTH) {
+            newRoute = AudioState.ROUTE_WIRED_OR_EARPIECE;
             // Do not switch to speaker when bluetooth disconnects.
             mWasSpeakerOn = false;
         }
@@ -248,10 +248,10 @@
         return mBluetoothManager.isBluetoothAvailable();
     }
 
-    private void saveAudioState(CallAudioState audioState) {
+    private void saveAudioState(AudioState audioState) {
         mAudioState = audioState;
         mStatusBarNotifier.notifyMute(mAudioState.isMuted);
-        mStatusBarNotifier.notifySpeakerphone(mAudioState.route == CallAudioState.ROUTE_SPEAKER);
+        mStatusBarNotifier.notifySpeakerphone(mAudioState.route == AudioState.ROUTE_SPEAKER);
     }
 
     private void onCallUpdated(Call call) {
@@ -269,8 +269,8 @@
             return;
         }
 
-        CallAudioState oldAudioState = mAudioState;
-        saveAudioState(new CallAudioState(isMuted, route, supportedRouteMask));
+        AudioState oldAudioState = mAudioState;
+        saveAudioState(new AudioState(isMuted, route, supportedRouteMask));
         if (Objects.equals(oldAudioState, mAudioState)) {
             return;
         }
@@ -283,14 +283,14 @@
         }
 
         // Audio route.
-        if (mAudioState.route == CallAudioState.ROUTE_BLUETOOTH) {
+        if (mAudioState.route == AudioState.ROUTE_BLUETOOTH) {
             turnOnSpeaker(false);
             turnOnBluetooth(true);
-        } else if (mAudioState.route == CallAudioState.ROUTE_SPEAKER) {
+        } else if (mAudioState.route == AudioState.ROUTE_SPEAKER) {
             turnOnBluetooth(false);
             turnOnSpeaker(true);
-        } else if (mAudioState.route == CallAudioState.ROUTE_EARPIECE ||
-                mAudioState.route == CallAudioState.ROUTE_WIRED_HEADSET) {
+        } else if (mAudioState.route == AudioState.ROUTE_EARPIECE ||
+                mAudioState.route == AudioState.ROUTE_WIRED_HEADSET) {
             turnOnBluetooth(false);
             turnOnSpeaker(false);
         }
@@ -390,37 +390,37 @@
         // Since they are mutually exclusive and one is ALWAYS valid, we allow a special input of
         // ROUTE_WIRED_OR_EARPIECE so that callers dont have to make a call to check which is
         // supported before calling setAudioRoute.
-        if (route == CallAudioState.ROUTE_WIRED_OR_EARPIECE) {
-            route = CallAudioState.ROUTE_WIRED_OR_EARPIECE & supportedRouteMask;
+        if (route == AudioState.ROUTE_WIRED_OR_EARPIECE) {
+            route = AudioState.ROUTE_WIRED_OR_EARPIECE & supportedRouteMask;
             if (route == 0) {
                 Log.wtf(this, "One of wired headset or earpiece should always be valid.");
                 // assume earpiece in this case.
-                route = CallAudioState.ROUTE_EARPIECE;
+                route = AudioState.ROUTE_EARPIECE;
             }
         }
         return route;
     }
 
     private int calculateSupportedRoutes() {
-        int routeMask = CallAudioState.ROUTE_SPEAKER;
+        int routeMask = AudioState.ROUTE_SPEAKER;
 
         if (mWiredHeadsetManager.isPluggedIn()) {
-            routeMask |= CallAudioState.ROUTE_WIRED_HEADSET;
+            routeMask |= AudioState.ROUTE_WIRED_HEADSET;
         } else {
-            routeMask |= CallAudioState.ROUTE_EARPIECE;
+            routeMask |= AudioState.ROUTE_EARPIECE;
         }
 
         if (mBluetoothManager.isBluetoothAvailable()) {
-            routeMask |=  CallAudioState.ROUTE_BLUETOOTH;
+            routeMask |=  AudioState.ROUTE_BLUETOOTH;
         }
 
         return routeMask;
     }
 
-    private CallAudioState getInitialAudioState(Call call) {
+    private AudioState getInitialAudioState(Call call) {
         int supportedRouteMask = calculateSupportedRoutes();
         int route = selectWiredOrEarpiece(
-                CallAudioState.ROUTE_WIRED_OR_EARPIECE, supportedRouteMask);
+                AudioState.ROUTE_WIRED_OR_EARPIECE, supportedRouteMask);
 
         // We want the UI to indicate that "bluetooth is in use" in two slightly different cases:
         // (a) The obvious case: if a bluetooth headset is currently in use for an ongoing call.
@@ -430,22 +430,22 @@
         //     the first call.
         if (call != null && mBluetoothManager.isBluetoothAvailable()) {
             switch(call.getState()) {
-                case ACTIVE:
-                case ON_HOLD:
-                case DIALING:
-                case RINGING:
-                    route = CallAudioState.ROUTE_BLUETOOTH;
+                case CallState.ACTIVE:
+                case CallState.ON_HOLD:
+                case CallState.DIALING:
+                case CallState.RINGING:
+                    route = AudioState.ROUTE_BLUETOOTH;
                     break;
                 default:
                     break;
             }
         }
 
-        return new CallAudioState(false, route, supportedRouteMask);
+        return new AudioState(false, route, supportedRouteMask);
     }
 
     private void setInitialAudioState(Call call) {
-        CallAudioState audioState = getInitialAudioState(call);
+        AudioState audioState = getInitialAudioState(call);
         Log.v(this, "setInitialAudioState %s, %s", audioState, call);
         setSystemAudioState(audioState.isMuted, audioState.route, audioState.supportedRouteMask);
     }
diff --git a/src/com/android/telecomm/CallLogManager.java b/src/com/android/telecomm/CallLogManager.java
index 33c6d5a..d0668b9 100644
--- a/src/com/android/telecomm/CallLogManager.java
+++ b/src/com/android/telecomm/CallLogManager.java
@@ -22,7 +22,7 @@
 import android.provider.CallLog.Calls;
 import android.telecomm.CallState;
 import android.telecomm.PhoneAccountHandle;
-import android.telecomm.VideoCallProfile;
+import android.telecomm.VideoProfile;
 import android.telephony.PhoneNumberUtils;
 
 import com.android.internal.telephony.CallerInfo;
@@ -87,7 +87,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         if ((newState == CallState.DISCONNECTED || newState == CallState.ABORTED) &&
                 oldState != CallState.PRE_DIAL_WAIT) {
             int type;
@@ -180,8 +180,8 @@
      * @return The call features.
      */
     private static int getCallFeatures(int videoState) {
-        if ((videoState & VideoCallProfile.VideoState.TX_ENABLED)
-                == VideoCallProfile.VideoState.TX_ENABLED) {
+        if ((videoState & VideoProfile.VideoState.TX_ENABLED)
+                == VideoProfile.VideoState.TX_ENABLED) {
             return Calls.FEATURES_VIDEO;
         }
         return Calls.FEATURES_NONE;
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index d9d3ef9..5f01cb8 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -18,7 +18,7 @@
 
 import android.net.Uri;
 import android.os.Bundle;
-import android.telecomm.CallAudioState;
+import android.telecomm.AudioState;
 import android.telecomm.CallState;
 import android.telecomm.GatewayInfo;
 import android.telecomm.PhoneAccountHandle;
@@ -46,7 +46,7 @@
     interface CallsManagerListener {
         void onCallAdded(Call call);
         void onCallRemoved(Call call);
-        void onCallStateChanged(Call call, CallState oldState, CallState newState);
+        void onCallStateChanged(Call call, int oldState, int newState);
         void onConnectionServiceChanged(
                 Call call,
                 ConnectionServiceWrapper oldService,
@@ -54,7 +54,7 @@
         void onIncomingCallAnswered(Call call);
         void onIncomingCallRejected(Call call, boolean rejectWithMessage, String textMessage);
         void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall);
-        void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState);
+        void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState);
         void onRequestingRingback(Call call, boolean ringback);
         void onIsConferencedChanged(Call call);
         void onAudioModeIsVoipChanged(Call call);
@@ -123,7 +123,7 @@
     }
 
     @Override
-    public void onSuccessfulOutgoingCall(Call call, CallState callState) {
+    public void onSuccessfulOutgoingCall(Call call, int callState) {
         Log.v(this, "onSuccessfulOutgoingCall, %s", call);
         setCallState(call, callState);
         if (mCalls.contains(call)) {
@@ -245,7 +245,7 @@
         return false;
     }
 
-    CallAudioState getAudioState() {
+    AudioState getAudioState() {
         return mCallAudioManager.getAudioState();
     }
 
@@ -354,7 +354,7 @@
         // as if a phoneAccount was not specified (does the default behavior instead).
         if (accountHandle != null) {
             List<PhoneAccountHandle> enabledAccounts =
-                    app.getPhoneAccountRegistrar().getEnabledPhoneAccounts();
+                    app.getPhoneAccountRegistrar().getOutgoingPhoneAccounts();
             if (!enabledAccounts.contains(accountHandle)) {
                 accountHandle = null;
             }
@@ -425,7 +425,7 @@
             Log.i(this, "Request to answer a non-existent call %s", call);
         } else {
             // If the foreground call is not the ringing call and it is currently isActive() or
-            // DIALING, put it on hold before answering the call.
+            // STATE_DIALING, put it on hold before answering the call.
             if (mForegroundCall != null && mForegroundCall != call &&
                     (mForegroundCall.isActive() ||
                      mForegroundCall.getState() == CallState.DIALING)) {
@@ -588,7 +588,7 @@
     }
 
     /** Called when the audio state changes. */
-    void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState) {
+    void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState) {
         Log.v(this, "onAudioStateChanged, audioState: %s -> %s", oldAudioState, newAudioState);
         for (CallsManagerListener listener : mListeners) {
             listener.onAudioStateChanged(oldAudioState, newAudioState);
@@ -610,7 +610,7 @@
         setCallState(call, CallState.ACTIVE);
 
         if (call.getStartWithSpeakerphoneOn()) {
-            setAudioRoute(CallAudioState.ROUTE_SPEAKER);
+            setAudioRoute(AudioState.ROUTE_SPEAKER);
         }
     }
 
@@ -619,7 +619,7 @@
     }
 
     /**
-     * Marks the specified call as DISCONNECTED and notifies the in-call app. If this was the last
+     * Marks the specified call as STATE_DISCONNECTED and notifies the in-call app. If this was the last
      * live call, then also disconnect from the in-call controller.
      *
      * @param disconnectCause The disconnect reason, see {@link android.telephony.DisconnectCause}.
@@ -710,8 +710,8 @@
      * priority order so that any call with the first state will be returned before any call with
      * states listed later in the parameter list.
      */
-    Call getFirstCallWithState(CallState... states) {
-        for (CallState currentState : states) {
+    Call getFirstCallWithState(int... states) {
+        for (int currentState : states) {
             // check the foreground first
             if (mForegroundCall != null && mForegroundCall.getState() == currentState) {
                 return mForegroundCall;
@@ -769,14 +769,14 @@
      * @param call The call.
      * @param newState The new state of the call.
      */
-    private void setCallState(Call call, CallState newState) {
+    private void setCallState(Call call, int newState) {
         Preconditions.checkNotNull(newState);
-        CallState oldState = call.getState();
+        int oldState = call.getState();
         Log.i(this, "setCallState %s -> %s, call: %s", oldState, newState, call);
         if (newState != oldState) {
             // Unfortunately, in the telephony world the radio is king. So if the call notifies
             // us that the call is in a particular state, we allow it even if it doesn't make
-            // sense (e.g., ACTIVE -> RINGING).
+            // sense (e.g., STATE_ACTIVE -> STATE_RINGING).
             // TODO: Consider putting a stop to the above and turning CallState
             // into a well-defined state machine.
             // TODO: Define expected state transitions here, and log when an
diff --git a/src/com/android/telecomm/CallsManagerListenerBase.java b/src/com/android/telecomm/CallsManagerListenerBase.java
index 7753105..65ce4ac 100644
--- a/src/com/android/telecomm/CallsManagerListenerBase.java
+++ b/src/com/android/telecomm/CallsManagerListenerBase.java
@@ -16,7 +16,7 @@
 
 package com.android.telecomm;
 
-import android.telecomm.CallAudioState;
+import android.telecomm.AudioState;
 import android.telecomm.CallState;
 
 /**
@@ -32,7 +32,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
     }
 
     @Override
@@ -55,7 +55,7 @@
     }
 
     @Override
-    public void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState) {
+    public void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState) {
     }
 
     @Override
diff --git a/src/com/android/telecomm/ConnectionServiceWrapper.java b/src/com/android/telecomm/ConnectionServiceWrapper.java
index 76612d4..2d5ade2 100644
--- a/src/com/android/telecomm/ConnectionServiceWrapper.java
+++ b/src/com/android/telecomm/ConnectionServiceWrapper.java
@@ -24,7 +24,7 @@
 import android.os.IBinder;
 import android.os.Message;
 import android.os.RemoteException;
-import android.telecomm.CallAudioState;
+import android.telecomm.AudioState;
 import android.telecomm.ConnectionRequest;
 import android.telecomm.ConnectionService;
 import android.telecomm.GatewayInfo;
@@ -37,13 +37,11 @@
 import com.android.internal.os.SomeArgs;
 import com.android.internal.telecomm.IConnectionService;
 import com.android.internal.telecomm.IConnectionServiceAdapter;
-import com.android.internal.telecomm.IVideoCallProvider;
+import com.android.internal.telecomm.IVideoProvider;
 import com.android.internal.telecomm.RemoteServiceCallback;
 import com.google.common.base.Preconditions;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -73,7 +71,7 @@
     private static final int MSG_REMOVE_CALL = 13;
     private static final int MSG_ON_POST_DIAL_WAIT = 14;
     private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 15;
-    private static final int MSG_SET_CALL_VIDEO_PROVIDER = 16;
+    private static final int MSG_SET_VIDEO_PROVIDER = 16;
     private static final int MSG_SET_AUDIO_MODE_IS_VOIP = 17;
     private static final int MSG_SET_STATUS_HINTS = 18;
     private static final int MSG_SET_HANDLE = 19;
@@ -90,10 +88,11 @@
                 case MSG_HANDLE_CREATE_CONNECTION_SUCCESSFUL: {
                     SomeArgs args = (SomeArgs) msg.obj;
                     try {
-                        ConnectionRequest request = (ConnectionRequest) args.arg1;
-                        if (mPendingResponses.containsKey(request.getCallId())) {
-                            ParcelableConnection connection = (ParcelableConnection) args.arg2;
-                            mPendingResponses.remove(request.getCallId()).
+                        String callId = (String) args.arg1;
+                        ConnectionRequest request = (ConnectionRequest) args.arg2;
+                        if (mPendingResponses.containsKey(callId)) {
+                            ParcelableConnection connection = (ParcelableConnection) args.arg3;
+                            mPendingResponses.remove(callId).
                                     handleCreateConnectionSuccessful(request, connection);
                         }
                     } finally {
@@ -104,11 +103,12 @@
                 case MSG_HANDLE_CREATE_CONNECTION_FAILED: {
                     SomeArgs args = (SomeArgs) msg.obj;
                     try {
-                        ConnectionRequest request = (ConnectionRequest) args.arg1;
+                        String callId = (String) args.arg1;
+                        ConnectionRequest request = (ConnectionRequest) args.arg2;
                         int statusCode = args.argi1;
-                        String statusMsg = (String) args.arg2;
+                        String statusMsg = (String) args.arg3;
                         removeCall(
-                                mCallIdMapper.getCall(request.getCallId()),
+                                mCallIdMapper.getCall(callId),
                                 statusCode,
                                 statusMsg);
                     } finally {
@@ -117,12 +117,18 @@
                     break;
                 }
                 case MSG_HANDLE_CREATE_CONNECTION_CANCELLED: {
-                    ConnectionRequest request = (ConnectionRequest) msg.obj;
-                    if (mPendingResponses.containsKey(request.getCallId())) {
-                        mPendingResponses.remove(
-                                request.getCallId()).handleCreateConnectionCancelled();
-                    } else {
-                        //Log.w(this, "handleCreateConnectionCancelled, unknown call: %s", callId);
+                    SomeArgs args = (SomeArgs) msg.obj;
+                    try {
+                        String callId = (String) args.arg1;
+                        ConnectionRequest request = (ConnectionRequest) args.arg2;
+                        if (mPendingResponses.containsKey(callId)) {
+                            mPendingResponses.remove(callId)
+                                    .handleCreateConnectionCancelled();
+                        } else {
+                            //Log.w(this, "handleCreateConnectionCancelled, unknown call: %s", callId);
+                        }
+                    } finally {
+                        args.recycle();
                     }
                     break;
                 }
@@ -251,13 +257,13 @@
                     queryRemoteConnectionServices((RemoteServiceCallback) msg.obj);
                     break;
                 }
-                case MSG_SET_CALL_VIDEO_PROVIDER: {
+                case MSG_SET_VIDEO_PROVIDER: {
                     SomeArgs args = (SomeArgs) msg.obj;
                     try {
                         call = mCallIdMapper.getCall(args.arg1);
-                        IVideoCallProvider videoCallProvider = (IVideoCallProvider) args.arg2;
+                        IVideoProvider videoProvider = (IVideoProvider) args.arg2;
                         if (call != null) {
-                            call.setVideoCallProvider(videoCallProvider);
+                            call.setVideoProvider(videoProvider);
                         }
                     } finally {
                         args.recycle();
@@ -354,37 +360,50 @@
     };
 
     private final class Adapter extends IConnectionServiceAdapter.Stub {
+
         @Override
         public void handleCreateConnectionSuccessful(
-                ConnectionRequest request, ParcelableConnection connection) {
-
+                String callId,
+                ConnectionRequest request,
+                ParcelableConnection connection) {
             logIncoming("handleCreateConnectionSuccessful %s", request);
-            if (mCallIdMapper.isValidCallId(request.getCallId())) {
+            if (mCallIdMapper.isValidCallId(callId)) {
                 SomeArgs args = SomeArgs.obtain();
-                args.arg1 = request;
-                args.arg2 = connection;
-                mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_SUCCESSFUL, args).sendToTarget();
+                args.arg1 = callId;
+                args.arg2 = request;
+                args.arg3 = connection;
+                mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_SUCCESSFUL, args)
+                        .sendToTarget();
             }
         }
 
         @Override
         public void handleCreateConnectionFailed(
-                ConnectionRequest request, int errorCode, String errorMsg) {
+                String callId,
+                ConnectionRequest request,
+                int errorCode,
+                String errorMsg) {
             logIncoming("handleCreateConnectionFailed %s %d %s", request, errorCode, errorMsg);
-            if (mCallIdMapper.isValidCallId(request.getCallId())) {
+            if (mCallIdMapper.isValidCallId(callId)) {
                 SomeArgs args = SomeArgs.obtain();
-                args.arg1 = request;
+                args.arg1 = callId;
+                args.arg2 = request;
                 args.argi1 = errorCode;
-                args.arg2 = errorMsg;
+                args.arg3 = errorMsg;
                 mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_FAILED, args).sendToTarget();
             }
         }
 
         @Override
-        public void handleCreateConnectionCancelled(ConnectionRequest request) {
+        public void handleCreateConnectionCancelled(
+                String callId,
+                ConnectionRequest request) {
             logIncoming("handleCreateConnectionCancelled %s", request);
-            if (mCallIdMapper.isValidCallId(request.getCallId())) {
-                mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_CANCELLED, request).sendToTarget();
+            if (mCallIdMapper.isValidCallId(callId)) {
+                SomeArgs args = SomeArgs.obtain();
+                args.arg1 = callId;
+                args.arg2 = request;
+                mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_CANCELLED, args).sendToTarget();
             }
         }
 
@@ -405,13 +424,13 @@
         }
 
         @Override
-        public void setVideoCallProvider(String callId, IVideoCallProvider videoCallProvider) {
-            logIncoming("setVideoCallProvider %s", callId);
+        public void setVideoProvider(String callId, IVideoProvider videoProvider) {
+            logIncoming("setVideoProvider %s", callId);
             if (mCallIdMapper.isValidCallId(callId)) {
                 SomeArgs args = SomeArgs.obtain();
                 args.arg1 = callId;
-                args.arg2 = videoCallProvider;
-                mHandler.obtainMessage(MSG_SET_CALL_VIDEO_PROVIDER, args).sendToTarget();
+                args.arg2 = videoProvider;
+                mHandler.obtainMessage(MSG_SET_VIDEO_PROVIDER, args).sendToTarget();
             }
         }
 
@@ -648,9 +667,9 @@
                 try {
                     mServiceInterface.createConnection(
                             call.getConnectionManagerPhoneAccount(),
+                            callId,
                             new ConnectionRequest(
                                     call.getTargetPhoneAccount(),
-                                    callId,
                                     call.getHandle(),
                                     call.getHandlePresentation(),
                                     extras,
@@ -714,8 +733,8 @@
         }
     }
 
-    /** @see ConnectionService#onAudioStateChanged(String,CallAudioState) */
-    void onAudioStateChanged(Call activeCall, CallAudioState audioState) {
+    /** @see ConnectionService#onAudioStateChanged(String,AudioState) */
+    void onAudioStateChanged(Call activeCall, AudioState audioState) {
         final String callId = mCallIdMapper.getCallId(activeCall);
         if (callId != null && isServiceValid("onAudioStateChanged")) {
             try {
@@ -870,17 +889,6 @@
         }
     }
 
-    void swapWithBackgroundCall(Call call) {
-        final String callId = mCallIdMapper.getCallId(call);
-        if (callId != null && isServiceValid("swapWithBackgroundCall")) {
-            try {
-                logOutgoing("swapWithBackgroundCall %s", callId);
-                mServiceInterface.swapWithBackgroundCall(callId);
-            } catch (RemoteException ignored) {
-            }
-        }
-    }
-
     /** {@inheritDoc} */
     @Override
     protected void setServiceInterface(IBinder binder) {
@@ -936,7 +944,7 @@
 
         // Make a list of ConnectionServices that are listed as being associated with SIM accounts
         final Set<ConnectionServiceWrapper> simServices = new HashSet<>();
-        for (PhoneAccountHandle handle : registrar.getEnabledPhoneAccounts()) {
+        for (PhoneAccountHandle handle : registrar.getOutgoingPhoneAccounts()) {
             PhoneAccount account = registrar.getPhoneAccount(handle);
             if ((account.getCapabilities() & PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) != 0) {
                 ConnectionServiceWrapper service =
diff --git a/src/com/android/telecomm/CreateConnectionProcessor.java b/src/com/android/telecomm/CreateConnectionProcessor.java
index 8ba73bf..cc7808e 100644
--- a/src/com/android/telecomm/CreateConnectionProcessor.java
+++ b/src/com/android/telecomm/CreateConnectionProcessor.java
@@ -189,7 +189,7 @@
             Log.i(this, "Emergency number detected");
             mAttemptRecords.clear();
             List<PhoneAccountHandle> allAccountHandles = TelecommApp.getInstance()
-                    .getPhoneAccountRegistrar().getEnabledPhoneAccounts();
+                    .getPhoneAccountRegistrar().getOutgoingPhoneAccounts();
             for (int i = 0; i < allAccountHandles.size(); i++) {
                 if (TelephonyUtil.isPstnComponentName(
                         allAccountHandles.get(i).getComponentName())) {
diff --git a/src/com/android/telecomm/InCallAdapter.java b/src/com/android/telecomm/InCallAdapter.java
index 66ce1ee..9f3fd0f 100644
--- a/src/com/android/telecomm/InCallAdapter.java
+++ b/src/com/android/telecomm/InCallAdapter.java
@@ -184,14 +184,6 @@
                         Log.w(this, "splitFromConference, unknown call id: %s", msg.obj);
                     }
                     break;
-                case MSG_SWAP_WITH_BACKGROUND_CALL:
-                    call = mCallIdMapper.getCall(msg.obj);
-                    if (call != null) {
-                        call.swapWithBackgroundCall();
-                    } else {
-                        Log.w(this, "swapWithBackgroundCall, unknown call id: %s", msg.obj);
-                    }
-                    break;
                 case MSG_TURN_ON_PROXIMITY_SENSOR:
                     mCallsManager.turnOnProximitySensor();
                     break;
@@ -328,13 +320,6 @@
     }
 
     @Override
-    public void swapWithBackgroundCall(String callId) {
-        if (mCallIdMapper.isValidCallId(callId)) {
-            mHandler.obtainMessage(MSG_SWAP_WITH_BACKGROUND_CALL, callId).sendToTarget();
-        }
-    }
-
-    @Override
     public void turnOnProximitySensor() {
         mHandler.obtainMessage(MSG_TURN_ON_PROXIMITY_SENSOR).sendToTarget();
     }
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index c94b656..4f24c27 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -27,9 +27,9 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.UserHandle;
-import android.telecomm.CallAudioState;
-import android.telecomm.CallCapabilities;
-import android.telecomm.CallPropertyPresentation;
+import android.telecomm.AudioState;
+import android.telecomm.PhoneCapabilities;
+import android.telecomm.PropertyPresentation;
 import android.telecomm.CallState;
 import android.telecomm.ParcelableCall;
 
@@ -159,7 +159,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         updateCall(call);
     }
 
@@ -172,7 +172,7 @@
     }
 
     @Override
-    public void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState) {
+    public void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState) {
         if (mInCallService != null) {
             Log.i(this, "Calling onAudioStateChanged, audioState: %s -> %s", oldAudioState,
                     newAudioState);
@@ -304,13 +304,13 @@
 
         int capabilities = call.getCallCapabilities();
         if (CallsManager.getInstance().isAddCallCapable(call)) {
-            capabilities |= CallCapabilities.ADD_CALL;
+            capabilities |= PhoneCapabilities.ADD_CALL;
         }
         if (!call.isEmergencyCall()) {
-            capabilities |= CallCapabilities.MUTE;
+            capabilities |= PhoneCapabilities.MUTE;
         }
 
-        CallState state = call.getState();
+        int state = call.getState();
         if (state == CallState.ABORTED) {
             state = CallState.DISCONNECTED;
         }
@@ -333,13 +333,13 @@
         }
 
         if (call.isRespondViaSmsCapable()) {
-            capabilities |= CallCapabilities.RESPOND_VIA_TEXT;
+            capabilities |= PhoneCapabilities.RESPOND_VIA_TEXT;
         }
 
-        Uri handle = call.getHandlePresentation() == CallPropertyPresentation.ALLOWED ?
+        Uri handle = call.getHandlePresentation() == PropertyPresentation.ALLOWED ?
                 call.getHandle() : null;
         String callerDisplayName = call.getCallerDisplayNamePresentation() ==
-                CallPropertyPresentation.ALLOWED ?  call.getCallerDisplayName() : null;
+                PropertyPresentation.ALLOWED ?  call.getCallerDisplayName() : null;
 
         List<Call> conferenceableCalls = call.getConferenceableCalls();
         List<String> conferenceableCallIds = new ArrayList<String>(conferenceableCalls.size());
@@ -364,7 +364,7 @@
                 call.getCallerDisplayNamePresentation(),
                 call.getGatewayInfo(),
                 call.getTargetPhoneAccount(),
-                call.getVideoCallProvider(),
+                call.getVideoProvider(),
                 parentCallId,
                 childCallIds,
                 call.getStatusHints(),
diff --git a/src/com/android/telecomm/InCallToneMonitor.java b/src/com/android/telecomm/InCallToneMonitor.java
index bafbfcc..5757540 100644
--- a/src/com/android/telecomm/InCallToneMonitor.java
+++ b/src/com/android/telecomm/InCallToneMonitor.java
@@ -16,7 +16,6 @@
 
 package com.android.telecomm;
 
-import android.telecomm.CallAudioState;
 import android.telecomm.CallState;
 import android.telephony.DisconnectCause;
 
@@ -37,7 +36,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         if (mCallsManager.getForegroundCall() != call) {
             // We only play tones for foreground calls.
             return;
diff --git a/src/com/android/telecomm/MissedCallNotifier.java b/src/com/android/telecomm/MissedCallNotifier.java
index 9e757df..94de312 100644
--- a/src/com/android/telecomm/MissedCallNotifier.java
+++ b/src/com/android/telecomm/MissedCallNotifier.java
@@ -71,7 +71,7 @@
 
     /** {@inheritDoc} */
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         if (oldState == CallState.RINGING && newState == CallState.DISCONNECTED &&
                 call.getDisconnectCause() == DisconnectCause.INCOMING_MISSED) {
             showMissedCallNotification(call);
diff --git a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
index 71d8a96..a3aa740 100644
--- a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
@@ -26,7 +26,7 @@
 import android.telecomm.GatewayInfo;
 import android.telecomm.PhoneAccountHandle;
 import android.telecomm.TelecommManager;
-import android.telecomm.VideoCallProfile;
+import android.telecomm.VideoProfile;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 
@@ -130,7 +130,7 @@
                     mIntent.getBooleanExtra(TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE,
                             false),
                     mIntent.getIntExtra(TelecommManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
-                            VideoCallProfile.VideoState.AUDIO_ONLY));
+                            VideoProfile.VideoState.AUDIO_ONLY));
         }
     }
 
@@ -206,7 +206,7 @@
                     TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
             int videoState = mIntent.getIntExtra(
                     TelecommManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
-                    VideoCallProfile.VideoState.AUDIO_ONLY);
+                    VideoProfile.VideoState.AUDIO_ONLY);
             mCallsManager.placeOutgoingCall(mCall, Uri.fromParts(scheme, handle, null), null, null,
                     speakerphoneOn, videoState);
 
diff --git a/src/com/android/telecomm/PhoneAccountPreferencesActivity.java b/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
index 2551b47..a7a6a62 100644
--- a/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
+++ b/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
@@ -56,7 +56,7 @@
 
             mDefaultOutgoingAccount.setModel(
                     registrar,
-                    registrar.getEnabledPhoneAccounts(),
+                    registrar.getOutgoingPhoneAccounts(),
                     registrar.getDefaultOutgoingPhoneAccount(),
                     getString(R.string.account_ask_every_time));
 
diff --git a/src/com/android/telecomm/PhoneAccountRegistrar.java b/src/com/android/telecomm/PhoneAccountRegistrar.java
index c9e0e46..294fedb 100644
--- a/src/com/android/telecomm/PhoneAccountRegistrar.java
+++ b/src/com/android/telecomm/PhoneAccountRegistrar.java
@@ -19,7 +19,6 @@
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
 import android.telecomm.ConnectionService;
 import android.telecomm.PhoneAccount;
 import android.telecomm.PhoneAccountHandle;
@@ -97,14 +96,14 @@
             // as though there were no default
         }
 
-        List<PhoneAccountHandle> enabled = getEnabledPhoneAccounts();
-        switch (enabled.size()) {
+        List<PhoneAccountHandle> outgoing = getOutgoingPhoneAccounts();
+        switch (outgoing.size()) {
             case 0:
                 // There are no accounts, so there can be no default
                 return null;
             case 1:
                 // There is only one account, which is by definition the default
-                return enabled.get(0);
+                return outgoing.get(0);
             default:
                 // There are multiple accounts with no selected default
                 return null;
@@ -214,8 +213,7 @@
         return new ArrayList<>(mState.accounts);
     }
 
-    // TODO: Rename systemwide to "getCallProviderPhoneAccounts"?
-    public List<PhoneAccountHandle> getEnabledPhoneAccounts() {
+    public List<PhoneAccountHandle> getOutgoingPhoneAccounts() {
         return getCallProviderAccountHandles();
     }
 
@@ -574,14 +572,15 @@
                         shortDescription = parser.getText();
                     }
                 }
-                return new PhoneAccount(
-                        accountHandle,
-                        handle,
-                        subscriptionNumber,
-                        capabilities,
-                        iconResId,
-                        label,
-                        shortDescription);
+                return PhoneAccount.builder()
+                        .withAccountHandle(accountHandle)
+                        .withHandle(handle)
+                        .withSubscriptionNumber(subscriptionNumber)
+                        .withCapabilities(capabilities)
+                        .withIconResId(iconResId)
+                        .withLabel(label)
+                        .withShortDescription(shortDescription)
+                        .build();
             }
             return null;
         }
diff --git a/src/com/android/telecomm/PhoneStateBroadcaster.java b/src/com/android/telecomm/PhoneStateBroadcaster.java
index 7aab729..fa5185e 100644
--- a/src/com/android/telecomm/PhoneStateBroadcaster.java
+++ b/src/com/android/telecomm/PhoneStateBroadcaster.java
@@ -29,19 +29,19 @@
  */
 final class PhoneStateBroadcaster extends CallsManagerListenerBase {
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         final String phoneState;
         switch (newState) {
-            case DIALING:
-            case ACTIVE:
-            case ON_HOLD:
+            case CallState.DIALING:
+            case CallState.ACTIVE:
+            case CallState.ON_HOLD:
                 phoneState = TelephonyManager.EXTRA_STATE_OFFHOOK;
                 break;
-            case RINGING:
+            case CallState.RINGING:
                 phoneState = TelephonyManager.EXTRA_STATE_RINGING;
                 break;
-            case ABORTED:
-            case DISCONNECTED:
+            case CallState.ABORTED:
+            case CallState.DISCONNECTED:
                 phoneState = TelephonyManager.EXTRA_STATE_IDLE;
                 break;
             default:
diff --git a/src/com/android/telecomm/Ringer.java b/src/com/android/telecomm/Ringer.java
index 69d3a6a..a5edeb9 100644
--- a/src/com/android/telecomm/Ringer.java
+++ b/src/com/android/telecomm/Ringer.java
@@ -99,7 +99,7 @@
     }
 
     @Override
-    public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
+    public void onCallStateChanged(Call call, int oldState, int newState) {
         if (newState != CallState.RINGING) {
             removeFromUnansweredCall(call);
         }
@@ -139,8 +139,8 @@
             stopCallWaiting();
         }
 
-        // We do not remove the call from mRingingCalls until the call state changes from RINGING
-        // or the call is removed. see onCallStateChanged or onCallRemoved.
+        // We do not remove the call from mRingingCalls until the call state changes from
+        // STATE_RINGING or the call is removed. see onCallStateChanged or onCallRemoved.
     }
 
     private Call getTopMostUnansweredCall() {
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index 6e657d5..7af1534 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -170,11 +170,11 @@
     }
 
     @Override
-    public List<PhoneAccountHandle> getEnabledPhoneAccounts() {
+    public List<PhoneAccountHandle> getOutgoingPhoneAccounts() {
         try {
-            return mPhoneAccountRegistrar.getEnabledPhoneAccounts();
+            return mPhoneAccountRegistrar.getOutgoingPhoneAccounts();
         } catch (Exception e) {
-            Log.e(this, e, "getEnabledPhoneAccounts");
+            Log.e(this, e, "getOutgoingPhoneAccounts");
             throw e;
         }
     }