Search in sources :

Example 1 with TelephonyServiceState

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetrics method toServiceStateProto.

/**
 * Convert the service state into service state proto
 *
 * @param serviceState Service state
 * @return Service state proto
 */
private TelephonyServiceState toServiceStateProto(ServiceState serviceState) {
    TelephonyServiceState ssProto = new TelephonyServiceState();
    ssProto.voiceRoamingType = serviceState.getVoiceRoamingType();
    ssProto.dataRoamingType = serviceState.getDataRoamingType();
    ssProto.voiceOperator = new TelephonyServiceState.TelephonyOperator();
    if (serviceState.getVoiceOperatorAlphaLong() != null) {
        ssProto.voiceOperator.alphaLong = serviceState.getVoiceOperatorAlphaLong();
    }
    if (serviceState.getVoiceOperatorAlphaShort() != null) {
        ssProto.voiceOperator.alphaShort = serviceState.getVoiceOperatorAlphaShort();
    }
    if (serviceState.getVoiceOperatorNumeric() != null) {
        ssProto.voiceOperator.numeric = serviceState.getVoiceOperatorNumeric();
    }
    ssProto.dataOperator = new TelephonyServiceState.TelephonyOperator();
    if (serviceState.getDataOperatorAlphaLong() != null) {
        ssProto.dataOperator.alphaLong = serviceState.getDataOperatorAlphaLong();
    }
    if (serviceState.getDataOperatorAlphaShort() != null) {
        ssProto.dataOperator.alphaShort = serviceState.getDataOperatorAlphaShort();
    }
    if (serviceState.getDataOperatorNumeric() != null) {
        ssProto.dataOperator.numeric = serviceState.getDataOperatorNumeric();
    }
    ssProto.voiceRat = serviceState.getRilVoiceRadioTechnology();
    ssProto.dataRat = serviceState.getRilDataRadioTechnology();
    return ssProto;
}
Also used : TelephonyServiceState(com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState)

Example 2 with TelephonyServiceState

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetrics method startNewSmsSessionIfNeeded.

/**
 * Create the SMS session if there isn't any existing one
 *
 * @param phoneId Phone id
 * @return The SMS session
 */
private synchronized InProgressSmsSession startNewSmsSessionIfNeeded(int phoneId) {
    InProgressSmsSession smsSession = mInProgressSmsSessions.get(phoneId);
    if (smsSession == null) {
        if (VDBG)
            Rlog.v(TAG, "Starting a new sms session on phone " + phoneId);
        smsSession = new InProgressSmsSession(phoneId);
        mInProgressSmsSessions.append(phoneId, smsSession);
        // Insert the latest service state, ims capabilities, and ims connection state as the
        // base.
        TelephonyServiceState serviceState = mLastServiceState.get(phoneId);
        if (serviceState != null) {
            smsSession.addEvent(smsSession.startElapsedTimeMs, new SmsSessionEventBuilder(TelephonyCallSession.Event.Type.RIL_SERVICE_STATE_CHANGED).setServiceState(serviceState));
        }
        ImsCapabilities imsCapabilities = mLastImsCapabilities.get(phoneId);
        if (imsCapabilities != null) {
            smsSession.addEvent(smsSession.startElapsedTimeMs, new SmsSessionEventBuilder(SmsSession.Event.Type.IMS_CAPABILITIES_CHANGED).setImsCapabilities(imsCapabilities));
        }
        ImsConnectionState imsConnectionState = mLastImsConnectionState.get(phoneId);
        if (imsConnectionState != null) {
            smsSession.addEvent(smsSession.startElapsedTimeMs, new SmsSessionEventBuilder(SmsSession.Event.Type.IMS_CONNECTION_STATE_CHANGED).setImsConnectionState(imsConnectionState));
        }
    }
    return smsSession;
}
Also used : TelephonyServiceState(com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState) ImsConnectionState(com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState) ImsCapabilities(com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities)

Example 3 with TelephonyServiceState

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetrics method startNewCallSessionIfNeeded.

/**
 * Create the call session if there isn't any existing one
 *
 * @param phoneId Phone id
 * @return The call session
 */
