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

Commit 8e9b66a3 authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Ignore geofence carrier tag IDs requirements for old devices

- Ignore geofence carrier tag IDs requirements for device that don't support new format of geofence data

Flag: EXEMPT bugfix
Bug: 404710263
Test: SatelliteManagerTestOnMockService
Manual test

Change-Id: I92d6d630c0cf0d8c64bbb9710b4c1ed1f7bd6904
parent 4eacec1c
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -7925,14 +7925,37 @@ public class SatelliteController extends Handler {
        }

        if(carrierTagIds == null) {
            plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier satellite enabled " +
                    "are not available");
            String satelliteAccessConfigFile =
                getSatelliteAccessConfigurationFileFromOverlayConfig();
            if (TextUtils.isEmpty(satelliteAccessConfigFile)) {
                plogd("isSatelliteAvailableAtCurrentLocation: device does not support"
                          + " custom satellite access configuration per location");
                return true;
            } else {
                plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier "
                          + info.getCarrierName() + ", subId=" + info.getSubscriptionId()
                          + " are not available");
                return false;
            }
        }

        return isCarrierSatelliteAvailableAtCurrentLocation(carrierTagIds);
    }

    @Nullable
    private String getSatelliteAccessConfigurationFileFromOverlayConfig() {
        String satelliteAccessConfigFile = null;
        try {
            satelliteAccessConfigFile = mContext.getResources().getString(
                    com.android.internal.R.string.satellite_access_config_file);
        } catch (Resources.NotFoundException ex) {
            loge("getSatelliteAccessConfigurationFileFromOverlayConfig: got ex=" + ex);
        }

        logd("satelliteAccessConfigFile =" + satelliteAccessConfigFile);
        return satelliteAccessConfigFile;
    }

    /**
     * Compares tagIds and determine if
     * carrier satellite is available at current location while selecting highest priority profile.
+60 −0
Original line number Diff line number Diff line
@@ -6040,6 +6040,11 @@ public class SatelliteControllerTest extends TelephonyTest {
            return mLocationServiceEnabled;
        }

        @Override
        protected boolean isSatelliteAvailableAtCurrentLocation(@Nullable SubscriptionInfo info) {
            return super.isSatelliteAvailableAtCurrentLocation(info);
        }

        void setSatelliteProvisioned(@Nullable Boolean isProvisioned) {
            synchronized (mDeviceProvisionLock) {
                mIsDeviceProvisioned = isProvisioned;
@@ -6950,6 +6955,61 @@ public class SatelliteControllerTest extends TelephonyTest {
        assertTrue(mSatelliteControllerUT.isCarrierRoamingNtnEligible(mPhone));
    }

    @Test
    public void testIsSatelliteAvailableAtCurrentLocation() throws Exception {
        SubscriptionInfo ntnOnlySubscriptionInfo = new SubscriptionInfo.Builder()
                .setOnlyNonTerrestrialNetwork(true)
                .build();
        SubscriptionInfo esosSubscriptionInfo = new SubscriptionInfo.Builder()
                .setSatelliteESOSSupported(true)
                .build();
        Field currentLocationTagIdsField = SatelliteController.class.getDeclaredField(
                "mCurrentLocationTagIds");
        currentLocationTagIdsField.setAccessible(true);

        // Null subscription info
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(null));

        // Satellite is not allowed
        mSatelliteControllerUT.setIsSatelliteAllowedState(false);
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                ntnOnlySubscriptionInfo));
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Satellite is allowed
        mSatelliteControllerUT.setIsSatelliteAllowedState(true);
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                ntnOnlySubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are not configured
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // config_verizon_satellite_enabled_tagids is not configured whereas
        // satellite_access_config_file is configured
        mContextFixture.putResource(
                com.android.internal.R.string.satellite_access_config_file,
                "test_satellite_access_config_file");
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are configured, but mCurrentLocationTagIds is empty
        mContextFixture.putIntArrayResource(
                R.array.config_verizon_satellite_enabled_tagids,
                new int[]{1001});
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are configured, and mCurrentLocationTagIds contains the carrier tag id
        currentLocationTagIdsField.set(mSatelliteControllerUT, Arrays.asList(1001));
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));
    }

    public void testNotifyNtnEligibilityLocationServiceStatusChanged() {
        // Enable CarrierRoamingNtn
        mContextFixture.putBooleanResource(