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

Commit c56bc7ee authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Log Telephony Event on receiving RIL_UNSOL_MODEM_RESTART"

parents f6c5adcd a254eeb4
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -4209,6 +4209,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        mMetrics.writeRilSrvcc(mPhoneId, state);
    }

    void writeMetricsModemRestartEvent(String reason) {
        mMetrics.writeModemRestartEvent(mPhoneId, reason);
    }

    /**
     * Notify all registrants that the ril has connected or disconnected.
@@ -4652,6 +4655,8 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                return "UNSOL_LCE_INFO_RECV";
            case RIL_UNSOL_PCO_DATA:
                return "UNSOL_PCO_DATA";
            case RIL_UNSOL_MODEM_RESTART:
                return "UNSOL_MODEM_RESTART";
            case RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION:
                return "RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION";
            default:
@@ -4939,5 +4944,4 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                signalStrength.tdScdma.rscp,
                false /* gsmFlag - don't care; will be changed by SST */);
    }

}
+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ENTER_EMERGE
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_HARDWARE_CONFIG_CHANGED;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_LCEDATA_RECV;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_MODEM_RESTART;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NITZ_TIME_RECEIVED;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_SS;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_USSD;
@@ -775,6 +776,10 @@ public class RadioIndication extends IRadioIndication.Stub {

    public void modemReset(int indicationType, String reason) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_MODEM_RESTART, reason);

        mRil.writeMetricsModemRestartEvent(reason);
    }

    /**
+9 −2
Original line number Diff line number Diff line
@@ -16,18 +16,19 @@

package com.android.internal.telephony.metrics;

import android.os.SystemClock;

import static com.android.internal.telephony.TelephonyProto.ImsCapabilities;
import static com.android.internal.telephony.TelephonyProto.ImsConnectionState;
import static com.android.internal.telephony.TelephonyProto.RilDataCall;
import static com.android.internal.telephony.TelephonyProto.TelephonyEvent;
import static com.android.internal.telephony.TelephonyProto.TelephonyEvent.ModemRestart;
import static com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilDeactivateDataCall;
import static com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilSetupDataCall;
import static com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilSetupDataCallResponse;
import static com.android.internal.telephony.TelephonyProto.TelephonyServiceState;
import static com.android.internal.telephony.TelephonyProto.TelephonySettings;

import android.os.SystemClock;

public class TelephonyEventBuilder {
    private final TelephonyEvent mEvent = new TelephonyEvent();

@@ -109,4 +110,10 @@ public class TelephonyEventBuilder {
        mEvent.setNitzTimestampMillis(timestamp);
        return this;
    }

    public TelephonyEventBuilder setModemRestart(ModemRestart modemRestart) {
        mEvent.setType(TelephonyEvent.Type.MODEM_RESTART);
        mEvent.modemRestart = modemRestart;
        return this;
    }
}
+38 −22
Original line number Diff line number Diff line
@@ -16,18 +16,36 @@

package com.android.internal.telephony.metrics;

import static android.text.format.DateUtils.MINUTE_IN_MILLIS;

import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ANSWER;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CDMA_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DEACTIVATE_DATA_CALL;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DIAL;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_IMS_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS_EXPECT_MORE;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SETUP_DATA_CALL;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IP;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IPV4V6;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IPV6;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_PPP;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_UNKNOWN;

import android.os.Build;
import android.os.SystemClock;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.TelephonyHistogram;
import android.util.Base64;
import android.util.Log;
import android.util.SparseArray;

import com.android.ims.ImsConfig;
import com.android.ims.ImsReasonInfo;
import com.android.ims.internal.ImsCallSession;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.GsmCdmaConnection;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RIL;
@@ -39,10 +57,11 @@ import com.android.internal.telephony.TelephonyProto.ImsConnectionState;
import com.android.internal.telephony.TelephonyProto.RilDataCall;
import com.android.internal.telephony.TelephonyProto.SmsSession;
import com.android.internal.telephony.TelephonyProto.TelephonyCallSession;
import com.android.internal.telephony.TelephonyProto.TelephonyCallSession.Event.CallState.*;
import com.android.internal.telephony.TelephonyProto.TelephonyCallSession.Event.RilCall;
import com.android.internal.telephony.TelephonyProto.TelephonyCallSession.Event.RilCall.Type.*;
import com.android.internal.telephony.TelephonyProto.TelephonyCallSession.Event.CallState.*;
import com.android.internal.telephony.TelephonyProto.TelephonyEvent;
import com.android.internal.telephony.TelephonyProto.TelephonyEvent.ModemRestart;
import com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilDeactivateDataCall;
import com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilSetupDataCall;
import com.android.internal.telephony.TelephonyProto.TelephonyEvent.RilSetupDataCallResponse;
@@ -63,25 +82,6 @@ import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

import static android.text.format.DateUtils.MINUTE_IN_MILLIS;

import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ANSWER;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CDMA_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DEACTIVATE_DATA_CALL;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DIAL;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_IMS_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS_EXPECT_MORE;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SETUP_DATA_CALL;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IP;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IPV4V6;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_IPV6;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_TYPE_PPP;
import static com.android.internal.telephony.TelephonyProto.PdpType.PDP_UNKNOWN;

/**
 * Telephony metrics holds all metrics events and convert it into telephony proto buf.
 * @hide
@@ -1627,6 +1627,22 @@ public class TelephonyMetrics {
                        .setNITZ(timestamp));
    }

    /**
     * Write Modem Restart event
     *
     * @param phoneId Phone id
     * @param reason Reason for the modem reset.
     */
    public void writeModemRestartEvent(int phoneId, String reason) {
        final ModemRestart modemRestart = new ModemRestart();
        String basebandVersion = Build.getRadioVersion();
        if (basebandVersion != null) modemRestart.setBasebandVersion(basebandVersion);
        if (reason != null) modemRestart.setReason(reason);
        TelephonyEvent event = new TelephonyEventBuilder(phoneId).setModemRestart(
                modemRestart).build();
        addTelephonyEvent(event);
    }

    //TODO: Expand the proto in the future
    public void writeOnImsCallProgressing(int phoneId, ImsCallSession session) {}
    public void writeOnImsCallStarted(int phoneId, ImsCallSession session) {}
+15 −1
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;

import android.support.test.filters.FlakyTest;
import android.telephony.ServiceState;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Base64;
@@ -166,6 +165,21 @@ public class TelephonyMetricsTest extends TelephonyTest {
        assertEquals(3, log.events[0].getDataStallAction());
    }

    // Test write modem restart event
    @Test
    @SmallTest
    public void testModemRestartEvent() throws Exception {
        mMetrics.writeModemRestartEvent(mPhone.getPhoneId(), "Test");
        TelephonyLog log = buildProto();

        assertEquals(1, log.events.length);
        assertEquals(0, log.callSessions.length);
        assertEquals(0, log.smsSessions.length);
        assertTrue(log.events[0].hasPhoneId());
        assertEquals(mPhone.getPhoneId(), log.events[0].getPhoneId());
        assertEquals("Test", log.events[0].modemRestart.getReason());
    }

    // Test write on IMS call start
    @Test
    @SmallTest