1 /* 2 * Copyright (C) 2018 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 #ifndef ANDROID_VINTF_MANIFEST_INSTANCE_H 18 #define ANDROID_VINTF_MANIFEST_INSTANCE_H 19 20 #include <optional> 21 #include <string> 22 23 #include <hidl-util/FqInstance.h> 24 25 #include "HalFormat.h" 26 #include "TransportArch.h" 27 #include "Version.h" 28 29 namespace android { 30 namespace vintf { 31 32 class ManifestInstance { 33 public: 34 ManifestInstance(); 35 ManifestInstance(const ManifestInstance&); 36 ManifestInstance(ManifestInstance&&) noexcept; 37 ManifestInstance& operator=(const ManifestInstance&); 38 ManifestInstance& operator=(ManifestInstance&&) noexcept; 39 40 using VersionType = Version; 41 ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta, HalFormat fmt, 42 std::optional<std::string>&& updatableViaApex); 43 ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta, HalFormat fmt, 44 const std::optional<std::string>& updatableViaApex); 45 const std::string& package() const; 46 Version version() const; 47 const std::string& interface() const; 48 const std::string& instance() const; 49 Transport transport() const; 50 Arch arch() const; 51 HalFormat format() const; 52 const std::optional<std::string>& updatableViaApex() const; 53 const std::optional<std::string> ip() const; 54 const std::optional<uint64_t> port() const; 55 56 bool operator==(const ManifestInstance& other) const; 57 bool operator<(const ManifestInstance& other) const; 58 59 // Convenience methods. 60 // return package@version::interface/instance 61 const FqInstance& getFqInstance() const; 62 63 // This is for writing the XML <fqname> tag. 64 // For AIDL, return "interface/instance". 65 // For others, return "@version::interface/instance". 66 std::string getSimpleFqInstance() const; 67 68 // For AIDL, return "package.interface/instance (@version)". 69 // For others, return "package@version::interface/instance". 70 std::string description() const; 71 72 // Similar to description() but without package name. 73 // For AIDL, return "interface/instance (@version)". 74 // For others, return "@version::interface/instance". 75 std::string descriptionWithoutPackage() const; 76 77 // Return a new ManifestInstance that's the same as this, but with the given version. 78 ManifestInstance withVersion(const Version& v) const; 79 80 private: 81 FqInstance mFqInstance; 82 TransportArch mTransportArch; 83 HalFormat mHalFormat; 84 std::optional<std::string> mUpdatableViaApex; 85 }; 86 87 } // namespace vintf 88 } // namespace android 89 90 #endif // ANDROID_VINTF_MANIFEST_INSTANCE_H 91