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

Commit e0f5ff94 authored by Umashankar Godachi's avatar Umashankar Godachi Committed by Gerrit - the friendly Code Review server
Browse files

FR29338: Read SIM Contacts from EF-ADN if EF-PBR read failed.

Currently on a USIM UICC card, contacts are read from EF-PBR.
If EF-PBR file is absent or the read failed, no contacts displayed.
This requirement will add the support for reading SIM contacts from
EF-ADN, if EF-PBR read failed.

Fix: In IccPhoneBookInterfaceManager, while loading the records check
for EF-PBR present. If EF-PBR is absent, treat the card as 2g and
reload the records from EF-ADN.

Add code to check if EF-PBR is present in UsimPhoneBookManager.

Change-Id: I55ef0541789cd5958da26cd18b070a46d75d78b0
parent edb37773
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public abstract class IccPhoneBookInterfaceManager {
    protected final Object mLock = new Object();
    protected int mRecordSize[];
    protected boolean mSuccess;
    private   boolean mForceAdnUsage = false;
    protected List<AdnRecord> mRecords;


@@ -125,6 +126,7 @@ public abstract class IccPhoneBookInterfaceManager {
        if (mRecords != null) {
            mRecords.clear();
        }
        mForceAdnUsage = false;
    }

    public void updateIccRecords(IccRecords iccRecords) {
@@ -314,13 +316,13 @@ public abstract class IccPhoneBookInterfaceManager {
                    "Requires android.permission.READ_CONTACTS permission");
        }

        efid = updateEfForIccType(efid);
        if (DBG) logd("getAdnRecordsInEF: efid=" + efid);

        synchronized(mLock) {
            checkThread();
            AtomicBoolean status = new AtomicBoolean(false);
            Message response = mBaseHandler.obtainMessage(EVENT_LOAD_DONE, status);
            efid = updateEfForIccType(efid);
            if (DBG) logd("getAdnRecordsInEF: efid=" + efid);

            if (mAdnCache != null) {
                mAdnCache.requestLoadAllAdnLike(efid,
                        mAdnCache.extensionEfForEf(efid), null, response);
@@ -328,6 +330,11 @@ public abstract class IccPhoneBookInterfaceManager {
            } else {
                loge("Failure while trying to load from SIM due to uninitialised adncache");
            }
            if (mRecords == null && efid == IccConstants.EF_PBR && !mAdnCache.isPbrPresent()) {
                logd("getAdnRecordsInEF: Load from EF_ADN as pbr is not present");
                mForceAdnUsage = true;
                return getAdnRecordsInEf(IccConstants.EF_ADN);
            }
        }
        return mRecords;
    }
@@ -369,7 +376,7 @@ public abstract class IccPhoneBookInterfaceManager {

    private int updateEfForIccType(int efid) {
        // Check if we are trying to read ADN records
        if (efid == IccConstants.EF_ADN) {
        if (efid == IccConstants.EF_ADN && !mForceAdnUsage) {
            if (mPhone.getCurrentUiccAppType() == AppType.APPTYPE_USIM ||
                    mPhone.getCurrentUiccAppType() == AppType.APPTYPE_CSIM) {
                return IccConstants.EF_PBR;
+6 −0
Original line number Diff line number Diff line
@@ -149,6 +149,10 @@ public class UsimPhoneBookManager extends Handler implements IccConstants {
        mRefreshCache = false;
    }

    public boolean isPbrFilePresent() {
        return mIsPbrPresent;
    }

    public ArrayList<AdnRecord> loadEfFilesFromUsim() {
        synchronized (mLock) {
            if (!mPhoneBookRecords.isEmpty()) {
@@ -947,6 +951,8 @@ public class UsimPhoneBookManager extends Handler implements IccConstants {
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null) {
                    createPbrFile((ArrayList<byte[]>) ar.result);
                } else {
                    mIsPbrPresent = false;
                }
                synchronized (mLock) {
                    mLock.notify();
+4 −0
Original line number Diff line number Diff line
@@ -355,6 +355,10 @@ public final class AdnRecordCache extends Handler implements IccConstants {
                useLocalPb ? mUsimLocalPhoneBookManager : mUsimGlobalPhoneBookManager;
    }

    public boolean isPbrPresent() {
        return (mUsimGlobalPhoneBookManager.isPbrFilePresent() ||
                mUsimLocalPhoneBookManager.isPbrFilePresent());
    }

    /**
     * Responds with exception (in response) if efid is not a known ADN-like