• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 <string>
20 
21 #include "application_info.h"
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 enum ExtensionAbilityInfoFlag {
27     GET_EXTENSION_INFO_DEFAULT = 0x00000000,
28     GET_EXTENSION_INFO_WITH_PERMISSION = 0x00000002,
29     GET_EXTENSION_INFO_WITH_APPLICATION = 0x00000004,
30     GET_EXTENSION_INFO_WITH_METADATA = 0x00000020,
31 };
32 
33 enum class GetExtensionAbilityInfoFlag {
34     GET_EXTENSION_ABILITY_INFO_DEFAULT = 0x00000000,
35     GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION = 0x00000001,
36     GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION = 0x00000002,
37     GET_EXTENSION_ABILITY_INFO_WITH_METADATA = 0x00000004,
38 };
39 
40 enum class ExtensionAbilityType {
41     FORM = 0,
42     WORK_SCHEDULER = 1,
43     INPUTMETHOD = 2,
44     SERVICE = 3,
45     ACCESSIBILITY = 4,
46     DATASHARE = 5,
47     FILESHARE = 6,
48     STATICSUBSCRIBER = 7,
49     WALLPAPER = 8,
50     BACKUP = 9,
51     WINDOW = 10,
52     ENTERPRISE_ADMIN = 11,
53     FILEACCESS_EXTENSION = 12,
54     THUMBNAIL = 13,
55     PREVIEW = 14,
56     PRINT = 15,
57     SHARE = 16,
58     PUSH = 17,
59     DRIVER = 18,
60     ACTION = 19,
61     ADS_SERVICE = 20,
62     UNSPECIFIED = 255,
63     UI = 256,
64     HMS_ACCOUNT = 257,
65     APP_ACCOUNT_AUTHORIZATION = 258,
66     ADS = 259,
67     REMOTE_NOTIFICATION = 260,
68     REMOTE_LOCATION = 261,
69     VOIP = 262,
70     SYSDIALOG_USERAUTH = 300,
71     SYSDIALOG_COMMON = 301,
72     SYSDIALOG_ATOMICSERVICEPANEL = 302,
73     SYSDIALOG_POWER = 303,
74     SYSDIALOG_MEETIMECALL = 304,
75     SYSDIALOG_MEETIMECONTACT = 305,
76     SYSDIALOG_MEETIMEMESSAGE = 306,
77     SYSDIALOG_PRINT = 307,
78     SYSPICKER_MEDIACONTROL = 400,
79     SYSPICKER_SHARE = 401,
80     SYSPICKER_MEETIMECONTACT = 402,
81     SYSPICKER_MEETIMECALLLOG = 403,
82     SYSPICKER_PHOTOPICKER = 404,
83     SYSPICKER_CAMERA = 405,
84     SYS_COMMON_UI = 500,
85     AUTO_FILL_PASSWORD = 501,
86     VPN = 502
87 };
88 
89 enum class CompileMode {
90     JS_BUNDLE = 0,
91     ES_MODULE,
92 };
93 
94 enum class ExtensionProcessMode {
95     UNDEFINED = -1,
96     INSTANCE = 0,
97     TYPE = 1,
98     BUNDLE = 2,
99 };
100 
101 struct SkillUriForAbilityAndExtension {
102     std::string scheme;
103     std::string host;
104     std::string port;
105     std::string path;
106     std::string pathStartWith;
107     std::string pathRegex;
108     std::string type;
109     std::string utd;
110     int32_t maxFileSupported = 0;
111 };
112 
113 struct ExtensionAbilityInfo : public Parcelable {
114     std::string bundleName;
115     std::string moduleName;
116     std::string name;
117     std::string srcEntrance;
118     std::string icon;
119     int32_t iconId = 0;
120     std::string label;
121     int32_t labelId = 0;
122     std::string description;
123     int32_t descriptionId = 0;
124     int32_t priority = 0;
125     std::vector<std::string> permissions;
126     std::string readPermission;
127     std::string writePermission;
128     std::string uri;
129     ExtensionAbilityType type = ExtensionAbilityType::UNSPECIFIED;
130     std::string extensionTypeName;
131     bool visible = false;
132     std::vector<Metadata> metadata;
133     ApplicationInfo applicationInfo;
134     ExtensionProcessMode extensionProcessMode = ExtensionProcessMode::UNDEFINED;
135     // set when install
136     std::string resourcePath;
137     std::string hapPath;
138     bool enabled = true;
139     std::string process;
140     CompileMode compileMode = CompileMode::JS_BUNDLE;
141     // for NAPI, save self query cache
142     int32_t uid = -1;
143 
144     // for Check flags, add to abilityInfo and extensionAbilityInfo
145     std::vector<SkillUriForAbilityAndExtension> skillUri;
146 
147     bool ReadFromParcel(Parcel &parcel);
148     virtual bool Marshalling(Parcel &parcel) const override;
149     static ExtensionAbilityInfo *Unmarshalling(Parcel &parcel);
150 };
151 
152 ExtensionAbilityType ConvertToExtensionAbilityType(const std::string &type);
153 std::string ConvertToExtensionTypeName(ExtensionAbilityType type);
154 ExtensionProcessMode ConvertToExtensionProcessMode(const std::string &extensionProcessMode);
155 }  // namespace AppExecFwk
156 }  // namespace OHOS
157 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_EXTENSION_INFO_H
158