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

Commit 12b6dddf authored by Arun Voddu's avatar Arun Voddu Committed by Android (Google) Code Review
Browse files

Merge "[Satellite] Enhanced the satellite metrics to record datagram count per...

Merge "[Satellite] Enhanced the satellite metrics to record datagram count per message type." into main
parents 259cbb5e 094320b9
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -753,6 +753,8 @@ public class DatagramDispatcher extends Handler {

    private void reportSendDatagramCompleted(@NonNull SendSatelliteDatagramArgument argument,
            @NonNull @SatelliteManager.SatelliteResult int resultCode) {
        long datagramTransmissionTime = argument.datagramStartTime > 0
                ? (System.currentTimeMillis() - argument.datagramStartTime) : 0;
        SatelliteStats.getInstance().onSatelliteOutgoingDatagramMetrics(
                new SatelliteStats.SatelliteOutgoingDatagramParams.Builder()
                        .setDatagramType(argument.datagramType)
@@ -760,15 +762,15 @@ public class DatagramDispatcher extends Handler {
                        .setDatagramSizeBytes(argument.getDatagramRoundedSizeBytes())
                        /* In case pending datagram has not been attempted to send to modem
                        interface. transfer time will be 0. */
                        .setDatagramTransferTimeMillis(argument.datagramStartTime > 0
                                ? (System.currentTimeMillis() - argument.datagramStartTime) : 0)
                        .setDatagramTransferTimeMillis(datagramTransmissionTime)
                        .setIsDemoMode(mIsDemoMode)
                        .setCarrierId(SatelliteController.getInstance().getSatelliteCarrierId())
                        .build());
        if (resultCode == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
            mControllerMetricsStats.reportOutgoingDatagramSuccessCount(argument.datagramType,
                    mIsDemoMode);
            mSessionMetricsStats.addCountOfSuccessfulOutgoingDatagram(argument.datagramType);
            mSessionMetricsStats.addCountOfSuccessfulOutgoingDatagram(argument.datagramType,
                    datagramTransmissionTime);
        } else {
            mControllerMetricsStats.reportOutgoingDatagramFailCount(argument.datagramType,
                    mIsDemoMode);
+15 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telephony.satellite.metrics;

import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID;
import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_NONE;
import static android.telephony.satellite.SatelliteManager.KEY_SESSION_STATS_V2;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;

import android.annotation.NonNull;
@@ -61,9 +62,11 @@ public class SessionMetricsStats {
    private int mCountOfSatelliteNotificationDisplayed;
    private int mCountOfAutoExitDueToScreenOff;
    private int mCountOfAutoExitDueToTnNetwork;
    private SatelliteSessionStats datagramStats;

    private SessionMetricsStats() {
        initializeSessionMetricsParam();
        datagramStats = new SatelliteSessionStats();
    }

    /**
@@ -128,7 +131,9 @@ public class SessionMetricsStats {

    /** Increase the count of successful outgoing datagram transmission. */
    public SessionMetricsStats addCountOfSuccessfulOutgoingDatagram(
            @NonNull @SatelliteManager.DatagramType int datagramType) {
            @NonNull @SatelliteManager.DatagramType int datagramType,
            long datagramTransmissionTime) {
        datagramStats.recordSuccessfulOutgoingDatagramStats(datagramType, datagramTransmissionTime);
        if (datagramType == SatelliteManager.DATAGRAM_TYPE_KEEP_ALIVE) {
            // Ignore KEEP_ALIVE messages
            return this;
@@ -145,6 +150,7 @@ public class SessionMetricsStats {
    public SessionMetricsStats addCountOfFailedOutgoingDatagram(
            @NonNull @SatelliteManager.DatagramType int datagramType,
            @NonNull @SatelliteManager.SatelliteResult int resultCode) {
        datagramStats.addCountOfUnsuccessfulUserMessages(datagramType, resultCode);
        if (datagramType == SatelliteManager.DATAGRAM_TYPE_KEEP_ALIVE) {
            // Ignore KEEP_ALIVE messages
            return this;
@@ -284,6 +290,7 @@ public class SessionMetricsStats {

    /** Returns {@link SatelliteSessionStats} of the satellite service. */
    public void requestSatelliteSessionStats(int subId, @NonNull ResultReceiver result) {
        Log.i(TAG, "requestSatelliteSessionStats called");
        Bundle bundle = new Bundle();
        SatelliteSessionStats sessionStats = new SatelliteSessionStats.Builder()
                .setCountOfSuccessfulUserMessages(mShadowCountOfSuccessfulOutgoingDatagram)
@@ -296,6 +303,10 @@ public class SessionMetricsStats {
                        DatagramDispatcher.getInstance().getPendingUserMessagesCount())
                .build();
        bundle.putParcelable(SatelliteManager.KEY_SESSION_STATS, sessionStats);

        // TODO b/381007377 should retrieve MessagesInQueueToBeSent count per messageType and add
        //  to datagramStats
        bundle.putParcelable(KEY_SESSION_STATS_V2, datagramStats);
        result.send(SATELLITE_RESULT_SUCCESS, bundle);
    }

@@ -310,9 +321,9 @@ public class SessionMetricsStats {
    }

    private void initializeSessionMetricsParam() {
        mInitializationResult = SatelliteManager.SATELLITE_RESULT_SUCCESS;
        mInitializationResult = SATELLITE_RESULT_SUCCESS;
        mRadioTechnology = SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN;
        mTerminationResult = SatelliteManager.SATELLITE_RESULT_SUCCESS;
        mTerminationResult = SATELLITE_RESULT_SUCCESS;
        mInitializationProcessingTimeMillis = 0;
        mTerminationProcessingTimeMillis = 0;
        mSessionDurationSec = 0;
@@ -336,6 +347,7 @@ public class SessionMetricsStats {
        mShadowCountOfFailedOutgoingDatagram = 0;
        mShadowCountOfTimedOutUserMessagesWaitingForConnection = 0;
        mShadowCountOfTimedOutUserMessagesWaitingForAck = 0;
        datagramStats.clear();
    }

    private static void logd(@NonNull String log) {
+8 −7
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
@@ -257,7 +258,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                            eq(SATELLITE_RESULT_SUCCESS));
            verifyNoMoreInteractions(mMockDatagramController);
            verify(mMockSessionMetricsStats, times(1))
                    .addCountOfSuccessfulOutgoingDatagram(eq(datagramType));
                    .addCountOfSuccessfulOutgoingDatagram(eq(datagramType), anyLong());
            verify(mMockSatelliteModemInterface, times(1)).sendSatelliteDatagram(
                    any(SatelliteDatagram.class), anyBoolean(), anyBoolean(), any(Message.class));
            assertFalse(mDatagramDispatcherUT.isDatagramWaitForConnectedStateTimerStarted());
@@ -398,7 +399,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                    any(SatelliteDatagram.class), anyBoolean(), anyBoolean(), any(Message.class));
            assertThat(mResultListener.peek()).isEqualTo(SATELLITE_RESULT_SUCCESS);
            verify(mMockSessionMetricsStats, times(1))
                    .addCountOfSuccessfulOutgoingDatagram(anyInt());
                    .addCountOfSuccessfulOutgoingDatagram(anyInt(), anyLong());
            clearInvocations(mMockSatelliteModemInterface);
            clearInvocations(mMockDatagramController);
            clearInvocations(mMockSessionMetricsStats);
@@ -523,7 +524,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                            eq(SATELLITE_RESULT_SUCCESS));
            assertThat(mResultListener.peek()).isEqualTo(SATELLITE_RESULT_SUCCESS);
            verify(mMockSessionMetricsStats, times(1))
                    .addCountOfSuccessfulOutgoingDatagram(eq(datagramType));
                    .addCountOfSuccessfulOutgoingDatagram(eq(datagramType), anyLong());
            mDatagramDispatcherUT.setDemoMode(false);
            mDatagramDispatcherUT.setDeviceAlignedWithSatellite(false);
        }
@@ -618,7 +619,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE), eq(0),
                        eq(SATELLITE_RESULT_SUCCESS));
        verify(mMockSessionMetricsStats, times(1))
                .addCountOfSuccessfulOutgoingDatagram(eq(DATAGRAM_TYPE2));
                .addCountOfSuccessfulOutgoingDatagram(eq(DATAGRAM_TYPE2), anyLong());

        mDatagramDispatcherUT.setDemoMode(false);
        mDatagramDispatcherUT.setDeviceAlignedWithSatellite(false);
@@ -731,7 +732,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                    anyInt(), any(SatelliteDatagram.class));
            verify(mMockDatagramController).pollPendingSatelliteDatagrams(anyInt(), any());
            verify(mMockSessionMetricsStats, times(1))
                    .addCountOfSuccessfulOutgoingDatagram(anyInt());
                    .addCountOfSuccessfulOutgoingDatagram(anyInt(), anyLong());

            // Test when overlay config config_send_satellite_datagram_to_modem_in_demo_mode is
            // false
@@ -1041,7 +1042,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                        eq(1),
                        eq(SATELLITE_RESULT_SUCCESS));
        verify(mMockSessionMetricsStats, times(1))
                .addCountOfSuccessfulOutgoingDatagram(eq(datagramTypeSos));
                .addCountOfSuccessfulOutgoingDatagram(eq(datagramTypeSos), anyLong());
        verify(mMockSatelliteModemInterface, times(1)).sendSatelliteDatagram(
                any(SatelliteDatagram.class), anyBoolean(), anyBoolean(), any(Message.class));
        assertFalse(mDatagramDispatcherUT.isDatagramWaitForConnectedStateTimerStarted());
@@ -1133,7 +1134,7 @@ public class DatagramDispatcherTest extends TelephonyTest {
                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE), eq(0),
                        eq(SATELLITE_RESULT_SUCCESS));
        verify(mMockSessionMetricsStats, times(1))
                .addCountOfSuccessfulOutgoingDatagram(eq(datagramTypeSos));
                .addCountOfSuccessfulOutgoingDatagram(eq(datagramTypeSos), anyLong());
        verify(mMockSatelliteModemInterface, times(1)).sendSatelliteDatagram(
                any(SatelliteDatagram.class), anyBoolean(), anyBoolean(), any(Message.class));
        assertFalse(mDatagramDispatcherUT.isDatagramWaitForConnectedStateTimerStarted());