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

Commit c2db7e05 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge "Add Metrics for Data connected time"

parents 283b03b2 d54f3b84
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -619,6 +619,24 @@ message RilDataCall {

  // The network interface name e.g. wlan0, rmnet_data0.
  optional string iframe = 3;

  // State of the Data Call connection
  optional State state = 4;

  // Bitmask of APN types
  optional int32 apn_type_bitmask = 5;

  enum State {

    // Unknown event
    UNKNOWN = 0;

    // Connected event
    CONNECTED = 1;

    // Disconnected event
    DISCONNECTED = 2;
  }
}

message TelephonyEvent {
+5 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.dataconnection.DcTracker.ReleaseNetworkType;
import com.android.internal.telephony.dataconnection.DcTracker.RequestNetworkType;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.nano.TelephonyProto.RilDataCall;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Protocol;
@@ -1901,6 +1902,8 @@ public class DataConnection extends StateMachine {
                mPhone.mCi.registerForLceInfo(
                        getHandler(), DataConnection.EVENT_LINK_CAPACITY_CHANGED, null);
            }
            TelephonyMetrics.getInstance().writeRilDataCallEvent(mPhone.getPhoneId(),
                    mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.CONNECTED);
        }

        @Override
@@ -1928,6 +1931,8 @@ public class DataConnection extends StateMachine {
                mNetworkAgent.sendNetworkInfo(mNetworkInfo);
                mNetworkAgent = null;
            }
            TelephonyMetrics.getInstance().writeRilDataCallEvent(mPhone.getPhoneId(),
                    mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.DISCONNECTED);
        }

        @Override
+43 −16
Original line number Diff line number Diff line
@@ -199,6 +199,12 @@ public class TelephonyMetrics {
     */
    private final SparseArray<CarrierIdMatching> mLastCarrierId = new SparseArray<>();

    /**
     * Last RilDataCall Events (indexed by cid), indexed by phone id
     */
    private final SparseArray<SparseArray<RilDataCall>> mLastRilDataCallEvents =
            new SparseArray<>();

    /** The start system time of the TelephonyLog in milliseconds*/
    private long mStartSystemTimeMs;

@@ -607,6 +613,16 @@ public class TelephonyMetrics {
            addTelephonyEvent(event);
        }

        for (int i = 0; i < mLastRilDataCallEvents.size(); i++) {
            final int key = mLastRilDataCallEvents.keyAt(i);
            for (int j = 0; j < mLastRilDataCallEvents.get(key).size(); j++) {
                final int cidKey = mLastRilDataCallEvents.get(key).keyAt(j);
                RilDataCall[] dataCalls = new RilDataCall[1];
                dataCalls[0] = mLastRilDataCallEvents.get(key).get(cidKey);
                addTelephonyEvent(new TelephonyEventBuilder(mStartElapsedTimeMs, key)
                        .setDataCalls(dataCalls).build());
            }
        }
        addTelephonyEvent(new TelephonyEventBuilder(mStartElapsedTimeMs, -1 /* phoneId */)
                .setSimStateChange(mLastSimState).build());

@@ -1343,25 +1359,36 @@ public class TelephonyMetrics {
    }

    /**
     * Write get data call list event
     *
     * Write data call list event when connected
     * @param phoneId          Phone id
     * @param dcsList Data call list
     */
    public void writeRilDataCallList(int phoneId, ArrayList<DataCallResponse> dcsList) {

        RilDataCall[] dataCalls = new RilDataCall[dcsList.size()];

        for (int i = 0; i < dcsList.size(); i++) {
            dataCalls[i] = new RilDataCall();
            dataCalls[i].cid = dcsList.get(i).getCallId();
            if (!TextUtils.isEmpty(dcsList.get(i).getIfname())) {
                dataCalls[i].iframe = dcsList.get(i).getIfname();
     * @param cid              Context Id, uniquely identifies the call
     * @param apnTypeBitmask   Bitmask of supported APN types
     * @param state            State of the data call event
     */
    public void writeRilDataCallEvent(int phoneId, int cid,
            int apnTypeBitmask, int state) {
        RilDataCall[] dataCalls = new RilDataCall[1];
        dataCalls[0] = new RilDataCall();
        dataCalls[0].cid = cid;
        dataCalls[0].apnTypeBitmask = apnTypeBitmask;
        dataCalls[0].state = state;

        SparseArray<RilDataCall> dataCallList;
        if (mLastRilDataCallEvents.get(phoneId) != null) {
            // If the Data call event does not change, do not log it.
            if (mLastRilDataCallEvents.get(phoneId).get(cid) != null
                    && Arrays.equals(
                        RilDataCall.toByteArray(mLastRilDataCallEvents.get(phoneId).get(cid)),
                        RilDataCall.toByteArray(dataCalls[0]))) {
                return;
            }

            dataCalls[i].type = dcsList.get(i).getProtocolType() + 1;
            dataCallList =  mLastRilDataCallEvents.get(phoneId);
        } else {
            dataCallList = new SparseArray<>();
        }

        dataCallList.put(cid, dataCalls[0]);
        mLastRilDataCallEvents.put(phoneId, dataCallList);
        addTelephonyEvent(new TelephonyEventBuilder(phoneId).setDataCalls(dataCalls).build());
    }