Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +36 −7 Original line number Diff line number Diff line Loading @@ -794,7 +794,7 @@ public class SatelliteController extends Handler { } SessionMetricsStats.getInstance() .setInitializationResult(error) .setRadioTechnology(SatelliteManager.NT_RADIO_TECHNOLOGY_PROPRIETARY) .setRadioTechnology(getSupportedNtnRadioTechnology()) .reportSessionMetrics(); } else { mControllerMetricsStats.onSatelliteDisabled(); Loading Loading @@ -1195,14 +1195,15 @@ public class SatelliteController extends Handler { Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); int error = evaluateOemSatelliteRequestAllowed(true); if (error != SATELLITE_RESULT_SUCCESS) { result.accept(error); sendErrorAndReportSessionMetrics(error, result); return; } if (enableSatellite) { if (!mIsRadioOn) { loge("Radio is not on, can not enable satellite"); result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE, result); return; } } else { Loading @@ -1216,12 +1217,14 @@ public class SatelliteController extends Handler { if (enableDemoMode != mIsDemoModeEnabled) { loge("Received invalid demo mode while satellite session is enabled" + " enableDemoMode = " + enableDemoMode); result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS, result); return; } else { logd("Enable request matches with current state" + " enableSatellite = " + enableSatellite); result.accept(SATELLITE_RESULT_SUCCESS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_SUCCESS, result); return; } } Loading @@ -1246,13 +1249,15 @@ public class SatelliteController extends Handler { } else if (mSatelliteEnabledRequest.enableSatellite == request.enableSatellite) { logd("requestSatelliteEnabled enableSatellite: " + enableSatellite + " is already in progress."); result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_IN_PROGRESS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_REQUEST_IN_PROGRESS, result); return; } else if (mSatelliteEnabledRequest.enableSatellite == false && request.enableSatellite == true) { logd("requestSatelliteEnabled enableSatellite: " + enableSatellite + " cannot be " + "processed. Disable satellite is already in progress."); result.accept(SatelliteManager.SATELLITE_RESULT_ERROR); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_ERROR, result); return; } } Loading Loading @@ -2983,6 +2988,30 @@ public class SatelliteController extends Handler { return SATELLITE_RESULT_SUCCESS; } /** * Returns the non-terrestrial network radio technology that the satellite modem currently * supports. If multiple technologies are available, returns the first supported technology. */ @VisibleForTesting protected @SatelliteManager.NTRadioTechnology int getSupportedNtnRadioTechnology() { synchronized (mSatelliteCapabilitiesLock) { if (mSatelliteCapabilities != null) { return mSatelliteCapabilities.getSupportedRadioTechnologies() .stream().findFirst().orElse(SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN); } return SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN; } } private void sendErrorAndReportSessionMetrics(@SatelliteManager.SatelliteResult int error, Consumer<Integer> result) { result.accept(error); SessionMetricsStats.getInstance() .setInitializationResult(error) .setRadioTechnology(getSupportedNtnRadioTechnology()) .reportSessionMetrics(); } private static void logd(@NonNull String log) { Rlog.d(TAG, log); } Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +19 −3 Original line number Diff line number Diff line Loading @@ -764,9 +764,9 @@ public class SatelliteControllerTest extends TelephonyTest { verify(mMockDatagramController, times(4)).setDemoMode(eq(false)); verify(mMockControllerMetricsStats, times(2)).onSatelliteEnabled(); verify(mMockControllerMetricsStats, times(2)).reportServiceEnablementSuccessCount(); verify(mMockSessionMetricsStats, times(3)).setInitializationResult(anyInt()); verify(mMockSessionMetricsStats, times(3)).setRadioTechnology(anyInt()); verify(mMockSessionMetricsStats, times(3)).reportSessionMetrics(); verify(mMockSessionMetricsStats, times(7)).setInitializationResult(anyInt()); verify(mMockSessionMetricsStats, times(7)).setRadioTechnology(anyInt()); verify(mMockSessionMetricsStats, times(7)).reportSessionMetrics(); // Successfully enable satellite when it is already enabled. mIIntegerConsumerResults.clear(); Loading Loading @@ -921,6 +921,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mSatelliteCapabilities, mQueriedSatelliteCapabilities); assertTrue( mQueriedSatelliteCapabilities.getSupportedRadioTechnologies().contains( mSatelliteControllerUT.getSupportedNtnRadioTechnology())); resetSatelliteControllerUT(); setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS); Loading Loading @@ -1992,6 +1995,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mEmptySatelliteCapabilities, mQueriedSatelliteCapabilities); assertEquals(SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN, mSatelliteControllerUT.getSupportedNtnRadioTechnology()); assertFalse(satelliteController.isSatelliteAttachRequired()); setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS); Loading @@ -2007,6 +2013,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mSatelliteCapabilities, mQueriedSatelliteCapabilities); assertTrue( mQueriedSatelliteCapabilities.getSupportedRadioTechnologies().contains( satelliteController.getSupportedNtnRadioTechnology())); assertTrue(satelliteController.isSatelliteAttachRequired()); when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false); Loading Loading @@ -3023,5 +3032,12 @@ public class SatelliteControllerTest extends TelephonyTest { protected boolean areAllRadiosDisabled() { return allRadiosDisabled; } @Override protected int getSupportedNtnRadioTechnology() { int ntRadioTechnology = super.getSupportedNtnRadioTechnology(); logd("getCurrentNtnRadioTechnology: val=" + ntRadioTechnology); return ntRadioTechnology; } } } Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +36 −7 Original line number Diff line number Diff line Loading @@ -794,7 +794,7 @@ public class SatelliteController extends Handler { } SessionMetricsStats.getInstance() .setInitializationResult(error) .setRadioTechnology(SatelliteManager.NT_RADIO_TECHNOLOGY_PROPRIETARY) .setRadioTechnology(getSupportedNtnRadioTechnology()) .reportSessionMetrics(); } else { mControllerMetricsStats.onSatelliteDisabled(); Loading Loading @@ -1195,14 +1195,15 @@ public class SatelliteController extends Handler { Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); int error = evaluateOemSatelliteRequestAllowed(true); if (error != SATELLITE_RESULT_SUCCESS) { result.accept(error); sendErrorAndReportSessionMetrics(error, result); return; } if (enableSatellite) { if (!mIsRadioOn) { loge("Radio is not on, can not enable satellite"); result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE, result); return; } } else { Loading @@ -1216,12 +1217,14 @@ public class SatelliteController extends Handler { if (enableDemoMode != mIsDemoModeEnabled) { loge("Received invalid demo mode while satellite session is enabled" + " enableDemoMode = " + enableDemoMode); result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS, result); return; } else { logd("Enable request matches with current state" + " enableSatellite = " + enableSatellite); result.accept(SATELLITE_RESULT_SUCCESS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_SUCCESS, result); return; } } Loading @@ -1246,13 +1249,15 @@ public class SatelliteController extends Handler { } else if (mSatelliteEnabledRequest.enableSatellite == request.enableSatellite) { logd("requestSatelliteEnabled enableSatellite: " + enableSatellite + " is already in progress."); result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_IN_PROGRESS); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_REQUEST_IN_PROGRESS, result); return; } else if (mSatelliteEnabledRequest.enableSatellite == false && request.enableSatellite == true) { logd("requestSatelliteEnabled enableSatellite: " + enableSatellite + " cannot be " + "processed. Disable satellite is already in progress."); result.accept(SatelliteManager.SATELLITE_RESULT_ERROR); sendErrorAndReportSessionMetrics( SatelliteManager.SATELLITE_RESULT_ERROR, result); return; } } Loading Loading @@ -2983,6 +2988,30 @@ public class SatelliteController extends Handler { return SATELLITE_RESULT_SUCCESS; } /** * Returns the non-terrestrial network radio technology that the satellite modem currently * supports. If multiple technologies are available, returns the first supported technology. */ @VisibleForTesting protected @SatelliteManager.NTRadioTechnology int getSupportedNtnRadioTechnology() { synchronized (mSatelliteCapabilitiesLock) { if (mSatelliteCapabilities != null) { return mSatelliteCapabilities.getSupportedRadioTechnologies() .stream().findFirst().orElse(SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN); } return SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN; } } private void sendErrorAndReportSessionMetrics(@SatelliteManager.SatelliteResult int error, Consumer<Integer> result) { result.accept(error); SessionMetricsStats.getInstance() .setInitializationResult(error) .setRadioTechnology(getSupportedNtnRadioTechnology()) .reportSessionMetrics(); } private static void logd(@NonNull String log) { Rlog.d(TAG, log); } Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +19 −3 Original line number Diff line number Diff line Loading @@ -764,9 +764,9 @@ public class SatelliteControllerTest extends TelephonyTest { verify(mMockDatagramController, times(4)).setDemoMode(eq(false)); verify(mMockControllerMetricsStats, times(2)).onSatelliteEnabled(); verify(mMockControllerMetricsStats, times(2)).reportServiceEnablementSuccessCount(); verify(mMockSessionMetricsStats, times(3)).setInitializationResult(anyInt()); verify(mMockSessionMetricsStats, times(3)).setRadioTechnology(anyInt()); verify(mMockSessionMetricsStats, times(3)).reportSessionMetrics(); verify(mMockSessionMetricsStats, times(7)).setInitializationResult(anyInt()); verify(mMockSessionMetricsStats, times(7)).setRadioTechnology(anyInt()); verify(mMockSessionMetricsStats, times(7)).reportSessionMetrics(); // Successfully enable satellite when it is already enabled. mIIntegerConsumerResults.clear(); Loading Loading @@ -921,6 +921,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mSatelliteCapabilities, mQueriedSatelliteCapabilities); assertTrue( mQueriedSatelliteCapabilities.getSupportedRadioTechnologies().contains( mSatelliteControllerUT.getSupportedNtnRadioTechnology())); resetSatelliteControllerUT(); setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS); Loading Loading @@ -1992,6 +1995,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mEmptySatelliteCapabilities, mQueriedSatelliteCapabilities); assertEquals(SatelliteManager.NT_RADIO_TECHNOLOGY_UNKNOWN, mSatelliteControllerUT.getSupportedNtnRadioTechnology()); assertFalse(satelliteController.isSatelliteAttachRequired()); setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS); Loading @@ -2007,6 +2013,9 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForRequestSatelliteCapabilitiesResult(1)); assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteCapabilitiesResultCode); assertEquals(mSatelliteCapabilities, mQueriedSatelliteCapabilities); assertTrue( mQueriedSatelliteCapabilities.getSupportedRadioTechnologies().contains( satelliteController.getSupportedNtnRadioTechnology())); assertTrue(satelliteController.isSatelliteAttachRequired()); when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false); Loading Loading @@ -3023,5 +3032,12 @@ public class SatelliteControllerTest extends TelephonyTest { protected boolean areAllRadiosDisabled() { return allRadiosDisabled; } @Override protected int getSupportedNtnRadioTechnology() { int ntRadioTechnology = super.getSupportedNtnRadioTechnology(); logd("getCurrentNtnRadioTechnology: val=" + ntRadioTechnology); return ntRadioTechnology; } } }