• 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_APPLICATION_INFO_H
17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "module_info.h"
24 #include "parcel.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 namespace {
29     const std::string AVAILABLELEVEL_NORMAL = "normal";
30 }
31 enum ApplicationFlag {
32     GET_BASIC_APPLICATION_INFO = 0x00000000,
33     GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008,
34     GET_APPLICATION_INFO_WITH_METADATA = 0x00000040,
35     GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200,
36     GET_ALL_APPLICATION_INFO = 0xFFFF0000,
37 };
38 
39 struct Metadata : public Parcelable {
40     std::string name;
41     std::string value;
42     std::string resource;
43     Metadata() = default;
44     Metadata(const std::string &paramName, const std::string &paramValue, const std::string &paramResource);
45     bool ReadFromParcel(Parcel &parcel);
46     virtual bool Marshalling(Parcel &parcel) const override;
47     static Metadata *Unmarshalling(Parcel &parcel);
48 };
49 
50 struct CustomizeData : public Parcelable {
51     std::string name;
52     std::string value;
53     std::string extra;
54     CustomizeData() = default;
55     CustomizeData(std::string paramName, std::string paramValue, std::string paramExtra);
56     bool ReadFromParcel(Parcel &parcel);
57     virtual bool Marshalling(Parcel &parcel) const override;
58     static CustomizeData *Unmarshalling(Parcel &parcel);
59 };
60 
61 struct MetaData {
62     std::vector<CustomizeData> customizeData;
63 };
64 
65 struct ApplicationInfo;
66 
67 struct CompatibleApplicationInfo : public Parcelable {
68     // items set when installing.
69     std::string name; // application name.
70     std::string icon; // application icon resource index.
71     std::string label; // application name displayed to the user.
72     std::string description; // description of application.
73     std::string cpuAbi; // current device cpu abi.
74     std::string process;
75     bool isCompressNativeLibs = true;
76 
77     int32_t iconId = 0;
78     int32_t labelId = 0;
79     int32_t descriptionId = 0;
80 
81     bool systemApp = false;
82 
83     std::vector<std::string> permissions;
84     std::vector<ModuleInfo> moduleInfos;
85 
86     int32_t supportedModes = 0; // supported modes.
87     bool enabled = true;
88     bool debug = false;
89 
90     bool ReadFromParcel(Parcel& parcel);
91     virtual bool Marshalling(Parcel& parcel) const override;
92     static CompatibleApplicationInfo* Unmarshalling(Parcel& parcel);
93     void ConvertToApplicationInfo(ApplicationInfo& applicationInfo) const;
94 };
95 
96 // configuration information about an application
97 struct ApplicationInfo : public Parcelable {
98     std::string name;  // application name is same to bundleName
99     std::string bundleName;
100 
101     uint32_t versionCode = 0;
102     std::string versionName;
103     int32_t minCompatibleVersionCode = 0;
104 
105     uint32_t apiCompatibleVersion = 0;
106     int32_t apiTargetVersion = 0;
107 
108     std::string iconPath;
109     int32_t iconId = 0;
110     std::string label;
111     int32_t labelId = 0;
112     std::string description;
113     int32_t descriptionId = 0;
114 
115     bool keepAlive = false;
116     bool removable = true;
117     bool singleUser = false;
118     bool userDataClearable = true;
119     bool accessible = false;
120 
121     bool isSystemApp = false;
122     bool isLauncherApp = false;
123 
124     std::string codePath;
125     std::string dataDir;
126     std::string dataBaseDir;
127     std::string cacheDir;
128     std::string entryDir;
129 
130     std::string apiReleaseType;
131     bool debug = false;
132     std::string deviceId;
133     bool distributedNotificationEnabled = true;
134     std::string entityType;
135     std::string process;
136     int32_t supportedModes = 0;  // returns 0 if the application does not support the driving mode
137     std::string vendor;
138 
139     // apl
140     std::string appPrivilegeLevel = AVAILABLELEVEL_NORMAL;
141 
142     // user related fields, assign when calling the get interface
143     uint32_t accessTokenId = 0;
144     bool enabled = false;
145     int32_t uid = -1;
146 
147     // native so
148     std::string nativeLibraryPath;
149     std::string cpuAbi;
150 
151     // assign when calling the get interface
152     std::vector<std::string> permissions;
153     std::vector<std::string> moduleSourceDirs;
154     std::vector<ModuleInfo> moduleInfos;
155     std::map<std::string, std::vector<CustomizeData>> metaData;
156     std::map<std::string, std::vector<Metadata>> metadata;
157 
158     bool isCloned = false;
159 
160     // unused
161     std::string icon;
162     int32_t flags = 0;
163     std::string entryModuleName;
164     bool isCompressNativeLibs = true;
165     std::string signatureKey;
166 
167     bool ReadFromParcel(Parcel &parcel);
168     bool ReadMetaDataFromParcel(Parcel &parcel);
169     virtual bool Marshalling(Parcel &parcel) const override;
170     static ApplicationInfo *Unmarshalling(Parcel &parcel);
171     void Dump(std::string prefix, int fd);
172     void ConvertToCompatibleApplicationInfo(CompatibleApplicationInfo& compatibleApplicationInfo) const;
173 };
174 }  // namespace AppExecFwk
175 }  // namespace OHOS
176 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H
177