Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f1244e0 authored by Alex Yakavenka's avatar Alex Yakavenka
Browse files

Ccat: Initial CCAT implementation

Launch Stk service for Cdma phone.

Change-Id: I1d0e00a3a31af59239b1355babb37f05cb7e5e07
parent eb678fb6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.gsm.stk.StkService;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccException;
import com.android.internal.telephony.IccFileHandler;
@@ -109,7 +110,7 @@ public class CDMAPhone extends PhoneBase {
    PhoneSubInfo mSubInfo;
    EriManager mEriManager;
    WakeLock mWakeLock;

    StkService mStkService;

    // mNvLoadedRegistrants are informed after the EVENT_NV_READY
    private RegistrantList mNvLoadedRegistrants = new RegistrantList();
@@ -161,6 +162,8 @@ public class CDMAPhone extends PhoneBase {
        mRuimSmsInterfaceManager = new RuimSmsInterfaceManager(this);
        mSubInfo = new PhoneSubInfo(this);
        mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
        mStkService = StkService.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 @@ public class CDMAPhone extends PhoneBase {
            mRuimSmsInterfaceManager.dispose();
            mSubInfo.dispose();
            mEriManager.dispose();
            mStkService.dispose();
        }
    }

@@ -251,6 +255,7 @@ public class CDMAPhone extends PhoneBase {
            this.mCT = null;
            this.mSST = null;
            this.mEriManager = null;
            this.mStkService = null;
    }

    protected void finalize() {
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ 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 @@ class CommandParamsFactory extends Handler {
    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 @@ class CommandParamsFactory extends Handler {
        return null;
    }

    private CommandParamsFactory(RilMessageDecoder caller, SIMFileHandler fh) {
    private CommandParamsFactory(RilMessageDecoder caller, IccFileHandler fh) {
        mCaller = caller;
        mIconLoader = IconLoader.getInstance(this, fh);
    }
+4 −4
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.internal.telephony.gsm.stk;

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 @@ class IconLoader extends Handler {
    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,14 +68,14 @@ class IconLoader extends Handler {
    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;
        }
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.internal.telephony.gsm.stk;

import com.android.internal.telephony.gsm.SIMFileHandler;
import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccUtils;

import android.os.Handler;
@@ -51,7 +51,7 @@ class RilMessageDecoder extends HierarchicalStateMachine {
     * @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();
@@ -90,7 +90,7 @@ class RilMessageDecoder extends HierarchicalStateMachine {
        msg.sendToTarget();
    }

    private RilMessageDecoder(Handler caller, SIMFileHandler fh) {
    private RilMessageDecoder(Handler caller, IccFileHandler fh) {
        super("RilMessageDecoder");

        addState(mStateStart);
+25 −25
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ import android.os.Message;

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;

@@ -114,7 +114,7 @@ class RilMessage {
public class StkService extends Handler implements AppInterface {

    // Class members
    private static SIMRecords mSimRecords;
    private static IccRecords mIccRecords;

    // Service members.
    private static StkService sInstance;
@@ -136,7 +136,7 @@ public class StkService extends Handler implements AppInterface {
    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 @@ public class StkService extends Handler implements AppInterface {
    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 StkService(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");
        }
@@ -166,17 +166,17 @@ public class StkService extends Handler implements AppInterface {
        mCmdIf.setOnStkCallSetUp(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");
    }

    public void dispose() {
        mSimRecords.unregisterForRecordsLoaded(this);
        mIccRecords.unregisterForRecordsLoaded(this);
        mCmdIf.unSetOnStkSessionEnd(this);
        mCmdIf.unSetOnStkProactiveCmd(this);
        mCmdIf.unSetOnStkEvent(this);
@@ -446,32 +446,32 @@ public class StkService extends Handler implements AppInterface {
    }

    /**
     * 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 StkService 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");
            thread.start();
            sInstance = new StkService(ci, sr, context, fh, sc);
            sInstance = new StkService(ci, ir, context, fh, ic);
            StkLog.d(sInstance, "NEW sInstance");
        } else if ((sr != null) && (mSimRecords != sr)) {
        } else if ((ir != null) && (mIccRecords != ir)) {
            StkLog.d(sInstance, "Reinitialize the Service with SIMRecords");
            mSimRecords = sr;
            mIccRecords = ir;

            // re-Register for SIM ready event.
            mSimRecords.registerForRecordsLoaded(sInstance, MSG_ID_SIM_LOADED, null);
            mIccRecords.registerForRecordsLoaded(sInstance, MSG_ID_ICC_RECORDS_LOADED, null);
            StkLog.d(sInstance, "sr changed reinitialize and return current sInstance");
        } else {
            StkLog.d(sInstance, "Return current sInstance");
@@ -513,7 +513,7 @@ public class StkService extends Handler implements AppInterface {
        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);