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

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

Merge changes from topic 'radio-sprint-selector'

* changes:
  Split VENDOR program type to four distinct types.
  Move utils lib out from implementation namespace.
parents 603195bc d167caff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ static ProgramInfo makeDummyProgramInfo(const ProgramSelector& selector) {
    ProgramInfo info11 = {};
    auto& info10 = info11.base;

    utils::getLegacyChannel(selector, info10.channel, info10.subChannel);
    utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
    info11.selector = selector;
    info11.flags |= ProgramInfoFlags::MUTED;

+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ VirtualProgram::operator ProgramInfo() const {
    ProgramInfo info11 = {};
    auto& info10 = info11.base;

    utils::getLegacyChannel(selector, info10.channel, info10.subChannel);
    utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
    info11.selector = selector;
    info10.tuned = true;
    info10.stereo = true;
+13 −3
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ struct Properties {
/**
 * Type of a radio technology.
 *
 * There are multiple VENDOR program types just to make vendor implementation
 * easier with multiple properitary radio technologies. They are treated the
 * same by the framework.
 *
 * All other values are reserved for future use.
 */
enum ProgramType : uint32_t {
@@ -80,7 +84,10 @@ enum ProgramType : uint32_t {
    DAB,     // Digital audio broadcasting
    DRMO,    // Digital Radio Mondiale
    SXM,     // SiriusXM Satellite Radio
    VENDOR,  // vendor-specific, not synced across devices
    VENDOR1, // Vendor-specific, not synced across devices.
    VENDOR2, // Vendor-specific, not synced across devices.
    VENDOR3, // Vendor-specific, not synced across devices.
    VENDOR4, // Vendor-specific, not synced across devices.
};

/**
@@ -142,9 +149,12 @@ enum IdentifierType : uint32_t {
     * Primary identifier for vendor-specific radio technology.
     * The value format is determined by a vendor.
     *
     * It must not be used in any other programType than VENDOR.
     * It must not be used in any other programType than VENDORx.
     */
    VENDOR_PRIMARY,
    VENDOR1_PRIMARY,
    VENDOR2_PRIMARY,
    VENDOR3_PRIMARY,
    VENDOR4_PRIMARY,
};

/**
+19 −13
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ namespace android {
namespace hardware {
namespace broadcastradio {
namespace V1_1 {
namespace implementation {
namespace utils {

using V1_0::Band;
@@ -92,7 +91,10 @@ bool tunesTo(const ProgramSelector& a, const ProgramSelector& b) {
                return haveEqualIds(a, b, IdentifierType::SXM_SERVICE_ID);
            }
            return haveEqualIds(a, b, IdentifierType::SXM_CHANNEL);
        case ProgramType::VENDOR:
        case ProgramType::VENDOR1:
        case ProgramType::VENDOR2:
        case ProgramType::VENDOR3:
        case ProgramType::VENDOR4:
        default:
            ALOGW("Unsupported program type: %s", toString(type).c_str());
            return false;
@@ -166,26 +168,31 @@ ProgramSelector make_selector(Band band, uint32_t channel, uint32_t subChannel)
    sel.primaryId.type = static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY);
    sel.primaryId.value = channel;
    if (subChannel > 0) {
        // stating sub channel for AM/FM channel does not give any guarantees,
        // but we can't do much more without HD station ID
        /* stating sub channel for AM/FM channel does not give any guarantees,
         * but we can't do much more without HD station ID
         *
         * The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
         */
        sel.secondaryIds = hidl_vec<ProgramIdentifier>{
            {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel},
            {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel - 1},
        };
    }

    return sel;
}

bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut) {
bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut) {
    if (channelOut) *channelOut = 0;
    if (subChannelOut) *subChannelOut = 0;
    if (isAmFm(getType(sel))) {
        channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY);
        subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL, 0);
        if (channelOut) *channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY);
        if (subChannelOut && hasId(sel, IdentifierType::HD_SUBCHANNEL)) {
            // The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
            *subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL) + 1;
        }
        return true;
    } else {
        channelOut = 0;
        subChannelOut = 0;
        return false;
    }
    return false;
}

bool isDigital(const ProgramSelector& sel) {
@@ -200,7 +207,6 @@ bool isDigital(const ProgramSelector& sel) {
}

}  // namespace utils
}  // namespace implementation
}  // namespace V1_1
}  // namespace broadcastradio
}  // namespace hardware
+1 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ namespace android {
namespace hardware {
namespace broadcastradio {
namespace V1_1 {
namespace implementation {
namespace utils {

/**
@@ -61,12 +60,11 @@ uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t d

ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);

bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut);
bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut);

bool isDigital(const ProgramSelector& sel);

}  // namespace utils
}  // namespace implementation
}  // namespace V1_1
}  // namespace broadcastradio
}  // namespace hardware