Merge "Fix a bug that prevented the creation of EGL shared contexts."
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a388311..804af9c 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -9047,7 +9047,28 @@
                 sr.crashCount++;
             }
         }
-        
+
+        // If the crashing process is what we consider to be the "home process" and it has been
+        // replaced by a third-party app, clear the package preferred activities from packages
+        // with a home activity running in the process to prevent a repeatedly crashing app
+        // from blocking the user to manually clear the list.
+        if (app == mHomeProcess && mHomeProcess.activities.size() > 0
+                    && (mHomeProcess.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+            Iterator it = mHomeProcess.activities.iterator();
+            while (it.hasNext()) {
+                HistoryRecord r = (HistoryRecord)it.next();
+                if (r.isHomeActivity) {
+                    Log.i(TAG, "Clearing package preferred activities from " + r.packageName);
+                    try {
+                        ActivityThread.getPackageManager()
+                                .clearPackagePreferredActivities(r.packageName);
+                    } catch (RemoteException c) {
+                        // pm is in same process, this will never happen.
+                    }
+                }
+            }
+        }
+
         mProcessCrashTimes.put(app.info.processName, app.info.uid, now);
         return true;
     }
diff --git a/telephony/java/com/android/internal/telephony/BaseCommands.java b/telephony/java/com/android/internal/telephony/BaseCommands.java
index b962375..815fbfb 100644
--- a/telephony/java/com/android/internal/telephony/BaseCommands.java
+++ b/telephony/java/com/android/internal/telephony/BaseCommands.java
@@ -73,10 +73,10 @@
     protected Registrant mSmsOnSimRegistrant;
     protected Registrant mSmsStatusRegistrant;
     protected Registrant mSsnRegistrant;
-    protected Registrant mStkSessionEndRegistrant;
-    protected Registrant mStkProCmdRegistrant;
-    protected Registrant mStkEventRegistrant;
-    protected Registrant mStkCallSetUpRegistrant;
+    protected Registrant mCatSessionEndRegistrant;
+    protected Registrant mCatProCmdRegistrant;
+    protected Registrant mCatEventRegistrant;
+    protected Registrant mCatCallSetUpRegistrant;
     protected Registrant mIccSmsFullRegistrant;
     protected Registrant mEmergencyCallbackModeRegistrant;
     protected Registrant mIccRefreshRegistrant;
@@ -395,36 +395,36 @@
         mSsnRegistrant.clear();
     }
 
