Adds EventManager and SessionManager callbacks for Analytics
Implements the callbacks in EventManager and SessionManager to pipe the
completion time of call operations into Analytics.
Test: Manual Testing and running existing Telecom Unit Tests
Bug: 26571395
Change-Id: I14712b45ca4cf0c51e44da7eb5b4758b4eb68aaa
diff --git a/src/com/android/server/telecom/LogUtils.java b/src/com/android/server/telecom/LogUtils.java
index 457db50..b7b22e0 100644
--- a/src/com/android/server/telecom/LogUtils.java
+++ b/src/com/android/server/telecom/LogUtils.java
@@ -27,6 +27,7 @@
public class LogUtils {
private static final String TAG = "Telecom";
+ private static final String LOGUTILS_TAG = "LogUtils";
public static final boolean SYSTRACE_DEBUG = false; /* STOP SHIP if true */
@@ -156,6 +157,23 @@
}
}
+ private static void eventRecordAdded(EventManager.EventRecord eventRecord) {
+ // Only Calls will be added as event records in this case
+ EventManager.Loggable recordEntry = eventRecord.getRecordEntry();
+ if (recordEntry instanceof Call) {
+ Call callRecordEntry = (Call) recordEntry;
+ android.telecom.Log.i(LOGUTILS_TAG, "EventRecord added as Call: " + callRecordEntry);
+ Analytics.CallInfo callInfo = callRecordEntry.getAnalytics();
+ if(callInfo != null) {
+ callInfo.setCallEvents(eventRecord);
+ } else {
+ android.telecom.Log.w(LOGUTILS_TAG, "Could not get Analytics CallInfo.");
+ }
+ } else {
+ android.telecom.Log.w(LOGUTILS_TAG, "Non-Call EventRecord Added.");
+ }
+ }
+
public static void initLogging(Context context) {
android.telecom.Log.setTag(TAG);
android.telecom.Log.setSessionContext(context);
@@ -163,5 +181,8 @@
for (EventManager.TimedEventPair p : Events.Timings.sTimedEvents) {
android.telecom.Log.addRequestResponsePair(p);
}
+ android.telecom.Log.registerEventListener(LogUtils::eventRecordAdded);
+ // Store analytics about recently completed Sessions.
+ android.telecom.Log.registerSessionListener(Analytics::addSessionTiming);
}
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index af7f0b5..c5e7f60 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -611,6 +611,11 @@
// called correctly in order to continue.
verify(localAppContext).sendBroadcastAsUser(actionCallIntent, UserHandle.SYSTEM);
mTelecomSystem.getCallIntentProcessor().processIntent(actionCallIntent);
+ // Wait for handler to start CallerInfo lookup.
+ waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
+ // Send the CallerInfo lookup reply.
+ mCallerInfoAsyncQueryFactoryFixture.mRequests.forEach(
+ CallerInfoAsyncQueryFactoryFixture.Request::reply);
if (!hasInCallAdapter) {
verify(mInCallServiceFixtureX.getTestDouble())
@@ -742,10 +747,11 @@
.createConnection(any(PhoneAccountHandle.class), anyString(),
any(ConnectionRequest.class), eq(true), eq(false), any());
- for (CallerInfoAsyncQueryFactoryFixture.Request request :
- mCallerInfoAsyncQueryFactoryFixture.mRequests) {
- request.reply();
- }
+ // Wait for the handler to start the CallerInfo lookup
+ waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
+ // Process the CallerInfo lookup reply
+ mCallerInfoAsyncQueryFactoryFixture.mRequests.forEach(
+ CallerInfoAsyncQueryFactoryFixture.Request::reply);
IContentProvider blockedNumberProvider =
mSpyContext.getContentResolver().acquireProvider(BlockedNumberContract.AUTHORITY);