Merge "Camera: HAL1: remove libbinder usage" into oc-dev
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..787d47a
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+#
+# Below are some minor deviations from the default Google style to
+# accommodate for handling of the large legacy code base.
+#
+
+BasedOnStyle: Google
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+AllowShortFunctionsOnASingleLine: Inline
+TabWidth: 4
+UseTab: Never
+IndentWidth: 4
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..213c93a
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,5 @@
+[Options]
+ignore_merged_commits = true
+
+[Builtin Hooks]
+clang_format = true
diff --git a/automotive/vehicle/2.0/default/Android.mk b/automotive/vehicle/2.0/default/Android.mk
index 4a010e9..b8535bd 100644
--- a/automotive/vehicle/2.0/default/Android.mk
+++ b/automotive/vehicle/2.0/default/Android.mk
@@ -22,7 +22,6 @@
include $(CLEAR_VARS)
LOCAL_MODULE := $(vhal_v2_0)-manager-lib
LOCAL_SRC_FILES := \
- common/src/AccessControlConfigParser.cpp \
common/src/SubscriptionManager.cpp \
common/src/VehicleHalManager.cpp \
common/src/VehicleObjectPool.cpp \
@@ -35,7 +34,6 @@
$(LOCAL_PATH)/common/include
LOCAL_SHARED_LIBRARIES := \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
@@ -89,7 +87,6 @@
LOCAL_SHARED_LIBRARIES := \
libbase \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
@@ -117,7 +114,6 @@
$(vhal_v2_0)-manager-lib \
LOCAL_SRC_FILES:= \
- tests/AccessControlConfigParser_test.cpp \
tests/RecurrentTimer_test.cpp \
tests/SubscriptionManager_test.cpp \
tests/VehicleHalManager_test.cpp \
@@ -125,7 +121,6 @@
tests/VehiclePropConfigIndex_test.cpp \
LOCAL_SHARED_LIBRARIES := \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
@@ -153,7 +148,6 @@
LOCAL_SHARED_LIBRARIES := \
libbase \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/AccessControlConfigParser.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/AccessControlConfigParser.h
deleted file mode 100644
index 8ef6f5a..0000000
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/AccessControlConfigParser.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#ifndef android_hardware_automotive_vehicle_V2_0_AccessControlConfigParser_H_
-#define android_hardware_automotive_vehicle_V2_0_AccessControlConfigParser_H_
-
-#include <string>
-#include <vector>
-#include <unordered_map>
-#include <list>
-
-#include <android/hardware/automotive/vehicle/2.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace automotive {
-namespace vehicle {
-namespace V2_0 {
-
-struct PropertyAcl {
- int32_t propId;
- unsigned uid;
- VehiclePropertyAccess access;
-};
-
-using PropertyAclMap = std::unordered_multimap<int32_t, PropertyAcl>;
-
-/**
- * Parser for per-property access control in vehicle HAL.
- *
- * It supports the following format:
- * Set ALIAS_NAME UID
- * {S,V}:0x0305 {ALIAS_NAME,UID} {R,W,RW}
- *
- * ALIAS_NAME is just an alias for UID
- * S - for system properties (VehiclePropertyGroup::SYSTEM)
- * V - for vendor properties (VehiclePropertyGroup::VENDOR)
- *
- * Example:
- *
- * Set AID_AUDIO 1004
- * Set AID_MY_APP 10022
- *
- * S:0x0305 AID_AUDIO RW
- * S:0x0305 10021 R
- * V:0x0101 AID_MY_APP R
- */
-class AccessControlConfigParser {
-public:
- /**
- * Creates an instance of AccessControlConfigParser
- *
- * @param properties - properties supported by HAL implementation
- */
- AccessControlConfigParser(const std::vector<int32_t>& properties);
-
- /**
- * Parses config content from given stream and writes results to
- * propertyAclMap.
- */
- bool parseFromStream(std::istream* stream, PropertyAclMap* propertyAclMap);
-
-private:
- bool processTokens(std::list<std::string>* tokens,
- PropertyAclMap* propertyAclMap);
-
- bool parsePropertyGroup(char group,
- VehiclePropertyGroup* outPropertyGroup) const;
-
- bool parsePropertyId(const std::string& strPropId,
- VehiclePropertyGroup propertyGroup,
- int32_t* outVehicleProperty) const;
-
- bool parseUid(const std::string& strUid, unsigned* outUid) const;
-
- bool parseAccess(const std::string& strAccess,
- VehiclePropertyAccess* outAccess) const;
-
-
- std::string readNextToken(std::list<std::string>* tokens) const;
-
- static bool parseInt(const char* strValue, int* outIntValue);
- static void split(const std::string& line,
- std::list<std::string>* outTokens);
-
-private:
- std::unordered_map<std::string, unsigned> mUidMap {}; // Contains UID
- // aliases.
-
- // Map property ids w/o TYPE and AREA to VehicleProperty.
- std::unordered_map<int32_t, int32_t> mStrippedToVehiclePropertyMap;
-};
-
-} // namespace V2_0
-} // namespace vehicle
-} // namespace automotive
-} // namespace hardware
-} // namespace android
-
-#endif // android_hardware_automotive_vehicle_V2_0_AccessControlConfigParser_H_
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
index a808c66..fd59802 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
@@ -24,7 +24,7 @@
#include <android/log.h>
#include <hidl/HidlSupport.h>
-#include <hwbinder/IPCThreadState.h>
+#include <utils/SortedVector.h>
#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
@@ -39,10 +39,8 @@
class HalClient : public android::RefBase {
public:
- HalClient(const sp<IVehicleCallback> &callback,
- int32_t pid,
- int32_t uid)
- : mCallback(callback), mPid(pid), mUid(uid) {}
+ HalClient(const sp<IVehicleCallback> &callback)
+ : mCallback(callback) {}
virtual ~HalClient() {}
public:
@@ -56,8 +54,6 @@
private:
const sp<IVehicleCallback> mCallback;
- const int32_t mPid;
- const int32_t mUid;
std::map<int32_t, SubscribeOptions> mSubscriptions;
};
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
index b8ab309..1d45f4b 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
@@ -27,9 +27,7 @@
#include <set>
#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
-#include <hwbinder/IPCThreadState.h>
-#include "AccessControlConfigParser.h"
#include "ConcurrentQueue.h"
#include "SubscriptionManager.h"
#include "VehicleHal.h"
@@ -42,11 +40,6 @@
namespace vehicle {
namespace V2_0 {
-struct Caller {
- pid_t pid;
- uid_t uid;
-};
-
/**
* This class is a thick proxy between IVehicle HIDL interface and vendor's implementation.
*
@@ -99,14 +92,8 @@
const VehiclePropConfig* getPropConfigOrNull(int32_t prop) const;
- bool checkWritePermission(const VehiclePropConfig &config,
- const Caller& callee) const;
- bool checkReadPermission(const VehiclePropConfig &config,
- const Caller& caller) const;
- bool checkAcl(uid_t callerUid,
- int32_t propertyId,
- VehiclePropertyAccess requiredAccess) const;
-
+ bool checkWritePermission(const VehiclePropConfig &config) const;
+ bool checkReadPermission(const VehiclePropConfig &config) const;
void onAllClientsUnsubscribed(int32_t propertyId);
static bool isSubscribable(const VehiclePropConfig& config,
@@ -114,12 +101,6 @@
static bool isSampleRateFixed(VehiclePropertyChangeMode mode);
static float checkSampleRate(const VehiclePropConfig& config,
float sampleRate);
- static void readAndParseAclConfig(const char* filename,
- AccessControlConfigParser* parser,
- PropertyAclMap* outAclMap);
-
- static Caller getCaller();
-
private:
VehicleHal* mHal;
std::unique_ptr<VehiclePropConfigIndex> mConfigIndex;
@@ -130,7 +111,6 @@
ConcurrentQueue<VehiclePropValuePtr> mEventQueue;
BatchingConsumer<VehiclePropValuePtr> mBatchingConsumer;
VehiclePropValuePool mValueObjectPool;
- PropertyAclMap mPropertyAclMap;
};
} // namespace V2_0
diff --git a/automotive/vehicle/2.0/default/common/src/AccessControlConfigParser.cpp b/automotive/vehicle/2.0/default/common/src/AccessControlConfigParser.cpp
deleted file mode 100644
index 6a3f8e5..0000000
--- a/automotive/vehicle/2.0/default/common/src/AccessControlConfigParser.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2016 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 "automotive.vehicle@2.0-impl"
-
-#include "AccessControlConfigParser.h"
-#include "VehicleUtils.h"
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace automotive {
-namespace vehicle {
-namespace V2_0 {
-
-AccessControlConfigParser::AccessControlConfigParser(
- const std::vector<int32_t>& properties) {
- // Property Id in the config file doesn't include information about
- // type and area. So we want to create a map from these kind of
- // *stripped* properties to the whole VehicleProperty.
- // We also want to filter out ACL to the properties that supported
- // by concrete Vehicle HAL implementation.
- for (auto prop : properties) {
- auto strippedProp = prop
- & ~toInt(VehiclePropertyType::MASK)
- & ~toInt(VehicleArea::MASK);
- mStrippedToVehiclePropertyMap.emplace(strippedProp, prop);
- }
-}
-
-bool AccessControlConfigParser::parseFromStream(
- std::istream* stream, PropertyAclMap* propertyAclMap) {
- std::list<std::string> tokens;
- std::string line;
- int lineNo = 0;
- bool warnings = false;
- for (;std::getline(*stream, line); lineNo++) {
- split(line, &tokens);
- if (!processTokens(&tokens, propertyAclMap)) {
- warnings = true;
- ALOGW("Failed to parse line %d : %s", lineNo, line.c_str());
- }
- }
- return !warnings;
-}
-
-
-bool AccessControlConfigParser::processTokens(std::list<std::string>* tokens,
- PropertyAclMap* propertyAclMap) {
- std::string token = readNextToken(tokens);
- if (token.empty() || token[0] == '#') { // Ignore comment.
- return true;
- }
-
- if (token == "Set") {
- std::string alias = readNextToken(tokens);
- std::string strUid = readNextToken(tokens);
- if (alias.empty() || strUid.empty()) {
- ALOGW("Expected alias and UID must be specified");
- return false;
- }
- int uid;
- if (!parseInt(strUid.c_str(), &uid)) {
- ALOGW("Invalid UID: %d", uid);
- }
- mUidMap.emplace(std::move(alias), uid);
- } else if (token.size() > 2 && token[1] == ':') {
- VehiclePropertyGroup propGroup;
- if (!parsePropertyGroup(token[0], &propGroup)) {
- return false;
- }
- std::string strUid = readNextToken(tokens);
- std::string strAccess = readNextToken(tokens);
- if (strUid.empty() || strAccess.empty()) {
- ALOGW("Expected UID and access for property: %s",
- token.c_str());
- }
-
-
- PropertyAcl acl;
- if (parsePropertyId(token.substr(2), propGroup, &acl.propId)
- && parseUid(strUid, &acl.uid)
- && parseAccess(strAccess, &acl.access)) {
- propertyAclMap->emplace(acl.propId, std::move(acl));
- } else {
- return false;
- }
- } else {
- ALOGW("Unexpected token: %s", token.c_str());
- return false;
- }
-
- return true;
-}
-
-bool AccessControlConfigParser::parsePropertyGroup(
- char group, VehiclePropertyGroup* outPropertyGroup) const {
- switch (group) {
- case 'S': // Fall through.
- case 's':
- *outPropertyGroup = VehiclePropertyGroup::SYSTEM;
- break;
- case 'V': // Fall through.
- case 'v':
- *outPropertyGroup = VehiclePropertyGroup::VENDOR;
- break;
- default:
- ALOGW("Unexpected group: %c", group);
- return false;
- }
- return true;
-}
-
-bool AccessControlConfigParser::parsePropertyId(
- const std::string& strPropId,
- VehiclePropertyGroup propertyGroup,
- int32_t* outVehicleProperty) const {
- int32_t propId;
- if (!parseInt(strPropId.c_str(), &propId)) {
- ALOGW("Failed to convert property id to integer: %s",
- strPropId.c_str());
- return false;
- }
- propId |= static_cast<int>(propertyGroup);
- auto it = mStrippedToVehiclePropertyMap.find(propId);
- if (it == mStrippedToVehiclePropertyMap.end()) {
- ALOGW("Property Id not found or not supported: 0x%x", propId);
- return false;
- }
- *outVehicleProperty = it->second;
- return true;
-}
-
-bool AccessControlConfigParser::parseInt(const char* strValue,
- int* outIntValue) {
- char* end;
- long num = std::strtol(strValue, &end, 0 /* auto detect base */);
- bool success = *end == 0 && errno != ERANGE;
- if (success) {
- *outIntValue = static_cast<int>(num);
- }
-
- return success;
-}
-
-bool AccessControlConfigParser::parseUid(const std::string& strUid,
- unsigned* outUid) const {
- auto element = mUidMap.find(strUid);
- if (element != mUidMap.end()) {
- *outUid = element->second;
- } else {
- int val;
- if (!parseInt(strUid.c_str(), &val)) {
- ALOGW("Failed to convert UID '%s' to integer", strUid.c_str());
- return false;
- }
- *outUid = static_cast<unsigned>(val);
- }
- return true;
-}
-
-bool AccessControlConfigParser::parseAccess(
- const std::string& strAccess, VehiclePropertyAccess* outAccess) const {
- if (strAccess.size() == 0 || strAccess.size() > 2) {
- ALOGW("Unknown access mode '%s'", strAccess.c_str());
- return false;
- }
- int32_t access = static_cast<int32_t>(VehiclePropertyAccess::NONE);
- for (char c : strAccess) {
- if (c == 'R' || c == 'r') {
- access |= VehiclePropertyAccess::READ;
- } else if (c == 'W' || c == 'w') {
- access |= VehiclePropertyAccess::WRITE;
- } else {
- ALOGW("Unknown access mode: %c", c);
- return false;
- }
- }
- *outAccess = static_cast<VehiclePropertyAccess>(access);
- return true;
-}
-
-void AccessControlConfigParser::split(const std::string& line,
- std::list<std::string>* outTokens) {
- outTokens->clear();
- std::istringstream iss(line);
-
- while (!iss.eof()) {
- std::string token;
- iss >> token;
- outTokens->push_back(std::move(token));
- }
-}
-
-std::string AccessControlConfigParser::readNextToken(
- std::list<std::string>* tokens) const {
- if (tokens->empty()) {
- return "";
- }
-
- std::string token = tokens->front();
- tokens->pop_front();
- return token;
-}
-
-} // namespace V2_0
-} // namespace vehicle
-} // namespace automotive
-} // namespace hardware
-} // namespace android
diff --git a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
index 4493a41..e0f3f31 100644
--- a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
@@ -232,10 +232,8 @@
__func__, callback.get(), res.description().c_str());
return nullptr;
}
- IPCThreadState* self = IPCThreadState::self();
- pid_t pid = self->getCallingPid();
- uid_t uid = self->getCallingUid();
- sp<HalClient> client = new HalClient(callback, pid, uid);
+
+ sp<HalClient> client = new HalClient(callback);
mClients.emplace(callback, client);
return client;
} else {
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
index 8906f6e..f452be8 100644
--- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
@@ -18,10 +18,10 @@
#include "VehicleHalManager.h"
+#include <cmath>
#include <fstream>
#include <android/log.h>
-#include <private/android_filesystem_config.h>
#include "VehicleUtils.h"
@@ -84,7 +84,7 @@
return Void();
}
- if (!checkReadPermission(*config, getCaller())) {
+ if (!checkReadPermission(*config)) {
_hidl_cb(StatusCode::ACCESS_DENIED, kEmptyValue);
return Void();
}
@@ -105,7 +105,7 @@
return StatusCode::INVALID_ARG;
}
- if (!checkWritePermission(*config, getCaller())) {
+ if (!checkWritePermission(*config)) {
return StatusCode::ACCESS_DENIED;
}
@@ -119,7 +119,6 @@
Return<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &callback,
const hidl_vec<SubscribeOptions> &options) {
hidl_vec<SubscribeOptions> verifiedOptions(options);
- auto caller = getCaller();
for (size_t i = 0; i < verifiedOptions.size(); i++) {
SubscribeOptions& ops = verifiedOptions[i];
auto prop = ops.propId;
@@ -136,10 +135,6 @@
return StatusCode::INVALID_ARG;
}
- if (!checkAcl(caller.uid, config->prop, VehiclePropertyAccess::READ)) {
- return StatusCode::ACCESS_DENIED;
- }
-
if (!isSubscribable(*config, ops.flags)) {
ALOGE("Failed to subscribe: property 0x%x is not subscribable",
prop);
@@ -209,13 +204,6 @@
for (const auto& config : supportedPropConfigs) {
supportedProperties.push_back(config.prop);
}
-
- AccessControlConfigParser aclParser(supportedProperties);
- const char* configs[] = { "/system/etc/vehicle_access.conf",
- "/vendor/etc/vehicle_access.conf" };
- for (const char* filename : configs) {
- readAndParseAclConfig(filename, &aclParser, &mPropertyAclMap);
- }
}
VehicleHalManager::~VehicleHalManager() {
@@ -317,39 +305,22 @@
return true;
}
-bool VehicleHalManager::checkAcl(uid_t callerUid, int32_t propertyId,
- VehiclePropertyAccess requiredAccess) const {
- if (callerUid == AID_SYSTEM && isSystemProperty(propertyId)) {
- return true;
- }
-
- auto range = mPropertyAclMap.equal_range(propertyId);
- for (auto it = range.first; it != range.second; ++it) {
- auto& acl = it->second;
- if (acl.uid == callerUid && (acl.access & requiredAccess)) {
- return true;
- }
- }
- return false;
-}
-
-bool VehicleHalManager::checkWritePermission(const VehiclePropConfig &config,
- const Caller& caller) const {
+bool VehicleHalManager::checkWritePermission(const VehiclePropConfig &config) const {
if (!(config.access & VehiclePropertyAccess::WRITE)) {
ALOGW("Property 0%x has no write access", config.prop);
return false;
+ } else {
+ return true;
}
- return checkAcl(caller.uid, config.prop, VehiclePropertyAccess::WRITE);
}
-bool VehicleHalManager::checkReadPermission(const VehiclePropConfig &config,
- const Caller& caller) const {
+bool VehicleHalManager::checkReadPermission(const VehiclePropConfig &config) const {
if (!(config.access & VehiclePropertyAccess::READ)) {
ALOGW("Property 0%x has no read access", config.prop);
return false;
+ } else {
+ return true;
}
-
- return checkAcl(caller.uid, config.prop, VehiclePropertyAccess::READ);
}
void VehicleHalManager::handlePropertySetEvent(const VehiclePropValue& value) {
@@ -366,26 +337,6 @@
? &mConfigIndex->getConfig(prop) : nullptr;
}
-Caller VehicleHalManager::getCaller() {
- Caller caller;
- IPCThreadState* self = IPCThreadState::self();
- caller.pid = self->getCallingPid();
- caller.uid = self->getCallingUid();
-
- return caller;
-}
-
-void VehicleHalManager::readAndParseAclConfig(const char* filename,
- AccessControlConfigParser* parser,
- PropertyAclMap* outAclMap) {
- std::ifstream file(filename);
- if (file.is_open()) {
- ALOGI("Parsing file: %s", filename);
- parser->parseFromStream(&file, outAclMap);
- file.close();
- }
-}
-
void VehicleHalManager::onAllClientsUnsubscribed(int32_t propertyId) {
mHal->unsubscribe(propertyId);
}
diff --git a/automotive/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp b/automotive/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp
deleted file mode 100644
index d9611c0..0000000
--- a/automotive/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#include <gtest/gtest.h>
-#include <memory>
-#include <fstream>
-#include <unordered_set>
-
-#include "vhal_v2_0/AccessControlConfigParser.h"
-#include "vhal_v2_0/VehicleUtils.h"
-
-namespace android {
-namespace hardware {
-namespace automotive {
-namespace vehicle {
-namespace V2_0 {
-
-namespace {
-
-class AccessControlConfigParserTest : public ::testing::Test {
-protected:
- void SetUp() override {
- std::vector<int32_t> supportedProperties {
- toInt(VehicleProperty::HVAC_FAN_SPEED),
- toInt(VehicleProperty::HVAC_FAN_DIRECTION),
- };
- parser.reset(new AccessControlConfigParser(supportedProperties));
- }
-public:
- PropertyAclMap aclMap;
- std::unique_ptr<AccessControlConfigParser> parser;
-};
-
-TEST_F(AccessControlConfigParserTest, basicParsing) {
- std::stringstream file;
- file << "S:0x0500 1000 RW" << std::endl;
-
- ASSERT_TRUE(parser->parseFromStream(&file, &aclMap));
-
- ASSERT_EQ(1u, aclMap.size());
- auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
- ASSERT_NE(aclMap.end(), it);
- ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
- ASSERT_EQ(1000u, it->second.uid);
-}
-
-TEST_F(AccessControlConfigParserTest, multipleUids) {
- std::stringstream file;
- file << "Set AID_AUDIO 1004" << std::endl
- << "Set AID_SYSTEM 1000" << std::endl
- << "S:0x0500 AID_SYSTEM RW" << std::endl
- << "S:0x0500 AID_AUDIO RW" << std::endl
- << "S:0x0500 0xbeef R" << std::endl; // Read-only.
-
- std::unordered_set<unsigned> expectedUids {1000, 1004, 0xbeef};
-
- ASSERT_TRUE(parser->parseFromStream(&file, &aclMap));
-
- auto range = aclMap.equal_range(toInt(VehicleProperty::HVAC_FAN_SPEED));
- for (auto it = range.first; it != range.second; ++it) {
- auto& acl = it->second;
-
- ASSERT_EQ(1u, expectedUids.count(acl.uid))
- << " uid: " << std::hex << acl.uid;
-
- if (acl.uid == 0xbeef) {
- ASSERT_EQ(VehiclePropertyAccess::READ, acl.access);
- } else {
- ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, acl.access);
- }
- }
-}
-
-TEST_F(AccessControlConfigParserTest, fileContainsJunk) {
- std::stringstream file;
- file << "This string will be ignored with warning in the log" << std::endl
- << "# However comments are quit legitimate" << std::endl
- << "S:0x0500 0xbeef R # YAY" << std::endl;
-
- ASSERT_FALSE(parser->parseFromStream(&file, &aclMap));
-
- ASSERT_EQ(1u, aclMap.size());
- auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
- ASSERT_NE(aclMap.end(), it);
- ASSERT_EQ(VehiclePropertyAccess::READ, it->second.access);
- ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
- ASSERT_EQ(0xBEEFu, it->second.uid);
-}
-
-TEST_F(AccessControlConfigParserTest, badIntegerFormat) {
- std::stringstream file;
- file << "S:0x0500 A12 RW " << std::endl;
-
- ASSERT_FALSE(parser->parseFromStream(&file, &aclMap));
- ASSERT_EQ(0u, aclMap.size());
-}
-
-TEST_F(AccessControlConfigParserTest, ignoreNotSupportedProperties) {
- std::stringstream file;
- file << "S:0x0666 1000 RW " << std::endl;
-
- ASSERT_FALSE(parser->parseFromStream(&file, &aclMap));
- ASSERT_EQ(0u, aclMap.size());
-}
-
-TEST_F(AccessControlConfigParserTest, multipleCalls) {
- std::stringstream configFile;
- configFile << "S:0x0500 1000 RW" << std::endl;
-
- ASSERT_TRUE(parser->parseFromStream(&configFile, &aclMap));
- ASSERT_EQ(1u, aclMap.size());
-
- std::stringstream configFile2;
- configFile2 << "S:0x0501 1004 RW" << std::endl;
- ASSERT_TRUE(parser->parseFromStream(&configFile2, &aclMap));
- ASSERT_EQ(2u, aclMap.size());
-
- auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
- ASSERT_NE(aclMap.end(), it);
- ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
- ASSERT_EQ(1000u, it->second.uid);
-
- it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_DIRECTION));
- ASSERT_NE(aclMap.end(), it);
- ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_DIRECTION), it->second.propId);
- ASSERT_EQ(1004u, it->second.uid);
-}
-
-
-} // namespace anonymous
-
-} // namespace V2_0
-} // namespace vehicle
-} // namespace automotive
-} // namespace hardware
-} // namespace android
diff --git a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
index b5cdf5c..04335b5 100644
--- a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
+++ b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
@@ -452,8 +452,8 @@
HalClientVector clients;
sp<IVehicleCallback> callback1 = new MockedVehicleCallback();
- sp<HalClient> c1 = new HalClient(callback1, 10, 20);
- sp<HalClient> c2 = new HalClient(callback1, 10, 20);
+ sp<HalClient> c1 = new HalClient(callback1);
+ sp<HalClient> c2 = new HalClient(callback1);
clients.addOrUpdate(c1);
clients.addOrUpdate(c1);
diff --git a/automotive/vehicle/2.1/default/Android.mk b/automotive/vehicle/2.1/default/Android.mk
index 3075956..51cb146 100644
--- a/automotive/vehicle/2.1/default/Android.mk
+++ b/automotive/vehicle/2.1/default/Android.mk
@@ -33,7 +33,6 @@
$(LOCAL_PATH)/common/include
LOCAL_SHARED_LIBRARIES := \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
@@ -71,7 +70,6 @@
LOCAL_SHARED_LIBRARIES := \
libbase \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
@@ -107,7 +105,6 @@
LOCAL_SHARED_LIBRARIES := \
libbase \
- libbinder \
libhidlbase \
libhidltransport \
libhwbinder \
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 9a4efae..d699f21 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -23,9 +23,8 @@
#include <hardware/bluetooth.h>
#include <utils/Log.h>
+#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
-#include <condition_variable>
-#include <mutex>
#include <queue>
using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
@@ -92,6 +91,11 @@
#define ACL_BROADCAST_ACTIVE_SLAVE (0x1 << 4)
#define ACL_PACKET_BOUNDARY_COMPLETE (0x3 << 6)
+constexpr char kCallbackNameAclEventReceived[] = "aclDataReceived";
+constexpr char kCallbackNameHciEventReceived[] = "hciEventReceived";
+constexpr char kCallbackNameInitializationComplete[] = "initializationComplete";
+constexpr char kCallbackNameScoEventReceived[] = "scoDataReceived";
+
class ThroughputLogger {
public:
ThroughputLogger(std::string task)
@@ -121,7 +125,8 @@
public:
virtual void SetUp() override {
// currently test passthrough mode only
- bluetooth = ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothHci>();
+ bluetooth =
+ ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothHci>();
ASSERT_NE(bluetooth, nullptr);
ALOGI("%s: getService() for bluetooth is %s", __func__,
bluetooth->isRemote() ? "remote" : "local");
@@ -135,10 +140,6 @@
max_sco_data_packets = 0;
initialized = false;
- initialized_count = 0;
- event_count = 0;
- acl_count = 0;
- sco_count = 0;
event_cb_count = 0;
acl_cb_count = 0;
sco_cb_count = 0;
@@ -146,7 +147,18 @@
ASSERT_EQ(initialized, false);
bluetooth->initialize(bluetooth_cb);
- wait_for_init_callback();
+ bluetooth_cb->SetWaitTimeout(kCallbackNameInitializationComplete,
+ WAIT_FOR_INIT_TIMEOUT);
+ bluetooth_cb->SetWaitTimeout(kCallbackNameHciEventReceived,
+ WAIT_FOR_HCI_EVENT_TIMEOUT);
+ bluetooth_cb->SetWaitTimeout(kCallbackNameAclEventReceived,
+ WAIT_FOR_ACL_DATA_TIMEOUT);
+ bluetooth_cb->SetWaitTimeout(kCallbackNameScoEventReceived,
+ WAIT_FOR_SCO_DATA_TIMEOUT);
+
+ EXPECT_TRUE(
+ bluetooth_cb->WaitForCallback(kCallbackNameInitializationComplete)
+ .no_timeout);
ASSERT_EQ(initialized, true);
}
@@ -171,82 +183,10 @@
void wait_for_command_complete_event(hidl_vec<uint8_t> cmd);
int wait_for_completed_packets_event(uint16_t handle);
- // Inform the test about the initialization callback
- inline void notify_initialized() {
- std::unique_lock<std::mutex> lock(initialized_mutex);
- initialized_count++;
- initialized_condition.notify_one();
- }
-
- // Test code calls this function to wait for the init callback
- inline void wait_for_init_callback() {
- std::unique_lock<std::mutex> lock(initialized_mutex);
-
- auto start_time = std::chrono::steady_clock::now();
- while (initialized_count == 0)
- if (initialized_condition.wait_until(lock,
- start_time + WAIT_FOR_INIT_TIMEOUT) ==
- std::cv_status::timeout)
- return;
- initialized_count--;
- }
-
- // Inform the test about an event callback
- inline void notify_event_received() {
- std::unique_lock<std::mutex> lock(event_mutex);
- event_count++;
- event_condition.notify_one();
- }
-
- // Test code calls this function to wait for an event callback
- inline void wait_for_event() {
- std::unique_lock<std::mutex> lock(event_mutex);
-
- auto start_time = std::chrono::steady_clock::now();
- while (event_count == 0)
- if (event_condition.wait_until(lock,
- start_time + WAIT_FOR_HCI_EVENT_TIMEOUT) ==
- std::cv_status::timeout)
- return;
- event_count--;
- }
-
- // Inform the test about an acl data callback
- inline void notify_acl_data_received() {
- std::unique_lock<std::mutex> lock(acl_mutex);
- acl_count++;
- acl_condition.notify_one();
- }
-
- // Test code calls this function to wait for an acl data callback
- inline void wait_for_acl() {
- std::unique_lock<std::mutex> lock(acl_mutex);
-
- while (acl_count == 0)
- acl_condition.wait_until(
- lock, std::chrono::steady_clock::now() + WAIT_FOR_ACL_DATA_TIMEOUT);
- acl_count--;
- }
-
- // Inform the test about a sco data callback
- inline void notify_sco_data_received() {
- std::unique_lock<std::mutex> lock(sco_mutex);
- sco_count++;
- sco_condition.notify_one();
- }
-
- // Test code calls this function to wait for a sco data callback
- inline void wait_for_sco() {
- std::unique_lock<std::mutex> lock(sco_mutex);
-
- while (sco_count == 0)
- sco_condition.wait_until(
- lock, std::chrono::steady_clock::now() + WAIT_FOR_SCO_DATA_TIMEOUT);
- sco_count--;
- }
-
// A simple test implementation of BluetoothHciCallbacks.
- class BluetoothHciCallbacks : public IBluetoothHciCallbacks {
+ class BluetoothHciCallbacks
+ : public ::testing::VtsHalHidlTargetCallbackBase<BluetoothHidlTest>,
+ public IBluetoothHciCallbacks {
BluetoothHidlTest& parent_;
public:
@@ -256,7 +196,7 @@
Return<void> initializationComplete(Status status) override {
parent_.initialized = (status == Status::SUCCESS);
- parent_.notify_initialized();
+ NotifyFromCallback(kCallbackNameInitializationComplete);
ALOGV("%s (status = %d)", __func__, static_cast<int>(status));
return Void();
};
@@ -265,7 +205,7 @@
const ::android::hardware::hidl_vec<uint8_t>& event) override {
parent_.event_cb_count++;
parent_.event_queue.push(event);
- parent_.notify_event_received();
+ NotifyFromCallback(kCallbackNameHciEventReceived);
ALOGV("Event received (length = %d)", static_cast<int>(event.size()));
return Void();
};
@@ -274,7 +214,7 @@
const ::android::hardware::hidl_vec<uint8_t>& data) override {
parent_.acl_cb_count++;
parent_.acl_queue.push(data);
- parent_.notify_acl_data_received();
+ NotifyFromCallback(kCallbackNameAclEventReceived);
return Void();
};
@@ -282,13 +222,13 @@
const ::android::hardware::hidl_vec<uint8_t>& data) override {
parent_.sco_cb_count++;
parent_.sco_queue.push(data);
- parent_.notify_sco_data_received();
+ NotifyFromCallback(kCallbackNameScoEventReceived);
return Void();
};
};
sp<IBluetoothHci> bluetooth;
- sp<IBluetoothHciCallbacks> bluetooth_cb;
+ sp<BluetoothHciCallbacks> bluetooth_cb;
std::queue<hidl_vec<uint8_t>> event_queue;
std::queue<hidl_vec<uint8_t>> acl_queue;
std::queue<hidl_vec<uint8_t>> sco_queue;
@@ -303,20 +243,6 @@
int max_sco_data_packet_length;
int max_acl_data_packets;
int max_sco_data_packets;
-
- private:
- std::mutex initialized_mutex;
- std::mutex event_mutex;
- std::mutex sco_mutex;
- std::mutex acl_mutex;
- std::condition_variable initialized_condition;
- std::condition_variable event_condition;
- std::condition_variable sco_condition;
- std::condition_variable acl_condition;
- int initialized_count;
- int event_count;
- int sco_count;
- int acl_count;
};
// A class for test environment setup (kept since this file is a template).
@@ -334,11 +260,12 @@
int status_event_count = 0;
hidl_vec<uint8_t> event;
do {
- wait_for_event();
- EXPECT_LT(static_cast<size_t>(0), event_queue.size());
- if (event_queue.size() == 0) {
- event.resize(0);
- break;
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ EXPECT_LT(static_cast<size_t>(0), event_queue.size());
+ if (event_queue.size() == 0) {
+ event.resize(0);
+ break;
}
event = event_queue.front();
event_queue.pop();
@@ -366,7 +293,8 @@
hidl_vec<uint8_t> cmd = COMMAND_HCI_READ_BUFFER_SIZE;
bluetooth->sendHciCommand(cmd);
- wait_for_event();
+ EXPECT_TRUE(
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
EXPECT_LT(static_cast<size_t>(0), event_queue.size());
if (event_queue.size() == 0) return;
@@ -420,7 +348,8 @@
bluetooth->sendHciCommand(cmd);
// Check the loopback of the HCI packet
- wait_for_event();
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();
size_t compare_length =
@@ -456,7 +385,8 @@
bluetooth->sendScoData(sco_vector);
// Check the loopback of the SCO packet
- wait_for_sco();
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> sco_loopback = sco_queue.front();
sco_queue.pop();
@@ -501,7 +431,8 @@
bluetooth->sendAclData(acl_vector);
// Check the loopback of the ACL packet
- wait_for_acl();
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> acl_loopback = acl_queue.front();
acl_queue.pop();
@@ -527,19 +458,20 @@
// Return the number of completed packets reported by the controller.
int BluetoothHidlTest::wait_for_completed_packets_event(uint16_t handle) {
- wait_for_event();
- int packets_processed = 0;
- while (event_queue.size() > 0) {
- hidl_vec<uint8_t> event = event_queue.front();
- event_queue.pop();
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ int packets_processed = 0;
+ while (event_queue.size() > 0) {
+ hidl_vec<uint8_t> event = event_queue.front();
+ event_queue.pop();
- EXPECT_EQ(EVENT_NUMBER_OF_COMPLETED_PACKETS, event[EVENT_CODE_BYTE]);
- EXPECT_EQ(1, event[EVENT_NUMBER_OF_COMPLETED_PACKETS_NUM_HANDLES]);
+ EXPECT_EQ(EVENT_NUMBER_OF_COMPLETED_PACKETS, event[EVENT_CODE_BYTE]);
+ EXPECT_EQ(1, event[EVENT_NUMBER_OF_COMPLETED_PACKETS_NUM_HANDLES]);
- uint16_t event_handle = event[3] + (event[4] << 8);
- EXPECT_EQ(handle, event_handle);
+ uint16_t event_handle = event[3] + (event[4] << 8);
+ EXPECT_EQ(handle, event_handle);
- packets_processed += event[5] + (event[6] << 8);
+ packets_processed += event[5] + (event[6] << 8);
}
return packets_processed;
}
@@ -554,32 +486,34 @@
int connection_event_count = 0;
hidl_vec<uint8_t> event;
do {
- wait_for_event();
- event = event_queue.front();
- event_queue.pop();
- EXPECT_GT(event.size(),
- static_cast<size_t>(EVENT_COMMAND_COMPLETE_STATUS_BYTE));
- if (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE) {
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ event = event_queue.front();
+ event_queue.pop();
EXPECT_GT(event.size(),
- static_cast<size_t>(EVENT_CONNECTION_COMPLETE_TYPE));
- EXPECT_EQ(event[EVENT_LENGTH_BYTE],
- EVENT_CONNECTION_COMPLETE_PARAM_LENGTH);
- uint8_t connection_type = event[EVENT_CONNECTION_COMPLETE_TYPE];
+ static_cast<size_t>(EVENT_COMMAND_COMPLETE_STATUS_BYTE));
+ if (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE) {
+ EXPECT_GT(event.size(),
+ static_cast<size_t>(EVENT_CONNECTION_COMPLETE_TYPE));
+ EXPECT_EQ(event[EVENT_LENGTH_BYTE],
+ EVENT_CONNECTION_COMPLETE_PARAM_LENGTH);
+ uint8_t connection_type = event[EVENT_CONNECTION_COMPLETE_TYPE];
- EXPECT_TRUE(connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO ||
- connection_type == EVENT_CONNECTION_COMPLETE_TYPE_ACL);
+ EXPECT_TRUE(connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO ||
+ connection_type == EVENT_CONNECTION_COMPLETE_TYPE_ACL);
- // Save handles
- uint16_t handle = event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE] |
- event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1] << 8;
- if (connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO)
- sco_handles.push_back(handle);
- else
- acl_handles.push_back(handle);
+ // Save handles
+ uint16_t handle = event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE] |
+ event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1]
+ << 8;
+ if (connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO)
+ sco_handles.push_back(handle);
+ else
+ acl_handles.push_back(handle);
- ALOGD("Connect complete type = %d handle = %d",
- event[EVENT_CONNECTION_COMPLETE_TYPE], handle);
- connection_event_count++;
+ ALOGD("Connect complete type = %d handle = %d",
+ event[EVENT_CONNECTION_COMPLETE_TYPE], handle);
+ connection_event_count++;
}
} while (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE);
@@ -592,7 +526,7 @@
}
// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
-TEST_F(BluetoothHidlTest, InitializeAndClose) { }
+TEST_F(BluetoothHidlTest, InitializeAndClose) {}
// Send an HCI Reset with sendHciCommand and wait for a command complete event.
TEST_F(BluetoothHidlTest, HciReset) {
@@ -607,7 +541,8 @@
hidl_vec<uint8_t> cmd = COMMAND_HCI_READ_LOCAL_VERSION_INFORMATION;
bluetooth->sendHciCommand(cmd);
- wait_for_event();
+ EXPECT_TRUE(
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();
@@ -627,7 +562,8 @@
hidl_vec<uint8_t> cmd = COMMAND_HCI_SHOULD_BE_UNKNOWN;
bluetooth->sendHciCommand(cmd);
- wait_for_event();
+ EXPECT_TRUE(
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();
diff --git a/camera/device/1.0/ICameraDevice.hal b/camera/device/1.0/ICameraDevice.hal
index 52d6cf0..d4aa8cc 100644
--- a/camera/device/1.0/ICameraDevice.hal
+++ b/camera/device/1.0/ICameraDevice.hal
@@ -328,6 +328,20 @@
releaseRecordingFrameHandle(MemoryId memId, uint32_t bufferIndex, handle frame);
/**
+ * Release a batch of record frames previously returned by CAMERA_MSG_VIDEO_FRAME
+ * in handleCallbackTimestampBatch.
+ *
+ * It is camera HAL client's responsibility to release video recording
+ * frames sent out by the camera HAL before the camera HAL receives a call
+ * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
+ * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
+ * responsibility to manage the life-cycle of the video recording frames.
+ *
+ * @param batch A batch of recording frames to be released by camera HAL.
+ */
+ releaseRecordingFrameHandleBatch(vec<VideoFrameMessage> batch);
+
+ /**
* Start auto focus.
*
* The notification callback routine is called with
diff --git a/camera/device/1.0/ICameraDeviceCallback.hal b/camera/device/1.0/ICameraDeviceCallback.hal
index 1b0db24..1dfcd80 100644
--- a/camera/device/1.0/ICameraDeviceCallback.hal
+++ b/camera/device/1.0/ICameraDeviceCallback.hal
@@ -92,10 +92,24 @@
* @param timestamp The time this buffer was captured by the camera, in
* nanoseconds.
*
- * @return frameId a frame ID to be used with releaseRecordingFrameId later
- *
*/
handleCallbackTimestamp(DataCallbackMsg msgType, handle frameData, MemoryId data,
uint32_t bufferIndex, int64_t timestamp);
+ /**
+ * Send a batch of image data buffer to the camera service, with timestamps
+ *
+ * This callback can be used to send multiple frames to camera framework in one callback, which
+ * reduce number of callbacks in performance intensive use cases, such as high speed video
+ * recording. The HAL must not mix use of this method with handleCallbackTimestamp in one
+ * recording session (between startRecording and stopRecording)
+ *
+ * @param msgType The kind of image buffer data this call represents.
+ * @param batch a vector messages. Each message contains a image buffer and a timestamp. The
+ * messages must be ordered in time from lower index to higher index, so that timestamp of
+ * i-th message is always smaller than i+1-th message.
+ *
+ */
+ handleCallbackTimestampBatch(DataCallbackMsg msgType, vec<HandleTimestampMessage> batch);
+
};
diff --git a/camera/device/1.0/ICameraDevicePreviewCallback.hal b/camera/device/1.0/ICameraDevicePreviewCallback.hal
index 4c9b517..e772301 100644
--- a/camera/device/1.0/ICameraDevicePreviewCallback.hal
+++ b/camera/device/1.0/ICameraDevicePreviewCallback.hal
@@ -17,7 +17,6 @@
package android.hardware.camera.device@1.0;
import android.hardware.camera.common@1.0::types;
-import android.hardware.graphics.allocator@2.0::types;
import android.hardware.graphics.common@1.0::types;
/**
@@ -89,7 +88,7 @@
*
* @return Status The status code for this operation.
*/
- setUsage(ProducerUsage usage) generates (Status status);
+ setUsage(ProducerUsageFlags usage) generates (Status status);
/**
* Set the expected buffering mode for the preview output.
diff --git a/camera/device/1.0/default/Android.bp b/camera/device/1.0/default/Android.bp
index af94b0f..2fe0699 100644
--- a/camera/device/1.0/default/Android.bp
+++ b/camera/device/1.0/default/Android.bp
@@ -24,8 +24,8 @@
"libcamera_metadata",
],
static_libs: [
- "android.hardware.camera.common@1.0-helper"
+ "android.hardware.camera.common@1.0-helper",
+ "libgrallocusage"
],
export_include_dirs: ["."]
}
-
diff --git a/camera/device/1.0/default/CameraDevice.cpp b/camera/device/1.0/default/CameraDevice.cpp
index 8c6031b..5c4723d 100644
--- a/camera/device/1.0/default/CameraDevice.cpp
+++ b/camera/device/1.0/default/CameraDevice.cpp
@@ -21,6 +21,8 @@
#include <hidlmemory/mapping.h>
#include <utils/Trace.h>
+#include <grallocusage/GrallocUsageConversion.h>
+
#include "CameraDevice_1_0.h"
namespace android {
@@ -30,7 +32,6 @@
namespace V1_0 {
namespace implementation {
-using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
HandleImporter& CameraDevice::sHandleImporter = HandleImporter::getInstance();
@@ -259,7 +260,10 @@
}
object->cleanUpCirculatingBuffers();
- return getStatusT(object->mPreviewCallback->setUsage((ProducerUsage) usage));
+ ProducerUsageFlags producerUsage;
+ uint64_t consumerUsage;
+ ::android_convertGralloc0To1Usage(usage, &producerUsage, &consumerUsage);
+ return getStatusT(object->mPreviewCallback->setUsage(producerUsage));
}
int CameraDevice::sSetSwapInterval(struct preview_stream_ops *w, int interval) {
@@ -448,6 +452,39 @@
}
}
+void CameraDevice::handleCallbackTimestamp(
+ nsecs_t timestamp, int32_t msg_type,
+ MemoryId memId , unsigned index, native_handle_t* handle) {
+ uint32_t batchSize = 0;
+ {
+ Mutex::Autolock _l(mBatchLock);
+ batchSize = mBatchSize;
+ }
+
+ if (batchSize == 0) { // non-batch mode
+ mDeviceCallback->handleCallbackTimestamp(
+ (DataCallbackMsg) msg_type, handle, memId, index, timestamp);
+ } else { // batch mode
+ Mutex::Autolock _l(mBatchLock);
+ size_t inflightSize = mInflightBatch.size();
+ if (inflightSize == 0) {
+ mBatchMsgType = msg_type;
+ } else if (mBatchMsgType != msg_type) {
+ ALOGE("%s: msg_type change (from %d to %d) is not supported!",
+ __FUNCTION__, mBatchMsgType, msg_type);
+ return;
+ }
+ mInflightBatch.push_back({handle, memId, index, timestamp});
+
+ // Send batched frames to camera framework
+ if (mInflightBatch.size() >= batchSize) {
+ mDeviceCallback->handleCallbackTimestampBatch(
+ (DataCallbackMsg) mBatchMsgType, mInflightBatch);
+ mInflightBatch.clear();
+ }
+ }
+}
+
void CameraDevice::sDataCbTimestamp(nsecs_t timestamp, int32_t msg_type,
const camera_memory_t *data, unsigned index, void *user) {
ALOGV("%s", __FUNCTION__);
@@ -478,8 +515,7 @@
object->mDeviceCallback->dataCallbackTimestamp(
(DataCallbackMsg) msg_type, mem->handle.mId, index, timestamp);
} else {
- object->mDeviceCallback->handleCallbackTimestamp(
- (DataCallbackMsg) msg_type, handle, mem->handle.mId, index, timestamp);
+ object->handleCallbackTimestamp(timestamp, msg_type, mem->handle.mId, index, handle);
}
}
}
@@ -840,6 +876,17 @@
return Void();
}
+Return<void> CameraDevice::releaseRecordingFrameHandleBatch(
+ const hidl_vec<VideoFrameMessage>& msgs) {
+ ALOGV("%s(%s)", __FUNCTION__, mCameraId.c_str());
+ Mutex::Autolock _l(mLock);
+ for (auto& msg : msgs) {
+ releaseRecordingFrameLocked(
+ msg.data, msg.bufferIndex, msg.frameData.getNativeHandle());
+ }
+ return Void();
+}
+
Return<Status> CameraDevice::autoFocus() {
ALOGV("%s(%s)", __FUNCTION__, mCameraId.c_str());
Mutex::Autolock _l(mLock);
diff --git a/camera/device/1.0/default/CameraDevice_1_0.h b/camera/device/1.0/default/CameraDevice_1_0.h
index 66d7519..a9f55c2 100644
--- a/camera/device/1.0/default/CameraDevice_1_0.h
+++ b/camera/device/1.0/default/CameraDevice_1_0.h
@@ -95,6 +95,8 @@
Return<void> releaseRecordingFrame(uint32_t memId, uint32_t bufferIndex) override;
Return<void> releaseRecordingFrameHandle(
uint32_t memId, uint32_t bufferIndex, const hidl_handle& frame) override;
+ Return<void> releaseRecordingFrameHandleBatch(
+ const hidl_vec<VideoFrameMessage>&) override;
Return<Status> autoFocus() override;
Return<Status> cancelAutoFocus() override;
Return<Status> takePicture() override;
@@ -178,6 +180,16 @@
bool mMetadataMode = false;
+ mutable Mutex mBatchLock;
+ // Start of protection scope for mBatchLock
+ uint32_t mBatchSize = 0; // 0 for non-batch mode, set to other value to start batching
+ int32_t mBatchMsgType; // Maybe only allow DataCallbackMsg::VIDEO_FRAME?
+ std::vector<HandleTimestampMessage> mInflightBatch;
+ // End of protection scope for mBatchLock
+
+ void handleCallbackTimestamp(
+ nsecs_t timestamp, int32_t msg_type,
+ MemoryId memId , unsigned index, native_handle_t* handle);
void releaseRecordingFrameLocked(uint32_t memId, uint32_t bufferIndex, const native_handle_t*);
// shared memory methods
@@ -187,13 +199,13 @@
// Device callback forwarding methods
static void sNotifyCb(int32_t msg_type, int32_t ext1, int32_t ext2, void *user);
static void sDataCb(int32_t msg_type, const camera_memory_t *data, unsigned int index,
- camera_frame_metadata_t *metadata, void *user);
+ camera_frame_metadata_t *metadata, void *user);
static void sDataCbTimestamp(nsecs_t timestamp, int32_t msg_type,
const camera_memory_t *data, unsigned index, void *user);
// Preview window callback forwarding methods
static int sDequeueBuffer(struct preview_stream_ops* w,
- buffer_handle_t** buffer, int *stride);
+ buffer_handle_t** buffer, int *stride);
static int sLockBuffer(struct preview_stream_ops* w, buffer_handle_t* buffer);
@@ -204,7 +216,7 @@
static int sSetBufferCount(struct preview_stream_ops* w, int count);
static int sSetBuffersGeometry(struct preview_stream_ops* w,
- int width, int height, int format);
+ int width, int height, int format);
static int sSetCrop(struct preview_stream_ops *w, int left, int top, int right, int bottom);
diff --git a/camera/device/1.0/types.hal b/camera/device/1.0/types.hal
index bf632d1..0b3445f 100644
--- a/camera/device/1.0/types.hal
+++ b/camera/device/1.0/types.hal
@@ -16,6 +16,10 @@
package android.hardware.camera.device@1.0;
+import android.hardware.graphics.allocator@2.0::types;
+
+typedef bitfield<ProducerUsage> ProducerUsageFlags;
+
enum CameraFacing : uint32_t {
/** The facing of the camera is opposite to that of the screen. */
BACK = 0,
@@ -254,3 +258,36 @@
* between the HAL and the framework.
*/
typedef uint32_t MemoryId;
+
+/*
+ * Struct containing arguments of ICameraDeviceCallback::handleCallbackTimestamp.
+ * Used to send a batch of messages in ICameraDeviceCallback::handleCallbackTimestampBatch.
+ */
+struct HandleTimestampMessage {
+ // The handle of image buffer data.
+ handle frameData;
+
+ // A memory handle to the buffer containing the data
+ MemoryId data;
+
+ // The offset into the memory handle where the buffer starts.
+ uint32_t bufferIndex;
+
+ // The time this buffer was captured by the camera, in nanoseconds
+ int64_t timestamp;
+};
+
+/*
+ * Struct containing arguments of ICameraDevice::releaseRecordingFrameHandle.
+ * Used by camera framework to send a batch of recording frames back to camera HAL.
+ */
+struct VideoFrameMessage {
+ // The handle of image buffer data.
+ handle frameData;
+
+ // A memory handle to the buffer containing the data
+ MemoryId data;
+
+ // The offset into the memory handle where the buffer starts.
+ uint32_t bufferIndex;
+};
diff --git a/camera/device/3.2/ICameraDeviceSession.hal b/camera/device/3.2/ICameraDeviceSession.hal
index e186c8d..731fc76 100644
--- a/camera/device/3.2/ICameraDeviceSession.hal
+++ b/camera/device/3.2/ICameraDeviceSession.hal
@@ -183,6 +183,11 @@
* client, the HAL must process the requests in order of lowest index to
* highest index.
*
+ * The cachesToRemove argument contains a list of buffer caches (see
+ * StreamBuffer document for more information on buffer cache) to be removed
+ * by camera HAL. Camera HAL must remove these cache entries whether or not
+ * this method returns OK.
+ *
* The actual request processing is asynchronous, with the results of
* capture being returned by the HAL through the processCaptureResult()
* call. This call requires the result metadata to be available, but output
@@ -238,7 +243,8 @@
* that HAL processed successfully before HAL runs into an error.
*
*/
- processCaptureRequest(vec<CaptureRequest> requests)
+ processCaptureRequest(vec<CaptureRequest> requests,
+ vec<BufferCache> cachesToRemove)
generates (Status status, uint32_t numRequestProcessed);
/**
diff --git a/camera/device/3.2/default/Android.bp b/camera/device/3.2/default/Android.bp
index e0dc5ff..5a81d41 100644
--- a/camera/device/3.2/default/Android.bp
+++ b/camera/device/3.2/default/Android.bp
@@ -17,7 +17,8 @@
"libcamera_metadata"
],
static_libs: [
- "android.hardware.camera.common@1.0-helper"
+ "android.hardware.camera.common@1.0-helper",
+ "libgrallocusage"
],
export_include_dirs: ["."]
}
diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp
index fb1d1ff..f2f9e5e 100644
--- a/camera/device/3.2/default/CameraDeviceSession.cpp
+++ b/camera/device/3.2/default/CameraDeviceSession.cpp
@@ -611,7 +611,7 @@
return Void();
}
mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].rotation;
- mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].usage;
+ mStreamMap[id].usage = convertFromHidlUsage(requestedConfiguration.streams[i].usage);
}
streams[i] = &mStreamMap[id];
}
@@ -678,8 +678,32 @@
mCirculatingBuffers.erase(id);
}
+void CameraDeviceSession::updateBufferCaches(const hidl_vec<BufferCache>& cachesToRemove) {
+ Mutex::Autolock _l(mInflightLock);
+ for (auto& cache : cachesToRemove) {
+ auto cbsIt = mCirculatingBuffers.find(cache.streamId);
+ if (cbsIt == mCirculatingBuffers.end()) {
+ // The stream could have been removed
+ continue;
+ }
+ CirculatingBuffers& cbs = cbsIt->second;
+ auto it = cbs.find(cache.bufferId);
+ if (it != cbs.end()) {
+ sHandleImporter.freeBuffer(it->second);
+ cbs.erase(it);
+ } else {
+ ALOGE("%s: stream %d buffer %" PRIu64 " is not cached",
+ __FUNCTION__, cache.streamId, cache.bufferId);
+ }
+ }
+}
+
Return<void> CameraDeviceSession::processCaptureRequest(
- const hidl_vec<CaptureRequest>& requests, processCaptureRequest_cb _hidl_cb) {
+ const hidl_vec<CaptureRequest>& requests,
+ const hidl_vec<BufferCache>& cachesToRemove,
+ processCaptureRequest_cb _hidl_cb) {
+ updateBufferCaches(cachesToRemove);
+
uint32_t numRequestProcessed = 0;
Status s = Status::OK;
for (size_t i = 0; i < requests.size(); i++, numRequestProcessed++) {
diff --git a/camera/device/3.2/default/CameraDeviceSession.h b/camera/device/3.2/default/CameraDeviceSession.h
index 8923c05..781056e 100644
--- a/camera/device/3.2/default/CameraDeviceSession.h
+++ b/camera/device/3.2/default/CameraDeviceSession.h
@@ -85,7 +85,9 @@
Return<void> configureStreams(
const StreamConfiguration& requestedConfiguration, configureStreams_cb _hidl_cb) override;
Return<void> processCaptureRequest(
- const hidl_vec<CaptureRequest>& requests, processCaptureRequest_cb _hidl_cb) override;
+ const hidl_vec<CaptureRequest>& requests,
+ const hidl_vec<BufferCache>& cachesToRemove,
+ processCaptureRequest_cb _hidl_cb) override;
Return<Status> flush() override;
Return<void> close() override;
@@ -234,6 +236,8 @@
void cleanupBuffersLocked(int id);
+ void updateBufferCaches(const hidl_vec<BufferCache>& cachesToRemove);
+
Status processOneCaptureRequest(const CaptureRequest& request);
/**
* Static callback forwarding methods from HAL to instance
diff --git a/camera/device/3.2/default/convert.cpp b/camera/device/3.2/default/convert.cpp
index 35676df..c99d903 100644
--- a/camera/device/3.2/default/convert.cpp
+++ b/camera/device/3.2/default/convert.cpp
@@ -15,8 +15,12 @@
*/
#define LOG_TAG "android.hardware.camera.device@3.2-convert-impl"
+#include <inttypes.h>
+
#include <android/log.h>
+#include <grallocusage/GrallocUsageConversion.h>
+
#include "include/convert.h"
namespace android {
@@ -28,6 +32,7 @@
using ::android::hardware::graphics::common::V1_0::Dataspace;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
+using ::android::hardware::graphics::allocator::V2_0::ConsumerUsage;
using ::android::hardware::camera::device::V3_2::ConsumerUsageFlags;
using ::android::hardware::camera::device::V3_2::ProducerUsageFlags;
@@ -66,23 +71,37 @@
dst->format = (int) src.format;
dst->data_space = (android_dataspace_t) src.dataSpace;
dst->rotation = (int) src.rotation;
- dst->usage = (uint32_t) src.usage;
+ dst->usage = convertFromHidlUsage(src.usage);
// Fields to be filled by HAL (max_buffers, priv) are initialized to 0
dst->max_buffers = 0;
dst->priv = 0;
return;
}
+uint32_t convertFromHidlUsage(ConsumerUsageFlags usage) {
+ uint32_t dstUsage = 0;
+ dstUsage = ::android_convertGralloc1To0Usage(/*producerUsage*/ 0, usage);
+ // Compatibility workaround - add HW_CAMERA_ZSL when ConsumerUsage.CAMERA is set, to
+ // match pre-HIDL expected usage flags
+ if ( (usage & ConsumerUsage::CAMERA) == static_cast<uint64_t>(ConsumerUsage::CAMERA)) {
+ dstUsage |= GRALLOC_USAGE_HW_CAMERA_ZSL;
+ }
+ return dstUsage;
+}
+
void convertToHidl(const Camera3Stream* src, HalStream* dst) {
dst->id = src->mId;
dst->overrideFormat = (PixelFormat) src->format;
dst->maxBuffers = src->max_buffers;
+ ConsumerUsageFlags consumerUsage;
+ ProducerUsageFlags producerUsage;
+ ::android_convertGralloc0To1Usage(src->usage, &producerUsage, &consumerUsage);
if (src->stream_type == CAMERA3_STREAM_OUTPUT) {
dst->consumerUsage = (ConsumerUsageFlags) 0;
- dst->producerUsage = (ProducerUsageFlags) src->usage;
+ dst->producerUsage = producerUsage;
} else if (src->stream_type == CAMERA3_STREAM_INPUT) {
dst->producerUsage = (ProducerUsageFlags) 0;
- dst->consumerUsage = (ConsumerUsageFlags) src->usage;
+ dst->consumerUsage = consumerUsage;
} else {
//Should not reach here per current HIDL spec, but we might end up adding
// bi-directional stream to HIDL.
diff --git a/camera/device/3.2/default/include/convert.h b/camera/device/3.2/default/include/convert.h
index 96891f0..7c8e02f 100644
--- a/camera/device/3.2/default/include/convert.h
+++ b/camera/device/3.2/default/include/convert.h
@@ -45,6 +45,8 @@
void convertFromHidl(const Stream &src, Camera3Stream* dst);
void convertToHidl(const Camera3Stream* src, HalStream* dst);
+uint32_t convertFromHidlUsage(ConsumerUsageFlags usage);
+
void convertFromHidl(
buffer_handle_t*, BufferStatus, camera3_stream_t*, int acquireFence, // inputs
camera3_stream_buffer_t* dst);
diff --git a/camera/device/3.2/types.hal b/camera/device/3.2/types.hal
index fd75528..5ae7a18 100644
--- a/camera/device/3.2/types.hal
+++ b/camera/device/3.2/types.hal
@@ -958,3 +958,25 @@
uint32_t partialResult;
};
+
+/**
+ * BufferCache:
+ *
+ * A list of cached bufferIds associated with a certain stream.
+ * Buffers are passed between camera service and camera HAL via bufferId except
+ * the first time a new buffer is being passed to HAL in CaptureRequest. Camera
+ * service and camera HAL therefore need to maintain a cached map of bufferId
+ * and corresponing native handle.
+ *
+ */
+struct BufferCache {
+ /**
+ * The ID of the stream this list is associated with.
+ */
+ int32_t streamId;
+
+ /**
+ * A cached buffer ID associated with streamId.
+ */
+ uint64_t bufferId;
+};
diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp
index a0be5cb..02c42c9 100644
--- a/camera/provider/2.4/vts/functional/Android.bp
+++ b/camera/provider/2.4/vts/functional/Android.bp
@@ -33,7 +33,10 @@
"libgui",
"libui"
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: [
+ "VtsHalHidlTargetTestBase",
+ "libgrallocusage"
+ ],
cflags: [
"-O0",
"-g",
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index a79c9fa..4d3c6eb 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -21,6 +21,7 @@
#include "CameraParameters.h"
#include <system/camera.h>
#include <android/log.h>
+#include <grallocusage/GrallocUsageConversion.h>
#include <ui/GraphicBuffer.h>
#include <VtsHalHidlTargetTestBase.h>
#include <gui/BufferQueue.h>
@@ -53,6 +54,7 @@
using ::android::Surface;
using ::android::CameraParameters;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
+using ::android::hardware::graphics::allocator::V2_0::ConsumerUsage;
using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
using ::android::hardware::camera::common::V1_0::Status;
using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
@@ -60,7 +62,10 @@
using ::android::hardware::camera::common::V1_0::TorchModeStatus;
using ::android::hardware::camera::provider::V2_4::ICameraProvider;
using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback;
+using ::android::hardware::camera::device::V3_2::ProducerUsageFlags;
+using ::android::hardware::camera::device::V3_2::ConsumerUsageFlags;
using ::android::hardware::camera::device::V3_2::ICameraDevice;
+using ::android::hardware::camera::device::V3_2::BufferCache;
using ::android::hardware::camera::device::V3_2::CaptureRequest;
using ::android::hardware::camera::device::V3_2::CaptureResult;
using ::android::hardware::camera::device::V3_2::ICameraDeviceCallback;
@@ -79,6 +84,7 @@
using ::android::hardware::camera::device::V3_2::MsgType;
using ::android::hardware::camera::device::V3_2::ErrorMsg;
using ::android::hardware::camera::device::V3_2::ErrorCode;
+using ::android::hardware::camera::device::V1_0::ProducerUsageFlags;
using ::android::hardware::camera::device::V1_0::CameraFacing;
using ::android::hardware::camera::device::V1_0::NotifyCallbackMsg;
using ::android::hardware::camera::device::V1_0::CommandType;
@@ -86,6 +92,7 @@
using ::android::hardware::camera::device::V1_0::CameraFrameMetadata;
using ::android::hardware::camera::device::V1_0::ICameraDevicePreviewCallback;
using ::android::hardware::camera::device::V1_0::FrameCallbackFlag;
+using ::android::hardware::camera::device::V1_0::HandleTimestampMessage;
const char kCameraPassthroughServiceName[] = "legacy/0";
const uint32_t kMaxPreviewWidth = 1920;
@@ -231,7 +238,7 @@
Return<Status> setCrop(int32_t left, int32_t top,
int32_t right, int32_t bottom) override;
- Return<Status> setUsage(ProducerUsage usage) override;
+ Return<Status> setUsage(ProducerUsageFlags usage) override;
Return<Status> setSwapInterval(int32_t interval) override;
@@ -406,10 +413,11 @@
return mapToStatus(rc);
}
-Return<Status> PreviewWindowCb::setUsage(ProducerUsage usage) {
- auto rc = native_window_set_usage(mAnw.get(), static_cast<int>(usage));
+Return<Status> PreviewWindowCb::setUsage(ProducerUsageFlags usage) {
+ int dstUsage = ::android_convertGralloc1To0Usage(usage, /*consumerUsage*/ 0);
+ auto rc = native_window_set_usage(mAnw.get(), dstUsage);
if (rc == ::android::OK) {
- mPreviewUsage = static_cast<int>(usage);
+ mPreviewUsage = dstUsage;
}
return mapToStatus(rc);
}
@@ -510,6 +518,10 @@
const hidl_handle& frameData,uint32_t data,
uint32_t bufferIndex, int64_t timestamp) override;
+ Return<void> handleCallbackTimestampBatch(DataCallbackMsg msgType,
+ const ::android::hardware::hidl_vec<HandleTimestampMessage>& batch) override;
+
+
private:
CameraHidlTest *mParent; // Parent object
};
@@ -666,6 +678,23 @@
return Void();
}
+Return<void> CameraHidlTest::Camera1DeviceCb::handleCallbackTimestampBatch(
+ DataCallbackMsg msgType,
+ const hidl_vec<HandleTimestampMessage>& batch) {
+ std::unique_lock<std::mutex> l(mParent->mLock);
+ for (auto& msg : batch) {
+ mParent->mDataMessageTypeReceived = msgType;
+ mParent->mVideoBufferIndex = msg.bufferIndex;
+ if (mParent->mMemoryPool.count(msg.data) == 0) {
+ ADD_FAILURE() << "memory pool ID " << msg.data << " not found";
+ }
+ mParent->mVideoData = msg.data;
+ mParent->mVideoNativeHandle = msg.frameData;
+ mParent->mResultCondition.notify_one();
+ }
+ return Void();
+}
+
Return<void> CameraHidlTest::DeviceCb::processCaptureResult(
const hidl_vec<CaptureResult>& results) {
if (nullptr == mParent) {
@@ -2176,7 +2205,7 @@
static_cast<uint32_t> (input.width),
static_cast<uint32_t> (input.height),
static_cast<PixelFormat> (input.format),
- GRALLOC_USAGE_HW_CAMERA_ZSL, 0,
+ static_cast<ConsumerUsageFlags>(ConsumerUsage::CAMERA), 0,
StreamRotation::ROTATION_0};
Stream inputStream = {streamId++, StreamType::INPUT,
static_cast<uint32_t> (input.width),
@@ -2408,7 +2437,7 @@
static_cast<uint32_t> (blobIter.width),
static_cast<uint32_t> (blobIter.height),
static_cast<PixelFormat> (blobIter.format),
- GRALLOC_USAGE_HW_VIDEO_ENCODER, 0,
+ static_cast<ConsumerUsageFlags>(ConsumerUsage::VIDEO_ENCODER), 0,
StreamRotation::ROTATION_0};
::android::hardware::hidl_vec<Stream> streams = {
videoStream, blobStream};
@@ -2481,8 +2510,10 @@
Status status = Status::INTERNAL_ERROR;
uint32_t numRequestProcessed = 0;
+ hidl_vec<BufferCache> cachesToRemove;
Return<void> returnStatus = session->processCaptureRequest(
{request},
+ cachesToRemove,
[&status, &numRequestProcessed] (auto s, uint32_t n) {
status = s;
numRequestProcessed = n;
@@ -2513,6 +2544,7 @@
returnStatus = session->processCaptureRequest(
{request},
+ cachesToRemove,
[&status, &numRequestProcessed] (auto s, uint32_t n) {
status = s;
numRequestProcessed = n;
@@ -2579,8 +2611,10 @@
//Settings were not correctly initialized, we should fail here
Status status = Status::OK;
uint32_t numRequestProcessed = 0;
+ hidl_vec<BufferCache> cachesToRemove;
Return<void> ret = session->processCaptureRequest(
{request},
+ cachesToRemove,
[&status, &numRequestProcessed] (auto s, uint32_t n) {
status = s;
numRequestProcessed = n;
@@ -2632,8 +2666,10 @@
//Output buffers are missing, we should fail here
Status status = Status::OK;
uint32_t numRequestProcessed = 0;
+ hidl_vec<BufferCache> cachesToRemove;
ret = session->processCaptureRequest(
{request},
+ cachesToRemove,
[&status, &numRequestProcessed] (auto s, uint32_t n) {
status = s;
numRequestProcessed = n;
@@ -2701,8 +2737,10 @@
Status status = Status::INTERNAL_ERROR;
uint32_t numRequestProcessed = 0;
+ hidl_vec<BufferCache> cachesToRemove;
ret = session->processCaptureRequest(
{request},
+ cachesToRemove,
[&status, &numRequestProcessed] (auto s, uint32_t n) {
status = s;
numRequestProcessed = n;
diff --git a/configstore/1.0/default/android.hardware.configstore@1.0-service.rc b/configstore/1.0/default/android.hardware.configstore@1.0-service.rc
index 8741bdd..563d854 100644
--- a/configstore/1.0/default/android.hardware.configstore@1.0-service.rc
+++ b/configstore/1.0/default/android.hardware.configstore@1.0-service.rc
@@ -1,4 +1,4 @@
service configstore-hal-1-0 /vendor/bin/hw/android.hardware.configstore@1.0-service
- class hal
+ class hal animation
user system
group system
diff --git a/gnss/1.0/IGnssDebug.hal b/gnss/1.0/IGnssDebug.hal
index 716ba88..4c4cfb8 100644
--- a/gnss/1.0/IGnssDebug.hal
+++ b/gnss/1.0/IGnssDebug.hal
@@ -71,8 +71,8 @@
/** Represents heading in degrees. */
float bearingDegrees;
/**
- * Estimated horizontal accuracy of position expressed in meters, radial,
- * 68% confidence.
+ * Estimated horizontal accuracy of position expressed in meters,
+ * radial, 68% confidence.
*/
double horizontalAccuracyMeters;
/**
@@ -126,7 +126,11 @@
/** Defines the constellation type of the given SV. */
GnssConstellationType constellation;
- /** Defines the ephemeris type of the satellite. */
+ /**
+ * Defines the standard broadcast ephemeris or almanac availability for
+ * the satellite. To report status of predicted orbit and clock
+ * information, see the serverPrediction fields below.
+ */
SatelliteEphemerisType ephemerisType;
/** Defines the ephemeris source of the satellite. */
SatelliteEphemerisSource ephemerisSource;
@@ -143,7 +147,7 @@
float ephemerisAgeSeconds;
/**
- * True if a server has provided a predicted orbit (& clock) for
+ * True if a server has provided a predicted orbit and clock model for
* this satellite.
*/
bool serverPredictionIsAvailable;
diff --git a/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc b/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc
index 3e2edda..9a08f66 100644
--- a/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc
+++ b/graphics/allocator/2.0/default/android.hardware.graphics.allocator@2.0-service.rc
@@ -1,5 +1,5 @@
service gralloc-2-0 /vendor/bin/hw/android.hardware.graphics.allocator@2.0-service
- class hal
+ class hal animation
user system
group graphics drmrpc
onrestart restart surfaceflinger
diff --git a/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc b/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc
index b6060db..51b0e3b 100644
--- a/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc
+++ b/graphics/composer/2.1/default/android.hardware.graphics.composer@2.1-service.rc
@@ -1,5 +1,5 @@
service hwcomposer-2-1 /vendor/bin/hw/android.hardware.graphics.composer@2.1-service
- class hal
+ class hal animation
user system
group graphics drmrpc
capabilities SYS_NICE
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index aa3bc9c..cf9f66e 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -22,10 +22,8 @@
#include <android/hardware/nfc/1.0/types.h>
#include <hardware/nfc.h>
+#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
-#include <chrono>
-#include <condition_variable>
-#include <mutex>
using ::android::hardware::nfc::V1_0::INfc;
using ::android::hardware::nfc::V1_0::INfcClientCallback;
@@ -55,6 +53,43 @@
#define VERSION 0x11
#define TIMEOUT_PERIOD 5
+constexpr char kCallbackNameSendEvent[] = "sendEvent";
+constexpr char kCallbackNameSendData[] = "sendData";
+
+class NfcClientCallbackArgs {
+ public:
+ NfcEvent last_event_;
+ NfcStatus last_status_;
+ NfcData last_data_;
+};
+
+/* Callback class for data & Event. */
+class NfcClientCallback
+ : public ::testing::VtsHalHidlTargetCallbackBase<NfcClientCallbackArgs>,
+ public INfcClientCallback {
+ public:
+ virtual ~NfcClientCallback() = default;
+
+ /* sendEvent callback function - Records the Event & Status
+ * and notifies the TEST
+ **/
+ Return<void> sendEvent(NfcEvent event, NfcStatus event_status) override {
+ NfcClientCallbackArgs args;
+ args.last_event_ = event;
+ args.last_status_ = event_status;
+ NotifyFromCallback(kCallbackNameSendEvent, args);
+ return Void();
+ };
+
+ /* sendData callback function. Records the data and notifies the TEST*/
+ Return<void> sendData(const NfcData& data) override {
+ NfcClientCallbackArgs args;
+ args.last_data_ = data;
+ NotifyFromCallback(kCallbackNameSendData, args);
+ return Void();
+ };
+};
+
// The main test class for NFC HIDL HAL.
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@@ -62,88 +97,28 @@
nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>();
ASSERT_NE(nfc_, nullptr);
- nfc_cb_ = new NfcClientCallback(*this);
+ nfc_cb_ = new NfcClientCallback();
ASSERT_NE(nfc_cb_, nullptr);
- count = 0;
- last_event_ = NfcEvent::ERROR;
- last_status_ = NfcStatus::FAILED;
-
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
virtual void TearDown() override {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
- /* Used as a mechanism to inform the test about data/event callback */
- inline void notify() {
- std::unique_lock<std::mutex> lock(mtx);
- count++;
- cv.notify_one();
- }
-
- /* Test code calls this function to wait for data/event callback */
- inline std::cv_status wait() {
- std::unique_lock<std::mutex> lock(mtx);
-
- std::cv_status status = std::cv_status::no_timeout;
- auto now = std::chrono::system_clock::now();
- while (count == 0) {
- status = cv.wait_until(lock, now + std::chrono::seconds(TIMEOUT_PERIOD));
- if (status == std::cv_status::timeout) return status;
- }
- count--;
- return status;
- }
-
- /* Callback class for data & Event. */
- class NfcClientCallback : public INfcClientCallback {
- NfcHidlTest& parent_;
-
- public:
- NfcClientCallback(NfcHidlTest& parent) : parent_(parent){};
-
- virtual ~NfcClientCallback() = default;
-
- /* sendEvent callback function - Records the Event & Status
- * and notifies the TEST
- **/
- Return<void> sendEvent(NfcEvent event, NfcStatus event_status) override {
- parent_.last_event_ = event;
- parent_.last_status_ = event_status;
- parent_.notify();
- return Void();
- };
-
- /* sendData callback function. Records the data and notifies the TEST*/
- Return<void> sendData(const NfcData& data) override {
- size_t size = parent_.last_data_.size();
- parent_.last_data_.resize(size + 1);
- parent_.last_data_[size] = data;
- parent_.notify();
- return Void();
- };
- };
-
sp<INfc> nfc_;
- sp<INfcClientCallback> nfc_cb_;
- NfcEvent last_event_;
- NfcStatus last_status_;
- hidl_vec<NfcData> last_data_;
-
- private:
- std::mutex mtx;
- std::condition_variable cv;
- int count;
+ sp<NfcClientCallback> nfc_cb_;
};
// A class for test environment setup (kept since this file is a template).
@@ -175,12 +150,12 @@
NfcData data = cmd;
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for CORE_RESET_RSP
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(6ul, last_data_[0].size());
- EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
- EXPECT_GE(VERSION, last_data_[0][4]);
- EXPECT_EQ(0ul, last_data_[0][5]);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(6ul, res.args->last_data_.size());
+ EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+ EXPECT_GE(VERSION, res.args->last_data_[4]);
+ EXPECT_EQ(0ul, res.args->last_data_[5]);
}
/*
@@ -194,12 +169,12 @@
NfcData data = cmd;
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for CORE_RESET_RSP
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(6ul, last_data_[0].size());
- EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
- EXPECT_GE(VERSION, last_data_[0][4]);
- EXPECT_EQ(1ul, last_data_[0][5]);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(6ul, res.args->last_data_.size());
+ EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+ EXPECT_GE(VERSION, res.args->last_data_[4]);
+ EXPECT_EQ(1ul, res.args->last_data_[5]);
}
/*
@@ -214,10 +189,10 @@
NfcData data = cmd;
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for RSP
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(4ul, last_data_[0].size());
- EXPECT_EQ(SYNTAX_ERROR, last_data_[0][3]);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(4ul, res.args->last_data_.size());
+ EXPECT_EQ(SYNTAX_ERROR, res.args->last_data_[3]);
}
/*
@@ -236,29 +211,27 @@
size_t size = data.size();
for (int i = 0; i < 100; i++) {
- last_data_.resize(0);
data.resize(++size);
data[size - 1] = 0xFF;
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for CORE_INTERFACE_ERROR_NTF
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(5ul, last_data_[0].size());
- EXPECT_EQ(0x60, last_data_[0][0]);
- EXPECT_EQ(0x08, last_data_[0][1]);
- EXPECT_EQ(0x02, last_data_[0][2]);
- EXPECT_EQ(SYNTAX_ERROR, last_data_[0][3]);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(5ul, res.args->last_data_.size());
+ EXPECT_EQ(0x60, res.args->last_data_[0]);
+ EXPECT_EQ(0x08, res.args->last_data_[1]);
+ EXPECT_EQ(0x02, res.args->last_data_[2]);
+ EXPECT_EQ(SYNTAX_ERROR, res.args->last_data_[3]);
}
cmd = CORE_CONN_CREATE_CMD;
data = cmd;
- last_data_.resize(0);
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for CORE_CONN_CREATE_RSP
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(7ul, last_data_[0].size());
- EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(7ul, res.args->last_data_.size());
+ EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
}
/*
* Bandwidth:
@@ -273,40 +246,48 @@
NfcData data = cmd;
EXPECT_EQ(data.size(), nfc_->write(data));
// Wait for CORE_CONN_CREATE_RSP
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(1ul, last_data_.size());
- EXPECT_EQ(7ul, last_data_[0].size());
- EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
- uint8_t conn_id = last_data_[0][6];
- uint32_t max_payload_size = last_data_[0][4];
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(7ul, res.args->last_data_.size());
+ EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+ uint8_t conn_id = res.args->last_data_[6];
+ uint32_t max_payload_size = res.args->last_data_[4];
for (int loops = 0; loops < NUMBER_LOOPS; loops++) {
- last_data_.resize(0);
- data.resize(max_payload_size + LOOP_BACK_HEADER_SIZE);
- data[0] = conn_id;
- data[1] = 0x00;
- data[2] = max_payload_size;
- for (uint32_t i = 0; i < max_payload_size; i++) {
- data[i + LOOP_BACK_HEADER_SIZE] = i;
+ res.args->last_data_.resize(0);
+ data.resize(max_payload_size + LOOP_BACK_HEADER_SIZE);
+ data[0] = conn_id;
+ data[1] = 0x00;
+ data[2] = max_payload_size;
+ for (uint32_t i = 0; i < max_payload_size; i++) {
+ data[i + LOOP_BACK_HEADER_SIZE] = i;
}
EXPECT_EQ(max_payload_size + LOOP_BACK_HEADER_SIZE, nfc_->write(data));
// Wait for data and CORE_CONN_CREDITS_NTF
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- // Check if the same data was recieved back
- EXPECT_EQ(2ul, last_data_.size());
+ auto res1 = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res1.no_timeout);
+ auto res2 = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+ EXPECT_TRUE(res2.no_timeout);
+ // Check if the same data was received back
+ EXPECT_TRUE(res1.args);
+ EXPECT_TRUE(res2.args);
+ NfcData credits_ntf = res1.args->last_data_;
+ NfcData received_data = res2.args->last_data_;
/* It is possible that CORE_CONN_CREDITS_NTF is received before data,
* Find the order and do further checks depending on that */
- uint8_t data_index = last_data_[0].size() == data.size() ? 0 : 1;
- EXPECT_EQ(data.size(), last_data_[data_index].size());
+ if (received_data.size() != data.size()) {
+ credits_ntf = res2.args->last_data_;
+ received_data = res1.args->last_data_;
+ }
+ EXPECT_EQ(data.size(), received_data.size());
for (size_t i = 0; i < data.size(); i++) {
- EXPECT_EQ(data[i], last_data_[data_index][i]);
+ EXPECT_EQ(data[i], received_data[i]);
}
- EXPECT_EQ(6ul, last_data_[!data_index].size());
+ EXPECT_EQ(6ul, credits_ntf.size());
// Check if the credit is refilled to 1
- EXPECT_EQ(1, last_data_[!data_index][5]);
+ EXPECT_EQ(1, credits_ntf[5]);
}
}
@@ -319,9 +300,10 @@
TEST_F(NfcHidlTest, PowerCycle) {
EXPECT_EQ(NfcStatus::OK, nfc_->powerCycle());
// Wait for NfcEvent.OPEN_CPLT
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
/*
@@ -332,17 +314,19 @@
TEST_F(NfcHidlTest, PowerCycleAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
EXPECT_EQ(NfcStatus::FAILED, nfc_->powerCycle());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
/*
@@ -353,13 +337,16 @@
TEST_F(NfcHidlTest, CoreInitialized) {
NfcData data;
data.resize(1);
- for (int i = 0; i <= 6; i++)
- {
- data[0] = i;
- EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
- // Wait for NfcEvent.POST_INIT_CPLT
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
+ // These parameters might lead to device specific proprietary behavior
+ // Using > 10 values should result in predictable and common results for
+ // most devices.
+ for (int i = 10; i <= 16; i++) {
+ data[0] = i;
+ EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
+ // Wait for NfcEvent.POST_INIT_CPLT
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::POST_INIT_CPLT, res.args->last_event_);
}
}
@@ -380,17 +367,19 @@
TEST_F(NfcHidlTest, ControlGrantedAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
/* PreDiscover:
@@ -409,17 +398,19 @@
TEST_F(NfcHidlTest, PreDiscoverAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
/*
@@ -430,20 +421,21 @@
TEST_F(NfcHidlTest, CloseAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
EXPECT_EQ(NfcStatus::FAILED, nfc_->close());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
- EXPECT_EQ(NfcStatus::OK, last_status_);
+ res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+ EXPECT_TRUE(res.no_timeout);
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+ EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
}
-
/*
* OpenAfterOpen:
* Calls open() multiple times
diff --git a/tests/Android.bp b/tests/Android.bp
index 31dc75e..6f99a36 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -9,6 +9,8 @@
"foo/1.0",
"foo/1.0/default",
"foo/1.0/default/lib",
+ "hash/1.0",
+ "hash/1.0/default",
"inheritance/1.0",
"inheritance/1.0/default",
"libhwbinder/1.0",
diff --git a/tests/hash/1.0/Android.bp b/tests/hash/1.0/Android.bp
new file mode 100644
index 0000000..c217e5c
--- /dev/null
+++ b/tests/hash/1.0/Android.bp
@@ -0,0 +1,59 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.tests.hash@1.0_hal",
+ srcs: [
+ "IHash.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.hash@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.hash@1.0",
+ srcs: [
+ ":android.hardware.tests.hash@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/hash/1.0/HashAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.hash@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.hash@1.0",
+ srcs: [
+ ":android.hardware.tests.hash@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/hash/1.0/IHash.h",
+ "android/hardware/tests/hash/1.0/IHwHash.h",
+ "android/hardware/tests/hash/1.0/BnHwHash.h",
+ "android/hardware/tests/hash/1.0/BpHwHash.h",
+ "android/hardware/tests/hash/1.0/BsHash.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.tests.hash@1.0",
+ generated_sources: ["android.hardware.tests.hash@1.0_genc++"],
+ generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hidl.base@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hidl.base@1.0",
+ ],
+}
diff --git a/tests/hash/1.0/Android.mk b/tests/hash/1.0/Android.mk
new file mode 100644
index 0000000..15428b4
--- /dev/null
+++ b/tests/hash/1.0/Android.mk
@@ -0,0 +1,76 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.tests.hash@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base@1.0-java \
+
+
+#
+# Build IHash.hal
+#
+GEN := $(intermediates)/android/hardware/tests/hash/V1_0/IHash.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHash.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.tests.hash@1.0::IHash
+
+$(GEN): $(LOCAL_PATH)/IHash.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.tests.hash@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hidl.base@1.0-java-static \
+
+
+#
+# Build IHash.hal
+#
+GEN := $(intermediates)/android/hardware/tests/hash/V1_0/IHash.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHash.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.tests.hash@1.0::IHash
+
+$(GEN): $(LOCAL_PATH)/IHash.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/hash/1.0/IHash.hal b/tests/hash/1.0/IHash.hal
new file mode 100644
index 0000000..ba48384
--- /dev/null
+++ b/tests/hash/1.0/IHash.hal
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tests.hash@1.0;
+
+/**
+ * Test interface for hashing HAL files.
+ * This file is FREEZED to ensure its hash doesn't change.
+ */
+interface IHash {
+ /**
+ * Dummy.
+ */
+ dummy();
+ /**
+ * Dummy.
+ */
+ functions();
+};
diff --git a/tests/hash/1.0/default/Android.bp b/tests/hash/1.0/default/Android.bp
new file mode 100644
index 0000000..e798a66
--- /dev/null
+++ b/tests/hash/1.0/default/Android.bp
@@ -0,0 +1,15 @@
+cc_library_shared {
+ name: "android.hardware.tests.hash@1.0-impl",
+ relative_install_path: "hw",
+ proprietary: true,
+ srcs: [
+ "Hash.cpp",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "android.hardware.tests.hash@1.0",
+ "android.hidl.base@1.0",
+ ],
+}
diff --git a/tests/hash/1.0/default/Hash.cpp b/tests/hash/1.0/default/Hash.cpp
new file mode 100644
index 0000000..caed721
--- /dev/null
+++ b/tests/hash/1.0/default/Hash.cpp
@@ -0,0 +1,30 @@
+#include "Hash.h"
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace hash {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::hash::V1_0::IHash follow.
+Return<void> Hash::dummy() {
+ return Void();
+}
+
+Return<void> Hash::functions() {
+ return Void();
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+IHash* HIDL_FETCH_IHash(const char* /* name */) {
+ return new Hash();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace hash
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/hash/1.0/default/Hash.h b/tests/hash/1.0/default/Hash.h
new file mode 100644
index 0000000..dd1678f
--- /dev/null
+++ b/tests/hash/1.0/default/Hash.h
@@ -0,0 +1,43 @@
+#ifndef ANDROID_HARDWARE_TESTS_HASH_V1_0_HASH_H
+#define ANDROID_HARDWARE_TESTS_HASH_V1_0_HASH_H
+
+#include <android/hardware/tests/hash/1.0/IHash.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace hash {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::hash::V1_0::IHash;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct Hash : public IHash {
+ // Methods from ::android::hardware::tests::hash::V1_0::IHash follow.
+ Return<void> dummy() override;
+ Return<void> functions() override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+};
+
+extern "C" IHash* HIDL_FETCH_IHash(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace hash
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_HASH_V1_0_HASH_H