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

Commit 42e7cd4b authored by youngtaecha's avatar youngtaecha Committed by Youngtae Cha
Browse files

Apply valid check for the satellite config data(plmns, services)

Bug: 331576454
Test: Manually verified if the config data is parsed well
Test: atest com.android.internal.telephony.configupdate (ab/I96600010259993081 PASS)

Change-Id: I6391efedae288db9c3cfa562396c44f2b06e7360
parent bac19195
Loading
Loading
Loading
Loading
+104 −29
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.os.FileUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.satellite.SatelliteConfig;
import com.android.internal.telephony.satellite.SatelliteConfigParser;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.server.updates.ConfigUpdateInstallReceiver;

import libcore.io.IoUtils;
@@ -33,6 +35,8 @@ import libcore.io.IoUtils;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;

@@ -43,7 +47,8 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected static final String UPDATE_DIR = "/data/misc/telephonyconfig";
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected static final String UPDATE_CONTENT_PATH = "telephony_config.pb";
    protected static final String NEW_CONFIG_CONTENT_PATH = "new_telephony_config.pb";
    protected static final String VALID_CONFIG_CONTENT_PATH = "valid_telephony_config.pb";
    protected static final String UPDATE_METADATA_PATH = "metadata/";
    public static final String VERSION = "version";

