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

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

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30772089',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30772089', 'googleplex-android-review.googlesource.com/30827344', 'googleplex-android-review.googlesource.com/30664691'] into 25Q1-release.

Change-Id: I5e84ec08125e75fc3b507686fc989c0b83b3fe02
parents f89331dd df98bf66
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.telephony.satellite.SatelliteManager.DATAGRAM_TYPE_CHECK_P
import static android.telephony.satellite.SatelliteManager.DATAGRAM_TYPE_SMS;
import static android.telephony.satellite.SatelliteManager.DATAGRAM_TYPE_UNKNOWN;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_TIMEOUT;
@@ -418,7 +419,7 @@ public class DatagramDispatcher extends Handler {
            case EVENT_MT_SMS_POLLING_THROTTLE_TIMED_OUT: {
                synchronized (mLock) {
                    mIsMtSmsPollingThrottled = false;
                    if (mIsAligned && mModemState == SATELLITE_MODEM_STATE_CONNECTED) {
                    if (allowMtSmsPolling()) {
                        sendMtSmsPollingMessage();
                    }
                }
@@ -514,8 +515,7 @@ public class DatagramDispatcher extends Handler {
            mIsAligned = isAligned;
            plogd("setDeviceAlignedWithSatellite: " + mIsAligned);
            if (isAligned && mIsDemoMode) handleEventSatelliteAligned();
            if (isAligned && !mIsMtSmsPollingThrottled
                    && mModemState == SATELLITE_MODEM_STATE_CONNECTED) {
            if (allowMtSmsPolling()) {
                sendMtSmsPollingMessage();
            }
        }
@@ -810,9 +810,6 @@ public class DatagramDispatcher extends Handler {
                    stopDatagramWaitForConnectedStateTimer();
                    sendPendingMessages();
                }
                if (mIsAligned && !mIsMtSmsPollingThrottled) {
                    sendMtSmsPollingMessage();
                }
            }

            if (state == SATELLITE_MODEM_STATE_NOT_CONNECTED) {
@@ -821,6 +818,10 @@ public class DatagramDispatcher extends Handler {
                    mShouldPollMtSms = shouldPollMtSms();
                }
            }

            if (allowMtSmsPolling()) {
                sendMtSmsPollingMessage();
            }
        }
    }

@@ -1334,6 +1335,32 @@ public class DatagramDispatcher extends Handler {
        removeMessages(EVENT_MT_SMS_POLLING_THROTTLE_TIMED_OUT);
    }

    @GuardedBy("mLock")
    private boolean allowMtSmsPolling() {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) return false;

        if (mIsMtSmsPollingThrottled) return false;

        if (!mIsAligned) return false;

        boolean isModemStateConnectedOrTransferring =
                mModemState == SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED
                        || mModemState
                                == SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING;
        if (!isModemStateConnectedOrTransferring && !allowCheckMessageInNotConnected()) {
            plogd("EVENT_MT_SMS_POLLING_THROTTLE_TIMED_OUT:"
                    + " allow_check_message_in_not_connected is disabled");
            return false;
        }

        return true;
    }

    private boolean allowCheckMessageInNotConnected() {
        return mContext.getResources()
                .getBoolean(R.bool.config_satellite_allow_check_message_in_not_connected);
    }

    private static void logd(@NonNull String log) {
        Rlog.d(TAG, log);
    }
