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

Commit 1d770256 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Reset carrier roaming satellite params when radio is off" into 24D1-dev

parents 149aa0b7 10e5d92b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1178,7 +1178,11 @@ public class SatelliteController extends Handler {
            case EVENT_RADIO_STATE_CHANGED: {
                if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
                    mIsRadioOn = true;
                } else if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF) {
                    mIsRadioOn = false;
                    resetCarrierRoamingSatelliteModeParams();
                }

                if (mCi.getRadioState() != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
                    if (mSatelliteModemInterface.isSatelliteServiceConnected()) {
                        synchronized (mIsSatelliteSupportedLock) {
@@ -4516,6 +4520,14 @@ public class SatelliteController extends Handler {
                notificationBuilder.build(), UserHandle.ALL);
    }

    private void resetCarrierRoamingSatelliteModeParams() {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) return;

        for (Phone phone : PhoneFactory.getPhones()) {
            resetCarrierRoamingSatelliteModeParams(phone.getSubId());
        }
    }

    private void resetCarrierRoamingSatelliteModeParams(int subId) {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) return;

+35 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.satellite;
import static android.telephony.CarrierConfigManager.KEY_EMERGENCY_CALL_TO_SATELLITE_T911_HANDOVER_TIMEOUT_MILLIS_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
import static android.telephony.SubscriptionManager.SATELLITE_ENTITLEMENT_STATUS;
import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_GOOD;
import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_GREAT;
@@ -102,6 +103,7 @@ import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.telephony.CarrierConfigManager;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.satellite.INtnSignalStrengthCallback;
@@ -174,6 +176,8 @@ public class SatelliteControllerTest extends TelephonyTest {
    private static final int[] ACTIVE_SUB_IDS = {SUB_ID};
    private static final int TEST_WAIT_FOR_SATELLITE_ENABLING_RESPONSE_TIMEOUT_MILLIS =
            (int) TimeUnit.SECONDS.toMillis(60);

    private static final String SATELLITE_PLMN = "00103";
    private List<Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener>>
            mCarrierConfigChangedListenerList = new ArrayList<>();

@@ -700,6 +704,37 @@ public class SatelliteControllerTest extends TelephonyTest {
                .requestIsSatelliteSupported(any(Message.class));
    }

    @Test
    public void testRadioPowerOff() {
        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true);
        NetworkRegistrationInfo satelliteNri = new NetworkRegistrationInfo.Builder()
                .setIsNonTerrestrialNetwork(true)
                .setAvailableServices(List.of(NetworkRegistrationInfo.SERVICE_TYPE_DATA))
                .build();
        mCarrierConfigBundle.putInt(KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT, 1 * 60);
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
        for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair
                : mCarrierConfigChangedListenerList) {
            pair.first.execute(() -> pair.second.onCarrierConfigChanged(
                    /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0)
            );
        }
        when(mServiceState.getNetworkRegistrationInfoList()).thenReturn(List.of(satelliteNri));
        when(mServiceState.isUsingNonTerrestrialNetwork()).thenReturn(true);
        sendServiceStateChangedEvent();
        processAllMessages();
        assertTrue(mSatelliteControllerUT.isInSatelliteModeForCarrierRoaming(mPhone));
        assertEquals(List.of(SERVICE_TYPE_DATA),
                mSatelliteControllerUT.getCapabilitiesForCarrierRoamingSatelliteMode(mPhone));

        when(mServiceState.isUsingNonTerrestrialNetwork()).thenReturn(false);
        setRadioPower(false);
        processAllMessages();
        assertFalse(mSatelliteControllerUT.isInSatelliteModeForCarrierRoaming(mPhone));
        assertEquals(new ArrayList<>(),
                mSatelliteControllerUT.getCapabilitiesForCarrierRoamingSatelliteMode(mPhone));
    }

    @Test
    public void testRequestSatelliteEnabled() {
        mIsSatelliteEnabledSemaphore.drainPermits();