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

Commit 9e20514b authored by Ian Roy's avatar Ian Roy Committed by Matt Mower
Browse files

Store correct IMSI when retreived from SIMRecords and use it for RuimRecords

Stock stores the IMSI gathered with SIMRecords and uses that value when
RuimRecords wants to get the APN/operator number.

Set System prop "ro.telephony.get_imsi_from_sim=true" to enable this function

Change-Id: I5e766951313afe4dedb0b6bccfdc83acf701f440
parent 9e7b80a7
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.cdma.sms.UserData;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.UICCConfig;


/**
@@ -253,6 +254,18 @@ public final class RuimRecords extends IccRecords {
            return null;
        }

        if (SystemProperties.getBoolean("ro.telephony.get_imsi_from_sim", false)) {
            String imsi = mParentApp.getUICCConfig().getImsi();
            int mnclength = mParentApp.getUICCConfig().getMncLength();

            // If we are LTE over CDMA (Verizon), then pull the correct info from SIMRecords
            if (imsi != null) {
                log("Overriding with Operator Numeric: " + imsi.substring(0, 3 + mnclength));
                return imsi.substring(0, 3 + mnclength);
            }
        }


        if (mMncLength != UNINITIALIZED && mMncLength != UNKNOWN) {
            // Length = length of MCC + length of MNC
            // length of mcc = 3 (3GPP2 C.S0005 - Section 2.3)
+14 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.SmsConstants;
import com.android.internal.telephony.gsm.SimTlv;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.UICCConfig;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -240,6 +241,8 @@ public class SIMRecords extends IccRecords {
        setSystemProperty(PROPERTY_APN_SIM_OPERATOR_NUMERIC, null);
        setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, null);
        setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, null);
        mParentApp.getUICCConfig().setImsi(mImsi);
        mParentApp.getUICCConfig().setMncLength(mMncLength);

        // recordsRequested is set to false indicating that the SIM
        // read requests made so far are not valid. This is set to
@@ -660,6 +663,14 @@ public class SIMRecords extends IccRecords {
                    }
                }

                mParentApp.getUICCConfig().setImsi(mImsi);
                if (mMncLength == UNKNOWN || mMncLength == UNINITIALIZED) {
                    // We need to default to something that seems common
                    mParentApp.getUICCConfig().setMncLength(3);
                } else {
                    mParentApp.getUICCConfig().setMncLength(mMncLength);
                }

                if (mMncLength != UNKNOWN && mMncLength != UNINITIALIZED) {
                    // finally have both the imsi and the mncLength and can parse the imsi properly
                    MccTable.updateMccMncConfiguration(mContext,
@@ -872,7 +883,10 @@ public class SIMRecords extends IccRecords {

                    if (mMncLength == 0xf) {
                        mMncLength = UNKNOWN;
                    } else {
                        mParentApp.getUICCConfig().setMncLength(mMncLength);
                    }

                } finally {
                    if (((mMncLength == UNINITIALIZED) || (mMncLength == UNKNOWN) ||
                            (mMncLength == 2)) && ((mImsi != null) && (mImsi.length() >= 6))) {
+87 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony.uicc;

import android.content.Context;
import android.content.SharedPreferences;
import android.telephony.Rlog;

/**
 * A class that stores various UICC Settings/values.
 * @hide
 */
public final class UICCConfig
{
    private final String PREFERENCE_NAME = "UICCConfig";
    private final String TAG = "UICCConfig";
    private final boolean LOG_DEBUG = false;

    private String mImsi;
    private int mMncLength;

    /**
     * A method to get the stored Imsi.
     * @hide
     */
    public String getImsi() {
        if (mImsi == null) {
            logd("Getting IMSI: null");
        } else {
            logd("Getting IMSI: " + mImsi);
        }
        return mImsi;
    }

    /**
     * A method to set the stored Imsi.
     * @hide
     */
    public void setImsi(String lImsi) {
        logd("Setting IMSI: " + lImsi);
        mImsi = lImsi;
    }

    /**
     * A method to get the stored MncLength.
     * @hide
     */
    public int getMncLength() {
        logd("Getting MncLength: " + Integer.toString(mMncLength));
        return mMncLength;
    }

    /**
     * A method to set the stored MncLength.
     * @hide
     */
    public void setMncLength(int lMncLength) {
        logd("Setting MncLength: " + Integer.toString(lMncLength));
        mMncLength = lMncLength;
    }

    private void logd(String sLog) {
        if (LOG_DEBUG) {
            Rlog.d(TAG, sLog);
        }
    }

    private void loge(String sLog)
    {
        Rlog.e(TAG, sLog);
    }

}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class UiccCard {
    protected CatService mCatService;
    private boolean mDestroyed = false; //set to true once this card is commanded to be disposed of.
    private RadioState mLastRadioState =  RadioState.RADIO_UNAVAILABLE;
    private UICCConfig mUICCConfig = null;

    private RegistrantList mAbsentRegistrants = new RegistrantList();

@@ -100,6 +101,7 @@ public class UiccCard {
            }
            mCatService = null;
            mUiccApplications = null;
            mUICCConfig = null;
        }
    }

@@ -118,6 +120,8 @@ public class UiccCard {
            mContext = c;
            mCi = ci;
            //update applications
            if (mUICCConfig == null)
                mUICCConfig = new UICCConfig();
            if (DBG) log(ics.mApplications.length + " applications");
            for ( int i = 0; i < mUiccApplications.length; i++) {
                if (mUiccApplications[i] == null) {
@@ -374,6 +378,10 @@ public class UiccCard {
        return count;
    }

    public UICCConfig getUICCConfig() {
        return mUICCConfig;
    }

    void onRefresh(IccRefreshResponse refreshResponse){
        for ( int i = 0; i < mUiccApplications.length; i++) {
            if (mUiccApplications[i] != null) {
+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState;
import com.android.internal.telephony.uicc.IccCardStatus.PinState;
import com.android.internal.telephony.uicc.UICCConfig;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -904,6 +905,10 @@ public class UiccCardApplication {
        }
    }

    public UICCConfig getUICCConfig() {
        return mUiccCard.getUICCConfig();
    }

    private void log(String msg) {
        Rlog.d(LOG_TAG, msg);
    }