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

Commit 4c9140c8 authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Record video call events in analytics" into nyc-mr1-dev

parents 9452dbb7 4640c4fc
Loading
Loading
Loading
Loading
+48 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.telecom;
import android.telecom.DisconnectCause;
import android.telecom.ParcelableCallAnalytics;
import android.telecom.TelecomAnalytics;
import android.util.SparseArray;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
@@ -165,6 +164,12 @@ public class Analytics {

        public void setCallEvents(Log.CallEventRecord records) {
        }

        public void setCallIsVideo(boolean isVideo) {
        }

        public void addVideoEvent(int eventId, int videoState) {
        }
    }

    /**
@@ -194,6 +199,10 @@ public class Analytics {

        public Log.CallEventRecord callEvents;

        public boolean isVideo = false;
        public List<ParcelableCallAnalytics.VideoEvent> videoEvents;
        private long mTimeOfLastVideoEvent = -1;

        CallInfoImpl(String callId, int callDirection) {
            this.callId = callId;
            startTime = 0;
@@ -201,6 +210,7 @@ public class Analytics {
            this.callDirection = callDirection;
            callTechnologies = 0;
            connectionService = "";
            videoEvents = new LinkedList<>();
        }

        CallInfoImpl(CallInfoImpl other) {
@@ -215,6 +225,8 @@ public class Analytics {
            this.connectionService = other.connectionService;
            this.isEmergency = other.isEmergency;
            this.callEvents = other.callEvents;
            this.isVideo = other.isVideo;
            this.videoEvents = other.videoEvents;

            if (other.callTerminationReason != null) {
                this.callTerminationReason = new DisconnectCause(
@@ -283,6 +295,26 @@ public class Analytics {
            this.callEvents = records;
        }

        @Override
        public void setCallIsVideo(boolean isVideo) {
            this.isVideo = isVideo;
        }

        @Override
        public void addVideoEvent(int eventId, int videoState) {
            long timeSinceLastEvent;
            long currentTime = System.currentTimeMillis();
            if (mTimeOfLastVideoEvent < 0) {
                timeSinceLastEvent = -1;
            } else {
                timeSinceLastEvent = roundToOneSigFig(currentTime - mTimeOfLastVideoEvent);
            }
            mTimeOfLastVideoEvent = currentTime;

            videoEvents.add(new ParcelableCallAnalytics.VideoEvent(
                    eventId, timeSinceLastEvent, videoState));
        }

        @Override
        public String toString() {
            return "{\n"
@@ -294,6 +326,7 @@ public class Analytics {
                    + "    callTechnologies: " + getCallTechnologiesAsString() + '\n'
                    + "    callTerminationReason: " + getCallDisconnectReasonString() + '\n'
                    + "    connectionService: " + connectionService + '\n'
                    + "    isVideoCall: " + isVideo + '\n'
                    + "}\n";
        }

@@ -314,7 +347,7 @@ public class Analytics {
                events = Collections.emptyList();
                timings = Collections.emptyList();
            }
            return new ParcelableCallAnalytics(
            ParcelableCallAnalytics result = new ParcelableCallAnalytics(
                    // rounds down to nearest 5 minute mark
                    startTime - startTime % ParcelableCallAnalytics.MILLIS_IN_5_MINUTES,
                    callDuration,
@@ -330,6 +363,9 @@ public class Analytics {
                    createdFromExistingConnection,
                    events,
                    timings);
            result.setIsVideoCall(isVideo);
            result.setVideoEvents(videoEvents);
            return result;
        }

        private String getCallDirectionString() {
@@ -379,6 +415,16 @@ public class Analytics {
    public static final int SIP_PHONE = ParcelableCallAnalytics.SIP_PHONE;
    public static final int THIRD_PARTY_PHONE = ParcelableCallAnalytics.THIRD_PARTY_PHONE;

    // Constants for video events
    public static final int SEND_LOCAL_SESSION_MODIFY_REQUEST =
            ParcelableCallAnalytics.VideoEvent.SEND_LOCAL_SESSION_MODIFY_REQUEST;
    public static final int SEND_LOCAL_SESSION_MODIFY_RESPONSE =
            ParcelableCallAnalytics.VideoEvent.SEND_LOCAL_SESSION_MODIFY_RESPONSE;
    public static final int RECEIVE_REMOTE_SESSION_MODIFY_REQUEST =
            ParcelableCallAnalytics.VideoEvent.RECEIVE_REMOTE_SESSION_MODIFY_REQUEST;
    public static final int RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE =
            ParcelableCallAnalytics.VideoEvent.RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE;

    public static final long MILLIS_IN_1_SECOND = ParcelableCallAnalytics.MILLIS_IN_1_SECOND;

    private static final Object sLock = new Object(); // Coarse lock for all of analytics
+4 −0
Original line number Diff line number Diff line
@@ -1901,6 +1901,10 @@ public class Call implements CreateConnectionResponse {
        for (Listener l : mListeners) {
            l.onVideoStateChanged(this);
        }

        if (VideoProfile.isVideo(videoState)) {
            mAnalytics.setCallIsVideo(true);
        }
    }

    public boolean getIsVoipAudioMode() {
+12 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.internal.telecom.IVideoCallback;
import com.android.internal.telecom.IVideoProvider;

import java.util.Collections;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

@@ -133,6 +132,9 @@ public class VideoProviderProxy extends Connection.VideoProvider {
                    Log.event(mCall, Log.Events.RECEIVE_VIDEO_REQUEST,
                            VideoProfile.videoStateToString(videoProfile.getVideoState()));

                    mCall.getAnalytics().addVideoEvent(
                            Analytics.RECEIVE_REMOTE_SESSION_MODIFY_REQUEST,
                            videoProfile.getVideoState());
                    // Inform other Telecom components of the session modification request.
                    for (Listener listener : mListeners) {
                        listener.onSessionModifyRequestReceived(mCall, videoProfile);
@@ -157,6 +159,9 @@ public class VideoProviderProxy extends Connection.VideoProvider {
        public void receiveSessionModifyResponse(int status, VideoProfile requestProfile,
                VideoProfile responseProfile) {
            synchronized (mLock) {
                mCall.getAnalytics().addVideoEvent(
                        Analytics.RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE,
                        requestProfile.getVideoState());
                logFromVideoProvider("receiveSessionModifyResponse: status=" + status +
                        " requestProfile=" + requestProfile + " responseProfile=" +
                        responseProfile);
@@ -343,6 +348,9 @@ public class VideoProviderProxy extends Connection.VideoProvider {
            logFromInCall("sendSessionModifyRequest: from=" + fromProfile + " to=" + toProfile);
            Log.event(mCall, Log.Events.SEND_VIDEO_REQUEST,
                    VideoProfile.videoStateToString(toProfile.getVideoState()));
            mCall.getAnalytics().addVideoEvent(
                    Analytics.SEND_LOCAL_SESSION_MODIFY_REQUEST,
                    toProfile.getVideoState());
            try {
                mConectionServiceVideoProvider.sendSessionModifyRequest(fromProfile, toProfile);
            } catch (RemoteException e) {
@@ -362,6 +370,9 @@ public class VideoProviderProxy extends Connection.VideoProvider {
            logFromInCall("sendSessionModifyResponse: " + responseProfile);
            Log.event(mCall, Log.Events.SEND_VIDEO_RESPONSE,
                    VideoProfile.videoStateToString(responseProfile.getVideoState()));
            mCall.getAnalytics().addVideoEvent(
                    Analytics.SEND_LOCAL_SESSION_MODIFY_RESPONSE,
                    responseProfile.getVideoState());
            try {
                mConectionServiceVideoProvider.sendSessionModifyResponse(responseProfile);
            } catch (RemoteException e) {