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

Commit 407d3bd8 authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Add sorting by ascending order for repeated atom fields

We have below 2 fields, which are object of grouping. but order is matter for repeated data when it is used for dimension factor.

CarrierRoamingSatelliteSession
    - repeated int32 supported_satellite_services
SatelliteEntitlement
    - repeated int32 entitlement_service_type

To reduce the number of cases, it is needed to make sure the list of service types is reported as ascending order every time.

Consulted with Metrics Council

Flag: EXEMPT bug fix
Bug: 373149631
Test: atest SatelliteStatsTest
Change-Id: I064d1b0a7374719145b3ac14273eef4fb6efb1a5
parent 6de683d2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2053,6 +2053,7 @@ public class SatelliteStats {
             */
            public Builder setSupportedSatelliteServices(int[] supportedSatelliteServices) {
                this.mSupportedSatelliteServices = supportedSatelliteServices;
                Arrays.sort(this.mSupportedSatelliteServices);
                return this;
            }

@@ -2495,6 +2496,7 @@ public class SatelliteStats {
             */
            public Builder setEntitlementServiceType(int[] entitlementServiceType) {
                this.mEntitlementServiceType = entitlementServiceType;
                Arrays.sort(this.mEntitlementServiceType);
                return this;
            }

+35 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

public class SatelliteStatsTest extends TelephonyTest {
@@ -636,4 +637,38 @@ public class SatelliteStatsTest extends TelephonyTest {
        assertEquals(param.getConfigDataSource(), stats.configDataSource);
        verifyNoMoreInteractions(mPersistAtomsStorage);
    }

    @Test
    public void testReportRepeatedDataWithAscendingOrder() {
        int[] supportedSatelliteServicesArray = {3, 2, 1};
        SatelliteStats.CarrierRoamingSatelliteSessionParams sessionParams =
                new SatelliteStats.CarrierRoamingSatelliteSessionParams.Builder()
                        .setSupportedSatelliteServices(supportedSatelliteServicesArray)
                        .build();
        mSatelliteStats.onCarrierRoamingSatelliteSessionMetrics(sessionParams);
        ArgumentCaptor<CarrierRoamingSatelliteSession> sessionArgumentCaptor =
                ArgumentCaptor.forClass(CarrierRoamingSatelliteSession.class);
        verify(mPersistAtomsStorage).addCarrierRoamingSatelliteSessionStats(
                sessionArgumentCaptor.capture());
        CarrierRoamingSatelliteSession sessionStats = sessionArgumentCaptor.getValue();

        Arrays.sort(supportedSatelliteServicesArray);
        assertEquals(supportedSatelliteServicesArray, sessionStats.supportedSatelliteServices);
        verifyNoMoreInteractions(mPersistAtomsStorage);

        int[] entitlementServiceTypeArray = {2, 3, 1};
        SatelliteStats.SatelliteEntitlementParams entitlementParams =
                new SatelliteStats.SatelliteEntitlementParams.Builder()
                        .setEntitlementServiceType(entitlementServiceTypeArray)
                        .build();
        mSatelliteStats.onSatelliteEntitlementMetrics(entitlementParams);
        ArgumentCaptor<SatelliteEntitlement> entitlementArgumentCaptor =
                ArgumentCaptor.forClass(SatelliteEntitlement.class);
        verify(mPersistAtomsStorage).addSatelliteEntitlementStats(
                entitlementArgumentCaptor.capture());
        SatelliteEntitlement entitlementStats = entitlementArgumentCaptor.getValue();
        Arrays.sort(entitlementServiceTypeArray);
        assertEquals(entitlementServiceTypeArray, entitlementStats.entitlementServiceType);
        verifyNoMoreInteractions(mPersistAtomsStorage);
    }
}