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

Commit 62d74c08 authored by Kiwon Park's avatar Kiwon Park Committed by Automerger Merge Worker
Browse files

Merge "Split addCall() in VoiceCallSessionStats into addCall() and...

Merge "Split addCall() in VoiceCallSessionStats into addCall() and acceptCall() for readability" am: f97c67e9

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1961242

Change-Id: I1a84602258f0759e7a72e5154c69cd08e3822075
parents 7efe1ad5 f97c67e9
Loading
Loading
Loading
Loading
+82 −66
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public class VoiceCallSessionStats {
    /** Updates internal states when previous CS calls are accepted to track MT call setup time. */
    public synchronized void onRilAcceptCall(List<Connection> connections) {
        for (Connection conn : connections) {
            addCall(conn);
            acceptCall(conn);
        }
    }

@@ -174,7 +174,10 @@ public class VoiceCallSessionStats {
                    addCall(conn);
                    checkCallSetup(conn, mCallProtos.get(id));
                } else {
                    logd("onRilCallListChanged: skip adding disconnected connection");
                    logd(
                            "onRilCallListChanged: skip adding disconnected connection,"
                                    + " connectionId=%d",
                            id);
                }
            } else {
                VoiceCallSession proto = mCallProtos.get(id);
@@ -215,7 +218,7 @@ public class VoiceCallSessionStats {
    /** Updates internal states when previous IMS calls are accepted to track MT call setup time. */
    public synchronized void onImsAcceptCall(List<Connection> connections) {
        for (Connection conn : connections) {
            addCall(conn);
            acceptCall(conn);
        }
    }

@@ -235,7 +238,7 @@ public class VoiceCallSessionStats {
            if (mCallProtos.contains(id)) {
                finishImsCall(id, reasonInfo);
            } else {
                loge("onImsCallTerminated: untracked connection");
                loge("onImsCallTerminated: untracked connection, connectionId=%d", id);
                // fake a call so at least some info can be tracked
                addCall(conn);
                finishImsCall(id, reasonInfo);
@@ -255,7 +258,7 @@ public class VoiceCallSessionStats {
        int id = getConnectionId(conn);
        VoiceCallSession proto = mCallProtos.get(id);
        if (proto == null) {
            loge("onAudioCodecChanged: untracked connection");
            loge("onAudioCodecChanged: untracked connection, connectionId=%d", id);
            return;
        }
        int codec = audioQualityToCodec(proto.bearerAtEnd, audioQuality);
@@ -276,10 +279,10 @@ public class VoiceCallSessionStats {
        int id = getConnectionId(conn);
        VoiceCallSession proto = mCallProtos.get(id);
        if (proto == null) {
            loge("onVideoStateChange: untracked connection");
            loge("onVideoStateChange: untracked connection, connectionId=%d", id);
            return;
        }
        logd("Video state = " + videoState);
        logd("onVideoStateChange: video state=%d, connectionId=%d", videoState, id);
        if (videoState != VideoProfile.STATE_AUDIO_ONLY) {
            proto.videoEnabled = true;
        }
@@ -290,10 +293,10 @@ public class VoiceCallSessionStats {
        int id = getConnectionId(conn);
        VoiceCallSession proto = mCallProtos.get(id);
        if (proto == null) {
            loge("onMultipartyChange: untracked connection");
            loge("onMultipartyChange: untracked connection, connectionId=%d", id);
            return;
        }
        logd("Multiparty = " + isMultiParty);
        logd("onMultipartyChange: isMultiparty=%b, connectionId=%d", isMultiParty, id);
        if (isMultiParty) {
            proto.isMultiparty = true;
        }
@@ -307,11 +310,12 @@ public class VoiceCallSessionStats {
     */
    public synchronized void onCallStateChanged(Call call) {
        for (Connection conn : call.getConnections()) {
            VoiceCallSession proto = mCallProtos.get(getConnectionId(conn));
            int id = getConnectionId(conn);
            VoiceCallSession proto = mCallProtos.get(id);
            if (proto != null) {
                checkCallSetup(conn, proto);
            } else {
                loge("onCallStateChanged: untracked connection");
                loge("onCallStateChanged: untracked connection, connectionId=%d", id);
            }
        }
    }
@@ -366,6 +370,19 @@ public class VoiceCallSessionStats {

    /* internal */

    /** Handles ringing MT call getting accepted. */
    private void acceptCall(Connection conn) {
        int id = getConnectionId(conn);
        if (mCallProtos.contains(id)) {
            logd("acceptCall: resetting setup info, connectionId=%d", id);
            VoiceCallSession proto = mCallProtos.get(id);
            proto.setupBeginMillis = getTimeMillis();
            proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_UNKNOWN;
        } else {
            loge("acceptCall: untracked connection, connectionId=%d", id);
        }
    }

    /**
     * Adds a call connection.
     *
@@ -375,12 +392,11 @@ public class VoiceCallSessionStats {
    private void addCall(Connection conn) {
        int id = getConnectionId(conn);
        if (mCallProtos.contains(id)) {
            // mostly handles ringing MT call getting accepted (MT call setup begins)
            logd("addCall: resetting setup info");
            VoiceCallSession proto = mCallProtos.get(id);
            proto.setupBeginMillis = getTimeMillis();
            proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_UNKNOWN;
        } else {
            loge(
                    "addCall: already tracked connection, connectionId=%d, connectionInfo=%s",
                    id, conn);
            return;
        }
        int bearer = getBearer(conn);
        ServiceState serviceState = getServiceState();
        @NetworkType int rat = ServiceStateStats.getVoiceRat(mPhone, serviceState);
@@ -427,13 +443,12 @@ public class VoiceCallSessionStats {
        // RAT call count needs to be updated
        updateRatTracker(serviceState);
    }
    }

    /** Sends the call metrics to persist storage when it is finished. */
    private void finishCall(int connectionId) {
        VoiceCallSession proto = mCallProtos.get(connectionId);
        if (proto == null) {
            loge("finishCall: could not find call to be removed");
            loge("finishCall: could not find call to be removed, connectionId=%d", connectionId);
            return;
        }
        mCallProtos.delete(connectionId);
@@ -469,14 +484,15 @@ public class VoiceCallSessionStats {
    }

    private void setRttStarted(ImsPhoneConnection conn) {
        VoiceCallSession proto = mCallProtos.get(getConnectionId(conn));
        int id = getConnectionId(conn);
        VoiceCallSession proto = mCallProtos.get(id);
        if (proto == null) {
            loge("onRttStarted: untracked connection");
            loge("onRttStarted: untracked connection, connectionId=%d", id);
            return;
        }
        // should be IMS w/o SRVCC
        if (proto.bearerAtStart != getBearer(conn) || proto.bearerAtEnd != getBearer(conn)) {
            loge("onRttStarted: connection bearer mismatch but proceeding");
            loge("onRttStarted: connection bearer mismatch but proceeding, connectionId=%d", id);
        }
        proto.rttEnabled = true;
    }