SIP telephony cleanup.

+ Remove unused classes.
+ Remove unused imports.
+ Remove unused code.
+ add DEBUG flag.

Change-Id: Ie1236d909d971093b68b066d3d8c1857ac89f56f
diff --git a/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java b/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java
deleted file mode 100644
index 4092c69..0000000
--- a/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2010 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.internal.telephony;
-
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-
-import com.android.internal.telephony.ITelephonyRegistry;
-
-/**
- * Temporary. Will be removed after integrating with CallManager.
- * 100% copy from DefaultPhoneNotifier. Cannot access its package level
- * constructor; thus the copy.
- * @hide
- */
-public class SipPhoneNotifier implements PhoneNotifier {
-
-    static final String LOG_TAG = "GSM";
-    private static final boolean DBG = true;
-    private ITelephonyRegistry mRegistry;
-
-    public SipPhoneNotifier() {
-        mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
-                    "telephony.registry"));
-    }
-
-    public void notifyPhoneState(Phone sender) {
-        Call ringingCall = sender.getRingingCall();
-        String incomingNumber = "";
-        if (ringingCall != null && ringingCall.getEarliestConnection() != null){
-            incomingNumber = ringingCall.getEarliestConnection().getAddress();
-        }
-        try {
-            mRegistry.notifyCallState(convertCallState(sender.getState()), incomingNumber);
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyServiceState(Phone sender) {
-        try {
-            mRegistry.notifyServiceState(sender.getServiceState());
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifySignalStrength(Phone sender) {
-        try {
-            mRegistry.notifySignalStrength(sender.getSignalStrength());
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyMessageWaitingChanged(Phone sender) {
-        try {
-            mRegistry.notifyMessageWaitingChanged(sender.getMessageWaitingIndicator());
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyCallForwardingChanged(Phone sender) {
-        try {
-            mRegistry.notifyCallForwardingChanged(sender.getCallForwardingIndicator());
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyDataActivity(Phone sender) {
-        try {
-            mRegistry.notifyDataActivity(convertDataActivityState(sender.getDataActivityState()));
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyDataConnection(Phone sender, String reason) {
-        TelephonyManager telephony = TelephonyManager.getDefault();
-        try {
-            mRegistry.notifyDataConnection(
-                    convertDataState(sender.getDataConnectionState()),
-                    sender.isDataConnectivityPossible(), reason,
-                    sender.getActiveApn(),
-                    sender.getActiveApnTypes(),
-                    sender.getInterfaceName(null),
-                    ((telephony!=null) ? telephony.getNetworkType() :
-                    TelephonyManager.NETWORK_TYPE_UNKNOWN),
-                    sender.getGateway(null));
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyDataConnectionFailed(Phone sender, String reason) {
-        try {
-            mRegistry.notifyDataConnectionFailed(reason);
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    public void notifyCellLocation(Phone sender) {
-        Bundle data = new Bundle();
-        sender.getCellLocation().fillInNotifierBundle(data);
-        try {
-            mRegistry.notifyCellLocation(data);
-        } catch (RemoteException ex) {
-            // system process is dead
-        }
-    }
-
-    private void log(String s) {
-        Log.d(LOG_TAG, "[PhoneNotifier] " + s);
-    }
-
-    /**
-     * Convert the {@link State} enum into the TelephonyManager.CALL_STATE_* constants
-     * for the public API.
-     */
-    public static int convertCallState(Phone.State state) {
-        switch (state) {
-            case RINGING:
-                return TelephonyManager.CALL_STATE_RINGING;
-            case OFFHOOK:
-                return TelephonyManager.CALL_STATE_OFFHOOK;
-            default:
-                return TelephonyManager.CALL_STATE_IDLE;
-        }
-    }
-
-    /**
-     * Convert the TelephonyManager.CALL_STATE_* constants into the {@link State} enum
-     * for the public API.
-     */
-    public static Phone.State convertCallState(int state) {
-        switch (state) {
-            case TelephonyManager.CALL_STATE_RINGING:
-                return Phone.State.RINGING;
-            case TelephonyManager.CALL_STATE_OFFHOOK:
-                return Phone.State.OFFHOOK;
-            default:
-                return Phone.State.IDLE;
-        }
-    }
-
-    /**
-     * Convert the {@link DataState} enum into the TelephonyManager.DATA_* constants
-     * for the public API.
-     */
-    public static int convertDataState(Phone.DataState state) {
-        switch (state) {
-            case CONNECTING:
-                return TelephonyManager.DATA_CONNECTING;
-            case CONNECTED:
-                return TelephonyManager.DATA_CONNECTED;
-            case SUSPENDED:
-                return TelephonyManager.DATA_SUSPENDED;
-            default:
-                return TelephonyManager.DATA_DISCONNECTED;
-        }
-    }
-
-    /**
-     * Convert the TelephonyManager.DATA_* constants into {@link DataState} enum
-     * for the public API.
-     */
-    public static Phone.DataState convertDataState(int state) {
-        switch (state) {
-            case TelephonyManager.DATA_CONNECTING:
-                return Phone.DataState.CONNECTING;
-            case TelephonyManager.DATA_CONNECTED:
-                return Phone.DataState.CONNECTED;
-            case TelephonyManager.DATA_SUSPENDED:
-                return Phone.DataState.SUSPENDED;
-            default:
-                return Phone.DataState.DISCONNECTED;
-        }
-    }
-
-    /**
-     * Convert the {@link DataState} enum into the TelephonyManager.DATA_* constants
-     * for the public API.
-     */
-    public static int convertDataActivityState(Phone.DataActivityState state) {
-        switch (state) {
-            case DATAIN:
-                return TelephonyManager.DATA_ACTIVITY_IN;
-            case DATAOUT:
-                return TelephonyManager.DATA_ACTIVITY_OUT;
-            case DATAINANDOUT:
-                return TelephonyManager.DATA_ACTIVITY_INOUT;
-            case DORMANT:
-                return TelephonyManager.DATA_ACTIVITY_DORMANT;
-            default:
-                return TelephonyManager.DATA_ACTIVITY_NONE;
-        }
-    }
-
-    /**
-     * Convert the TelephonyManager.DATA_* constants into the {@link DataState} enum
-     * for the public API.
-     */
-    public static Phone.DataActivityState convertDataActivityState(int state) {
-        switch (state) {
-            case TelephonyManager.DATA_ACTIVITY_IN:
-                return Phone.DataActivityState.DATAIN;
-            case TelephonyManager.DATA_ACTIVITY_OUT:
-                return Phone.DataActivityState.DATAOUT;
-            case TelephonyManager.DATA_ACTIVITY_INOUT:
-                return Phone.DataActivityState.DATAINANDOUT;
-            case TelephonyManager.DATA_ACTIVITY_DORMANT:
-                return Phone.DataActivityState.DORMANT;
-            default:
-                return Phone.DataActivityState.NONE;
-        }
-    }
-}
diff --git a/telephony/java/com/android/internal/telephony/sip/CallFailCause.java b/telephony/java/com/android/internal/telephony/sip/CallFailCause.java
deleted file mode 100644
index 58fb408..0000000
--- a/telephony/java/com/android/internal/telephony/sip/CallFailCause.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010 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.internal.telephony.sip;
-
-/**
- * Call fail causes from TS 24.008 .
- * These are mostly the cause codes we need to distinguish for the UI.
- * See 22.001 Annex F.4 for mapping of cause codes to local tones.
- *
- * {@hide}
- *
- */
-public interface CallFailCause {
-    static final int NORMAL_CLEARING     = 16;
-    // Busy Tone
-    static final int USER_BUSY           = 17;
-
-    // No Tone
-    static final int NUMBER_CHANGED      = 22;
-    static final int STATUS_ENQUIRY      = 30;
-    static final int NORMAL_UNSPECIFIED  = 31;
-
-    // Congestion Tone
-    static final int NO_CIRCUIT_AVAIL    = 34;
-    static final int TEMPORARY_FAILURE   = 41;
-    static final int SWITCHING_CONGESTION    = 42;
-    static final int CHANNEL_NOT_AVAIL   = 44;
-    static final int QOS_NOT_AVAIL       = 49;
-    static final int BEARER_NOT_AVAIL    = 58;
-
-    // others
-    static final int ACM_LIMIT_EXCEEDED = 68;
-    static final int CALL_BARRED        = 240;
-    static final int FDN_BLOCKED        = 241;
-    static final int ERROR_UNSPECIFIED = 0xffff;
-}
diff --git a/telephony/java/com/android/internal/telephony/sip/CallProxy.java b/telephony/java/com/android/internal/telephony/sip/CallProxy.java
deleted file mode 100644
index fad9663..0000000
--- a/telephony/java/com/android/internal/telephony/sip/CallProxy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 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.internal.telephony.sip;
-
-import com.android.internal.telephony.*;
-import java.util.List;
-
-// TODO: remove this class after integrating with CallManager
-class CallProxy extends Call {
-    private Call mTarget;
-
-    void setTarget(Call target) {
-        mTarget = target;
-    }
-
-    @Override
-    public List<Connection> getConnections() {
-        return mTarget.getConnections();
-    }
-
-    @Override
-    public Phone getPhone() {
-        return mTarget.getPhone();
-    }
-
-    @Override
-    public boolean isMultiparty() {
-        return mTarget.isMultiparty();
-    }
-
-    @Override
-    public void hangup() throws CallStateException {
-        mTarget.hangup();
-    }
-
-    @Override
-    public boolean hasConnection(Connection c) {
-        return mTarget.hasConnection(c);
-    }
-
-    @Override
-    public boolean hasConnections() {
-        return mTarget.hasConnections();
-    }
-
-    @Override
-    public State getState() {
-        return mTarget.getState();
-    }
-
-    @Override
-    public boolean isIdle() {
-        return mTarget.isIdle();
-    }
-
-    @Override
-    public Connection getEarliestConnection() {
-        return mTarget.getEarliestConnection();
-    }
-
-    @Override
-    public long getEarliestCreateTime() {
-        return mTarget.getEarliestCreateTime();
-    }
-
-    @Override
-    public long getEarliestConnectTime() {
-        return mTarget.getEarliestConnectTime();
-    }
-
-    @Override
-    public boolean isDialingOrAlerting() {
-        return mTarget.isDialingOrAlerting();
-    }
-
-    @Override
-    public boolean isRinging() {
-        return mTarget.isRinging();
-    }
-
-    @Override
-    public Connection getLatestConnection() {
-        return mTarget.getLatestConnection();
-    }
-
-    @Override
-    public boolean isGeneric() {
-        return mTarget.isGeneric();
-    }
-
-    @Override
-    public void setGeneric(boolean generic) {
-        mTarget.setGeneric(generic);
-    }
-
-    @Override
-    public void hangupIfAlive() {
-        mTarget.hangupIfAlive();
-    }
-}
diff --git a/telephony/java/com/android/internal/telephony/sip/SipCallBase.java b/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
index 7e407b2..9050a43 100644
--- a/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
@@ -19,7 +19,6 @@
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Connection;
-import com.android.internal.telephony.DriverCall;
 import com.android.internal.telephony.Phone;
 
 import android.net.sip.SipManager;
@@ -28,15 +27,10 @@
 import java.util.List;
 
 abstract class SipCallBase extends Call {
-    private static final int MAX_CONNECTIONS_PER_CALL = 5;
-
     protected List<Connection> connections = new ArrayList<Connection>();
 
     protected abstract void setState(State newState);
 
-    public void dispose() {
-    }
-
     public List<Connection> getConnections() {
         // FIXME should return Collections.unmodifiableList();
         return connections;
@@ -47,48 +41,7 @@
     }
 
     public String toString() {
-        return state.toString();
-    }
-
-    /**
-     * Called by SipConnection when it has disconnected
-     */
-    void connectionDisconnected(Connection conn) {
-        if (state != State.DISCONNECTED) {
-            /* If only disconnected connections remain, we are disconnected*/
-
-            boolean hasOnlyDisconnectedConnections = true;
-
-            for (int i = 0, s = connections.size()  ; i < s; i ++) {
-                if (connections.get(i).getState()
-                    != State.DISCONNECTED
-                ) {
-                    hasOnlyDisconnectedConnections = false;
-                    break;
-                }
-            }
-
-            if (hasOnlyDisconnectedConnections) {
-                state = State.DISCONNECTED;
-            }
-        }
-    }
-
-
-    /*package*/ void detach(Connection conn) {
-        connections.remove(conn);
-
-        if (connections.size() == 0) {
-            state = State.IDLE;
-        }
-    }
-
-    /**
-     * @return true if there's no space in this call for additional
-     * connections to be added via "conference"
-     */
-    /*package*/ boolean isFull() {
-        return connections.size() == MAX_CONNECTIONS_PER_CALL;
+        return state.toString() + ":" + super.toString();
     }
 
     void clearDisconnected() {
diff --git a/telephony/java/com/android/internal/telephony/sip/SipCommandInterface.java b/telephony/java/com/android/internal/telephony/sip/SipCommandInterface.java
index 33c89f8..ed578c8 100644
--- a/telephony/java/com/android/internal/telephony/sip/SipCommandInterface.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipCommandInterface.java
@@ -330,7 +330,6 @@
     public void setGsmBroadcastActivation(boolean activate, Message response) {
     }
 
-
     // ***** Methods for CDMA support
     public void getDeviceIdentity(Message response) {
     }
diff --git a/telephony/java/com/android/internal/telephony/sip/SipConnectionBase.java b/telephony/java/com/android/internal/telephony/sip/SipConnectionBase.java
index 6c989b4..dc4b27b 100644
--- a/telephony/java/com/android/internal/telephony/sip/SipConnectionBase.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipConnectionBase.java
@@ -16,29 +16,16 @@
 
 package com.android.internal.telephony.sip;
 
-import android.content.Context;
+import com.android.internal.telephony.Call;
+import com.android.internal.telephony.Connection;
+import com.android.internal.telephony.Phone;
+
 import android.net.sip.SipAudioCall;
-import android.os.Message;
-import android.os.Registrant;
 import android.os.SystemClock;
 import android.util.Log;
 import android.telephony.PhoneNumberUtils;
-import android.telephony.ServiceState;
-
-import com.android.internal.telephony.*;
 
 abstract class SipConnectionBase extends Connection {
-    //***** Event Constants
-    private static final int EVENT_DTMF_DONE = 1;
-    private static final int EVENT_PAUSE_DONE = 2;
-    private static final int EVENT_NEXT_POST_DIAL = 3;
-    private static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
-
-    //***** Constants
-    private static final int PAUSE_DELAY_FIRST_MILLIS = 100;
-    private static final int PAUSE_DELAY_MILLIS = 3 * 1000;
-    private static final int WAKE_LOCK_TIMEOUT_MILLIS = 60*1000;
-
     private static final String LOG_TAG = "SIP_CONN";
 
     private SipAudioCall mSipAudioCall;
@@ -47,10 +34,6 @@
     private String postDialString;      // outgoing calls only
     private int nextPostDialChar;       // index into postDialString
     private boolean isIncoming;
-    private boolean disconnected;
-
-    int index;          // index in SipCallTracker.connections[], -1 if unassigned
-                        // The Sip index is 1 + this
 
     /*
      * These time/timespan values are based on System.currentTimeMillis(),
@@ -167,55 +150,6 @@
 
     protected abstract Phone getPhone();
 
-    DisconnectCause disconnectCauseFromCode(int causeCode) {
-        /**
-         * See 22.001 Annex F.4 for mapping of cause codes
-         * to local tones
-         */
-
-        switch (causeCode) {
-            case CallFailCause.USER_BUSY:
-                return DisconnectCause.BUSY;
-
-            case CallFailCause.NO_CIRCUIT_AVAIL:
-            case CallFailCause.TEMPORARY_FAILURE:
-            case CallFailCause.SWITCHING_CONGESTION:
-            case CallFailCause.CHANNEL_NOT_AVAIL:
-            case CallFailCause.QOS_NOT_AVAIL:
-            case CallFailCause.BEARER_NOT_AVAIL:
-                return DisconnectCause.CONGESTION;
-
-            case CallFailCause.ACM_LIMIT_EXCEEDED:
-                return DisconnectCause.LIMIT_EXCEEDED;
-
-            case CallFailCause.CALL_BARRED:
-                return DisconnectCause.CALL_BARRED;
-
-            case CallFailCause.FDN_BLOCKED:
-                return DisconnectCause.FDN_BLOCKED;
-
-            case CallFailCause.ERROR_UNSPECIFIED:
-            case CallFailCause.NORMAL_CLEARING:
-            default:
-                Phone phone = getPhone();
-                int serviceState = phone.getServiceState().getState();
-                if (serviceState == ServiceState.STATE_POWER_OFF) {
-                    return DisconnectCause.POWER_OFF;
-                } else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
-                        || serviceState == ServiceState.STATE_EMERGENCY_ONLY ) {
-                    return DisconnectCause.OUT_OF_SERVICE;
-                } else if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
-                    return DisconnectCause.ERROR_UNSPECIFIED;
-                } else if (causeCode == CallFailCause.NORMAL_CLEARING) {
-                    return DisconnectCause.NORMAL;
-                } else {
-                    // If nothing else matches, report unknown call drop reason
-                    // to app, not NORMAL call end.
-                    return DisconnectCause.ERROR_UNSPECIFIED;
-                }
-        }
-    }
-
     @Override
     public String getRemainingPostDialString() {
         if (postDialState == PostDialState.CANCELLED
@@ -237,12 +171,4 @@
         // TODO: add PRESENTATION_URL
         return Connection.PRESENTATION_ALLOWED;
     }
-
-    /*
-    @Override
-    public UUSInfo getUUSInfo() {
-        // FIXME: what's this for SIP?
-        return null;
-    }
-    */
 }
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index e3c3d65..5d8fe1d 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -16,10 +16,7 @@
 
 package com.android.internal.telephony.sip;
 
-import android.content.ContentValues;
 import android.content.Context;
-import android.content.SharedPreferences;
-import android.net.Uri;
 import android.net.rtp.AudioGroup;
 import android.net.rtp.AudioStream;
 import android.net.sip.SipAudioCall;
@@ -29,43 +26,21 @@
 import android.net.sip.SipProfile;
 import android.net.sip.SipSession;
 import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Looper;
 import android.os.Message;
-import android.os.Registrant;
-import android.os.RegistrantList;
-import android.os.SystemProperties;
-import android.preference.PreferenceManager;
-import android.provider.Telephony;
-import android.telephony.CellLocation;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
-import android.telephony.SignalStrength;
 import android.text.TextUtils;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallerInfo;
 import com.android.internal.telephony.CallStateException;
-import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.Connection;
-import com.android.internal.telephony.DataConnection;
-import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccPhoneBookInterfaceManager;
-import com.android.internal.telephony.IccSmsInterfaceManager;
-import com.android.internal.telephony.MmiCode;
 import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.PhoneNotifier;
-import com.android.internal.telephony.PhoneProxy;
-import com.android.internal.telephony.PhoneSubInfo;
-import com.android.internal.telephony.TelephonyProperties;
 import com.android.internal.telephony.UUSInfo;
 
-import java.io.IOException;
 import java.text.ParseException;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -73,7 +48,7 @@
  */
 public class SipPhone extends SipPhoneBase {
     private static final String LOG_TAG = "SipPhone";
-    private static final boolean LOCAL_DEBUG = true;
+    private static final boolean DEBUG = true;
     private static final int TIMEOUT_MAKE_CALL = 15; // in seconds
     private static final int TIMEOUT_ANSWER_CALL = 8; // in seconds
     private static final int TIMEOUT_HOLD_CALL = 15; // in seconds
@@ -89,17 +64,12 @@
     SipPhone (Context context, PhoneNotifier notifier, SipProfile profile) {
         super(context, notifier);
 
-        Log.v(LOG_TAG, "  +++++++++++++++++++++ new SipPhone: " + profile.getUriString());
+        if (DEBUG) Log.d(LOG_TAG, "new SipPhone: " + profile.getUriString());
         ringingCall = new SipCall();
         foregroundCall = new SipCall();
         backgroundCall = new SipCall();
         mProfile = profile;
         mSipManager = SipManager.newInstance(context);
-
-        // FIXME: what's this for SIP?
-        //Change the system property
-        //SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
-        //        new Integer(Phone.PHONE_TYPE_GSM).toString());
     }
 
     public String getPhoneName() {
@@ -128,7 +98,7 @@
 
             try {
                 SipAudioCall sipAudioCall = (SipAudioCall) incomingCall;
-                Log.d(LOG_TAG, "+++ taking call from: "
+                if (DEBUG) Log.d(LOG_TAG, "+++ taking call from: "
                         + sipAudioCall.getPeerProfile().getUriString());
                 String localUri = sipAudioCall.getLocalProfile().getUriString();
                 if (localUri.equals(mProfile.getUriString())) {
@@ -137,7 +107,7 @@
                     if (sipAudioCall.getState()
                             != SipSession.State.INCOMING_CALL) {
                         // Peer cancelled the call!
-                        Log.d(LOG_TAG, "    call cancelled !!");
+                        if (DEBUG) Log.d(LOG_TAG, "    call cancelled !!");
                         ringingCall.reset();
                     }
                     return true;
@@ -154,13 +124,9 @@
 
     public void acceptCall() throws CallStateException {
         synchronized (SipPhone.class) {
-            // FIXME if SWITCH fails, should retry with ANSWER
-            // in case the active/holding call disappeared and this
-            // is no longer call waiting
-
             if ((ringingCall.getState() == Call.State.INCOMING) ||
                     (ringingCall.getState() == Call.State.WAITING)) {
-                Log.v(LOG_TAG, "acceptCall");
+                if (DEBUG) Log.d(LOG_TAG, "acceptCall");
                 // Always unmute when answering a new call
                 setMute(false);
                 ringingCall.acceptCall();
@@ -173,7 +139,7 @@
     public void rejectCall() throws CallStateException {
         synchronized (SipPhone.class) {
             if (ringingCall.getState().isRinging()) {
-                Log.v(LOG_TAG, "rejectCall");
+                if (DEBUG) Log.d(LOG_TAG, "rejectCall");
                 ringingCall.rejectCall();
             } else {
                 throw new CallStateException("phone not ringing");
@@ -193,10 +159,6 @@
 
     private Connection dialInternal(String dialString)
             throws CallStateException {
-        // TODO: parse SIP URL?
-        // Need to make sure dialString gets parsed properly
-        //String newDialString = PhoneNumberUtils.stripSeparators(dialString);
-        //return mCT.dial(newDialString);
         clearDisconnected();
 
         if (!canDial()) {
@@ -211,7 +173,6 @@
         }
 
         setMute(false);
-        //cm.dial(pendingMO.address, clirMode, obtainCompleteMessage());
         try {
             Connection c = foregroundCall.dial(dialString);
             return c;
@@ -222,7 +183,7 @@
     }
 
     public void switchHoldingAndActive() throws CallStateException {
-        Log.v(LOG_TAG, " ~~~~~~  switch fg and bg");
+        if (DEBUG) Log.d(LOG_TAG, " ~~~~~~  switch fg and bg");
         synchronized (SipPhone.class) {
             foregroundCall.switchWith(backgroundCall);
             if (backgroundCall.getState().isAlive()) backgroundCall.hold();
@@ -336,8 +297,9 @@
             audioGroup.setMode(enabled
                     ? AudioGroup.MODE_ECHO_SUPPRESSION
                     : AudioGroup.MODE_NORMAL);
-            Log.d(LOG_TAG, String.format("audioGroup mode change: %d --> %d",
-                    mode, audioGroup.getMode()));
+            if (DEBUG) Log.d(LOG_TAG, String.format(
+                    "audioGroup mode change: %d --> %d", mode,
+                    audioGroup.getMode()));
         }
     }
 
@@ -427,9 +389,11 @@
             CallerInfo info = new CallerInfo();
             info.name = name;
             info.phoneNumber = number;
-            Log.v(LOG_TAG, "create caller info from scratch:");
-            Log.v(LOG_TAG, "     name: " + info.name);
-            Log.v(LOG_TAG, "     numb: " + info.phoneNumber);
+            if (DEBUG) {
+                Log.d(LOG_TAG, "create caller info from scratch:");
+                Log.d(LOG_TAG, "     name: " + info.name);
+                Log.d(LOG_TAG, "     numb: " + info.phoneNumber);
+            }
             return info;
         }
 
@@ -437,10 +401,12 @@
         private CallerInfo findCallerInfo(String number) {
             CallerInfo info = CallerInfo.getCallerInfo(mContext, number);
             if ((info == null) || (info.name == null)) return null;
-            Log.v(LOG_TAG, "got caller info from contact:");
-            Log.v(LOG_TAG, "     name: " + info.name);
-            Log.v(LOG_TAG, "     numb: " + info.phoneNumber);
-            Log.v(LOG_TAG, "     pres: " + info.numberPresentation);
+            if (DEBUG) {
+                Log.d(LOG_TAG, "got caller info from contact:");
+                Log.d(LOG_TAG, "     name: " + info.name);
+                Log.d(LOG_TAG, "     numb: " + info.phoneNumber);
+                Log.d(LOG_TAG, "     pres: " + info.numberPresentation);
+            }
             return info;
         }
 
@@ -474,8 +440,8 @@
         public void hangup() throws CallStateException {
             synchronized (SipPhone.class) {
                 if (state.isAlive()) {
-                    Log.d(LOG_TAG, "hang up call: " + getState() + ": " + this
-                            + " on phone " + getPhone());
+                    if (DEBUG) Log.d(LOG_TAG, "hang up call: " + getState()
+                            + ": " + this + " on phone " + getPhone());
                     setState(State.DISCONNECTING);
                     CallStateException excp = null;
                     for (Connection c : connections) {
@@ -487,8 +453,8 @@
                     }
                     if (excp != null) throw excp;
                 } else {
-                    Log.d(LOG_TAG, "hang up dead call: " + getState() + ": "
-                            + this + " on phone " + getPhone());
+                    if (DEBUG) Log.d(LOG_TAG, "hang up dead call: " + getState()
+                            + ": " + this + " on phone " + getPhone());
                 }
             }
         }
@@ -600,7 +566,7 @@
         @Override
         protected void setState(State newState) {
             if (state != newState) {
-                Log.v(LOG_TAG, "++******++ call state changed: " + state
+                if (DEBUG) Log.v(LOG_TAG, "+***+ call state changed: " + state
                         + " --> " + newState + ": " + this + ": on phone "
                         + getPhone() + " " + connections.size());
 
@@ -627,10 +593,11 @@
             // set state to DISCONNECTED only when all conns are disconnected
             if (state != State.DISCONNECTED) {
                 boolean allConnectionsDisconnected = true;
-                Log.v(LOG_TAG, "---check if all connections are disconnected: "
+                if (DEBUG) Log.d(LOG_TAG, "---check connections: "
                         + connections.size());
                 for (Connection c : connections) {
-                    Log.v(LOG_TAG, "   state=" + c.getState() + ": " + c);
+                    if (DEBUG) Log.d(LOG_TAG, "   state=" + c.getState() + ": "
+                            + c);
                     if (c.getState() != State.DISCONNECTED) {
                         allConnectionsDisconnected = false;
                         break;
@@ -667,7 +634,7 @@
                     String sessionState = (sipAudioCall == null)
                             ? ""
                             : (sipAudioCall.getState() + ", ");
-                    Log.v(LOG_TAG, "--- connection ended: "
+                    if (DEBUG) Log.d(LOG_TAG, "--- connection ended: "
                             + mPeer.getUriString() + ": " + sessionState
                             + "cause: " + getDisconnectCause() + ", on phone "
                             + getPhone());
@@ -714,7 +681,7 @@
                         setState(newState);
                     }
                     mOwner.onConnectionStateChanged(SipConnection.this);
-                    Log.v(LOG_TAG, "++******++ connection state changed: "
+                    if (DEBUG) Log.v(LOG_TAG, "+***+ connection state changed: "
                             + mPeer.getUriString() + ": " + mState
                             + " on phone " + getPhone());
                 }
@@ -722,7 +689,7 @@
 
             @Override
             protected void onError(DisconnectCause cause) {
-                Log.w(LOG_TAG, "SIP error: " + cause);
+                if (DEBUG) Log.d(LOG_TAG, "SIP error: " + cause);
                 if (mSipAudioCall.isInCall()
                         && (cause != DisconnectCause.LOST_SIGNAL)) {
                     // Don't end the call when in a call.
@@ -827,8 +794,9 @@
         @Override
         public void hangup() throws CallStateException {
             synchronized (SipPhone.class) {
-                Log.v(LOG_TAG, "hangup conn: " + mPeer.getUriString() + ": "
-                        + mState + ": on phone " + getPhone().getPhoneName());
+                if (DEBUG) Log.d(LOG_TAG, "hangup conn: " + mPeer.getUriString()
+                        + ": " + mState + ": on phone "
+                        + getPhone().getPhoneName());
                 if (!mState.isAlive()) return;
                 try {
                     SipAudioCall sipAudioCall = mSipAudioCall;
@@ -853,8 +821,9 @@
                             "cannot put conn back to a call in non-idle state: "
                             + call.getState());
                 }
-                Log.v(LOG_TAG, "separate conn: " + mPeer.getUriString()
-                        + " from " + mOwner + " back to " + call);
+                if (DEBUG) Log.d(LOG_TAG, "separate conn: "
+                        + mPeer.getUriString() + " from " + mOwner + " back to "
+                        + call);
 
                 AudioGroup audioGroup = call.getAudioGroup(); // may be null
                 call.add(this);
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
index 9098e6f..5499966 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
@@ -16,42 +16,20 @@
 
 package com.android.internal.telephony.sip;
 
-import android.content.ContentValues;
 import android.content.Context;
-import android.content.SharedPreferences;
-import android.net.Uri;
 import android.os.AsyncResult;
 import android.os.Handler;
-import android.os.Looper;
 import android.os.Message;
 import android.os.Registrant;
 import android.os.RegistrantList;
 import android.os.SystemProperties;
-import android.preference.PreferenceManager;
-import android.provider.Telephony;
 import android.telephony.CellLocation;
-import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
-import android.text.TextUtils;
 import android.util.Log;
 
-import static com.android.internal.telephony.CommandsInterface.CF_ACTION_DISABLE;
-import static com.android.internal.telephony.CommandsInterface.CF_ACTION_ENABLE;
-import static com.android.internal.telephony.CommandsInterface.CF_ACTION_ERASURE;
-import static com.android.internal.telephony.CommandsInterface.CF_ACTION_REGISTRATION;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_ALL;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_ALL_CONDITIONAL;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_NO_REPLY;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_NOT_REACHABLE;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_BUSY;
-import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDITIONAL;
-import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE;
-import static com.android.internal.telephony.TelephonyProperties.PROPERTY_BASEBAND_VERSION;
-
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
-import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.DataConnection;
 import com.android.internal.telephony.IccCard;
@@ -62,38 +40,20 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.PhoneNotifier;
-import com.android.internal.telephony.PhoneProxy;
 import com.android.internal.telephony.PhoneSubInfo;
 import com.android.internal.telephony.TelephonyProperties;
-//import com.android.internal.telephony.UUSInfo;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 abstract class SipPhoneBase extends PhoneBase {
-    // NOTE that LOG_TAG here is "Sip", which means that log messages
-    // from this file will go into the radio log rather than the main
-    // log.  (Use "adb logcat -b radio" to see them.)
-    static final String LOG_TAG = "SipPhone";
-    private static final boolean LOCAL_DEBUG = true;
+    private static final String LOG_TAG = "SipPhone";
 
-    //SipCallTracker mCT;
-    PhoneSubInfo mSubInfo;
-
-    Registrant mPostDialHandler;
-
-    final RegistrantList mRingbackRegistrants = new RegistrantList();
-
+    private RegistrantList mRingbackRegistrants = new RegistrantList();
     private State state = State.IDLE;
 
     public SipPhoneBase(Context context, PhoneNotifier notifier) {
         super(notifier, context, new SipCommandInterface(context), false);
-
-        // FIXME: what's this for SIP?
-        //Change the system property
-        //SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
-        //        new Integer(Phone.PHONE_TYPE_GSM).toString());
     }
 
     public abstract Call getForegroundCall();
@@ -102,14 +62,6 @@
 
     public abstract Call getRingingCall();
 
-    /*
-    public Connection dial(String dialString, UUSInfo uusInfo)
-            throws CallStateException {
-        // ignore UUSInfo
-        return dial(dialString);
-    }
-    */
-
     void migrateFrom(SipPhoneBase from) {
         migrate(mRingbackRegistrants, from.mRingbackRegistrants);
         migrate(mPreciseCallStateRegistrants, from.mPreciseCallStateRegistrants);
@@ -150,15 +102,6 @@
         mRingbackRegistrants.notifyRegistrants(result);
     }
 
-    public void dispose() {
-        mIsTheCurrentActivePhone = false;
-        mSubInfo.dispose();
-    }
-
-    public void removeReferences() {
-        mSubInfo = null;
-    }
-
     public ServiceState getServiceState() {
         // FIXME: we may need to provide this when data connectivity is lost
         // or when server is down
@@ -168,7 +111,7 @@
     }
 
     public CellLocation getCellLocation() {
-        return null; //mSST.cellLoc;
+        return null;
     }
 
     public State getState() {
@@ -224,7 +167,6 @@
     }
 
     void notifyNewRingingConnection(Connection c) {
-        /* we'd love it if this was package-scoped*/
         super.notifyNewRingingConnectionP(c);
     }
 
@@ -352,53 +294,12 @@
         onComplete.sendToTarget();
     }
 
-    private boolean isValidCommandInterfaceCFReason(int commandInterfaceCFReason) {
-        switch (commandInterfaceCFReason) {
-        case CF_REASON_UNCONDITIONAL:
-        case CF_REASON_BUSY:
-        case CF_REASON_NO_REPLY:
-        case CF_REASON_NOT_REACHABLE:
-        case CF_REASON_ALL:
-        case CF_REASON_ALL_CONDITIONAL:
-            return true;
-        default:
-            return false;
-        }
-    }
-
-    private boolean isValidCommandInterfaceCFAction (int commandInterfaceCFAction) {
-        switch (commandInterfaceCFAction) {
-        case CF_ACTION_DISABLE:
-        case CF_ACTION_ENABLE:
-        case CF_ACTION_REGISTRATION:
-        case CF_ACTION_ERASURE:
-            return true;
-        default:
-            return false;
-        }
-    }
-
-    protected  boolean isCfEnable(int action) {
-        return (action == CF_ACTION_ENABLE) || (action == CF_ACTION_REGISTRATION);
-    }
-
     public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
-        if (isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
-            // FIXME: what to reply?
-            AsyncResult.forMessage(onComplete, null, null);
-            onComplete.sendToTarget();
-        }
     }
 
     public void setCallForwardingOption(int commandInterfaceCFAction,
             int commandInterfaceCFReason, String dialingNumber,
             int timerSeconds, Message onComplete) {
-        if (isValidCommandInterfaceCFAction(commandInterfaceCFAction)
-                && isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
-            // FIXME: what to reply?
-            AsyncResult.forMessage(onComplete, null, null);
-            onComplete.sendToTarget();
-        }
     }
 
     public void getOutgoingCallerIdDisplay(Message onComplete) {
@@ -415,13 +316,11 @@
     }
 
     public void getCallWaiting(Message onComplete) {
-        // FIXME: what to reply?
         AsyncResult.forMessage(onComplete, null, null);
         onComplete.sendToTarget();
     }
 
     public void setCallWaiting(boolean enable, Message onComplete) {
-        // FIXME: what to reply?
         Log.e(LOG_TAG, "call waiting not supported");
     }
 
@@ -434,29 +333,23 @@
     }
 
     public void getAvailableNetworks(Message response) {
-        // FIXME: what to reply?
     }
 
     public void setNetworkSelectionModeAutomatic(Message response) {
-        // FIXME: what to reply?
     }
 
     public void selectNetworkManually(
             com.android.internal.telephony.gsm.NetworkInfo network,
             Message response) {
-        // FIXME: what to reply?
     }
 
     public void getNeighboringCids(Message response) {
-        // FIXME: what to reply?
     }
 
     public void setOnPostDialCharacter(Handler h, int what, Object obj) {
-        mPostDialHandler = new Registrant(h, what, obj);
     }
 
     public void getDataCallList(Message response) {
-        // FIXME: what to reply?
     }
 
     public List<DataConnection> getCurrentDataConnectionList () {
@@ -496,27 +389,20 @@
     }
 
     public void saveClirSetting(int commandInterfaceCLIRMode) {
-        // FIXME: what's this for SIP?
     }
 
-    /**
-     * Retrieves the PhoneSubInfo of the SipPhone
-     */
     public PhoneSubInfo getPhoneSubInfo(){
-        return mSubInfo;
+        return null;
     }
 
-    /** {@inheritDoc} */
     public IccSmsInterfaceManager getIccSmsInterfaceManager(){
         return null;
     }
 
-    /** {@inheritDoc} */
     public IccPhoneBookInterfaceManager getIccPhoneBookInterfaceManager(){
         return null;
     }
 
-    /** {@inheritDoc} */
     public IccFileHandler getIccFileHandler(){
         return null;
     }
@@ -544,9 +430,9 @@
         } else {
             state = State.OFFHOOK;
         }
-        Log.e(LOG_TAG, "    ^^^^^^   new phone state: " + state);
 
         if (state != oldState) {
+            Log.d(LOG_TAG, " ^^^ new phone state: " + state);
             notifyPhoneStateChanged();
         }
     }