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

Commit b2e58017 authored by Suresh Koleti's avatar Suresh Koleti Committed by Linux Build Service Account
Browse files

Reorganize code to handle class 2 SMS.

If SIM card is having more than one USIM application the
registering mechanism in SIMRecords.java to the
CommandsInterface is not as expected. The CommandsInterface
will hold only the last registered application registrant
due to for every application the it is overwritten. So
whenever telephony received SMS_ON_SIM it will come to only
last USIM application created not the desired application
which is used by actual phone object.
Move registering mechanism for SMS_ON_SIM to SMSDispatcher
where we can get the proper application.

Change-Id: I02616e7a2e0f0250cc27780e53a061ef49f72fd6
CRs-fixed: 432656
(cherry picked from commit 3e1a7315e4eb10d8abd41a16d91edcecadae9d1e)
(cherry picked from commit a39dc52dbff1e71809398ed8079dc80c21a77f04)
parent 3378b132
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -123,6 +123,9 @@ public abstract class SMSDispatcher extends Handler {
    protected static final int EVENT_NEW_ICC_SMS = 14;
    protected static final int EVENT_ICC_CHANGED = 15;

    /** Class2 SMS  */
    static final protected int EVENT_SMS_ON_ICC = 16;

    protected PhoneBase mPhone;
    protected final Context mContext;
    protected final ContentResolver mResolver;
+13 −0
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.SmsStorageMonitor;
import com.android.internal.telephony.SmsUsageMonitor;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.uicc.IccConstants;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
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.uicc.UsimServiceTable;
@@ -67,6 +69,7 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
            GsmInboundSmsHandler gsmInboundSmsHandler) {
        super(phone, usageMonitor);
        mCi.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null);
        mCi.setOnSmsOnSim(this, EVENT_SMS_ON_ICC, null);
        mImsSMSDispatcher = imsSMSDispatcher;
        mGsmInboundSmsHandler = gsmInboundSmsHandler;
        mUiccController = UiccController.getInstance();
@@ -79,6 +82,10 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
        super.dispose();
        mCi.unSetOnSmsStatus(this);
        mUiccController.unregisterForIccChanged(this);
        mCi.unSetOnSmsOnSim(this);
        if (mIccRecords.get() != null) {
            mIccRecords.get().unregisterForNewSms(this);
        }
    }

    @Override
@@ -108,6 +115,12 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
            onUpdateIccAvailability();
            break;

        case EVENT_SMS_ON_ICC:
            if (mIccRecords.get() != null) {
                ((SIMRecords)(mIccRecords.get())).handleSmsOnIcc((AsyncResult) msg.obj);
            }
            break;

        default:
            super.handleMessage(msg);
        }
+20 −21
Original line number Diff line number Diff line
@@ -154,7 +154,6 @@ public class SIMRecords extends IccRecords {
    private static final int EVENT_GET_ALL_SMS_DONE = 18;
    private static final int EVENT_MARK_SMS_READ_DONE = 19;
    private static final int EVENT_SET_MBDN_DONE = 20;
    private static final int EVENT_SMS_ON_SIM = 21;
    private static final int EVENT_GET_SMS_DONE = 22;
    private static final int EVENT_GET_CFF_DONE = 24;
    private static final int EVENT_SET_CPHS_MAILBOX_DONE = 25;
@@ -201,7 +200,6 @@ public class SIMRecords extends IccRecords {
        // recordsToLoad is set to 0 because no requests are made yet
        mRecordsToLoad = 0;

        mCi.setOnSmsOnSim(this, EVENT_SMS_ON_SIM, null);
        // Start off by setting empty state
        resetRecords();
        mParentApp.registerForReady(this, EVENT_APP_READY, null);
@@ -212,7 +210,6 @@ public class SIMRecords extends IccRecords {
    public void dispose() {
        if (DBG) log("Disposing SIMRecords this=" + this);
        //Unregister for all events
        mCi.unSetOnSmsOnSim(this);
        mParentApp.unregisterForReady(this);
        resetRecords();
        super.dispose();
@@ -1000,24 +997,6 @@ public class SIMRecords extends IccRecords {
                Rlog.i("ENF", "marked read: sms " + msg.arg1);
                break;


            case EVENT_SMS_ON_SIM:
                isRecordLoadResponse = false;

                ar = (AsyncResult)msg.obj;

                int[] index = (int[])ar.result;

                if (ar.exception != null || index.length != 1) {
                    loge("Error on SMS_ON_SIM with exp "
                            + ar.exception + " length " + index.length);
                } else {
                    log("READ EF_SMS RECORD index=" + index[0]);
                    mFh.loadEFLinearFixed(EF_SMS,index[0],
                            obtainMessage(EVENT_GET_SMS_DONE));
                }
                break;

            case EVENT_GET_SMS_DONE:
                isRecordLoadResponse = false;
                ar = (AsyncResult)msg.obj;
@@ -1241,6 +1220,26 @@ public class SIMRecords extends IccRecords {
        return 0;
    }

    /*
     * Called when a Class2 SMS is  received.
     *
     * @param ar AsyncResult passed to this function. "ar.result" should
     *           be representing the INDEX of SMS on SIM.
     */
    public void handleSmsOnIcc(AsyncResult ar) {

        int[] index = (int[])ar.result;

        if (ar.exception != null || index.length != 1) {
            loge(" Error on SMS_ON_SIM with exp "
                   + ar.exception + " length " + index.length);
        } else {
            log("READ EF_SMS RECORD index= " + index[0]);
            mFh.loadEFLinearFixed(EF_SMS,index[0],
                            obtainMessage(EVENT_GET_SMS_DONE));
        }
    }

    private void handleSms(byte[] ba) {
        if (ba[0] != 0)
            Rlog.d("ENF", "status : " + ba[0]);