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

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

Merge cherrypicks of ['googleplex-android-review.googlesource.com/33443931'] into 25Q2-release.

Change-Id: I51a951e3fa0595a07d664d964cdf63592f674b1e
parents 6f7e004a 0a93c66b
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -365,6 +365,7 @@ public class SatelliteController extends Handler {
    private boolean mDisableNFCOnSatelliteEnabled = false;
    private boolean mDisableUWBOnSatelliteEnabled = false;
    private boolean mDisableWifiOnSatelliteEnabled = false;
    private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false);

    private final Object mSatelliteEnabledRequestLock = new Object();
    /* This variable is used to store the first enable request that framework has received in the
@@ -5421,7 +5422,8 @@ public class SatelliteController extends Handler {
                obtainMessage(EVENT_SET_SATELLITE_PLMN_INFO_DONE));
    }

    private Set<String> getAllPlmnSet() {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    protected Set<String> getAllPlmnSet() {
        Set<String> allPlmnSetFromSubInfo = new HashSet<>();
        int[] activeSubIdArray = mSubscriptionManagerService.getActiveSubIdList(true);
        for (int activeSubId : activeSubIdArray) {
@@ -5430,6 +5432,12 @@ public class SatelliteController extends Handler {
        }
        allPlmnSetFromSubInfo.addAll(mSatellitePlmnListFromOverlayConfig);

        if (mIgnorePlmnListFromStorage.get()) {
            // Do not use PLMN list from storage
            plogd("getAllPlmnList: allPlmnSetFromSubInfo=" + allPlmnSetFromSubInfo);
            return allPlmnSetFromSubInfo;
        }

        Set<String> allPlmnListFromStorage = getCarrierRoamingNtnAllSatellitePlmnSetFromStorage();
        if (!allPlmnListFromStorage.containsAll(allPlmnSetFromSubInfo)) {
            allPlmnListFromStorage.addAll(allPlmnSetFromSubInfo);
@@ -9322,4 +9330,17 @@ public class SatelliteController extends Handler {

        return getSatelliteDataServicePolicyForPlmn(subId, "");
    }

    /**
     * This API can be used by only CTS to make the function {@link #getAllPlmnSet()} to exclude the
     * PLMN list from storage from the returned result.
     *
     * @param enabled Whether to enable boolean config.
     * @return {@code true} if the value is set successfully, {@code false} otherwise.
     */
    public boolean setSatelliteIgnorePlmnListFromStorage(boolean enabled) {
        plogd("setSatelliteIgnorePlmnListFromStorage - " + enabled);
        mIgnorePlmnListFromStorage.set(enabled);
        return true;
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.util.TelephonyUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -556,8 +557,8 @@ public class SatelliteServiceUtils {

    /** Check whether device is connected to satellite PLMN */
    public static boolean isSatellitePlmn(int subId, @NonNull ServiceState serviceState) {
        List<String> satellitePlmnList =
                SatelliteController.getInstance().getSatellitePlmnsForCarrier(subId);
        List<String> satellitePlmnList = new ArrayList<>(
                SatelliteController.getInstance().getAllPlmnSet());
        if (satellitePlmnList.isEmpty()) {
            logd("isSatellitePlmn: satellitePlmnList is empty");
            return false;
@@ -567,12 +568,12 @@ public class SatelliteServiceUtils {
                serviceState.getNetworkRegistrationInfoListForTransportType(
                        AccessNetworkConstants.TRANSPORT_TYPE_WWAN)) {
            String registeredPlmn = nri.getRegisteredPlmn();
            if (TextUtils.isEmpty(registeredPlmn)) {
                logd("isSatellitePlmn: registeredPlmn is empty");
            String mccmnc = getMccMnc(nri);
            if (TextUtils.isEmpty(registeredPlmn) && TextUtils.isEmpty(mccmnc)) {
                logd("isSatellitePlmn: registeredPlmn and cell plmn are empty");
                continue;
            }

            String mccmnc = getMccMnc(nri);
            for (String satellitePlmn : satellitePlmnList) {
                if (TextUtils.equals(satellitePlmn, registeredPlmn)
                        || TextUtils.equals(satellitePlmn, mccmnc)) {
+11 −3
Original line number Diff line number Diff line
@@ -248,6 +248,8 @@ public class SatelliteControllerTest extends TelephonyTest {
            (int) TimeUnit.SECONDS.toMillis(60);
    private static final int TEST_WAIT_FOR_CELLULAR_MODEM_OFF_TIMEOUT_MILLIS =
            (int) TimeUnit.SECONDS.toMillis(60);
    private static final Set<String> TEST_ALL_SATELLITE_PLMN_SET = new HashSet<>(
            Arrays.asList("310830", "313210"));


    private static final String SATELLITE_PLMN = "00103";
@@ -262,7 +264,7 @@ public class SatelliteControllerTest extends TelephonyTest {
    private SubscriptionInfo testSubscriptionInfo;
    private SubscriptionInfo testSubscriptionInfo2;

    @Mock private SatelliteController mMockSatelliteController;
    @Mock private TestSatelliteController mMockSatelliteController;
    @Mock private DatagramController mMockDatagramController;
    @Mock private SatelliteModemInterface mMockSatelliteModemInterface;
    @Mock private SatelliteSessionController mMockSatelliteSessionController;
@@ -729,6 +731,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        doReturn(mSubscriptionInfo).when(mMockSubscriptionManagerService).getSubscriptionInfo(
                anyInt());
        doReturn("").when(mSubscriptionInfo).getIccId();
        doReturn(TEST_ALL_SATELLITE_PLMN_SET).when(mMockSatelliteController).getAllPlmnSet();
    }

    @After
@@ -5911,7 +5914,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        }
    }

    private class TestSatelliteController extends SatelliteController {
    public class TestSatelliteController extends SatelliteController {
        public boolean setSettingsKeyForSatelliteModeCalled = false;
        public boolean allRadiosDisabled = true;
        public long elapsedRealtime = 0;
@@ -5930,7 +5933,7 @@ public class SatelliteControllerTest extends TelephonyTest {

        private boolean mLocationServiceEnabled = true;

        TestSatelliteController(
        public TestSatelliteController(
                Context context, Looper looper, @NonNull FeatureFlags featureFlags) {
            super(context, looper, featureFlags);
            logd("Constructing TestSatelliteController");
@@ -6073,6 +6076,11 @@ public class SatelliteControllerTest extends TelephonyTest {
            }
        }

        @Override
        protected Set<String> getAllPlmnSet() {
            return super.getAllPlmnSet();
        }

        public boolean isRadioOn() {
            synchronized (mIsRadioOnLock) {
                return mIsRadioOn;
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
@@ -88,6 +89,7 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -122,6 +124,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
    private static final String DEFAULT_SATELLITE_SOS_HANDOVER_CLASS =
            "android.com.vendor.message.SosHandoverApp";
    private static final String DEFAULT_T911_HANDOVER_INTENT_ACTION = Intent.ACTION_SENDTO;
    private static final Set<String> TEST_ALL_SATELLITE_PLMN_SET = new HashSet<>(
            Arrays.asList("310830", "313210"));
    private TestSatelliteController mTestSatelliteController;
    private TestImsManager mTestImsManager;
    @Mock
@@ -139,6 +143,7 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
    @Mock
    private SatelliteStats mMockSatelliteStats;
    @Mock private SubscriptionManagerService mMockSubscriptionManagerService;
    @Mock private SatelliteControllerTest.TestSatelliteController mMockSatelliteController;

    @Before
    public void setUp() throws Exception {
@@ -183,6 +188,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
                mMockSatelliteStats);
        replaceInstance(SubscriptionManagerService.class, "sInstance", null,
                mMockSubscriptionManagerService);
        replaceInstance(SatelliteController.class, "sInstance", null,
                mMockSatelliteController);
        doNothing().when(mMockSatelliteStats).onSatelliteSosMessageRecommender(
                any(SatelliteStats.SatelliteSosMessageRecommenderParams.class));
        mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(
@@ -194,6 +201,7 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
                .setId(SUB_ID1).setOnlyNonTerrestrialNetwork(true).build();
        when(mMockSubscriptionManagerService.getSubscriptionInfo(eq(SUB_ID1)))
            .thenReturn(subscriptionInfo);
        doReturn(TEST_ALL_SATELLITE_PLMN_SET).when(mMockSatelliteController).getAllPlmnSet();
    }

    @After
+9 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -55,6 +56,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
    private static final int SUB_ID1 = 1;
    @Mock private ServiceState mServiceState2;

    @Mock SatelliteControllerTest.TestSatelliteController mMockSatelliteController;

    @Before
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
@@ -68,6 +71,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
        when(mPhone2.getServiceState()).thenReturn(mServiceState2);
        when(mPhone2.getSubId()).thenReturn(SUB_ID1);
        when(mPhone2.getPhoneId()).thenReturn(1);
        replaceInstance(SatelliteController.class, "sInstance", null,
                mMockSatelliteController);
    }

    @After
@@ -182,8 +187,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
    public void testIsSatellitePlmn() {
        int subId = 1;

        when(mSatelliteController.getSatellitePlmnsForCarrier(eq(subId)))
                .thenReturn(new ArrayList<>());
        when(mMockSatelliteController.getAllPlmnSet())
                .thenReturn(new HashSet<>(new ArrayList<>()));
        assertFalse(SatelliteServiceUtils.isSatellitePlmn(subId, mServiceState));

        // registered PLMN is null
@@ -196,8 +201,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
        assertFalse(SatelliteServiceUtils.isSatellitePlmn(subId, mServiceState));

        // cell identity is null
        when(mSatelliteController.getSatellitePlmnsForCarrier(eq(subId))).thenReturn(
                List.of("120260"));
        when(mMockSatelliteController.getAllPlmnSet()).thenReturn(
                new HashSet<>(List.of("120260")));
        nri = new NetworkRegistrationInfo.Builder()
                .setRegisteredPlmn("123456")
                .setCellIdentity(null)