Yifan Hong | 676447a | 2016-11-15 12:57:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <iostream> |
| 18 | #include <vintf/parse_xml.h> |
Yifan Hong | ccf967b | 2017-01-18 11:04:19 -0800 | [diff] [blame] | 19 | #include <vintf/parse_string.h> |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 20 | #include <vintf/VintfObject.h> |
Yifan Hong | 676447a | 2016-11-15 12:57:23 -0800 | [diff] [blame] | 21 | |
Yifan Hong | 1e5a054 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 22 | // A convenience binary to dump information available through libvintf. |
Yifan Hong | 676447a | 2016-11-15 12:57:23 -0800 | [diff] [blame] | 23 | int main(int, char **) { |
| 24 | using namespace ::android::vintf; |
| 25 | |
Yifan Hong | 1e5a054 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 26 | std::cout << "======== Device HAL Manifest =========" << std::endl; |
| 27 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 28 | const HalManifest *vm = VintfObject::GetDeviceHalManifest(); |
Yifan Hong | 676447a | 2016-11-15 12:57:23 -0800 | [diff] [blame] | 29 | if (vm != nullptr) |
Yifan Hong | d2b7e64 | 2017-02-17 10:15:32 -0800 | [diff] [blame] | 30 | std::cout << gHalManifestConverter(*vm); |
Yifan Hong | ccf967b | 2017-01-18 11:04:19 -0800 | [diff] [blame] | 31 | |
Yifan Hong | 1e5a054 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 32 | std::cout << "======== Framework HAL Manifest =========" << std::endl; |
| 33 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 34 | const HalManifest *fm = VintfObject::GetFrameworkHalManifest(); |
| 35 | if (fm != nullptr) |
| 36 | std::cout << gHalManifestConverter(*fm); |
| 37 | |
Yifan Hong | 1e5a054 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 38 | std::cout << "======== Device Compatibility Matrix =========" << std::endl; |
| 39 | |
| 40 | const CompatibilityMatrix *vcm = VintfObject::GetDeviceCompatibilityMatrix(); |
| 41 | if (vcm != nullptr) |
| 42 | std::cout << gCompatibilityMatrixConverter(*vcm); |
| 43 | |
| 44 | std::cout << "======== Framework Compatibility Matrix =========" << std::endl; |
| 45 | |
| 46 | const CompatibilityMatrix *fcm = VintfObject::GetFrameworkCompatibilityMatrix(); |
| 47 | if (fcm != nullptr) |
| 48 | std::cout << gCompatibilityMatrixConverter(*fcm); |
| 49 | |
| 50 | std::cout << "======== Compatibility check =========" << std::endl; |
| 51 | std::cout << "Device HAL Manifest? " << (vm != nullptr) << std::endl |
| 52 | << "Device Compatibility Matrix? " << (vcm != nullptr) << std::endl |
| 53 | << "Framework HAL Manifest? " << (fm != nullptr) << std::endl |
| 54 | << "Framework Compatibility Matrix? " << (fcm != nullptr) << std::endl; |
| 55 | std::string error; |
| 56 | if (vm && fcm) { |
| 57 | bool compatible = vm->checkCompatibility(*fcm, &error); |
| 58 | std::cout << "Device HAL Manifest <==> Framework Compatibility Matrix? " |
| 59 | << compatible; |
| 60 | if (!compatible) |
| 61 | std::cout << ", " << error; |
| 62 | std::cout << std::endl; |
| 63 | } |
| 64 | if (fm && vcm) { |
| 65 | bool compatible = fm->checkCompatibility(*vcm, &error); |
| 66 | std::cout << "Framework HAL Manifest <==> Device Compatibility Matrix? " |
| 67 | << compatible; |
| 68 | if (!compatible) |
| 69 | std::cout << ", " << error; |
| 70 | std::cout << std::endl; |
| 71 | } |
| 72 | |
| 73 | std::cout << "======== Runtime Info =========" << std::endl; |
| 74 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 75 | const RuntimeInfo *ki = VintfObject::GetRuntimeInfo(); |
Yifan Hong | ccf967b | 2017-01-18 11:04:19 -0800 | [diff] [blame] | 76 | if (ki != nullptr) |
| 77 | std::cout << dump(*ki); |
| 78 | std::cout << std::endl; |
Yifan Hong | 676447a | 2016-11-15 12:57:23 -0800 | [diff] [blame] | 79 | } |