/* * Copyright (C) 2018 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef VTS_TREBLE_VINTF_TEST_UTILS_H_ #define VTS_TREBLE_VINTF_TEST_UTILS_H_ #include #include #include #include #include #include #include #include #include #include #include namespace android { namespace vintf { namespace testing { using android::FQName; using android::Hash; using android::sp; using android::hardware::hidl_array; using android::hardware::hidl_string; using android::hardware::hidl_vec; using android::hardware::Return; using android::hidl::base::V1_0::IBase; using android::hidl::manager::V1_0::IServiceManager; using android::procpartition::Partition; using android::vintf::HalManifest; using android::vintf::Level; using android::vintf::ManifestHal; using android::vintf::RuntimeInfo; using android::vintf::SchemaType; using android::vintf::to_string; using android::vintf::Transport; using android::vintf::Version; using android::vintf::VintfObject; using std::cout; using std::endl; using std::map; using std::multimap; using std::set; using std::string; using std::vector; using HalVerifyFn = std::function; using HashCharArray = hidl_array; using HalManifestPtr = std::shared_ptr; using MatrixPtr = std::shared_ptr; using RuntimeInfoPtr = std::shared_ptr; // Path to directory on target containing test data. extern const string kDataDir; // Name of file containing HAL hashes. extern const string kHashFileName; // Map from package name to package root. extern const map kPackageRoot; // HALs that are allowed to be passthrough under Treble rules. extern const set kPassthroughHals; extern const map kFcm2ApiLevelMap; // Returns ro.product.first_api_level if it is defined and not 0. Returns // ro.build.version.sdk otherwise. uint64_t GetShippingApiLevel(); // For a given interface returns package root if known. Returns empty string // otherwise. const string PackageRoot(const FQName& fq_iface_name); // Returns true iff HAL interface is Android platform. bool IsAndroidPlatformInterface(const FQName& fq_iface_name); // Returns the set of released hashes for a given HAL interface. set ReleasedHashes(const FQName& fq_iface_name); // Returns the partition that a HAL is associated with. Partition PartitionOfProcess(int32_t pid); // Returns SYSTEM for FRAMEWORK, VENDOR for DEVICE. Partition PartitionOfType(SchemaType type); } // namespace testing } // namespace vintf // Allows GTest to print pointers with a human readable string. template void PrintTo(const sp& v, std::ostream* os) { *os << android::hardware::details::toHexString( reinterpret_cast(&*v), true /* prefix */); } template void PrintTo(const T* v, std::ostream* os) { *os << android::hardware::details::toHexString( reinterpret_cast(v), true /* prefix */); } } // namespace android // Allows GTest to print pointers with a human readable string. namespace std { void PrintTo(const android::vintf::testing::HalManifestPtr& v, ostream* os); template void PrintTo(const T* v, ostream* os) { *os << android::hardware::details::toHexString( reinterpret_cast(v), true /* prefix */); } } // namespace std #endif // VTS_TREBLE_VINTF_TEST_UTILS_H_