@@ -66,7 +71,7 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
    }

    public TelephonyConfigUpdateInstallReceiver() {
        super(UPDATE_DIR, UPDATE_CONTENT_PATH, UPDATE_METADATA_PATH, VERSION);
        super(UPDATE_DIR, NEW_CONFIG_CONTENT_PATH, UPDATE_METADATA_PATH, VERSION);
    }

    /**
@@ -74,58 +79,95 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
     */
    @Nullable
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public byte[] getCurrentContent() {
    public byte[] getContentFromContentPath(@NonNull File contentPath) {
        try {
            return IoUtils.readFileAsByteArray(updateContent.getCanonicalPath());
            return IoUtils.readFileAsByteArray(contentPath.getCanonicalPath());
        } catch (IOException e) {
            Slog.i(TAG, "Failed to read current content, assuming first update!");
            Log.e(TAG, "Failed to read current content : " + contentPath);
            return null;
        }
    }

    /**
     * @param parser target of validation.
     * @return {@code true} if all the config data are valid {@code false} otherwise.
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean isValidSatelliteCarrierConfigData(@NonNull ConfigParser parser) {
        SatelliteConfig satelliteConfig = (SatelliteConfig) parser.getConfig();
        if (satelliteConfig == null) {
            Log.e(TAG, "satelliteConfig is null");
            return false;
        }

        // If no carrier config exist then it is considered as a valid config
        Set<Integer> carrierIds = satelliteConfig.getAllSatelliteCarrierIds();
        for (int carrierId : carrierIds) {
            Map<String, Set<Integer>> plmnsServices =
                    satelliteConfig.getSupportedSatelliteServices(carrierId);
            Set<String> plmns = plmnsServices.keySet();
            for (String plmn : plmns) {
                if (!TelephonyUtils.isValidPlmn(plmn)) {
                    Log.e(TAG, "found invalid plmn : " + plmn);
                    return false;
                }
                Set<Integer> serviceSet = plmnsServices.get(plmn);
                for (int service : serviceSet) {
                    if (!TelephonyUtils.isValidService(service)) {
                        Log.e(TAG, "found invalid service : " + service);
                        return false;
                    }
                }
            }
        }
        Log.d(TAG, "the config data is valid");
        return true;
    }


    @Override
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PROTECTED)
    public void postInstall(Context context, Intent intent) {
        Log.d(TAG, "Telephony config is updated in file partition");
        ConfigParser updatedConfigParser = getNewConfigParser(DOMAIN_SATELLITE,
                getCurrentContent());

        if (updatedConfigParser == null) {
            Log.d(TAG, "updatedConfigParser is null");
        ConfigParser newConfigParser = getNewConfigParser(DOMAIN_SATELLITE,
                getContentFromContentPath(updateContent));

        if (newConfigParser == null) {
            Log.e(TAG, "newConfigParser is null");
            return;
        }

        boolean isParserChanged = false;
        if (!isValidSatelliteCarrierConfigData(newConfigParser)) {
            Log.e(TAG, "received config data has invalid satellite carrier config data");
            return;
        }

        synchronized (getInstance().mConfigParserLock) {
            if (getInstance().mConfigParser == null) {
                getInstance().mConfigParser = updatedConfigParser;
                isParserChanged = true;
            } else {
                int updatedVersion = updatedConfigParser.mVersion;
            if (getInstance().mConfigParser != null) {
                int updatedVersion = newConfigParser.mVersion;
                int previousVersion = getInstance().mConfigParser.mVersion;
                Log.d(TAG, "previous version is " + previousVersion + " | updated version is "
                        + updatedVersion);
                if (updatedVersion > previousVersion) {
                    getInstance().mConfigParser = updatedConfigParser;
                    isParserChanged = true;
                if (updatedVersion <= previousVersion) {
                    Log.e(TAG, "updatedVersion is smaller than previousVersion");
                    return;
                }
            }
            getInstance().mConfigParser = newConfigParser;
        }

        if (isParserChanged) {
            if (getInstance().mCallbackHashMap.keySet().isEmpty()) {
                Log.d(TAG, "mCallbackHashMap.keySet().isEmpty");
                return;
            }
            Iterator<Executor> iterator =
                    getInstance().mCallbackHashMap.keySet().iterator();
        if (!getInstance().mCallbackHashMap.keySet().isEmpty()) {
            Iterator<Executor> iterator = getInstance().mCallbackHashMap.keySet().iterator();
            while (iterator.hasNext()) {
                Executor executor = iterator.next();
                getInstance().mCallbackHashMap.get(executor).onChanged(
                        updatedConfigParser);
                getInstance().mCallbackHashMap.get(executor).onChanged(newConfigParser);
            }
        }

        if (!copySourceFileToTargetFile(NEW_CONFIG_CONTENT_PATH, VALID_CONFIG_CONTENT_PATH)) {
            Log.e(TAG, "fail to copy to the valid satellite carrier config data");
        }
    }

    @Nullable
@@ -135,7 +177,9 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
        synchronized (getInstance().mConfigParserLock) {
            if (getInstance().mConfigParser == null) {
                Log.d(TAG, "CreateNewConfigParser with domain " + domain);
                getInstance().mConfigParser = getNewConfigParser(domain, getCurrentContent());
                getInstance().mConfigParser = getNewConfigParser(
                        domain, getContentFromContentPath(new File(updateDir,
                                VALID_CONFIG_CONTENT_PATH)));
            }
            return getInstance().mConfigParser;
        }
@@ -197,4 +241,35 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec
                return null;
        }
    }

    /**
     * @param sourceFileName source file name
     * @param targetFileName target file name
     * @return {@code true} if successful, {@code false} otherwise
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean copySourceFileToTargetFile(
            @NonNull String sourceFileName, @NonNull String targetFileName) {
        try {
            File sourceFile = new File(UPDATE_DIR, sourceFileName);
            File targetFile = new File(UPDATE_DIR, targetFileName);
            Log.d(TAG, "copy " + sourceFile.getName() + " >> " + targetFile.getName());

            if (sourceFile.exists()) {
                if (targetFile.exists()) {
                    targetFile.delete();
                }
                FileUtils.copy(sourceFile, targetFile);
                FileUtils.copyPermissions(sourceFile, targetFile);
                Log.d(TAG, "success to copy the file " + sourceFile.getName() + " to "
                        + targetFile.getName());
                return true;
            }
        } catch (Exception e) {
            Log.e(TAG, "copy error : " + e);
            return false;
        }
        Log.d(TAG, "source file is not exist, no file to copy");
        return false;
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.satellite;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
@@ -138,6 +139,19 @@ public class SatelliteConfig {
        return new HashMap<>();
    }

    /**
     * Get carrier identifier set for the satellite
     *
     * @return carrier identifier set from the config data.
     */
    @NonNull
    public Set<Integer> getAllSatelliteCarrierIds() {
        if (mSupportedServicesPerCarrier != null) {
            return new ArraySet<>(mSupportedServicesPerCarrier.keySet());
        }
        return new ArraySet<>();
    }

    /**
     * @return satellite region country codes
     */
+4 −3
Original line number Diff line number Diff line
@@ -526,11 +526,12 @@ public class SatelliteController extends Handler {
     * Get satelliteConfig from SatelliteConfigParser
     */
    public SatelliteConfig getSatelliteConfig() {
        if (getSatelliteConfigParser() == null) {
            Log.d(TAG, "getSatelliteConfigParser() is not ready");
        SatelliteConfigParser satelliteConfigParser = getSatelliteConfigParser();
        if (satelliteConfigParser == null) {
            Log.d(TAG, "satelliteConfigParser is not ready");
            return null;
        }
        return (SatelliteConfig) getSatelliteConfigParser().getConfig();
        return satelliteConfigParser.getConfig();
    }

    /**
+185 −22
Original line number Diff line number Diff line
@@ -16,34 +16,47 @@

package com.android.internal.telephony.configupdate;

import static com.android.internal.telephony.configupdate.TelephonyConfigUpdateInstallReceiver.UPDATE_CONTENT_PATH;
import static android.telephony.NetworkRegistrationInfo.FIRST_SERVICE_TYPE;
import static android.telephony.NetworkRegistrationInfo.LAST_SERVICE_TYPE;

import static com.android.internal.telephony.configupdate.TelephonyConfigUpdateInstallReceiver.NEW_CONFIG_CONTENT_PATH;
import static com.android.internal.telephony.configupdate.TelephonyConfigUpdateInstallReceiver.UPDATE_DIR;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.content.Intent;
import android.util.ArraySet;

import androidx.annotation.Nullable;

import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.satellite.SatelliteConfig;
import com.android.internal.telephony.satellite.SatelliteConfigParser;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.io.File;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -74,7 +87,7 @@ public class TelephonyConfigUpdateInstallReceiverTest extends TelephonyTest {
        TelephonyConfigUpdateInstallReceiver testReceiver =
                new TelephonyConfigUpdateInstallReceiver();
        assertEquals(UPDATE_DIR, testReceiver.getUpdateDir().toString());
        assertEquals(new File(new File(UPDATE_DIR), UPDATE_CONTENT_PATH).toString(),
        assertEquals(new File(new File(UPDATE_DIR), NEW_CONFIG_CONTENT_PATH).toString(),
                testReceiver.getUpdateContent().toString());
    }

@@ -92,38 +105,133 @@ public class TelephonyConfigUpdateInstallReceiverTest extends TelephonyTest {
        // create spyTelephonyConfigUpdateInstallReceiver
        TelephonyConfigUpdateInstallReceiver spyTelephonyConfigUpdateInstallReceiver =
                spy(new TelephonyConfigUpdateInstallReceiver());
        doReturn(true).when(spyTelephonyConfigUpdateInstallReceiver)
                .copySourceFileToTargetFile(any(), any());
        replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "sReceiverAdaptorInstance",
                null, spyTelephonyConfigUpdateInstallReceiver);

        // mock BeforeParser
        assertSame(spyTelephonyConfigUpdateInstallReceiver,
                TelephonyConfigUpdateInstallReceiver.getInstance());

        // valid config data case
        // mVersion:4 | mSupportedServicesPerCarrier:{1={310160=[1, 2, 3], 310220=[3]}} |
        // mSatelliteRegionCountryCodes:[US] | mIsSatelliteRegionAllowed:true | s2CellFile size:10
        String mBase64StrForPBByteArray =
                "CjYIBBIeCAESDgoGMzEwMTYwEAEQAhADEgoKBjMxMDIyMBADGhIKCjAxMjM0NTY3ODkSAlVTGAE=";
        byte[] mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);
        doReturn(mBytesProtoBuffer).when(
                spyTelephonyConfigUpdateInstallReceiver).getCurrentContent();
        SatelliteConfigParser mMockSatelliteConfigParserBefore =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(mMockSatelliteConfigParserBefore).when(
                spyTelephonyConfigUpdateInstallReceiver).getConfigParser(DOMAIN_SATELLITE);
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        // mock UpdatedParser
        SatelliteConfigParser spySatelliteConfigParserAfter =
        SatelliteConfigParser spyValidParser =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(5).when(spySatelliteConfigParserAfter).getVersion();
        doReturn(spySatelliteConfigParserAfter).when(spyTelephonyConfigUpdateInstallReceiver)
                .getNewConfigParser(any(), any());

        replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "sReceiverAdaptorInstance",
                null, spyTelephonyConfigUpdateInstallReceiver);

        assertSame(spyTelephonyConfigUpdateInstallReceiver,
                TelephonyConfigUpdateInstallReceiver.getInstance());

        ConcurrentHashMap<Executor, ConfigProviderAdaptor.Callback> spyCallbackHashMap = spy(
                new ConcurrentHashMap<>());
        spyCallbackHashMap.put(mExecutor, mCallback);
        spyTelephonyConfigUpdateInstallReceiver.setCallbackMap(spyCallbackHashMap);

        spyTelephonyConfigUpdateInstallReceiver.postInstall(mContext, new Intent());

        verify(spyCallbackHashMap, times(2)).keySet();
        verify(spyTelephonyConfigUpdateInstallReceiver, times(1))
                .copySourceFileToTargetFile(any(), any());
        Mockito.clearInvocations(spyCallbackHashMap);
        Mockito.clearInvocations(spyTelephonyConfigUpdateInstallReceiver);

        replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "mConfigParser",
                spyTelephonyConfigUpdateInstallReceiver, spyValidParser);

        // valid config data but smaller version case
        // mVersion:3 | mSupportedServicesPerCarrier:{1={12345=[1, 2]}} |
        // mSatelliteRegionCountryCodes:[US] | mIsSatelliteRegionAllowed:true | s2CellFile size:10
        mBase64StrForPBByteArray =
                "CicIAxIPCAESCwoFMTIzNDUQARACGhIKCjAxMjM0NTY3ODkSAlVTGAE=";
        mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);

        // mock UpdatedParser
        SatelliteConfigParser spyInvalidParser =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(spyInvalidParser).when(spyTelephonyConfigUpdateInstallReceiver)
                .getNewConfigParser(any(), any());

        spyTelephonyConfigUpdateInstallReceiver.postInstall(mContext, new Intent());

        verify(spyCallbackHashMap, times(0)).keySet();
        verify(spyTelephonyConfigUpdateInstallReceiver, times(0))
                .copySourceFileToTargetFile(any(), any());
        Mockito.clearInvocations(spyCallbackHashMap);
        Mockito.clearInvocations(spyTelephonyConfigUpdateInstallReceiver);

        // Empty config data case which is valid
        // mSupportedServicesPerCarrier:{} | mSatelliteRegionCountryCodes:[US] |
        // mIsSatelliteRegionAllowed:true | s2CellFile size:30
        mBase64StrForPBByteArray =
                "CioIDBomCh4wMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkSAlVTGAE=";
        mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);
        doReturn(mBytesProtoBuffer).when(
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        // mock UpdatedParser
        SatelliteConfigParser spyValidEmptyParser =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(spyValidEmptyParser).when(spyTelephonyConfigUpdateInstallReceiver)
                .getNewConfigParser(any(), any());

        spyTelephonyConfigUpdateInstallReceiver.postInstall(mContext, new Intent());
        verify(spyCallbackHashMap, times(2)).keySet();
        verify(spyTelephonyConfigUpdateInstallReceiver, times(1))
                .copySourceFileToTargetFile(any(), any());
        Mockito.clearInvocations(spyCallbackHashMap);
        Mockito.clearInvocations(spyTelephonyConfigUpdateInstallReceiver);

        // Wrong plmn("1234") config data case
        // mSupportedServicesPerCarrier:{1={"1234"=[1, 2, 3]}} |
        // mSatelliteRegionCountryCodes:[US]
        // | mIsSatelliteRegionAllowed:true | s2CellFile size:10
        mBase64StrForPBByteArray =
                "CigIDBIQCAESDAoEMTIzNBABEAIQAxoSCgowMTIzNDU2Nzg5EgJVUxgB";
        mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);
        doReturn(mBytesProtoBuffer).when(
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        // mock UpdatedParser
        spyInvalidParser =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(spyInvalidParser).when(spyTelephonyConfigUpdateInstallReceiver)
                .getNewConfigParser(any(), any());

        spyTelephonyConfigUpdateInstallReceiver.postInstall(mContext, new Intent());

        verify(spyCallbackHashMap, atLeast(1)).keySet();
        verify(spyCallbackHashMap, times(0)).keySet();
        verify(spyTelephonyConfigUpdateInstallReceiver, times(0))
                .copySourceFileToTargetFile(any(), any());
        Mockito.clearInvocations(spyCallbackHashMap);
        Mockito.clearInvocations(spyTelephonyConfigUpdateInstallReceiver);

        // Wrong service("8") config data case
        // mSupportedServicesPerCarrier:{1={12345=[6, "8"]}} |
        // mSatelliteRegionCountryCodes:[US] |
        // mIsSatelliteRegionAllowed:true | s2CellFile size:10
        mBase64StrForPBByteArray =
                "CicIDBIPCAESCwoFMTIzNDUQBhAIGhIKCjAxMjM0NTY3ODkSAlVTGAE=";
        mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);
        doReturn(mBytesProtoBuffer).when(
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        // mock UpdatedParser
        spyInvalidParser =
                spy(new SatelliteConfigParser(mBytesProtoBuffer));
        doReturn(spyInvalidParser).when(spyTelephonyConfigUpdateInstallReceiver)
                .getNewConfigParser(any(), any());

        spyTelephonyConfigUpdateInstallReceiver.postInstall(mContext, new Intent());

        verify(spyCallbackHashMap, times(0)).keySet();
        verify(spyTelephonyConfigUpdateInstallReceiver, times(0))
                .copySourceFileToTargetFile(any(), any());
        Mockito.clearInvocations(spyCallbackHashMap);
        Mockito.clearInvocations(spyTelephonyConfigUpdateInstallReceiver);
    }


@@ -133,7 +241,7 @@ public class TelephonyConfigUpdateInstallReceiverTest extends TelephonyTest {
                spy(new TelephonyConfigUpdateInstallReceiver());

        doReturn(null).when(
                spyTelephonyConfigUpdateInstallReceiver).getCurrentContent();
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "sReceiverAdaptorInstance",
                null, spyTelephonyConfigUpdateInstallReceiver);
@@ -144,7 +252,7 @@ public class TelephonyConfigUpdateInstallReceiverTest extends TelephonyTest {
                "CjYIBBIeCAESDgoGMzEwMTYwEAEQAhADEgoKBjMxMDIyMBADGhIKCjAxMjM0NTY3ODkSAlVTGAE=";
        byte[] mBytesProtoBuffer = Base64.getDecoder().decode(mBase64StrForPBByteArray);
        doReturn(mBytesProtoBuffer).when(
                spyTelephonyConfigUpdateInstallReceiver).getCurrentContent();
                spyTelephonyConfigUpdateInstallReceiver).getContentFromContentPath(any());

        replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "sReceiverAdaptorInstance",
                null, spyTelephonyConfigUpdateInstallReceiver);
@@ -172,4 +280,59 @@ public class TelephonyConfigUpdateInstallReceiverTest extends TelephonyTest {
        testReceiver.unregisterCallback(testCallback);
        assertEquals(0, testReceiver.getCallbackMap().size());
    }

    @Test
    public void testIsValidSatelliteCarrierConfigData() {
        TelephonyConfigUpdateInstallReceiver spyTelephonyConfigUpdateInstallReceiver =
                spy(new TelephonyConfigUpdateInstallReceiver());
        SatelliteConfigParser mockParser = mock(SatelliteConfigParser.class);
        SatelliteConfig mockConfig = mock(SatelliteConfig.class);
        doReturn(new ArraySet<>()).when(mockConfig).getAllSatelliteCarrierIds();
        doReturn(mockConfig).when(mockParser).getConfig();

        assertTrue(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));

        doReturn(Set.of(1)).when(mockConfig).getAllSatelliteCarrierIds();
        Map<String, Set<Integer>> validPlmnsServices = new HashMap<>();
        validPlmnsServices.put("123456", Set.of(FIRST_SERVICE_TYPE, 3, LAST_SERVICE_TYPE));
        validPlmnsServices.put("12345", Set.of(FIRST_SERVICE_TYPE, 4, LAST_SERVICE_TYPE));
        doReturn(validPlmnsServices).when(mockConfig).getSupportedSatelliteServices(anyInt());
        doReturn(mockConfig).when(mockParser).getConfig();

        assertTrue(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));

        doReturn(Set.of(1)).when(mockConfig).getAllSatelliteCarrierIds();
        Map<String, Set<Integer>> invalidPlmnsServices1 = new HashMap<>();
        invalidPlmnsServices1.put("123456", Set.of(FIRST_SERVICE_TYPE - 1, 3, LAST_SERVICE_TYPE));
        doReturn(invalidPlmnsServices1).when(mockConfig).getSupportedSatelliteServices(anyInt());
        doReturn(mockConfig).when(mockParser).getConfig();
        assertFalse(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));

        doReturn(Set.of(1)).when(mockConfig).getAllSatelliteCarrierIds();
        Map<String, Set<Integer>> invalidPlmnsServices2 = new HashMap<>();
        invalidPlmnsServices2.put("123456", Set.of(FIRST_SERVICE_TYPE, 3, LAST_SERVICE_TYPE + 1));
        doReturn(invalidPlmnsServices2).when(mockConfig).getSupportedSatelliteServices(anyInt());
        doReturn(mockConfig).when(mockParser).getConfig();
        assertFalse(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));

        doReturn(Set.of(1)).when(mockConfig).getAllSatelliteCarrierIds();
        Map<String, Set<Integer>> invalidPlmnsServices3 = new HashMap<>();
        invalidPlmnsServices3.put("1234", Set.of(FIRST_SERVICE_TYPE, 3, LAST_SERVICE_TYPE));
        doReturn(invalidPlmnsServices3).when(mockConfig).getSupportedSatelliteServices(anyInt());
        doReturn(mockConfig).when(mockParser).getConfig();
        assertFalse(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));

        doReturn(Set.of(1)).when(mockConfig).getAllSatelliteCarrierIds();
        Map<String, Set<Integer>> invalidPlmnsServices4 = new HashMap<>();
        invalidPlmnsServices4.put("1234567", Set.of(FIRST_SERVICE_TYPE, 3, LAST_SERVICE_TYPE));
        doReturn(invalidPlmnsServices4).when(mockConfig).getSupportedSatelliteServices(anyInt());
        doReturn(mockConfig).when(mockParser).getConfig();
        assertFalse(spyTelephonyConfigUpdateInstallReceiver
                .isValidSatelliteCarrierConfigData(mockParser));
    }
}