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

Commit 577e9a0d authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android Build Coastguard Worker
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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8e9b66a36e2562a4084e056a8fcc62b8d57c84fb)
Merged-In: I92d6d630c0cf0d8c64bbb9710b4c1ed1f7bd6904
Change-Id: I92d6d630c0cf0d8c64bbb9710b4c1ed1f7bd6904
parent 0f40261c
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -7927,14 +7927,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
@@ -6056,6 +6056,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;
@@ -6966,6 +6971,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(