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

Commit 9de25c7c authored by Weilin Xu's avatar Weilin Xu
Browse files

Add test for AIDL radio client program list update

Added unit tests for program list update using filter in AIDL
broadcast radio HAL client. Also added unit tests for handing
expcetion and non-current user cases during program list update.

Bug: 241118988
Test: com.android.server.broadcastradio.aidl.ProgramInfoCacheTest
Change-Id: I1ce5770207f11933c16dfb19c2c6b967b77d36fc
parent 326f9b5c
Loading
Loading
Loading
Loading
+46 −1
Original line number Diff line number Diff line
@@ -21,10 +21,15 @@ import android.hardware.broadcastradio.ProgramIdentifier;
import android.hardware.broadcastradio.ProgramInfo;
import android.hardware.broadcastradio.ProgramListChunk;
import android.hardware.broadcastradio.VendorKeyValue;
import android.hardware.radio.ProgramList;
import android.hardware.radio.ProgramSelector;
import android.hardware.radio.RadioManager;
import android.hardware.radio.RadioMetadata;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.ArraySet;

import java.util.List;

final class AidlTestUtils {

@@ -94,6 +99,14 @@ final class AidlTestUtils {
        return makeHalProgramInfo(hwSel, hwSel.primaryId, hwSel.primaryId, hwSignalQuality);
    }

    static ProgramInfo programInfoToHalProgramInfo(RadioManager.ProgramInfo info) {
        return makeHalProgramInfo(
                ConversionUtils.programSelectorToHalProgramSelector(info.getSelector()),
                ConversionUtils.identifierToHalProgramIdentifier(info.getLogicallyTunedTo()),
                ConversionUtils.identifierToHalProgramIdentifier(info.getPhysicallyTunedTo()),
                info.getSignalStrength());
    }

    static ProgramInfo makeHalProgramInfo(
            android.hardware.broadcastradio.ProgramSelector hwSel,
            ProgramIdentifier logicallyTunedTo, ProgramIdentifier physicallyTunedTo,
@@ -108,7 +121,23 @@ final class AidlTestUtils {
        return hwInfo;
    }

    static ProgramListChunk makeProgramListChunk(boolean purge, boolean complete,
    static ProgramListChunk makeHalChunk(boolean purge, List<RadioManager.ProgramInfo> modified,
            List<ProgramSelector.Identifier> removed) {
        ProgramInfo[] halModified =
                new android.hardware.broadcastradio.ProgramInfo[modified.size()];
        for (int i = 0; i < modified.size(); i++) {
            halModified[i] = programInfoToHalProgramInfo(modified.get(i));
        }

        ProgramIdentifier[] halRemoved =
                new android.hardware.broadcastradio.ProgramIdentifier[removed.size()];
        for (int i = 0; i < removed.size(); i++) {
            halRemoved[i] = ConversionUtils.identifierToHalProgramIdentifier(removed.get(i));
        }
        return makeHalChunk(purge, /* complete= */ true, halModified, halRemoved);
    }

    static ProgramListChunk makeHalChunk(boolean purge, boolean complete,
            ProgramInfo[] modified, ProgramIdentifier[] removed) {
        ProgramListChunk halChunk = new ProgramListChunk();
        halChunk.purge = purge;
@@ -118,6 +147,22 @@ final class AidlTestUtils {
        return halChunk;
    }

    static ProgramList.Chunk makeChunk(boolean purge,
            List<RadioManager.ProgramInfo> modified,
            List<ProgramSelector.Identifier> removed) throws RemoteException {
        ArraySet<RadioManager.ProgramInfo> modifiedSet = new ArraySet<>();
        if (modified != null) {
            modifiedSet.addAll(modified);
        }
        ArraySet<ProgramSelector.Identifier> removedSet = new ArraySet<>();
        if (removed != null) {
            removedSet.addAll(removed);
        }
        ProgramList.Chunk chunk = new ProgramList.Chunk(/* purge= */ purge, /* complete= */true,
                modifiedSet, removedSet);
        return chunk;
    }

    static VendorKeyValue makeVendorKeyValue(String vendorKey, String vendorValue) {
        VendorKeyValue vendorKeyValue = new VendorKeyValue();
        vendorKeyValue.key = vendorKey;
+2 −2
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public final class ConversionUtilsTest {
                TEST_HAL_DAB_SID_EXT_ID, TEST_HAL_DAB_FREQUENCY_ID, TEST_SIGNAL_QUALITY);
        RadioManager.ProgramInfo dabInfo =
                ConversionUtils.programInfoFromHalProgramInfo(halDabInfo);
        ProgramListChunk halChunk = AidlTestUtils.makeProgramListChunk(purge, complete,
        ProgramListChunk halChunk = AidlTestUtils.makeHalChunk(purge, complete,
                new ProgramInfo[]{halDabInfo},
                new ProgramIdentifier[]{TEST_HAL_VENDOR_ID, TEST_HAL_FM_FREQUENCY_ID});

@@ -353,7 +353,7 @@ public final class ConversionUtilsTest {
                        TEST_HAL_DAB_ENSEMBLE_ID, TEST_HAL_DAB_FREQUENCY_ID});
        ProgramInfo halDabInfo = AidlTestUtils.makeHalProgramInfo(halDabSelector,
                TEST_HAL_DAB_SID_EXT_ID, TEST_HAL_DAB_ENSEMBLE_ID, TEST_SIGNAL_QUALITY);
        ProgramListChunk halChunk = AidlTestUtils.makeProgramListChunk(purge, complete,
        ProgramListChunk halChunk = AidlTestUtils.makeHalChunk(purge, complete,
                new ProgramInfo[]{halDabInfo}, new ProgramIdentifier[]{TEST_HAL_FM_FREQUENCY_ID});

        ProgramList.Chunk chunk = ConversionUtils.chunkFromHalProgramListChunk(halChunk);
+298 −9

File changed.

Preview size limit exceeded, changes collapsed.

+30 −4

File changed.

Preview size limit exceeded, changes collapsed.