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

Commit 3fdfb5f1 authored by Chi Zhang's avatar Chi Zhang
Browse files

Log telephony atoms to statsd.

The actual puller and registration have been stubbed due to missing Java
puller support in statsd, and will be added once it becomes available.

Test: atest FrameworksTelephonyTests
Bug: 146066107
Bug: 141631489
Bug: 122371089
Bug: 149880090
Bug: 127666858
Bug: 142026991
Bug: 155097675
Bug: 158014276

Merged-In: I399a76bb0b1a5da53488f3ed05108d4eb7c8839a
Merged-In: Ied6a928550d1894a0595e7ef7d5e1ef35ebbfd87
Change-Id: I55d50b86d87ec269ccec20ed88c556f5d793952d
parent 0ea366ae
Loading
Loading
Loading
Loading
+84 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package telephonyStatsLog;

option java_package = "com.android.internal.telephony";
option java_outer_classname = "PersistAtomsProto";

// Holds atoms to store on persist storage in case of power cycle or process crash.
// NOTE: using int64 rather than google.protobuf.Timestamp for timestamps simplifies implementation.
// Next id: 5
message PersistAtoms {
    /* Aggregated RAT usage during the call. */
    repeated RawVoiceCallRatUsage raw_voice_call_rat_usage = 1;

    /* Timestamp of last voice_call_rat_usages pull. */
    optional int64 raw_voice_call_rat_usage_pull_timestamp_millis = 2;

    /* Per call statistics and information. */
    repeated VoiceCallSession voice_call_session = 3;

    /* Timestamp of last voice_call_sessions pull. */
    optional int64 voice_call_session_pull_timestamp_millis = 4;
}

// The canonical versions of the following enums live in:
//   frameworks/base/core/proto/android/telephony/enums.proto
// The canonical versions of the following atoms live in:
//   frameworks/base/cmds/statsd/src/atoms.proto
// We cannot link against framework's and statsd's protolite libraries as it is "for test only".
// NOTE: StatsLog functions use int in place of enum

message VoiceCallSession {
    optional int32 bearer_at_start = 1;
    optional int32 bearer_at_end = 2;
    optional int32 direction = 3;
    optional int32 setup_duration = 4;
    optional bool setup_failed = 5;
    optional int32 disconnect_reason_code = 6;
    optional int32 disconnect_extra_code = 7;
    optional string disconnect_extra_message = 8;
    optional int32 rat_at_start = 9;
    optional int32 rat_at_end = 10;
    optional int64 rat_switch_count = 11;
    optional int64 codec_bitmask = 12;
    optional int32 concurrent_call_count_at_start = 13;
    optional int32 concurrent_call_count_at_end = 14;
    optional int32 sim_slot_index = 15;
    optional bool is_multi_sim = 16;
    optional bool is_esim = 17;
    optional int32 carrier_id = 18;
    optional bool srvcc_completed = 19;
    optional int64 srvcc_failure_count = 20;
    optional int64 srvcc_cancellation_count = 21;
    optional bool rtt_enabled = 22;
    optional bool is_emergency = 23;
    optional bool is_roaming = 24;

    // Internal use only
    optional int64 setup_begin_millis = 10001;
}

