Search in sources :

Example 1 with TelephonyEvent

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

the class TelephonyMetrics method writeServiceStateChanged.

/**
 * Write service changed event
 *
 * @param phoneId Phone id
 * @param serviceState Service state
 */
public synchronized void writeServiceStateChanged(int phoneId, ServiceState serviceState) {
    TelephonyEvent event = new TelephonyEventBuilder(phoneId).setServiceState(toServiceStateProto(serviceState)).build();
    // If service state doesn't change, we don't log the event.
    if (mLastServiceState.get(phoneId) != null && Arrays.equals(TelephonyServiceState.toByteArray(mLastServiceState.get(phoneId)), TelephonyServiceState.toByteArray(event.serviceState))) {
        return;
    }
    mLastServiceState.put(phoneId, event.serviceState);
    addTelephonyEvent(event);
    annotateInProgressCallSession(event.timestampMillis, phoneId, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.RIL_SERVICE_STATE_CHANGED).setServiceState(event.serviceState));
    annotateInProgressSmsSession(event.timestampMillis, phoneId, new SmsSessionEventBuilder(SmsSession.Event.Type.RIL_SERVICE_STATE_CHANGED).setServiceState(event.serviceState));
}
Also used : TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)

Example 2 with TelephonyEvent

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

the class TelephonyMetrics method reset.

/**
 * Reset all events and sessions
 */
private synchronized void reset() {
    mTelephonyEvents.clear();
    mCompletedCallSessions.clear();
    mCompletedSmsSessions.clear();
    mTelephonyEventsDropped = false;
    mStartSystemTimeMs = System.currentTimeMillis();
    mStartElapsedTimeMs = SystemClock.elapsedRealtime();
    // base.
    for (int i = 0; i < mLastServiceState.size(); i++) {
        final int key = mLastServiceState.keyAt(i);
        TelephonyEvent event = new TelephonyEventBuilder(mStartElapsedTimeMs, key).setServiceState(mLastServiceState.get(key)).build();
        addTelephonyEvent(event);
    }
    for (int i = 0; i < mLastImsCapabilities.size(); i++) {
        final int key = mLastImsCapabilities.keyAt(i);
        TelephonyEvent event = new TelephonyEventBuilder(mStartElapsedTimeMs, key).setImsCapabilities(mLastImsCapabilities.get(key)).build();
        addTelephonyEvent(event);
    }
    for (int i = 0; i < mLastImsConnectionState.size(); i++) {
        final int key = mLastImsConnectionState.keyAt(i);
        TelephonyEvent event = new TelephonyEventBuilder(mStartElapsedTimeMs, key).setImsConnectionState(mLastImsConnectionState.get(key)).build();
        addTelephonyEvent(event);
    }
}
Also used : TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)

Example 3 with TelephonyEvent

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

the class TelephonyMetrics method printAllMetrics.

/**
 * Print all metrics data for debugging purposes
 *
 * @param rawWriter Print writer
 */
private synchronized void printAllMetrics(PrintWriter rawWriter) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(rawWriter, "  ");
    pw.println("Telephony metrics proto:");
    pw.println("------------------------------------------");
    pw.println("Telephony events:");
    pw.increaseIndent();
    for (TelephonyEvent event : mTelephonyEvents) {
        pw.print(event.timestampMillis);
        pw.print(" [");
        pw.print(event.phoneId);
        pw.print("] ");
        pw.print("T=");
        if (event.type == TelephonyEvent.Type.RIL_SERVICE_STATE_CHANGED) {
            pw.print(telephonyEventToString(event.type) + "(" + event.serviceState.dataRat + ")");
        } else {
            pw.print(telephonyEventToString(event.type));
        }
        pw.println("");
    }
    pw.decreaseIndent();
    pw.println("Call sessions:");
    pw.increaseIndent();
    for (TelephonyCallSession callSession : mCompletedCallSessions) {
        pw.println("Start time in minutes: " + callSession.startTimeMinutes);
        pw.println("Events dropped: " + callSession.eventsDropped);
        pw.println("Events: ");
        pw.increaseIndent();
        for (TelephonyCallSession.Event event : callSession.events) {
            pw.print(event.delay);
            pw.print(" T=");
            if (event.type == TelephonyCallSession.Event.Type.RIL_SERVICE_STATE_CHANGED) {
                pw.println(callSessionEventToString(event.type) + "(" + event.serviceState.dataRat + ")");
            } else if (event.type == TelephonyCallSession.Event.Type.RIL_CALL_LIST_CHANGED) {
                pw.println(callSessionEventToString(event.type));
                pw.increaseIndent();
                for (RilCall call : event.calls) {
                    pw.println(call.index + ". Type = " + call.type + " State = " + call.state + " End Reason " + call.callEndReason + " isMultiparty = " + call.isMultiparty);
                }
                pw.decreaseIndent();
            } else {
                pw.println(callSessionEventToString(event.type));
            }
        }
        pw.decreaseIndent();
    }
    pw.decreaseIndent();
    pw.println("Sms sessions:");
    pw.increaseIndent();
    int count = 0;
    for (SmsSession smsSession : mCompletedSmsSessions) {
        count++;
        pw.print("[" + count + "] Start time in minutes: " + smsSession.startTimeMinutes);
        if (smsSession.eventsDropped) {
            pw.println(", events dropped: " + smsSession.eventsDropped);
        }
        pw.println("Events: ");
        pw.increaseIndent();
        for (SmsSession.Event event : smsSession.events) {
            pw.print(event.delay);
            pw.print(" T=");
            pw.println(smsSessionEventToString(event.type));
        }
        pw.decreaseIndent();
    }
    pw.decreaseIndent();
}
Also used : TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) TelephonyCallSession(com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter) RilCall(com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.RilCall) SmsSession(com.android.internal.telephony.nano.TelephonyProto.SmsSession)

Example 4 with TelephonyEvent

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

the class TelephonyMetrics method writeOnImsCapabilities.

/**
 * Write the IMS capabilities changed event
 *
 * @param phoneId Phone id
 * @param capabilities IMS capabilities array
 */
public synchronized void writeOnImsCapabilities(int phoneId, boolean[] capabilities) {
    ImsCapabilities cap = new ImsCapabilities();
    cap.voiceOverLte = capabilities[0];
    cap.videoOverLte = capabilities[1];
    cap.voiceOverWifi = capabilities[2];
    cap.videoOverWifi = capabilities[3];
    cap.utOverLte = capabilities[4];
    cap.utOverWifi = capabilities[5];
    TelephonyEvent event = new TelephonyEventBuilder(phoneId).setImsCapabilities(cap).build();
    // If the capabilities don't change, we don't log the event.
    if (mLastImsCapabilities.get(phoneId) != null && Arrays.equals(ImsCapabilities.toByteArray(mLastImsCapabilities.get(phoneId)), ImsCapabilities.toByteArray(cap))) {
        return;
    }
    mLastImsCapabilities.put(phoneId, cap);
    addTelephonyEvent(event);
    annotateInProgressCallSession(event.timestampMillis, phoneId, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.IMS_CAPABILITIES_CHANGED).setImsCapabilities(event.imsCapabilities));
    annotateInProgressSmsSession(event.timestampMillis, phoneId, new SmsSessionEventBuilder(SmsSession.Event.Type.IMS_CAPABILITIES_CHANGED).setImsCapabilities(event.imsCapabilities));
}
Also used : TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) ImsCapabilities(com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities)

Example 5 with TelephonyEvent

use of com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent 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)

Aggregations

TelephonyEvent (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)11 FlakyTest (android.support.test.filters.FlakyTest)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 TelephonyTest (com.android.internal.telephony.TelephonyTest)3 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)3 Test (org.junit.Test)3 TelephonyServiceState (com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState)2 ImsReasonInfo (com.android.ims.ImsReasonInfo)1 TelephonyProto (com.android.internal.telephony.nano.TelephonyProto)1 ImsCapabilities (com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities)1 ImsConnectionState (com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState)1 SmsSession (com.android.internal.telephony.nano.TelephonyProto.SmsSession)1 TelephonyCallSession (com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession)1 RilCall (com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.RilCall)1 ModemRestart (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.ModemRestart)1 TelephonySettings (com.android.internal.telephony.nano.TelephonyProto.TelephonySettings)1 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)1