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

Commit 39384f1f authored by html6405's avatar html6405 Committed by Rohit Sekhar
Browse files

telephony: add support for fake ICCID

Change-Id: I49eba6235f9879971361ea0952878c0288596d60
parent 0ee3f70b
Loading
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ public class RIL extends BaseCommands implements CommandsInterface {
    AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);

    final Integer mPhoneId;
    private List<String> mOldRilFeatures;
    private boolean mUseOldMncMccFormat;

    /* default work source which will blame phone process */
@@ -458,8 +457,6 @@ public class RIL extends BaseCommands implements CommandsInterface {
        mPhoneType = RILConstants.NO_PHONE;
        mPhoneId = instanceId;

        final String oldRilFeatures = SystemProperties.get("ro.telephony.ril.config", "");
        mOldRilFeatures = Arrays.asList(oldRilFeatures.split(","));

        mUseOldMncMccFormat = SystemProperties.getBoolean(
                "ro.telephony.use_old_mnc_mcc_format", false);
@@ -5591,7 +5588,9 @@ public class RIL extends BaseCommands implements CommandsInterface {
                signalStrength.wcdma.rscp);
    }

    public boolean needsOldRilFeature(String feature) {
        return mOldRilFeatures.contains(feature);
    public static boolean needsOldRilFeature(String feature) {
        List<String> oldRilFeatures = Arrays.asList(SystemProperties.get("ro.telephony.ril.config", "").split(","));

        return oldRilFeatures.contains(feature);
    }
}
+38 −12
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.RIL;

import static com.android.internal.telephony.uicc.IccConstants.FAKE_ICCID;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -81,6 +84,10 @@ public class SubscriptionInfoUpdater extends Handler {
    private static final int EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS = 12;

    private static final String ICCID_STRING_FOR_NO_SIM = "";

    // Fake ICCID
    private static final String FAKE_ICCID = "00000000000001";

    /**
     *  int[] sInsertSimState maintains all slots' SIM inserted status currently,
     *  it may contain 4 kinds of values:
@@ -484,30 +491,45 @@ public class SubscriptionInfoUpdater extends Handler {
        if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) {
            logd("SIM" + (slotId + 1) + " hot plug out or error.");
        }
        if (!RIL.needsOldRilFeature("fakeiccid"))
            mIccId[slotId] = ICCID_STRING_FOR_NO_SIM;
        else
            mIccId[slotId] = FAKE_ICCID;

        if (isAllIccIdQueryDone()) {
            updateSubscriptionInfoByIccId();
        }

        if (!RIL.needsOldRilFeature("fakeiccid")) {
            updateCarrierServices(slotId, IccCardConstants.INTENT_VALUE_ICC_ABSENT);
            broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_ABSENT, null);
            broadcastSimCardStateChanged(slotId, TelephonyManager.SIM_STATE_ABSENT);
            broadcastSimApplicationStateChanged(slotId, TelephonyManager.SIM_STATE_NOT_READY);
        }
    }

    protected void handleSimError(int slotId) {
        if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) {
            logd("SIM" + (slotId + 1) + " Error ");
        }

        if (!RIL.needsOldRilFeature("fakeiccid"))
            mIccId[slotId] = ICCID_STRING_FOR_NO_SIM;
        else
            mIccId[slotId] = FAKE_ICCID;


        if (isAllIccIdQueryDone()) {
            updateSubscriptionInfoByIccId();
        }
        if (!RIL.needsOldRilFeature("fakeiccid")) {
            updateCarrierServices(slotId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR);
            broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR,
                    IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR);
            broadcastSimCardStateChanged(slotId, TelephonyManager.SIM_STATE_CARD_IO_ERROR);
            broadcastSimApplicationStateChanged(slotId, TelephonyManager.SIM_STATE_NOT_READY);
        }
    }

    /**
     * TODO: Simplify more, as no one is interested in what happened
@@ -583,7 +605,11 @@ public class SubscriptionInfoUpdater extends Handler {
                    // no SIM inserted last time, but there is one SIM inserted now
                    mInsertSimState[i] = SIM_CHANGED;
                }
                if (!RIL.needsOldRilFeature("fakeiccid"))
                    oldIccId[i] = ICCID_STRING_FOR_NO_SIM;
                else
                    oldIccId[i] = FAKE_ICCID;

                logd("updateSubscriptionInfoByIccId: No SIM in slot " + i + " last time");
            }
        }
+3 −0
Original line number Diff line number Diff line
@@ -106,4 +106,7 @@ public interface IccConstants {

    //UICC access
    static final String DF_ADF = "7FFF";

    // Fake ICCID
    static final String FAKE_ICCID = "00000000000001";
}
+13 −5
Original line number Diff line number Diff line
@@ -33,11 +33,14 @@ import android.util.Log;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.cdma.sms.UserData;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.util.BitwiseInputStream;

import static com.android.internal.telephony.uicc.IccConstants.FAKE_ICCID;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -676,12 +679,17 @@ public class RuimRecords extends IccRecords {
                ar = (AsyncResult)msg.obj;
                data = (byte[])ar.result;

                if (!RIL.needsOldRilFeature("fakeiccid")) {
                    if (ar.exception != null) {
                        break;
                    }

                    mIccId = IccUtils.bcdToString(data, 0, data.length);
                    mFullIccId = IccUtils.bchToString(data, 0, data.length);
                } else {
                    mIccId = FAKE_ICCID;
                    mFullIccId = FAKE_ICCID;
                }

                log("iccid: " + SubscriptionInfo.givePrintableIccid(mFullIccId));

+13 −5
Original line number Diff line number Diff line
@@ -31,11 +31,14 @@ import android.text.TextUtils;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.SmsConstants;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.gsm.SimTlv;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;

import static com.android.internal.telephony.uicc.IccConstants.FAKE_ICCID;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -892,12 +895,17 @@ public class SIMRecords extends IccRecords {
                    ar = (AsyncResult) msg.obj;
                    data = (byte[]) ar.result;

                    if (!RIL.needsOldRilFeature("fakeiccid")) {
                        if (ar.exception != null) {
                            break;
                        }

                        mIccId = IccUtils.bcdToString(data, 0, data.length);
                        mFullIccId = IccUtils.bchToString(data, 0, data.length);
                    } else {
                        mIccId = FAKE_ICCID;
                        mFullIccId = FAKE_ICCID;
                    }

                    log("iccid: " + SubscriptionInfo.givePrintableIccid(mFullIccId));
                    break;