• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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_EXTENSION_INFO_H
17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_EXTENSION_INFO_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "application_info.h"
23 #include "parcel.h"
24 #include "skill.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 enum ExtensionAbilityInfoFlag {
29     GET_EXTENSION_INFO_DEFAULT = 0x00000000,
30     GET_EXTENSION_INFO_WITH_PERMISSION = 0x00000002,
31     GET_EXTENSION_INFO_WITH_APPLICATION = 0x00000004,
32     GET_EXTENSION_INFO_WITH_METADATA = 0x00000020,
33     GET_EXTENSION_INFO_WITH_SKILL_URI = 0x00000200,
34     GET_EXTENSION_INFO_WITH_SKILL = 0x00000400,
35 };
36 
37 enum class GetExtensionAbilityInfoFlag {
38     GET_EXTENSION_ABILITY_INFO_DEFAULT = 0x00000000,
39     GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION = 0x00000001,
40     GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION = 0x00000002,
41     GET_EXTENSION_ABILITY_INFO_WITH_METADATA = 0x00000004,
42     GET_EXTENSION_ABILITY_INFO_WITH_SKILL_URI = 0x00000008,
43     GET_EXTENSION_ABILITY_INFO_WITH_SKILL = 0x00000010,
44     // using this tag will only return the first system app, only for c++
45     // appIndex = 0,invalid input of other flag
46     // appIndex !=0,this flag is invalid
47     GET_EXTENSION_ABILITY_INFO_BY_TYPE_NAME = 0x80000000,
48 };
49 
50 enum class ExtensionAbilityType {
51     FORM = 0,
52     WORK_SCHEDULER = 1,
53     INPUTMETHOD = 2,
54     SERVICE = 3,
55     ACCESSIBILITY = 4,
56     DATASHARE = 5,
57     FILESHARE = 6,
58     STATICSUBSCRIBER = 7,
59     WALLPAPER = 8,
60     BACKUP = 9,
61     WINDOW = 10,
62     ENTERPRISE_ADMIN = 11,
63     FILEACCESS_EXTENSION = 12,
64     THUMBNAIL = 13,
65     PREVIEW = 14,
66     PRINT = 15,
67     SHARE = 16,
68     PUSH = 17,
69     DRIVER = 18,
70     ACTION = 19,
71     ADS_SERVICE = 20,
72     EMBEDDED_UI = 21,
73     INSIGHT_INTENT_UI = 22,
74     PHOTO_EDITOR = 23,
75     FENCE = 24,
76     UNSPECIFIED = 255,
77     UI = 256,
78     HMS_ACCOUNT = 257,
79     APP_ACCOUNT_AUTHORIZATION = 258,
80     ADS = 259,
81     REMOTE_NOTIFICATION = 260,
82     REMOTE_LOCATION = 261,
83     VOIP = 262,
84     ACCOUNTLOGOUT = 263,
85     STATUS_BAR_VIEW = 264,
86     LIVEVIEW_LOCKSCREEN = 265,
87     UI_SERVICE = 269,
88     SYSDIALOG_USERAUTH = 300,
89     SYSDIALOG_COMMON = 301,
90     SYSDIALOG_ATOMICSERVICEPANEL = 302,
91     SYSDIALOG_POWER = 303,
92     SYSDIALOG_MEETIMECALL = 304,
93     SYSDIALOG_MEETIMECONTACT = 305,
94     SYSDIALOG_MEETIMEMESSAGE = 306,
95     SYSDIALOG_PRINT = 307,
96     SYSPICKER_MEDIACONTROL = 400,
97     SYSPICKER_SHARE = 401,
98     SYSPICKER_MEETIMECONTACT = 402,
99     SYSPICKER_MEETIMECALLLOG = 403,
100     SYSPICKER_PHOTOPICKER = 404,
101     SYSPICKER_CAMERA = 405,
102     SYSPICKER_NAVIGATION = 406,
103     SYSPICKER_APPSELECTOR = 407,
104     SYSPICKER_FILEPICKER = 408,
105     SYSPICKER_AUDIOPICKER = 409,
106     SYS_COMMON_UI = 500,
107     AUTO_FILL_PASSWORD = 501,
108     VPN = 502,
109     AUTO_FILL_SMART = 503,
110     SYSPICKER_PHOTOEDITOR = 504,
111     SYS_VISUAL = 505,
112     RECENT_PHOTO = 506
113 };
114 
115 enum class CompileMode {
116     JS_BUNDLE = 0,
117     ES_MODULE,
118 };
119 
120 enum class ExtensionProcessMode {
121     UNDEFINED = -1,
122     INSTANCE = 0,
123     TYPE = 1,
124     BUNDLE = 2,
125 };
126 
127 struct SkillUriForAbilityAndExtension {
128     std::string scheme;
129     std::string host;
130     std::string port;
131     std::string path;
132     std::string pathStartWith;
133     std::string pathRegex;
134     std::string type;
135     std::string utd;
136     int32_t maxFileSupported = 0;
137     std::string linkFeature;
138     bool isMatch = false;
139 };
140 
141 struct ExtensionAbilityInfo : public Parcelable {
142     std::string bundleName;
143     std::string moduleName;
144     std::string name;
145     std::string srcEntrance;
146     std::string icon;
147     uint32_t iconId = 0;
148     std::string label;
149     uint32_t labelId = 0;
150     std::string description;
151     uint32_t descriptionId = 0;
152     int32_t priority = 0;
153     std::vector<std::string> permissions;
154     std::string readPermission;
155     std::string writePermission;
156     std::string uri;
157     ExtensionAbilityType type = ExtensionAbilityType::UNSPECIFIED;
158     std::string extensionTypeName;
159     bool visible = false;
160     std::vector<Metadata> metadata;
161     ApplicationInfo applicationInfo;
162     ExtensionProcessMode extensionProcessMode = ExtensionProcessMode::UNDEFINED;
163     // set when install
164     std::string resourcePath;
165     std::string hapPath;
166     bool enabled = true;
167     std::string process;
168     CompileMode compileMode = CompileMode::JS_BUNDLE;
169     // for NAPI, save self query cache
170     int32_t uid = -1;
171     int32_t appIndex = 0;
172 
173     // for Check flags, add to abilityInfo and extensionAbilityInfo
174     std::vector<SkillUriForAbilityAndExtension> skillUri;
175     std::vector<Skill> skills;
176 
177     bool needCreateSandbox = false;
178     std::vector<std::string> dataGroupIds;
179     std::vector<std::string> validDataGroupIds;
180 
181     bool ReadFromParcel(Parcel &parcel);
182     virtual bool Marshalling(Parcel &parcel) const override;
183     static ExtensionAbilityInfo *Unmarshalling(Parcel &parcel);
184     bool MarshallingSkillUri(Parcel &parcel, SkillUriForAbilityAndExtension uri) const;
185     void UpdateNeedCreateSandbox();
186 };
187 
188 ExtensionAbilityType ConvertToExtensionAbilityType(const std::string &type);
189 std::string ConvertToExtensionTypeName(ExtensionAbilityType type);
190 ExtensionProcessMode ConvertToExtensionProcessMode(const std::string &extensionProcessMode);
191 }  // namespace AppExecFwk
192 }  // namespace OHOS
193 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_EXTENSION_INFO_H
194