private synchronized InProgressCallSession startNewCallSessionIfNeeded(int phoneId) {
    InProgressCallSession callSession = mInProgressCallSessions.get(phoneId);
    if (callSession == null) {
        if (VDBG)
            Rlog.v(TAG, "Starting a new call session on phone " + phoneId);
        callSession = new InProgressCallSession(phoneId);
        mInProgressCallSessions.append(phoneId, callSession);
        // Insert the latest service state, ims capabilities, and ims connection states as the
        // base.
        TelephonyServiceState serviceState = mLastServiceState.get(phoneId);
        if (serviceState != null) {
            callSession.addEvent(callSession.startElapsedTimeMs, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.RIL_SERVICE_STATE_CHANGED).setServiceState(serviceState));
        }
        ImsCapabilities imsCapabilities = mLastImsCapabilities.get(phoneId);
        if (imsCapabilities != null) {
            callSession.addEvent(callSession.startElapsedTimeMs, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.IMS_CAPABILITIES_CHANGED).setImsCapabilities(imsCapabilities));
        }
        ImsConnectionState imsConnectionState = mLastImsConnectionState.get(phoneId);
        if (imsConnectionState != null) {
            callSession.addEvent(callSession.startElapsedTimeMs, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.IMS_CONNECTION_STATE_CHANGED).setImsConnectionState(imsConnectionState));
        }
    }
    return callSession;
}
Also used : TelephonyServiceState(com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState) ImsConnectionState(com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState) ImsCapabilities(com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities)

Example 4 with TelephonyServiceState

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetricsTest method testWriteServiceStateChanged.

// Test write service state changed
@Test
@SmallTest
public void testWriteServiceStateChanged() throws Exception {
    mMetrics.writeServiceStateChanged(mPhone.getPhoneId(), mServiceState);
    mMetrics.writeServiceStateChanged(mPhone.getPhoneId(), mServiceState);
    TelephonyLog log = buildProto();
    assertEquals(1, log.events.length);
    assertEquals(0, log.callSessions.length);
    assertEquals(0, log.smsSessions.length);
    assertFalse(log.eventsDropped);
    TelephonyEvent event = log.events[0];
    assertEquals(TelephonyEvent.Type.RIL_SERVICE_STATE_CHANGED, event.type);
    TelephonyServiceState state = event.serviceState;
    assertEquals(RadioAccessTechnology.RAT_LTE, state.voiceRat);
    assertEquals(RadioAccessTechnology.RAT_LTE, state.dataRat);
    assertEquals(RoamingType.ROAMING_TYPE_DOMESTIC, state.voiceRoamingType);
    assertEquals(RoamingType.ROAMING_TYPE_DOMESTIC, state.dataRoamingType);
    assertEquals("voicelong", state.voiceOperator.alphaLong);
    assertEquals("voiceshort", state.voiceOperator.alphaShort);
    assertEquals("123456", state.voiceOperator.numeric);
    assertEquals("datalong", state.dataOperator.alphaLong);
    assertEquals("datashort", state.dataOperator.alphaShort);
    assertEquals("123456", state.dataOperator.numeric);
}
Also used : TelephonyLog(com.android.internal.telephony.nano.TelephonyProto.TelephonyLog) TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) TelephonyServiceState(com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with TelephonyServiceState

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetricsTest method testReset.

// Test reset scenario
@Test
@SmallTest
public void testReset() throws Exception {
    mMetrics.writeServiceStateChanged(mPhone.getPhoneId(), mServiceState);
    reset();
    TelephonyLog log = buildProto();
    assertEquals(1, log.events.length);
    assertEquals(0, log.callSessions.length);
    assertEquals(0, log.smsSessions.length);
    assertFalse(log.eventsDropped);
    TelephonyEvent event = log.events[0];
    assertEquals(TelephonyEvent.Type.RIL_SERVICE_STATE_CHANGED, event.type);
    TelephonyServiceState state = event.serviceState;
    assertEquals(RadioAccessTechnology.RAT_LTE, state.voiceRat);
    assertEquals(RadioAccessTechnology.RAT_LTE, state.dataRat);
    assertEquals(RoamingType.ROAMING_TYPE_DOMESTIC, state.voiceRoamingType);
    assertEquals(RoamingType.ROAMING_TYPE_DOMESTIC, state.dataRoamingType);
    assertEquals("voicelong", state.voiceOperator.alphaLong);
    assertEquals("voiceshort", state.voiceOperator.alphaShort);
    assertEquals("123456", state.voiceOperator.numeric);
    assertEquals("datalong", state.dataOperator.alphaLong);
    assertEquals("datashort", state.dataOperator.alphaShort);
    assertEquals("123456", state.dataOperator.numeric);
}
Also used : TelephonyLog(com.android.internal.telephony.nano.TelephonyProto.TelephonyLog) TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) TelephonyServiceState(com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

TelephonyServiceState (com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState)5 FlakyTest (android.support.test.filters.FlakyTest)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 TelephonyTest (com.android.internal.telephony.TelephonyTest)2 ImsCapabilities (com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities)2 ImsConnectionState (com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState)2 TelephonyEvent (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)2 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)2 Test (org.junit.Test)2