1 /* 2 * Copyright (C) 2020 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 #pragma once 18 19 #include <functional> 20 #include <map> 21 #include <memory> 22 #include <optional> 23 24 #include <vintf/FileSystem.h> 25 #include <vintf/HalFormat.h> 26 #include <vintf/Level.h> 27 #include <vintf/VintfObject.h> 28 29 namespace android::vintf { 30 31 class VintfFm { 32 public: 33 // Use default filesystem. 34 VintfFm(); 35 // Exposed for testing. VintfFm(std::unique_ptr<WritableFileSystem> && fs)36 VintfFm(std::unique_ptr<WritableFileSystem>&& fs) : mFs(std::move(fs)) {} 37 int main(int argc, char** argv); 38 39 private: 40 using FrozenMatrices = std::map<Level, CompatibilityMatrix>; 41 using FsFactory = std::function<std::unique_ptr<FileSystem>()>; 42 43 std::unique_ptr<WritableFileSystem> mFs; 44 45 // Check framework manifest against frozen text in dir. 46 int check(const FsFactory& vintfFsFactory, const std::string& dir); 47 // Dump frozen text suing framework manifest 48 int update(const FsFactory& vintfFsFactory, const std::string& dir, Level level); 49 std::shared_ptr<const HalManifest> getManifestForLevel(const FsFactory& vintfFsFactory, 50 Level level); 51 bool dumpMatrix(const HalManifest& manifest, const std::string& dir, Level level); 52 std::optional<FrozenMatrices> loadMatrices(const std::string& dir); 53 }; 54 55 } // namespace android::vintf 56