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

Commit 1162635a authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Fix for NPE when subscription is not found" into main

parents 526c50b1 acb8c9c4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -638,7 +638,7 @@ public class DatagramController {
                    }
                    }
                };
                };
                pollPendingSatelliteDatagrams(
                pollPendingSatelliteDatagrams(
                        SatelliteController.getInstance().getHighestPrioritySubscrption(),
                        SatelliteController.getInstance().getSelectedSatelliteSubId(),
                        internalCallback);
                        internalCallback);
            }
            }
        }
        }
+4 −16
Original line number Original line Diff line number Diff line
@@ -781,7 +781,7 @@ public class DatagramDispatcher extends Handler {
        mSendingInProgress = false;
        mSendingInProgress = false;
        mIsEmergencyCommunicationEstablished = false;
        mIsEmergencyCommunicationEstablished = false;


        int subId = SatelliteController.getInstance().getHighestPrioritySubscrption();
        int subId = SatelliteController.getInstance().getSelectedSatelliteSubId();
        if (getPendingMessagesCount() > 0) {
        if (getPendingMessagesCount() > 0) {
            mDatagramController.updateSendStatus(subId,
            mDatagramController.updateSendStatus(subId,
                    mLastSendRequestDatagramType,
                    mLastSendRequestDatagramType,
@@ -867,7 +867,7 @@ public class DatagramDispatcher extends Handler {
            @SatelliteManager.DatagramType int datagramType) {
            @SatelliteManager.DatagramType int datagramType) {
        plogw("Timed out to wait for satellite connected before sending datagrams");
        plogw("Timed out to wait for satellite connected before sending datagrams");
        synchronized (mLock) {
        synchronized (mLock) {
            int subId = SatelliteController.getInstance().getHighestPrioritySubscrption();
            int subId = SatelliteController.getInstance().getSelectedSatelliteSubId();
            // Update send status
            // Update send status
            mDatagramController.updateSendStatus(subId,
            mDatagramController.updateSendStatus(subId,
                    datagramType,
                    datagramType,
@@ -1051,15 +1051,9 @@ public class DatagramDispatcher extends Handler {
     *                    carrier roaming nb iot ntn SMS.
     *                    carrier roaming nb iot ntn SMS.
     */
     */
    public void sendSms(@NonNull PendingRequest pendingSms) {
    public void sendSms(@NonNull PendingRequest pendingSms) {
        Phone satellitePhone = SatelliteController.getInstance().getSatellitePhone();
        if (satellitePhone == null) {
            ploge("sendSms: satellitePhone is null.");
            return;
        }

        SatelliteController.getInstance().startPointingUI();
        SatelliteController.getInstance().startPointingUI();


        int subId = satellitePhone.getSubId();
        int subId = SatelliteController.getInstance().getSelectedSatelliteSubId();
        long messageId = pendingSms.uniqueMessageId;
        long messageId = pendingSms.uniqueMessageId;
        plogd("sendSms: subId=" + subId + " messageId:" + messageId);
        plogd("sendSms: subId=" + subId + " messageId:" + messageId);


@@ -1098,13 +1092,7 @@ public class DatagramDispatcher extends Handler {
            return;
            return;
        }
        }


        Phone satellitePhone = SatelliteController.getInstance().getSatellitePhone();
        int subId = SatelliteController.getInstance().getSelectedSatelliteSubId();
        if (satellitePhone == null) {
            ploge("sendPendingSms: satellitePhone is null.");
            return;
        }
        int subId = satellitePhone.getSubId();

        Set<Entry<Long, PendingRequest>> pendingSms = null;
        Set<Entry<Long, PendingRequest>> pendingSms = null;
        if (!mSendingInProgress) {
        if (!mSendingInProgress) {
            pendingSms = mPendingSmsMap.entrySet();
            pendingSms = mPendingSmsMap.entrySet();
+1 −1
Original line number Original line Diff line number Diff line
@@ -703,7 +703,7 @@ public class DatagramReceiver extends Handler {
            stopDatagramWaitForConnectedStateTimer();
            stopDatagramWaitForConnectedStateTimer();
        }
        }


        int subId = SatelliteController.getInstance().getHighestPrioritySubscrption();
        int subId = SatelliteController.getInstance().getSelectedSatelliteSubId();
        if (mDatagramController.isReceivingDatagrams()) {
        if (mDatagramController.isReceivingDatagrams()) {
            mDatagramController.updateReceiveStatus(subId,
            mDatagramController.updateReceiveStatus(subId,
                    SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
                    SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+79 −47
Original line number Original line Diff line number Diff line
@@ -1310,8 +1310,20 @@ public class SatelliteController extends Handler {
                    }
                    }
                }
                }
                onCompleted = obtainMessage(EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE, request);
                onCompleted = obtainMessage(EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE, request);
                SatelliteModemEnableRequestAttributes enableRequestAttributes =
                    createModemEnableRequest(argument);
                if (enableRequestAttributes == null) {
                    plogw("UpdateEnableAttributes: enableRequestAttributes is null");
                    sendErrorAndReportSessionMetrics(
                        SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE,
                        argument.callback);
                    synchronized (mSatelliteEnabledRequestLock) {
                        mSatelliteEnableAttributesUpdateRequest = null;
                    }
                    break;
                }
                mSatelliteModemInterface.requestSatelliteEnabled(
                mSatelliteModemInterface.requestSatelliteEnabled(
                        createModemEnableRequest(argument), onCompleted);
                        enableRequestAttributes, onCompleted);
                startWaitForUpdateSatelliteEnableAttributesResponseTimer(argument);
                startWaitForUpdateSatelliteEnableAttributesResponseTimer(argument);
                break;
                break;
            }
            }
@@ -1739,15 +1751,22 @@ public class SatelliteController extends Handler {
                onCompleted = obtainMessage(EVENT_UPDATE_PROVISION_SATELLITE_TOKEN_DONE, request);
                onCompleted = obtainMessage(EVENT_UPDATE_PROVISION_SATELLITE_TOKEN_DONE, request);
                boolean provisionChanged = updateSatelliteSubscriptionProvisionState(
                boolean provisionChanged = updateSatelliteSubscriptionProvisionState(
                        argument.mSatelliteSubscriberInfoList, argument.mProvisioned);
                        argument.mSatelliteSubscriberInfoList, argument.mProvisioned);
                selectBindingSatelliteSubscription();
                int subId = getSelectedSatelliteSubId();
                int subId = getSelectedSatelliteSubId();
                setSatellitePhone(subId);
                SubscriptionInfo subscriptionInfo =
                String iccId = mSubscriptionManagerService.getSubscriptionInfo(subId).getIccId();
                    mSubscriptionManagerService.getSubscriptionInfo(subId);
                if (subscriptionInfo == null) {
                    logw("updateSatelliteToken subId=" + subId + " is not found");
                } else {
                    String iccId = subscriptionInfo.getIccId();
                    argument.setIccId(iccId);
                    argument.setIccId(iccId);
                    synchronized (mSatelliteTokenProvisionedLock) {
                    synchronized (mSatelliteTokenProvisionedLock) {
                        if (!iccId.equals(mLastConfiguredIccId)) {
                        if (!iccId.equals(mLastConfiguredIccId)) {
                        logd("updateSatelliteSubscription subId=" + subId + ", iccId=" + iccId
                            logd("updateSatelliteSubscription subId=" + subId
                                + " to modem");
                                    + ", iccId=" + iccId + " to modem");
                        mSatelliteModemInterface.updateSatelliteSubscription(iccId, onCompleted);
                            mSatelliteModemInterface.updateSatelliteSubscription(
                                iccId, onCompleted);
                        }
                    }
                    }
                }
                }
                if (provisionChanged) {
                if (provisionChanged) {
@@ -2227,7 +2246,7 @@ public class SatelliteController extends Handler {
                /* We have already successfully queried the satellite modem. */
                /* We have already successfully queried the satellite modem. */
                Bundle bundle = new Bundle();
                Bundle bundle = new Bundle();
                bundle.putBoolean(SatelliteManager.KEY_SATELLITE_SUPPORTED, mIsSatelliteSupported);
                bundle.putBoolean(SatelliteManager.KEY_SATELLITE_SUPPORTED, mIsSatelliteSupported);
                bundle.putInt(SATELLITE_SUBSCRIPTION_ID, getHighestPrioritySubscrption());
                bundle.putInt(SATELLITE_SUBSCRIPTION_ID, getSelectedSatelliteSubId());
                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                return;
                return;
            }
            }
@@ -2280,7 +2299,7 @@ public class SatelliteController extends Handler {
            return;
            return;
        }
        }


        final int validSubId = getHighestPrioritySubscrption();
        final int validSubId = getSelectedSatelliteSubId();
        mPointingAppController.registerForSatelliteTransmissionUpdates(validSubId, callback);
        mPointingAppController.registerForSatelliteTransmissionUpdates(validSubId, callback);
        sendRequestAsync(CMD_START_SATELLITE_TRANSMISSION_UPDATES,
        sendRequestAsync(CMD_START_SATELLITE_TRANSMISSION_UPDATES,
                new SatelliteTransmissionUpdateArgument(result, callback, validSubId), null);
                new SatelliteTransmissionUpdateArgument(result, callback, validSubId), null);
@@ -2298,7 +2317,7 @@ public class SatelliteController extends Handler {
            @NonNull ISatelliteTransmissionUpdateCallback callback) {
            @NonNull ISatelliteTransmissionUpdateCallback callback) {
        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(errorCallback::accept);
        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(errorCallback::accept);
        mPointingAppController.unregisterForSatelliteTransmissionUpdates(
        mPointingAppController.unregisterForSatelliteTransmissionUpdates(
                getHighestPrioritySubscrption(), result, callback);
                getSelectedSatelliteSubId(), result, callback);


        // Even if handler is null - which means there are no listeners, the modem command to stop
        // Even if handler is null - which means there are no listeners, the modem command to stop
        // satellite transmission updates might have failed. The callers might want to retry
        // satellite transmission updates might have failed. The callers might want to retry
@@ -2328,7 +2347,7 @@ public class SatelliteController extends Handler {
            return null;
            return null;
        }
        }


        final int validSubId = getHighestPrioritySubscrption();
        final int validSubId = getSelectedSatelliteSubId();
        if (mSatelliteProvisionCallbacks.containsKey(validSubId)) {
        if (mSatelliteProvisionCallbacks.containsKey(validSubId)) {
            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS);
            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS);
            return null;
            return null;
@@ -2380,7 +2399,7 @@ public class SatelliteController extends Handler {


        sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
        sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
                new ProvisionSatelliteServiceArgument(token, null,
                new ProvisionSatelliteServiceArgument(token, null,
                        result, getHighestPrioritySubscrption()),
                        result, getSelectedSatelliteSubId()),
                null);
                null);
    }
    }


@@ -2528,7 +2547,7 @@ public class SatelliteController extends Handler {
        }
        }
        plogd("registerForIncomingDatagram: callback=" + callback);
        plogd("registerForIncomingDatagram: callback=" + callback);
        return mDatagramController.registerForSatelliteDatagram(
        return mDatagramController.registerForSatelliteDatagram(
                getHighestPrioritySubscrption(), callback);
                getSelectedSatelliteSubId(), callback);
    }
    }


    /**
    /**
@@ -2549,7 +2568,7 @@ public class SatelliteController extends Handler {
        }
        }
        plogd("unregisterForIncomingDatagram: callback=" + callback);
        plogd("unregisterForIncomingDatagram: callback=" + callback);
        mDatagramController.unregisterForSatelliteDatagram(
        mDatagramController.unregisterForSatelliteDatagram(
                getHighestPrioritySubscrption(), callback);
                getSelectedSatelliteSubId(), callback);
    }
    }


    /**
    /**
@@ -2571,7 +2590,7 @@ public class SatelliteController extends Handler {
        }
        }


        mDatagramController.pollPendingSatelliteDatagrams(
        mDatagramController.pollPendingSatelliteDatagrams(
                getHighestPrioritySubscrption(), result);
                getSelectedSatelliteSubId(), result);
    }
    }


    /**
    /**
@@ -2611,7 +2630,7 @@ public class SatelliteController extends Handler {
                    mIsEmergency);
                    mIsEmergency);
        }
        }


        mDatagramController.sendSatelliteDatagram(getHighestPrioritySubscrption(), datagramType,
        mDatagramController.sendSatelliteDatagram(getSelectedSatelliteSubId(), datagramType,
                datagram, needFullScreenPointingUI, result);
                datagram, needFullScreenPointingUI, result);
    }
    }


@@ -3272,7 +3291,7 @@ public class SatelliteController extends Handler {
            return;
            return;
        }
        }


        int satelliteSubId = getHighestPrioritySubscrption();
        int satelliteSubId = getSelectedSatelliteSubId();
        if (subId != satelliteSubId) {
        if (subId != satelliteSubId) {
            logd("onSmsReceived: SMS received " + subId
            logd("onSmsReceived: SMS received " + subId
                    + ", but not satellite subscription " + satelliteSubId);
                    + ", but not satellite subscription " + satelliteSubId);
@@ -3947,6 +3966,23 @@ public class SatelliteController extends Handler {
        RequestSatelliteEnabledArgument argument =
        RequestSatelliteEnabledArgument argument =
                (RequestSatelliteEnabledArgument) request.argument;
                (RequestSatelliteEnabledArgument) request.argument;
        handlePersistentLoggingOnSessionStart(argument);
        handlePersistentLoggingOnSessionStart(argument);
        selectBindingSatelliteSubscription();
        SatelliteModemEnableRequestAttributes enableRequestAttributes =
                    createModemEnableRequest(argument);
        if (enableRequestAttributes == null) {
            plogw("handleSatelliteEnabled: enableRequestAttributes is null");
            sendErrorAndReportSessionMetrics(
                    SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, argument.callback);
            synchronized (mSatelliteEnabledRequestLock) {
                if (argument.enableSatellite) {
                    mSatelliteEnabledRequest = null;
                } else {
                    mSatelliteDisabledRequest = null;
                }
            }
            return;
        }

        if (mSatelliteSessionController != null) {
        if (mSatelliteSessionController != null) {
            mSatelliteSessionController.onSatelliteEnablementStarted(argument.enableSatellite);
            mSatelliteSessionController.onSatelliteEnablementStarted(argument.enableSatellite);
        } else {
        } else {
@@ -3966,8 +4002,7 @@ public class SatelliteController extends Handler {


        Message onCompleted = obtainMessage(EVENT_SET_SATELLITE_ENABLED_DONE, request);
        Message onCompleted = obtainMessage(EVENT_SET_SATELLITE_ENABLED_DONE, request);
        mSatelliteModemInterface.requestSatelliteEnabled(
        mSatelliteModemInterface.requestSatelliteEnabled(
                createModemEnableRequest(argument),
                enableRequestAttributes, onCompleted);
                onCompleted);
        startWaitForSatelliteEnablingResponseTimer(argument);
        startWaitForSatelliteEnablingResponseTimer(argument);
        // Logs satellite session timestamps for session metrics
        // Logs satellite session timestamps for session metrics
        if (argument.enableSatellite) {
        if (argument.enableSatellite) {
@@ -3977,11 +4012,15 @@ public class SatelliteController extends Handler {
    }
    }


    /** Get the request attributes that modem needs to enable/disable satellite */
    /** Get the request attributes that modem needs to enable/disable satellite */
    private SatelliteModemEnableRequestAttributes createModemEnableRequest(
    @Nullable private SatelliteModemEnableRequestAttributes createModemEnableRequest(
            @NonNull RequestSatelliteEnabledArgument arg) {
            @NonNull RequestSatelliteEnabledArgument arg) {
        int subId = getHighestPrioritySubscrption();
        int subId = getSelectedSatelliteSubId();
        SubscriptionInfo subInfo = mSubscriptionManagerService.getSubscriptionInfo(subId);
        SubscriptionInfo subInfo = mSubscriptionManagerService.getSubscriptionInfo(subId);
        String iccid = subInfo != null ? subInfo.getIccId() : "";
        if (subInfo == null) {
            loge("createModemEnableRequest: no SubscriptionInfo found for subId=" + subId);
            return null;
        }
        String iccid = subInfo.getIccId();
        String apn = getConfigForSubId(subId).getString(KEY_SATELLITE_NIDD_APN_NAME_STRING, "");
        String apn = getConfigForSubId(subId).getString(KEY_SATELLITE_NIDD_APN_NAME_STRING, "");
        return new SatelliteModemEnableRequestAttributes(
        return new SatelliteModemEnableRequestAttributes(
                arg.enableSatellite, arg.enableDemoMode, arg.isEmergency,
                arg.enableSatellite, arg.enableDemoMode, arg.isEmergency,
@@ -4794,13 +4833,13 @@ public class SatelliteController extends Handler {
        resetCarrierRoamingSatelliteModeParams(subId);
        resetCarrierRoamingSatelliteModeParams(subId);
        handleStateChangedForCarrierRoamingNtnEligibility();
        handleStateChangedForCarrierRoamingNtnEligibility();
        sendMessageDelayed(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION),
        sendMessageDelayed(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION),
                TimeUnit.MINUTES.toMillis(1));
                mEvaluateEsosProfilesPrioritizationDurationMillis);
    }
    }


    // imsi, msisdn, default sms subId change
    // imsi, msisdn, default sms subId change
    private void handleSubscriptionsChanged() {
    private void handleSubscriptionsChanged() {
        sendMessageDelayed(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION),
        sendMessageDelayed(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION),
                TimeUnit.MINUTES.toMillis(1));
                mEvaluateEsosProfilesPrioritizationDurationMillis);
    }
    }


    private void processNewCarrierConfigData(int subId) {
    private void processNewCarrierConfigData(int subId) {
@@ -5432,7 +5471,7 @@ public class SatelliteController extends Handler {
                return;
                return;
            }
            }


            int subId = getHighestPrioritySubscrption();
            int subId = getSelectedSatelliteSubId();
            long timeout = getCarrierSupportedSatelliteNotificationHysteresisTimeMillis(subId);
            long timeout = getCarrierSupportedSatelliteNotificationHysteresisTimeMillis(subId);
            mNtnEligibilityHysteresisTimedOut = false;
            mNtnEligibilityHysteresisTimedOut = false;
            plogd("startNtnEligibilityHysteresisTimer: sendMessageDelayed subId=" + subId
            plogd("startNtnEligibilityHysteresisTimer: sendMessageDelayed subId=" + subId
@@ -5471,7 +5510,7 @@ public class SatelliteController extends Handler {
                    || mLastNotifiedNtnEligibility != currentNtnEligibility) {
                    || mLastNotifiedNtnEligibility != currentNtnEligibility) {
                mLastNotifiedNtnEligibility = currentNtnEligibility;
                mLastNotifiedNtnEligibility = currentNtnEligibility;
                mSatellitePhone.notifyCarrierRoamingNtnEligibleStateChanged(currentNtnEligibility);
                mSatellitePhone.notifyCarrierRoamingNtnEligibleStateChanged(currentNtnEligibility);
                updateSatelliteSystemNotification(getHighestPrioritySubscrption(),
                updateSatelliteSystemNotification(getSelectedSatelliteSubId(),
                        CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL,
                        CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL,
                        currentNtnEligibility);
                        currentNtnEligibility);
            }
            }
@@ -6295,6 +6334,7 @@ public class SatelliteController extends Handler {
                mContext.getOpPackageName(), mContext.getAttributionTag());
                mContext.getOpPackageName(), mContext.getAttributionTag());
        // Key : priority - lower value has higher priority; Value : List<SubscriptionInfo>
        // Key : priority - lower value has higher priority; Value : List<SubscriptionInfo>
        TreeMap<Integer, List<SubscriptionInfo>> newSubsInfoListPerPriority = new TreeMap<>();
        TreeMap<Integer, List<SubscriptionInfo>> newSubsInfoListPerPriority = new TreeMap<>();
        plogd("evaluateESOSProfilesPrioritization: allSubInfos.size()=" + allSubInfos.size());
        synchronized (mSatelliteTokenProvisionedLock) {
        synchronized (mSatelliteTokenProvisionedLock) {
            for (SubscriptionInfo info : allSubInfos) {
            for (SubscriptionInfo info : allSubInfos) {
                int subId = info.getSubscriptionId();
                int subId = info.getSubscriptionId();
@@ -6333,6 +6373,8 @@ public class SatelliteController extends Handler {
                }
                }
            }
            }
        }
        }
        plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()="
                  + newSubsInfoListPerPriority.size());


        if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) {
        if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) {
            logd("evaluateESOSProfilesPrioritization: no satellite subscription available");
            logd("evaluateESOSProfilesPrioritization: no satellite subscription available");
@@ -6506,7 +6548,7 @@ public class SatelliteController extends Handler {
        return list;
        return list;
    }
    }


    private int getSelectedSatelliteSubId() {
    public int getSelectedSatelliteSubId() {
        synchronized (mSatelliteTokenProvisionedLock) {
        synchronized (mSatelliteTokenProvisionedLock) {
            return mSelectedSatelliteSubId;
            return mSelectedSatelliteSubId;
        }
        }
@@ -6535,13 +6577,11 @@ public class SatelliteController extends Handler {
        synchronized (mSatelliteTokenProvisionedLock) {
        synchronized (mSatelliteTokenProvisionedLock) {
            if (selectedSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
            if (selectedSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
                    && isSatelliteSupportedViaOem()) {
                    && isSatelliteSupportedViaOem()) {
                mSelectedSatelliteSubId = SatelliteServiceUtils.getNtnOnlySubscriptionId(mContext);
                selectedSubId = SatelliteServiceUtils.getNtnOnlySubscriptionId(mContext);
            }
            }
            if (selectedSubId != mSelectedSatelliteSubId) {
            mSelectedSatelliteSubId = selectedSubId;
            mSelectedSatelliteSubId = selectedSubId;
            setSatellitePhone(selectedSubId);
            setSatellitePhone(selectedSubId);
        }
        }
        }
        plogd("selectBindingSatelliteSubscription: SelectedSatelliteSubId="
        plogd("selectBindingSatelliteSubscription: SelectedSatelliteSubId="
                + mSelectedSatelliteSubId);
                + mSelectedSatelliteSubId);
    }
    }
@@ -6647,13 +6687,14 @@ public class SatelliteController extends Handler {
    /** Return the carrier ID of the binding satellite subscription. */
    /** Return the carrier ID of the binding satellite subscription. */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public int getSatelliteCarrierId() {
    public int getSatelliteCarrierId() {
        synchronized (mSatellitePhoneLock) {
        synchronized (mSatelliteTokenProvisionedLock) {
            if (mSatellitePhone != null) {
            SubscriptionInfo subInfo = mSubscriptionManagerService.getSubscriptionInfo(
                return mSatellitePhone.getCarrierId();
                    mSelectedSatelliteSubId);
            } else {
            if (subInfo == null) {
                logd("getSatelliteCarrierId: returns UNKNOWN_CARRIER_ID");
                logd("getSatelliteCarrierId: returns UNKNOWN_CARRIER_ID");
                return UNKNOWN_CARRIER_ID;
                return UNKNOWN_CARRIER_ID;
            }
            }
            return subInfo.getCarrierId();
        }
        }
    }
    }


@@ -6756,15 +6797,6 @@ public class SatelliteController extends Handler {
        }
        }
    }
    }


    /**
     * Return the highest priority satellite subscirption ID.
     */
    public int getHighestPrioritySubscrption() {
        synchronized (mSatellitePhoneLock) {
            return mSatellitePhone.getSubId();
        }
    }

    /** Start PointingUI if it is required. */
    /** Start PointingUI if it is required. */
    public void startPointingUI() {
    public void startPointingUI() {
        synchronized (mNeedsSatellitePointingLock) {
        synchronized (mNeedsSatellitePointingLock) {
+2 −24
Original line number Original line Diff line number Diff line
@@ -415,7 +415,7 @@ public class SatelliteSOSMessageRecommender extends Handler {
                        .setRecommendingHandoverType(getEmergencyCallToSatelliteHandoverType())
                        .setRecommendingHandoverType(getEmergencyCallToSatelliteHandoverType())
                        .setIsSatelliteAllowedInCurrentLocation(isSatelliteAllowed())
                        .setIsSatelliteAllowedInCurrentLocation(isSatelliteAllowed())
                        .setIsWifiConnected(mCountryDetector.isWifiNetworkConnected())
                        .setIsWifiConnected(mCountryDetector.isWifiNetworkConnected())
                        .setCarrierId(getAvailableNtnCarrierID()).build());
                        .setCarrierId(mSatelliteController.getSatelliteCarrierId()).build());
    }
    }


    private void cleanUpResources(boolean isDialerNotified) {
    private void cleanUpResources(boolean isDialerNotified) {
@@ -739,12 +739,7 @@ public class SatelliteSOSMessageRecommender extends Handler {
    public int getEmergencyCallToSatelliteHandoverType() {
    public int getEmergencyCallToSatelliteHandoverType() {
        if (Flags.carrierRoamingNbIotNtn() && isSatelliteViaOemAvailable()
        if (Flags.carrierRoamingNbIotNtn() && isSatelliteViaOemAvailable()
                && isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
                && isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
            Phone satellitePhone = mSatelliteController.getSatellitePhone();
            int satelliteSubId = mSatelliteController.getSelectedSatelliteSubId();
            if (satellitePhone == null) {
                ploge("getEmergencyCallToSatelliteHandoverType: satellitePhone is null");
                return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911;
            }
            int satelliteSubId = satellitePhone.getSubId();
            return mSatelliteController.getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(
            return mSatelliteController.getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(
                    satelliteSubId);
                    satelliteSubId);
        } else if (isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
        } else if (isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
@@ -833,23 +828,6 @@ public class SatelliteSOSMessageRecommender extends Handler {
        }
        }
    }
    }


    /** Returns the carrier ID of NTN subscription */
    private int getAvailableNtnCarrierID() {
        Pair<Boolean, Integer> ntnSubInfo =
                mSatelliteController.isUsingNonTerrestrialNetworkViaCarrier();
        if (ntnSubInfo.first) {
            TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
            return tm.createForSubscriptionId(ntnSubInfo.second).getSimCarrierId();
        }

        Phone satellitePhone = mSatelliteController.getSatellitePhone();
        if (satellitePhone != null) {
            return satellitePhone.getCarrierId();
        }

        return TelephonyManager.UNKNOWN_CARRIER_ID;
    }

    private void plogd(@NonNull String log) {
    private void plogd(@NonNull String log) {
        Rlog.d(TAG, log);
        Rlog.d(TAG, log);
        if (mPersistentLogger != null) {
        if (mPersistentLogger != null) {
Loading