Merge "Fix test case for setSimCardPower radio api." into oc-dev
diff --git a/audio/2.0/default/Android.mk b/audio/2.0/default/Android.mk
index 93f7ad0..621853c 100644
--- a/audio/2.0/default/Android.mk
+++ b/audio/2.0/default/Android.mk
@@ -43,6 +43,12 @@
android.hardware.audio.common@2.0 \
android.hardware.audio.common@2.0-util \
+LOCAL_HEADER_LIBRARIES := \
+ libaudioclient_headers \
+ libaudio_system_headers \
+ libhardware_headers \
+ libmedia_headers \
+
LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index 2745607..0798bbe 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -20,6 +20,7 @@
#include <android/log.h>
#include <hardware/audio.h>
+#include <memory>
#include <utils/Trace.h>
#include "StreamIn.h"
@@ -52,7 +53,11 @@
mDataMQ(dataMQ),
mStatusMQ(statusMQ),
mEfGroup(efGroup),
- mBuffer(new uint8_t[dataMQ->getQuantumCount()]) {
+ mBuffer(nullptr) {
+ }
+ bool init() {
+ mBuffer.reset(new(std::nothrow) uint8_t[mDataMQ->getQuantumCount()]);
+ return mBuffer != nullptr;
}
virtual ~ReadThread() {}
@@ -308,8 +313,14 @@
return Void();
}
std::unique_ptr<CommandMQ> tempCommandMQ(new CommandMQ(1));
- std::unique_ptr<DataMQ> tempDataMQ(
- new DataMQ(frameSize * framesCount, true /* EventFlag */));
+ if (frameSize > std::numeric_limits<size_t>::max() / framesCount) {
+ ALOGE("Requested buffer is too big, %d*%d can not fit in size_t", frameSize, framesCount);
+ _hidl_cb(Result::INVALID_ARGUMENTS,
+ CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
+ return Void();
+ }
+ std::unique_ptr<DataMQ> tempDataMQ(new DataMQ(frameSize * framesCount, true /* EventFlag */));
+
std::unique_ptr<StatusMQ> tempStatusMQ(new StatusMQ(1));
if (!tempCommandMQ->isValid() || !tempDataMQ->isValid() || !tempStatusMQ->isValid()) {
ALOGE_IF(!tempCommandMQ->isValid(), "command MQ is invalid");
@@ -319,8 +330,11 @@
CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
return Void();
}
- status = EventFlag::createEventFlag(tempDataMQ->getEventFlagWord(), &mEfGroup);
- if (status != OK || !mEfGroup) {
+ EventFlag* tempRawEfGroup{};
+ status = EventFlag::createEventFlag(tempDataMQ->getEventFlagWord(), &tempRawEfGroup);
+ std::unique_ptr<EventFlag, void(*)(EventFlag*)> tempElfGroup(tempRawEfGroup, [](auto *ef) {
+ EventFlag::deleteEventFlag(&ef); });
+ if (status != OK || !tempElfGroup) {
ALOGE("failed creating event flag for data MQ: %s", strerror(-status));
_hidl_cb(Result::INVALID_ARGUMENTS,
CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
@@ -328,13 +342,18 @@
}
// Create and launch the thread.
- mReadThread = new ReadThread(
+ auto tempReadThread = std::make_unique<ReadThread>(
&mStopReadThread,
mStream,
tempCommandMQ.get(),
tempDataMQ.get(),
tempStatusMQ.get(),
- mEfGroup);
+ tempElfGroup.get());
+ if (!tempReadThread->init()) {
+ _hidl_cb(Result::INVALID_ARGUMENTS,
+ CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
+ return Void();
+ }
status = mReadThread->run("reader", PRIORITY_URGENT_AUDIO);
if (status != OK) {
ALOGW("failed to start reader thread: %s", strerror(-status));
@@ -346,6 +365,8 @@
mCommandMQ = std::move(tempCommandMQ);
mDataMQ = std::move(tempDataMQ);
mStatusMQ = std::move(tempStatusMQ);
+ mReadThread = tempReadThread.release();
+ mEfGroup = tempElfGroup.release();
threadInfo.pid = getpid();
threadInfo.tid = mReadThread->getTid();
_hidl_cb(Result::OK,
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 88045a0..3339b63 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -18,6 +18,8 @@
//#define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_AUDIO
+#include <memory>
+
#include <android/log.h>
#include <hardware/audio.h>
#include <utils/Trace.h>
@@ -50,7 +52,11 @@
mDataMQ(dataMQ),
mStatusMQ(statusMQ),
mEfGroup(efGroup),
- mBuffer(new uint8_t[dataMQ->getQuantumCount()]) {
+ mBuffer(nullptr) {
+ }
+ bool init() {
+ mBuffer.reset(new(std::nothrow) uint8_t[mDataMQ->getQuantumCount()]);
+ return mBuffer != nullptr;
}
virtual ~WriteThread() {}
@@ -291,8 +297,15 @@
return Void();
}
std::unique_ptr<CommandMQ> tempCommandMQ(new CommandMQ(1));
- std::unique_ptr<DataMQ> tempDataMQ(
- new DataMQ(frameSize * framesCount, true /* EventFlag */));
+
+ if (frameSize > std::numeric_limits<size_t>::max() / framesCount) {
+ ALOGE("Requested buffer is too big, %d*%d can not fit in size_t", frameSize, framesCount);
+ _hidl_cb(Result::INVALID_ARGUMENTS,
+ CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
+ return Void();
+ }
+ std::unique_ptr<DataMQ> tempDataMQ(new DataMQ(frameSize * framesCount, true /* EventFlag */));
+
std::unique_ptr<StatusMQ> tempStatusMQ(new StatusMQ(1));
if (!tempCommandMQ->isValid() || !tempDataMQ->isValid() || !tempStatusMQ->isValid()) {
ALOGE_IF(!tempCommandMQ->isValid(), "command MQ is invalid");
@@ -302,8 +315,11 @@
CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
return Void();
}
- status = EventFlag::createEventFlag(tempDataMQ->getEventFlagWord(), &mEfGroup);
- if (status != OK || !mEfGroup) {
+ EventFlag* tempRawEfGroup{};
+ status = EventFlag::createEventFlag(tempDataMQ->getEventFlagWord(), &tempRawEfGroup);
+ std::unique_ptr<EventFlag, void(*)(EventFlag*)> tempElfGroup(tempRawEfGroup,[](auto *ef) {
+ EventFlag::deleteEventFlag(&ef); });
+ if (status != OK || !tempElfGroup) {
ALOGE("failed creating event flag for data MQ: %s", strerror(-status));
_hidl_cb(Result::INVALID_ARGUMENTS,
CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
@@ -311,14 +327,19 @@
}
// Create and launch the thread.
- mWriteThread = new WriteThread(
+ auto tempWriteThread = std::make_unique<WriteThread>(
&mStopWriteThread,
mStream,
tempCommandMQ.get(),
tempDataMQ.get(),
tempStatusMQ.get(),
- mEfGroup);
- status = mWriteThread->run("writer", PRIORITY_URGENT_AUDIO);
+ tempElfGroup.get());
+ if (!tempWriteThread->init()) {
+ _hidl_cb(Result::INVALID_ARGUMENTS,
+ CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo);
+ return Void();
+ }
+ status = tempWriteThread->run("writer", PRIORITY_URGENT_AUDIO);
if (status != OK) {
ALOGW("failed to start writer thread: %s", strerror(-status));
_hidl_cb(Result::INVALID_ARGUMENTS,
@@ -329,6 +350,8 @@
mCommandMQ = std::move(tempCommandMQ);
mDataMQ = std::move(tempDataMQ);
mStatusMQ = std::move(tempStatusMQ);
+ mWriteThread = tempWriteThread.release();
+ mEfGroup = tempElfGroup.release();
threadInfo.pid = getpid();
threadInfo.tid = mWriteThread->getTid();
_hidl_cb(Result::OK,
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 1021569..4b00f35 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -171,6 +171,7 @@
sp<IDevice> baseDevice;
ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
returnIn(result, baseDevice)));
+ ASSERT_OK(result);
ASSERT_TRUE(baseDevice != nullptr);
environment->registerTearDown([]{ device.clear(); });
@@ -990,10 +991,12 @@
};
TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) {
+ doc::test("Implementation must expose pause, resume and drain capabilities");
Capability(stream.get());
}
TEST_P(OutputStreamTest, GetRenderPosition) {
+ doc::test("The render position should be 0 on a not started");
uint32_t dspFrames;
ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
if (res == Result::NOT_SUPPORTED) {
@@ -1005,6 +1008,7 @@
}
TEST_P(OutputStreamTest, GetNextWriteTimestamp) {
+ doc::test("The render position of a stream just created should be 0");
uint64_t timestampUs;
ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
if (res == Result::NOT_SUPPORTED) {
@@ -1030,6 +1034,7 @@
}
TEST_P(OutputStreamTest, SetCallback) {
+ doc::test("If supported, registering callback for async operation should never fail");
if (!isAsyncModeSupported(stream.get())) {
doc::partialTest("The stream does not support async operations");
return;
@@ -1039,6 +1044,7 @@
}
TEST_P(OutputStreamTest, clearCallback) {
+ doc::test("If supported, clearing a callback to go back to sync operation should not fail");
if (!isAsyncModeSupported(stream.get())) {
doc::partialTest("The stream does not support async operations");
return;
@@ -1049,6 +1055,7 @@
}
TEST_P(OutputStreamTest, Resume) {
+ doc::test("If supported, a stream should fail to resume if not previously paused");
if (!Capability(stream.get()).resume) {
doc::partialTest("The output stream does not support resume");
return;
@@ -1057,6 +1064,7 @@
}
TEST_P(OutputStreamTest, Pause) {
+ doc::test("If supported, a stream should fail to pause if not previously started");
if (!Capability(stream.get()).pause) {
doc::partialTest("The output stream does not support pause");
return;
@@ -1066,21 +1074,24 @@
static void testDrain(IStreamOut *stream, AudioDrain type) {
if (!Capability(stream).drain) {
- doc::partialTest("The output stream does not support pause");
+ doc::partialTest("The output stream does not support drain");
return;
}
ASSERT_RESULT(Result::OK, stream->drain(type));
}
TEST_P(OutputStreamTest, DrainAll) {
+ doc::test("If supported, a stream should always succeed to drain");
testDrain(stream.get(), AudioDrain::ALL);
}
TEST_P(OutputStreamTest, DrainEarlyNotify) {
+ doc::test("If supported, a stream should always succeed to drain");
testDrain(stream.get(), AudioDrain::EARLY_NOTIFY);
}
TEST_P(OutputStreamTest, FlushStop) {
+ doc::test("If supported, a stream should always succeed to flush");
auto ret = stream->flush();
ASSERT_TRUE(ret.isOk());
if (ret == Result::NOT_SUPPORTED) {
@@ -1091,6 +1102,7 @@
}
TEST_P(OutputStreamTest, GetPresentationPositionStop) {
+ doc::test("If supported, a stream should always succeed to retrieve the presentation position");
uint64_t frames;
TimeSpec mesureTS;
ASSERT_OK(stream->getPresentationPosition(returnIn(res, frames, mesureTS)));
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
index e39a908..0486a5c 100644
--- a/audio/common/2.0/default/Android.bp
+++ b/audio/common/2.0/default/Android.bp
@@ -24,9 +24,14 @@
export_include_dirs: ["."],
shared_libs: [
+ "liblog",
"libutils",
"libhidlbase",
"android.hardware.audio.common@2.0",
],
+ header_libs: [
+ "libaudio_system_headers",
+ "libhardware_headers",
+ ],
}
diff --git a/audio/effect/2.0/default/Android.mk b/audio/effect/2.0/default/Android.mk
index bbcf298..f89d4f7 100644
--- a/audio/effect/2.0/default/Android.mk
+++ b/audio/effect/2.0/default/Android.mk
@@ -36,4 +36,11 @@
android.hardware.audio.effect@2.0 \
android.hidl.memory@1.0 \
+LOCAL_HEADER_LIBRARIES := \
+ libaudio_system_headers \
+ libaudioclient_headers \
+ libeffects_headers \
+ libhardware_headers \
+ libmedia_headers \
+
include $(BUILD_SHARED_LIBRARY)
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 fd59802..8e9089d 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
@@ -78,6 +78,8 @@
std::list<VehiclePropValue *> values;
};
+using ClientId = uint64_t;
+
class SubscriptionManager {
public:
using OnPropertyUnsubscribed = std::function<void(int32_t)>;
@@ -100,7 +102,8 @@
* Updates subscription. Returns the vector of properties subscription that
* needs to be updated in VehicleHAL.
*/
- StatusCode addOrUpdateSubscription(const sp<IVehicleCallback>& callback,
+ StatusCode addOrUpdateSubscription(ClientId clientId,
+ const sp<IVehicleCallback>& callback,
const hidl_vec<SubscribeOptions>& optionList,
std::list<SubscribeOptions>* outUpdatedOptions);
@@ -119,7 +122,7 @@
* If there are no clients subscribed to given properties than callback function provided
* in the constructor will be called.
*/
- void unsubscribe(const sp<IVehicleCallback>& callback, int32_t propId);
+ void unsubscribe(ClientId clientId, int32_t propId);
private:
std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId,
int32_t area,
@@ -131,7 +134,8 @@
sp<HalClientVector> getClientsForPropertyLocked(int32_t propId) const;
- sp<HalClient> getOrCreateHalClientLocked(const sp<IVehicleCallback> &callback);
+ sp<HalClient> getOrCreateHalClientLocked(ClientId callingPid,
+ const sp<IVehicleCallback>& callback);
void onCallbackDead(uint64_t cookie);
@@ -160,7 +164,7 @@
mutable std::mutex mLock;
- std::map<sp<IVehicleCallback>, sp<HalClient>> mClients;
+ std::map<ClientId, sp<HalClient>> mClients;
std::map<int32_t, sp<HalClientVector>> mPropToClients;
std::map<int32_t, SubscribeOptions> mHalEventSubscribeOptions;
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 1d45f4b..c1e9e88 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
@@ -101,6 +101,7 @@
static bool isSampleRateFixed(VehiclePropertyChangeMode mode);
static float checkSampleRate(const VehiclePropConfig& config,
float sampleRate);
+ static ClientId getClientId(const sp<IVehicleCallback>& callback);
private:
VehicleHal* mHal;
std::unique_ptr<VehiclePropConfigIndex> mConfigIndex;
diff --git a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
index e0f3f31..74f0a5f 100644
--- a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
@@ -97,6 +97,7 @@
}
StatusCode SubscriptionManager::addOrUpdateSubscription(
+ ClientId clientId,
const sp<IVehicleCallback> &callback,
const hidl_vec<SubscribeOptions> &optionList,
std::list<SubscribeOptions>* outUpdatedSubscriptions) {
@@ -106,7 +107,7 @@
ALOGI("SubscriptionManager::addOrUpdateSubscription, callback: %p", callback.get());
- const sp<HalClient>& client = getOrCreateHalClientLocked(callback);
+ const sp<HalClient>& client = getOrCreateHalClientLocked(clientId, callback);
if (client.get() == nullptr) {
return StatusCode::INTERNAL_ERROR;
}
@@ -221,10 +222,11 @@
}
sp<HalClient> SubscriptionManager::getOrCreateHalClientLocked(
- const sp<IVehicleCallback>& callback) {
- auto it = mClients.find(callback);
+ ClientId clientId, const sp<IVehicleCallback>& callback) {
+ auto it = mClients.find(clientId);
+
if (it == mClients.end()) {
- uint64_t cookie = reinterpret_cast<uint64_t>(callback.get());
+ uint64_t cookie = reinterpret_cast<uint64_t>(clientId);
ALOGI("Creating new client and linking to death recipient, cookie: 0x%" PRIx64, cookie);
auto res = callback->linkToDeath(mCallbackDeathRecipient, cookie);
if (!res.isOk()) { // Client is already dead?
@@ -234,18 +236,18 @@
}
sp<HalClient> client = new HalClient(callback);
- mClients.emplace(callback, client);
+ mClients.insert({clientId, client});
return client;
} else {
return it->second;
}
}
-void SubscriptionManager::unsubscribe(const sp<IVehicleCallback>& callback,
+void SubscriptionManager::unsubscribe(ClientId clientId,
int32_t propId) {
MuxGuard g(mLock);
auto propertyClients = getClientsForPropertyLocked(propId);
- auto clientIter = mClients.find(callback);
+ auto clientIter = mClients.find(clientId);
if (clientIter == mClients.end()) {
ALOGW("Unable to unsubscribe: no callback found, propId: 0x%x", propId);
} else {
@@ -285,12 +287,12 @@
void SubscriptionManager::onCallbackDead(uint64_t cookie) {
ALOGI("%s, cookie: 0x%" PRIx64, __func__, cookie);
- IVehicleCallback* callback = reinterpret_cast<IVehicleCallback*>(cookie);
+ ClientId clientId = cookie;
std::vector<int32_t> props;
{
MuxGuard g(mLock);
- const auto& it = mClients.find(callback);
+ const auto& it = mClients.find(clientId);
if (it == mClients.end()) {
return; // Nothing to do here, client wasn't subscribed to any properties.
}
@@ -299,7 +301,7 @@
}
for (int32_t propId : props) {
- unsubscribe(callback, propId);
+ unsubscribe(clientId, propId);
}
}
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
index f452be8..ae543bb 100644
--- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
@@ -22,6 +22,7 @@
#include <fstream>
#include <android/log.h>
+#include <android/hardware/automotive/vehicle/2.0/BpHwVehicleCallback.h>
#include "VehicleUtils.h"
@@ -154,7 +155,8 @@
}
std::list<SubscribeOptions> updatedOptions;
- auto res = mSubscriptionManager.addOrUpdateSubscription(callback, verifiedOptions,
+ auto res = mSubscriptionManager.addOrUpdateSubscription(getClientId(callback),
+ callback, verifiedOptions,
&updatedOptions);
if (StatusCode::OK != res) {
ALOGW("%s failed to subscribe, error code: %d", __func__, res);
@@ -170,7 +172,7 @@
Return<StatusCode> VehicleHalManager::unsubscribe(const sp<IVehicleCallback>& callback,
int32_t propId) {
- mSubscriptionManager.unsubscribe(callback, propId);
+ mSubscriptionManager.unsubscribe(getClientId(callback), propId);
return StatusCode::OK;
}
@@ -341,6 +343,18 @@
mHal->unsubscribe(propertyId);
}
+ClientId VehicleHalManager::getClientId(const sp<IVehicleCallback>& callback) {
+ //TODO(b/32172906): rework this to get some kind of unique id for callback interface when this
+ // feature is ready in HIDL.
+
+ if (callback->isRemote()) {
+ BpHwVehicleCallback* hwCallback = static_cast<BpHwVehicleCallback*>(callback.get());
+ return static_cast<ClientId>(reinterpret_cast<intptr_t>(hwCallback->onAsBinder()));
+ } else {
+ return static_cast<ClientId>(reinterpret_cast<intptr_t>(callback.get()));
+ }
+}
+
} // namespace V2_0
} // namespace vehicle
} // namespace automotive
diff --git a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
index 7ec9b79..5688dd6 100644
--- a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
+++ b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
@@ -119,8 +119,10 @@
TEST_F(SubscriptionManagerTest, multipleClients) {
std::list<SubscribeOptions> updatedOptions;
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb2, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(2, cb2, subscrToProp1, &updatedOptions));
auto clients = manager.getSubscribedClients(
PROP1,
@@ -132,7 +134,8 @@
TEST_F(SubscriptionManagerTest, negativeCases) {
std::list<SubscribeOptions> updatedOptions;
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions));
// Wrong zone
auto clients = manager.getSubscribedClients(
@@ -158,7 +161,8 @@
TEST_F(SubscriptionManagerTest, mulipleSubscriptions) {
std::list<SubscribeOptions> updatedOptions;
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, subscrToProp1,
+ &updatedOptions));
auto clients = manager.getSubscribedClients(
PROP1,
@@ -169,7 +173,7 @@
// Same property, but different zone, to make sure we didn't unsubscribe
// from previous zone.
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, {
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, {
SubscribeOptions {
.propId = PROP1,
.vehicleAreas = toInt(VehicleAreaZone::ROW_2),
@@ -190,15 +194,17 @@
TEST_F(SubscriptionManagerTest, unsubscribe) {
std::list<SubscribeOptions> updatedOptions;
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb2, subscrToProp2, &updatedOptions));
- ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb3, subscrToProp1and2,
- &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(2, cb2, subscrToProp2, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK,
+ manager.addOrUpdateSubscription(3, cb3, subscrToProp1and2, &updatedOptions));
- ASSERT_ALL_EXISTS({cb1, cb3}, extractCallbacks(clientsToProp1()));
+ ASSERT_ALL_EXISTS({ cb1, cb3 }, extractCallbacks(clientsToProp1()));
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
- manager.unsubscribe(cb1, PROP1);
+ manager.unsubscribe(1, PROP1);
assertOnPropertyUnsubscribedNotCalled();
ASSERT_ALL_EXISTS({cb3}, extractCallbacks(clientsToProp1()));
@@ -206,20 +212,20 @@
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
// No one subscribed to PROP1, subscription for PROP2 is not affected.
- manager.unsubscribe(cb3, PROP1);
+ manager.unsubscribe(3, PROP1);
assertLastUnsubscribedProperty(PROP1);
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
- manager.unsubscribe(cb3, PROP2);
+ manager.unsubscribe(3, PROP2);
assertOnPropertyUnsubscribedNotCalled();
ASSERT_ALL_EXISTS({cb2}, extractCallbacks(clientsToProp2()));
// The last client unsubscribed from this property.
- manager.unsubscribe(cb2, PROP2);
+ manager.unsubscribe(2, PROP2);
assertLastUnsubscribedProperty(PROP2);
// No one subscribed anymore
- manager.unsubscribe(cb1, PROP1);
+ manager.unsubscribe(1, PROP1);
assertLastUnsubscribedProperty(PROP1);
}
diff --git a/configstore/1.0/vts/functional/Android.bp b/configstore/1.0/vts/functional/Android.bp
new file mode 100644
index 0000000..1775538
--- /dev/null
+++ b/configstore/1.0/vts/functional/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+ name: "VtsHalConfigstoreV1_0TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalConfigstoreV1_0TargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "libhidlbase",
+ "liblog",
+ "libutils",
+ "android.hardware.configstore@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ]
+}
+
diff --git a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
new file mode 100644
index 0000000..95cd30b
--- /dev/null
+++ b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "ConfigstoreHidlHalTest"
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <android-base/logging.h>
+#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
+#include <android/hardware/configstore/1.0/types.h>
+#include <unistd.h>
+
+using ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs;
+using ::android::hardware::configstore::V1_0::OptionalBool;
+using ::android::hardware::configstore::V1_0::OptionalInt64;
+using ::android::hardware::configstore::V1_0::OptionalUInt64;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
+#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
+
+class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ sp<ISurfaceFlingerConfigs> sfConfigs;
+
+ virtual void SetUp() override {
+ sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<
+ ISurfaceFlingerConfigs>();
+ }
+
+ virtual void TearDown() override {}
+};
+
+/**
+ * Ensure all ISurfaceFlingerConfigs.hal function calls are successful.
+ */
+TEST_F(ConfigstoreHidlTest, TestFunctionCalls) {
+ bool tmp;
+
+ Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs(
+ [&tmp](OptionalInt64 arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->vsyncSfEventPhaseOffsetNs(
+ [&tmp](OptionalInt64 arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->useContextPriority(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->hasWideColorDisplay(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->hasHDRDisplay(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->presentTimeOffsetFromVSyncNs(
+ [&tmp](OptionalInt64 arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->useHwcForRGBtoYUV(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->maxVirtualDisplaySize(
+ [&tmp](OptionalUInt64 arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->hasSyncFramework(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->useVrFlinger(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->maxFrameBufferAcquiredBuffers(
+ [&tmp](OptionalInt64 arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+
+ status = sfConfigs->startGraphicsAllocatorService(
+ [&tmp](OptionalBool arg) { tmp = arg.specified; });
+ EXPECT_OK(status);
+}
+
+/**
+ * Ensure repeated call to the same function returns the same result.
+ */
+TEST_F(ConfigstoreHidlTest, TestSameReturnValue) {
+ int64_t original_ret;
+ Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs(
+ [&original_ret](OptionalInt64 arg) { original_ret = arg.value; });
+
+ int64_t next_ret;
+ for (int cnt = 0; cnt < 10; cnt++) {
+ status = sfConfigs->vsyncEventPhaseOffsetNs(
+ [&next_ret](OptionalInt64 arg) { next_ret = arg.value; });
+ EXPECT_EQ(original_ret, next_ret);
+ }
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/configstore/Android.bp b/configstore/Android.bp
index 79b63f6..ba3e62e 100644
--- a/configstore/Android.bp
+++ b/configstore/Android.bp
@@ -1,5 +1,6 @@
// This is an autogenerated file, do not edit.
subdirs = [
"1.0",
+ "1.0/vts/functional",
"utils",
]
diff --git a/contexthub/1.0/default/Android.mk b/contexthub/1.0/default/Android.mk
index 538a6b2..917bfe0 100644
--- a/contexthub/1.0/default/Android.mk
+++ b/contexthub/1.0/default/Android.mk
@@ -13,7 +13,6 @@
libcutils \
libdl \
libhardware \
- libhardware_legacy \
libhidlbase \
libhidltransport \
liblog \
diff --git a/gnss/1.0/default/Android.mk b/gnss/1.0/default/Android.mk
index dd0ebe9..34da64e 100644
--- a/gnss/1.0/default/Android.mk
+++ b/gnss/1.0/default/Android.mk
@@ -45,7 +45,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
libbinder \
diff --git a/keymaster/3.0/default/Android.mk b/keymaster/3.0/default/Android.mk
index c537346..9df5bf8 100644
--- a/keymaster/3.0/default/Android.mk
+++ b/keymaster/3.0/default/Android.mk
@@ -34,7 +34,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
libhidlbase \
libhidltransport \
diff --git a/light/2.0/default/Android.mk b/light/2.0/default/Android.mk
index 3439c9b..1f44e66 100644
--- a/light/2.0/default/Android.mk
+++ b/light/2.0/default/Android.mk
@@ -34,7 +34,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
LOCAL_SHARED_LIBRARIES += \
diff --git a/sensors/1.0/default/Android.mk b/sensors/1.0/default/Android.mk
index bc1cfbd..d114542 100644
--- a/sensors/1.0/default/Android.mk
+++ b/sensors/1.0/default/Android.mk
@@ -14,8 +14,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
- libhardware \
LOCAL_SHARED_LIBRARIES += \
libhidlbase \
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 9c0fe45..e8d28a3 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -4,6 +4,7 @@
name: "android.hardware.tests.libhwbinder@1.0_hal",
srcs: [
"IBenchmark.hal",
+ "IScheduleTest.hal",
],
}
@@ -16,6 +17,7 @@
],
out: [
"android/hardware/tests/libhwbinder/1.0/BenchmarkAll.cpp",
+ "android/hardware/tests/libhwbinder/1.0/ScheduleTestAll.cpp",
],
}
@@ -32,6 +34,11 @@
"android/hardware/tests/libhwbinder/1.0/BnHwBenchmark.h",
"android/hardware/tests/libhwbinder/1.0/BpHwBenchmark.h",
"android/hardware/tests/libhwbinder/1.0/BsBenchmark.h",
+ "android/hardware/tests/libhwbinder/1.0/IScheduleTest.h",
+ "android/hardware/tests/libhwbinder/1.0/IHwScheduleTest.h",
+ "android/hardware/tests/libhwbinder/1.0/BnHwScheduleTest.h",
+ "android/hardware/tests/libhwbinder/1.0/BpHwScheduleTest.h",
+ "android/hardware/tests/libhwbinder/1.0/BsScheduleTest.h",
],
}
diff --git a/tests/libhwbinder/1.0/Android.mk b/tests/libhwbinder/1.0/Android.mk
index 4a5f779..bb430fb 100644
--- a/tests/libhwbinder/1.0/Android.mk
+++ b/tests/libhwbinder/1.0/Android.mk
@@ -34,6 +34,25 @@
$(GEN): $(LOCAL_PATH)/IBenchmark.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IScheduleTest.hal
+#
+GEN := $(intermediates)/android/hardware/tests/libhwbinder/V1_0/IScheduleTest.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IScheduleTest.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.libhwbinder@1.0::IScheduleTest
+
+$(GEN): $(LOCAL_PATH)/IScheduleTest.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_JAVA_LIBRARY)
@@ -69,6 +88,25 @@
$(GEN): $(LOCAL_PATH)/IBenchmark.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IScheduleTest.hal
+#
+GEN := $(intermediates)/android/hardware/tests/libhwbinder/V1_0/IScheduleTest.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IScheduleTest.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.libhwbinder@1.0::IScheduleTest
+
+$(GEN): $(LOCAL_PATH)/IScheduleTest.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/libhwbinder/1.0/IBenchmark.hal b/tests/libhwbinder/1.0/IBenchmark.hal
index 6b266e2..b3aa320 100644
--- a/tests/libhwbinder/1.0/IBenchmark.hal
+++ b/tests/libhwbinder/1.0/IBenchmark.hal
@@ -17,5 +17,5 @@
package android.hardware.tests.libhwbinder@1.0;
interface IBenchmark {
- sendVec(vec<uint8_t> data) generates (vec<uint8_t> return_data);
+ sendVec(vec<uint8_t> data) generates (vec<uint8_t> data);
};
diff --git a/tests/libhwbinder/1.0/IScheduleTest.hal b/tests/libhwbinder/1.0/IScheduleTest.hal
new file mode 100644
index 0000000..b3f57c5
--- /dev/null
+++ b/tests/libhwbinder/1.0/IScheduleTest.hal
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tests.libhwbinder@1.0;
+
+interface IScheduleTest {
+ send(uint32_t cfg, uint32_t callerSta) generates (uint32_t data);
+};
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
index e690ca5..fa1b2b3 100644
--- a/tests/libhwbinder/1.0/default/Android.bp
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -1,18 +1,16 @@
cc_library_shared {
name: "android.hardware.tests.libhwbinder@1.0-impl",
- defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
"Benchmark.cpp",
+ "ScheduleTest.cpp",
],
-
shared_libs: [
- "libbase",
"libhidlbase",
"libhidltransport",
- "liblog",
"libutils",
"android.hardware.tests.libhwbinder@1.0",
+ "android.hidl.base@1.0",
],
}
diff --git a/tests/libhwbinder/1.0/default/ScheduleTest.cpp b/tests/libhwbinder/1.0/default/ScheduleTest.cpp
new file mode 100644
index 0000000..6356953
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/ScheduleTest.cpp
@@ -0,0 +1,84 @@
+#include "ScheduleTest.h"
+#include <pthread.h>
+#include <iomanip>
+#include <iostream>
+
+using namespace std;
+
+#define ASSERT(cond) \
+ do { \
+ if (!(cond)) { \
+ cerr << __func__ << ":" << __LINE__ << " condition:" << #cond \
+ << " failed\n" \
+ << endl; \
+ exit(EXIT_FAILURE); \
+ } \
+ } while (0)
+
+static int threadPri() {
+ struct sched_param param;
+ int policy;
+ ASSERT(!pthread_getschedparam(pthread_self(), &policy, ¶m));
+ return param.sched_priority;
+}
+
+static void threadDump(const char* prefix, int verbose) {
+ struct sched_param param;
+ int policy;
+ if (!verbose) return;
+ cout << "--------------------------------------------------" << endl;
+ cout << setw(12) << left << prefix << " pid: " << getpid()
+ << " tid: " << gettid() << " cpu: " << sched_getcpu() << endl;
+ ASSERT(!pthread_getschedparam(pthread_self(), &policy, ¶m));
+ string s = (policy == SCHED_OTHER)
+ ? "SCHED_OTHER"
+ : (policy == SCHED_FIFO)
+ ? "SCHED_FIFO"
+ : (policy == SCHED_RR) ? "SCHED_RR" : "???";
+ cout << setw(12) << left << s << param.sched_priority << endl;
+ return;
+}
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest
+// follow.
+Return<uint32_t> ScheduleTest::send(uint32_t cfg, uint32_t callerSta) {
+ // TODO implement
+ int priority = threadPri();
+ int priority_caller = (callerSta >> 16) & 0xffff;
+ int verbose = cfg & 1;
+ threadDump("hwbinder", verbose);
+ uint32_t h = 0, s = 0;
+ if (priority_caller != priority) {
+ h++;
+ if (verbose) {
+ cout << "err priority_caller:" << priority_caller
+ << ", priority:" << priority << endl;
+ }
+ }
+ int cpu = sched_getcpu();
+ int cpu_caller = (callerSta)&0xffff;
+ if (cpu != cpu_caller) {
+ s++;
+ }
+ return (h << 16) | (s & 0xffff);
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+IScheduleTest* HIDL_FETCH_IScheduleTest(const char* /* name */) {
+ return new ScheduleTest();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace libhwbinder
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/libhwbinder/1.0/default/ScheduleTest.h b/tests/libhwbinder/1.0/default/ScheduleTest.h
new file mode 100644
index 0000000..ad6dd9d
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/ScheduleTest.h
@@ -0,0 +1,41 @@
+#ifndef ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H
+#define ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H
+
+#include <android/hardware/tests/libhwbinder/1.0/IScheduleTest.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest;
+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 ScheduleTest : public IScheduleTest {
+ // Methods from ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest
+ // follow.
+ Return<uint32_t> send(uint32_t cfg, uint32_t callerSta) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace libhwbinder
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H
diff --git a/thermal/1.0/default/Android.mk b/thermal/1.0/default/Android.mk
index 2d25dc3..113020a 100644
--- a/thermal/1.0/default/Android.mk
+++ b/thermal/1.0/default/Android.mk
@@ -29,7 +29,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
LOCAL_SHARED_LIBRARIES += \