Merge "Remove requestIsSatelliteCommunicationAllowedForCurrentLocation from vendor implementation" into 24D1-dev
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 0a7fd6c..8489015 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -17,6 +17,7 @@
 package com.android.phone.satellite.accesscontrol;
 
 import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED;
+import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_SUPPORTED;
 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
 
@@ -43,6 +44,7 @@
 import android.telecom.TelecomManager;
 import android.telephony.AnomalyReporter;
 import android.telephony.Rlog;
+import android.telephony.satellite.SatelliteManager;
 import android.text.TextUtils;
 import android.util.Pair;
 
@@ -120,7 +122,7 @@
     @NonNull private final TelecomManager mTelecomManager;
     @NonNull private final TelephonyCountryDetector mCountryDetector;
     @NonNull private final SatelliteController mSatelliteController;
-    @NonNull private final ResultReceiver mInternalSatelliteAllowResultReceiver;
+    @NonNull private final ResultReceiver mInternalSatelliteSupportedResultReceiver;
     @NonNull protected final Object mLock = new Object();
     @GuardedBy("mLock")
     @NonNull
@@ -184,10 +186,10 @@
         if (s2CellFile != null) {
             mSatelliteS2CellFile = s2CellFile;
         }
-        mInternalSatelliteAllowResultReceiver = new ResultReceiver(this) {
+        mInternalSatelliteSupportedResultReceiver = new ResultReceiver(this) {
             @Override
             protected void onReceiveResult(int resultCode, Bundle resultData) {
-                handleSatelliteAllowResultFromSatelliteController(resultCode, resultData);
+                handleIsSatelliteSupportedResult(resultCode, resultData);
             }
         };
         // Init the SatelliteOnDeviceAccessController so that the S2 level can be cached
@@ -464,8 +466,8 @@
                         + "processed");
                 return;
             }
-            mSatelliteController.requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                    requestArguments.first, mInternalSatelliteAllowResultReceiver);
+            mSatelliteController.requestIsSatelliteSupported(
+                    requestArguments.first, mInternalSatelliteSupportedResultReceiver);
         }
     }
 
@@ -483,26 +485,25 @@
         }
     }
 
