Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-interfaces: Commit

hardware/interfaces


Commit MetaInfo

Révisionb72c8722a7e6cfe84f75fbd7996d6f9ea6abee51 (tree)
l'heure2017-10-11 16:21:12
Auteurandroid-build-team Robot <android-build-team-robot@goog...>
Commiterandroid-build-team Robot

Message de Log

Snap for 4388906 from 0b9f25d5c9eadb5eda353f5cc01a8bd2d05cf5f2 to oc-mr1-release

Change-Id: I4d9f66c09a4eaa9bb2237ab1cceddc5914e18f76

Change Summary

Modification

--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -49,6 +49,13 @@ using ::android::sp;
4949 struct Stream : public IStream, public ParametersUtil {
5050 explicit Stream(audio_stream_t* stream);
5151
52+ /** 1GiB is the maximum buffer size the HAL client is allowed to request.
53+ * This value has been chosen to be under SIZE_MAX and still big enough
54+ * for all audio use case.
55+ * Keep private for 2.0, put in .hal in 2.1
56+ */
57+ static constexpr uint32_t MAX_BUFFER_SIZE = 2 << 30 /* == 1GiB */;
58+
5259 // Methods from ::android::hardware::audio::V2_0::IStream follow.
5360 Return<uint64_t> getFrameSize() override;
5461 Return<uint64_t> getFrameCount() override;
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -347,14 +347,10 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize,
347347 sendError(Result::INVALID_ARGUMENTS);
348348 return Void();
349349 }
350- // A message queue asserts if it can not handle the requested buffer,
351- // thus the client has to guess the maximum size it can handle
352- // Choose an arbitrary margin for the overhead of a message queue
353- size_t metadataOverhead = 100000;
354- if (frameSize >
355- (std::numeric_limits<size_t>::max() - metadataOverhead) / framesCount) {
356- ALOGE("Buffer too big: %u*%u bytes can not fit in a message queue",
357- frameSize, framesCount);
350+
351+ if (frameSize > Stream::MAX_BUFFER_SIZE / framesCount) {
352+ ALOGE("Buffer too big: %u*%u bytes > MAX_BUFFER_SIZE (%u)", frameSize, framesCount,
353+ Stream::MAX_BUFFER_SIZE);
358354 sendError(Result::INVALID_ARGUMENTS);
359355 return Void();
360356 }
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -323,14 +323,9 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize,
323323 sendError(Result::INVALID_ARGUMENTS);
324324 return Void();
325325 }
326- // A message queue asserts if it can not handle the requested buffer,
327- // thus the client has to guess the maximum size it can handle
328- size_t metadataOverhead =
329- 100000; // Arbitrary margin for the overhead of a message queue
330- if (frameSize >
331- (std::numeric_limits<size_t>::max() - metadataOverhead) / framesCount) {
332- ALOGE("Buffer too big: %u*%u bytes can not fit in a message queue",
333- frameSize, framesCount);
326+ if (frameSize > Stream::MAX_BUFFER_SIZE / framesCount) {
327+ ALOGE("Buffer too big: %u*%u bytes > MAX_BUFFER_SIZE (%u)", frameSize, framesCount,
328+ Stream::MAX_BUFFER_SIZE);
334329 sendError(Result::INVALID_ARGUMENTS);
335330 return Void();
336331 }
--- a/cas/1.0/vts/functional/Android.bp
+++ b/cas/1.0/vts/functional/Android.bp
@@ -25,5 +25,8 @@ cc_test {
2525 "android.hidl.memory@1.0",
2626 "libhidlmemory",
2727 ],
28+ shared_libs: [
29+ "libbinder",
30+ ],
2831 }
2932
--- a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
+++ b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
@@ -25,12 +25,10 @@
2525 #include <android/hardware/cas/1.0/types.h>
2626 #include <android/hardware/cas/native/1.0/IDescrambler.h>
2727 #include <android/hardware/cas/native/1.0/types.h>
28-#include <android/hidl/allocator/1.0/IAllocator.h>
29-#include <android/hidl/memory/1.0/IMapper.h>
28+#include <binder/MemoryDealer.h>
3029 #include <hidl/HidlSupport.h>
3130 #include <hidl/HidlTransportSupport.h>
3231 #include <hidl/Status.h>
33-#include <hidlmemory/mapping.h>
3432 #include <utils/Condition.h>
3533 #include <utils/Mutex.h>
3634
@@ -69,9 +67,9 @@ using android::hardware::hidl_handle;
6967 using android::hardware::hidl_memory;
7068 using android::hardware::Return;
7169 using android::hardware::cas::V1_0::Status;
72-using android::hidl::allocator::V1_0::IAllocator;
73-using android::hidl::memory::V1_0::IMemory;
74-using android::hidl::memory::V1_0::IMapper;
70+using android::IMemory;
71+using android::IMemoryHeap;
72+using android::MemoryDealer;
7573 using android::Mutex;
7674 using android::sp;
7775
@@ -230,7 +228,7 @@ class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
230228 ::testing::AssertionResult openCasSession(std::vector<uint8_t>* sessionId);
231229 ::testing::AssertionResult descrambleTestInputBuffer(const sp<IDescrambler>& descrambler,
232230 Status* descrambleStatus,
233- hidl_memory* hidlInMemory);
231+ sp<IMemory>* hidlInMemory);
234232 };
235233
236234 ::testing::AssertionResult MediaCasHidlTest::createCasPlugin(int32_t caSystemId) {
@@ -271,34 +269,48 @@ class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
271269 }
272270
273271 ::testing::AssertionResult MediaCasHidlTest::descrambleTestInputBuffer(
274- const sp<IDescrambler>& descrambler, Status* descrambleStatus, hidl_memory* hidlInMemory) {
272+ const sp<IDescrambler>& descrambler, Status* descrambleStatus, sp<IMemory>* inMemory) {
275273 hidl_vec<SubSample> hidlSubSamples;
276274 hidlSubSamples.setToExternal(const_cast<SubSample*>(kSubSamples),
277275 (sizeof(kSubSamples) / sizeof(SubSample)), false /*own*/);
278- sp<IAllocator> allocator = IAllocator::getService("ashmem");
279- if (nullptr == allocator.get()) {
276+
277+ sp<MemoryDealer> dealer = new MemoryDealer(sizeof(kInBinaryBuffer), "vts-cas");
278+ if (nullptr == dealer.get()) {
279+ ALOGE("couldn't get MemoryDealer!");
280280 return ::testing::AssertionFailure();
281281 }
282282
283- bool allocateStatus;
284- auto returnStatus =
285- allocator->allocate(sizeof(kInBinaryBuffer), [&](bool status, hidl_memory const& mem) {
286- allocateStatus = status;
287- *hidlInMemory = mem;
288- });
289- if (!returnStatus.isOk() || !allocateStatus) {
283+ sp<IMemory> mem = dealer->allocate(sizeof(kInBinaryBuffer));
284+ if (nullptr == mem.get()) {
285+ ALOGE("couldn't allocate IMemory!");
290286 return ::testing::AssertionFailure();
291287 }
292- android::sp<IMemory> inMemory = mapMemory(*hidlInMemory);
293- if (nullptr == inMemory.get()) {
288+ *inMemory = mem;
289+
290+ // build hidl_memory from memory heap
291+ ssize_t offset;
292+ size_t size;
293+ sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
294+ if (nullptr == heap.get()) {
295+ ALOGE("couldn't get memory heap!");
296+ return ::testing::AssertionFailure();
297+ }
298+
299+ native_handle_t* nativeHandle = native_handle_create(1, 0);
300+ if (!nativeHandle) {
301+ ALOGE("failed to create native handle!");
294302 return ::testing::AssertionFailure();
295303 }
304+ nativeHandle->data[0] = heap->getHeapID();
296305
297- uint8_t* ipBuffer = static_cast<uint8_t*>(static_cast<void*>(inMemory->getPointer()));
306+ uint8_t* ipBuffer = static_cast<uint8_t*>(static_cast<void*>(mem->pointer()));
298307 memcpy(ipBuffer, kInBinaryBuffer, sizeof(kInBinaryBuffer));
299308
300309 SharedBuffer srcBuffer = {
301- .heapBase = *hidlInMemory, .offset = (uint64_t)0, .size = sizeof(kInBinaryBuffer)};
310+ .heapBase = hidl_memory("ashmem", hidl_handle(nativeHandle), heap->getSize()),
311+ .offset = (uint64_t) offset,
312+ .size = (uint64_t) size
313+ };
302314
303315 DestinationBuffer dstBuffer;
304316 dstBuffer.type = BufferType::SHARED_MEMORY;
@@ -461,14 +473,13 @@ TEST_F(MediaCasHidlTest, TestClearKeyApis) {
461473 ASSERT_NE(descrambler, nullptr);
462474
463475 Status descrambleStatus = Status::OK;
464- hidl_memory hidlDataMemory;
476+ sp<IMemory> dataMemory;
465477
466- ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &hidlDataMemory));
478+ ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
467479 EXPECT_EQ(Status::OK, descrambleStatus);
468480
469- android::sp<IMemory> outMemory = mapMemory(hidlDataMemory);
470- ASSERT_NE(nullptr, outMemory.get());
471- uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(outMemory->getPointer()));
481+ ASSERT_NE(nullptr, dataMemory.get());
482+ uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->pointer()));
472483
473484 int compareResult =
474485 memcmp(static_cast<const void*>(opBuffer), static_cast<const void*>(kOutRefBinaryBuffer),
@@ -572,9 +583,9 @@ TEST_F(MediaCasHidlTest, TestClearKeyErrors) {
572583 ASSERT_NE(descrambler, nullptr);
573584
574585 Status descrambleStatus = Status::OK;
575- hidl_memory hidlInMemory;
586+ sp<IMemory> dataMemory;
576587
577- ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &hidlInMemory));
588+ ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
578589 EXPECT_EQ(Status::ERROR_CAS_DECRYPT_UNIT_NOT_INITIALIZED, descrambleStatus);
579590
580591 // Now set a valid session, should still fail because no valid ecm is processed
@@ -582,7 +593,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyErrors) {
582593 EXPECT_TRUE(returnStatus.isOk());
583594 EXPECT_EQ(Status::OK, returnStatus);
584595
585- ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &hidlInMemory));
596+ ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
586597 EXPECT_EQ(Status::ERROR_CAS_DECRYPT, descrambleStatus);
587598 }
588599
--- a/keymaster/3.0/vts/functional/attestation_record.cpp
+++ b/keymaster/3.0/vts/functional/attestation_record.cpp
@@ -274,10 +274,12 @@ ErrorCode parse_attestation_record(const uint8_t* asn1_key_desc, size_t asn1_key
274274 *keymaster_security_level =
275275 static_cast<SecurityLevel>(ASN1_ENUMERATED_get(record->keymaster_security_level));
276276
277- attestation_challenge->setToExternal(record->attestation_challenge->data,
278- record->attestation_challenge->length);
279-
280- unique_id->setToExternal(record->unique_id->data, record->unique_id->length);
277+ auto& chall = record->attestation_challenge;
278+ attestation_challenge->resize(chall->length);
279+ memcpy(attestation_challenge->data(), chall->data, chall->length);
280+ auto& uid = record->unique_id;
281+ unique_id->resize(uid->length);
282+ memcpy(unique_id->data(), uid->data, uid->length);
281283
282284 ErrorCode error = extract_auth_list(record->software_enforced, software_enforced);
283285 if (error != ErrorCode::OK) return error;
Afficher sur ancien navigateur de dépôt.