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

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

Reorganize code to handle class 2 SMS.

If card is having more than one USIM applications then because of
registering mechanism in SIMRecords.java to command interface, command
interface will hold only the last registered application registrant.
So when ever telephony received SMS_ON_SIM it will come to only
last 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.
CRs-fixed: 432656

Change-Id: I02616e7a2e0f0250cc27780e53a061ef49f72fd6
parent a025dc93
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ public final class ImsSMSDispatcher extends SMSDispatcher {
    public void dispose() {
        mCi.unregisterForOn(this);
        mCi.unregisterForImsNetworkStateChanged(this);
        mPhone.mIccRecords.get().unregisterForNewSms(this);
        mCdmaDispatcher.dispose();
        mGsmDispatcher.dispose();
    }

    /**
+4 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2006 The Android Open Source Project
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -161,6 +161,9 @@ public abstract class SMSDispatcher extends Handler {
    protected static final int EVENT_NEW_ICC_SMS = 13;
    protected static final int EVENT_ICC_CHANGED = 14;

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

    protected PhoneBase mPhone;
    protected final Context mContext;
    protected final ContentResolver mResolver;
+14 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2006 The Android Open Source Project
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -44,8 +44,10 @@ import com.android.internal.telephony.SmsMessageBase;
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;
@@ -82,6 +84,7 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
        mCi.setOnNewGsmSms(this, EVENT_NEW_SMS, null);
        mCi.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null);
        mCi.setOnNewGsmBroadcastSms(this, EVENT_NEW_BROADCAST_SMS, null);
        mCi.setOnSmsOnSim(this, EVENT_SMS_ON_ICC, null);
        mImsSMSDispatcher = imsSMSDispatcher;
        mUiccController = UiccController.getInstance();
        mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
@@ -93,6 +96,10 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
        mCi.unSetOnNewGsmSms(this);
        mCi.unSetOnSmsStatus(this);
        mCi.unSetOnNewGsmBroadcastSms(this);
        mCi.unSetOnSmsOnSim(this);
        if (mIccRecords.get() != null) {
            mIccRecords.get().unregisterForNewSms(this);
        }
    }

    @Override
@@ -138,6 +145,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
@@ -149,7 +149,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;
@@ -198,7 +197,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);
        mCi.registerForIccRefresh(this, EVENT_SIM_REFRESH, null);

        // Start off by setting empty state
@@ -212,7 +210,6 @@ public class SIMRecords extends IccRecords {
        if (DBG) log("Disposing SIMRecords this=" + this);
        //Unregister for all events
        mCi.unregisterForIccRefresh(this);
        mCi.unSetOnSmsOnSim(this);
        mParentApp.unregisterForReady(this);
        resetRecords();
        super.dispose();
@@ -1009,24 +1006,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;
@@ -1308,6 +1287,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]);