-    private void handleSatelliteAllowResultFromSatelliteController(
-            int resultCode, Bundle resultData) {
-        logd("handleSatelliteAllowResultFromSatelliteController: resultCode=" + resultCode);
+    private void handleIsSatelliteSupportedResult(int resultCode, Bundle resultData) {
+        logd("handleIsSatelliteSupportedResult: resultCode=" + resultCode);
         synchronized (mLock) {
             if (resultCode == SATELLITE_RESULT_SUCCESS) {
-                if (resultData.containsKey(KEY_SATELLITE_COMMUNICATION_ALLOWED)) {
-                    boolean isSatelliteAllowed = resultData.getBoolean(
-                            KEY_SATELLITE_COMMUNICATION_ALLOWED);
-                    if (!isSatelliteAllowed) {
-                        logd("Satellite is not allowed by modem");
-                        sendSatelliteAllowResultToReceivers(resultCode, resultData);
+                if (resultData.containsKey(KEY_SATELLITE_SUPPORTED)) {
+                    boolean isSatelliteSupported = resultData.getBoolean(KEY_SATELLITE_SUPPORTED);
+                    if (!isSatelliteSupported) {
+                        logd("Satellite is not supported");
+                        Bundle bundle = new Bundle();
+                        bundle.putBoolean(SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED,
+                                false);
+                        sendSatelliteAllowResultToReceivers(resultCode, bundle);
                     } else {
                         checkSatelliteAccessRestrictionForCurrentLocation();
                     }
                 } else {
-                    loge("KEY_SATELLITE_COMMUNICATION_ALLOWED does not exist.");
+                    loge("KEY_SATELLITE_SUPPORTED does not exist.");
                     sendSatelliteAllowResultToReceivers(resultCode, resultData);
                 }
-            } else if (resultCode == SATELLITE_RESULT_REQUEST_NOT_SUPPORTED) {
-                checkSatelliteAccessRestrictionForCurrentLocation();
             } else {
                 sendSatelliteAllowResultToReceivers(resultCode, resultData);
             }
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
index af37611..ed9fa10 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
@@ -371,22 +371,6 @@
     }
 
     @Override
-    public void requestIsSatelliteCommunicationAllowedForCurrentLocation(
-            @NonNull IIntegerConsumer errorCallback, @NonNull IBooleanConsumer callback) {
-        logd("requestIsCommunicationAllowedForCurrentLocation: mErrorCode=" + mErrorCode);
-        if (mErrorCode != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
-            runWithExecutor(() -> errorCallback.accept(mErrorCode));
-            return;
-        }
-
-        if (mIsCommunicationAllowedInLocation) {
-            runWithExecutor(() -> callback.accept(true));
-        } else {
-            runWithExecutor(() -> callback.accept(false));
-        }
-    }
-
-    @Override
     public void requestTimeForNextSatelliteVisibility(@NonNull IIntegerConsumer errorCallback,
             @NonNull IIntegerConsumer callback) {
         logd("requestTimeForNextSatelliteVisibility: mErrorCode=" + mErrorCode);
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
index b5c0c0b..8df0603 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
@@ -17,7 +17,7 @@
 package com.android.phone.satellite.accesscontrol;
 
 import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED;
-import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ERROR;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_ERROR;
 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
 
@@ -34,7 +34,7 @@
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.clearInvocations;
-import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -58,6 +58,7 @@
 import android.os.Message;
 import android.os.ResultReceiver;
 import android.telecom.TelecomManager;
+import android.telephony.satellite.SatelliteManager;
 import android.testing.TestableLooper;
 import android.util.Log;
 import android.util.Pair;
@@ -71,6 +72,7 @@
 import com.android.internal.telephony.satellite.SatelliteConfig;
 import com.android.internal.telephony.satellite.SatelliteConfigParser;
 import com.android.internal.telephony.satellite.SatelliteController;
+import com.android.internal.telephony.satellite.SatelliteModemInterface;
 
 import org.junit.After;
 import org.junit.Before;
@@ -119,6 +121,8 @@
     @Mock
     private SatelliteController mMockSatelliteController;
     @Mock
+    private SatelliteModemInterface mMockSatelliteModemInterface;
+    @Mock
     private Context mMockContext;
     @Mock private Phone mMockPhone;
     @Mock private Phone mMockPhone2;
@@ -139,8 +143,6 @@
     @Captor
     private ArgumentCaptor<Consumer<Location>> mLocationRequestConsumerCaptor;
     @Captor
-    private ArgumentCaptor<ResultReceiver> mResultReceiverFromSatelliteControllerCaptor;
-    @Captor
     private ArgumentCaptor<Handler> mConfigUpdateHandlerCaptor;
     @Captor
     private ArgumentCaptor<Integer> mConfigUpdateIntCaptor;
@@ -174,33 +176,6 @@
         }
     };
 
-    private boolean mQueriedSatelliteAllowed2 = false;
-    private int mQueriedSatelliteAllowedResultCode2 = SATELLITE_RESULT_SUCCESS;
-    private Semaphore mSatelliteAllowedSemaphore2 = new Semaphore(0);
-    private ResultReceiver mSatelliteAllowedReceiver2 = new ResultReceiver(null) {
-        @Override
-        protected void onReceiveResult(int resultCode, Bundle resultData) {
-            mQueriedSatelliteAllowedResultCode2 = resultCode;
-            if (resultCode == SATELLITE_RESULT_SUCCESS) {
-                if (resultData.containsKey(KEY_SATELLITE_COMMUNICATION_ALLOWED)) {
-                    mQueriedSatelliteAllowed2 = resultData.getBoolean(
-                            KEY_SATELLITE_COMMUNICATION_ALLOWED);
-                } else {
-                    logd("KEY_SATELLITE_COMMUNICATION_ALLOWED does not exist.");
-                    mQueriedSatelliteAllowed2 = false;
-                }
-            } else {
-                logd("mSatelliteAllowedReceiver2: resultCode=" + resultCode);
-                mQueriedSatelliteAllowed2 = false;
-            }
-            try {
-                mSatelliteAllowedSemaphore2.release();
-            } catch (Exception ex) {
-                fail("mSatelliteAllowedReceiver2: Got exception in releasing semaphore, ex=" + ex);
-            }
-        }
-    };
-
     @Before
     public void setUp() throws Exception {
         logd("setUp");
@@ -226,6 +201,8 @@
         replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
         replaceInstance(SatelliteController.class, "sInstance", null,
                 mMockSatelliteController);
+        replaceInstance(SatelliteModemInterface.class, "sInstance", null,
+                mMockSatelliteModemInterface);
         replaceInstance(TelephonyCountryDetector.class, "sInstance", null,
                 mMockCountryDetector);
         when(mMockContext.getResources()).thenReturn(mMockResources);
@@ -241,9 +218,6 @@
         when(mMockResources.getInteger(com.android.internal.R.integer
                 .config_oem_enabled_satellite_location_fresh_duration))
                 .thenReturn(TEST_LOCATION_FRESH_DURATION_SECONDS);
-        doNothing().when(mMockSatelliteController)
-                .requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                        anyInt(), any(ResultReceiver.class));
 
         when(mMockLocationManager.getProviders(true)).thenReturn(LOCATION_PROVIDERS);
         when(mMockLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER))
@@ -297,92 +271,44 @@
                 mSatelliteAllowedSemaphore, 1));
         assertEquals(SATELLITE_RESULT_REQUEST_NOT_SUPPORTED, mQueriedSatelliteAllowedResultCode);
 
