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

Commit 52bbbd47 authored by Weilin Xu's avatar Weilin Xu
Browse files

Add test for AIDL radio service program info cache

Added unit tests for program info cache of AIDL broadcast radio HAL
client.

Bug: 241118988
Test: com.android.server.broadcastradio.aidl
Change-Id: I6796917f95644e4e606ef8bfeefdb9d6e7c05437
parent 9de25c7c
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -121,8 +121,8 @@ final class AidlTestUtils {
        return hwInfo;
    }

    static ProgramListChunk makeHalChunk(boolean purge, List<RadioManager.ProgramInfo> modified,
            List<ProgramSelector.Identifier> removed) {
    static ProgramListChunk makeHalChunk(boolean purge, boolean complete,
            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++) {
@@ -134,7 +134,7 @@ final class AidlTestUtils {
        for (int i = 0; i < removed.size(); i++) {
            halRemoved[i] = ConversionUtils.identifierToHalProgramIdentifier(removed.get(i));
        }
        return makeHalChunk(purge, /* complete= */ true, halModified, halRemoved);
        return makeHalChunk(purge, complete, halModified, halRemoved);
    }

    static ProgramListChunk makeHalChunk(boolean purge, boolean complete,
@@ -147,7 +147,7 @@ final class AidlTestUtils {
        return halChunk;
    }

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

+409 −0

File added.

Preview size limit exceeded, changes collapsed.

+43 −42

File changed.

Preview size limit exceeded, changes collapsed.

+2 −6
Original line number Diff line number Diff line
@@ -86,12 +86,8 @@ final class ProgramInfoCache {
    }

    @VisibleForTesting
    boolean programInfosAreExactly(RadioManager.ProgramInfo... programInfos) {
        Map<ProgramSelector.Identifier, RadioManager.ProgramInfo> expectedMap = new ArrayMap<>();
        for (int i = 0; i < programInfos.length; i++) {
            expectedMap.put(programInfos[i].getSelector().getPrimaryId(), programInfos[i]);
        }
        return expectedMap.equals(mProgramInfoMap);
    List<RadioManager.ProgramInfo> toProgramInfoList() {
        return new ArrayList<>(mProgramInfoMap.values());
    }

    @Override