• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
54     bool operator==(const ManifestInstance& other) const;
55     bool operator<(const ManifestInstance& other) const;
56 
57     // Convenience methods.
58     // return package@version::interface/instance
59     const FqInstance& getFqInstance() const;
60 
61     // This is for writing the XML <fqname> tag.
62     // For AIDL, return "interface/instance".
63     // For others, return "@version::interface/instance".
64     std::string getSimpleFqInstance() const;
65 
66     // For AIDL, return "package.interface/instance (@version)".
67     // For others, return "package@version::interface/instance".
68     std::string description() const;
69 
70     // Similar to description() but without package name.
71     // For AIDL, return "interface/instance (@version)".
72     // For others, return "@version::interface/instance".
73     std::string descriptionWithoutPackage() const;
74 
75     // Return a new ManifestInstance that's the same as this, but with the given version.
76     ManifestInstance withVersion(const Version& v) const;
77 
78    private:
79     FqInstance mFqInstance;
80     TransportArch mTransportArch;
81     HalFormat mHalFormat;
82     std::optional<std::string> mUpdatableViaApex;
83 };
84 
85 }  // namespace vintf
86 }  // namespace android
87 
88 #endif  // ANDROID_VINTF_MANIFEST_INSTANCE_H
89