Fix bcradio HAL unsigned int comparison error

Bug: 299489486
Test: atest VtsHalBroadcastradioAidlTargetTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:664048f21856ab30d5b713e524ef588f35747938)
Merged-In: I87fe60a593800535e0aadb0baf87696ee6844004
Change-Id: I87fe60a593800535e0aadb0baf87696ee6844004
This commit is contained in:
Weilin Xu
2023-09-07 11:26:38 -07:00
committed by Cherrypicker Worker
parent 4aca9377db
commit 5d9b066c04
3 changed files with 25 additions and 25 deletions

View File

@@ -53,18 +53,18 @@ const VirtualRadio& VirtualRadio::getAmFmRadio() {
static VirtualRadio amFmRadioMock(
"AM/FM radio mock",
{
{makeSelectorAmfm(/* frequency= */ 94900), "Wild 94.9", "Drake ft. Rihanna",
{makeSelectorAmfm(/* frequency= */ 94900u), "Wild 94.9", "Drake ft. Rihanna",
"Too Good"},
{makeSelectorAmfm(/* frequency= */ 96500), "KOIT", "Celine Dion", "All By Myself"},
{makeSelectorAmfm(/* frequency= */ 97300), "Alice@97.3", "Drops of Jupiter", "Train"},
{makeSelectorAmfm(/* frequency= */ 99700), "99.7 Now!", "The Chainsmokers", "Closer"},
{makeSelectorAmfm(/* frequency= */ 101300), "101-3 KISS-FM", "Justin Timberlake",
{makeSelectorAmfm(/* frequency= */ 96500u), "KOIT", "Celine Dion", "All By Myself"},
{makeSelectorAmfm(/* frequency= */ 97300u), "Alice@97.3", "Drops of Jupiter", "Train"},
{makeSelectorAmfm(/* frequency= */ 99700u), "99.7 Now!", "The Chainsmokers", "Closer"},
{makeSelectorAmfm(/* frequency= */ 101300u), "101-3 KISS-FM", "Justin Timberlake",
"Rock Your Body"},
{makeSelectorAmfm(/* frequency= */ 103700), "iHeart80s @ 103.7", "Michael Jackson",
{makeSelectorAmfm(/* frequency= */ 103700u), "iHeart80s @ 103.7", "Michael Jackson",
"Billie Jean"},
{makeSelectorAmfm(/* frequency= */ 106100), "106 KMEL", "Drake", "Marvins Room"},
{makeSelectorAmfm(/* frequency= */ 700), "700 AM", "Artist700", "Title700"},
{makeSelectorAmfm(/* frequency= */ 1700), "1700 AM", "Artist1700", "Title1700"},
{makeSelectorAmfm(/* frequency= */ 106100u), "106 KMEL", "Drake", "Marvins Room"},
{makeSelectorAmfm(/* frequency= */ 700u), "700 AM", "Artist700", "Title700"},
{makeSelectorAmfm(/* frequency= */ 1700u), "1700 AM", "Artist1700", "Title1700"},
});
// clang-format on
return amFmRadioMock;
@@ -77,13 +77,13 @@ const VirtualRadio& VirtualRadio::getDabRadio() {
"DAB radio mock",
{
{makeSelectorDab(/* sidExt= */ 0xA000000001u, /* ensemble= */ 0x0001u,
/* freq= */ 225648), "BBC Radio 1", "Khalid", "Talk"},
/* freq= */ 225648u), "BBC Radio 1", "Khalid", "Talk"},
{makeSelectorDab(/* sidExt= */ 0xB000000001u, /* ensemble= */ 0x1001u,
/* freq= */ 222064), "Classic FM", "Jean Sibelius", "Andante Festivo"},
/* freq= */ 222064u), "Classic FM", "Jean Sibelius", "Andante Festivo"},
{makeSelectorDab(/* sidExt= */ 0xB000000002u, /* ensemble= */ 0x1002u,
/* freq= */ 227360), "Absolute Radio", "Coldplay", "Clocks"},
/* freq= */ 227360u), "Absolute Radio", "Coldplay", "Clocks"},
{makeSelectorDab(/* sidExt= */ 0xB000000002u, /* ensemble= */ 0x1002u,
/* freq= */ 222064), "Absolute Radio", "Coldplay", "Clocks"},
/* freq= */ 222064u), "Absolute Radio", "Coldplay", "Clocks"},
});
// clang-format on
return dabRadioMock;

