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));
}
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);
}
}
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();
}
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));
}
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);
}
Aggregations