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

Commit 535034b8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I6796917f,I1ce57702

* changes:
  Add test for AIDL radio service program info cache
  Add test for AIDL radio client program list update
parents 04beb2c1 52bbbd47
Loading
Loading
Loading
Loading
+45 −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, 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++) {
            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, halModified, halRemoved);
    }

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

    static ProgramList.Chunk makeChunk(boolean purge, boolean complete,
            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, complete, 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);
+409 −0

File added.

Preview size limit exceeded, changes collapsed.

+299 −9

File changed.

Preview size limit exceeded, changes collapsed.

+30 −4

File changed.

Preview size limit exceeded, changes collapsed.

Loading