+187 −17
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ import android.telephony.satellite.ISatelliteTransmissionUpdateCallback;
import android.telephony.satellite.ISelectedNbIotSatelliteSubscriptionCallback;
import android.telephony.satellite.NtnSignalStrength;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteCommunicationAllowedStateCallback;
import android.telephony.satellite.SatelliteDatagram;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.SatelliteModemEnableRequestAttributes;
@@ -146,6 +147,7 @@ import android.telephony.satellite.SatelliteSubscriberInfo;
import android.telephony.satellite.SatelliteSubscriberProvisionStatus;
import android.telephony.satellite.SatelliteSubscriptionInfo;
import android.telephony.satellite.SystemSelectionSpecifier;
import android.telephony.satellite.SatelliteAccessConfiguration;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -319,6 +321,7 @@ public class SatelliteController extends Handler {
    @NonNull private final ProvisionMetricsStats mProvisionMetricsStats;
    @NonNull private SessionMetricsStats mSessionMetricsStats;
    @NonNull private CarrierRoamingSatelliteControllerStats mCarrierRoamingSatelliteControllerStats;

    @NonNull private final SubscriptionManagerService mSubscriptionManagerService;
    @NonNull private final TelephonyCountryDetector mCountryDetector;
    @NonNull private final TelecomManager mTelecomManager;
@@ -391,6 +394,8 @@ public class SatelliteController extends Handler {
            new AtomicBoolean(false);
    private final AtomicBoolean mRegisteredForTerrestrialNetworkAvailableChanged =
            new AtomicBoolean(false);
    private final AtomicBoolean mRegisteredForSatelliteCommunicationAllowedStateChanged =
        new AtomicBoolean(false);
    /**
     * Map key: subId, value: callback to get error code of the provision request.
     */
@@ -725,6 +730,15 @@ public class SatelliteController extends Handler {
    // device.
    private List<DeviceState> mDeviceStates = new ArrayList();

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected final Object mSatelliteAccessConfigLock = new Object();
    @GuardedBy("mSatelliteAccessConfigLock")
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected List<Integer> mCurrentLocationTagIds = new ArrayList();
    @GuardedBy("mSatelliteAccessConfigLock")
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected boolean mSatelliteAccessAllowed = false;

    public static final int RESULT_RECEIVER_COUNT_ANOMALY_THRESHOLD = 500;
    protected final Object mResultReceiverTotalCountLock = new Object();
    @GuardedBy("mResultReceiverTotalCountLock")
@@ -884,6 +898,7 @@ public class SatelliteController extends Handler {
        registerForSatelliteModemStateChanged();
        registerForServiceStateChanged();
        registerForSignalStrengthChanged();
        registerForSatelliteCommunicationAllowedStateChanged();
        mContentResolver = mContext.getContentResolver();
        mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);

@@ -3961,28 +3976,30 @@ public class SatelliteController extends Handler {
    }

    /**
     * @return {@code true} if the device is connected to satellite via any carrier within the
     * @return {@code true} and the corresponding subId if the device is connected to
     * satellite via any carrier within the
     * {@link CarrierConfigManager#KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT}
     * duration, {@code false} otherwise.
     * duration, {@code false} and null otherwise.
     */
    public boolean isSatelliteConnectedViaCarrierWithinHysteresisTime() {
    public Pair<Boolean, Integer> isSatelliteConnectedViaCarrierWithinHysteresisTime() {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            logd("isSatelliteConnectedViaCarrierWithinHysteresisTime: carrierEnabledSatelliteFlag"
                    + " is disabled");
            return false;
            return new Pair<>(false, null);
        }
        if (isUsingNonTerrestrialNetworkViaCarrier().first) {
            return true;
        Pair<Boolean, Integer> ntnConnectedState = isUsingNonTerrestrialNetworkViaCarrier();
        if (ntnConnectedState.first) {
            return ntnConnectedState;
        }
        for (Phone phone : PhoneFactory.getPhones()) {
            if (isInSatelliteModeForCarrierRoaming(phone)) {
                logd("isSatelliteConnectedViaCarrierWithinHysteresisTime: "
                        + "subId:" + phone.getSubId()
                        + " is connected to satellite within hysteresis time");
                return true;
                return new Pair<>(true, phone.getSubId());
            }
        }
        return false;
        return new Pair<>(false, null);
    }

    /**
@@ -4185,7 +4202,7 @@ public class SatelliteController extends Handler {
        return DEFAULT_CARRIER_EMERGENCY_CALL_WAIT_FOR_CONNECTION_TIMEOUT_MILLIS;
    }

    private int getCarrierEmergencyCallWaitForConnectionTimeoutMillis(int subId) {
    public int getCarrierEmergencyCallWaitForConnectionTimeoutMillis(int subId) {
        PersistableBundle config = getPersistableBundle(subId);
        return config.getInt(KEY_EMERGENCY_CALL_TO_SATELLITE_T911_HANDOVER_TIMEOUT_MILLIS_INT);
    }
@@ -4546,12 +4563,22 @@ public class SatelliteController extends Handler {
            return null;
        }
        String iccid = subInfo.getIccId();
        String apn = getConfigForSubId(subId).getString(KEY_SATELLITE_NIDD_APN_NAME_STRING, "");
        String apn = getNiddApnName(subId);
        return new SatelliteModemEnableRequestAttributes(
                arg.enableSatellite, arg.enableDemoMode, arg.isEmergency,
                new SatelliteSubscriptionInfo(iccid, apn));
    }

    @NonNull private String getNiddApnName(int subId) {
        if (SatelliteServiceUtils.isNtnOnlySubscriptionId(subId)) {
            String apn = mContext.getResources().getString(R.string.config_satellite_nidd_apn_name);
            if (!TextUtils.isEmpty(apn)) {
                return apn;
            }
        }
        return getConfigForSubId(subId).getString(KEY_SATELLITE_NIDD_APN_NAME_STRING, "");
    }

    private void handleRequestSatelliteAttachRestrictionForCarrierCmd(
            SatelliteControllerHandlerRequest request) {
        RequestHandleSatelliteAttachRestrictionForCarrierArgument argument =
@@ -5625,7 +5652,7 @@ public class SatelliteController extends Handler {
                KEY_SATELLITE_ROAMING_TURN_OFF_SESSION_FOR_EMERGENCY_CALL_BOOL);
    }

    public int getCarrierRoamingNtnConnectType(int subId) {
    private int getCarrierRoamingNtnConnectType(int subId) {
        return getConfigForSubId(subId).getInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT);
    }

@@ -6080,6 +6107,8 @@ public class SatelliteController extends Handler {
            return;
        }

        registerForSatelliteCommunicationAllowedStateChanged();

        boolean eligible = isCarrierRoamingNtnEligible(getSatellitePhone());
        plogd("evaluateCarrierRoamingNtnEligibilityChange: "
                + "isCarrierRoamingNtnEligible=" + eligible);
@@ -6532,7 +6561,7 @@ public class SatelliteController extends Handler {
                        /*visible*/ true);
            }
        } else if (mIsNotificationShowing
                && !isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
                && !isSatelliteConnectedViaCarrierWithinHysteresisTime().first) {
            // Dismiss the notification if it is still displaying.
            dismissSatelliteNotification();
        }
@@ -7041,6 +7070,8 @@ public class SatelliteController extends Handler {
                        mSubscriptionManagerService.getDefaultSmsSubId() == subId;
                boolean isNtnOnly = info.isOnlyNonTerrestrialNetwork();
                boolean isESOSSupported = info.isSatelliteESOSSupported();
                boolean isCarrierSatelliteHigherPriority =
                    isCarrierSatelliteHigherPriority(info);
                if (!isNtnOnly && !isESOSSupported) {
                    continue;
                }
@@ -7053,9 +7084,13 @@ public class SatelliteController extends Handler {
                    continue;
                }

                int keyPriority = (isESOSSupported && isActive && isDefaultSmsSubId) ? 0
                        : (isESOSSupported && isActive) ? 1
                                : (isNtnOnly) ? 2 : (isESOSSupported) ? 3 : -1;
                int keyPriority = (isESOSSupported && isActive && isDefaultSmsSubId
                    && isCarrierSatelliteHigherPriority)
                    ? 0 : (isESOSSupported && isActive &&
                        isCarrierSatelliteHigherPriority)
                        ? 1 : (isNtnOnly)
                            ? 2 : (isESOSSupported)
                                ? 3 : -1;
                if (keyPriority != -1) {
                    newSubsInfoListPerPriority.computeIfAbsent(keyPriority,
                            k -> new ArrayList<>()).add(info);
@@ -7367,11 +7402,14 @@ public class SatelliteController extends Handler {
        int selectedSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        List<SatelliteSubscriberProvisionStatus> satelliteSubscribers =
                getPrioritizedSatelliteSubscriberProvisionStatusList();

        for (SatelliteSubscriberProvisionStatus status : satelliteSubscribers) {
            // TODO: need to check if satellite is allowed at current location for the subscription
            int subId = getSubIdFromSubscriberId(
                    status.getSatelliteSubscriberInfo().getSubscriberId());
            if (status.isProvisioned() && isActiveSubId(subId)) {

            if (status.isProvisioned() && isActiveSubId(subId) &&
                isSatelliteAvailableAtCurrentLocation(
                    mSubscriptionManagerService.getSubscriptionInfo(subId))) {
                selectedSubId = subId;
                break;
            }
@@ -7390,6 +7428,67 @@ public class SatelliteController extends Handler {
        handleEventSelectedNbIotSatelliteSubscriptionChanged(selectedSubId);
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    protected boolean isCarrierSatelliteHigherPriority(SubscriptionInfo info) {
        if(!isSatelliteAccessAllowedAtCurrentLocation()) {
            return true;
        }
        if(isSatelliteAvailableAtCurrentLocation(info)) {
            return true;
        }
        return false;
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    protected boolean isSatelliteAvailableAtCurrentLocation(@Nullable SubscriptionInfo info) {
        if(info == null) {
            plogd("isSatelliteAvailableAtCurrentLocation: subscriptionInfo is null");
            return false;
        }
        if (!isSatelliteAccessAllowedAtCurrentLocation()) {
            plogd("isSatelliteAvailableAtCurrentLocation: satellite access is not allowed at " +
                    "current location");
            return false;
        }
        if(info.isOnlyNonTerrestrialNetwork()) {
            return true;
        }

        int[] carrierTagIdsArray = mContext.getResources().getIntArray(
            R.array.config_verizon_satellite_enabled_tagids);
        List<Integer> carrierTagIds = null;

        if(carrierTagIdsArray != null && carrierTagIdsArray.length > 0) {
            carrierTagIds = Arrays.stream(carrierTagIdsArray)
                .boxed()
                .collect(Collectors.toList());
        }

        if(carrierTagIds == null) {
            plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier satellite enabled " +
                    "are not available");
            return false;
        }

        return isCarrierSatelliteAvailableAtCurrentLocation(carrierTagIds);
    }

    /**
     * Compares tagIds and determine if
     * carrier satellite is available at current location while selecting highest priority profile.
     *
     * @param carrierTagIds a list of integer tagIds representing regions where carrier satellite
     * coverage is available.
     * @return {@code true} if the carrier satellite is available at current location,
     *      {@code false} otherwise.
     */
    public boolean isCarrierSatelliteAvailableAtCurrentLocation(
        List<Integer> carrierTagIds) {
        synchronized (mSatelliteAccessConfigLock) {
            return !Collections.disjoint(carrierTagIds, mCurrentLocationTagIds);
        }
    }

    private int getSubIdFromSubscriberId(String subscriberId) {
        synchronized (mSatelliteTokenProvisionedLock) {
            return mSubscriberIdPerSub.getOrDefault(subscriberId,
@@ -7807,6 +7906,71 @@ public class SatelliteController extends Handler {
        }
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected void registerForSatelliteCommunicationAllowedStateChanged() {
        if (mRegisteredForSatelliteCommunicationAllowedStateChanged.get()) {
            if (DEBUG) {
                plogd("registerForSatelliteCommunicationAllowedStateChanged: already registered.");
            }
            return;
        }

        SatelliteManager satelliteManager = mContext.getSystemService(SatelliteManager.class);
        if (satelliteManager == null) {
            ploge("registerForSatelliteCommunicationAllowedStateChanged: SatelliteManager is null");
            return;
        }

        SatelliteCommunicationAllowedStateCallback allowedStateCallback =
            new SatelliteCommunicationAllowedStateCallback() {
                @Override
                public void onSatelliteCommunicationAllowedStateChanged(boolean isAllowed) {
                    plogd("onSatelliteCommunicationAllowedStateChanged: isAllowed="
                        + isAllowed);
                    synchronized (mSatelliteAccessConfigLock) {
                        mSatelliteAccessAllowed = isAllowed;
                    }
                }

                @Override
                public void onSatelliteAccessConfigurationChanged(
                    SatelliteAccessConfiguration satelliteAccessConfiguration) {
                    plogd("onSatelliteAccessConfigurationChanged: satelliteAccessConfiguration="
                        + satelliteAccessConfiguration);
                    handleSatelliteAccessConfigUpdateResult(satelliteAccessConfiguration);
                }
            };
        try {
            satelliteManager.registerForCommunicationAllowedStateChanged(
                    this::post, allowedStateCallback);
        } catch(RuntimeException e) {
            plogd("registerForSatelliteCommunicationAllowedStateChanged: " +
                    "satelliteManager.registerForCommunicationAllowedStateChanged() failed, " +
                    "e=" + e);
            return;
        }
        mRegisteredForSatelliteCommunicationAllowedStateChanged.set(true);
    }

    private void handleSatelliteAccessConfigUpdateResult(
        SatelliteAccessConfiguration satelliteAccessConfig) {
        if(satelliteAccessConfig != null) {
            synchronized (mSatelliteAccessConfigLock) {
                plogd("handleSatelliteAccessConfigUpdateResult:" + " satelliteAccessConfig="
                    + satelliteAccessConfig);
                List<Integer> tagIds = satelliteAccessConfig.getTagIds();
                if (!mCurrentLocationTagIds.equals(tagIds)) {
                    mCurrentLocationTagIds = tagIds;
                    sendMessageDelayed(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION),
                        mEvaluateEsosProfilesPrioritizationDurationMillis);
                }
            }
        } else {
                plogd("handleSatelliteAccessConfigUpdateResult: "
                    + "satelliteAccessConfiguration is null");
        }
    }

    private void handleEventSatelliteRegistrationFailure(int causeCode) {
        plogd("handleEventSatelliteRegistrationFailure: " + causeCode);

@@ -8313,6 +8477,12 @@ public class SatelliteController extends Handler {
        }
    }

    private boolean isSatelliteAccessAllowedAtCurrentLocation() {
        synchronized (mSatelliteAccessConfigLock) {
            return mSatelliteAccessAllowed;
        }
    }

    @Nullable
    private Boolean getIsSatelliteEnabled() {
        synchronized (mIsSatelliteEnabledLock) {
+40 −15
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.telephony.DropBoxManagerLoggerBackend;
import android.telephony.PersistentLogger;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsRegistrationAttributes;
@@ -79,6 +80,7 @@ import com.android.internal.telephony.metrics.SatelliteStats;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;


/**
@@ -119,8 +121,10 @@ public class SatelliteSOSMessageRecommender extends Handler {
    private boolean mCheckingAccessRestrictionInProgress = false;
    protected long mTimeoutMillis = 0;
    private final long mOemEnabledTimeoutMillis;
    private final AtomicBoolean mIsSatelliteConnectedViaCarrierWithinHysteresisTime =
    protected final AtomicBoolean mIsSatelliteConnectedViaCarrierWithinHysteresisTime =
            new AtomicBoolean(false);
    protected final AtomicInteger mSubIdOfSatelliteConnectedViaCarrierWithinHysteresisTime =
            new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    @GuardedBy("mLock")
    private boolean mIsTimerTimedOut = false;
    protected int mCountOfTimerStarted = 0;
@@ -238,8 +242,7 @@ public class SatelliteSOSMessageRecommender extends Handler {
         * should do this check now so that we have higher chance of sending the event
         * EVENT_DISPLAY_EMERGENCY_MESSAGE to Dialer.
         */
        mIsSatelliteConnectedViaCarrierWithinHysteresisTime.set(
                mSatelliteController.isSatelliteConnectedViaCarrierWithinHysteresisTime());
        updateSatelliteConnectedViaCarrierWithinHysteresisTimeState();
        sendMessage(obtainMessage(EVENT_EMERGENCY_CALL_STARTED, connection));
    }

@@ -377,8 +380,7 @@ public class SatelliteSOSMessageRecommender extends Handler {

    private void updateSatelliteViaCarrierAvailability() {
        if (!mIsSatelliteConnectedViaCarrierWithinHysteresisTime.get()) {
            mIsSatelliteConnectedViaCarrierWithinHysteresisTime.set(
                    mSatelliteController.isSatelliteConnectedViaCarrierWithinHysteresisTime());
            updateSatelliteConnectedViaCarrierWithinHysteresisTimeState();
        }
    }

@@ -571,11 +573,20 @@ public class SatelliteSOSMessageRecommender extends Handler {

    private void selectEmergencyCallWaitForConnectionTimeoutDuration() {
        if (isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
            int satelliteSubId = mSubIdOfSatelliteConnectedViaCarrierWithinHysteresisTime.get();
            mTimeoutMillis =
                    mSatelliteController.getCarrierEmergencyCallWaitForConnectionTimeoutMillis();
                    mSatelliteController.getCarrierEmergencyCallWaitForConnectionTimeoutMillis(
                            satelliteSubId);
        } else {
            int satelliteSubId = mSatelliteController.getSelectedSatelliteSubId();
            if (!SatelliteServiceUtils.isNtnOnlySubscriptionId(satelliteSubId)) {
                mTimeoutMillis =
                    mSatelliteController.getCarrierEmergencyCallWaitForConnectionTimeoutMillis(
                        satelliteSubId);
            } else {
                mTimeoutMillis = mOemEnabledTimeoutMillis;
            }
        }
        plogd("mTimeoutMillis = " + mTimeoutMillis);
    }

@@ -763,19 +774,20 @@ public class SatelliteSOSMessageRecommender extends Handler {

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public int getEmergencyCallToSatelliteHandoverType() {
        if (Flags.carrierRoamingNbIotNtn()
                && isDeviceProvisioned()
                && isSatelliteAllowedByReasons()
                && isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
            int satelliteSubId = mSatelliteController.getSelectedSatelliteSubId();
        if (isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
            int satelliteSubId = mSubIdOfSatelliteConnectedViaCarrierWithinHysteresisTime.get();
            return mSatelliteController.getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(
                    satelliteSubId);
        } else if (isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
            return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911;
        } else {
            int satelliteSubId = mSatelliteController.getSelectedSatelliteSubId();
            if (!SatelliteServiceUtils.isNtnOnlySubscriptionId(satelliteSubId)) {
                return mSatelliteController
                    .getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(satelliteSubId);
            } else {
                return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS;
            }
        }
    }

    private void requestIsSatelliteAllowedForCurrentLocation() {
        synchronized (mLock) {
@@ -831,6 +843,19 @@ public class SatelliteSOSMessageRecommender extends Handler {
        return (provisioned != null) && provisioned;
    }

    private void updateSatelliteConnectedViaCarrierWithinHysteresisTimeState() {
        Pair<Boolean, Integer> satelliteConnectedState =
                mSatelliteController.isSatelliteConnectedViaCarrierWithinHysteresisTime();
        mIsSatelliteConnectedViaCarrierWithinHysteresisTime.set(satelliteConnectedState.first);
        if (satelliteConnectedState.first) {
            mSubIdOfSatelliteConnectedViaCarrierWithinHysteresisTime.set(
                    satelliteConnectedState.second);
        } else {
            mSubIdOfSatelliteConnectedViaCarrierWithinHysteresisTime.set(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        }
    }

    private static void logv(@NonNull String log) {
        Rlog.v(TAG, log);
    }
+23 −0
Original line number Diff line number Diff line
@@ -365,6 +365,29 @@ public class SatelliteServiceUtils {
        return subId;
    }

    /**
     * Check if the subscription ID is a NTN only subscription ID.
     *
     * @return {@code true} if the subscription ID is a NTN only subscription ID,
     * {@code false} otherwise.
    */
    public static boolean isNtnOnlySubscriptionId(int subId) {
        SubscriptionManagerService subscriptionManagerService =
            SubscriptionManagerService.getInstance();
        if (subscriptionManagerService == null) {
            logd("isNtnOnlySubscriptionId: subscriptionManagerService is null");
            return false;
        }

        SubscriptionInfo subInfo = subscriptionManagerService.getSubscriptionInfo(subId);
        if (subInfo == null) {
            logd("isNtnOnlySubscriptionId: subInfo is null for subId=" + subId);
            return false;
        }

        return subInfo.isOnlyNonTerrestrialNetwork();
    }

    /**
     * Expected format of the input dictionary bundle is:
     * <ul>
+161 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading