1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "parcel.h"
23 
24 #include "ability_info.h"
25 #include "application_info.h"
26 #include "extension_ability_info.h"
27 #include "hap_module_info.h"
28 #include "message_parcel.h"
29 #include "overlay/overlay_bundle_info.h"
30 
31 namespace OHOS {
32 namespace AppExecFwk {
33 enum BundleFlag {
34     // get bundle info except abilityInfos
35     GET_BUNDLE_DEFAULT = 0x00000000,
36     // get bundle info include abilityInfos
37     GET_BUNDLE_WITH_ABILITIES = 0x00000001,
38     // get bundle info include request permissions
39     GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010,
40     // get bundle info include extension info
41     GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020,
42     // get bundle info include hash value
43     GET_BUNDLE_WITH_HASH_VALUE = 0x00000030,
44     // get bundle info inlcude menu, only for dump usage
45     GET_BUNDLE_WITH_MENU = 0x00000040,
46     // get bundle info inlcude router map, only for dump usage
47     GET_BUNDLE_WITH_ROUTER_MAP = 0x00000080,
48     // get bundle info include skill info
49     GET_BUNDLE_WITH_SKILL = 0x00000800,
50 };
51 
52 enum class GetBundleInfoFlag {
53     GET_BUNDLE_INFO_DEFAULT = 0x00000000,
54     GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001,
55     GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002,
56     GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004,
57     GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008,
58     GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010,
59     GET_BUNDLE_INFO_WITH_METADATA = 0x00000020,
60     GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040,
61     GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080,
62     GET_BUNDLE_INFO_WITH_MENU = 0x00000100,
63     GET_BUNDLE_INFO_WITH_ROUTER_MAP = 0x00000200,
64     GET_BUNDLE_INFO_WITH_SKILL = 0x00000800,
65     GET_BUNDLE_INFO_ONLY_WITH_LAUNCHER_ABILITY = 0x00001000,
66     GET_BUNDLE_INFO_OF_ANY_USER = 0x00002000,
67     GET_BUNDLE_INFO_EXCLUDE_CLONE = 0x00004000,
68 };
69 
70 struct RequestPermissionUsedScene : public Parcelable {
71     std::vector<std::string> abilities;
72     std::string when;
73 
74     bool ReadFromParcel(Parcel &parcel);
75     virtual bool Marshalling(Parcel &parcel) const override;
76     static RequestPermissionUsedScene *Unmarshalling(Parcel &parcel);
77 };
78 
79 struct RequestPermission : public Parcelable {
80     std::string name;
81     std::string moduleName;
82     std::string reason;
83     uint32_t reasonId = 0;
84     RequestPermissionUsedScene usedScene;
85 
86     bool ReadFromParcel(Parcel &parcel);
87     virtual bool Marshalling(Parcel &parcel) const override;
88     static RequestPermission *Unmarshalling(Parcel &parcel);
89 };
90 
91 struct SignatureInfo : public Parcelable {
92     std::string appId;
93     std::string fingerprint;
94     std::string appIdentifier;
95     std::string certificate;
96 
97     bool ReadFromParcel(Parcel &parcel);
98     virtual bool Marshalling(Parcel &parcel) const override;
99     static SignatureInfo *Unmarshalling(Parcel &parcel);
100 };
101 
102 // configuration information about a bundle
103 struct BundleInfo : public Parcelable {
104     std::string name;
105 
106     bool isNewVersion = false;
107     uint32_t versionCode = 0;
108     std::string versionName;
109     uint32_t minCompatibleVersionCode = 0;
110 
111     uint32_t compatibleVersion = 0;
112     uint32_t targetVersion = 0;
113 
114     bool isKeepAlive = false;
115     bool singleton = false;
116     bool isPreInstallApp = false;
117 
118     std::string vendor;
119     std::string releaseType;
120     bool isNativeApp = false;
121 
122     std::string mainEntry; // modulePackage
123     std::string entryModuleName; // moduleName
124     bool entryInstallationFree = false; // application : false; atomic service : true
125     std::string appId;
126     std::vector<std::string> oldAppIds; // used for appId changed
127 
128     // user related fields, assign when calling the get interface
129     int uid = -1;
130     int gid = -1;
131     int64_t installTime = 0;
132     int64_t updateTime = 0;
133     int32_t appIndex = 0; // index for sandbox app
134 
135     ApplicationInfo applicationInfo;
136     std::vector<AbilityInfo> abilityInfos;
137     std::vector<ExtensionAbilityInfo> extensionInfos;
138     std::vector<HapModuleInfo> hapModuleInfos;
139     std::vector<std::string> hapModuleNames;    // the "module.package" in each config.json
140     std::vector<std::string> moduleNames;       // the "module.name" in each config.json
141     std::vector<std::string> modulePublicDirs;  // the public paths of all modules of the application.
142     std::vector<std::string> moduleDirs;        // the paths of all modules of the application.
143     std::vector<std::string> moduleResPaths;    // the paths of all resources paths.
144 
145     std::vector<std::string> reqPermissions;
146     std::vector<std::string> defPermissions;
147     std::vector<int32_t> reqPermissionStates;
148     std::vector<RequestPermission> reqPermissionDetails;
149     std::vector<OverlayBundleInfo> overlayBundleInfos;
150 
151     std::string cpuAbi;
152     std::string seInfo;
153     std::string label;
154     std::string description;
155     std::string jointUserId;
156     int32_t minSdkVersion = -1;
157     int32_t maxSdkVersion = -1;
158     bool isDifferentName = false;
159     int32_t overlayType = NON_OVERLAY_TYPE;
160 
161     SignatureInfo signatureInfo;
162     std::vector<RouterItem> routerArray;
163 
164     bool ReadFromParcel(Parcel &parcel);
165     virtual bool Marshalling(Parcel &parcel) const override;
166     static BundleInfo *Unmarshalling(Parcel &parcel);
167 };
168 }  // namespace AppExecFwk
169 }  // namespace OHOS
170 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
171