Fix isValidV2 check for HD station location id

Bug: 328313667
Test: atest broadcastradio_utils_aidl_test
Change-Id: I570d24fee3607cf53d197fe886e6c4a5a611b932
This commit is contained in:
Weilin Xu 2024-03-05 12:58:50 -08:00
parent 1b6c03d742
commit af20855c7c
2 changed files with 8 additions and 7 deletions

View file

@ -174,7 +174,7 @@ enum IdentifierType {
* - 13 bit: Fractional bits of longitude
* - 8 bit: Integer bits of longitude
* - 1 bit: 0 for east and 1 for west for longitude
* - 1 bit: 0, representing latitude
* - 1 bit: 0, representing longitude
* - 5 bit: pad of zeros separating longitude and latitude
* - 4 bit: Bits 4:7 of altitude
* - 13 bit: Fractional bits of latitude

View file

@ -102,15 +102,16 @@ bool isValidV2(const ProgramIdentifier& id) {
expect(val < 1000u, "SXM channel < 1000");
break;
case IdentifierType::HD_STATION_LOCATION: {
val >>= 26;
uint64_t latitudeBit = val & 0x1;
expect(latitudeBit == 1u, "Latitude comes first");
val >>= 27;
expect(latitudeBit == 0u, "Longitude comes first");
val >>= 1;
uint64_t latitudePad = val & 0x1Fu;
expect(latitudePad == 0u, "Latitude padding");
val >>= 5;
expect(latitudePad == 0u, "Longitude padding");
val >>= 31;
uint64_t longitudeBit = val & 0x1;
expect(longitudeBit == 1u, "Longitude comes next");
val >>= 27;
expect(longitudeBit == 1u, "Latitude comes next");
val >>= 1;
uint64_t longitudePad = val & 0x1Fu;
expect(longitudePad == 0u, "Latitude padding");
break;