From: android-build-team Robot Date: Wed, 19 Jul 2017 07:24:36 +0000 (+0000) Subject: release-request-bd6aa7dd-7b02-4794-942c-14599bf61208-for-git_oc-mr1-release-4193791... X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8644676323fd16b1d648a1d9c1ecb44ddd7a96b2;hp=9f41207e3df1dac340e2e2ea4d7bb8d000258583;p=android-x86%2Fhardware-interfaces.git release-request-bd6aa7dd-7b02-4794-942c-14599bf61208-for-git_oc-mr1-release-4193791 snap-temp-L98700000083613807 Change-Id: Ib931cb810771edc7355e926d5b19b14fed626d7c --- diff --git a/broadcastradio/1.1/ITuner.hal b/broadcastradio/1.1/ITuner.hal index 912786ab..a5c569a9 100644 --- a/broadcastradio/1.1/ITuner.hal +++ b/broadcastradio/1.1/ITuner.hal @@ -42,6 +42,24 @@ interface ITuner extends @1.0::ITuner { tune_1_1(ProgramSelector program) generates (Result result); /** + * Cancels announcement. + * + * If it was traffic announcement, trafficAnnouncement(false) callback + * should be called (just like it was ended in a normal way). Similarly for + * emergency announcement. If there was no announcement, then no action + * should be taken. + * + * There is a race condition between calling cancelAnnouncement and the + * actual announcement being finished, so trafficAnnouncement / + * emergencyAnnouncement callback should be tracked with proper locking. + * + * @return result OK if successfully cancelled announcement or there was + * no announcement. + * NOT_INITIALIZED if another error occurs. + */ + cancelAnnouncement() generates (Result result); + + /** * Retrieve current station information. * @return result OK if scan successfully started * NOT_INITIALIZED if another error occurs diff --git a/broadcastradio/1.1/ITunerCallback.hal b/broadcastradio/1.1/ITunerCallback.hal index 158e2170..b1c5b01d 100644 --- a/broadcastradio/1.1/ITunerCallback.hal +++ b/broadcastradio/1.1/ITunerCallback.hal @@ -28,16 +28,26 @@ interface ITunerCallback extends @1.0::ITunerCallback { /** * Method called by the HAL when a tuning operation completes * following a step(), scan() or tune() command. + * + * This callback supersedes V1_0::tuneComplete. For performance reasons, + * the 1.0 callback may not be called when HAL implementation detects 1.1 + * client (by casting V1_0::ITunerCallback to V1_1::ITunerCallback). + * * @param result OK if tune succeeded or TIMEOUT in case of time out. - * @param info A ProgramInfo structure describing the tuned station. + * @param selector A ProgramSelector structure describing the tuned station. */ - oneway tuneComplete_1_1(Result result, ProgramInfo info); + oneway tuneComplete_1_1(Result result, ProgramSelector selector); /** * Method called by the HAL when a frequency switch occurs. - * @param info A ProgramInfo structure describing the new tuned station. + * + * This callback supersedes V1_0::afSwitch. For performance reasons, + * the 1.0 callback may not be called when HAL implementation detects 1.1 + * client (by casting V1_0::ITunerCallback to V1_1::ITunerCallback). + * + * @param selector A ProgramSelector structure describing the tuned station. */ - oneway afSwitch_1_1(ProgramInfo info); + oneway afSwitch_1_1(ProgramSelector selector); /** * Called by the HAL when background scan feature becomes available or not. @@ -69,4 +79,20 @@ interface ITunerCallback extends @1.0::ITunerCallback { * Client may retrieve the actual list with ITuner::getProgramList. */ oneway programListChanged(); + + /** + * Method called by the HAL when current program information (including + * metadata) is updated. + * + * Client may retrieve the actual program info with + * ITuner::getProgramInformation_1_1. + * + * This may be called together with tuneComplete_1_1 or afSwitch_1_1. + * + * This callback supersedes V1_0::tuneComplete, V1_0::afSwitch and + * newMetadata. For performance reasons, these callbacks may not be called + * when HAL implementation detects 1.1 client (by casting + * V1_0::ITunerCallback to V1_1::ITunerCallback). + */ + oneway programInfoChanged(); }; diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.1/default/BroadcastRadio.cpp index 1119ffd8..297dcc1c 100644 --- a/broadcastradio/1.1/default/BroadcastRadio.cpp +++ b/broadcastradio/1.1/default/BroadcastRadio.cpp @@ -89,6 +89,16 @@ Return BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) { prop10.numAudioSources = 1; prop10.supportsCapture = false; prop11.supportsBackgroundScanning = false; + prop11.supportedProgramTypes = vector({ + static_cast(ProgramType::AM), static_cast(ProgramType::FM), + static_cast(ProgramType::AM_HD), static_cast(ProgramType::FM_HD), + }); + prop11.supportedIdentifierTypes = vector({ + static_cast(IdentifierType::AMFM_FREQUENCY), + static_cast(IdentifierType::RDS_PI), + static_cast(IdentifierType::HD_STATION_ID_EXT), + static_cast(IdentifierType::HD_SUBCHANNEL), + }); prop11.vendorExension = "dummy"; prop10.bands.resize(mConfig.amFmBands.size()); diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp index a36ec3f1..271f6337 100644 --- a/broadcastradio/1.1/default/Tuner.cpp +++ b/broadcastradio/1.1/default/Tuner.cpp @@ -98,7 +98,7 @@ static ProgramInfo makeDummyProgramInfo(const ProgramSelector& selector) { ProgramInfo info11 = {}; auto& info10 = info11.base; - utils::getLegacyChannel(selector, info10.channel, info10.subChannel); + utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel); info11.selector = selector; info11.flags |= ProgramInfoFlags::MUTED; @@ -126,9 +126,10 @@ void Tuner::tuneInternalLocked(const ProgramSelector& sel) { } mIsTuneCompleted = true; - mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base); - if (mCallback1_1 != nullptr) { - mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo); + if (mCallback1_1 == nullptr) { + mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base); + } else { + mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector); } } @@ -146,8 +147,9 @@ Return Tuner::scan(Direction direction, bool skipSubChannel __unused) { auto task = [this, direction]() { ALOGI("Performing failed scan %s", toString(direction).c_str()); - mCallback->tuneComplete(Result::TIMEOUT, {}); - if (mCallback1_1 != nullptr) { + if (mCallback1_1 == nullptr) { + mCallback->tuneComplete(Result::TIMEOUT, {}); + } else { mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {}); } }; @@ -267,6 +269,11 @@ Return Tuner::cancel() { return Result::OK; } +Return Tuner::cancelAnnouncement() { + ALOGV("%s", __func__); + return Result::OK; +} + Return Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb) { ALOGV("%s", __func__); return getProgramInformation_1_1([&](Result result, const ProgramInfo& info) { diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.1/default/Tuner.h index 5c8a7e57..2ab4f407 100644 --- a/broadcastradio/1.1/default/Tuner.h +++ b/broadcastradio/1.1/default/Tuner.h @@ -34,19 +34,21 @@ struct Tuner : public ITuner { void forceClose(); // V1_1::ITuner methods - Return setConfiguration(const V1_0::BandConfig& config) override; - Return getConfiguration(getConfiguration_cb _hidl_cb) override; - Return scan(V1_0::Direction direction, bool skipSubChannel) override; - Return step(V1_0::Direction direction, bool skipSubChannel) override; - Return tune(uint32_t channel, uint32_t subChannel) override; - Return tune_1_1(const ProgramSelector& program) override; - Return cancel() override; - Return getProgramInformation(getProgramInformation_cb _hidl_cb) override; - Return getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override; - Return startBackgroundScan() override; - Return getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override; - Return isAnalogForced(isAnalogForced_cb _hidl_cb) override; - Return setAnalogForced(bool isForced) override; + virtual Return setConfiguration(const V1_0::BandConfig& config) override; + virtual Return getConfiguration(getConfiguration_cb _hidl_cb) override; + virtual Return scan(V1_0::Direction direction, bool skipSubChannel) override; + virtual Return step(V1_0::Direction direction, bool skipSubChannel) override; + virtual Return tune(uint32_t channel, uint32_t subChannel) override; + virtual Return tune_1_1(const ProgramSelector& program) override; + virtual Return cancel() override; + virtual Return cancelAnnouncement() override; + virtual Return getProgramInformation(getProgramInformation_cb _hidl_cb) override; + virtual Return getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override; + virtual Return startBackgroundScan() override; + virtual Return getProgramList(const hidl_string& filter, + getProgramList_cb _hidl_cb) override; + virtual Return isAnalogForced(isAnalogForced_cb _hidl_cb) override; + virtual Return setAnalogForced(bool isForced) override; private: std::mutex mMut; diff --git a/broadcastradio/1.1/default/VirtualProgram.cpp b/broadcastradio/1.1/default/VirtualProgram.cpp index ef8bd1c4..babf0d8b 100644 --- a/broadcastradio/1.1/default/VirtualProgram.cpp +++ b/broadcastradio/1.1/default/VirtualProgram.cpp @@ -31,7 +31,7 @@ VirtualProgram::operator ProgramInfo() const { ProgramInfo info11 = {}; auto& info10 = info11.base; - utils::getLegacyChannel(selector, info10.channel, info10.subChannel); + utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel); info11.selector = selector; info10.tuned = true; info10.stereo = true; diff --git a/broadcastradio/1.1/types.hal b/broadcastradio/1.1/types.hal index dee38b8c..356c2991 100644 --- a/broadcastradio/1.1/types.hal +++ b/broadcastradio/1.1/types.hal @@ -43,6 +43,17 @@ enum ProgramInfoFlags : uint32_t { * increasing volume too much. */ MUTED = 1 << 1, + + /** + * Station broadcasts traffic information regularly, + * but not necessarily right now. + */ + TRAFFIC_PROGRAM = 1 << 2, + + /** + * Station is broadcasting traffic information at the very moment. + */ + TRAFFIC_ANNOUNCEMENT = 1 << 3, }; struct Properties { @@ -55,6 +66,29 @@ struct Properties { bool supportsBackgroundScanning; /** + * A list of supported ProgramType values. + * + * If a program type is supported by radio module, it means it can tune + * to ProgramSelector of a given type. + * + * Support for VENDOR program type does not guarantee compatibility, as + * other module properties (implementor, product, version) must be checked. + */ + vec supportedProgramTypes; + + /** + * A list of supported IdentifierType values. + * + * If an identifier is supported by radio module, it means it can use it for + * tuning to ProgramSelector with either primary or secondary Identifier of + * a given type. + * + * Support for VENDOR identifier type does not guarantee compatibility, as + * other module properties (implementor, product, version) must be checked. + */ + vec supportedIdentifierTypes; + + /** * Opaque vendor-specific string, to be passed to front-end without changes. * Format of this string can vary across vendors. * @@ -70,6 +104,10 @@ struct Properties { /** * Type of a radio technology. * + * There are multiple VENDOR program types just to make vendor implementation + * easier with multiple properitary radio technologies. They are treated the + * same by the framework. + * * All other values are reserved for future use. */ enum ProgramType : uint32_t { @@ -80,7 +118,10 @@ enum ProgramType : uint32_t { DAB, // Digital audio broadcasting DRMO, // Digital Radio Mondiale SXM, // SiriusXM Satellite Radio - VENDOR, // vendor-specific, not synced across devices + VENDOR1, // Vendor-specific, not synced across devices. + VENDOR2, // Vendor-specific, not synced across devices. + VENDOR3, // Vendor-specific, not synced across devices. + VENDOR4, // Vendor-specific, not synced across devices. }; /** @@ -142,9 +183,12 @@ enum IdentifierType : uint32_t { * Primary identifier for vendor-specific radio technology. * The value format is determined by a vendor. * - * It must not be used in any other programType than VENDOR. + * It must not be used in any other programType than VENDORx. */ - VENDOR_PRIMARY, + VENDOR1_PRIMARY, + VENDOR2_PRIMARY, + VENDOR3_PRIMARY, + VENDOR4_PRIMARY, }; /** diff --git a/broadcastradio/1.1/utils/Android.bp b/broadcastradio/1.1/utils/Android.bp index df5e8e02..73c66809 100644 --- a/broadcastradio/1.1/utils/Android.bp +++ b/broadcastradio/1.1/utils/Android.bp @@ -16,7 +16,7 @@ cc_library_static { name: "android.hardware.broadcastradio@1.1-utils-lib", - vendor: true, + vendor_available: true, relative_install_path: "hw", cflags: [ "-Wall", diff --git a/broadcastradio/1.1/utils/Utils.cpp b/broadcastradio/1.1/utils/Utils.cpp index 9dc0a53c..f8a44790 100644 --- a/broadcastradio/1.1/utils/Utils.cpp +++ b/broadcastradio/1.1/utils/Utils.cpp @@ -24,7 +24,6 @@ namespace android { namespace hardware { namespace broadcastradio { namespace V1_1 { -namespace implementation { namespace utils { using V1_0::Band; @@ -92,7 +91,10 @@ bool tunesTo(const ProgramSelector& a, const ProgramSelector& b) { return haveEqualIds(a, b, IdentifierType::SXM_SERVICE_ID); } return haveEqualIds(a, b, IdentifierType::SXM_CHANNEL); - case ProgramType::VENDOR: + case ProgramType::VENDOR1: + case ProgramType::VENDOR2: + case ProgramType::VENDOR3: + case ProgramType::VENDOR4: default: ALOGW("Unsupported program type: %s", toString(type).c_str()); return false; @@ -166,26 +168,31 @@ ProgramSelector make_selector(Band band, uint32_t channel, uint32_t subChannel) sel.primaryId.type = static_cast(IdentifierType::AMFM_FREQUENCY); sel.primaryId.value = channel; if (subChannel > 0) { - // stating sub channel for AM/FM channel does not give any guarantees, - // but we can't do much more without HD station ID + /* stating sub channel for AM/FM channel does not give any guarantees, + * but we can't do much more without HD station ID + * + * The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based. + */ sel.secondaryIds = hidl_vec{ - {static_cast(IdentifierType::HD_SUBCHANNEL), subChannel}, + {static_cast(IdentifierType::HD_SUBCHANNEL), subChannel - 1}, }; } return sel; } -bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut) { +bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut) { + if (channelOut) *channelOut = 0; + if (subChannelOut) *subChannelOut = 0; if (isAmFm(getType(sel))) { - channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY); - subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL, 0); + if (channelOut) *channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY); + if (subChannelOut && hasId(sel, IdentifierType::HD_SUBCHANNEL)) { + // The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based. + *subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL) + 1; + } return true; - } else { - channelOut = 0; - subChannelOut = 0; - return false; } + return false; } bool isDigital(const ProgramSelector& sel) { @@ -200,7 +207,6 @@ bool isDigital(const ProgramSelector& sel) { } } // namespace utils -} // namespace implementation } // namespace V1_1 } // namespace broadcastradio } // namespace hardware diff --git a/broadcastradio/1.1/utils/Utils.h b/broadcastradio/1.1/utils/Utils.h index 1110e79f..cd86ffaa 100644 --- a/broadcastradio/1.1/utils/Utils.h +++ b/broadcastradio/1.1/utils/Utils.h @@ -25,7 +25,6 @@ namespace android { namespace hardware { namespace broadcastradio { namespace V1_1 { -namespace implementation { namespace utils { /** @@ -61,12 +60,11 @@ uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t d ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0); -bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut); +bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut); bool isDigital(const ProgramSelector& sel); } // namespace utils -} // namespace implementation } // namespace V1_1 } // namespace broadcastradio } // namespace hardware diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp index 6e6ab44e..9e7c00bc 100644 --- a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp +++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp @@ -47,6 +47,7 @@ using testing::_; using testing::AnyNumber; using testing::ByMove; using testing::DoAll; +using testing::Invoke; using testing::SaveArg; using broadcastradio::vts::CallBarrier; @@ -63,14 +64,15 @@ static void printSkipped(std::string msg) { std::cout << "[ SKIPPED ] " << msg << std::endl; } -class TunerCallbackMock : public ITunerCallback { - public: +struct TunerCallbackMock : public ITunerCallback { + TunerCallbackMock() { EXPECT_CALL(*this, hardwareFailure()).Times(0); } + MOCK_METHOD0(hardwareFailure, Return()); MOCK_TIMEOUT_METHOD2(configChange, Return(Result, const BandConfig&)); MOCK_METHOD2(tuneComplete, Return(Result, const V1_0::ProgramInfo&)); - MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return(Result, const ProgramInfo&)); + MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return(Result, const ProgramSelector&)); MOCK_METHOD1(afSwitch, Return(const V1_0::ProgramInfo&)); - MOCK_METHOD1(afSwitch_1_1, Return(const ProgramInfo&)); + MOCK_METHOD1(afSwitch_1_1, Return(const ProgramSelector&)); MOCK_METHOD1(antennaStateChange, Return(bool connected)); MOCK_METHOD1(trafficAnnouncement, Return(bool active)); MOCK_METHOD1(emergencyAnnouncement, Return(bool active)); @@ -78,6 +80,7 @@ class TunerCallbackMock : public ITunerCallback { MOCK_METHOD1(backgroundScanAvailable, Return(bool)); MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return(ProgramListResult)); MOCK_METHOD0(programListChanged, Return()); + MOCK_METHOD0(programInfoChanged, Return()); }; class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase, @@ -105,9 +108,6 @@ class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase, void BroadcastRadioHalTest::SetUp() { radioClass = GetParam(); - // set general expectations for a callback - EXPECT_CALL(*mCallback, hardwareFailure()).Times(0); - // lookup HIDL service auto factory = getService(); ASSERT_NE(nullptr, factory.get()); @@ -139,6 +139,8 @@ void BroadcastRadioHalTest::SetUp() { ASSERT_TRUE(propResult.isOk()); EXPECT_EQ(radioClass, prop10.classId); EXPECT_GT(prop10.numTuners, 0u); + EXPECT_GT(prop11.supportedProgramTypes.size(), 0u); + EXPECT_GT(prop11.supportedIdentifierTypes.size(), 0u); if (radioClass == Class::AM_FM) { EXPECT_GT(prop10.bands.size(), 0u); } @@ -276,14 +278,22 @@ TEST_P(BroadcastRadioHalTest, TuneFromProgramList) { return; } - ProgramInfo infoCb; + ProgramSelector selCb; EXPECT_CALL(*mCallback, tuneComplete(_, _)); EXPECT_TIMEOUT_CALL(*mCallback, tuneComplete_1_1, Result::OK, _) - .WillOnce(DoAll(SaveArg<1>(&infoCb), testing::Return(ByMove(Void())))); + .WillOnce(DoAll(SaveArg<1>(&selCb), testing::Return(ByMove(Void())))); auto tuneResult = mTuner->tune_1_1(firstProgram.selector); ASSERT_EQ(Result::OK, tuneResult); EXPECT_TIMEOUT_CALL_WAIT(*mCallback, tuneComplete_1_1, kTuneTimeout); - EXPECT_EQ(firstProgram.selector.primaryId, infoCb.selector.primaryId); + EXPECT_EQ(firstProgram.selector.primaryId, selCb.primaryId); +} + +TEST_P(BroadcastRadioHalTest, CancelAnnouncement) { + if (skipped) return; + ASSERT_TRUE(openTuner(0)); + + auto hidlResult = mTuner->cancelAnnouncement(); + EXPECT_EQ(Result::OK, hidlResult); } INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest, diff --git a/current.txt b/current.txt index 2b57af99..e85920fa 100644 --- a/current.txt +++ b/current.txt @@ -220,4 +220,4 @@ bb7c96762d0aa3ddb874c8815bacdd3cbc8fb87ea2f82b928bc29e24a3593055 android.hardwar c3354ab0d381a236c12dc486ad4b6bec28c979d26748b4661f12ede36f392808 android.hardware.wifi.offload@1.0::IOffloadCallback b18caefefcc765092412285d776234fcf213b73bdf07ae1b67a5f71b2d2464e3 android.hardware.wifi.offload@1.0::types c26473e2e4a00af43e28a0ddf9002e5062a7d0940429e5efb6e5513a8abcb75c android.hardware.wifi@1.1::IWifi -48adfb7259e3816a82a4c394ffaf56fb14628a542295b7a51f1311392d3f8769 android.hardware.wifi@1.1::IWifiChip +bfcf4856c7b6c66ebc56785ed3e5d181b7be859c2add672497a843b024518737 android.hardware.wifi@1.1::IWifiChip diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp index 591861ae..fd75dbd3 100644 --- a/drm/1.0/default/CryptoPlugin.cpp +++ b/drm/1.0/default/CryptoPlugin.cpp @@ -51,7 +51,11 @@ namespace implementation { Return CryptoPlugin::setSharedBufferBase(const hidl_memory& base, uint32_t bufferId) { - mSharedBufferMap[bufferId] = mapMemory(base); + sp hidlMemory = mapMemory(base); + ALOGE_IF(hidlMemory == nullptr, "mapMemory returns nullptr"); + + // allow mapMemory to return nullptr + mSharedBufferMap[bufferId] = hidlMemory; return Void(); } @@ -107,6 +111,10 @@ namespace implementation { AString detailMessage; sp sourceBase = mSharedBufferMap[source.bufferId]; + if (sourceBase == nullptr) { + _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "source is a nullptr"); + return Void(); + } if (source.offset + offset + source.size > sourceBase->getSize()) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size"); @@ -121,6 +129,11 @@ namespace implementation { if (destination.type == BufferType::SHARED_MEMORY) { const SharedBuffer& destBuffer = destination.nonsecureMemory; sp destBase = mSharedBufferMap[destBuffer.bufferId]; + if (destBase == nullptr) { + _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "destination is a nullptr"); + return Void(); + } + if (destBuffer.offset + destBuffer.size > destBase->getSize()) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size"); return Void(); diff --git a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp index 26641e89..eeee3c0e 100644 --- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp +++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp @@ -94,10 +94,10 @@ class DrmHalClearkeyFactoryTest : public ::testing::VtsHalHidlTargetTestBase { drmFactory = ::testing::VtsHalHidlTargetTestBase::getService(); - ASSERT_NE(drmFactory, nullptr); + ASSERT_NE(nullptr, drmFactory.get()); cryptoFactory = ::testing::VtsHalHidlTargetTestBase::getService(); - ASSERT_NE(cryptoFactory, nullptr); + ASSERT_NE(nullptr, cryptoFactory.get()); } virtual void TearDown() override {} @@ -166,7 +166,7 @@ TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyDrmPlugin) { kClearKeyUUID, packageName, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - EXPECT_NE(plugin, nullptr); + EXPECT_NE(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -180,7 +180,7 @@ TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyCryptoPlugin) { kClearKeyUUID, initVec, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - EXPECT_NE(plugin, nullptr); + EXPECT_NE(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -194,7 +194,7 @@ TEST_F(DrmHalClearkeyFactoryTest, CreateInvalidDrmPlugin) { kInvalidUUID, packageName, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); - EXPECT_EQ(plugin, nullptr); + EXPECT_EQ(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -208,7 +208,7 @@ TEST_F(DrmHalClearkeyFactoryTest, CreateInvalidCryptoPlugin) { kInvalidUUID, initVec, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); - EXPECT_EQ(plugin, nullptr); + EXPECT_EQ(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -219,13 +219,13 @@ class DrmHalClearkeyPluginTest : public DrmHalClearkeyFactoryTest { // Create factories DrmHalClearkeyFactoryTest::SetUp(); - ASSERT_NE(drmFactory, nullptr); + ASSERT_NE(nullptr, drmFactory.get()); hidl_string packageName("android.hardware.drm.test"); auto res = drmFactory->createPlugin( kClearKeyUUID, packageName, [this](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - ASSERT_NE(plugin, nullptr); + ASSERT_NE(nullptr, plugin.get()); drmPlugin = plugin; }); ASSERT_OK(res); @@ -235,7 +235,7 @@ class DrmHalClearkeyPluginTest : public DrmHalClearkeyFactoryTest { kClearKeyUUID, initVec, [this](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - ASSERT_NE(plugin, nullptr); + ASSERT_NE(nullptr, plugin.get()); cryptoPlugin = plugin; }); ASSERT_OK(res); @@ -866,7 +866,7 @@ TEST_F(DrmHalClearkeyPluginTest, NotifyResolution) { sp DrmHalClearkeyPluginTest::getDecryptMemory(size_t size, size_t index) { sp ashmemAllocator = IAllocator::getService("ashmem"); - EXPECT_NE(ashmemAllocator, nullptr); + EXPECT_NE(nullptr, ashmemAllocator.get()); hidl_memory hidlMemory; auto res = ashmemAllocator->allocate( @@ -878,6 +878,7 @@ sp DrmHalClearkeyPluginTest::getDecryptMemory(size_t size, EXPECT_OK(res); sp mappedMemory = mapMemory(hidlMemory); + EXPECT_NE(nullptr, mappedMemory.get()); EXPECT_OK(cryptoPlugin->setSharedBufferBase(hidlMemory, index)); return mappedMemory; } diff --git a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp index 67b2c7d6..6ce465f3 100644 --- a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp +++ b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp @@ -113,7 +113,7 @@ class DrmHalVendorFactoryTest : public testing::TestWithParam { test_info->test_case_name(), test_info->name(), GetParam().c_str()); - ASSERT_NE(vendorModule, nullptr); + ASSERT_NE(nullptr, vendorModule.get()); // First try the binderized service name provided by the vendor module. // If that fails, which it can on non-binderized devices, try the default @@ -123,14 +123,14 @@ class DrmHalVendorFactoryTest : public testing::TestWithParam { if (drmFactory == nullptr) { drmFactory = VtsTestBase::getService(); } - ASSERT_NE(drmFactory, nullptr); + ASSERT_NE(nullptr, drmFactory.get()); // Do the same for the crypto factory cryptoFactory = VtsTestBase::getService(name); if (cryptoFactory == nullptr) { cryptoFactory = VtsTestBase::getService(); } - ASSERT_NE(cryptoFactory, nullptr); + ASSERT_NE(nullptr, cryptoFactory.get()); // If drm scheme not installed skip subsequent tests if (!drmFactory->isCryptoSchemeSupported(getVendorUUID())) { @@ -239,7 +239,7 @@ TEST_P(DrmHalVendorFactoryTest, CreateVendorDrmPlugin) { getVendorUUID(), packageName, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - EXPECT_NE(plugin, nullptr); + EXPECT_NE(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -254,7 +254,7 @@ TEST_P(DrmHalVendorFactoryTest, CreateVendorCryptoPlugin) { getVendorUUID(), initVec, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - EXPECT_NE(plugin, nullptr); + EXPECT_NE(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -269,7 +269,7 @@ TEST_P(DrmHalVendorFactoryTest, CreateInvalidDrmPlugin) { kInvalidUUID, packageName, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); - EXPECT_EQ(plugin, nullptr); + EXPECT_EQ(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -284,7 +284,7 @@ TEST_P(DrmHalVendorFactoryTest, CreateInvalidCryptoPlugin) { kInvalidUUID, initVec, [&](Status status, const sp& plugin) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); - EXPECT_EQ(plugin, nullptr); + EXPECT_EQ(nullptr, plugin.get()); }); EXPECT_OK(res); } @@ -302,7 +302,7 @@ class DrmHalVendorPluginTest : public DrmHalVendorFactoryTest { getVendorUUID(), packageName, [this](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - ASSERT_NE(plugin, nullptr); + ASSERT_NE(nullptr, plugin.get()); drmPlugin = plugin; }); ASSERT_OK(res); @@ -312,7 +312,7 @@ class DrmHalVendorPluginTest : public DrmHalVendorFactoryTest { getVendorUUID(), initVec, [this](Status status, const sp& plugin) { EXPECT_EQ(Status::OK, status); - ASSERT_NE(plugin, nullptr); + ASSERT_NE(nullptr, plugin.get()); cryptoPlugin = plugin; }); ASSERT_OK(res); @@ -1185,7 +1185,7 @@ TEST_P(DrmHalVendorPluginTest, NotifyResolution) { sp DrmHalVendorPluginTest::getDecryptMemory(size_t size, size_t index) { sp ashmemAllocator = IAllocator::getService("ashmem"); - EXPECT_NE(ashmemAllocator, nullptr); + EXPECT_NE(nullptr, ashmemAllocator.get()); hidl_memory hidlMemory; auto res = ashmemAllocator->allocate( @@ -1198,7 +1198,7 @@ sp DrmHalVendorPluginTest::getDecryptMemory(size_t size, EXPECT_OK(res); sp mappedMemory = mapMemory(hidlMemory); - EXPECT_NE(mappedMemory, nullptr); + EXPECT_NE(nullptr, mappedMemory.get()); res = cryptoPlugin->setSharedBufferBase(hidlMemory, index); EXPECT_OK(res); return mappedMemory; diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp index 336cab48..6790ebfc 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp @@ -588,12 +588,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, AudioDecHidlTest::standardComp comp) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { EXPECT_EQ(msg.type, Message::Type::EVENT); packedArgs audioArgs = {eEncoding, comp}; @@ -613,8 +613,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -654,11 +654,12 @@ void decodeNFrames(sp omxNode, sp observer, frameID++; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); // Port Reconfiguration if (status == android::hardware::media::omx::V1_0::Status::OK && @@ -688,18 +689,16 @@ void decodeNFrames(sp omxNode, sp observer, (*Info)[frameID].bytesCount, flags, (*Info)[frameID].timestamp); frameID++; - stall = false; - } else - stall = true; + iQueued = true; + } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; @@ -1149,9 +1148,8 @@ TEST_F(AudioDecHidlTest, FlushTest) { decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, nFrames, compName, false); - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // Seek to next key frame and start decoding till the end @@ -1172,9 +1170,8 @@ TEST_F(AudioDecHidlTest, FlushTest) { kPortIndexInput, kPortIndexOutput, eleStream, &Info, index, Info.size() - index, compName, false); } - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // set state to idle diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp index ae79e826..038830dc 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp @@ -342,12 +342,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, android::Vector* oBuffer) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); EXPECT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); // status == TIMED_OUT, it could be due to process time being large @@ -362,8 +362,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -400,11 +400,12 @@ void encodeNFrames(sp omxNode, sp observer, nFrames--; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) ASSERT_TRUE(false); @@ -425,19 +426,17 @@ void encodeNFrames(sp omxNode, sp observer, timestamp); timestamp += timestampIncr; nFrames--; - stall = false; - } else - stall = true; + iQueued = true; + } // Dispatch output buffer if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp index 1863972e..a890c4f4 100755 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp @@ -532,7 +532,7 @@ void testEOS(sp omxNode, sp observer, } } - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_PE; while (timeOut--) { // Dispatch all client owned output buffers to recover remaining frames while (1) { @@ -541,15 +541,15 @@ void testEOS(sp omxNode, sp observer, // if dispatch is successful, perhaps there is a latency // in the component. Dont be in a haste to leave. reset timeout // counter - timeOut = TIMEOUT_COUNTER; + timeOut = TIMEOUT_COUNTER_PE; } else { break; } } Message msg; - status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, iBuffer, + oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { if (fptr) { diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h index 95e32fa1..802f4d60 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h @@ -33,8 +33,21 @@ #include #include +/* TIME OUTS (Wait time in dequeueMessage()) */ + +/* As component is switching states (loaded<->idle<->execute), dequeueMessage() + * expects the events to be received within this duration */ #define DEFAULT_TIMEOUT 100000 -#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT) +/* Time interval between successive Input/Output enqueues */ +#define DEFAULT_TIMEOUT_Q 2000 +/* While the component is amidst a process call, asynchronous commands like + * flush, change states can get delayed (at max by process call time). Instead + * of waiting on DEFAULT_TIMEOUT, we give an additional leeway. */ +#define DEFAULT_TIMEOUT_PE 500000 + +/* Breakout Timeout :: 5 sec*/ +#define TIMEOUT_COUNTER_Q (5000000 / DEFAULT_TIMEOUT_Q) +#define TIMEOUT_COUNTER_PE (5000000 / DEFAULT_TIMEOUT_PE) /* * Random Index used for monkey testing while get/set parameters @@ -310,7 +323,8 @@ void dispatchInputBuffer(sp omxNode, void flushPorts(sp omxNode, sp observer, android::Vector* iBuffer, android::Vector* oBuffer, OMX_U32 kPortIndexInput, - OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT); + OMX_U32 kPortIndexOutput, + int64_t timeoutUs = DEFAULT_TIMEOUT_PE); typedef void (*portreconfig)(sp omxNode, sp observer, android::Vector* iBuffer, diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp index 12b1355f..a9c29c73 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp @@ -604,12 +604,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, PortMode oPortMode) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { EXPECT_EQ(msg.type, Message::Type::EVENT); portReconfiguration(omxNode, observer, iBuffer, oBuffer, @@ -628,8 +628,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -669,11 +669,12 @@ void decodeNFrames(sp omxNode, sp observer, frameID++; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); // Port Reconfiguration if (status == android::hardware::media::omx::V1_0::Status::OK && @@ -702,18 +703,16 @@ void decodeNFrames(sp omxNode, sp observer, (*Info)[frameID].bytesCount, flags, (*Info)[frameID].timestamp); frameID++; - stall = false; - } else - stall = true; + iQueued = true; + } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; @@ -1165,9 +1164,8 @@ TEST_F(VideoDecHidlTest, FlushTest) { decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1], false); - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // Seek to next key frame and start decoding till the end @@ -1188,9 +1186,8 @@ TEST_F(VideoDecHidlTest, FlushTest) { kPortIndexOutput, eleStream, &Info, index, Info.size() - index, portMode[1], false); } - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // set state to idle diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index a1ed21ae..f4a4e9bf 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp @@ -612,12 +612,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, sp listener = nullptr) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); EXPECT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); // status == TIMED_OUT, it could be due to process time being large @@ -636,6 +636,7 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } } } @@ -1027,11 +1028,12 @@ void encodeNFrames(sp omxNode, sp observer, } } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { ASSERT_EQ(msg.type, Message::Type::EVENT); @@ -1062,9 +1064,7 @@ void encodeNFrames(sp omxNode, sp observer, timestamp += timestampIncr; nFrames--; ipCount++; - stall = false; - } else { - stall = true; + iQueued = true; } } else { if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { @@ -1083,20 +1083,17 @@ void encodeNFrames(sp omxNode, sp observer, timestamp += timestampIncr; nFrames--; ipCount++; - stall = false; - } else { - stall = true; + iQueued = true; } } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h index e6a61d4a..55de1258 100644 --- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h @@ -17,7 +17,6 @@ #ifndef MEDIA_VIDEO_HIDL_TEST_COMMON_H #define MEDIA_VIDEO_HIDL_TEST_COMMON_H - /* * Common video utils */ diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp index 2a9607be..82d34a95 100644 --- a/tests/bar/1.0/default/Android.bp +++ b/tests/bar/1.0/default/Android.bp @@ -4,7 +4,6 @@ cc_library_shared { name: "android.hardware.tests.bar@1.0-impl", defaults: ["hidl_defaults"], relative_install_path: "hw", - proprietary: true, srcs: [ "Bar.cpp", "ImportTypes.cpp", diff --git a/tests/baz/1.0/default/Android.bp b/tests/baz/1.0/default/Android.bp index ef1c28e4..f247b837 100644 --- a/tests/baz/1.0/default/Android.bp +++ b/tests/baz/1.0/default/Android.bp @@ -2,7 +2,6 @@ cc_library_shared { name: "android.hardware.tests.baz@1.0-impl", defaults: ["hidl_defaults"], relative_install_path: "hw", - proprietary: true, srcs: [ "Baz.cpp", ], diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp index f8acf9db..0e1d34d3 100644 --- a/tests/foo/1.0/default/Android.bp +++ b/tests/foo/1.0/default/Android.bp @@ -4,7 +4,6 @@ cc_library_shared { name: "android.hardware.tests.foo@1.0-impl", defaults: ["hidl_defaults"], relative_install_path: "hw", - proprietary: true, srcs: [ "Foo.cpp", ], diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp index b512311a..895582c5 100644 --- a/tests/foo/1.0/default/lib/Android.bp +++ b/tests/foo/1.0/default/lib/Android.bp @@ -1,6 +1,5 @@ cc_library_shared { name: "libfootest", - vendor: true, defaults: ["hidl_defaults"], srcs: [ "FooHelper.cpp" diff --git a/tests/hash/1.0/default/Android.bp b/tests/hash/1.0/default/Android.bp index d6e96303..ae44876c 100644 --- a/tests/hash/1.0/default/Android.bp +++ b/tests/hash/1.0/default/Android.bp @@ -1,7 +1,6 @@ cc_library_shared { name: "android.hardware.tests.hash@1.0-impl", relative_install_path: "hw", - proprietary: true, srcs: [ "Hash.cpp", ], diff --git a/tests/inheritance/1.0/default/Android.bp b/tests/inheritance/1.0/default/Android.bp index f6ca88a0..158da4b1 100644 --- a/tests/inheritance/1.0/default/Android.bp +++ b/tests/inheritance/1.0/default/Android.bp @@ -4,7 +4,6 @@ cc_library_shared { name: "android.hardware.tests.inheritance@1.0-impl", defaults: ["hidl_defaults"], relative_install_path: "hw", - proprietary: true, srcs: [ "Fetcher.cpp", "Parent.cpp", diff --git a/tests/memory/1.0/default/Android.bp b/tests/memory/1.0/default/Android.bp index e889bd8b..efd41650 100644 --- a/tests/memory/1.0/default/Android.bp +++ b/tests/memory/1.0/default/Android.bp @@ -15,7 +15,6 @@ cc_library_shared { name: "android.hardware.tests.memory@1.0-impl", defaults: ["hidl_defaults"], - proprietary: true, relative_install_path: "hw", srcs: [ "MemoryTest.cpp", diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp index 4615463c..0c91edb1 100644 --- a/tests/pointer/1.0/default/Android.bp +++ b/tests/pointer/1.0/default/Android.bp @@ -4,7 +4,6 @@ cc_library_shared { name: "android.hardware.tests.pointer@1.0-impl", defaults: ["hidl_defaults"], relative_install_path: "hw", - proprietary: true, srcs: [ "Graph.cpp", "Pointer.cpp", diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp index 1fe0896f..ae07b046 100644 --- a/tests/pointer/1.0/default/lib/Android.bp +++ b/tests/pointer/1.0/default/lib/Android.bp @@ -1,6 +1,5 @@ cc_library_shared { name: "libpointertest", - vendor: true, defaults: ["hidl_defaults"], srcs: [ "PointerHelper.cpp" diff --git a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp index 160fcd23..beac0398 100644 --- a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp +++ b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp @@ -20,10 +20,16 @@ #include "wifi_hidl_test_utils.h" +WifiHidlEnvironment* gEnv; + int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(new WifiHidlEnvironment); + gEnv = new WifiHidlEnvironment(); + ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; + int status = gEnv->initFromOptions(argc, argv); + if (status == 0) { + status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + } return status; } diff --git a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp index 6c2372f8..06e21ff4 100644 --- a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp +++ b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp @@ -42,6 +42,8 @@ using ::android::hardware::wifi::V1_0::IWifiP2pIface; using ::android::hardware::wifi::V1_0::IWifiRttController; using ::android::hardware::wifi::V1_0::IWifiStaIface; +extern WifiHidlEnvironment* gEnv; + namespace { constexpr WifiDebugRingBufferVerboseLevel kDebugRingBufferVerboseLvl = WifiDebugRingBufferVerboseLevel::VERBOSE; @@ -78,7 +80,8 @@ class WifiChipHidlTest : public ::testing::VtsHalHidlTargetTestBase { // to be first configured. ChipModeId configureChipForIfaceType(IfaceType type, bool expectSuccess) { ChipModeId mode_id; - EXPECT_EQ(expectSuccess, configureChipToSupportIfaceType(wifi_chip_, type, &mode_id)); + EXPECT_EQ(expectSuccess, + configureChipToSupportIfaceType(wifi_chip_, type, &mode_id)); return mode_id; } @@ -436,10 +439,14 @@ TEST_F(WifiChipHidlTest, RemoveApIface) { * succeeds. The 2nd iface creation should be rejected. */ TEST_F(WifiChipHidlTest, CreateNanIface) { - configureChipForIfaceType(IfaceType::NAN, false); + configureChipForIfaceType(IfaceType::NAN, gEnv->isNanOn); + if (!gEnv->isNanOn) return; sp iface; - ASSERT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&iface)); + ASSERT_EQ(WifiStatusCode::SUCCESS, createNanIface(&iface)); + EXPECT_NE(nullptr, iface.get()); + + EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&iface)); } /* @@ -449,12 +456,30 @@ TEST_F(WifiChipHidlTest, CreateNanIface) { * iface name is returned via the list. */ TEST_F(WifiChipHidlTest, GetNanIfaceNames) { - configureChipForIfaceType(IfaceType::NAN, false); + configureChipForIfaceType(IfaceType::NAN, gEnv->isNanOn); + if (!gEnv->isNanOn) return; const auto& status_and_iface_names1 = HIDL_INVOKE(wifi_chip_, getNanIfaceNames); ASSERT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names1.first.code); EXPECT_EQ(0u, status_and_iface_names1.second.size()); + + sp iface; + EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&iface)); + EXPECT_NE(nullptr, iface.get()); + + std::string iface_name = getIfaceName(iface); + const auto& status_and_iface_names2 = + HIDL_INVOKE(wifi_chip_, getNanIfaceNames); + EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names2.first.code); + EXPECT_EQ(1u, status_and_iface_names2.second.size()); + EXPECT_EQ(iface_name, status_and_iface_names2.second[0]); + + EXPECT_EQ(WifiStatusCode::SUCCESS, removeNanIface(iface_name)); + const auto& status_and_iface_names3 = + HIDL_INVOKE(wifi_chip_, getNanIfaceNames); + EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names3.first.code); + EXPECT_EQ(0u, status_and_iface_names3.second.size()); } /* @@ -464,10 +489,24 @@ TEST_F(WifiChipHidlTest, GetNanIfaceNames) { * doesn't retrieve an iface object. */ TEST_F(WifiChipHidlTest, GetNanIface) { - configureChipForIfaceType(IfaceType::NAN, false); + configureChipForIfaceType(IfaceType::NAN, gEnv->isNanOn); + if (!gEnv->isNanOn) return; sp nan_iface; - ASSERT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&nan_iface)); + EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&nan_iface)); + EXPECT_NE(nullptr, nan_iface.get()); + + std::string iface_name = getIfaceName(nan_iface); + const auto& status_and_iface1 = + HIDL_INVOKE(wifi_chip_, getNanIface, iface_name); + EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface1.first.code); + EXPECT_NE(nullptr, status_and_iface1.second.get()); + + std::string invalid_name = iface_name + "0"; + const auto& status_and_iface2 = + HIDL_INVOKE(wifi_chip_, getNanIface, invalid_name); + EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, status_and_iface2.first.code); + EXPECT_EQ(nullptr, status_and_iface2.second.get()); } /* @@ -477,10 +516,21 @@ TEST_F(WifiChipHidlTest, GetNanIface) { * doesn't remove the iface. */ TEST_F(WifiChipHidlTest, RemoveNanIface) { - configureChipForIfaceType(IfaceType::NAN, false); + configureChipForIfaceType(IfaceType::NAN, gEnv->isNanOn); + if (!gEnv->isNanOn) return; sp nan_iface; - ASSERT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&nan_iface)); + EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&nan_iface)); + EXPECT_NE(nullptr, nan_iface.get()); + + std::string iface_name = getIfaceName(nan_iface); + std::string invalid_name = iface_name + "0"; + EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeNanIface(invalid_name)); + + EXPECT_EQ(WifiStatusCode::SUCCESS, removeNanIface(iface_name)); + + // No such iface exists now. So, this should return failure. + EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeNanIface(iface_name)); } /* diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h index 39a0ebaf..c4a19ddf 100644 --- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h +++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h @@ -24,6 +24,8 @@ #include #include +#include + // Helper functions to obtain references to the various HIDL interface objects. // Note: We only have a single instance of each of these objects currently. // These helper functions should be modified to return vectors if we support @@ -46,10 +48,46 @@ bool configureChipToSupportIfaceType( void stopWifi(); class WifiHidlEnvironment : public ::testing::Environment { - public: - virtual void SetUp() override { - stopWifi(); - sleep(5); - } - virtual void TearDown() override {} -}; \ No newline at end of file + protected: + virtual void SetUp() override { + stopWifi(); + sleep(5); + } + + public: + // Whether NaN feature is supported on the device. + bool isNanOn = false; + + void usage(char* me, char* arg) { + fprintf(stderr, + "unrecognized option: %s\n\n" + "usage: %s \n\n" + "test options are:\n\n" + "-N, --nan_on: Whether NAN feature is supported\n", + arg, me); + } + + int initFromOptions(int argc, char** argv) { + static struct option options[] = {{"nan_on", no_argument, 0, 'N'}, + {0, 0, 0, 0}}; + + int c; + while ((c = getopt_long(argc, argv, "N", options, NULL)) >= 0) { + switch (c) { + case 'N': + isNanOn = true; + break; + default: + usage(argv[0], argv[optind]); + return 2; + } + } + + if (optind < argc) { + usage(argv[0], argv[optind]); + return 2; + } + + return 0; + } +}; diff --git a/wifi/1.1/IWifiChip.hal b/wifi/1.1/IWifiChip.hal index 72754128..50cd02dd 100644 --- a/wifi/1.1/IWifiChip.hal +++ b/wifi/1.1/IWifiChip.hal @@ -32,7 +32,15 @@ interface IWifiChip extends @1.0::IWifiChip { /** * Set/Reset Tx Power limits. */ - SET_TX_POWER_LIMIT = 1 << 8 + SET_TX_POWER_LIMIT = 1 << 8, + /** + * Device to Device RTT. + */ + D2D_RTT = 1 << 9, + /** + * Device to AP RTT. + */ + D2AP_RTT = 1 << 10 }; /** diff --git a/wifi/1.1/default/hidl_struct_util.cpp b/wifi/1.1/default/hidl_struct_util.cpp index a413cbb3..6b93b9ef 100644 --- a/wifi/1.1/default/hidl_struct_util.cpp +++ b/wifi/1.1/default/hidl_struct_util.cpp @@ -75,6 +75,10 @@ V1_1::IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability( switch (feature) { case WIFI_FEATURE_SET_TX_POWER_LIMIT: return HidlChipCaps::SET_TX_POWER_LIMIT; + case WIFI_FEATURE_D2D_RTT: + return HidlChipCaps::D2D_RTT; + case WIFI_FEATURE_D2AP_RTT: + return HidlChipCaps::D2AP_RTT; }; CHECK(false) << "Unknown legacy feature: " << feature; return {}; @@ -133,7 +137,9 @@ bool convertLegacyFeaturesToHidlChipCapabilities( *hidl_caps |= convertLegacyLoggerFeatureToHidlChipCapability(feature); } } - for (const auto feature : {WIFI_FEATURE_SET_TX_POWER_LIMIT}) { + for (const auto feature : {WIFI_FEATURE_SET_TX_POWER_LIMIT, + WIFI_FEATURE_D2D_RTT, + WIFI_FEATURE_D2AP_RTT}) { if (feature & legacy_feature_set) { *hidl_caps |= convertLegacyFeatureToHidlChipCapability(feature); } diff --git a/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp b/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp index 160fcd23..9b92b57e 100644 --- a/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp +++ b/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp @@ -20,10 +20,16 @@ #include "wifi_hidl_test_utils.h" +WifiHidlEnvironment* gEnv; + int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(new WifiHidlEnvironment); + gEnv = new WifiHidlEnvironment(); + ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; + int status = gEnv->initFromOptions(argc, argv); + if (status == 0) { + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + } return status; }