Loading security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ parcelable ProtectedData { * ; HKDF. See details on use in ProtectedData comments above. The public key data * ; included in the other field of PartyUInfo / PartyVInfo is encoded as: * ; - a raw 32-byte public key for X25519 * ; - uncompressed SEC-1 coordinate data (0x04 || x || y) for P-256 * ; - raw coordinate data (x || y) for P-256 * Context = [ * AlgorithmID : 3 ; AES-GCM 256 * PartyUInfo : [ Loading thermal/aidl/vts/VtsHalThermalTargetTest.cpp +139 −11 Original line number Diff line number Diff line Loading @@ -95,20 +95,15 @@ class ThermalAidlTest : public testing::TestWithParam<std::string> { mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); ASSERT_NE(mThermalCallback, nullptr); auto status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()); // Expect to fail if register again status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); } void TearDown() override { auto status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()); ::ndk::ScopedAStatus status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail if unregister again status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } Loading @@ -121,11 +116,144 @@ class ThermalAidlTest : public testing::TestWithParam<std::string> { // This just calls into and back from our local ThermalChangedCallback impl. TEST_P(ThermalAidlTest, NotifyThrottlingTest) { std::shared_ptr<ThermalCallback> thermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); auto ret = thermalCallback->notifyThrottling(kThrottleTemp); ASSERT_TRUE(ret.isOk()); ::ndk::ScopedAStatus status = thermalCallback->notifyThrottling(kThrottleTemp); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(thermalCallback->waitForCallback(200ms)); } // Test Thermal->registerThermalChangedCallback. TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackTest) { // Expect to fail with same callback ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); std::shared_ptr<ThermalCallback> localThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); // Expect to succeed with different callback status = mThermal->registerThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(localThermalCallback->waitForCallback(200ms)); // Remove the local callback status = mThermal->unregisterThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } // Test Thermal->registerThermalChangedCallbackWithType. TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackWithTypeTest) { // Expect to fail with same callback ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallbackWithType( mThermalCallback, TemperatureType::SKIN); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallbackWithType(nullptr, TemperatureType::SKIN); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); std::shared_ptr<ThermalCallback> localThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); // Expect to succeed with different callback status = mThermal->registerThermalChangedCallbackWithType(localThermalCallback, TemperatureType::SKIN); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(localThermalCallback->waitForCallback(200ms)); // Remove the local callback status = mThermal->unregisterThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } // Test Thermal->getCurrentTemperatures(). TEST_P(ThermalAidlTest, TemperatureTest) { std::vector<Temperature> ret; ::ndk::ScopedAStatus status = mThermal->getTemperatures(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<TemperatureType>(); for (const auto& type : types) { status = mThermal->getTemperaturesWithType(type, &ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } // Test Thermal->getTemperatureThresholds(). TEST_P(ThermalAidlTest, TemperatureThresholdTest) { std::vector<TemperatureThreshold> ret; ::ndk::ScopedAStatus status = mThermal->getTemperatureThresholds(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<TemperatureType>(); for (const auto& type : types) { status = mThermal->getTemperatureThresholdsWithType(type, &ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } // Test Thermal->getCoolingDevices(). TEST_P(ThermalAidlTest, CoolingDeviceTest) { std::vector<CoolingDevice> ret; ::ndk::ScopedAStatus status = mThermal->getCoolingDevices(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<CoolingType>(); for (const auto& type : types) { status = mThermal->getCoolingDevicesWithType(type, &ret); if (status.isOk()) { ASSERT_TRUE(status.isOk()); for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ThermalAidlTest); INSTANTIATE_TEST_SUITE_P( Thermal, ThermalAidlTest, Loading Loading
security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ parcelable ProtectedData { * ; HKDF. See details on use in ProtectedData comments above. The public key data * ; included in the other field of PartyUInfo / PartyVInfo is encoded as: * ; - a raw 32-byte public key for X25519 * ; - uncompressed SEC-1 coordinate data (0x04 || x || y) for P-256 * ; - raw coordinate data (x || y) for P-256 * Context = [ * AlgorithmID : 3 ; AES-GCM 256 * PartyUInfo : [ Loading
thermal/aidl/vts/VtsHalThermalTargetTest.cpp +139 −11 Original line number Diff line number Diff line Loading @@ -95,20 +95,15 @@ class ThermalAidlTest : public testing::TestWithParam<std::string> { mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); ASSERT_NE(mThermalCallback, nullptr); auto status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()); // Expect to fail if register again status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); } void TearDown() override { auto status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()); ::ndk::ScopedAStatus status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail if unregister again status = mThermal->unregisterThermalChangedCallback(mThermalCallback); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } Loading @@ -121,11 +116,144 @@ class ThermalAidlTest : public testing::TestWithParam<std::string> { // This just calls into and back from our local ThermalChangedCallback impl. TEST_P(ThermalAidlTest, NotifyThrottlingTest) { std::shared_ptr<ThermalCallback> thermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); auto ret = thermalCallback->notifyThrottling(kThrottleTemp); ASSERT_TRUE(ret.isOk()); ::ndk::ScopedAStatus status = thermalCallback->notifyThrottling(kThrottleTemp); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(thermalCallback->waitForCallback(200ms)); } // Test Thermal->registerThermalChangedCallback. TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackTest) { // Expect to fail with same callback ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); std::shared_ptr<ThermalCallback> localThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); // Expect to succeed with different callback status = mThermal->registerThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(localThermalCallback->waitForCallback(200ms)); // Remove the local callback status = mThermal->unregisterThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } // Test Thermal->registerThermalChangedCallbackWithType. TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackWithTypeTest) { // Expect to fail with same callback ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallbackWithType( mThermalCallback, TemperatureType::SKIN); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallbackWithType(nullptr, TemperatureType::SKIN); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); std::shared_ptr<ThermalCallback> localThermalCallback = ndk::SharedRefBase::make<ThermalCallback>(); // Expect to succeed with different callback status = mThermal->registerThermalChangedCallbackWithType(localThermalCallback, TemperatureType::SKIN); ASSERT_TRUE(status.isOk()) << status.getMessage(); ASSERT_TRUE(localThermalCallback->waitForCallback(200ms)); // Remove the local callback status = mThermal->unregisterThermalChangedCallback(localThermalCallback); ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } // Test Thermal->getCurrentTemperatures(). TEST_P(ThermalAidlTest, TemperatureTest) { std::vector<Temperature> ret; ::ndk::ScopedAStatus status = mThermal->getTemperatures(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<TemperatureType>(); for (const auto& type : types) { status = mThermal->getTemperaturesWithType(type, &ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } // Test Thermal->getTemperatureThresholds(). TEST_P(ThermalAidlTest, TemperatureThresholdTest) { std::vector<TemperatureThreshold> ret; ::ndk::ScopedAStatus status = mThermal->getTemperatureThresholds(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<TemperatureType>(); for (const auto& type : types) { status = mThermal->getTemperatureThresholdsWithType(type, &ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } // Test Thermal->getCoolingDevices(). TEST_P(ThermalAidlTest, CoolingDeviceTest) { std::vector<CoolingDevice> ret; ::ndk::ScopedAStatus status = mThermal->getCoolingDevices(&ret); if (status.isOk()) { for (auto& i : ret) { EXPECT_LT(0u, i.name.size()); LOG(INFO) << i.name + " " + toString(i.type) << "\n"; } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } auto types = ::ndk::enum_range<CoolingType>(); for (const auto& type : types) { status = mThermal->getCoolingDevicesWithType(type, &ret); if (status.isOk()) { ASSERT_TRUE(status.isOk()); for (auto& i : ret) { EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " + toString(i.type) + " for " + i.name; EXPECT_LT(0u, i.name.size()); } } else { ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode()); } } } GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ThermalAidlTest); INSTANTIATE_TEST_SUITE_P( Thermal, ThermalAidlTest, Loading