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

Commit 34d5b710 authored by fionaxu's avatar fionaxu
Browse files

DO NOT MERGE CarrierIdentifier listen for simrecordsOverride event

CarrierTestOverride is a test API to override sim records
information. It notify the listeners that new sim records is available.
For example, DcTracker will refetch and APN settings and sent out an
initial attach request to RIL. It turns out that frequent
carrierTestOverride could end up with frequent RIL requests and
eventually crash the RILD. The short term fix is notify sim records
override events without waking update other components.
The long term fix is ganrantee RIL do not crash and also try to
decouple DcTracker and other components from listening internal
sim records loaded events.

Bug: 72332597
Test: Gts carrierIdTest
Change-Id: I18f055b2b18ab55b0e1c140668b60d6688a8a47d
parent a43d71d6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -211,11 +211,13 @@ public class CarrierIdentifier extends Handler {
                    if (mIccRecords != null) {
                        logd("Removing stale icc objects.");
                        mIccRecords.unregisterForRecordsLoaded(this);
                        mIccRecords.unregisterForRecordsOverride(this);
                        mIccRecords = null;
                    }
                    if (newIccRecords != null) {
                        logd("new Icc object");
                        newIccRecords.registerForRecordsLoaded(this, SIM_LOAD_EVENT, null);
                        newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, null);
                        mIccRecords = newIccRecords;
                    }
                }
+20 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
    protected RegistrantList mNewSmsRegistrants = new RegistrantList();
    protected RegistrantList mNetworkSelectionModeAutomaticRegistrants = new RegistrantList();
    protected RegistrantList mSpnUpdatedRegistrants = new RegistrantList();
    protected RegistrantList mRecordsOverrideRegistrants = new RegistrantList();

    protected int mRecordsToLoad;  // number of pending load requests

@@ -218,7 +219,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
        mCarrierTestOverride.override(mccmnc, imsi, iccid, gid1, gid2, pnn, spn);
        mTelephonyManager.setSimOperatorNameForPhone(mParentApp.getPhoneId(), spn);
        mTelephonyManager.setSimOperatorNumericForPhone(mParentApp.getPhoneId(), mccmnc);
        mRecordsLoadedRegistrants.notifyRegistrants();
        mRecordsOverrideRegistrants.notifyRegistrants();
    }

    /**
@@ -308,10 +309,28 @@ public abstract class IccRecords extends Handler implements IccConstants {
            r.notifyRegistrant(new AsyncResult(null, null, null));
        }
    }

    public void unregisterForRecordsLoaded(Handler h) {
        mRecordsLoadedRegistrants.remove(h);
    }

    public void unregisterForRecordsOverride(Handler h) {
        mRecordsOverrideRegistrants.remove(h);
    }

    public void registerForRecordsOverride(Handler h, int what, Object obj) {
        if (mDestroyed.get()) {
            return;
        }

        Registrant r = new Registrant(h, what, obj);
        mRecordsOverrideRegistrants.add(r);

        if (getRecordsLoaded()) {
            r.notifyRegistrant(new AsyncResult(null, null, null));
        }
    }

    /**
     * Register to be notified when records are loaded for a PIN or PUK locked SIM
     */