use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStats method finishCall.
/**
* Sends the call metrics to persist storage when it is finished.
*/
private void finishCall(int connectionId) {
VoiceCallSession proto = mCallProtos.get(connectionId);
if (proto == null) {
loge("finishCall: could not find call to be removed");
return;
}
mCallProtos.delete(connectionId);
proto.concurrentCallCountAtEnd = mCallProtos.size();
// ensure internal fields are cleared
proto.setupBeginMillis = 0L;
// sanitize for javanano & StatsEvent
if (proto.disconnectExtraMessage == null) {
proto.disconnectExtraMessage = "";
}
mAtomsStorage.addVoiceCallSession(proto);
// merge RAT usages to PersistPullers when the call session ends (i.e. no more active calls)
if (!hasCalls()) {
mRatUsage.conclude(getTimeMillis());
mAtomsStorage.addVoiceCallRatUsage(mRatUsage);
mRatUsage.clear();
}
}
use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession in project android_frameworks_opt_telephony by LineageOS.
the class PersistAtomsStorageTest method addVoiceCallSession_emptyProto.
@Test
@SmallTest
public void addVoiceCallSession_emptyProto() throws Exception {
createEmptyTestFile();
mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
mPersistAtomsStorage.addVoiceCallSession(mCall1Proto);
mPersistAtomsStorage.incTimeMillis(100L);
// call should be added successfully, there should be no RAT usage, changes should be saved
RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
assertNotNull(voiceCallRatUsage);
assertEquals(0, voiceCallRatUsage.length);
assertProtoArrayEquals(new VoiceCallSession[] { mCall1Proto }, voiceCallSession);
InOrder inOrder = inOrder(mTestFileOutputStream);
inOrder.verify(mTestFileOutputStream, times(1)).write(eq(PersistAtoms.toByteArray(mPersistAtomsStorage.getAtomsProto())));
inOrder.verify(mTestFileOutputStream, times(1)).close();
inOrder.verifyNoMoreInteractions();
}
use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession in project android_frameworks_opt_telephony by LineageOS.
the class PersistAtomsStorageTest method getVoiceCallRatUsages_withSavedAtoms.
@Test
@SmallTest
public void getVoiceCallRatUsages_withSavedAtoms() throws Exception {
createTestFile(START_TIME_MILLIS);
mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
mPersistAtomsStorage.incTimeMillis(100L);
RawVoiceCallRatUsage[] voiceCallRatUsage1 = mPersistAtomsStorage.getVoiceCallRatUsages(50L);
mPersistAtomsStorage.incTimeMillis(100L);
RawVoiceCallRatUsage[] voiceCallRatUsage2 = mPersistAtomsStorage.getVoiceCallRatUsages(50L);
long voiceCallSessionPullTimestampMillis = mPersistAtomsStorage.getAtomsProto().voiceCallSessionPullTimestampMillis;
VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(50L);
// first set of results should equal to file contents, second should be empty, corresponding
// pull timestamp should be updated and saved, other fields should be unaffected
assertProtoArrayEquals(mVoiceCallRatUsages, voiceCallRatUsage1);
assertProtoArrayEquals(new RawVoiceCallRatUsage[0], voiceCallRatUsage2);
assertEquals(START_TIME_MILLIS + 200L, mPersistAtomsStorage.getAtomsProto().rawVoiceCallRatUsagePullTimestampMillis);
assertProtoArrayEquals(mVoiceCallSessions, voiceCallSession);
assertEquals(START_TIME_MILLIS, voiceCallSessionPullTimestampMillis);
InOrder inOrder = inOrder(mTestFileOutputStream);
assertEquals(START_TIME_MILLIS + 100L, getAtomsWritten(inOrder).rawVoiceCallRatUsagePullTimestampMillis);
assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).rawVoiceCallRatUsagePullTimestampMillis);
assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).voiceCallSessionPullTimestampMillis);
inOrder.verifyNoMoreInteractions();
}
use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession in project android_frameworks_opt_telephony by LineageOS.
the class PersistAtomsStorageTest method addVoiceCallSession_withExistingCalls.
@Test
@SmallTest
public void addVoiceCallSession_withExistingCalls() throws Exception {
createTestFile(100L);
mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
mPersistAtomsStorage.addVoiceCallSession(mCall1Proto);
mPersistAtomsStorage.incTimeMillis(100L);
// call should be added successfully, RAT usages should not change, changes should be saved
RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
assertNotNull(voiceCallRatUsage);
assertEquals(mVoiceCallRatUsages.length, voiceCallRatUsage.length);
assertNotNull(voiceCallSession);
// call lists are randomized, but sorted version should be identical
VoiceCallSession[] expectedVoiceCallSessions = new VoiceCallSession[] { mCall1Proto, mCall1Proto, mCall2Proto, mCall3Proto, mCall4Proto };
Arrays.sort(expectedVoiceCallSessions, sProtoComparator);
Arrays.sort(voiceCallSession, sProtoComparator);
assertProtoArrayEquals(expectedVoiceCallSessions, voiceCallSession);
InOrder inOrder = inOrder(mTestFileOutputStream);
inOrder.verify(mTestFileOutputStream, times(1)).write(eq(PersistAtoms.toByteArray(mPersistAtomsStorage.getAtomsProto())));
inOrder.verify(mTestFileOutputStream, times(1)).close();
inOrder.verifyNoMoreInteractions();
}
use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession in project android_frameworks_opt_telephony by LineageOS.
the class PersistAtomsStorageTest method assertHasCall.
private static void assertHasCall(VoiceCallSession[] calls, @Nullable VoiceCallSession expectedCall, int expectedCount) {
assertNotNull(calls);
int actualCount = 0;
for (VoiceCallSession call : calls) {
if (call != null && expectedCall != null) {
if (MessageNano.messageNanoEquals(call, expectedCall)) {
actualCount++;
}
}
}
assertEquals(expectedCount, actualCount);
}
Aggregations