mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Add check_feature helper" into android12-tests-dev
This commit is contained in:
@@ -30,6 +30,7 @@ cc_defaults {
|
|||||||
"VtsHalTargetTestDefaults",
|
"VtsHalTargetTestDefaults",
|
||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
|
"libbinder",
|
||||||
"libbinder_ndk",
|
"libbinder_ndk",
|
||||||
"libcrypto",
|
"libcrypto",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android/binder_manager.h>
|
#include <android/binder_manager.h>
|
||||||
|
#include <android/content/pm/IPackageManagerNative.h>
|
||||||
#include <cppbor_parse.h>
|
#include <cppbor_parse.h>
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
@@ -1679,6 +1680,29 @@ void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey)
|
|||||||
*signingKey = std::move(pubKey);
|
*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 test
|
||||||
|
|
||||||
} // namespace aidl::android::hardware::security::keymint
|
} // namespace aidl::android::hardware::security::keymint
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ vector<uint8_t> make_name_from_str(const string& name);
|
|||||||
void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode,
|
void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode,
|
||||||
vector<uint8_t>* payload_value);
|
vector<uint8_t>* payload_value);
|
||||||
void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey);
|
void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey);
|
||||||
|
bool check_feature(const std::string& name);
|
||||||
|
|
||||||
AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
|
AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
|
||||||
AuthorizationSet SwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
|
AuthorizationSet SwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
|
||||||
|
|||||||
Reference in New Issue
Block a user