From e63a50fef263c585b2976d7b9948853b1cf4adc3 Mon Sep 17 00:00:00 2001 From: Aishwarya Mallampati Date: Thu, 20 Feb 2025 20:21:20 +0000 Subject: Block premium SMS in satellite mode. Bug: 395930717 Test: atest SatelliteManagerTestOnMockService Test: 402193100 Flag: EXEMPT bugfix Change-Id: Ibd2fb263efe91f172b0cb200ae5c34ae1914b6de --- .../android/internal/telephony/SMSDispatcher.java | 41 ++++++++++++++++++++++ .../telephony/satellite/SatelliteController.java | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java index 759273a76b..fd72c88d79 100644 --- a/src/java/com/android/internal/telephony/SMSDispatcher.java +++ b/src/java/com/android/internal/telephony/SMSDispatcher.java @@ -63,6 +63,7 @@ import android.service.carrier.CarrierMessagingServiceWrapper; import android.service.carrier.CarrierMessagingServiceWrapper.CarrierMessagingCallback; import android.telephony.AnomalyReporter; import android.telephony.CarrierConfigManager; +import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; import android.telephony.SmsManager; @@ -90,9 +91,11 @@ import com.android.internal.telephony.analytics.TelephonyAnalytics; import com.android.internal.telephony.analytics.TelephonyAnalytics.SmsMmsAnalytics; import com.android.internal.telephony.cdma.sms.UserData; import com.android.internal.telephony.flags.Flags; +import com.android.internal.telephony.satellite.SatelliteController; import com.android.internal.telephony.subscription.SubscriptionInfoInternal; import com.android.internal.telephony.subscription.SubscriptionManagerService; import com.android.internal.telephony.uicc.IccRecords; +import com.android.internal.telephony.util.ArrayUtils; import com.android.internal.telephony.util.TelephonyUtils; import com.android.telephony.Rlog; @@ -2226,6 +2229,7 @@ public abstract class SMSDispatcher extends Handler { if (mContext.checkCallingOrSelfPermission(SEND_SMS_NO_CONFIRMATION) == PackageManager.PERMISSION_GRANTED || trackers[0].mIsForVvm || trackers[0].mSkipShortCodeDestAddrCheck) { + Rlog.d(TAG, "checkDestination: app pre-approved"); return true; // app is pre-approved to send to short codes } else { int rule = mPremiumSmsRule.get(); @@ -2245,6 +2249,7 @@ public abstract class SMSDispatcher extends Handler { mSmsDispatchersController .getUsageMonitor() .checkDestination(trackers[0].mDestAddress, simCountryIso); + Rlog.d(TAG, "checkDestination: simCountryIso=" + simCountryIso); } if (rule == PREMIUM_RULE_USE_NETWORK || rule == PREMIUM_RULE_USE_BOTH) { String networkCountryIso = @@ -2264,7 +2269,9 @@ public abstract class SMSDispatcher extends Handler { .getUsageMonitor() .checkDestination( trackers[0].mDestAddress, networkCountryIso)); + Rlog.d(TAG, "checkDestination: networkCountryIso=" + networkCountryIso); } + Rlog.d(TAG, "checkDestination: smsCategory=" + smsCategory); if (smsCategory != SmsManager.SMS_CATEGORY_NOT_SHORT_CODE) { int xmlVersion = mSmsDispatchersController.getUsageMonitor() @@ -2286,6 +2293,14 @@ public abstract class SMSDispatcher extends Handler { return false; } + // Check whether to block premium sms in satellite mode. + if (shouldBlockPremiumSmsInSatelliteMode()) { + Rlog.d(TAG, "Block premium SMS in satellite mode." + + " messageId=" + SmsController.formatCrossStackMessageId( + getMultiTrackermessageId(trackers))); + return false; + } + // Wait for user confirmation unless the user has set permission to always allow/deny int premiumSmsPermission = mSmsDispatchersController @@ -2325,6 +2340,32 @@ public abstract class SMSDispatcher extends Handler { } } + /** Block premium sms in satellite mode. */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) + public boolean shouldBlockPremiumSmsInSatelliteMode() { + SatelliteController sc = SatelliteController.getInstance(); + + if (sc.isSatelliteBeingEnabled()) { + Rlog.d(TAG, "shouldBlockPremiumSmsInSatelliteMode: block premium sms when " + + "satellite is being enabled"); + return true; + } + + if (sc.isSatelliteEnabled()) { + int satelliteSubId = sc.getSelectedSatelliteSubId(); + int[] services = sc.getSupportedServicesOnCarrierRoamingNtn(satelliteSubId); + boolean isSmsSupported = ArrayUtils.contains( + services, NetworkRegistrationInfo.SERVICE_TYPE_SMS); + Rlog.d(TAG, "shouldBlockPremiumSmsInSatelliteMode: satelliteSubId=" + + satelliteSubId + " isSmsSupported=" + isSmsSupported + + " services=" + Arrays.toString(services)); + return !isSmsSupported; + } + + Rlog.d(TAG, "shouldBlockPremiumSmsInSatelliteMode: return false."); + return false; + } + /** * Deny sending a single or a multi-part SMS if the outgoing queue limit is reached. Used when * the message must be confirmed by the user due to excessive usage or potential premium SMS diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java index 89c3c95f98..6ec5ec1529 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java @@ -2627,7 +2627,7 @@ public class SatelliteController extends Handler { * * @return {@code true} if the satellite modem is enabled and {@code false} otherwise. */ - private boolean isSatelliteEnabled() { + public boolean isSatelliteEnabled() { synchronized (mIsSatelliteEnabledLock) { if (mIsSatelliteEnabled == null) return false; return mIsSatelliteEnabled; @@ -2639,7 +2639,7 @@ public class SatelliteController extends Handler { * * @return {@code true} if the satellite modem is being enabled and {@code false} otherwise. */ - private boolean isSatelliteBeingEnabled() { + public boolean isSatelliteBeingEnabled() { if (mSatelliteSessionController != null && mSatelliteSessionController.isInEnablingState()) { return true; -- cgit v1.2.3-59-g8ed1b