From 3fac35a98ae8dcc2b475c8a5b7f031c031d011a7 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 16 Jul 2018 10:33:46 -0700 Subject: [PATCH 01/14] HWC2OnFbAdapter: don't claim present fences work We never produce real present fences, so indicate this to the compositor. This will prevent GOOGLE_display_timing & friends from being exposed in the client APIs. Similar to previous change in HWC2On1Adapter. Bug: b/111505197 Change-Id: I601a7f5628d4b218431fc0f1abb4807c9941ce64 --- .../utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp | 30 +++++++++++++++++-- .../include/hwc2onfbadapter/HWC2OnFbAdapter.h | 7 +++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp b/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp index 7c9e6518b7..0f5057756e 100644 --- a/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp +++ b/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp @@ -32,6 +32,8 @@ #include #include +using namespace HWC2; + namespace android { namespace { @@ -629,9 +631,10 @@ hwc2_function_pointer_t getFunctionHook(hwc2_device_t* /*device*/, int32_t descr } } -void getCapabilitiesHook(hwc2_device_t* /*device*/, uint32_t* outCount, - int32_t* /*outCapabilities*/) { - *outCount = 0; +void getCapabilitiesHook(hwc2_device_t* device, uint32_t* outCount, + int32_t* outCapabilities) { + auto& adapter = HWC2OnFbAdapter::cast(device); + adapter.getCapabilities(outCount, outCapabilities); } int closeHook(hw_device_t* device) { @@ -656,6 +659,10 @@ HWC2OnFbAdapter::HWC2OnFbAdapter(framebuffer_device_t* fbDevice) mFbInfo.xdpi_scaled = int(mFbDevice->xdpi * 1000.0f); mFbInfo.ydpi_scaled = int(mFbDevice->ydpi * 1000.0f); + // Present fences aren't supported, always indicate PresentFenceIsNotReliable + // for FB devices + mCapabilities.insert(Capability::PresentFenceIsNotReliable); + mVsyncThread.start(0, mFbInfo.vsync_period_ns); } @@ -791,6 +798,23 @@ void HWC2OnFbAdapter::enableVsync(bool enable) { mVsyncThread.enableCallback(enable); } +void HWC2OnFbAdapter::getCapabilities(uint32_t* outCount, + int32_t* outCapabilities) { + if (outCapabilities == nullptr) { + *outCount = mCapabilities.size(); + return; + } + + auto capabilityIter = mCapabilities.cbegin(); + for (size_t written = 0; written < *outCount; ++written) { + if (capabilityIter == mCapabilities.cend()) { + return; + } + outCapabilities[written] = static_cast(*capabilityIter); + ++capabilityIter; + } +} + int64_t HWC2OnFbAdapter::VsyncThread::now() { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); diff --git a/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h b/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h index d6272fdb17..f1f11ef2bf 100644 --- a/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h +++ b/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h @@ -23,7 +23,11 @@ #include #include +#define HWC2_INCLUDE_STRINGIFICATION +#define HWC2_USE_CPP11 #include +#undef HWC2_INCLUDE_STRINGIFICATION +#undef HWC2_USE_CPP11 struct framebuffer_device_t; @@ -75,6 +79,7 @@ public: void setVsyncCallback(HWC2_PFN_VSYNC callback, hwc2_callback_data_t data); void enableVsync(bool enable); + void getCapabilities(uint32_t* outCount, int32_t* outCapabilities); private: framebuffer_device_t* mFbDevice{nullptr}; @@ -90,6 +95,8 @@ private: buffer_handle_t mBuffer{nullptr}; + std::unordered_set mCapabilities; + class VsyncThread { public: static int64_t now(); From b065c9d8b7f926c57a7ec59e50e979a8c6e38e7f Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Thu, 19 Jul 2018 16:31:56 -0700 Subject: [PATCH 02/14] Fix failing drm 1.0 vts tests The shared library path was incorrectly set based on the drm.64bit.enabled flag. It should be set based on whether the drm service is running as 32-bit or 64-bit. Test: vts-tradefed run commandAndExit vts -m VtsHalDrmV1_0Target bug:111289939 Change-Id: I388dc87bd4566211dc2901feccf1e6e1c90bfe67 --- drm/1.0/default/DrmFactory.cpp | 2 +- drm/1.0/default/LegacyPluginPath.cpp | 16 +++++++++++----- drm/1.0/default/include/PluginLoader.h | 5 ++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drm/1.0/default/DrmFactory.cpp b/drm/1.0/default/DrmFactory.cpp index 7e5d998e4f..05951d7c02 100644 --- a/drm/1.0/default/DrmFactory.cpp +++ b/drm/1.0/default/DrmFactory.cpp @@ -1,6 +1,6 @@ /* * 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 diff --git a/drm/1.0/default/LegacyPluginPath.cpp b/drm/1.0/default/LegacyPluginPath.cpp index 369059d2c7..d0a8f90a77 100644 --- a/drm/1.0/default/LegacyPluginPath.cpp +++ b/drm/1.0/default/LegacyPluginPath.cpp @@ -16,6 +16,8 @@ #include "LegacyPluginPath.h" +#include + #include namespace android { @@ -24,12 +26,16 @@ namespace drm { namespace V1_0 { namespace implementation { +// 64-bit DRM depends on OEM libraries that aren't +// provided for all devices. If the drm hal service +// is running as 64-bit use the 64-bit libs, otherwise +// use the 32-bit libs. const char* getDrmPluginPath() { - if (property_get_bool("drm.64bit.enabled", false)) { - return "/vendor/lib64/mediadrm"; - } else { - return "/vendor/lib/mediadrm"; - } +#if defined(__LP64__) + return "/vendor/lib64/mediadrm"; +#else + return "/vendor/lib/mediadrm"; +#endif } } // namespace implementation diff --git a/drm/1.0/default/include/PluginLoader.h b/drm/1.0/default/include/PluginLoader.h index f387b3cbc5..0c45fb3efd 100644 --- a/drm/1.0/default/include/PluginLoader.h +++ b/drm/1.0/default/include/PluginLoader.h @@ -85,7 +85,10 @@ class PluginLoader { libraries.push(library); T* result = createFactoryFunc(); return result; - } + } else { + ALOGE("Failed to lookup symbol %s in library %s: %s", + entry, path, library->lastError()); + } } return NULL; } From 934243085ae70d7ce4ec7f6ee331099b4566b051 Mon Sep 17 00:00:00 2001 From: sqian Date: Fri, 20 Jul 2018 16:33:16 -0700 Subject: [PATCH 03/14] Fix setSimCardPower_1_1 If the function isn't executed successfully, do not expect its effect of cardStatus. Bug: 111661946 Test: run vts Change-Id: I952728311b595149b449280e73142f2f82af544d --- radio/1.1/vts/functional/radio_hidl_hal_api.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp index 90077dcf61..40759a6efd 100644 --- a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp @@ -43,7 +43,9 @@ TEST_F(RadioHidlTest_v1_1, setSimCardPower_1_1) { sleep(2); updateSimCardStatus(); } - EXPECT_EQ(CardState::ABSENT, cardStatus.cardState); + if (radioRsp_v1_1->rspInfo.error == RadioError::NONE) { + EXPECT_EQ(CardState::ABSENT, cardStatus.cardState); + } /* Test setSimCardPower power up */ serial = GetRandomSerialNumber(); @@ -59,7 +61,8 @@ TEST_F(RadioHidlTest_v1_1, setSimCardPower_1_1) { * If the sim card status for the testing environment is PRESENT, * verify if sim status is reset back. */ - if (cardStateForTest == CardState::PRESENT) { + if (cardStateForTest == CardState::PRESENT && + radioRsp_v1_1->rspInfo.error == RadioError::NONE) { /* Wait some time for resetting back to sim power on and then verify it */ updateSimCardStatus(); startTime = std::chrono::system_clock::now(); From b41b575475f3c93fe30216b9cdb2db441b92854b Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 19 Jul 2018 13:31:47 -0700 Subject: [PATCH 04/14] VTS: Do not require XML for Audio effect V2 In O, the Audio effect V2 HAL allows not to have an audio effect XML configuration but to use a .conf format. In P, before this patch, the Audio effect V2 HAL _requires_ to have an audio effect XML configuration and forbids the use of a .conf format. This is discouraged by Treble as it means that an unchanged HAL V2 implementation that was compatible with O VTS will not be with P VTS. As a result, revert to the Oreo behavior for Audio Effect V2 VTS. Note that the audio effect V4 VTS is not changed by this patch and still requires an audio effect XML configuration. Aka device _updating_ to P will not have to upgrade to XML but new devices lunching on P are still required to have an audio effect XML configuration. This commit only changes VTS code. Test: cd hardware/interfaces/audio/effect/ mmm 2.0/vts/functional 4.0/vts/functional && adb sync data adb push *.0/xml/audio_effects_conf_V*.xsd /data/local/tmp/ adb shell cd /data/nativetest64 OPS=--gtest_filter=CheckConfig.audioEffectsConfigurationValidation VtsHalAudioEffectV2_0TargetTest/VtsHalAudioEffectV2_0TargetTest $OPS VtsHalAudioEffectV4_0TargetTest/VtsHalAudioEffectV4_0TargetTest $OPS rm /{odm,vendor,system}/etc/audio_effects.xml || true VtsHalAudioEffectV2_0TargetTest/VtsHalAudioEffectV2_0TargetTest $OPS ! VtsHalAudioEffectV4_0TargetTest/VtsHalAudioEffectV4_0TargetTest $OPS Bug: 111421676 Change-Id: Ifb15d65ae4aa65759c8ebaa91cbc8c02234030dc Signed-off-by: Kevin Rocard --- .../utility/include/utility/ValidateXml.h | 40 +++++++++++-------- .../test/utility/src/ValidateXml.cpp | 16 +++++++- .../ValidateAudioEffectsConfiguration.cpp | 4 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h index 95080d1c4e..91adfc12c8 100644 --- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h +++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h @@ -45,29 +45,37 @@ namespace utility { xmlFilePath, xsdFilePath) /** Validate an XML according to an xsd. - * The XML file must be in at least one of the provided locations. - * If multiple are found, all are validated. + * All file named xmlFileName in each xmlFileLocations folder must be valid if present. + * @tparam atLeastOneRequired If true, at least one file has to be found. + * If false, no found file is a success. */ +template ::testing::AssertionResult validateXmlMultipleLocations( const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr, const char* xmlFileName, std::vector xmlFileLocations, const char* xsdFilePath); -/** ASSERT that an XML is valid according to an xsd. - * The XML file must be in at least one of the provided locations. - * If multiple are found, all are validated. - */ -#define ASSERT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ - ASSERT_PRED_FORMAT3( \ - ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ +/** ASSERT that all found XML are valid according to an xsd. */ +#define ASSERT_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ + ASSERT_PRED_FORMAT3( \ + ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ xmlFileName, xmlFileLocations, xsdFilePath) -/** EXPECT an XML to be valid according to an xsd. - * The XML file must be in at least one of the provided locations. - * If multiple are found, all are validated. - */ -#define EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ - EXPECT_PRED_FORMAT3( \ - ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ +/** EXPECT that all found XML are valid according to an xsd. */ +#define EXPECT_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ + EXPECT_PRED_FORMAT3( \ + ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ + xmlFileName, xmlFileLocations, xsdFilePath) + +/** ASSERT that all found XML are valid according to an xsd. At least one must be found. */ +#define ASSERT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ + ASSERT_PRED_FORMAT3( \ + ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ + xmlFileName, xmlFileLocations, xsdFilePath) + +/** EXPECT that all found XML are valid according to an xsd. At least one must be found. */ +#define EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \ + EXPECT_PRED_FORMAT3( \ + ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \ xmlFileName, xmlFileLocations, xsdFilePath) } // namespace utility diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp index 5030af5067..1a906d668b 100644 --- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp +++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp @@ -129,6 +129,7 @@ struct Libxml2Global { return ::testing::AssertionSuccess(); } +template ::testing::AssertionResult validateXmlMultipleLocations( const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr, const char* xmlFileName, std::vector xmlFileLocations, const char* xsdFilePath) { @@ -150,7 +151,7 @@ struct Libxml2Global { } } - if (foundFiles.empty()) { + if (atLeastOneRequired && foundFiles.empty()) { errors.push_back("No xml file found in provided locations.\n"); } @@ -160,9 +161,20 @@ struct Libxml2Global { << " While validating all: " << xmlFileNameExpr << "\n Which is: " << xmlFileName << "\n In the following folders: " << xmlFileLocationsExpr - << "\n Which is: " << ::testing::PrintToString(xmlFileLocations); + << "\n Which is: " << ::testing::PrintToString(xmlFileLocations) + << (atLeastOneRequired ? "Where at least one file must be found." + : "Where no file might exist."); } +template ::testing::AssertionResult validateXmlMultipleLocations(const char*, const char*, + const char*, const char*, + std::vector, + const char*); +template ::testing::AssertionResult validateXmlMultipleLocations(const char*, const char*, + const char*, const char*, + std::vector, + const char*); + } // namespace utility } // namespace test } // namespace common diff --git a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp index d0bc6908d6..bf080d3edc 100644 --- a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp +++ b/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp @@ -27,6 +27,6 @@ TEST(CheckConfig, audioEffectsConfigurationValidation) { using namespace android::effectsConfig; std::vector locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS)); - EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, - "/data/local/tmp/audio_effects_conf_V2_0.xsd"); + EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, + "/data/local/tmp/audio_effects_conf_V2_0.xsd"); } From 8cec80be1fc3d2d30fe095fa009dfa83cb7651ce Mon Sep 17 00:00:00 2001 From: nagendra modadugu Date: Mon, 23 Jul 2018 10:32:28 -0700 Subject: [PATCH 05/14] keymaster: skip SHA2 digest tests for strongbox Strongbox is not required to support SHA-2 digests, so skip the related tests. Bug: 109771020 Change-Id: I5f877b2a1ac66026a876e145416ba078d486e4b5 --- .../functional/keymaster_hidl_hal_test.cpp | 80 ++++++++++++------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp index 5dc0c7faff..ccb51ecfb1 100644 --- a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp +++ b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp @@ -198,7 +198,8 @@ bool verify_chain(const hidl_vec>& chain) { if (!signing_pubkey.get()) return false; EXPECT_EQ(1, X509_verify(key_cert.get(), signing_pubkey.get())) - << "Verification of certificate " << i << " failed"; + << "Verification of certificate " << i << " failed " + << "OpenSSL error string: " << ERR_error_string(ERR_get_error(), NULL); char* cert_issuer = // X509_NAME_oneline(X509_get_issuer_name(key_cert.get()), nullptr, 0); @@ -535,10 +536,16 @@ TEST_F(NewKeyGenerationTest, EcdsaAllValidSizes) { * Verifies that keymaster does not support any curve designated as unsupported. */ TEST_F(NewKeyGenerationTest, EcdsaAllValidCurves) { + Digest digest; + if (SecLevel() == SecurityLevel::STRONGBOX) { + digest = Digest::SHA_2_256; + } else { + digest = Digest::SHA_2_512; + } for (auto curve : ValidCurves()) { EXPECT_EQ( ErrorCode::OK, - GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(curve).Digest(Digest::SHA_2_512))) + GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(curve).Digest(digest))) << "Failed to generate key on curve: " << curve; CheckCharacteristics(key_blob_, key_characteristics_); CheckedDeleteKey(); @@ -828,6 +835,7 @@ TEST_F(SigningOperationsTest, RsaPkcs1NoDigestTooLong) { * 1024-bit key. */ TEST_F(SigningOperationsTest, RsaPssSha512TooSmallKey) { + if (SecLevel() == SecurityLevel::STRONGBOX) return; ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder() .RsaSigningKey(1024, 65537) .Digest(Digest::SHA_2_512) @@ -1185,10 +1193,12 @@ TEST_F(SigningOperationsTest, HmacRfc4231TestCase3) { 0xbe, 0xe8, 0x94, 0x26, 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb, }; - CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + if (SecLevel() != SecurityLevel::STRONGBOX) { + CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + } } /* @@ -1217,10 +1227,12 @@ TEST_F(SigningOperationsTest, HmacRfc4231TestCase5) { 0x1d, 0x41, 0x79, 0xbc, 0x89, 0x1d, 0x87, 0xa6, }; - CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + if (SecLevel() != SecurityLevel::STRONGBOX) { + CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + } } /* @@ -1255,10 +1267,12 @@ TEST_F(SigningOperationsTest, HmacRfc4231TestCase6) { 0xf6, 0x3f, 0x0a, 0xec, 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98, }; - CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + if (SecLevel() != SecurityLevel::STRONGBOX) { + CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + } } /* @@ -1296,10 +1310,12 @@ TEST_F(SigningOperationsTest, HmacRfc4231TestCase7) { 0x6d, 0xe0, 0x44, 0x60, 0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58, }; - CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); CheckHmacTestVector(key, message, Digest::SHA_2_256, make_string(sha_256_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); - CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + if (SecLevel() != SecurityLevel::STRONGBOX) { + CheckHmacTestVector(key, message, Digest::SHA_2_224, make_string(sha_224_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_384, make_string(sha_384_expected)); + CheckHmacTestVector(key, message, Digest::SHA_2_512, make_string(sha_512_expected)); + } } typedef KeymasterHidlTest VerificationOperationsTest; @@ -1511,7 +1527,7 @@ TEST_F(VerificationOperationsTest, HmacSigningKeyCannotVerify) { .Authorization(TAG_NO_AUTH_REQUIRED) .Authorization(TAG_ALGORITHM, Algorithm::HMAC) .Authorization(TAG_PURPOSE, KeyPurpose::SIGN) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Authorization(TAG_MIN_MAC_LENGTH, 160), KeyFormat::RAW, key_material, &signing_key, &signing_key_chars)); EXPECT_EQ(ErrorCode::OK, @@ -1519,24 +1535,24 @@ TEST_F(VerificationOperationsTest, HmacSigningKeyCannotVerify) { .Authorization(TAG_NO_AUTH_REQUIRED) .Authorization(TAG_ALGORITHM, Algorithm::HMAC) .Authorization(TAG_PURPOSE, KeyPurpose::VERIFY) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Authorization(TAG_MIN_MAC_LENGTH, 160), KeyFormat::RAW, key_material, &verification_key, &verification_key_chars)); string message = "This is a message."; string signature = SignMessage( signing_key, message, - AuthorizationSetBuilder().Digest(Digest::SHA1).Authorization(TAG_MAC_LENGTH, 160)); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Authorization(TAG_MAC_LENGTH, 160)); // Signing key should not work. AuthorizationSet out_params; EXPECT_EQ(ErrorCode::INCOMPATIBLE_PURPOSE, - Begin(KeyPurpose::VERIFY, signing_key, AuthorizationSetBuilder().Digest(Digest::SHA1), + Begin(KeyPurpose::VERIFY, signing_key, AuthorizationSetBuilder().Digest(Digest::SHA_2_256), &out_params, &op_handle_)); // Verification key should work. VerifyMessage(verification_key, message, signature, - AuthorizationSetBuilder().Digest(Digest::SHA1)); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256)); CheckedDeleteKey(&signing_key); CheckedDeleteKey(&verification_key); @@ -1895,14 +1911,14 @@ class ImportWrappedKeyTest : public KeymasterHidlTest {}; TEST_F(ImportWrappedKeyTest, Success) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::OK, ImportWrappedKey( wrapped_key, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); string message = "Hello World!"; auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7); @@ -1914,39 +1930,39 @@ TEST_F(ImportWrappedKeyTest, Success) { TEST_F(ImportWrappedKeyTest, SuccessMasked) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::OK, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); } TEST_F(ImportWrappedKeyTest, WrongMask) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::VERIFICATION_FAILED, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); } TEST_F(ImportWrappedKeyTest, WrongPurpose) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA1) + .Digest(Digest::SHA_2_256) .Padding(PaddingMode::RSA_OAEP); ASSERT_EQ(ErrorCode::INCOMPATIBLE_PURPOSE, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); } typedef KeymasterHidlTest EncryptionOperationsTest; @@ -2140,11 +2156,13 @@ TEST_F(EncryptionOperationsTest, RsaOaepInvalidDigest) { * different digest than was used to encrypt. */ TEST_F(EncryptionOperationsTest, RsaOaepDecryptWithWrongDigest) { + if (SecLevel() == SecurityLevel::STRONGBOX) return; + ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder() .Authorization(TAG_NO_AUTH_REQUIRED) .RsaEncryptionKey(1024, 65537) .Padding(PaddingMode::RSA_OAEP) - .Digest(Digest::SHA_2_256, Digest::SHA_2_224))); + .Digest(Digest::SHA_2_224, Digest::SHA_2_256))); string message = "Hello World!"; string ciphertext = EncryptMessage( message, @@ -2170,13 +2188,13 @@ TEST_F(EncryptionOperationsTest, RsaOaepTooLarge) { .Authorization(TAG_NO_AUTH_REQUIRED) .RsaEncryptionKey(1024, 65537) .Padding(PaddingMode::RSA_OAEP) - .Digest(Digest::SHA1))); - constexpr size_t digest_size = 160 /* SHA1 */ / 8; + .Digest(Digest::SHA_2_256))); + constexpr size_t digest_size = 256 /* SHA_2_256 */ / 8; constexpr size_t oaep_overhead = 2 * digest_size + 2; string message(1024 / 8 - oaep_overhead + 1, 'a'); EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::ENCRYPT, - AuthorizationSetBuilder().Padding(PaddingMode::RSA_OAEP).Digest(Digest::SHA1))); + AuthorizationSetBuilder().Padding(PaddingMode::RSA_OAEP).Digest(Digest::SHA_2_256))); string result; EXPECT_EQ(ErrorCode::INVALID_ARGUMENT, Finish(message, &result)); EXPECT_EQ(0U, result.size()); From 8e920568371136b011c79e6c1d15bcb4c047d0a3 Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Thu, 26 Jul 2018 13:00:08 +0100 Subject: [PATCH 06/14] Camera: Don't hold 'mLock' when closing the camera session After flushing the camera requests don't try to close the camera session while still holding 'mLock'. Different Hals could still try and return additional results which then will get blocked on 'mLock'. Closing the session could potentially introduce a deadlock if the Hal implementation waits for any of the result calls to return. Bug: 111836165 Test: vts-tradefed run commandAndExit vts --skip-all-system-status-check --skip-preconditions --module VtsHalCameraProviderV2_4Target -l INFO Change-Id: I0f309f435cc76db3f9b6ba500da65a232b014717 --- .../vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index 1a245c4610..439333d9ca 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -4046,10 +4046,10 @@ TEST_F(CameraHidlTest, flushPreviewRequest) { << static_cast(inflightReq.errorCode); } } - - ret = session->close(); - ASSERT_TRUE(ret.isOk()); } + + ret = session->close(); + ASSERT_TRUE(ret.isOk()); } } From 17fec3625d7094fd68c4a43966ddc2eb513658e4 Mon Sep 17 00:00:00 2001 From: Shuo Qian Date: Thu, 26 Jul 2018 22:37:50 +0000 Subject: [PATCH 07/14] Revert "Fixed VTS failure in no SIM case" Since the EMERGENCY-type APN is a must set in the radio setupDataCall request for modem to perform Emergency call, and the given VTS test case does not set that emergency bit, I think modem should treat the request as a normal call request, and should not return "NONE" for no-sim. This reverts commit 431eb118f84de14c94ec18f887197944ec17e712. Reason for revert: after further discussion, NONE is not acceptable given the test case. Bug: 109767888 Change-Id: I3d1cc96120d53a9be0ae5059c26b091bf82dc352 --- radio/1.2/vts/functional/radio_hidl_hal_api.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/radio/1.2/vts/functional/radio_hidl_hal_api.cpp b/radio/1.2/vts/functional/radio_hidl_hal_api.cpp index 11a73c35e8..9284fd8fae 100644 --- a/radio/1.2/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.2/vts/functional/radio_hidl_hal_api.cpp @@ -621,9 +621,8 @@ TEST_F(RadioHidlTest_v1_2, setupDataCall_1_2) { if (cardStatus.base.cardState == CardState::ABSENT) { ASSERT_TRUE(CheckAnyOfErrors( radioRsp_v1_2->rspInfo.error, - {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, - RadioError::INVALID_ARGUMENTS, RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW, - RadioError::REQUEST_NOT_SUPPORTED})); + {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS, + RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW, RadioError::REQUEST_NOT_SUPPORTED})); } else if (cardStatus.base.cardState == CardState::PRESENT) { ASSERT_TRUE(CheckAnyOfErrors( radioRsp_v1_2->rspInfo.error, From 44b129f7288016a4113f5e6ff059d63987d63385 Mon Sep 17 00:00:00 2001 From: sqian Date: Tue, 31 Jul 2018 09:23:24 -0700 Subject: [PATCH 08/14] Fix setAllowedCarrier If function is not supported or executed successfully, do not expect its effect on cardStatus. Bug: 112008372 Test: run vts Change-Id: I4532a39af2cfcf0e44eafe29c3c7f6779ae101f5 --- .../vts/functional/radio_hidl_hal_misc.cpp | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp index 24d9944935..34997625b1 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp @@ -779,20 +779,27 @@ TEST_F(RadioHidlTest, setAllowedCarriers) { {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } - /* Setting to carrier restriction needs some time */ - updateSimCardStatus(); - auto startTime = std::chrono::system_clock::now(); - while (cardStatus.cardState != CardState::RESTRICTED && - std::chrono::duration_cast(std::chrono::system_clock::now() - startTime) - .count() < 10) { - /* Set 2 seconds as interval to check card status */ - sleep(2); + if (radioRsp->rspInfo.error == RadioError::NONE) { + /* Setting to carrier restriction needs some time */ updateSimCardStatus(); + auto startTime = std::chrono::system_clock::now(); + while (cardStatus.cardState != CardState::RESTRICTED && + std::chrono::duration_cast(std::chrono::system_clock::now() - + startTime) + .count() < 10) { + /* Set 2 seconds as interval to check card status */ + sleep(2); + updateSimCardStatus(); + } + EXPECT_EQ(CardState::RESTRICTED, cardStatus.cardState); } - EXPECT_EQ(CardState::RESTRICTED, cardStatus.cardState); sleep(10); - /* Reset back to no carrier restriction */ + /** + * Another test case of the API to cover to allow carrier. + * If the API is supported, this is also used to reset to no carrier restriction + * status for cardStatus. + */ memset(&carriers, 0, sizeof(carriers)); carriers.allowedCarriers.resize(0); carriers.excludedCarriers.resize(0); @@ -808,18 +815,21 @@ TEST_F(RadioHidlTest, setAllowedCarriers) { {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } - /* Resetting back to no carrier restriction needs some time */ - updateSimCardStatus(); - startTime = std::chrono::system_clock::now(); - while (cardStatus.cardState == CardState::RESTRICTED && - std::chrono::duration_cast(std::chrono::system_clock::now() - startTime) - .count() < 10) { - /* Set 2 seconds as interval to check card status */ - sleep(2); + if (radioRsp->rspInfo.error == RadioError::NONE) { + /* Resetting back to no carrier restriction needs some time */ updateSimCardStatus(); + auto startTime = std::chrono::system_clock::now(); + while (cardStatus.cardState == CardState::RESTRICTED && + std::chrono::duration_cast(std::chrono::system_clock::now() - + startTime) + .count() < 10) { + /* Set 2 seconds as interval to check card status */ + sleep(2); + updateSimCardStatus(); + } + EXPECT_NE(CardState::RESTRICTED, cardStatus.cardState); + sleep(10); } - EXPECT_NE(CardState::RESTRICTED, cardStatus.cardState); - sleep(10); } /* From 4721523a96007b3b928ca847cfb3945e3e68c346 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Thu, 2 Aug 2018 15:09:17 +0800 Subject: [PATCH 09/14] Fix base class of WifiHidlEnvironment_1_2 WifiHidlEnvironment_1_2 inherits WifiHidlEnvironment so that it stops Wifi before every test. Test: run vts -m VtsHalWifiV1_2Target Bug: 112058501 Change-Id: I73c50351fa486f2ae7749e43a060ff05672c0f65 --- wifi/1.2/vts/functional/VtsHalWifiV1_2TargetTest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/wifi/1.2/vts/functional/VtsHalWifiV1_2TargetTest.cpp b/wifi/1.2/vts/functional/VtsHalWifiV1_2TargetTest.cpp index cfad208287..c765cdcc3b 100644 --- a/wifi/1.2/vts/functional/VtsHalWifiV1_2TargetTest.cpp +++ b/wifi/1.2/vts/functional/VtsHalWifiV1_2TargetTest.cpp @@ -17,14 +17,12 @@ #include #include -#include - #include "wifi_hidl_test_utils.h" using ::android::hardware::wifi::V1_2::IWifi; // Test environment for Wifi HIDL HAL. -class WifiHidlEnvironment_1_2 : public ::testing::VtsHalHidlTargetTestEnvBase { +class WifiHidlEnvironment_1_2 : public WifiHidlEnvironment { public: // get the test environment singleton static WifiHidlEnvironment_1_2* Instance() { From 4e006c2b92be6ac71927b975b6725ddadf0b3342 Mon Sep 17 00:00:00 2001 From: Shawn Willden Date: Tue, 31 Jul 2018 13:47:37 -0600 Subject: [PATCH 10/14] Require keymaster4 attestations to contain the right version. Note that devices with KM4 will fail to pass VTS after this lands, until the fix from Qualcomm arrives. Test: VtsHalKeymasterV4_0TargetTest Bug: 112040197 Change-Id: Ie2cd917af704b9f19de3537297b3a7e4f0c861e9 --- keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp index ccb51ecfb1..612426453a 100644 --- a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp +++ b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp @@ -308,7 +308,7 @@ bool verify_attestation_record(const string& challenge, const string& app_id, expected_sw_enforced.push_back(TAG_ATTESTATION_APPLICATION_ID, HidlBuf(app_id)); - EXPECT_GE(att_keymaster_version, 3U); + EXPECT_EQ(att_keymaster_version, 4U); EXPECT_EQ(security_level, att_keymaster_security_level); EXPECT_EQ(security_level, att_attestation_security_level); From 7d1fdecea5bfa16ab7af3b0b98db1973c1775abd Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Fri, 3 Aug 2018 11:50:47 -0700 Subject: [PATCH 11/14] Legacy camera shim: add option to free buffers earlier This option allows HAL to opt in for the behavior that will free cached buffers earlier if the libhardware HAL implementation doesn't cache/reference the cached buffers internally. Test: buffers are freed earlier when the property is set Bug: 111850884 Change-Id: I3a10b288c7160c86dc7d3a30d04b5c4903917731 --- .../3.2/default/CameraDeviceSession.cpp | 50 ++++++++++++++++++- .../device/3.2/default/CameraDeviceSession.h | 5 ++ .../3.3/default/CameraDeviceSession.cpp | 2 + .../3.4/default/CameraDeviceSession.cpp | 43 +++++++++++++++- .../device_v3_4_impl/CameraDeviceSession.h | 2 + 5 files changed, 100 insertions(+), 2 deletions(-) diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp index 69f853562c..fd785df1a9 100644 --- a/camera/device/3.2/default/CameraDeviceSession.cpp +++ b/camera/device/3.2/default/CameraDeviceSession.cpp @@ -53,6 +53,7 @@ CameraDeviceSession::CameraDeviceSession( camera3_callback_ops({&sProcessCaptureResult, &sNotify}), mDevice(device), mDeviceVersion(device->common.version), + mFreeBufEarly(shouldFreeBufEarly()), mIsAELockAvailable(false), mDerivePostRawSensKey(false), mNumPartialResults(1), @@ -129,6 +130,10 @@ bool CameraDeviceSession::initialize() { return false; } +bool CameraDeviceSession::shouldFreeBufEarly() { + return property_get_bool("ro.vendor.camera.free_buf_early", 0) == 1; +} + CameraDeviceSession::~CameraDeviceSession() { if (!isClosed()) { ALOGE("CameraDeviceSession deleted before close!"); @@ -887,6 +892,24 @@ bool CameraDeviceSession::preProcessConfigurationLocked( (*streams)[i] = &mStreamMap[id]; } + if (mFreeBufEarly) { + // Remove buffers of deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.id) { + found = true; + break; + } + } + if (!found) { + // Unmap all buffers of deleted stream + cleanupBuffersLocked(id); + } + } + } + return true; } @@ -908,7 +931,9 @@ void CameraDeviceSession::postProcessConfigurationLocked( // Unmap all buffers of deleted stream // in case the configuration call succeeds and HAL // is able to release the corresponding resources too. - cleanupBuffersLocked(id); + if (!mFreeBufEarly) { + cleanupBuffersLocked(id); + } it = mStreamMap.erase(it); } else { ++it; @@ -927,6 +952,27 @@ void CameraDeviceSession::postProcessConfigurationLocked( mResultBatcher.setBatchedStreams(mVideoStreamIds); } + +void CameraDeviceSession::postProcessConfigurationFailureLocked( + const StreamConfiguration& requestedConfiguration) { + if (mFreeBufEarly) { + // Re-build the buf cache entry for deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.id) { + found = true; + break; + } + } + if (!found) { + mCirculatingBuffers.emplace(id, CirculatingBuffers{}); + } + } + } +} + Return CameraDeviceSession::configureStreams( const StreamConfiguration& requestedConfiguration, ICameraDeviceSession::configureStreams_cb _hidl_cb) { @@ -979,6 +1025,8 @@ Return CameraDeviceSession::configureStreams( // the corresponding resources of the deleted streams. if (ret == OK) { postProcessConfigurationLocked(requestedConfiguration); + } else { + postProcessConfigurationFailureLocked(requestedConfiguration); } if (ret == -EINVAL) { diff --git a/camera/device/3.2/default/CameraDeviceSession.h b/camera/device/3.2/default/CameraDeviceSession.h index af90e5a00f..bcee259fbd 100644 --- a/camera/device/3.2/default/CameraDeviceSession.h +++ b/camera/device/3.2/default/CameraDeviceSession.h @@ -120,6 +120,8 @@ protected: hidl_vec *streams /*out*/); void postProcessConfigurationLocked(const StreamConfiguration& requestedConfiguration); + void postProcessConfigurationFailureLocked(const StreamConfiguration& requestedConfiguration); + protected: // protecting mClosed/mDisconnected/mInitFail @@ -142,6 +144,7 @@ protected: camera3_device_t* mDevice; const uint32_t mDeviceVersion; + const bool mFreeBufEarly; bool mIsAELockAvailable; bool mDerivePostRawSensKey; uint32_t mNumPartialResults; @@ -293,6 +296,8 @@ protected: bool initialize(); + static bool shouldFreeBufEarly(); + Status initStatus() const; // Validate and import request's input buffer and acquire fence diff --git a/camera/device/3.3/default/CameraDeviceSession.cpp b/camera/device/3.3/default/CameraDeviceSession.cpp index d36e9ed4a0..60174fb92d 100644 --- a/camera/device/3.3/default/CameraDeviceSession.cpp +++ b/camera/device/3.3/default/CameraDeviceSession.cpp @@ -92,6 +92,8 @@ Return CameraDeviceSession::configureStreams_3_3( // the corresponding resources of the deleted streams. if (ret == OK) { postProcessConfigurationLocked(requestedConfiguration); + } else { + postProcessConfigurationFailureLocked(requestedConfiguration); } if (ret == -EINVAL) { diff --git a/camera/device/3.4/default/CameraDeviceSession.cpp b/camera/device/3.4/default/CameraDeviceSession.cpp index 6a18161f20..f2e031c674 100644 --- a/camera/device/3.4/default/CameraDeviceSession.cpp +++ b/camera/device/3.4/default/CameraDeviceSession.cpp @@ -154,6 +154,8 @@ Return CameraDeviceSession::configureStreams_3_4( // the corresponding resources of the deleted streams. if (ret == OK) { postProcessConfigurationLocked_3_4(requestedConfiguration); + } else { + postProcessConfigurationFailureLocked_3_4(requestedConfiguration); } if (ret == -EINVAL) { @@ -215,6 +217,23 @@ bool CameraDeviceSession::preProcessConfigurationLocked_3_4( (*streams)[i] = &mStreamMap[id]; } + if (mFreeBufEarly) { + // Remove buffers of deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.v3_2.id) { + found = true; + break; + } + } + if (!found) { + // Unmap all buffers of deleted stream + cleanupBuffersLocked(id); + } + } + } return true; } @@ -236,7 +255,9 @@ void CameraDeviceSession::postProcessConfigurationLocked_3_4( // Unmap all buffers of deleted stream // in case the configuration call succeeds and HAL // is able to release the corresponding resources too. - cleanupBuffersLocked(id); + if (!mFreeBufEarly) { + cleanupBuffersLocked(id); + } it = mStreamMap.erase(it); } else { ++it; @@ -255,6 +276,26 @@ void CameraDeviceSession::postProcessConfigurationLocked_3_4( mResultBatcher_3_4.setBatchedStreams(mVideoStreamIds); } +void CameraDeviceSession::postProcessConfigurationFailureLocked_3_4( + const StreamConfiguration& requestedConfiguration) { + if (mFreeBufEarly) { + // Re-build the buf cache entry for deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.v3_2.id) { + found = true; + break; + } + } + if (!found) { + mCirculatingBuffers.emplace(id, CirculatingBuffers{}); + } + } + } +} + Return CameraDeviceSession::processCaptureRequest_3_4( const hidl_vec& requests, const hidl_vec& cachesToRemove, diff --git a/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h b/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h index 5d6a112e37..fdc8a5afd2 100644 --- a/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h +++ b/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h @@ -84,6 +84,8 @@ protected: camera3_stream_configuration_t *stream_list /*out*/, hidl_vec *streams /*out*/); void postProcessConfigurationLocked_3_4(const StreamConfiguration& requestedConfiguration); + void postProcessConfigurationFailureLocked_3_4( + const StreamConfiguration& requestedConfiguration); Return processCaptureRequest_3_4( const hidl_vec& requests, From 12f7d6127b301b140ee81696fed19f81a7ea50c6 Mon Sep 17 00:00:00 2001 From: sqian Date: Fri, 3 Aug 2018 16:19:29 -0700 Subject: [PATCH 12/14] Loose startNetworkScan cases startNetworkScan: Some vendor may not support the required manual GSM search functionality. startNetworkScan_GoodRequest1 and startNetworkScan_GoodRequest2: Some vendor may not support max search time of 360s. Test: sanity Bug: 109765420 Change-Id: I456847815057d76561bfb3e840016619ac753476 --- .../1.2/vts/functional/radio_hidl_hal_api.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/radio/1.2/vts/functional/radio_hidl_hal_api.cpp b/radio/1.2/vts/functional/radio_hidl_hal_api.cpp index 0215e80902..35101637df 100644 --- a/radio/1.2/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.2/vts/functional/radio_hidl_hal_api.cpp @@ -48,8 +48,11 @@ TEST_F(RadioHidlTest_v1_2, startNetworkScan) { // error for now. This should be fixed correctly, possibly in a future version of the hal // (b/110421924). This is being allowed because some vendors do not support // this request on dual sim devices. + // OPERATION_NOT_ALLOWED should not be allowed; however, some vendors do not support the + // required manual GSM search functionality. This is tracked in b/112206766. ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, - {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, + RadioError::OPERATION_NOT_ALLOWED})); } } @@ -317,7 +320,9 @@ TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest1) { .type = ScanType::ONE_SHOT, .interval = 60, .specifiers = {specifier}, - .maxSearchTime = 600, + // Some vendor may not support max search time of 360s. + // This issue is tracked in b/112205669. + .maxSearchTime = 300, .incrementalResults = false, .incrementalResultsPeriodicity = 10}; @@ -333,8 +338,9 @@ TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest1) { ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE, RadioError::SIM_ABSENT})); } else if (cardStatus.base.cardState == CardState::PRESENT) { - ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, - {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_v1_2->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } } @@ -353,7 +359,9 @@ TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest2) { .type = ScanType::ONE_SHOT, .interval = 60, .specifiers = {specifier}, - .maxSearchTime = 600, + // Some vendor may not support max search time of 360s. + // This issue is tracked in b/112205669. + .maxSearchTime = 300, .incrementalResults = false, .incrementalResultsPeriodicity = 10, .mccMncs = {"310410"}}; @@ -370,8 +378,9 @@ TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest2) { ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE, RadioError::SIM_ABSENT})); } else if (cardStatus.base.cardState == CardState::PRESENT) { - ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, - {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_v1_2->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } } From 0dba88861267b2b37355b41504b9d1e0d89bbe0f Mon Sep 17 00:00:00 2001 From: Shawn Willden Date: Mon, 6 Aug 2018 17:23:23 -0600 Subject: [PATCH 13/14] Change ImportWrappedKeyTest back to SHA1 Change I5f877b2a1ac66026a876e145416ba078d486e4b5 inadvertently changed the digest used for ImportWrappedKey, breaking the test. This CL reverts that portion of the change. Test: VtsHalKeymasterV4_0TargetTest Bug: 112279922 Change-Id: Ib8e2e7793ba46ae0d29d8407bb730a35bdb5ea98 --- .../vts/functional/keymaster_hidl_hal_test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp index 612426453a..3919a69dbf 100644 --- a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp +++ b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp @@ -1911,14 +1911,14 @@ class ImportWrappedKeyTest : public KeymasterHidlTest {}; TEST_F(ImportWrappedKeyTest, Success) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA_2_256) + .Digest(Digest::SHA1) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::OK, ImportWrappedKey( wrapped_key, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); string message = "Hello World!"; auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7); @@ -1930,39 +1930,39 @@ TEST_F(ImportWrappedKeyTest, Success) { TEST_F(ImportWrappedKeyTest, SuccessMasked) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA_2_256) + .Digest(Digest::SHA1) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::OK, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); } TEST_F(ImportWrappedKeyTest, WrongMask) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA_2_256) + .Digest(Digest::SHA1) .Padding(PaddingMode::RSA_OAEP) .Authorization(TAG_PURPOSE, KeyPurpose::WRAP_KEY); ASSERT_EQ(ErrorCode::VERIFICATION_FAILED, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); } TEST_F(ImportWrappedKeyTest, WrongPurpose) { auto wrapping_key_desc = AuthorizationSetBuilder() .RsaEncryptionKey(2048, 65537) - .Digest(Digest::SHA_2_256) + .Digest(Digest::SHA1) .Padding(PaddingMode::RSA_OAEP); ASSERT_EQ(ErrorCode::INCOMPATIBLE_PURPOSE, ImportWrappedKey( wrapped_key_masked, wrapping_key, wrapping_key_desc, zero_masking_key, - AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_OAEP))); + AuthorizationSetBuilder().Digest(Digest::SHA1).Padding(PaddingMode::RSA_OAEP))); } typedef KeymasterHidlTest EncryptionOperationsTest; From ec720564dbdef01d14fcf46c46ea18294440358b Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 20 Aug 2018 10:46:48 -0700 Subject: [PATCH 14/14] Add back keymaster@4.0 hash. This was changed after this branch was released. The originally released hash needs to be restored since that is what partners are building with. Bug: 112688384 Bug: 78104779 Test: m android.hardware.keymaster@4.0 (tests hashes) Change-Id: I0f59a493d7f17a13402d992495d1a259f6257077 --- current.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/current.txt b/current.txt index cae8dbf2d2..316bc4348a 100644 --- a/current.txt +++ b/current.txt @@ -335,7 +335,8 @@ dd83be076b6b3f10ed62ab34d8c8b95f2415961fb785200eb842e7bfb2b0ee92 android.hardwar 675682dd3007805c985eaaec91612abc88f4c25b3431fb84070b7584a1a741fb android.hardware.health@2.0::IHealth 434c4c32c00b0e54bb05e40c79503208b40f786a318029a2a4f66e34f10f2a76 android.hardware.health@2.0::IHealthInfoCallback c9e498f1ade5e26f00d290b4763a9671ec6720f915e7d592844b62e8cb1f9b5c android.hardware.health@2.0::types -6122abe9bc2e7868463d3787db2991c1e47cc01fe3e4cfb7293c5ba421ff8ad9 android.hardware.keymaster@4.0::IKeymasterDevice +201f9723353fdbd40bf3705537fb7e015e4c399879425e68688fe0f43606ea4d android.hardware.keymaster@4.0::IKeymasterDevice # b/112688384 +6122abe9bc2e7868463d3787db2991c1e47cc01fe3e4cfb7293c5ba421ff8ad9 android.hardware.keymaster@4.0::IKeymasterDevice # b/78104779 1b7d2090c0a28b229d37c4b96160796b1f0d703950ac6ccc163fccd280830503 android.hardware.keymaster@4.0::types 6d5c646a83538f0f9d8438c259932509f4353410c6c76e56db0d6ca98b69c3bb android.hardware.media.bufferpool@1.0::IAccessor b8c7ed58aa8740361e63d0ce9e7c94227572a629f356958840b34809d2393a7c android.hardware.media.bufferpool@1.0::IClientManager