-        // OEM-enabled satellite is supported, but SatelliteController returns error for the query
+        // OEM-enabled satellite is supported
         when(mMockFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
-        mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
-                SUB_ID, mSatelliteAllowedReceiver);
-        mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
 
-        clearInvocations(mMockSatelliteController);
-        mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
-                SUB_ID, mSatelliteAllowedReceiver2);
-        mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController, never())
-                .requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                        anyInt(), any(ResultReceiver.class));
-
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_ERROR, null);
-        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
-                mSatelliteAllowedSemaphore, 1));
-        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
-                mSatelliteAllowedSemaphore2, 1));
-        assertEquals(SATELLITE_RESULT_ERROR, mQueriedSatelliteAllowedResultCode);
-        assertEquals(SATELLITE_RESULT_ERROR, mQueriedSatelliteAllowedResultCode2);
-        assertFalse(mQueriedSatelliteAllowed);
-        assertFalse(mQueriedSatelliteAllowed2);
-
-        // SatelliteController returns success result but the result bundle does not have
-        // KEY_SATELLITE_COMMUNICATION_ALLOWED
+        // Satellite is not supported
+        setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
         clearAllInvocations();
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, null);
         assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
                 mSatelliteAllowedSemaphore, 1));
         assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
         assertFalse(mQueriedSatelliteAllowed);
 
-        // SatelliteController returns disallowed result
+        // Failed to query whether satellite is supported or not
+        setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_MODEM_ERROR);
         clearAllInvocations();
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, false);
         assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
                 mSatelliteAllowedSemaphore, 1));
-        assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
-        assertFalse(mQueriedSatelliteAllowed);
+        assertEquals(SATELLITE_RESULT_MODEM_ERROR, mQueriedSatelliteAllowedResultCode);
 
-        // SatelliteController returns allowed result. Network country codes are available, but one
-        // country code is not in the allowed list
-        clearAllInvocations();
-        when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(listOf("US", "IN"));
-        mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
-                SUB_ID, mSatelliteAllowedReceiver);
-        mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
-        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
-                mSatelliteAllowedSemaphore, 1));
-        assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
-        assertFalse(mQueriedSatelliteAllowed);
-
-        // SatelliteController returns allowed result. Network country codes are available, and all
-        // country codes are in the allowed list
+        // Network country codes are available.
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
         clearAllInvocations();
         when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(listOf("US", "CA"));
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
                 mSatelliteAllowedSemaphore, 1));
         assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
         assertTrue(mQueriedSatelliteAllowed);
 
-        // SatelliteController returns allowed result. Network country codes are not available.
-        // TelecomManager.isInEmergencyCall() returns true. On-device access controller will be
-        // used. Last known location is available and fresh.
+        // Network country codes are not available. TelecomManager.isInEmergencyCall() returns true.
+        // On-device access controller will be used. Last known location is available and fresh.
         clearAllInvocations();
         when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(EMPTY_STRING_LIST);
         when(mMockTelecomManager.isInEmergencyCall()).thenReturn(true);
