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

Commit 1db4d12a authored by arunvoddu's avatar arunvoddu
Browse files

Fetches smsc value from the EF_PSISMSC elementary file of the sim

Bug: 229066443
Test: aTest verification completed
Change-Id: I5e3cd32022803982b15cb06d79549bbdf809415d
parent f60548ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public interface IccConstants {
    static final int EF_SST = 0x6F38;
    static final int EF_CFIS = 0x6FCB;
    static final int EF_IMG = 0x4F20;
    static final int EF_PSISMSC = 0x6FE5;

    // USIM SIM file ids from TS 131.102
    public static final int EF_PBR = 0x4F30;
@@ -84,7 +85,6 @@ public interface IccConstants {
    static final int EF_DOMAIN = 0x6F03;
    static final int EF_IST = 0x6F07;
    static final int EF_PCSCF = 0x6F09;
    static final int EF_PSI = 0x6FE5;

    //PLMN Selection Information w/ Access Technology TS 131.102
    static final int EF_PLMN_W_ACT = 0x6F60;
+1 −1
Original line number Diff line number Diff line
@@ -693,7 +693,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        case EF_EXT1:
        case EF_EXT2:
        case EF_EXT3:
        case EF_PSI:
        case EF_PSISMSC:
            return MF_SIM + DF_TELECOM;

        case EF_ICCID:
+36 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.gsm.SimTlv;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.telephony.Rlog;

@@ -43,6 +44,7 @@ import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
@@ -173,6 +175,10 @@ public abstract class IccRecords extends Handler implements IccConstants {
    protected String[] mEhplmns;
    protected String[] mFplmns;

    // SIP or TEL URI [ Public Service Identity of the SM-SC]
    // Reference: TS 31.102 section 4.5.9
    protected String mPsiSmsc;

    CarrierTestOverride mCarrierTestOverride;

    //Arbitrary offset for the Handler
@@ -232,6 +238,8 @@ public abstract class IccRecords extends Handler implements IccConstants {
    // arrive and returning null to the callers.
    private static final long ICC_SIM_CHALLENGE_TIMEOUT_MILLIS = 2500;

    // TAG value to retrieve EF_PSISMSC from parsed SimTlv object
    private static final int TAG_TLV_USIM_VALUE_80 = 0x80;
    /**
     * There are two purposes for this class. First, each instance of AuthAsyncResponse acts as a
     * lock to for calling thead to wait in getIccSimChallengeResponse(). Second, pass the IMS
@@ -1306,6 +1314,34 @@ public abstract class IccRecords extends Handler implements IccConstants {
        return mSmsCountOnIcc;
    }

    /**
     * parse EF PSISMSC value [3GPP TS 31.102 Section 4.5.9]
     *
     * @param data read from EF PSISMSC field of type byte[]
     * @return SIP URI or tel URI of type string
     */
    protected String parseEfPsiSmsc(byte[] data) {
        SimTlv tlv = new SimTlv(data, 0, data.length);
        if (tlv.isValidObject() && tlv.getData() != null) {
            if (tlv.getTag() == TAG_TLV_USIM_VALUE_80) {
                return new String(tlv.getData(), Charset.forName("UTF-8"));
            }
        }
        if (VDBG) {
            log("Can't find EF PSISMSC field in SIM = " + IccUtils.bytesToHexString(data));
        }
        return null;
    }

    /**
     * SMSC address read from the elementary file EF_PSISMSC
     *
     * @return SIP URI or tel URI of type string
     */
    public String getSmscIdentity() {
        return mPsiSmsc;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("IccRecords: " + this);
        pw.println(" mDestroyed=" + mDestroyed);
+32 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Build;
import android.os.Message;
import android.telephony.SubscriptionManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.gsm.SimTlv;
import com.android.telephony.Rlog;
@@ -69,7 +70,8 @@ public class IsimUiccRecords extends IccRecords implements IsimRecords {
                + " mIsimDomain=" + mIsimDomain
                + " mIsimImpu=" + mIsimImpu
                + " mIsimIst=" + mIsimIst
                + " mIsimPcscf=" + mIsimPcscf) : "");
                + " mIsimPcscf=" + mIsimPcscf
                + " mPsiSmsc=" + mPsiSmsc) : "");
    }

    public IsimUiccRecords(UiccCardApplication app, Context c, CommandsInterface ci) {
@@ -144,6 +146,10 @@ public class IsimUiccRecords extends IccRecords implements IsimRecords {
                    IccRecords.EVENT_GET_ICC_RECORD_DONE, new EfIsimPcscfLoaded()));
        mRecordsToLoad++;

        mFh.loadEFLinearFixed(EF_PSISMSC, 1, obtainMessage(
                IccRecords.EVENT_GET_ICC_RECORD_DONE, new EfIsimPsiSmscLoaded()));
        mRecordsToLoad++;

        if (DBG) log("fetchIsimRecords " + mRecordsToLoad + " requested: " + mRecordsRequested);
    }

