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

Commit e8323c62 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13495399 from f72c8b0d to 25Q3-release

Change-Id: Id73a358b1dd8df291b0050435aefed894d9d0959
parents 97d44c15 f72c8b0d
Loading
Loading
Loading
Loading
+203 −109
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ import android.annotation.ArrayRes;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannel;
@@ -117,6 +118,7 @@ import android.os.ServiceSpecificException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.WorkSource;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Telephony;
import android.provider.Telephony;
import android.telecom.TelecomManager;
import android.telecom.TelecomManager;
@@ -203,6 +205,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Collectors;
@@ -249,8 +252,8 @@ public class SatelliteController extends Handler {
    public static final long DEFAULT_CARRIER_EMERGENCY_CALL_WAIT_FOR_CONNECTION_TIMEOUT_MILLIS =
    public static final long DEFAULT_CARRIER_EMERGENCY_CALL_WAIT_FOR_CONNECTION_TIMEOUT_MILLIS =
            TimeUnit.SECONDS.toMillis(30);
            TimeUnit.SECONDS.toMillis(30);


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


    /**
    /**
@@ -310,7 +313,7 @@ public class SatelliteController extends Handler {
    private static final int EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE = 51;
    private static final int EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE = 51;
    protected static final int
    protected static final int
            EVENT_WAIT_FOR_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_RESPONSE_TIMED_OUT = 52;
            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;
    private static final int EVENT_WAIT_FOR_REGULAR_METRICS_REPORT_HYSTERESIS_TIMED_OUT = 53;
    protected static final int EVENT_SATELLITE_REGISTRATION_FAILURE = 54;
    protected static final int EVENT_SATELLITE_REGISTRATION_FAILURE = 54;
    private static final int EVENT_TERRESTRIAL_NETWORK_AVAILABLE_CHANGED = 55;
    private static final int EVENT_TERRESTRIAL_NETWORK_AVAILABLE_CHANGED = 55;
    private static final int EVENT_SET_NETWORK_SELECTION_AUTO_DONE = 56;
    private static final int EVENT_SET_NETWORK_SELECTION_AUTO_DONE = 56;
@@ -396,6 +399,12 @@ public class SatelliteController extends Handler {
    protected AtomicBoolean mIsDeviceProvisioned = null;
    protected AtomicBoolean mIsDeviceProvisioned = null;
    private AtomicBoolean mOverriddenIsSatelliteViaOemProvisioned = null;
    private AtomicBoolean mOverriddenIsSatelliteViaOemProvisioned = null;
    private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false);
    private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false);
    private AtomicBoolean mNtnSmsSupportedByMessagesApp = null;
    private AtomicBoolean mIsWifiConnected = new AtomicBoolean(false);
    private AtomicBoolean mHasSentBroadcast = new AtomicBoolean(false);
    @SatelliteManager.SatelliteModemState
    private AtomicInteger mSatelliteModemState = new AtomicInteger(
            SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN);


    private final Object mSatelliteEnabledRequestLock = new Object();
    private final Object mSatelliteEnabledRequestLock = new Object();
    /* This variable is used to store the first enable request that framework has received in the
    /* This variable is used to store the first enable request that framework has received in the
@@ -523,10 +532,8 @@ public class SatelliteController extends Handler {
    /** Key: subId, value: (key: Regional satellite config Id string, value: Integer
    /** Key: subId, value: (key: Regional satellite config Id string, value: Integer
     * arrays of earfcns in the corresponding regions.)
     * arrays of earfcns in the corresponding regions.)
     */
     */
    @GuardedBy("mRegionalSatelliteEarfcnsLock")
    @NonNull private final ConcurrentHashMap<Integer, Map<String, Set<Integer>>>
    @NonNull private final Map<Integer, Map<String, Set<Integer>>>
            mRegionalSatelliteEarfcns = new ConcurrentHashMap<>();
            mRegionalSatelliteEarfcns = new HashMap<>();
    @NonNull private final Object mRegionalSatelliteEarfcnsLock = new Object();
    @NonNull private final FeatureFlags mFeatureFlags;
    @NonNull private final FeatureFlags mFeatureFlags;
    @NonNull private final Object mSatelliteConnectedLock = new Object();
    @NonNull private final Object mSatelliteConnectedLock = new Object();
    /** Key: Subscription ID; Value: Last satellite connected time */
    /** Key: Subscription ID; Value: Last satellite connected time */
@@ -680,10 +687,6 @@ public class SatelliteController extends Handler {
    // mocked. Using this to inject a mock SubscriptionManager to work around this limitation.
    // mocked. Using this to inject a mock SubscriptionManager to work around this limitation.
    private SubscriptionManager mInjectSubscriptionManager = null;
    private SubscriptionManager mInjectSubscriptionManager = null;


    private final Object mIsWifiConnectedLock = new Object();
    @GuardedBy("mIsWifiConnectedLock")
    private boolean mIsWifiConnected = false;
    private boolean mHasSentBroadcast = false;
    // For satellite CTS test which to configure intent component with the necessary values.
    // For satellite CTS test which to configure intent component with the necessary values.
    private boolean mChangeIntentComponent = false;
    private boolean mChangeIntentComponent = false;
    private String mConfigSatelliteGatewayServicePackage = "";
    private String mConfigSatelliteGatewayServicePackage = "";
@@ -700,19 +703,11 @@ public class SatelliteController extends Handler {
    private String mOverriddenSatelliteGatewayServicePackageName = "";
    private String mOverriddenSatelliteGatewayServicePackageName = "";
    private Boolean mOverriddenDisableSatelliteWhileEnableInProgressSupported = null;
    private Boolean mOverriddenDisableSatelliteWhileEnableInProgressSupported = null;


    private final Object mNtnSmsSupportedByMessagesAppLock = new Object();
    @GuardedBy("mNtnSmsSupportedByMessagesAppLock")
    private Boolean mNtnSmsSupportedByMessagesApp = null;


    private final Object mCarrierRoamingNtnAllSatellitePlmnSetLock = new Object();
    private final Object mCarrierRoamingNtnAllSatellitePlmnSetLock = new Object();
    @GuardedBy("mCarrierRoamingNtnAllSatellitePlmnSetLock")
    @GuardedBy("mCarrierRoamingNtnAllSatellitePlmnSetLock")
    private Set<String> mCarrierRoamingNtnAllSatellitePlmnSet = null;
    private Set<String> mCarrierRoamingNtnAllSatellitePlmnSet = null;


    private final Object mSatelliteModemStateLock = new Object();
    @GuardedBy("mSatelliteModemStateLock")
    @SatelliteManager.SatelliteModemState
    private int mSatelliteModemState = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN;

    // Data Plan types at entitlement for the plmn allowed
    // 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_METERED = 0;
    public static final int SATELLITE_DATA_PLAN_UNMETERED = 1;
    public static final int SATELLITE_DATA_PLAN_UNMETERED = 1;
@@ -784,6 +779,17 @@ public class SatelliteController extends Handler {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected boolean mSatelliteAccessAllowed = false;
    protected boolean mSatelliteAccessAllowed = false;


    @Nullable
    private AlarmManager mAlarmManager;
    @NonNull
    private final AlarmManager.OnAlarmListener mRegularMetricReportAlarmListener =
            () -> {
                plogd("onAlarm: regular metric report hysteresis timer expired");
                Message msg = SatelliteController.getInstance().obtainMessage(
                        EVENT_WAIT_FOR_REGULAR_METRICS_REPORT_HYSTERESIS_TIMED_OUT, null);
                msg.sendToTarget();
            };

    public static final int RESULT_RECEIVER_COUNT_ANOMALY_THRESHOLD = 500;
    public static final int RESULT_RECEIVER_COUNT_ANOMALY_THRESHOLD = 500;
    protected final Object mResultReceiverTotalCountLock = new Object();
    protected final Object mResultReceiverTotalCountLock = new Object();
    @GuardedBy("mResultReceiverTotalCountLock")
    @GuardedBy("mResultReceiverTotalCountLock")
@@ -993,10 +999,8 @@ public class SatelliteController extends Handler {
        loadSatelliteSharedPreferences();
        loadSatelliteSharedPreferences();
        if (mSharedPreferences != null) {
        if (mSharedPreferences != null) {
            try {
            try {
                synchronized (mNtnSmsSupportedByMessagesAppLock) {
                setNtnSmsSupportedByMessagesAppCache(mSharedPreferences.getBoolean(
                    mNtnSmsSupportedByMessagesApp = mSharedPreferences.getBoolean(
                        NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false));
                            NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false);
                }


                synchronized (mCarrierRoamingNtnAllSatellitePlmnSetLock) {
                synchronized (mCarrierRoamingNtnAllSatellitePlmnSetLock) {
                    mCarrierRoamingNtnAllSatellitePlmnSet = mSharedPreferences.getStringSet(
                    mCarrierRoamingNtnAllSatellitePlmnSet = mSharedPreferences.getStringSet(
@@ -1040,6 +1044,8 @@ public class SatelliteController extends Handler {
            sendRequestAsync(CMD_GET_SATELLITE_ENABLED_FOR_CARRIER, null, phoneToSendRequest);
            sendRequestAsync(CMD_GET_SATELLITE_ENABLED_FOR_CARRIER, null, phoneToSendRequest);
        }
        }


        mAlarmManager = mContext.getSystemService(AlarmManager.class);
        scheduleRegularMetricReportTimer();
        logd("Satellite Tracker is created");
        logd("Satellite Tracker is created");
    }
    }


@@ -2140,12 +2146,10 @@ public class SatelliteController extends Handler {
            }
            }


            case EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: {
            case EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: {
                synchronized (mIsWifiConnectedLock) {
                ar = (AsyncResult) msg.obj;
                ar = (AsyncResult) msg.obj;
                    mIsWifiConnected = (boolean) ar.result;
                mIsWifiConnected.set((boolean) ar.result);
                plogd("EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: mIsWifiConnected="
                plogd("EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: mIsWifiConnected="
                            + mIsWifiConnected);
                        + mIsWifiConnected.get());
                }
                evaluateCarrierRoamingNtnEligibilityChange();
                evaluateCarrierRoamingNtnEligibilityChange();
                break;
                break;
            }
            }
@@ -2156,18 +2160,9 @@ public class SatelliteController extends Handler {
                break;
                break;
            }
            }


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


@@ -4933,15 +4928,7 @@ public class SatelliteController extends Handler {
        synchronized (mSupportedSatelliteServicesLock) {
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) {
            if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) {
                logd("update the carrier satellite enabled to " + entitlementEnabled);
                logd("update the carrier satellite enabled to " + entitlementEnabled);
                mSatelliteEntitlementStatusPerCarrier.put(subId, entitlementEnabled);
                handleIndividualEntitlementMetricReport(subId, 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(
                                    EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT),
                            WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS);
                }
                try {
                try {
                    mSubscriptionManagerService.setSubscriptionProperty(subId,
                    mSubscriptionManagerService.setSubscriptionProperty(subId,
                            SATELLITE_ENTITLEMENT_STATUS, entitlementEnabled ? "1" : "0");
                            SATELLITE_ENTITLEMENT_STATUS, entitlementEnabled ? "1" : "0");
@@ -5435,9 +5422,7 @@ public class SatelliteController extends Handler {
        updateCachedDeviceProvisionStatus();
        updateCachedDeviceProvisionStatus();
        // Report updated provisioned status to metrics.
        // Report updated provisioned status to metrics.
        synchronized (mSatelliteTokenProvisionedLock) {
        synchronized (mSatelliteTokenProvisionedLock) {
            boolean isProvisioned = !mProvisionedSubscriberId.isEmpty()
            handleEntireProvisionMetricReport();
                    && mProvisionedSubscriberId.containsValue(Boolean.TRUE);
            mControllerMetricsStats.setIsProvisioned(isProvisioned);
        }
        }
        selectBindingSatelliteSubscription(false);
        selectBindingSatelliteSubscription(false);
        evaluateCarrierRoamingNtnEligibilityChange();
        evaluateCarrierRoamingNtnEligibilityChange();
@@ -5474,11 +5459,7 @@ public class SatelliteController extends Handler {
    private void handleEventSatelliteModemStateChanged(
    private void handleEventSatelliteModemStateChanged(
            @SatelliteManager.SatelliteModemState int state) {
            @SatelliteManager.SatelliteModemState int state) {
        plogd("handleEventSatelliteModemStateChanged: state=" + state);
        plogd("handleEventSatelliteModemStateChanged: state=" + state);

        mSatelliteModemState.set(state);
        synchronized (mSatelliteModemStateLock) {
            mSatelliteModemState = state;
        }

        if (state == SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE
        if (state == SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE
                || state == SatelliteManager.SATELLITE_MODEM_STATE_OFF) {
                || state == SatelliteManager.SATELLITE_MODEM_STATE_OFF) {
            if (!isWaitingForDisableSatelliteModemResponse()) {
            if (!isWaitingForDisableSatelliteModemResponse()) {
@@ -6581,14 +6562,7 @@ public class SatelliteController extends Handler {
                    entitlementStatus = "0";
                    entitlementStatus = "0";
                }
                }
                boolean result = entitlementStatus.equals("1");
                boolean result = entitlementStatus.equals("1");
                mSatelliteEntitlementStatusPerCarrier.put(subId, result);
                handleIndividualEntitlementMetricReport(subId, 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(
                                    EVENT_WAIT_FOR_REPORT_ENTITLED_TO_MERTICS_HYSTERESIS_TIMED_OUT),
                            WAIT_FOR_REPORT_ENTITLED_MERTICS_TIMEOUT_MILLIS);
                }
            }
            }


            if (!mSatelliteEntitlementStatusPerCarrier.get(subId, false)) {
            if (!mSatelliteEntitlementStatusPerCarrier.get(subId, false)) {
@@ -8041,7 +8015,7 @@ public class SatelliteController extends Handler {
        plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()="
        plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()="
                  + newSubsInfoListPerPriority.size());
                  + newSubsInfoListPerPriority.size());


        if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) {
        if (!mHasSentBroadcast.get() && newSubsInfoListPerPriority.size() == 0) {
            logd("evaluateESOSProfilesPrioritization: no satellite subscription available");
            logd("evaluateESOSProfilesPrioritization: no satellite subscription available");
            return;
            return;
        }
        }
@@ -8058,7 +8032,7 @@ public class SatelliteController extends Handler {
                mSubsInfoListPerPriority = newSubsInfoListPerPriority;
                mSubsInfoListPerPriority = newSubsInfoListPerPriority;
                mLastEvaluatedSubscriberProvisionStatus = newEvaluatedSubscriberProvisionStatus;
                mLastEvaluatedSubscriberProvisionStatus = newEvaluatedSubscriberProvisionStatus;
                sendBroadCastForProvisionedESOSSubs();
                sendBroadCastForProvisionedESOSSubs();
                mHasSentBroadcast = true;
                mHasSentBroadcast.set(true);
                selectBindingSatelliteSubscription(false);
                selectBindingSatelliteSubscription(false);
            }
            }
        }
        }
@@ -8620,7 +8594,7 @@ public class SatelliteController extends Handler {
            logd("getRegionalSatelliteEarfcns: carrierRoamingNbIotNtnFlag is disabled");
            logd("getRegionalSatelliteEarfcns: carrierRoamingNbIotNtnFlag is disabled");
            return new HashMap<>();
            return new HashMap<>();
        }
        }
        synchronized (mRegionalSatelliteEarfcnsLock) {

        if (mRegionalSatelliteEarfcns.containsKey(subId)) {
        if (mRegionalSatelliteEarfcns.containsKey(subId)) {
            return mRegionalSatelliteEarfcns.get(subId);
            return mRegionalSatelliteEarfcns.get(subId);
        } else {
        } else {
@@ -8628,7 +8602,6 @@ public class SatelliteController extends Handler {
            return new HashMap<>();
            return new HashMap<>();
        }
        }
    }
    }
    }


    /**
    /**
     * Update regional satellite earfcn information from carrier config.
     * Update regional satellite earfcn information from carrier config.
@@ -8641,11 +8614,9 @@ public class SatelliteController extends Handler {
            return;
            return;
        }
        }


        synchronized (mRegionalSatelliteEarfcnsLock) {
        mRegionalSatelliteEarfcns.put(subId,
        mRegionalSatelliteEarfcns.put(subId,
                readRegionalSatelliteEarfcnsFromCarrierConfig(subId));
                readRegionalSatelliteEarfcnsFromCarrierConfig(subId));
    }
    }
    }


    /**
    /**
     * Deliver the list of deprovisioned satellite subscriber ids.
     * Deliver the list of deprovisioned satellite subscriber ids.
@@ -8721,18 +8692,22 @@ public class SatelliteController extends Handler {
        } else {
        } else {
            mSharedPreferences.edit().putBoolean(
            mSharedPreferences.edit().putBoolean(
                    NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, ntnSmsSupported).apply();
                    NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, ntnSmsSupported).apply();
            synchronized (mNtnSmsSupportedByMessagesAppLock) {
            setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported);
                mNtnSmsSupportedByMessagesApp = ntnSmsSupported;
        }
        }
    }
    }

    private void setNtnSmsSupportedByMessagesAppCache(boolean ntnSmsSupported) {
        if (mNtnSmsSupportedByMessagesApp == null) {
            mNtnSmsSupportedByMessagesApp = new AtomicBoolean(ntnSmsSupported);
        } else {
            mNtnSmsSupportedByMessagesApp.set(ntnSmsSupported);
        }
    }
    }


    private boolean isNtnSmsSupportedByMessagesApp() {
    private boolean isNtnSmsSupportedByMessagesApp() {
        synchronized (mNtnSmsSupportedByMessagesAppLock) {
        if (mNtnSmsSupportedByMessagesApp != null) {
        if (mNtnSmsSupportedByMessagesApp != null) {
                plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp);
            plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp.get());
                return mNtnSmsSupportedByMessagesApp;
            return mNtnSmsSupportedByMessagesApp.get();
            }
        }
        }


        if (!loadSatelliteSharedPreferences()) return false;
        if (!loadSatelliteSharedPreferences()) return false;
@@ -8743,10 +8718,8 @@ public class SatelliteController extends Handler {
        } else {
        } else {
            boolean ntnSmsSupported = mSharedPreferences.getBoolean(
            boolean ntnSmsSupported = mSharedPreferences.getBoolean(
                    NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false);
                    NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false);
            synchronized (mNtnSmsSupportedByMessagesAppLock) {
            setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported);
                mNtnSmsSupportedByMessagesApp = ntnSmsSupported;
            plogd("isNtnSmsSupportedByMessagesApp:" + ntnSmsSupported);
                plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp);
            }
            return ntnSmsSupported;
            return ntnSmsSupported;
        }
        }
    }
    }
@@ -8866,13 +8839,11 @@ public class SatelliteController extends Handler {
            return false;
            return false;
        }
        }


        synchronized (mIsWifiConnectedLock) {
        if (mIsWifiConnected.get()) {
            if (mIsWifiConnected) {
            plogd("isCarrierRoamingNtnEligible[phoneId=" + phone.getPhoneId()
            plogd("isCarrierRoamingNtnEligible[phoneId=" + phone.getPhoneId()
                    + "]: Wi-Fi is connected");
                    + "]: Wi-Fi is connected");
            return false;
            return false;
        }
        }
        }


        return true;
        return true;
    }
    }
@@ -9579,8 +9550,7 @@ public class SatelliteController extends Handler {
     * Returns satellite connected state from modem, return true if connected.
     * Returns satellite connected state from modem, return true if connected.
     */
     */
    public boolean isInConnectedState() {
    public boolean isInConnectedState() {
        synchronized (mSatelliteModemStateLock) {
        switch (mSatelliteModemState.get()) {
            switch (mSatelliteModemState) {
            case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED: //fallthrough
            case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED: //fallthrough
            case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING: //fallthrough
            case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING: //fallthrough
            case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING: //fallthrough
            case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING: //fallthrough
@@ -9592,7 +9562,6 @@ public class SatelliteController extends Handler {
                return false;
                return false;
        }
        }
    }
    }
    }


    protected void updateLastNotifiedCarrierRoamingNtnSignalStrengthAndNotify(
    protected void updateLastNotifiedCarrierRoamingNtnSignalStrengthAndNotify(
            @Nullable Phone phone) {
            @Nullable Phone phone) {
@@ -9744,6 +9713,131 @@ public class SatelliteController extends Handler {
        return mWifiStateEnabled.get();
        return mWifiStateEnabled.get();
    }
    }


    @GuardedBy("mSupportedSatelliteServicesLock")
    private void handleEntireEntitlementMetricReport() {
        synchronized (mSupportedSatelliteServicesLock) {
            int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true);
            if (activeSubIds != null && activeSubIds.length > 0) {
                for (int subId : activeSubIds) {
                    boolean isSubIdEntitled = mSatelliteEntitlementStatusPerCarrier.get(subId);
                    mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(subId,
                            isSubIdEntitled);
                    plogd("handleEntitlementMetricReport: subId=" + subId + ", isSubEntitled="
                            + isSubIdEntitled);
                }
            } else {
                loge("handleEntireEntitlementMetricReport: no active subId");
            }
        }
        scheduleRegularMetricReportTimer();
    }

    @GuardedBy("mSupportedSatelliteServicesLock")
    private void handleIndividualEntitlementMetricReport(int subId,
            boolean isSubscriptionEntitled) {
        synchronized (mSupportedSatelliteServicesLock) {
            mSatelliteEntitlementStatusPerCarrier.put(subId, isSubscriptionEntitled);
            mCarrierRoamingSatelliteControllerStats.reportIsDeviceEntitled(subId,
                    isSubscriptionEntitled);
        }
    }

    @GuardedBy("mSatelliteTokenProvisionedLock")
    private void handleEntireProvisionMetricReport() {
        logd("handleEntireProvisionMetricReport:");
        // Hold the final aggregated status for each carrierId.
        Map<Integer, CarrierReportInfo> reportDataPerCarrier = new HashMap<>();
        synchronized (mSatelliteTokenProvisionedLock) {
            // Aggregate provision status and isNtnOnlyCarrier info per carrierId
            List<SubscriptionInfo> allSubInfos = mSubscriptionManagerService.getAllSubInfoList(
                    mContext.getOpPackageName(), mContext.getAttributionTag());
            for (SubscriptionInfo info : allSubInfos) {
                int subId = info.getSubscriptionId();
                boolean isNtnOnlySubId = info.isOnlyNonTerrestrialNetwork();
                boolean isActiveSubId = info.isActive();

                if (!isNtnOnlySubId && !isActiveSubId) {
                    plogd("handleEntireProvisionMetricReport: subId=" + subId
                            + " is neither NTN-only nor active. Skipping.");
                    continue;
                }

                int carrierId = SatelliteServiceUtils.getCarrierIdFromSubscription(subId);
                if (carrierId == TelephonyManager.UNKNOWN_CARRIER_ID && !isNtnOnlySubId) {
                    plogd("handleEntireProvisionMetricReport: neither valid carrierId "
                            + "nor NTN-only, subId=" + subId + ". Skipping.");
                    continue;
                }

                String subscriberId = getSubscriberIdAndType(info).first;
                boolean isProvisioned = mProvisionedSubscriberId.getOrDefault(subscriberId, false);

                CarrierReportInfo carrierInfo = reportDataPerCarrier.computeIfAbsent(
                        carrierId, key -> new CarrierReportInfo());
                carrierInfo.aggregate(isProvisioned, isNtnOnlySubId);
            }
        }

        // Report the aggregated status for each carrierId
        if (reportDataPerCarrier.isEmpty()) {
            plogd("handleEntireProvisionMetricReport: No reportable data found");
        } else {
            plogd("handleEntireProvisionMetricReport: Reporting final aggregated status for "
                    + reportDataPerCarrier.size() + " carrier(s).");
            for (Map.Entry<Integer, CarrierReportInfo> reportEntry :
                    reportDataPerCarrier.entrySet()) {
                int carrierId = reportEntry.getKey();
                CarrierReportInfo info = reportEntry.getValue();

                plogd("handleEntireProvisionMetricReport: Final report for carrierId="
                        + carrierId + ", isProvisioned=" + info.mIsAnySubProvisioned
                        + ", isNtnOnlyCarrier=" + info.mIsNtnOnlyCarrier);

                mControllerMetricsStats.setIsProvisioned(
                        carrierId,
                        info.mIsAnySubProvisioned,
                        info.mIsNtnOnlyCarrier);
            }
        }
        scheduleRegularMetricReportTimer();
    }

    // Helper class to store aggregated information per carrierId.
    private static class CarrierReportInfo {
        boolean mIsAnySubProvisioned = false;
        boolean mIsNtnOnlyCarrier = false;

        void aggregate(boolean isProvisioned, boolean isNtnOnlyCarrier) {
            // if any subId for the carrier was provisioned, this carrier is provisioned
            if (isProvisioned) {
                this.mIsAnySubProvisioned = true;
            }
            this.mIsNtnOnlyCarrier = isNtnOnlyCarrier;
        }
    }

    private void scheduleRegularMetricReportTimer() {
        if (mAlarmManager == null) {
            plogd("scheduleRegularMetricReportTimer: AlarmManager is null");
            return;
        }
        mAlarmManager.cancel(mRegularMetricReportAlarmListener);
        mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                getElapsedRealtime() + REGULAR_METRIC_REPORTING_INTERVAL_MILLIS,
                TAG, new HandlerExecutor(this), new WorkSource(),
                mRegularMetricReportAlarmListener);
    }

    /**
     * Uses this function to set AlarmManager object for testing.
     *
     * @param alarmManager The instance of AlarmManager.
     */
    @VisibleForTesting
    public void setAlarmManager(AlarmManager alarmManager) {
        mAlarmManager = alarmManager;
    }

    /**
    /**
     * Method to return the current data plan for the registered plmn based on entitlement
     * Method to return the current data plan for the registered plmn based on entitlement
     * provisioning information. Note: If no information at
     * provisioning information. Note: If no information at
+8 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.telephony.PersistentLogger;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.satellite.AntennaPosition;
import android.telephony.satellite.AntennaPosition;
import android.telephony.satellite.EarfcnRange;
import android.telephony.satellite.EarfcnRange;
import android.telephony.satellite.NtnSignalStrength;
import android.telephony.satellite.NtnSignalStrength;
@@ -738,6 +739,13 @@ public class SatelliteServiceUtils {
        return satelliteController.isInCarrierRoamingNbIotNtn(phone);
        return satelliteController.isInCarrierRoamingNbIotNtn(phone);
    }
    }


    /** Returns the carrier ID of the given subscription id. */
    public static 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) {
    private static void logd(@NonNull String log) {
        Log.d(TAG, log);
        Log.d(TAG, log);
    }
    }
+4 −3
Original line number Original line Diff line number Diff line
@@ -390,12 +390,13 @@ public class ControllerMetricsStats {
    }
    }


    /** Capture the latest provisioned state for satellite service */
    /** Capture the latest provisioned state for satellite service */
    @VisibleForTesting
    public void setIsProvisioned(int carrierId, boolean isProvisioned, boolean isNtnOnlyCarrier) {
    public void setIsProvisioned(boolean isProvisioned) {
        logd("setIsProvisioned: carrierId=" + carrierId + ", isProvisioned=" + isProvisioned);
        logd("setIsProvisioned:" + isProvisioned);
        mSatelliteStats.onSatelliteControllerMetrics(
        mSatelliteStats.onSatelliteControllerMetrics(
                new SatelliteStats.SatelliteControllerParams.Builder()
                new SatelliteStats.SatelliteControllerParams.Builder()
                        .setCarrierId(carrierId)
                        .setIsProvisioned(isProvisioned)
                        .setIsProvisioned(isProvisioned)
                        .setIsNtnOnlyCarrier(isNtnOnlyCarrier)
                        .build());
                        .build());
    }
    }


+67 −1

File changed.

Preview size limit exceeded, changes collapsed.