am 9b5a5a0f: am eb69ddd4: am c2e35f33: (-s ours) am 932e8e5d: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '9b5a5a0f9dac0b5d7d540e1669bbccc74c1a37d2':
diff --git a/Android.mk b/Android.mk
index 6a50514..9c43ee3 100644
--- a/Android.mk
+++ b/Android.mk
@@ -17,12 +17,9 @@
 include $(CLEAR_VARS)
 
 LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java
-LOCAL_SRC_FILES := \
-	src/java/com/android/internal/telephony/ISms.aidl \
-    src/java/com/android/internal/telephony/IIccPhoneBook.aidl \
-    src/java/com/android/internal/telephony/EventLogTags.logtags \
-
-LOCAL_SRC_FILES += $(call all-java-files-under, src/java)
+LOCAL_SRC_FILES := $(call all-java-files-under, src/java) \
+	$(call all-Iaidl-files-under, src/java) \
+	$(call all-logtags-files-under, src/java)
 
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := telephony-common
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 8b3a29d..f4475ef 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -40,6 +40,7 @@
 
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates)
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/mockril/src/com/android/internal/telephony/mockril/MockRilController.java b/mockril/src/com/android/internal/telephony/mockril/MockRilController.java
index 0e75c72..aef9fb5 100644
--- a/mockril/src/com/android/internal/telephony/mockril/MockRilController.java
+++ b/mockril/src/com/android/internal/telephony/mockril/MockRilController.java
@@ -17,7 +17,7 @@
 package com.android.internal.telephony.mockril;
 
 import android.os.Bundle;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.communication.MsgHeader;
 import com.android.internal.communication.Msg;
@@ -62,7 +62,7 @@
         try {
             Msg.send(mRilChannel, cmd, token, status, pbData);
         } catch (IOException e) {
-            Log.v(TAG, "send command : %d failed: " + e.getStackTrace());
+            Rlog.v(TAG, "send command : %d failed: " + e.getStackTrace());
             return false;
         }
         return true;
@@ -77,7 +77,7 @@
         try {
             response = Msg.recv(mRilChannel);
         } catch (IOException e) {
-            Log.v(TAG, "receive response for getRadioState() error: " + e.getStackTrace());
+            Rlog.v(TAG, "receive response for getRadioState() error: " + e.getStackTrace());
             return null;
         }
         return response;
@@ -92,7 +92,7 @@
         }
         Msg response = getCtrlResponse();
         if (response == null) {
-            Log.v(TAG, "failed to get response");
+            Rlog.v(TAG, "failed to get response");
             return -1;
         }
         response.printHeader(TAG);
@@ -113,17 +113,17 @@
     public boolean setRadioState(int state) {
         RilCtrlCmds.CtrlReqRadioState req = new RilCtrlCmds.CtrlReqRadioState();
         if (state < 0 || state > RilCmds.RADIOSTATE_NV_READY) {
-            Log.v(TAG, "the give radio state is not valid.");
+            Rlog.v(TAG, "the give radio state is not valid.");
             return false;
         }
         req.setState(state);
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_RADIO_STATE, 0, 0, req)) {
-            Log.v(TAG, "send set radio state request failed.");
+            Rlog.v(TAG, "send set radio state request failed.");
             return false;
         }
         Msg response = getCtrlResponse();
         if (response == null) {
-            Log.v(TAG, "failed to get response for setRadioState");
+            Rlog.v(TAG, "failed to get response for setRadioState");
             return false;
         }
         response.printHeader(TAG);
@@ -144,7 +144,7 @@
 
         req.setPhoneNumber(phoneNumber);
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_MT_CALL, 0, 0, req)) {
-            Log.v(TAG, "send CMD_SET_MT_CALL request failed");
+            Rlog.v(TAG, "send CMD_SET_MT_CALL request failed");
             return false;
         }
         return true;
@@ -163,7 +163,7 @@
         req.setCallFailCause(failCause);
 
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, req)) {
-            Log.v(TAG, "send CTRL_CMD_HANGUP_CONN_REMOTE request failed");
+            Rlog.v(TAG, "send CTRL_CMD_HANGUP_CONN_REMOTE request failed");
             return false;
         }
         return true;
@@ -183,7 +183,7 @@
         req.setFlag(flag);
 
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, req)) {
-            Log.v(TAG, "send CTRL_CMD_SET_CALL_TRANSITION_FLAG request failed");
+            Rlog.v(TAG, "send CTRL_CMD_SET_CALL_TRANSITION_FLAG request failed");
             return false;
         }
         return true;
@@ -196,7 +196,7 @@
      */
     public boolean setDialCallToAlert() {
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ALERT, 0, 0, null)) {
-            Log.v(TAG, "send CTRL_CMD_SET_CALL_ALERT request failed");
+            Rlog.v(TAG, "send CTRL_CMD_SET_CALL_ALERT request failed");
             return false;
         }
         return true;
@@ -209,7 +209,7 @@
     */
    public boolean setAlertCallToActive() {
         if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ACTIVE, 0, 0, null)) {
-            Log.v(TAG, "send CTRL_CMD_SET_CALL_ACTIVE request failed");
+            Rlog.v(TAG, "send CTRL_CMD_SET_CALL_ACTIVE request failed");
             return false;
         }
         return true;
diff --git a/src/java/android/provider/Telephony.java b/src/java/android/provider/Telephony.java
index e932e2b..50f3203 100644
--- a/src/java/android/provider/Telephony.java
+++ b/src/java/android/provider/Telephony.java
@@ -28,7 +28,7 @@
 import android.os.Environment;
 import android.telephony.SmsMessage;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Patterns;
 
 
@@ -1293,7 +1293,7 @@
             }
 
             Uri uri = uriBuilder.build();
-            //if (DEBUG) Log.v(TAG, "getOrCreateThreadId uri: " + uri);
+            //if (DEBUG) Rlog.v(TAG, "getOrCreateThreadId uri: " + uri);
 
             Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
                     uri, ID_PROJECTION, null, null, null);
@@ -1302,14 +1302,14 @@
                     if (cursor.moveToFirst()) {
                         return cursor.getLong(0);
                     } else {
-                        Log.e(TAG, "getOrCreateThreadId returned no rows!");
+                        Rlog.e(TAG, "getOrCreateThreadId returned no rows!");
                     }
                 } finally {
                     cursor.close();
                 }
             }
 
-            Log.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString());
+            Rlog.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString());
             throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
         }
     }
diff --git a/src/java/android/telephony/SmsCbEtwsInfo.java b/src/java/android/telephony/SmsCbEtwsInfo.java
index 0890d52..f208fbf 100644
--- a/src/java/android/telephony/SmsCbEtwsInfo.java
+++ b/src/java/android/telephony/SmsCbEtwsInfo.java
@@ -20,7 +20,7 @@
 import android.os.Parcelable;
 import android.text.format.Time;
 
-import com.android.internal.telephony.IccUtils;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.util.Arrays;
 
diff --git a/src/java/android/telephony/SmsManager.java b/src/java/android/telephony/SmsManager.java
index deffebc..e782379 100644
--- a/src/java/android/telephony/SmsManager.java
+++ b/src/java/android/telephony/SmsManager.java
@@ -22,8 +22,8 @@
 import android.text.TextUtils;
 
 import com.android.internal.telephony.ISms;
-import com.android.internal.telephony.IccConstants;
 import com.android.internal.telephony.SmsRawData;
+import com.android.internal.telephony.uicc.IccConstants;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -358,7 +358,8 @@
      * Note: This call is blocking, callers may want to avoid calling it from
      * the main thread of an application.
      *
-     * @param messageIdentifier Message identifier as specified in TS 23.041
+     * @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      * @see #disableCellBroadcast(int)
      *
@@ -387,7 +388,8 @@
      * Note: This call is blocking, callers may want to avoid calling it from
      * the main thread of an application.
      *
-     * @param messageIdentifier Message identifier as specified in TS 23.041
+     * @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #enableCellBroadcast(int)
@@ -418,8 +420,10 @@
      * Note: This call is blocking, callers may want to avoid calling it from
      * the main thread of an application.
      *
-     * @param startMessageId first message identifier as specified in TS 23.041
-     * @param endMessageId last message identifier as specified in TS 23.041
+     * @param startMessageId first message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
+     * @param endMessageId last message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      * @see #disableCellBroadcastRange(int, int)
      *
@@ -452,8 +456,10 @@
      * Note: This call is blocking, callers may want to avoid calling it from
      * the main thread of an application.
      *
-     * @param startMessageId first message identifier as specified in TS 23.041
-     * @param endMessageId last message identifier as specified in TS 23.041
+     * @param startMessageId first message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
+     * @param endMessageId last message identifier as specified in TS 23.041 (3GPP)
+     * or C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #enableCellBroadcastRange(int, int)
diff --git a/src/java/android/telephony/SmsMessage.java b/src/java/android/telephony/SmsMessage.java
index b94609e..c35f09e 100644
--- a/src/java/android/telephony/SmsMessage.java
+++ b/src/java/android/telephony/SmsMessage.java
@@ -17,7 +17,7 @@
 package android.telephony;
 
 import android.os.Parcel;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.GsmAlphabet;
 import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
@@ -158,7 +158,7 @@
         } else if (SmsConstants.FORMAT_3GPP.equals(format)) {
             wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
         } else {
-            Log.e(LOG_TAG, "createFromPdu(): unsupported message format " + format);
+            Rlog.e(LOG_TAG, "createFromPdu(): unsupported message format " + format);
             return null;
         }
 
@@ -337,7 +337,7 @@
                 nextPos = pos + Math.min(limit / 2, textLen - pos);
             }
             if ((nextPos <= pos) || (nextPos > textLen)) {
-                Log.e(LOG_TAG, "fragmentText failed (" + pos + " >= " + nextPos + " or " +
+                Rlog.e(LOG_TAG, "fragmentText failed (" + pos + " >= " + nextPos + " or " +
                           nextPos + " >= " + textLen + ")");
                 break;
             }
diff --git a/src/java/com/android/internal/telephony/ApnContext.java b/src/java/com/android/internal/telephony/ApnContext.java
index 4817a7b..b6083ad 100644
--- a/src/java/com/android/internal/telephony/ApnContext.java
+++ b/src/java/com/android/internal/telephony/ApnContext.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -237,7 +237,7 @@
     }
 
     protected void log(String s) {
-        Log.d(LOG_TAG, "[ApnContext:" + mApnType + "] " + s);
+        Rlog.d(LOG_TAG, "[ApnContext:" + mApnType + "] " + s);
     }
 
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
diff --git a/src/java/com/android/internal/telephony/BaseCommands.java b/src/java/com/android/internal/telephony/BaseCommands.java
index 1b54656..49d3c76 100644
--- a/src/java/com/android/internal/telephony/BaseCommands.java
+++ b/src/java/com/android/internal/telephony/BaseCommands.java
@@ -24,7 +24,7 @@
 import android.os.AsyncResult;
 import android.os.SystemProperties;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -555,11 +555,11 @@
      */
     @Override
     public void registerForRilConnected(Handler h, int what, Object obj) {
-        Log.d(LOG_TAG, "registerForRilConnected h=" + h + " w=" + what);
+        Rlog.d(LOG_TAG, "registerForRilConnected h=" + h + " w=" + what);
         Registrant r = new Registrant (h, what, obj);
         mRilConnectedRegistrants.add(r);
         if (mRilVersion != -1) {
-            Log.d(LOG_TAG, "Notifying: ril connected mRilVersion=" + mRilVersion);
+            Rlog.d(LOG_TAG, "Notifying: ril connected mRilVersion=" + mRilVersion);
             r.notifyRegistrant(new AsyncResult(null, new Integer(mRilVersion), null));
         }
     }
@@ -592,7 +592,7 @@
 
         synchronized (mStateMonitor) {
             if (false) {
-                Log.v(LOG_TAG, "setRadioState old: " + mState
+                Rlog.v(LOG_TAG, "setRadioState old: " + mState
                     + " new " + newState);
             }
 
@@ -607,25 +607,25 @@
             mRadioStateChangedRegistrants.notifyRegistrants();
 
             if (mState.isAvailable() && !oldState.isAvailable()) {
-                Log.d(LOG_TAG,"Notifying: radio available");
+                Rlog.d(LOG_TAG,"Notifying: radio available");
                 mAvailRegistrants.notifyRegistrants();
                 onRadioAvailable();
             }
 
             if (!mState.isAvailable() && oldState.isAvailable()) {
-                Log.d(LOG_TAG,"Notifying: radio not available");
+                Rlog.d(LOG_TAG,"Notifying: radio not available");
                 mNotAvailRegistrants.notifyRegistrants();
             }
 
             if (mState.isOn() && !oldState.isOn()) {
-                Log.d(LOG_TAG,"Notifying: Radio On");
+                Rlog.d(LOG_TAG,"Notifying: Radio On");
                 mOnRegistrants.notifyRegistrants();
             }
 
             if ((!mState.isOn() || !mState.isAvailable())
                 && !((!oldState.isOn() || !oldState.isAvailable()))
             ) {
-                Log.d(LOG_TAG,"Notifying: radio off or not available");
+                Rlog.d(LOG_TAG,"Notifying: radio off or not available");
                 mOffOrNotAvailRegistrants.notifyRegistrants();
             }
         }
diff --git a/src/java/com/android/internal/telephony/Call.java b/src/java/com/android/internal/telephony/Call.java
index 4967ab8..2127258 100644
--- a/src/java/com/android/internal/telephony/Call.java
+++ b/src/java/com/android/internal/telephony/Call.java
@@ -18,7 +18,7 @@
 
 import java.util.List;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * {@hide}
@@ -248,7 +248,7 @@
             try {
                 hangup();
             } catch (CallStateException ex) {
-                Log.w(LOG_TAG, " hangupIfActive: caught " + ex);
+                Rlog.w(LOG_TAG, " hangupIfActive: caught " + ex);
             }
         }
     }
diff --git a/src/java/com/android/internal/telephony/CallManager.java b/src/java/com/android/internal/telephony/CallManager.java
index 34ad810..1c1799f 100644
--- a/src/java/com/android/internal/telephony/CallManager.java
+++ b/src/java/com/android/internal/telephony/CallManager.java
@@ -27,7 +27,7 @@
 import android.os.Registrant;
 import android.telephony.PhoneStateListener;
 import android.telephony.ServiceState;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -295,7 +295,7 @@
         if (basePhone != null && !mPhones.contains(basePhone)) {
 
             if (DBG) {
-                Log.d(LOG_TAG, "registerPhone(" +
+                Rlog.d(LOG_TAG, "registerPhone(" +
                         phone.getPhoneName() + " " + phone + ")");
             }
 
@@ -322,7 +322,7 @@
         if (basePhone != null && mPhones.contains(basePhone)) {
 
             if (DBG) {
-                Log.d(LOG_TAG, "unregisterPhone(" +
+                Rlog.d(LOG_TAG, "unregisterPhone(" +
                         phone.getPhoneName() + " " + phone + ")");
             }
 
@@ -383,7 +383,7 @@
                 if (curAudioMode != AudioManager.MODE_RINGTONE) {
                     // only request audio focus if the ringtone is going to be heard
                     if (audioManager.getStreamVolume(AudioManager.STREAM_RING) > 0) {
-                        if (VDBG) Log.d(LOG_TAG, "requestAudioFocus on STREAM_RING");
+                        if (VDBG) Rlog.d(LOG_TAG, "requestAudioFocus on STREAM_RING");
                         audioManager.requestAudioFocusForCall(AudioManager.STREAM_RING,
                                 AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
                     }
@@ -411,7 +411,7 @@
                 }
                 if (audioManager.getMode() != newAudioMode || mSpeedUpAudioForMtCall) {
                     // request audio focus before setting the new mode
-                    if (VDBG) Log.d(LOG_TAG, "requestAudioFocus on STREAM_VOICE_CALL");
+                    if (VDBG) Rlog.d(LOG_TAG, "requestAudioFocus on STREAM_VOICE_CALL");
                     audioManager.requestAudioFocusForCall(AudioManager.STREAM_VOICE_CALL,
                             AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
                     audioManager.setMode(newAudioMode);
@@ -421,7 +421,7 @@
             case IDLE:
                 if (audioManager.getMode() != AudioManager.MODE_NORMAL) {
                     audioManager.setMode(AudioManager.MODE_NORMAL);
-                    if (VDBG) Log.d(LOG_TAG, "abandonAudioFocus");
+                    if (VDBG) Rlog.d(LOG_TAG, "abandonAudioFocus");
                     // abandon audio focus after the mode has been set back to normal
                     audioManager.abandonAudioFocusForCall();
                 }
@@ -518,8 +518,8 @@
         Phone ringingPhone = ringingCall.getPhone();
 
         if (VDBG) {
-            Log.d(LOG_TAG, "acceptCall(" +ringingCall + " from " + ringingCall.getPhone() + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "acceptCall(" +ringingCall + " from " + ringingCall.getPhone() + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if ( hasActiveFgCall() ) {
@@ -528,7 +528,7 @@
             boolean sameChannel = (activePhone == ringingPhone);
 
             if (VDBG) {
-                Log.d(LOG_TAG, "hasBgCall: "+ hasBgCall + "sameChannel:" + sameChannel);
+                Rlog.d(LOG_TAG, "hasBgCall: "+ hasBgCall + "sameChannel:" + sameChannel);
             }
 
             if (sameChannel && hasBgCall) {
@@ -542,15 +542,15 @@
 
         Context context = getContext();
         if (context == null) {
-            Log.d(LOG_TAG, "Speedup Audio Path enhancement: Context is null");
+            Rlog.d(LOG_TAG, "Speedup Audio Path enhancement: Context is null");
         } else if (context.getResources().getBoolean(
                 com.android.internal.R.bool.config_speed_up_audio_on_mt_calls)) {
-            Log.d(LOG_TAG, "Speedup Audio Path enhancement");
+            Rlog.d(LOG_TAG, "Speedup Audio Path enhancement");
             AudioManager audioManager = (AudioManager)
                     context.getSystemService(Context.AUDIO_SERVICE);
             int currMode = audioManager.getMode();
             if ((currMode != AudioManager.MODE_IN_CALL) && !(ringingPhone instanceof SipPhone)) {
-                Log.d(LOG_TAG, "setAudioMode Setting audio mode from " +
+                Rlog.d(LOG_TAG, "setAudioMode Setting audio mode from " +
                                 currMode + " to " + AudioManager.MODE_IN_CALL);
                 audioManager.setMode(AudioManager.MODE_IN_CALL);
                 mSpeedUpAudioForMtCall = true;
@@ -560,8 +560,8 @@
         ringingPhone.acceptCall();
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End acceptCall(" +ringingCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End acceptCall(" +ringingCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -576,8 +576,8 @@
      */
     public void rejectCall(Call ringingCall) throws CallStateException {
         if (VDBG) {
-            Log.d(LOG_TAG, "rejectCall(" +ringingCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "rejectCall(" +ringingCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         Phone ringingPhone = ringingCall.getPhone();
@@ -585,8 +585,8 @@
         ringingPhone.rejectCall();
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End rejectCall(" +ringingCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End rejectCall(" +ringingCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -613,8 +613,8 @@
         Phone heldPhone = null;
 
         if (VDBG) {
-            Log.d(LOG_TAG, "switchHoldingAndActive(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "switchHoldingAndActive(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -634,8 +634,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End switchHoldingAndActive(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End switchHoldingAndActive(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -652,8 +652,8 @@
         Phone backgroundPhone = null;
 
         if (VDBG) {
-            Log.d(LOG_TAG, "hangupForegroundResumeBackground(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "hangupForegroundResumeBackground(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -671,8 +671,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End hangupForegroundResumeBackground(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End hangupForegroundResumeBackground(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -708,8 +708,8 @@
     public void conference(Call heldCall) throws CallStateException {
 
         if (VDBG) {
-            Log.d(LOG_TAG, "conference(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "conference(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
 
@@ -723,8 +723,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End conference(" +heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End conference(" +heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
     }
@@ -744,8 +744,8 @@
         Connection result;
 
         if (VDBG) {
-            Log.d(LOG_TAG, " dial(" + basePhone + ", "+ dialString + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " dial(" + basePhone + ", "+ dialString + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (!canDial(phone)) {
@@ -757,15 +757,15 @@
             boolean hasBgCall = !(activePhone.getBackgroundCall().isIdle());
 
             if (DBG) {
-                Log.d(LOG_TAG, "hasBgCall: "+ hasBgCall + " sameChannel:" + (activePhone == basePhone));
+                Rlog.d(LOG_TAG, "hasBgCall: "+ hasBgCall + " sameChannel:" + (activePhone == basePhone));
             }
 
             if (activePhone != basePhone) {
                 if (hasBgCall) {
-                    Log.d(LOG_TAG, "Hangup");
+                    Rlog.d(LOG_TAG, "Hangup");
                     getActiveFgCall().hangup();
                 } else {
-                    Log.d(LOG_TAG, "Switch");
+                    Rlog.d(LOG_TAG, "Switch");
                     activePhone.switchHoldingAndActive();
                 }
             }
@@ -774,8 +774,8 @@
         result = basePhone.dial(dialString);
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End dial(" + basePhone + ", "+ dialString + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End dial(" + basePhone + ", "+ dialString + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         return result;
@@ -830,7 +830,7 @@
                     || (fgCallState == Call.State.DISCONNECTED)));
 
         if (result == false) {
-            Log.d(LOG_TAG, "canDial serviceState=" + serviceState
+            Rlog.d(LOG_TAG, "canDial serviceState=" + serviceState
                             + " hasRingingCall=" + hasRingingCall
                             + " hasActiveCall=" + hasActiveCall
                             + " hasHoldingCall=" + hasHoldingCall
@@ -874,8 +874,8 @@
      */
     public void explicitCallTransfer(Call heldCall) throws CallStateException {
         if (VDBG) {
-            Log.d(LOG_TAG, " explicitCallTransfer(" + heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " explicitCallTransfer(" + heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (canTransfer(heldCall)) {
@@ -883,8 +883,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End explicitCallTransfer(" + heldCall + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End explicitCallTransfer(" + heldCall + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
     }
@@ -899,7 +899,7 @@
      * @return null if phone doesn't have or support mmi code
      */
     public List<? extends MmiCode> getPendingMmiCodes(Phone phone) {
-        Log.e(LOG_TAG, "getPendingMmiCodes not implemented");
+        Rlog.e(LOG_TAG, "getPendingMmiCodes not implemented");
         return null;
     }
 
@@ -912,7 +912,7 @@
      * @return false if phone doesn't support ussd service
      */
     public boolean sendUssdResponse(Phone phone, String ussdMessge) {
-        Log.e(LOG_TAG, "sendUssdResponse not implemented");
+        Rlog.e(LOG_TAG, "sendUssdResponse not implemented");
         return false;
     }
 
@@ -927,8 +927,8 @@
 
     public void setMute(boolean muted) {
         if (VDBG) {
-            Log.d(LOG_TAG, " setMute(" + muted + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " setMute(" + muted + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -936,8 +936,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End setMute(" + muted + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End setMute(" + muted + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -964,8 +964,8 @@
      */
     public void setEchoSuppressionEnabled(boolean enabled) {
         if (VDBG) {
-            Log.d(LOG_TAG, " setEchoSuppression(" + enabled + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " setEchoSuppression(" + enabled + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -973,8 +973,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End setEchoSuppression(" + enabled + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End setEchoSuppression(" + enabled + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -990,8 +990,8 @@
         boolean result = false;
 
         if (VDBG) {
-            Log.d(LOG_TAG, " sendDtmf(" + c + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " sendDtmf(" + c + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -1000,8 +1000,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End sendDtmf(" + c + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End sendDtmf(" + c + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
         return result;
     }
@@ -1019,8 +1019,8 @@
         boolean result = false;
 
         if (VDBG) {
-            Log.d(LOG_TAG, " startDtmf(" + c + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " startDtmf(" + c + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) {
@@ -1029,8 +1029,8 @@
         }
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End startDtmf(" + c + ")");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End startDtmf(" + c + ")");
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         return result;
@@ -1042,15 +1042,15 @@
      */
     public void stopDtmf() {
         if (VDBG) {
-            Log.d(LOG_TAG, " stopDtmf()" );
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, " stopDtmf()" );
+            Rlog.d(LOG_TAG, this.toString());
         }
 
         if (hasActiveFgCall()) getFgPhone().stopDtmf();
 
         if (VDBG) {
-            Log.d(LOG_TAG, "End stopDtmf()");
-            Log.d(LOG_TAG, this.toString());
+            Rlog.d(LOG_TAG, "End stopDtmf()");
+            Rlog.d(LOG_TAG, this.toString());
         }
     }
 
@@ -1742,98 +1742,98 @@
 
             switch (msg.what) {
                 case EVENT_DISCONNECT:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_DISCONNECT)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_DISCONNECT)");
                     mDisconnectRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_PRECISE_CALL_STATE_CHANGED:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_PRECISE_CALL_STATE_CHANGED)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_PRECISE_CALL_STATE_CHANGED)");
                     mPreciseCallStateRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_NEW_RINGING_CONNECTION:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_NEW_RINGING_CONNECTION)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_NEW_RINGING_CONNECTION)");
                     if (getActiveFgCallState().isDialing() || hasMoreThanOneRingingCall()) {
                         Connection c = (Connection) ((AsyncResult) msg.obj).result;
                         try {
-                            Log.d(LOG_TAG, "silently drop incoming call: " + c.getCall());
+                            Rlog.d(LOG_TAG, "silently drop incoming call: " + c.getCall());
                             c.getCall().hangup();
                         } catch (CallStateException e) {
-                            Log.w(LOG_TAG, "new ringing connection", e);
+                            Rlog.w(LOG_TAG, "new ringing connection", e);
                         }
                     } else {
                         mNewRingingConnectionRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     }
                     break;
                 case EVENT_UNKNOWN_CONNECTION:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_UNKNOWN_CONNECTION)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_UNKNOWN_CONNECTION)");
                     mUnknownConnectionRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_INCOMING_RING:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_INCOMING_RING)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_INCOMING_RING)");
                     // The event may come from RIL who's not aware of an ongoing fg call
                     if (!hasActiveFgCall()) {
                         mIncomingRingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     }
                     break;
                 case EVENT_RINGBACK_TONE:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_RINGBACK_TONE)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_RINGBACK_TONE)");
                     mRingbackToneRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_IN_CALL_VOICE_PRIVACY_ON:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_IN_CALL_VOICE_PRIVACY_ON)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_IN_CALL_VOICE_PRIVACY_ON)");
                     mInCallVoicePrivacyOnRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_IN_CALL_VOICE_PRIVACY_OFF:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_IN_CALL_VOICE_PRIVACY_OFF)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_IN_CALL_VOICE_PRIVACY_OFF)");
                     mInCallVoicePrivacyOffRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_CALL_WAITING:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_CALL_WAITING)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_CALL_WAITING)");
                     mCallWaitingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_DISPLAY_INFO:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_DISPLAY_INFO)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_DISPLAY_INFO)");
                     mDisplayInfoRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_SIGNAL_INFO:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_SIGNAL_INFO)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SIGNAL_INFO)");
                     mSignalInfoRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_CDMA_OTA_STATUS_CHANGE:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_CDMA_OTA_STATUS_CHANGE)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_CDMA_OTA_STATUS_CHANGE)");
                     mCdmaOtaStatusChangeRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_RESEND_INCALL_MUTE:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_RESEND_INCALL_MUTE)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_RESEND_INCALL_MUTE)");
                     mResendIncallMuteRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_MMI_INITIATE:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_MMI_INITIATE)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_MMI_INITIATE)");
                     mMmiInitiateRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_MMI_COMPLETE:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_MMI_COMPLETE)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_MMI_COMPLETE)");
                     mMmiCompleteRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_ECM_TIMER_RESET:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_ECM_TIMER_RESET)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_ECM_TIMER_RESET)");
                     mEcmTimerResetRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_SUBSCRIPTION_INFO_READY:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_SUBSCRIPTION_INFO_READY)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SUBSCRIPTION_INFO_READY)");
                     mSubscriptionInfoReadyRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_SUPP_SERVICE_FAILED:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_SUPP_SERVICE_FAILED)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SUPP_SERVICE_FAILED)");
                     mSuppServiceFailedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_SERVICE_STATE_CHANGED:
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_SERVICE_STATE_CHANGED)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SERVICE_STATE_CHANGED)");
                     mServiceStateChangedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                     break;
                 case EVENT_POST_DIAL_CHARACTER:
                     // we need send the character that is being processed in msg.arg1
                     // so can't use notifyRegistrants()
-                    if (VDBG) Log.d(LOG_TAG, " handleMessage (EVENT_POST_DIAL_CHARACTER)");
+                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_POST_DIAL_CHARACTER)");
                     for(int i=0; i < mPostDialCharacterRegistrants.size(); i++) {
                         Message notifyMsg;
                         notifyMsg = ((Registrant)mPostDialCharacterRegistrants.get(i)).messageForRegistrant();
diff --git a/src/java/com/android/internal/telephony/CallTracker.java b/src/java/com/android/internal/telephony/CallTracker.java
index 62caf01..efe53c9 100644
--- a/src/java/com/android/internal/telephony/CallTracker.java
+++ b/src/java/com/android/internal/telephony/CallTracker.java
@@ -21,7 +21,7 @@
 import android.os.Message;
 import android.os.SystemProperties;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandException;
 
diff --git a/src/java/com/android/internal/telephony/CommandException.java b/src/java/com/android/internal/telephony/CommandException.java
index 94c544e..d1085f6 100644
--- a/src/java/com/android/internal/telephony/CommandException.java
+++ b/src/java/com/android/internal/telephony/CommandException.java
@@ -18,7 +18,7 @@
 
 import com.android.internal.telephony.RILConstants;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * {@hide}
@@ -84,7 +84,7 @@
             case RILConstants.ILLEGAL_SIM_OR_ME:
                 return new CommandException(Error.ILLEGAL_SIM_OR_ME);
             default:
-                Log.e("GSM", "Unrecognized RIL errno " + ril_errno);
+                Rlog.e("GSM", "Unrecognized RIL errno " + ril_errno);
                 return new CommandException(Error.INVALID_RESPONSE);
         }
     }
diff --git a/src/java/com/android/internal/telephony/CommandsInterface.java b/src/java/com/android/internal/telephony/CommandsInterface.java
index f7757b3..fc116ef 100644
--- a/src/java/com/android/internal/telephony/CommandsInterface.java
+++ b/src/java/com/android/internal/telephony/CommandsInterface.java
@@ -16,11 +16,13 @@
 
 package com.android.internal.telephony;
 
+import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
+import com.android.internal.telephony.uicc.IccCardStatus;
 
 import android.os.Message;
 import android.os.Handler;
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * {@hide}
@@ -1522,11 +1524,10 @@
     /**
      * Configure cdma cell broadcast SMS.
      *
-     * @param result
+     * @param response
      *            Callback message is empty on completion
      */
-    // TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message result);
+    public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response);
 
     /**
      * Query the current configuration of cdma cell broadcast SMS.
diff --git a/src/java/com/android/internal/telephony/Connection.java b/src/java/com/android/internal/telephony/Connection.java
index 554d974..8e10af5 100644
--- a/src/java/com/android/internal/telephony/Connection.java
+++ b/src/java/com/android/internal/telephony/Connection.java
@@ -16,6 +16,7 @@
 
 package com.android.internal.telephony;
 
+import android.telephony.Rlog;
 import android.util.Log;
 
 /**
@@ -293,7 +294,7 @@
     public String toString() {
         StringBuilder str = new StringBuilder(128);
 
-        if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
+        if (Rlog.isLoggable(LOG_TAG, Log.DEBUG)) {
             str.append("addr: " + getAddress())
                     .append(" pres.: " + getNumberPresentation())
                     .append(" dial: " + getOrigDialString())
diff --git a/src/java/com/android/internal/telephony/DataCallState.java b/src/java/com/android/internal/telephony/DataCallState.java
index efbf608..c3a3b1d 100644
--- a/src/java/com/android/internal/telephony/DataCallState.java
+++ b/src/java/com/android/internal/telephony/DataCallState.java
@@ -22,7 +22,7 @@
 import android.net.NetworkUtils;
 import android.net.RouteInfo;
 import android.os.SystemProperties;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.DataConnection.FailCause;
 
@@ -149,7 +149,7 @@
                                 // Assume point to point
                                 addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128;
                             }
-                            if (DBG) Log.d(LOG_TAG, "addr/pl=" + addr + "/" + addrPrefixLen);
+                            if (DBG) Rlog.d(LOG_TAG, "addr/pl=" + addr + "/" + addrPrefixLen);
                             la = new LinkAddress(ia, addrPrefixLen);
                             linkProperties.addLinkAddress(la);
                         }
@@ -219,7 +219,7 @@
 
                 result = SetupResult.SUCCESS;
             } catch (UnknownHostException e) {
-                Log.d(LOG_TAG, "setLinkProperties: UnknownHostException " + e);
+                Rlog.d(LOG_TAG, "setLinkProperties: UnknownHostException " + e);
                 e.printStackTrace();
                 result = SetupResult.ERR_UnacceptableParameter;
             }
@@ -234,7 +234,7 @@
         // An error occurred so clear properties
         if (result != SetupResult.SUCCESS) {
             if(DBG) {
-                Log.d(LOG_TAG, "setLinkProperties: error clearing LinkProperties " +
+                Rlog.d(LOG_TAG, "setLinkProperties: error clearing LinkProperties " +
                         "status=" + status + " result=" + result);
             }
             linkProperties.clear();
diff --git a/src/java/com/android/internal/telephony/DataConnection.java b/src/java/com/android/internal/telephony/DataConnection.java
index 9751040..43b89d0 100644
--- a/src/java/com/android/internal/telephony/DataConnection.java
+++ b/src/java/com/android/internal/telephony/DataConnection.java
@@ -163,9 +163,11 @@
         public boolean isPermanentFail() {
             return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) ||
                    (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) ||
-                   (this == SERVICE_OPTION_NOT_SUPPORTED) ||
+                   (this == ACTIVATION_REJECT_GGSN) || (this == SERVICE_OPTION_NOT_SUPPORTED) ||
                    (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) ||
-                   (this == PROTOCOL_ERRORS);
+                   (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
+                   (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) ||
+                   (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE);
         }
 
         public boolean isEventLoggable() {
@@ -175,7 +177,9 @@
                     (this == SERVICE_OPTION_NOT_SUBSCRIBED) ||
                     (this == SERVICE_OPTION_NOT_SUPPORTED) ||
                     (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) ||
-                    (this == PROTOCOL_ERRORS) ||
+                    (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
+                    (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) ||
+                    (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) ||
                     (this == UNACCEPTABLE_NETWORK_PARAMETER);
         }
 
diff --git a/src/java/com/android/internal/telephony/DataConnectionAc.java b/src/java/com/android/internal/telephony/DataConnectionAc.java
index a24414f..2cd64e1 100644
--- a/src/java/com/android/internal/telephony/DataConnectionAc.java
+++ b/src/java/com/android/internal/telephony/DataConnectionAc.java
@@ -586,6 +586,6 @@
     }
 
     private void log(String s) {
-        android.util.Log.d(mLogTag, "DataConnectionAc " + s);
+        android.telephony.Rlog.d(mLogTag, "DataConnectionAc " + s);
     }
 }
diff --git a/src/java/com/android/internal/telephony/DataConnectionTracker.java b/src/java/com/android/internal/telephony/DataConnectionTracker.java
index a2980be..ec83723 100644
--- a/src/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/src/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -44,11 +44,12 @@
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.R;
 import com.android.internal.telephony.DataConnection.FailCause;
 import com.android.internal.telephony.DctConstants;
+import com.android.internal.telephony.uicc.IccRecords;
 import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.util.AsyncChannel;
 
@@ -706,7 +707,7 @@
                 break;
 
             default:
-                Log.e("DATA", "Unidentified event msg=" + msg);
+                Rlog.e("DATA", "Unidentified event msg=" + msg);
                 break;
         }
     }
@@ -1294,6 +1295,7 @@
                 throw new RuntimeException("doRecovery: Invalid recoveryAction=" +
                     recoveryAction);
             }
+            mSentSinceLastRecv = 0;
         }
     }
 
@@ -1373,32 +1375,34 @@
         int nextAction = getRecoveryAction();
         int delayInMs;
 
-        // If screen is on or data stall is currently suspected, set the alarm
-        // with an aggresive timeout.
-        if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
-            delayInMs = Settings.Global.getInt(mResolver,
-                                       Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
-                                       DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
-        } else {
-            delayInMs = Settings.Global.getInt(mResolver,
-                                       Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS,
-                                       DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
-        }
+        if (getOverallState() == DctConstants.State.CONNECTED) {
+            // If screen is on or data stall is currently suspected, set the alarm
+            // with an aggresive timeout.
+            if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
+                delayInMs = Settings.Global.getInt(mResolver,
+                        Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
+                        DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
+            } else {
+                delayInMs = Settings.Global.getInt(mResolver,
+                        Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS,
+                        DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
+            }
 
-        mDataStallAlarmTag += 1;
-        if (VDBG) {
-            log("startDataStallAlarm: tag=" + mDataStallAlarmTag +
-                    " delay=" + (delayInMs / 1000) + "s");
-        }
-        AlarmManager am =
-            (AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
+            mDataStallAlarmTag += 1;
+            if (VDBG) {
+                log("startDataStallAlarm: tag=" + mDataStallAlarmTag +
+                        " delay=" + (delayInMs / 1000) + "s");
+            }
+            AlarmManager am =
+                    (AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
 
-        Intent intent = new Intent(getActionIntentDataStallAlarm());
-        intent.putExtra(DATA_STALL_ALARM_TAG_EXTRA, mDataStallAlarmTag);
-        mDataStallAlarmIntent = PendingIntent.getBroadcast(mPhone.getContext(), 0, intent,
-                PendingIntent.FLAG_UPDATE_CURRENT);
-        am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
-                SystemClock.elapsedRealtime() + delayInMs, mDataStallAlarmIntent);
+            Intent intent = new Intent(getActionIntentDataStallAlarm());
+            intent.putExtra(DATA_STALL_ALARM_TAG_EXTRA, mDataStallAlarmTag);
+            mDataStallAlarmIntent = PendingIntent.getBroadcast(mPhone.getContext(), 0, intent,
+                    PendingIntent.FLAG_UPDATE_CURRENT);
+            am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+                    SystemClock.elapsedRealtime() + delayInMs, mDataStallAlarmIntent);
+        }
     }
 
     protected void stopDataStallAlarm() {
diff --git a/src/java/com/android/internal/telephony/DebugService.java b/src/java/com/android/internal/telephony/DebugService.java
index 29fea6e..deba3eb 100644
--- a/src/java/com/android/internal/telephony/DebugService.java
+++ b/src/java/com/android/internal/telephony/DebugService.java
@@ -16,7 +16,10 @@
 
 package com.android.internal.telephony;
 
-import android.util.Log;
+import android.telephony.Rlog;
+
+import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardProxy;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -99,10 +102,24 @@
         }
         pw.flush();
         pw.println("++++++++++++++++++++++++++++++++");
+        try {
+            UiccController.getInstance().dump(fd, pw, args);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        pw.flush();
+        pw.println("++++++++++++++++++++++++++++++++");
+        try {
+            ((IccCardProxy)phoneProxy.getIccCard()).dump(fd, pw, args);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        pw.flush();
+        pw.println("++++++++++++++++++++++++++++++++");
         log("dump: -");
     }
 
     private static void log(String s) {
-        Log.d(TAG, "DebugService " + s);
+        Rlog.d(TAG, "DebugService " + s);
     }
 }
diff --git a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
index 157fee6..8f4ae84 100644
--- a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
+++ b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
@@ -24,7 +24,7 @@
 import android.telephony.CellInfo;
 import android.telephony.ServiceState;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.ITelephonyRegistry;
 
@@ -176,7 +176,7 @@
     }
 
     private void log(String s) {
-        Log.d(LOG_TAG, "[PhoneNotifier] " + s);
+        Rlog.d(LOG_TAG, "[PhoneNotifier] " + s);
     }
 
     /**
diff --git a/src/java/com/android/internal/telephony/DriverCall.java b/src/java/com/android/internal/telephony/DriverCall.java
index b1e63ae..c76be5f 100644
--- a/src/java/com/android/internal/telephony/DriverCall.java
+++ b/src/java/com/android/internal/telephony/DriverCall.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony;
 //import com.android.internal.telephony.*;
-import android.util.Log;
+import android.telephony.Rlog;
 import java.lang.Comparable;
 import android.telephony.PhoneNumberUtils;
 
@@ -90,7 +90,7 @@
 
             }
         } catch (ATParseEx ex) {
-            Log.e(LOG_TAG,"Invalid CLCC line: '" + line + "'");
+            Rlog.e(LOG_TAG,"Invalid CLCC line: '" + line + "'");
             return null;
         }
 
diff --git a/src/java/com/android/internal/telephony/IIccPhoneBook.aidl b/src/java/com/android/internal/telephony/IIccPhoneBook.aidl
index f700dfe..95b3efb 100644
--- a/src/java/com/android/internal/telephony/IIccPhoneBook.aidl
+++ b/src/java/com/android/internal/telephony/IIccPhoneBook.aidl
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony;
 
-import com.android.internal.telephony.AdnRecord;
+import com.android.internal.telephony.uicc.AdnRecord;
 
 
 
diff --git a/src/java/com/android/internal/telephony/ISms.aidl b/src/java/com/android/internal/telephony/ISms.aidl
index 1fd9f70..6917b1b 100644
--- a/src/java/com/android/internal/telephony/ISms.aidl
+++ b/src/java/com/android/internal/telephony/ISms.aidl
@@ -150,7 +150,8 @@
      * message identifier, they must both disable it for the device to stop
      * receiving those messages.
      *
-     * @param messageIdentifier Message identifier as specified in TS 23.041
+     * @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #disableCellBroadcast(int)
@@ -163,21 +164,24 @@
      * message identifier, they must both disable it for the device to stop
      * receiving those messages.
      *
-     * @param messageIdentifier Message identifier as specified in TS 23.041
+     * @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #enableCellBroadcast(int)
      */
     boolean disableCellBroadcast(int messageIdentifier);
 
-    /**
+    /*
      * Enable reception of cell broadcast (SMS-CB) messages with the given
      * message identifier range. Note that if two different clients enable
      * a message identifier range, they must both disable it for the device
      * to stop receiving those messages.
      *
-     * @param startMessageId first message identifier as specified in TS 23.041
-     * @param endMessageId last message identifier as specified in TS 23.041
+     * @param startMessageId first message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
+     * @param endMessageId last message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #disableCellBroadcastRange(int, int)
@@ -190,8 +194,10 @@
      * a message identifier range, they must both disable it for the device
      * to stop receiving those messages.
      *
-     * @param startMessageId first message identifier as specified in TS 23.041
-     * @param endMessageId last message identifier as specified in TS 23.041
+     * @param startMessageId first message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
+     * @param endMessageId last message identifier as specified in TS 23.041 (3GPP) or
+     *   C.R1001-G (3GPP2)
      * @return true if successful, false otherwise
      *
      * @see #enableCellBroadcastRange(int, int)
diff --git a/src/java/com/android/internal/telephony/IccCard.java b/src/java/com/android/internal/telephony/IccCard.java
index f1ac581..1ec4f18 100644
--- a/src/java/com/android/internal/telephony/IccCard.java
+++ b/src/java/com/android/internal/telephony/IccCard.java
@@ -20,6 +20,9 @@
 import android.os.Message;
 
 import com.android.internal.telephony.IccCardConstants.State;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccRecords;
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java b/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
index 9f561da..2bab4bb 100644
--- a/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
@@ -23,7 +23,12 @@
 import android.os.Message;
 import android.os.ServiceManager;
 
-import com.android.internal.telephony.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.AdnRecord;
+import com.android.internal.telephony.uicc.AdnRecordCache;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.IccConstants;
+import com.android.internal.telephony.uicc.IccRecords;
 
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
diff --git a/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManagerProxy.java b/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManagerProxy.java
index 1c0fc52..6810fb0 100644
--- a/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManagerProxy.java
+++ b/src/java/com/android/internal/telephony/IccPhoneBookInterfaceManagerProxy.java
@@ -23,7 +23,10 @@
 import android.os.Message;
 import android.os.ServiceManager;
 import android.telephony.PhoneNumberUtils;
-import android.util.Log;
+import android.telephony.Rlog;
+
+import com.android.internal.telephony.uicc.AdnRecord;
+
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/src/java/com/android/internal/telephony/IccProvider.java b/src/java/com/android/internal/telephony/IccProvider.java
index a66e19d..6f2c4ed 100644
--- a/src/java/com/android/internal/telephony/IccProvider.java
+++ b/src/java/com/android/internal/telephony/IccProvider.java
@@ -25,13 +25,13 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.List;
 
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.AdnRecord;
 import com.android.internal.telephony.IIccPhoneBook;
+import com.android.internal.telephony.uicc.AdnRecord;
+import com.android.internal.telephony.uicc.IccConstants;
 
 
 /**
@@ -207,12 +207,7 @@
             String param = tokens[n];
             if (DBG) log("parsing '" + param + "'");
 
-            String[] pair = param.split("=");
-
-            if (pair.length != 2) {
-                Log.e(TAG, "resolve: bad whereClause parameter: " + param);
-                continue;
-            }
+            String[] pair = param.split("=", 2);
 
             String key = pair[0].trim();
             String val = pair[1].trim();
@@ -312,7 +307,7 @@
             return cursor;
         } else {
             // No results to load
-            Log.w(TAG, "Cannot load ADN records");
+            Rlog.w(TAG, "Cannot load ADN records");
             return new MatrixCursor(ADDRESS_BOOK_COLUMN_NAMES);
         }
     }
@@ -425,7 +420,7 @@
     }
 
     private void log(String msg) {
-        Log.d(TAG, "[IccProvider] " + msg);
+        Rlog.d(TAG, "[IccProvider] " + msg);
     }
 
 }
diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
index 525bcd9..10ca2cc 100644
--- a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
@@ -18,29 +18,123 @@
 
 import android.app.PendingIntent;
 import android.content.Context;
+import android.os.AsyncResult;
+import android.os.Handler;
+import android.os.Message;
+import android.telephony.Rlog;
 import android.util.Log;
 
+import com.android.internal.telephony.uicc.IccConstants;
+import com.android.internal.telephony.uicc.IccFileHandler;
 import com.android.internal.util.HexDump;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import static android.telephony.SmsManager.STATUS_ON_ICC_FREE;
+import static android.telephony.SmsManager.STATUS_ON_ICC_READ;
+import static android.telephony.SmsManager.STATUS_ON_ICC_UNREAD;
 
 /**
  * IccSmsInterfaceManager to provide an inter-process communication to
  * access Sms in Icc.
  */
 public abstract class IccSmsInterfaceManager extends ISms.Stub {
+    static final String LOG_TAG = "RIL_IccSms";
+    static final boolean DBG = true;
+
+    protected final Object mLock = new Object();
+    protected boolean mSuccess;
+    private List<SmsRawData> mSms;
+
+    private static final int EVENT_LOAD_DONE = 1;
+    private static final int EVENT_UPDATE_DONE = 2;
+    protected static final int EVENT_SET_BROADCAST_ACTIVATION_DONE = 3;
+    protected static final int EVENT_SET_BROADCAST_CONFIG_DONE = 4;
+
     protected PhoneBase mPhone;
     protected Context mContext;
     protected SMSDispatcher mDispatcher;
 
+    protected Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            AsyncResult ar;
+
+            switch (msg.what) {
+                case EVENT_UPDATE_DONE:
+                    ar = (AsyncResult) msg.obj;
+                    synchronized (mLock) {
+                        mSuccess = (ar.exception == null);
+                        mLock.notifyAll();
+                    }
+                    break;
+                case EVENT_LOAD_DONE:
+                    ar = (AsyncResult)msg.obj;
+                    synchronized (mLock) {
+                        if (ar.exception == null) {
+                            mSms = buildValidRawData((ArrayList<byte[]>) ar.result);
+                            //Mark SMS as read after importing it from card.
+                            markMessagesAsRead((ArrayList<byte[]>) ar.result);
+                        } else {
+                            if(DBG) log("Cannot load Sms records");
+                            if (mSms != null)
+                                mSms.clear();
+                        }
+                        mLock.notifyAll();
+                    }
+                    break;
+                case EVENT_SET_BROADCAST_ACTIVATION_DONE:
+                case EVENT_SET_BROADCAST_CONFIG_DONE:
+                    ar = (AsyncResult) msg.obj;
+                    synchronized (mLock) {
+                        mSuccess = (ar.exception == null);
+                        mLock.notifyAll();
+                    }
+                    break;
+            }
+        }
+    };
+
     protected IccSmsInterfaceManager(PhoneBase phone){
         mPhone = phone;
         mContext = phone.getContext();
     }
 
+    protected void markMessagesAsRead(ArrayList<byte[]> messages) {
+        if (messages == null) {
+            return;
+        }
+
+        //IccFileHandler can be null, if icc card is absent.
+        IccFileHandler fh = mPhone.getIccFileHandler();
+        if (fh == null) {
+            //shouldn't really happen, as messages are marked as read, only
+            //after importing it from icc.
+            if (Rlog.isLoggable("SMS", Log.DEBUG)) {
+                log("markMessagesAsRead - aborting, no icc card present.");
+            }
+            return;
+        }
+
+        int count = messages.size();
+
+        for (int i = 0; i < count; i++) {
+             byte[] ba = messages.get(i);
+             if (ba[0] == STATUS_ON_ICC_UNREAD) {
+                 int n = ba.length;
+                 byte[] nba = new byte[n - 1];
+                 System.arraycopy(ba, 1, nba, 0, n - 1);
+                 byte[] record = makeSmsRecordData(STATUS_ON_ICC_READ, nba);
+                 fh.updateEFLinearFixed(IccConstants.EF_SMS, i + 1, record, null, null);
+                 if (Rlog.isLoggable("SMS", Log.DEBUG)) {
+                     log("SMS " + (i + 1) + " marked as read");
+                 }
+             }
+        }
+    }
+
     protected void enforceReceiveAndSend(String message) {
         mContext.enforceCallingPermission(
                 "android.permission.RECEIVE_SMS", message);
@@ -49,6 +143,119 @@
     }
 
     /**
+     * Update the specified message on the Icc.
+     *
+     * @param index record index of message to update
+     * @param status new message status (STATUS_ON_ICC_READ,
+     *                  STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
+     *                  STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
+     * @param pdu the raw PDU to store
+     * @return success or not
+     *
+     */
+    public boolean
+    updateMessageOnIccEf(int index, int status, byte[] pdu) {
+        if (DBG) log("updateMessageOnIccEf: index=" + index +
+                " status=" + status + " ==> " +
+                "("+ Arrays.toString(pdu) + ")");
+        enforceReceiveAndSend("Updating message on Icc");
+        synchronized(mLock) {
+            mSuccess = false;
+            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
+
+            if (status == STATUS_ON_ICC_FREE) {
+                // RIL_REQUEST_DELETE_SMS_ON_SIM vs RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM
+                // Special case FREE: call deleteSmsOnSim/Ruim instead of
+                // manipulating the record
+                // Will eventually fail if icc card is not present.
+                deleteSms(index, response);
+            } else {
+                //IccFilehandler can be null if ICC card is not present.
+                IccFileHandler fh = mPhone.getIccFileHandler();
+                if (fh == null) {
+                    response.recycle();
+                    return mSuccess; /* is false */
+                }
+                byte[] record = makeSmsRecordData(status, pdu);
+                fh.updateEFLinearFixed(
+                        IccConstants.EF_SMS,
+                        index, record, null, response);
+            }
+            try {
+                mLock.wait();
+            } catch (InterruptedException e) {
+                log("interrupted while trying to update by index");
+            }
+        }
+        return mSuccess;
+    }
+
+    /**
+     * Copy a raw SMS PDU to the Icc.
+     *
+     * @param pdu the raw PDU to store
+     * @param status message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
+     *               STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)
+     * @return success or not
+     *
+     */
+    public boolean copyMessageToIccEf(int status, byte[] pdu, byte[] smsc) {
+        //NOTE smsc not used in RUIM
+        if (DBG) log("copyMessageToIccEf: status=" + status + " ==> " +
+                "pdu=("+ Arrays.toString(pdu) +
+                "), smsc=(" + Arrays.toString(smsc) +")");
+        enforceReceiveAndSend("Copying message to Icc");
+        synchronized(mLock) {
+            mSuccess = false;
+            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
+
+            //RIL_REQUEST_WRITE_SMS_TO_SIM vs RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM
+            writeSms(status, smsc, pdu, response);
+
+            try {
+                mLock.wait();
+            } catch (InterruptedException e) {
+                log("interrupted while trying to update by index");
+            }
+        }
+        return mSuccess;
+    }
+
+    /**
+     * Retrieves all messages currently stored on Icc.
+     *
+     * @return list of SmsRawData of all sms on Icc
+     */
+    public List<SmsRawData> getAllMessagesFromIccEf() {
+        if (DBG) log("getAllMessagesFromEF");
+
+        mContext.enforceCallingPermission(
+                "android.permission.RECEIVE_SMS",
+                "Reading messages from Icc");
+        synchronized(mLock) {
+
+            IccFileHandler fh = mPhone.getIccFileHandler();
+            if (fh == null) {
+                Rlog.e(LOG_TAG, "Cannot load Sms records. No icc card?");
+                if (mSms != null) {
+                    mSms.clear();
+                    return mSms;
+                }
+            }
+
+            Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
+            fh.loadEFLinearFixedAll(IccConstants.EF_SMS, response);
+
+            try {
+                mLock.wait();
+            } catch (InterruptedException e) {
+                log("interrupted while trying to load from the Icc");
+            }
+        }
+        return mSms;
+    }
+
+    /**
      * Send a data based SMS to a specific application port.
      *
      * @param destAddr the address to send the message to
@@ -78,7 +285,7 @@
         mPhone.getContext().enforceCallingPermission(
                 "android.permission.SEND_SMS",
                 "Sending SMS message");
-        if (Log.isLoggable("SMS", Log.VERBOSE)) {
+        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
             log("sendData: destAddr=" + destAddr + " scAddr=" + scAddr + " destPort=" +
                 destPort + " data='"+ HexDump.toHexString(data)  + "' sentIntent=" +
                 sentIntent + " deliveryIntent=" + deliveryIntent);
@@ -115,7 +322,7 @@
         mPhone.getContext().enforceCallingPermission(
                 "android.permission.SEND_SMS",
                 "Sending SMS message");
-        if (Log.isLoggable("SMS", Log.VERBOSE)) {
+        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
             log("sendText: destAddr=" + destAddr + " scAddr=" + scAddr +
                 " text='"+ text + "' sentIntent=" +
                 sentIntent + " deliveryIntent=" + deliveryIntent);
@@ -153,7 +360,7 @@
         mPhone.getContext().enforceCallingPermission(
                 "android.permission.SEND_SMS",
                 "Sending SMS message");
-        if (Log.isLoggable("SMS", Log.VERBOSE)) {
+        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
             int i = 0;
             for (String part : parts) {
                 log("sendMultipartText: destAddr=" + destAddr + ", srAddr=" + scAddr +
@@ -220,6 +427,10 @@
         return data;
     }
 
+    protected abstract void deleteSms(int index, Message response);
+
+    protected abstract void writeSms(int status, byte[] pdu, byte[] smsc, Message response);
+
     protected abstract void log(String msg);
 
 }
diff --git a/src/java/com/android/internal/telephony/IccUtils.java b/src/java/com/android/internal/telephony/IccUtils.java
index a966f76..795740c 100644
--- a/src/java/com/android/internal/telephony/IccUtils.java
+++ b/src/java/com/android/internal/telephony/IccUtils.java
@@ -20,7 +20,7 @@
 import android.content.res.Resources.NotFoundException;
 import android.graphics.Bitmap;
 import android.graphics.Color;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.GsmAlphabet;
 import java.io.UnsupportedEncodingException;
@@ -187,7 +187,7 @@
                 try {
                     ret = new String(data, offset + 1, ucslen * 2, "utf-16be");
                 } catch (UnsupportedEncodingException ex) {
-                    Log.e(LOG_TAG, "implausible UnsupportedEncodingException",
+                    Rlog.e(LOG_TAG, "implausible UnsupportedEncodingException",
                           ex);
                 }
 
@@ -360,7 +360,7 @@
                             offset + 1, length - 1, "utf-16");
                 } catch (UnsupportedEncodingException ex) {
                     ret = "";
-                    Log.e(LOG_TAG,"implausible UnsupportedEncodingException", ex);
+                    Rlog.e(LOG_TAG,"implausible UnsupportedEncodingException", ex);
                 }
             break;
 
@@ -409,7 +409,7 @@
         };
 
         if (pixelIndex != numOfPixels) {
-            Log.e(LOG_TAG, "parse end and size error");
+            Rlog.e(LOG_TAG, "parse end and size error");
         }
         return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
     }
@@ -461,7 +461,7 @@
     private static int[] mapTo2OrderBitColor(byte[] data, int valueIndex,
             int length, int[] colorArray, int bits) {
         if (0 != (8 % bits)) {
-            Log.e(LOG_TAG, "not event number of color");
+            Rlog.e(LOG_TAG, "not event number of color");
             return mapToNon2OrderBitColor(data, valueIndex, length, colorArray,
                     bits);
         }
@@ -499,7 +499,7 @@
     private static int[] mapToNon2OrderBitColor(byte[] data, int valueIndex,
             int length, int[] colorArray, int bits) {
         if (0 == (8 % bits)) {
-            Log.e(LOG_TAG, "not odd number of color");
+            Rlog.e(LOG_TAG, "not odd number of color");
             return mapTo2OrderBitColor(data, valueIndex, length, colorArray,
                     bits);
         }
diff --git a/src/java/com/android/internal/telephony/MccTable.java b/src/java/com/android/internal/telephony/MccTable.java
index cb33521..8a2f30e 100644
--- a/src/java/com/android/internal/telephony/MccTable.java
+++ b/src/java/com/android/internal/telephony/MccTable.java
@@ -26,12 +26,12 @@
 import android.os.SystemProperties;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Locale;
-import libcore.icu.TimeZones;
+import libcore.icu.TimeZoneNames;
 
 /**
  * Mobile Country Code
@@ -105,7 +105,7 @@
             } else {
                 locale = new Locale(entry.language, entry.iso);
             }
-            String[] tz = TimeZones.forLocale(locale);
+            String[] tz = TimeZoneNames.forLocale(locale);
             if (tz.length == 0) return null;
             return tz[0];
         }
@@ -180,11 +180,11 @@
                 mcc = Integer.parseInt(mccmnc.substring(0,3));
                 mnc = Integer.parseInt(mccmnc.substring(3));
             } catch (NumberFormatException e) {
-                Log.e(LOG_TAG, "Error parsing IMSI");
+                Rlog.e(LOG_TAG, "Error parsing IMSI");
                 return;
             }
 
-            Log.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
+            Rlog.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
 
             if (mcc != 0) {
                 setTimezoneFromMccIfNeeded(context, mcc);
@@ -201,7 +201,7 @@
                 }
                 ActivityManagerNative.getDefault().updateConfiguration(config);
             } catch (RemoteException e) {
-                Log.e(LOG_TAG, "Can't update configuration", e);
+                Rlog.e(LOG_TAG, "Can't update configuration", e);
             }
         }
     }
@@ -273,7 +273,7 @@
                 AlarmManager alarm =
                         (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
                 alarm.setTimeZone(zoneId);
-                Log.d(LOG_TAG, "timezone set to "+zoneId);
+                Rlog.d(LOG_TAG, "timezone set to "+zoneId);
             }
         }
     }
@@ -292,7 +292,7 @@
         String language = MccTable.defaultLanguageForMcc(mcc);
         String country = MccTable.countryCodeForMcc(mcc);
 
-        Log.d(LOG_TAG, "locale set to "+language+"_"+country);
+        Rlog.d(LOG_TAG, "locale set to "+language+"_"+country);
         setSystemLocale(context, language, country);
     }
 
@@ -305,7 +305,7 @@
     private static void setWifiCountryCodeFromMcc(Context context, int mcc) {
         String country = MccTable.countryCodeForMcc(mcc);
         if (!country.isEmpty()) {
-            Log.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country);
+            Rlog.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country);
             WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
             //persist
             wM.setCountryCode(country, true);
diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java
index 71912b6..fbce476 100644
--- a/src/java/com/android/internal/telephony/Phone.java
+++ b/src/java/com/android/internal/telephony/Phone.java
@@ -29,9 +29,9 @@
 import android.telephony.SignalStrength;
 
 import com.android.internal.telephony.DataConnection;
-import com.android.internal.telephony.gsm.UsimServiceTable;
-import com.android.internal.telephony.ims.IsimRecords;
 import com.android.internal.telephony.test.SimulatedRadioControl;
+import com.android.internal.telephony.uicc.IsimRecords;
+import com.android.internal.telephony.uicc.UsimServiceTable;
 
 import com.android.internal.telephony.PhoneConstants.*; // ???? 
 
@@ -126,9 +126,12 @@
     int NT_MODE_EVDO_NO_CDMA = RILConstants.NETWORK_MODE_EVDO_NO_CDMA;
     int NT_MODE_GLOBAL       = RILConstants.NETWORK_MODE_GLOBAL;
 
-    int NT_MODE_LTE_ONLY     = RILConstants.NETWORK_MODE_LTE_ONLY;
-    int PREFERRED_NT_MODE    = RILConstants.PREFERRED_NETWORK_MODE;
-
+    int NT_MODE_LTE_CDMA_AND_EVDO        = RILConstants.NETWORK_MODE_LTE_CDMA_EVDO;
+    int NT_MODE_LTE_GSM_WCDMA            = RILConstants.NETWORK_MODE_LTE_GSM_WCDMA;
+    int NT_MODE_LTE_CMDA_EVDO_GSM_WCDMA  = RILConstants.NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA;
+    int NT_MODE_LTE_ONLY                 = RILConstants.NETWORK_MODE_LTE_ONLY;
+    int NT_MODE_LTE_WCDMA                = RILConstants.NETWORK_MODE_LTE_WCDMA;
+    int PREFERRED_NT_MODE                = RILConstants.PREFERRED_NETWORK_MODE;
 
     // Used for CDMA roaming mode
     static final int CDMA_RM_HOME        = 0;  // Home Networks only, as defined in PRL
diff --git a/src/java/com/android/internal/telephony/PhoneBase.java b/src/java/com/android/internal/telephony/PhoneBase.java
index f617e2b..c62f72f 100644
--- a/src/java/com/android/internal/telephony/PhoneBase.java
+++ b/src/java/com/android/internal/telephony/PhoneBase.java
@@ -36,16 +36,19 @@
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.R;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
-import com.android.internal.telephony.IccCardApplicationStatus.AppType;
-import com.android.internal.telephony.gsm.UsimServiceTable;
-import com.android.internal.telephony.ims.IsimRecords;
 import com.android.internal.telephony.test.SimulatedRadioControl;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.IsimRecords;
+import com.android.internal.telephony.uicc.SIMRecords;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
-import com.android.internal.telephony.gsm.SIMRecords;
+import com.android.internal.telephony.uicc.UsimServiceTable;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -253,11 +256,11 @@
          */
         mDoesRilSendMultipleCallRing = SystemProperties.getBoolean(
                 TelephonyProperties.PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING, true);
-        Log.d(LOG_TAG, "mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing);
+        Rlog.d(LOG_TAG, "mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing);
 
         mCallRingDelay = SystemProperties.getInt(
                 TelephonyProperties.PROPERTY_CALL_RING_DELAY, 3000);
-        Log.d(LOG_TAG, "mCallRingDelay=" + mCallRingDelay);
+        Rlog.d(LOG_TAG, "mCallRingDelay=" + mCallRingDelay);
 
         // Initialize device storage and outgoing SMS usage monitors for SMSDispatchers.
         mSmsStorageMonitor = new SmsStorageMonitor(this);
@@ -302,7 +305,7 @@
 
         switch(msg.what) {
             case EVENT_CALL_RING:
-                Log.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState());
+                Rlog.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState());
                 ar = (AsyncResult)msg.obj;
                 if (ar.exception == null) {
                     PhoneConstants.State state = getState();
@@ -318,7 +321,7 @@
                 break;
 
             case EVENT_CALL_RING_CONTINUE:
-                Log.d(LOG_TAG, "Event EVENT_CALL_RING_CONTINUE Received stat=" + getState());
+                Rlog.d(LOG_TAG, "Event EVENT_CALL_RING_CONTINUE Received stat=" + getState());
                 if (getState() == PhoneConstants.State.RINGING) {
                     sendIncomingCallRingNotification(msg.arg1);
                 }
@@ -1118,12 +1121,12 @@
     private void sendIncomingCallRingNotification(int token) {
         if (mIsVoiceCapable && !mDoesRilSendMultipleCallRing &&
                 (token == mCallRingContinueToken)) {
-            Log.d(LOG_TAG, "Sending notifyIncomingRing");
+            Rlog.d(LOG_TAG, "Sending notifyIncomingRing");
             notifyIncomingRing();
             sendMessageDelayed(
                     obtainMessage(EVENT_CALL_RING_CONTINUE, token, 0), mCallRingDelay);
         } else {
-            Log.d(LOG_TAG, "Ignoring ring notification request,"
+            Rlog.d(LOG_TAG, "Ignoring ring notification request,"
                     + " mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing
                     + " token=" + token
                     + " mCallRingContinueToken=" + mCallRingContinueToken
@@ -1139,12 +1142,12 @@
     }
 
     public IsimRecords getIsimRecords() {
-        Log.e(LOG_TAG, "getIsimRecords() is only supported on LTE devices");
+        Rlog.e(LOG_TAG, "getIsimRecords() is only supported on LTE devices");
         return null;
     }
 
     public void requestIsimAuthentication(String nonce, Message result) {
-        Log.e(LOG_TAG, "requestIsimAuthentication() is only supported on LTE devices");
+        Rlog.e(LOG_TAG, "requestIsimAuthentication() is only supported on LTE devices");
     }
 
     public String getMsisdn() {
@@ -1157,7 +1160,7 @@
      */
     private static void logUnexpectedCdmaMethodCall(String name)
     {
-        Log.e(LOG_TAG, "Error! " + name + "() in PhoneBase should not be " +
+        Rlog.e(LOG_TAG, "Error! " + name + "() in PhoneBase should not be " +
                 "called, CDMAPhone inactive.");
     }
 
@@ -1169,14 +1172,14 @@
      * Common error logger method for unexpected calls to GSM/WCDMA-only methods.
      */
     private static void logUnexpectedGsmMethodCall(String name) {
-        Log.e(LOG_TAG, "Error! " + name + "() in PhoneBase should not be " +
+        Rlog.e(LOG_TAG, "Error! " + name + "() in PhoneBase should not be " +
                 "called, GSMPhone inactive.");
     }
 
     // Called by SimRecords which is constructed with a PhoneBase instead of a GSMPhone.
     public void notifyCallForwardingIndicator() {
         // This function should be overridden by the class GSMPhone. Not implemented in CDMAPhone.
-        Log.e(LOG_TAG, "Error! This function should never be executed, inactive CDMAPhone.");
+        Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive CDMAPhone.");
     }
 
     public void notifyDataConnectionFailed(String reason, String apnType) {
diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java
index 1892427..c0641d5 100644
--- a/src/java/com/android/internal/telephony/PhoneFactory.java
+++ b/src/java/com/android/internal/telephony/PhoneFactory.java
@@ -21,7 +21,7 @@
 import android.os.Looper;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.os.SystemProperties;
 
 import com.android.internal.telephony.cdma.CDMAPhone;
@@ -108,7 +108,7 @@
                 }
                 int networkMode = Settings.Global.getInt(context.getContentResolver(),
                         Settings.Global.PREFERRED_NETWORK_MODE, preferredNetworkMode);
-                Log.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkMode));
+                Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkMode));
 
                 // Get cdmaSubscription
                 // TODO: Change when the ril will provides a way to know at runtime
@@ -119,11 +119,11 @@
                 switch (lteOnCdma) {
                     case PhoneConstants.LTE_ON_CDMA_FALSE:
                         cdmaSubscription = CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_NV;
-                        Log.i(LOG_TAG, "lteOnCdma is 0 use SUBSCRIPTION_FROM_NV");
+                        Rlog.i(LOG_TAG, "lteOnCdma is 0 use SUBSCRIPTION_FROM_NV");
                         break;
                     case PhoneConstants.LTE_ON_CDMA_TRUE:
                         cdmaSubscription = CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM;
-                        Log.i(LOG_TAG, "lteOnCdma is 1 use SUBSCRIPTION_FROM_RUIM");
+                        Rlog.i(LOG_TAG, "lteOnCdma is 1 use SUBSCRIPTION_FROM_RUIM");
                         break;
                     case PhoneConstants.LTE_ON_CDMA_UNKNOWN:
                     default:
@@ -131,10 +131,10 @@
                         cdmaSubscription = Settings.Global.getInt(context.getContentResolver(),
                                 Settings.Global.PREFERRED_CDMA_SUBSCRIPTION,
                                 preferredCdmaSubscription);
-                        Log.i(LOG_TAG, "lteOnCdma not set, using PREFERRED_CDMA_SUBSCRIPTION");
+                        Rlog.i(LOG_TAG, "lteOnCdma not set, using PREFERRED_CDMA_SUBSCRIPTION");
                         break;
                 }
-                Log.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);
+                Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);
 
                 //reads the system properties and makes commandsinterface
                 sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
@@ -144,19 +144,19 @@
 
                 int phoneType = TelephonyManager.getPhoneType(networkMode);
                 if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
-                    Log.i(LOG_TAG, "Creating GSMPhone");
+                    Rlog.i(LOG_TAG, "Creating GSMPhone");
                     sProxyPhone = new PhoneProxy(new GSMPhone(context,
                             sCommandsInterface, sPhoneNotifier));
                 } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
                     switch (TelephonyManager.getLteOnCdmaModeStatic()) {
                         case PhoneConstants.LTE_ON_CDMA_TRUE:
-                            Log.i(LOG_TAG, "Creating CDMALTEPhone");
+                            Rlog.i(LOG_TAG, "Creating CDMALTEPhone");
                             sProxyPhone = new PhoneProxy(new CDMALTEPhone(context,
                                 sCommandsInterface, sPhoneNotifier));
                             break;
                         case PhoneConstants.LTE_ON_CDMA_FALSE:
                         default:
-                            Log.i(LOG_TAG, "Creating CDMAPhone");
+                            Rlog.i(LOG_TAG, "Creating CDMAPhone");
                             sProxyPhone = new PhoneProxy(new CDMAPhone(context,
                                     sCommandsInterface, sPhoneNotifier));
                             break;
diff --git a/src/java/com/android/internal/telephony/PhoneProxy.java b/src/java/com/android/internal/telephony/PhoneProxy.java
index 1c4bdc5..300529b 100644
--- a/src/java/com/android/internal/telephony/PhoneProxy.java
+++ b/src/java/com/android/internal/telephony/PhoneProxy.java
@@ -31,13 +31,14 @@
 import android.telephony.CellLocation;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.cdma.CDMAPhone;
 import com.android.internal.telephony.gsm.GSMPhone;
-import com.android.internal.telephony.gsm.UsimServiceTable;
-import com.android.internal.telephony.ims.IsimRecords;
 import com.android.internal.telephony.test.SimulatedRadioControl;
+import com.android.internal.telephony.uicc.IccCardProxy;
+import com.android.internal.telephony.uicc.IsimRecords;
+import com.android.internal.telephony.uicc.UsimServiceTable;
 import com.android.internal.telephony.CallManager;
 
 import java.util.List;
@@ -131,15 +132,15 @@
     }
 
     private static void logd(String msg) {
-        Log.d(LOG_TAG, "[PhoneProxy] " + msg);
+        Rlog.d(LOG_TAG, "[PhoneProxy] " + msg);
     }
 
     private void logw(String msg) {
-        Log.w(LOG_TAG, "[PhoneProxy] " + msg);
+        Rlog.w(LOG_TAG, "[PhoneProxy] " + msg);
     }
 
     private void loge(String msg) {
-        Log.e(LOG_TAG, "[PhoneProxy] " + msg);
+        Rlog.e(LOG_TAG, "[PhoneProxy] " + msg);
     }
 
     private void updatePhoneObject(int newVoiceRadioTech) {
diff --git a/src/java/com/android/internal/telephony/PhoneStateIntentReceiver.java b/src/java/com/android/internal/telephony/PhoneStateIntentReceiver.java
index 89084ac..40f0c34 100644
--- a/src/java/com/android/internal/telephony/PhoneStateIntentReceiver.java
+++ b/src/java/com/android/internal/telephony/PhoneStateIntentReceiver.java
@@ -25,7 +25,7 @@
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  *
@@ -174,7 +174,7 @@
                     mTarget.sendMessage(message);
                 }
             } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
-                if (DBG) Log.d(LOG_TAG, "onReceiveIntent: ACTION_PHONE_STATE_CHANGED, state="
+                if (DBG) Rlog.d(LOG_TAG, "onReceiveIntent: ACTION_PHONE_STATE_CHANGED, state="
                                + intent.getStringExtra(PhoneConstants.STATE_KEY));
                 String phoneState = intent.getStringExtra(PhoneConstants.STATE_KEY);
                 mPhoneState = (PhoneConstants.State) Enum.valueOf(
@@ -195,7 +195,7 @@
                 }
             }
         } catch (Exception ex) {
-            Log.e(LOG_TAG, "[PhoneStateIntentRecv] caught " + ex);
+            Rlog.e(LOG_TAG, "[PhoneStateIntentRecv] caught " + ex);
             ex.printStackTrace();
         }
     }
diff --git a/src/java/com/android/internal/telephony/PhoneSubInfo.java b/src/java/com/android/internal/telephony/PhoneSubInfo.java
index e8449ce..cbab817 100755
--- a/src/java/com/android/internal/telephony/PhoneSubInfo.java
+++ b/src/java/com/android/internal/telephony/PhoneSubInfo.java
@@ -22,9 +22,9 @@
 import android.content.pm.PackageManager;
 import android.os.Binder;
 import android.telephony.PhoneNumberUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.ims.IsimRecords;
+import com.android.internal.telephony.uicc.IsimRecords;
 
 public class PhoneSubInfo extends IPhoneSubInfo.Stub {
     static final String LOG_TAG = "PHONE";
@@ -50,9 +50,9 @@
         try {
             super.finalize();
         } catch (Throwable throwable) {
-            Log.e(LOG_TAG, "Error while finalizing:", throwable);
+            Rlog.e(LOG_TAG, "Error while finalizing:", throwable);
         }
-        Log.d(LOG_TAG, "PhoneSubInfo finalized");
+        Rlog.d(LOG_TAG, "PhoneSubInfo finalized");
     }
 
     /**
@@ -118,7 +118,7 @@
     public String getVoiceMailNumber() {
         mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, "Requires READ_PHONE_STATE");
         String number = PhoneNumberUtils.extractNetworkPortion(mPhone.getVoiceMailNumber());
-        Log.d(LOG_TAG, "VM: PhoneSubInfo.getVoiceMailNUmber: "); // + number);
+        Rlog.d(LOG_TAG, "VM: PhoneSubInfo.getVoiceMailNUmber: "); // + number);
         return number;
     }
 
@@ -131,7 +131,7 @@
         mContext.enforceCallingOrSelfPermission(CALL_PRIVILEGED,
                 "Requires CALL_PRIVILEGED");
         String number = mPhone.getVoiceMailNumber();
-        Log.d(LOG_TAG, "VM: PhoneSubInfo.getCompleteVoiceMailNUmber: "); // + number);
+        Rlog.d(LOG_TAG, "VM: PhoneSubInfo.getCompleteVoiceMailNUmber: "); // + number);
         return number;
     }
 
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index faae72a..9c6f90e 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -47,14 +47,18 @@
 import android.telephony.SmsManager;
 import android.telephony.SmsMessage;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SuppServiceNotification;
-import com.android.internal.telephony.IccCardApplicationStatus;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus;
+import com.android.internal.telephony.uicc.IccCardStatus;
+import com.android.internal.telephony.uicc.IccIoResult;
+import com.android.internal.telephony.uicc.IccRefreshResponse;
+import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
 import com.android.internal.telephony.cdma.CdmaInformationRecords;
-import com.android.internal.telephony.IccRefreshResponse;
+import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
 
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
@@ -179,7 +183,7 @@
 
         ex = CommandException.fromRilErrno(error);
 
-        if (RIL.RILJ_LOGD) Log.d(LOG_TAG, serialString() + "< "
+        if (RIL.RILJ_LOGD) Rlog.d(LOG_TAG, serialString() + "< "
             + RIL.requestToString(mRequest)
             + " error: " + ex);
 
@@ -232,7 +236,7 @@
     int mRequestMessagesWaiting;
 
     //I'd rather this be LinkedList or something
-    ArrayList<RILRequest> mRequestsList = new ArrayList<RILRequest>();
+    ArrayList<RILRequest> mRequestList = new ArrayList<RILRequest>();
 
     Object     mLastNITZTimeInfo;
 
@@ -269,7 +273,7 @@
             } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
                 sendScreenState(false);
             } else {
-                Log.w(LOG_TAG, "RIL received unexpected Intent: " + intent.getAction());
+                Rlog.w(LOG_TAG, "RIL received unexpected Intent: " + intent.getAction());
             }
         }
     };
@@ -317,8 +321,8 @@
                             return;
                         }
 
-                        synchronized (mRequestsList) {
-                            mRequestsList.add(rr);
+                        synchronized (mRequestList) {
+                            mRequestList.add(rr);
                             mRequestMessagesWaiting++;
                         }
 
@@ -343,12 +347,12 @@
                         dataLength[2] = (byte)((data.length >> 8) & 0xff);
                         dataLength[3] = (byte)((data.length) & 0xff);
 
-                        //Log.v(LOG_TAG, "writing packet: " + data.length + " bytes");
+                        //Rlog.v(LOG_TAG, "writing packet: " + data.length + " bytes");
 
                         s.getOutputStream().write(dataLength);
                         s.getOutputStream().write(data);
                     } catch (IOException ex) {
-                        Log.e(LOG_TAG, "IOException", ex);
+                        Rlog.e(LOG_TAG, "IOException", ex);
                         req = findAndRemoveRequestFromList(rr.mSerial);
                         // make sure this request has not already been handled,
                         // eg, if RILReceiver cleared the list.
@@ -357,7 +361,7 @@
                             rr.release();
                         }
                     } catch (RuntimeException exc) {
-                        Log.e(LOG_TAG, "Uncaught exception ", exc);
+                        Rlog.e(LOG_TAG, "Uncaught exception ", exc);
                         req = findAndRemoveRequestFromList(rr.mSerial);
                         // make sure this request has not already been handled,
                         // eg, if RILReceiver cleared the list.
@@ -393,21 +397,21 @@
                             // Note: Keep mRequestList so that delayed response
                             // can still be handled when response finally comes.
                             if (mRequestMessagesWaiting != 0) {
-                                Log.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but"
+                                Rlog.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but"
                                         + mRequestMessagesWaiting + " at TIMEOUT, reset!"
                                         + " There still msg waitng for response");
 
                                 mRequestMessagesWaiting = 0;
 
                                 if (RILJ_LOGD) {
-                                    synchronized (mRequestsList) {
-                                        int count = mRequestsList.size();
-                                        Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
+                                    synchronized (mRequestList) {
+                                        int count = mRequestList.size();
+                                        Rlog.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
                                                 " mRequestList=" + count);
 
                                         for (int i = 0; i < count; i++) {
-                                            rr = mRequestsList.get(i);
-                                            Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] "
+                                            rr = mRequestList.get(i);
+                                            Rlog.d(LOG_TAG, i + ": [" + rr.mSerial + "] "
                                                     + requestToString(rr.mRequest));
                                         }
                                     }
@@ -421,7 +425,7 @@
                             // should already sent out (i.e.
                             // mRequestMessagesPending is 0 )while TIMEOUT occurs.
                             if (mRequestMessagesPending != 0) {
-                                Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but"
+                                Rlog.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but"
                                         + mRequestMessagesPending + " at TIMEOUT, reset!");
                                 mRequestMessagesPending = 0;
 
@@ -461,7 +465,7 @@
             countRead = is.read(buffer, offset, remaining);
 
             if (countRead < 0 ) {
-                Log.e(LOG_TAG, "Hit EOS reading message length");
+                Rlog.e(LOG_TAG, "Hit EOS reading message length");
                 return -1;
             }
 
@@ -481,7 +485,7 @@
             countRead = is.read(buffer, offset, remaining);
 
             if (countRead < 0 ) {
-                Log.e(LOG_TAG, "Hit EOS reading message.  messageLength=" + messageLength
+                Rlog.e(LOG_TAG, "Hit EOS reading message.  messageLength=" + messageLength
                         + " remaining=" + remaining);
                 return -1;
             }
@@ -526,12 +530,12 @@
                     // or after the 8th time
 
                     if (retryCount == 8) {
-                        Log.e (LOG_TAG,
+                        Rlog.e (LOG_TAG,
                             "Couldn't find '" + SOCKET_NAME_RIL
                             + "' socket after " + retryCount
                             + " times, continuing to retry silently");
                     } else if (retryCount > 0 && retryCount < 8) {
-                        Log.i (LOG_TAG,
+                        Rlog.i (LOG_TAG,
                             "Couldn't find '" + SOCKET_NAME_RIL
                             + "' socket; retrying after timeout");
                     }
@@ -548,7 +552,7 @@
                 retryCount = 0;
 
                 mSocket = s;
-                Log.i(LOG_TAG, "Connected to '" + SOCKET_NAME_RIL + "' socket");
+                Rlog.i(LOG_TAG, "Connected to '" + SOCKET_NAME_RIL + "' socket");
 
                 int length = 0;
                 try {
@@ -568,20 +572,20 @@
                         p.unmarshall(buffer, 0, length);
                         p.setDataPosition(0);
 
-                        //Log.v(LOG_TAG, "Read packet: " + length + " bytes");
+                        //Rlog.v(LOG_TAG, "Read packet: " + length + " bytes");
 
                         processResponse(p);
                         p.recycle();
                     }
                 } catch (java.io.IOException ex) {
-                    Log.i(LOG_TAG, "'" + SOCKET_NAME_RIL + "' socket closed",
+                    Rlog.i(LOG_TAG, "'" + SOCKET_NAME_RIL + "' socket closed",
                           ex);
                 } catch (Throwable tr) {
-                    Log.e(LOG_TAG, "Uncaught exception read length=" + length +
+                    Rlog.e(LOG_TAG, "Uncaught exception read length=" + length +
                         "Exception:" + tr.toString());
                 }
 
-                Log.i(LOG_TAG, "Disconnected from '" + SOCKET_NAME_RIL
+                Rlog.i(LOG_TAG, "Disconnected from '" + SOCKET_NAME_RIL
                       + "' socket");
 
                 setRadioState (RadioState.RADIO_UNAVAILABLE);
@@ -595,9 +599,9 @@
                 RILRequest.resetSerial();
 
                 // Clear request list on close
-                clearRequestsList(RADIO_NOT_AVAILABLE, false);
+                clearRequestList(RADIO_NOT_AVAILABLE, false);
             }} catch (Throwable tr) {
-                Log.e(LOG_TAG,"Uncaught exception", tr);
+                Rlog.e(LOG_TAG,"Uncaught exception", tr);
             }
 
             /* We're disconnected so we don't know the ril version */
@@ -637,6 +641,8 @@
                 Context.CONNECTIVITY_SERVICE);
         if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false) {
             riljLog("Not starting RILReceiver: wifi-only");
+        } if (SystemProperties.getBoolean("ro.radio.noril", false)) {
+            riljLog("Not starting RILReceiver: basebandless target");
         } else {
             riljLog("Starting RILReceiver");
             mReceiver = new RILReceiver();
@@ -1712,8 +1718,12 @@
         RILRequest rr
                 = RILRequest.obtain(RIL_REQUEST_SEND_USSD, response);
 
-        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
-                            + " " + ussdString);
+        if (RILJ_LOGD) {
+            String logUssdString = "*******";
+            if (RILJ_LOGV) logUssdString = ussdString;
+            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+                                   + " " + logUssdString);
+        }
 
         rr.mp.writeString(ussdString);
 
@@ -2047,9 +2057,8 @@
         // In case screen state was lost (due to process crash),
         // this ensures that the RIL knows the correct screen state.
 
-        // TODO: Should query Power Manager and send the actual
-        // screen state.  Just send true for now.
-        sendScreenState(true);
+        PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
+        sendScreenState(pm.isScreenOn());
    }
 
     private RadioState getRadioStateFromInt(int stateInt) {
@@ -2138,41 +2147,41 @@
     }
 
     /**
-     * Release each request in mReqeustsList then clear the list
+     * Release each request in mRequestList then clear the list
      * @param error is the RIL_Errno sent back
-     * @param loggable true means to print all requests in mRequestslist
+     * @param loggable true means to print all requests in mRequestList
      */
-    private void clearRequestsList(int error, boolean loggable) {
+    private void clearRequestList(int error, boolean loggable) {
         RILRequest rr;
-        synchronized (mRequestsList) {
-            int count = mRequestsList.size();
+        synchronized (mRequestList) {
+            int count = mRequestList.size();
             if (RILJ_LOGD && loggable) {
-                Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
+                Rlog.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
                         " mReqPending=" + mRequestMessagesPending +
                         " mRequestList=" + count);
             }
 
             for (int i = 0; i < count ; i++) {
-                rr = mRequestsList.get(i);
+                rr = mRequestList.get(i);
                 if (RILJ_LOGD && loggable) {
-                    Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " +
+                    Rlog.d(LOG_TAG, i + ": [" + rr.mSerial + "] " +
                             requestToString(rr.mRequest));
                 }
                 rr.onError(error, null);
                 rr.release();
             }
-            mRequestsList.clear();
+            mRequestList.clear();
             mRequestMessagesWaiting = 0;
         }
     }
 
     private RILRequest findAndRemoveRequestFromList(int serial) {
-        synchronized (mRequestsList) {
-            for (int i = 0, s = mRequestsList.size() ; i < s ; i++) {
-                RILRequest rr = mRequestsList.get(i);
+        synchronized (mRequestList) {
+            for (int i = 0, s = mRequestList.size() ; i < s ; i++) {
+                RILRequest rr = mRequestList.get(i);
 
                 if (rr.mSerial == serial) {
-                    mRequestsList.remove(i);
+                    mRequestList.remove(i);
                     if (mRequestMessagesWaiting > 0)
                         mRequestMessagesWaiting--;
                     return rr;
@@ -2196,7 +2205,7 @@
         rr = findAndRemoveRequestFromList(serial);
 
         if (rr == null) {
-            Log.w(LOG_TAG, "Unexpected solicited response! sn: "
+            Rlog.w(LOG_TAG, "Unexpected solicited response! sn: "
                             + serial + " error: " + error);
             return;
         }
@@ -2334,7 +2343,7 @@
             }} catch (Throwable tr) {
                 // Exceptions here usually mean invalid RIL responses
 
-                Log.w(LOG_TAG, rr.serialString() + "< "
+                Rlog.w(LOG_TAG, rr.serialString() + "< "
                         + requestToString(rr.mRequest)
                         + " exception, possible invalid RIL response", tr);
 
@@ -2514,7 +2523,7 @@
                 throw new RuntimeException("Unrecognized unsol response: " + response);
             //break; (implied)
         }} catch (Throwable tr) {
-            Log.e(LOG_TAG, "Exception processing unsol response: " + response +
+            Rlog.e(LOG_TAG, "Exception processing unsol response: " + response +
                 "Exception:" + tr.toString());
             return;
         }
@@ -2785,7 +2794,7 @@
                 try {
                     listInfoRecs = (ArrayList<CdmaInformationRecords>)ret;
                 } catch (ClassCastException e) {
-                    Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
+                    Rlog.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
                     break;
                 }
 
@@ -3643,7 +3652,7 @@
             case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
             case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
             case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
-            case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONG";
+            case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
             case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
             case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED";
             case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
@@ -3655,11 +3664,11 @@
     }
 
     private void riljLog(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     private void riljLogv(String msg) {
-        Log.v(LOG_TAG, msg);
+        Rlog.v(LOG_TAG, msg);
     }
 
     private void unsljLog(int response) {
@@ -3810,15 +3819,36 @@
         send(rr);
     }
 
-    // TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
+    public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response) {
         RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response);
 
-        for(int i = 0; i < configValuesArray.length; i++) {
-            rr.mp.writeInt(configValuesArray[i]);
+        // Convert to 1 service category per config (the way RIL takes is)
+        ArrayList<CdmaSmsBroadcastConfigInfo> processedConfigs =
+            new ArrayList<CdmaSmsBroadcastConfigInfo>();
+        for (CdmaSmsBroadcastConfigInfo config : configs) {
+            for (int i = config.getFromServiceCategory(); i <= config.getToServiceCategory(); i++) {
+                processedConfigs.add(new CdmaSmsBroadcastConfigInfo(i,
+                        i,
+                        config.getLanguage(),
+                        config.isSelected()));
+            }
         }
 
-        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+        CdmaSmsBroadcastConfigInfo[] rilConfigs = processedConfigs.toArray(configs);
+        rr.mp.writeInt(rilConfigs.length);
+        for(int i = 0; i < rilConfigs.length; i++) {
+            rr.mp.writeInt(rilConfigs[i].getFromServiceCategory());
+            rr.mp.writeInt(rilConfigs[i].getLanguage());
+            rr.mp.writeInt(rilConfigs[i].isSelected() ? 1 : 0);
+        }
+
+        if (RILJ_LOGD) {
+            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+                    + " with " + rilConfigs.length + " configs : ");
+            for (int i = 0; i < rilConfigs.length; i++) {
+                riljLog(rilConfigs[i].toString());
+            }
+        }
 
         send(rr);
     }
@@ -3865,7 +3895,7 @@
     }
 
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        pw.println("RIL:");
+        pw.println("RIL: " + this);
         pw.println(" mSocket=" + mSocket);
         pw.println(" mSenderThread=" + mSenderThread);
         pw.println(" mSender=" + mSender);
@@ -3873,13 +3903,13 @@
         pw.println(" mReceiver=" + mReceiver);
         pw.println(" mWakeLock=" + mWakeLock);
         pw.println(" mWakeLockTimeout=" + mWakeLockTimeout);
-        synchronized (mRequestsList) {
+        synchronized (mRequestList) {
           pw.println(" mRequestMessagesPending=" + mRequestMessagesPending);
           pw.println(" mRequestMessagesWaiting=" + mRequestMessagesWaiting);
-            int count = mRequestsList.size();
+            int count = mRequestList.size();
             pw.println(" mRequestList count=" + count);
             for (int i = 0; i < count; i++) {
-                RILRequest rr = mRequestsList.get(i);
+                RILRequest rr = mRequestList.get(i);
                 pw.println("  [" + rr.mSerial + "] " + requestToString(rr.mRequest));
             }
         }
diff --git a/src/java/com/android/internal/telephony/RetryManager.java b/src/java/com/android/internal/telephony/RetryManager.java
index 250d99e..7d9dc9c 100644
--- a/src/java/com/android/internal/telephony/RetryManager.java
+++ b/src/java/com/android/internal/telephony/RetryManager.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony;
 
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Pair;
 import android.text.TextUtils;
 
@@ -208,7 +208,7 @@
                             mMaxRetryCount = value.second;
                         }
                     } else {
-                        Log.e(LOG_TAG, "Unrecognized configuration name value pair: "
+                        Rlog.e(LOG_TAG, "Unrecognized configuration name value pair: "
                                         + strArray[i]);
                         return false;
                     }
@@ -365,7 +365,7 @@
             value = Integer.parseInt(stringValue);
             retVal = new Pair<Boolean, Integer>(validateNonNegativeInt(name, value), value);
         } catch (NumberFormatException e) {
-            Log.e(LOG_TAG, name + " bad value: " + stringValue, e);
+            Rlog.e(LOG_TAG, name + " bad value: " + stringValue, e);
             retVal = new Pair<Boolean, Integer>(false, 0);
         }
         if (VDBG) log("parseNonNetativeInt: " + name + ", " + stringValue + ", "
@@ -383,7 +383,7 @@
     private boolean validateNonNegativeInt(String name, int value) {
         boolean retVal;
         if (value < 0) {
-            Log.e(LOG_TAG, name + " bad value: is < 0");
+            Rlog.e(LOG_TAG, name + " bad value: is < 0");
             retVal = false;
         } else {
             retVal = true;
@@ -405,6 +405,6 @@
     }
 
     private void log(String s) {
-        Log.d(LOG_TAG, "[RM] " + s);
+        Rlog.d(LOG_TAG, "[RM] " + s);
     }
 }
diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java
index 6740372..a13f30e 100644
--- a/src/java/com/android/internal/telephony/SMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/SMSDispatcher.java
@@ -51,7 +51,7 @@
 import android.text.Html;
 import android.text.Spanned;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -225,7 +225,7 @@
                                 TelephonyProperties.PROPERTY_SMS_RECEIVE, mSmsCapable);
         mSmsSendDisabled = !SystemProperties.getBoolean(
                                 TelephonyProperties.PROPERTY_SMS_SEND, mSmsCapable);
-        Log.d(TAG, "SMSDispatcher: ctor mSmsCapable=" + mSmsCapable + " format=" + getFormat()
+        Rlog.d(TAG, "SMSDispatcher: ctor mSmsCapable=" + mSmsCapable + " format=" + getFormat()
                 + " mSmsReceiveDisabled=" + mSmsReceiveDisabled
                 + " mSmsSendDisabled=" + mSmsSendDisabled);
     }
@@ -271,7 +271,7 @@
 
     @Override
     protected void finalize() {
-        Log.d(TAG, "SMSDispatcher finalized");
+        Rlog.d(TAG, "SMSDispatcher finalized");
     }
 
 
@@ -296,7 +296,7 @@
         case EVENT_NEW_SMS:
             // A new SMS has been received by the device
             if (false) {
-                Log.d(TAG, "New SMS Message Received");
+                Rlog.d(TAG, "New SMS Message Received");
             }
 
             SmsMessage sms;
@@ -304,7 +304,7 @@
             ar = (AsyncResult) msg.obj;
 
             if (ar.exception != null) {
-                Log.e(TAG, "Exception processing incoming SMS. Exception:" + ar.exception);
+                Rlog.e(TAG, "Exception processing incoming SMS. Exception:" + ar.exception);
                 return;
             }
 
@@ -318,7 +318,7 @@
                     notifyAndAcknowledgeLastIncomingSms(handled, result, null);
                 }
             } catch (RuntimeException ex) {
-                Log.e(TAG, "Exception dispatching message", ex);
+                Rlog.e(TAG, "Exception dispatching message", ex);
                 notifyAndAcknowledgeLastIncomingSms(false, Intents.RESULT_SMS_GENERIC_ERROR, null);
             }
 
@@ -364,7 +364,7 @@
                 try {
                     tracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
                 } catch (CanceledException ex) {
-                    Log.e(TAG, "failed to send RESULT_ERROR_LIMIT_EXCEEDED");
+                    Rlog.e(TAG, "failed to send RESULT_ERROR_LIMIT_EXCEEDED");
                 }
             }
             mPendingTrackerCount--;
@@ -424,16 +424,20 @@
         SmsTracker tracker = (SmsTracker) ar.userObj;
         PendingIntent sentIntent = tracker.mSentIntent;
 
+        if (ar.result != null) {
+            tracker.mMessageRef = ((SmsResponse)ar.result).messageRef;
+        } else {
+            Rlog.d(TAG, "SmsResponse was null");
+        }
+
         if (ar.exception == null) {
             if (false) {
-                Log.d(TAG, "SMS send complete. Broadcasting "
+                Rlog.d(TAG, "SMS send complete. Broadcasting "
                         + "intent: " + sentIntent);
             }
 
             if (tracker.mDeliveryIntent != null) {
                 // Expecting a status report.  Add it to the list.
-                int messageRef = ((SmsResponse)ar.result).messageRef;
-                tracker.mMessageRef = messageRef;
                 deliveryPendingList.add(tracker);
             }
 
@@ -454,7 +458,7 @@
             }
         } else {
             if (false) {
-                Log.d(TAG, "SMS send failed");
+                Rlog.d(TAG, "SMS send failed");
             }
 
             int ss = mPhone.getServiceState().getState();
@@ -609,12 +613,12 @@
 
             // moveToNext() returns false if no duplicates were found
             if (cursor.moveToNext()) {
-                Log.w(TAG, "Discarding duplicate message segment from address=" + address
+                Rlog.w(TAG, "Discarding duplicate message segment from address=" + address
                         + " refNumber=" + refNumber + " seqNumber=" + seqNumber);
                 String oldPduString = cursor.getString(PDU_COLUMN);
                 byte[] oldPdu = HexDump.hexStringToByteArray(oldPduString);
                 if (!Arrays.equals(oldPdu, pdu)) {
-                    Log.e(TAG, "Warning: dup message segment PDU of length " + pdu.length
+                    Rlog.e(TAG, "Warning: dup message segment PDU of length " + pdu.length
                             + " is different from existing PDU of length " + oldPdu.length);
                 }
                 return Intents.RESULT_SMS_HANDLED;
@@ -672,7 +676,7 @@
             // Remove the parts from the database
             mResolver.delete(mRawUri, where, whereArgs);
         } catch (SQLException e) {
-            Log.e(TAG, "Can't access multipart SMS database", e);
+            Rlog.e(TAG, "Can't access multipart SMS database", e);
             return Intents.RESULT_SMS_GENERIC_ERROR;
         } finally {
             if (cursor != null) cursor.close();
@@ -938,7 +942,7 @@
                     sentIntent.send(RESULT_ERROR_NO_SERVICE);
                 } catch (CanceledException ex) {}
             }
-            Log.d(TAG, "Device does not support sending sms.");
+            Rlog.d(TAG, "Device does not support sending sms.");
             return;
         }
 
@@ -961,12 +965,12 @@
 
         if (packageNames == null || packageNames.length == 0) {
             // Refuse to send SMS if we can't get the calling package name.
-            Log.e(TAG, "Can't get calling app package name: refusing to send SMS");
+            Rlog.e(TAG, "Can't get calling app package name: refusing to send SMS");
             if (sentIntent != null) {
                 try {
                     sentIntent.send(RESULT_ERROR_GENERIC_FAILURE);
                 } catch (CanceledException ex) {
-                    Log.e(TAG, "failed to send error result");
+                    Rlog.e(TAG, "failed to send error result");
                 }
             }
             return;
@@ -978,12 +982,12 @@
             // XXX this is lossy- apps can share a UID
             appInfo = pm.getPackageInfo(packageNames[0], PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
-            Log.e(TAG, "Can't get calling app package info: refusing to send SMS");
+            Rlog.e(TAG, "Can't get calling app package info: refusing to send SMS");
             if (sentIntent != null) {
                 try {
                     sentIntent.send(RESULT_ERROR_GENERIC_FAILURE);
                 } catch (CanceledException ex) {
-                    Log.e(TAG, "failed to send error result");
+                    Rlog.e(TAG, "failed to send error result");
                 }
             }
             return;
@@ -1031,7 +1035,7 @@
             if (rule == PREMIUM_RULE_USE_SIM || rule == PREMIUM_RULE_USE_BOTH) {
                 String simCountryIso = mTelephonyManager.getSimCountryIso();
                 if (simCountryIso == null || simCountryIso.length() != 2) {
-                    Log.e(TAG, "Can't get SIM country Iso: trying network country Iso");
+                    Rlog.e(TAG, "Can't get SIM country Iso: trying network country Iso");
                     simCountryIso = mTelephonyManager.getNetworkCountryIso();
                 }
 
@@ -1040,7 +1044,7 @@
             if (rule == PREMIUM_RULE_USE_NETWORK || rule == PREMIUM_RULE_USE_BOTH) {
                 String networkCountryIso = mTelephonyManager.getNetworkCountryIso();
                 if (networkCountryIso == null || networkCountryIso.length() != 2) {
-                    Log.e(TAG, "Can't get Network country Iso: trying SIM country Iso");
+                    Rlog.e(TAG, "Can't get Network country Iso: trying SIM country Iso");
                     networkCountryIso = mTelephonyManager.getSimCountryIso();
                 }
 
@@ -1064,11 +1068,11 @@
 
             switch (premiumSmsPermission) {
                 case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW:
-                    Log.d(TAG, "User approved this app to send to premium SMS");
+                    Rlog.d(TAG, "User approved this app to send to premium SMS");
                     return true;
 
                 case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW:
-                    Log.w(TAG, "User denied this app from sending to premium SMS");
+                    Rlog.w(TAG, "User denied this app from sending to premium SMS");
                     sendMessage(obtainMessage(EVENT_STOP_SENDING, tracker));
                     return false;   // reject this message
 
@@ -1096,9 +1100,11 @@
         if (mPendingTrackerCount >= MO_MSG_QUEUE_LIMIT) {
             // Deny sending message when the queue limit is reached.
             try {
-                tracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
+                if (tracker.mSentIntent != null) {
+                    tracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
+                }
             } catch (CanceledException ex) {
-                Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
+                Rlog.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
             }
             return true;
         }
@@ -1117,7 +1123,7 @@
             ApplicationInfo appInfo = pm.getApplicationInfo(appPackage, 0);
             return appInfo.loadLabel(pm);
         } catch (PackageManager.NameNotFoundException e) {
-            Log.e(TAG, "PackageManager Name Not Found for package " + appPackage);
+            Rlog.e(TAG, "PackageManager Name Not Found for package " + appPackage);
             return appPackage;  // fall back to package name if we can't get app label
         }
     }
@@ -1373,7 +1379,7 @@
             int newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER;
 
             if (which == DialogInterface.BUTTON_POSITIVE) {
-                Log.d(TAG, "CONFIRM sending SMS");
+                Rlog.d(TAG, "CONFIRM sending SMS");
                 // XXX this is lossy- apps can have more than one signature
                 EventLog.writeEvent(EventLogTags.SMS_SENT_BY_USER,
                                     mTracker.mAppInfo.signatures[0].toCharsString());
@@ -1382,7 +1388,7 @@
                     newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW;
                 }
             } else if (which == DialogInterface.BUTTON_NEGATIVE) {
-                Log.d(TAG, "DENY sending SMS");
+                Rlog.d(TAG, "DENY sending SMS");
                 // XXX this is lossy- apps can have more than one signature
                 EventLog.writeEvent(EventLogTags.SMS_DENIED_BY_USER,
                                     mTracker.mAppInfo.signatures[0].toCharsString());
@@ -1396,13 +1402,13 @@
 
         @Override
         public void onCancel(DialogInterface dialog) {
-            Log.d(TAG, "dialog dismissed: don't send SMS");
+            Rlog.d(TAG, "dialog dismissed: don't send SMS");
             sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker));
         }
 
         @Override
         public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-            Log.d(TAG, "remember this choice: " + isChecked);
+            Rlog.d(TAG, "remember this choice: " + isChecked);
             mRememberChoice = isChecked;
             if (isChecked) {
                 mPositiveButton.setText(R.string.sms_short_code_confirm_always_allow);
@@ -1426,15 +1432,20 @@
     private final BroadcastReceiver mResultReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
-            // Assume the intent is one of the SMS receive intents that
-            // was sent as an ordered broadcast.  Check result and ACK.
-            int rc = getResultCode();
-            boolean success = (rc == Activity.RESULT_OK)
-                    || (rc == Intents.RESULT_SMS_HANDLED);
+            if (intent.getAction().equals(Intents.SMS_CB_RECEIVED_ACTION) ||
+                    intent.getAction().equals(Intents.SMS_EMERGENCY_CB_RECEIVED_ACTION)) {
+                // Ignore this intent. Apps will process it.
+            } else {
+                // Assume the intent is one of the SMS receive intents that
+                // was sent as an ordered broadcast. Check result and ACK.
+                int rc = getResultCode();
+                boolean success = (rc == Activity.RESULT_OK)
+                        || (rc == Intents.RESULT_SMS_HANDLED);
 
-            // For a multi-part message, this only ACKs the last part.
-            // Previous parts were ACK'd as they were received.
-            acknowledgeLastIncomingSms(success, rc, null);
+                // For a multi-part message, this only ACKs the last part.
+                // Previous parts were ACK'd as they were received.
+                acknowledgeLastIncomingSms(success, rc, null);
+            }
         }
     };
 
@@ -1442,12 +1453,12 @@
         if (message.isEmergencyMessage()) {
             Intent intent = new Intent(Intents.SMS_EMERGENCY_CB_RECEIVED_ACTION);
             intent.putExtra("message", message);
-            Log.d(TAG, "Dispatching emergency SMS CB");
+            Rlog.d(TAG, "Dispatching emergency SMS CB");
             dispatch(intent, RECEIVE_EMERGENCY_BROADCAST_PERMISSION);
         } else {
             Intent intent = new Intent(Intents.SMS_CB_RECEIVED_ACTION);
             intent.putExtra("message", message);
-            Log.d(TAG, "Dispatching SMS CB");
+            Rlog.d(TAG, "Dispatching SMS CB");
             dispatch(intent, RECEIVE_SMS_PERMISSION);
         }
     }
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index 0fa2ca1..d4710cb 100644
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -33,7 +33,9 @@
 import java.io.PrintWriter;
 import java.util.List;
 
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
 
 /**
@@ -198,6 +200,7 @@
 
     public void dispose() {
         cm.unSetOnSignalStrengthUpdate(this);
+        mUiccController.unregisterForIccChanged(this);
     }
 
     public boolean getDesiredPowerState() {
diff --git a/src/java/com/android/internal/telephony/SmsStorageMonitor.java b/src/java/com/android/internal/telephony/SmsStorageMonitor.java
index 0c06ffc..6a9283f 100644
--- a/src/java/com/android/internal/telephony/SmsStorageMonitor.java
+++ b/src/java/com/android/internal/telephony/SmsStorageMonitor.java
@@ -25,7 +25,7 @@
 import android.os.Message;
 import android.os.PowerManager;
 import android.provider.Telephony.Sms.Intents;
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * Monitors the device and ICC storage, and sends the appropriate events.
@@ -107,7 +107,7 @@
                 ar = (AsyncResult) msg.obj;
                 if (ar.exception != null) {
                     mReportMemoryStatusPending = true;
-                    Log.v(TAG, "Memory status report to modem pending : mStorageAvailable = "
+                    Rlog.v(TAG, "Memory status report to modem pending : mStorageAvailable = "
                             + mStorageAvailable);
                 } else {
                     mReportMemoryStatusPending = false;
@@ -116,7 +116,7 @@
 
             case EVENT_RADIO_ON:
                 if (mReportMemoryStatusPending) {
-                    Log.v(TAG, "Sending pending memory status report : mStorageAvailable = "
+                    Rlog.v(TAG, "Sending pending memory status report : mStorageAvailable = "
                             + mStorageAvailable);
                     mCm.reportSmsMemoryStatus(mStorageAvailable,
                             obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
diff --git a/src/java/com/android/internal/telephony/SmsUsageMonitor.java b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
index c76987e..359069c 100644
--- a/src/java/com/android/internal/telephony/SmsUsageMonitor.java
+++ b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
@@ -31,7 +31,7 @@
 import android.provider.Settings;
 import android.telephony.PhoneNumberUtils;
 import android.util.AtomicFile;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Xml;
 
 import com.android.internal.util.FastXmlSerializer;
@@ -290,9 +290,9 @@
             parser.setInput(patternReader);
             return getPatternMatcherFromXmlParser(parser, country);
         } catch (FileNotFoundException e) {
-            Log.e(TAG, "Short Code Pattern File not found");
+            Rlog.e(TAG, "Short Code Pattern File not found");
         } catch (XmlPullParserException e) {
-            Log.e(TAG, "XML parser exception reading short code pattern file", e);
+            Rlog.e(TAG, "XML parser exception reading short code pattern file", e);
         } finally {
             mPatternFileLastModified = mPatternFile.lastModified();
             if (patternReader != null) {
@@ -324,13 +324,13 @@
                 XmlUtils.nextElement(parser);
                 String element = parser.getName();
                 if (element == null) {
-                    Log.e(TAG, "Parsing pattern data found null");
+                    Rlog.e(TAG, "Parsing pattern data found null");
                     break;
                 }
 
                 if (element.equals(TAG_SHORTCODE)) {
                     String currentCountry = parser.getAttributeValue(null, ATTR_COUNTRY);
-                    if (VDBG) Log.d(TAG, "Found country " + currentCountry);
+                    if (VDBG) Rlog.d(TAG, "Found country " + currentCountry);
                     if (country.equals(currentCountry)) {
                         String pattern = parser.getAttributeValue(null, ATTR_PATTERN);
                         String premium = parser.getAttributeValue(null, ATTR_PREMIUM);
@@ -339,15 +339,15 @@
                         return new ShortCodePatternMatcher(pattern, premium, free, standard);
                     }
                 } else {
-                    Log.e(TAG, "Error: skipping unknown XML tag " + element);
+                    Rlog.e(TAG, "Error: skipping unknown XML tag " + element);
                 }
             }
         } catch (XmlPullParserException e) {
-            Log.e(TAG, "XML parser exception reading short code patterns", e);
+            Rlog.e(TAG, "XML parser exception reading short code patterns", e);
         } catch (IOException e) {
-            Log.e(TAG, "I/O exception reading short code patterns", e);
+            Rlog.e(TAG, "I/O exception reading short code patterns", e);
         }
-        if (DBG) Log.d(TAG, "Country (" + country + ") not found");
+        if (DBG) Rlog.d(TAG, "Country (" + country + ") not found");
         return null;    // country not found
     }
 
@@ -398,12 +398,12 @@
         synchronized (mSettingsObserverHandler) {
             // always allow emergency numbers
             if (PhoneNumberUtils.isEmergencyNumber(destAddress, countryIso)) {
-                if (DBG) Log.d(TAG, "isEmergencyNumber");
+                if (DBG) Rlog.d(TAG, "isEmergencyNumber");
                 return CATEGORY_NOT_SHORT_CODE;
             }
             // always allow if the feature is disabled
             if (!mCheckEnabled.get()) {
-                if (DBG) Log.e(TAG, "check disabled");
+                if (DBG) Rlog.e(TAG, "check disabled");
                 return CATEGORY_NOT_SHORT_CODE;
             }
 
@@ -411,10 +411,10 @@
                 if (mCurrentCountry == null || !countryIso.equals(mCurrentCountry) ||
                         mPatternFile.lastModified() != mPatternFileLastModified) {
                     if (mPatternFile.exists()) {
-                        if (DBG) Log.d(TAG, "Loading SMS Short Code patterns from file");
+                        if (DBG) Rlog.d(TAG, "Loading SMS Short Code patterns from file");
                         mCurrentPatternMatcher = getPatternMatcherFromFile(countryIso);
                     } else {
-                        if (DBG) Log.d(TAG, "Loading SMS Short Code patterns from resource");
+                        if (DBG) Rlog.d(TAG, "Loading SMS Short Code patterns from resource");
                         mCurrentPatternMatcher = getPatternMatcherFromResource(countryIso);
                     }
                     mCurrentCountry = countryIso;
@@ -425,7 +425,7 @@
                 return mCurrentPatternMatcher.getNumberCategory(destAddress);
             } else {
                 // Generic rule: numbers of 5 digits or less are considered potential short codes
-                Log.e(TAG, "No patterns for \"" + countryIso + "\": using generic short code rule");
+                Rlog.e(TAG, "No patterns for \"" + countryIso + "\": using generic short code rule");
                 if (destAddress.length() <= 5) {
                     return CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE;
                 } else {
@@ -465,26 +465,26 @@
                             String packageName = parser.getAttributeValue(null, ATTR_PACKAGE_NAME);
                             String policy = parser.getAttributeValue(null, ATTR_PACKAGE_SMS_POLICY);
                             if (packageName == null) {
-                                Log.e(TAG, "Error: missing package name attribute");
+                                Rlog.e(TAG, "Error: missing package name attribute");
                             } else if (policy == null) {
-                                Log.e(TAG, "Error: missing package policy attribute");
+                                Rlog.e(TAG, "Error: missing package policy attribute");
                             } else try {
                                 mPremiumSmsPolicy.put(packageName, Integer.parseInt(policy));
                             } catch (NumberFormatException e) {
-                                Log.e(TAG, "Error: non-numeric policy type " + policy);
+                                Rlog.e(TAG, "Error: non-numeric policy type " + policy);
                             }
                         } else {
-                            Log.e(TAG, "Error: skipping unknown XML tag " + element);
+                            Rlog.e(TAG, "Error: skipping unknown XML tag " + element);
                         }
                     }
                 } catch (FileNotFoundException e) {
                     // No data yet
                 } catch (IOException e) {
-                    Log.e(TAG, "Unable to read premium SMS policy database", e);
+                    Rlog.e(TAG, "Unable to read premium SMS policy database", e);
                 } catch (NumberFormatException e) {
-                    Log.e(TAG, "Unable to parse premium SMS policy database", e);
+                    Rlog.e(TAG, "Unable to parse premium SMS policy database", e);
                 } catch (XmlPullParserException e) {
-                    Log.e(TAG, "Unable to parse premium SMS policy database", e);
+                    Rlog.e(TAG, "Unable to parse premium SMS policy database", e);
                 } finally {
                     if (infile != null) {
                         try {
@@ -526,7 +526,7 @@
 
                 mPolicyFile.finishWrite(outfile);
             } catch (IOException e) {
-                Log.e(TAG, "Unable to write premium SMS policy database", e);
+                Rlog.e(TAG, "Unable to write premium SMS policy database", e);
                 if (outfile != null) {
                     mPolicyFile.failWrite(outfile);
                 }
@@ -649,6 +649,6 @@
     }
 
     private static void log(String msg) {
-        Log.d(TAG, msg);
+        Rlog.d(TAG, msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/TelephonyCapabilities.java b/src/java/com/android/internal/telephony/TelephonyCapabilities.java
index a9e9376..f374f41 100644
--- a/src/java/com/android/internal/telephony/TelephonyCapabilities.java
+++ b/src/java/com/android/internal/telephony/TelephonyCapabilities.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.Phone;
 
@@ -104,7 +104,7 @@
         } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
             return com.android.internal.R.string.meid;
         } else {
-            Log.w(LOG_TAG, "getDeviceIdLabel: no known label for phone "
+            Rlog.w(LOG_TAG, "getDeviceIdLabel: no known label for phone "
                   + phone.getPhoneName());
             return 0;
         }
diff --git a/src/java/com/android/internal/telephony/WapPushOverSms.java b/src/java/com/android/internal/telephony/WapPushOverSms.java
index e2779dc..ef74e1e 100755
--- a/src/java/com/android/internal/telephony/WapPushOverSms.java
+++ b/src/java/com/android/internal/telephony/WapPushOverSms.java
@@ -24,10 +24,12 @@
 import android.content.ServiceConnection;
 import android.provider.Telephony;
 import android.provider.Telephony.Sms.Intents;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.os.IBinder;
 import android.os.RemoteException;
 
+import com.android.internal.telephony.uicc.IccUtils;
+
 /**
  * WAP push handler class.
  *
@@ -61,13 +63,15 @@
 
         public void onServiceConnected(ComponentName name, IBinder service) {
             mWapPushMan = IWapPushManager.Stub.asInterface(service);
-            if (false) Log.v(LOG_TAG, "wappush manager connected to " +
+            if (false) Rlog.v(LOG_TAG, "wappush manager connected to " +
                     mOwner.hashCode());
         }
 
         public void onServiceDisconnected(ComponentName name) {
             mWapPushMan = null;
-            if (false) Log.v(LOG_TAG, "wappush manager disconnected.");
+            if (false) Rlog.v(LOG_TAG, "wappush manager disconnected.");
+            // Detach the previous binder
+            mOwner.unbindService(mWapConn);
             // WapPushManager must be always attached.
             rebindWapPushManager();
         }
@@ -100,7 +104,7 @@
                         try {
                             Thread.sleep(BIND_RETRY_INTERVAL);
                         } catch (InterruptedException e) {
-                            if (false) Log.v(LOG_TAG, "sleep interrupted.");
+                            if (false) Rlog.v(LOG_TAG, "sleep interrupted.");
                         }
                     }
                 }
@@ -134,7 +138,7 @@
      */
     public int dispatchWapPdu(byte[] pdu) {
 
-        if (false) Log.d(LOG_TAG, "Rx: " + IccUtils.bytesToHexString(pdu));
+        if (false) Rlog.d(LOG_TAG, "Rx: " + IccUtils.bytesToHexString(pdu));
 
         int index = 0;
         int transactionId = pdu[index++] & 0xFF;
@@ -143,7 +147,7 @@
 
         if ((pduType != WspTypeDecoder.PDU_TYPE_PUSH) &&
                 (pduType != WspTypeDecoder.PDU_TYPE_CONFIRMED_PUSH)) {
-            if (false) Log.w(LOG_TAG, "Received non-PUSH WAP PDU. Type = " + pduType);
+            if (false) Rlog.w(LOG_TAG, "Received non-PUSH WAP PDU. Type = " + pduType);
             return Intents.RESULT_SMS_HANDLED;
         }
 
@@ -156,7 +160,7 @@
          * So it will be encoded in no more than 5 octets.
          */
         if (pduDecoder.decodeUintvarInteger(index) == false) {
-            if (false) Log.w(LOG_TAG, "Received PDU. Header Length error.");
+            if (false) Rlog.w(LOG_TAG, "Received PDU. Header Length error.");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
         headerLength = (int)pduDecoder.getValue32();
@@ -177,7 +181,7 @@
          * Length = Uintvar-integer
          */
         if (pduDecoder.decodeContentType(index) == false) {
-            if (false) Log.w(LOG_TAG, "Received PDU. Header Content-Type error.");
+            if (false) Rlog.w(LOG_TAG, "Received PDU. Header Content-Type error.");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
 
@@ -214,14 +218,14 @@
 
             String contentType = ((mimeType == null) ?
                                   Long.toString(binaryContentType) : mimeType);
-            if (false) Log.v(LOG_TAG, "appid found: " + wapAppId + ":" + contentType);
+            if (false) Rlog.v(LOG_TAG, "appid found: " + wapAppId + ":" + contentType);
 
             try {
                 boolean processFurther = true;
                 IWapPushManager wapPushMan = mWapConn.getWapPushManager();
 
                 if (wapPushMan == null) {
-                    if (false) Log.w(LOG_TAG, "wap push manager not found!");
+                    if (false) Rlog.w(LOG_TAG, "wap push manager not found!");
                 } else {
                     Intent intent = new Intent();
                     intent.putExtra("transactionId", transactionId);
@@ -232,7 +236,7 @@
                             pduDecoder.getContentParameters());
 
                     int procRet = wapPushMan.processMessage(wapAppId, contentType, intent);
-                    if (false) Log.v(LOG_TAG, "procRet:" + procRet);
+                    if (false) Rlog.v(LOG_TAG, "procRet:" + procRet);
                     if ((procRet & WapPushManagerParams.MESSAGE_HANDLED) > 0
                         && (procRet & WapPushManagerParams.FURTHER_PROCESSING) == 0) {
                         processFurther = false;
@@ -242,13 +246,13 @@
                     return Intents.RESULT_SMS_HANDLED;
                 }
             } catch (RemoteException e) {
-                if (false) Log.w(LOG_TAG, "remote func failed...");
+                if (false) Rlog.w(LOG_TAG, "remote func failed...");
             }
         }
-        if (false) Log.v(LOG_TAG, "fall back to existing handler");
+        if (false) Rlog.v(LOG_TAG, "fall back to existing handler");
 
         if (mimeType == null) {
-            if (false) Log.w(LOG_TAG, "Header Content-Type error.");
+            if (false) Rlog.w(LOG_TAG, "Header Content-Type error.");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
 
diff --git a/src/java/com/android/internal/telephony/cat/AppInterface.java b/src/java/com/android/internal/telephony/cat/AppInterface.java
index 299e140..01b86ef 100644
--- a/src/java/com/android/internal/telephony/cat/AppInterface.java
+++ b/src/java/com/android/internal/telephony/cat/AppInterface.java
@@ -64,7 +64,8 @@
         OPEN_CHANNEL(0x40),
         CLOSE_CHANNEL(0x41),
         RECEIVE_DATA(0x42),
-        SEND_DATA(0x43);
+        SEND_DATA(0x43),
+        GET_CHANNEL_STATUS(0x44);
 
         private int mValue;
 
diff --git a/src/java/com/android/internal/telephony/cat/BerTlv.java b/src/java/com/android/internal/telephony/cat/BerTlv.java
index 095e65b..c264c11 100644
--- a/src/java/com/android/internal/telephony/cat/BerTlv.java
+++ b/src/java/com/android/internal/telephony/cat/BerTlv.java
@@ -28,15 +28,17 @@
 class BerTlv {
     private int mTag = BER_UNKNOWN_TAG;
     private List<ComprehensionTlv> mCompTlvs = null;
+    private boolean mLengthValid = true;
 
     public static final int BER_UNKNOWN_TAG             = 0x00;
     public static final int BER_PROACTIVE_COMMAND_TAG   = 0xd0;
     public static final int BER_MENU_SELECTION_TAG      = 0xd3;
     public static final int BER_EVENT_DOWNLOAD_TAG      = 0xd6;
 
-    private BerTlv(int tag, List<ComprehensionTlv> ctlvs) {
+    private BerTlv(int tag, List<ComprehensionTlv> ctlvs, boolean lengthValid) {
         mTag = tag;
         mCompTlvs = ctlvs;
+        mLengthValid = lengthValid;
     }
 
     /**
@@ -58,6 +60,15 @@
     }
 
     /**
+     * Gets if the length of the BER-TLV object is valid
+     *
+     * @return if length valid
+     */
+     public boolean isLengthValid() {
+         return mLengthValid;
+     }
+
+    /**
      * Decodes a BER-TLV object from a byte array.
      *
      * @param data A byte array to decode from
@@ -68,6 +79,7 @@
         int curIndex = 0;
         int endIndex = data.length;
         int tag, length = 0;
+        boolean isLengthValid = true;
 
         try {
             /* tag */
@@ -118,6 +130,32 @@
         List<ComprehensionTlv> ctlvs = ComprehensionTlv.decodeMany(data,
                 curIndex);
 
-        return new BerTlv(tag, ctlvs);
+        if (tag == BER_PROACTIVE_COMMAND_TAG) {
+            int totalLength = 0;
+            for (ComprehensionTlv item : ctlvs) {
+                int itemLength = item.getLength();
+                if (itemLength >= 0x80 && itemLength <= 0xFF) {
+                    totalLength += itemLength + 3; //3: 'tag'(1 byte) and 'length'(2 bytes).
+                } else if (itemLength >= 0 && itemLength < 0x80) {
+                    totalLength += itemLength + 2; //2: 'tag'(1 byte) and 'length'(1 byte).
+                } else {
+                    isLengthValid = false;
+                    break;
+                }
+            }
+
+            // According to 3gpp11.14, chapter 6.10.6 "Length errors",
+
+            // If the total lengths of the SIMPLE-TLV data objects are not
+            // consistent with the length given in the BER-TLV data object,
+            // then the whole BER-TLV data object shall be rejected. The
+            // result field in the TERMINAL RESPONSE shall have the error
+            // condition "Command data not understood by ME".
+            if (length != totalLength) {
+                isLengthValid = false;
+            }
+        }
+
+        return new BerTlv(tag, ctlvs, isLengthValid);
     }
 }
diff --git a/src/java/com/android/internal/telephony/cat/CatCmdMessage.java b/src/java/com/android/internal/telephony/cat/CatCmdMessage.java
index 48c2e2b..9284d03 100644
--- a/src/java/com/android/internal/telephony/cat/CatCmdMessage.java
+++ b/src/java/com/android/internal/telephony/cat/CatCmdMessage.java
@@ -80,6 +80,9 @@
             mToneSettings = params.settings;
             mTextMsg = params.textMsg;
             break;
+        case GET_CHANNEL_STATUS:
+            mTextMsg = ((CallSetupParams) cmdParams).confirmMsg;
+            break;
         case SET_UP_CALL:
             mCallSettings = new CallSettings();
             mCallSettings.confirmMsg = ((CallSetupParams) cmdParams).confirmMsg;
diff --git a/src/java/com/android/internal/telephony/cat/CatLog.java b/src/java/com/android/internal/telephony/cat/CatLog.java
index e19ff43..b2e641c 100644
--- a/src/java/com/android/internal/telephony/cat/CatLog.java
+++ b/src/java/com/android/internal/telephony/cat/CatLog.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony.cat;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 public abstract class CatLog {
     static final boolean DEBUG = true;
@@ -27,7 +27,7 @@
         }
 
         String className = caller.getClass().getName();
-        Log.d("CAT", className.substring(className.lastIndexOf('.') + 1) + ": "
+        Rlog.d("CAT", className.substring(className.lastIndexOf('.') + 1) + ": "
                 + msg);
     }
 
@@ -36,6 +36,6 @@
             return;
         }
 
-        Log.d("CAT", caller + ": " + msg);
+        Rlog.d("CAT", caller + ": " + msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/cat/CatResponseMessage.java b/src/java/com/android/internal/telephony/cat/CatResponseMessage.java
index cfcac36..15309e4 100644
--- a/src/java/com/android/internal/telephony/cat/CatResponseMessage.java
+++ b/src/java/com/android/internal/telephony/cat/CatResponseMessage.java
@@ -23,7 +23,8 @@
         String usersInput  = null;
         boolean usersYesNoSelection = false;
         boolean usersConfirm = false;
-
+        boolean includeAdditionalInfo = false;
+        int additionalInfo = 0;
         public CatResponseMessage(CatCmdMessage cmdMsg) {
             this.cmdDet = cmdMsg.mCmdDet;
         }
@@ -48,7 +49,12 @@
             usersConfirm = confirm;
         }
 
+        public void setAdditionalInfo(int info) {
+            this.includeAdditionalInfo = true;
+            this.additionalInfo = info;
+        }
+
         CommandDetails getCmdDetails() {
             return cmdDet;
         }
-    }
\ No newline at end of file
+    }
diff --git a/src/java/com/android/internal/telephony/cat/CatService.java b/src/java/com/android/internal/telephony/cat/CatService.java
index f327d31..f84fba2 100644
--- a/src/java/com/android/internal/telephony/cat/CatService.java
+++ b/src/java/com/android/internal/telephony/cat/CatService.java
@@ -26,12 +26,12 @@
 import android.os.Message;
 import android.os.SystemProperties;
 
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccRecords;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.IccUtils;
+import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 
 
 import java.io.ByteArrayOutputStream;
@@ -704,6 +704,7 @@
         ResponseData resp = null;
         boolean helpRequired = false;
         CommandDetails cmdDet = resMsg.getCmdDetails();
+        AppInterface.CommandType type = AppInterface.CommandType.fromInt(cmdDet.typeOfCommand);
 
         switch (resMsg.resCode) {
         case HELP_INFO_REQUIRED:
@@ -719,7 +720,8 @@
         case PRFRMD_WITH_MODIFICATION:
         case PRFRMD_NAA_NOT_ACTIVE:
         case PRFRMD_TONE_NOT_PLAYED:
-            switch (AppInterface.CommandType.fromInt(cmdDet.typeOfCommand)) {
+        case TERMINAL_CRNTLY_UNABLE_TO_PROCESS:
+            switch (type) {
             case SET_UP_MENU:
                 helpRequired = resMsg.resCode == ResultCode.HELP_INFO_REQUIRED;
                 sendMenuSelection(resMsg.usersMenuSelection, helpRequired);
@@ -754,16 +756,29 @@
                 return;
             }
             break;
-        case NO_RESPONSE_FROM_USER:
-        case UICC_SESSION_TERM_BY_USER:
         case BACKWARD_MOVE_BY_USER:
         case USER_NOT_ACCEPT:
+            // if the user dismissed the alert dialog for a
+            // setup call/open channel, consider that as the user
+            // rejecting the call. Use dedicated API for this, rather than
+            // sending a terminal response.
+            if (type == CommandType.SET_UP_CALL || type == CommandType.OPEN_CHANNEL) {
+                mCmdIf.handleCallSetupRequestFromSim(false, null);
+                mCurrntCmd = null;
+                return;
+            } else {
+                resp = null;
+            }
+            break;
+        case NO_RESPONSE_FROM_USER:
+        case UICC_SESSION_TERM_BY_USER:
             resp = null;
             break;
         default:
             return;
         }
-        sendTerminalResponse(cmdDet, resMsg.resCode, false, 0, resp);
+        sendTerminalResponse(cmdDet, resMsg.resCode, resMsg.includeAdditionalInfo,
+                resMsg.additionalInfo, resp);
         mCurrntCmd = null;
     }
 
diff --git a/src/java/com/android/internal/telephony/cat/CommandParamsFactory.java b/src/java/com/android/internal/telephony/cat/CommandParamsFactory.java
index 9de8399..6e3b19f 100644
--- a/src/java/com/android/internal/telephony/cat/CommandParamsFactory.java
+++ b/src/java/com/android/internal/telephony/cat/CommandParamsFactory.java
@@ -21,7 +21,7 @@
 import android.os.Message;
 
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccFileHandler;
+import com.android.internal.telephony.uicc.IccFileHandler;
 
 import java.util.Iterator;
 import java.util.List;
@@ -124,6 +124,13 @@
             return;
         }
 
+        // proactive command length is incorrect.
+        if (!berTlv.isLengthValid()) {
+            mCmdParams = new CommandParams(cmdDet);
+            sendCmdParams(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
+            return;
+        }
+
         try {
             switch (cmdType) {
             case SET_UP_MENU:
@@ -150,6 +157,7 @@
              case SEND_USSD:
                  cmdPending = processEventNotify(cmdDet, ctlvs);
                  break;
+             case GET_CHANNEL_STATUS:
              case SET_UP_CALL:
                  cmdPending = processSetupCall(cmdDet, ctlvs);
                  break;
diff --git a/src/java/com/android/internal/telephony/cat/ComprehensionTlv.java b/src/java/com/android/internal/telephony/cat/ComprehensionTlv.java
index 22cd5a4..e2522a4 100644
--- a/src/java/com/android/internal/telephony/cat/ComprehensionTlv.java
+++ b/src/java/com/android/internal/telephony/cat/ComprehensionTlv.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony.cat;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -125,7 +125,7 @@
             case 0:
             case 0xff:
             case 0x80:
-                Log.d("CAT     ", "decode: unexpected first tag byte=" + Integer.toHexString(temp) +
+                Rlog.d("CAT     ", "decode: unexpected first tag byte=" + Integer.toHexString(temp) +
                         ", startIndex=" + startIndex + " curIndex=" + curIndex +
                         " endIndex=" + endIndex);
                 // Return null which will stop decoding, this has occurred
diff --git a/src/java/com/android/internal/telephony/cat/IconLoader.java b/src/java/com/android/internal/telephony/cat/IconLoader.java
index 2fa1811..c339f5e 100644
--- a/src/java/com/android/internal/telephony/cat/IconLoader.java
+++ b/src/java/com/android/internal/telephony/cat/IconLoader.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony.cat;
 
-import com.android.internal.telephony.IccFileHandler;
+import com.android.internal.telephony.uicc.IccFileHandler;
 
 import android.graphics.Bitmap;
 import android.graphics.Color;
@@ -25,7 +25,7 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.HashMap;
 
diff --git a/src/java/com/android/internal/telephony/cat/RilMessageDecoder.java b/src/java/com/android/internal/telephony/cat/RilMessageDecoder.java
index fb33a8e..d75c63d 100644
--- a/src/java/com/android/internal/telephony/cat/RilMessageDecoder.java
+++ b/src/java/com/android/internal/telephony/cat/RilMessageDecoder.java
@@ -16,8 +16,8 @@
 
 package com.android.internal.telephony.cat;
 
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccUtils;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import android.os.Handler;
 import com.android.internal.util.State;
diff --git a/src/java/com/android/internal/telephony/cat/ValueParser.java b/src/java/com/android/internal/telephony/cat/ValueParser.java
index 584d96c..5b1ae91 100644
--- a/src/java/com/android/internal/telephony/cat/ValueParser.java
+++ b/src/java/com/android/internal/telephony/cat/ValueParser.java
@@ -17,8 +17,8 @@
 package com.android.internal.telephony.cat;
 
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.cat.Duration.TimeUnit;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
diff --git a/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java b/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
index cc59b67..632a24c 100644
--- a/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
+++ b/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
@@ -25,7 +25,7 @@
 import android.os.Message;
 import android.preference.PreferenceManager;
 import android.provider.Telephony;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.OperatorInfo;
@@ -34,12 +34,12 @@
 import com.android.internal.telephony.PhoneNotifier;
 import com.android.internal.telephony.PhoneProxy;
 import com.android.internal.telephony.SMSDispatcher;
-import com.android.internal.telephony.UiccCardApplication;
 import com.android.internal.telephony.gsm.GsmSMSDispatcher;
-import com.android.internal.telephony.gsm.SIMRecords;
 import com.android.internal.telephony.gsm.SmsMessage;
-import com.android.internal.telephony.ims.IsimRecords;
-import com.android.internal.telephony.ims.IsimUiccRecords;
+import com.android.internal.telephony.uicc.IsimRecords;
+import com.android.internal.telephony.uicc.IsimUiccRecords;
+import com.android.internal.telephony.uicc.SIMRecords;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
 
 import java.io.FileDescriptor;
@@ -177,7 +177,7 @@
         // look for our wrapper within the asyncresult, skip the rest if it
         // is null.
         if (!(ar.userObj instanceof NetworkSelectMessage)) {
-            Log.e(LOG_TAG, "unexpected result from user object.");
+            Rlog.e(LOG_TAG, "unexpected result from user object.");
             return;
         }
 
@@ -200,7 +200,7 @@
 
         // commit and log the result.
         if (! editor.commit()) {
-            Log.e(LOG_TAG, "failed to commit network selection preference");
+            Rlog.e(LOG_TAG, "failed to commit network selection preference");
         }
 
     }
@@ -218,7 +218,7 @@
                 mContext.getContentResolver().insert(uri, map);
                 return true;
             } catch (SQLException e) {
-                Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
+                Rlog.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
             }
         } else {
             if (DBG) log("updateCurrentCarrierInProvider mIccRecords == null ret false");
@@ -302,7 +302,7 @@
 
     @Override
     protected void log(String s) {
-            Log.d(LOG_TAG, "[CDMALTEPhone] " + s);
+            Rlog.d(LOG_TAG, "[CDMALTEPhone] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
index c43888b..1465a17 100755
--- a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -39,7 +39,7 @@
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
@@ -48,10 +48,7 @@
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccException;
-import com.android.internal.telephony.IccFileHandler;
 import com.android.internal.telephony.IccPhoneBookInterfaceManager;
-import com.android.internal.telephony.IccRecords;
 import com.android.internal.telephony.IccSmsInterfaceManager;
 import com.android.internal.telephony.MccTable;
 import com.android.internal.telephony.MmiCode;
@@ -65,12 +62,16 @@
 import com.android.internal.telephony.ServiceStateTracker;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.TelephonyProperties;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
 import com.android.internal.telephony.UUSInfo;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.cat.CatService;
+import com.android.internal.telephony.uicc.IccException;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.RuimRecords;
+import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -265,9 +266,9 @@
 
     @Override
     protected void finalize() {
-        if(DBG) Log.d(LOG_TAG, "CDMAPhone finalized");
+        if(DBG) Rlog.d(LOG_TAG, "CDMAPhone finalized");
         if (mWakeLock.isHeld()) {
-            Log.e(LOG_TAG, "UNEXPECTED; mWakeLock is held when finalizing.");
+            Rlog.e(LOG_TAG, "UNEXPECTED; mWakeLock is held when finalizing.");
             mWakeLock.release();
         }
     }
@@ -297,7 +298,7 @@
     }
 
     public boolean canTransfer() {
-        Log.e(LOG_TAG, "canTransfer: not possible in CDMA");
+        Rlog.e(LOG_TAG, "canTransfer: not possible in CDMA");
         return false;
     }
 
@@ -315,7 +316,7 @@
 
     public void conference() throws CallStateException {
         // three way calls in CDMA will be handled by feature codes
-        Log.e(LOG_TAG, "conference: not possible in CDMA");
+        Rlog.e(LOG_TAG, "conference: not possible in CDMA");
     }
 
     public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) {
@@ -379,7 +380,7 @@
 
     public void registerForSuppServiceNotification(
             Handler h, int what, Object obj) {
-        Log.e(LOG_TAG, "method registerForSuppServiceNotification is NOT supported in CDMA!");
+        Rlog.e(LOG_TAG, "method registerForSuppServiceNotification is NOT supported in CDMA!");
     }
 
     public CdmaCall getBackgroundCall() {
@@ -387,7 +388,7 @@
     }
 
     public boolean handleInCallMmiCommands(String dialString) {
-        Log.e(LOG_TAG, "method handleInCallMmiCommands is NOT supported in CDMA!");
+        Rlog.e(LOG_TAG, "method handleInCallMmiCommands is NOT supported in CDMA!");
         return false;
     }
 
@@ -402,11 +403,11 @@
 
     public void
     setNetworkSelectionModeAutomatic(Message response) {
-        Log.e(LOG_TAG, "method setNetworkSelectionModeAutomatic is NOT supported in CDMA!");
+        Rlog.e(LOG_TAG, "method setNetworkSelectionModeAutomatic is NOT supported in CDMA!");
     }
 
     public void unregisterForSuppServiceNotification(Handler h) {
-        Log.e(LOG_TAG, "method unregisterForSuppServiceNotification is NOT supported in CDMA!");
+        Rlog.e(LOG_TAG, "method unregisterForSuppServiceNotification is NOT supported in CDMA!");
     }
 
     public void
@@ -461,14 +462,14 @@
     public String getDeviceId() {
         String id = getMeid();
         if ((id == null) || id.matches("^0*$")) {
-            Log.d(LOG_TAG, "getDeviceId(): MEID is not initialized use ESN");
+            Rlog.d(LOG_TAG, "getDeviceId(): MEID is not initialized use ESN");
             id = getEsn();
         }
         return id;
     }
 
     public String getDeviceSvn() {
-        Log.d(LOG_TAG, "getDeviceSvn(): return 0");
+        Rlog.d(LOG_TAG, "getDeviceSvn(): return 0");
         return "0";
     }
 
@@ -477,12 +478,12 @@
     }
 
     public String getImei() {
-        Log.e(LOG_TAG, "IMEI is not available in CDMA");
+        Rlog.e(LOG_TAG, "IMEI is not available in CDMA");
         return null;
     }
 
     public boolean canConference() {
-        Log.e(LOG_TAG, "canConference: not possible in CDMA");
+        Rlog.e(LOG_TAG, "canConference: not possible in CDMA");
         return false;
     }
 
@@ -497,7 +498,7 @@
     public void
     selectNetworkManually(OperatorInfo network,
             Message response) {
-        Log.e(LOG_TAG, "selectNetworkManually: not possible in CDMA");
+        Rlog.e(LOG_TAG, "selectNetworkManually: not possible in CDMA");
     }
 
     public void setOnPostDialCharacter(Handler h, int what, Object obj) {
@@ -508,7 +509,7 @@
         CdmaMmiCode mmi = CdmaMmiCode.newFromDialString(dialString, this);
 
         if (mmi == null) {
-            Log.e(LOG_TAG, "Mmi is NULL!");
+            Rlog.e(LOG_TAG, "Mmi is NULL!");
             return false;
         } else if (mmi.isPukCommand()) {
             mPendingMmis.add(mmi);
@@ -516,7 +517,7 @@
             mmi.processCode();
             return true;
         }
-        Log.e(LOG_TAG, "Unrecognized mmi!");
+        Rlog.e(LOG_TAG, "Unrecognized mmi!");
         return false;
     }
 
@@ -537,11 +538,11 @@
     }
 
     public void setLine1Number(String alphaTag, String number, Message onComplete) {
-        Log.e(LOG_TAG, "setLine1Number: not possible in CDMA");
+        Rlog.e(LOG_TAG, "setLine1Number: not possible in CDMA");
     }
 
     public void setCallWaiting(boolean enable, Message onComplete) {
-        Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
+        Rlog.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
     }
 
     public void updateServiceLocation() {
@@ -647,12 +648,12 @@
     }
 
     public void sendUssdResponse(String ussdMessge) {
-        Log.e(LOG_TAG, "sendUssdResponse: not possible in CDMA");
+        Rlog.e(LOG_TAG, "sendUssdResponse: not possible in CDMA");
     }
 
     public void sendDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                     "sendDtmf called with invalid character '" + c + "'");
         } else {
             if (mCT.state ==  PhoneConstants.State.OFFHOOK) {
@@ -663,7 +664,7 @@
 
     public void startDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                     "startDtmf called with invalid character '" + c + "'");
         } else {
             mCM.startDtmf(c, null);
@@ -678,7 +679,7 @@
         boolean check = true;
         for (int itr = 0;itr < dtmfString.length(); itr++) {
             if (!PhoneNumberUtils.is12Key(dtmfString.charAt(itr))) {
-                Log.e(LOG_TAG,
+                Rlog.e(LOG_TAG,
                         "sendDtmf called with invalid character '" + dtmfString.charAt(itr)+ "'");
                 check = false;
                 break;
@@ -690,11 +691,11 @@
      }
 
     public void getAvailableNetworks(Message response) {
-        Log.e(LOG_TAG, "getAvailableNetworks: not possible in CDMA");
+        Rlog.e(LOG_TAG, "getAvailableNetworks: not possible in CDMA");
     }
 
     public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) {
-        Log.e(LOG_TAG, "setOutgoingCallerIdDisplay: not possible in CDMA");
+        Rlog.e(LOG_TAG, "setOutgoingCallerIdDisplay: not possible in CDMA");
     }
 
     public void enableLocationUpdates() {
@@ -771,7 +772,7 @@
     }
 
     public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
-        Log.e(LOG_TAG, "getCallForwardingOption: not possible in CDMA");
+        Rlog.e(LOG_TAG, "getCallForwardingOption: not possible in CDMA");
     }
 
     public void setCallForwardingOption(int commandInterfaceCFAction,
@@ -779,26 +780,26 @@
             String dialingNumber,
             int timerSeconds,
             Message onComplete) {
-        Log.e(LOG_TAG, "setCallForwardingOption: not possible in CDMA");
+        Rlog.e(LOG_TAG, "setCallForwardingOption: not possible in CDMA");
     }
 
     public void
     getOutgoingCallerIdDisplay(Message onComplete) {
-        Log.e(LOG_TAG, "getOutgoingCallerIdDisplay: not possible in CDMA");
+        Rlog.e(LOG_TAG, "getOutgoingCallerIdDisplay: not possible in CDMA");
     }
 
     public boolean
     getCallForwardingIndicator() {
-        Log.e(LOG_TAG, "getCallForwardingIndicator: not possible in CDMA");
+        Rlog.e(LOG_TAG, "getCallForwardingIndicator: not possible in CDMA");
         return false;
     }
 
     public void explicitCallTransfer() {
-        Log.e(LOG_TAG, "explicitCallTransfer: not possible in CDMA");
+        Rlog.e(LOG_TAG, "explicitCallTransfer: not possible in CDMA");
     }
 
     public String getLine1AlphaTag() {
-        Log.e(LOG_TAG, "getLine1AlphaTag: not possible in CDMA");
+        Rlog.e(LOG_TAG, "getLine1AlphaTag: not possible in CDMA");
         return null;
     }
 
@@ -852,7 +853,7 @@
         Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
         intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, mIsPhoneInEcmState);
         ActivityManagerNative.broadcastStickyIntent(intent,null,UserHandle.USER_ALL);
-        if (DBG) Log.d(LOG_TAG, "sendEmergencyCallbackModeChange");
+        if (DBG) Rlog.d(LOG_TAG, "sendEmergencyCallbackModeChange");
     }
 
     @Override
@@ -866,7 +867,7 @@
 
     private void handleEnterEmergencyCallbackMode(Message msg) {
         if (DBG) {
-            Log.d(LOG_TAG, "handleEnterEmergencyCallbackMode,mIsPhoneInEcmState= "
+            Rlog.d(LOG_TAG, "handleEnterEmergencyCallbackMode,mIsPhoneInEcmState= "
                     + mIsPhoneInEcmState);
         }
         // if phone is not in Ecm mode, and it's changed to Ecm mode
@@ -889,7 +890,7 @@
     private void handleExitEmergencyCallbackMode(Message msg) {
         AsyncResult ar = (AsyncResult)msg.obj;
         if (DBG) {
-            Log.d(LOG_TAG, "handleExitEmergencyCallbackMode,ar.exception , mIsPhoneInEcmState "
+            Rlog.d(LOG_TAG, "handleExitEmergencyCallbackMode,ar.exception , mIsPhoneInEcmState "
                     + ar.exception + mIsPhoneInEcmState);
         }
         // Remove pending exit Ecm runnable, if any
@@ -929,7 +930,7 @@
             mEcmTimerResetRegistrants.notifyResult(Boolean.FALSE);
             break;
         default:
-            Log.e(LOG_TAG, "handleTimerInEmergencyCallbackMode, unsupported action " + action);
+            Rlog.e(LOG_TAG, "handleTimerInEmergencyCallbackMode, unsupported action " + action);
         }
     }
 
@@ -967,7 +968,7 @@
                     break;
                 }
 
-                if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result);
+                if (DBG) Rlog.d(LOG_TAG, "Baseband version: " + ar.result);
                 setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result);
             }
             break;
@@ -1002,40 +1003,40 @@
             break;
 
             case EVENT_RUIM_RECORDS_LOADED:{
-                Log.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received");
+                Rlog.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received");
                 updateCurrentCarrierInProvider();
             }
             break;
 
             case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:{
-                Log.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received");
+                Rlog.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received");
             }
             break;
 
             case EVENT_RADIO_ON:{
-                Log.d(LOG_TAG, "Event EVENT_RADIO_ON Received");
+                Rlog.d(LOG_TAG, "Event EVENT_RADIO_ON Received");
                 handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource());
             }
             break;
 
             case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:{
-                Log.d(LOG_TAG, "EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED");
+                Rlog.d(LOG_TAG, "EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED");
                 handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource());
             }
             break;
 
             case EVENT_SSN:{
-                Log.d(LOG_TAG, "Event EVENT_SSN Received");
+                Rlog.d(LOG_TAG, "Event EVENT_SSN Received");
             }
             break;
 
             case EVENT_REGISTERED_TO_NETWORK:{
-                Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received");
+                Rlog.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received");
             }
             break;
 
             case EVENT_NV_READY:{
-                Log.d(LOG_TAG, "Event EVENT_NV_READY Received");
+                Rlog.d(LOG_TAG, "Event EVENT_NV_READY Received");
                 prepareEri();
             }
             break;
@@ -1097,7 +1098,7 @@
                 break;
 
             default:
-                Log.e(LOG_TAG,"Unknown icc records event code " + eventCode);
+                Rlog.e(LOG_TAG,"Unknown icc records event code " + eventCode);
                 break;
         }
     }
@@ -1162,7 +1163,7 @@
      * @param response Callback message is empty on completion
      */
     public void activateCellBroadcastSms(int activate, Message response) {
-        Log.e(LOG_TAG, "[CDMAPhone] activateCellBroadcastSms() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[CDMAPhone] activateCellBroadcastSms() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1172,7 +1173,7 @@
      * @param response Callback message is empty on completion
      */
     public void getCellBroadcastSmsConfig(Message response) {
-        Log.e(LOG_TAG, "[CDMAPhone] getCellBroadcastSmsConfig() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[CDMAPhone] getCellBroadcastSmsConfig() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1182,7 +1183,7 @@
      * @param response Callback message is empty on completion
      */
     public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response) {
-        Log.e(LOG_TAG, "[CDMAPhone] setCellBroadcastSmsConfig() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[CDMAPhone] setCellBroadcastSmsConfig() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1254,7 +1255,7 @@
                                 dialStr.substring (IS683A_FEATURE_CODE_NUM_DIGITS,
                                 IS683A_FEATURE_CODE_NUM_DIGITS + IS683A_SYS_SEL_CODE_NUM_DIGITS));
         }
-        if (DBG) Log.d(LOG_TAG, "extractSelCodeFromOtaSpNum " + sysSelCodeInt);
+        if (DBG) Rlog.d(LOG_TAG, "extractSelCodeFromOtaSpNum " + sysSelCodeInt);
         return sysSelCodeInt;
     }
 
@@ -1284,7 +1285,7 @@
         } catch (NumberFormatException ex) {
             // If the carrier ota sp number schema is not correct, we still allow dial
             // and only log the error:
-            Log.e(LOG_TAG, "checkOtaSpNumBasedOnSysSelCode, error", ex);
+            Rlog.e(LOG_TAG, "checkOtaSpNumBasedOnSysSelCode, error", ex);
         }
         return isOtaSpNum;
     }
@@ -1321,7 +1322,7 @@
         if (!TextUtils.isEmpty(mCarrierOtaSpNumSchema)) {
             Matcher m = pOtaSpNumSchema.matcher(mCarrierOtaSpNumSchema);
             if (DBG) {
-                Log.d(LOG_TAG, "isCarrierOtaSpNum,schema" + mCarrierOtaSpNumSchema);
+                Rlog.d(LOG_TAG, "isCarrierOtaSpNum,schema" + mCarrierOtaSpNumSchema);
             }
 
             if (m.find()) {
@@ -1332,7 +1333,7 @@
                         isOtaSpNum=checkOtaSpNumBasedOnSysSelCode(sysSelCodeInt,sch);
                     } else {
                         if (DBG) {
-                            Log.d(LOG_TAG, "isCarrierOtaSpNum,sysSelCodeInt is invalid");
+                            Rlog.d(LOG_TAG, "isCarrierOtaSpNum,sysSelCodeInt is invalid");
                         }
                     }
                 } else if (!TextUtils.isEmpty(sch[0]) && sch[0].equals("FC")) {
@@ -1341,21 +1342,21 @@
                     if (dialStr.regionMatches(0,fc,0,fcLen)) {
                         isOtaSpNum = true;
                     } else {
-                        if (DBG) Log.d(LOG_TAG, "isCarrierOtaSpNum,not otasp number");
+                        if (DBG) Rlog.d(LOG_TAG, "isCarrierOtaSpNum,not otasp number");
                     }
                 } else {
                     if (DBG) {
-                        Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema not supported" + sch[0]);
+                        Rlog.d(LOG_TAG, "isCarrierOtaSpNum,ota schema not supported" + sch[0]);
                     }
                 }
             } else {
                 if (DBG) {
-                    Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern not right" +
+                    Rlog.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern not right" +
                           mCarrierOtaSpNumSchema);
                 }
             }
         } else {
-            if (DBG) Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern empty");
+            if (DBG) Rlog.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern empty");
         }
         return isOtaSpNum;
     }
@@ -1377,7 +1378,7 @@
                 isOtaSpNum = isCarrierOtaSpNum(dialableStr);
             }
         }
-        if (DBG) Log.d(LOG_TAG, "isOtaSpNumber " + isOtaSpNum);
+        if (DBG) Rlog.d(LOG_TAG, "isOtaSpNumber " + isOtaSpNum);
         return isOtaSpNum;
     }
 
@@ -1430,9 +1431,9 @@
                 iso = MccTable.countryCodeForMcc(Integer.parseInt(
                         operatorNumeric.substring(0,3)));
             } catch (NumberFormatException ex) {
-                Log.w(LOG_TAG, "countryCodeForMcc error" + ex);
+                Rlog.w(LOG_TAG, "countryCodeForMcc error" + ex);
             } catch (StringIndexOutOfBoundsException ex) {
-                Log.w(LOG_TAG, "countryCodeForMcc error" + ex);
+                Rlog.w(LOG_TAG, "countryCodeForMcc error" + ex);
             }
 
             setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso);
@@ -1459,7 +1460,7 @@
 
                 return true;
             } catch (SQLException e) {
-                Log.e(LOG_TAG, "Can't store current operator", e);
+                Rlog.e(LOG_TAG, "Can't store current operator", e);
             }
         }
         return false;
@@ -1508,7 +1509,7 @@
 
     protected void log(String s) {
         if (DBG)
-            Log.d(LOG_TAG, "[CDMAPhone] " + s);
+            Rlog.d(LOG_TAG, "[CDMAPhone] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
index a7d5d0a..8ec5633 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
@@ -23,7 +23,7 @@
 import android.os.RegistrantList;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.os.SystemProperties;
 
 import com.android.internal.telephony.CallStateException;
@@ -112,14 +112,14 @@
             try {
                 if(c != null) hangup(c);
             } catch (CallStateException ex) {
-                Log.e(LOG_TAG, "unexpected error on hangup during dispose");
+                Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
             }
         }
 
         try {
             if(pendingMO != null) hangup(pendingMO);
         } catch (CallStateException ex) {
-            Log.e(LOG_TAG, "unexpected error on hangup during dispose");
+            Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
         }
 
         clearDisconnected();
@@ -128,7 +128,7 @@
 
     @Override
     protected void finalize() {
-        Log.d(LOG_TAG, "CdmaCallTracker finalized");
+        Rlog.d(LOG_TAG, "CdmaCallTracker finalized");
     }
 
     //***** Instance Methods
@@ -274,7 +274,7 @@
     void
     acceptCall() throws CallStateException {
         if (ringingCall.getState() == CdmaCall.State.INCOMING) {
-            Log.i("phone", "acceptCall: incoming...");
+            Rlog.i("phone", "acceptCall: incoming...");
             // Always unmute when answering a new call
             setMute(false);
             cm.acceptCall(obtainCompleteMessage());
@@ -386,7 +386,7 @@
 
     boolean
     canTransfer() {
-        Log.e(LOG_TAG, "canTransfer: not possible in CDMA");
+        Rlog.e(LOG_TAG, "canTransfer: not possible in CDMA");
         return false;
     }
 
@@ -436,7 +436,7 @@
             cm.getCurrentCalls(lastRelevantPoll);
         } else if (pendingOperations < 0) {
             // this should never happen
-            Log.e(LOG_TAG,"CdmaCallTracker.pendingOperations < 0");
+            Rlog.e(LOG_TAG,"CdmaCallTracker.pendingOperations < 0");
             pendingOperations = 0;
         }
     }
@@ -540,7 +540,7 @@
                                     "poll: hangupPendingMO, hangup conn " + i);
                             hangup(connections[i]);
                         } catch (CallStateException ex) {
-                            Log.e(LOG_TAG, "unexpected error on hangup");
+                            Rlog.e(LOG_TAG, "unexpected error on hangup");
                         }
 
                         // Do not continue processing this poll
@@ -608,7 +608,7 @@
                         // We should follow the rule of MT calls taking precedence over MO calls
                         // when there is conflict, so here we drop the call info from dc and
                         // continue to use the call info from conn, and only take a log.
-                        Log.e(LOG_TAG,"Error in RIL, Phantom call appeared " + dc);
+                        Rlog.e(LOG_TAG,"Error in RIL, Phantom call appeared " + dc);
                     }
                 } else {
                     boolean changed;
@@ -641,7 +641,7 @@
         // We expect the pending call to appear in the list
         // If it does not, we land here
         if (pendingMO != null) {
-            Log.d(LOG_TAG,"Pending MO dropped before poll fg state:"
+            Rlog.d(LOG_TAG,"Pending MO dropped before poll fg state:"
                             + foregroundCall.getState());
 
             droppedDuringPoll.add(pendingMO);
@@ -756,7 +756,7 @@
             } catch (CallStateException ex) {
                 // Ignore "connection not found"
                 // Call may have hung up already
-                Log.w(LOG_TAG,"CdmaCallTracker WARN: hangup() on absent connection "
+                Rlog.w(LOG_TAG,"CdmaCallTracker WARN: hangup() on absent connection "
                                 + conn);
             }
         }
@@ -776,7 +776,7 @@
         } catch (CallStateException ex) {
             // Ignore "connection not found"
             // Call may have hung up already
-            Log.w(LOG_TAG,"CdmaCallTracker WARN: separate() on absent connection "
+            Rlog.w(LOG_TAG,"CdmaCallTracker WARN: separate() on absent connection "
                           + conn);
         }
     }
@@ -867,7 +867,7 @@
                 cm.hangupConnection(cn.getCDMAIndex(), obtainCompleteMessage());
             }
         } catch (CallStateException ex) {
-            Log.e(LOG_TAG, "hangupConnectionByIndex caught " + ex);
+            Rlog.e(LOG_TAG, "hangupConnectionByIndex caught " + ex);
         }
     }
 
@@ -949,7 +949,7 @@
 
         switch (msg.what) {
             case EVENT_POLL_CALLS_RESULT:{
-                Log.d(LOG_TAG, "Event EVENT_POLL_CALLS_RESULT Received");
+                Rlog.d(LOG_TAG, "Event EVENT_POLL_CALLS_RESULT Received");
                 ar = (AsyncResult)msg.obj;
 
                 if(msg == lastRelevantPoll) {
@@ -982,7 +982,7 @@
                     // An exception occurred...just treat the disconnect
                     // cause as "normal"
                     causeCode = CallFailCause.NORMAL_CLEARING;
-                    Log.i(LOG_TAG,
+                    Rlog.i(LOG_TAG,
                             "Exception during getLastCallFailCause, assuming normal disconnect");
                 } else {
                     causeCode = ((int[])ar.result)[0];
@@ -1028,7 +1028,7 @@
                ar = (AsyncResult)msg.obj;
                if (ar.exception == null) {
                    handleCallWaitingInfo((CdmaCallWaitingNotification)ar.result);
-                   Log.d(LOG_TAG, "Event EVENT_CALL_WAITING_INFO_CDMA Received");
+                   Rlog.d(LOG_TAG, "Event EVENT_CALL_WAITING_INFO_CDMA Received");
                }
             break;
 
@@ -1056,7 +1056,7 @@
         case CDMAPhone.CANCEL_ECM_TIMER: mIsEcmTimerCanceled = true; break;
         case CDMAPhone.RESTART_ECM_TIMER: mIsEcmTimerCanceled = false; break;
         default:
-            Log.e(LOG_TAG, "handleEcmTimer, unsupported action " + action);
+            Rlog.e(LOG_TAG, "handleEcmTimer, unsupported action " + action);
         }
     }
 
@@ -1106,13 +1106,17 @@
             // Something strange happened: a call which is neither
             // a ringing call nor the one we created. It could be the
             // call collision result from RIL
-            Log.e(LOG_TAG,"Phantom call appeared " + dc);
+            Rlog.e(LOG_TAG,"Phantom call appeared " + dc);
             // If it's a connected call, set the connect time so that
             // it's non-zero.  It may not be accurate, but at least
             // it won't appear as a Missed Call.
             if (dc.state != DriverCall.State.ALERTING
                 && dc.state != DriverCall.State.DIALING) {
-                connections[i].connectTime = System.currentTimeMillis();
+                connections[i].onConnectedInOrOut();
+                if (dc.state == DriverCall.State.HOLDING) {
+                    // We've transitioned into HOLDING
+                    connections[i].onStartedHolding();
+                }
             }
         }
         return newRinging;
@@ -1129,7 +1133,7 @@
     }
 
     protected void log(String msg) {
-        Log.d(LOG_TAG, "[CdmaCallTracker] " + msg);
+        Rlog.d(LOG_TAG, "[CdmaCallTracker] " + msg);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaCallWaitingNotification.java b/src/java/com/android/internal/telephony/cdma/CdmaCallWaitingNotification.java
index 0a9bdb7..1d50c8b 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaCallWaitingNotification.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaCallWaitingNotification.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony.cdma;
 
-import android.util.Log;
+import android.telephony.Rlog;
 import com.android.internal.telephony.Connection;
 import com.android.internal.telephony.PhoneConstants;
 
@@ -62,7 +62,7 @@
             case 2: return PhoneConstants.PRESENTATION_UNKNOWN;
             default:
                 // This shouldn't happen, just log an error and treat as Unknown
-                Log.d(LOG_TAG, "Unexpected presentation " + cli);
+                Rlog.d(LOG_TAG, "Unexpected presentation " + cli);
                 return PhoneConstants.PRESENTATION_UNKNOWN;
         }
     }
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaConnection.java b/src/java/com/android/internal/telephony/cdma/CdmaConnection.java
index 17eecbd..29ed9cb 100755
--- a/src/java/com/android/internal/telephony/cdma/CdmaConnection.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaConnection.java
@@ -25,17 +25,15 @@
 import android.os.PowerManager;
 import android.os.Registrant;
 import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.text.TextUtils;
 
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
-import com.android.internal.telephony.TelephonyProperties;
-import com.android.internal.telephony.RILConstants;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 /**
  * {@hide}
@@ -151,9 +149,9 @@
         h = new MyHandler(owner.getLooper());
 
         this.dialString = dialString;
-        Log.d(LOG_TAG, "[CDMAConn] CdmaConnection: dialString=" + dialString);
+        Rlog.d(LOG_TAG, "[CDMAConn] CdmaConnection: dialString=" + dialString);
         dialString = formatDialString(dialString);
-        Log.d(LOG_TAG, "[CDMAConn] CdmaConnection:formated dialString=" + dialString);
+        Rlog.d(LOG_TAG, "[CDMAConn] CdmaConnection:formated dialString=" + dialString);
 
         this.address = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
         this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
@@ -304,7 +302,7 @@
 
     public void proceedAfterWaitChar() {
         if (postDialState != PostDialState.WAIT) {
-            Log.w(LOG_TAG, "CdmaConnection.proceedAfterWaitChar(): Expected "
+            Rlog.w(LOG_TAG, "CdmaConnection.proceedAfterWaitChar(): Expected "
                 + "getPostDialState() to be WAIT but was " + postDialState);
             return;
         }
@@ -316,7 +314,7 @@
 
     public void proceedAfterWildChar(String str) {
         if (postDialState != PostDialState.WILD) {
-            Log.w(LOG_TAG, "CdmaConnection.proceedAfterWaitChar(): Expected "
+            Rlog.w(LOG_TAG, "CdmaConnection.proceedAfterWaitChar(): Expected "
                 + "getPostDialState() to be WILD but was " + postDialState);
             return;
         }
@@ -418,10 +416,10 @@
             default:
                 CDMAPhone phone = owner.phone;
                 int serviceState = phone.getServiceState().getState();
-                AppState uiccAppState = UiccController
+                UiccCardApplication app = UiccController
                         .getInstance()
-                        .getUiccCardApplication(UiccController.APP_FAM_3GPP2)
-                        .getState();
+                        .getUiccCardApplication(UiccController.APP_FAM_3GPP2);
+                AppState uiccAppState = (app != null) ? app.getState() : AppState.APPSTATE_UNKNOWN;
                 if (serviceState == ServiceState.STATE_POWER_OFF) {
                     return DisconnectCause.POWER_OFF;
                 } else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
@@ -451,7 +449,7 @@
 
         if (!disconnected) {
             doDisconnect();
-            if (false) Log.d(LOG_TAG,
+            if (false) Rlog.d(LOG_TAG,
                     "[CDMAConn] onDisconnect: cause=" + cause);
 
             owner.phone.notifyDisconnect(this);
@@ -468,7 +466,7 @@
     onLocalDisconnect() {
         if (!disconnected) {
             doDisconnect();
-            if (false) Log.d(LOG_TAG,
+            if (false) Rlog.d(LOG_TAG,
                     "[CDMAConn] onLoalDisconnect" );
 
             if (parent != null) {
@@ -605,7 +603,7 @@
        disconnected = true;
     }
 
-    private void
+    /*package*/ void
     onStartedHolding() {
         holdingStartTime = SystemClock.elapsedRealtime();
     }
@@ -679,7 +677,7 @@
          * and or onConnectedInOrOut.
          */
         if (mPartialWakeLock.isHeld()) {
-            Log.e(LOG_TAG, "[CdmaConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
+            Rlog.e(LOG_TAG, "[CdmaConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
         }
         releaseWakeLock();
     }
@@ -690,7 +688,7 @@
 
         if (postDialState == PostDialState.CANCELLED) {
             releaseWakeLock();
-            //Log.v("CDMA", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
+            //Rlog.v("CDMA", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
             return;
         }
 
@@ -716,7 +714,7 @@
                 // Will call processNextPostDialChar
                 h.obtainMessage(EVENT_NEXT_POST_DIAL).sendToTarget();
                 // Don't notify application
-                Log.e("CDMA", "processNextPostDialChar: c=" + c + " isn't valid!");
+                Rlog.e("CDMA", "processNextPostDialChar: c=" + c + " isn't valid!");
                 return;
             }
         }
@@ -936,7 +934,7 @@
     }
 
     private void log(String msg) {
-        Log.d(LOG_TAG, "[CDMAConn] " + msg);
+        Rlog.d(LOG_TAG, "[CDMAConn] " + msg);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaDataConnection.java b/src/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
index 8761828..a041974 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
@@ -17,7 +17,7 @@
 package com.android.internal.telephony.cdma;
 
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.DataConnection;
 import com.android.internal.telephony.DataConnectionTracker;
@@ -113,7 +113,7 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[" + getName() + "] " + s);
+        Rlog.d(LOG_TAG, "[" + getName() + "] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 2acc5f9..0e68125 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -29,7 +29,7 @@
 import android.telephony.cdma.CdmaCellLocation;
 import android.text.TextUtils;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.ApnSetting;
 import com.android.internal.telephony.CommandsInterface;
@@ -41,11 +41,11 @@
 import com.android.internal.telephony.DctConstants;
 import com.android.internal.telephony.EventLogTags;
 import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.IccRecords;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.RetryManager;
 import com.android.internal.telephony.RILConstants;
-import com.android.internal.telephony.UiccCard;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.UiccCard;
 import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.util.AsyncChannel;
 
@@ -951,12 +951,12 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[CdmaDCT] " + s);
+        Rlog.d(LOG_TAG, "[CdmaDCT] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[CdmaDCT] " + s);
+        Rlog.e(LOG_TAG, "[CdmaDCT] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
index 50e87b1..9a84303 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
@@ -37,11 +37,12 @@
 import android.os.SystemProperties;
 
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.EventLog;
 
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.gsm.GsmDataConnectionTracker;
+import com.android.internal.telephony.uicc.RuimRecords;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.IccCardConstants;
 
 import java.io.FileDescriptor;
@@ -222,6 +223,7 @@
         switch (cm.getRadioState()) {
             case RADIO_UNAVAILABLE:
                 newSS.setStateOutOfService();
+                mLteSS.setStateOutOfService();
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
@@ -231,6 +233,7 @@
 
             case RADIO_OFF:
                 newSS.setStateOff();
+                mLteSS.setStateOff();
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
@@ -564,10 +567,12 @@
 
     @Override
     public boolean isConcurrentVoiceAndDataAllowed() {
-        // Note: it needs to be confirmed which CDMA network types
-        // can support voice and data calls concurrently.
-        // For the time-being, the return value will be false.
-        return (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE);
+        // For non-LTE, look at the CSS indicator to check on SV capability
+        if (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) {
+            return true;
+        } else {
+            return ss.getCssIndicator() == 1;
+        }
     }
 
     /**
@@ -614,12 +619,12 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[CdmaLteSST] " + s);
+        Rlog.d(LOG_TAG, "[CdmaLteSST] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[CdmaLteSST] " + s);
+        Rlog.e(LOG_TAG, "[CdmaLteSST] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaMmiCode.java b/src/java/com/android/internal/telephony/cdma/CdmaMmiCode.java
index 8dd8c2e..eaf5d01 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaMmiCode.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaMmiCode.java
@@ -24,7 +24,7 @@
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
@@ -183,7 +183,7 @@
     }
 
     public boolean isUssdRequest() {
-        Log.w(LOG_TAG, "isUssdRequest is not implemented in CdmaMmiCode");
+        Rlog.w(LOG_TAG, "isUssdRequest is not implemented in CdmaMmiCode");
         return false;
     }
 
@@ -239,7 +239,7 @@
             ar = (AsyncResult) (msg.obj);
             onSetComplete(ar);
         } else {
-            Log.e(LOG_TAG, "Unexpected reply");
+            Rlog.e(LOG_TAG, "Unexpected reply");
         }
     }
     // Private instance methods
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index 1a49db9..8473113 100755
--- a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -39,7 +39,7 @@
 import android.telephony.SmsManager;
 import android.telephony.cdma.CdmaSmsCbProgramData;
 import android.telephony.cdma.CdmaSmsCbProgramResults;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.GsmAlphabet;
@@ -116,7 +116,7 @@
     private void handleServiceCategoryProgramData(SmsMessage sms) {
         ArrayList<CdmaSmsCbProgramData> programDataList = sms.getSmsCbProgramData();
         if (programDataList == null) {
-            Log.e(TAG, "handleServiceCategoryProgramData: program data list is null!");
+            Rlog.e(TAG, "handleServiceCategoryProgramData: program data list is null!");
             return;
         }
 
@@ -132,7 +132,7 @@
 
         // If sms is null, means there was a parsing error.
         if (smsb == null) {
-            Log.e(TAG, "dispatchMessage: message is null");
+            Rlog.e(TAG, "dispatchMessage: message is null");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
 
@@ -143,7 +143,7 @@
 
         if (mSmsReceiveDisabled) {
             // Device doesn't support receiving SMS,
-            Log.d(TAG, "Received short message on device which doesn't support "
+            Rlog.d(TAG, "Received short message on device which doesn't support "
                     + "receiving SMS. Ignored.");
             return Intents.RESULT_SMS_HANDLED;
         }
@@ -152,7 +152,7 @@
 
         // Handle CMAS emergency broadcast messages.
         if (SmsEnvelope.MESSAGE_TYPE_BROADCAST == sms.getMessageType()) {
-            Log.d(TAG, "Broadcast type message");
+            Rlog.d(TAG, "Broadcast type message");
             SmsCbMessage message = sms.parseBroadcastSms();
             if (message != null) {
                 dispatchBroadcastMessage(message);
@@ -175,7 +175,7 @@
                 (SmsEnvelope.TELESERVICE_MWI == teleService)) {
             // handling Voicemail
             int voicemailCount = sms.getNumOfVoicemails();
-            Log.d(TAG, "Voicemail count=" + voicemailCount);
+            Rlog.d(TAG, "Voicemail count=" + voicemailCount);
             // Store the voicemail count in preferences.
             SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(
                     mContext);
@@ -194,7 +194,7 @@
             handled = true;
         } else if ((sms.getUserData() == null)) {
             if (false) {
-                Log.d(TAG, "Received SMS without user data");
+                Rlog.d(TAG, "Received SMS without user data");
             }
             handled = true;
         }
@@ -243,14 +243,14 @@
 
         int msgType = (0xFF & pdu[index++]);
         if (msgType != 0) {
-            Log.w(TAG, "Received a WAP SMS which is not WDP. Discard.");
+            Rlog.w(TAG, "Received a WAP SMS which is not WDP. Discard.");
             return Intents.RESULT_SMS_HANDLED;
         }
         int totalSegments = (0xFF & pdu[index++]);   // >= 1
         int segment = (0xFF & pdu[index++]);         // >= 0
 
         if (segment >= totalSegments) {
-            Log.e(TAG, "WDP bad segment #" + segment + " expecting 0-" + (totalSegments - 1));
+            Rlog.e(TAG, "WDP bad segment #" + segment + " expecting 0-" + (totalSegments - 1));
             return Intents.RESULT_SMS_HANDLED;
         }
 
@@ -273,7 +273,7 @@
         }
 
         // Lookup all other related parts
-        Log.i(TAG, "Received WAP PDU. Type = " + msgType + ", originator = " + address
+        Rlog.i(TAG, "Received WAP PDU. Type = " + msgType + ", originator = " + address
                 + ", src-port = " + sourcePort + ", dst-port = " + destinationPort
                 + ", ID = " + referenceNumber + ", segment# = " + segment + '/' + totalSegments);
 
@@ -344,7 +344,7 @@
                 } catch (CanceledException ex) {}
             }
             if (false) {
-                Log.d(TAG, "Block SMS in Emergency Callback mode");
+                Rlog.d(TAG, "Block SMS in Emergency Callback mode");
             }
             return;
         }
@@ -443,23 +443,23 @@
             int rc = getResultCode();
             boolean success = (rc == Activity.RESULT_OK) || (rc == Intents.RESULT_SMS_HANDLED);
             if (!success) {
-                Log.e(TAG, "SCP results error: result code = " + rc);
+                Rlog.e(TAG, "SCP results error: result code = " + rc);
                 return;
             }
             Bundle extras = getResultExtras(false);
             if (extras == null) {
-                Log.e(TAG, "SCP results error: missing extras");
+                Rlog.e(TAG, "SCP results error: missing extras");
                 return;
             }
             String sender = extras.getString("sender");
             if (sender == null) {
-                Log.e(TAG, "SCP results error: missing sender extra.");
+                Rlog.e(TAG, "SCP results error: missing sender extra.");
                 return;
             }
             ArrayList<CdmaSmsCbProgramResults> results
                     = extras.getParcelableArrayList("results");
             if (results == null) {
-                Log.e(TAG, "SCP results error: missing results extra.");
+                Rlog.e(TAG, "SCP results error: missing results extra.");
                 return;
             }
 
@@ -492,7 +492,7 @@
                 // Ignore the RIL response. TODO: implement retry if SMS send fails.
                 mCm.sendCdmaSms(baos.toByteArray(), null);
             } catch (IOException e) {
-                Log.e(TAG, "exception creating SCP results PDU", e);
+                Rlog.e(TAG, "exception creating SCP results PDU", e);
             } finally {
                 try {
                     dos.close();
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
old mode 100755
new mode 100644
index 2554691..5909ec2
--- a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -28,9 +28,9 @@
 import com.android.internal.telephony.ServiceStateTracker;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.TelephonyProperties;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
 import com.android.internal.telephony.CommandsInterface.RadioState;
+import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
 
 import android.app.AlarmManager;
@@ -57,7 +57,7 @@
 import android.telephony.cdma.CdmaCellLocation;
 import android.text.TextUtils;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.TimeUtils;
 
 import java.io.FileDescriptor;
@@ -832,6 +832,7 @@
         switch (cm.getRadioState()) {
         case RADIO_UNAVAILABLE:
             newSS.setStateOutOfService();
+            mNewDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE;
             newCellLoc.setStateInvalid();
             setSignalStrengthDefaultValues();
             mGotCountryCode = false;
@@ -841,6 +842,7 @@
 
         case RADIO_OFF:
             newSS.setStateOff();
+            mNewDataConnectionState = ServiceState.STATE_POWER_OFF;
             newCellLoc.setStateInvalid();
             setSignalStrengthDefaultValues();
             mGotCountryCode = false;
@@ -1709,12 +1711,12 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[CdmaSST] " + s);
+        Rlog.d(LOG_TAG, "[CdmaSST] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[CdmaSST] " + s);
+        Rlog.e(LOG_TAG, "[CdmaSST] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSmsBroadcastConfigInfo.java b/src/java/com/android/internal/telephony/cdma/CdmaSmsBroadcastConfigInfo.java
new file mode 100755
index 0000000..b31df59
--- /dev/null
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSmsBroadcastConfigInfo.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011-2013 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.cdma;
+
+/**
+ * CdmaSmsBroadcastConfigInfo defines one configuration of Cdma Broadcast
+ * Message to be received by the ME
+ *
+ * serviceCategory defines a Broadcast message identifier
+ * whose value is 0x0000 - 0xFFFF as defined in C.R1001G 9.3.1 and 9.3.2.
+ * All other values can be treated as empty message ID.
+ *
+ * language defines a language code of Broadcast Message
+ * whose value is 0x00 - 0x07 as defined in C.R1001G 9.2.
+ * All other values can be treated as empty language code.
+ *
+ * selected false means message types specified in serviceCategory
+ * are not accepted, while true means accepted.
+ *
+ */
+public class CdmaSmsBroadcastConfigInfo {
+    private int mFromServiceCategory;
+    private int mToServiceCategory;
+    private int mLanguage;
+    private boolean mSelected;
+
+    /**
+     * Initialize the object from rssi and cid.
+     */
+    public CdmaSmsBroadcastConfigInfo(int fromServiceCategory, int toServiceCategory,
+            int language, boolean selected) {
+        mFromServiceCategory = fromServiceCategory;
+        mToServiceCategory = toServiceCategory;
+        mLanguage = language;
+        mSelected = selected;
+    }
+
+    /**
+     * @return the mFromServiceCategory
+     */
+    public int getFromServiceCategory() {
+        return mFromServiceCategory;
+    }
+
+    /**
+     * @return the mToServiceCategory
+     */
+    public int getToServiceCategory() {
+        return mToServiceCategory;
+    }
+
+    /**
+     * @return the mLanguage
+     */
+    public int getLanguage() {
+        return mLanguage;
+    }
+
+    /**
+     * @return the selected
+     */
+    public boolean isSelected() {
+        return mSelected;
+    }
+
+    @Override
+    public String toString() {
+        return "CdmaSmsBroadcastConfigInfo: Id [" +
+            mFromServiceCategory + ", " + mToServiceCategory + "] " +
+            (isSelected() ? "ENABLED" : "DISABLED");
+    }
+}
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSubscriptionSourceManager.java b/src/java/com/android/internal/telephony/cdma/CdmaSubscriptionSourceManager.java
index 6d82f3d..972d3c3 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaSubscriptionSourceManager.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSubscriptionSourceManager.java
@@ -28,7 +28,7 @@
 import android.os.Registrant;
 import android.os.RegistrantList;
 import android.provider.Settings;
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * Class that handles the CDMA subscription source changed events from RIL
@@ -182,15 +182,15 @@
     }
 
     private void log(String s) {
-        Log.d(LOG_TAG, "[CdmaSSM] " + s);
+        Rlog.d(LOG_TAG, "[CdmaSSM] " + s);
     }
 
     private void loge(String s) {
-        Log.e(LOG_TAG, "[CdmaSSM] " + s);
+        Rlog.e(LOG_TAG, "[CdmaSSM] " + s);
     }
 
     private void logw(String s) {
-        Log.w(LOG_TAG, "[CdmaSSM] " + s);
+        Rlog.w(LOG_TAG, "[CdmaSSM] " + s);
     }
 
 }
diff --git a/src/java/com/android/internal/telephony/cdma/EriManager.java b/src/java/com/android/internal/telephony/cdma/EriManager.java
index 1bcc90a..bb1707c 100644
--- a/src/java/com/android/internal/telephony/cdma/EriManager.java
+++ b/src/java/com/android/internal/telephony/cdma/EriManager.java
@@ -20,7 +20,7 @@
 import android.content.res.Resources;
 import android.content.res.XmlResourceParser;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Xml;
 
 import com.android.internal.telephony.Phone;
@@ -159,22 +159,22 @@
         Resources r = mContext.getResources();
 
         try {
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: check for alternate file");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: check for alternate file");
             stream = new FileInputStream(
                             r.getString(com.android.internal.R.string.alternate_eri_file));
             parser = Xml.newPullParser();
             parser.setInput(stream, null);
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: opened alternate file");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: opened alternate file");
         } catch (FileNotFoundException e) {
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: no alternate file");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: no alternate file");
             parser = null;
         } catch (XmlPullParserException e) {
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: no parser for alternate file");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: no parser for alternate file");
             parser = null;
         }
 
         if (parser == null) {
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: open normal file");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: open normal file");
             parser = r.getXml(com.android.internal.R.xml.eri);
         }
 
@@ -193,7 +193,7 @@
                 String name = parser.getName();
                 if (name == null) {
                     if (parsedEriEntries != mEriFile.mNumberOfEriEntries)
-                        Log.e(LOG_TAG, "Error Parsing ERI file: " +  mEriFile.mNumberOfEriEntries
+                        Rlog.e(LOG_TAG, "Error Parsing ERI file: " +  mEriFile.mNumberOfEriEntries
                                 + " defined, " + parsedEriEntries + " parsed!");
                     break;
                 } else if (name.equals("CallPromptId")) {
@@ -202,7 +202,7 @@
                     if (id >= 0 && id <= 2) {
                         mEriFile.mCallPromptId[id] = text;
                     } else {
-                        Log.e(LOG_TAG, "Error Parsing ERI file: found" + id + " CallPromptId");
+                        Rlog.e(LOG_TAG, "Error Parsing ERI file: found" + id + " CallPromptId");
                     }
 
                 } else if (name.equals("EriInfo")) {
@@ -220,11 +220,11 @@
                 }
             }
 
-            if (DBG) Log.d(LOG_TAG, "loadEriFileFromXml: eri parsing successful, file loaded");
+            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: eri parsing successful, file loaded");
             isEriFileLoaded = true;
 
         } catch (Exception e) {
-            Log.e(LOG_TAG, "Got exception while loading ERI file.", e);
+            Rlog.e(LOG_TAG, "Got exception while loading ERI file.", e);
         } finally {
             if (parser instanceof XmlResourceParser) {
                 ((XmlResourceParser)parser).close();
@@ -290,7 +290,7 @@
         if (isEriFileLoaded) {
             EriInfo eriInfo = getEriInfo(roamInd);
             if (eriInfo != null) {
-                if (VDBG) Log.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
+                if (VDBG) Rlog.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
                 ret = new EriDisplayInformation(
                         eriInfo.mIconIndex,
                         eriInfo.mIconMode,
@@ -398,16 +398,16 @@
         default:
             if (!isEriFileLoaded) {
                 // ERI file NOT loaded
-                if (DBG) Log.d(LOG_TAG, "ERI File not loaded");
+                if (DBG) Rlog.d(LOG_TAG, "ERI File not loaded");
                 if(defRoamInd > 2) {
-                    if (VDBG) Log.v(LOG_TAG, "ERI defRoamInd > 2 ...flashing");
+                    if (VDBG) Rlog.v(LOG_TAG, "ERI defRoamInd > 2 ...flashing");
                     ret = new EriDisplayInformation(
                             EriInfo.ROAMING_INDICATOR_FLASH,
                             EriInfo.ROAMING_ICON_MODE_FLASH,
                             mContext.getText(com.android.internal
                                                             .R.string.roamingText2).toString());
                 } else {
-                    if (VDBG) Log.v(LOG_TAG, "ERI defRoamInd <= 2");
+                    if (VDBG) Rlog.v(LOG_TAG, "ERI defRoamInd <= 2");
                     switch (defRoamInd) {
                     case EriInfo.ROAMING_INDICATOR_ON:
                         ret = new EriDisplayInformation(
@@ -443,11 +443,11 @@
                 EriInfo defEriInfo = getEriInfo(defRoamInd);
                 if (eriInfo == null) {
                     if (VDBG) {
-                        Log.v(LOG_TAG, "ERI roamInd " + roamInd
+                        Rlog.v(LOG_TAG, "ERI roamInd " + roamInd
                             + " not found in ERI file ...using defRoamInd " + defRoamInd);
                     }
                     if(defEriInfo == null) {
-                        Log.e(LOG_TAG, "ERI defRoamInd " + defRoamInd
+                        Rlog.e(LOG_TAG, "ERI defRoamInd " + defRoamInd
                                 + " not found in ERI file ...on");
                         ret = new EriDisplayInformation(
                                 EriInfo.ROAMING_INDICATOR_ON,
@@ -457,7 +457,7 @@
 
                     } else {
                         if (VDBG) {
-                            Log.v(LOG_TAG, "ERI defRoamInd " + defRoamInd + " found in ERI file");
+                            Rlog.v(LOG_TAG, "ERI defRoamInd " + defRoamInd + " found in ERI file");
                         }
                         ret = new EriDisplayInformation(
                                 defEriInfo.mIconIndex,
@@ -465,7 +465,7 @@
                                 defEriInfo.mEriText);
                     }
                 } else {
-                    if (VDBG) Log.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
+                    if (VDBG) Rlog.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
                     ret = new EriDisplayInformation(
                             eriInfo.mIconIndex,
                             eriInfo.mIconMode,
@@ -474,7 +474,7 @@
             }
             break;
         }
-        if (VDBG) Log.v(LOG_TAG, "Displaying ERI " + ret.toString());
+        if (VDBG) Rlog.v(LOG_TAG, "Displaying ERI " + ret.toString());
         return ret;
     }
 
diff --git a/src/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java b/src/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
index e919245..75b2f59 100644
--- a/src/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
@@ -19,10 +19,10 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccFileHandler;
 import com.android.internal.telephony.IccPhoneBookInterfaceManager;
+import com.android.internal.telephony.uicc.IccFileHandler;
 
 /**
  * RuimPhoneBookInterfaceManager to provide an inter-process communication to
@@ -46,9 +46,9 @@
         try {
             super.finalize();
         } catch (Throwable throwable) {
-            Log.e(LOG_TAG, "Error while finalizing:", throwable);
+            Rlog.e(LOG_TAG, "Error while finalizing:", throwable);
         }
-        if(DBG) Log.d(LOG_TAG, "RuimPhoneBookInterfaceManager finalized");
+        if(DBG) Rlog.d(LOG_TAG, "RuimPhoneBookInterfaceManager finalized");
     }
 
     public int[] getAdnRecordsSize(int efid) {
@@ -73,11 +73,11 @@
     }
 
     protected void logd(String msg) {
-        Log.d(LOG_TAG, "[RuimPbInterfaceManager] " + msg);
+        Rlog.d(LOG_TAG, "[RuimPbInterfaceManager] " + msg);
     }
 
     protected void loge(String msg) {
-        Log.e(LOG_TAG, "[RuimPbInterfaceManager] " + msg);
+        Rlog.e(LOG_TAG, "[RuimPbInterfaceManager] " + msg);
     }
 }
 
diff --git a/src/java/com/android/internal/telephony/cdma/RuimSmsInterfaceManager.java b/src/java/com/android/internal/telephony/cdma/RuimSmsInterfaceManager.java
index 9cd059d..0679470 100644
--- a/src/java/com/android/internal/telephony/cdma/RuimSmsInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/cdma/RuimSmsInterfaceManager.java
@@ -18,23 +18,16 @@
 package com.android.internal.telephony.cdma;
 
 import android.content.Context;
-import android.os.AsyncResult;
-import android.os.Handler;
+import android.os.Binder;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccConstants;
 import com.android.internal.telephony.IccSmsInterfaceManager;
-import com.android.internal.telephony.IccUtils;
-import com.android.internal.telephony.PhoneProxy;
+import com.android.internal.telephony.IntRangeManager;
 import com.android.internal.telephony.SMSDispatcher;
-import com.android.internal.telephony.SmsRawData;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static android.telephony.SmsManager.STATUS_ON_ICC_FREE;
 
 /**
  * RuimSmsInterfaceManager to provide an inter-process communication to
@@ -44,42 +37,8 @@
     static final String LOG_TAG = "CDMA";
     static final boolean DBG = true;
 
-    private final Object mLock = new Object();
-    private boolean mSuccess;
-    private List<SmsRawData> mSms;
-
-    private static final int EVENT_LOAD_DONE = 1;
-    private static final int EVENT_UPDATE_DONE = 2;
-
-    Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            AsyncResult ar;
-
-            switch (msg.what) {
-                case EVENT_UPDATE_DONE:
-                    ar = (AsyncResult) msg.obj;
-                    synchronized (mLock) {
-                        mSuccess = (ar.exception == null);
-                        mLock.notifyAll();
-                    }
-                    break;
-                case EVENT_LOAD_DONE:
-                    ar = (AsyncResult)msg.obj;
-                    synchronized (mLock) {
-                        if (ar.exception == null) {
-                            mSms = buildValidRawData((ArrayList<byte[]>) ar.result);
-                        } else {
-                            if(DBG) log("Cannot load Sms records");
-                            if (mSms != null)
-                                mSms.clear();
-                        }
-                        mLock.notifyAll();
-                    }
-                    break;
-            }
-        }
-    };
+    private CdmaBroadcastRangeManager mCdmaBroadcastRangeManager =
+        new CdmaBroadcastRangeManager();
 
     public RuimSmsInterfaceManager(CDMAPhone phone, SMSDispatcher dispatcher) {
         super(phone);
@@ -93,130 +52,165 @@
         try {
             super.finalize();
         } catch (Throwable throwable) {
-            Log.e(LOG_TAG, "Error while finalizing:", throwable);
+            Rlog.e(LOG_TAG, "Error while finalizing:", throwable);
         }
-        if(DBG) Log.d(LOG_TAG, "RuimSmsInterfaceManager finalized");
+        if(DBG) Rlog.d(LOG_TAG, "RuimSmsInterfaceManager finalized");
     }
 
-    /**
-     * Update the specified message on the RUIM.
-     *
-     * @param index record index of message to update
-     * @param status new message status (STATUS_ON_ICC_READ,
-     *                  STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
-     *                  STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
-     * @param pdu the raw PDU to store
-     * @return success or not
-     *
-     */
-    public boolean
-    updateMessageOnIccEf(int index, int status, byte[] pdu) {
-        if (DBG) log("updateMessageOnIccEf: index=" + index +
-                " status=" + status + " ==> " +
-                "("+ pdu + ")");
-        enforceReceiveAndSend("Updating message on RUIM");
-        synchronized(mLock) {
-            mSuccess = false;
-            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
-
-            if (status == STATUS_ON_ICC_FREE) {
-                // Special case FREE: call deleteSmsOnRuim instead of
-                // manipulating the RUIM record
-                mPhone.mCM.deleteSmsOnRuim(index, response);
-            } else {
-                byte[] record = makeSmsRecordData(status, pdu);
-                mPhone.getIccFileHandler().updateEFLinearFixed(
-                        IccConstants.EF_SMS, index, record, null, response);
-            }
-            try {
-                mLock.wait();
-            } catch (InterruptedException e) {
-                log("interrupted while trying to update by index");
-            }
-        }
-        return mSuccess;
+    protected void deleteSms(int index, Message response) {
+        mPhone.mCM.deleteSmsOnRuim(index, response);
     }
 
-    /**
-     * Copy a raw SMS PDU to the RUIM.
-     *
-     * @param pdu the raw PDU to store
-     * @param status message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
-     *               STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)
-     * @return success or not
-     *
-     */
-    public boolean copyMessageToIccEf(int status, byte[] pdu, byte[] smsc) {
+    protected void writeSms(int status, byte[] pdu, byte[] smsc, Message response) {
         //NOTE smsc not used in RUIM
-        if (DBG) log("copyMessageToIccEf: status=" + status + " ==> " +
-                "pdu=("+ Arrays.toString(pdu) + ")");
-        enforceReceiveAndSend("Copying message to RUIM");
-        synchronized(mLock) {
-            mSuccess = false;
-            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
-
-            mPhone.mCM.writeSmsToRuim(status, IccUtils.bytesToHexString(pdu),
-                    response);
-
-            try {
-                mLock.wait();
-            } catch (InterruptedException e) {
-                log("interrupted while trying to update by index");
-            }
-        }
-        return mSuccess;
+        mPhone.mCM.writeSmsToRuim(status, IccUtils.bytesToHexString(pdu),
+                response);
     }
 
-    /**
-     * Retrieves all messages currently stored on RUIM.
-     */
-    public List<SmsRawData> getAllMessagesFromIccEf() {
-        if (DBG) log("getAllMessagesFromEF");
+    public boolean enableCellBroadcast(int messageIdentifier) {
+        return enableCellBroadcastRange(messageIdentifier, messageIdentifier);
+    }
+
+    public boolean disableCellBroadcast(int messageIdentifier) {
+        return disableCellBroadcastRange(messageIdentifier, messageIdentifier);
+    }
+
+    public boolean enableCellBroadcastRange(int startMessageId, int endMessageId) {
+        if (DBG) log("enableCellBroadcastRange");
 
         Context context = mPhone.getContext();
 
         context.enforceCallingPermission(
                 "android.permission.RECEIVE_SMS",
-                "Reading messages from RUIM");
-        synchronized(mLock) {
-            Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
-            mPhone.getIccFileHandler().loadEFLinearFixedAll(IccConstants.EF_SMS, response);
+                "Enabling cdma broadcast SMS");
+
+        String client = context.getPackageManager().getNameForUid(
+                Binder.getCallingUid());
+
+        if (!mCdmaBroadcastRangeManager.enableRange(startMessageId, endMessageId, client)) {
+            log("Failed to add cdma broadcast subscription for MID range " + startMessageId
+                    + " to " + endMessageId + " from client " + client);
+            return false;
+        }
+
+        if (DBG)
+            log("Added cdma broadcast subscription for MID range " + startMessageId
+                    + " to " + endMessageId + " from client " + client);
+
+        setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty());
+
+        return true;
+    }
+
+    public boolean disableCellBroadcastRange(int startMessageId, int endMessageId) {
+        if (DBG) log("disableCellBroadcastRange");
+
+        Context context = mPhone.getContext();
+
+        context.enforceCallingPermission(
+                "android.permission.RECEIVE_SMS",
+                "Disabling cell broadcast SMS");
+
+        String client = context.getPackageManager().getNameForUid(
+                Binder.getCallingUid());
+
+        if (!mCdmaBroadcastRangeManager.disableRange(startMessageId, endMessageId, client)) {
+            log("Failed to remove cdma broadcast subscription for MID range " + startMessageId
+                    + " to " + endMessageId + " from client " + client);
+            return false;
+        }
+
+        if (DBG)
+            log("Removed cdma broadcast subscription for MID range " + startMessageId
+                    + " to " + endMessageId + " from client " + client);
+
+        setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty());
+
+        return true;
+    }
+
+    class CdmaBroadcastRangeManager extends IntRangeManager {
+        private ArrayList<CdmaSmsBroadcastConfigInfo> mConfigList =
+                new ArrayList<CdmaSmsBroadcastConfigInfo>();
+
+        /**
+         * Called when the list of enabled ranges has changed. This will be
+         * followed by zero or more calls to {@link #addRange} followed by
+         * a call to {@link #finishUpdate}.
+         */
+        protected void startUpdate() {
+            mConfigList.clear();
+        }
+
+        /**
+         * Called after {@link #startUpdate} to indicate a range of enabled
+         * values.
+         * @param startId the first id included in the range
+         * @param endId the last id included in the range
+         */
+        protected void addRange(int startId, int endId, boolean selected) {
+            mConfigList.add(new CdmaSmsBroadcastConfigInfo(startId, endId,
+                        1, selected));
+        }
+
+        /**
+         * Called to indicate the end of a range update started by the
+         * previous call to {@link #startUpdate}.
+         * @return true if successful, false otherwise
+         */
+        protected boolean finishUpdate() {
+            if (mConfigList.isEmpty()) {
+                return true;
+            } else {
+                CdmaSmsBroadcastConfigInfo[] configs =
+                        mConfigList.toArray(new CdmaSmsBroadcastConfigInfo[mConfigList.size()]);
+                return setCdmaBroadcastConfig(configs);
+            }
+        }
+    }
+
+    private boolean setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs) {
+        if (DBG)
+            log("Calling setCdmaBroadcastConfig with " + configs.length + " configurations");
+
+        synchronized (mLock) {
+            Message response = mHandler.obtainMessage(EVENT_SET_BROADCAST_CONFIG_DONE);
+
+            mSuccess = false;
+            mPhone.mCM.setCdmaBroadcastConfig(configs, response);
 
             try {
                 mLock.wait();
             } catch (InterruptedException e) {
-                log("interrupted while trying to load from the RUIM");
+                log("interrupted while trying to set cdma broadcast config");
             }
         }
-        return mSms;
+
+        return mSuccess;
     }
 
-    public boolean enableCellBroadcast(int messageIdentifier) {
-        // Not implemented
-        Log.e(LOG_TAG, "Error! Not implemented for CDMA.");
-        return false;
-    }
+    private boolean setCdmaBroadcastActivation(boolean activate) {
+        if (DBG)
+            log("Calling setCdmaBroadcastActivation(" + activate + ")");
 
-    public boolean disableCellBroadcast(int messageIdentifier) {
-        // Not implemented
-        Log.e(LOG_TAG, "Error! Not implemented for CDMA.");
-        return false;
-    }
+        synchronized (mLock) {
+            Message response = mHandler.obtainMessage(EVENT_SET_BROADCAST_ACTIVATION_DONE);
 
-    public boolean enableCellBroadcastRange(int startMessageId, int endMessageId) {
-        // Not implemented
-        Log.e(LOG_TAG, "Error! Not implemented for CDMA.");
-        return false;
-    }
+            mSuccess = false;
+            mPhone.mCM.setCdmaBroadcastActivation(activate, response);
 
-    public boolean disableCellBroadcastRange(int startMessageId, int endMessageId) {
-        // Not implemented
-        Log.e(LOG_TAG, "Error! Not implemented for CDMA.");
-        return false;
+            try {
+                mLock.wait();
+            } catch (InterruptedException e) {
+                log("interrupted while trying to set cdma broadcast activation");
+            }
+        }
+
+        return mSuccess;
     }
 
     protected void log(String msg) {
-        Log.d(LOG_TAG, "[RuimSmsInterfaceManager] " + msg);
+        Rlog.d(LOG_TAG, "[RuimSmsInterfaceManager] " + msg);
     }
 }
 
diff --git a/src/java/com/android/internal/telephony/cdma/SignalToneUtil.java b/src/java/com/android/internal/telephony/cdma/SignalToneUtil.java
index a149e72..5fedc52 100644
--- a/src/java/com/android/internal/telephony/cdma/SignalToneUtil.java
+++ b/src/java/com/android/internal/telephony/cdma/SignalToneUtil.java
@@ -18,7 +18,7 @@
 
 import java.util.HashMap;
 import java.util.HashSet;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.media.ToneGenerator;
 
 public class SignalToneUtil {
diff --git a/src/java/com/android/internal/telephony/cdma/SmsMessage.java b/src/java/com/android/internal/telephony/cdma/SmsMessage.java
index 617a328..4777cbb 100644
--- a/src/java/com/android/internal/telephony/cdma/SmsMessage.java
+++ b/src/java/com/android/internal/telephony/cdma/SmsMessage.java
@@ -22,10 +22,10 @@
 import android.telephony.SmsCbLocation;
 import android.telephony.SmsCbMessage;
 import android.telephony.cdma.CdmaSmsCbProgramData;
+import android.telephony.Rlog;
 import android.util.Log;
 
 import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.SmsConstants;
 import com.android.internal.telephony.SmsHeader;
 import com.android.internal.telephony.SmsMessageBase;
@@ -35,6 +35,7 @@
 import com.android.internal.telephony.cdma.sms.CdmaSmsSubaddress;
 import com.android.internal.telephony.cdma.sms.SmsEnvelope;
 import com.android.internal.telephony.cdma.sms.UserData;
+import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.util.BitwiseInputStream;
 import com.android.internal.util.HexDump;
 
@@ -110,7 +111,7 @@
             msg.parsePdu(pdu);
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
             return null;
         }
     }
@@ -237,7 +238,7 @@
             // or STORED_UNSENT
             // See 3GPP2 C.S0023 3.4.27
             if ((data[0] & 1) == 0) {
-                Log.w(LOG_TAG, "SMS parsing failed: Trying to parse a free record");
+                Rlog.w(LOG_TAG, "SMS parsing failed: Trying to parse a free record");
                 return null;
             } else {
                 msg.statusOnIcc = data[0] & 0x07;
@@ -256,7 +257,7 @@
             msg.parsePduFromEfRecord(pdu);
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
             return null;
         }
 
@@ -266,7 +267,7 @@
      * Note: This function is a GSM specific functionality which is not supported in CDMA mode.
      */
     public static int getTPLayerLengthForPDU(String pdu) {
-        Log.w(LOG_TAG, "getTPLayerLengthForPDU: is not supported in CDMA mode.");
+        Rlog.w(LOG_TAG, "getTPLayerLengthForPDU: is not supported in CDMA mode.");
         return 0;
     }
 
@@ -369,7 +370,7 @@
      * Note: This function is a GSM specific functionality which is not supported in CDMA mode.
      */
     public int getProtocolIdentifier() {
-        Log.w(LOG_TAG, "getProtocolIdentifier: is not supported in CDMA mode.");
+        Rlog.w(LOG_TAG, "getProtocolIdentifier: is not supported in CDMA mode.");
         // (3GPP TS 23.040): "no interworking, but SME to SME protocol":
         return 0;
     }
@@ -378,7 +379,7 @@
      * Note: This function is a GSM specific functionality which is not supported in CDMA mode.
      */
     public boolean isReplace() {
-        Log.w(LOG_TAG, "isReplace: is not supported in CDMA mode.");
+        Rlog.w(LOG_TAG, "isReplace: is not supported in CDMA mode.");
         return false;
     }
 
@@ -387,7 +388,7 @@
      * Note: This function is a GSM specific functionality which is not supported in CDMA mode.
      */
     public boolean isCphsMwiMessage() {
-        Log.w(LOG_TAG, "isCphsMwiMessage: is not supported in CDMA mode.");
+        Rlog.w(LOG_TAG, "isCphsMwiMessage: is not supported in CDMA mode.");
         return false;
     }
 
@@ -432,7 +433,7 @@
      * Note: This function is a GSM specific functionality which is not supported in CDMA mode.
      */
     public boolean isReplyPathPresent() {
-        Log.w(LOG_TAG, "isReplyPathPresent: is not supported in CDMA mode.");
+        Rlog.w(LOG_TAG, "isReplyPathPresent: is not supported in CDMA mode.");
         return false;
     }
 
@@ -487,7 +488,7 @@
     private void parsePdu(byte[] pdu) {
         ByteArrayInputStream bais = new ByteArrayInputStream(pdu);
         DataInputStream dis = new DataInputStream(bais);
-        byte length;
+        int length;
         int bearerDataLength;
         SmsEnvelope env = new SmsEnvelope();
         CdmaSmsAddress addr = new CdmaSmsAddress();
@@ -502,7 +503,7 @@
             addr.ton = dis.readByte();
             addr.numberPlan = dis.readByte();
 
-            length = dis.readByte();
+            length = dis.readUnsignedByte();
             addr.numberOfDigits = length;
             addr.origBytes = new byte[length];
             dis.read(addr.origBytes, 0, length); // digits
@@ -519,7 +520,7 @@
             dis.read(env.bearerData, 0, bearerDataLength);
             dis.close();
         } catch (Exception ex) {
-            Log.e(LOG_TAG, "createFromPdu: conversion from byte array to object failed: " + ex);
+            Rlog.e(LOG_TAG, "createFromPdu: conversion from byte array to object failed: " + ex);
         }
 
         // link the filled objects to this SMS
@@ -546,7 +547,7 @@
 
             while (dis.available() > 0) {
                 int parameterId = dis.readByte();
-                int parameterLen = dis.readByte();
+                int parameterLen = dis.readUnsignedByte();
                 byte[] parameterData = new byte[parameterLen];
 
                 switch (parameterId) {
@@ -557,7 +558,7 @@
                          * this message
                          */
                         env.teleService = dis.readUnsignedShort();
-                        Log.i(LOG_TAG, "teleservice = " + env.teleService);
+                        Rlog.i(LOG_TAG, "teleservice = " + env.teleService);
                         break;
                     case SERVICE_CATEGORY:
                         /*
@@ -603,18 +604,18 @@
 
                             } else if (addr.numberMode == CdmaSmsAddress.NUMBER_MODE_DATA_NETWORK) {
                                 if (numberType == 2)
-                                    Log.e(LOG_TAG, "TODO: Originating Addr is email id");
+                                    Rlog.e(LOG_TAG, "TODO: Originating Addr is email id");
                                 else
-                                    Log.e(LOG_TAG,
+                                    Rlog.e(LOG_TAG,
                                           "TODO: Originating Addr is data network address");
                             } else {
-                                Log.e(LOG_TAG, "Originating Addr is of incorrect type");
+                                Rlog.e(LOG_TAG, "Originating Addr is of incorrect type");
                             }
                         } else {
-                            Log.e(LOG_TAG, "Incorrect Digit mode");
+                            Rlog.e(LOG_TAG, "Incorrect Digit mode");
                         }
                         addr.origBytes = data;
-                        Log.i(LOG_TAG, "Originating Addr=" + addr.toString());
+                        Rlog.i(LOG_TAG, "Originating Addr=" + addr.toString());
                         break;
                     case ORIGINATING_SUB_ADDRESS:
                     case DESTINATION_SUB_ADDRESS:
@@ -655,7 +656,7 @@
             bais.close();
             dis.close();
         } catch (Exception ex) {
-            Log.e(LOG_TAG, "parsePduFromEfRecord: conversion from pdu to SmsMessage failed" + ex);
+            Rlog.e(LOG_TAG, "parsePduFromEfRecord: conversion from pdu to SmsMessage failed" + ex);
         }
 
         // link the filled objects to this SMS
@@ -680,16 +681,16 @@
                 mBearerData.numberOfMessages = 0x000000FF & mEnvelope.bearerData[0];
             }
             if (false) {
-                Log.d(LOG_TAG, "parseSms: get MWI " +
+                Rlog.d(LOG_TAG, "parseSms: get MWI " +
                       Integer.toString(mBearerData.numberOfMessages));
             }
             return;
         }
         mBearerData = BearerData.decode(mEnvelope.bearerData);
-        if (Log.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
-            Log.d(LOG_TAG, "MT raw BearerData = '" +
+        if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
+            Rlog.d(LOG_TAG, "MT raw BearerData = '" +
                       HexDump.toHexString(mEnvelope.bearerData) + "'");
-            Log.d(LOG_TAG, "MT (decoded) BearerData = " + mBearerData);
+            Rlog.d(LOG_TAG, "MT (decoded) BearerData = " + mBearerData);
         }
         messageRef = mBearerData.messageId;
         if (mBearerData.userData != null) {
@@ -700,7 +701,7 @@
 
         if (originatingAddress != null) {
             originatingAddress.address = new String(originatingAddress.origBytes);
-            if (false) Log.v(LOG_TAG, "SMS originating address: "
+            if (false) Rlog.v(LOG_TAG, "SMS originating address: "
                     + originatingAddress.address);
         }
 
@@ -708,7 +709,7 @@
             scTimeMillis = mBearerData.msgCenterTimeStamp.toMillis(true);
         }
 
-        if (false) Log.d(LOG_TAG, "SMS SC timestamp: " + scTimeMillis);
+        if (false) Rlog.d(LOG_TAG, "SMS SC timestamp: " + scTimeMillis);
 
         // Message Type (See 3GPP2 C.S0015-B, v2, 4.5.1)
         if (mBearerData.messageType == BearerData.MESSAGE_TYPE_DELIVERY_ACK) {
@@ -720,7 +721,7 @@
             // message without this subparameter is assumed to
             // indicate successful delivery (status == 0).
             if (! mBearerData.messageStatusSet) {
-                Log.d(LOG_TAG, "DELIVERY_ACK message without msgStatus (" +
+                Rlog.d(LOG_TAG, "DELIVERY_ACK message without msgStatus (" +
                         (userData == null ? "also missing" : "does have") +
                         " userData).");
                 status = 0;
@@ -733,10 +734,10 @@
         }
 
         if (messageBody != null) {
-            if (false) Log.v(LOG_TAG, "SMS message body: '" + messageBody + "'");
+            if (false) Rlog.v(LOG_TAG, "SMS message body: '" + messageBody + "'");
             parseMessageBody();
         } else if ((userData != null) && (false)) {
-            Log.v(LOG_TAG, "SMS payload: '" + IccUtils.bytesToHexString(userData) + "'");
+            Rlog.v(LOG_TAG, "SMS payload: '" + IccUtils.bytesToHexString(userData) + "'");
         }
     }
 
@@ -746,12 +747,12 @@
     SmsCbMessage parseBroadcastSms() {
         BearerData bData = BearerData.decode(mEnvelope.bearerData, mEnvelope.serviceCategory);
         if (bData == null) {
-            Log.w(LOG_TAG, "BearerData.decode() returned null");
+            Rlog.w(LOG_TAG, "BearerData.decode() returned null");
             return null;
         }
 
-        if (Log.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
-            Log.d(LOG_TAG, "MT raw BearerData = " + HexDump.toHexString(mEnvelope.bearerData));
+        if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
+            Rlog.d(LOG_TAG, "MT raw BearerData = " + HexDump.toHexString(mEnvelope.bearerData));
         }
 
         String plmn = SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC);
@@ -791,9 +792,9 @@
         int msgId = SystemProperties.getInt(TelephonyProperties.PROPERTY_CDMA_MSG_ID, 1);
         String nextMsgId = Integer.toString((msgId % 0xFFFF) + 1);
         SystemProperties.set(TelephonyProperties.PROPERTY_CDMA_MSG_ID, nextMsgId);
-        if (Log.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
-            Log.d(LOG_TAG, "next " + TelephonyProperties.PROPERTY_CDMA_MSG_ID + " = " + nextMsgId);
-            Log.d(LOG_TAG, "readback gets " +
+        if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
+            Rlog.d(LOG_TAG, "next " + TelephonyProperties.PROPERTY_CDMA_MSG_ID + " = " + nextMsgId);
+            Rlog.d(LOG_TAG, "readback gets " +
                     SystemProperties.get(TelephonyProperties.PROPERTY_CDMA_MSG_ID));
         }
         return msgId;
@@ -837,9 +838,9 @@
         bearerData.userData = userData;
 
         byte[] encodedBearerData = BearerData.encode(bearerData);
-        if (Log.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
-            Log.d(LOG_TAG, "MO (encoded) BearerData = " + bearerData);
-            Log.d(LOG_TAG, "MO raw BearerData = '" + HexDump.toHexString(encodedBearerData) + "'");
+        if (Rlog.isLoggable(LOGGABLE_TAG, Log.VERBOSE)) {
+            Rlog.d(LOG_TAG, "MO (encoded) BearerData = " + bearerData);
+            Rlog.d(LOG_TAG, "MO raw BearerData = '" + HexDump.toHexString(encodedBearerData) + "'");
         }
         if (encodedBearerData == null) return null;
 
@@ -887,7 +888,7 @@
             pdu.encodedScAddress = null;
             return pdu;
         } catch(IOException ex) {
-            Log.e(LOG_TAG, "creating SubmitPdu failed: " + ex);
+            Rlog.e(LOG_TAG, "creating SubmitPdu failed: " + ex);
         }
         return null;
     }
@@ -934,7 +935,7 @@
 
             mPdu = baos.toByteArray();
         } catch (IOException ex) {
-            Log.e(LOG_TAG, "createPdu: conversion from object to byte array failed: " + ex);
+            Rlog.e(LOG_TAG, "createPdu: conversion from object to byte array failed: " + ex);
         }
     }
 
diff --git a/src/java/com/android/internal/telephony/cdma/sms/BearerData.java b/src/java/com/android/internal/telephony/cdma/sms/BearerData.java
index d40242c..c6a1d5c 100644
--- a/src/java/com/android/internal/telephony/cdma/sms/BearerData.java
+++ b/src/java/com/android/internal/telephony/cdma/sms/BearerData.java
@@ -21,13 +21,13 @@
 import android.telephony.cdma.CdmaSmsCbProgramData;
 import android.telephony.cdma.CdmaSmsCbProgramResults;
 import android.text.format.Time;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.SmsConstants;
 import com.android.internal.telephony.SmsHeader;
 import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
+import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.util.BitwiseInputStream;
 import com.android.internal.util.BitwiseOutputStream;
 
@@ -70,6 +70,9 @@
     //private final static byte SUBPARAM_ENHANCED_VMN                     = 0x16;
     //private final static byte SUBPARAM_ENHANCED_VMN_ACK                 = 0x17;
 
+    // All other values after this are reserved.
+    private final static byte SUBPARAM_ID_LAST_DEFINED                    = 0x17;
+
     /**
      * Supported message types for CDMA SMS messages
      * (See 3GPP2 C.S0015-B, v2.0, table 4.5.1-1)
@@ -623,11 +626,19 @@
         }
     }
 
+    private static byte[] encodeShiftJis(String msg) throws CodingException {
+        try {
+            return msg.getBytes("Shift_JIS");
+        } catch (java.io.UnsupportedEncodingException ex) {
+            throw new CodingException("Shift-JIS encode failed: " + ex);
+        }
+    }
+
     private static void encodeUserDataPayload(UserData uData)
         throws CodingException
     {
         if ((uData.payloadStr == null) && (uData.msgEncoding != UserData.ENCODING_OCTET)) {
-            Log.e(LOG_TAG, "user data with null payloadStr");
+            Rlog.e(LOG_TAG, "user data with null payloadStr");
             uData.payloadStr = "";
         }
 
@@ -639,7 +650,7 @@
         if (uData.msgEncodingSet) {
             if (uData.msgEncoding == UserData.ENCODING_OCTET) {
                 if (uData.payload == null) {
-                    Log.e(LOG_TAG, "user data with octet encoding but null payload");
+                    Rlog.e(LOG_TAG, "user data with octet encoding but null payload");
                     uData.payload = new byte[0];
                     uData.numFields = 0;
                 } else {
@@ -647,7 +658,7 @@
                 }
             } else {
                 if (uData.payloadStr == null) {
-                    Log.e(LOG_TAG, "non-octet user data with null payloadStr");
+                    Rlog.e(LOG_TAG, "non-octet user data with null payloadStr");
                     uData.payloadStr = "";
                 }
                 if (uData.msgEncoding == UserData.ENCODING_GSM_7BIT_ALPHABET) {
@@ -660,6 +671,9 @@
                 } else if (uData.msgEncoding == UserData.ENCODING_UNICODE_16) {
                     uData.payload = encodeUtf16(uData.payloadStr);
                     uData.numFields = uData.payloadStr.length();
+                } else if (uData.msgEncoding == UserData.ENCODING_SHIFT_JIS) {
+                    uData.payload = encodeShiftJis(uData.payloadStr);
+                    uData.numFields = uData.payload.length;
                 } else {
                     throw new CodingException("unsupported user data encoding (" +
                                               uData.msgEncoding + ")");
@@ -937,9 +951,9 @@
             }
             return outStream.toByteArray();
         } catch (BitwiseOutputStream.AccessException ex) {
-            Log.e(LOG_TAG, "BearerData encode failed: " + ex);
+            Rlog.e(LOG_TAG, "BearerData encode failed: " + ex);
         } catch (CodingException ex) {
-            Log.e(LOG_TAG, "BearerData encode failed: " + ex);
+            Rlog.e(LOG_TAG, "BearerData encode failed: " + ex);
         }
         return null;
    }
@@ -960,7 +974,7 @@
             inStream.skip(3);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "MESSAGE_IDENTIFIER decode " +
+            Rlog.d(LOG_TAG, "MESSAGE_IDENTIFIER decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -968,6 +982,27 @@
         return decodeSuccess;
     }
 
+    private static boolean decodeReserved(
+            BearerData bData, BitwiseInputStream inStream, int subparamId)
+        throws BitwiseInputStream.AccessException, CodingException
+    {
+        boolean decodeSuccess = false;
+        int subparamLen = inStream.read(8); // SUBPARAM_LEN
+        int paramBits = subparamLen * 8;
+        if (paramBits <= inStream.available()) {
+            decodeSuccess = true;
+            inStream.skip(paramBits);
+        }
+        Rlog.d(LOG_TAG, "RESERVED bearer data subparameter " + subparamId + " decode "
+                + (decodeSuccess ? "succeeded" : "failed") + " (param bits = " + paramBits + ")");
+        if (!decodeSuccess) {
+            throw new CodingException("RESERVED bearer data subparameter " + subparamId
+                    + " had invalid SUBPARAM_LEN " + subparamLen);
+        }
+
+        return decodeSuccess;
+    }
+
     private static boolean decodeUserData(BearerData bData, BitwiseInputStream inStream)
         throws BitwiseInputStream.AccessException
     {
@@ -1014,7 +1049,7 @@
             if (maxNumFields < 0) {
                 throw new CodingException(charset + " decode failed: offset out of range");
             }
-            Log.e(LOG_TAG, charset + " decode error: offset = " + offset + " numFields = "
+            Rlog.e(LOG_TAG, charset + " decode error: offset = " + offset + " numFields = "
                     + numFields + " data.length = " + data.length + " maxNumFields = "
                     + maxNumFields);
             numFields = maxNumFields;
@@ -1081,6 +1116,16 @@
         return decodeCharset(data, offset, numFields, 1, "ISO-8859-1");
     }
 
+    private static String decodeShiftJis(byte[] data, int offset, int numFields)
+        throws CodingException
+    {
+        try {
+            return new String(data, offset, numFields - offset, "Shift_JIS");
+        } catch (java.io.UnsupportedEncodingException ex) {
+            throw new CodingException("Shift_JIS decode failed: " + ex);
+        }
+    }
+
     private static void decodeUserDataPayload(UserData userData, boolean hasUserDataHeader)
         throws CodingException
     {
@@ -1132,6 +1177,9 @@
         case UserData.ENCODING_LATIN:
             userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
             break;
+        case UserData.ENCODING_SHIFT_JIS:
+            userData.payloadStr = decodeShiftJis(userData.payload, offset, userData.numFields);
+            break;
         default:
             throw new CodingException("unsupported user data encoding ("
                                       + userData.msgEncoding + ")");
@@ -1271,7 +1319,7 @@
             inStream.skip(4);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "REPLY_OPTION decode " +
+            Rlog.d(LOG_TAG, "REPLY_OPTION decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1291,7 +1339,7 @@
             bData.numberOfMessages = IccUtils.cdmaBcdByteToInt((byte)inStream.read(8));
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "NUMBER_OF_MESSAGES decode " +
+            Rlog.d(LOG_TAG, "NUMBER_OF_MESSAGES decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1311,7 +1359,7 @@
             bData.depositIndex = (inStream.read(8) << 8) | inStream.read(8);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "MESSAGE_DEPOSIT_INDEX decode " +
+            Rlog.d(LOG_TAG, "MESSAGE_DEPOSIT_INDEX decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1353,7 +1401,12 @@
     private static boolean decodeCallbackNumber(BearerData bData, BitwiseInputStream inStream)
         throws BitwiseInputStream.AccessException, CodingException
     {
+        final int EXPECTED_PARAM_SIZE = 1 * 8; //at least
         int paramBits = inStream.read(8) * 8;
+        if (paramBits < EXPECTED_PARAM_SIZE) {
+            inStream.skip(paramBits);
+            return false;
+        }
         CdmaSmsAddress addr = new CdmaSmsAddress();
         addr.digitMode = inStream.read(1);
         byte fieldBits = 4;
@@ -1394,7 +1447,7 @@
             bData.messageStatus = inStream.read(6);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "MESSAGE_STATUS decode " +
+            Rlog.d(LOG_TAG, "MESSAGE_STATUS decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1415,7 +1468,7 @@
             bData.msgCenterTimeStamp = TimeStamp.fromByteArray(inStream.readByteArray(6 * 8));
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "MESSAGE_CENTER_TIME_STAMP decode " +
+            Rlog.d(LOG_TAG, "MESSAGE_CENTER_TIME_STAMP decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1435,7 +1488,7 @@
             bData.validityPeriodAbsolute = TimeStamp.fromByteArray(inStream.readByteArray(6 * 8));
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "VALIDITY_PERIOD_ABSOLUTE decode " +
+            Rlog.d(LOG_TAG, "VALIDITY_PERIOD_ABSOLUTE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1456,7 +1509,7 @@
                     inStream.readByteArray(6 * 8));
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "DEFERRED_DELIVERY_TIME_ABSOLUTE decode " +
+            Rlog.d(LOG_TAG, "DEFERRED_DELIVERY_TIME_ABSOLUTE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1476,7 +1529,7 @@
             bData.deferredDeliveryTimeRelative = inStream.read(8);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "VALIDITY_PERIOD_RELATIVE decode " +
+            Rlog.d(LOG_TAG, "VALIDITY_PERIOD_RELATIVE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1497,7 +1550,7 @@
             bData.validityPeriodRelative = inStream.read(8);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "DEFERRED_DELIVERY_TIME_RELATIVE decode " +
+            Rlog.d(LOG_TAG, "DEFERRED_DELIVERY_TIME_RELATIVE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1519,7 +1572,7 @@
             inStream.skip(6);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "PRIVACY_INDICATOR decode " +
+            Rlog.d(LOG_TAG, "PRIVACY_INDICATOR decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1540,7 +1593,7 @@
             bData.language = inStream.read(8);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "LANGUAGE_INDICATOR decode " +
+            Rlog.d(LOG_TAG, "LANGUAGE_INDICATOR decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1562,7 +1615,7 @@
             inStream.skip(6);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "DISPLAY_MODE decode " +
+            Rlog.d(LOG_TAG, "DISPLAY_MODE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1584,7 +1637,7 @@
             inStream.skip(6);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "PRIORITY_INDICATOR decode " +
+            Rlog.d(LOG_TAG, "PRIORITY_INDICATOR decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1606,7 +1659,7 @@
             inStream.skip(6);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "ALERT_ON_MESSAGE_DELIVERY decode " +
+            Rlog.d(LOG_TAG, "ALERT_ON_MESSAGE_DELIVERY decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1627,7 +1680,7 @@
             bData.userResponseCode = inStream.read(8);
         }
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "USER_RESPONSE_CODE decode " +
+            Rlog.d(LOG_TAG, "USER_RESPONSE_CODE decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ")");
         }
@@ -1689,7 +1742,7 @@
         }
 
         if ((! decodeSuccess) || (paramBits > 0)) {
-            Log.d(LOG_TAG, "SERVICE_CATEGORY_PROGRAM_DATA decode " +
+            Rlog.d(LOG_TAG, "SERVICE_CATEGORY_PROGRAM_DATA decode " +
                       (decodeSuccess ? "succeeded" : "failed") +
                       " (extra bits = " + paramBits + ')');
         }
@@ -1823,7 +1876,7 @@
                     break;
 
                 default:
-                    Log.w(LOG_TAG, "skipping unsupported CMAS record type " + recordType);
+                    Rlog.w(LOG_TAG, "skipping unsupported CMAS record type " + recordType);
                     inStream.skip(recordLen * 8);
                     break;
             }
@@ -1865,7 +1918,15 @@
             while (inStream.available() > 0) {
                 int subparamId = inStream.read(8);
                 int subparamIdBit = 1 << subparamId;
-                if ((foundSubparamMask & subparamIdBit) != 0) {
+                // int is 4 bytes. This duplicate check has a limit to Id number up to 32 (4*8)
+                // as 32th bit is the max bit in int.
+                // Per 3GPP2 C.S0015-B Table 4.5-1 Bearer Data Subparameter Identifiers:
+                // last defined subparam ID is 23 (00010111 = 0x17 = 23).
+                // Only do duplicate subparam ID check if subparam is within defined value as
+                // reserved subparams are just skipped.
+                if ((foundSubparamMask & subparamIdBit) != 0 &&
+                        (subparamId >= SUBPARAM_MESSAGE_IDENTIFIER &&
+                        subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
                     throw new CodingException("illegal duplicate subparameter (" +
                                               subparamId + ")");
                 }
@@ -1929,10 +1990,13 @@
                     decodeSuccess = decodeServiceCategoryProgramData(bData, inStream);
                     break;
                 default:
-                    throw new CodingException("unsupported bearer data subparameter ("
-                                              + subparamId + ")");
+                    decodeSuccess = decodeReserved(bData, inStream, subparamId);
                 }
-                if (decodeSuccess) foundSubparamMask |= subparamIdBit;
+                if (decodeSuccess &&
+                        (subparamId >= SUBPARAM_MESSAGE_IDENTIFIER &&
+                        subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
+                    foundSubparamMask |= subparamIdBit;
+                }
             }
             if ((foundSubparamMask & (1 << SUBPARAM_MESSAGE_IDENTIFIER)) == 0) {
                 throw new CodingException("missing MESSAGE_IDENTIFIER subparam");
@@ -1945,7 +2009,7 @@
                              (1 << SUBPARAM_MESSAGE_IDENTIFIER) ^
                              (1 << SUBPARAM_USER_DATA))
                             != 0) {
-                        Log.e(LOG_TAG, "IS-91 must occur without extra subparams (" +
+                        Rlog.e(LOG_TAG, "IS-91 must occur without extra subparams (" +
                               foundSubparamMask + ")");
                     }
                     decodeIs91(bData);
@@ -1955,9 +2019,9 @@
             }
             return bData;
         } catch (BitwiseInputStream.AccessException ex) {
-            Log.e(LOG_TAG, "BearerData decode failed: " + ex);
+            Rlog.e(LOG_TAG, "BearerData decode failed: " + ex);
         } catch (CodingException ex) {
-            Log.e(LOG_TAG, "BearerData decode failed: " + ex);
+            Rlog.e(LOG_TAG, "BearerData decode failed: " + ex);
         }
         return null;
     }
diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
index 393d101..7c675d8 100644
--- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -35,7 +35,7 @@
 import android.telephony.SignalStrength;
 import com.android.internal.telephony.CallTracker;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import static com.android.internal.telephony.CommandsInterface.CF_ACTION_DISABLE;
 import static com.android.internal.telephony.CommandsInterface.CF_ACTION_ENABLE;
@@ -50,16 +50,13 @@
 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.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.cat.CatService;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallForwardInfo;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.Connection;
-import com.android.internal.telephony.IccFileHandler;
 import com.android.internal.telephony.IccPhoneBookInterfaceManager;
-import com.android.internal.telephony.IccRecords;
 import com.android.internal.telephony.IccSmsInterfaceManager;
 import com.android.internal.telephony.MmiCode;
 import com.android.internal.telephony.OperatorInfo;
@@ -71,11 +68,14 @@
 import com.android.internal.telephony.PhoneSubInfo;
 import com.android.internal.telephony.TelephonyProperties;
 import com.android.internal.telephony.UUSInfo;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
 import com.android.internal.telephony.test.SimulatedRadioControl;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.IccVmNotSupportedException;
+import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
-import com.android.internal.telephony.IccVmNotSupportedException;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.ServiceStateTracker;
 
 import java.io.FileDescriptor;
@@ -176,11 +176,11 @@
                                     try {
                                         Socket sock;
                                         sock = debugSocket.accept();
-                                        Log.i(LOG_TAG, "New connection; resetting radio");
+                                        Rlog.i(LOG_TAG, "New connection; resetting radio");
                                         mCM.resetRadio(null);
                                         sock.close();
                                     } catch (IOException ex) {
-                                        Log.w(LOG_TAG,
+                                        Rlog.w(LOG_TAG,
                                             "Exception accepting socket", ex);
                                     }
                                 }
@@ -191,7 +191,7 @@
                 debugPortThread.start();
 
             } catch (IOException ex) {
-                Log.w(LOG_TAG, "Failure to open com.android.internal.telephony.debug socket", ex);
+                Rlog.w(LOG_TAG, "Failure to open com.android.internal.telephony.debug socket", ex);
             }
         }
 
@@ -228,7 +228,7 @@
 
     @Override
     public void removeReferences() {
-        Log.d(LOG_TAG, "removeReferences");
+        Rlog.d(LOG_TAG, "removeReferences");
         mSimulatedRadioControl = null;
         mSimPhoneBookIntManager = null;
         mSimSmsIntManager = null;
@@ -239,7 +239,7 @@
     }
 
     protected void finalize() {
-        if(LOCAL_DEBUG) Log.d(LOG_TAG, "GSMPhone finalized");
+        if(LOCAL_DEBUG) Rlog.d(LOG_TAG, "GSMPhone finalized");
     }
 
 
@@ -481,16 +481,16 @@
         }
 
         if (getRingingCall().getState() != GsmCall.State.IDLE) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG, "MmiCode 0: rejectCall");
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "MmiCode 0: rejectCall");
             try {
                 mCT.rejectCall();
             } catch (CallStateException e) {
-                if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "reject failed", e);
                 notifySuppServiceFailed(Phone.SuppService.REJECT);
             }
         } else if (getBackgroundCall().getState() != GsmCall.State.IDLE) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG,
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "MmiCode 0: hangupWaitingOrBackground");
             mCT.hangupWaitingOrBackground();
         }
@@ -514,25 +514,25 @@
                 int callIndex = ch - '0';
 
                 if (callIndex >= 1 && callIndex <= GsmCallTracker.MAX_CONNECTIONS) {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                             "MmiCode 1: hangupConnectionByIndex " +
                             callIndex);
                     mCT.hangupConnectionByIndex(call, callIndex);
                 }
             } else {
                 if (call.getState() != GsmCall.State.IDLE) {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                             "MmiCode 1: hangup foreground");
                     //mCT.hangupForegroundResumeBackground();
                     mCT.hangup(call);
                 } else {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                             "MmiCode 1: switchWaitingOrHoldingAndActive");
                     mCT.switchWaitingOrHoldingAndActive();
                 }
             }
         } catch (CallStateException e) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG,
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                 "hangup failed", e);
             notifySuppServiceFailed(Phone.SuppService.HANGUP);
         }
@@ -558,32 +558,32 @@
 
                 // gsm index starts at 1, up to 5 connections in a call,
                 if (conn != null && callIndex >= 1 && callIndex <= GsmCallTracker.MAX_CONNECTIONS) {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG, "MmiCode 2: separate call "+
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "MmiCode 2: separate call "+
                             callIndex);
                     mCT.separate(conn);
                 } else {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG, "separate: invalid call index "+
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "separate: invalid call index "+
                             callIndex);
                     notifySuppServiceFailed(Phone.SuppService.SEPARATE);
                 }
             } catch (CallStateException e) {
-                if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "separate failed", e);
                 notifySuppServiceFailed(Phone.SuppService.SEPARATE);
             }
         } else {
             try {
                 if (getRingingCall().getState() != GsmCall.State.IDLE) {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "MmiCode 2: accept ringing call");
                     mCT.acceptCall();
                 } else {
-                    if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                    if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "MmiCode 2: switchWaitingOrHoldingAndActive");
                     mCT.switchWaitingOrHoldingAndActive();
                 }
             } catch (CallStateException e) {
-                if (LOCAL_DEBUG) Log.d(LOG_TAG,
+                if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                     "switch failed", e);
                 notifySuppServiceFailed(Phone.SuppService.SWITCH);
             }
@@ -598,11 +598,11 @@
             return false;
         }
 
-        if (LOCAL_DEBUG) Log.d(LOG_TAG, "MmiCode 3: merge calls");
+        if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "MmiCode 3: merge calls");
         try {
             conference();
         } catch (CallStateException e) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG,
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                 "conference failed", e);
             notifySuppServiceFailed(Phone.SuppService.CONFERENCE);
         }
@@ -618,11 +618,11 @@
             return false;
         }
 
-        if (LOCAL_DEBUG) Log.d(LOG_TAG, "MmiCode 4: explicit call transfer");
+        if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "MmiCode 4: explicit call transfer");
         try {
             explicitCallTransfer();
         } catch (CallStateException e) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG,
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                 "transfer failed", e);
             notifySuppServiceFailed(Phone.SuppService.TRANSFER);
         }
@@ -635,7 +635,7 @@
             return false;
         }
 
-        Log.i(LOG_TAG, "MmiCode 5: CCBS not supported!");
+        Rlog.i(LOG_TAG, "MmiCode 5: CCBS not supported!");
         // Treat it as an "unknown" service.
         notifySuppServiceFailed(Phone.SuppService.UNKNOWN);
         return true;
@@ -710,7 +710,7 @@
         String networkPortion = PhoneNumberUtils.extractNetworkPortionAlt(newDialString);
         GsmMmiCode mmi =
                 GsmMmiCode.newFromDialString(networkPortion, this, mUiccApplication.get());
-        if (LOCAL_DEBUG) Log.d(LOG_TAG,
+        if (LOCAL_DEBUG) Rlog.d(LOG_TAG,
                                "dialing w/ mmi '" + mmi + "'...");
 
         if (mmi == null) {
@@ -750,7 +750,7 @@
     public void
     sendDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                     "sendDtmf called with invalid character '" + c + "'");
         } else {
             if (mCT.state ==  PhoneConstants.State.OFFHOOK) {
@@ -762,7 +762,7 @@
     public void
     startDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                 "startDtmf called with invalid character '" + c + "'");
         } else {
             mCM.startDtmf(c, null);
@@ -776,7 +776,7 @@
 
     public void
     sendBurstDtmf(String dtmfString) {
-        Log.e(LOG_TAG, "[GSMPhone] sendBurstDtmf() is a CDMA method");
+        Rlog.e(LOG_TAG, "[GSMPhone] sendBurstDtmf() is a CDMA method");
     }
 
     public void
@@ -842,23 +842,23 @@
     }
 
     public String getEsn() {
-        Log.e(LOG_TAG, "[GSMPhone] getEsn() is a CDMA method");
+        Rlog.e(LOG_TAG, "[GSMPhone] getEsn() is a CDMA method");
         return "0";
     }
 
     public String getMeid() {
-        Log.e(LOG_TAG, "[GSMPhone] getMeid() is a CDMA method");
+        Rlog.e(LOG_TAG, "[GSMPhone] getMeid() is a CDMA method");
         return "0";
     }
 
     public String getSubscriberId() {
         IccRecords r = mIccRecords.get();
-        return (r != null) ? r.getIMSI() : "";
+        return (r != null) ? r.getIMSI() : null;
     }
 
     public String getLine1Number() {
         IccRecords r = mIccRecords.get();
-        return (r != null) ? r.getMsisdnNumber() : "";
+        return (r != null) ? r.getMsisdnNumber() : null;
     }
 
     @Override
@@ -924,7 +924,7 @@
 
     public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
         if (isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG, "requesting call forwarding query.");
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "requesting call forwarding query.");
             Message resp;
             if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) {
                 resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete);
@@ -1009,7 +1009,7 @@
         // get the message
         Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm);
         if (LOCAL_DEBUG)
-            Log.d(LOG_TAG, "wrapping and sending message to connect automatically");
+            Rlog.d(LOG_TAG, "wrapping and sending message to connect automatically");
 
         mCM.setNetworkSelectionModeAutomatic(msg);
     }
@@ -1199,7 +1199,7 @@
                     break;
                 }
 
-                if (LOCAL_DEBUG) Log.d(LOG_TAG, "Baseband version: " + ar.result);
+                if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "Baseband version: " + ar.result);
                 setSystemProperty(PROPERTY_BASEBAND_VERSION, (String)ar.result);
             break;
 
@@ -1232,7 +1232,7 @@
                     try {
                         onIncomingUSSD(Integer.parseInt(ussdResult[0]), ussdResult[1]);
                     } catch (NumberFormatException e) {
-                        Log.w(LOG_TAG, "error parsing USSD");
+                        Rlog.w(LOG_TAG, "error parsing USSD");
                     }
                 }
             break;
@@ -1389,7 +1389,7 @@
                 mContext.getContentResolver().insert(uri, map);
                 return true;
             } catch (SQLException e) {
-                Log.e(LOG_TAG, "Can't store current operator", e);
+                Rlog.e(LOG_TAG, "Can't store current operator", e);
             }
         }
         return false;
@@ -1402,7 +1402,7 @@
         // look for our wrapper within the asyncresult, skip the rest if it
         // is null.
         if (!(ar.userObj instanceof NetworkSelectMessage)) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG, "unexpected result from user object.");
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "unexpected result from user object.");
             return;
         }
 
@@ -1411,7 +1411,7 @@
         // found the object, now we send off the message we had originally
         // attached to the request.
         if (nsm.message != null) {
-            if (LOCAL_DEBUG) Log.d(LOG_TAG, "sending original message to recipient");
+            if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "sending original message to recipient");
             AsyncResult.forMessage(nsm.message, ar.result, ar.exception);
             nsm.message.sendToTarget();
         }
@@ -1425,7 +1425,7 @@
 
         // commit and log the result.
         if (! editor.commit()) {
-            Log.e(LOG_TAG, "failed to commit network selection preference");
+            Rlog.e(LOG_TAG, "failed to commit network selection preference");
         }
 
     }
@@ -1442,7 +1442,7 @@
 
         // commit and log the result.
         if (! editor.commit()) {
-            Log.e(LOG_TAG, "failed to commit CLIR preference");
+            Rlog.e(LOG_TAG, "failed to commit CLIR preference");
         }
     }
 
@@ -1493,7 +1493,7 @@
      * @param response Callback message is empty on completion
      */
     public void activateCellBroadcastSms(int activate, Message response) {
-        Log.e(LOG_TAG, "[GSMPhone] activateCellBroadcastSms() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[GSMPhone] activateCellBroadcastSms() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1503,7 +1503,7 @@
      * @param response Callback message is empty on completion
      */
     public void getCellBroadcastSmsConfig(Message response) {
-        Log.e(LOG_TAG, "[GSMPhone] getCellBroadcastSmsConfig() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[GSMPhone] getCellBroadcastSmsConfig() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1513,7 +1513,7 @@
      * @param response Callback message is empty on completion
      */
     public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response) {
-        Log.e(LOG_TAG, "[GSMPhone] setCellBroadcastSmsConfig() is obsolete; use SmsManager");
+        Rlog.e(LOG_TAG, "[GSMPhone] setCellBroadcastSmsConfig() is obsolete; use SmsManager");
         response.sendToTarget();
     }
 
@@ -1561,6 +1561,6 @@
     }
 
     protected void log(String s) {
-        Log.d(LOG_TAG, "[GSMPhone] " + s);
+        Rlog.d(LOG_TAG, "[GSMPhone] " + s);
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/GsmCallTracker.java b/src/java/com/android/internal/telephony/gsm/GsmCallTracker.java
index fc7fe8a..2080976 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmCallTracker.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmCallTracker.java
@@ -27,7 +27,7 @@
 import android.telephony.TelephonyManager;
 import android.telephony.gsm.GsmCellLocation;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.CallTracker;
@@ -114,21 +114,21 @@
             try {
                 if(c != null) hangup(c);
             } catch (CallStateException ex) {
-                Log.e(LOG_TAG, "unexpected error on hangup during dispose");
+                Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
             }
         }
 
         try {
             if(pendingMO != null) hangup(pendingMO);
         } catch (CallStateException ex) {
-            Log.e(LOG_TAG, "unexpected error on hangup during dispose");
+            Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
         }
 
         clearDisconnected();
     }
 
     protected void finalize() {
-        Log.d(LOG_TAG, "GsmCallTracker finalized");
+        Rlog.d(LOG_TAG, "GsmCallTracker finalized");
     }
 
     //***** Instance Methods
@@ -249,7 +249,7 @@
         // is no longer call waiting
 
         if (ringingCall.getState() == GsmCall.State.INCOMING) {
-            Log.i("phone", "acceptCall: incoming...");
+            Rlog.i("phone", "acceptCall: incoming...");
             // Always unmute when answering a new call
             setMute(false);
             cm.acceptCall(obtainCompleteMessage());
@@ -378,7 +378,7 @@
             cm.getCurrentCalls(lastRelevantPoll);
         } else if (pendingOperations < 0) {
             // this should never happen
-            Log.e(LOG_TAG,"GsmCallTracker.pendingOperations < 0");
+            Rlog.e(LOG_TAG,"GsmCallTracker.pendingOperations < 0");
             pendingOperations = 0;
         }
     }
@@ -471,7 +471,7 @@
                                     "poll: hangupPendingMO, hangup conn " + i);
                             hangup(connections[i]);
                         } catch (CallStateException ex) {
-                            Log.e(LOG_TAG, "unexpected error on hangup");
+                            Rlog.e(LOG_TAG, "unexpected error on hangup");
                         }
 
                         // Do not continue processing this poll
@@ -490,14 +490,18 @@
                         // Either we've crashed and re-attached to an existing
                         // call, or something else (eg, SIM) initiated the call.
 
-                        Log.i(LOG_TAG,"Phantom call appeared " + dc);
+                        Rlog.i(LOG_TAG,"Phantom call appeared " + dc);
 
                         // If it's a connected call, set the connect time so that
                         // it's non-zero.  It may not be accurate, but at least
                         // it won't appear as a Missed Call.
                         if (dc.state != DriverCall.State.ALERTING
                                 && dc.state != DriverCall.State.DIALING) {
-                            connections[i].connectTime = System.currentTimeMillis();
+                            connections[i].onConnectedInOrOut();
+                            if (dc.state == DriverCall.State.HOLDING) {
+                                // We've transitioned into HOLDING
+                                connections[i].onStartedHolding();
+                            }
                         }
 
                         unknownConnectionAppeared = true;
@@ -552,7 +556,7 @@
         // We expect the pending call to appear in the list
         // If it does not, we land here
         if (pendingMO != null) {
-            Log.d(LOG_TAG,"Pending MO dropped before poll fg state:"
+            Rlog.d(LOG_TAG,"Pending MO dropped before poll fg state:"
                             + foregroundCall.getState());
 
             droppedDuringPoll.add(pendingMO);
@@ -640,27 +644,27 @@
     dumpState() {
         List l;
 
-        Log.i(LOG_TAG,"Phone State:" + state);
+        Rlog.i(LOG_TAG,"Phone State:" + state);
 
-        Log.i(LOG_TAG,"Ringing call: " + ringingCall.toString());
+        Rlog.i(LOG_TAG,"Ringing call: " + ringingCall.toString());
 
         l = ringingCall.getConnections();
         for (int i = 0, s = l.size(); i < s; i++) {
-            Log.i(LOG_TAG,l.get(i).toString());
+            Rlog.i(LOG_TAG,l.get(i).toString());
         }
 
-        Log.i(LOG_TAG,"Foreground call: " + foregroundCall.toString());
+        Rlog.i(LOG_TAG,"Foreground call: " + foregroundCall.toString());
 
         l = foregroundCall.getConnections();
         for (int i = 0, s = l.size(); i < s; i++) {
-            Log.i(LOG_TAG,l.get(i).toString());
+            Rlog.i(LOG_TAG,l.get(i).toString());
         }
 
-        Log.i(LOG_TAG,"Background call: " + backgroundCall.toString());
+        Rlog.i(LOG_TAG,"Background call: " + backgroundCall.toString());
 
         l = backgroundCall.getConnections();
         for (int i = 0, s = l.size(); i < s; i++) {
-            Log.i(LOG_TAG,l.get(i).toString());
+            Rlog.i(LOG_TAG,l.get(i).toString());
         }
 
     }
@@ -686,7 +690,7 @@
             } catch (CallStateException ex) {
                 // Ignore "connection not found"
                 // Call may have hung up already
-                Log.w(LOG_TAG,"GsmCallTracker WARN: hangup() on absent connection "
+                Rlog.w(LOG_TAG,"GsmCallTracker WARN: hangup() on absent connection "
                                 + conn);
             }
         }
@@ -706,7 +710,7 @@
         } catch (CallStateException ex) {
             // Ignore "connection not found"
             // Call may have hung up already
-            Log.w(LOG_TAG,"GsmCallTracker WARN: separate() on absent connection "
+            Rlog.w(LOG_TAG,"GsmCallTracker WARN: separate() on absent connection "
                           + conn);
         }
     }
@@ -797,7 +801,7 @@
                 cm.hangupConnection(cn.getGSMIndex(), obtainCompleteMessage());
             }
         } catch (CallStateException ex) {
-            Log.e(LOG_TAG, "hangupConnectionByIndex caught " + ex);
+            Rlog.e(LOG_TAG, "hangupConnectionByIndex caught " + ex);
         }
     }
 
@@ -874,7 +878,7 @@
                     // An exception occurred...just treat the disconnect
                     // cause as "normal"
                     causeCode = CallFailCause.NORMAL_CLEARING;
-                    Log.i(LOG_TAG,
+                    Rlog.i(LOG_TAG,
                             "Exception during getLastCallFailCause, assuming normal disconnect");
                 } else {
                     causeCode = ((int[])ar.result)[0];
@@ -923,7 +927,7 @@
     }
 
     protected void log(String msg) {
-        Log.d(LOG_TAG, "[GsmCallTracker] " + msg);
+        Rlog.d(LOG_TAG, "[GsmCallTracker] " + msg);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/gsm/GsmConnection.java b/src/java/com/android/internal/telephony/gsm/GsmConnection.java
index 875b680..9ccc0aa 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmConnection.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmConnection.java
@@ -23,14 +23,15 @@
 import android.os.PowerManager;
 import android.os.Registrant;
 import android.os.SystemClock;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 import android.text.TextUtils;
 
 import com.android.internal.telephony.*;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 /**
  * {@hide}
@@ -88,7 +89,6 @@
     static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
 
     //***** Constants
-    static final int PAUSE_DELAY_FIRST_MILLIS = 100;
     static final int PAUSE_DELAY_MILLIS = 3 * 1000;
     static final int WAKE_LOCK_TIMEOUT_MILLIS = 60*1000;
 
@@ -266,7 +266,7 @@
 
     public void proceedAfterWaitChar() {
         if (postDialState != PostDialState.WAIT) {
-            Log.w(LOG_TAG, "GsmConnection.proceedAfterWaitChar(): Expected "
+            Rlog.w(LOG_TAG, "GsmConnection.proceedAfterWaitChar(): Expected "
                 + "getPostDialState() to be WAIT but was " + postDialState);
             return;
         }
@@ -278,7 +278,7 @@
 
     public void proceedAfterWildChar(String str) {
         if (postDialState != PostDialState.WILD) {
-            Log.w(LOG_TAG, "GsmConnection.proceedAfterWaitChar(): Expected "
+            Rlog.w(LOG_TAG, "GsmConnection.proceedAfterWaitChar(): Expected "
                 + "getPostDialState() to be WILD but was " + postDialState);
             return;
         }
@@ -373,10 +373,11 @@
             default:
                 GSMPhone phone = owner.phone;
                 int serviceState = phone.getServiceState().getState();
-                AppState uiccAppState = UiccController
+                UiccCardApplication cardApp = UiccController
                         .getInstance()
-                        .getUiccCardApplication(UiccController.APP_FAM_3GPP)
-                        .getState();
+                        .getUiccCardApplication(UiccController.APP_FAM_3GPP);
+                AppState uiccAppState = (cardApp != null) ? cardApp.getState() :
+                                                            AppState.APPSTATE_UNKNOWN;
                 if (serviceState == ServiceState.STATE_POWER_OFF) {
                     return DisconnectCause.POWER_OFF;
                 } else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
@@ -421,7 +422,7 @@
             duration = SystemClock.elapsedRealtime() - connectTimeReal;
             disconnected = true;
 
-            if (false) Log.d(LOG_TAG,
+            if (false) Rlog.d(LOG_TAG,
                     "[GSMConn] onDisconnect: cause=" + cause);
 
             owner.phone.notifyDisconnect(this);
@@ -549,7 +550,7 @@
         releaseWakeLock();
     }
 
-    private void
+    /*package*/ void
     onStartedHolding() {
         holdingStartTime = SystemClock.elapsedRealtime();
     }
@@ -564,24 +565,19 @@
             owner.cm.sendDtmf(c, h.obtainMessage(EVENT_DTMF_DONE));
         } else if (c == PhoneNumberUtils.PAUSE) {
             // From TS 22.101:
-
-            // "The first occurrence of the "DTMF Control Digits Separator"
-            //  shall be used by the ME to distinguish between the addressing
-            //  digits (i.e. the phone number) and the DTMF digits...."
-
-            if (nextPostDialChar == 1) {
-                // The first occurrence.
-                // We don't need to pause here, but wait for just a bit anyway
-                h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE),
-                                            PAUSE_DELAY_FIRST_MILLIS);
-            } else {
-                // It continues...
-                // "Upon subsequent occurrences of the separator, the UE shall
-                //  pause again for 3 seconds (\u00B1 20 %) before sending any
-                //  further DTMF digits."
-                h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE),
-                                            PAUSE_DELAY_MILLIS);
-            }
+            // It continues...
+            // Upon the called party answering the UE shall send the DTMF digits
+            // automatically to the network after a delay of 3 seconds(± 20 %).
+            // The digits shall be sent according to the procedures and timing
+            // specified in 3GPP TS 24.008 [13]. The first occurrence of the
+            // "DTMF Control Digits Separator" shall be used by the ME to
+            // distinguish between the addressing digits (i.e. the phone number)
+            // and the DTMF digits. Upon subsequent occurrences of the
+            // separator,
+            // the UE shall pause again for 3 seconds (± 20 %) before sending
+            // any further DTMF digits.
+            h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE),
+                    PAUSE_DELAY_MILLIS);
         } else if (c == PhoneNumberUtils.WAIT) {
             setPostDialState(PostDialState.WAIT);
         } else if (c == PhoneNumberUtils.WILD) {
@@ -616,7 +612,7 @@
          * and or onConnectedInOrOut.
          */
         if (mPartialWakeLock.isHeld()) {
-            Log.e(LOG_TAG, "[GSMConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
+            Rlog.e(LOG_TAG, "[GSMConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
         }
         releaseWakeLock();
     }
@@ -627,7 +623,7 @@
         Registrant postDialHandler;
 
         if (postDialState == PostDialState.CANCELLED) {
-            //Log.v("GSM", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
+            //Rlog.v("GSM", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
             return;
         }
 
@@ -650,7 +646,7 @@
                 // Will call processNextPostDialChar
                 h.obtainMessage(EVENT_NEXT_POST_DIAL).sendToTarget();
                 // Don't notify application
-                Log.e("GSM", "processNextPostDialChar: c=" + c + " isn't valid!");
+                Rlog.e("GSM", "processNextPostDialChar: c=" + c + " isn't valid!");
                 return;
             }
         }
@@ -670,7 +666,7 @@
             // arg1 is the character that was/is being processed
             notifyMessage.arg1 = c;
 
-            //Log.v("GSM", "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
+            //Rlog.v("GSM", "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
             notifyMessage.sendToTarget();
         }
     }
@@ -752,7 +748,7 @@
     }
 
     private void log(String msg) {
-        Log.d(LOG_TAG, "[GSMConn] " + msg);
+        Rlog.d(LOG_TAG, "[GSMConn] " + msg);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/gsm/GsmDataConnection.java b/src/java/com/android/internal/telephony/gsm/GsmDataConnection.java
index 156574d..af36f8e 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmDataConnection.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmDataConnection.java
@@ -17,7 +17,7 @@
 package com.android.internal.telephony.gsm;
 
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Patterns;
 import android.text.TextUtils;
 
@@ -147,7 +147,7 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[" + getName() + "] " + s);
+        Rlog.d(LOG_TAG, "[" + getName() + "] " + s);
     }
 
     private boolean isIpAddress(String address) {
diff --git a/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index bada3d4..ae5fb0f 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -49,7 +49,7 @@
 import android.telephony.gsm.GsmCellLocation;
 import android.text.TextUtils;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.ApnContext;
 import com.android.internal.telephony.ApnSetting;
@@ -62,13 +62,13 @@
 import com.android.internal.telephony.DctConstants;
 import com.android.internal.telephony.EventLogTags;
 import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccRecords;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.RILConstants;
 import com.android.internal.telephony.RetryManager;
-import com.android.internal.telephony.UiccCard;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.UiccCard;
 import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.util.AsyncChannel;
 
@@ -2413,12 +2413,12 @@
 
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[GsmDCT] "+ s);
+        Rlog.d(LOG_TAG, "[GsmDCT] "+ s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[GsmDCT] " + s);
+        Rlog.e(LOG_TAG, "[GsmDCT] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
index 10efdc4..55230f2 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
@@ -18,13 +18,15 @@
 
 import android.content.Context;
 import com.android.internal.telephony.*;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.UiccCardApplication;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 import android.os.*;
 import android.telephony.PhoneNumberUtils;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import static com.android.internal.telephony.CommandsInterface.*;
 
@@ -126,6 +128,7 @@
 
     private boolean isUssdRequest;
 
+    private boolean isCallFwdReg;
     State state = State.PENDING;
     CharSequence message;
 
@@ -476,7 +479,7 @@
 
     static private boolean
     isTwoDigitShortCode(Context context, String dialString) {
-        Log.d(LOG_TAG, "isTwoDigitShortCode");
+        Rlog.d(LOG_TAG, "isTwoDigitShortCode");
 
         if (dialString == null || dialString.length() != 2) return false;
 
@@ -486,13 +489,13 @@
         }
 
         for (String dialnumber : sTwoDigitNumberPattern) {
-            Log.d(LOG_TAG, "Two Digit Number Pattern " + dialnumber);
+            Rlog.d(LOG_TAG, "Two Digit Number Pattern " + dialnumber);
             if (dialString.equals(dialnumber)) {
-                Log.d(LOG_TAG, "Two Digit Number Pattern -true");
+                Rlog.d(LOG_TAG, "Two Digit Number Pattern -true");
                 return true;
             }
         }
-        Log.d(LOG_TAG, "Two Digit Number Pattern -false");
+        Rlog.d(LOG_TAG, "Two Digit Number Pattern -false");
         return false;
     }
 
@@ -536,27 +539,16 @@
      * equal or less then the MAX_LENGTH_SHORT_CODE [constant that is equal to 2]
      *
      * The phone shall initiate a USSD/SS commands.
-     *
-     * Exception (2) to Call initiation is: If the user of the device enters one
-     * Digit followed by the #-key. This rule defines this String as the
-     * #-String which is a USSD/SS command.
-     *
-     * The phone shall initiate a USSD/SS command.
      */
     static private boolean isShortCodeUSSD(String dialString, GSMPhone phone) {
-        if (dialString != null) {
+        if (dialString != null && dialString.length() <= MAX_LENGTH_SHORT_CODE) {
             if (phone.isInCall()) {
-                // The maximum length of a Short Code (aka Short String) is 2
-                if (dialString.length() <= MAX_LENGTH_SHORT_CODE) {
-                    return true;
-                }
+                return true;
             }
 
-            // The maximum length of a Short Code (aka Short String) is 2
-            if (dialString.length() <= MAX_LENGTH_SHORT_CODE) {
-                if (dialString.charAt(dialString.length() - 1) == END_OF_USSD_COMMAND) {
-                    return true;
-                }
+            if (dialString.length() != MAX_LENGTH_SHORT_CODE ||
+                    dialString.charAt(0) != '1') {
+                return true;
             }
         }
         return false;
@@ -637,14 +629,14 @@
     processCode () {
         try {
             if (isShortCode()) {
-                Log.d(LOG_TAG, "isShortCode");
+                Rlog.d(LOG_TAG, "isShortCode");
                 // These just get treated as USSD.
                 sendUssd(dialingNumber);
             } else if (dialingNumber != null) {
                 // We should have no dialing numbers here
                 throw new RuntimeException ("Invalid or Unsupported MMI Code");
             } else if (sc != null && sc.equals(SC_CLIP)) {
-                Log.d(LOG_TAG, "is CLIP");
+                Rlog.d(LOG_TAG, "is CLIP");
                 if (isInterrogate()) {
                     phone.mCM.queryCLIP(
                             obtainMessage(EVENT_QUERY_COMPLETE, this));
@@ -652,7 +644,7 @@
                     throw new RuntimeException ("Invalid or Unsupported MMI Code");
                 }
             } else if (sc != null && sc.equals(SC_CLIR)) {
-                Log.d(LOG_TAG, "is CLIR");
+                Rlog.d(LOG_TAG, "is CLIR");
                 if (isActivate()) {
                     phone.mCM.setCLIR(CommandsInterface.CLIR_INVOCATION,
                         obtainMessage(EVENT_SET_COMPLETE, this));
@@ -666,7 +658,7 @@
                     throw new RuntimeException ("Invalid or Unsupported MMI Code");
                 }
             } else if (isServiceCodeCallForwarding(sc)) {
-                Log.d(LOG_TAG, "is CF");
+                Rlog.d(LOG_TAG, "is CF");
 
                 String dialingNumber = sia;
                 int serviceClass = siToServiceClass(sib);
@@ -681,7 +673,17 @@
                     int cfAction;
 
                     if (isActivate()) {
-                        cfAction = CommandsInterface.CF_ACTION_ENABLE;
+                        // 3GPP TS 22.030 6.5.2
+                        // a call forwarding request with a single * would be
+                        // interpreted as registration if containing a forwarded-to
+                        // number, or an activation if not
+                        if (isEmptyOrNull(dialingNumber)) {
+                            cfAction = CommandsInterface.CF_ACTION_ENABLE;
+                            isCallFwdReg = false;
+                        } else {
+                            cfAction = CommandsInterface.CF_ACTION_REGISTRATION;
+                            isCallFwdReg = true;
+                        }
                     } else if (isDeactivate()) {
                         cfAction = CommandsInterface.CF_ACTION_DISABLE;
                     } else if (isRegister()) {
@@ -702,7 +704,7 @@
                         ((cfAction == CommandsInterface.CF_ACTION_ENABLE) ||
                                 (cfAction == CommandsInterface.CF_ACTION_REGISTRATION)) ? 1 : 0;
 
-                    Log.d(LOG_TAG, "is CF setCallForward");
+                    Rlog.d(LOG_TAG, "is CF setCallForward");
                     phone.mCM.setCallForward(cfAction, reason, serviceClass,
                             dialingNumber, time, obtainMessage(
                                     EVENT_SET_CFF_COMPLETE,
@@ -957,7 +959,7 @@
         if (ar.exception instanceof CommandException) {
             CommandException.Error err = ((CommandException)(ar.exception)).getCommandError();
             if (err == CommandException.Error.FDN_CHECK_FAILURE) {
-                Log.i(LOG_TAG, "FDN_CHECK_FAILURE");
+                Rlog.i(LOG_TAG, "FDN_CHECK_FAILURE");
                 return context.getText(com.android.internal.R.string.mmiFdnError);
             }
         }
@@ -1018,7 +1020,7 @@
                     sb.append(context.getText(
                             com.android.internal.R.string.needPuk2));
                 } else if (err == CommandException.Error.FDN_CHECK_FAILURE) {
-                    Log.i(LOG_TAG, "FDN_CHECK_FAILURE");
+                    Rlog.i(LOG_TAG, "FDN_CHECK_FAILURE");
                     sb.append(context.getText(com.android.internal.R.string.mmiFdnError));
                 } else {
                     sb.append(context.getText(
@@ -1030,8 +1032,13 @@
             }
         } else if (isActivate()) {
             state = State.COMPLETE;
-            sb.append(context.getText(
-                    com.android.internal.R.string.serviceEnabled));
+            if (isCallFwdReg) {
+                sb.append(context.getText(
+                        com.android.internal.R.string.serviceRegistered));
+            } else {
+                sb.append(context.getText(
+                        com.android.internal.R.string.serviceEnabled));
+            }
             // Record CLIR setting
             if (sc.equals(SC_CLIR)) {
                 phone.saveClirSetting(CommandsInterface.CLIR_INVOCATION);
diff --git a/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java b/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
index 9295773..9c22b90 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
@@ -30,11 +30,10 @@
 import android.telephony.SmsCbMessage;
 import android.telephony.SmsManager;
 import android.telephony.gsm.GsmCellLocation;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.SmsConstants;
 import com.android.internal.telephony.SMSDispatcher;
@@ -43,6 +42,8 @@
 import com.android.internal.telephony.SmsStorageMonitor;
 import com.android.internal.telephony.SmsUsageMonitor;
 import com.android.internal.telephony.TelephonyProperties;
+import com.android.internal.telephony.uicc.IccUtils;
+import com.android.internal.telephony.uicc.UsimServiceTable;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -103,10 +104,10 @@
         case EVENT_WRITE_SMS_COMPLETE:
             AsyncResult ar = (AsyncResult) msg.obj;
             if (ar.exception == null) {
-                Log.d(TAG, "Successfully wrote SMS-PP message to UICC");
+                Rlog.d(TAG, "Successfully wrote SMS-PP message to UICC");
                 mCm.acknowledgeLastIncomingGsmSms(true, 0, null);
             } else {
-                Log.d(TAG, "Failed to write SMS-PP message to UICC", ar.exception);
+                Rlog.d(TAG, "Failed to write SMS-PP message to UICC", ar.exception);
                 mCm.acknowledgeLastIncomingGsmSms(false,
                         CommandsInterface.GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR, null);
             }
@@ -160,7 +161,7 @@
 
         // If sms is null, means there was a parsing error.
         if (smsb == null) {
-            Log.e(TAG, "dispatchMessage: message is null");
+            Rlog.e(TAG, "dispatchMessage: message is null");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
 
@@ -169,7 +170,7 @@
         if (sms.isTypeZero()) {
             // As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
             // Displayed/Stored/Notified. They should only be acknowledged.
-            Log.d(TAG, "Received short message type 0, Don't display or store it. Send Ack");
+            Rlog.d(TAG, "Received short message type 0, Don't display or store it. Send Ack");
             return Intents.RESULT_SMS_HANDLED;
         }
 
@@ -182,10 +183,10 @@
             // records have been loaded, after the USIM service table has been loaded.
             if (ust != null && ust.isAvailable(
                     UsimServiceTable.UsimService.DATA_DL_VIA_SMS_PP)) {
-                Log.d(TAG, "Received SMS-PP data download, sending to UICC.");
+                Rlog.d(TAG, "Received SMS-PP data download, sending to UICC.");
                 return mDataDownloadHandler.startDataDownload(sms);
             } else {
-                Log.d(TAG, "DATA_DL_VIA_SMS_PP service not available, storing message to UICC.");
+                Rlog.d(TAG, "DATA_DL_VIA_SMS_PP service not available, storing message to UICC.");
                 String smsc = IccUtils.bytesToHexString(
                         PhoneNumberUtils.networkPortionToCalledPartyBCDWithLength(
                                 sms.getServiceCenterAddress()));
@@ -198,7 +199,7 @@
 
         if (mSmsReceiveDisabled) {
             // Device doesn't support SMS service,
-            Log.d(TAG, "Received short message on device which doesn't support "
+            Rlog.d(TAG, "Received short message on device which doesn't support "
                     + "SMS service. Ignored.");
             return Intents.RESULT_SMS_HANDLED;
         }
@@ -209,13 +210,13 @@
             mPhone.setVoiceMessageWaiting(1, -1);  // line 1: unknown number of msgs waiting
             handled = sms.isMwiDontStore();
             if (false) {
-                Log.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
+                Rlog.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
             }
         } else if (sms.isMWIClearMessage()) {
             mPhone.setVoiceMessageWaiting(1, 0);   // line 1: no msgs waiting
             handled = sms.isMwiDontStore();
             if (false) {
-                Log.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
+                Rlog.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
             }
         }
 
@@ -243,7 +244,7 @@
             sendRawPdu(pdu.encodedScAddress, pdu.encodedMessage, sentIntent, deliveryIntent,
                     destAddr);
         } else {
-            Log.e(TAG, "GsmSMSDispatcher.sendData(): getSubmitPdu() returned null");
+            Rlog.e(TAG, "GsmSMSDispatcher.sendData(): getSubmitPdu() returned null");
         }
     }
 
@@ -257,7 +258,7 @@
             sendRawPdu(pdu.encodedScAddress, pdu.encodedMessage, sentIntent, deliveryIntent,
                     destAddr);
         } else {
-            Log.e(TAG, "GsmSMSDispatcher.sendText(): getSubmitPdu() returned null");
+            Rlog.e(TAG, "GsmSMSDispatcher.sendText(): getSubmitPdu() returned null");
         }
     }
 
@@ -280,7 +281,7 @@
             sendRawPdu(pdu.encodedScAddress, pdu.encodedMessage, sentIntent, deliveryIntent,
                     destinationAddress);
         } else {
-            Log.e(TAG, "GsmSMSDispatcher.sendNewSubmitPdu(): getSubmitPdu() returned null");
+            Rlog.e(TAG, "GsmSMSDispatcher.sendNewSubmitPdu(): getSubmitPdu() returned null");
         }
     }
 
@@ -293,6 +294,21 @@
         byte pdu[] = (byte[]) map.get("pdu");
 
         Message reply = obtainMessage(EVENT_SEND_SMS_COMPLETE, tracker);
+
+        if (tracker.mRetryCount > 0) {
+            Rlog.d(TAG, "sendSms: "
+                    + " mRetryCount=" + tracker.mRetryCount
+                    + " mMessageRef=" + tracker.mMessageRef
+                    + " SS=" + mPhone.getServiceState().getState());
+
+            // per TS 23.040 Section 9.2.3.6:  If TP-MTI SMS-SUBMIT (0x01) type
+            //   TP-RD (bit 2) is 1 for retry
+            //   and TP-MR is set to previously failed sms TP-MR
+            if (((0x01 & pdu[0]) == 0x01)) {
+                pdu[0] |= 0x04; // TP-RD
+                pdu[1] = (byte) tracker.mMessageRef; // TP-MR
+            }
+        }
         mCm.sendSMS(IccUtils.bytesToHexString(smsc), IccUtils.bytesToHexString(pdu), reply);
     }
 
@@ -387,7 +403,7 @@
                         }
                         sb.append(Integer.toHexString(b)).append(' ');
                     }
-                    Log.d(TAG, sb.toString());
+                    Rlog.d(TAG, sb.toString());
                 }
             }
 
@@ -473,7 +489,7 @@
                 }
             }
         } catch (RuntimeException e) {
-            Log.e(TAG, "Error in decoding SMS CB pdu", e);
+            Rlog.e(TAG, "Error in decoding SMS CB pdu", e);
         }
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 6110bd1..25ac850 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -22,8 +22,6 @@
 import com.android.internal.telephony.EventLogTags;
 import com.android.internal.telephony.IccCard;
 import com.android.internal.telephony.IccCardConstants;
-import com.android.internal.telephony.IccCardStatus;
-import com.android.internal.telephony.IccRecords;
 import com.android.internal.telephony.MccTable;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.RestrictedState;
@@ -31,10 +29,13 @@
 import com.android.internal.telephony.ServiceStateTracker;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.TelephonyProperties;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccCardStatus;
+import com.android.internal.telephony.uicc.IccRecords;
+import com.android.internal.telephony.uicc.SIMRecords;
+import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 
 import android.app.AlarmManager;
 import android.app.Notification;
@@ -65,7 +66,7 @@
 import android.telephony.gsm.GsmCellLocation;
 import android.text.TextUtils;
 import android.util.EventLog;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.TimeUtils;
 
 import java.io.FileDescriptor;
@@ -183,7 +184,7 @@
     private ContentObserver mAutoTimeObserver = new ContentObserver(new Handler()) {
         @Override
         public void onChange(boolean selfChange) {
-            Log.i("GsmServiceStateTracker", "Auto time state changed");
+            Rlog.i("GsmServiceStateTracker", "Auto time state changed");
             revertToNitzTime();
         }
     };
@@ -191,7 +192,7 @@
     private ContentObserver mAutoTimeZoneObserver = new ContentObserver(new Handler()) {
         @Override
         public void onChange(boolean selfChange) {
-            Log.i("GsmServiceStateTracker", "Auto time zone state changed");
+            Rlog.i("GsmServiceStateTracker", "Auto time zone state changed");
             revertToNitzTimeZone();
         }
     };
@@ -272,7 +273,7 @@
         Message message;
 
         if (!phone.mIsTheCurrentActivePhone) {
-            Log.e(LOG_TAG, "Received message " + msg +
+            Rlog.e(LOG_TAG, "Received message " + msg +
                     "[" + msg.what + "] while being destroyed. Ignoring.");
             return;
         }
@@ -339,7 +340,7 @@
                                 cid = Integer.parseInt(states[2], 16);
                             }
                         } catch (NumberFormatException ex) {
-                            Log.w(LOG_TAG, "error parsing location: " + ex);
+                            Rlog.w(LOG_TAG, "error parsing location: " + ex);
                         }
                     }
                     cellLoc.setLacAndCid(lac, cid);
@@ -744,6 +745,7 @@
         switch (cm.getRadioState()) {
             case RADIO_UNAVAILABLE:
                 newSS.setStateOutOfService();
+                newGPRSState = ServiceState.STATE_OUT_OF_SERVICE;
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
@@ -753,6 +755,7 @@
 
             case RADIO_OFF:
                 newSS.setStateOff();
+                newGPRSState = ServiceState.STATE_POWER_OFF;
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
@@ -1503,7 +1506,7 @@
                     }
 
                     setAndBroadcastNetworkSetTime(c.getTimeInMillis());
-                    Log.i(LOG_TAG, "NITZ: after Setting time of day");
+                    Rlog.i(LOG_TAG, "NITZ: after Setting time of day");
                 }
                 SystemProperties.set("gsm.nitz.time", String.valueOf(c.getTimeInMillis()));
                 saveNitzTime(c.getTimeInMillis());
@@ -1702,16 +1705,16 @@
     }
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[GsmSST] " + s);
+        Rlog.d(LOG_TAG, "[GsmSST] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[GsmSST] " + s);
+        Rlog.e(LOG_TAG, "[GsmSST] " + s);
     }
 
     private static void sloge(String s) {
-        Log.e(LOG_TAG, "[GsmSST] " + s);
+        Rlog.e(LOG_TAG, "[GsmSST] " + s);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java b/src/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
index 37f9a4f..9c5ce3b 100644
--- a/src/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
@@ -19,10 +19,10 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccFileHandler;
 import com.android.internal.telephony.IccPhoneBookInterfaceManager;
+import com.android.internal.telephony.uicc.IccFileHandler;
 
 /**
  * SimPhoneBookInterfaceManager to provide an inter-process communication to
@@ -46,9 +46,9 @@
         try {
             super.finalize();
         } catch (Throwable throwable) {
-            Log.e(LOG_TAG, "Error while finalizing:", throwable);
+            Rlog.e(LOG_TAG, "Error while finalizing:", throwable);
         }
-        if(DBG) Log.d(LOG_TAG, "SimPhoneBookInterfaceManager finalized");
+        if(DBG) Rlog.d(LOG_TAG, "SimPhoneBookInterfaceManager finalized");
     }
 
     public int[] getAdnRecordsSize(int efid) {
@@ -72,11 +72,11 @@
     }
 
     protected void logd(String msg) {
-        Log.d(LOG_TAG, "[SimPbInterfaceManager] " + msg);
+        Rlog.d(LOG_TAG, "[SimPbInterfaceManager] " + msg);
     }
 
     protected void loge(String msg) {
-        Log.e(LOG_TAG, "[SimPbInterfaceManager] " + msg);
+        Rlog.e(LOG_TAG, "[SimPbInterfaceManager] " + msg);
     }
 }
 
diff --git a/src/java/com/android/internal/telephony/gsm/SimSmsInterfaceManager.java b/src/java/com/android/internal/telephony/gsm/SimSmsInterfaceManager.java
index 92bf390..003a5d3 100644
--- a/src/java/com/android/internal/telephony/gsm/SimSmsInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/gsm/SimSmsInterfaceManager.java
@@ -17,28 +17,16 @@
 package com.android.internal.telephony.gsm;
 
 import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.AsyncResult;
 import android.os.Binder;
-import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccConstants;
 import com.android.internal.telephony.IccSmsInterfaceManager;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.IntRangeManager;
 import com.android.internal.telephony.SMSDispatcher;
-import com.android.internal.telephony.SmsRawData;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static android.telephony.SmsManager.STATUS_ON_ICC_FREE;
 
 /**
  * SimSmsInterfaceManager to provide an inter-process communication to
@@ -48,60 +36,12 @@
     static final String LOG_TAG = "GSM";
     static final boolean DBG = true;
 
-    private final Object mLock = new Object();
-    private boolean mSuccess;
-    private List<SmsRawData> mSms;
-    private HashMap<Integer, HashSet<String>> mCellBroadcastSubscriptions =
-            new HashMap<Integer, HashSet<String>>();
-
     private CellBroadcastRangeManager mCellBroadcastRangeManager =
             new CellBroadcastRangeManager();
 
-    private static final int EVENT_LOAD_DONE = 1;
-    private static final int EVENT_UPDATE_DONE = 2;
-    private static final int EVENT_SET_BROADCAST_ACTIVATION_DONE = 3;
-    private static final int EVENT_SET_BROADCAST_CONFIG_DONE = 4;
     private static final int SMS_CB_CODE_SCHEME_MIN = 0;
     private static final int SMS_CB_CODE_SCHEME_MAX = 255;
 
-    Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            AsyncResult ar;
-
-            switch (msg.what) {
-                case EVENT_UPDATE_DONE:
-                    ar = (AsyncResult) msg.obj;
-                    synchronized (mLock) {
-                        mSuccess = (ar.exception == null);
-                        mLock.notifyAll();
-                    }
-                    break;
-                case EVENT_LOAD_DONE:
-                    ar = (AsyncResult)msg.obj;
-                    synchronized (mLock) {
-                        if (ar.exception == null) {
-                            mSms  = buildValidRawData((ArrayList<byte[]>) ar.result);
-                        } else {
-                            if(DBG) log("Cannot load Sms records");
-                            if (mSms != null)
-                                mSms.clear();
-                        }
-                        mLock.notifyAll();
-                    }
-                    break;
-                case EVENT_SET_BROADCAST_ACTIVATION_DONE:
-                case EVENT_SET_BROADCAST_CONFIG_DONE:
-                    ar = (AsyncResult) msg.obj;
-                    synchronized (mLock) {
-                        mSuccess = (ar.exception == null);
-                        mLock.notifyAll();
-                    }
-                    break;
-            }
-        }
-    };
-
     public SimSmsInterfaceManager(GSMPhone phone, SMSDispatcher dispatcher) {
         super(phone);
         mDispatcher = dispatcher;
@@ -115,105 +55,18 @@
         try {
             super.finalize();
         } catch (Throwable throwable) {
-            Log.e(LOG_TAG, "Error while finalizing:", throwable);
+            Rlog.e(LOG_TAG, "Error while finalizing:", throwable);
         }
-        if(DBG) Log.d(LOG_TAG, "SimSmsInterfaceManager finalized");
+        if(DBG) Rlog.d(LOG_TAG, "SimSmsInterfaceManager finalized");
     }
 
-    /**
-     * Update the specified message on the SIM.
-     *
-     * @param index record index of message to update
-     * @param status new message status (STATUS_ON_ICC_READ,
-     *                  STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
-     *                  STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
-     * @param pdu the raw PDU to store
-     * @return success or not
-     *
-     */
-    public boolean
-    updateMessageOnIccEf(int index, int status, byte[] pdu) {
-        if (DBG) log("updateMessageOnIccEf: index=" + index +
-                " status=" + status + " ==> " +
-                "("+ Arrays.toString(pdu) + ")");
-        enforceReceiveAndSend("Updating message on SIM");
-        synchronized(mLock) {
-            mSuccess = false;
-            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
-
-            if (status == STATUS_ON_ICC_FREE) {
-                // Special case FREE: call deleteSmsOnSim instead of
-                // manipulating the SIM record
-                mPhone.mCM.deleteSmsOnSim(index, response);
-            } else {
-                byte[] record = makeSmsRecordData(status, pdu);
-                mPhone.getIccFileHandler().updateEFLinearFixed(
-                        IccConstants.EF_SMS,
-                        index, record, null, response);
-            }
-            try {
-                mLock.wait();
-            } catch (InterruptedException e) {
-                log("interrupted while trying to update by index");
-            }
-        }
-        return mSuccess;
+    protected void deleteSms(int index, Message response) {
+        mPhone.mCM.deleteSmsOnSim(index, response);
     }
 
-    /**
-     * Copy a raw SMS PDU to the SIM.
-     *
-     * @param pdu the raw PDU to store
-     * @param status message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
-     *               STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)
-     * @return success or not
-     *
-     */
-    public boolean copyMessageToIccEf(int status, byte[] pdu, byte[] smsc) {
-        if (DBG) log("copyMessageToIccEf: status=" + status + " ==> " +
-                "pdu=("+ Arrays.toString(pdu) +
-                "), smsm=(" + Arrays.toString(smsc) +")");
-        enforceReceiveAndSend("Copying message to SIM");
-        synchronized(mLock) {
-            mSuccess = false;
-            Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
-
-            mPhone.mCM.writeSmsToSim(status, IccUtils.bytesToHexString(smsc),
-                    IccUtils.bytesToHexString(pdu), response);
-
-            try {
-                mLock.wait();
-            } catch (InterruptedException e) {
-                log("interrupted while trying to update by index");
-            }
-        }
-        return mSuccess;
-    }
-
-    /**
-     * Retrieves all messages currently stored on ICC.
-     *
-     * @return list of SmsRawData of all sms on ICC
-     */
-    public List<SmsRawData> getAllMessagesFromIccEf() {
-        if (DBG) log("getAllMessagesFromEF");
-
-        Context context = mPhone.getContext();
-
-        context.enforceCallingPermission(
-                "android.permission.RECEIVE_SMS",
-                "Reading messages from SIM");
-        synchronized(mLock) {
-            Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
-            mPhone.getIccFileHandler().loadEFLinearFixedAll(IccConstants.EF_SMS, response);
-
-            try {
-                mLock.wait();
-            } catch (InterruptedException e) {
-                log("interrupted while trying to load from the SIM");
-            }
-        }
-        return mSms;
+    protected void writeSms(int status, byte[] pdu, byte[] smsc, Message response) {
+        mPhone.mCM.writeSmsToSim(status, IccUtils.bytesToHexString(smsc),
+                IccUtils.bytesToHexString(pdu), response);
     }
 
     public boolean enableCellBroadcast(int messageIdentifier) {
@@ -360,6 +213,6 @@
 
     @Override
     protected void log(String msg) {
-        Log.d(LOG_TAG, "[SimSmsInterfaceManager] " + msg);
+        Rlog.d(LOG_TAG, "[SimSmsInterfaceManager] " + msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/SmsMessage.java b/src/java/com/android/internal/telephony/gsm/SmsMessage.java
index 9421dd7..0bf1ea1 100644
--- a/src/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/src/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -18,12 +18,12 @@
 
 import android.telephony.PhoneNumberUtils;
 import android.text.format.Time;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.EncodeException;
 import com.android.internal.telephony.GsmAlphabet;
 import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
-import com.android.internal.telephony.IccUtils;
+import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.telephony.SmsHeader;
 import com.android.internal.telephony.SmsMessageBase;
 
@@ -105,7 +105,7 @@
             msg.parsePdu(pdu);
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
             return null;
         }
     }
@@ -133,7 +133,7 @@
             msg.parsePdu(IccUtils.hexStringToBytes(lines[1]));
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
             return null;
         }
     }
@@ -145,7 +145,7 @@
             msg.parsePdu(IccUtils.hexStringToBytes(line));
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "CDS SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "CDS SMS PDU parsing failed: ", ex);
             return null;
         }
     }
@@ -170,7 +170,7 @@
             // or STORED_UNSENT
             // See TS 51.011 10.5.3
             if ((data[0] & 1) == 0) {
-                Log.w(LOG_TAG,
+                Rlog.w(LOG_TAG,
                         "SMS parsing failed: Trying to parse a free record");
                 return null;
             } else {
@@ -186,7 +186,7 @@
             msg.parsePdu(pdu);
             return msg;
         } catch (RuntimeException ex) {
-            Log.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
+            Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
             return null;
         }
     }
@@ -256,7 +256,7 @@
                     SmsHeader smsHeader = SmsHeader.fromByteArray(header);
                     if (smsHeader.languageTable != languageTable
                             || smsHeader.languageShiftTable != languageShiftTable) {
-                        Log.w(LOG_TAG, "Updating language table in SMS header: "
+                        Rlog.w(LOG_TAG, "Updating language table in SMS header: "
                                 + smsHeader.languageTable + " -> " + languageTable + ", "
                                 + smsHeader.languageShiftTable + " -> " + languageShiftTable);
                         smsHeader.languageTable = languageTable;
@@ -289,7 +289,7 @@
                 try {
                     userData = encodeUCS2(message, header);
                 } catch(UnsupportedEncodingException uex) {
-                    Log.e(LOG_TAG,
+                    Rlog.e(LOG_TAG,
                             "Implausible UnsupportedEncodingException ",
                             uex);
                     return null;
@@ -302,7 +302,7 @@
                 userData = encodeUCS2(message, header);
                 encoding = ENCODING_16BIT;
             } catch(UnsupportedEncodingException uex) {
-                Log.e(LOG_TAG,
+                Rlog.e(LOG_TAG,
                         "Implausible UnsupportedEncodingException ",
                         uex);
                 return null;
@@ -312,7 +312,7 @@
         if (encoding == ENCODING_7BIT) {
             if ((0xff & userData[0]) > MAX_USER_DATA_SEPTETS) {
                 // Message too long
-                Log.e(LOG_TAG, "Message too long (" + (0xff & userData[0]) + " septets)");
+                Rlog.e(LOG_TAG, "Message too long (" + (0xff & userData[0]) + " septets)");
                 return null;
             }
             // TP-Data-Coding-Scheme
@@ -327,7 +327,7 @@
         } else { // assume UCS-2
             if ((0xff & userData[0]) > MAX_USER_DATA_BYTES) {
                 // Message too long
-                Log.e(LOG_TAG, "Message too long (" + (0xff & userData[0]) + " bytes)");
+                Rlog.e(LOG_TAG, "Message too long (" + (0xff & userData[0]) + " bytes)");
                 return null;
             }
             // TP-Data-Coding-Scheme
@@ -411,7 +411,7 @@
         byte[] smsHeaderData = SmsHeader.toByteArray(smsHeader);
 
         if ((data.length + smsHeaderData.length + 1) > MAX_USER_DATA_BYTES) {
-            Log.e(LOG_TAG, "SMS data message may only contain "
+            Rlog.e(LOG_TAG, "SMS data message may only contain "
                     + (MAX_USER_DATA_BYTES - smsHeaderData.length - 1) + " bytes");
             return null;
         }
@@ -472,7 +472,7 @@
         if (statusReportRequested) {
             // Set TP-Status-Report-Request bit.
             mtiByte |= 0x20;
-            if (false) Log.d(LOG_TAG, "SMS status report requested");
+            if (false) Rlog.d(LOG_TAG, "SMS status report requested");
         }
         bo.write(mtiByte);
 
@@ -530,7 +530,7 @@
                     ret = PhoneNumberUtils
                             .calledPartyBCDToString(pdu, cur, len);
                 } catch (RuntimeException tr) {
-                    Log.d(LOG_TAG, "invalid SC address: ", tr);
+                    Rlog.d(LOG_TAG, "invalid SC address: ", tr);
                     ret = null;
                 }
             }
@@ -564,7 +564,7 @@
             try {
                 ret = new GsmSmsAddress(pdu, cur, lengthBytes);
             } catch (ParseException e) {
-                Log.e(LOG_TAG, e.getMessage());
+                Rlog.e(LOG_TAG, e.getMessage());
                 ret = null;
             }
 
@@ -738,7 +738,7 @@
                 ret = new String(pdu, cur, byteCount, "utf-16");
             } catch (UnsupportedEncodingException ex) {
                 ret = "";
-                Log.e(LOG_TAG, "implausible UnsupportedEncodingException", ex);
+                Rlog.e(LOG_TAG, "implausible UnsupportedEncodingException", ex);
             }
 
             cur += byteCount;
@@ -759,7 +759,7 @@
                 ret = new String(pdu, cur, byteCount, "KSC5601");
             } catch (UnsupportedEncodingException ex) {
                 ret = "";
-                Log.e(LOG_TAG, "implausible UnsupportedEncodingException", ex);
+                Rlog.e(LOG_TAG, "implausible UnsupportedEncodingException", ex);
             }
 
             cur += byteCount;
@@ -862,9 +862,8 @@
             // If the user data is a single space char, do not store
             // the message. Otherwise, store and display as usual
             if (" ".equals(getMessageBody())) {
-                ;
+                return true;
             }
-            return true;
         }
 
         return false;
@@ -898,15 +897,15 @@
      */
     private void parsePdu(byte[] pdu) {
         mPdu = pdu;
-        // Log.d(LOG_TAG, "raw sms message:");
-        // Log.d(LOG_TAG, s);
+        // Rlog.d(LOG_TAG, "raw sms message:");
+        // Rlog.d(LOG_TAG, s);
 
         PduParser p = new PduParser(pdu);
 
         scAddress = p.getSCAddress();
 
         if (scAddress != null) {
-            if (false) Log.d(LOG_TAG, "SMS SC address: " + scAddress);
+            if (false) Rlog.d(LOG_TAG, "SMS SC address: " + scAddress);
         }
 
         // TODO(mkf) support reply path, user data header indicator
@@ -924,6 +923,9 @@
                 //This should be processed in the same way as MTI == 0 (Deliver)
             parseSmsDeliver(p, firstByte);
             break;
+        case 1:
+            parseSmsSubmit(p, firstByte);
+            break;
         case 2:
             parseSmsStatusReport(p, firstByte);
             break;
@@ -992,7 +994,7 @@
         originatingAddress = p.getAddress();
 
         if (originatingAddress != null) {
-            if (false) Log.v(LOG_TAG, "SMS originating address: "
+            if (false) Rlog.v(LOG_TAG, "SMS originating address: "
                     + originatingAddress.address);
         }
 
@@ -1005,13 +1007,72 @@
         dataCodingScheme = p.getByte();
 
         if (false) {
-            Log.v(LOG_TAG, "SMS TP-PID:" + protocolIdentifier
+            Rlog.v(LOG_TAG, "SMS TP-PID:" + protocolIdentifier
                     + " data coding scheme: " + dataCodingScheme);
         }
 
         scTimeMillis = p.getSCTimestampMillis();
 
-        if (false) Log.d(LOG_TAG, "SMS SC timestamp: " + scTimeMillis);
+        if (false) Rlog.d(LOG_TAG, "SMS SC timestamp: " + scTimeMillis);
+
+        boolean hasUserDataHeader = (firstByte & 0x40) == 0x40;
+
+        parseUserData(p, hasUserDataHeader);
+    }
+
+    /**
+     * Parses a SMS-SUBMIT message.
+     *
+     * @param p A PduParser, cued past the first byte.
+     * @param firstByte The first byte of the PDU, which contains MTI, etc.
+     */
+    private void parseSmsSubmit(PduParser p, int firstByte) {
+        replyPathPresent = (firstByte & 0x80) == 0x80;
+
+        // TP-MR (TP-Message Reference)
+        messageRef = p.getByte();
+
+        recipientAddress = p.getAddress();
+
+        if (recipientAddress != null) {
+            if (false) Rlog.v(LOG_TAG, "SMS recipient address: "
+                    + recipientAddress.address);
+        }
+
+        // TP-Protocol-Identifier (TP-PID)
+        // TS 23.040 9.2.3.9
+        protocolIdentifier = p.getByte();
+
+        // TP-Data-Coding-Scheme
+        // see TS 23.038
+        dataCodingScheme = p.getByte();
+
+        if (false) {
+            Rlog.v(LOG_TAG, "SMS TP-PID:" + protocolIdentifier
+                    + " data coding scheme: " + dataCodingScheme);
+        }
+
+        // TP-Validity-Period-Format
+        int validityPeriodLength = 0;
+        int validityPeriodFormat = ((firstByte>>3) & 0x3);
+        if (0x0 == validityPeriodFormat) /* 00, TP-VP field not present*/
+        {
+            validityPeriodLength = 0;
+        }
+        else if (0x2 == validityPeriodFormat) /* 10, TP-VP: relative format*/
+        {
+            validityPeriodLength = 1;
+        }
+        else /* other case, 11 or 01, TP-VP: absolute or enhanced format*/
+        {
+            validityPeriodLength = 7;
+        }
+
+        // TP-Validity-Period is not used on phone, so just ignore it for now.
+        while (validityPeriodLength-- > 0)
+        {
+            p.getByte();
+        }
 
         boolean hasUserDataHeader = (firstByte & 0x40) == 0x40;
 
@@ -1039,7 +1100,7 @@
             hasMessageClass = (0 != (dataCodingScheme & 0x10));
 
             if (userDataCompressed) {
-                Log.w(LOG_TAG, "4 - Unsupported SMS data coding scheme "
+                Rlog.w(LOG_TAG, "4 - Unsupported SMS data coding scheme "
                         + "(compression) " + (dataCodingScheme & 0xff));
             } else {
                 switch ((dataCodingScheme >> 2) & 0x3) {
@@ -1053,7 +1114,7 @@
 
                 case 1: // 8 bit data
                 case 3: // reserved
-                    Log.w(LOG_TAG, "1 - Unsupported SMS data coding scheme "
+                    Rlog.w(LOG_TAG, "1 - Unsupported SMS data coding scheme "
                             + (dataCodingScheme & 0xff));
                     encodingType = ENCODING_8BIT;
                     break;
@@ -1098,7 +1159,7 @@
             } else {
                 isMwi = false;
 
-                Log.w(LOG_TAG, "MWI for fax, email, or other "
+                Rlog.w(LOG_TAG, "MWI for fax, email, or other "
                         + (dataCodingScheme & 0xff));
             }
         } else if ((dataCodingScheme & 0xC0) == 0x80) {
@@ -1108,11 +1169,11 @@
                 // This value used for KSC5601 by carriers in Korea.
                 encodingType = ENCODING_KSC5601;
             } else {
-                Log.w(LOG_TAG, "5 - Unsupported SMS data coding scheme "
+                Rlog.w(LOG_TAG, "5 - Unsupported SMS data coding scheme "
                         + (dataCodingScheme & 0xff));
             }
         } else {
-            Log.w(LOG_TAG, "3 - Unsupported SMS data coding scheme "
+            Rlog.w(LOG_TAG, "3 - Unsupported SMS data coding scheme "
                     + (dataCodingScheme & 0xff));
         }
 
@@ -1143,7 +1204,7 @@
             break;
         }
 
-        if (false) Log.v(LOG_TAG, "SMS message body (raw): '" + messageBody + "'");
+        if (false) Rlog.v(LOG_TAG, "SMS message body (raw): '" + messageBody + "'");
 
         if (messageBody != null) {
             parseMessageBody();
diff --git a/src/java/com/android/internal/telephony/gsm/UsimDataDownloadHandler.java b/src/java/com/android/internal/telephony/gsm/UsimDataDownloadHandler.java
index f47ff1b..108cf5d 100644
--- a/src/java/com/android/internal/telephony/gsm/UsimDataDownloadHandler.java
+++ b/src/java/com/android/internal/telephony/gsm/UsimDataDownloadHandler.java
@@ -21,12 +21,12 @@
 import android.os.Handler;
 import android.os.Message;
 import android.provider.Telephony.Sms.Intents;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccIoResult;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.cat.ComprehensionTlvTag;
+import com.android.internal.telephony.uicc.IccIoResult;
+import com.android.internal.telephony.uicc.IccUtils;
 
 /**
  * Handler for SMS-PP data download messages.
@@ -67,7 +67,7 @@
         if (sendMessage(obtainMessage(EVENT_START_DATA_DOWNLOAD, smsMessage))) {
             return Activity.RESULT_OK;  // we will send SMS ACK/ERROR based on UICC response
         } else {
-            Log.e(TAG, "startDataDownload failed to send message to start data download.");
+            Rlog.e(TAG, "startDataDownload failed to send message to start data download.");
             return Intents.RESULT_SMS_GENERIC_ERROR;
         }
     }
@@ -122,7 +122,7 @@
 
         // Verify that we calculated the payload size correctly.
         if (index != envelope.length) {
-            Log.e(TAG, "startDataDownload() calculated incorrect envelope length, aborting.");
+            Rlog.e(TAG, "startDataDownload() calculated incorrect envelope length, aborting.");
             acknowledgeSmsWithError(CommandsInterface.GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR);
             return;
         }
@@ -164,17 +164,17 @@
 
         boolean success;
         if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
-            Log.d(TAG, "USIM data download succeeded: " + response.toString());
+            Rlog.d(TAG, "USIM data download succeeded: " + response.toString());
             success = true;
         } else if (sw1 == 0x93 && sw2 == 0x00) {
-            Log.e(TAG, "USIM data download failed: Toolkit busy");
+            Rlog.e(TAG, "USIM data download failed: Toolkit busy");
             acknowledgeSmsWithError(CommandsInterface.GSM_SMS_FAIL_CAUSE_USIM_APP_TOOLKIT_BUSY);
             return;
         } else if (sw1 == 0x62 || sw1 == 0x63) {
-            Log.e(TAG, "USIM data download failed: " + response.toString());
+            Rlog.e(TAG, "USIM data download failed: " + response.toString());
             success = false;
         } else {
-            Log.e(TAG, "Unexpected SW1/SW2 response from UICC: " + response.toString());
+            Rlog.e(TAG, "Unexpected SW1/SW2 response from UICC: " + response.toString());
             success = false;
         }
 
@@ -250,7 +250,7 @@
                 AsyncResult ar = (AsyncResult) msg.obj;
 
                 if (ar.exception != null) {
-                    Log.e(TAG, "UICC Send Envelope failure, exception: " + ar.exception);
+                    Rlog.e(TAG, "UICC Send Envelope failure, exception: " + ar.exception);
                     acknowledgeSmsWithError(
                             CommandsInterface.GSM_SMS_FAIL_CAUSE_USIM_DATA_DOWNLOAD_ERROR);
                     return;
@@ -261,7 +261,7 @@
                 break;
 
             default:
-                Log.e(TAG, "Ignoring unexpected message, what=" + msg.what);
+                Rlog.e(TAG, "Ignoring unexpected message, what=" + msg.what);
         }
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java b/src/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
index 8f5a420..f46b461 100755
--- a/src/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
+++ b/src/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
@@ -19,14 +19,14 @@
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.AdnRecord;
-import com.android.internal.telephony.AdnRecordCache;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.PhoneBase;
+import com.android.internal.telephony.uicc.AdnRecord;
+import com.android.internal.telephony.uicc.AdnRecordCache;
+import com.android.internal.telephony.uicc.IccConstants;
+import com.android.internal.telephony.uicc.IccFileHandler;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -143,7 +143,7 @@
         try {
             mLock.wait();
         } catch (InterruptedException e) {
-            Log.e(LOG_TAG, "Interrupted Exception in readAdnFileAndWait");
+            Rlog.e(LOG_TAG, "Interrupted Exception in readAdnFileAndWait");
         }
     }
 
@@ -161,7 +161,7 @@
             if (mEmailPresentInIap) {
                 readIapFileAndWait(fileIds.get(USIM_EFIAP_TAG));
                 if (mIapFileRecord == null) {
-                    Log.e(LOG_TAG, "Error: IAP file is empty");
+                    Rlog.e(LOG_TAG, "Error: IAP file is empty");
                     return;
                 }
             }
@@ -171,11 +171,11 @@
             try {
                 mLock.wait();
             } catch (InterruptedException e) {
-                Log.e(LOG_TAG, "Interrupted Exception in readEmailFileAndWait");
+                Rlog.e(LOG_TAG, "Interrupted Exception in readEmailFileAndWait");
             }
 
             if (mEmailFileRecord == null) {
-                Log.e(LOG_TAG, "Error: Email file is empty");
+                Rlog.e(LOG_TAG, "Error: Email file is empty");
                 return;
             }
             updatePhoneAdnRecord();
@@ -188,7 +188,7 @@
         try {
             mLock.wait();
         } catch (InterruptedException e) {
-            Log.e(LOG_TAG, "Interrupted Exception in readIapFileAndWait");
+            Rlog.e(LOG_TAG, "Interrupted Exception in readIapFileAndWait");
         }
     }
 
@@ -206,7 +206,7 @@
                 try {
                     record = mIapFileRecord.get(i);
                 } catch (IndexOutOfBoundsException e) {
-                    Log.e(LOG_TAG, "Error: Improper ICC card: No IAP record for ADN, continuing");
+                    Rlog.e(LOG_TAG, "Error: Improper ICC card: No IAP record for ADN, continuing");
                     break;
                 }
                 int recNum = record[mEmailTagNumberInIap];
@@ -262,7 +262,7 @@
             try {
                 emailRec = mEmailFileRecord.get(i);
             } catch (IndexOutOfBoundsException e) {
-                Log.e(LOG_TAG, "Error: Improper ICC card: No email record for ADN, continuing");
+                Rlog.e(LOG_TAG, "Error: Improper ICC card: No email record for ADN, continuing");
                 break;
             }
             int adnRecNum = emailRec[emailRec.length - 1];
@@ -318,7 +318,7 @@
         try {
             mLock.wait();
         } catch (InterruptedException e) {
-            Log.e(LOG_TAG, "Interrupted Exception in readAdnFileAndWait");
+            Rlog.e(LOG_TAG, "Interrupted Exception in readAdnFileAndWait");
         }
     }
 
@@ -448,6 +448,6 @@
     }
 
     private void log(String msg) {
-        if(DBG) Log.d(LOG_TAG, msg);
+        if(DBG) Rlog.d(LOG_TAG, msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/sip/SipCommandInterface.java b/src/java/com/android/internal/telephony/sip/SipCommandInterface.java
index 99f4e0f..33a61f5 100644
--- a/src/java/com/android/internal/telephony/sip/SipCommandInterface.java
+++ b/src/java/com/android/internal/telephony/sip/SipCommandInterface.java
@@ -23,6 +23,7 @@
 import com.android.internal.telephony.BaseCommands;
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.UUSInfo;
+import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 
 /**
@@ -382,7 +383,7 @@
     public void getCdmaBroadcastConfig(Message response) {
     }
 
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
+    public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response) {
     }
 
     public void setCdmaBroadcastActivation(boolean activate, Message response) {
diff --git a/src/java/com/android/internal/telephony/sip/SipConnectionBase.java b/src/java/com/android/internal/telephony/sip/SipConnectionBase.java
index eaba2c4..eca4a50 100644
--- a/src/java/com/android/internal/telephony/sip/SipConnectionBase.java
+++ b/src/java/com/android/internal/telephony/sip/SipConnectionBase.java
@@ -24,7 +24,7 @@
 
 import android.net.sip.SipAudioCall;
 import android.os.SystemClock;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.telephony.PhoneNumberUtils;
 
 abstract class SipConnectionBase extends Connection {
@@ -165,7 +165,7 @@
     }
 
     private void log(String msg) {
-        Log.d(LOG_TAG, "[SipConn] " + msg);
+        Rlog.d(LOG_TAG, "[SipConn] " + msg);
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/sip/SipPhone.java b/src/java/com/android/internal/telephony/sip/SipPhone.java
index 346b126..24651df 100644
--- a/src/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/src/java/com/android/internal/telephony/sip/SipPhone.java
@@ -30,7 +30,7 @@
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
@@ -64,7 +64,7 @@
     SipPhone (Context context, PhoneNotifier notifier, SipProfile profile) {
         super(context, notifier);
 
-        if (DEBUG) Log.d(LOG_TAG, "new SipPhone: " + profile.getUriString());
+        if (DEBUG) Rlog.d(LOG_TAG, "new SipPhone: " + profile.getUriString());
         ringingCall = new SipCall();
         foregroundCall = new SipCall();
         backgroundCall = new SipCall();
@@ -106,7 +106,7 @@
 
             try {
                 SipAudioCall sipAudioCall = (SipAudioCall) incomingCall;
-                if (DEBUG) Log.d(LOG_TAG, "+++ taking call from: "
+                if (DEBUG) Rlog.d(LOG_TAG, "+++ taking call from: "
                         + sipAudioCall.getPeerProfile().getUriString());
                 String localUri = sipAudioCall.getLocalProfile().getUriString();
                 if (localUri.equals(mProfile.getUriString())) {
@@ -115,7 +115,7 @@
                     if (sipAudioCall.getState()
                             != SipSession.State.INCOMING_CALL) {
                         // Peer cancelled the call!
-                        if (DEBUG) Log.d(LOG_TAG, "    call cancelled !!");
+                        if (DEBUG) Rlog.d(LOG_TAG, "    call cancelled !!");
                         ringingCall.reset();
                     }
                     return true;
@@ -134,7 +134,7 @@
         synchronized (SipPhone.class) {
             if ((ringingCall.getState() == Call.State.INCOMING) ||
                     (ringingCall.getState() == Call.State.WAITING)) {
-                if (DEBUG) Log.d(LOG_TAG, "acceptCall");
+                if (DEBUG) Rlog.d(LOG_TAG, "acceptCall");
                 // Always unmute when answering a new call
                 ringingCall.setMute(false);
                 ringingCall.acceptCall();
@@ -147,7 +147,7 @@
     public void rejectCall() throws CallStateException {
         synchronized (SipPhone.class) {
             if (ringingCall.getState().isRinging()) {
-                if (DEBUG) Log.d(LOG_TAG, "rejectCall");
+                if (DEBUG) Rlog.d(LOG_TAG, "rejectCall");
                 ringingCall.rejectCall();
             } else {
                 throw new CallStateException("phone not ringing");
@@ -181,13 +181,13 @@
             Connection c = foregroundCall.dial(dialString);
             return c;
         } catch (SipException e) {
-            Log.e(LOG_TAG, "dial()", e);
+            Rlog.e(LOG_TAG, "dial()", e);
             throw new CallStateException("dial error: " + e);
         }
     }
 
     public void switchHoldingAndActive() throws CallStateException {
-        if (DEBUG) Log.d(LOG_TAG, " ~~~~~~  switch fg and bg");
+        if (DEBUG) Rlog.d(LOG_TAG, " ~~~~~~  switch fg and bg");
         synchronized (SipPhone.class) {
             foregroundCall.switchWith(backgroundCall);
             if (backgroundCall.getState().isAlive()) backgroundCall.hold();
@@ -242,7 +242,7 @@
 
     public void sendDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                     "sendDtmf called with invalid character '" + c + "'");
         } else if (foregroundCall.getState().isAlive()) {
             synchronized (SipPhone.class) {
@@ -253,7 +253,7 @@
 
     public void startDtmf(char c) {
         if (!PhoneNumberUtils.is12Key(c)) {
-            Log.e(LOG_TAG,
+            Rlog.e(LOG_TAG,
                 "startDtmf called with invalid character '" + c + "'");
         } else {
             sendDtmf(c);
@@ -265,7 +265,7 @@
     }
 
     public void sendBurstDtmf(String dtmfString) {
-        Log.e(LOG_TAG, "[SipPhone] sendBurstDtmf() is a CDMA method");
+        Rlog.e(LOG_TAG, "[SipPhone] sendBurstDtmf() is a CDMA method");
     }
 
     public void getOutgoingCallerIdDisplay(Message onComplete) {
@@ -289,7 +289,7 @@
 
     public void setCallWaiting(boolean enable, Message onComplete) {
         // FIXME: what to reply?
-        Log.e(LOG_TAG, "call waiting not supported");
+        Rlog.e(LOG_TAG, "call waiting not supported");
     }
 
     @Override
@@ -410,7 +410,7 @@
         public void hangup() throws CallStateException {
             synchronized (SipPhone.class) {
                 if (state.isAlive()) {
-                    if (DEBUG) Log.d(LOG_TAG, "hang up call: " + getState()
+                    if (DEBUG) Rlog.d(LOG_TAG, "hang up call: " + getState()
                             + ": " + this + " on phone " + getPhone());
                     setState(State.DISCONNECTING);
                     CallStateException excp = null;
@@ -423,7 +423,7 @@
                     }
                     if (excp != null) throw excp;
                 } else {
-                    if (DEBUG) Log.d(LOG_TAG, "hang up dead call: " + getState()
+                    if (DEBUG) Rlog.d(LOG_TAG, "hang up dead call: " + getState()
                             + ": " + this + " on phone " + getPhone());
                 }
             }
@@ -473,7 +473,7 @@
             } else {
                 audioGroup.setMode(AudioGroup.MODE_NORMAL);
             }
-            if (DEBUG) Log.d(LOG_TAG, String.format(
+            if (DEBUG) Rlog.d(LOG_TAG, String.format(
                     "audioGroup mode change: %d --> %d", mode,
                     audioGroup.getMode()));
         }
@@ -558,7 +558,7 @@
         @Override
         protected void setState(State newState) {
             if (state != newState) {
-                if (DEBUG) Log.v(LOG_TAG, "+***+ call state changed: " + state
+                if (DEBUG) Rlog.v(LOG_TAG, "+***+ call state changed: " + state
                         + " --> " + newState + ": " + this + ": on phone "
                         + getPhone() + " " + connections.size());
 
@@ -585,10 +585,10 @@
             // set state to DISCONNECTED only when all conns are disconnected
             if (state != State.DISCONNECTED) {
                 boolean allConnectionsDisconnected = true;
-                if (DEBUG) Log.d(LOG_TAG, "---check connections: "
+                if (DEBUG) Rlog.d(LOG_TAG, "---check connections: "
                         + connections.size());
                 for (Connection c : connections) {
-                    if (DEBUG) Log.d(LOG_TAG, "   state=" + c.getState() + ": "
+                    if (DEBUG) Rlog.d(LOG_TAG, "   state=" + c.getState() + ": "
                             + c);
                     if (c.getState() != State.DISCONNECTED) {
                         allConnectionsDisconnected = false;
@@ -627,7 +627,7 @@
                     String sessionState = (sipAudioCall == null)
                             ? ""
                             : (sipAudioCall.getState() + ", ");
-                    if (DEBUG) Log.d(LOG_TAG, "--- connection ended: "
+                    if (DEBUG) Rlog.d(LOG_TAG, "--- connection ended: "
                             + mPeer.getUriString() + ": " + sessionState
                             + "cause: " + getDisconnectCause() + ", on phone "
                             + getPhone());
@@ -674,7 +674,7 @@
                         setState(newState);
                     }
                     mOwner.onConnectionStateChanged(SipConnection.this);
-                    if (DEBUG) Log.v(LOG_TAG, "+***+ connection state changed: "
+                    if (DEBUG) Rlog.v(LOG_TAG, "+***+ connection state changed: "
                             + mPeer.getUriString() + ": " + mState
                             + " on phone " + getPhone());
                 }
@@ -682,7 +682,7 @@
 
             @Override
             protected void onError(DisconnectCause cause) {
-                if (DEBUG) Log.d(LOG_TAG, "SIP error: " + cause);
+                if (DEBUG) Rlog.d(LOG_TAG, "SIP error: " + cause);
                 onCallEnded(cause);
             }
         };
@@ -810,7 +810,7 @@
         @Override
         public void hangup() throws CallStateException {
             synchronized (SipPhone.class) {
-                if (DEBUG) Log.d(LOG_TAG, "hangup conn: " + mPeer.getUriString()
+                if (DEBUG) Rlog.d(LOG_TAG, "hangup conn: " + mPeer.getUriString()
                         + ": " + mState + ": on phone "
                         + getPhone().getPhoneName());
                 if (!mState.isAlive()) return;
@@ -842,7 +842,7 @@
                             "cannot put conn back to a call in non-idle state: "
                             + call.getState());
                 }
-                if (DEBUG) Log.d(LOG_TAG, "separate conn: "
+                if (DEBUG) Rlog.d(LOG_TAG, "separate conn: "
                         + mPeer.getUriString() + " from " + mOwner + " back to "
                         + call);
 
@@ -877,7 +877,7 @@
             case SipSession.State.OUTGOING_CALL_CANCELING:  return Call.State.DISCONNECTING;
             case SipSession.State.IN_CALL:                  return Call.State.ACTIVE;
             default:
-                Log.w(LOG_TAG, "illegal connection state: " + sessionState);
+                Rlog.w(LOG_TAG, "illegal connection state: " + sessionState);
                 return Call.State.DISCONNECTED;
         }
     }
@@ -930,7 +930,7 @@
                 case SipErrorCode.SOCKET_ERROR:
                 case SipErrorCode.CLIENT_ERROR:
                 default:
-                    Log.w(LOG_TAG, "error: " + SipErrorCode.toString(errorCode)
+                    Rlog.w(LOG_TAG, "error: " + SipErrorCode.toString(errorCode)
                             + ": " + errorMessage);
                     onError(Connection.DisconnectCause.ERROR_UNSPECIFIED);
             }
diff --git a/src/java/com/android/internal/telephony/sip/SipPhoneBase.java b/src/java/com/android/internal/telephony/sip/SipPhoneBase.java
index 43b0de3..041ac79 100755
--- a/src/java/com/android/internal/telephony/sip/SipPhoneBase.java
+++ b/src/java/com/android/internal/telephony/sip/SipPhoneBase.java
@@ -28,14 +28,13 @@
 import android.telephony.CellLocation;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 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;
@@ -47,6 +46,7 @@
 import com.android.internal.telephony.PhoneSubInfo;
 import com.android.internal.telephony.TelephonyProperties;
 import com.android.internal.telephony.UUSInfo;
+import com.android.internal.telephony.uicc.IccFileHandler;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -211,17 +211,17 @@
 
     public boolean canDial() {
         int serviceState = getServiceState().getState();
-        Log.v(LOG_TAG, "canDial(): serviceState = " + serviceState);
+        Rlog.v(LOG_TAG, "canDial(): serviceState = " + serviceState);
         if (serviceState == ServiceState.STATE_POWER_OFF) return false;
 
         String disableCall = SystemProperties.get(
                 TelephonyProperties.PROPERTY_DISABLE_CALL, "false");
-        Log.v(LOG_TAG, "canDial(): disableCall = " + disableCall);
+        Rlog.v(LOG_TAG, "canDial(): disableCall = " + disableCall);
         if (disableCall.equals("true")) return false;
 
-        Log.v(LOG_TAG, "canDial(): ringingCall: " + getRingingCall().getState());
-        Log.v(LOG_TAG, "canDial(): foregndCall: " + getForegroundCall().getState());
-        Log.v(LOG_TAG, "canDial(): backgndCall: " + getBackgroundCall().getState());
+        Rlog.v(LOG_TAG, "canDial(): ringingCall: " + getRingingCall().getState());
+        Rlog.v(LOG_TAG, "canDial(): foregndCall: " + getForegroundCall().getState());
+        Rlog.v(LOG_TAG, "canDial(): backgndCall: " + getBackgroundCall().getState());
         return !getRingingCall().isRinging()
                 && (!getForegroundCall().getState().isAlive()
                     || !getBackgroundCall().getState().isAlive());
@@ -279,12 +279,12 @@
     }
 
     public String getEsn() {
-        Log.e(LOG_TAG, "[SipPhone] getEsn() is a CDMA method");
+        Rlog.e(LOG_TAG, "[SipPhone] getEsn() is a CDMA method");
         return "0";
     }
 
     public String getMeid() {
-        Log.e(LOG_TAG, "[SipPhone] getMeid() is a CDMA method");
+        Rlog.e(LOG_TAG, "[SipPhone] getMeid() is a CDMA method");
         return "0";
     }
 
@@ -344,7 +344,7 @@
     }
 
     public void setCallWaiting(boolean enable, Message onComplete) {
-        Log.e(LOG_TAG, "call waiting not supported");
+        Rlog.e(LOG_TAG, "call waiting not supported");
     }
 
     public boolean getIccRecordsLoaded() {
@@ -431,15 +431,15 @@
     }
 
     public void activateCellBroadcastSms(int activate, Message response) {
-        Log.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
+        Rlog.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
     }
 
     public void getCellBroadcastSmsConfig(Message response) {
-        Log.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
+        Rlog.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
     }
 
     public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response){
-        Log.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
+        Rlog.e(LOG_TAG, "Error! This functionality is not implemented for SIP.");
     }
 
     //@Override
@@ -467,7 +467,7 @@
         }
 
         if (state != oldState) {
-            Log.d(LOG_TAG, " ^^^ new phone state: " + state);
+            Rlog.d(LOG_TAG, " ^^^ new phone state: " + state);
             notifyPhoneStateChanged();
         }
     }
diff --git a/src/java/com/android/internal/telephony/sip/SipPhoneFactory.java b/src/java/com/android/internal/telephony/sip/SipPhoneFactory.java
index 611e3ea..3383bed 100644
--- a/src/java/com/android/internal/telephony/sip/SipPhoneFactory.java
+++ b/src/java/com/android/internal/telephony/sip/SipPhoneFactory.java
@@ -20,7 +20,7 @@
 
 import android.content.Context;
 import android.net.sip.SipProfile;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.text.ParseException;
 
@@ -42,7 +42,7 @@
             SipProfile profile = new SipProfile.Builder(sipUri).build();
             return new SipPhone(context, phoneNotifier, profile);
         } catch (ParseException e) {
-            Log.w("SipPhoneFactory", "makePhone", e);
+            Rlog.w("SipPhoneFactory", "makePhone", e);
             return null;
         }
     }
diff --git a/src/java/com/android/internal/telephony/test/ModelInterpreter.java b/src/java/com/android/internal/telephony/test/ModelInterpreter.java
index b116c35..20aca89 100644
--- a/src/java/com/android/internal/telephony/test/ModelInterpreter.java
+++ b/src/java/com/android/internal/telephony/test/ModelInterpreter.java
@@ -19,7 +19,7 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -204,7 +204,7 @@
                 try {
                     s = ss.accept();
                 } catch (java.io.IOException ex) {
-                    Log.w(LOG_TAG,
+                    Rlog.w(LOG_TAG,
                         "IOException on socket.accept(); stopping", ex);
                     return;
                 }
@@ -213,12 +213,12 @@
                     in = s.getInputStream();
                     out = s.getOutputStream();
                 } catch (java.io.IOException ex) {
-                    Log.w(LOG_TAG,
+                    Rlog.w(LOG_TAG,
                         "IOException on accepted socket(); re-listening", ex);
                     continue;
                 }
 
-                Log.i(LOG_TAG, "New connection accepted");
+                Rlog.i(LOG_TAG, "New connection accepted");
             }
 
 
@@ -260,7 +260,7 @@
                 }
             }
 
-            Log.i(LOG_TAG, "Disconnected");
+            Rlog.i(LOG_TAG, "Disconnected");
 
             if (ss == null) {
                 // no reconnect in this case
diff --git a/src/java/com/android/internal/telephony/test/SimulatedCommands.java b/src/java/com/android/internal/telephony/test/SimulatedCommands.java
index 4f61509..5125a40 100644
--- a/src/java/com/android/internal/telephony/test/SimulatedCommands.java
+++ b/src/java/com/android/internal/telephony/test/SimulatedCommands.java
@@ -20,7 +20,7 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.BaseCommands;
 import com.android.internal.telephony.CommandException;
@@ -28,6 +28,7 @@
 import com.android.internal.telephony.DataCallState;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.UUSInfo;
+import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.CallFailCause;
 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SuppServiceNotification;
@@ -109,7 +110,7 @@
 
     public void supplyIccPin(String pin, Message result)  {
         if (mSimLockedState != SimLockState.REQUIRE_PIN) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin: wrong state, state=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin: wrong state, state=" +
                     mSimLockedState);
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -119,7 +120,7 @@
         }
 
         if (pin != null && pin.equals(mPinCode)) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin: success!");
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin: success!");
             mPinUnlockAttempts = 0;
             mSimLockedState = SimLockState.NONE;
             mIccStatusChangedRegistrants.notifyRegistrants();
@@ -135,10 +136,10 @@
         if (result != null) {
             mPinUnlockAttempts ++;
 
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin: failed! attempt=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin: failed! attempt=" +
                     mPinUnlockAttempts);
             if (mPinUnlockAttempts >= 3) {
-                Log.i(LOG_TAG, "[SimCmd] supplyIccPin: set state to REQUIRE_PUK");
+                Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin: set state to REQUIRE_PUK");
                 mSimLockedState = SimLockState.REQUIRE_PUK;
             }
 
@@ -151,7 +152,7 @@
 
     public void supplyIccPuk(String puk, String newPin, Message result)  {
         if (mSimLockedState != SimLockState.REQUIRE_PUK) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk: wrong state, state=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk: wrong state, state=" +
                     mSimLockedState);
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -161,7 +162,7 @@
         }
 
         if (puk != null && puk.equals(SIM_PUK_CODE)) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk: success!");
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk: success!");
             mSimLockedState = SimLockState.NONE;
             mPukUnlockAttempts = 0;
             mIccStatusChangedRegistrants.notifyRegistrants();
@@ -177,10 +178,10 @@
         if (result != null) {
             mPukUnlockAttempts ++;
 
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk: failed! attempt=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk: failed! attempt=" +
                     mPukUnlockAttempts);
             if (mPukUnlockAttempts >= 10) {
-                Log.i(LOG_TAG, "[SimCmd] supplyIccPuk: set state to SIM_PERM_LOCKED");
+                Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk: set state to SIM_PERM_LOCKED");
                 mSimLockedState = SimLockState.SIM_PERM_LOCKED;
             }
 
@@ -193,7 +194,7 @@
 
     public void supplyIccPin2(String pin2, Message result)  {
         if (mSimFdnEnabledState != SimFdnState.REQUIRE_PIN2) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin2: wrong state, state=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin2: wrong state, state=" +
                     mSimFdnEnabledState);
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -203,7 +204,7 @@
         }
 
         if (pin2 != null && pin2.equals(mPin2Code)) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin2: success!");
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin2: success!");
             mPin2UnlockAttempts = 0;
             mSimFdnEnabledState = SimFdnState.NONE;
 
@@ -218,10 +219,10 @@
         if (result != null) {
             mPin2UnlockAttempts ++;
 
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPin2: failed! attempt=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin2: failed! attempt=" +
                     mPin2UnlockAttempts);
             if (mPin2UnlockAttempts >= 3) {
-                Log.i(LOG_TAG, "[SimCmd] supplyIccPin2: set state to REQUIRE_PUK2");
+                Rlog.i(LOG_TAG, "[SimCmd] supplyIccPin2: set state to REQUIRE_PUK2");
                 mSimFdnEnabledState = SimFdnState.REQUIRE_PUK2;
             }
 
@@ -234,7 +235,7 @@
 
     public void supplyIccPuk2(String puk2, String newPin2, Message result)  {
         if (mSimFdnEnabledState != SimFdnState.REQUIRE_PUK2) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk2: wrong state, state=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk2: wrong state, state=" +
                     mSimLockedState);
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -244,7 +245,7 @@
         }
 
         if (puk2 != null && puk2.equals(SIM_PUK2_CODE)) {
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk2: success!");
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk2: success!");
             mSimFdnEnabledState = SimFdnState.NONE;
             mPuk2UnlockAttempts = 0;
 
@@ -259,10 +260,10 @@
         if (result != null) {
             mPuk2UnlockAttempts ++;
 
-            Log.i(LOG_TAG, "[SimCmd] supplyIccPuk2: failed! attempt=" +
+            Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk2: failed! attempt=" +
                     mPuk2UnlockAttempts);
             if (mPuk2UnlockAttempts >= 10) {
-                Log.i(LOG_TAG, "[SimCmd] supplyIccPuk2: set state to SIM_PERM_LOCKED");
+                Rlog.i(LOG_TAG, "[SimCmd] supplyIccPuk2: set state to SIM_PERM_LOCKED");
                 mSimFdnEnabledState = SimFdnState.SIM_PERM_LOCKED;
             }
 
@@ -285,7 +286,7 @@
         }
 
         if (result != null) {
-            Log.i(LOG_TAG, "[SimCmd] changeIccPin: pin failed!");
+            Rlog.i(LOG_TAG, "[SimCmd] changeIccPin: pin failed!");
 
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -306,7 +307,7 @@
         }
 
         if (result != null) {
-            Log.i(LOG_TAG, "[SimCmd] changeIccPin2: pin2 failed!");
+            Rlog.i(LOG_TAG, "[SimCmd] changeIccPin2: pin2 failed!");
 
             CommandException ex = new CommandException(
                     CommandException.Error.PASSWORD_INCORRECT);
@@ -325,7 +326,7 @@
         resultSuccess(result, null);
 
         if (enable && mSsnNotifyOn) {
-            Log.w(LOG_TAG, "Supp Service Notifications already enabled!");
+            Rlog.w(LOG_TAG, "Supp Service Notifications already enabled!");
         }
 
         mSsnNotifyOn = enable;
@@ -344,7 +345,7 @@
             if (result != null) {
                 int[] r = new int[1];
                 r[0] = (mSimLockEnabled ? 1 : 0);
-                Log.i(LOG_TAG, "[SimCmd] queryFacilityLock: SIM is "
+                Rlog.i(LOG_TAG, "[SimCmd] queryFacilityLock: SIM is "
                         + (r[0] == 0 ? "unlocked" : "locked"));
                 AsyncResult.forMessage(result, r, null);
                 result.sendToTarget();
@@ -354,7 +355,7 @@
             if (result != null) {
                 int[] r = new int[1];
                 r[0] = (mSimFdnEnabled ? 1 : 0);
-                Log.i(LOG_TAG, "[SimCmd] queryFacilityLock: FDN is "
+                Rlog.i(LOG_TAG, "[SimCmd] queryFacilityLock: FDN is "
                         + (r[0] == 0 ? "disabled" : "enabled"));
                 AsyncResult.forMessage(result, r, null);
                 result.sendToTarget();
@@ -378,7 +379,7 @@
         if (facility != null &&
                 facility.equals(CommandsInterface.CB_FACILITY_BA_SIM)) {
             if (pin != null && pin.equals(mPinCode)) {
-                Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin is valid");
+                Rlog.i(LOG_TAG, "[SimCmd] setFacilityLock: pin is valid");
                 mSimLockEnabled = lockEnabled;
 
                 if (result != null) {
@@ -390,7 +391,7 @@
             }
 
             if (result != null) {
-                Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin failed!");
+                Rlog.i(LOG_TAG, "[SimCmd] setFacilityLock: pin failed!");
 
                 CommandException ex = new CommandException(
                         CommandException.Error.GENERIC_FAILURE);
@@ -402,7 +403,7 @@
         }  else if (facility != null &&
                 facility.equals(CommandsInterface.CB_FACILITY_BA_FD)) {
             if (pin != null && pin.equals(mPin2Code)) {
-                Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 is valid");
+                Rlog.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 is valid");
                 mSimFdnEnabled = lockEnabled;
 
                 if (result != null) {
@@ -414,7 +415,7 @@
             }
 
             if (result != null) {
-                Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 failed!");
+                Rlog.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 failed!");
 
                 CommandException ex = new CommandException(
                         CommandException.Error.GENERIC_FAILURE);
@@ -442,10 +443,10 @@
      */
     public void getCurrentCalls (Message result) {
         if ((mState == RadioState.RADIO_ON) && !isSimLocked()) {
-            //Log.i("GSM", "[SimCmds] getCurrentCalls");
+            //Rlog.i("GSM", "[SimCmds] getCurrentCalls");
             resultSuccess(result, simulatedCallState.getDriverCalls());
         } else {
-            //Log.i("GSM", "[SimCmds] getCurrentCalls: RADIO_OFF or SIM not ready!");
+            //Rlog.i("GSM", "[SimCmds] getCurrentCalls: RADIO_OFF or SIM not ready!");
             resultFail(result,
                 new CommandException(
                     CommandException.Error.RADIO_NOT_AVAILABLE));
@@ -557,10 +558,10 @@
         success = simulatedCallState.onChld('1', (char)('0'+gsmIndex));
 
         if (!success){
-            Log.i("GSM", "[SimCmd] hangupConnection: resultFail");
+            Rlog.i("GSM", "[SimCmd] hangupConnection: resultFail");
             resultFail(result, new RuntimeException("Hangup Error"));
         } else {
-            Log.i("GSM", "[SimCmd] hangupConnection: resultSuccess");
+            Rlog.i("GSM", "[SimCmd] hangupConnection: resultSuccess");
             resultSuccess(result, null);
         }
     }
@@ -942,22 +943,22 @@
     public void sendSMS (String smscPDU, String pdu, Message result) {unimplemented(result);}
 
     public void deleteSmsOnSim(int index, Message response) {
-        Log.d(LOG_TAG, "Delete message at index " + index);
+        Rlog.d(LOG_TAG, "Delete message at index " + index);
         unimplemented(response);
     }
 
     public void deleteSmsOnRuim(int index, Message response) {
-        Log.d(LOG_TAG, "Delete RUIM message at index " + index);
+        Rlog.d(LOG_TAG, "Delete RUIM message at index " + index);
         unimplemented(response);
     }
 
     public void writeSmsToSim(int status, String smsc, String pdu, Message response) {
-        Log.d(LOG_TAG, "Write SMS to SIM with status " + status);
+        Rlog.d(LOG_TAG, "Write SMS to SIM with status " + status);
         unimplemented(response);
     }
 
     public void writeSmsToRuim(int status, String pdu, Message response) {
-        Log.d(LOG_TAG, "Write SMS to RUIM with status " + status);
+        Rlog.d(LOG_TAG, "Write SMS to RUIM with status " + status);
         unimplemented(response);
     }
 
@@ -1321,7 +1322,7 @@
             }
             pausedResponses.clear();
         } else {
-            Log.e("GSM", "SimulatedCommands.resumeResponses < 0");
+            Rlog.e("GSM", "SimulatedCommands.resumeResponses < 0");
         }
     }
 
@@ -1365,44 +1366,44 @@
     // ***** Methods for CDMA support
     public void
     getDeviceIdentity(Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
     public void
     getCDMASubscription(Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
     public void
     setCdmaSubscriptionSource(int cdmaSubscriptionType, Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
     public void queryCdmaRoamingPreference(Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
     public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
     public void
     setPhoneType(int phoneType) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
     }
 
     public void getPreferredVoicePrivacy(Message result) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(result);
     }
 
     public void setPreferredVoicePrivacy(boolean enable, Message result) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(result);
     }
 
@@ -1417,7 +1418,7 @@
      * @param response is callback message
      */
     public void setTTYMode(int ttyMode, Message response) {
-        Log.w(LOG_TAG, "Not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "Not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
@@ -1432,7 +1433,7 @@
      * @param response is callback message
      */
     public void queryTTYMode(Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
@@ -1440,7 +1441,7 @@
      * {@inheritDoc}
      */
     public void sendCDMAFeatureCode(String FeatureCode, Message response) {
-        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+        Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
         unimplemented(response);
     }
 
@@ -1448,7 +1449,7 @@
      * {@inheritDoc}
      */
     public void sendCdmaSms(byte[] pdu, Message response){
-       Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
+       Rlog.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
     }
 
     public void setCdmaBroadcastActivation(boolean activate, Message response) {
@@ -1461,9 +1462,8 @@
 
     }
 
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
+    public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response) {
         unimplemented(response);
-
     }
 
     public void forceDataDormancy(Message response) {
diff --git a/src/java/com/android/internal/telephony/test/SimulatedGsmCallState.java b/src/java/com/android/internal/telephony/test/SimulatedGsmCallState.java
index c6c301d..6b0a346 100644
--- a/src/java/com/android/internal/telephony/test/SimulatedGsmCallState.java
+++ b/src/java/com/android/internal/telephony/test/SimulatedGsmCallState.java
@@ -25,7 +25,7 @@
 import java.util.List;
 import java.util.ArrayList;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 class CallInfo {
     enum State {
@@ -189,7 +189,7 @@
                     && (call.state == CallInfo.State.INCOMING
                         || call.state == CallInfo.State.WAITING)
                 ) {
-                    Log.w("ModelInterpreter",
+                    Rlog.w("ModelInterpreter",
                         "triggerRing failed; phone already ringing");
                     return false;
                 } else if (call != null) {
@@ -198,7 +198,7 @@
             }
 
             if (empty < 0 ) {
-                Log.w("ModelInterpreter", "triggerRing failed; all full");
+                Rlog.w("ModelInterpreter", "triggerRing failed; all full");
                 return false;
             }
 
@@ -658,25 +658,25 @@
         CallInfo call;
         int freeSlot = -1;
 
-        Log.d("GSM", "SC> dial '" + address + "'");
+        Rlog.d("GSM", "SC> dial '" + address + "'");
 
         if (nextDialFailImmediately) {
             nextDialFailImmediately = false;
 
-            Log.d("GSM", "SC< dial fail (per request)");
+            Rlog.d("GSM", "SC< dial fail (per request)");
             return false;
         }
 
         String phNum = PhoneNumberUtils.extractNetworkPortion(address);
 
         if (phNum.length() == 0) {
-            Log.d("GSM", "SC< dial fail (invalid ph num)");
+            Rlog.d("GSM", "SC< dial fail (invalid ph num)");
             return false;
         }
 
         // Ignore setting up GPRS
         if (phNum.startsWith("*99") && phNum.endsWith("#")) {
-            Log.d("GSM", "SC< dial ignored (gprs)");
+            Rlog.d("GSM", "SC< dial ignored (gprs)");
             return true;
         }
 
@@ -684,11 +684,11 @@
         // a new call
         try {
             if (countActiveLines() > 1) {
-                Log.d("GSM", "SC< dial fail (invalid call state)");
+                Rlog.d("GSM", "SC< dial fail (invalid call state)");
                 return false;
             }
         } catch (InvalidStateEx ex) {
-            Log.d("GSM", "SC< dial fail (invalid call state)");
+            Rlog.d("GSM", "SC< dial fail (invalid call state)");
             return false;
         }
 
@@ -700,7 +700,7 @@
             if (calls[i] != null && !calls[i].isActiveOrHeld()) {
                 // Can't make outgoing calls when there is a ringing or
                 // connecting outgoing call
-                Log.d("GSM", "SC< dial fail (invalid call state)");
+                Rlog.d("GSM", "SC< dial fail (invalid call state)");
                 return false;
             } else if (calls[i] != null && calls[i].state == CallInfo.State.ACTIVE) {
                 // All active calls behome held
@@ -709,7 +709,7 @@
         }
 
         if (freeSlot < 0) {
-            Log.d("GSM", "SC< dial fail (invalid call state)");
+            Rlog.d("GSM", "SC< dial fail (invalid call state)");
             return false;
         }
 
@@ -721,7 +721,7 @@
                     CONNECTING_PAUSE_MSEC);
         }
 
-        Log.d("GSM", "SC< dial (slot = " + freeSlot + ")");
+        Rlog.d("GSM", "SC< dial (slot = " + freeSlot + ")");
 
         return true;
     }
@@ -741,7 +741,7 @@
             }
         }
 
-        Log.d("GSM", "SC< getDriverCalls " + ret);
+        Rlog.d("GSM", "SC< getDriverCalls " + ret);
 
         return ret;
     }
@@ -779,12 +779,12 @@
                 } else if (call.isMpty && mptyIsHeld
                     && call.state == CallInfo.State.ACTIVE
                 ) {
-                    Log.e("ModelInterpreter", "Invalid state");
+                    Rlog.e("ModelInterpreter", "Invalid state");
                     throw new InvalidStateEx();
                 } else if (!call.isMpty && hasMpty && mptyIsHeld
                     && call.state == CallInfo.State.HOLDING
                 ) {
-                    Log.e("ModelInterpreter", "Invalid state");
+                    Rlog.e("ModelInterpreter", "Invalid state");
                     throw new InvalidStateEx();
                 }
 
diff --git a/src/java/com/android/internal/telephony/AdnRecord.aidl b/src/java/com/android/internal/telephony/uicc/AdnRecord.aidl
similarity index 93%
rename from src/java/com/android/internal/telephony/AdnRecord.aidl
rename to src/java/com/android/internal/telephony/uicc/AdnRecord.aidl
index b4a1a29..8bb0415 100644
--- a/src/java/com/android/internal/telephony/AdnRecord.aidl
+++ b/src/java/com/android/internal/telephony/uicc/AdnRecord.aidl
@@ -14,7 +14,7 @@
 ** limitations under the License.
 */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 parcelable AdnRecord;
 
diff --git a/src/java/com/android/internal/telephony/AdnRecord.java b/src/java/com/android/internal/telephony/uicc/AdnRecord.java
similarity index 95%
rename from src/java/com/android/internal/telephony/AdnRecord.java
rename to src/java/com/android/internal/telephony/uicc/AdnRecord.java
index 1bf2d3c..ce5c329 100644
--- a/src/java/com/android/internal/telephony/AdnRecord.java
+++ b/src/java/com/android/internal/telephony/uicc/AdnRecord.java
@@ -14,13 +14,15 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
+
+import com.android.internal.telephony.GsmAlphabet;
 
 import java.util.Arrays;
 
@@ -212,15 +214,15 @@
         }
 
         if (TextUtils.isEmpty(number)) {
-            Log.w(LOG_TAG, "[buildAdnString] Empty dialing number");
+            Rlog.w(LOG_TAG, "[buildAdnString] Empty dialing number");
             return adnString;   // return the empty record (for delete)
         } else if (number.length()
                 > (ADN_DIALING_NUMBER_END - ADN_DIALING_NUMBER_START + 1) * 2) {
-            Log.w(LOG_TAG,
+            Rlog.w(LOG_TAG,
                     "[buildAdnString] Max length of dialing number is 20");
             return null;
         } else if (alphaTag != null && alphaTag.length() > footerOffset) {
-            Log.w(LOG_TAG,
+            Rlog.w(LOG_TAG,
                     "[buildAdnString] Max length of tag is " + footerOffset);
             return null;
         } else {
@@ -271,7 +273,7 @@
             // We don't support ext record chaining.
 
         } catch (RuntimeException ex) {
-            Log.w(LOG_TAG, "Error parsing AdnRecord ext record", ex);
+            Rlog.w(LOG_TAG, "Error parsing AdnRecord ext record", ex);
         }
     }
 
@@ -312,7 +314,7 @@
             emails = null;
 
         } catch (RuntimeException ex) {
-            Log.w(LOG_TAG, "Error parsing AdnRecord", ex);
+            Rlog.w(LOG_TAG, "Error parsing AdnRecord", ex);
             number = "";
             alphaTag = "";
             emails = null;
diff --git a/src/java/com/android/internal/telephony/AdnRecordCache.java b/src/java/com/android/internal/telephony/uicc/AdnRecordCache.java
similarity index 98%
rename from src/java/com/android/internal/telephony/AdnRecordCache.java
rename to src/java/com/android/internal/telephony/uicc/AdnRecordCache.java
index db5f4da..f7b5d8c 100644
--- a/src/java/com/android/internal/telephony/AdnRecordCache.java
+++ b/src/java/com/android/internal/telephony/uicc/AdnRecordCache.java
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.SparseArray;
 
 import com.android.internal.telephony.gsm.UsimPhoneBookManager;
@@ -56,7 +56,7 @@
 
 
 
-    public AdnRecordCache(IccFileHandler fh) {
+    AdnRecordCache(IccFileHandler fh) {
         mFh = fh;
         mUsimPhoneBookManager = new UsimPhoneBookManager(mFh, this);
     }
@@ -108,7 +108,7 @@
      *
      * See 3GPP TS 51.011 for this mapping
      */
-    int extensionEfForEf(int efid) {
+    public int extensionEfForEf(int efid) {
         switch (efid) {
             case EF_MBDN: return EF_EXT6;
             case EF_ADN: return EF_EXT1;
diff --git a/src/java/com/android/internal/telephony/AdnRecordLoader.java b/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java
similarity index 97%
rename from src/java/com/android/internal/telephony/AdnRecordLoader.java
rename to src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java
index 084fae6..4de69d1 100644
--- a/src/java/com/android/internal/telephony/AdnRecordLoader.java
+++ b/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import java.util.ArrayList;
 
@@ -22,8 +22,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
-
+import android.telephony.Rlog;
 
 public class AdnRecordLoader extends Handler {
     final static String LOG_TAG = "RIL_AdnRecordLoader";
@@ -57,7 +56,7 @@
 
     //***** Constructor
 
-    public AdnRecordLoader(IccFileHandler fh) {
+    AdnRecordLoader(IccFileHandler fh) {
         // The telephony unit-test cases may create AdnRecords
         // in secondary threads
         super(Looper.getMainLooper());
@@ -186,7 +185,7 @@
                     }
 
                     if (false) {
-                        Log.d(LOG_TAG,"ADN EF: 0x"
+                        Rlog.d(LOG_TAG,"ADN EF: 0x"
                             + Integer.toHexString(ef)
                             + ":" + recordNumber
                             + "\n" + IccUtils.bytesToHexString(data));
@@ -217,7 +216,7 @@
                         throw new RuntimeException("load failed", ar.exception);
                     }
 
-                    Log.d(LOG_TAG,"ADN extension EF: 0x"
+                    Rlog.d(LOG_TAG,"ADN extension EF: 0x"
                         + Integer.toHexString(extensionEF)
                         + ":" + adn.extRecord
                         + "\n" + IccUtils.bytesToHexString(data));
diff --git a/src/java/com/android/internal/telephony/CsimFileHandler.java b/src/java/com/android/internal/telephony/uicc/CsimFileHandler.java
similarity index 86%
rename from src/java/com/android/internal/telephony/CsimFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/CsimFileHandler.java
index 979d1d2..54f9a60 100644
--- a/src/java/com/android/internal/telephony/CsimFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/CsimFileHandler.java
@@ -14,14 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.UiccCardApplication;
 
 /**
  * {@hide}
@@ -61,11 +58,11 @@
 
     @Override
     protected void logd(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     @Override
     protected void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/IccCardApplicationStatus.java b/src/java/com/android/internal/telephony/uicc/IccCardApplicationStatus.java
similarity index 95%
rename from src/java/com/android/internal/telephony/IccCardApplicationStatus.java
rename to src/java/com/android/internal/telephony/uicc/IccCardApplicationStatus.java
index f3f22ea..db5065b 100644
--- a/src/java/com/android/internal/telephony/IccCardApplicationStatus.java
+++ b/src/java/com/android/internal/telephony/uicc/IccCardApplicationStatus.java
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
-import com.android.internal.telephony.IccCardStatus.PinState;
+import com.android.internal.telephony.uicc.IccCardStatus.PinState;
 
 
 /**
@@ -109,7 +109,7 @@
     public PinState            pin1;
     public PinState            pin2;
 
-    AppType AppTypeFromRILInt(int type) {
+    public AppType AppTypeFromRILInt(int type) {
         AppType newType;
         /* RIL_AppType ril.h */
         switch(type) {
@@ -126,7 +126,7 @@
         return newType;
     }
 
-    AppState AppStateFromRILInt(int state) {
+    public AppState AppStateFromRILInt(int state) {
         AppState newState;
         /* RIL_AppState ril.h */
         switch(state) {
@@ -143,7 +143,7 @@
         return newState;
     }
 
-    PersoSubState PersoSubstateFromRILInt(int substate) {
+    public PersoSubState PersoSubstateFromRILInt(int substate) {
         PersoSubState newSubState;
         /* RIL_PeroSubstate ril.h */
         switch(substate) {
@@ -179,7 +179,7 @@
         return newSubState;
     }
 
-    PinState PinStateFromRILInt(int state) {
+    public PinState PinStateFromRILInt(int state) {
         PinState newPinState;
         switch(state) {
             case 0:
diff --git a/src/java/com/android/internal/telephony/IccCardProxy.java b/src/java/com/android/internal/telephony/uicc/IccCardProxy.java
similarity index 90%
rename from src/java/com/android/internal/telephony/IccCardProxy.java
rename to src/java/com/android/internal/telephony/uicc/IccCardProxy.java
index cdd2fea..e0e7124 100644
--- a/src/java/com/android/internal/telephony/IccCardProxy.java
+++ b/src/java/com/android/internal/telephony/uicc/IccCardProxy.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import static android.Manifest.permission.READ_PHONE_STATE;
 import android.app.ActivityManagerNative;
@@ -27,18 +27,27 @@
 import android.os.RegistrantList;
 import android.os.SystemProperties;
 import android.os.UserHandle;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.telephony.ServiceState;
 import android.telephony.TelephonyManager;
 
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.IccCardConstants.State;
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
-import com.android.internal.telephony.IccCardApplicationStatus.PersoSubState;
-import com.android.internal.telephony.IccCardStatus.CardState;
-import com.android.internal.telephony.IccCardStatus.PinState;
 import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
-import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState;
+import com.android.internal.telephony.uicc.IccCardStatus.CardState;
+import com.android.internal.telephony.uicc.IccCardStatus.PinState;
+import com.android.internal.telephony.uicc.UiccController;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_SIM_STATE;
 
@@ -687,10 +696,43 @@
     }
 
     private void log(String s) {
-        Log.d(LOG_TAG, s);
+        Rlog.d(LOG_TAG, s);
     }
 
     private void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
+    }
+
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("IccCardProxy: " + this);
+        pw.println(" mContext=" + mContext);
+        pw.println(" mCi=" + mCi);
+        pw.println(" mAbsentRegistrants: size=" + mAbsentRegistrants.size());
+        for (int i = 0; i < mAbsentRegistrants.size(); i++) {
+            pw.println("  mAbsentRegistrants[" + i + "]="
+                    + ((Registrant)mAbsentRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mPinLockedRegistrants: size=" + mPinLockedRegistrants.size());
+        for (int i = 0; i < mPinLockedRegistrants.size(); i++) {
+            pw.println("  mPinLockedRegistrants[" + i + "]="
+                    + ((Registrant)mPinLockedRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mNetworkLockedRegistrants: size=" + mNetworkLockedRegistrants.size());
+        for (int i = 0; i < mNetworkLockedRegistrants.size(); i++) {
+            pw.println("  mNetworkLockedRegistrants[" + i + "]="
+                    + ((Registrant)mNetworkLockedRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mCurrentAppType=" + mCurrentAppType);
+        pw.println(" mUiccController=" + mUiccController);
+        pw.println(" mUiccCard=" + mUiccCard);
+        pw.println(" mUiccApplication=" + mUiccApplication);
+        pw.println(" mIccRecords=" + mIccRecords);
+        pw.println(" mCdmaSSM=" + mCdmaSSM);
+        pw.println(" mRadioOn=" + mRadioOn);
+        pw.println(" mQuietMode=" + mQuietMode);
+        pw.println(" mInitialized=" + mInitialized);
+        pw.println(" mExternalState=" + mExternalState);
+
+        pw.flush();
     }
 }
diff --git a/src/java/com/android/internal/telephony/IccCardStatus.java b/src/java/com/android/internal/telephony/uicc/IccCardStatus.java
similarity index 98%
rename from src/java/com/android/internal/telephony/IccCardStatus.java
rename to src/java/com/android/internal/telephony/uicc/IccCardStatus.java
index b4a5e68..a4fbc1f 100644
--- a/src/java/com/android/internal/telephony/IccCardStatus.java
+++ b/src/java/com/android/internal/telephony/uicc/IccCardStatus.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 import java.util.ArrayList;
 
diff --git a/src/java/com/android/internal/telephony/IccConstants.java b/src/java/com/android/internal/telephony/uicc/IccConstants.java
similarity index 98%
rename from src/java/com/android/internal/telephony/IccConstants.java
rename to src/java/com/android/internal/telephony/uicc/IccConstants.java
index 847c883..c689539 100644
--- a/src/java/com/android/internal/telephony/IccConstants.java
+++ b/src/java/com/android/internal/telephony/uicc/IccConstants.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccException.java b/src/java/com/android/internal/telephony/uicc/IccException.java
similarity index 94%
rename from src/java/com/android/internal/telephony/IccException.java
rename to src/java/com/android/internal/telephony/uicc/IccException.java
index 1659a4e..1ba5b28 100644
--- a/src/java/com/android/internal/telephony/IccException.java
+++ b/src/java/com/android/internal/telephony/uicc/IccException.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccFileHandler.java b/src/java/com/android/internal/telephony/uicc/IccFileHandler.java
similarity index 99%
rename from src/java/com/android/internal/telephony/IccFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/IccFileHandler.java
index fd4e3cc..ae460ba 100644
--- a/src/java/com/android/internal/telephony/IccFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/IccFileHandler.java
@@ -14,10 +14,13 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import android.os.*;
-import android.util.Log;
+import android.telephony.Rlog;
+
+import com.android.internal.telephony.CommandsInterface;
+
 import java.util.ArrayList;
 
 /**
diff --git a/src/java/com/android/internal/telephony/IccFileNotFound.java b/src/java/com/android/internal/telephony/uicc/IccFileNotFound.java
similarity index 94%
rename from src/java/com/android/internal/telephony/IccFileNotFound.java
rename to src/java/com/android/internal/telephony/uicc/IccFileNotFound.java
index 915cea6..08bfcf9 100644
--- a/src/java/com/android/internal/telephony/IccFileNotFound.java
+++ b/src/java/com/android/internal/telephony/uicc/IccFileNotFound.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccFileTypeMismatch.java b/src/java/com/android/internal/telephony/uicc/IccFileTypeMismatch.java
similarity index 94%
rename from src/java/com/android/internal/telephony/IccFileTypeMismatch.java
rename to src/java/com/android/internal/telephony/uicc/IccFileTypeMismatch.java
index 66fcfa9..7e4794e 100644
--- a/src/java/com/android/internal/telephony/IccFileTypeMismatch.java
+++ b/src/java/com/android/internal/telephony/uicc/IccFileTypeMismatch.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccIoResult.java b/src/java/com/android/internal/telephony/uicc/IccIoResult.java
similarity index 97%
rename from src/java/com/android/internal/telephony/IccIoResult.java
rename to src/java/com/android/internal/telephony/uicc/IccIoResult.java
index 7043da5..281a391 100644
--- a/src/java/com/android/internal/telephony/IccIoResult.java
+++ b/src/java/com/android/internal/telephony/uicc/IccIoResult.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccRecords.java b/src/java/com/android/internal/telephony/uicc/IccRecords.java
similarity index 83%
rename from src/java/com/android/internal/telephony/IccRecords.java
rename to src/java/com/android/internal/telephony/uicc/IccRecords.java
index cfcc412..38da633 100644
--- a/src/java/com/android/internal/telephony/IccRecords.java
+++ b/src/java/com/android/internal/telephony/uicc/IccRecords.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import android.content.Context;
 import android.os.AsyncResult;
@@ -23,9 +23,10 @@
 import android.os.Registrant;
 import android.os.RegistrantList;
 
-import com.android.internal.telephony.gsm.UsimServiceTable;
-import com.android.internal.telephony.ims.IsimRecords;
+import com.android.internal.telephony.CommandsInterface;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
@@ -443,4 +444,55 @@
     public UsimServiceTable getUsimServiceTable() {
         return null;
     }
+
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("IccRecords: " + this);
+        pw.println(" mDestroyed=" + mDestroyed);
+        pw.println(" mCi=" + mCi);
+        pw.println(" mFh=" + mFh);
+        pw.println(" mParentApp=" + mParentApp);
+        pw.println(" recordsLoadedRegistrants: size=" + recordsLoadedRegistrants.size());
+        for (int i = 0; i < recordsLoadedRegistrants.size(); i++) {
+            pw.println("  recordsLoadedRegistrants[" + i + "]="
+                    + ((Registrant)recordsLoadedRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mImsiReadyRegistrants: size=" + mImsiReadyRegistrants.size());
+        for (int i = 0; i < mImsiReadyRegistrants.size(); i++) {
+            pw.println("  mImsiReadyRegistrants[" + i + "]="
+                    + ((Registrant)mImsiReadyRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mRecordsEventsRegistrants: size=" + mRecordsEventsRegistrants.size());
+        for (int i = 0; i < mRecordsEventsRegistrants.size(); i++) {
+            pw.println("  mRecordsEventsRegistrants[" + i + "]="
+                    + ((Registrant)mRecordsEventsRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mNewSmsRegistrants: size=" + mNewSmsRegistrants.size());
+        for (int i = 0; i < mNewSmsRegistrants.size(); i++) {
+            pw.println("  mNewSmsRegistrants[" + i + "]="
+                    + ((Registrant)mNewSmsRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mNetworkSelectionModeAutomaticRegistrants: size="
+                + mNetworkSelectionModeAutomaticRegistrants.size());
+        for (int i = 0; i < mNetworkSelectionModeAutomaticRegistrants.size(); i++) {
+            pw.println("  mNetworkSelectionModeAutomaticRegistrants[" + i + "]="
+                    + ((Registrant)mNetworkSelectionModeAutomaticRegistrants.get(i)).getHandler());
+        }
+        pw.println(" recordsRequested=" + recordsRequested);
+        pw.println(" recordsToLoad=" + recordsToLoad);
+        pw.println(" adnCache=" + adnCache);
+        pw.println(" iccid=" + iccid);
+        pw.println(" msisdn=" + msisdn);
+        pw.println(" msisdnTag=" + msisdnTag);
+        pw.println(" voiceMailNum=" + voiceMailNum);
+        pw.println(" voiceMailTag=" + voiceMailTag);
+        pw.println(" newVoiceMailNum=" + newVoiceMailNum);
+        pw.println(" newVoiceMailTag=" + newVoiceMailTag);
+        pw.println(" isVoiceMailFixed=" + isVoiceMailFixed);
+        pw.println(" countVoiceMessages=" + countVoiceMessages);
+        pw.println(" mImsi=" + mImsi);
+        pw.println(" mncLength=" + mncLength);
+        pw.println(" mailboxIndex=" + mailboxIndex);
+        pw.println(" spn=" + spn);
+        pw.flush();
+    }
 }
diff --git a/src/java/com/android/internal/telephony/IccRefreshResponse.java b/src/java/com/android/internal/telephony/uicc/IccRefreshResponse.java
similarity index 96%
rename from src/java/com/android/internal/telephony/IccRefreshResponse.java
rename to src/java/com/android/internal/telephony/uicc/IccRefreshResponse.java
index 6806703..c1d29f8 100644
--- a/src/java/com/android/internal/telephony/IccRefreshResponse.java
+++ b/src/java/com/android/internal/telephony/uicc/IccRefreshResponse.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 /**
  * See also RIL_SimRefresh in include/telephony/ril.h
diff --git a/src/java/com/android/internal/telephony/IccServiceTable.java b/src/java/com/android/internal/telephony/uicc/IccServiceTable.java
similarity index 93%
rename from src/java/com/android/internal/telephony/IccServiceTable.java
rename to src/java/com/android/internal/telephony/uicc/IccServiceTable.java
index ed74a11..2b5b2de 100644
--- a/src/java/com/android/internal/telephony/IccServiceTable.java
+++ b/src/java/com/android/internal/telephony/uicc/IccServiceTable.java
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 /**
  * Wrapper class for an ICC EF containing a bit field of enabled services.
@@ -43,7 +43,7 @@
         int offset = service / 8;
         if (offset >= mServiceTable.length) {
             // Note: Enums are zero-based, but the TS service numbering is one-based
-            Log.e(getTag(), "isAvailable for service " + (service + 1) + " fails, max service is " +
+            Rlog.e(getTag(), "isAvailable for service " + (service + 1) + " fails, max service is " +
                     (mServiceTable.length * 8));
             return false;
         }
diff --git a/src/java/com/android/internal/telephony/uicc/IccUtils.java b/src/java/com/android/internal/telephony/uicc/IccUtils.java
new file mode 100644
index 0000000..8b84bfe
--- /dev/null
+++ b/src/java/com/android/internal/telephony/uicc/IccUtils.java
@@ -0,0 +1,530 @@
+/*
+ * Copyright (C) 2006 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.uicc;
+
+import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.telephony.Rlog;
+
+import com.android.internal.telephony.GsmAlphabet;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+/**
+ * Various methods, useful for dealing with SIM data.
+ */
+public class IccUtils {
+    static final String LOG_TAG="IccUtils";
+
+    /**
+     * Many fields in GSM SIM's are stored as nibble-swizzled BCD
+     *
+     * Assumes left-justified field that may be padded right with 0xf
+     * values.
+     *
+     * Stops on invalid BCD value, returning string so far
+     */
+    public static String
+    bcdToString(byte[] data, int offset, int length) {
+        StringBuilder ret = new StringBuilder(length*2);
+
+        for (int i = offset ; i < offset + length ; i++) {
+            byte b;
+            int v;
+
+            v = data[i] & 0xf;
+            if (v > 9)  break;
+            ret.append((char)('0' + v));
+
+            v = (data[i] >> 4) & 0xf;
+            // Some PLMNs have 'f' as high nibble, ignore it
+            if (v == 0xf) continue;
+            if (v > 9)  break;
+            ret.append((char)('0' + v));
+        }
+
+        return ret.toString();
+    }
+
+    /**
+     * Decode cdma byte into String.
+     */
+    public static String
+    cdmaBcdToString(byte[] data, int offset, int length) {
+        StringBuilder ret = new StringBuilder(length);
+
+        int count = 0;
+        for (int i = offset; count < length; i++) {
+            int v;
+            v = data[i] & 0xf;
+            if (v > 9)  v = 0;
+            ret.append((char)('0' + v));
+
+            if (++count == length) break;
+
+            v = (data[i] >> 4) & 0xf;
+            if (v > 9)  v = 0;
+            ret.append((char)('0' + v));
+            ++count;
+        }
+        return ret.toString();
+    }
+
+    /**
+     * Decodes a GSM-style BCD byte, returning an int ranging from 0-99.
+     *
+     * In GSM land, the least significant BCD digit is stored in the most
+     * significant nibble.
+     *
+     * Out-of-range digits are treated as 0 for the sake of the time stamp,
+     * because of this:
+     *
+     * TS 23.040 section 9.2.3.11
+     * "if the MS receives a non-integer value in the SCTS, it shall
+     * assume the digit is set to 0 but shall store the entire field
+     * exactly as received"
+     */
+    public static int
+    gsmBcdByteToInt(byte b) {
+        int ret = 0;
+
+        // treat out-of-range BCD values as 0
+        if ((b & 0xf0) <= 0x90) {
+            ret = (b >> 4) & 0xf;
+        }
+
+        if ((b & 0x0f) <= 0x09) {
+            ret +=  (b & 0xf) * 10;
+        }
+
+        return ret;
+    }
+
+    /**
+     * Decodes a CDMA style BCD byte like {@link gsmBcdByteToInt}, but
+     * opposite nibble format. The least significant BCD digit
+     * is in the least significant nibble and the most significant
+     * is in the most significant nibble.
+     */
+    public static int
+    cdmaBcdByteToInt(byte b) {
+        int ret = 0;
+
+        // treat out-of-range BCD values as 0
+        if ((b & 0xf0) <= 0x90) {
+            ret = ((b >> 4) & 0xf) * 10;
+        }
+
+        if ((b & 0x0f) <= 0x09) {
+            ret +=  (b & 0xf);
+        }
+
+        return ret;
+    }
+
+    /**
+     * Decodes a string field that's formatted like the EF[ADN] alpha
+     * identifier
+     *
+     * From TS 51.011 10.5.1:
+     *   Coding:
+     *       this alpha tagging shall use either
+     *      -    the SMS default 7 bit coded alphabet as defined in
+     *          TS 23.038 [12] with bit 8 set to 0. The alpha identifier
+     *          shall be left justified. Unused bytes shall be set to 'FF'; or
+     *      -    one of the UCS2 coded options as defined in annex B.
+     *
+     * Annex B from TS 11.11 V8.13.0:
+     *      1)  If the first octet in the alpha string is '80', then the
+     *          remaining octets are 16 bit UCS2 characters ...
+     *      2)  if the first octet in the alpha string is '81', then the
+     *          second octet contains a value indicating the number of
+     *          characters in the string, and the third octet contains an
+     *          8 bit number which defines bits 15 to 8 of a 16 bit
+     *          base pointer, where bit 16 is set to zero and bits 7 to 1
+     *          are also set to zero.  These sixteen bits constitute a
+     *          base pointer to a "half page" in the UCS2 code space, to be
+     *          used with some or all of the remaining octets in the string.
+     *          The fourth and subsequent octets contain codings as follows:
+     *          If bit 8 of the octet is set to zero, the remaining 7 bits
+     *          of the octet contain a GSM Default Alphabet character,
+     *          whereas if bit 8 of the octet is set to one, then the
+     *          remaining seven bits are an offset value added to the
+     *          16 bit base pointer defined earlier...
+     *      3)  If the first octet of the alpha string is set to '82', then
+     *          the second octet contains a value indicating the number of
+     *          characters in the string, and the third and fourth octets
+     *          contain a 16 bit number which defines the complete 16 bit
+     *          base pointer to a "half page" in the UCS2 code space...
+     */
+    public static String
+    adnStringFieldToString(byte[] data, int offset, int length) {
+        if (length == 0) {
+            return "";
+        }
+        if (length >= 1) {
+            if (data[offset] == (byte) 0x80) {
+                int ucslen = (length - 1) / 2;
+                String ret = null;
+
+                try {
+                    ret = new String(data, offset + 1, ucslen * 2, "utf-16be");
+                } catch (UnsupportedEncodingException ex) {
+                    Rlog.e(LOG_TAG, "implausible UnsupportedEncodingException",
+                          ex);
+                }
+
+                if (ret != null) {
+                    // trim off trailing FFFF characters
+
+                    ucslen = ret.length();
+                    while (ucslen > 0 && ret.charAt(ucslen - 1) == '\uFFFF')
+                        ucslen--;
+
+                    return ret.substring(0, ucslen);
+                }
+            }
+        }
+
+        boolean isucs2 = false;
+        char base = '\0';
+        int len = 0;
+
+        if (length >= 3 && data[offset] == (byte) 0x81) {
+            len = data[offset + 1] & 0xFF;
+            if (len > length - 3)
+                len = length - 3;
+
+            base = (char) ((data[offset + 2] & 0xFF) << 7);
+            offset += 3;
+            isucs2 = true;
+        } else if (length >= 4 && data[offset] == (byte) 0x82) {
+            len = data[offset + 1] & 0xFF;
+            if (len > length - 4)
+                len = length - 4;
+
+            base = (char) (((data[offset + 2] & 0xFF) << 8) |
+                            (data[offset + 3] & 0xFF));
+            offset += 4;
+            isucs2 = true;
+        }
+
+        if (isucs2) {
+            StringBuilder ret = new StringBuilder();
+
+            while (len > 0) {
+                // UCS2 subset case
+
+                if (data[offset] < 0) {
+                    ret.append((char) (base + (data[offset] & 0x7F)));
+                    offset++;
+                    len--;
+                }
+
+                // GSM character set case
+
+                int count = 0;
+                while (count < len && data[offset + count] >= 0)
+                    count++;
+
+                ret.append(GsmAlphabet.gsm8BitUnpackedToString(data,
+                           offset, count));
+
+                offset += count;
+                len -= count;
+            }
+
+            return ret.toString();
+        }
+
+        Resources resource = Resources.getSystem();
+        String defaultCharset = "";
+        try {
+            defaultCharset =
+                    resource.getString(com.android.internal.R.string.gsm_alphabet_default_charset);
+        } catch (NotFoundException e) {
+            // Ignore Exception and defaultCharset is set to a empty string.
+        }
+        return GsmAlphabet.gsm8BitUnpackedToString(data, offset, length, defaultCharset.trim());
+    }
+
+    static int
+    hexCharToInt(char c) {
+        if (c >= '0' && c <= '9') return (c - '0');
+        if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
+        if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
+
+        throw new RuntimeException ("invalid hex char '" + c + "'");
+    }
+
+    /**
+     * Converts a hex String to a byte array.
+     *
+     * @param s A string of hexadecimal characters, must be an even number of
+     *          chars long
+     *
+     * @return byte array representation
+     *
+     * @throws RuntimeException on invalid format
+     */
+    public static byte[]
+    hexStringToBytes(String s) {
+        byte[] ret;
+
+        if (s == null) return null;
+
+        int sz = s.length();
+
+        ret = new byte[sz/2];
+
+        for (int i=0 ; i <sz ; i+=2) {
+            ret[i/2] = (byte) ((hexCharToInt(s.charAt(i)) << 4)
+                                | hexCharToInt(s.charAt(i+1)));
+        }
+
+        return ret;
+    }
+
+
+    /**
+     * Converts a byte array into a String of hexadecimal characters.
+     *
+     * @param bytes an array of bytes
+     *
+     * @return hex string representation of bytes array
+     */
+    public static String
+    bytesToHexString(byte[] bytes) {
+        if (bytes == null) return null;
+
+        StringBuilder ret = new StringBuilder(2*bytes.length);
+
+        for (int i = 0 ; i < bytes.length ; i++) {
+            int b;
+
+            b = 0x0f & (bytes[i] >> 4);
+
+            ret.append("0123456789abcdef".charAt(b));
+
+            b = 0x0f & bytes[i];
+
+            ret.append("0123456789abcdef".charAt(b));
+        }
+
+        return ret.toString();
+    }
+
+
+    /**
+     * Convert a TS 24.008 Section 10.5.3.5a Network Name field to a string
+     * "offset" points to "octet 3", the coding scheme byte
+     * empty string returned on decode error
+     */
+    public static String
+    networkNameToString(byte[] data, int offset, int length) {
+        String ret;
+
+        if ((data[offset] & 0x80) != 0x80 || length < 1) {
+            return "";
+        }
+
+        switch ((data[offset] >>> 4) & 0x7) {
+            case 0:
+                // SMS character set
+                int countSeptets;
+                int unusedBits = data[offset] & 7;
+                countSeptets = (((length - 1) * 8) - unusedBits) / 7 ;
+                ret =  GsmAlphabet.gsm7BitPackedToString(data, offset + 1, countSeptets);
+            break;
+            case 1:
+                // UCS2
+                try {
+                    ret = new String(data,
+                            offset + 1, length - 1, "utf-16");
+                } catch (UnsupportedEncodingException ex) {
+                    ret = "";
+                    Rlog.e(LOG_TAG,"implausible UnsupportedEncodingException", ex);
+                }
+            break;
+
+            // unsupported encoding
+            default:
+                ret = "";
+            break;
+        }
+
+        // "Add CI"
+        // "The MS should add the letters for the Country's Initials and
+        //  a separator (e.g. a space) to the text string"
+
+        if ((data[offset] & 0x40) != 0) {
+            // FIXME(mkf) add country initials here
+
+        }
+
+        return ret;
+    }
+
+    /**
+     * Convert a TS 131.102 image instance of code scheme '11' into Bitmap
+     * @param data The raw data
+     * @param length The length of image body
+     * @return The bitmap
+     */
+    public static Bitmap parseToBnW(byte[] data, int length){
+        int valueIndex = 0;
+        int width = data[valueIndex++] & 0xFF;
+        int height = data[valueIndex++] & 0xFF;
+        int numOfPixels = width*height;
+
+        int[] pixels = new int[numOfPixels];
+
+        int pixelIndex = 0;
+        int bitIndex = 7;
+        byte currentByte = 0x00;
+        while (pixelIndex < numOfPixels) {
+            // reassign data and index for every byte (8 bits).
+            if (pixelIndex % 8 == 0) {
+                currentByte = data[valueIndex++];
+                bitIndex = 7;
+            }
+            pixels[pixelIndex++] = bitToRGB((currentByte >> bitIndex-- ) & 0x01);
+        };
+
+        if (pixelIndex != numOfPixels) {
+            Rlog.e(LOG_TAG, "parse end and size error");
+        }
+        return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
+    }
+
+    private static int bitToRGB(int bit){
+        if(bit == 1){
+            return Color.WHITE;
+        } else {
+            return Color.BLACK;
+        }
+    }
+
+    /**
+     * a TS 131.102 image instance of code scheme '11' into color Bitmap
+     *
+     * @param data The raw data
+     * @param length the length of image body
+     * @param transparency with or without transparency
+     * @return The color bitmap
+     */
+    public static Bitmap parseToRGB(byte[] data, int length,
+            boolean transparency) {
+        int valueIndex = 0;
+        int width = data[valueIndex++] & 0xFF;
+        int height = data[valueIndex++] & 0xFF;
+        int bits = data[valueIndex++] & 0xFF;
+        int colorNumber = data[valueIndex++] & 0xFF;
+        int clutOffset = ((data[valueIndex++] & 0xFF) << 8)
+                | (data[valueIndex++] & 0xFF);
+
+        int[] colorIndexArray = getCLUT(data, clutOffset, colorNumber);
+        if (true == transparency) {
+            colorIndexArray[colorNumber - 1] = Color.TRANSPARENT;
+        }
+
+        int[] resultArray = null;
+        if (0 == (8 % bits)) {
+            resultArray = mapTo2OrderBitColor(data, valueIndex,
+                    (width * height), colorIndexArray, bits);
+        } else {
+            resultArray = mapToNon2OrderBitColor(data, valueIndex,
+                    (width * height), colorIndexArray, bits);
+        }
+
+        return Bitmap.createBitmap(resultArray, width, height,
+                Bitmap.Config.RGB_565);
+    }
+
+    private static int[] mapTo2OrderBitColor(byte[] data, int valueIndex,
+            int length, int[] colorArray, int bits) {
+        if (0 != (8 % bits)) {
+            Rlog.e(LOG_TAG, "not event number of color");
+            return mapToNon2OrderBitColor(data, valueIndex, length, colorArray,
+                    bits);
+        }
+
+        int mask = 0x01;
+        switch (bits) {
+        case 1:
+            mask = 0x01;
+            break;
+        case 2:
+            mask = 0x03;
+            break;
+        case 4:
+            mask = 0x0F;
+            break;
+        case 8:
+            mask = 0xFF;
+            break;
+        }
+
+        int[] resultArray = new int[length];
+        int resultIndex = 0;
+        int run = 8 / bits;
+        while (resultIndex < length) {
+            byte tempByte = data[valueIndex++];
+            for (int runIndex = 0; runIndex < run; ++runIndex) {
+                int offset = run - runIndex - 1;
+                resultArray[resultIndex++] = colorArray[(tempByte >> (offset * bits))
+                        & mask];
+            }
+        }
+        return resultArray;
+    }
+
+    private static int[] mapToNon2OrderBitColor(byte[] data, int valueIndex,
+            int length, int[] colorArray, int bits) {
+        if (0 == (8 % bits)) {
+            Rlog.e(LOG_TAG, "not odd number of color");
+            return mapTo2OrderBitColor(data, valueIndex, length, colorArray,
+                    bits);
+        }
+
+        int[] resultArray = new int[length];
+        // TODO fix me:
+        return resultArray;
+    }
+
+    private static int[] getCLUT(byte[] rawData, int offset, int number) {
+        if (null == rawData) {
+            return null;
+        }
+
+        int[] result = new int[number];
+        int endIndex = offset + (number * 3); // 1 color use 3 bytes
+        int valueIndex = offset;
+        int colorIndex = 0;
+        int alpha = 0xff << 24;
+        do {
+            result[colorIndex++] = alpha
+                    | ((rawData[valueIndex++] & 0xFF) << 16)
+                    | ((rawData[valueIndex++] & 0xFF) << 8)
+                    | ((rawData[valueIndex++] & 0xFF));
+        } while (valueIndex < endIndex);
+        return result;
+    }
+}
diff --git a/src/java/com/android/internal/telephony/IccVmFixedException.java b/src/java/com/android/internal/telephony/uicc/IccVmFixedException.java
similarity index 94%
rename from src/java/com/android/internal/telephony/IccVmFixedException.java
rename to src/java/com/android/internal/telephony/uicc/IccVmFixedException.java
index a75496f..f3f3fbb 100644
--- a/src/java/com/android/internal/telephony/IccVmFixedException.java
+++ b/src/java/com/android/internal/telephony/uicc/IccVmFixedException.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/IccVmNotSupportedException.java b/src/java/com/android/internal/telephony/uicc/IccVmNotSupportedException.java
similarity index 94%
rename from src/java/com/android/internal/telephony/IccVmNotSupportedException.java
rename to src/java/com/android/internal/telephony/uicc/IccVmNotSupportedException.java
index 3c9d126..faa5831 100644
--- a/src/java/com/android/internal/telephony/IccVmNotSupportedException.java
+++ b/src/java/com/android/internal/telephony/uicc/IccVmNotSupportedException.java
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
+
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/ims/IsimFileHandler.java b/src/java/com/android/internal/telephony/uicc/IsimFileHandler.java
similarity index 82%
rename from src/java/com/android/internal/telephony/ims/IsimFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/IsimFileHandler.java
index 2e00c19..d7f2e40 100644
--- a/src/java/com/android/internal/telephony/ims/IsimFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/IsimFileHandler.java
@@ -14,14 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.ims;
+package com.android.internal.telephony.uicc;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.UiccCardApplication;
 
 /**
  * {@hide}
@@ -48,11 +45,11 @@
 
     @Override
     protected void logd(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     @Override
     protected void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/ims/IsimRecords.java b/src/java/com/android/internal/telephony/uicc/IsimRecords.java
similarity index 96%
rename from src/java/com/android/internal/telephony/ims/IsimRecords.java
rename to src/java/com/android/internal/telephony/uicc/IsimRecords.java
index b8b98b9..25376c1 100644
--- a/src/java/com/android/internal/telephony/ims/IsimRecords.java
+++ b/src/java/com/android/internal/telephony/uicc/IsimRecords.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.ims;
+package com.android.internal.telephony.uicc;
 
 /**
  * {@hide}
diff --git a/src/java/com/android/internal/telephony/ims/IsimUiccRecords.java b/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java
similarity index 88%
rename from src/java/com/android/internal/telephony/ims/IsimUiccRecords.java
rename to src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java
index 2a658bf..2330aa8 100644
--- a/src/java/com/android/internal/telephony/ims/IsimUiccRecords.java
+++ b/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java
@@ -14,30 +14,27 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.ims;
+package com.android.internal.telephony.uicc;
 
 import android.content.Context;
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.AdnRecord;
-import com.android.internal.telephony.AdnRecordCache;
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccRecords;
-import com.android.internal.telephony.UiccCardApplication;
 import com.android.internal.telephony.gsm.SimTlv;
-import com.android.internal.telephony.gsm.SpnOverride;
 //import com.android.internal.telephony.gsm.VoiceMailConstants;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
+import java.util.Arrays;
 
-import static com.android.internal.telephony.IccConstants.EF_DOMAIN;
-import static com.android.internal.telephony.IccConstants.EF_IMPI;
-import static com.android.internal.telephony.IccConstants.EF_IMPU;
+import static com.android.internal.telephony.uicc.IccConstants.EF_DOMAIN;
+import static com.android.internal.telephony.uicc.IccConstants.EF_IMPI;
+import static com.android.internal.telephony.uicc.IccConstants.EF_IMPU;
 
 /**
  * {@hide}
@@ -80,7 +77,7 @@
     // ***** Overridden from Handler
     public void handleMessage(Message msg) {
         if (mDestroyed.get()) {
-            Log.e(LOG_TAG, "Received message " + msg +
+            Rlog.e(LOG_TAG, "Received message " + msg +
                     "[" + msg.what + "] while being destroyed. Ignoring.");
             return;
         }
@@ -97,7 +94,7 @@
             }
         } catch (RuntimeException exc) {
             // I don't want these exceptions to be fatal
-            Log.w(LOG_TAG, "Exception parsing SIM record", exc);
+            Rlog.w(LOG_TAG, "Exception parsing SIM record", exc);
         }
     }
 
@@ -179,7 +176,7 @@
             }
         } while (tlv.nextObject());
 
-        Log.e(LOG_TAG, "[ISIM] can't find TLV tag in ISIM record, returning null");
+        Rlog.e(LOG_TAG, "[ISIM] can't find TLV tag in ISIM record, returning null");
         return null;
     }
 
@@ -262,11 +259,22 @@
 
     @Override
     protected void log(String s) {
-        if (DBG) Log.d(LOG_TAG, "[ISIM] " + s);
+        if (DBG) Rlog.d(LOG_TAG, "[ISIM] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        if (DBG) Log.e(LOG_TAG, "[ISIM] " + s);
+        if (DBG) Rlog.e(LOG_TAG, "[ISIM] " + s);
+    }
+
+    @Override
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("IsimRecords: " + this);
+        pw.println(" extends:");
+        super.dump(fd, pw, args);
+        pw.println(" mIsimImpi=" + mIsimImpi);
+        pw.println(" mIsimDomain=" + mIsimDomain);
+        pw.println(" mIsimImpu[]=" + Arrays.toString(mIsimImpu));
+        pw.flush();
     }
 }
diff --git a/src/java/com/android/internal/telephony/cdma/RuimFileHandler.java b/src/java/com/android/internal/telephony/uicc/RuimFileHandler.java
similarity index 87%
rename from src/java/com/android/internal/telephony/cdma/RuimFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/RuimFileHandler.java
index 4c271f9..180b277 100644
--- a/src/java/com/android/internal/telephony/cdma/RuimFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/RuimFileHandler.java
@@ -14,14 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.cdma;
+package com.android.internal.telephony.uicc;
 
 import android.os.*;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.UiccCardApplication;
 
 /**
  * {@hide}
@@ -67,12 +65,12 @@
 
     @Override
     protected void logd(String msg) {
-        Log.d(LOG_TAG, "[RuimFileHandler] " + msg);
+        Rlog.d(LOG_TAG, "[RuimFileHandler] " + msg);
     }
 
     @Override
     protected void loge(String msg) {
-        Log.e(LOG_TAG, "[RuimFileHandler] " + msg);
+        Rlog.e(LOG_TAG, "[RuimFileHandler] " + msg);
     }
 
 }
diff --git a/src/java/com/android/internal/telephony/cdma/RuimRecords.java b/src/java/com/android/internal/telephony/uicc/RuimRecords.java
similarity index 94%
rename from src/java/com/android/internal/telephony/cdma/RuimRecords.java
rename to src/java/com/android/internal/telephony/uicc/RuimRecords.java
index e8cd8f3..c7d1070 100755
--- a/src/java/com/android/internal/telephony/cdma/RuimRecords.java
+++ b/src/java/com/android/internal/telephony/uicc/RuimRecords.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.cdma;
+package com.android.internal.telephony.uicc;
 
 
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY;
@@ -23,7 +23,10 @@
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_TEST_CSIM;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Locale;
 import android.content.Context;
 import android.os.AsyncResult;
@@ -31,29 +34,20 @@
 import android.os.Message;
 import android.os.Registrant;
 import android.os.SystemProperties;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.AdnRecord;
-import com.android.internal.telephony.AdnRecordCache;
-import com.android.internal.telephony.AdnRecordLoader;
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.IccCardConstants;
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccRefreshResponse;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.TelephonyProperties;
 import com.android.internal.telephony.MccTable;
-import com.android.internal.telephony.UiccCardApplication;
 
 // can't be used since VoiceMailConstants is not public
 //import com.android.internal.telephony.gsm.VoiceMailConstants;
-import com.android.internal.telephony.IccException;
-import com.android.internal.telephony.IccRecords;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.PhoneProxy;
-import com.android.internal.telephony.IccCardApplicationStatus.AppType;
-import com.android.internal.telephony.IccRecords.IccRecordLoaded;
 import com.android.internal.telephony.cdma.sms.UserData;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
 
 
 /**
@@ -506,7 +500,7 @@
             case EVENT_UPDATE_DONE:
                 ar = (AsyncResult)msg.obj;
                 if (ar.exception != null) {
-                    Log.i(LOG_TAG, "RuimRecords update failed", ar.exception);
+                    Rlog.i(LOG_TAG, "RuimRecords update failed", ar.exception);
                 }
             break;
 
@@ -514,7 +508,7 @@
             case EVENT_MARK_SMS_READ_DONE:
             case EVENT_SMS_ON_RUIM:
             case EVENT_GET_SMS_DONE:
-                Log.w(LOG_TAG, "Event not supported: " + msg.what);
+                Rlog.w(LOG_TAG, "Event not supported: " + msg.what);
                 break;
 
             // TODO: probably EF_CST should be read instead
@@ -535,7 +529,7 @@
 
         }}catch (RuntimeException exc) {
             // I don't want these exceptions to be fatal
-            Log.w(LOG_TAG, "Exception parsing RUIM record", exc);
+            Rlog.w(LOG_TAG, "Exception parsing RUIM record", exc);
         } finally {
             // Count up record load responses even if they are fails
             if (isRecordLoadResponse) {
@@ -799,11 +793,30 @@
     }
     @Override
     protected void log(String s) {
-        Log.d(LOG_TAG, "[RuimRecords] " + s);
+        Rlog.d(LOG_TAG, "[RuimRecords] " + s);
     }
 
     @Override
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[RuimRecords] " + s);
+        Rlog.e(LOG_TAG, "[RuimRecords] " + s);
+    }
+
+    @Override
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("RuimRecords: " + this);
+        pw.println(" extends:");
+        super.dump(fd, pw, args);
+        pw.println(" m_ota_commited=" + m_ota_commited);
+        pw.println(" mMyMobileNumber=" + mMyMobileNumber);
+        pw.println(" mMin2Min1=" + mMin2Min1);
+        pw.println(" mPrlVersion=" + mPrlVersion);
+        pw.println(" mEFpl[]=" + Arrays.toString(mEFpl));
+        pw.println(" mEFli[]=" + Arrays.toString(mEFli));
+        pw.println(" mCsimSpnDisplayCondition=" + mCsimSpnDisplayCondition);
+        pw.println(" mMdn=" + mMdn);
+        pw.println(" mMin=" + mMin);
+        pw.println(" mHomeSystemId=" + mHomeSystemId);
+        pw.println(" mHomeNetworkId=" + mHomeNetworkId);
+        pw.flush();
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java b/src/java/com/android/internal/telephony/uicc/SIMFileHandler.java
similarity index 83%
rename from src/java/com/android/internal/telephony/gsm/SIMFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/SIMFileHandler.java
index 0387a70..797a085 100644
--- a/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/SIMFileHandler.java
@@ -14,15 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm;
+package com.android.internal.telephony.uicc;
 
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.UiccCardApplication;
 
 /**
  * {@hide}
@@ -71,18 +68,18 @@
         }
         String path = getCommonIccEFPath(efid);
         if (path == null) {
-            Log.e(LOG_TAG, "Error: EF Path being returned in null");
+            Rlog.e(LOG_TAG, "Error: EF Path being returned in null");
         }
         return path;
     }
 
     @Override
     protected void logd(String msg) {
-        Log.d(LOG_TAG, "[SIMFileHandler] " + msg);
+        Rlog.d(LOG_TAG, "[SIMFileHandler] " + msg);
     }
 
     @Override
     protected void loge(String msg) {
-        Log.e(LOG_TAG, "[SIMFileHandler] " + msg);
+        Rlog.e(LOG_TAG, "[SIMFileHandler] " + msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/SIMRecords.java b/src/java/com/android/internal/telephony/uicc/SIMRecords.java
similarity index 96%
rename from src/java/com/android/internal/telephony/gsm/SIMRecords.java
rename to src/java/com/android/internal/telephony/uicc/SIMRecords.java
index e866757..66eaf6a 100755
--- a/src/java/com/android/internal/telephony/gsm/SIMRecords.java
+++ b/src/java/com/android/internal/telephony/uicc/SIMRecords.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm;
+package com.android.internal.telephony.uicc;
 
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;
 import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY;
@@ -25,27 +25,22 @@
 import android.os.Message;
 import android.os.SystemProperties;
 import android.text.TextUtils;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.AdnRecord;
-import com.android.internal.telephony.AdnRecordCache;
-import com.android.internal.telephony.AdnRecordLoader;
 import com.android.internal.telephony.BaseCommands;
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.IccCardConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccRecords;
-import com.android.internal.telephony.IccUtils;
-import com.android.internal.telephony.IccVmFixedException;
-import com.android.internal.telephony.IccVmNotSupportedException;
 import com.android.internal.telephony.MccTable;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.SmsMessageBase;
-import com.android.internal.telephony.IccRefreshResponse;
-import com.android.internal.telephony.UiccCardApplication;
+import com.android.internal.telephony.gsm.SimTlv;
+import com.android.internal.telephony.gsm.SmsMessage;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 
 /**
@@ -100,8 +95,8 @@
     // ***** Constants
 
     // Bitmasks for SPN display rules.
-    static final int SPN_RULE_SHOW_SPN  = 0x01;
-    static final int SPN_RULE_SHOW_PLMN = 0x02;
+    public static final int SPN_RULE_SHOW_SPN  = 0x01;
+    public static final int SPN_RULE_SHOW_PLMN = 0x02;
 
     // From TS 51.011 EF[SPDI] section
     static final int TAG_SPDI = 0xA3;
@@ -944,7 +939,7 @@
                 break;
 
             case EVENT_MARK_SMS_READ_DONE:
-                Log.i("ENF", "marked read: sms " + msg.arg1);
+                Rlog.i("ENF", "marked read: sms " + msg.arg1);
                 break;
 
 
@@ -1205,7 +1200,7 @@
 
     private void handleSms(byte[] ba) {
         if (ba[0] != 0)
-            Log.d("ENF", "status : " + ba[0]);
+            Rlog.d("ENF", "status : " + ba[0]);
 
         // 3GPP TS 51.011 v5.0.0 (20011-12)  10.5.3
         // 3 == "received by MS from network; message to be read"
@@ -1230,7 +1225,7 @@
             byte[] ba = (byte[]) messages.get(i);
 
             if (ba[0] != 0)
-                Log.i("ENF", "status " + i + ": " + ba[0]);
+                Rlog.i("ENF", "status " + i + ": " + ba[0]);
 
             // 3GPP TS 51.011 v5.0.0 (20011-12)  10.5.3
             // 3 == "received by MS from network; message to be read"
@@ -1618,19 +1613,19 @@
     }
 
     protected void log(String s) {
-        Log.d(LOG_TAG, "[SIMRecords] " + s);
+        Rlog.d(LOG_TAG, "[SIMRecords] " + s);
     }
 
     protected void loge(String s) {
-        Log.e(LOG_TAG, "[SIMRecords] " + s);
+        Rlog.e(LOG_TAG, "[SIMRecords] " + s);
     }
 
     protected void logw(String s, Throwable tr) {
-        Log.w(LOG_TAG, "[SIMRecords] " + s, tr);
+        Rlog.w(LOG_TAG, "[SIMRecords] " + s, tr);
     }
 
     protected void logv(String s) {
-        Log.v(LOG_TAG, "[SIMRecords] " + s);
+        Rlog.v(LOG_TAG, "[SIMRecords] " + s);
     }
 
     /**
@@ -1681,4 +1676,26 @@
 
         log("[CSP] Value Added Service Group (0xC0), not found!");
     }
-}
+
+    @Override
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("SIMRecords: " + this);
+        pw.println(" extends:");
+        super.dump(fd, pw, args);
+        pw.println(" mVmConfig=" + mVmConfig);
+        pw.println(" mSpnOverride=" + mSpnOverride);
+        pw.println(" callForwardingEnabled=" + callForwardingEnabled);
+        pw.println(" spnState=" + spnState);
+        pw.println(" mCphsInfo=" + mCphsInfo);
+        pw.println(" mCspPlmnEnabled=" + mCspPlmnEnabled);
+        pw.println(" efMWIS[]=" + Arrays.toString(efMWIS));
+        pw.println(" efCPHS_MWI[]=" + Arrays.toString(efCPHS_MWI));
+        pw.println(" mEfCff[]=" + Arrays.toString(mEfCff));
+        pw.println(" mEfCfis[]=" + Arrays.toString(mEfCfis));
+        pw.println(" spnDisplayCondition=" + spnDisplayCondition);
+        pw.println(" spdiNetworks[]=" + spdiNetworks);
+        pw.println(" pnnHomeName=" + pnnHomeName);
+        pw.println(" mUsimServiceTable=" + mUsimServiceTable);
+        pw.flush();
+    }
+}
\ No newline at end of file
diff --git a/src/java/com/android/internal/telephony/gsm/SpnOverride.java b/src/java/com/android/internal/telephony/uicc/SpnOverride.java
similarity index 90%
rename from src/java/com/android/internal/telephony/gsm/SpnOverride.java
rename to src/java/com/android/internal/telephony/uicc/SpnOverride.java
index 918c2d2..2c06b2b 100644
--- a/src/java/com/android/internal/telephony/gsm/SpnOverride.java
+++ b/src/java/com/android/internal/telephony/uicc/SpnOverride.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm;
+package com.android.internal.telephony.uicc;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -26,7 +26,7 @@
 import org.xmlpull.v1.XmlPullParserException;
 
 import android.os.Environment;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.util.Xml;
 
 import com.android.internal.util.XmlUtils;
@@ -60,7 +60,7 @@
         try {
             spnReader = new FileReader(spnFile);
         } catch (FileNotFoundException e) {
-            Log.w(LOG_TAG, "Can't open " +
+            Rlog.w(LOG_TAG, "Can't open " +
                     Environment.getRootDirectory() + "/" + PARTNER_SPN_OVERRIDE_PATH);
             return;
         }
@@ -85,9 +85,9 @@
                 CarrierSpnMap.put(numeric, data);
             }
         } catch (XmlPullParserException e) {
-            Log.w(LOG_TAG, "Exception in spn-conf parser " + e);
+            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
         } catch (IOException e) {
-            Log.w(LOG_TAG, "Exception in spn-conf parser " + e);
+            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
         }
     }
 
diff --git a/src/java/com/android/internal/telephony/UiccCard.java b/src/java/com/android/internal/telephony/uicc/UiccCard.java
similarity index 83%
rename from src/java/com/android/internal/telephony/UiccCard.java
rename to src/java/com/android/internal/telephony/uicc/UiccCard.java
index 038a138..c3e816d 100644
--- a/src/java/com/android/internal/telephony/UiccCard.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccCard.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import static android.Manifest.permission.READ_PHONE_STATE;
 import android.app.ActivityManagerNative;
@@ -29,31 +29,29 @@
 import android.os.PowerManager;
 import android.os.Registrant;
 import android.os.RegistrantList;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.view.WindowManager;
 
+import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.PhoneBase;
 import com.android.internal.telephony.CommandsInterface.RadioState;
 import com.android.internal.telephony.IccCardConstants.State;
-import com.android.internal.telephony.IccCardApplicationStatus;
-import com.android.internal.telephony.IccCardApplicationStatus.AppType;
-import com.android.internal.telephony.IccCardStatus.CardState;
-import com.android.internal.telephony.IccCardStatus.PinState;
 import com.android.internal.telephony.gsm.GSMPhone;
-import com.android.internal.telephony.gsm.SIMFileHandler;
-import com.android.internal.telephony.gsm.SIMRecords;
-import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.IccCardStatus.CardState;
+import com.android.internal.telephony.uicc.IccCardStatus.PinState;
 import com.android.internal.telephony.cat.CatService;
 import com.android.internal.telephony.cdma.CDMALTEPhone;
 import com.android.internal.telephony.cdma.CDMAPhone;
 import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
-import com.android.internal.telephony.cdma.RuimFileHandler;
-import com.android.internal.telephony.cdma.RuimRecords;
 
 import android.os.SystemProperties;
 
 import com.android.internal.R;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
 /**
  * {@hide}
  */
@@ -349,10 +347,57 @@
     }
 
     private void log(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     private void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
+    }
+
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("UiccCard:");
+        pw.println(" mCi=" + mCi);
+        pw.println(" mDestroyed=" + mDestroyed);
+        pw.println(" mLastRadioState=" + mLastRadioState);
+        pw.println(" mCatService=" + mCatService);
+        pw.println(" mAbsentRegistrants: size=" + mAbsentRegistrants.size());
+        for (int i = 0; i < mAbsentRegistrants.size(); i++) {
+            pw.println("  mAbsentRegistrants[" + i + "]="
+                    + ((Registrant)mAbsentRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mCardState=" + mCardState);
+        pw.println(" mUniversalPinState=" + mUniversalPinState);
+        pw.println(" mGsmUmtsSubscriptionAppIndex=" + mGsmUmtsSubscriptionAppIndex);
+        pw.println(" mCdmaSubscriptionAppIndex=" + mCdmaSubscriptionAppIndex);
+        pw.println(" mImsSubscriptionAppIndex=" + mImsSubscriptionAppIndex);
+        pw.println(" mImsSubscriptionAppIndex=" + mImsSubscriptionAppIndex);
+        pw.println(" mUiccApplications: length=" + mUiccApplications.length);
+        for (int i = 0; i < mUiccApplications.length; i++) {
+            if (mUiccApplications[i] == null) {
+                pw.println("  mUiccApplications[" + i + "]=" + null);
+            } else {
+                pw.println("  mUiccApplications[" + i + "]="
+                        + mUiccApplications[i].getType() + " " + mUiccApplications[i]);
+            }
+        }
+        pw.println();
+        // Print details of all applications
+        for (UiccCardApplication app : mUiccApplications) {
+            if (app != null) {
+                app.dump(fd, pw, args);
+                pw.println();
+            }
+        }
+        // Print details of all IccRecords
+        for (UiccCardApplication app : mUiccApplications) {
+            if (app != null) {
+                IccRecords ir = app.getIccRecords();
+                if (ir != null) {
+                    ir.dump(fd, pw, args);
+                    pw.println();
+                }
+            }
+        }
+        pw.flush();
     }
 }
diff --git a/src/java/com/android/internal/telephony/UiccCardApplication.java b/src/java/com/android/internal/telephony/uicc/UiccCardApplication.java
similarity index 90%
rename from src/java/com/android/internal/telephony/UiccCardApplication.java
rename to src/java/com/android/internal/telephony/uicc/UiccCardApplication.java
index 2718af6..6618197 100644
--- a/src/java/com/android/internal/telephony/UiccCardApplication.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccCardApplication.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
 import android.content.Context;
 import android.os.AsyncResult;
@@ -22,18 +22,16 @@
 import android.os.Message;
 import android.os.Registrant;
 import android.os.RegistrantList;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccCardApplicationStatus.AppState;
-import com.android.internal.telephony.IccCardApplicationStatus.AppType;
-import com.android.internal.telephony.IccCardApplicationStatus.PersoSubState;
-import com.android.internal.telephony.IccCardStatus.PinState;
-import com.android.internal.telephony.cdma.RuimFileHandler;
-import com.android.internal.telephony.cdma.RuimRecords;
-import com.android.internal.telephony.gsm.SIMFileHandler;
-import com.android.internal.telephony.gsm.SIMRecords;
-import com.android.internal.telephony.ims.IsimFileHandler;
-import com.android.internal.telephony.ims.IsimUiccRecords;
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState;
+import com.android.internal.telephony.uicc.IccCardStatus.PinState;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 
 /**
  * {@hide}
@@ -690,10 +688,47 @@
     }
 
     private void log(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     private void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
+    }
+
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("UiccCardApplication: " + this);
+        pw.println(" mUiccCard=" + mUiccCard);
+        pw.println(" mAppState=" + mAppState);
+        pw.println(" mAppType=" + mAppType);
+        pw.println(" mPersoSubState=" + mPersoSubState);
+        pw.println(" mAid=" + mAid);
+        pw.println(" mAppLabel=" + mAppLabel);
+        pw.println(" mPin1Replaced=" + mPin1Replaced);
+        pw.println(" mPin1State=" + mPin1State);
+        pw.println(" mPin2State=" + mPin2State);
+        pw.println(" mIccFdnEnabled=" + mIccFdnEnabled);
+        pw.println(" mDesiredFdnEnabled=" + mDesiredFdnEnabled);
+        pw.println(" mIccLockEnabled=" + mIccLockEnabled);
+        pw.println(" mDesiredPinLocked=" + mDesiredPinLocked);
+        pw.println(" mCi=" + mCi);
+        pw.println(" mIccRecords=" + mIccRecords);
+        pw.println(" mIccFh=" + mIccFh);
+        pw.println(" mDestroyed=" + mDestroyed);
+        pw.println(" mReadyRegistrants: size=" + mReadyRegistrants.size());
+        for (int i = 0; i < mReadyRegistrants.size(); i++) {
+            pw.println("  mReadyRegistrants[" + i + "]="
+                    + ((Registrant)mReadyRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mPinLockedRegistrants: size=" + mPinLockedRegistrants.size());
+        for (int i = 0; i < mPinLockedRegistrants.size(); i++) {
+            pw.println("  mPinLockedRegistrants[" + i + "]="
+                    + ((Registrant)mPinLockedRegistrants.get(i)).getHandler());
+        }
+        pw.println(" mNetworkLockedRegistrants: size=" + mNetworkLockedRegistrants.size());
+        for (int i = 0; i < mNetworkLockedRegistrants.size(); i++) {
+            pw.println("  mNetworkLockedRegistrants[" + i + "]="
+                    + ((Registrant)mNetworkLockedRegistrants.get(i)).getHandler());
+        }
+        pw.flush();
     }
 }
diff --git a/src/java/com/android/internal/telephony/uicc/UiccController.java b/src/java/com/android/internal/telephony/uicc/UiccController.java
index 8d0868e..2647b39 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccController.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccController.java
@@ -22,15 +22,12 @@
 import android.os.Message;
 import android.os.Registrant;
 import android.os.RegistrantList;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccCardStatus;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.IccRecords;
-import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.UiccCard;
-import com.android.internal.telephony.UiccCardApplication;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 
 /**
  * This class is responsible for keeping all knowledge about
@@ -185,7 +182,7 @@
                     onGetIccCardStatusDone(ar);
                     break;
                 default:
-                    Log.e(LOG_TAG, " Unknown Event " + msg.what);
+                    Rlog.e(LOG_TAG, " Unknown Event " + msg.what);
             }
         }
     }
@@ -201,7 +198,7 @@
 
     private synchronized void onGetIccCardStatusDone(AsyncResult ar) {
         if (ar.exception != null) {
-            Log.e(LOG_TAG,"Error getting ICC status. "
+            Rlog.e(LOG_TAG,"Error getting ICC status. "
                     + "RIL_REQUEST_GET_ICC_STATUS should "
                     + "never return an error", ar.exception);
             return;
@@ -222,6 +219,24 @@
     }
 
     private void log(String string) {
-        Log.d(LOG_TAG, string);
+        Rlog.d(LOG_TAG, string);
+    }
+
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("UiccController: " + this);
+        pw.println(" mContext=" + mContext);
+        pw.println(" mInstance=" + mInstance);
+        pw.println(" mCi=" + mCi);
+        pw.println(" mUiccCard=" + mUiccCard);
+        pw.println(" mIccChangedRegistrants: size=" + mIccChangedRegistrants.size());
+        for (int i = 0; i < mIccChangedRegistrants.size(); i++) {
+            pw.println("  mIccChangedRegistrants[" + i + "]="
+                    + ((Registrant)mIccChangedRegistrants.get(i)).getHandler());
+        }
+        pw.println();
+        pw.flush();
+        if (mUiccCard != null) {
+            mUiccCard.dump(fd, pw, args);
+        }
     }
 }
diff --git a/src/java/com/android/internal/telephony/UsimFileHandler.java b/src/java/com/android/internal/telephony/uicc/UsimFileHandler.java
similarity index 88%
rename from src/java/com/android/internal/telephony/UsimFileHandler.java
rename to src/java/com/android/internal/telephony/uicc/UsimFileHandler.java
index 5ef0333..f219153 100644
--- a/src/java/com/android/internal/telephony/UsimFileHandler.java
+++ b/src/java/com/android/internal/telephony/uicc/UsimFileHandler.java
@@ -14,14 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.internal.telephony.uicc;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccConstants;
-import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.UiccCardApplication;
+import com.android.internal.telephony.uicc.UiccCardApplication;
 
 /**
  * {@hide}
@@ -77,11 +75,11 @@
 
     @Override
     protected void logd(String msg) {
-        Log.d(LOG_TAG, msg);
+        Rlog.d(LOG_TAG, msg);
     }
 
     @Override
     protected void loge(String msg) {
-        Log.e(LOG_TAG, msg);
+        Rlog.e(LOG_TAG, msg);
     }
 }
diff --git a/src/java/com/android/internal/telephony/gsm/UsimServiceTable.java b/src/java/com/android/internal/telephony/uicc/UsimServiceTable.java
similarity index 97%
rename from src/java/com/android/internal/telephony/gsm/UsimServiceTable.java
rename to src/java/com/android/internal/telephony/uicc/UsimServiceTable.java
index 3fe200b..d00475c 100644
--- a/src/java/com/android/internal/telephony/gsm/UsimServiceTable.java
+++ b/src/java/com/android/internal/telephony/uicc/UsimServiceTable.java
@@ -14,9 +14,8 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm;
+package com.android.internal.telephony.uicc;
 
-import com.android.internal.telephony.IccServiceTable;
 
 /**
  * Wrapper class for the USIM Service Table EF.
diff --git a/src/java/com/android/internal/telephony/gsm/VoiceMailConstants.java b/src/java/com/android/internal/telephony/uicc/VoiceMailConstants.java
similarity index 92%
rename from src/java/com/android/internal/telephony/gsm/VoiceMailConstants.java
rename to src/java/com/android/internal/telephony/uicc/VoiceMailConstants.java
index d2665cb..b2357fc 100644
--- a/src/java/com/android/internal/telephony/gsm/VoiceMailConstants.java
+++ b/src/java/com/android/internal/telephony/uicc/VoiceMailConstants.java
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm;
+package com.android.internal.telephony.uicc;
 
 import android.os.Environment;
 import android.util.Xml;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.util.HashMap;
 import java.io.FileReader;
@@ -79,7 +79,7 @@
         try {
             vmReader = new FileReader(vmFile);
         } catch (FileNotFoundException e) {
-            Log.w(LOG_TAG, "Can't open " +
+            Rlog.w(LOG_TAG, "Can't open " +
                     Environment.getRootDirectory() + "/" + PARTNER_VOICEMAIL_PATH);
             return;
         }
@@ -107,9 +107,9 @@
                 CarrierVmMap.put(numeric, data);
             }
         } catch (XmlPullParserException e) {
-            Log.w(LOG_TAG, "Exception in Voicemail parser " + e);
+            Rlog.w(LOG_TAG, "Exception in Voicemail parser " + e);
         } catch (IOException e) {
-            Log.w(LOG_TAG, "Exception in Voicemail parser " + e);
+            Rlog.w(LOG_TAG, "Exception in Voicemail parser " + e);
         } finally {
             try {
                 if (vmReader != null) {
diff --git a/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java b/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java
index 78ee738..b6bcd27 100644
--- a/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java
+++ b/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java
@@ -20,7 +20,7 @@
 import android.test.InstrumentationTestRunner;
 import android.test.InstrumentationTestSuite;
 import com.android.internal.telephony.mockril.MockRilController;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.telephonymockriltests.functional.SimpleTestUsingMockRil;
 
diff --git a/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java b/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java
index 3ea1cf2..df79b8b 100644
--- a/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java
+++ b/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java
@@ -18,7 +18,7 @@
 
 import com.android.internal.telephony.mockril.MockRilController;
 import android.test.InstrumentationTestCase;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.telephonymockriltests.TelephonyMockTestRunner;
 
@@ -43,7 +43,7 @@
      */
     public void testGetRadioState() {
         int state = mMockRilCtrl.getRadioState();
-        Log.v(TAG, "testGetRadioState: " + state);
+        Rlog.v(TAG, "testGetRadioState: " + state);
         assertTrue(state >= 0 && state <= 9);
     }
 
@@ -53,7 +53,7 @@
      */
     public void testSetRadioState() {
         for (int state = 0; state <= 9; state++) {
-            Log.v(TAG, "set radio state to be " + state);
+            Rlog.v(TAG, "set radio state to be " + state);
             assertTrue("set radio state: " + state + " failed.",
                        mMockRilCtrl.setRadioState(state));
         }
diff --git a/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java b/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java
index 9192f57..25d9f4d 100644
--- a/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java
+++ b/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java
@@ -20,7 +20,7 @@
 
 import android.test.InstrumentationTestRunner;
 import android.test.InstrumentationTestSuite;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.io.IOException;
 
@@ -88,6 +88,6 @@
     }
 
     private void log(String s) {
-        Log.e("TelephonyMockRilTestRunner", s);
+        Rlog.e("TelephonyMockRilTestRunner", s);
     }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java b/tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java
index 8a4a285..d647ae1 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java
@@ -19,6 +19,9 @@
 import junit.framework.TestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import com.android.internal.telephony.uicc.AdnRecord;
+import com.android.internal.telephony.uicc.IccUtils;
+
 /**
  * {@hide}
  */
diff --git a/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java b/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java
index 1e5dafb..5155ccf 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java
@@ -24,7 +24,7 @@
 import android.content.res.Resources;
 import com.android.internal.telephony.CallerInfo;
 import com.android.internal.telephony.CallerInfoAsyncQuery;
-import android.util.Log;
+import android.telephony.Rlog;
 import android.os.Looper;
 import android.test.ActivityInstrumentationTestCase;
 import android.util.StringBuilderPrinter;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/GsmAlphabetTest.java b/tests/telephonytests/src/com/android/internal/telephony/GsmAlphabetTest.java
index f9dc3a9..5a90f4e 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/GsmAlphabetTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/GsmAlphabetTest.java
@@ -17,6 +17,7 @@
 package com.android.internal.telephony;
 
 import com.android.internal.telephony.GsmAlphabet;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import junit.framework.TestCase;
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/IccServiceTableTest.java b/tests/telephonytests/src/com/android/internal/telephony/IccServiceTableTest.java
index c89f33a..f715266 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/IccServiceTableTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/IccServiceTableTest.java
@@ -19,6 +19,8 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import com.android.internal.telephony.uicc.IccServiceTable;
+
 /**
  * Test IccServiceTable class.
  */
diff --git a/tests/telephonytests/src/com/android/internal/telephony/MccTableTest.java b/tests/telephonytests/src/com/android/internal/telephony/MccTableTest.java
index 868c76d..e6dee8b 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/MccTableTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/MccTableTest.java
@@ -21,7 +21,7 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
-import android.util.Log;
+import android.telephony.Rlog;
 
 public class MccTableTest extends AndroidTestCase {
     private final static String LOG_TAG = "GSM";
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SMSDispatcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/SMSDispatcherTest.java
index 8a66614..80cd9f1 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SMSDispatcherTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SMSDispatcherTest.java
@@ -21,6 +21,8 @@
 import com.android.internal.telephony.gsm.SmsMessage;
 import com.android.internal.telephony.test.SimulatedCommands;
 import com.android.internal.telephony.test.SimulatedRadioControl;
+import com.android.internal.telephony.uicc.IccUtils;
+
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.Suppress;
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SimPhoneBookTest.java b/tests/telephonytests/src/com/android/internal/telephony/SimPhoneBookTest.java
index 609e768..9d5c680 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SimPhoneBookTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SimPhoneBookTest.java
@@ -19,6 +19,9 @@
 import android.os.ServiceManager;
 import android.test.suitebuilder.annotation.Suppress;
 
+import com.android.internal.telephony.uicc.AdnRecord;
+import com.android.internal.telephony.uicc.IccConstants;
+
 import java.util.List;
 
 import junit.framework.TestCase;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SimUtilsTest.java b/tests/telephonytests/src/com/android/internal/telephony/SimUtilsTest.java
index ef62d85..c79f17f 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SimUtilsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SimUtilsTest.java
@@ -17,7 +17,8 @@
 package com.android.internal.telephony;
 
 import com.android.internal.telephony.gsm.SimTlv;
-import com.android.internal.telephony.IccUtils;
+import com.android.internal.telephony.uicc.IccUtils;
+
 import junit.framework.TestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java b/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
index b848657..2069696 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
@@ -22,7 +22,7 @@
 import android.test.suitebuilder.annotation.LargeTest;
 import android.test.suitebuilder.annotation.MediumTest;
 import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.SmsConstants;
 
@@ -480,9 +480,9 @@
         }
 
         void printStats() {
-            Log.d(TAG, "Unicode selection count: " + mUnicodeCounter);
+            Rlog.d(TAG, "Unicode selection count: " + mUnicodeCounter);
             for (int i = 0; i < 12; i++) {
-                Log.d(TAG, "Language pair index " + i + " count: " + mStatsCounters[i]);
+                Rlog.d(TAG, "Language pair index " + i + " count: " + mStatsCounters[i]);
             }
         }
     }
@@ -517,7 +517,7 @@
                 ch.addChar(charClass);
 
 //                if (i % 20 == 0) {
-//                    Log.d(TAG, "test string: " + sb);
+//                    Rlog.d(TAG, "test string: " + sb);
 //                }
 
                 // Test string against all combinations of enabled languages
@@ -537,13 +537,13 @@
                 // after 10 iterations with a Unicode-only string, skip to next test string
                 // so we can spend more time testing strings that do encode into 7 bits.
                 if (unicodeOnly && ++unicodeOnlyCount == 10) {
-//                    Log.d(TAG, "Unicode only: skipping to next test string");
+//                    Rlog.d(TAG, "Unicode only: skipping to next test string");
                     break;
                 }
             }
         }
         ch.printStats();
-        Log.d(TAG, "Completed in " + (System.currentTimeMillis() - startTime) + " ms");
+        Rlog.d(TAG, "Completed in " + (System.currentTimeMillis() - startTime) + " ms");
         GsmAlphabet.setEnabledLockingShiftTables(origLockingShiftTables);
         GsmAlphabet.setEnabledSingleShiftTables(origSingleShiftTables);
     }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyUtilsTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyUtilsTest.java
index 3757017..f61aef8 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyUtilsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyUtilsTest.java
@@ -55,8 +55,8 @@
         assertEquals(0, rm.getRetryTimer());
 
         rm.setRetryCount(2);
-        assertFalse(rm.isRetryForever());
-        assertFalse(rm.isRetryNeeded());
+        assertTrue(rm.isRetryForever());
+        assertTrue(rm.isRetryNeeded());
         assertEquals(0, rm.getRetryCount());
         assertEquals(0, rm.getRetryTimer());
     }
@@ -203,7 +203,7 @@
 
         rm.setRetryCount(1);
         assertTrue(rm.isRetryNeeded());
-        assertFalse(rm.isRetryForever());
+        assertTrue(rm.isRetryForever());
         assertEquals(1, rm.getRetryCount());
         assertEquals(2000, rm.getRetryTimer());
 
@@ -212,7 +212,7 @@
         assertTrue(rm.isRetryForever());
         rm.resetRetryCount();
         assertTrue(rm.isRetryNeeded());
-        assertFalse(rm.isRetryForever());
+        assertTrue(rm.isRetryForever());
         assertEquals(0, rm.getRetryCount());
         assertEquals(1000, rm.getRetryTimer());
     }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java b/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
index a95f60c..8f84bdc 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
@@ -21,14 +21,14 @@
 import android.telephony.SmsCbMessage;
 import android.telephony.cdma.CdmaSmsCbProgramData;
 import android.test.AndroidTestCase;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.cdma.sms.BearerData;
 import com.android.internal.telephony.cdma.sms.CdmaSmsAddress;
 import com.android.internal.telephony.cdma.sms.SmsEnvelope;
 import com.android.internal.telephony.cdma.sms.UserData;
+import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.util.BitwiseOutputStream;
 
 import java.util.Arrays;
@@ -525,7 +525,7 @@
             for (int i = 0; i < len; i++) {
                 data[i] = (byte) r.nextInt(256);
             }
-            // Log.d("CdmaSmsCbTest", "trying random bearer data run " + run + " length " + len);
+            // Rlog.d("CdmaSmsCbTest", "trying random bearer data run " + run + " length " + len);
             try {
                 int category = 0x0ff0 + r.nextInt(32);  // half CMAS, half non-CMAS
                 Parcel p = createBroadcastParcel(category);
@@ -533,10 +533,10 @@
                 SmsCbMessage cbMessage = msg.parseBroadcastSms();
                 // with random input, cbMessage will almost always be null (log when it isn't)
                 if (cbMessage != null) {
-                    Log.d("CdmaSmsCbTest", "success: " + cbMessage);
+                    Rlog.d("CdmaSmsCbTest", "success: " + cbMessage);
                 }
             } catch (Exception e) {
-                Log.d("CdmaSmsCbTest", "exception thrown", e);
+                Rlog.d("CdmaSmsCbTest", "exception thrown", e);
                 fail("Exception in decoder at run " + run + " length " + len + ": " + e);
             }
         }
@@ -549,7 +549,7 @@
             int category = 0x0ff0 + r.nextInt(32);  // half CMAS, half non-CMAS
             Parcel p = createBroadcastParcel(category);
             int len = r.nextInt(140);
-            // Log.d("CdmaSmsCbTest", "trying random user data run " + run + " length " + len);
+            // Rlog.d("CdmaSmsCbTest", "trying random user data run " + run + " length " + len);
 
             try {
                 BitwiseOutputStream bos = createBearerDataStream(r.nextInt(65536), r.nextInt(4),
@@ -565,7 +565,7 @@
                 SmsMessage msg = createMessageFromParcel(p, bos.toByteArray());
                 SmsCbMessage cbMessage = msg.parseBroadcastSms();
             } catch (Exception e) {
-                Log.d("CdmaSmsCbTest", "exception thrown", e);
+                Rlog.d("CdmaSmsCbTest", "exception thrown", e);
                 fail("Exception in decoder at run " + run + " length " + len + ": " + e);
             }
         }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/GSMTestHandler.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/GSMTestHandler.java
index fb8a5d9..aa94e0e 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/GSMTestHandler.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/GSMTestHandler.java
@@ -22,7 +22,7 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.gsm.GSMPhone;
 import com.android.internal.telephony.test.SimulatedCommands;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsCbTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsCbTest.java
index 82c6944..943e36d 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsCbTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsCbTest.java
@@ -20,9 +20,9 @@
 import android.telephony.SmsCbLocation;
 import android.telephony.SmsCbMessage;
 import android.test.AndroidTestCase;
-import android.util.Log;
+import android.telephony.Rlog;
 
-import com.android.internal.telephony.IccUtils;
+import com.android.internal.telephony.uicc.IccUtils;
 
 import java.util.Random;
 
@@ -709,7 +709,7 @@
 
     public void testEtwsMessageNormal() {
         SmsCbMessage msg = createFromPdu(etwsMessageNormal);
-        Log.d(TAG, msg.toString());
+        Rlog.d(TAG, msg.toString());
         assertEquals("GS mismatch", 0, msg.getGeographicalScope());
         assertEquals("serial number mismatch", 0, msg.getSerialNumber());
         assertEquals("message ID mismatch", 0x1100, msg.getServiceCategory());
@@ -719,7 +719,7 @@
 
     public void testEtwsMessageCancel() {
         SmsCbMessage msg = createFromPdu(etwsMessageCancel);
-        Log.d(TAG, msg.toString());
+        Rlog.d(TAG, msg.toString());
         assertEquals("GS mismatch", 0, msg.getGeographicalScope());
         assertEquals("serial number mismatch", 0, msg.getSerialNumber());
         assertEquals("message ID mismatch", 0x1100, msg.getServiceCategory());
@@ -729,7 +729,7 @@
 
     public void testEtwsMessageTest() {
         SmsCbMessage msg = createFromPdu(etwsMessageTest);
-        Log.d(TAG, msg.toString());
+        Rlog.d(TAG, msg.toString());
         assertEquals("GS mismatch", 0, msg.getGeographicalScope());
         assertEquals("serial number mismatch", 0, msg.getSerialNumber());
         assertEquals("message ID mismatch", 0x1103, msg.getServiceCategory());
@@ -750,7 +750,7 @@
                 // this should return a SmsCbMessage object or null for invalid data
                 SmsCbMessage msg = createFromPdu(data);
             } catch (Exception e) {
-                Log.d(TAG, "exception thrown", e);
+                Rlog.d(TAG, "exception thrown", e);
                 fail("Exception in decoder at run " + run + " length " + len + ": " + e);
             }
         }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadCommands.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadCommands.java
index ea6836d..980be13 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadCommands.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadCommands.java
@@ -20,11 +20,12 @@
 import android.os.AsyncResult;
 import android.os.Message;
 import android.os.SystemClock;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import com.android.internal.telephony.BaseCommands;
-import com.android.internal.telephony.IccIoResult;
 import com.android.internal.telephony.UUSInfo;
+import com.android.internal.telephony.uicc.IccIoResult;
+import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
 
 import junit.framework.Assert;
 
@@ -105,7 +106,7 @@
     @Override
     public synchronized void acknowledgeLastIncomingGsmSms(boolean success, int cause,
             Message response) {
-        Log.d(TAG, "acknowledgeLastIncomingGsmSms: success=" + success + ", cause=" + cause);
+        Rlog.d(TAG, "acknowledgeLastIncomingGsmSms: success=" + success + ", cause=" + cause);
         Assert.assertTrue("unexpected call to acknowledge SMS", mExpectingAcknowledgeGsmSms);
         Assert.assertEquals(mExpectingAcknowledgeGsmSmsSuccess, success);
         Assert.assertEquals(mExpectingAcknowledgeGsmSmsFailureCause, cause);
@@ -120,7 +121,7 @@
     @Override
     public synchronized void acknowledgeIncomingGsmSmsWithPdu(boolean success, String ackPdu,
             Message response) {
-        Log.d(TAG, "acknowledgeLastIncomingGsmSmsWithPdu: success=" + success
+        Rlog.d(TAG, "acknowledgeLastIncomingGsmSmsWithPdu: success=" + success
                 + ", ackPDU= " + ackPdu);
         Assert.assertTrue("unexpected call to acknowledge SMS", mExpectingAcknowledgeGsmSms);
         Assert.assertEquals(mExpectingAcknowledgeGsmSmsSuccess, success);
@@ -140,7 +141,7 @@
         for (int i = 0; i < contents.length(); i += 2) {
             builder.append(contents.charAt(i)).append(contents.charAt(i+1)).append(' ');
         }
-        Log.d(TAG, "sendEnvelopeWithStatus: " + builder.toString());
+        Rlog.d(TAG, "sendEnvelopeWithStatus: " + builder.toString());
 
         Assert.assertTrue("unexpected call to send envelope", mExpectingSendEnvelope);
         Assert.assertEquals(mExpectingSendEnvelopeContents, contents);
@@ -590,7 +591,7 @@
     }
 
     @Override
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message result) {
+    public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response) {
     }
 
     @Override
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadTest.java
index 6c8ba5e..7f0282a 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimDataDownloadTest.java
@@ -18,7 +18,7 @@
 
 import android.os.HandlerThread;
 import android.test.AndroidTestCase;
-import android.util.Log;
+import android.telephony.Rlog;
 
 import java.nio.charset.Charset;
 
@@ -67,7 +67,7 @@
         mHandlerThread = new TestHandlerThread();
         mHandlerThread.start();
         mHandler = mHandlerThread.getHandler();
-        Log.d(TAG, "mHandler is constructed");
+        Rlog.d(TAG, "mHandler is constructed");
     }
 
     @Override
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimServiceTableTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimServiceTableTest.java
index 56854ed..a2965c6 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimServiceTableTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/UsimServiceTableTest.java
@@ -19,6 +19,8 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import com.android.internal.telephony.uicc.UsimServiceTable;
+
 /**
  * Test UsimServiceTable class.
  */
diff --git a/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java b/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java
index 3149ee1..598d9fe 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.telephony.mockril;
 
-import android.util.Log;
+import android.telephony.Rlog;
 import android.test.InstrumentationTestCase;
 
 import java.io.IOException;
@@ -51,7 +51,7 @@
     }
 
     static void log(String s) {
-        Log.v(TAG, s);
+        Rlog.v(TAG, s);
     }
 
     /**