Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2c4d588 authored by Nagendra Prasad Nagarle Basavaraju's avatar Nagendra Prasad Nagarle Basavaraju
Browse files

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
parent 74968249
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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 {
+8 −2
Original line number Diff line number Diff line
@@ -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) {
+115 −2
Original line number Diff line number Diff line
@@ -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
@@ -2016,6 +2040,34 @@ public class SatelliteStats {
                return this;
            }

            /**
             * 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
@@ -2342,6 +2419,33 @@ public class SatelliteStats {
                return this;
            }

            /**
             * 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);
    }

+14 −0
Original line number Diff line number Diff line
@@ -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 {}
}
+64 −9
Original line number Diff line number Diff line
@@ -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,18 +4203,26 @@ 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 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,
@@ -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
Loading