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

Commit 8f82d513 authored by Kiwon Park's avatar Kiwon Park
Browse files

Add anomaly reports when there are too many concurrent calls at the start of voice calls.

Bug: 184961070
Test: m
Change-Id: I1fb5928abe227b7279d9d981d72b1bfe7fc18f9f
parent d0e84608
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.os.SystemClock;
import android.telecom.VideoProfile;
import android.telecom.VideoProfile.VideoState;
import android.telephony.Annotation.NetworkType;
import android.telephony.AnomalyReporter;
import android.telephony.DisconnectCause;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
@@ -83,6 +84,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

/** Collects voice call events per phone ID for the pulled atom. */
@@ -131,6 +133,13 @@ public class VoiceCallSessionStats {
    /** Holds call duration buckets with values as their upper bounds in milliseconds. */
    private static final SparseIntArray CALL_DURATION_MAP = buildCallDurationMap();

    /** UUID for reporting concurrent call anomaly */
    private static final UUID CONCURRENT_CALL_ANOMALY_UUID =
            UUID.fromString("76780b5a-623e-48a4-be3f-925e05177c9c");

    /** If the number of concurrent calls exceeds this number, report anomaly*/
    private static final int MAX_NORMAL_CONCURRENT_CALLS = 3;

    /**
     * Tracks statistics for each call connection, indexed with ID returned by {@link
     * #getConnectionId}.
@@ -456,6 +465,10 @@ public class VoiceCallSessionStats {
        }

        proto.concurrentCallCountAtStart = mCallProtos.size();
        if (proto.concurrentCallCountAtStart > MAX_NORMAL_CONCURRENT_CALLS) {
            AnomalyReporter.reportAnomaly(
                    CONCURRENT_CALL_ANOMALY_UUID, "Anomalous number of concurrent calls");
        }
        mCallProtos.put(id, proto);

        // RAT call count needs to be updated