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

Commit 96dbf8e5 authored by Tom Taylor's avatar Tom Taylor
Browse files

Add the messageId to TelephonyMetrics

Bug: 135755360

Test: manually tested sending and receiving sms's and mms's
Change-Id: Ice718fefbd085226d63bf1fde2c3809bee37e163
parent fa836529
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2605,6 +2605,9 @@ message SmsSession {

    // Indicates if the incoming SMS was blocked
    optional bool blocked = 17;

    // Optional xMS message unique id
    optional int64 message_id = 18;
  }

  // Time when session has started, in minutes since epoch,
+3 −2
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.RemoteException;
import android.provider.Telephony.Sms.Intents;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.RegistrationManager;
@@ -41,6 +40,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.util.SMSDispatcherUtil;
import com.android.telephony.Rlog;

import java.util.HashMap;
import java.util.Map;
@@ -121,8 +121,9 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                    + " status=" + status + " reason=" + reason + " networkReasonCode="
                    + networkReasonCode);
            // TODO integrate networkReasonCode into IMS SMS metrics.
            mMetrics.writeOnImsServiceSmsSolicitedResponse(mPhone.getPhoneId(), status, reason);
            SmsTracker tracker = mTrackers.get(token);
            mMetrics.writeOnImsServiceSmsSolicitedResponse(mPhone.getPhoneId(), status, reason,
                    (tracker != null ? tracker.mMessageId : 0L));
            if (tracker == null) {
                throw new IllegalArgumentException("Invalid token.");
            }
+5 −4
Original line number Diff line number Diff line
@@ -941,7 +941,7 @@ public abstract class InboundSmsHandler extends StateMachine {
        String format = tracker.getFormat();
        if (!isWapPush) {
            mMetrics.writeIncomingSmsSession(mPhone.getPhoneId(), mLastSmsWasInjected,
                    format, timestamps, block);
                    format, timestamps, block, tracker.getMessageId());
        }

        // Do not process null pdu(s). Check for that and return false in that case.
@@ -968,7 +968,8 @@ public abstract class InboundSmsHandler extends StateMachine {
                                + " id: "
                                + tracker.getMessageId());
                        mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                                SmsConstants.FORMAT_3GPP, timestamps, false);
                                SmsConstants.FORMAT_3GPP, timestamps, false,
                                tracker.getMessageId());
                        return false;
                    }
                }
@@ -994,10 +995,10 @@ public abstract class InboundSmsHandler extends StateMachine {
            // needs to be ignored, so treating it as a success case.
            if (result == Activity.RESULT_OK || result == Intents.RESULT_SMS_HANDLED) {
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                        format, timestamps, true);
                        format, timestamps, true, tracker.getMessageId());
            } else {
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                        format, timestamps, false);
                        format, timestamps, false, tracker.getMessageId());
            }
            // result is Activity.RESULT_OK if an ordered broadcast was sent
            if (result == Activity.RESULT_OK) {
+6 −0
Original line number Diff line number Diff line
@@ -116,4 +116,10 @@ public class SmsSessionEventBuilder {
        mEvent.smsType = type;
        return this;
    }

    /** Set message id */
    public SmsSessionEventBuilder setMessageId(long messageId) {
        mEvent.messageId = messageId;
        return this;
    }
}
+18 −9
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import android.telephony.AccessNetworkConstants;
import android.telephony.CallQuality;
import android.telephony.DisconnectCause;
import android.telephony.NetworkRegistrationInfo;
import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
@@ -113,6 +112,7 @@ import com.android.internal.telephony.nano.TelephonyProto.TimeInterval;
import com.android.internal.telephony.protobuf.nano.MessageNano;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.telephony.Rlog;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -1838,9 +1838,11 @@ public class TelephonyMetrics {
     *
     * @param phoneId Phone id
     * @param errorReason Defined in {@link SmsManager} RESULT_XXX.
     * @param messageId Unique id for this message.
     */
    public synchronized void writeOnImsServiceSmsSolicitedResponse(int phoneId,
            @ImsSmsImplBase.SendStatusResult int resultCode, int errorReason) {
            @ImsSmsImplBase.SendStatusResult int resultCode, int errorReason,
            long messageId) {

        InProgressSmsSession smsSession = mInProgressSmsSessions.get(phoneId);
        if (smsSession == null) {
@@ -1851,6 +1853,7 @@ public class TelephonyMetrics {
                    SmsSession.Event.Type.SMS_SEND_RESULT)
                    .setImsServiceErrno(resultCode)
                    .setErrorCode(errorReason)
                    .setMessageId((messageId))
            );

            smsSession.decreaseExpectedResponse();
@@ -2398,13 +2401,16 @@ public class TelephonyMetrics {
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @param blocked indicates if the message was blocked or not.
     * @param success Indicates if the SMS-PP was successfully delivered to the USIM.
     * @param messageId Unique id for this message.
     */
    private void writeIncomingSmsSessionWithType(int phoneId, int type, boolean smsOverIms,
            String format, long[] timestamps, boolean blocked, boolean success) {
            String format, long[] timestamps, boolean blocked, boolean success,
            long messageId) {
        logv("Logged SMS session consisting of " + timestamps.length
                + " parts, over IMS = " + smsOverIms
                + " blocked = " + blocked
                + " type = " + type);
                + " type = " + type
                + " messageId = " + messageId);

        InProgressSmsSession smsSession = startNewSmsSession(phoneId);
        for (long time : timestamps) {
@@ -2416,7 +2422,8 @@ public class TelephonyMetrics {
                        .setErrorCode(success ? SmsManager.RESULT_ERROR_NONE :
                            SmsManager.RESULT_ERROR_GENERIC_FAILURE)
                        .setSmsType(type)
                        .setBlocked(blocked);
                        .setBlocked(blocked)
                        .setMessageId(messageId);
            smsSession.addEvent(time, eventBuilder);
        }
        finishSmsSession(smsSession);
@@ -2430,11 +2437,12 @@ public class TelephonyMetrics {
     * @param format SMS format. Either 3GPP or 3GPP2.
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @param success Indicates if the SMS-PP was successfully delivered to the USIM.
     * @param messageId Unique id for this message.
     */
    public void writeIncomingWapPush(int phoneId, boolean smsOverIms, String format,
            long[] timestamps, boolean success) {
            long[] timestamps, boolean success, long messageId) {
        writeIncomingSmsSessionWithType(phoneId, SmsSession.Event.SmsType.SMS_TYPE_WAP_PUSH,
                smsOverIms, format, timestamps, false, success);
                smsOverIms, format, timestamps, false, success, messageId);
    }

    /**
@@ -2445,11 +2453,12 @@ public class TelephonyMetrics {
     * @param format SMS format. Either 3GPP or 3GPP2.
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @param blocked indicates if the message was blocked or not.
     * @param messageId Unique id for this message.
     */
    public void writeIncomingSmsSession(int phoneId, boolean smsOverIms, String format,
            long[] timestamps, boolean blocked) {
            long[] timestamps, boolean blocked, long messageId) {
        writeIncomingSmsSessionWithType(phoneId, SmsSession.Event.SmsType.SMS_TYPE_NORMAL,
                smsOverIms, format, timestamps, blocked, true);
                smsOverIms, format, timestamps, blocked, true, messageId);
    }

    /**