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

Commit f29a3a34 authored by danielwbhuang's avatar danielwbhuang Committed by Daniel Huang
Browse files

OTASP: Replace PhoneStateListener with registrant.

Bug: 149478811
Test: manual sanity
log and video:
b/149478811 #18&19
Test#2:
USC/OTASP modem:OFF AP:ON
Case2_bugreport_data_20200226_102732_01081FQC200422.zip

Change-Id: Ic5c761478cf39899ba300c947d44538bb6549184
Merged-In: I0890895853125a65b61bebe8f83f84624bab24b7
Merged-In: I789c3f983a53b53176d6f6c2c91dc79e9e219553
parent 0034e2fd
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -255,18 +255,6 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        }
    }

    @Override
    public void notifyOtaspChanged(Phone sender, int otaspMode) {
        int subId = sender.getSubId();
        try {
            if (mRegistry != null) {
                mRegistry.notifyOtaspChanged(subId, otaspMode);
            }
        } catch (RemoteException ex) {
            // system process is dead
        }
    }

    public void notifyPreciseCallState(Phone sender) {
        Call ringingCall = sender.getRingingCall();
        Call foregroundCall = sender.getForegroundCall();
+5 −0
Original line number Diff line number Diff line
@@ -3440,6 +3440,11 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    @Override
    public int getOtasp() {
        return mSST.getOtasp();
    }

    @Override
    public int getCdmaEriIconIndex() {
        if (isPhoneTypeGsm()) {
+39 −1
Original line number Diff line number Diff line
@@ -380,6 +380,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    private final RegistrantList mCellInfoRegistrants = new RegistrantList();

    private final RegistrantList mOtaspRegistrants = new RegistrantList();

    protected Registrant mPostDialHandler;

    protected final LocalLog mLocalLog;
@@ -2356,7 +2358,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    @UnsupportedAppUsage
    public void notifyOtaspChanged(int otaspMode) {
        mNotifier.notifyOtaspChanged(this, otaspMode);
        mOtaspRegistrants.notifyRegistrants(new AsyncResult(null, otaspMode, null));
    }

    public void notifyVoiceActivationStateChanged(int state) {
@@ -2753,6 +2755,42 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return false;
    }

    /**
     * Register for notifications when OTA Service Provisioning mode has changed.
     *
     * <p>The mode is integer. {@link TelephonyManager#OTASP_UNKNOWN}
     * means the value is currently unknown and the system should wait until
     * {@link TelephonyManager#OTASP_NEEDED} or {@link TelephonyManager#OTASP_NOT_NEEDED} is
     * received before making the decision to perform OTASP or not.
     *
     * @param h Handler that receives the notification message.
     * @param what User-defined message code.
     * @param obj User object.
     */
    public void registerForOtaspChange(Handler h, int what, Object obj) {
        checkCorrectThread(h);
        mOtaspRegistrants.addUnique(h, what, obj);
        // notify first
        new Registrant(h, what, obj).notifyRegistrant(new AsyncResult(null, getOtasp(), null));
    }

    /**
     * Unegister for notifications when OTA Service Provisioning mode has changed.
     * @param h Handler to be removed from the registrant list.
     */
    public void unregisterForOtaspChange(Handler h) {
        mOtaspRegistrants.remove(h);
    }

    /**
     * Returns the current OTA Service Provisioning mode.
     *
     * @see registerForOtaspChange
     */
    public int getOtasp() {
        return TelephonyManager.OTASP_UNKNOWN;
    }

    /**
     * Register for notifications when CDMA call waiting comes
     *
+0 −2
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ public interface PhoneNotifier {

    void notifyDataActivity(Phone sender);

    void notifyOtaspChanged(Phone sender, int otaspMode);

    void notifyCellInfo(Phone sender, List<CellInfo> cellInfo);

    /** Notify of change to PhysicalChannelConfiguration. */
+0 −11
Original line number Diff line number Diff line
@@ -265,15 +265,4 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {
        assertEquals(3, cellLocationCapture.getValue().getInt("cid"));
        assertEquals(5, cellLocationCapture.getValue().getInt("psc"));
    }

    @Test @SmallTest
    public void testNotifyOtaspChanged() throws Exception {
        mDefaultPhoneNotifierUT.notifyOtaspChanged(mPhone, TelephonyManager.OTASP_NEEDED);
        verify(mTelephonyRegisteryMock).notifyOtaspChanged(eq(mPhone.getSubId()),
                eq(TelephonyManager.OTASP_NEEDED));

        mDefaultPhoneNotifierUT.notifyOtaspChanged(mPhone, TelephonyManager.OTASP_UNKNOWN);
        verify(mTelephonyRegisteryMock).notifyOtaspChanged(eq(mPhone.getSubId()),
                eq(TelephonyManager.OTASP_UNKNOWN));
    }
}