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

Commit 99d67c0d authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7017853 from 1ef474f3 to sc-release

Change-Id: I50d981b65155b8a03d26596dbfa6f332d534360a
parents 100e1daf 1ef474f3
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
#include <log/log.h>

#include <AndroidKeymaster3Device.h>
#include <hardware/keymaster0.h>
#include <hardware/keymaster1.h>
#include <hardware/keymaster2.h>
#include <hardware/keymaster_defs.h>
@@ -33,16 +32,6 @@ namespace keymaster {
namespace V3_0 {
namespace implementation {

static int get_keymaster0_dev(keymaster0_device_t** dev, const hw_module_t* mod) {
    int rc = keymaster0_open(mod, dev);
    if (rc) {
        ALOGE("Error opening keystore keymaster0 device.");
        *dev = nullptr;
        return rc;
    }
    return 0;
}

static int get_keymaster1_dev(keymaster1_device_t** dev, const hw_module_t* mod) {
    int rc = keymaster1_open(mod, dev);
    if (rc) {
@@ -75,11 +64,7 @@ static IKeymasterDevice* createKeymaster3Device() {
    }

    if (mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0) {
        keymaster0_device_t* dev = nullptr;
        if (get_keymaster0_dev(&dev, mod)) {
        return nullptr;
        }
        return ::keymaster::ng::CreateKeymasterDevice(dev);
    } else if (mod->module_api_version == KEYMASTER_MODULE_API_VERSION_1_0) {
        keymaster1_device_t* dev = nullptr;
        if (get_keymaster1_dev(&dev, mod)) {
+38 −23
Original line number Diff line number Diff line
@@ -24,20 +24,28 @@

namespace android::nn {

GeneralResult<OperandType> convert(const hal::V1_0::OperandType& operandType);
GeneralResult<OperationType> convert(const hal::V1_0::OperationType& operationType);
GeneralResult<Operand::LifeTime> convert(const hal::V1_0::OperandLifeTime& lifetime);
GeneralResult<DeviceStatus> convert(const hal::V1_0::DeviceStatus& deviceStatus);
GeneralResult<Capabilities::PerformanceInfo> convert(
GeneralResult<OperandType> unvalidatedConvert(const hal::V1_0::OperandType& operandType);
GeneralResult<OperationType> unvalidatedConvert(const hal::V1_0::OperationType& operationType);
GeneralResult<Operand::LifeTime> unvalidatedConvert(const hal::V1_0::OperandLifeTime& lifetime);
GeneralResult<DeviceStatus> unvalidatedConvert(const hal::V1_0::DeviceStatus& deviceStatus);
GeneralResult<Capabilities::PerformanceInfo> unvalidatedConvert(
        const hal::V1_0::PerformanceInfo& performanceInfo);
GeneralResult<Capabilities> unvalidatedConvert(const hal::V1_0::Capabilities& capabilities);
GeneralResult<DataLocation> unvalidatedConvert(const hal::V1_0::DataLocation& location);
GeneralResult<Operand> unvalidatedConvert(const hal::V1_0::Operand& operand);
GeneralResult<Operation> unvalidatedConvert(const hal::V1_0::Operation& operation);
GeneralResult<Model::OperandValues> unvalidatedConvert(
        const hardware::hidl_vec<uint8_t>& operandValues);
GeneralResult<Memory> unvalidatedConvert(const hardware::hidl_memory& memory);
GeneralResult<Model> unvalidatedConvert(const hal::V1_0::Model& model);
GeneralResult<Request::Argument> unvalidatedConvert(
        const hal::V1_0::RequestArgument& requestArgument);
GeneralResult<Request> unvalidatedConvert(const hal::V1_0::Request& request);
GeneralResult<ErrorStatus> unvalidatedConvert(const hal::V1_0::ErrorStatus& status);

GeneralResult<DeviceStatus> convert(const hal::V1_0::DeviceStatus& deviceStatus);
GeneralResult<Capabilities> convert(const hal::V1_0::Capabilities& capabilities);
GeneralResult<DataLocation> convert(const hal::V1_0::DataLocation& location);
GeneralResult<Operand> convert(const hal::V1_0::Operand& operand);
GeneralResult<Operation> convert(const hal::V1_0::Operation& operation);
GeneralResult<Model::OperandValues> convert(const hardware::hidl_vec<uint8_t>& operandValues);
GeneralResult<Memory> convert(const hardware::hidl_memory& memory);
GeneralResult<Model> convert(const hal::V1_0::Model& model);
GeneralResult<Request::Argument> convert(const hal::V1_0::RequestArgument& requestArgument);
GeneralResult<Request> convert(const hal::V1_0::Request& request);
GeneralResult<ErrorStatus> convert(const hal::V1_0::ErrorStatus& status);

@@ -45,21 +53,28 @@ GeneralResult<ErrorStatus> convert(const hal::V1_0::ErrorStatus& status);

namespace android::hardware::neuralnetworks::V1_0::utils {

nn::GeneralResult<OperandType> convert(const nn::OperandType& operandType);
nn::GeneralResult<OperationType> convert(const nn::OperationType& operationType);
nn::GeneralResult<OperandLifeTime> convert(const nn::Operand::LifeTime& lifetime);
nn::GeneralResult<DeviceStatus> convert(const nn::DeviceStatus& deviceStatus);
nn::GeneralResult<PerformanceInfo> convert(
nn::GeneralResult<OperandType> unvalidatedConvert(const nn::OperandType& operandType);
nn::GeneralResult<OperationType> unvalidatedConvert(const nn::OperationType& operationType);
nn::GeneralResult<OperandLifeTime> unvalidatedConvert(const nn::Operand::LifeTime& lifetime);
nn::GeneralResult<DeviceStatus> unvalidatedConvert(const nn::DeviceStatus& deviceStatus);
nn::GeneralResult<PerformanceInfo> unvalidatedConvert(
        const nn::Capabilities::PerformanceInfo& performanceInfo);
nn::GeneralResult<Capabilities> unvalidatedConvert(const nn::Capabilities& capabilities);
nn::GeneralResult<DataLocation> unvalidatedConvert(const nn::DataLocation& location);
nn::GeneralResult<Operand> unvalidatedConvert(const nn::Operand& operand);
nn::GeneralResult<Operation> unvalidatedConvert(const nn::Operation& operation);
nn::GeneralResult<hidl_vec<uint8_t>> unvalidatedConvert(
        const nn::Model::OperandValues& operandValues);
nn::GeneralResult<hidl_memory> unvalidatedConvert(const nn::Memory& memory);
nn::GeneralResult<Model> unvalidatedConvert(const nn::Model& model);
nn::GeneralResult<RequestArgument> unvalidatedConvert(const nn::Request::Argument& requestArgument);
nn::GeneralResult<hidl_memory> unvalidatedConvert(const nn::Request::MemoryPool& memoryPool);
nn::GeneralResult<Request> unvalidatedConvert(const nn::Request& request);
nn::GeneralResult<ErrorStatus> unvalidatedConvert(const nn::ErrorStatus& status);

nn::GeneralResult<DeviceStatus> convert(const nn::DeviceStatus& deviceStatus);
nn::GeneralResult<Capabilities> convert(const nn::Capabilities& capabilities);
nn::GeneralResult<DataLocation> convert(const nn::DataLocation& location);
nn::GeneralResult<Operand> convert(const nn::Operand& operand);
nn::GeneralResult<Operation> convert(const nn::Operation& operation);
nn::GeneralResult<hidl_vec<uint8_t>> convert(const nn::Model::OperandValues& operandValues);
nn::GeneralResult<hidl_memory> convert(const nn::Memory& memory);
nn::GeneralResult<Model> convert(const nn::Model& model);
nn::GeneralResult<RequestArgument> convert(const nn::Request::Argument& requestArgument);
nn::GeneralResult<hidl_memory> convert(const nn::Request::MemoryPool& memoryPool);
nn::GeneralResult<Request> convert(const nn::Request& request);
nn::GeneralResult<ErrorStatus> convert(const nn::ErrorStatus& status);

+0 −24
Original line number Diff line number Diff line
@@ -22,25 +22,16 @@
#include <android-base/logging.h>
#include <android/hardware/neuralnetworks/1.0/types.h>
#include <nnapi/Result.h>
#include <nnapi/TypeUtils.h>
#include <nnapi/Types.h>
#include <nnapi/Validation.h>

namespace android::hardware::neuralnetworks::V1_0::utils {

constexpr auto kVersion = nn::Version::ANDROID_OC_MR1;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
    const auto maybeCanonical = nn::convert(halObject);
    if (!maybeCanonical.has_value()) {
        return nn::error() << maybeCanonical.error().message;
    }
    const auto version = NN_TRY(nn::validate(maybeCanonical.value()));
    if (version > utils::kVersion) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required "
                          << utils::kVersion;
    }
    return {};
}

@@ -53,21 +44,6 @@ bool valid(const Type& halObject) {
    return result.has_value();
}

template <typename Type>
decltype(nn::convert(std::declval<Type>())) validatedConvertToCanonical(const Type& halObject) {
    auto canonical = NN_TRY(nn::convert(halObject));
    const auto maybeVersion = nn::validate(canonical);
    if (!maybeVersion.has_value()) {
        return nn::error() << maybeVersion.error();
    }
    const auto version = maybeVersion.value();
    if (version > utils::kVersion) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required "
                          << utils::kVersion;
    }
    return canonical;
}

}  // namespace android::hardware::neuralnetworks::V1_0::utils

#endif  // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_0_UTILS_H
+2 −4
Original line number Diff line number Diff line
@@ -45,8 +45,7 @@ nn::GeneralResult<nn::SharedPreparedModel> convertPreparedModel(
Return<void> PreparedModelCallback::notify(ErrorStatus status,
                                           const sp<IPreparedModel>& preparedModel) {
    if (status != ErrorStatus::NONE) {
        const auto canonical =
                validatedConvertToCanonical(status).value_or(nn::ErrorStatus::GENERAL_FAILURE);
        const auto canonical = nn::convert(status).value_or(nn::ErrorStatus::GENERAL_FAILURE);
        notifyInternal(NN_ERROR(canonical) << "preparedModel failed with " << toString(status));
    } else if (preparedModel == nullptr) {
        notifyInternal(NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
@@ -73,8 +72,7 @@ void PreparedModelCallback::notifyInternal(PreparedModelCallback::Data result) {

Return<void> ExecutionCallback::notify(ErrorStatus status) {
    if (status != ErrorStatus::NONE) {
        const auto canonical =
                validatedConvertToCanonical(status).value_or(nn::ErrorStatus::GENERAL_FAILURE);
        const auto canonical = nn::convert(status).value_or(nn::ErrorStatus::GENERAL_FAILURE);
        notifyInternal(NN_ERROR(canonical) << "execute failed with " << toString(status));
    } else {
        notifyInternal({});
+150 −72

File changed.

Preview size limit exceeded, changes collapsed.

Loading