Loading src/java/com/android/internal/telephony/metrics/ServiceStateStats.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -189,11 +189,15 @@ public class ServiceStateStats { return copy; return copy; } } /** * Returns {@code true} if modem radio is turned off (e.g. airplane mode). * * <p>Currently this is approximated by voice service state being {@code STATE_POWER_OFF}. */ private static boolean isModemOff(ServiceState state) { private static boolean isModemOff(ServiceState state) { // NOTE: Wifi calls can be made in airplane mode, where voice reg state is POWER_OFF but // TODO(b/189335473): we should get this info from phone's radio power state, which is // data reg state is IN_SERVICE. In this case, service state should still be tracked. // updated separately return state.getVoiceRegState() == ServiceState.STATE_POWER_OFF return state.getVoiceRegState() == ServiceState.STATE_POWER_OFF; && state.getDataRegState() == ServiceState.STATE_POWER_OFF; } } private static @NetworkType int getVoiceRat(Phone phone, ServiceState state) { private static @NetworkType int getVoiceRat(Phone phone, ServiceState state) { Loading tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java +1 −15 Original line number Original line Diff line number Diff line Loading @@ -198,21 +198,7 @@ public class ServiceStateStatsTest extends TelephonyTest { mServiceStateStats.incTimeMillis(100L); mServiceStateStats.incTimeMillis(100L); mServiceStateStats.conclude(); mServiceStateStats.conclude(); // Duration for Wifi calling should be counted and there should not be any switch // There should be no new switches, service states, or added durations ArgumentCaptor<CellularServiceState> captor = ArgumentCaptor.forClass(CellularServiceState.class); verify(mPersistAtomsStorage) .addCellularServiceStateAndCellularDataServiceSwitch(captor.capture(), eq(null)); CellularServiceState state = captor.getValue(); assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, state.voiceRat); assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, state.dataRat); assertEquals(ServiceState.ROAMING_TYPE_NOT_ROAMING, state.voiceRoamingType); assertEquals(ServiceState.ROAMING_TYPE_NOT_ROAMING, state.dataRoamingType); assertFalse(state.isEndc); assertEquals(0, state.simSlotIndex); assertFalse(state.isMultiSim); assertEquals(CARRIER1_ID, state.carrierId); assertEquals(100L, state.totalTimeMillis); verifyNoMoreInteractions(mPersistAtomsStorage); verifyNoMoreInteractions(mPersistAtomsStorage); } } Loading Loading
src/java/com/android/internal/telephony/metrics/ServiceStateStats.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -189,11 +189,15 @@ public class ServiceStateStats { return copy; return copy; } } /** * Returns {@code true} if modem radio is turned off (e.g. airplane mode). * * <p>Currently this is approximated by voice service state being {@code STATE_POWER_OFF}. */ private static boolean isModemOff(ServiceState state) { private static boolean isModemOff(ServiceState state) { // NOTE: Wifi calls can be made in airplane mode, where voice reg state is POWER_OFF but // TODO(b/189335473): we should get this info from phone's radio power state, which is // data reg state is IN_SERVICE. In this case, service state should still be tracked. // updated separately return state.getVoiceRegState() == ServiceState.STATE_POWER_OFF return state.getVoiceRegState() == ServiceState.STATE_POWER_OFF; && state.getDataRegState() == ServiceState.STATE_POWER_OFF; } } private static @NetworkType int getVoiceRat(Phone phone, ServiceState state) { private static @NetworkType int getVoiceRat(Phone phone, ServiceState state) { Loading
tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java +1 −15 Original line number Original line Diff line number Diff line Loading @@ -198,21 +198,7 @@ public class ServiceStateStatsTest extends TelephonyTest { mServiceStateStats.incTimeMillis(100L); mServiceStateStats.incTimeMillis(100L); mServiceStateStats.conclude(); mServiceStateStats.conclude(); // Duration for Wifi calling should be counted and there should not be any switch // There should be no new switches, service states, or added durations ArgumentCaptor<CellularServiceState> captor = ArgumentCaptor.forClass(CellularServiceState.class); verify(mPersistAtomsStorage) .addCellularServiceStateAndCellularDataServiceSwitch(captor.capture(), eq(null)); CellularServiceState state = captor.getValue(); assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, state.voiceRat); assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, state.dataRat); assertEquals(ServiceState.ROAMING_TYPE_NOT_ROAMING, state.voiceRoamingType); assertEquals(ServiceState.ROAMING_TYPE_NOT_ROAMING, state.dataRoamingType); assertFalse(state.isEndc); assertEquals(0, state.simSlotIndex); assertFalse(state.isMultiSim); assertEquals(CARRIER1_ID, state.carrierId); assertEquals(100L, state.totalTimeMillis); verifyNoMoreInteractions(mPersistAtomsStorage); verifyNoMoreInteractions(mPersistAtomsStorage); } } Loading