// Internal use only
message RawVoiceCallRatUsage {
    optional int32 carrier_id = 1;
    optional int32 rat = 2;
    optional int64 total_duration_millis = 3;
    optional int64 call_count = 4;
}
+6 −1
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ public class GsmCdmaCallTracker extends CallTracker {
            // This is a hack to delay DIAL so that it is sent out to RIL only after
            // EVENT_SWITCH_RESULT is received. We've seen failures when adding a new call to
            // multi-way conference calls due to DIAL being sent out before SWITCH is processed
            // TODO: setup duration metrics won't capture this
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
@@ -328,7 +329,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        }
        mHangupPendingMO = false;
        mMetrics.writeRilDial(mPhone.getPhoneId(), mPendingMO, clirMode, uusInfo);

        mPhone.getVoiceCallSessionStats().onRilDial(mPendingMO);

        if ( mPendingMO.getAddress() == null || mPendingMO.getAddress().length() == 0
                || mPendingMO.getAddress().indexOf(PhoneNumberUtils.WILD) >= 0) {
@@ -551,6 +552,7 @@ public class GsmCdmaCallTracker extends CallTracker {
            Rlog.i("phone", "acceptCall: incoming...");
            // Always unmute when answering a new call
            setMute(false);
            mPhone.getVoiceCallSessionStats().onRilAcceptCall(mRingingCall.getConnections());
            mCi.acceptCall(obtainCompleteMessage());
        } else if (mRingingCall.getState() == GsmCdmaCall.State.WAITING) {
            if (isPhoneTypeGsm()) {
@@ -1084,6 +1086,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        if (locallyDisconnectedConnections.size() > 0) {
            mMetrics.writeRilCallList(mPhone.getPhoneId(), locallyDisconnectedConnections,
                    getNetworkCountryIso());
            mPhone.getVoiceCallSessionStats().onRilCallListChanged(locallyDisconnectedConnections);
        }

        /* Disconnect any pending Handover connections */
@@ -1155,6 +1158,7 @@ public class GsmCdmaCallTracker extends CallTracker {
            if (conn != null) activeConnections.add(conn);
        }
        mMetrics.writeRilCallList(mPhone.getPhoneId(), activeConnections, getNetworkCountryIso());
        mPhone.getVoiceCallSessionStats().onRilCallListChanged(activeConnections);
    }

    private void handleRadioNotAvailable() {
@@ -1574,6 +1578,7 @@ public class GsmCdmaCallTracker extends CallTracker {
                mPhone.notifyPreciseCallStateChanged();
                mMetrics.writeRilCallList(mPhone.getPhoneId(), mDroppedDuringPoll,
                        getNetworkCountryIso());
                mPhone.getVoiceCallSessionStats().onRilCallListChanged(mDroppedDuringPoll);
                mDroppedDuringPoll.clear();
            break;

+1 −0
Original line number Diff line number Diff line
@@ -674,6 +674,7 @@ public class GsmCdmaConnection extends Connection {
        if (dc.audioQuality != mAudioCodec) {
            mAudioCodec = dc.audioQuality;
            mMetrics.writeAudioCodecGsmCdma(mOwner.getPhone().getPhoneId(), dc.audioQuality);
            mOwner.getPhone().getVoiceCallSessionStats().onAudioCodecChanged(this, dc.audioQuality);
        }

        // A null cnapName should be the same as ""
+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardStatus;
@@ -252,6 +253,7 @@ public class GsmCdmaPhone extends Phone {

        // phone type needs to be set before other initialization as other objects rely on it
        mPrecisePhoneType = precisePhoneType;
        mVoiceCallSessionStats = new VoiceCallSessionStats(mPhoneId, this);
        initOnce(ci);
        initRatSpecific(precisePhoneType);
        // CarrierSignalAgent uses CarrierActionAgent in construction so it needs to be created
+14 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.dataconnection.TransportManager;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccFileHandler;
@@ -425,6 +426,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    private final CarrierPrivilegesTracker mCarrierPrivilegesTracker;

    protected VoiceCallSessionStats mVoiceCallSessionStats;

    public IccRecords getIccRecords() {
        return mIccRecords.get();
    }
@@ -4276,6 +4279,17 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return "";
    }

    /** Returns the {@link VoiceCallSessionStats} for this phone ID. */
    public VoiceCallSessionStats getVoiceCallSessionStats() {
        return mVoiceCallSessionStats;
    }

    /** Sets the {@link VoiceCallSessionStats} mock for this phone ID during unit testing. */
    @VisibleForTesting
    public void setVoiceCallSessionStats(VoiceCallSessionStats voiceCallSessionStats) {
        mVoiceCallSessionStats = voiceCallSessionStats;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Phone: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
Loading