Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eebf1d7 authored by Brad Ebinger's avatar Brad Ebinger Committed by Hall Liu
Browse files

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
parent fd9ae118
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telecom.Logging.EventManager.TimedEventPair;
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 @@ public class LogUtils {
        }
    }

    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 @@ public class LogUtils {
        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);
    }
}
+10 −4
Original line number Diff line number Diff line
@@ -611,6 +611,11 @@ public class TelecomSystemTest extends TelecomTestCase {
        // 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 @@ public class TelecomSystemTest extends TelecomTestCase {
                .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);