• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 };
45 
46 enum class GetBundleInfoFlag {
47     GET_BUNDLE_INFO_DEFAULT = 0x00000000,
48     GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001,
49     GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002,
50     GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004,
51     GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008,
52     GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010,
53     GET_BUNDLE_INFO_WITH_METADATA = 0x00000020,
54     GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040,
55     GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080,
56 };
57 
58 struct RequestPermissionUsedScene : public Parcelable {
59     std::vector<std::string> abilities;
60     std::string when;
61 
62     bool ReadFromParcel(Parcel &parcel);
63     virtual bool Marshalling(Parcel &parcel) const override;
64     static RequestPermissionUsedScene *Unmarshalling(Parcel &parcel);
65 };
66 
67 struct RequestPermission : public Parcelable {
68     std::string name;
69     std::string moduleName;
70     std::string reason;
71     int32_t reasonId = 0;
72     RequestPermissionUsedScene usedScene;
73 
74     bool ReadFromParcel(Parcel &parcel);
75     virtual bool Marshalling(Parcel &parcel) const override;
76     static RequestPermission *Unmarshalling(Parcel &parcel);
77 };
78 
79 struct SignatureInfo : public Parcelable {
80     std::string appId;
81     std::string fingerprint;
82 
83     bool ReadFromParcel(Parcel &parcel);
84     virtual bool Marshalling(Parcel &parcel) const override;
85     static SignatureInfo *Unmarshalling(Parcel &parcel);
86 };
87 
88 // configuration information about a bundle
89 struct BundleInfo : public Parcelable {
90     std::string name;
91 
92     uint32_t versionCode = 0;
93     std::string versionName;
94     uint32_t minCompatibleVersionCode = 0;
95 
96     uint32_t compatibleVersion = 0;
97     uint32_t targetVersion = 0;
98 
99     bool isKeepAlive = false;
100     bool singleton = false;
101     bool isPreInstallApp = false;
102 
103     std::string vendor;
104     std::string releaseType;
105     bool isNativeApp = false;
106 
107     std::string mainEntry; // modulePackage
108     std::string entryModuleName; // moduleName
109     bool entryInstallationFree = false; // application : false; atomic service : true
110     std::string appId;
111 
112     // user related fields, assign when calling the get interface
113     int uid = -1;
114     int gid = -1;
115     int64_t installTime = 0;
116     int64_t updateTime = 0;
117     int32_t appIndex = 0; // index for sandbox app
118 
119     ApplicationInfo applicationInfo;
120     std::vector<AbilityInfo> abilityInfos;
121     std::vector<ExtensionAbilityInfo> extensionInfos;
122     std::vector<HapModuleInfo> hapModuleInfos;
123     std::vector<std::string> hapModuleNames;    // the "module.package" in each config.json
124     std::vector<std::string> moduleNames;       // the "module.name" in each config.json
125     std::vector<std::string> modulePublicDirs;  // the public paths of all modules of the application.
126     std::vector<std::string> moduleDirs;        // the paths of all modules of the application.
127     std::vector<std::string> moduleResPaths;    // the paths of all resources paths.
128 
129     std::vector<std::string> reqPermissions;
130     std::vector<std::string> defPermissions;
131     std::vector<int32_t> reqPermissionStates;
132     std::vector<RequestPermission> reqPermissionDetails;
133     std::vector<OverlayBundleInfo> overlayBundleInfos;
134 
135     // unused
136     std::string cpuAbi;
137     std::string seInfo;
138     std::string label;
139     std::string description;
140     std::string jointUserId;
141     int32_t minSdkVersion = -1;
142     int32_t maxSdkVersion = -1;
143     bool isDifferentName = false;
144     int32_t overlayType = NON_OVERLAY_TYPE;
145 
146     SignatureInfo signatureInfo;
147 
148     bool ReadFromParcel(Parcel &parcel);
149     virtual bool Marshalling(Parcel &parcel) const override;
150     static BundleInfo *Unmarshalling(Parcel &parcel);
151 };
152 }  // namespace AppExecFwk
153 }  // namespace OHOS
154 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
155