diff options
author | 2025-02-10 06:55:48 +0000 | |
---|---|---|
committer | 2025-02-24 22:56:32 -0800 | |
commit | d2c4d5885d8935186ef73fcca1032e7555e50782 (patch) | |
tree | fcde1afa02755b8688ed98995525e90cce81e248 | |
parent | 74968249f83b42d4f82e122ec0bed8c8889357c7 (diff) |
Add Satellite Data Metrics Support
- Add Satellite services supported at satellite network session.
- Add Satellite service data policy supported at satellite network
session.
- Add Satellite Data consumed at satellite network sessions.
Flag: EXEMPT BugFix
Bug: 373149631
Test: m and atest
Test: Device test at b/373149631#comment33
Change-Id: Iac92467882421bb84724f5b66256ac3f25c1b5b9
8 files changed, 296 insertions, 17 deletions
diff --git a/proto/src/persist_atoms.proto b/proto/src/persist_atoms.proto index 37a61b2e99..34424c1668 100644 --- a/proto/src/persist_atoms.proto +++ b/proto/src/persist_atoms.proto @@ -822,6 +822,9 @@ message CarrierRoamingSatelliteSession { optional int32 count_of_outgoing_sms = 14; optional int32 count_of_incoming_mms = 15; optional int32 count_of_outgoing_mms = 16; + repeated int32 supported_satellite_services = 17; + optional int32 service_data_policy = 18; + optional int64 satellite_data_consumed_bytes = 19; } message CarrierRoamingSatelliteControllerStats { @@ -842,6 +845,9 @@ message SatelliteEntitlement { optional int32 entitlement_status = 3; optional bool is_retry = 4; optional int32 count = 5; + optional bool is_allowed_service_entitlement = 6; + repeated int32 entitlement_service_type = 7; + optional int32 entitlement_data_policy = 8; } message SatelliteConfigUpdater { diff --git a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java index e925e1a742..e8db5506be 100644 --- a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java +++ b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java @@ -1593,7 +1593,10 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback { stats.countOfIncomingSms, stats.countOfOutgoingSms, stats.countOfIncomingMms, - stats.countOfOutgoingMms); + stats.countOfOutgoingMms, + stats.supportedSatelliteServices, + stats.serviceDataPolicy, + stats.satelliteDataConsumedBytes); } private static StatsEvent buildStatsEvent(CarrierRoamingSatelliteControllerStats stats) { @@ -1617,7 +1620,10 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback { stats.result, stats.entitlementStatus, stats.isRetry, - stats.count); + stats.count, + stats.isAllowedServiceEntitlement, + stats.entitlementServiceType, + stats.entitlementDataPolicy); } private static StatsEvent buildStatsEvent(SatelliteConfigUpdater stats) { diff --git a/src/java/com/android/internal/telephony/metrics/SatelliteStats.java b/src/java/com/android/internal/telephony/metrics/SatelliteStats.java index 6ae86f3e66..8a1b5b4bd3 100644 --- a/src/java/com/android/internal/telephony/metrics/SatelliteStats.java +++ b/src/java/com/android/internal/telephony/metrics/SatelliteStats.java @@ -16,8 +16,8 @@ package com.android.internal.telephony.metrics; -import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_NONE; import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID; +import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_NONE; import static com.android.internal.telephony.satellite.SatelliteConstants.TRIGGERING_EVENT_UNKNOWN; @@ -1762,6 +1762,9 @@ public class SatelliteStats { private final int mCountOfOutgoingSms; private final int mCountOfIncomingMms; private final int mCountOfOutgoingMms; + private final int[] mSupportedSatelliteServices; + private final int mServiceDataPolicy; + private final long mSatelliteDataConsumedBytes; private CarrierRoamingSatelliteSessionParams(Builder builder) { this.mCarrierId = builder.mCarrierId; @@ -1781,6 +1784,10 @@ public class SatelliteStats { this.mCountOfOutgoingSms = builder.mCountOfOutgoingSms; this.mCountOfIncomingMms = builder.mCountOfIncomingMms; this.mCountOfOutgoingMms = builder.mCountOfOutgoingMms; + this.mSupportedSatelliteServices = builder.mSupportedSatelliteServices; + this.mServiceDataPolicy = builder.mServiceDataPolicy; + this.mSatelliteDataConsumedBytes = + builder.mSatelliteDataConsumedBytes; } public int getCarrierId() { @@ -1847,6 +1854,19 @@ public class SatelliteStats { return mCountOfOutgoingMms; } + public int[] getSupportedSatelliteServices() { + return mSupportedSatelliteServices; + } + + + public int getServiceDataPolicy() { + return mServiceDataPolicy; + } + + public long getSatelliteDataConsumedBytes() { + return mSatelliteDataConsumedBytes; + } + /** * A builder class to create {@link CarrierRoamingSatelliteSessionParams} data structure * class @@ -1868,6 +1888,10 @@ public class SatelliteStats { private int mCountOfOutgoingSms = 0; private int mCountOfIncomingMms = 0; private int mCountOfOutgoingMms = 0; + private int[] mSupportedSatelliteServices = new int[0]; + int mServiceDataPolicy = + SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN; + long mSatelliteDataConsumedBytes = 0L; /** * Sets carrierId value of {@link CarrierRoamingSatelliteSession} atom @@ -2017,6 +2041,34 @@ public class SatelliteStats { } /** + * Sets supportedSatelliteServices value of {@link CarrierRoamingSatelliteSession} + * atom then returns Builder class + */ + public Builder setSupportedSatelliteServices(int[] supportedSatelliteServices) { + this.mSupportedSatelliteServices = supportedSatelliteServices; + return this; + } + + /** + * Sets serviceDataPolicy value of {@link CarrierRoamingSatelliteSession} + * atom then returns Builder class + */ + public Builder setServiceDataPolicy(int serviceDataPolicy) { + this.mServiceDataPolicy = serviceDataPolicy; + return this; + } + + /** + * Sets satelliteDataConsumedPerSessionBytes value of + * {@link CarrierRoamingSatelliteSession} atom then returns Builder class + */ + public Builder setSatelliteDataConsumedBytes( + long satelliteDataConsumedPerSessionBytes) { + this.mSatelliteDataConsumedBytes = satelliteDataConsumedPerSessionBytes; + return this; + } + + /** * Returns CarrierRoamingSatelliteSessionParams, which contains whole component of * {@link CarrierRoamingSatelliteSession} atom */ @@ -2046,6 +2098,9 @@ public class SatelliteStats { + ", countOfOutgoingSms=" + mCountOfOutgoingSms + ", countOfIncomingMms=" + mCountOfIncomingMms + ", countOfOutgoingMms=" + mCountOfOutgoingMms + + ", supportedSatelliteServices=" + Arrays.toString(mSupportedSatelliteServices) + + ", serviceDataPolicy=" + mServiceDataPolicy + + ", SatelliteDataConsumedBytes=" + mSatelliteDataConsumedBytes + ")"; } } @@ -2258,6 +2313,9 @@ public class SatelliteStats { private final int mEntitlementStatus; private final boolean mIsRetry; private final int mCount; + private final boolean mIsAllowedServiceEntitlement; + private final int[] mEntitlementServiceType; + private final int mEntitlementDataPolicy; private SatelliteEntitlementParams(Builder builder) { this.mCarrierId = builder.mCarrierId; @@ -2265,6 +2323,9 @@ public class SatelliteStats { this.mEntitlementStatus = builder.mEntitlementStatus; this.mIsRetry = builder.mIsRetry; this.mCount = builder.mCount; + this.mIsAllowedServiceEntitlement = builder.mIsAllowedServiceEntitlement; + this.mEntitlementServiceType = builder.mEntitlementServiceType; + this.mEntitlementDataPolicy = builder.mEntitlementDataPolicy; } public int getCarrierId() { @@ -2287,6 +2348,18 @@ public class SatelliteStats { return mCount; } + public boolean getIsAllowedServiceEntitlement() { + return mIsAllowedServiceEntitlement; + } + + public int[] getEntitlementServiceType() { + return mEntitlementServiceType; + } + + public int getEntitlementDataPolicy() { + return mEntitlementDataPolicy; + } + /** * A builder class to create {@link SatelliteEntitlementParams} data structure class */ @@ -2296,6 +2369,10 @@ public class SatelliteStats { private int mEntitlementStatus = -1; private boolean mIsRetry = false; private int mCount = -1; + private boolean mIsAllowedServiceEntitlement = false; + private int[] mEntitlementServiceType = new int[0]; + private int mEntitlementDataPolicy = + SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN; /** * Sets carrierId value of {@link SatelliteEntitlement} atom @@ -2343,6 +2420,33 @@ public class SatelliteStats { } /** + * Sets isAllowedServiceEntitlement value of {@link SatelliteEntitlement} atom + * then returns Builder class + */ + public Builder setIsAllowedServiceEntitlement(boolean isAllowedServiceEntitlement) { + this.mIsAllowedServiceEntitlement = isAllowedServiceEntitlement; + return this; + } + + /** + * Sets entitlementServiceType value of {@link SatelliteEntitlement} atom + * then returns Builder class + */ + public Builder setEntitlementServiceType(int[] entitlementServiceType) { + this.mEntitlementServiceType = entitlementServiceType; + return this; + } + + /** + * Sets entitlementDataPolicy value of {@link SatelliteEntitlement} atom + * then returns Builder class + */ + public Builder setEntitlementDataPolicy(int entitlementDataPolicy) { + this.mEntitlementDataPolicy = entitlementDataPolicy; + return this; + } + + /** * Returns SatelliteEntitlementParams, which contains whole component of * {@link SatelliteEntitlement} atom */ @@ -2359,7 +2463,10 @@ public class SatelliteStats { + ", result=" + mResult + ", entitlementStatus=" + mEntitlementStatus + ", isRetry=" + mIsRetry - + ", count=" + mCount + ")"; + + ", count=" + mCount + + ",isAllowedServiceEntitlement=" + mIsAllowedServiceEntitlement + + ",entitlementServiceType=" + Arrays.toString(mEntitlementServiceType) + + ",entitlementServicePolicy=" + mEntitlementDataPolicy + ")"; } } @@ -2831,6 +2938,9 @@ public class SatelliteStats { proto.countOfOutgoingSms = param.mCountOfOutgoingSms; proto.countOfIncomingMms = param.mCountOfIncomingMms; proto.countOfOutgoingMms = param.mCountOfOutgoingMms; + proto.supportedSatelliteServices = param.mSupportedSatelliteServices; + proto.serviceDataPolicy = param.mServiceDataPolicy; + proto.satelliteDataConsumedBytes = param.mSatelliteDataConsumedBytes; mAtomsStorage.addCarrierRoamingSatelliteSessionStats(proto); } @@ -2858,6 +2968,9 @@ public class SatelliteStats { proto.entitlementStatus = param.getEntitlementStatus(); proto.isRetry = param.getIsRetry(); proto.count = param.getCount(); + proto.isAllowedServiceEntitlement = param.getIsAllowedServiceEntitlement(); + proto.entitlementServiceType = param.getEntitlementServiceType(); + proto.entitlementDataPolicy = param.getEntitlementDataPolicy(); mAtomsStorage.addSatelliteEntitlementStats(proto); } diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteConstants.java b/src/java/com/android/internal/telephony/satellite/SatelliteConstants.java index e81a708bfa..866969fd16 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteConstants.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteConstants.java @@ -124,4 +124,18 @@ public class SatelliteConstants { }) @Retention(RetentionPolicy.SOURCE) public @interface TriggeringEvent {} + + public static final int SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN = 0; + public static final int SATELLITE_ENTITLEMENT_SERVICE_POLICY_RESTRICTED = 1; + public static final int SATELLITE_ENTITLEMENT_SERVICE_POLICY_CONSTRAINED = 2; + public static final int SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNCONSTRAINED = 3; + + @IntDef(prefix = {"SATELLITE_ENTITLEMENT_SERVICE_POLICY_"}, value = { + SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN, + SATELLITE_ENTITLEMENT_SERVICE_POLICY_RESTRICTED, + SATELLITE_ENTITLEMENT_SERVICE_POLICY_CONSTRAINED, + SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNCONSTRAINED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SatelliteEntitlementServicePolicy {} } diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java index bd0f7665ff..642b74a344 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java @@ -68,6 +68,7 @@ import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCC import static com.android.internal.telephony.configupdate.ConfigProviderAdaptor.DOMAIN_SATELLITE; import android.annotation.ArrayRes; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AlertDialog; @@ -183,6 +184,8 @@ import com.android.internal.telephony.util.TelephonyUtils; import com.android.internal.telephony.util.WorkerThread; import com.android.internal.util.FunctionalUtils; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -693,6 +696,12 @@ public class SatelliteController extends Handler { // Data Plan types at entitlement for the plmn allowed public static final int SATELLITE_DATA_PLAN_METERED = 0; public static final int SATELLITE_DATA_PLAN_UNMETERED = 1; + @IntDef(prefix = {"SATELLITE_DATA_PLAN_"}, value = { + SATELLITE_DATA_PLAN_METERED, + SATELLITE_DATA_PLAN_UNMETERED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SatelliteDataPlan {} private BroadcastReceiver mDefaultSmsSubscriptionChangedBroadcastReceiver = new BroadcastReceiver() { @Override @@ -4194,19 +4203,27 @@ public class SatelliteController extends Handler { } /** - * To use the satellite service, update the EntitlementStatus and the PlmnAllowedList after - * receiving the satellite configuration from the entitlement server. If satellite - * entitlement is enabled, enable satellite for the carrier. Otherwise, disable satellite. + * To use the satellite service, update the EntitlementStatus, PlmnAllowedList, barred plmn list + * data plan, service type, data service policy and voice service policy after receiving the + * satellite configuration from the entitlement server. If satellite entitlement is enabled, + * enable satellite for the carrier. Otherwise, disable satellite. * * @param subId subId * @param entitlementEnabled {@code true} Satellite service enabled * @param allowedPlmnList plmn allowed list to use the satellite service * @param barredPlmnList plmn barred list to pass the modem - * @param plmnDataPlanMap data plan map for the plmn - * @param plmnServiceTypeMap available services map for the plmn - * @param plmnDataServicePolicyMap data service policy map for the plmn - * @param plmnVoiceServicePolicyMap voice service policy map for the plmn - * @param callback callback for accept + * @param plmnDataPlanMap data plan map for the plmn with key as plmn and data plan as value + * with possible values {@link SatelliteDataPlan} + * @param plmnServiceTypeMap available services map for the plmn with key as plmn and service + * type as list of integer values with possible values + * {@link NetworkRegistrationInfo#ServiceType} + * @param plmnDataServicePolicyMap data service policy map for the plmn with key as plmn and + * data service policy as integer value with possible values + * {@link CarrierConfigManager#SATELLITE_DATA_SUPPORT_MODE} + * @param plmnVoiceServicePolicyMap voice service policy map for the plmn with key as plmn and + * voice service policy as integer value with possible values + * @link CarrierConfigManager#SATELLITE_DATA_SUPPORT_MODE} + * @param callback callback for accept */ public void onSatelliteEntitlementStatusUpdated(int subId, boolean entitlementEnabled, @Nullable List<String> allowedPlmnList, @Nullable List<String> barredPlmnList, @@ -6039,6 +6056,36 @@ public class SatelliteController extends Handler { } } + /** + * map data policy to support unknown case at metrics + * @param dataPolicy data support mode for the service type + * @return corresponding value from {@link SatelliteConstants.SatelliteEntitlementServicePolicy} + * + */ + @SatelliteConstants.SatelliteEntitlementServicePolicy + public int mapDataPolicyForMetrics(int dataPolicy) { + switch (dataPolicy) { + case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED -> { + return SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_RESTRICTED; + } + case CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED -> { + return SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_CONSTRAINED; + } + case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL -> { + return SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNCONSTRAINED; + } + } + return SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN; + } + + private int[] getSupportedSatelliteServicesOnSessionStart(List<Integer> supportedServices) { + if (supportedServices == null || supportedServices.isEmpty()) { + return new int[0]; + } + + return supportedServices.stream().mapToInt(Integer::intValue).toArray(); + } + private void logCarrierRoamingSatelliteSessionStats(@NonNull Phone phone, boolean lastNotifiedNtnMode, boolean currNtnMode) { synchronized (mSatelliteConnectedLock) { @@ -6047,7 +6094,15 @@ public class SatelliteController extends Handler { // Log satellite session start CarrierRoamingSatelliteSessionStats sessionStats = CarrierRoamingSatelliteSessionStats.getInstance(subId); - sessionStats.onSessionStart(phone.getCarrierId(), phone); + int[] supported_satellite_services = + getSupportedSatelliteServicesOnSessionStart( + getSupportedSatelliteServicesForPlmn(subId, + phone.getServiceState().getOperatorNumeric())); + int dataPolicy = mapDataPolicyForMetrics(getSatelliteDataServicePolicyForPlmn(subId, + phone.getServiceState().getOperatorNumeric())); + + sessionStats.onSessionStart(phone.getCarrierId(), phone, + supported_satellite_services, dataPolicy); mCarrierRoamingSatelliteSessionStatsMap.put(subId, sessionStats); } else if (lastNotifiedNtnMode && !currNtnMode) { // Log satellite session end diff --git a/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteSessionStats.java b/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteSessionStats.java index 3138b16cba..b55e485062 100644 --- a/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteSessionStats.java +++ b/src/java/com/android/internal/telephony/satellite/metrics/CarrierRoamingSatelliteSessionStats.java @@ -17,6 +17,10 @@ package com.android.internal.telephony.satellite.metrics; import android.annotation.NonNull; +import android.app.usage.NetworkStats; +import android.app.usage.NetworkStatsManager; +import android.content.Context; +import android.net.NetworkTemplate; import android.telephony.CellInfo; import android.telephony.CellSignalStrength; import android.telephony.CellSignalStrengthLte; @@ -24,18 +28,22 @@ import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; +import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; import com.android.internal.telephony.MccTable; import com.android.internal.telephony.Phone; import com.android.internal.telephony.metrics.SatelliteStats; +import com.android.internal.telephony.satellite.SatelliteConstants; import com.android.internal.telephony.subscription.SubscriptionInfoInternal; import com.android.internal.telephony.subscription.SubscriptionManagerService; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Set; public class CarrierRoamingSatelliteSessionStats { private static final String TAG = CarrierRoamingSatelliteSessionStats.class.getSimpleName(); @@ -49,12 +57,17 @@ public class CarrierRoamingSatelliteSessionStats { private int mCountOfIncomingMms; private int mCountOfOutgoingMms; private long mIncomingMessageId; - private int mSessionStartTimeSec; private List<Long> mConnectionStartTimeList; private List<Long> mConnectionEndTimeList; private List<Integer> mRsrpList; private List<Integer> mRssnrList; + private int[] mSupportedSatelliteServices; + private int mServiceDataPolicy; + private Phone mPhone; + private Context mContext; + private long mSatelliteDataConsumedBytes = 0L; + private long mDataUsageOnSessionStartBytes = 0L; public CarrierRoamingSatelliteSessionStats(int subId) { logd("Create new CarrierRoamingSatelliteSessionStats. subId=" + subId); @@ -74,11 +87,18 @@ public class CarrierRoamingSatelliteSessionStats { } /** Log carrier roaming satellite session start */ - public void onSessionStart(int carrierId, Phone phone) { + public void onSessionStart(int carrierId, Phone phone, int[] supportedServices, + int serviceDataPolicy) { + mPhone = phone; + mContext = mPhone.getContext(); mCarrierId = carrierId; + mSupportedSatelliteServices = supportedServices; + mServiceDataPolicy = serviceDataPolicy; mSessionStartTimeSec = getCurrentTimeInSec(); mIsNtnRoamingInHomeCountry = false; - onConnectionStart(phone); + onConnectionStart(mPhone); + mDataUsageOnSessionStartBytes = getDataUsage(); + logd("current data consumed: " + mDataUsageOnSessionStartBytes); } /** Log carrier roaming satellite connection start */ @@ -87,11 +107,51 @@ public class CarrierRoamingSatelliteSessionStats { updateNtnRoamingInHomeCountry(phone); } + /** calculate total satellite data consumed at the session */ + private long getDataUsage() { + if (mContext == null) { + return 0L; + } + + NetworkStatsManager networkStatsManager = + mContext.getSystemService(NetworkStatsManager.class); + + if (networkStatsManager != null) { + final NetworkTemplate.Builder builder = + new NetworkTemplate.Builder(NetworkTemplate.MATCH_MOBILE); + final String subscriberId = mPhone.getSubscriberId(); + logd("subscriber id for data consumed:" + subscriberId); + + if (!TextUtils.isEmpty(subscriberId)) { + builder.setSubscriberIds(Set.of(subscriberId)); + // Consider data usage calculation of only metered capabilities / data network + builder.setMeteredness(android.net.NetworkStats.METERED_YES); + NetworkTemplate template = builder.build(); + final NetworkStats.Bucket ret = networkStatsManager + .querySummaryForDevice(template, 0L, System.currentTimeMillis()); + return ret.getRxBytes() + ret.getTxBytes(); + } + } + return 0L; + } + /** Log carrier roaming satellite session end */ public void onSessionEnd() { onConnectionEnd(); + long dataUsageOnSessionEndBytes = getDataUsage(); + logd("update data consumed: " + dataUsageOnSessionEndBytes); + if (dataUsageOnSessionEndBytes > 0L + && dataUsageOnSessionEndBytes > mDataUsageOnSessionStartBytes) { + mSatelliteDataConsumedBytes = + dataUsageOnSessionEndBytes - mDataUsageOnSessionStartBytes; + } + logd("satellite data consumed at session: " + mSatelliteDataConsumedBytes); reportMetrics(); mIsNtnRoamingInHomeCountry = false; + mSupportedSatelliteServices = new int[0]; + mServiceDataPolicy = SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN; + mSatelliteDataConsumedBytes = 0L; + mDataUsageOnSessionStartBytes = 0L; } /** Log carrier roaming satellite connection end */ @@ -189,8 +249,12 @@ public class CarrierRoamingSatelliteSessionStats { .setCountOfOutgoingSms(mCountOfOutgoingSms) .setCountOfIncomingMms(mCountOfIncomingMms) .setCountOfOutgoingMms(mCountOfOutgoingMms) + .setSupportedSatelliteServices(mSupportedSatelliteServices) + .setServiceDataPolicy(mServiceDataPolicy) + .setSatelliteDataConsumedBytes(mSatelliteDataConsumedBytes) .build(); SatelliteStats.getInstance().onCarrierRoamingSatelliteSessionMetrics(params); + logd("Supported satellite services: " + Arrays.toString(mSupportedSatelliteServices)); logd("reportMetrics: " + params); initializeParams(); } 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 4862188328..828642c339 100644 --- a/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java +++ b/src/java/com/android/internal/telephony/satellite/metrics/EntitlementMetricsStats.java @@ -35,6 +35,9 @@ public class EntitlementMetricsStats { private int mResult; private int mEntitlementStatus; private boolean mIsRetry; + private boolean mIsAllowedServiceEntitlement; + private int[] mEntitlementServiceType; + private int mEntitlementDataPolicy; private EntitlementMetricsStats() {} @@ -56,11 +59,14 @@ public class EntitlementMetricsStats { /** Report metrics on entitlement query request success */ public void reportSuccess(int subId, @SatelliteConstants.SatelliteEntitlementStatus int entitlementStatus, - boolean isRetry) { + boolean isRetry, boolean isAllowedServiceInfo, int[] serviceType, int dataPolicy) { mSubId = subId; mResult = RESULT_SUCCESS; mEntitlementStatus = entitlementStatus; mIsRetry = isRetry; + mIsAllowedServiceEntitlement = isAllowedServiceInfo; + mEntitlementServiceType = serviceType; + mEntitlementDataPolicy = dataPolicy; reportEntitlementMetrics(); } @@ -70,6 +76,9 @@ public class EntitlementMetricsStats { mResult = result; mIsRetry = isRetry; mEntitlementStatus = SatelliteConstants.SATELLITE_ENTITLEMENT_STATUS_UNKNOWN; + mIsAllowedServiceEntitlement = false; + mEntitlementServiceType = new int[0]; + mEntitlementDataPolicy = SatelliteConstants.SATELLITE_ENTITLEMENT_SERVICE_POLICY_UNKNOWN; reportEntitlementMetrics(); } @@ -82,6 +91,9 @@ public class EntitlementMetricsStats { .setEntitlementStatus(mEntitlementStatus) .setIsRetry(mIsRetry) .setCount(1) + .setIsAllowedServiceEntitlement(mIsAllowedServiceEntitlement) + .setEntitlementServiceType(mEntitlementServiceType) + .setEntitlementDataPolicy(mEntitlementDataPolicy) .build(); SatelliteStats.getInstance().onSatelliteEntitlementMetrics(entitlementParams); logd("reportEntitlementMetrics: " + entitlementParams); diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java index 831c15d88c..21541c8874 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java @@ -124,6 +124,7 @@ import static org.mockito.Mockito.when; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.NotificationManager; +import android.app.usage.NetworkStatsManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -621,6 +622,14 @@ public class SatelliteControllerTest extends TelephonyTest { when(mPhone2.getPhoneId()).thenReturn(1); when(mPhone2.getSignalStrengthController()).thenReturn(mSignalStrengthController); + doReturn(Context.NETWORK_STATS_SERVICE).when(mContext).getSystemServiceName( + NetworkStatsManager.class); + doReturn(mStatsManager).when(mContext).getSystemService(Context.NETWORK_STATS_SERVICE); + if (mContext.getSystemService(NetworkStatsManager.class) == null) { + // Test is using mockito-extended + doReturn(mStatsManager).when(mContext).getSystemService(NetworkStatsManager.class); + } + mContextFixture.putStringArrayResource( R.array.config_satellite_providers, EMPTY_STRING_ARRAY); |