blob: 01e3ea09c65dc71e1e254df5bc10880d3c89f56a [file] [log] [blame]
Yifan Hong676447a2016-11-15 12:57:23 -08001/*
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 Hongccf967b2017-01-18 11:04:19 -080019#include <vintf/parse_string.h>
Yifan Hong3daec812017-02-27 18:49:11 -080020#include <vintf/VintfObject.h>
Yifan Hong676447a2016-11-15 12:57:23 -080021
Yifan Hong1e5a0542017-04-28 14:37:56 -070022// A convenience binary to dump information available through libvintf.
Yifan Hong676447a2016-11-15 12:57:23 -080023int main(int, char **) {
24 using namespace ::android::vintf;
25
Yifan Hong1e5a0542017-04-28 14:37:56 -070026 std::cout << "======== Device HAL Manifest =========" << std::endl;
27
Yifan Hong3daec812017-02-27 18:49:11 -080028 const HalManifest *vm = VintfObject::GetDeviceHalManifest();
Yifan Hong676447a2016-11-15 12:57:23 -080029 if (vm != nullptr)
Yifan Hongd2b7e642017-02-17 10:15:32 -080030 std::cout << gHalManifestConverter(*vm);
Yifan Hongccf967b2017-01-18 11:04:19 -080031
Yifan Hong1e5a0542017-04-28 14:37:56 -070032 std::cout << "======== Framework HAL Manifest =========" << std::endl;
33
Yifan Hong3daec812017-02-27 18:49:11 -080034 const HalManifest *fm = VintfObject::GetFrameworkHalManifest();
35 if (fm != nullptr)
36 std::cout << gHalManifestConverter(*fm);
37
Yifan Hong1e5a0542017-04-28 14:37:56 -070038 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
Yifan Hong3f835d62017-05-16 13:10:11 -070050 std::cout << "======== Runtime Info =========" << std::endl;
51
52 const RuntimeInfo* ki = VintfObject::GetRuntimeInfo();
53 if (ki != nullptr) std::cout << dump(*ki);
54 std::cout << std::endl;
55
Yifan Hong1e5a0542017-04-28 14:37:56 -070056 std::cout << "======== Compatibility check =========" << std::endl;
57 std::cout << "Device HAL Manifest? " << (vm != nullptr) << std::endl
58 << "Device Compatibility Matrix? " << (vcm != nullptr) << std::endl
59 << "Framework HAL Manifest? " << (fm != nullptr) << std::endl
60 << "Framework Compatibility Matrix? " << (fcm != nullptr) << std::endl;
61 std::string error;
62 if (vm && fcm) {
63 bool compatible = vm->checkCompatibility(*fcm, &error);
64 std::cout << "Device HAL Manifest <==> Framework Compatibility Matrix? "
65 << compatible;
66 if (!compatible)
67 std::cout << ", " << error;
68 std::cout << std::endl;
69 }
70 if (fm && vcm) {
71 bool compatible = fm->checkCompatibility(*vcm, &error);
72 std::cout << "Framework HAL Manifest <==> Device Compatibility Matrix? "
73 << compatible;
74 if (!compatible)
75 std::cout << ", " << error;
76 std::cout << std::endl;
77 }
Yifan Hong3f835d62017-05-16 13:10:11 -070078 if (ki && fcm) {
79 bool compatible = ki->checkCompatibility(*fcm, &error);
80 std::cout << "Runtime info <==> Framework Compatibility Matrix? " << compatible;
81 if (!compatible) std::cout << ", " << error;
82 std::cout << std::endl;
83 }
Yifan Hong1e5a0542017-04-28 14:37:56 -070084
Yifan Hong3f835d62017-05-16 13:10:11 -070085 {
86 auto compatible = VintfObject::CheckCompatibility({}, &error);
87 std::cout << "VintfObject::CheckCompatibility (0 == compatible)? " << compatible;
88 if (compatible != COMPATIBLE) std::cout << ", " << error;
89 std::cout << std::endl;
90 }
Yifan Hong676447a2016-11-15 12:57:23 -080091}