Loading broadcastradio/1.0/types.hal +7 −4 Original line number Diff line number Diff line Loading @@ -146,8 +146,11 @@ enum MetadataType : int32_t { /** String */ TEXT = 1, /** * Raw binary data (icon or art) This data must be transparent to the android framework */ * Raw binary data (icon or art). * * The data should be a valid PNG, JPEG, GIF or BMP file. * Invalid format must be handled gracefully as if the field was missing. */ RAW = 2, /** clock data, see MetaDataClock */ CLOCK = 3, Loading @@ -173,9 +176,9 @@ enum MetadataKey : int32_t { ALBUM = 7, /** Musical genre - string */ GENRE = 8, /** Station icon - raw */ /** Station icon - raw (int32_t for HAL 1.1) */ ICON = 9, /** Album art - raw */ /** Album art - raw (int32_t for HAL 1.1) */ ART = 10, /** Clock - MetaDataClock */ CLOCK = 11, Loading broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp +48 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ using ::android::hardware::broadcastradio::V1_0::BandConfig; using ::android::hardware::broadcastradio::V1_0::Direction; using ::android::hardware::broadcastradio::V1_0::ProgramInfo; using ::android::hardware::broadcastradio::V1_0::MetaData; using ::android::hardware::broadcastradio::V1_0::MetadataKey; using ::android::hardware::broadcastradio::V1_0::MetadataType; #define RETURN_IF_SKIPPED \ if (skipped) { \ Loading Loading @@ -648,6 +649,52 @@ TEST_P(BroadcastRadioHidlTest, TuneFailsOutOfBounds) { EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs)); } /** * Test proper image format in metadata. * * Verifies that: * - all images in metadata are provided in-band (as a binary blob, not by id) * * This is a counter-test for OobImagesOnly from 1.1 VTS. */ TEST_P(BroadcastRadioHidlTest, IbImagesOnly) { RETURN_IF_SKIPPED; ASSERT_TRUE(openTuner()); ASSERT_TRUE(checkAntenna()); bool firstScan = true; uint32_t firstChannel, prevChannel; while (true) { mCallbackCalled = false; auto hidlResult = mTuner->scan(Direction::UP, true); ASSERT_TRUE(hidlResult.isOk()); if (hidlResult == Result::TIMEOUT) { ALOGI("Got timeout on scan operation"); break; } ASSERT_EQ(Result::OK, hidlResult); ASSERT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); if (firstScan) { firstScan = false; firstChannel = mProgramInfoCallbackData.channel; } else { // scanned the whole band if (mProgramInfoCallbackData.channel >= firstChannel && prevChannel <= firstChannel) { break; } } prevChannel = mProgramInfoCallbackData.channel; for (auto&& entry : mProgramInfoCallbackData.metadata) { if (entry.key != MetadataKey::ICON && entry.key != MetadataKey::ART) continue; EXPECT_EQ(MetadataType::RAW, entry.type); EXPECT_EQ(0, entry.intValue); EXPECT_GT(entry.rawValue.size(), 0u); } } } INSTANTIATE_TEST_CASE_P( BroadcastRadioHidlTestCases, BroadcastRadioHidlTest, Loading broadcastradio/1.1/IBroadcastRadio.hal +19 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,23 @@ interface IBroadcastRadio extends @1.0::IBroadcastRadio { */ getProperties_1_1() generates (Properties properties); /** * Fetch image from radio module. * * This call is meant to make V1_0::MetaData lightweight - instead of * passing image data blob in MetadataType.RAW field, only identifier is * passed, so the client may cache images or even not fetch them. * * Identifier may be any arbitrary number - sequential, sha256 prefix, * or any other unique value selected by the vendor. * * The data should be a valid PNG, JPEG, GIF or BMP file. * Invalid format must be handled gracefully as if the image was missing. * * @param id Identifier of an image; * value of 0 is reserved and should be treated as invalid image. * @return image A binary blob with image data * or zero-length vector if identifier doesn't exists. */ getImage(int32_t id) generates (vec<uint8_t> image); }; broadcastradio/1.1/default/BroadcastRadio.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <log/log.h> #include "resources.h" namespace android { namespace hardware { namespace broadcastradio { Loading Loading @@ -155,6 +157,19 @@ Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio __un return Void(); } Return<void> BroadcastRadio::getImage(int32_t id, getImage_cb _hidl_cb) { ALOGV("%s(%x)", __func__, id); if (id == resources::demoPngId) { _hidl_cb(std::vector<uint8_t>(resources::demoPng, std::end(resources::demoPng))); return {}; } ALOGI("Image %x doesn't exists", id); _hidl_cb({}); return Void(); } } // namespace implementation } // namespace V1_1 } // namespace broadcastradio Loading broadcastradio/1.1/default/BroadcastRadio.h +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ struct BroadcastRadio : public V1_1::IBroadcastRadio { Return<void> openTuner(const V1_0::BandConfig& config, bool audio, const sp<V1_0::ITunerCallback>& callback, openTuner_cb _hidl_cb) override; Return<void> getImage(int32_t id, getImage_cb _hidl_cb); private: std::mutex mMut; Loading Loading
broadcastradio/1.0/types.hal +7 −4 Original line number Diff line number Diff line Loading @@ -146,8 +146,11 @@ enum MetadataType : int32_t { /** String */ TEXT = 1, /** * Raw binary data (icon or art) This data must be transparent to the android framework */ * Raw binary data (icon or art). * * The data should be a valid PNG, JPEG, GIF or BMP file. * Invalid format must be handled gracefully as if the field was missing. */ RAW = 2, /** clock data, see MetaDataClock */ CLOCK = 3, Loading @@ -173,9 +176,9 @@ enum MetadataKey : int32_t { ALBUM = 7, /** Musical genre - string */ GENRE = 8, /** Station icon - raw */ /** Station icon - raw (int32_t for HAL 1.1) */ ICON = 9, /** Album art - raw */ /** Album art - raw (int32_t for HAL 1.1) */ ART = 10, /** Clock - MetaDataClock */ CLOCK = 11, Loading
broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp +48 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ using ::android::hardware::broadcastradio::V1_0::BandConfig; using ::android::hardware::broadcastradio::V1_0::Direction; using ::android::hardware::broadcastradio::V1_0::ProgramInfo; using ::android::hardware::broadcastradio::V1_0::MetaData; using ::android::hardware::broadcastradio::V1_0::MetadataKey; using ::android::hardware::broadcastradio::V1_0::MetadataType; #define RETURN_IF_SKIPPED \ if (skipped) { \ Loading Loading @@ -648,6 +649,52 @@ TEST_P(BroadcastRadioHidlTest, TuneFailsOutOfBounds) { EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs)); } /** * Test proper image format in metadata. * * Verifies that: * - all images in metadata are provided in-band (as a binary blob, not by id) * * This is a counter-test for OobImagesOnly from 1.1 VTS. */ TEST_P(BroadcastRadioHidlTest, IbImagesOnly) { RETURN_IF_SKIPPED; ASSERT_TRUE(openTuner()); ASSERT_TRUE(checkAntenna()); bool firstScan = true; uint32_t firstChannel, prevChannel; while (true) { mCallbackCalled = false; auto hidlResult = mTuner->scan(Direction::UP, true); ASSERT_TRUE(hidlResult.isOk()); if (hidlResult == Result::TIMEOUT) { ALOGI("Got timeout on scan operation"); break; } ASSERT_EQ(Result::OK, hidlResult); ASSERT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); if (firstScan) { firstScan = false; firstChannel = mProgramInfoCallbackData.channel; } else { // scanned the whole band if (mProgramInfoCallbackData.channel >= firstChannel && prevChannel <= firstChannel) { break; } } prevChannel = mProgramInfoCallbackData.channel; for (auto&& entry : mProgramInfoCallbackData.metadata) { if (entry.key != MetadataKey::ICON && entry.key != MetadataKey::ART) continue; EXPECT_EQ(MetadataType::RAW, entry.type); EXPECT_EQ(0, entry.intValue); EXPECT_GT(entry.rawValue.size(), 0u); } } } INSTANTIATE_TEST_CASE_P( BroadcastRadioHidlTestCases, BroadcastRadioHidlTest, Loading
broadcastradio/1.1/IBroadcastRadio.hal +19 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,23 @@ interface IBroadcastRadio extends @1.0::IBroadcastRadio { */ getProperties_1_1() generates (Properties properties); /** * Fetch image from radio module. * * This call is meant to make V1_0::MetaData lightweight - instead of * passing image data blob in MetadataType.RAW field, only identifier is * passed, so the client may cache images or even not fetch them. * * Identifier may be any arbitrary number - sequential, sha256 prefix, * or any other unique value selected by the vendor. * * The data should be a valid PNG, JPEG, GIF or BMP file. * Invalid format must be handled gracefully as if the image was missing. * * @param id Identifier of an image; * value of 0 is reserved and should be treated as invalid image. * @return image A binary blob with image data * or zero-length vector if identifier doesn't exists. */ getImage(int32_t id) generates (vec<uint8_t> image); };
broadcastradio/1.1/default/BroadcastRadio.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <log/log.h> #include "resources.h" namespace android { namespace hardware { namespace broadcastradio { Loading Loading @@ -155,6 +157,19 @@ Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio __un return Void(); } Return<void> BroadcastRadio::getImage(int32_t id, getImage_cb _hidl_cb) { ALOGV("%s(%x)", __func__, id); if (id == resources::demoPngId) { _hidl_cb(std::vector<uint8_t>(resources::demoPng, std::end(resources::demoPng))); return {}; } ALOGI("Image %x doesn't exists", id); _hidl_cb({}); return Void(); } } // namespace implementation } // namespace V1_1 } // namespace broadcastradio Loading
broadcastradio/1.1/default/BroadcastRadio.h +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ struct BroadcastRadio : public V1_1::IBroadcastRadio { Return<void> openTuner(const V1_0::BandConfig& config, bool audio, const sp<V1_0::ITunerCallback>& callback, openTuner_cb _hidl_cb) override; Return<void> getImage(int32_t id, getImage_cb _hidl_cb); private: std::mutex mMut; Loading