-    public void setOnStkSessionEnd(Handler h, int what, Object obj) {
-        mStkSessionEndRegistrant = new Registrant (h, what, obj);
+    public void setOnCatSessionEnd(Handler h, int what, Object obj) {
+        mCatSessionEndRegistrant = new Registrant (h, what, obj);
     }
 
-    public void unSetOnStkSessionEnd(Handler h) {
-        mStkSessionEndRegistrant.clear();
+    public void unSetOnCatSessionEnd(Handler h) {
+        mCatSessionEndRegistrant.clear();
     }
 
-    public void setOnStkProactiveCmd(Handler h, int what, Object obj) {
-        mStkProCmdRegistrant = new Registrant (h, what, obj);
+    public void setOnCatProactiveCmd(Handler h, int what, Object obj) {
+        mCatProCmdRegistrant = new Registrant (h, what, obj);
     }
 
-    public void unSetOnStkProactiveCmd(Handler h) {
-        mStkProCmdRegistrant.clear();
+    public void unSetOnCatProactiveCmd(Handler h) {
+        mCatProCmdRegistrant.clear();
     }
 
-    public void setOnStkEvent(Handler h, int what, Object obj) {
-        mStkEventRegistrant = new Registrant (h, what, obj);
+    public void setOnCatEvent(Handler h, int what, Object obj) {
+        mCatEventRegistrant = new Registrant (h, what, obj);
     }
 
-    public void unSetOnStkEvent(Handler h) {
-        mStkEventRegistrant.clear();
+    public void unSetOnCatEvent(Handler h) {
+        mCatEventRegistrant.clear();
     }
 
-    public void setOnStkCallSetUp(Handler h, int what, Object obj) {
-        mStkCallSetUpRegistrant = new Registrant (h, what, obj);
+    public void setOnCatCallSetUp(Handler h, int what, Object obj) {
+        mCatCallSetUpRegistrant = new Registrant (h, what, obj);
     }
 
-    public void unSetOnStkCallSetUp(Handler h) {
-        mStkCallSetUpRegistrant.clear();
+    public void unSetOnCatCallSetUp(Handler h) {
+        mCatCallSetUpRegistrant.clear();
     }
 
     public void setOnIccSmsFull(Handler h, int what, Object obj) {
diff --git a/telephony/java/com/android/internal/telephony/CommandsInterface.java b/telephony/java/com/android/internal/telephony/CommandsInterface.java
index 8e03c5a..5de0426 100644
--- a/telephony/java/com/android/internal/telephony/CommandsInterface.java
+++ b/telephony/java/com/android/internal/telephony/CommandsInterface.java
@@ -374,48 +374,48 @@
     void unSetOnSuppServiceNotification(Handler h);
 
     /**
-     * Sets the handler for Session End Notifications for STK.
+     * Sets the handler for Session End Notifications for CAT.
      * Unlike the register* methods, there's only one notification handler
      *
      * @param h Handler for notification message.
      * @param what User-defined message code.
      * @param obj User object.
      */
-    void setOnStkSessionEnd(Handler h, int what, Object obj);
-    void unSetOnStkSessionEnd(Handler h);
+    void setOnCatSessionEnd(Handler h, int what, Object obj);
+    void unSetOnCatSessionEnd(Handler h);
 
     /**
-     * Sets the handler for Proactive Commands for STK.
+     * Sets the handler for Proactive Commands for CAT.
      * Unlike the register* methods, there's only one notification handler
      *
      * @param h Handler for notification message.
      * @param what User-defined message code.
      * @param obj User object.
      */
-    void setOnStkProactiveCmd(Handler h, int what, Object obj);
-    void unSetOnStkProactiveCmd(Handler h);
+    void setOnCatProactiveCmd(Handler h, int what, Object obj);
+    void unSetOnCatProactiveCmd(Handler h);
 
     /**
-     * Sets the handler for Event Notifications for STK.
+     * Sets the handler for Event Notifications for CAT.
      * Unlike the register* methods, there's only one notification handler
      *
      * @param h Handler for notification message.
      * @param what User-defined message code.
      * @param obj User object.
      */
-    void setOnStkEvent(Handler h, int what, Object obj);
-    void unSetOnStkEvent(Handler h);
+    void setOnCatEvent(Handler h, int what, Object obj);
+    void unSetOnCatEvent(Handler h);
 
     /**
-     * Sets the handler for Call Set Up Notifications for STK.
+     * Sets the handler for Call Set Up Notifications for CAT.
      * Unlike the register* methods, there's only one notification handler
      *
      * @param h Handler for notification message.
      * @param what User-defined message code.
      * @param obj User object.
      */
-    void setOnStkCallSetUp(Handler h, int what, Object obj);
-    void unSetOnStkCallSetUp(Handler h);
+    void setOnCatCallSetUp(Handler h, int what, Object obj);
+    void unSetOnCatCallSetUp(Handler h);
 
     /**
      * Enables/disbables supplementary service related notifications from
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index d79a89e..569ac5c 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -2481,8 +2481,8 @@
             case RIL_UNSOL_STK_SESSION_END:
                 if (RILJ_LOGD) unsljLog(response);
 
-                if (mStkSessionEndRegistrant != null) {
-                    mStkSessionEndRegistrant.notifyRegistrant(
+                if (mCatSessionEndRegistrant != null) {
+                    mCatSessionEndRegistrant.notifyRegistrant(
                                         new AsyncResult (null, ret, null));
                 }
                 break;
@@ -2490,8 +2490,8 @@
             case RIL_UNSOL_STK_PROACTIVE_COMMAND:
                 if (RILJ_LOGD) unsljLogRet(response, ret);
 
-                if (mStkProCmdRegistrant != null) {
-                    mStkProCmdRegistrant.notifyRegistrant(
+                if (mCatProCmdRegistrant != null) {
+                    mCatProCmdRegistrant.notifyRegistrant(
                                         new AsyncResult (null, ret, null));
                 }
                 break;
@@ -2499,8 +2499,8 @@
             case RIL_UNSOL_STK_EVENT_NOTIFY:
                 if (RILJ_LOGD) unsljLogRet(response, ret);
 
-                if (mStkEventRegistrant != null) {
-                    mStkEventRegistrant.notifyRegistrant(
+                if (mCatEventRegistrant != null) {
+                    mCatEventRegistrant.notifyRegistrant(
                                         new AsyncResult (null, ret, null));
                 }
                 break;
@@ -2508,8 +2508,8 @@
             case RIL_UNSOL_STK_CALL_SETUP:
                 if (RILJ_LOGD) unsljLogRet(response, ret);
 
-                if (mStkCallSetUpRegistrant != null) {
-                    mStkCallSetUpRegistrant.notifyRegistrant(
+                if (mCatCallSetUpRegistrant != null) {
+                    mCatCallSetUpRegistrant.notifyRegistrant(
                                         new AsyncResult (null, ret, null));
                 }
                 break;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/AppInterface.java b/telephony/java/com/android/internal/telephony/cat/AppInterface.java
similarity index 88%
rename from telephony/java/com/android/internal/telephony/gsm/stk/AppInterface.java
rename to telephony/java/com/android/internal/telephony/cat/AppInterface.java
index 58f1f97..0ba3e11 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/AppInterface.java
+++ b/telephony/java/com/android/internal/telephony/cat/AppInterface.java
@@ -14,29 +14,29 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 /**
- * Interface for communication between STK App and STK Telephony
+ * Interface for communication between STK App and CAT Telephony
  *
  * {@hide}
  */
 public interface AppInterface {
 
     /*
-     * Intent's actions which are broadcasted by the Telephony once a new STK
+     * Intent's actions which are broadcasted by the Telephony once a new CAT
      * proactive command, session end arrive.
      */
-    public static final String STK_CMD_ACTION =
+    public static final String CAT_CMD_ACTION =
                                     "android.intent.action.stk.command";
-    public static final String STK_SESSION_END_ACTION =
+    public static final String CAT_SESSION_END_ACTION =
                                     "android.intent.action.stk.session_end";
 
     /*
      * Callback function from app to telephony to pass a result code and user's
-     * input back to the SIM.
+     * input back to the ICC.
      */
-    void onCmdResponse(StkResponseMessage resMsg);
+    void onCmdResponse(CatResponseMessage resMsg);
 
     /*
      * Enumeration for representing "Type of Command" of proactive commands.
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/BerTlv.java b/telephony/java/com/android/internal/telephony/cat/BerTlv.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/BerTlv.java
rename to telephony/java/com/android/internal/telephony/cat/BerTlv.java
index 19d3279..774bfa3 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/BerTlv.java
+++ b/telephony/java/com/android/internal/telephony/cat/BerTlv.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import java.util.List;
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/StkCmdMessage.java b/telephony/java/com/android/internal/telephony/cat/CatCmdMessage.java
similarity index 89%
rename from telephony/java/com/android/internal/telephony/gsm/stk/StkCmdMessage.java
rename to telephony/java/com/android/internal/telephony/cat/CatCmdMessage.java
index 5425a43..5155bb2 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/StkCmdMessage.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatCmdMessage.java
@@ -14,17 +14,17 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.os.Parcel;
 import android.os.Parcelable;
 
 /**
- * Class used to pass STK messages from telephony to application. Application
+ * Class used to pass CAT messages from telephony to application. Application
  * should call getXXX() to get commands's specific values.
  *
  */
-public class StkCmdMessage implements Parcelable {
+public class CatCmdMessage implements Parcelable {
     // members
     CommandDetails mCmdDet;
     private TextMessage mTextMsg;
@@ -50,7 +50,7 @@
         public TextMessage callMsg;
     }
 
-    StkCmdMessage(CommandParams cmdParams) {
+    CatCmdMessage(CommandParams cmdParams) {
         mCmdDet = cmdParams.cmdDet;
         switch(getCmdType()) {
         case SET_UP_MENU:
@@ -88,7 +88,7 @@
         }
     }
 
-    public StkCmdMessage(Parcel in) {
+    public CatCmdMessage(Parcel in) {
         mCmdDet = in.readParcelable(null);
         mTextMsg = in.readParcelable(null);
         mMenu = in.readParcelable(null);
@@ -130,13 +130,13 @@
         }
     }
 
-    public static final Parcelable.Creator<StkCmdMessage> CREATOR = new Parcelable.Creator<StkCmdMessage>() {
-        public StkCmdMessage createFromParcel(Parcel in) {
-            return new StkCmdMessage(in);
+    public static final Parcelable.Creator<CatCmdMessage> CREATOR = new Parcelable.Creator<CatCmdMessage>() {
+        public CatCmdMessage createFromParcel(Parcel in) {
+            return new CatCmdMessage(in);
         }
 
-        public StkCmdMessage[] newArray(int size) {
-            return new StkCmdMessage[size];
+        public CatCmdMessage[] newArray(int size) {
+            return new CatCmdMessage[size];
         }
     };
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/StkException.java b/telephony/java/com/android/internal/telephony/cat/CatException.java
similarity index 80%
rename from telephony/java/com/android/internal/telephony/gsm/stk/StkException.java
rename to telephony/java/com/android/internal/telephony/cat/CatException.java
index 86de366..1bf1369 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/StkException.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatException.java
@@ -14,18 +14,18 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.util.AndroidException;
 
 
 /**
- * Base class for all the exceptions in STK service.
+ * Base class for all the exceptions in CAT service.
  *
  * {@hide}
  */
-class StkException extends AndroidException {
-    public StkException() {
+class CatException extends AndroidException {
+    public CatException() {
         super();
     }
 }
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/StkLog.java b/telephony/java/com/android/internal/telephony/cat/CatLog.java
similarity index 84%
rename from telephony/java/com/android/internal/telephony/gsm/stk/StkLog.java
rename to telephony/java/com/android/internal/telephony/cat/CatLog.java
index bd6bc8f..e19ff43 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/StkLog.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatLog.java
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.util.Log;
 
-public abstract class StkLog {
+public abstract class CatLog {
     static final boolean DEBUG = true;
 
     public static void d(Object caller, String msg) {
@@ -27,7 +27,7 @@
         }
 
         String className = caller.getClass().getName();
-        Log.d("STK", className.substring(className.lastIndexOf('.') + 1) + ": "
+        Log.d("CAT", className.substring(className.lastIndexOf('.') + 1) + ": "
                 + msg);
     }
 
@@ -36,6 +36,6 @@
             return;
         }
 
-        Log.d("STK", caller + ": " + msg);
+        Log.d("CAT", caller + ": " + msg);
     }
 }
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/StkResponseMessage.java b/telephony/java/com/android/internal/telephony/cat/CatResponseMessage.java
similarity index 91%
rename from telephony/java/com/android/internal/telephony/gsm/stk/StkResponseMessage.java
rename to telephony/java/com/android/internal/telephony/cat/CatResponseMessage.java
index 04a52e6..cfcac36 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/StkResponseMessage.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatResponseMessage.java
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
-public class StkResponseMessage {
+public class CatResponseMessage {
         CommandDetails cmdDet = null;
         ResultCode resCode  = ResultCode.OK;
         int usersMenuSelection = 0;
@@ -24,7 +24,7 @@
         boolean usersYesNoSelection = false;
         boolean usersConfirm = false;
 
-        public StkResponseMessage(StkCmdMessage cmdMsg) {
+        public CatResponseMessage(CatCmdMessage cmdMsg) {
             this.cmdDet = cmdMsg.mCmdDet;
         }
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/StkService.java b/telephony/java/com/android/internal/telephony/cat/CatService.java
similarity index 84%
rename from telephony/java/com/android/internal/telephony/gsm/stk/StkService.java
rename to telephony/java/com/android/internal/telephony/cat/CatService.java
index 29ed95c..b916713 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/StkService.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatService.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.content.Context;
 import android.content.Intent;
@@ -25,9 +25,9 @@
 
 import com.android.internal.telephony.IccUtils;
 import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.gsm.SimCard;
-import com.android.internal.telephony.gsm.SIMFileHandler;
-import com.android.internal.telephony.gsm.SIMRecords;
+import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccFileHandler;
+import com.android.internal.telephony.IccRecords;
 
 import android.util.Config;
 
@@ -111,17 +111,17 @@
  *
  * {@hide}
  */
-public class StkService extends Handler implements AppInterface {
+public class CatService extends Handler implements AppInterface {
 
     // Class members
-    private static SIMRecords mSimRecords;
+    private static IccRecords mIccRecords;
 
     // Service members.
-    private static StkService sInstance;
+    private static CatService sInstance;
     private CommandsInterface mCmdIf;
     private Context mContext;
-    private StkCmdMessage mCurrntCmd = null;
-    private StkCmdMessage mMenuCmd = null;
+    private CatCmdMessage mCurrntCmd = null;
+    private CatCmdMessage mMenuCmd = null;
 
     private RilMessageDecoder mMsgDecoder = null;
 
@@ -136,7 +136,7 @@
     static final int MSG_ID_RIL_MSG_DECODED          = 10;
 
     // Events to signal SIM presence or absent in the device.
-    private static final int MSG_ID_SIM_LOADED       = 20;
+    private static final int MSG_ID_ICC_RECORDS_LOADED       = 20;
 
     private static final int DEV_ID_KEYPAD      = 0x01;
     private static final int DEV_ID_DISPLAY     = 0x02;
@@ -146,10 +146,10 @@
     private static final int DEV_ID_NETWORK     = 0x83;
 
     /* Intentionally private for singleton */
-    private StkService(CommandsInterface ci, SIMRecords sr, Context context,
-            SIMFileHandler fh, SimCard sc) {
-        if (ci == null || sr == null || context == null || fh == null
-                || sc == null) {
+    private CatService(CommandsInterface ci, IccRecords ir, Context context,
+            IccFileHandler fh, IccCard ic) {
+        if (ci == null || ir == null || context == null || fh == null
+                || ic == null) {
             throw new NullPointerException(
                     "Service: Input parameters must not be null");
         }
@@ -160,33 +160,33 @@
         mMsgDecoder = RilMessageDecoder.getInstance(this, fh);
 
         // Register ril events handling.
-        mCmdIf.setOnStkSessionEnd(this, MSG_ID_SESSION_END, null);
-        mCmdIf.setOnStkProactiveCmd(this, MSG_ID_PROACTIVE_COMMAND, null);
-        mCmdIf.setOnStkEvent(this, MSG_ID_EVENT_NOTIFY, null);
-        mCmdIf.setOnStkCallSetUp(this, MSG_ID_CALL_SETUP, null);
+        mCmdIf.setOnCatSessionEnd(this, MSG_ID_SESSION_END, null);
+        mCmdIf.setOnCatProactiveCmd(this, MSG_ID_PROACTIVE_COMMAND, null);
+        mCmdIf.setOnCatEvent(this, MSG_ID_EVENT_NOTIFY, null);
+        mCmdIf.setOnCatCallSetUp(this, MSG_ID_CALL_SETUP, null);
         //mCmdIf.setOnSimRefresh(this, MSG_ID_REFRESH, null);
 
-        mSimRecords = sr;
+        mIccRecords = ir;
 
         // Register for SIM ready event.
-        mSimRecords.registerForRecordsLoaded(this, MSG_ID_SIM_LOADED, null);
+        mIccRecords.registerForRecordsLoaded(this, MSG_ID_ICC_RECORDS_LOADED, null);
 
         mCmdIf.reportStkServiceIsRunning(null);
-        StkLog.d(this, "StkService: is running");
+        CatLog.d(this, "Is running");
     }
 
     public void dispose() {
-        mSimRecords.unregisterForRecordsLoaded(this);
-        mCmdIf.unSetOnStkSessionEnd(this);
-        mCmdIf.unSetOnStkProactiveCmd(this);
-        mCmdIf.unSetOnStkEvent(this);
-        mCmdIf.unSetOnStkCallSetUp(this);
+        mIccRecords.unregisterForRecordsLoaded(this);
+        mCmdIf.unSetOnCatSessionEnd(this);
+        mCmdIf.unSetOnCatProactiveCmd(this);
+        mCmdIf.unSetOnCatEvent(this);
+        mCmdIf.unSetOnCatCallSetUp(this);
 
         this.removeCallbacksAndMessages(null);
     }
 
     protected void finalize() {
-        StkLog.d(this, "Service finalized");
+        CatLog.d(this, "Service finalized");
     }
 
     private void handleRilMsg(RilMessage rilMsg) {
@@ -241,9 +241,9 @@
      *
      */
     private void handleProactiveCommand(CommandParams cmdParams) {
-        StkLog.d(this, cmdParams.getCommandType().name());
+        CatLog.d(this, cmdParams.getCommandType().name());
 
-        StkCmdMessage cmdMsg = new StkCmdMessage(cmdParams);
+        CatCmdMessage cmdMsg = new CatCmdMessage(cmdParams);
         switch (cmdParams.getCommandType()) {
         case SET_UP_MENU:
             if (removeMenu(cmdMsg.getMenu())) {
@@ -285,11 +285,11 @@
             // nothing to do on telephony!
             break;
         default:
-            StkLog.d(this, "Unsupported command");
+            CatLog.d(this, "Unsupported command");
             return;
         }
         mCurrntCmd = cmdMsg;
-        Intent intent = new Intent(AppInterface.STK_CMD_ACTION);
+        Intent intent = new Intent(AppInterface.CAT_CMD_ACTION);
         intent.putExtra("STK CMD", cmdMsg);
         mContext.sendBroadcast(intent);
     }
@@ -299,10 +299,10 @@
      *
      */
     private void handleSessionEnd() {
-        StkLog.d(this, "SESSION END");
+        CatLog.d(this, "SESSION END");
 
         mCurrntCmd = mMenuCmd;
-        Intent intent = new Intent(AppInterface.STK_SESSION_END_ACTION);
+        Intent intent = new Intent(AppInterface.CAT_SESSION_END_ACTION);
         mContext.sendBroadcast(intent);
     }
 
@@ -353,7 +353,7 @@
         byte[] rawData = buf.toByteArray();
         String hexString = IccUtils.bytesToHexString(rawData);
         if (Config.LOGD) {
-            StkLog.d(this, "TERMINAL RESPONSE: " + hexString);
+            CatLog.d(this, "TERMINAL RESPONSE: " + hexString);
         }
 
         mCmdIf.sendTerminalResponse(hexString, null);
@@ -446,35 +446,35 @@
     }
 
     /**
-     * Used for instantiating/updating the Service from the GsmPhone constructor.
+     * Used for instantiating/updating the Service from the GsmPhone or CdmaPhone constructor.
      *
      * @param ci CommandsInterface object
-     * @param sr SIMRecords object
+     * @param ir IccRecords object
      * @param context phone app context
-     * @param fh SIM file handler
-     * @param sc GSM SIM card
+     * @param fh Icc file handler
+     * @param ic Icc card
      * @return The only Service object in the system
      */
-    public static StkService getInstance(CommandsInterface ci, SIMRecords sr,
-            Context context, SIMFileHandler fh, SimCard sc) {
+    public static CatService getInstance(CommandsInterface ci, IccRecords ir,
+            Context context, IccFileHandler fh, IccCard ic) {
         if (sInstance == null) {
-            if (ci == null || sr == null || context == null || fh == null
-                    || sc == null) {
+            if (ci == null || ir == null || context == null || fh == null
+                    || ic == null) {
                 return null;
             }
-            HandlerThread thread = new HandlerThread("Stk Telephony service");
+            HandlerThread thread = new HandlerThread("Cat Telephony service");
             thread.start();
-            sInstance = new StkService(ci, sr, context, fh, sc);
-            StkLog.d(sInstance, "NEW sInstance");
-        } else if ((sr != null) && (mSimRecords != sr)) {
-            StkLog.d(sInstance, "Reinitialize the Service with SIMRecords");
-            mSimRecords = sr;
+            sInstance = new CatService(ci, ir, context, fh, ic);
+            CatLog.d(sInstance, "NEW sInstance");
+        } else if ((ir != null) && (mIccRecords != ir)) {
+            CatLog.d(sInstance, "Reinitialize the Service with SIMRecords");
+            mIccRecords = ir;
 
             // re-Register for SIM ready event.
-            mSimRecords.registerForRecordsLoaded(sInstance, MSG_ID_SIM_LOADED, null);
-            StkLog.d(sInstance, "sr changed reinitialize and return current sInstance");
+            mIccRecords.registerForRecordsLoaded(sInstance, MSG_ID_ICC_RECORDS_LOADED, null);
+            CatLog.d(sInstance, "sr changed reinitialize and return current sInstance");
         } else {
-            StkLog.d(sInstance, "Return current sInstance");
+            CatLog.d(sInstance, "Return current sInstance");
         }
         return sInstance;
     }
@@ -496,7 +496,7 @@
         case MSG_ID_PROACTIVE_COMMAND:
         case MSG_ID_EVENT_NOTIFY:
         case MSG_ID_REFRESH:
-            StkLog.d(this, "ril message arrived");
+            CatLog.d(this, "ril message arrived");
             String data = null;
             if (msg.obj != null) {
                 AsyncResult ar = (AsyncResult) msg.obj;
@@ -513,20 +513,20 @@
         case MSG_ID_CALL_SETUP:
             mMsgDecoder.sendStartDecodingMessageParams(new RilMessage(msg.what, null));
             break;
-        case MSG_ID_SIM_LOADED:
+        case MSG_ID_ICC_RECORDS_LOADED:
             break;
         case MSG_ID_RIL_MSG_DECODED:
             handleRilMsg((RilMessage) msg.obj);
             break;
         case MSG_ID_RESPONSE:
-            handleCmdResponse((StkResponseMessage) msg.obj);
+            handleCmdResponse((CatResponseMessage) msg.obj);
             break;
         default:
-            throw new AssertionError("Unrecognized STK command: " + msg.what);
+            throw new AssertionError("Unrecognized CAT command: " + msg.what);
         }
     }
 
-    public synchronized void onCmdResponse(StkResponseMessage resMsg) {
+    public synchronized void onCmdResponse(CatResponseMessage resMsg) {
         if (resMsg == null) {
             return;
         }
@@ -535,7 +535,7 @@
         msg.sendToTarget();
     }
 
-    private boolean validateResponse(StkResponseMessage resMsg) {
+    private boolean validateResponse(CatResponseMessage resMsg) {
         if (mCurrntCmd != null) {
             return (resMsg.cmdDet.compareTo(mCurrntCmd.mCmdDet));
         }
@@ -548,13 +548,13 @@
                 return true;
             }
         } catch (NullPointerException e) {
-            StkLog.d(this, "Unable to get Menu's items size");
+            CatLog.d(this, "Unable to get Menu's items size");
             return true;
         }
         return false;
     }
 
-    private void handleCmdResponse(StkResponseMessage resMsg) {
+    private void handleCmdResponse(CatResponseMessage resMsg) {
         // Make sure the response details match the last valid command. An invalid
         // response is a one that doesn't have a corresponding proactive command
         // and sending it can "confuse" the baseband/ril.
@@ -563,7 +563,7 @@
         // by the framework inside the history stack. That activity will be
         // available for relaunch using the latest application dialog
         // (long press on the home button). Relaunching that activity can send
-        // the same command's result again to the StkService and can cause it to
+        // the same command's result again to the CatService and can cause it to
         // get out of sync with the SIM.
         if (!validateResponse(resMsg)) {
             return;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/CommandDetails.java b/telephony/java/com/android/internal/telephony/cat/CommandDetails.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/CommandDetails.java
rename to telephony/java/com/android/internal/telephony/cat/CommandDetails.java
index e81ff98..e3f0798 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/CommandDetails.java
+++ b/telephony/java/com/android/internal/telephony/cat/CommandDetails.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.os.Parcel;
 import android.os.Parcelable;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParams.java b/telephony/java/com/android/internal/telephony/cat/CommandParams.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/CommandParams.java
rename to telephony/java/com/android/internal/telephony/cat/CommandParams.java
index 3da652f..22a5c8c 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParams.java
+++ b/telephony/java/com/android/internal/telephony/cat/CommandParams.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java b/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java
rename to telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java
index ce4c459..edb2dc8 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java
+++ b/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java
@@ -14,14 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 import android.os.Handler;
 import android.os.Message;
 
 import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.gsm.SIMFileHandler;
+import com.android.internal.telephony.IccFileHandler;
 
 import java.util.Iterator;
 import java.util.List;
@@ -53,7 +53,7 @@
     static final int REFRESH_UICC_RESET                     = 0x04;
 
     static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller,
-            SIMFileHandler fh) {
+            IccFileHandler fh) {
         if (sInstance != null) {
             return sInstance;
         }
@@ -63,7 +63,7 @@
         return null;
     }
 
-    private CommandParamsFactory(RilMessageDecoder caller, SIMFileHandler fh) {
+    private CommandParamsFactory(RilMessageDecoder caller, IccFileHandler fh) {
         mCaller = caller;
         mIconLoader = IconLoader.getInstance(this, fh);
     }
@@ -79,7 +79,7 @@
                 try {
                     cmdDet = ValueParser.retrieveCommandDetails(ctlvCmdDet);
                 } catch (ResultException e) {
-                    StkLog.d(this, "Failed to procees command details");
+                    CatLog.d(this, "Failed to procees command details");
                 }
             }
         }
@@ -259,7 +259,7 @@
             List<ComprehensionTlv> ctlvs)
             throws ResultException {
 
-        StkLog.d(this, "process DisplayText");
+        CatLog.d(this, "process DisplayText");
 
         TextMessage textMsg = new TextMessage();
         IconId iconId = null;
@@ -319,7 +319,7 @@
     private boolean processSetUpIdleModeText(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process SetUpIdleModeText");
+        CatLog.d(this, "process SetUpIdleModeText");
 
         TextMessage textMsg = new TextMessage();
         IconId iconId = null;
@@ -362,7 +362,7 @@
     private boolean processGetInkey(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process GetInkey");
+        CatLog.d(this, "process GetInkey");
 
         Input input = new Input();
         IconId iconId = null;
@@ -412,7 +412,7 @@
     private boolean processGetInput(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process GetInput");
+        CatLog.d(this, "process GetInput");
 
         Input input = new Input();
         IconId iconId = null;
@@ -476,7 +476,7 @@
     private boolean processRefresh(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) {
 
-        StkLog.d(this, "process Refresh");
+        CatLog.d(this, "process Refresh");
 
         // REFRESH proactive command is rerouted by the baseband and handled by
         // the telephony layer. IDLE TEXT should be removed for a REFRESH command
@@ -505,7 +505,7 @@
     private boolean processSelectItem(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process SelectItem");
+        CatLog.d(this, "process SelectItem");
 
         Menu menu = new Menu();
         IconId titleIconId = null;
@@ -534,7 +534,7 @@
 
         ctlv = searchForTag(ComprehensionTlvTag.ITEM_ID, ctlvs);
         if (ctlv != null) {
-            // STK items are listed 1...n while list start at 0, need to
+            // CAT items are listed 1...n while list start at 0, need to
             // subtract one.
             menu.defaultItem = ValueParser.retrieveItemId(ctlv) - 1;
         }
@@ -602,7 +602,7 @@
     private boolean processEventNotify(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process EventNotify");
+        CatLog.d(this, "process EventNotify");
 
         TextMessage textMsg = new TextMessage();
         IconId iconId = null;
@@ -645,7 +645,7 @@
     private boolean processSetUpEventList(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) {
 
-        StkLog.d(this, "process SetUpEventList");
+        CatLog.d(this, "process SetUpEventList");
         //
         // ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.EVENT_LIST,
         // ctlvs);
@@ -670,10 +670,10 @@
      *         asynchronous processing is required.
      * @throws ResultException
      */
-     private boolean processLaunchBrowser(CommandDetails cmdDet,
+    private boolean processLaunchBrowser(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process LaunchBrowser");
+        CatLog.d(this, "process LaunchBrowser");
 
         TextMessage confirmMsg = new TextMessage();
         IconId iconId = null;
@@ -744,10 +744,10 @@
      *         asynchronous processing is required.t
      * @throws ResultException
      */
-     private boolean processPlayTone(CommandDetails cmdDet,
+    private boolean processPlayTone(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
 
-        StkLog.d(this, "process PlayTone");
+        CatLog.d(this, "process PlayTone");
 
         Tone tone = null;
         TextMessage textMsg = new TextMessage();
@@ -810,9 +810,9 @@
      * @return true if the command is processing is pending and additional
      *         asynchronous processing is required.
      */
-     private boolean processSetupCall(CommandDetails cmdDet,
+    private boolean processSetupCall(CommandDetails cmdDet,
             List<ComprehensionTlv> ctlvs) throws ResultException {
-        StkLog.d(this, "process SetupCall");
+        CatLog.d(this, "process SetupCall");
 
         Iterator<ComprehensionTlv> iter = ctlvs.iterator();
         ComprehensionTlv ctlv = null;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ComprehensionTlv.java b/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ComprehensionTlv.java
rename to telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java
index ffde6a3..99f662d 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ComprehensionTlv.java
+++ b/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Duration.java b/telephony/java/com/android/internal/telephony/cat/Duration.java
similarity index 94%
rename from telephony/java/com/android/internal/telephony/gsm/stk/Duration.java
rename to telephony/java/com/android/internal/telephony/cat/Duration.java
index 9d8cc97..e8cd404 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/Duration.java
+++ b/telephony/java/com/android/internal/telephony/cat/Duration.java
@@ -14,14 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.os.Parcel;
 import android.os.Parcelable;
 
 
 /**
- * Class for representing "Duration" object for STK.
+ * Class for representing "Duration" object for CAT.
  *
  * {@hide}
  */
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/FontSize.java b/telephony/java/com/android/internal/telephony/cat/FontSize.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/FontSize.java
rename to telephony/java/com/android/internal/telephony/cat/FontSize.java
index bd4f49f..02c7ea0 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/FontSize.java
+++ b/telephony/java/com/android/internal/telephony/cat/FontSize.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/IconLoader.java b/telephony/java/com/android/internal/telephony/cat/IconLoader.java
similarity index 95%
rename from telephony/java/com/android/internal/telephony/gsm/stk/IconLoader.java
rename to telephony/java/com/android/internal/telephony/cat/IconLoader.java
index fc02d2a..2fa1811 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/IconLoader.java
+++ b/telephony/java/com/android/internal/telephony/cat/IconLoader.java
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
-import com.android.internal.telephony.gsm.SIMFileHandler;
+import com.android.internal.telephony.IccFileHandler;
 
 import android.graphics.Bitmap;
 import android.graphics.Color;
@@ -40,7 +40,7 @@
     private ImageDescriptor mId = null;
     private Bitmap mCurrentIcon = null;
     private int mRecordNumber;
-    private SIMFileHandler mSimFH = null;
+    private IccFileHandler mSimFH = null;
     private Message mEndMsg = null;
     private byte[] mIconData = null;
     // multi icons state members
@@ -68,19 +68,19 @@
     private static final int CLUT_ENTRY_SIZE = 3;
 
 
-    private IconLoader(Looper looper , SIMFileHandler fh) {
+    private IconLoader(Looper looper , IccFileHandler fh) {
         super(looper);
         mSimFH = fh;
 
         mIconsCache = new HashMap<Integer, Bitmap>(50);
     }
 
-    static IconLoader getInstance(Handler caller, SIMFileHandler fh) {
+    static IconLoader getInstance(Handler caller, IccFileHandler fh) {
         if (sLoader != null) {
             return sLoader;
         }
         if (fh != null) {
-            HandlerThread thread = new HandlerThread("Stk Icon Loader");
+            HandlerThread thread = new HandlerThread("Cat Icon Loader");
             thread.start();
             return new IconLoader(thread.getLooper(), fh);
         }
@@ -163,7 +163,7 @@
                 break;
             }
         } catch (Exception e) {
-            StkLog.d(this, "Icon load failed");
+            CatLog.d(this, "Icon load failed");
             // post null icon back to the caller.
             postIcon();
         }
@@ -254,7 +254,7 @@
         }
 
         if (pixelIndex != numOfPixels) {
-            StkLog.d("IconLoader", "parseToBnW; size error");
+            CatLog.d("IconLoader", "parseToBnW; size error");
         }
         return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
     }
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ImageDescriptor.java b/telephony/java/com/android/internal/telephony/cat/ImageDescriptor.java
similarity index 95%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ImageDescriptor.java
rename to telephony/java/com/android/internal/telephony/cat/ImageDescriptor.java
index 880b9e5..711d977 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ImageDescriptor.java
+++ b/telephony/java/com/android/internal/telephony/cat/ImageDescriptor.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 /**
  * {@hide}
@@ -69,7 +69,7 @@
 
             d.length = ((rawData[valueIndex++] & 0xff) << 8 | (rawData[valueIndex++] & 0xff));
         } catch (IndexOutOfBoundsException e) {
-            StkLog.d("ImageDescripter", "parse; failed parsing image descriptor");
+            CatLog.d("ImageDescripter", "parse; failed parsing image descriptor");
             d = null;
         }
         return d;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Input.java b/telephony/java/com/android/internal/telephony/cat/Input.java
similarity index 95%
rename from telephony/java/com/android/internal/telephony/gsm/stk/Input.java
rename to telephony/java/com/android/internal/telephony/cat/Input.java
index 19f724b..8bcaab9 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/Input.java
+++ b/telephony/java/com/android/internal/telephony/cat/Input.java
@@ -14,14 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 import android.os.Parcel;
 import android.os.Parcelable;
 
 /**
- * Container class for STK GET INPUT, GET IN KEY commands parameters.
+ * Container class for CAT GET INPUT, GET IN KEY commands parameters.
  *
  */
 public class Input implements Parcelable {
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Item.java b/telephony/java/com/android/internal/telephony/cat/Item.java
similarity index 97%
rename from telephony/java/com/android/internal/telephony/gsm/stk/Item.java
rename to telephony/java/com/android/internal/telephony/cat/Item.java
index b2f338c..d4702bb 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/Item.java
+++ b/telephony/java/com/android/internal/telephony/cat/Item.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 import android.os.Parcel;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/LaunchBrowserMode.java b/telephony/java/com/android/internal/telephony/cat/LaunchBrowserMode.java
similarity index 95%
rename from telephony/java/com/android/internal/telephony/gsm/stk/LaunchBrowserMode.java
rename to telephony/java/com/android/internal/telephony/cat/LaunchBrowserMode.java
index 302273c..af043d1 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/LaunchBrowserMode.java
+++ b/telephony/java/com/android/internal/telephony/cat/LaunchBrowserMode.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Menu.java b/telephony/java/com/android/internal/telephony/cat/Menu.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/Menu.java
rename to telephony/java/com/android/internal/telephony/cat/Menu.java
index 331f69d..7bbae01 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/Menu.java
+++ b/telephony/java/com/android/internal/telephony/cat/Menu.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 import android.os.Parcel;
@@ -24,7 +24,7 @@
 import java.util.List;
 
 /**
- * Container class for STK menu (SET UP MENU, SELECT ITEM) parameters.
+ * Container class for CAT menu (SET UP MENU, SELECT ITEM) parameters.
  *
  */
 public class Menu implements Parcelable {
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/PresentationType.java b/telephony/java/com/android/internal/telephony/cat/PresentationType.java
similarity index 94%
rename from telephony/java/com/android/internal/telephony/gsm/stk/PresentationType.java
rename to telephony/java/com/android/internal/telephony/cat/PresentationType.java
index 71bdcdc..7c8cd8c 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/PresentationType.java
+++ b/telephony/java/com/android/internal/telephony/cat/PresentationType.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ResponseData.java b/telephony/java/com/android/internal/telephony/cat/ResponseData.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ResponseData.java
rename to telephony/java/com/android/internal/telephony/cat/ResponseData.java
index afd1bba..84c08f8 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ResponseData.java
+++ b/telephony/java/com/android/internal/telephony/cat/ResponseData.java
@@ -14,7 +14,7 @@
  * the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import com.android.internal.telephony.EncodeException;
 import com.android.internal.telephony.GsmAlphabet;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ResultCode.java b/telephony/java/com/android/internal/telephony/cat/ResultCode.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ResultCode.java
rename to telephony/java/com/android/internal/telephony/cat/ResultCode.java
index b96a524..8544175 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ResultCode.java
+++ b/telephony/java/com/android/internal/telephony/cat/ResultCode.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ResultException.java b/telephony/java/com/android/internal/telephony/cat/ResultException.java
similarity index 95%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ResultException.java
rename to telephony/java/com/android/internal/telephony/cat/ResultException.java
index 2eb16c9..1c2cb63 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ResultException.java
+++ b/telephony/java/com/android/internal/telephony/cat/ResultException.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
@@ -22,7 +22,7 @@
  *
  * {@hide}
  */
-public class ResultException extends StkException {
+public class ResultException extends CatException {
     private ResultCode mResult;
     private int mAdditionalInfo;
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java b/telephony/java/com/android/internal/telephony/cat/RilMessageDecoder.java
similarity index 87%
rename from telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java
rename to telephony/java/com/android/internal/telephony/cat/RilMessageDecoder.java
index a82177c..a197c9a 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java
+++ b/telephony/java/com/android/internal/telephony/cat/RilMessageDecoder.java
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
-import com.android.internal.telephony.gsm.SIMFileHandler;
+import com.android.internal.telephony.IccFileHandler;
 import com.android.internal.telephony.IccUtils;
 
 import android.os.Handler;
@@ -26,7 +26,7 @@
 
 /**
  * Class used for queuing raw ril messages, decoding them into CommanParams
- * objects and sending the result back to the STK Service.
+ * objects and sending the result back to the CAT Service.
  */
 class RilMessageDecoder extends HierarchicalStateMachine {
 
@@ -51,7 +51,7 @@
      * @param fh
      * @return RilMesssageDecoder
      */
-    public static synchronized RilMessageDecoder getInstance(Handler caller, SIMFileHandler fh) {
+    public static synchronized RilMessageDecoder getInstance(Handler caller, IccFileHandler fh) {
         if (sInstance == null) {
             sInstance = new RilMessageDecoder(caller, fh);
             sInstance.start();
@@ -85,12 +85,12 @@
     }
 
     private void sendCmdForExecution(RilMessage rilMsg) {
-        Message msg = mCaller.obtainMessage(StkService.MSG_ID_RIL_MSG_DECODED,
+        Message msg = mCaller.obtainMessage(CatService.MSG_ID_RIL_MSG_DECODED,
                 new RilMessage(rilMsg));
         msg.sendToTarget();
     }
 
-    private RilMessageDecoder(Handler caller, SIMFileHandler fh) {
+    private RilMessageDecoder(Handler caller, IccFileHandler fh) {
         super("RilMessageDecoder");
 
         addState(mStateStart);
@@ -108,7 +108,7 @@
                     transitionTo(mStateCmdParamsReady);
                 }
             } else {
-                StkLog.d(this, "StateStart unexpected expecting START=" +
+                CatLog.d(this, "StateStart unexpected expecting START=" +
                          CMD_START + " got " + msg.what);
             }
             return true;
@@ -123,7 +123,7 @@
                 sendCmdForExecution(mCurrentRilMessage);
                 transitionTo(mStateStart);
             } else {
-                StkLog.d(this, "StateCmdParamsReady expecting CMD_PARAMS_READY="
+                CatLog.d(this, "StateCmdParamsReady expecting CMD_PARAMS_READY="
                          + CMD_PARAMS_READY + " got " + msg.what);
                 deferMessage(msg);
             }
@@ -136,21 +136,21 @@
 
         mCurrentRilMessage = rilMsg;
         switch(rilMsg.mId) {
-        case StkService.MSG_ID_SESSION_END:
-        case StkService.MSG_ID_CALL_SETUP:
+        case CatService.MSG_ID_SESSION_END:
+        case CatService.MSG_ID_CALL_SETUP:
             mCurrentRilMessage.mResCode = ResultCode.OK;
             sendCmdForExecution(mCurrentRilMessage);
             decodingStarted = false;
             break;
-        case StkService.MSG_ID_PROACTIVE_COMMAND:
-        case StkService.MSG_ID_EVENT_NOTIFY:
-        case StkService.MSG_ID_REFRESH:
+        case CatService.MSG_ID_PROACTIVE_COMMAND:
+        case CatService.MSG_ID_EVENT_NOTIFY:
+        case CatService.MSG_ID_REFRESH:
             byte[] rawData = null;
             try {
                 rawData = IccUtils.hexStringToBytes((String) rilMsg.mData);
             } catch (Exception e) {
                 // zombie messages are dropped
-                StkLog.d(this, "decodeMessageParams dropping zombie messages");
+                CatLog.d(this, "decodeMessageParams dropping zombie messages");
                 decodingStarted = false;
                 break;
             }
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/TextAlignment.java b/telephony/java/com/android/internal/telephony/cat/TextAlignment.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/TextAlignment.java
rename to telephony/java/com/android/internal/telephony/cat/TextAlignment.java
index c5dd50e..7fb58a5 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/TextAlignment.java
+++ b/telephony/java/com/android/internal/telephony/cat/TextAlignment.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/TextAttribute.java b/telephony/java/com/android/internal/telephony/cat/TextAttribute.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/TextAttribute.java
rename to telephony/java/com/android/internal/telephony/cat/TextAttribute.java
index ace4300..0dea640 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/TextAttribute.java
+++ b/telephony/java/com/android/internal/telephony/cat/TextAttribute.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/TextColor.java b/telephony/java/com/android/internal/telephony/cat/TextColor.java
similarity index 96%
rename from telephony/java/com/android/internal/telephony/gsm/stk/TextColor.java
rename to telephony/java/com/android/internal/telephony/cat/TextColor.java
index 126fc62..6447e74 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/TextColor.java
+++ b/telephony/java/com/android/internal/telephony/cat/TextColor.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/TextMessage.java b/telephony/java/com/android/internal/telephony/cat/TextMessage.java
similarity index 97%
rename from telephony/java/com/android/internal/telephony/gsm/stk/TextMessage.java
rename to telephony/java/com/android/internal/telephony/cat/TextMessage.java
index 3b6a09a..5ffd076 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/TextMessage.java
+++ b/telephony/java/com/android/internal/telephony/cat/TextMessage.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.graphics.Bitmap;
 import android.os.Parcel;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Tone.java b/telephony/java/com/android/internal/telephony/cat/Tone.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/Tone.java
rename to telephony/java/com/android/internal/telephony/cat/Tone.java
index b64e777d..27b4489 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/Tone.java
+++ b/telephony/java/com/android/internal/telephony/cat/Tone.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.os.Parcel;
 import android.os.Parcelable;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ToneSettings.java b/telephony/java/com/android/internal/telephony/cat/ToneSettings.java
similarity index 97%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ToneSettings.java
rename to telephony/java/com/android/internal/telephony/cat/ToneSettings.java
index 90cc6c1..6375afb 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ToneSettings.java
+++ b/telephony/java/com/android/internal/telephony/cat/ToneSettings.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import android.os.Parcel;
 import android.os.Parcelable;
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/ValueParser.java b/telephony/java/com/android/internal/telephony/cat/ValueParser.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/gsm/stk/ValueParser.java
rename to telephony/java/com/android/internal/telephony/cat/ValueParser.java
index 09a860e..34e4811 100644
--- a/telephony/java/com/android/internal/telephony/gsm/stk/ValueParser.java
+++ b/telephony/java/com/android/internal/telephony/cat/ValueParser.java
@@ -14,11 +14,11 @@
  * the License.
  */
 
-package com.android.internal.telephony.gsm.stk;
+package com.android.internal.telephony.cat;
 
 import com.android.internal.telephony.GsmAlphabet;
 import com.android.internal.telephony.IccUtils;
-import com.android.internal.telephony.gsm.stk.Duration.TimeUnit;
+import com.android.internal.telephony.cat.Duration.TimeUnit;
 
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
@@ -182,7 +182,7 @@
      */
     static ItemsIconId retrieveItemsIconId(ComprehensionTlv ctlv)
             throws ResultException {
-        StkLog.d("ValueParser", "retrieveItemsIconId:");
+        CatLog.d("ValueParser", "retrieveItemsIconId:");
         ItemsIconId id = new ItemsIconId();
 
         byte[] rawValue = ctlv.getRawValue();
diff --git a/telephony/java/com/android/internal/telephony/cat/package.html b/telephony/java/com/android/internal/telephony/cat/package.html
new file mode 100644
index 0000000..5b6bfc6
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/cat/package.html
@@ -0,0 +1,5 @@
+<HTML>
+<BODY>
+Provides classes for ICC Toolkit Service (CAT).
+</BODY>
+</HTML>
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 0c591e4..27eae22 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -42,6 +42,7 @@
 import android.text.TextUtils;
 import android.util.Log;
 
+import com.android.internal.telephony.cat.CatService;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.CommandException;
@@ -109,7 +110,7 @@
     PhoneSubInfo mSubInfo;
     EriManager mEriManager;
     WakeLock mWakeLock;
-
+    CatService mCcatService;
 
     // mNvLoadedRegistrants are informed after the EVENT_NV_READY
     private RegistrantList mNvLoadedRegistrants = new RegistrantList();
@@ -161,6 +162,8 @@
         mRuimSmsInterfaceManager = new RuimSmsInterfaceManager(this);
         mSubInfo = new PhoneSubInfo(this);
         mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
+        mCcatService = CatService.getInstance(mCM, mRuimRecords, mContext,
+                mIccFileHandler, mRuimCard);
 
         mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
         mRuimRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
@@ -236,6 +239,7 @@
             mRuimSmsInterfaceManager.dispose();
             mSubInfo.dispose();
             mEriManager.dispose();
+            mCcatService.dispose();
         }
     }
 
@@ -251,6 +255,7 @@
             this.mCT = null;
             this.mSST = null;
             this.mEriManager = null;
+            this.mCcatService = null;
     }
 
     protected void finalize() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index c7b1e5c..5f093d4 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -49,6 +49,7 @@
 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.cat.CatService;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallForwardInfo;
 import com.android.internal.telephony.CallStateException;
@@ -68,7 +69,6 @@
 import com.android.internal.telephony.PhoneSubInfo;
 import com.android.internal.telephony.TelephonyProperties;
 import com.android.internal.telephony.UUSInfo;
-import com.android.internal.telephony.gsm.stk.StkService;
 import com.android.internal.telephony.test.SimulatedRadioControl;
 import com.android.internal.telephony.IccVmNotSupportedException;
 
@@ -102,7 +102,7 @@
     GsmSMSDispatcher mSMS;
     SIMRecords mSIMRecords;
     SimCard mSimCard;
-    StkService mStkService;
+    CatService mStkService;
     ArrayList <GsmMmiCode> mPendingMMIs = new ArrayList<GsmMmiCode>();
     SimPhoneBookInterfaceManager mSimPhoneBookIntManager;
     SimSmsInterfaceManager mSimSmsIntManager;
@@ -154,7 +154,7 @@
             mSimSmsIntManager = new SimSmsInterfaceManager(this);
             mSubInfo = new PhoneSubInfo(this);
         }
-        mStkService = StkService.getInstance(mCM, mSIMRecords, mContext,
+        mStkService = CatService.getInstance(mCM, mSIMRecords, mContext,
                 (SIMFileHandler)mIccFileHandler, mSimCard);
 
         mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/package.html b/telephony/java/com/android/internal/telephony/gsm/stk/package.html
deleted file mode 100644
index c285b57..0000000
--- a/telephony/java/com/android/internal/telephony/gsm/stk/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<HTML>
-<BODY>
-Provides classes for SIM Toolkit Service.
-</BODY>
-</HTML>