OSDN Git Service

release-request-bd6aa7dd-7b02-4794-942c-14599bf61208-for-git_oc-mr1-release-4193791...
authorandroid-build-team Robot <android-build-team-robot@google.com>
Wed, 19 Jul 2017 07:24:36 +0000 (07:24 +0000)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Wed, 19 Jul 2017 07:24:36 +0000 (07:24 +0000)
Change-Id: Ib931cb810771edc7355e926d5b19b14fed626d7c

37 files changed:
broadcastradio/1.1/ITuner.hal
broadcastradio/1.1/ITunerCallback.hal
broadcastradio/1.1/default/BroadcastRadio.cpp
broadcastradio/1.1/default/Tuner.cpp
broadcastradio/1.1/default/Tuner.h
broadcastradio/1.1/default/VirtualProgram.cpp
broadcastradio/1.1/types.hal
broadcastradio/1.1/utils/Android.bp
broadcastradio/1.1/utils/Utils.cpp
broadcastradio/1.1/utils/Utils.h
broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
current.txt
drm/1.0/default/CryptoPlugin.cpp
drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
drm/1.0/vts/functional/drm_hal_vendor_test.cpp
media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
media/omx/1.0/vts/functional/common/media_hidl_test_common.h
media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
tests/bar/1.0/default/Android.bp
tests/baz/1.0/default/Android.bp
tests/foo/1.0/default/Android.bp
tests/foo/1.0/default/lib/Android.bp
tests/hash/1.0/default/Android.bp
tests/inheritance/1.0/default/Android.bp
tests/memory/1.0/default/Android.bp
tests/pointer/1.0/default/Android.bp
tests/pointer/1.0/default/lib/Android.bp
wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
wifi/1.0/vts/functional/wifi_hidl_test_utils.h
wifi/1.1/IWifiChip.hal
wifi/1.1/default/hidl_struct_util.cpp
wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp

index 912786a..a5c569a 100644 (file)
@@ -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
index 158e217..b1c5b01 100644 (file)
@@ -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();
 };
index 1119ffd..297dcc1 100644 (file)
@@ -89,6 +89,16 @@ Return<void> BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) {
     prop10.numAudioSources = 1;
     prop10.supportsCapture = false;
     prop11.supportsBackgroundScanning = false;
+    prop11.supportedProgramTypes = vector<uint32_t>({
+        static_cast<uint32_t>(ProgramType::AM), static_cast<uint32_t>(ProgramType::FM),
+        static_cast<uint32_t>(ProgramType::AM_HD), static_cast<uint32_t>(ProgramType::FM_HD),
+    });
+    prop11.supportedIdentifierTypes = vector<uint32_t>({
+        static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY),
+        static_cast<uint32_t>(IdentifierType::RDS_PI),
+        static_cast<uint32_t>(IdentifierType::HD_STATION_ID_EXT),
+        static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL),
+    });
     prop11.vendorExension = "dummy";
 
     prop10.bands.resize(mConfig.amFmBands.size());
index a36ec3f..271f633 100644 (file)
@@ -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<Result> 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<Result> Tuner::cancel() {
     return Result::OK;
 }
 
