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

Commit cc97221c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add SMS latency to metrics" into tm-dev

parents c54fadb9 11a53636
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -261,6 +261,7 @@ message OutgoingSms {
    optional int32 carrier_id = 11;
    optional int64 message_id = 12;
    optional int32 retry_id = 13;
    optional int64 interval_millis = 14;
}

message CarrierIdMismatch {
+4 −2
Original line number Diff line number Diff line
@@ -194,7 +194,8 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                        status == ImsSmsImplBase.SEND_STATUS_ERROR_FALLBACK,
                        reason,
                        tracker.mMessageId,
                        tracker.isFromDefaultSmsApplication(mContext));
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval());
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
@@ -471,7 +472,8 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                    true /* fallbackToCs */,
                    SmsManager.RESULT_SYSTEM_ERROR,
                    tracker.mMessageId,
                    tracker.isFromDefaultSmsApplication(mContext));
                    tracker.isFromDefaultSmsApplication(mContext),
                    tracker.getInterval());
        }
    }

+21 −6
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Telephony;
@@ -902,7 +903,8 @@ public abstract class SMSDispatcher extends Handler {
                    false /* fallbackToCs */,
                    SmsManager.RESULT_ERROR_NONE,
                    tracker.mMessageId,
                    tracker.isFromDefaultSmsApplication(mContext));
                    tracker.isFromDefaultSmsApplication(mContext),
                    tracker.getInterval());
        } else {
            if (DBG) {
                Rlog.d(TAG, "SMS send failed "
@@ -937,7 +939,8 @@ public abstract class SMSDispatcher extends Handler {
                        false /* fallbackToCs */,
                        getNotInServiceError(ss),
                        tracker.mMessageId,
                        tracker.isFromDefaultSmsApplication(mContext));
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval());
            } else if (error == SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY
                    && tracker.mRetryCount < MAX_SEND_RETRIES) {
                // Retry after a delay if needed.
@@ -959,7 +962,8 @@ public abstract class SMSDispatcher extends Handler {
                        SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY,
                        errorCode,
                        tracker.mMessageId,
                        tracker.isFromDefaultSmsApplication(mContext));
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval());
            } else {
                int errorCode = (smsResponse != null) ? smsResponse.mErrorCode : NO_ERROR_CODE;
                tracker.onFailed(mContext, error, errorCode);
@@ -970,7 +974,8 @@ public abstract class SMSDispatcher extends Handler {
                        error,
                        errorCode,
                        tracker.mMessageId,
                        tracker.isFromDefaultSmsApplication(mContext));
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval());
            }
        }
    }
@@ -2007,7 +2012,8 @@ public abstract class SMSDispatcher extends Handler {
                    false /* fallbackToCs */,
                    error,
                    trackers[0].mMessageId,
                    trackers[0].isFromDefaultSmsApplication(mContext));
                    trackers[0].isFromDefaultSmsApplication(mContext),
                    trackers[0].getInterval());
        }
    }

@@ -2047,7 +2053,7 @@ public abstract class SMSDispatcher extends Handler {
        public final SmsHeader mSmsHeader;

        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
        private long mTimestamp = System.currentTimeMillis();
        private long mTimestamp = SystemClock.elapsedRealtime();
        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
        public Uri mMessageUri; // Uri of persisted message if we wrote one

@@ -2173,6 +2179,15 @@ public abstract class SMSDispatcher extends Handler {
            }
        }

        /**
         * Returns the interval in milliseconds between sending the message out and current time.
         * Called after receiving success/failure response to calculate the time
         * to complete the SMS send to the network.
         */
        protected long getInterval() {
            return SystemClock.elapsedRealtime() - mTimestamp;
        }

        /**
         * Persist a sent SMS if required:
         * 1. It is a text message
+2 −1
Original line number Diff line number Diff line
@@ -804,7 +804,8 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
                sms.isEsim,
                sms.carrierId,
                sms.messageId,
                sms.retryId);
                sms.retryId,
                sms.intervalMillis);
    }

    private static StatsEvent buildStatsEvent(DataCallSession dataCallSession) {
+8 −5
Original line number Diff line number Diff line
@@ -154,17 +154,19 @@ 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 errorCode, long messageId, boolean isFromDefaultApp) {
            @SmsManager.Result int errorCode, long messageId, boolean isFromDefaultApp,
            long intervalMillis) {
        onOutgoingSms(isOverIms, is3gpp2, fallbackToCs, errorCode, NO_ERROR_CODE,
                messageId, isFromDefaultApp);
                messageId, isFromDefaultApp, intervalMillis);
    }

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

        if (isOverIms) {
            // Populate error code and result for IMS case
@@ -217,7 +219,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 messageId, boolean isFromDefaultApp, long intervalMillis) {
        OutgoingSms proto = new OutgoingSms();
        proto.smsFormat = getSmsFormat(is3gpp2);
        proto.smsTech = getSmsTech(isOverIms, is3gpp2);
@@ -235,6 +237,7 @@ public class SmsStats {
        // Setting the retry ID to zero. If needed, it will be incremented when the atom is added
        // in the persistent storage.
        proto.retryId = 0;
        proto.intervalMillis = intervalMillis;
        return proto;
    }