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

Commit 25153f35 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge "Extend DAB primary identifier with SCIdS."

parents c610fd43 002151ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ cc_test {
    static_libs: [
        "android.hardware.broadcastradio@1.0",
        "android.hardware.broadcastradio@1.1",
        "android.hardware.broadcastradio@1.2",  // common-utils-lib dependency
        "android.hardware.broadcastradio@common-utils-lib",
        "android.hardware.broadcastradio@vts-utils-lib",
        "libgmock",
+92 −0
Original line number Diff line number Diff line
@@ -525,6 +525,98 @@ TEST_P(BroadcastRadioHalTest, AnalogForcedSwitch) {
    ASSERT_FALSE(forced);
}

static void verifyIdentifier(const ProgramIdentifier& id) {
    EXPECT_NE(id.type, 0u);
    auto val = id.value;

    switch (static_cast<IdentifierType>(id.type)) {
        case IdentifierType::AMFM_FREQUENCY:
        case IdentifierType::DAB_FREQUENCY:
        case IdentifierType::DRMO_FREQUENCY:
            EXPECT_GT(val, 100u) << "Expected f > 100kHz";
            EXPECT_LT(val, 10000000u) << "Expected f < 10GHz";
            break;
        case IdentifierType::RDS_PI:
            EXPECT_GT(val, 0u);
            EXPECT_LE(val, 0xFFFFu) << "Expected 16bit id";
            break;
        case IdentifierType::HD_STATION_ID_EXT: {
            auto stationId = val & 0xFFFFFFFF;  // 32bit
            val >>= 32;
            auto subchannel = val & 0xF;  // 4bit
            val >>= 4;
            auto freq = val & 0x3FFFF;  // 18bit
            EXPECT_GT(stationId, 0u);
            EXPECT_LT(subchannel, 8u) << "Expected ch < 8";
            EXPECT_GT(freq, 100u) << "Expected f > 100kHz";
            EXPECT_LT(freq, 10000000u) << "Expected f < 10GHz";
            break;
        }
        case IdentifierType::HD_SUBCHANNEL:
            EXPECT_LT(val, 8u) << "Expected ch < 8";
            break;
        case IdentifierType::DAB_SIDECC: {
            auto sid = val & 0xFFFF;  // 16bit
            val >>= 16;
            auto ecc = val & 0xFF;  // 8bit
            EXPECT_NE(sid, 0u);
            EXPECT_GE(ecc, 0xA0u) << "Invalid ECC, see ETSI TS 101 756 V2.1.1";
            EXPECT_LE(ecc, 0xF6u) << "Invalid ECC, see ETSI TS 101 756 V2.1.1";
            break;
        }
        case IdentifierType::DAB_ENSEMBLE:
            EXPECT_GT(val, 0u);
            EXPECT_LE(val, 0xFFFFu) << "Expected 16bit id";
            break;
        case IdentifierType::DAB_SCID:
            EXPECT_GT(val, 0xFu) << "Expected 12bit SCId (not 4bit SCIdS)";
            EXPECT_LE(val, 0xFFFu) << "Expected 12bit id";
            break;
        case IdentifierType::DRMO_SERVICE_ID:
            EXPECT_GT(val, 0u);
            EXPECT_LE(val, 0xFFFFFFu) << "Expected 24bit id";
            break;
        case IdentifierType::DRMO_MODULATION:
            EXPECT_GE(val, static_cast<uint32_t>(Modulation::AM));
            EXPECT_LE(val, static_cast<uint32_t>(Modulation::FM));
            break;
        case IdentifierType::SXM_SERVICE_ID:
            EXPECT_GT(val, 0u);
            EXPECT_LE(val, 0xFFFFFFFFu) << "Expected 32bit id";
            break;
        case IdentifierType::SXM_CHANNEL:
            EXPECT_LT(val, 1000u);
            break;
        case IdentifierType::VENDOR_PRIMARY_START:
        case IdentifierType::VENDOR_PRIMARY_END:
            // skip
            break;
    }
}

/**
 * Test ProgramIdentifier format.
 *
 * Verifies that:
 * - values of ProgramIdentifier match their definitions at IdentifierType.
 */
TEST_P(BroadcastRadioHalTest, VerifyIdentifiersFormat) {
    if (skipped) return;
    ASSERT_TRUE(openTuner());

    do {
        auto getCb = [&](const hidl_vec<ProgramInfo>& list) {
            for (auto&& program : list) {
                verifyIdentifier(program.selector.primaryId);
                for (auto&& id : program.selector.secondaryIds) {
                    verifyIdentifier(id);
                }
            }
        };
        getProgramList(getCb);
    } while (nextBand());
}

INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest,
                        ::testing::Values(Class::AM_FM, Class::SAT, Class::DT));

+2 −2
Original line number Diff line number Diff line
@@ -35,13 +35,13 @@ using V1_0::Band;
using V1_0::BandConfig;
using V1_0::Class;
using V1_0::Direction;
using V1_1::IdentifierType;
using V1_1::ProgramInfo;
using V1_1::ProgramInfoFlags;
using V1_1::ProgramListResult;
using V1_1::ProgramSelector;
using V1_1::ProgramType;
using V1_1::VendorKeyValue;
using V1_2::IdentifierType;
using utils::HalRevision;

using std::chrono::milliseconds;
@@ -282,7 +282,7 @@ Return<Result> Tuner::tuneByProgramSelector(const ProgramSelector& sel) {
            return Result::INVALID_ARGUMENTS;
        }
    } else if (programType == ProgramType::DAB) {
        if (!utils::hasId(sel, IdentifierType::DAB_SIDECC)) return Result::INVALID_ARGUMENTS;
        if (!utils::hasId(sel, IdentifierType::DAB_SID_EXT)) return Result::INVALID_ARGUMENTS;
    } else if (programType == ProgramType::DRMO) {
        if (!utils::hasId(sel, IdentifierType::DRMO_SERVICE_ID)) return Result::INVALID_ARGUMENTS;
    } else if (programType == ProgramType::SXM) {
+1 −1
Original line number Diff line number Diff line
@@ -30,9 +30,9 @@ using std::vector;
using V1_0::MetaData;
using V1_0::MetadataKey;
using V1_0::MetadataType;
using V1_1::IdentifierType;
using V1_1::ProgramInfo;
using V1_1::VendorKeyValue;
using V1_2::IdentifierType;
using utils::HalRevision;

static MetaData createDemoBitmap(MetadataKey key, HalRevision halRev) {
+27 −0
Original line number Diff line number Diff line
@@ -16,8 +16,35 @@

package android.hardware.broadcastradio@1.2;

import @1.1::IdentifierType;
import @1.1::Result;
import @1.1::VendorKeyValue;

typedef @1.1::Result Result;
typedef @1.1::VendorKeyValue VendorKeyValue;

enum IdentifierType : @1.1::IdentifierType {
    /**
     * 28bit compound primary identifier for DAB.
     *
     * Consists of (from the LSB):
     * - 16bit: SId;
     * - 8bit: ECC code;
     * - 4bit: SCIdS (optional).
     *
     * SCIdS (Service Component Identifier within the Service) value
     * of 0 represents the main service, while 1 and above represents
     * secondary services.
     *
     * The remaining bits should be set to zeros when writing on the chip side
     * and ignored when read.
     *
     * This identifier deprecates DAB_SIDECC and makes new primary identifier
     * for DAB. If the hal implementation detects 1.2 client (by casting
     * V1_0::ITunerCallback to V1_2::ITunerCallback), it must use DAB_SID_EXT
     * as a primary identifier for DAB program type. If the hal client detects
     * either 1.1 or 1.2 HAL, it must convert those identifiers to the
     * correct version.
     */
    DAB_SID_EXT = SXM_CHANNEL + 1,
};
Loading