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

Commit fe47a869 authored by Hui Wang's avatar Hui Wang
Browse files

Support pulled atoms for Telecom metrics

Flag: com.android.server.telecom.flags.telecom_metrics_support
Bug: 362394177
Test: manual
Test: atest TelecomUnitTests
Change-Id: I50cbc15b8f81bc86be5398cd605804743428f473
parent 63705494
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,5 +43,6 @@ aconfig_declarations {
        "telecom_profile_user_flags.aconfig",
        "telecom_bluetoothdevicemanager_flags.aconfig",
        "telecom_non_critical_security_flags.aconfig",
        "telecom_metrics_flags.aconfig",
    ],
}
+10 −0
Original line number Diff line number Diff line
package: "com.android.server.telecom.flags"
container: "system"

# OWNER=huiwang TARGET=25Q1
flag {
  name: "telecom_metrics_support"
  namespace: "telecom"
  description: "Support telecom metrics"
  bug: "362394177"
}
+114 −0
Original line number Diff line number Diff line
syntax = "proto2";

package com.android.server.telecom;

option java_package = "com.android.server.telecom";
option java_outer_classname = "PulledAtomsClass";

message PulledAtoms {
  repeated CallStats call_stats = 1;
  optional int64 call_stats_pull_timestamp_millis = 2;
  repeated CallAudioRouteStats call_audio_route_stats = 3;
  optional int64 call_audio_route_stats_pull_timestamp_millis = 4;
  repeated TelecomApiStats telecom_api_stats = 5;
  optional int64 telecom_api_stats_pull_timestamp_millis = 6;
  repeated TelecomErrorStats telecom_error_stats = 7;
  optional int64 telecom_error_stats_pull_timestamp_millis = 8;
}

/**
 * Pulled atom to capture stats of the calls
 * From frameworks/proto_logging/stats/atoms/telecomm/telecom_extension_atom.proto
 */
message CallStats {
    // The value should be converted to android.telecom.CallDirectionEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 call_direction = 1;

    // True if call is external. External calls are calls on connected Wear
    // devices but show up in Telecom so the user can pull them onto the device.
    optional bool external_call = 2;

    // True if call is emergency call.
    optional bool emergency_call = 3;

    // True if there are multiple audio routes available
    optional bool multiple_audio_available = 4;

    // The value should be converted to android.telecom.AccountTypeEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 account_type = 5;

    // UID of the package to init the call. This should always be -1/unknown for
    // the private space calls
    optional int32 uid = 6;

    // Total number of the calls
    optional int32 count = 7;

    // Average elapsed time between CALL_STATE_ACTIVE to CALL_STATE_DISCONNECTED.
    optional int32 average_duration_ms = 8;
}

/**
 * Pulled atom to capture stats of the call audio route
 * From frameworks/proto_logging/stats/atoms/telecomm/telecom_extension_atom.proto
 */
message CallAudioRouteStats {
    // The value should be converted to android.telecom.CallAudioEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 call_audio_route_source = 1;

    // The value should be converted to android.telecom.CallAudioEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 call_audio_route_dest = 2;

    // True if the route is successful.
    optional bool success = 3;

    // True if the route is revert
    optional bool revert = 4;

    // Total number of the audio route
    optional int32 count = 5;

    // Average time from the audio route start to complete
    optional int32 average_latency_ms = 6;
}

/**
 * Pulled atom to capture stats of Telecom API usage
 * From frameworks/proto_logging/stats/atoms/telecomm/telecom_extension_atom.proto
 */
message TelecomApiStats {
    // The value should be converted to android.telecom.ApiNameEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 api_name = 1;

    // UID of the caller. This is always -1/unknown for the private space.
    optional int32 uid = 2;

    // The value should be converted to android.telecom.ApiResultEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 api_result = 3;

    // The number of times this event occurs
    optional int32 count = 4;
}

/**
 * Pulled atom to capture stats of Telecom module errors
 * From frameworks/proto_logging/stats/atoms/telecomm/telecom_extension_atom.proto
 */
message TelecomErrorStats {
    // The value should be converted to android.telecom.SubmoduleNameEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 submodule_name = 1;

    // The value should be converted to android.telecom.ErrorNameEnum
    // From frameworks/proto_logging/stats/enums/telecomm/enums.proto
    optional int32 error_name = 2;

    // The number of times this error occurs
    optional int32 count = 3;
}
+7 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ public class AudioRoute {
    private @AudioRouteType int mAudioRouteType;
    private String mBluetoothAddress;
    private AudioDeviceInfo mInfo;
    private boolean mIsDestRouteForWatch;
    public static final Set<Integer> BT_AUDIO_DEVICE_INFO_TYPES = Set.of(
            AudioDeviceInfo.TYPE_BLE_HEADSET,
            AudioDeviceInfo.TYPE_BLE_SPEAKER,
@@ -241,6 +242,10 @@ public class AudioRoute {
        return mAudioRouteType;
    }

    public boolean isWatch() {
        return mIsDestRouteForWatch;
    }

    String getBluetoothAddress() {
        return mBluetoothAddress;
    }
@@ -264,6 +269,8 @@ public class AudioRoute {
                        audioManager, bluetoothRouteManager);
                // Special handling for SCO case.
                if (mAudioRouteType == TYPE_BLUETOOTH_SCO) {
                    // Set whether the dest route is for the watch
                    mIsDestRouteForWatch = bluetoothRouteManager.isWatch(device);
                    // Check if the communication device was set for the device, even if
                    // BluetoothHeadset#connectAudio reports that the SCO connection wasn't
                    // successfully established.
+0 −2
Original line number Diff line number Diff line
@@ -1980,7 +1980,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                PhoneAccount.EXTRA_LOG_SELF_MANAGED_CALLS, false);
    }

    @VisibleForTesting
    public boolean isIncoming() {
        return mCallDirection == CALL_DIRECTION_INCOMING;
    }
@@ -2272,7 +2271,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     * @return The "age" of this call object in milliseconds, which typically also represents the
     *     period since this call was added to the set pending outgoing calls.
     */
    @VisibleForTesting
    public long getAgeMillis() {
        if (mState == CallState.DISCONNECTED &&
                (mDisconnectCause.getCode() == DisconnectCause.REJECTED ||
Loading