@@ -229,6 +235,29 @@ public class IsimUiccRecords extends IccRecords implements IsimRecords {
        }
    }

    private class EfIsimPsiSmscLoaded implements IccRecords.IccRecordLoaded {

        @Override
        public String getEfName() {
            return "EF_ISIM_PSISMSC";
        }

        @Override
        public void onRecordLoaded(AsyncResult ar) {
            byte[] data = (byte[]) ar.result;
            if (data != null && data.length > 0) {
                mPsiSmsc = parseEfPsiSmsc(data);
                if (VDBG) {
                    log("IsimUiccRecords - EF_PSISMSC value = " + mPsiSmsc);
                }
            }
        }
    }

    @VisibleForTesting
    public EfIsimPsiSmscLoaded getPsiSmscObject() {
        return new EfIsimPsiSmscLoaded();
    }
    /**
     * ISIM records for IMS are stored inside a Tag-Length-Value record as a UTF-8 string
     * with tag value 0x80.
@@ -438,6 +467,7 @@ public class IsimUiccRecords extends IccRecords implements IsimRecords {
            pw.println(" mIsimImpu[]=" + Arrays.toString(mIsimImpu));
            pw.println(" mIsimIst" + mIsimIst);
            pw.println(" mIsimPcscf" + mIsimPcscf);
            pw.println(" mPsismsc=" + mPsiSmsc);
        }
        pw.flush();
    }
@@ -446,5 +476,4 @@ public class IsimUiccRecords extends IccRecords implements IsimRecords {
    public int getVoiceMessageCount() {
        return 0; // Not applicable to Isim
    }

}
 No newline at end of file
+23 −1
Original line number Diff line number Diff line
@@ -108,7 +108,8 @@ public class SIMRecords extends IccRecords {
                + " efCPHS_MWI=" + mEfCPHS_MWI
                + " mEfCff=" + mEfCff
                + " mEfCfis=" + mEfCfis
                + " getOperatorNumeric=" + getOperatorNumeric();
                + " getOperatorNumeric=" + getOperatorNumeric()
                + " mPsiSmsc=" + mPsiSmsc;
    }

    // ***** Constants
@@ -184,6 +185,7 @@ public class SIMRecords extends IccRecords {
    private static final int EVENT_GET_FPLMN_DONE = 41 + SIM_RECORD_EVENT_BASE;
    private static final int EVENT_GET_FPLMN_SIZE_DONE = 42 + SIM_RECORD_EVENT_BASE;
    private static final int EVENT_SET_FPLMN_DONE = 43 + SIM_RECORD_EVENT_BASE;
    protected static final int EVENT_GET_PSISMSC_DONE = 47 + SIM_RECORD_EVENT_BASE;
    // ***** Constructor

    public SIMRecords(UiccCardApplication app, Context c, CommandsInterface ci) {
@@ -1291,6 +1293,22 @@ public class SIMRecords extends IccRecords {
                    }
                    break;

                case EVENT_GET_PSISMSC_DONE:
                    isRecordLoadResponse = true;
                    ar = (AsyncResult) msg.obj;
                    if (ar.exception != null) {
                        loge("Failed to read USIM EF_SMSS field error=" + ar.exception);
                    } else {
                        data = (byte[]) ar.result;
                        if (data != null && data.length > 0) {
                            mPsiSmsc = parseEfPsiSmsc(data);
                            if (VDBG) {
                                log("SIMRecords - EF_PSISMSC value = " + mPsiSmsc);
                            }
                        }
                    }
                    break;

                default:
                    super.handleMessage(msg);   // IccRecords handles generic record load responses
            }
@@ -1680,6 +1698,9 @@ public class SIMRecords extends IccRecords {
        mFh.getEFLinearRecordSize(EF_SMS, obtainMessage(EVENT_GET_SMS_RECORD_SIZE_DONE));
        mRecordsToLoad++;

        mFh.loadEFLinearFixed(EF_PSISMSC, 1, obtainMessage(EVENT_GET_PSISMSC_DONE));
        mRecordsToLoad++;

        // XXX should seek instead of examining them all
        if (false) { // XXX
            mFh.loadEFLinearFixedAll(EF_SMS, obtainMessage(EVENT_GET_ALL_SMS_DONE));
@@ -2144,6 +2165,7 @@ public class SIMRecords extends IccRecords {
        pw.println(" mHplmnActRecords[]=" + Arrays.toString(mHplmnActRecords));
        pw.println(" mFplmns[]=" + Arrays.toString(mFplmns));
        pw.println(" mEhplmns[]=" + Arrays.toString(mEhplmns));
        pw.println(" mPsismsc=" + mPsiSmsc);
        pw.flush();
    }
}
Loading