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

Commit c075109f authored by Chi Zhang's avatar Chi Zhang Committed by Android (Google) Code Review
Browse files

Merge "Update ImsStats registration stat RAT on service state change" into tm-d1-dev

parents d598949a 523cc7e0
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ import com.android.internal.telephony.data.AccessNetworksManager;
import com.android.internal.telephony.data.DataNetwork;
import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
import com.android.internal.telephony.dataconnection.DataConnection;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.metrics.ServiceStateStats;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
@@ -1701,6 +1702,10 @@ public class ServiceStateTracker extends Handler {
                        TelephonyMetrics.getInstance().writeServiceStateChanged(
                                mPhone.getPhoneId(), mSS);
                        mPhone.getVoiceCallSessionStats().onServiceStateChanged(mSS);
                        ImsPhone imsPhone = (ImsPhone) mPhone.getImsPhone();
                        if (imsPhone != null) {
                            imsPhone.getImsStats().onServiceStateChanged(mSS);
                        }
                        mServiceStateStats.onServiceStateChanged(mSS);
                    }
                }
@@ -3820,6 +3825,10 @@ public class ServiceStateTracker extends Handler {

            TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS);
            mPhone.getVoiceCallSessionStats().onServiceStateChanged(mSS);
            ImsPhone imsPhone = (ImsPhone) mPhone.getImsPhone();
            if (imsPhone != null) {
                imsPhone.getImsStats().onServiceStateChanged(mSS);
            }
            mServiceStateStats.onServiceStateChanged(mSS);
        }

+16 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.os.SystemClock;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.Annotation.NetworkType;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ProvisioningManager;
@@ -196,7 +197,7 @@ public class ImsStats {

    private long mLastTimestamp;
    @Nullable private ImsRegistrationStats mLastRegistrationStats;

    @TransportType int mLastTransportType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
    // Available features are those reported by ImsService to be available for use.
    private MmTelCapabilities mLastAvailableFeatures = new MmTelCapabilities();

@@ -265,6 +266,10 @@ public class ImsStats {

        boolean ratChanged = false;
        @NetworkType int newRat = convertRegistrationTechToNetworkType(radioTech);
        mLastTransportType =
                (newRat == TelephonyManager.NETWORK_TYPE_IWLAN)
                        ? AccessNetworkConstants.TRANSPORT_TYPE_WLAN
                        : AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
        if (mLastRegistrationStats != null && mLastRegistrationStats.rat != newRat) {
            mLastRegistrationStats.rat = newRat;
            ratChanged = true;
@@ -301,6 +306,7 @@ public class ImsStats {
    public synchronized void onImsRegistering(@TransportType int imsRadioTech) {
        conclude();

        mLastTransportType = imsRadioTech;
        mLastRegistrationStats = getDefaultImsRegistrationStats();
        mLastRegistrationStats.rat = convertTransportTypeToNetworkType(imsRadioTech);
        mLastRegistrationState = REGISTRATION_STATE_REGISTERING;
@@ -310,6 +316,7 @@ public class ImsStats {
    public synchronized void onImsRegistered(@TransportType int imsRadioTech) {
        conclude();

        mLastTransportType = imsRadioTech;
        // NOTE: mLastRegistrationStats can be null (no registering phase).
        if (mLastRegistrationStats == null) {
            mLastRegistrationStats = getDefaultImsRegistrationStats();
@@ -347,6 +354,14 @@ public class ImsStats {
        mLastAvailableFeatures = new MmTelCapabilities();
    }

    /** Updates the RAT when service state changes. */
    public synchronized void onServiceStateChanged(ServiceState state) {
        if (mLastTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN
                && mLastRegistrationStats != null) {
            mLastRegistrationStats.rat = ServiceStateStats.getDataRat(state);
        }
    }

    /**
     * Returns the current RAT used for IMS voice registration, or {@link
     * TelephonyManager#NETWORK_TYPE_UNKNOWN} if there isn't any.
+36 −0
Original line number Diff line number Diff line
@@ -869,4 +869,40 @@ public class ImsStatsTest extends TelephonyTest {

        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, mImsStats.getImsVoiceRadioTech());
    }

    @Test
    @SmallTest
    public void getImsVoiceRadioTech_serviceStateChanged() throws Exception {
        mImsStats.onImsRegistered(TRANSPORT_TYPE_WWAN);
        mImsStats.onImsCapabilitiesChanged(
                REGISTRATION_TECH_LTE, new MmTelCapabilities(CAPABILITY_TYPE_VOICE));
        doReturn(
                        new NetworkRegistrationInfo.Builder()
                                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR)
                                .setRegistrationState(
                                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                                .build())
                .when(mServiceState)
                .getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN);
        mImsStats.onServiceStateChanged(mServiceState);
        assertEquals(TelephonyManager.NETWORK_TYPE_NR, mImsStats.getImsVoiceRadioTech());
    }

    @Test
    @SmallTest
    public void getImsVoiceRadioTech_serviceStateChanged_wlan() throws Exception {
        mImsStats.onImsRegistered(TRANSPORT_TYPE_WWAN);
        mImsStats.onImsCapabilitiesChanged(
                REGISTRATION_TECH_IWLAN, new MmTelCapabilities(CAPABILITY_TYPE_VOICE));
        doReturn(
                        new NetworkRegistrationInfo.Builder()
                                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR)
                                .setRegistrationState(
                                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                                .build())
                .when(mServiceState)
                .getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN);
        mImsStats.onServiceStateChanged(mServiceState);
        assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, mImsStats.getImsVoiceRadioTech());
    }
}