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

Commit fc07ef8a authored by Tom Taylor's avatar Tom Taylor Committed by Android (Google) Code Review
Browse files

Merge "Add the messageId to TelephonyMetrics"

parents 8ec8b549 96dbf8e5
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -2605,6 +2605,9 @@ message SmsSession {


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

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


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


import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Map;
@@ -121,8 +121,9 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                    + " status=" + status + " reason=" + reason + " networkReasonCode="
                    + " status=" + status + " reason=" + reason + " networkReasonCode="
                    + networkReasonCode);
                    + networkReasonCode);
            // TODO integrate networkReasonCode into IMS SMS metrics.
            // TODO integrate networkReasonCode into IMS SMS metrics.
            mMetrics.writeOnImsServiceSmsSolicitedResponse(mPhone.getPhoneId(), status, reason);
            SmsTracker tracker = mTrackers.get(token);
            SmsTracker tracker = mTrackers.get(token);
            mMetrics.writeOnImsServiceSmsSolicitedResponse(mPhone.getPhoneId(), status, reason,
                    (tracker != null ? tracker.mMessageId : 0L));
            if (tracker == null) {
            if (tracker == null) {
                throw new IllegalArgumentException("Invalid token.");
                throw new IllegalArgumentException("Invalid token.");
            }
            }
+5 −4
Original line number Original line Diff line number Diff line
@@ -942,7 +942,7 @@ public abstract class InboundSmsHandler extends StateMachine {
        String format = tracker.getFormat();
        String format = tracker.getFormat();
        if (!isWapPush) {
        if (!isWapPush) {
            mMetrics.writeIncomingSmsSession(mPhone.getPhoneId(), mLastSmsWasInjected,
            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.
        // Do not process null pdu(s). Check for that and return false in that case.
@@ -969,7 +969,8 @@ public abstract class InboundSmsHandler extends StateMachine {
                                + " id: "
                                + " id: "
                                + tracker.getMessageId());
                                + tracker.getMessageId());
                        mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                        mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                                SmsConstants.FORMAT_3GPP, timestamps, false);
                                SmsConstants.FORMAT_3GPP, timestamps, false,
                                tracker.getMessageId());
                        return false;
                        return false;
                    }
                    }
                }
                }
@@ -995,10 +996,10 @@ public abstract class InboundSmsHandler extends StateMachine {
            // needs to be ignored, so treating it as a success case.
            // needs to be ignored, so treating it as a success case.
            if (result == Activity.RESULT_OK || result == Intents.RESULT_SMS_HANDLED) {
            if (result == Activity.RESULT_OK || result == Intents.RESULT_SMS_HANDLED) {
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                        format, timestamps, true);
                        format, timestamps, true, tracker.getMessageId());
            } else {
            } else {
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                mMetrics.writeIncomingWapPush(mPhone.getPhoneId(), mLastSmsWasInjected,
                        format, timestamps, false);
                        format, timestamps, false, tracker.getMessageId());
            }
            }
            // result is Activity.RESULT_OK if an ordered broadcast was sent
            // result is Activity.RESULT_OK if an ordered broadcast was sent
            if (result == Activity.RESULT_OK) {
            if (result == Activity.RESULT_OK) {
+6 −0
Original line number Original line Diff line number Diff line
@@ -116,4 +116,10 @@ public class SmsSessionEventBuilder {
        mEvent.smsType = type;
        mEvent.smsType = type;
        return this;
        return this;
    }
    }

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


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -1838,9 +1838,11 @@ public class TelephonyMetrics {
     *
     *
     * @param phoneId Phone id
     * @param phoneId Phone id
     * @param errorReason Defined in {@link SmsManager} RESULT_XXX.
     * @param errorReason Defined in {@link SmsManager} RESULT_XXX.
     * @param messageId Unique id for this message.
     */
     */
    public synchronized void writeOnImsServiceSmsSolicitedResponse(int phoneId,
    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);
        InProgressSmsSession smsSession = mInProgressSmsSessions.get(phoneId);
        if (smsSession == null) {
        if (smsSession == null) {
@@ -1851,6 +1853,7 @@ public class TelephonyMetrics {
                    SmsSession.Event.Type.SMS_SEND_RESULT)
                    SmsSession.Event.Type.SMS_SEND_RESULT)
                    .setImsServiceErrno(resultCode)
                    .setImsServiceErrno(resultCode)
                    .setErrorCode(errorReason)
                    .setErrorCode(errorReason)
                    .setMessageId((messageId))
            );
            );


            smsSession.decreaseExpectedResponse();
            smsSession.decreaseExpectedResponse();
@@ -2398,13 +2401,16 @@ public class TelephonyMetrics {
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @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 blocked indicates if the message was blocked or not.
     * @param success Indicates if the SMS-PP was successfully delivered to the USIM.
     * @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,
    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
        logv("Logged SMS session consisting of " + timestamps.length
                + " parts, over IMS = " + smsOverIms
                + " parts, over IMS = " + smsOverIms
                + " blocked = " + blocked
                + " blocked = " + blocked
                + " type = " + type);
                + " type = " + type
                + " messageId = " + messageId);


        InProgressSmsSession smsSession = startNewSmsSession(phoneId);
        InProgressSmsSession smsSession = startNewSmsSession(phoneId);
        for (long time : timestamps) {
        for (long time : timestamps) {
@@ -2416,7 +2422,8 @@ public class TelephonyMetrics {
                        .setErrorCode(success ? SmsManager.RESULT_ERROR_NONE :
                        .setErrorCode(success ? SmsManager.RESULT_ERROR_NONE :
                            SmsManager.RESULT_ERROR_GENERIC_FAILURE)
                            SmsManager.RESULT_ERROR_GENERIC_FAILURE)
                        .setSmsType(type)
                        .setSmsType(type)
                        .setBlocked(blocked);
                        .setBlocked(blocked)
                        .setMessageId(messageId);
            smsSession.addEvent(time, eventBuilder);
            smsSession.addEvent(time, eventBuilder);
        }
        }
        finishSmsSession(smsSession);
        finishSmsSession(smsSession);
@@ -2430,11 +2437,12 @@ public class TelephonyMetrics {
     * @param format SMS format. Either 3GPP or 3GPP2.
     * @param format SMS format. Either 3GPP or 3GPP2.
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @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 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,
    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,
        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 format SMS format. Either 3GPP or 3GPP2.
     * @param timestamps array with timestamps of each incoming SMS part. It contains a single
     * @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 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,
    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,
        writeIncomingSmsSessionWithType(phoneId, SmsSession.Event.SmsType.SMS_TYPE_NORMAL,
                smsOverIms, format, timestamps, blocked, true);
                smsOverIms, format, timestamps, blocked, true, messageId);
    }
    }


    /**
    /**