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

Commit 0086e114 authored by Chen Xu's avatar Chen Xu Committed by Android (Google) Code Review
Browse files

Merge "PhoneStateListener msim improvement" into qt-dev

parents 790906ff 6b5af158
Loading
Loading
Loading
Loading
+22 −21
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    private void doNotifyDataConnection(Phone sender, String apnType,
                                        PhoneConstants.DataState state) {
        int subId = sender.getSubId();
        int phoneId = sender.getPhoneId();
        long dds = SubscriptionManager.getDefaultDataSubscriptionId();
        if (DBG) log("subId = " + subId + ", DDS = " + dds);

@@ -187,7 +188,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {

        try {
            if (mRegistry != null) {
                mRegistry.notifyDataConnectionForSubscriber(subId,
                mRegistry.notifyDataConnectionForSubscriber(phoneId, subId,
                    PhoneConstantConversions.convertDataState(state),
                        sender.isDataAllowed(ApnSetting.getApnTypesBitmaskFromString(apnType)),
                        sender.getActiveApnHost(apnType),
@@ -204,10 +205,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {

    @Override
    public void notifyDataConnectionFailed(Phone sender, String apnType) {
        int subId = sender.getSubId();
        try {
            if (mRegistry != null) {
                mRegistry.notifyDataConnectionFailedForSubscriber(subId, apnType);
                mRegistry.notifyDataConnectionFailedForSubscriber(sender.getPhoneId(),
                        sender.getSubId(), apnType);
            }
        } catch (RemoteException ex) {
            // system process is dead
@@ -255,10 +256,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {

    @Override
    public void notifyOtaspChanged(Phone sender, int otaspMode) {
        // FIXME: subId?
        int subId = sender.getSubId();
        try {
            if (mRegistry != null) {
                mRegistry.notifyOtaspChanged(otaspMode);
                mRegistry.notifyOtaspChanged(subId, otaspMode);
            }
        } catch (RemoteException ex) {
            // system process is dead
@@ -266,27 +267,25 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    public void notifyPreciseCallState(Phone sender) {
        // FIXME: subId?
        Call ringingCall = sender.getRingingCall();
        Call foregroundCall = sender.getForegroundCall();
        Call backgroundCall = sender.getBackgroundCall();
        if (ringingCall != null && foregroundCall != null && backgroundCall != null) {
            try {
                mRegistry.notifyPreciseCallState(
                mRegistry.notifyPreciseCallState(sender.getPhoneId(), sender.getSubId(),
                        convertPreciseCallState(ringingCall.getState()),
                        convertPreciseCallState(foregroundCall.getState()),
                        convertPreciseCallState(backgroundCall.getState()),
                        sender.getPhoneId());
                        convertPreciseCallState(backgroundCall.getState()));
            } catch (RemoteException ex) {
                // system process is dead
            }
        }
    }

    public void notifyDisconnectCause(int cause, int preciseCause) {
        // FIXME: subId?
    public void notifyDisconnectCause(Phone sender, int cause, int preciseCause) {
        try {
            mRegistry.notifyDisconnectCause(cause, preciseCause);
            mRegistry.notifyDisconnectCause(sender.getPhoneId(), sender.getSubId(), cause,
                    preciseCause);
        } catch (RemoteException ex) {
            // system process is dead
        }
@@ -303,9 +302,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier {

    public void notifyPreciseDataConnectionFailed(Phone sender, String apnType,
            String apn, @DataFailCause.FailCause int failCause) {
        // FIXME: subId?
        try {
            mRegistry.notifyPreciseDataConnectionFailed(apnType, apn, failCause);
            mRegistry.notifyPreciseDataConnectionFailed(sender.getPhoneId(), sender.getSubId(),
                    apnType, apn, failCause);
        } catch (RemoteException ex) {
            // system process is dead
        }
@@ -351,9 +350,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) {
    public void notifyOemHookRawEventForSubscriber(Phone sender, byte[] rawData) {
        try {
            mRegistry.notifyOemHookRawEventForSubscriber(subId, rawData);
            mRegistry.notifyOemHookRawEventForSubscriber(sender.getPhoneId(),
                    sender.getSubId(), rawData);
        } catch (RemoteException ex) {
            // system process is dead
        }
@@ -369,19 +369,20 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
    public void notifyRadioPowerStateChanged(Phone sender,
                                             @TelephonyManager.RadioPowerState int state) {
        try {
            mRegistry.notifyRadioPowerStateChanged(state);
            mRegistry.notifyRadioPowerStateChanged(sender.getPhoneId(), sender.getSubId(), state);
        } catch (RemoteException ex) {
            // system process is dead
        }
    }

    @Override
    public void notifyEmergencyNumberList() {
    public void notifyEmergencyNumberList(Phone sender) {
        try {
            if (mRegistry != null) {
                mRegistry.notifyEmergencyNumberList();
                mRegistry.notifyEmergencyNumberList(sender.getPhoneId(), sender.getSubId());
            }
        } catch (RemoteException ex) {
            // system process is dead
@@ -394,7 +395,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        try {
            if (mRegistry != null) {
                mRegistry.notifyCallQualityChanged(callQuality, sender.getPhoneId(),
                        callNetworkType);
                        sender.getSubId(), callNetworkType);
            }
        } catch (RemoteException ex) {
            // system process is dead
+3 −2
Original line number Diff line number Diff line
@@ -689,7 +689,8 @@ public class GsmCdmaPhone extends Phone {
    public void notifyDisconnect(Connection cn) {
        mDisconnectRegistrants.notifyResult(cn);

        mNotifier.notifyDisconnectCause(cn.getDisconnectCause(), cn.getPreciseDisconnectCause());
        mNotifier.notifyDisconnectCause(this, cn.getDisconnectCause(),
                cn.getPreciseDisconnectCause());
    }

    public void notifyUnknownConnection(Connection cn) {
@@ -2376,7 +2377,7 @@ public class GsmCdmaPhone extends Phone {

    private void handleRadioPowerStateChange() {
        Rlog.d(LOG_TAG, "handleRadioPowerStateChange, state= " + mCi.getRadioState());
        mNotifier.notifyRadioPowerStateChanged(mCi.getRadioState());
        mNotifier.notifyRadioPowerStateChanged(this, mCi.getRadioState());
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                ar = (AsyncResult)msg.obj;
                if (ar.exception == null) {
                    byte[] data = (byte[])ar.result;
                    mNotifier.notifyOemHookRawEventForSubscriber(getSubId(), data);
                    mNotifier.notifyOemHookRawEventForSubscriber(this, data);
                } else {
                    Rlog.e(LOG_TAG, "OEM hook raw exception: " + ar.exception);
                }
@@ -2389,7 +2389,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    /** Notify the {@link EmergencyNumber} changes. */
    public void notifyEmergencyNumberList() {
        mNotifier.notifyEmergencyNumberList();
        mNotifier.notifyEmergencyNumberList(this);
    }

    /**
+4 −4
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public interface PhoneNotifier {

    void notifyPreciseCallState(Phone sender);

    void notifyDisconnectCause(int cause, int preciseCause);
    void notifyDisconnectCause(Phone sender, int cause, int preciseCause);

    void notifyImsDisconnectCause(Phone sender, ImsReasonInfo imsReasonInfo);

@@ -79,14 +79,14 @@ public interface PhoneNotifier {

    public void notifyUserMobileDataStateChanged(Phone sender, boolean state);

    public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData);
    public void notifyOemHookRawEventForSubscriber(Phone sender, byte[] rawData);

    public void notifyPhoneCapabilityChanged(PhoneCapability capability);

    void notifyRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state);
    void notifyRadioPowerStateChanged(Phone sender, @TelephonyManager.RadioPowerState int state);

    /** Notify of change to EmergencyNumberList. */
    void notifyEmergencyNumberList();
    void notifyEmergencyNumberList(Phone sender);

    /** Notify of a change to the call quality of an active foreground call. */
    void notifyCallQualityChanged(Phone sender, CallQuality callQuality, int callNetworkType);
+31 −23
Original line number Diff line number Diff line
@@ -155,28 +155,30 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {

    @Test @SmallTest
    public void testNotifyDisconnectCause() throws Exception {
        mDefaultPhoneNotifierUT.notifyDisconnectCause(DisconnectCause.NOT_VALID,
        doReturn(1).when(mPhone).getPhoneId();
        doReturn(0).when(mPhone).getSubId();
        mDefaultPhoneNotifierUT.notifyDisconnectCause(mPhone, DisconnectCause.NOT_VALID,
                PreciseDisconnectCause.FDN_BLOCKED);
        verify(mTelephonyRegisteryMock).notifyDisconnectCause(DisconnectCause.NOT_VALID,
        verify(mTelephonyRegisteryMock).notifyDisconnectCause(1, 0, DisconnectCause.NOT_VALID,
                PreciseDisconnectCause.FDN_BLOCKED);

        mDefaultPhoneNotifierUT.notifyDisconnectCause(DisconnectCause.LOCAL,
        mDefaultPhoneNotifierUT.notifyDisconnectCause(mPhone, DisconnectCause.LOCAL,
                PreciseDisconnectCause.CHANNEL_NOT_AVAIL);
        verify(mTelephonyRegisteryMock).notifyDisconnectCause(DisconnectCause.LOCAL,
        verify(mTelephonyRegisteryMock).notifyDisconnectCause(1, 0, DisconnectCause.LOCAL,
                PreciseDisconnectCause.CHANNEL_NOT_AVAIL);
    }

    @Test @SmallTest
    public void testNotifyDataConnectionFailed() throws Exception {
        mDefaultPhoneNotifierUT.notifyDataConnectionFailed(mPhone, "APN_0");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(0, "APN_0");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(0, 0, "APN_0");

        mDefaultPhoneNotifierUT.notifyDataConnectionFailed(mPhone, "APN_1");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(0, "APN_1");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(0, 0, "APN_1");

        doReturn(1).when(mPhone).getSubId();
        mDefaultPhoneNotifierUT.notifyDataConnectionFailed(mPhone, "APN_1");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(1, "APN_1");
        verify(mTelephonyRegisteryMock).notifyDataConnectionFailedForSubscriber(0,1, "APN_1");
    }

    @Test @SmallTest
@@ -188,50 +190,54 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {
        doReturn(Call.State.IDLE).when(mRingingCall).getState();

        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt(), anyInt());
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(
                anyInt(), anyInt(), anyInt(), anyInt(), anyInt());

        doReturn(mForeGroundCall).when(mPhone).getForegroundCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt(), anyInt());
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(
                anyInt(), anyInt(), anyInt(), anyInt(), anyInt());

        doReturn(mBackGroundCall).when(mPhone).getBackgroundCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt(), anyInt());
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(
                anyInt(), anyInt(), anyInt(), anyInt(), anyInt());

        doReturn(mRingingCall).when(mPhone).getRingingCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                mPhone.getPhoneId(),
                mPhone.getSubId(),
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                mPhone.getPhoneId());
                PreciseCallState.PRECISE_CALL_STATE_IDLE);

        doReturn(Call.State.ACTIVE).when(mForeGroundCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                mPhone.getPhoneId(),
                mPhone.getSubId(),
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                mPhone.getPhoneId());
                PreciseCallState.PRECISE_CALL_STATE_IDLE);

        doReturn(Call.State.HOLDING).when(mBackGroundCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                mPhone.getPhoneId(),
                mPhone.getSubId(),
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_HOLDING,
                mPhone.getPhoneId());
                PreciseCallState.PRECISE_CALL_STATE_HOLDING);

        doReturn(Call.State.ALERTING).when(mRingingCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                mPhone.getPhoneId(),
                mPhone.getSubId(),
                PreciseCallState.PRECISE_CALL_STATE_ALERTING,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_HOLDING,
                mPhone.getPhoneId());
                PreciseCallState.PRECISE_CALL_STATE_HOLDING);
    }

    @Test @SmallTest
@@ -263,9 +269,11 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {
    @Test @SmallTest
    public void testNotifyOtaspChanged() throws Exception {
        mDefaultPhoneNotifierUT.notifyOtaspChanged(mPhone, TelephonyManager.OTASP_NEEDED);
        verify(mTelephonyRegisteryMock).notifyOtaspChanged(TelephonyManager.OTASP_NEEDED);
        verify(mTelephonyRegisteryMock).notifyOtaspChanged(eq(mPhone.getSubId()),
                eq(TelephonyManager.OTASP_NEEDED));

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