Loading src/java/com/android/internal/telephony/SMSDispatcher.java +41 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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 = Loading @@ -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() Loading @@ -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 Loading Loading @@ -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 Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import android.provider.Settings; import android.service.carrier.CarrierMessagingService; import android.service.carrier.ICarrierMessagingCallback; import android.service.carrier.ICarrierMessagingService; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SmsManager; import android.testing.AndroidTestingRunner; Loading @@ -75,6 +76,7 @@ import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.TelephonyTestUtils; import com.android.internal.telephony.TestApplication; import com.android.internal.telephony.flags.Flags; import com.android.internal.telephony.satellite.SatelliteController; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.telephony.uicc.IsimUiccRecords; Loading Loading @@ -103,6 +105,7 @@ public class GsmSmsDispatcherTest extends TelephonyTest { private SMSDispatcher.SmsTracker mSmsTracker; private ISub.Stub mISubStub; private ICarrierMessagingService.Stub mICarrierAppMessagingService; private SatelliteController mMockSatelliteController; private Object mLock = new Object(); private boolean mReceivedTestIntent; Loading Loading @@ -150,6 +153,9 @@ public class GsmSmsDispatcherTest extends TelephonyTest { mSmsTracker = mock(SMSDispatcher.SmsTracker.class); mISubStub = mock(ISub.Stub.class); mICarrierAppMessagingService = mock(ICarrierMessagingService.Stub.class); mMockSatelliteController = mock(SatelliteController.class); replaceInstance(SatelliteController.class, "sInstance", null, mMockSatelliteController); // Note that this replaces only cached services in ServiceManager. If a service is not found // in the cache, a real instance is used. Loading Loading @@ -703,4 +709,27 @@ public class GsmSmsDispatcherTest extends TelephonyTest { assertFalse(isMtSmsPollingMessage); } @Test public void testShouldBlockPremiumSmsInSatelliteMode() { doReturn(true).when(mMockSatelliteController).isSatelliteBeingEnabled(); assertTrue(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); int subId = mPhone.getSubId(); doReturn(subId).when(mMockSatelliteController).getSelectedSatelliteSubId(); doReturn(false).when(mMockSatelliteController).isSatelliteBeingEnabled(); doReturn(true).when(mMockSatelliteController).isSatelliteEnabled(); doReturn(new int[]{NetworkRegistrationInfo.SERVICE_TYPE_DATA}).when( mMockSatelliteController).getSupportedServicesOnCarrierRoamingNtn(anyInt()); assertTrue(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); doReturn(true).when(mMockSatelliteController).isSatelliteEnabled(); doReturn(new int[]{NetworkRegistrationInfo.SERVICE_TYPE_DATA, NetworkRegistrationInfo.SERVICE_TYPE_SMS}).when( mMockSatelliteController).getSupportedServicesOnCarrierRoamingNtn(anyInt()); assertFalse(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); doReturn(false).when(mMockSatelliteController).isSatelliteEnabled(); assertFalse(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); } } Loading
src/java/com/android/internal/telephony/SMSDispatcher.java +41 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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 = Loading @@ -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() Loading @@ -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 Loading Loading @@ -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 Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import android.provider.Settings; import android.service.carrier.CarrierMessagingService; import android.service.carrier.ICarrierMessagingCallback; import android.service.carrier.ICarrierMessagingService; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SmsManager; import android.testing.AndroidTestingRunner; Loading @@ -75,6 +76,7 @@ import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.TelephonyTestUtils; import com.android.internal.telephony.TestApplication; import com.android.internal.telephony.flags.Flags; import com.android.internal.telephony.satellite.SatelliteController; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.telephony.uicc.IsimUiccRecords; Loading Loading @@ -103,6 +105,7 @@ public class GsmSmsDispatcherTest extends TelephonyTest { private SMSDispatcher.SmsTracker mSmsTracker; private ISub.Stub mISubStub; private ICarrierMessagingService.Stub mICarrierAppMessagingService; private SatelliteController mMockSatelliteController; private Object mLock = new Object(); private boolean mReceivedTestIntent; Loading Loading @@ -150,6 +153,9 @@ public class GsmSmsDispatcherTest extends TelephonyTest { mSmsTracker = mock(SMSDispatcher.SmsTracker.class); mISubStub = mock(ISub.Stub.class); mICarrierAppMessagingService = mock(ICarrierMessagingService.Stub.class); mMockSatelliteController = mock(SatelliteController.class); replaceInstance(SatelliteController.class, "sInstance", null, mMockSatelliteController); // Note that this replaces only cached services in ServiceManager. If a service is not found // in the cache, a real instance is used. Loading Loading @@ -703,4 +709,27 @@ public class GsmSmsDispatcherTest extends TelephonyTest { assertFalse(isMtSmsPollingMessage); } @Test public void testShouldBlockPremiumSmsInSatelliteMode() { doReturn(true).when(mMockSatelliteController).isSatelliteBeingEnabled(); assertTrue(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); int subId = mPhone.getSubId(); doReturn(subId).when(mMockSatelliteController).getSelectedSatelliteSubId(); doReturn(false).when(mMockSatelliteController).isSatelliteBeingEnabled(); doReturn(true).when(mMockSatelliteController).isSatelliteEnabled(); doReturn(new int[]{NetworkRegistrationInfo.SERVICE_TYPE_DATA}).when( mMockSatelliteController).getSupportedServicesOnCarrierRoamingNtn(anyInt()); assertTrue(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); doReturn(true).when(mMockSatelliteController).isSatelliteEnabled(); doReturn(new int[]{NetworkRegistrationInfo.SERVICE_TYPE_DATA, NetworkRegistrationInfo.SERVICE_TYPE_SMS}).when( mMockSatelliteController).getSupportedServicesOnCarrierRoamingNtn(anyInt()); assertFalse(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); doReturn(false).when(mMockSatelliteController).isSatelliteEnabled(); assertFalse(mGsmSmsDispatcher.shouldBlockPremiumSmsInSatelliteMode()); } }