Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e9c3de6 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-2950741e-0b24-4d70-b748-67bb2b5435b5-for-git_oc-mr1-release-43...

release-request-2950741e-0b24-4d70-b748-67bb2b5435b5-for-git_oc-mr1-release-4357583 snap-temp-L55500000105655441

Change-Id: Ib6a647f37d4cad0b74b266ec12c979b9a8f6bd51
parents a16eb0a5 e9a134b8
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "VtsHalCasV1_0TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: ["VtsHalCasV1_0TargetTest.cpp"],
    static_libs: ["android.hardware.cas@1.0"],
}
+147 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "mediacas_hidl_hal_test"

#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <android/hardware/cas/1.0/ICas.h>
#include <android/hardware/cas/1.0/ICasListener.h>
#include <android/hardware/cas/1.0/IDescramblerBase.h>
#include <android/hardware/cas/1.0/IMediaCasService.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>

#include <cinttypes>
#include <utility>

// CA System Ids used for testing
#define CLEAR_KEY_SYSTEM_ID 0xF6D8
#define INVALID_SYSTEM_ID 0

using android::Condition;
using android::hardware::cas::V1_0::ICas;
using android::hardware::cas::V1_0::ICasListener;
using android::hardware::cas::V1_0::IDescramblerBase;
using android::hardware::cas::V1_0::IMediaCasService;
using android::hardware::cas::V1_0::HidlCasPluginDescriptor;
using android::hardware::Void;
using android::hardware::hidl_vec;
using android::hardware::Return;
using android::Mutex;
using android::sp;

namespace {

class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
   public:
    virtual void SetUp() override {
        mService = ::testing::VtsHalHidlTargetTestBase::getService<IMediaCasService>();
        ASSERT_NE(mService, nullptr);
    }

    sp<IMediaCasService> mService;

   protected:
    static void description(const std::string& description) {
        RecordProperty("description", description);
    }
};

class MediaCasListener : public ICasListener {
   public:
    virtual ::android::hardware::Return<void> onEvent(
        int32_t event, int32_t arg, const ::android::hardware::hidl_vec<uint8_t>& data) override {
        ALOGI("Info: received event: %d, arg: %d, size: %zu", event, arg, data.size());

        return Void();
    }
};

TEST_F(MediaCasHidlTest, EnumeratePlugins) {
    description("Test enumerate plugins");
    hidl_vec<HidlCasPluginDescriptor> descriptors;
    EXPECT_TRUE(mService
                    ->enumeratePlugins([&descriptors](
                        hidl_vec<HidlCasPluginDescriptor> const& desc) { descriptors = desc; })
                    .isOk());

    if (descriptors.size() == 0) {
        ALOGW("[   WARN   ] enumeratePlugins list empty");
        return;
    }

    sp<MediaCasListener> casListener = new MediaCasListener();
    for (size_t i = 0; i < descriptors.size(); i++) {
        int32_t caSystemId = descriptors[i].caSystemId;
        bool status = mService->isSystemIdSupported(caSystemId);
        ASSERT_EQ(status, true);

        status = mService->isDescramblerSupported(caSystemId);
        ASSERT_EQ(status, true);

        sp<ICas> mediaCas = mService->createPlugin(caSystemId, casListener);
        ASSERT_NE(mediaCas, nullptr);

        sp<IDescramblerBase> descramblerBase = mService->createDescrambler(caSystemId);
        ASSERT_NE(descramblerBase, nullptr);
    }
}

TEST_F(MediaCasHidlTest, TestInvalidSystemIdFails) {
    description("Test failure for invalid system ID");
    sp<MediaCasListener> casListener = new MediaCasListener();

    ASSERT_FALSE(mService->isSystemIdSupported(INVALID_SYSTEM_ID));
    ASSERT_FALSE(mService->isDescramblerSupported(INVALID_SYSTEM_ID));

    sp<ICas> mediaCas = mService->createPlugin(INVALID_SYSTEM_ID, casListener);
    EXPECT_EQ(mediaCas, nullptr);

    sp<IDescramblerBase> descramblerBase = mService->createDescrambler(INVALID_SYSTEM_ID);
    EXPECT_EQ(descramblerBase, nullptr);
}

TEST_F(MediaCasHidlTest, TestClearKeyPluginInstalled) {
    description("Test if ClearKey plugin is installed");
    hidl_vec<HidlCasPluginDescriptor> descriptors;
    EXPECT_TRUE(mService
                    ->enumeratePlugins([&descriptors](
                        hidl_vec<HidlCasPluginDescriptor> const& _desc) { descriptors = _desc; })
                    .isOk());

    if (descriptors.size() == 0) {
        ALOGW("[   WARN   ] enumeratePlugins list empty");
    }

    for (size_t i = 0; i < descriptors.size(); i++) {
        int32_t caSystemId = descriptors[i].caSystemId;
        if (CLEAR_KEY_SYSTEM_ID == caSystemId) {
            return;
        }
    }

    ASSERT_TRUE(false) << "ClearKey plugin not installed";
}

}  // anonymous namespace

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;
}
+1 −0
Original line number Original line Diff line number Diff line
// This is an autogenerated file, do not edit.
// This is an autogenerated file, do not edit.
subdirs = [
subdirs = [
    "1.0",
    "1.0",
    "1.0/vts/functional",
    "1.0/default",
    "1.0/default",
    "native/1.0",
    "native/1.0",
]
]
+23 −9
Original line number Original line Diff line number Diff line
@@ -14,8 +14,6 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


