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

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

Merge "Add In-call services to Analytics" into nyc-mr1-dev

parents ea48bbba 9d15ca43
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -149,6 +149,23 @@ message EventTimingEntry {
  optional int64 time_millis = 2;
}

message InCallServiceInfo {
  // Keep this up-to-date with com.android.server.telecom.InCallController.
  enum InCallServiceType {
    IN_CALL_SERVICE_TYPE_INVALID = 0;
    IN_CALL_SERVICE_TYPE_DIALER_UI = 1;
    IN_CALL_SERVICE_TYPE_SYSTEM_UI = 2;
    IN_CALL_SERVICE_TYPE_CAR_MODE_UI = 3;
    IN_CALL_SERVICE_TYPE_NON_UI = 4;
  }

  // The shortened component name of the in-call service.
  optional string in_call_service_name = 1;

  // The type of the in-call service
  optional InCallServiceType in_call_service_type = 2;
}

// Information about each call.
message CallLog {

@@ -227,7 +244,7 @@ message CallLog {
  // A bitmask with bits corresponding to call technologies that were used
  // during the call. The ones that we will record are CDMA, GSM, IMS, SIP,
  // and third-party.
  // https://googleplex-android-review.git.corp.google.com/#/c/816516/6/src/com/android/server/telecom/Analytics.java
  // See the com.android.server.telecom.Analytics.*_PHONE constants.
  optional int32 call_technologies = 6;

  // Indicates the call termination code.
@@ -253,4 +270,7 @@ message CallLog {

  // A list of the video events during the call.
  repeated VideoEvent video_events = 15;

  // A list of the in-call services bound during the call.
  repeated InCallServiceInfo in_call_services = 16;
}
+31 −0
Original line number Diff line number Diff line
@@ -176,6 +176,9 @@ public class Analytics {

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

        public void addInCallService(String serviceName, int type) {
        }
    }

    /**
@@ -207,6 +210,7 @@ public class Analytics {

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

        CallInfoImpl(String callId, int callDirection) {
@@ -217,6 +221,7 @@ public class Analytics {
            callTechnologies = 0;
            connectionService = "";
            videoEvents = new LinkedList<>();
            inCallServiceInfos = new LinkedList<>();
        }

        CallInfoImpl(CallInfoImpl other) {
@@ -323,6 +328,13 @@ public class Analytics {
                    .setVideoState(videoState));
        }

        @Override
        public void addInCallService(String serviceName, int type) {
            inCallServiceInfos.add(new TelecomLogClass.InCallServiceInfo()
                    .setInCallServiceName(serviceName)
                    .setInCallServiceType(type));
        }

        @Override
        public String toString() {
            return "{\n"
@@ -335,6 +347,7 @@ public class Analytics {
                    + "    callTerminationReason: " + getCallDisconnectReasonString() + '\n'
                    + "    connectionService: " + connectionService + '\n'
                    + "    isVideoCall: " + isVideo + '\n'
                    + "    inCallServices: " + getInCallServicesString() + '\n'
                    + "}\n";
        }

@@ -413,6 +426,9 @@ public class Analytics {
            }
            result.videoEvents =
                    videoEvents.toArray(new TelecomLogClass.VideoEvent[videoEvents.size()]);
            result.inCallServices = inCallServiceInfos.toArray(
                    new TelecomLogClass.InCallServiceInfo[inCallServiceInfos.size()]);

            return result;
        }

@@ -448,6 +464,21 @@ public class Analytics {
                return "NOT SET";
            }
        }

        private String getInCallServicesString() {
            StringBuilder s = new StringBuilder();
            s.append("[\n");
            for (TelecomLogClass.InCallServiceInfo service : inCallServiceInfos) {
                s.append("    ");
                s.append("name: ");
                s.append(service.getInCallServiceName());
                s.append(" type: ");
                s.append(service.getInCallServiceType());
                s.append("\n");
            }
            s.append("]");
            return s.toString();
        }
    }
    public static final String TAG = "TelecomAnalytics";

+18 −4
Original line number Diff line number Diff line
@@ -79,12 +79,16 @@ public final class InCallController extends CallsManagerListenerBase {
    }

    private class InCallServiceInfo {
        private ComponentName mComponentName;
        private final ComponentName mComponentName;
        private boolean mIsExternalCallsSupported;
        private final int mType;

        public InCallServiceInfo(ComponentName componentName, boolean isExternalCallsSupported) {
        public InCallServiceInfo(ComponentName componentName,
                boolean isExternalCallsSupported,
                int type) {
            mComponentName = componentName;
            mIsExternalCallsSupported = isExternalCallsSupported;
            mType = type;
        }

        public ComponentName getComponentName() {
@@ -95,6 +99,10 @@ public final class InCallController extends CallsManagerListenerBase {
            return mIsExternalCallsSupported;
        }

        public int getType() {
            return mType;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
@@ -192,6 +200,12 @@ public final class InCallController extends CallsManagerListenerBase {
                mIsConnected = false;
            }

            if (call != null && mIsConnected) {
                call.getAnalytics().addInCallService(
                        mInCallServiceInfo.getComponentName().flattenToShortString(),
                        mInCallServiceInfo.getType());
            }

            return mIsConnected;
        }

@@ -920,7 +934,7 @@ public final class InCallController extends CallsManagerListenerBase {
            // Last Resort: Try to bind to the ComponentName given directly.
            Log.e(this, new Exception(), "Package Manager could not find ComponentName: "
                    + componentName +". Trying to bind anyway.");
            return new InCallServiceInfo(componentName, false);
            return new InCallServiceInfo(componentName, false, type);
        }
    }

@@ -974,7 +988,7 @@ public final class InCallController extends CallsManagerListenerBase {

                    retval.add(new InCallServiceInfo(
                            new ComponentName(serviceInfo.packageName, serviceInfo.name),
                            isExternalCallsSupported));
                            isExternalCallsSupported, requestedType));
                }
            }
        }