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

Commit daa51a42 authored by Meng Wang's avatar Meng Wang Committed by Gerrit Code Review
Browse files

Merge "OTASP: Replace PhoneStateListener with registrant."

parents 3e88893c 82fcc7e2
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -194,12 +194,6 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        mTelephonyRegistryMgr.notifyCellInfoChanged(subId, cellInfo);
    }

    @Override
    public void notifyOtaspChanged(Phone sender, int otaspMode) {
        int subId = sender.getSubId();
        mTelephonyRegistryMgr.notifyOtaspChanged(subId, otaspMode);
    }

    public void notifyPreciseCallState(Phone sender) {
        Call ringingCall = sender.getRingingCall();
        Call foregroundCall = sender.getForegroundCall();
+5 −0
Original line number Diff line number Diff line
@@ -3503,6 +3503,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
@@ -356,6 +356,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList();

    private final RegistrantList mOtaspRegistrants = new RegistrantList();

    protected Registrant mPostDialHandler;

    protected final LocalLog mLocalLog;
@@ -2360,7 +2362,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) {
@@ -2794,6 +2796,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
@@ -55,8 +55,6 @@ public interface PhoneNotifier {

    void notifyDataActivity(Phone sender);

    void notifyOtaspChanged(Phone sender, int otaspMode);

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

    void notifyPreciseCallState(Phone sender);
+0 −11
Original line number Diff line number Diff line
@@ -259,15 +259,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(mTelephonyRegistryManager).notifyOtaspChanged(eq(mPhone.getSubId()),
                eq(TelephonyManager.OTASP_NEEDED));

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