Block incoming SMS if SMS is not supported.


Change-Id: I1c5acde9514207aba7cabceeaca9ccbd8c7f461a
BUG: 382769472
FLAG: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn
diff --git a/src/java/com/android/internal/telephony/InboundSmsHandler.java b/src/java/com/android/internal/telephony/InboundSmsHandler.java
index f404e04..52ceda5 100644
--- a/src/java/com/android/internal/telephony/InboundSmsHandler.java
+++ b/src/java/com/android/internal/telephony/InboundSmsHandler.java
@@ -764,6 +764,15 @@
             return Intents.RESULT_SMS_HANDLED;
         }
 
+        if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+            SatelliteController satelliteController = SatelliteController.getInstance();
+            if (satelliteController != null
+                    && satelliteController.shouldDropSms(mPhone)) {
+                log("SMS not supported during satellite session.");
+                return Intents.RESULT_SMS_HANDLED;
+            }
+        }
+
         int result = dispatchMessageRadioSpecific(smsb, smsSource, token);
 
         // In case of error, add to metrics. This is not required in case of success, as the
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index c1f03bb..85f7039 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -8279,6 +8279,21 @@
         }
     }
 
+    /** Returns whether to drop SMS or not. */
+    public boolean shouldDropSms(@Nullable Phone phone) {
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            if (!isInCarrierRoamingNbIotNtn(phone)) {
+                return false;
+            }
+
+            int[] services = getSupportedServicesOnCarrierRoamingNtn(phone.getSubId());
+            return !ArrayUtils.contains(services, NetworkRegistrationInfo.SERVICE_TYPE_SMS);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
+
     private boolean isWaitingForSatelliteModemOff() {
         synchronized (mSatelliteEnabledRequestLock) {
             return mWaitingForSatelliteModemOff;