summaryrefslogtreecommitdiff
path: root/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2023-06-23 03:27:00 -0700
committerLinux Build Service Account <lnxbuild@localhost>2023-06-23 03:27:00 -0700
commit7c8943fde12ec5fb0f9629746c65e8b1bc78d1b4 (patch)
tree90440ebec891f481da400afd777c5543e662d415 /security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
parentb3fa60314f030b03754610bb6c7a06a6e829929a (diff)
parent3e2ca930468dd371e5d125dccfc2595f9376d95b (diff)
Merge 3e2ca930468dd371e5d125dccfc2595f9376d95b on remote branch
Change-Id: If1cfbd071eda3663289762b17a2714cdef548869
Diffstat (limited to 'security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp')
-rw-r--r--security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 46db4f0c78..20c0bf580f 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -23,6 +23,7 @@
#include <android-base/logging.h>
#include <android/binder_manager.h>
+#include <android/content/pm/IPackageManagerNative.h>
#include <cppbor_parse.h>
#include <cutils/properties.h>
#include <gmock/gmock.h>
@@ -1923,6 +1924,29 @@ void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey)
*signingKey = std::move(pubKey);
}
+// Check whether the given named feature is available.
+bool check_feature(const std::string& name) {
+ ::android::sp<::android::IServiceManager> sm(::android::defaultServiceManager());
+ ::android::sp<::android::IBinder> binder(sm->getService(::android::String16("package_native")));
+ if (binder == nullptr) {
+ GTEST_LOG_(ERROR) << "getService package_native failed";
+ return false;
+ }
+ ::android::sp<::android::content::pm::IPackageManagerNative> packageMgr =
+ ::android::interface_cast<::android::content::pm::IPackageManagerNative>(binder);
+ if (packageMgr == nullptr) {
+ GTEST_LOG_(ERROR) << "Cannot find package manager";
+ return false;
+ }
+ bool hasFeature = false;
+ auto status = packageMgr->hasSystemFeature(::android::String16(name.c_str()), 0, &hasFeature);
+ if (!status.isOk()) {
+ GTEST_LOG_(ERROR) << "hasSystemFeature('" << name << "') failed: " << status;
+ return false;
+ }
+ return hasFeature;
+}
+
} // namespace test
} // namespace aidl::android::hardware::security::keymint