Merge "Remove requestIsSatelliteCommunicationAllowedForCurrentLocation from vendor implementation" into 24D1-dev
diff --git a/flags/network.aconfig b/flags/network.aconfig
index c0394e8..ab917f0 100644
--- a/flags/network.aconfig
+++ b/flags/network.aconfig
@@ -1,10 +1,14 @@
 package: "com.android.internal.telephony.flags"
 
 flag {
-    name: "enable_carrier_config_n1_control"
+    name: "enable_carrier_config_n1_control_attempt2"
     namespace: "telephony"
     description: "enabling this flag allows KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY to control N1 mode enablement"
-    bug:"302033535"
+    bug:"328848947"
+
+    metadata {
+        purpose: PURPOSE_BUGFIX
+    }
 }
 
 flag {
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index 44122b5..db0fb2d 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -2443,7 +2443,7 @@
      */
     @Override
     public void setN1ModeEnabled(boolean enable, @Nullable Message result) {
-        if (mFeatureFlags.enableCarrierConfigN1Control()) {
+        if (mFeatureFlags.enableCarrierConfigN1ControlAttempt2()) {
             // This might be called by IMS on another thread, so to avoid the requirement to
             // lock, post it through the handler.
             post(() -> {
@@ -2484,7 +2484,7 @@
 
     /** Only called on the handler thread. */
     private void updateCarrierN1ModeSupported(@NonNull PersistableBundle b) {
-        if (!mFeatureFlags.enableCarrierConfigN1Control()) return;
+        if (!mFeatureFlags.enableCarrierConfigN1ControlAttempt2()) return;
 
         if (!CarrierConfigManager.isConfigForIdentifiedCarrier(b)) return;
 
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index 66d0a3f..88682bf 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -1270,10 +1270,9 @@
                 if (SATELLITE_RESULT_SUCCESS != evaluateOemSatelliteRequestAllowed(true)) {
                     return;
                 }
-                if (mShouldReportNtnSignalStrength.get() == shouldReport) {
+                if (!isSatelliteEnabled() || mShouldReportNtnSignalStrength.get() == shouldReport) {
                     if (DBG) {
-                        logd("CMD_UPDATE_NTN_SIGNAL_STRENGTH_REPORTING : modem state matches the "
-                                + "expected state, return.");
+                        logd("CMD_UPDATE_NTN_SIGNAL_STRENGTH_REPORTING: ignore request.");
                     }
                     return;
                 }
@@ -2921,6 +2920,9 @@
         } else {
             loge(caller + ": mSatelliteSessionController is not initialized yet");
         }
+        if (!enabled) {
+            mShouldReportNtnSignalStrength.set(false);
+        }
     }
 
     private void registerForSatelliteProvisionStateChanged() {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
index 5e9ff46..614846b 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
@@ -1519,7 +1519,7 @@
 
     @Test
     public void testNrCapabilityChanged_firstRequest_incompleteCarrierConfig_changeNeeded() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         mPhoneUT.mCi = mMockCi;
         PersistableBundle bundle = mContextFixture.getCarrierConfigBundle();
@@ -1550,7 +1550,7 @@
 
     @Test
     public void testNrCapabilityChanged_firstRequest_noChangeNeeded() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         mPhoneUT.mCi = mMockCi;
         PersistableBundle bundle = mContextFixture.getCarrierConfigBundle();
@@ -1574,7 +1574,7 @@
 
     @Test
     public void testNrCapabilityChanged_firstRequest_needsChange() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         mPhoneUT.mCi = mMockCi;
         PersistableBundle bundle = mContextFixture.getCarrierConfigBundle();
@@ -1598,7 +1598,7 @@
 
     @Test
     public void testNrCapabilityChanged_CarrierConfigChanges() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         // Initialize the inner cache and set the modem to N1 mode = enabled/true
         testNrCapabilityChanged_firstRequest_needsChange();
@@ -1620,7 +1620,7 @@
 
     @Test
     public void testNrCapabilityChanged_CarrierConfigChanges_ErrorResponse() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         mPhoneUT.mCi = mMockCi;
         for (int i = 0; i < 2; i++) {
@@ -1646,7 +1646,7 @@
 
     @Test
     public void testNrCapabilityChanged_firstRequest_ImsChanges() {
-        when(mFeatureFlags.enableCarrierConfigN1Control()).thenReturn(true);
+        when(mFeatureFlags.enableCarrierConfigN1ControlAttempt2()).thenReturn(true);
 
         mPhoneUT.mCi = mMockCi;
         Message passthroughMessage = mTestHandler.obtainMessage(0xC0FFEE);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index dbbbc7a..bf841d0 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -2314,6 +2314,24 @@
         doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
         provisionSatelliteService();
         setUpResponseForStartSendingNtnSignalStrength(expectedResult);
+
+        // but it is ignored because satellite is disabled
+        setUpResponseForRequestIsSatelliteEnabled(false, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteEnabled(false, SATELLITE_RESULT_SUCCESS);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(true);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, never())
+                .startSendingNtnSignalStrength(any(Message.class));
+
+        // after satellite is enabled, startSendingNtnSignalStrength() is requested normally
+        resetSatelliteControllerUT();
+        reset(mMockSatelliteModemInterface);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        provisionSatelliteService();
+        setUpResponseForStartSendingNtnSignalStrength(expectedResult);
+        setUpResponseForRequestIsSatelliteEnabled(true, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteEnabled(true, SATELLITE_RESULT_SUCCESS);
+        processAllMessages();
         sendCmdStartSendingNtnSignalStrengthChangedEvent(true);
         processAllMessages();
         verify(mMockSatelliteModemInterface, times(1))