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

Commit d47dba33 authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "Add additional field for CarrierRoamingSatelliteController atom" into main

parents ed0ab1ef a76fdb33
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -821,6 +821,7 @@ message CarrierRoamingSatelliteControllerStats {
    optional int32 satellite_session_gap_avg_sec = 6;
    optional int32 satellite_session_gap_max_sec = 7;
    optional int32 carrier_id = 8;
    optional bool is_device_entitled = 9;
}

message SatelliteEntitlement {
+2 −1
Original line number Diff line number Diff line
@@ -1594,7 +1594,8 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
                stats.satelliteSessionGapMinSec,
                stats.satelliteSessionGapAvgSec,
                stats.satelliteSessionGapMaxSec,
                stats.carrierId);
                stats.carrierId,
                stats.isDeviceEntitled);
    }

    private static StatsEvent buildStatsEvent(SatelliteEntitlement stats) {
+1 −0
Original line number Diff line number Diff line
@@ -878,6 +878,7 @@ public class PersistAtomsStorage {
        atom.satelliteSessionGapAvgSec = stats.satelliteSessionGapAvgSec;
        atom.satelliteSessionGapMaxSec = stats.satelliteSessionGapMaxSec;
        atom.carrierId = stats.carrierId;
        atom.isDeviceEntitled = stats.isDeviceEntitled;

        mAtoms.carrierRoamingSatelliteControllerStats = atomArray;
        saveAtomsToFile(SAVE_TO_FILE_DELAY_FOR_UPDATE_MILLIS);
+20 −1
Original line number Diff line number Diff line
@@ -1870,6 +1870,7 @@ public class SatelliteStats {
        private final int mSatelliteSessionGapAvgSec;
        private final int mSatelliteSessionGapMaxSec;
        private static int sCarrierId;
        private static boolean sIsDeviceEntitled;

        private CarrierRoamingSatelliteControllerStatsParams(Builder builder) {
            this.mConfigDataSource = builder.mConfigDataSource;
@@ -1887,6 +1888,11 @@ public class SatelliteStats {
            if (builder.mCarrierId.isPresent()) {
                this.sCarrierId = builder.mCarrierId.get();
            }

            // isDeviceEntitled value should be updated only when it is meaningful.
            if (builder.mIsDeviceEntitled.isPresent()) {
                this.sIsDeviceEntitled = builder.mIsDeviceEntitled.get();
            }
        }

        public int getConfigDataSource() {
@@ -1922,6 +1928,10 @@ public class SatelliteStats {
            return sCarrierId;
        }

        public boolean isDeviceEntitled() {
            return sIsDeviceEntitled;
        }

        /**
         * A builder class to create {@link CarrierRoamingSatelliteControllerStatsParams}
         * data structure class
@@ -1935,6 +1945,7 @@ public class SatelliteStats {
            private int mSatelliteSessionGapAvgSec = 0;
            private int mSatelliteSessionGapMaxSec = 0;
            private Optional<Integer> mCarrierId = Optional.empty();
            private Optional<Boolean> mIsDeviceEntitled = Optional.empty();

            /**
             * Sets configDataSource value of {@link CarrierRoamingSatelliteControllerStats} atom
@@ -2008,6 +2019,12 @@ public class SatelliteStats {
                return this;
            }

            /** Sets whether the device is currently entitled or not. */
            public Builder setIsDeviceEntitled(boolean isDeviceEntitled) {
                this.mIsDeviceEntitled = Optional.of(isDeviceEntitled);
                return this;
            }

            /**
             * Returns CarrierRoamingSatelliteControllerStatsParams, which contains whole component
             * of {@link CarrierRoamingSatelliteControllerStats} atom
@@ -2031,7 +2048,8 @@ public class SatelliteStats {
                    + ", satelliteSessionGapMinSec=" + mSatelliteSessionGapMinSec
                    + ", satelliteSessionGapAvgSec=" + mSatelliteSessionGapAvgSec
                    + ", satelliteSessionGapMaxSec=" + mSatelliteSessionGapMaxSec
                    + ", CarrierId=" + sCarrierId
                    + ", carrierId=" + sCarrierId
                    + ", isDeviceEntitled=" + sIsDeviceEntitled
                    + ")";
        }
    }
@@ -2604,6 +2622,7 @@ public class SatelliteStats {
        proto.satelliteSessionGapAvgSec = param.mSatelliteSessionGapAvgSec;
        proto.satelliteSessionGapMaxSec = param.mSatelliteSessionGapMaxSec;
        proto.carrierId = param.getCarrierId();
        proto.isDeviceEntitled = param.isDeviceEntitled();
        mAtomsStorage.addCarrierRoamingSatelliteControllerStats(proto);
    }

+34 −0
Original line number Diff line number Diff line
@@ -206,6 +206,10 @@ public class SatelliteController extends Handler {
    public static final long DEFAULT_CARRIER_EMERGENCY_CALL_WAIT_FOR_CONNECTION_TIMEOUT_MILLIS =
            TimeUnit.SECONDS.toMillis(30);

    /** Sets report entitled metrics cool down to 23 hours to help enforcing privacy requirement.*/
    private static final long WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS =
            TimeUnit.HOURS.toMillis(23);

    /** Message codes used in handleMessage() */
    //TODO: Move the Commands and events related to position updates to PointingAppController
    private static final int CMD_START_SATELLITE_TRANSMISSION_UPDATES = 1;
@@ -256,6 +260,7 @@ public class SatelliteController extends Handler {
    private static final int EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE = 51;
    protected static final int
            EVENT_WAIT_FOR_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_RESPONSE_TIMED_OUT = 52;
    private static final int EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT = 53;

    @NonNull private static SatelliteController sInstance;
    @NonNull private final Context mContext;
@@ -1768,6 +1773,21 @@ public class SatelliteController extends Handler {
                synchronized (mIsRadioOnLock) {
                    mRadioOffRequested = false;
                }
                break;
            }

            case EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT: {
                // TODO: b/366329504 report carrier roaming metrics for multiple subscription IDs.
                synchronized (mSupportedSatelliteServicesLock) {
                    int defaultSubId = mSubscriptionManagerService.getDefaultSubId();
                    boolean isEntitled = mSatelliteEntitlementStatusPerCarrier.get(defaultSubId,
                            false);
                    mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(isEntitled);
                }
                sendMessageDelayed(obtainMessage(
                                EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT),
                        WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS);
                break;
            }

            default:
@@ -3602,6 +3622,13 @@ 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);
                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(
                                    EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT),
                            WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS);
                }
                try {
                    mSubscriptionManagerService.setSubscriptionProperty(subId,
                            SATELLITE_ENTITLEMENT_STATUS, entitlementEnabled ? "1" : "0");
@@ -4884,6 +4911,13 @@ public class SatelliteController extends Handler {
                }
                boolean result = entitlementStatus.equals("1");
                mSatelliteEntitlementStatusPerCarrier.put(subId, result);
                mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(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(
                                    EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT),
                            WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS);
                }
            }

            if (!mSatelliteEntitlementStatusPerCarrier.get(subId, false)) {
Loading