@@ -392,9 +318,6 @@
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         assertTrue(
                 mSatelliteAccessControllerUT.isKeepOnDeviceAccessControllerResourcesTimerStarted());
         verify(mMockSatelliteOnDeviceAccessController).isSatCommunicationAllowedAtLocation(
@@ -418,9 +341,9 @@
         mSatelliteAccessControllerUT.setSatelliteOnDeviceAccessController(
                 mMockSatelliteOnDeviceAccessController);
 
-        // SatelliteController returns allowed result. Network country codes are not available.
-        // TelecomManager.isInEmergencyCall() returns false. Phone0 is in ECM. On-device access
-        // controller will be used. Last known location is not fresh.
+        // Network country codes are not available. TelecomManager.isInEmergencyCall() returns
+        // false. Phone0 is in ECM. On-device access controller will be used. Last known location is
+        // not fresh.
         clearAllInvocations();
         when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(EMPTY_STRING_LIST);
         when(mMockTelecomManager.isInEmergencyCall()).thenReturn(false);
@@ -431,9 +354,6 @@
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         assertFalse(
                 mSatelliteAccessControllerUT.isKeepOnDeviceAccessControllerResourcesTimerStarted());
         verify(mMockLocationManager).getCurrentLocation(eq(LocationManager.GPS_PROVIDER),
@@ -463,9 +383,6 @@
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         assertFalse(
                 mSatelliteAccessControllerUT.isKeepOnDeviceAccessControllerResourcesTimerStarted());
         verify(mMockLocationManager).getCurrentLocation(anyString(), any(LocationRequest.class),
@@ -485,10 +402,9 @@
                 mQueriedSatelliteAllowedResultCode);
         assertFalse(mQueriedSatelliteAllowed);
 
-        // SatelliteController returns allowed result. Network country codes are not available.
-        // TelecomManager.isInEmergencyCall() returns false. No phone is in ECM. Last known location
-        // is not fresh. Cached country codes should be used for verifying satellite allow. No
-        // cached country codes are available.
+        // Network country codes are not available. TelecomManager.isInEmergencyCall() returns
+        // false. No phone is in ECM. Last known location is not fresh. Cached country codes should
+        // be used for verifying satellite allow. No cached country codes are available.
         clearAllInvocations();
         when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(EMPTY_STRING_LIST);
         when(mMockCountryDetector.getCachedLocationCountryIsoInfo()).thenReturn(new Pair<>("", 0L));
@@ -502,9 +418,6 @@
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         verify(mMockLocationManager, never()).getCurrentLocation(anyString(),
                 any(LocationRequest.class), any(CancellationSignal.class), any(Executor.class),
                 any(Consumer.class));
@@ -516,10 +429,9 @@
         assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
         assertFalse(mQueriedSatelliteAllowed);
 
-        // SatelliteController returns allowed result. Network country codes are not available.
-        // TelecomManager.isInEmergencyCall() returns false. No phone is in ECM. Last known location
-        // is not fresh. Cached country codes should be used for verifying satellite allow. Cached
-        // country codes are available.
+        // Network country codes are not available. TelecomManager.isInEmergencyCall() returns
+        // false. No phone is in ECM. Last known location is not fresh. Cached country codes should
+        // be used for verifying satellite allow. Cached country codes are available.
         clearAllInvocations();
         when(mMockCountryDetector.getCurrentNetworkCountryIso()).thenReturn(EMPTY_STRING_LIST);
         when(mMockCountryDetector.getCachedLocationCountryIsoInfo())
@@ -538,9 +450,6 @@
         mSatelliteAccessControllerUT.requestIsCommunicationAllowedForCurrentLocation(
                 SUB_ID, mSatelliteAllowedReceiver);
         mTestableLooper.processAllMessages();
-        verify(mMockSatelliteController).requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                anyInt(), mResultReceiverFromSatelliteControllerCaptor.capture());
-        sendSatelliteAllowResultFromSatelliteController(SATELLITE_RESULT_SUCCESS, true);
         verify(mMockLocationManager, never()).getCurrentLocation(anyString(),
                 any(LocationRequest.class), any(CancellationSignal.class), any(Executor.class),
                 any(Consumer.class));
@@ -643,24 +552,27 @@
         return true;
     }
 
-    private void sendSatelliteAllowResultFromSatelliteController(
-            int resultCode, Boolean satelliteAllowed) {
-        Bundle bundle = null;
-        if (resultCode == SATELLITE_RESULT_SUCCESS) {
-            bundle = new Bundle();
-            if (satelliteAllowed != null) {
-                bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED, satelliteAllowed);
-            }
-        }
-        mResultReceiverFromSatelliteControllerCaptor.getValue().send(resultCode, bundle);
-        mTestableLooper.processAllMessages();
-    }
-
     private void sendLocationRequestResult(Location location) {
         mLocationRequestConsumerCaptor.getValue().accept(location);
         mTestableLooper.processAllMessages();
     }
 
+    private void setUpResponseForRequestIsSatelliteSupported(
+            boolean isSatelliteSupported, @SatelliteManager.SatelliteResult int error) {
+        doAnswer(invocation -> {
+            ResultReceiver resultReceiver = invocation.getArgument(1);
+            if (error == SATELLITE_RESULT_SUCCESS) {
+                Bundle bundle = new Bundle();
+                bundle.putBoolean(SatelliteManager.KEY_SATELLITE_SUPPORTED, isSatelliteSupported);
+                resultReceiver.send(error, bundle);
+            } else {
+                resultReceiver.send(error, Bundle.EMPTY);
+            }
+            return null;
+        }).when(mMockSatelliteController).requestIsSatelliteSupported(anyInt(),
+                any(ResultReceiver.class));
+    }
+
     @SafeVarargs
     private static <E> List<E> listOf(E... values) {
         return Arrays.asList(values);