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 Original line 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. */
    /** Updates internal states when previous CS calls are accepted to track MT call setup time. */
    public synchronized void onRilAcceptCall(List<Connection> connections) {
    public synchronized void onRilAcceptCall(List<Connection> connections) {
        for (Connection conn : connections) {
        for (Connection conn : connections) {
            addCall(conn);
            acceptCall(conn);
        }
        }
    }
    }


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


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


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


    /** Sends the call metrics to persist storage when it is finished. */
    /** Sends the call metrics to persist storage when it is finished. */
    private void finishCall(int connectionId) {
    private void finishCall(int connectionId) {
        VoiceCallSession proto = mCallProtos.get(connectionId);
        VoiceCallSession proto = mCallProtos.get(connectionId);
        if (proto == null) {
        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;
            return;
        }
        }
        mCallProtos.delete(connectionId);
        mCallProtos.delete(connectionId);
@@ -469,14 +484,15 @@ public class VoiceCallSessionStats {
    }
    }


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