View File

@@ -204,7 +204,7 @@ bool isSupported(const Properties& prop, const ProgramSelector& sel) {
}
bool isValid(const ProgramIdentifier& id) {
int64_t val = id.value;
uint64_t val = static_cast<uint64_t>(id.value);
bool valid = true;
auto expect = [&valid](bool condition, const string& message) {
@@ -231,11 +231,11 @@ bool isValid(const ProgramIdentifier& id) {
expect(val <= 0xFFFFu, "16bit id");
break;
case IdentifierType::HD_STATION_ID_EXT: {
int64_t stationId = val & 0xFFFFFFFF; // 32bit
uint64_t stationId = val & 0xFFFFFFFF; // 32bit
val >>= 32;
int64_t subchannel = val & 0xF; // 4bit
uint64_t subchannel = val & 0xF; // 4bit
val >>= 4;
int64_t freq = val & 0x3FFFF; // 18bit
uint64_t freq = val & 0x3FFFF; // 18bit
expect(stationId != 0u, "HD station id != 0");
expect(subchannel < 8u, "HD subch < 8");
expect(freq > 100u, "f > 100kHz");
@@ -252,9 +252,9 @@ bool isValid(const ProgramIdentifier& id) {
break;
}
case IdentifierType::DAB_SID_EXT: {
int64_t sid = val & 0xFFFFFFFF; // 32bit
uint64_t sid = val & 0xFFFFFFFF; // 32bit
val >>= 32;
int64_t ecc = val & 0xFF; // 8bit
uint64_t ecc = val & 0xFF; // 8bit
expect(sid != 0u, "DAB SId != 0");
expect(ecc >= 0xA0u && ecc <= 0xF6u, "Invalid ECC, see ETSI TS 101 756 V2.1.1");
break;
@@ -305,19 +305,19 @@ ProgramIdentifier makeIdentifier(IdentifierType type, int64_t value) {
return {type, value};
}
ProgramSelector makeSelectorAmfm(int32_t frequency) {
ProgramSelector makeSelectorAmfm(uint32_t frequency) {
ProgramSelector sel = {};
sel.primaryId = makeIdentifier(IdentifierType::AMFM_FREQUENCY_KHZ, frequency);
return sel;
}
ProgramSelector makeSelectorDab(int64_t sidExt) {
ProgramSelector makeSelectorDab(uint64_t sidExt) {
ProgramSelector sel = {};
sel.primaryId = makeIdentifier(IdentifierType::DAB_SID_EXT, sidExt);
return sel;
}
ProgramSelector makeSelectorDab(int64_t sidExt, int32_t ensemble, int64_t freq) {
ProgramSelector makeSelectorDab(uint64_t sidExt, uint32_t ensemble, uint64_t freq) {
ProgramSelector sel = {};
sel.primaryId = makeIdentifier(IdentifierType::DAB_SID_EXT, sidExt);
vector<ProgramIdentifier> secondaryIds = {

View File

@@ -137,9 +137,9 @@ bool isValid(const ProgramIdentifier& id);
bool isValid(const ProgramSelector& sel);
ProgramIdentifier makeIdentifier(IdentifierType type, int64_t value);
ProgramSelector makeSelectorAmfm(int32_t frequency);
ProgramSelector makeSelectorDab(int64_t sidExt);
ProgramSelector makeSelectorDab(int64_t sidExt, int32_t ensemble, int64_t freq);
ProgramSelector makeSelectorAmfm(uint32_t frequency);
ProgramSelector makeSelectorDab(uint64_t sidExt);
ProgramSelector makeSelectorDab(uint64_t sidExt, uint32_t ensemble, uint64_t freq);
bool satisfies(const ProgramFilter& filter, const ProgramSelector& sel);