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

Commit 6b3a33c0 authored by Steve Statia's avatar Steve Statia Committed by Android (Google) Code Review
Browse files

Merge "Add config and flag check to getEmergencyCallToSatelliteHandoverType()...

Merge "Add config and flag check to getEmergencyCallToSatelliteHandoverType() to get the handover type from the carrier config." into main
parents 32b015b4 52ca4c84
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.provider.Settings.ACTION_SATELLITE_SETTING;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_TYPE;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_SATELLITE_DEFAULT_SERVICES_INT_ARRAY;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE;
@@ -4213,6 +4214,7 @@ public class SatelliteController extends Handler {
                    KEY_SATELLITE_ESOS_SUPPORTED_BOOL,
                    KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
                    KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT,
                    KEY_CARRIER_ROAMING_NTN_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_INT,
                    KEY_SATELLITE_SCREEN_OFF_INACTIVITY_TIMEOUT_SEC_INT
            );
        }
@@ -4352,6 +4354,11 @@ public class SatelliteController extends Handler {
        return getConfigForSubId(subId).getInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT);
    }

    protected int getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(int subId) {
        return getConfigForSubId(subId).getInt(
                KEY_CARRIER_ROAMING_NTN_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_INT);
    }

    /**
     * Check if satellite attach is enabled by user for the carrier associated with the
     * {@code subId}.
+16 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony.satellite;

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_INT;
import static android.telephony.ServiceState.STATE_EMERGENCY_ONLY;
import static android.telephony.ServiceState.STATE_IN_SERVICE;
import static android.telephony.ServiceState.STATE_OUT_OF_SERVICE;
@@ -42,6 +43,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.OutcomeReceiver;
import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.telecom.Connection;
@@ -68,6 +70,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SmsApplication;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.metrics.SatelliteStats;

import java.util.concurrent.atomic.AtomicBoolean;
@@ -702,8 +705,19 @@ public class SatelliteSOSMessageRecommender extends Handler {
        return telephonyManager.isMultiSimEnabled();
    }

    private int getEmergencyCallToSatelliteHandoverType() {
        if (isSatelliteViaCarrierAvailable()) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public int getEmergencyCallToSatelliteHandoverType() {
        if (Flags.carrierRoamingNbIotNtn() && isSatelliteViaOemAvailable()
                && isSatelliteViaCarrierAvailable()) {
            Phone satellitePhone = mSatelliteController.getSatellitePhone();
            if (satellitePhone == null) {
                ploge("getEmergencyCallToSatelliteHandoverType: satellitePhone is null");
                return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911;
            }
            int satelliteSubId = satellitePhone.getSubId();
            return mSatelliteController.getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(
                    satelliteSubId);
        } else if (isSatelliteViaCarrierAvailable()) {
            return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911;
        } else {
            return EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS;
+51 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.Bundle;
import android.os.Looper;
import android.os.OutcomeReceiver;
import android.os.RemoteException;
import android.platform.test.flag.junit.SetFlagsRule;
import android.telecom.Connection;
import android.telecom.TelecomManager;
import android.telephony.BinderCacheManager;
@@ -65,9 +66,11 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.flags.Flags;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -108,6 +111,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
    private ImsManager.MmTelFeatureConnectionFactory mMmTelFeatureConnectionFactory;
    @Mock
    private FeatureFlags mFeatureFlags;
    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    private TestConnection mTestConnection;
    private Uri mTestConnectionAddress = Uri.parse("tel:1234");
    private TestSOSMessageRecommender mTestSOSMessageRecommender;
@@ -127,6 +132,7 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
                R.integer.config_emergency_call_wait_for_connection_timeout_millis))
                .thenReturn(TEST_EMERGENCY_CALL_TO_SOS_MSG_HYSTERESIS_TIMEOUT_MILLIS);
        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        mTestSatelliteController = new TestSatelliteController(mContext,
                Looper.myLooper(), mFeatureFlags);
        mTestImsManager = new TestImsManager(
@@ -552,6 +558,51 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
        assertEquals(carrierTimeoutMillis, mTestSOSMessageRecommender.getTimeOutMillis());
    }

    @Test
    public void testGetEmergencyCallToSatelliteHandoverType_SatelliteViaCarrierAndOemAvailable() {
        mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);

        mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(true);
        mTestSatelliteController.mIsSatelliteViaOemProvisioned = true;
        mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection);
        assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911,
                mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());

        mSetFlagsRule.disableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
    }

    @Test
    public void testGetEmergencyCallToSatelliteHandoverType_OnlySatelliteViaCarrierAvailable() {
        mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);

        mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(true);
        mTestSatelliteController.mIsSatelliteViaOemProvisioned = false;
        mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection);
        assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911,
                mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());

        mSetFlagsRule.disableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
    }

    @Test
    public void testGetEmergencyCallToSatelliteHandoverType_OemAndCarrierNotAvailable() {
        mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);

        mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(false);
        mTestSatelliteController.mIsSatelliteViaOemProvisioned = true;
        mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection);
        assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS,
                mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());

        mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(false);
        mTestSatelliteController.mIsSatelliteViaOemProvisioned = false;
        mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection);
        assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS,
                mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());

        mSetFlagsRule.disableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
    }

    private void testStopTrackingCallBeforeTimeout(
            @Connection.ConnectionState int connectionState) {
        mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection);