Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61fb9e93 authored by Shawn Willden's avatar Shawn Willden Committed by Automerger Merge Worker
Browse files

Merge "Add check_feature helper" am: 786a9b96 am: a95165f3

parents 7913cfbf a95165f3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ cc_defaults {
        "VtsHalTargetTestDefaults",
    ],
    shared_libs: [
        "libbinder",
        "libbinder_ndk",
        "libcrypto",
        "packagemanager_aidl-cpp",
    ],
    static_libs: [
        "android.hardware.security.rkp-V3-ndk",
+24 −0
Original line number Diff line number Diff line
@@ -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>
@@ -2048,6 +2049,29 @@ void device_id_attestation_vsr_check(const ErrorCode& result) {
    }
}

// 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
+1 −0
Original line number Diff line number Diff line
@@ -402,6 +402,7 @@ void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode,
                        vector<uint8_t>* payload_value);
void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey);
void device_id_attestation_vsr_check(const ErrorCode& result);
bool check_feature(const std::string& name);

AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
AuthorizationSet SwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);