• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_ABILITY_INFO_H
17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
18 
19 #include <string>
20 
21 #include "parcel.h"
22 #include "application_info.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 
27 enum class AbilityType {
28     UNKNOWN = 0,
29     PAGE,
30     SERVICE,
31     DATA,
32     FORM,
33 };
34 
35 enum class AbilitySubType {
36     UNSPECIFIED = 0,
37     CA,
38 };
39 
40 enum class DisplayOrientation {
41     UNSPECIFIED = 0,
42     LANDSCAPE,
43     PORTRAIT,
44     FOLLOWRECENT,
45 };
46 
47 enum class LaunchMode {
48     SINGLETON = 0,
49     STANDARD,  // support more than one instance
50     SINGLETOP,
51 };
52 
53 struct Parameters {
54     std::string description;
55     std::string name;
56     std::string type;
57 };
58 
59 struct Results {
60     std::string description;
61     std::string name;
62     std::string type;
63 };
64 
65 struct CustomizeData {
66     std::string name;
67     std::string value;
68     std::string extra;
69 };
70 
71 struct MetaData {
72     std::vector<Parameters> parameters;
73     std::vector<Results> results;
74     std::vector<CustomizeData> customizeData;
75 };
76 
77 struct AbilityInfo;
78 
79 /*
80 * According to Ability profile 1.0
81 */
82 struct CompatibleAbilityInfo : public Parcelable {
83     // deprecated: ability code class simple name, use 'className' instead.
84     std::string package;
85     std::string name;
86     std::string label; // display name on screen.
87     std::string description;
88     std::string iconPath; // used as icon data (base64) for WEB Ability.
89     std::string uri; // uri of ability.
90     std::string moduleName; // indicates the name of the .hap package to which the capability belongs.
91     std::string process;
92     std::string targetAbility;
93     std::string appName;
94     std::string privacyUrl;
95     std::string privacyName;
96     std::string downloadUrl;
97     std::string versionName;
98     uint32_t backgroundModes = 0;
99     uint32_t packageSize = 0; // The size of the package that AbilityInfo.uri points to.
100     bool visible = false;
101     bool formEnabled = false;
102     bool multiUserShared = false;
103     // deprecated: remove this field in new package format.
104     AbilityType type = AbilityType::UNKNOWN;
105     AbilitySubType subType = AbilitySubType::UNSPECIFIED;
106     DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED;
107     LaunchMode launchMode = LaunchMode::STANDARD;
108     std::vector<std::string> permissions;
109     std::vector<std::string> deviceTypes;
110     std::vector<std::string> deviceCapabilities;
111     bool supportPipMode = false;
112     bool grantPermission = false;
113     std::string readPermission;
114     std::string writePermission;
115     std::string uriPermissionMode;
116     std::string uriPermissionPath;
117     bool directLaunch = true;
118 
119     // set when install
120     std::string bundleName; // bundle name which has this ability.
121     std::string className;  // the ability full class name.
122     std::string originalClassName; // the original ability full class name
123     std::string deviceId; // device UDID information.
124     CompatibleApplicationInfo applicationInfo;
125 
126     // form widget info
127     uint32_t formEntity = 1; // where form can be displayed
128     int32_t minFormHeight = 0; // minimum height of ability.
129     int32_t defaultFormHeight = 0; // default height of ability.
130     int32_t minFormWidth = 0; // minimum width of ability.
131     int32_t defaultFormWidth = 0; // default width of ability.
132 
133     uint32_t iconId = 0;
134     uint32_t labelId = 0;
135     uint32_t descriptionId = 0;
136     bool enabled = true;
137 
138     bool ReadFromParcel(Parcel& parcel);
139     virtual bool Marshalling(Parcel& parcel) const override;
140     static CompatibleAbilityInfo* Unmarshalling(Parcel& parcel);
141 
142     void CopyToDest(CompatibleAbilityInfo& dest) const;
143     void ConvertToAbilityInfo(AbilityInfo& abilityInfo) const;
144 };
145 
146 // configuration information about an ability
147 struct AbilityInfo : public Parcelable {
148     std::string name;  // ability name, only the main class name
149     std::string label;
150     std::string description;
151     std::string iconPath;
152     int32_t labelId;
153     int32_t descriptionId;
154     int32_t iconId;
155     std::string theme;
156     bool visible = false;
157     std::string kind;  // ability category
158     AbilityType type = AbilityType::UNKNOWN;
159     DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED;
160     LaunchMode launchMode = LaunchMode::STANDARD;
161     std::string srcPath;
162     std::string srcLanguage = "js";
163     std::vector<std::string> permissions;
164 
165     std::string process;
166     std::vector<std::string> deviceTypes;
167     std::vector<std::string> deviceCapabilities;
168     std::string uri;
169     std::string targetAbility;
170     ApplicationInfo applicationInfo;
171     bool isLauncherAbility = false;
172     bool isNativeAbility = false;
173     bool enabled = false;
174     bool supportPipMode = false;
175     bool formEnabled = false;
176     std::string readPermission;
177     std::string writePermission;
178     std::vector<std::string> configChanges;
179     uint32_t formEntity;
180     int32_t minFormHeight = 0;
181     int32_t defaultFormHeight = 0;
182     int32_t minFormWidth = 0;
183     int32_t defaultFormWidth = 0;
184     MetaData metaData;
185 
186     // set when install
187     std::string package;  // the "module.package" in config.json
188     std::string bundleName;
189     std::string moduleName;       // the "module.name" in config.json
190     std::string applicationName;  // the "bundlename" in config.json
191     std::string deviceId;         // should auto-get self device id
192     std::string codePath;         // ability main code path with name
193     std::string resourcePath;     // resource path for resource init
194     std::string libPath;          // ability library path without name, libPath->libDir
195 
196     // element that does not exist for a while
197     std::string originalBundleName;
198     std::string appName;
199     std::string privacyUrl;
200     std::string privacyName;
201     std::string downloadUrl;
202     std::string versionName;
203     std::string className;
204     std::string originalClassName;
205     std::string uriPermissionMode;
206     std::string uriPermissionPath;
207     uint32_t backgroundModes = 0;
208     uint32_t packageSize = 0;
209     bool multiUserShared = false;
210     bool grantPermission = false;
211     bool directLaunch = true;
212     AbilitySubType subType = AbilitySubType::UNSPECIFIED;
213 
214     bool ReadFromParcel(Parcel &parcel);
215     virtual bool Marshalling(Parcel &parcel) const override;
216     static AbilityInfo *Unmarshalling(Parcel &parcel);
217     void Dump(std::string prefix, int fd);
218     void ConvertToCompatiableAbilityInfo(CompatibleAbilityInfo& compatibleAbilityInfo) const;
219 };
220 
221 }  // namespace AppExecFwk
222 }  // namespace OHOS
223 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H