/* This HAL is a work in progress */

package android.hardware.neuralnetworks@1.0;
package android.hardware.neuralnetworks@1.0;


import IEvent;
import IEvent;
@@ -28,7 +26,10 @@ interface IDevice {
    /**
    /**
     * Gets the capabilities of a driver.
     * Gets the capabilities of a driver.
     *
     *
     * @return status ErrorStatus::NONE if successful.
     * @return status Error status of the call, must be:
     *                - NONE if successful
     *                - DEVICE_UNAVAILABLE if driver is offline or busy
     *                - GENERAL_FAILURE if there is an unspecified error
     * @return capabilities Capabilities of the driver.
     * @return capabilities Capabilities of the driver.
     */
     */
    getCapabilities() generates (ErrorStatus status, Capabilities capabilities);
    getCapabilities() generates (ErrorStatus status, Capabilities capabilities);
@@ -43,7 +44,11 @@ interface IDevice {
     *
     *
     * @param model A model whose operations--and their corresponding
     * @param model A model whose operations--and their corresponding
     *              operands--are to be verified by the driver.
     *              operands--are to be verified by the driver.
     * @return status ErrorStatus::NONE if successful.
     * @return status Error status of the call, must be:
     *                - NONE if successful
     *                - DEVICE_UNAVAILABLE if driver is offline or busy
     *                - GENERAL_FAILURE if there is an unspecified error
     *                - INVALID_ARGUMENT when provided model is invalid
     * @return supportedOperations A list of supported operations, where true
     * @return supportedOperations A list of supported operations, where true
     *                             indicates the operation is supported and
     *                             indicates the operation is supported and
     *                             false indicates the operation is not
     *                             false indicates the operation is not
@@ -60,7 +65,7 @@ interface IDevice {
     * prepareModel is used to make any necessary transformations or alternative
     * prepareModel is used to make any necessary transformations or alternative
     * representations to a model for execution, possible including
     * representations to a model for execution, possible including
     * transformations on the constant data, optimization on the model's graph,
     * transformations on the constant data, optimization on the model's graph,
     * or compilation into the device's native binary.
     * or compilation into the device's native binary format.
     *
     *
     * The only information that may be unknown to the model at this stage is
     * The only information that may be unknown to the model at this stage is
     * the shape of the tensors, which may only be known at execution time.
     * the shape of the tensors, which may only be known at execution time.
@@ -68,7 +73,12 @@ interface IDevice {
     * @param model The model to be prepared for execution.
     * @param model The model to be prepared for execution.
     * @param event A synchronization callback that must be signaled once the
     * @param event A synchronization callback that must be signaled once the
     *              execution has finished.
     *              execution has finished.
     * @return status ErrorStatus::NONE if successful.
     * @return status Error status of the call, must be:
     *                - NONE if preparation task is successfully launched
     *                - DEVICE_UNAVAILABLE if driver is offline or busy
     *                - GENERAL_FAILURE if there is an unspecified error
     *                - INVALID_ARGUMENT when one of the input arguments is
     *                  invalid
     * @return preparedModel A handle to the resultant prepared model.
     * @return preparedModel A handle to the resultant prepared model.
     */
     */
    prepareModel(Model model, IEvent event)
    prepareModel(Model model, IEvent event)
@@ -77,7 +87,11 @@ interface IDevice {
    /**
    /**
     * Returns the current status of a driver.
     * Returns the current status of a driver.
     *
     *
     * @return status Status of the driver.
     * @return status Status of the driver, one of:
     *                - DeviceStatus::AVAILABLE
     *                - DeviceStatus::BUSY
     *                - DeviceStatus::OFFLINE
     *                - DeviceStatus::UNKNOWN
     */
     */
    getStatus() generates (DeviceStatus status);
    getStatus() generates (DeviceStatus status);
};
};
+5 −3
Original line number Original line Diff line number Diff line
@@ -14,8 +14,6 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


/* This HAL is a work in progress */

package android.hardware.neuralnetworks@1.0;
package android.hardware.neuralnetworks@1.0;


/**
/**
@@ -37,7 +35,11 @@ interface IEvent {
     * the work) to mark the event as completed so that any threads requiring
     * the work) to mark the event as completed so that any threads requiring
     * the corresponding output can continue executing.
     * the corresponding output can continue executing.
     *
     *
     * @param status ErrorStatus::NONE if successful.
     * @param status Error status returned from the asynchronous task, must be:
     *               - NONE if asynchronous task was successful
     *               - DEVICE_UNAVAILABLE if driver is offline or busy
     *               - GENERAL_FAILURE if the asynchronous task resulted in an
     *                 unspecified error
     */
     */
    oneway notify(ErrorStatus status);
    oneway notify(ErrorStatus status);
};
};
Loading