Implement out-of-band metadata images.
This saves a lot of HIDL bandwidth, by not including raw image data in
metadata vector.
Bug: b/63702941
Test: VTS
Change-Id: I73d5218095e4af34c58da8dcfc520abd4cb46c26
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
index d165e32..e9ac4b7 100644
--- a/broadcastradio/1.0/types.hal
+++ b/broadcastradio/1.0/types.hal
@@ -146,8 +146,11 @@
/** 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,
@@ -173,9 +176,9 @@
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,
diff --git a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
index 7241ad4..fa0f030 100644
--- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
+++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
@@ -46,7 +46,8 @@
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) { \
@@ -648,6 +649,52 @@
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,