diff options
16 files changed, 1229 insertions, 81 deletions
diff --git a/proto/src/persist_atoms.proto b/proto/src/persist_atoms.proto index cca2435254..445664d035 100644 --- a/proto/src/persist_atoms.proto +++ b/proto/src/persist_atoms.proto @@ -728,6 +728,12 @@ message SatelliteController { optional int32 count_of_p2p_sms_available_notification_removed = 35; optional bool is_ntn_only_carrier = 36; optional int32 version_of_satellite_access_config = 37; + optional int32 count_of_incoming_datagram_type_sos_sms_success = 38; + optional int32 count_of_incoming_datagram_type_sos_sms_fail = 39; + optional int32 count_of_outgoing_datagram_type_sms_success = 40; + optional int32 count_of_outgoing_datagram_type_sms_fail = 41; + optional int32 count_of_incoming_datagram_type_sms_success = 42; + optional int32 count_of_incoming_datagram_type_sms_fail = 43; } message SatelliteSession { 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/data/DataNetworkController.java b/src/java/com/android/internal/telephony/data/DataNetworkController.java index 00612f74bd..6b916f2c7a 100644 --- a/src/java/com/android/internal/telephony/data/DataNetworkController.java +++ b/src/java/com/android/internal/telephony/data/DataNetworkController.java @@ -1640,8 +1640,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_CONFIG_NOT_READY); } - if (mFeatureFlags.dataServiceCheck() && !isDataServiceSupported(transport)) { - evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + if (mFeatureFlags.dataServiceCheck()) { + NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, transport); + if (nri != null && !nri.getAvailableServices().contains( + NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { + evaluation.addDataDisallowedReason( + DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + } } // Check CS call state and see if concurrent voice/data is allowed. @@ -1977,9 +1983,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE); } - if (mFeatureFlags.dataServiceCheck() - && !isDataServiceSupported(dataNetwork.getTransport())) { - evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + if (mFeatureFlags.dataServiceCheck()) { + NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, dataNetwork.getTransport()); + if (nri != null && nri.isInService() && !nri.getAvailableServices().contains( + NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { + evaluation.addDataDisallowedReason( + DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + } } // If the network is satellite, then the network must be restricted. @@ -2177,21 +2188,6 @@ public class DataNetworkController extends Handler { } /** - * Check if the available services support data service. - * {@link NetworkRegistrationInfo#SERVICE_TYPE_DATA} service or not. - * - * @param transport The preferred transport type for the request. The transport here is - * WWAN/WLAN. - * @return {@code true} if data services is supported, otherwise {@code false}. - */ - private boolean isDataServiceSupported(@TransportType int transport) { - NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( - NetworkRegistrationInfo.DOMAIN_PS, transport); - return nri != null && nri.getAvailableServices().contains( - NetworkRegistrationInfo.SERVICE_TYPE_DATA); - } - - /** * Check if the transport from connectivity service can satisfy the network request. Note the * transport here is connectivity service's transport (Wifi, cellular, satellite, etc..), not * the widely used {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN WLAN}, @@ -3803,6 +3799,22 @@ public class DataNetworkController extends Handler { } /** + * Check if network available services list is changed + * + * @param oldNri Previous network registration info. + * @param newNri Current network registration info. + * @return {@code true} if available services list is changed else return false + */ + private boolean areNetworkAvailableServicesChanged(@NonNull NetworkRegistrationInfo oldNri, + @NonNull NetworkRegistrationInfo newNri) { + List<Integer> oldAvailableServicesList = oldNri.getAvailableServices(); + List<Integer> newAvailableServicesList = newNri.getAvailableServices(); + + return !(oldAvailableServicesList.size() == newAvailableServicesList.size() + && oldAvailableServicesList.stream().allMatch(newAvailableServicesList::contains)); + } + + /** * Check if needed to re-evaluate the existing data networks. * * @param oldNri Previous network registration info. @@ -3818,6 +3830,10 @@ public class DataNetworkController extends Handler { return false; } + if (areNetworkAvailableServicesChanged(oldNri, newNri)) { + return true; + } + if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology() // Some CarrierConfig disallows vops in nonVops area for specified home/roaming. || (oldNri.isRoaming() != newNri.isRoaming())) { @@ -3863,6 +3879,10 @@ public class DataNetworkController extends Handler { return false; } + if (areNetworkAvailableServicesChanged(oldPsNri, newPsNri)) { + return true; + } + if (oldPsNri == null || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology() || (!oldPsNri.isInService() && newPsNri.isInService()) diff --git a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java index a5df6e6d9a..7863b25405 100644 --- a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java +++ b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java @@ -1485,7 +1485,13 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback { satelliteController.countOfP2PSmsAvailableNotificationShown, satelliteController.countOfP2PSmsAvailableNotificationRemoved, satelliteController.isNtnOnlyCarrier, - satelliteController.versionOfSatelliteAccessConfig); + satelliteController.versionOfSatelliteAccessConfig, + satelliteController.countOfIncomingDatagramTypeSosSmsSuccess, + satelliteController.countOfIncomingDatagramTypeSosSmsFail, + satelliteController.countOfOutgoingDatagramTypeSmsSuccess, + satelliteController.countOfOutgoingDatagramTypeSmsFail, + satelliteController.countOfIncomingDatagramTypeSmsSuccess, + satelliteController.countOfIncomingDatagramTypeSmsFail); } private static StatsEvent buildStatsEvent(SatelliteSession satelliteSession) { diff --git a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java index 9f6af3f7a1..4346da4b79 100644 --- a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java +++ b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java @@ -786,6 +786,18 @@ public class PersistAtomsStorage { += stats.countOfP2PSmsAvailableNotificationRemoved; // Does not update isNtnOnlyCarrier due to it is a dimension field. existingStats.versionOfSatelliteAccessConfig = stats.versionOfSatelliteAccessConfig; + existingStats.countOfIncomingDatagramTypeSosSmsSuccess + += stats.countOfIncomingDatagramTypeSosSmsSuccess; + existingStats.countOfIncomingDatagramTypeSosSmsFail + += stats.countOfIncomingDatagramTypeSosSmsFail; + existingStats.countOfOutgoingDatagramTypeSmsSuccess + += stats.countOfOutgoingDatagramTypeSmsSuccess; + existingStats.countOfOutgoingDatagramTypeSmsFail + += stats.countOfOutgoingDatagramTypeSmsFail; + existingStats.countOfIncomingDatagramTypeSmsSuccess + += stats.countOfIncomingDatagramTypeSmsSuccess; + existingStats.countOfIncomingDatagramTypeSmsFail + += stats.countOfIncomingDatagramTypeSmsFail; } else { mAtoms.satelliteController = insertAtRandomPlace(mAtoms.satelliteController, stats, mMaxNumSatelliteStats); diff --git a/src/java/com/android/internal/telephony/metrics/SatelliteStats.java b/src/java/com/android/internal/telephony/metrics/SatelliteStats.java index c46a53f530..a99613acdc 100644 --- a/src/java/com/android/internal/telephony/metrics/SatelliteStats.java +++ b/src/java/com/android/internal/telephony/metrics/SatelliteStats.java @@ -40,6 +40,7 @@ import com.android.internal.telephony.satellite.SatelliteConstants; import com.android.telephony.Rlog; import java.util.Arrays; +import java.util.Objects; import java.util.Optional; /** Tracks Satellite metrics for each phone */ @@ -105,6 +106,12 @@ public class SatelliteStats { private final int mCountOfP2PSmsAvailableNotificationRemoved; private static boolean sIsNtnOnlyCarrier; private static int sVersionOfSatelliteAccessConfig; + private final int mCountOfIncomingDatagramTypeSosSmsSuccess; + private final int mCountOfIncomingDatagramTypeSosSmsFail; + private final int mCountOfOutgoingDatagramTypeSmsSuccess; + private final int mCountOfOutgoingDatagramTypeSmsFail; + private final int mCountOfIncomingDatagramTypeSmsSuccess; + private final int mCountOfIncomingDatagramTypeSmsFail; private SatelliteControllerParams(Builder builder) { this.mCountOfSatelliteServiceEnablementsSuccess = @@ -181,6 +188,17 @@ public class SatelliteStats { this.sVersionOfSatelliteAccessConfig = builder.mVersionOfSatelliteAccessConfig.get(); } + + this.mCountOfIncomingDatagramTypeSosSmsSuccess = + builder.mCountOfIncomingDatagramTypeSosSmsSuccess; + this.mCountOfIncomingDatagramTypeSosSmsFail = + builder.mCountOfIncomingDatagramTypeSosSmsFail; + this.mCountOfOutgoingDatagramTypeSmsSuccess = + builder.mCountOfOutgoingDatagramTypeSmsSuccess; + this.mCountOfOutgoingDatagramTypeSmsFail = builder.mCountOfOutgoingDatagramTypeSmsFail; + this.mCountOfIncomingDatagramTypeSmsSuccess = + builder.mCountOfIncomingDatagramTypeSmsSuccess; + this.mCountOfIncomingDatagramTypeSmsFail = builder.mCountOfIncomingDatagramTypeSmsFail; } public int getCountOfSatelliteServiceEnablementsSuccess() { @@ -331,6 +349,30 @@ public class SatelliteStats { return sVersionOfSatelliteAccessConfig; } + public int getCountOfIncomingDatagramTypeSosSmsSuccess() { + return mCountOfIncomingDatagramTypeSosSmsSuccess; + } + + public int getCountOfIncomingDatagramTypeSosSmsFail() { + return mCountOfIncomingDatagramTypeSosSmsFail; + } + + public int getCountOfOutgoingDatagramTypeSmsSuccess() { + return mCountOfOutgoingDatagramTypeSmsSuccess; + } + + public int getCountOfOutgoingDatagramTypeSmsFail() { + return mCountOfOutgoingDatagramTypeSmsFail; + } + + public int getCountOfIncomingDatagramTypeSmsSuccess() { + return mCountOfIncomingDatagramTypeSmsSuccess; + } + + public int getCountOfIncomingDatagramTypeSmsFail() { + return mCountOfIncomingDatagramTypeSmsFail; + } + /** * A builder class to create {@link SatelliteControllerParams} data structure class */ @@ -372,6 +414,12 @@ public class SatelliteStats { private int mCountOfP2PSmsAvailableNotificationRemoved = 0; private Optional<Boolean> mIsNtnOnlyCarrier = Optional.empty(); private Optional<Integer> mVersionOfSatelliteAccessConfig = Optional.empty(); + private int mCountOfIncomingDatagramTypeSosSmsSuccess; + private int mCountOfIncomingDatagramTypeSosSmsFail; + private int mCountOfOutgoingDatagramTypeSmsSuccess; + private int mCountOfOutgoingDatagramTypeSmsFail; + private int mCountOfIncomingDatagramTypeSmsSuccess; + private int mCountOfIncomingDatagramTypeSmsFail; /** * Sets countOfSatelliteServiceEnablementsSuccess value of {@link SatelliteController} @@ -740,6 +788,67 @@ public class SatelliteStats { } /** + * Sets countOfIncomingDatagramTypeSosSmsSuccess value of {@link SatelliteController} + * atom then returns Builder class + */ + public Builder setCountOfIncomingDatagramTypeSosSmsSuccess( + int countOfIncomingDatagramTypeSosSmsSuccess) { + this.mCountOfIncomingDatagramTypeSosSmsSuccess = + countOfIncomingDatagramTypeSosSmsSuccess; + return this; + } + + /** + * Sets countOfIncomingDatagramTypeSosSmsFail value of {@link SatelliteController} atom + * then returns Builder class + */ + public Builder setCountOfIncomingDatagramTypeSosSmsFail( + int countOfIncomingDatagramTypeSosSmsFail) { + this.mCountOfIncomingDatagramTypeSosSmsFail = countOfIncomingDatagramTypeSosSmsFail; + return this; + } + + /** + * Sets countOfOutgoingDatagramTypeSmsSuccess value of {@link SatelliteController} atom + * then returns Builder class + */ + public Builder setCountOfOutgoingDatagramTypeSmsSuccess( + int countOfOutgoingDatagramTypeSmsSuccess) { + this.mCountOfOutgoingDatagramTypeSmsSuccess = countOfOutgoingDatagramTypeSmsSuccess; + return this; + } + + /** + * Sets countOfOutgoingDatagramTypeSmsFail value of {@link SatelliteController} atom + * then returns Builder class + */ + public Builder setCountOfOutgoingDatagramTypeSmsFail( + int countOfOutgoingDatagramTypeSmsFail) { + this.mCountOfOutgoingDatagramTypeSmsFail = countOfOutgoingDatagramTypeSmsFail; + return this; + } + + /** + * Sets countOfIncomingDatagramTypeSmsSuccess value of {@link SatelliteController} atom + * then returns Builder class + */ + public Builder setCountOfIncomingDatagramTypeSmsSuccess( + int countOfIncomingDatagramTypeSmsSuccess) { + this.mCountOfIncomingDatagramTypeSmsSuccess = countOfIncomingDatagramTypeSmsSuccess; + return this; + } + + /** + * Sets countOfIncomingDatagramTypeSmsFail value of {@link SatelliteController} atom + * then returns Builder class + */ + public Builder setCountOfIncomingDatagramTypeSmsFail( + int countOfIncomingDatagramTypeSmsFail) { + this.mCountOfIncomingDatagramTypeSmsFail = countOfIncomingDatagramTypeSmsFail; + return this; + } + + /** * Returns ControllerParams, which contains whole component of * {@link SatelliteController} atom */ @@ -799,6 +908,16 @@ public class SatelliteStats { + ", countOfP2PSmsAvailableNotificationRemoved=" + mCountOfP2PSmsAvailableNotificationRemoved + ", versionOfSatelliteAccessConfig=" + sVersionOfSatelliteAccessConfig + + ", countOfIncomingDatagramTypeSosSmsSuccess=" + + mCountOfIncomingDatagramTypeSosSmsSuccess + + ", countOfIncomingDatagramTypeSosSmsFail=" + + mCountOfIncomingDatagramTypeSosSmsFail + + ", countOfOutgoingDatagramTypeSmsSuccess=" + + mCountOfOutgoingDatagramTypeSmsSuccess + + ", countOfOutgoingDatagramTypeSmsFail=" + mCountOfOutgoingDatagramTypeSmsFail + + ", countOfIncomingDatagramTypeSmsSuccess=" + + mCountOfIncomingDatagramTypeSmsSuccess + + ", countOfIncomingDatagramTypeSmsFail=" + mCountOfIncomingDatagramTypeSmsFail + ")"; } } @@ -2183,7 +2302,6 @@ public class SatelliteStats { return mConfigDataSource; } - public int getCountOfEntitlementStatusQueryRequest() { return mCountOfEntitlementStatusQueryRequest; } @@ -2345,6 +2463,37 @@ public class SatelliteStats { } @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + CarrierRoamingSatelliteControllerStatsParams that = + (CarrierRoamingSatelliteControllerStatsParams) obj; + return mConfigDataSource == that.getConfigDataSource() + && mCountOfEntitlementStatusQueryRequest + == that.getCountOfEntitlementStatusQueryRequest() + && mCountOfSatelliteConfigUpdateRequest + == that.getCountOfSatelliteConfigUpdateRequest() + && mCountOfSatelliteNotificationDisplayed + == that.getCountOfSatelliteNotificationDisplayed() + && sSatelliteSessionGapMinSec == that.getSatelliteSessionGapMinSec() + && sSatelliteSessionGapAvgSec == that.getSatelliteSessionGapAvgSec() + && sSatelliteSessionGapMaxSec == that.getSatelliteSessionGapMaxSec() + && sCarrierId == that.getCarrierId() + && sIsDeviceEntitled == that.isDeviceEntitled() + && sIsMultiSim == that.isMultiSim() + && mCountOfSatelliteSessions == that.getCountOfSatelliteSessions(); + } + + @Override + public int hashCode() { + return Objects.hash(mConfigDataSource, mCountOfEntitlementStatusQueryRequest, + mCountOfSatelliteConfigUpdateRequest, mCountOfSatelliteNotificationDisplayed, + sSatelliteSessionGapMinSec, sSatelliteSessionGapAvgSec, + sSatelliteSessionGapMaxSec, sCarrierId, sIsDeviceEntitled, sIsMultiSim, + mCountOfSatelliteSessions); + } + + @Override public String toString() { return "CarrierRoamingSatelliteControllerStatsParams(" + "configDataSource=" + mConfigDataSource @@ -2892,6 +3041,16 @@ public class SatelliteStats { param.getCountOfP2PSmsAvailableNotificationRemoved(); proto.isNtnOnlyCarrier = param.isNtnOnlyCarrier(); proto.versionOfSatelliteAccessConfig = param.getVersionSatelliteAccessConfig(); + proto.countOfIncomingDatagramTypeSosSmsSuccess = + param.getCountOfIncomingDatagramTypeSosSmsSuccess(); + proto.countOfIncomingDatagramTypeSosSmsFail = + param.getCountOfIncomingDatagramTypeSosSmsFail(); + proto.countOfOutgoingDatagramTypeSmsSuccess = + param.getCountOfOutgoingDatagramTypeSmsSuccess(); + proto.countOfOutgoingDatagramTypeSmsFail = param.getCountOfOutgoingDatagramTypeSmsFail(); + proto.countOfIncomingDatagramTypeSmsSuccess = + param.getCountOfIncomingDatagramTypeSmsSuccess(); + proto.countOfIncomingDatagramTypeSmsFail = param.getCountOfIncomingDatagramTypeSmsFail(); if (DBG) logd("onSatelliteControllerMetrics" + param); mAtomsStorage.addSatelliteControllerStats(proto); } diff --git a/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java b/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java index 0b8589306f..bc7d5d142f 100644 --- a/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java +++ b/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java @@ -767,9 +767,11 @@ public class DatagramDispatcher extends Handler { if (resultCode == SATELLITE_RESULT_SUCCESS) { long smsTransmissionTime = mSmsTransmissionStartTime > 0 ? (System.currentTimeMillis() - mSmsTransmissionStartTime) : 0; + mControllerMetricsStats.reportOutgoingDatagramSuccessCount(datagramType, false); mSessionMetricsStats.addCountOfSuccessfulOutgoingDatagram( datagramType, smsTransmissionTime); } else { + mControllerMetricsStats.reportOutgoingDatagramFailCount(datagramType, false); mSessionMetricsStats.addCountOfFailedOutgoingDatagram( datagramType, resultCode); } diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java index d44100d3e5..be4308722f 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java @@ -2140,7 +2140,8 @@ public class SatelliteController extends Handler { int defaultSubId = mSubscriptionManagerService.getDefaultSubId(); boolean isEntitled = mSatelliteEntitlementStatusPerCarrier.get(defaultSubId, false); - mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(isEntitled); + mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(defaultSubId, + isEntitled); } sendMessageDelayed(obtainMessage( EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT), @@ -2626,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; @@ -2638,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; @@ -3810,6 +3811,9 @@ public class SatelliteController extends Handler { } else { logd("onSmsReceived: DatagramController is not initialized"); } + + mControllerMetricsStats.reportIncomingNtnSmsCount( + SatelliteManager.SATELLITE_RESULT_SUCCESS); } /** @@ -4333,7 +4337,8 @@ public class SatelliteController extends Handler { if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) { logd("update the carrier satellite enabled to " + entitlementEnabled); mSatelliteEntitlementStatusPerCarrier.put(subId, entitlementEnabled); - mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(entitlementEnabled); + mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(subId, + entitlementEnabled); if (hasMessages(EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT)) { removeMessages(EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT); sendMessageDelayed(obtainMessage( @@ -5342,7 +5347,7 @@ public class SatelliteController extends Handler { if (!entitlementPlmnList.isEmpty()) { mMergedPlmnListPerCarrier.put(subId, entitlementPlmnList); plogd("mMergedPlmnListPerCarrier is updated by Entitlement"); - mCarrierRoamingSatelliteControllerStats.reportConfigDataSource( + mCarrierRoamingSatelliteControllerStats.reportConfigDataSource(subId, SatelliteConstants.CONFIG_DATA_SOURCE_ENTITLEMENT); return; } @@ -5357,7 +5362,7 @@ public class SatelliteController extends Handler { plogd("mMergedPlmnListPerCarrier is updated by ConfigUpdater : " + String.join(",", plmnList)); mMergedPlmnListPerCarrier.put(subId, plmnList); - mCarrierRoamingSatelliteControllerStats.reportConfigDataSource( + mCarrierRoamingSatelliteControllerStats.reportConfigDataSource(subId, SatelliteConstants.CONFIG_DATA_SOURCE_CONFIG_UPDATER); return; } @@ -5370,7 +5375,7 @@ public class SatelliteController extends Handler { .stream().toList(); plogd("mMergedPlmnListPerCarrier is updated by carrier config: " + String.join(",", carrierPlmnList)); - mCarrierRoamingSatelliteControllerStats.reportConfigDataSource( + mCarrierRoamingSatelliteControllerStats.reportConfigDataSource(subId, SatelliteConstants.CONFIG_DATA_SOURCE_CARRIER_CONFIG); } else { carrierPlmnList = new ArrayList<>(); @@ -5866,7 +5871,7 @@ public class SatelliteController extends Handler { } boolean result = entitlementStatus.equals("1"); mSatelliteEntitlementStatusPerCarrier.put(subId, result); - mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(result); + mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(subId, result); if (hasMessages(EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT)) { removeMessages(EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT); sendMessageDelayed(obtainMessage( @@ -6226,14 +6231,14 @@ public class SatelliteController extends Handler { sessionStats.onSessionStart(phone.getCarrierId(), phone, supported_satellite_services, dataPolicy); mCarrierRoamingSatelliteSessionStatsMap.put(subId, sessionStats); - mCarrierRoamingSatelliteControllerStats.onSessionStart(); + mCarrierRoamingSatelliteControllerStats.onSessionStart(subId); } else if (lastNotifiedNtnMode && !currNtnMode) { // Log satellite session end CarrierRoamingSatelliteSessionStats sessionStats = mCarrierRoamingSatelliteSessionStatsMap.get(subId); sessionStats.onSessionEnd(); mCarrierRoamingSatelliteSessionStatsMap.remove(subId); - mCarrierRoamingSatelliteControllerStats.onSessionEnd(); + mCarrierRoamingSatelliteControllerStats.onSessionEnd(subId); } } } @@ -6906,7 +6911,7 @@ public class SatelliteController extends Handler { Context.RECEIVER_EXPORTED); mIsNotificationShowing = true; - mCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteNotificationDisplayed(); + mCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteNotificationDisplayed(subId); mCarrierRoamingSatelliteControllerStats.reportCarrierId(getSatelliteCarrierId()); mSessionMetricsStats.addCountOfSatelliteNotificationDisplayed(); } diff --git a/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteControllerStats.java b/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteControllerStats.java index 8d7804551c..642f39855b 100644 --- a/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteControllerStats.java +++ b/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteControllerStats.java @@ -17,26 +17,35 @@ package com.android.internal.telephony.satellite.metrics; import android.annotation.NonNull; +import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.telephony.Phone; +import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.metrics.SatelliteStats; import com.android.internal.telephony.satellite.SatelliteConstants; import com.android.internal.telephony.subscription.SubscriptionManagerService; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class CarrierRoamingSatelliteControllerStats { private static final String TAG = CarrierRoamingSatelliteControllerStats.class.getSimpleName(); private static CarrierRoamingSatelliteControllerStats sInstance = null; private static final int ADD_COUNT = 1; private SatelliteStats mSatelliteStats; - private List<Long> mSessionStartTimeList; - private List<Long> mSessionEndTimeList; + /** Map key subId, value: list of session start time in milliseconds */ + private Map<Integer, List<Long>> mSessionStartTimeMap = new HashMap<>(); + /** Map key subId, list of session end time in milliseconds */ + private Map<Integer, List<Long>> mSessionEndTimeMap = new HashMap<>(); - private CarrierRoamingSatelliteControllerStats() { + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) + public CarrierRoamingSatelliteControllerStats() { mSatelliteStats = SatelliteStats.getInstance(); resetSessionGapLists(); } @@ -57,19 +66,22 @@ public class CarrierRoamingSatelliteControllerStats { } /** Report config data source */ - public void reportConfigDataSource(@SatelliteConstants.ConfigDataSource int configDataSource) { + public void reportConfigDataSource(int subId, + @SatelliteConstants.ConfigDataSource int configDataSource) { mSatelliteStats.onCarrierRoamingSatelliteControllerStatsMetrics( new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() .setConfigDataSource(configDataSource) + .setCarrierId(getCarrierIdFromSubscription(subId)) .setIsMultiSim(isMultiSim()) .build()); } /** Report count of entitlement status query request */ - public void reportCountOfEntitlementStatusQueryRequest() { + public void reportCountOfEntitlementStatusQueryRequest(int subId) { mSatelliteStats.onCarrierRoamingSatelliteControllerStatsMetrics( new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() .setCountOfEntitlementStatusQueryRequest(ADD_COUNT) + .setCarrierId(getCarrierIdFromSubscription(subId)) .setIsMultiSim(isMultiSim()) .build()); } @@ -84,10 +96,11 @@ public class CarrierRoamingSatelliteControllerStats { } /** Report count of satellite notification displayed */ - public void reportCountOfSatelliteNotificationDisplayed() { + public void reportCountOfSatelliteNotificationDisplayed(int subId) { mSatelliteStats.onCarrierRoamingSatelliteControllerStatsMetrics( new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() .setCountOfSatelliteNotificationDisplayed(ADD_COUNT) + .setCarrierId(getCarrierIdFromSubscription(subId)) .setIsMultiSim(isMultiSim()) .build()); } @@ -102,29 +115,38 @@ public class CarrierRoamingSatelliteControllerStats { } /** Capture whether the device is satellite entitled or not */ - public void reportIsDeviceEntitled(boolean isDeviceEntitled) { + public void reportIsDeviceEntitled(int subId, boolean isDeviceEntitled) { mSatelliteStats.onCarrierRoamingSatelliteControllerStatsMetrics( new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() .setIsDeviceEntitled(isDeviceEntitled) + .setCarrierId(getCarrierIdFromSubscription(subId)) .setIsMultiSim(isMultiSim()) .build()); } /** Log carrier roaming satellite session start */ - public void onSessionStart() { - mSessionStartTimeList.add(getCurrentTime()); + public void onSessionStart(int subId) { + List<Long> sessionStartTimeListForSubscription = mSessionStartTimeMap.getOrDefault(subId, + new ArrayList<>()); + sessionStartTimeListForSubscription.add(getCurrentTime()); + mSessionStartTimeMap.put(subId, sessionStartTimeListForSubscription); + mSatelliteStats.onCarrierRoamingSatelliteControllerStatsMetrics( new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() + .setCarrierId(getCarrierIdFromSubscription(subId)) .increaseCountOfSatelliteSessions() .build()); } /** Log carrier roaming satellite session end */ - public void onSessionEnd() { - mSessionEndTimeList.add(getCurrentTime()); - - int numberOfSatelliteSessions = getNumberOfSatelliteSessions(); - List<Integer> sessionGapList = getSatelliteSessionGapList(numberOfSatelliteSessions); + public void onSessionEnd(int subId) { + List<Long> sessionEndTimeListForSubscription = mSessionEndTimeMap.getOrDefault(subId, + new ArrayList<>()); + sessionEndTimeListForSubscription.add(getCurrentTime()); + mSessionEndTimeMap.put(subId, sessionEndTimeListForSubscription); + + int numberOfSatelliteSessions = getNumberOfSatelliteSessions(subId); + List<Integer> sessionGapList = getSatelliteSessionGapList(subId, numberOfSatelliteSessions); int satelliteSessionGapMinSec = 0; int satelliteSessionGapMaxSec = 0; if (!sessionGapList.isEmpty()) { @@ -137,29 +159,34 @@ public class CarrierRoamingSatelliteControllerStats { .setSatelliteSessionGapMinSec(satelliteSessionGapMinSec) .setSatelliteSessionGapAvgSec(getAvg(sessionGapList)) .setSatelliteSessionGapMaxSec(satelliteSessionGapMaxSec) + .setCarrierId(getCarrierIdFromSubscription(subId)) .setIsMultiSim(isMultiSim()) .build()); } /** Atom is pulled once per day. Reset session gap lists after the atom is pulled. */ public void resetSessionGapLists() { - mSessionStartTimeList = new ArrayList<>(); - mSessionEndTimeList = new ArrayList<>(); + mSessionStartTimeMap = new HashMap<>(); + mSessionEndTimeMap = new HashMap<>(); } - private int getNumberOfSatelliteSessions() { - return Math.min(mSessionStartTimeList.size(), mSessionEndTimeList.size()); + private int getNumberOfSatelliteSessions(int subId) { + return Math.min(mSessionStartTimeMap.getOrDefault(subId, new ArrayList<>()).size(), + mSessionEndTimeMap.getOrDefault(subId, new ArrayList<>()).size()); } - private List<Integer> getSatelliteSessionGapList(int numberOfSatelliteSessions) { + private List<Integer> getSatelliteSessionGapList(int subId, int numberOfSatelliteSessions) { if (numberOfSatelliteSessions == 0) { return new ArrayList<>(); } + List<Long> sessionStartTimeList = mSessionStartTimeMap.getOrDefault(subId, + new ArrayList<>()); + List<Long> sessionEndTimeList = mSessionEndTimeMap.getOrDefault(subId, new ArrayList<>()); List<Integer> sessionGapList = new ArrayList<>(); for (int i = 1; i < numberOfSatelliteSessions; i++) { - long prevSessionEndTime = mSessionEndTimeList.get(i - 1); - long currentSessionStartTime = mSessionStartTimeList.get(i); + long prevSessionEndTime = sessionEndTimeList.get(i - 1); + long currentSessionStartTime = sessionStartTimeList.get(i); if (currentSessionStartTime > prevSessionEndTime && prevSessionEndTime > 0) { sessionGapList.add((int) ( (currentSessionStartTime - prevSessionEndTime) / 1000)); @@ -181,7 +208,8 @@ public class CarrierRoamingSatelliteControllerStats { return total / list.size(); } - private long getCurrentTime() { + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) + protected long getCurrentTime() { return System.currentTimeMillis(); } @@ -190,6 +218,14 @@ public class CarrierRoamingSatelliteControllerStats { return SubscriptionManagerService.getInstance().getActiveSubIdList(true).length > 1; } + /** Returns the carrier ID of the given subscription id. */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) + protected int getCarrierIdFromSubscription(int subId) { + int phoneId = SubscriptionManager.getPhoneId(subId); + Phone phone = PhoneFactory.getPhone(phoneId); + return phone != null ? phone.getCarrierId() : TelephonyManager.UNKNOWN_CARRIER_ID; + } + private static void logd(@NonNull String log) { Log.d(TAG, log); } diff --git a/src/java/com/android/internal/telephony/satellite/metrics/ControllerMetricsStats.java b/src/java/com/android/internal/telephony/satellite/metrics/ControllerMetricsStats.java index aef0808b59..5d0fa9d2f6 100644 --- a/src/java/com/android/internal/telephony/satellite/metrics/ControllerMetricsStats.java +++ b/src/java/com/android/internal/telephony/satellite/metrics/ControllerMetricsStats.java @@ -145,6 +145,9 @@ public class ControllerMetricsStats { builder.setCountOfDatagramTypeLocationSharingSuccess(ADD_COUNT); } else if (datagramType == SatelliteManager.DATAGRAM_TYPE_KEEP_ALIVE) { builder.setCountOfDatagramTypeKeepAliveSuccess(ADD_COUNT).build(); + } else if (datagramType == SatelliteManager.DATAGRAM_TYPE_SMS) { + builder.setCountOfDatagramTypeSosSmsSuccess(ADD_COUNT) + .setCountOfOutgoingDatagramTypeSmsSuccess(ADD_COUNT); } } @@ -169,6 +172,9 @@ public class ControllerMetricsStats { builder.setCountOfDatagramTypeLocationSharingFail(ADD_COUNT); } else if (datagramType == SatelliteManager.DATAGRAM_TYPE_KEEP_ALIVE) { builder.setCountOfDatagramTypeKeepAliveFail(ADD_COUNT); + } else if (datagramType == SatelliteManager.DATAGRAM_TYPE_SMS) { + builder.setCountOfDatagramTypeSosSmsFail(ADD_COUNT) + .setCountOfOutgoingDatagramTypeSmsFail(ADD_COUNT); } } @@ -177,7 +183,7 @@ public class ControllerMetricsStats { mSatelliteStats.onSatelliteControllerMetrics(controllerParam); } - /** Report a counter when an attempt for incoming datagram is failed */ + /** Increase counters for successful and failed incoming datagram attempts */ public void reportIncomingDatagramCount( @NonNull @SatelliteManager.SatelliteResult int result, boolean isDemoMode) { SatelliteStats.SatelliteControllerParams.Builder builder = @@ -190,9 +196,12 @@ public class ControllerMetricsStats { } } else { if (result == SatelliteManager.SATELLITE_RESULT_SUCCESS) { - builder.setCountOfIncomingDatagramSuccess(ADD_COUNT); + builder.setCountOfIncomingDatagramSuccess(ADD_COUNT) + .setCountOfIncomingDatagramTypeSosSmsSuccess(ADD_COUNT); + } else { - builder.setCountOfIncomingDatagramFail(ADD_COUNT); + builder.setCountOfIncomingDatagramFail(ADD_COUNT) + .setCountOfIncomingDatagramTypeSosSmsFail(ADD_COUNT); } } SatelliteStats.SatelliteControllerParams controllerParam = builder.build(); @@ -200,6 +209,23 @@ public class ControllerMetricsStats { mSatelliteStats.onSatelliteControllerMetrics(controllerParam); } + /** Increase counters for successful and failed incoming ntn sms attempts */ + public void reportIncomingNtnSmsCount( + @NonNull @SatelliteManager.SatelliteResult int result) { + SatelliteStats.SatelliteControllerParams.Builder builder = + new SatelliteStats.SatelliteControllerParams.Builder(); + if (result == SatelliteManager.SATELLITE_RESULT_SUCCESS) { + builder.setCountOfIncomingDatagramTypeSosSmsSuccess(ADD_COUNT) + .setCountOfIncomingDatagramTypeSmsSuccess(ADD_COUNT); + } else { + builder.setCountOfIncomingDatagramTypeSosSmsFail(ADD_COUNT) + .setCountOfIncomingDatagramTypeSmsFail(ADD_COUNT); + } + SatelliteStats.SatelliteControllerParams controllerParam = builder.build(); + logd("reportIncomingNtnSmsCount(): " + controllerParam); + mSatelliteStats.onSatelliteControllerMetrics(controllerParam); + } + /** Report a counter when an attempt for de-provision is success or not */ public void reportProvisionCount(@NonNull @SatelliteManager.SatelliteResult int result) { SatelliteStats.SatelliteControllerParams controllerParam; diff --git a/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java b/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java index 828642c339..93185b2bb1 100644 --- a/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java +++ b/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java @@ -99,7 +99,7 @@ public class EntitlementMetricsStats { logd("reportEntitlementMetrics: " + entitlementParams); CarrierRoamingSatelliteControllerStats.getOrCreateInstance() - .reportCountOfEntitlementStatusQueryRequest(); + .reportCountOfEntitlementStatusQueryRequest(mSubId); } /** Returns the carrier ID of the given subscription id. */ diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java index 0ac0b0e3e4..a7bd9bc131 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java @@ -186,7 +186,7 @@ public class DataNetworkControllerTest extends TelephonyTest { private LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback; private boolean mIsNonTerrestrialNetwork = false; - private ArrayList<Integer> mCarrierSupportedSatelliteServices = new ArrayList<>(); + private ArrayList<Integer> mCarrierSupportedServices = new ArrayList<>(); private final DataProfile mGeneralPurposeDataProfile = new DataProfile.Builder() .setApnSetting(new ApnSetting.Builder() @@ -692,7 +692,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDataSpecificInfo(dsri) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) - .setAvailableServices(mCarrierSupportedSatelliteServices) + .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .build()); @@ -702,7 +702,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setRegistrationState(iwlanRegState) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) - .setAvailableServices(mCarrierSupportedSatelliteServices) + .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .build()); @@ -1124,7 +1124,7 @@ public class DataNetworkControllerTest extends TelephonyTest { doReturn(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED) .when(mSatelliteController) .getSatelliteDataServicePolicyForPlmn(anyInt(), any()); - mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); logd("DataNetworkControllerTest -Setup!"); @@ -1538,15 +1538,144 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testMovingFromInServiceToNoService() throws Exception { testSetupDataNetwork(); - serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + // clear available services at no service + mCarrierSupportedServices.clear(); + + serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. verifyInternetConnected(); + } + + @Test + public void testInServiceAvailableServicesChanged() throws Exception { + testSetupDataNetwork(); + + List<DataDisallowedReason> reasons = mDataNetworkControllerUT + .getInternetDataDisallowedReasons(); + assertThat(reasons).isEmpty(); + + // Add available services sms to existing available services with data + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_SMS); + + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_HOME); - serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, - NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. verifyInternetConnected(); + + + mCarrierSupportedServices.clear(); + // Add available services data and mms + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_MMS); + + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_HOME); + + // Verify we don't tear down the data network. + verifyInternetConnected(); + + // clear all available services + mCarrierSupportedServices.clear(); + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_HOME); + + // Verify internet is not connected + verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + + reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); + assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + + } + + @Test + public void testHomeToRoamingAvailableServicesChangedWithDataRoamingDisabled() + throws Exception { + testSetupDataNetwork(); + + List<DataDisallowedReason> reasons = mDataNetworkControllerUT + .getInternetDataDisallowedReasons(); + assertThat(reasons).isEmpty(); + + // Disable data roaming setting + mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(false); + + // Home to roaming with same available services + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); + + // Verify internet is not connected due to roaming disabled + verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + + reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); + assertThat(reasons).contains(DataDisallowedReason.ROAMING_DISABLED); + } + + @Test + public void testHomeToRoamingAvailableServicesChangedWithDataRoamingEnabled() + throws Exception { + testSetupDataNetwork(); + + List<DataDisallowedReason> reasons = mDataNetworkControllerUT + .getInternetDataDisallowedReasons(); + assertThat(reasons).isEmpty(); + + // Enable data roaming setting + mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(true); + + // Home to roaming with same available services + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); + + // Verify we don't tear down the data network since available services as still data + // with data roaming enabled + verifyInternetConnected(); + + // clear all available services + mCarrierSupportedServices.clear(); + // At roaming + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); + + // Verify internet is not connected + verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + + reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); + assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + } + + @Test + public void testOnAvailableServiceChanged_WithReevaluateNetworkRequest() + throws Exception { + // clear available services at no service + mCarrierSupportedServices.clear(); + + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_HOME); + + // Set network request transport with Internet capability + mDataNetworkControllerUT.addNetworkRequest( + createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET)); + processAllMessages(); + + // Verify internet is not connected due to roaming disabled + verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + + List<DataDisallowedReason> reasons = mDataNetworkControllerUT + .getInternetDataDisallowedReasons(); + assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); + + // add available services with data, re-evaluate network request + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); + serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, + NetworkRegistrationInfo.REGISTRATION_STATE_HOME); + + // Verify now internet was connected + verifyInternetConnected(); + + reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); + assertThat(reasons).isEmpty(); } @Test @@ -1572,7 +1701,6 @@ public class DataNetworkControllerTest extends TelephonyTest { verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS); verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET); - // PS unrestricted, new setup is allowed mDataNetworkControllerUT.obtainMessage(7/*EVENT_PS_RESTRICT_DISABLED*/).sendToTarget(); processAllMessages(); @@ -2129,7 +2257,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -5846,8 +5974,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test public void testNotRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { - mCarrierSupportedSatelliteServices.clear(); - mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); + mCarrierSupportedServices.clear(); + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); @@ -5863,7 +5991,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -5872,8 +6000,8 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testConnection_WithDataServiceCheckFlagDisabled_WithoutDataServiceSupport() throws Exception { doReturn(false).when(mFeatureFlags).dataServiceCheck(); - mCarrierSupportedSatelliteServices.clear(); - mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); + mCarrierSupportedServices.clear(); + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); @@ -5889,7 +6017,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -5897,8 +6025,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test public void testRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { - mCarrierSupportedSatelliteServices.clear(); - mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); + mCarrierSupportedServices.clear(); + mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); @@ -5918,7 +6046,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -5947,7 +6075,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -5982,7 +6110,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -6017,7 +6145,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } @@ -6053,7 +6181,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; - mCarrierSupportedSatelliteServices.clear(); + mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java index 1033db17e6..e99a05466a 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java @@ -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; @@ -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; @@ -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; @@ -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. @@ -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()); + } } diff --git a/tests/telephonytests/src/com/android/internal/telephony/metrics/PersistAtomsStorageTest.java b/tests/telephonytests/src/com/android/internal/telephony/metrics/PersistAtomsStorageTest.java index 7bd82341cd..5bc8e680f5 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/metrics/PersistAtomsStorageTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/metrics/PersistAtomsStorageTest.java @@ -1153,6 +1153,13 @@ public class PersistAtomsStorageTest extends TelephonyTest { mSatelliteController1.countOfP2PSmsAvailableNotificationShown = 3; mSatelliteController1.countOfP2PSmsAvailableNotificationRemoved = 5; mSatelliteController1.isNtnOnlyCarrier = false; + mSatelliteController1.versionOfSatelliteAccessConfig = 10; + mSatelliteController1.countOfIncomingDatagramTypeSosSmsSuccess = 1; + mSatelliteController1.countOfIncomingDatagramTypeSosSmsFail = 2; + mSatelliteController1.countOfOutgoingDatagramTypeSmsSuccess = 3; + mSatelliteController1.countOfOutgoingDatagramTypeSmsFail = 4; + mSatelliteController1.countOfIncomingDatagramTypeSmsSuccess = 5; + mSatelliteController1.countOfIncomingDatagramTypeSmsFail = 6; mSatelliteController2 = new SatelliteController(); mSatelliteController2.countOfSatelliteServiceEnablementsSuccess = 2 + 1; @@ -1187,6 +1194,13 @@ public class PersistAtomsStorageTest extends TelephonyTest { mSatelliteController2.countOfP2PSmsAvailableNotificationShown = 30; mSatelliteController2.countOfP2PSmsAvailableNotificationRemoved = 50; mSatelliteController2.isNtnOnlyCarrier = true; + mSatelliteController2.versionOfSatelliteAccessConfig = 12; + mSatelliteController2.countOfIncomingDatagramTypeSosSmsSuccess = 11; + mSatelliteController2.countOfIncomingDatagramTypeSosSmsFail = 12; + mSatelliteController2.countOfOutgoingDatagramTypeSmsSuccess = 31; + mSatelliteController2.countOfOutgoingDatagramTypeSmsFail = 14; + mSatelliteController2.countOfIncomingDatagramTypeSmsSuccess = 15; + mSatelliteController2.countOfIncomingDatagramTypeSmsFail = 16; // SatelliteController atom has one data point mSatelliteControllers = @@ -4458,6 +4472,20 @@ public class PersistAtomsStorageTest extends TelephonyTest { expected.countOfP2PSmsAvailableNotificationRemoved = mSatelliteController1.countOfP2PSmsAvailableNotificationRemoved * 2; expected.isNtnOnlyCarrier = mSatelliteController1.isNtnOnlyCarrier; + expected.versionOfSatelliteAccessConfig = + mSatelliteController1.versionOfSatelliteAccessConfig; + expected.countOfIncomingDatagramTypeSosSmsSuccess = + mSatelliteController1.countOfIncomingDatagramTypeSosSmsSuccess * 2; + expected.countOfIncomingDatagramTypeSosSmsFail = + mSatelliteController1.countOfIncomingDatagramTypeSosSmsFail * 2; + expected.countOfOutgoingDatagramTypeSmsSuccess = + mSatelliteController1.countOfOutgoingDatagramTypeSmsSuccess * 2; + expected.countOfOutgoingDatagramTypeSmsFail = + mSatelliteController1.countOfOutgoingDatagramTypeSmsFail * 2; + expected.countOfIncomingDatagramTypeSmsSuccess = + mSatelliteController1.countOfIncomingDatagramTypeSmsSuccess * 2; + expected.countOfIncomingDatagramTypeSmsFail = + mSatelliteController1.countOfIncomingDatagramTypeSmsFail * 2; // Service state and service switch should be added successfully verifyCurrentStateSavedToFileOnce(); @@ -4610,6 +4638,26 @@ public class PersistAtomsStorageTest extends TelephonyTest { satelliteController1.countOfP2PSmsAvailableNotificationRemoved + satelliteController2.countOfP2PSmsAvailableNotificationRemoved; expected.isNtnOnlyCarrier = false; + expected.versionOfSatelliteAccessConfig = + mSatelliteController2.versionOfSatelliteAccessConfig; + expected.countOfIncomingDatagramTypeSosSmsSuccess = + mSatelliteController1.countOfIncomingDatagramTypeSosSmsSuccess + + mSatelliteController2.countOfIncomingDatagramTypeSosSmsSuccess; + expected.countOfIncomingDatagramTypeSosSmsFail = + mSatelliteController1.countOfIncomingDatagramTypeSosSmsFail + + mSatelliteController2.countOfIncomingDatagramTypeSosSmsFail; + expected.countOfOutgoingDatagramTypeSmsSuccess = + mSatelliteController1.countOfOutgoingDatagramTypeSmsSuccess + + mSatelliteController2.countOfOutgoingDatagramTypeSmsSuccess; + expected.countOfOutgoingDatagramTypeSmsFail = + mSatelliteController1.countOfOutgoingDatagramTypeSmsFail + + mSatelliteController2.countOfOutgoingDatagramTypeSmsFail; + expected.countOfIncomingDatagramTypeSmsSuccess = + mSatelliteController1.countOfIncomingDatagramTypeSmsSuccess + + mSatelliteController2.countOfIncomingDatagramTypeSmsSuccess; + expected.countOfIncomingDatagramTypeSmsFail = + mSatelliteController1.countOfIncomingDatagramTypeSmsFail + + mSatelliteController2.countOfIncomingDatagramTypeSmsFail; // Service state and service switch should be added successfully verifyCurrentStateSavedToFileOnce(); @@ -6058,6 +6106,20 @@ public class PersistAtomsStorageTest extends TelephonyTest { stats.countOfP2PSmsAvailableNotificationShown); assertEquals(expectedStats.countOfP2PSmsAvailableNotificationRemoved, stats.countOfP2PSmsAvailableNotificationRemoved); + assertEquals(expectedStats.versionOfSatelliteAccessConfig, + stats.versionOfSatelliteAccessConfig); + assertEquals(expectedStats.countOfIncomingDatagramTypeSosSmsSuccess, + stats.countOfIncomingDatagramTypeSosSmsSuccess); + assertEquals(expectedStats.countOfIncomingDatagramTypeSosSmsFail, + stats.countOfIncomingDatagramTypeSosSmsFail); + assertEquals(expectedStats.countOfOutgoingDatagramTypeSmsSuccess, + stats.countOfOutgoingDatagramTypeSmsSuccess); + assertEquals(expectedStats.countOfOutgoingDatagramTypeSmsFail, + stats.countOfOutgoingDatagramTypeSmsFail); + assertEquals(expectedStats.countOfIncomingDatagramTypeSmsSuccess, + stats.countOfIncomingDatagramTypeSmsSuccess); + assertEquals(expectedStats.countOfIncomingDatagramTypeSmsFail, + stats.countOfIncomingDatagramTypeSmsFail); actualCount++; } } diff --git a/tests/telephonytests/src/com/android/internal/telephony/metrics/SatelliteStatsTest.java b/tests/telephonytests/src/com/android/internal/telephony/metrics/SatelliteStatsTest.java index 540f7ffd4d..d438198448 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/metrics/SatelliteStatsTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/metrics/SatelliteStatsTest.java @@ -111,6 +111,13 @@ public class SatelliteStatsTest extends TelephonyTest { .setCountOfP2PSmsAvailableNotificationShown(3) .setCountOfP2PSmsAvailableNotificationRemoved(3) .setIsNtnOnlyCarrier(false) + .setVersionOfSatelliteAccessControl(10) + .setCountOfIncomingDatagramTypeSosSmsSuccess(1) + .setCountOfIncomingDatagramTypeSmsFail(2) + .setCountOfOutgoingDatagramTypeSmsSuccess(3) + .setCountOfOutgoingDatagramTypeSmsFail(4) + .setCountOfIncomingDatagramTypeSmsSuccess(5) + .setCountOfIncomingDatagramTypeSmsFail(6) .build(); mSatelliteStats.onSatelliteControllerMetrics(param); @@ -182,6 +189,20 @@ public class SatelliteStatsTest extends TelephonyTest { stats.countOfP2PSmsAvailableNotificationRemoved); assertEquals(SatelliteStats.SatelliteControllerParams.isNtnOnlyCarrier(), stats.isNtnOnlyCarrier); + assertEquals(SatelliteStats.SatelliteControllerParams.getVersionSatelliteAccessConfig(), + stats.versionOfSatelliteAccessConfig); + assertEquals(param.getCountOfIncomingDatagramTypeSosSmsSuccess(), + stats.countOfIncomingDatagramTypeSosSmsSuccess); + assertEquals(param.getCountOfIncomingDatagramTypeSosSmsFail(), + stats.countOfIncomingDatagramTypeSosSmsFail); + assertEquals(param.getCountOfOutgoingDatagramTypeSmsSuccess(), + stats.countOfOutgoingDatagramTypeSmsSuccess); + assertEquals(param.getCountOfOutgoingDatagramTypeSmsFail(), + stats.countOfOutgoingDatagramTypeSmsFail); + assertEquals(param.getCountOfIncomingDatagramTypeSmsSuccess(), + stats.countOfIncomingDatagramTypeSmsSuccess); + assertEquals(param.getCountOfIncomingDatagramTypeSmsSuccess(), + stats.countOfIncomingDatagramTypeSmsSuccess); verifyNoMoreInteractions(mPersistAtomsStorage); } diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/CarrierRoamingSatelliteControllerStatsTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/CarrierRoamingSatelliteControllerStatsTest.java new file mode 100644 index 0000000000..9b76d3a45d --- /dev/null +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/CarrierRoamingSatelliteControllerStatsTest.java @@ -0,0 +1,595 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony.satellite; + +import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID; + +import static com.android.internal.telephony.satellite.SatelliteConstants.CONFIG_DATA_SOURCE_CONFIG_UPDATER; +import static com.android.internal.telephony.satellite.SatelliteConstants.CONFIG_DATA_SOURCE_ENTITLEMENT; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.clearInvocations; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; + +import com.android.internal.telephony.TelephonyTest; +import com.android.internal.telephony.metrics.SatelliteStats; +import com.android.internal.telephony.satellite.metrics.CarrierRoamingSatelliteControllerStats; +import com.android.internal.telephony.subscription.SubscriptionManagerService; +import com.android.telephony.Rlog; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class CarrierRoamingSatelliteControllerStatsTest extends TelephonyTest { + private static final String TAG = "CarrierRoamingSatelliteControllerStatsTest"; + private static final int TEST_SUB_ID_0 = 0; + private static final int TEST_SUB_ID_1 = 1; + private static final int TEST_CARRIER_ID_0 = 1000; + private static final int TEST_CARRIER_ID_1 = 1111; + private static final long SESSION_TIME = 100L; + private static final long SESSION_GAP_1 = 1000000L; + private static final long SESSION_GAP_2 = 2000000L; + private static final long SESSION_GAP_3 = 4000000L; + + private TestCarrierRoamingSatelliteControllerStats mTestCarrierRoamingSatelliteControllerStats; + @Mock + private SatelliteStats mMockSatelliteStats; + @Mock + private SubscriptionManagerService mMockSubscriptionManagerService; + + @Before + public void setUp() throws Exception { + super.setUp(getClass().getSimpleName()); + MockitoAnnotations.initMocks(this); + logd(TAG + " Setup!"); + BackupAndRestoreCarrierRoamContParam.backUpStaticParams(); + replaceInstance(SatelliteStats.class, "sInstance", null, mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats = + new TestCarrierRoamingSatelliteControllerStats(); + replaceInstance(SubscriptionManagerService.class, "sInstance", null, + mMockSubscriptionManagerService); + } + + @After + public void tearDown() throws Exception { + Rlog.d(TAG, "tearDown()"); + BackupAndRestoreCarrierRoamContParam.restoreStaticParams(); + super.tearDown(); + } + + @Test + public void testReportConfigDataSource() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + + initializeStaticParams(); + expected.initializeParams(); + expected.setConfigDataSource(CONFIG_DATA_SOURCE_ENTITLEMENT); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportConfigDataSource(TEST_SUB_ID_0, + CONFIG_DATA_SOURCE_ENTITLEMENT); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setConfigDataSource(CONFIG_DATA_SOURCE_CONFIG_UPDATER); + expected.setCarrierId(TEST_CARRIER_ID_1); + expected.setIsMultiSim(true); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportConfigDataSource(TEST_SUB_ID_1, + CONFIG_DATA_SOURCE_CONFIG_UPDATER); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testReportCountOfEntitlementStatusQueryRequest() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfEntitlementStatusQueryRequest(1); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfEntitlementStatusQueryRequest( + TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfEntitlementStatusQueryRequest(1); + expected.setCarrierId(TEST_CARRIER_ID_1); + expected.setIsMultiSim(true); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfEntitlementStatusQueryRequest( + TEST_SUB_ID_1); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testReportCountOfSatelliteConfigUpdateRequest() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfSatelliteConfigUpdateRequest(1); + expected.setCarrierId(UNKNOWN_CARRIER_ID); + expected.setIsMultiSim(false); + + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteConfigUpdateRequest(); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfSatelliteConfigUpdateRequest(1); + expected.setCarrierId(UNKNOWN_CARRIER_ID); + expected.setIsMultiSim(true); + + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteConfigUpdateRequest(); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testReportCountOfSatelliteNotificationDisplayed() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfSatelliteNotificationDisplayed(1); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteNotificationDisplayed( + TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCountOfSatelliteNotificationDisplayed(1); + expected.setCarrierId(TEST_CARRIER_ID_1); + expected.setIsMultiSim(true); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCountOfSatelliteNotificationDisplayed( + TEST_SUB_ID_1); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testReportCarrierId() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCarrierId(TEST_CARRIER_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCarrierId(TEST_CARRIER_ID_1); + expected.setIsMultiSim(true); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportCarrierId(TEST_CARRIER_ID_1); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testReportIsDeviceEntitled() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setIsDeviceEntitled(true); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(TEST_SUB_ID_0, true); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + doReturn(new int[]{TEST_SUB_ID_0, TEST_SUB_ID_1}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setIsDeviceEntitled(false); + expected.setCarrierId(TEST_CARRIER_ID_1); + expected.setIsMultiSim(true); + clearInvocations(mMockSatelliteStats); + mTestCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(TEST_SUB_ID_1, false); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + @Test + public void testSatelliteSessionGaps() { + final ExpectedCarrierRoamingSatelliteControllerStatsParam expected = + new ExpectedCarrierRoamingSatelliteControllerStatsParam(); + doReturn(new int[]{TEST_SUB_ID_0}).when( + mMockSubscriptionManagerService).getActiveSubIdList(anyBoolean()); + initializeStaticParams(); + expected.initializeParams(); + expected.setCarrierId(TEST_CARRIER_ID_0); + expected.setIsMultiSim(false); + clearInvocations(mMockSatelliteStats); + // first satellite session starts + mTestCarrierRoamingSatelliteControllerStats.setCurrentTime(0L); + // session counter is increased when session starts + expected.setCountOfSatelliteSessions(1); + mTestCarrierRoamingSatelliteControllerStats.onSessionStart(TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // first satellite session ends + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_TIME); + mTestCarrierRoamingSatelliteControllerStats.onSessionEnd(TEST_SUB_ID_0); + + // session gaps would be 0 + expected.setSatelliteSessionGapMinSec(0); + expected.setSatelliteSessionGapAvgSec(0); + expected.setSatelliteSessionGapMaxSec(0); + // session counter is not reported when session ends + expected.setCountOfSatelliteSessions(0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // second session starts, gap between 1st and 2nd session is 1000sec + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_GAP_1); + expected.setCountOfSatelliteSessions(1); + mTestCarrierRoamingSatelliteControllerStats.onSessionStart(TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // second session end + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_TIME); + mTestCarrierRoamingSatelliteControllerStats.onSessionEnd(TEST_SUB_ID_0); + + // session gap min / avg / max would be 1000 each + expected.setSatelliteSessionGapMinSec(1000); + expected.setSatelliteSessionGapAvgSec(1000); + expected.setSatelliteSessionGapMaxSec(1000); + expected.setCountOfSatelliteSessions(0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // 3rd session starts, gap between 2nd and 3rd session is 2000 + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_GAP_2); + expected.setCountOfSatelliteSessions(1); + mTestCarrierRoamingSatelliteControllerStats.onSessionStart(TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // 3rd session end + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_TIME); + mTestCarrierRoamingSatelliteControllerStats.onSessionEnd(TEST_SUB_ID_0); + + // session gap min would be 1000 + expected.setSatelliteSessionGapMinSec(1000); + // session gap avg would be 1500 + int avgGapSec = (int) ((SESSION_GAP_1 + SESSION_GAP_2) / (2 * 1000)); + expected.setSatelliteSessionGapAvgSec(avgGapSec); + // session gap max would be 2000 + expected.setSatelliteSessionGapMaxSec(2000); + expected.setCountOfSatelliteSessions(0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // 4th session starts, gap between 3rd and 4th session is 4000 + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_GAP_3); + expected.setCountOfSatelliteSessions(1); + mTestCarrierRoamingSatelliteControllerStats.onSessionStart(TEST_SUB_ID_0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + + clearInvocations(mMockSatelliteStats); + // 4th session end + mTestCarrierRoamingSatelliteControllerStats.increaseCurrentTime(SESSION_TIME); + mTestCarrierRoamingSatelliteControllerStats.onSessionEnd(TEST_SUB_ID_0); + + // session gap min would be 1000 + expected.setSatelliteSessionGapMinSec(1000); + // session gap avg would be 2333 + avgGapSec = (int) ((SESSION_GAP_1 + SESSION_GAP_2 + SESSION_GAP_3) / (3 * 1000)); + expected.setSatelliteSessionGapAvgSec(avgGapSec); + // session gap max would be 4000 + expected.setSatelliteSessionGapMaxSec(4000); + expected.setCountOfSatelliteSessions(0); + verify(mMockSatelliteStats, times(1)).onCarrierRoamingSatelliteControllerStatsMetrics( + ArgumentMatchers.argThat(argument -> verifyAssets(expected, argument))); + } + + private static class BackupAndRestoreCarrierRoamContParam { + private static int sSatelliteSessionGapMinSec; + private static int sSatelliteSessionGapAvgSec; + private static int sSatelliteSessionGapMaxSec; + private static int sCarrierId; + private static boolean sIsDeviceEntitled; + private static boolean sIsMultiSim; + + public static void backUpStaticParams() { + SatelliteStats.CarrierRoamingSatelliteControllerStatsParams param = + new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() + .build(); + sSatelliteSessionGapMinSec = param.getSatelliteSessionGapMinSec(); + sSatelliteSessionGapAvgSec = param.getSatelliteSessionGapAvgSec(); + sSatelliteSessionGapMaxSec = param.getSatelliteSessionGapMaxSec(); + sCarrierId = param.getCarrierId(); + sIsDeviceEntitled = param.isDeviceEntitled(); + sIsMultiSim = param.isMultiSim(); + } + + public static void restoreStaticParams() { + SatelliteStats.getInstance().onCarrierRoamingSatelliteControllerStatsMetrics( + new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() + .setSatelliteSessionGapMinSec(sSatelliteSessionGapMinSec) + .setSatelliteSessionGapAvgSec(sSatelliteSessionGapAvgSec) + .setSatelliteSessionGapMaxSec(sSatelliteSessionGapMaxSec) + .setCarrierId(sCarrierId) + .setIsDeviceEntitled(sIsDeviceEntitled) + .setIsMultiSim(sIsMultiSim) + .build()); + } + } + + private void initializeStaticParams() { + SatelliteStats.getInstance().onCarrierRoamingSatelliteControllerStatsMetrics( + new SatelliteStats.CarrierRoamingSatelliteControllerStatsParams.Builder() + .setSatelliteSessionGapMinSec(0) + .setSatelliteSessionGapAvgSec(0) + .setSatelliteSessionGapMaxSec(0) + .setCarrierId(UNKNOWN_CARRIER_ID) + .setIsDeviceEntitled(false) + .setIsMultiSim(false) + .build()); + } + + private boolean verifyAssets(ExpectedCarrierRoamingSatelliteControllerStatsParam expected, + SatelliteStats.CarrierRoamingSatelliteControllerStatsParams actual) { + assertEquals(expected.getConfigDataSource(), actual.getConfigDataSource()); + assertEquals(expected.getCountOfEntitlementStatusQueryRequest(), + actual.getCountOfEntitlementStatusQueryRequest()); + assertEquals(expected.getCountOfSatelliteConfigUpdateRequest(), + actual.getCountOfSatelliteConfigUpdateRequest()); + assertEquals(expected.getCountOfSatelliteNotificationDisplayed(), + actual.getCountOfSatelliteNotificationDisplayed()); + assertEquals(expected.getSatelliteSessionGapMinSec(), + actual.getSatelliteSessionGapMinSec()); + assertEquals(expected.getSatelliteSessionGapAvgSec(), + actual.getSatelliteSessionGapAvgSec()); + assertEquals(expected.getSatelliteSessionGapMaxSec(), + actual.getSatelliteSessionGapMaxSec()); + assertEquals(expected.getCarrierId(), actual.getCarrierId()); + assertEquals(expected.isDeviceEntitled(), actual.isDeviceEntitled()); + assertEquals(expected.isMultiSim(), actual.isMultiSim()); + assertEquals(expected.getCountOfSatelliteSessions(), actual.getCountOfSatelliteSessions()); + return true; + } + + private static class ExpectedCarrierRoamingSatelliteControllerStatsParam { + private int mConfigDataSource; + private int mCountOfEntitlementStatusQueryRequest; + private int mCountOfSatelliteConfigUpdateRequest; + private int mCountOfSatelliteNotificationDisplayed; + private int mSatelliteSessionGapMinSec; + private int mSatelliteSessionGapAvgSec; + private int mSatelliteSessionGapMaxSec; + private int mCarrierId; + private boolean mIsDeviceEntitled; + private boolean mIsMultiSim; + private int mCountOfSatelliteSessions; + + public int getConfigDataSource() { + return mConfigDataSource; + } + + public int getCountOfEntitlementStatusQueryRequest() { + return mCountOfEntitlementStatusQueryRequest; + } + + public int getCountOfSatelliteConfigUpdateRequest() { + return mCountOfSatelliteConfigUpdateRequest; + } + + public int getCountOfSatelliteNotificationDisplayed() { + return mCountOfSatelliteNotificationDisplayed; + } + + public int getSatelliteSessionGapMinSec() { + return mSatelliteSessionGapMinSec; + } + + public int getSatelliteSessionGapAvgSec() { + return mSatelliteSessionGapAvgSec; + } + + public int getSatelliteSessionGapMaxSec() { + return mSatelliteSessionGapMaxSec; + } + + public int getCarrierId() { + return mCarrierId; + } + + public boolean isDeviceEntitled() { + return mIsDeviceEntitled; + } + + public boolean isMultiSim() { + return mIsMultiSim; + } + + public int getCountOfSatelliteSessions() { + return mCountOfSatelliteSessions; + } + + + public void setConfigDataSource(int configDataSource) { + mConfigDataSource = configDataSource; + } + + public void setCountOfEntitlementStatusQueryRequest( + int countOfEntitlementStatusQueryRequest) { + mCountOfEntitlementStatusQueryRequest = countOfEntitlementStatusQueryRequest; + } + + public void setCountOfSatelliteConfigUpdateRequest( + int countOfSatelliteConfigUpdateRequest) { + mCountOfSatelliteConfigUpdateRequest = countOfSatelliteConfigUpdateRequest; + } + + public void setCountOfSatelliteNotificationDisplayed( + int countOfSatelliteNotificationDisplayed) { + mCountOfSatelliteNotificationDisplayed = countOfSatelliteNotificationDisplayed; + } + + public void setSatelliteSessionGapMinSec(int satelliteSessionGapMinSec) { + mSatelliteSessionGapMinSec = satelliteSessionGapMinSec; + } + + public void setSatelliteSessionGapAvgSec(int satelliteSessionGapAvgSec) { + mSatelliteSessionGapAvgSec = satelliteSessionGapAvgSec; + } + + public void setSatelliteSessionGapMaxSec(int satelliteSessionGapMaxSec) { + mSatelliteSessionGapMaxSec = satelliteSessionGapMaxSec; + } + + public void setCarrierId(int carrierId) { + mCarrierId = carrierId; + } + + public void setIsDeviceEntitled(boolean isDeviceEntitled) { + mIsDeviceEntitled = isDeviceEntitled; + } + + public void setIsMultiSim(boolean isMultiSim) { + mIsMultiSim = isMultiSim; + } + + public void setCountOfSatelliteSessions(int countOfSatelliteSessions) { + mCountOfSatelliteSessions = countOfSatelliteSessions; + } + + public void initializeParams() { + mConfigDataSource = SatelliteConstants.CONFIG_DATA_SOURCE_UNKNOWN; + mCountOfEntitlementStatusQueryRequest = 0; + mCountOfSatelliteConfigUpdateRequest = 0; + mCountOfSatelliteNotificationDisplayed = 0; + mSatelliteSessionGapMinSec = 0; + mSatelliteSessionGapAvgSec = 0; + mSatelliteSessionGapMaxSec = 0; + mCarrierId = UNKNOWN_CARRIER_ID; + mIsDeviceEntitled = false; + mIsMultiSim = false; + mCountOfSatelliteSessions = 0; + } + } + + static class TestCarrierRoamingSatelliteControllerStats extends + CarrierRoamingSatelliteControllerStats { + private long mCurrentTime; + TestCarrierRoamingSatelliteControllerStats() { + super(); + logd("constructing TestCarrierRoamingSatelliteControllerStats"); + } + + @Override + public int getCarrierIdFromSubscription(int subId) { + logd("getCarrierIdFromSubscription()"); + if (subId == TEST_SUB_ID_0) { + return TEST_CARRIER_ID_0; + } else if (subId == TEST_SUB_ID_1) { + return TEST_CARRIER_ID_1; + } else { + return UNKNOWN_CARRIER_ID; + } + } + + @Override + public long getCurrentTime() { + return mCurrentTime; + } + + public void setCurrentTime(long currentTime) { + mCurrentTime = currentTime; + } + + public void increaseCurrentTime(long incTime) { + mCurrentTime += incTime; + } + } +} |