mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 22:04:26 +00:00
In theory, 32bit HD Radio station ID + subchannel index (parts of HD_STATION_ID_EXT) is a globally unique identifier. It allows broadcast radio framework to determine which programs are the same and allow the application to match entries from favourite list and the program list provided by the tuner. However, some broadcasters don't perform equipment setup correctly and don't set station ID. As a result, there are some stations with conflicting IDs. As a workaround to treat these stations separately in a given location, FM frequency was added as a part of HD_STATION_ID_EXT. This still doesn't solve the global uniqueness problem: user might save KCQW 105.5 (sid=0) in California, travel to Nevada and find KNAB 105.5 (sid=0). It turns out there is no reliable identifier that might identify the station globally. As a workaround, shortened station name is added for double-checking. This is a best-effort fix, so it's not required for such misbehaving stations to get correctly identified in every corner case. Bug: 69958777 Test: VTS Change-Id: Id11243096f1cde7fdda5cb70a7248d1831985cdd
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
/*
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <broadcastradio-utils-2x/Utils.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <optional>
|
|
|
|
namespace {
|
|
|
|
namespace utils = android::hardware::broadcastradio::utils;
|
|
|
|
TEST(ProgramIdentifierTest, hdRadioStationName) {
|
|
auto verify = [](std::string name, uint64_t nameId) {
|
|
auto id = utils::make_hdradio_station_name(name);
|
|
EXPECT_EQ(nameId, id.value) << "Failed to convert '" << name << "'";
|
|
};
|
|
|
|
verify("", 0);
|
|
verify("Abc", 0x434241);
|
|
verify("Some Station 1", 0x54415453454d4f53);
|
|
verify("Station1", 0x314e4f4954415453);
|
|
verify("!@#$%^&*()_+", 0);
|
|
verify("-=[]{};':\"0", 0x30);
|
|
}
|
|
|
|
} // anonymous namespace
|