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

Commit 3ad17e2b authored by Karthick M J's avatar Karthick M J
Browse files

Uncap maxAllowedDataMode in PhoneInfo#RadioInfo

Currently, within PhoneInfo test app, we have an option to override
data mode. It works based on CarrierConfig override. Now, as we
introduce maxAllowedDataMode, CarrierConfig changes to override
data mode is capped within maxAllowedDataMode value. Therefore,
we are making a change to uncap maxAllowedDataMode, so that we are
free to test any data mode through PhoneInfo#RadioInfo.

Bug: 417330132
Test: atest frameworks/opt/telephony/tests/telephonytests/src/com/android/internal/telephony/configupdate/TelephonyConfigUpdateInstallReceiverTest.java
Also, manually tested from PhoneInfo UX
Flag: EXEMPT bug fix

Change-Id: I739af9d69dcaf9954661dd88aa5747cacf370faf
parent b4d5b259
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -108,4 +108,14 @@ public abstract class ConfigParser<T> {
        mVersion = version;
        Log.d(TAG, "overrideVersion: mVersion=" + mVersion);
    }

    /**
     * Overrides the config
     *
     * @param config the config that should be overrided with
     */
    public void overrideConfig(T config) {
        Log.d(TAG, "overrideConfig: overriding config to " + config);
        mConfig = config;
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -249,6 +249,18 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
        }
    }

    /**
     * Overrides the config parser. Should be used only in tests.
     *
     * @param configParser the config parser that we have to override
     */
    public void overrideConfigParser(ConfigParser configParser) {
        Log.d(TAG, "overrideConfigParser");
        synchronized (getInstance().mConfigParserLock) {
            getInstance().mConfigParser = configParser;
        }
    }

    @Override
    public void registerCallback(@NonNull Executor executor, @NonNull Callback callback) {
        mCallbackHashMap.put(executor, callback);
+21 −1
Original line number Diff line number Diff line
@@ -60,8 +60,17 @@ public class SatelliteConfig {
    private File mSatelliteAccessConfigJsonFile;
    private SatelliteConfigData.SatelliteConfigProto mConfigData;

    public SatelliteConfig() {
        logd("SatelliteConfig: constructing from scratch");
    }

    public SatelliteConfig(@NonNull SatelliteConfig satelliteConfig) {
        logd("SatelliteConfig: constructing through deep copy of: " + satelliteConfig);
        new SatelliteConfig(satelliteConfig.mConfigData);
    }

    public SatelliteConfig(@NonNull SatelliteConfigData.SatelliteConfigProto configData) {
        logd("SatelliteConfig");
        logd("SatelliteConfig: constructing with configData: " + configData);
        mConfigData = configData;
        mVersion = mConfigData.version;
        logd("mVersion: " + mVersion);
@@ -165,6 +174,17 @@ public class SatelliteConfig {
        return null;
    }

    /**
     * Overrides the satellite max allowed data mode.
     *
     * @param maxAllowedDataMode the new max allowed data mode
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public void overrideSatelliteMaxAllowedDataMode(int maxAllowedDataMode) {
        logd("overrideSatelliteMaxAllowedDataMode: " + maxAllowedDataMode);
        mCarrierRoamingMaxAllowedDataMode = maxAllowedDataMode;
    }

    /**
     * Get satellite plmns for carrier
     *
+27 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;

import android.content.Context;
import android.telephony.CarrierConfigManager;
import android.testing.AndroidTestingRunner;

import androidx.test.InstrumentationRegistry;
@@ -844,4 +845,30 @@ public class SatelliteConfigParserTest extends TelephonyTest {
        assertEquals(Set.of(SERVICE_TYPE_SMS), satelliteConfigParser.getConfig()
                .getSupportedSatelliteServices(1).get(PLMN_45005));
    }

    @Test
    public void testOverrideConfigByOverridingSatelliteMaxAllowedDataMode() {
        SatelliteConfigParser satelliteConfigParser = new SatelliteConfigParser(mBytesProtoBuffer);
        assertNotNull(satelliteConfigParser);
        assertNotNull(satelliteConfigParser.getConfig());
        assertNotNull(satelliteConfigParser.getConfig().getSatelliteMaxAllowedDataMode());
        assertEquals(
                Integer.valueOf(CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED),
                satelliteConfigParser.getConfig().getSatelliteMaxAllowedDataMode());

        SatelliteConfig satelliteConfig = new SatelliteConfig();
        satelliteConfig.overrideSatelliteMaxAllowedDataMode(
                CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL);
        satelliteConfigParser.overrideConfig(satelliteConfig);
        assertEquals(
                Integer.valueOf(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL),
                satelliteConfigParser.getConfig().getSatelliteMaxAllowedDataMode());

        satelliteConfig.overrideSatelliteMaxAllowedDataMode(
                CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED);
        satelliteConfigParser.overrideConfig(satelliteConfig);
        assertEquals(
                Integer.valueOf(CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED),
                satelliteConfigParser.getConfig().getSatelliteMaxAllowedDataMode());
    }
}