+Return<Result> Tuner::cancelAnnouncement() {
+    ALOGV("%s", __func__);
+    return Result::OK;
+}
+
 Return<void> Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb) {
     ALOGV("%s", __func__);
     return getProgramInformation_1_1([&](Result result, const ProgramInfo& info) {
index 5c8a7e5..2ab4f40 100644 (file)
@@ -34,19 +34,21 @@ struct Tuner : public ITuner {
     void forceClose();
 
     // V1_1::ITuner methods
-    Return<Result> setConfiguration(const V1_0::BandConfig& config) override;
-    Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
-    Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override;
-    Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override;
-    Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
-    Return<Result> tune_1_1(const ProgramSelector& program) override;
-    Return<Result> cancel() override;
-    Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
-    Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
-    Return<ProgramListResult> startBackgroundScan() override;
-    Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
-    Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
-    Return<Result> setAnalogForced(bool isForced) override;
+    virtual Return<Result> setConfiguration(const V1_0::BandConfig& config) override;
+    virtual Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
+    virtual Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override;
+    virtual Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override;
+    virtual Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
+    virtual Return<Result> tune_1_1(const ProgramSelector& program) override;
+    virtual Return<Result> cancel() override;
+    virtual Return<Result> cancelAnnouncement() override;
+    virtual Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
+    virtual Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
+    virtual Return<ProgramListResult> startBackgroundScan() override;
+    virtual Return<void> getProgramList(const hidl_string& filter,
+                                        getProgramList_cb _hidl_cb) override;
+    virtual Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
+    virtual Return<Result> setAnalogForced(bool isForced) override;
 
    private:
     std::mutex mMut;
index ef8bd1c..babf0d8 100644 (file)
@@ -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;
index dee38b8..356c299 100644 (file)
@@ -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<uint32_t> 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<uint32_t> 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,
 };
 
 /**
index df5e8e0..73c6680 100644 (file)
@@ -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",
index 9dc0a53..f8a4479 100644 (file)
@@ -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<uint32_t>(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<ProgramIdentifier>{
-            {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel},
+            {static_cast<uint32_t>(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
index 1110e79..cd86ffa 100644 (file)
@@ -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
index 6e6ab44..9e7c00b 100644 (file)
@@ -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<void>());
     MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&));
     MOCK_METHOD2(tuneComplete, Return<void>(Result, const V1_0::ProgramInfo&));
-    MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return<void>(Result, const ProgramInfo&));
+    MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return<void>(Result, const ProgramSelector&));
     MOCK_METHOD1(afSwitch, Return<void>(const V1_0::ProgramInfo&));
-    MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramInfo&));
+    MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramSelector&));
     MOCK_METHOD1(antennaStateChange, Return<void>(bool connected));
     MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active));
     MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active));
@@ -78,6 +80,7 @@ class TunerCallbackMock : public ITunerCallback {
     MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool));
     MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult));
     MOCK_METHOD0(programListChanged, Return<void>());
+    MOCK_METHOD0(programInfoChanged, Return<void>());
 };
 
 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<IBroadcastRadioFactory>();
     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,
index 2b57af9..e85920f 100644 (file)
@@ -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
index 591861a..fd75dbd 100644 (file)
@@ -51,7 +51,11 @@ namespace implementation {
 
     Return<void> CryptoPlugin::setSharedBufferBase(const hidl_memory& base,
             uint32_t bufferId) {
-        mSharedBufferMap[bufferId] = mapMemory(base);
+        sp<IMemory> 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<IMemory> 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<IMemory> 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();
index 26641e8..eeee3c0 100644 (file)
@@ -94,10 +94,10 @@ class DrmHalClearkeyFactoryTest : public ::testing::VtsHalHidlTargetTestBase {
 
         drmFactory =
                 ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>();
-        ASSERT_NE(drmFactory, nullptr);
+        ASSERT_NE(nullptr, drmFactory.get());
         cryptoFactory =
                 ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>();
-        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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IMemory> DrmHalClearkeyPluginTest::getDecryptMemory(size_t size,
                                                        size_t index) {
     sp<IAllocator> 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<IMemory> DrmHalClearkeyPluginTest::getDecryptMemory(size_t size,
     EXPECT_OK(res);
 
     sp<IMemory> mappedMemory = mapMemory(hidlMemory);
+    EXPECT_NE(nullptr, mappedMemory.get());
     EXPECT_OK(cryptoPlugin->setSharedBufferBase(hidlMemory, index));
     return mappedMemory;
 }
index 67b2c7d..6ce465f 100644 (file)
@@ -113,7 +113,7 @@ class DrmHalVendorFactoryTest : public testing::TestWithParam<std::string> {
               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<std::string> {
         if (drmFactory == nullptr) {
             drmFactory = VtsTestBase::getService<IDrmFactory>();
         }
-        ASSERT_NE(drmFactory, nullptr);
+        ASSERT_NE(nullptr, drmFactory.get());
 
         // Do the same for the crypto factory
         cryptoFactory = VtsTestBase::getService<ICryptoFactory>(name);
         if (cryptoFactory == nullptr) {
             cryptoFactory = VtsTestBase::getService<ICryptoFactory>();
         }
-        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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IDrmPlugin>& 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<ICryptoPlugin>& 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<IMemory> DrmHalVendorPluginTest::getDecryptMemory(size_t size,
                                                      size_t index) {
     sp<IAllocator> 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<IMemory> DrmHalVendorPluginTest::getDecryptMemory(size_t size,
     EXPECT_OK(res);
 
     sp<IMemory> mappedMemory = mapMemory(hidlMemory);
-    EXPECT_NE(mappedMemory, nullptr);
+    EXPECT_NE(nullptr, mappedMemory.get());
     res = cryptoPlugin->setSharedBufferBase(hidlMemory, index);
     EXPECT_OK(res);
     return mappedMemory;
index 336cab4..6790ebf 100644 (file)
@@ -588,12 +588,12 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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
index ae79e82..038830d 100644 (file)
@@ -342,12 +342,12 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                             android::Vector<BufferInfo>* 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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;
index 1863972..a890c4f 100755 (executable)
@@ -532,7 +532,7 @@ void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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) {
index 95e32fa..802f4d6 100644 (file)
 #include <media/openmax/OMX_AudioExt.h>
 #include <media/openmax/OMX_VideoExt.h>
 
+/* 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<IOmxNode> omxNode,
 void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                 android::Vector<BufferInfo>* iBuffer,
                 android::Vector<BufferInfo>* 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<IOmxNode> omxNode, sp<CodecObserver> observer,
                              android::Vector<BufferInfo>* iBuffer,
index 12b1355..a9c29c7 100644 (file)
@@ -604,12 +604,12 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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
index a1ed21a..f4a4e9b 100644 (file)
@@ -612,12 +612,12 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                             sp<CodecProducerListener> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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<IOmxNode> omxNode, sp<CodecObserver> 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;
index 2a9607b..82d34a9 100644 (file)
@@ -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",
index ef1c28e..f247b83 100644 (file)
@@ -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",
     ],
index f8acf9d..0e1d34d 100644 (file)
@@ -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",
     ],
index b512311..895582c 100644 (file)
@@ -1,6 +1,5 @@
 cc_library_shared {
     name: "libfootest",
-    vendor: true,
     defaults: ["hidl_defaults"],
     srcs: [
         "FooHelper.cpp"
index d6e9630..ae44876 100644 (file)
@@ -1,7 +1,6 @@
 cc_library_shared {
     name: "android.hardware.tests.hash@1.0-impl",
     relative_install_path: "hw",
-    proprietary: true,
     srcs: [
         "Hash.cpp",
     ],
index f6ca88a..158da4b 100644 (file)
@@ -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",
index e889bd8..efd4165 100644 (file)
@@ -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",
index 4615463..0c91edb 100644 (file)
@@ -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",
index 1fe0896..ae07b04 100644 (file)
@@ -1,6 +1,5 @@
 cc_library_shared {
     name: "libpointertest",
-    vendor: true,
     defaults: ["hidl_defaults"],
     srcs: [
         "PointerHelper.cpp"
index 160fcd2..beac039 100644 (file)
 
 #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;
 }
index 6c2372f..06e21ff 100644 (file)
@@ -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<IWifiNanIface> 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<IWifiNanIface> 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<IWifiNanIface> 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<IWifiNanIface> 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));
 }
 
 /*
index 39a0eba..c4a19dd 100644 (file)
@@ -24,6 +24,8 @@
 #include <android/hardware/wifi/1.0/IWifiRttController.h>
 #include <android/hardware/wifi/1.0/IWifiStaIface.h>
 
+#include <getopt.h>
+
 // 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 <gtest options> <test options>\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;
+    }
+};
index 7275412..50cd02d 100644 (file)
@@ -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
   };
 
   /**
index a413cbb..6b93b9e 100644 (file)
@@ -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);
     }
index 160fcd2..9b92b57 100644 (file)
 
 #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;
 }