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

Commit aa7ab6a6 authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "Add pdu_length field into related atoms" into main

parents e0f7674c f73d22b2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -381,6 +381,7 @@ message OutgoingSms {
    optional bool is_ntn = 20;
    optional bool is_mt_sms_polling = 21;
    optional bool is_nb_iot_ntn = 22;
    optional int32 pdu_length = 23;

    // Internal use only
    optional int32 hashCode = 10001;
+4 −2
Original line number Diff line number Diff line
@@ -249,7 +249,8 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval(),
                        mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                        tracker.isMtSmsPollingMessage(mContext));
                        tracker.isMtSmsPollingMessage(mContext),
                        tracker.getPduLength());
                if (mPhone != null) {
                    TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                    if (telephonyAnalytics != null) {
@@ -668,7 +669,8 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                    tracker.isFromDefaultSmsApplication(mContext),
                    tracker.getInterval(),
                    mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                    tracker.isMtSmsPollingMessage(mContext));
                    tracker.isMtSmsPollingMessage(mContext),
                    tracker.getPduLength());
            if (mPhone != null) {
                TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                if (telephonyAnalytics != null) {
+28 −5
Original line number Diff line number Diff line
@@ -1144,7 +1144,8 @@ public abstract class SMSDispatcher extends Handler {
                    tracker.isFromDefaultSmsApplication(mContext),
                    tracker.getInterval(),
                    mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                    tracker.isMtSmsPollingMessage(mContext));
                    tracker.isMtSmsPollingMessage(mContext),
                    tracker.getPduLength());
            if (mPhone != null) {
                TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                if (telephonyAnalytics != null) {
@@ -1206,7 +1207,8 @@ public abstract class SMSDispatcher extends Handler {
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval(),
                        mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                        tracker.isMtSmsPollingMessage(mContext));
                        tracker.isMtSmsPollingMessage(mContext),
                        tracker.getPduLength());
                if (mPhone != null) {
                    TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                    if (telephonyAnalytics != null) {
@@ -1244,7 +1246,8 @@ public abstract class SMSDispatcher extends Handler {
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval(),
                        mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                        tracker.isMtSmsPollingMessage(mContext));
                        tracker.isMtSmsPollingMessage(mContext),
                        tracker.getPduLength());
                if (mPhone != null) {
                    TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                    if (telephonyAnalytics != null) {
@@ -1272,7 +1275,8 @@ public abstract class SMSDispatcher extends Handler {
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval(),
                        mTelephonyManager.isEmergencyNumber(tracker.mDestAddress),
                        tracker.isMtSmsPollingMessage(mContext));
                        tracker.isMtSmsPollingMessage(mContext),
                        tracker.getPduLength());
                if (mPhone != null) {
                    TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                    if (telephonyAnalytics != null) {
@@ -2544,7 +2548,8 @@ public abstract class SMSDispatcher extends Handler {
                    trackers[0].isFromDefaultSmsApplication(mContext),
                    trackers[0].getInterval(),
                    mTelephonyManager.isEmergencyNumber(trackers[0].mDestAddress),
                    trackers[0].isMtSmsPollingMessage(mContext));
                    trackers[0].isMtSmsPollingMessage(mContext),
                    trackers[0].getPduLength());
            if (mPhone != null) {
                TelephonyAnalytics telephonyAnalytics = mPhone.getTelephonyAnalytics();
                if (telephonyAnalytics != null) {
@@ -2745,6 +2750,24 @@ public abstract class SMSDispatcher extends Handler {
            return mFullMessageText.equals(mtSmsPollingText);
        }

        /**
         * Returns the length of the PDU in bytes for this tracker, if available.
         * This value is expected to be populated in the {@code mData} map during tracker creation
         * after the PDU has been generated.
         *
         * @return The PDU length in bytes, or 0 if the length is not available or invalid.
         */
        public int getPduLength() {
            if (mData == null) {
                return 0;
            }
            byte[] encodedPdu =  (byte[]) mData.get(MAP_KEY_PDU);
            if (encodedPdu == null) {
                return 0;
            }
            return encodedPdu.length;
        }

        /**
         * Update the status of this message if we persisted it
         */
+2 −1
Original line number Diff line number Diff line
@@ -1203,7 +1203,8 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
                sms.isEmergency,
                sms.isNtn,
                sms.isMtSmsPolling,
                sms.isNbIotNtn);
                sms.isNbIotNtn,
                sms.pduLength);
    }

    private static StatsEvent buildStatsEvent(DataCallSession dataCallSession) {
+9 −6
Original line number Diff line number Diff line
@@ -160,19 +160,20 @@ public class SmsStats {
    /** Create a new atom when an outgoing SMS is sent. */
    public void onOutgoingSms(boolean isOverIms, boolean is3gpp2, boolean fallbackToCs,
            @SmsManager.Result int sendErrorCode, long messageId, boolean isFromDefaultApp,
            long intervalMillis, boolean isEmergency, boolean isMtSmsPolling) {
            long intervalMillis, boolean isEmergency, boolean isMtSmsPolling, int pduLength) {
        onOutgoingSms(isOverIms, is3gpp2, fallbackToCs, sendErrorCode, NO_ERROR_CODE,
                messageId, isFromDefaultApp, intervalMillis, isEmergency, isMtSmsPolling);
                messageId, isFromDefaultApp, intervalMillis, isEmergency, isMtSmsPolling,
                pduLength);
    }

    /** Create a new atom when an outgoing SMS is sent. */
    public void onOutgoingSms(boolean isOverIms, boolean is3gpp2, boolean fallbackToCs,
            @SmsManager.Result int sendErrorCode, int networkErrorCode, long messageId,
            boolean isFromDefaultApp, long intervalMillis, boolean isEmergency,
            boolean isMtSmsPolling) {
            boolean isMtSmsPolling, int pduLength) {
        OutgoingSms proto =
                getOutgoingDefaultProto(is3gpp2, isOverIms, messageId, isFromDefaultApp,
                        intervalMillis, isEmergency, isMtSmsPolling);
                        intervalMillis, isEmergency, isMtSmsPolling, pduLength);

        // The field errorCode is used for up-to-Android-13 devices. From Android 14, sendErrorCode
        // and networkErrorCode will be used. The field errorCode will be deprecated when most
@@ -250,7 +251,7 @@ public class SmsStats {
    /** Create a proto for a normal {@code OutgoingSms} with default values. */
    private OutgoingSms getOutgoingDefaultProto(boolean is3gpp2, boolean isOverIms,
            long messageId, boolean isFromDefaultApp, long intervalMillis, boolean isEmergency,
            boolean isMtSmsPolling) {
            boolean isMtSmsPolling, int pduLength) {
        OutgoingSms proto = new OutgoingSms();
        proto.smsFormat = getSmsFormat(is3gpp2);
        proto.smsTech = getSmsTech(isOverIms, is3gpp2);
@@ -275,6 +276,7 @@ public class SmsStats {
        proto.isNtn = isNonTerrestrialNetwork();
        proto.isMtSmsPolling = isMtSmsPolling;
        proto.isNbIotNtn = isNbIotNtn(mPhone);
        proto.pduLength = pduLength;
        return proto;
    }

@@ -348,7 +350,8 @@ public class SmsStats {
    static int getSmsHashCode(OutgoingSms sms) {
        return Objects.hash(sms.smsFormat, sms.smsTech, sms.rat, sms.sendResult, sms.errorCode,
                sms.isRoaming, sms.isFromDefaultApp, sms.simSlotIndex, sms.isMultiSim, sms.isEsim,
                sms.carrierId, sms.isEmergency, sms.isNtn, sms.isMtSmsPolling, sms.isNbIotNtn);
                sms.carrierId, sms.isEmergency, sms.isNtn, sms.isMtSmsPolling, sms.isNbIotNtn,
                sms.pduLength);
    }

    /**