1 /*
2 * Copyright (c) 2021-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 #include "bundle_mgr_host.h"
17
18 #include <algorithm>
19 #include <cinttypes>
20 #include <unistd.h>
21
22 #include "app_log_wrapper.h"
23 #include "bundle_constants.h"
24 #include "bundle_framework_core_ipc_interface_code.h"
25 #include "bundle_memory_guard.h"
26 #include "hitrace_meter.h"
27 #include "datetime_ex.h"
28 #include "ipc_types.h"
29 #include "json_util.h"
30 #include "preinstalled_application_info.h"
31 #include "string_ex.h"
32 #include "securec.h"
33
34 namespace OHOS {
35 namespace AppExecFwk {
36 namespace {
37 const int16_t LIMIT_PARCEL_SIZE = 1024;
38 const int8_t ASHMEM_LEN = 16;
39 constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
40 constexpr int32_t ASHMEM_THRESHOLD = 200 * 1024; // 200K
41 constexpr int32_t PREINSTALL_PARCEL_CAPACITY = 400 * 1024; // 400K
42 constexpr int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M
43 constexpr int16_t MAX_BATCH_QUERY_BUNDLE_SIZE = 1000;
44 const int16_t MAX_STATUS_VECTOR_NUM = 1000;
45 constexpr int16_t MAX_BATCH_QUERY_ABILITY_SIZE = 1000;
46
SplitString(const std::string & source,std::vector<std::string> & strings)47 void SplitString(const std::string &source, std::vector<std::string> &strings)
48 {
49 int splitSize = (source.size() / LIMIT_PARCEL_SIZE);
50 if ((source.size() % LIMIT_PARCEL_SIZE) != 0) {
51 splitSize++;
52 }
53 APP_LOGD("the dump string split into %{public}d size", splitSize);
54 for (int i = 0; i < splitSize; i++) {
55 int32_t start = LIMIT_PARCEL_SIZE * i;
56 strings.emplace_back(source.substr(start, LIMIT_PARCEL_SIZE));
57 }
58 }
59
ClearAshmem(sptr<Ashmem> & optMem)60 inline void ClearAshmem(sptr<Ashmem> &optMem)
61 {
62 if (optMem != nullptr) {
63 optMem->UnmapAshmem();
64 optMem->CloseAshmem();
65 }
66 }
67
GetData(void * & buffer,size_t size,const void * data)68 bool GetData(void *&buffer, size_t size, const void *data)
69 {
70 if (data == nullptr) {
71 APP_LOGE("GetData failed due to null data");
72 return false;
73 }
74 if (size == 0 || size > MAX_PARCEL_CAPACITY) {
75 APP_LOGE("GetData failed due to zero size");
76 return false;
77 }
78 buffer = malloc(size);
79 if (buffer == nullptr) {
80 APP_LOGE("GetData failed due to malloc buffer failed");
81 return false;
82 }
83 if (memcpy_s(buffer, size, data, size) != EOK) {
84 free(buffer);
85 APP_LOGE("GetData failed due to memcpy_s failed");
86 return false;
87 }
88 return true;
89 }
90 } // namespace
91
BundleMgrHost()92 BundleMgrHost::BundleMgrHost()
93 {
94 APP_LOGD("create bundle manager host ");
95 }
96
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)97 int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
98 {
99 BundleMemoryGuard memoryGuard;
100 APP_LOGD("bundle mgr host onReceived message, the message code is %{public}u", code);
101 std::u16string descriptor = BundleMgrHost::GetDescriptor();
102 std::u16string remoteDescriptor = data.ReadInterfaceToken();
103 if (descriptor != remoteDescriptor) {
104 APP_LOGE("fail to write reply message in bundle mgr host due to the reply is nullptr");
105 return OBJECT_NULL;
106 }
107
108 ErrCode errCode = ERR_OK;
109 switch (code) {
110 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFO):
111 errCode = this->HandleGetApplicationInfo(data, reply);
112 break;
113 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFO_WITH_INT_FLAGS):
114 errCode = this->HandleGetApplicationInfoWithIntFlags(data, reply);
115 break;
116 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFOS):
117 errCode = this->HandleGetApplicationInfos(data, reply);
118 break;
119 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFO_WITH_INT_FLAGS_V9):
120 errCode = this->HandleGetApplicationInfoWithIntFlagsV9(data, reply);
121 break;
122 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFOS_WITH_INT_FLAGS):
123 errCode = this->HandleGetApplicationInfosWithIntFlags(data, reply);
124 break;
125 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_INFOS_WITH_INT_FLAGS_V9):
126 errCode = this->HandleGetApplicationInfosWithIntFlagsV9(data, reply);
127 break;
128 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFO):
129 errCode = this->HandleGetBundleInfo(data, reply);
130 break;
131 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFO_WITH_INT_FLAGS):
132 errCode = this->HandleGetBundleInfoWithIntFlags(data, reply);
133 break;
134 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFO_WITH_INT_FLAGS_V9):
135 errCode = this->HandleGetBundleInfoWithIntFlagsV9(data, reply);
136 break;
137 case static_cast<uint32_t>(BundleMgrInterfaceCode::BATCH_GET_BUNDLE_INFO):
138 errCode = this->HandleBatchGetBundleInfo(data, reply);
139 break;
140 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_PACK_INFO):
141 errCode = this->HandleGetBundlePackInfo(data, reply);
142 break;
143 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_PACK_INFO_WITH_INT_FLAGS):
144 errCode = this->HandleGetBundlePackInfoWithIntFlags(data, reply);
145 break;
146 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFOS):
147 errCode = this->HandleGetBundleInfos(data, reply);
148 break;
149 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFOS_WITH_INT_FLAGS):
150 errCode = this->HandleGetBundleInfosWithIntFlags(data, reply);
151 break;
152 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFOS_WITH_INT_FLAGS_V9):
153 errCode = this->HandleGetBundleInfosWithIntFlagsV9(data, reply);
154 break;
155 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_NAME_FOR_UID):
156 errCode = this->HandleGetBundleNameForUid(data, reply);
157 break;
158 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLES_FOR_UID):
159 errCode = this->HandleGetBundlesForUid(data, reply);
160 break;
161 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_NAME_FOR_UID):
162 errCode = this->HandleGetNameForUid(data, reply);
163 break;
164 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_NAME_AND_APPINDEX_FOR_UID):
165 errCode = this->HandleGetNameAndIndexForUid(data, reply);
166 break;
167 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_GIDS):
168 errCode = this->HandleGetBundleGids(data, reply);
169 break;
170 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_GIDS_BY_UID):
171 errCode = this->HandleGetBundleGidsByUid(data, reply);
172 break;
173 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFOS_BY_METADATA):
174 errCode = this->HandleGetBundleInfosByMetaData(data, reply);
175 break;
176 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO):
177 errCode = this->HandleQueryAbilityInfo(data, reply);
178 break;
179 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO_MUTI_PARAM):
180 errCode = this->HandleQueryAbilityInfoMutiparam(data, reply);
181 break;
182 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFOS):
183 errCode = this->HandleQueryAbilityInfos(data, reply);
184 break;
185 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFOS_MUTI_PARAM):
186 errCode = this->HandleQueryAbilityInfosMutiparam(data, reply);
187 break;
188 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFOS_V9):
189 errCode = this->HandleQueryAbilityInfosV9(data, reply);
190 break;
191 case static_cast<uint32_t>(BundleMgrInterfaceCode::BATCH_QUERY_ABILITY_INFOS):
192 errCode = this->HandleBatchQueryAbilityInfos(data, reply);
193 break;
194 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_LAUNCHER_ABILITY_INFO):
195 errCode = this->HandleQueryLauncherAbilityInfos(data, reply);
196 break;
197 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ALL_ABILITY_INFOS):
198 errCode = this->HandleQueryAllAbilityInfos(data, reply);
199 break;
200 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO_BY_URI):
201 errCode = this->HandleQueryAbilityInfoByUri(data, reply);
202 break;
203 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFOS_BY_URI):
204 errCode = this->HandleQueryAbilityInfosByUri(data, reply);
205 break;
206 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO_BY_URI_FOR_USERID):
207 errCode = this->HandleQueryAbilityInfoByUriForUserId(data, reply);
208 break;
209 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_KEEPALIVE_BUNDLE_INFOS):
210 errCode = this->HandleQueryKeepAliveBundleInfos(data, reply);
211 break;
212 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ABILITY_LABEL):
213 errCode = this->HandleGetAbilityLabel(data, reply);
214 break;
215 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ABILITY_LABEL_WITH_MODULE_NAME):
216 errCode = this->HandleGetAbilityLabelWithModuleName(data, reply);
217 break;
218 case static_cast<uint32_t>(BundleMgrInterfaceCode::CHECK_IS_SYSTEM_APP_BY_UID):
219 errCode = this->HandleCheckIsSystemAppByUid(data, reply);
220 break;
221 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_ARCHIVE_INFO):
222 errCode = this->HandleGetBundleArchiveInfo(data, reply);
223 break;
224 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_ARCHIVE_INFO_WITH_INT_FLAGS):
225 errCode = this->HandleGetBundleArchiveInfoWithIntFlags(data, reply);
226 break;
227 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_ARCHIVE_INFO_WITH_INT_FLAGS_V9):
228 errCode = this->HandleGetBundleArchiveInfoWithIntFlagsV9(data, reply);
229 break;
230 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_HAP_MODULE_INFO):
231 errCode = this->HandleGetHapModuleInfo(data, reply);
232 break;
233 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_LAUNCH_WANT_FOR_BUNDLE):
234 errCode = this->HandleGetLaunchWantForBundle(data, reply);
235 break;
236 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_PERMISSION_DEF):
237 errCode = this->HandleGetPermissionDef(data, reply);
238 break;
239 case static_cast<uint32_t>(BundleMgrInterfaceCode::AUTO_CLEAN_CACHE_BY_SIZE):
240 errCode = this->HandleCleanBundleCacheFilesAutomatic(data, reply);
241 break;
242 case static_cast<uint32_t>(BundleMgrInterfaceCode::CLEAN_BUNDLE_CACHE_FILES):
243 errCode = this->HandleCleanBundleCacheFiles(data, reply);
244 break;
245 case static_cast<uint32_t>(BundleMgrInterfaceCode::CREATE_BUNDLE_DATA_DIR):
246 errCode = this->HandleCreateBundleDataDir(data, reply);
247 break;
248 case static_cast<uint32_t>(BundleMgrInterfaceCode::CLEAN_BUNDLE_DATA_FILES):
249 errCode = this->HandleCleanBundleDataFiles(data, reply);
250 break;
251 case static_cast<uint32_t>(BundleMgrInterfaceCode::REGISTER_BUNDLE_STATUS_CALLBACK):
252 errCode = this->HandleRegisterBundleStatusCallback(data, reply);
253 break;
254 case static_cast<uint32_t>(BundleMgrInterfaceCode::REGISTER_BUNDLE_EVENT_CALLBACK):
255 errCode = this->HandleRegisterBundleEventCallback(data, reply);
256 break;
257 case static_cast<uint32_t>(BundleMgrInterfaceCode::UNREGISTER_BUNDLE_EVENT_CALLBACK):
258 errCode = this->HandleUnregisterBundleEventCallback(data, reply);
259 break;
260 case static_cast<uint32_t>(BundleMgrInterfaceCode::CLEAR_BUNDLE_STATUS_CALLBACK):
261 errCode = this->HandleClearBundleStatusCallback(data, reply);
262 break;
263 case static_cast<uint32_t>(BundleMgrInterfaceCode::UNREGISTER_BUNDLE_STATUS_CALLBACK):
264 errCode = this->HandleUnregisterBundleStatusCallback(data, reply);
265 break;
266 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_APPLICATION_ENABLED):
267 errCode = this->HandleIsApplicationEnabled(data, reply);
268 break;
269 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_APPLICATION_ENABLED):
270 errCode = this->HandleSetApplicationEnabled(data, reply);
271 break;
272 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_ABILITY_ENABLED):
273 errCode = this->HandleIsAbilityEnabled(data, reply);
274 break;
275 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_ABILITY_ENABLED):
276 errCode = this->HandleSetAbilityEnabled(data, reply);
277 break;
278 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ABILITY_INFO):
279 errCode = this->HandleGetAbilityInfo(data, reply);
280 break;
281 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ABILITY_INFO_WITH_MODULE_NAME):
282 errCode = this->HandleGetAbilityInfoWithModuleName(data, reply);
283 break;
284 case static_cast<uint32_t>(BundleMgrInterfaceCode::DUMP_INFOS):
285 errCode = this->HandleDumpInfos(data, reply);
286 break;
287 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INSTALLER):
288 errCode = this->HandleGetBundleInstaller(data, reply);
289 break;
290 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_FORMS_INFO):
291 errCode = this->HandleGetAllFormsInfo(data, reply);
292 break;
293 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_FORMS_INFO_BY_APP):
294 errCode = this->HandleGetFormsInfoByApp(data, reply);
295 break;
296 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_FORMS_INFO_BY_MODULE):
297 errCode = this->HandleGetFormsInfoByModule(data, reply);
298 break;
299 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SHORTCUT_INFO):
300 errCode = this->HandleGetShortcutInfos(data, reply);
301 break;
302 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SHORTCUT_INFO_V9):
303 errCode = this->HandleGetShortcutInfoV9(data, reply);
304 break;
305 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_COMMON_EVENT_INFO):
306 errCode = this->HandleGetAllCommonEventInfo(data, reply);
307 break;
308 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_USER_MGR):
309 errCode = this->HandleGetBundleUserMgr(data, reply);
310 break;
311 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_DISTRIBUTE_BUNDLE_INFO):
312 errCode = this->HandleGetDistributedBundleInfo(data, reply);
313 break;
314 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPLICATION_PRIVILEGE_LEVEL):
315 errCode = this->HandleGetAppPrivilegeLevel(data, reply);
316 break;
317 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_INFO_WITHOUT_TYPE):
318 errCode = this->HandleQueryExtAbilityInfosWithoutType(data, reply);
319 break;
320 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_INFO_WITHOUT_TYPE_V9):
321 errCode = this->HandleQueryExtAbilityInfosWithoutTypeV9(data, reply);
322 break;
323 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_INFO):
324 errCode = this->HandleQueryExtAbilityInfos(data, reply);
325 break;
326 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_INFO_V9):
327 errCode = this->HandleQueryExtAbilityInfosV9(data, reply);
328 break;
329 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_INFO_BY_TYPE):
330 errCode = this->HandleQueryExtAbilityInfosByType(data, reply);
331 break;
332 case static_cast<uint32_t>(BundleMgrInterfaceCode::VERIFY_CALLING_PERMISSION):
333 errCode = this->HandleVerifyCallingPermission(data, reply);
334 break;
335 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_ABILITY_INFO_BY_URI):
336 errCode = this->HandleQueryExtensionAbilityInfoByUri(data, reply);
337 break;
338 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APPID_BY_BUNDLE_NAME):
339 errCode = this->HandleGetAppIdByBundleName(data, reply);
340 break;
341 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APP_TYPE):
342 errCode = this->HandleGetAppType(data, reply);
343 break;
344 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_UID_BY_BUNDLE_NAME):
345 errCode = this->HandleGetUidByBundleName(data, reply);
346 break;
347 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_MODULE_REMOVABLE):
348 errCode = this->HandleIsModuleRemovable(data, reply);
349 break;
350 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_MODULE_REMOVABLE):
351 errCode = this->HandleSetModuleRemovable(data, reply);
352 break;
353 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO_WITH_CALLBACK):
354 errCode = this->HandleQueryAbilityInfoWithCallback(data, reply);
355 break;
356 case static_cast<uint32_t>(BundleMgrInterfaceCode::UPGRADE_ATOMIC_SERVICE):
357 errCode = this->HandleUpgradeAtomicService(data, reply);
358 break;
359 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_MODULE_NEED_UPDATE):
360 errCode = this->HandleGetModuleUpgradeFlag(data, reply);
361 break;
362 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_MODULE_NEED_UPDATE):
363 errCode = this->HandleSetModuleUpgradeFlag(data, reply);
364 break;
365 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_HAP_MODULE_INFO_WITH_USERID):
366 errCode = this->HandleGetHapModuleInfoWithUserId(data, reply);
367 break;
368 case static_cast<uint32_t>(BundleMgrInterfaceCode::IMPLICIT_QUERY_INFO_BY_PRIORITY):
369 errCode = this->HandleImplicitQueryInfoByPriority(data, reply);
370 break;
371 case static_cast<uint32_t>(BundleMgrInterfaceCode::IMPLICIT_QUERY_INFOS):
372 errCode = this->HandleImplicitQueryInfos(data, reply);
373 break;
374 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_DEPENDENT_MODULE_NAMES):
375 errCode = this->HandleGetAllDependentModuleNames(data, reply);
376 break;
377 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SANDBOX_APP_BUNDLE_INFO):
378 errCode = this->HandleGetSandboxBundleInfo(data, reply);
379 break;
380 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_CALLING_BUNDLE_NAME):
381 errCode = this->HandleObtainCallingBundleName(data, reply);
382 break;
383 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_STATS):
384 errCode = this->HandleGetBundleStats(data, reply);
385 break;
386 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_BUNDLE_STATS):
387 errCode = this->HandleGetAllBundleStats(data, reply);
388 break;
389 case static_cast<uint32_t>(BundleMgrInterfaceCode::CHECK_ABILITY_ENABLE_INSTALL):
390 errCode = this->HandleCheckAbilityEnableInstall(data, reply);
391 break;
392 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_STRING_BY_ID):
393 errCode = this->HandleGetStringById(data, reply);
394 break;
395 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ICON_BY_ID):
396 errCode = this->HandleGetIconById(data, reply);
397 break;
398 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
399 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_DEFAULT_APP_PROXY):
400 errCode = this->HandleGetDefaultAppProxy(data, reply);
401 break;
402 #endif
403 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SANDBOX_APP_ABILITY_INFO):
404 errCode = this->HandleGetSandboxAbilityInfo(data, reply);
405 break;
406 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SANDBOX_APP_EXTENSION_INFOS):
407 errCode = this->HandleGetSandboxExtAbilityInfos(data, reply);
408 break;
409 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SANDBOX_MODULE_INFO):
410 errCode = this->HandleGetSandboxHapModuleInfo(data, reply);
411 break;
412 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_MEDIA_DATA):
413 errCode = this->HandleGetMediaData(data, reply);
414 break;
415 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_QUICK_FIX_MANAGER_PROXY):
416 errCode = this->HandleGetQuickFixManagerProxy(data, reply);
417 break;
418 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL
419 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APP_CONTROL_PROXY):
420 errCode = this->HandleGetAppControlProxy(data, reply);
421 break;
422 #endif
423 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_DEBUG_MODE):
424 errCode = this->HandleSetDebugMode(data, reply);
425 break;
426 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFO_FOR_SELF):
427 errCode = this->HandleGetBundleInfoForSelf(data, reply);
428 break;
429 case static_cast<uint32_t>(BundleMgrInterfaceCode::VERIFY_SYSTEM_API):
430 errCode = this->HandleVerifySystemApi(data, reply);
431 break;
432 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_OVERLAY_MANAGER_PROXY):
433 errCode = this->HandleGetOverlayManagerProxy(data, reply);
434 break;
435 case static_cast<uint32_t>(BundleMgrInterfaceCode::SILENT_INSTALL):
436 errCode = this->HandleSilentInstall(data, reply);
437 break;
438 case static_cast<uint32_t>(BundleMgrInterfaceCode::PROCESS_PRELOAD):
439 errCode = this->HandleProcessPreload(data, reply);
440 break;
441 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_APP_PROVISION_INFO):
442 errCode = this->HandleGetAppProvisionInfo(data, reply);
443 break;
444 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_PROVISION_METADATA):
445 errCode = this->HandleGetProvisionMetadata(data, reply);
446 break;
447 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BASE_SHARED_BUNDLE_INFOS):
448 errCode = this->HandleGetBaseSharedBundleInfos(data, reply);
449 break;
450 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_SHARED_BUNDLE_INFO):
451 errCode = this->HandleGetAllSharedBundleInfo(data, reply);
452 break;
453 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SHARED_BUNDLE_INFO):
454 errCode = this->HandleGetSharedBundleInfo(data, reply);
455 break;
456 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SHARED_BUNDLE_INFO_BY_SELF):
457 errCode = this->HandleGetSharedBundleInfoBySelf(data, reply);
458 break;
459 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SHARED_DEPENDENCIES):
460 errCode = this->HandleGetSharedDependencies(data, reply);
461 break;
462 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_DEPENDENT_BUNDLE_INFO):
463 errCode = this->HandleGetDependentBundleInfo(data, reply);
464 break;
465 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_UID_BY_DEBUG_BUNDLE_NAME):
466 errCode = this->HandleGetUidByDebugBundleName(data, reply);
467 break;
468 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_PROXY_DATA_INFOS):
469 errCode = this->HandleGetProxyDataInfos(data, reply);
470 break;
471 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_PROXY_DATA_INFOS):
472 errCode = this->HandleGetAllProxyDataInfos(data, reply);
473 break;
474 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SPECIFIED_DISTRIBUTED_TYPE):
475 errCode = this->HandleGetSpecifiedDistributionType(data, reply);
476 break;
477 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ADDITIONAL_INFO):
478 errCode = this->HandleGetAdditionalInfo(data, reply);
479 break;
480 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_EXT_NAME_OR_MIME_TO_APP):
481 errCode = this->HandleSetExtNameOrMIMEToApp(data, reply);
482 break;
483 case static_cast<uint32_t>(BundleMgrInterfaceCode::DEL_EXT_NAME_OR_MIME_TO_APP):
484 errCode = this->HandleDelExtNameOrMIMEToApp(data, reply);
485 break;
486 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_DATA_GROUP_INFOS):
487 errCode = this->HandleQueryDataGroupInfos(data, reply);
488 break;
489 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_PREFERENCE_DIR_BY_GROUP_ID):
490 errCode = this->HandleGetPreferenceDirByGroupId(data, reply);
491 break;
492 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_APPGALLERY_BUNDLE_NAME):
493 errCode = this->HandleQueryAppGalleryBundleName(data, reply);
494 break;
495 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_ABILITY_INFO_WITH_TYPE_NAME):
496 errCode = this->HandleQueryExtensionAbilityInfosWithTypeName(data, reply);
497 break;
498 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_EXTENSION_ABILITY_INFO_ONLY_WITH_TYPE_NAME):
499 errCode = this->HandleQueryExtensionAbilityInfosOnlyWithTypeName(data, reply);
500 break;
501 case static_cast<uint32_t>(BundleMgrInterfaceCode::RESET_AOT_COMPILE_STATUS):
502 errCode = this->HandleResetAOTCompileStatus(data, reply);
503 break;
504 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_JSON_PROFILE):
505 errCode = this->HandleGetJsonProfile(data, reply);
506 break;
507 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_RESOURCE_PROXY):
508 errCode = this->HandleGetBundleResourceProxy(data, reply);
509 break;
510 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_VERIFY_MANAGER):
511 errCode = this->HandleGetVerifyManager(data, reply);
512 break;
513 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_RECOVERABLE_APPLICATION_INFO):
514 errCode = this->HandleGetRecoverableApplicationInfo(data, reply);
515 break;
516 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_UNINSTALLED_BUNDLE_INFO):
517 errCode = this->HandleGetUninstalledBundleInfo(data, reply);
518 break;
519 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_ADDITIONAL_INFO):
520 errCode = this->HandleSetAdditionalInfo(data, reply);
521 break;
522 case static_cast<uint32_t>(BundleMgrInterfaceCode::COMPILE_PROCESSAOT):
523 errCode = this->HandleCompileProcessAOT(data, reply);
524 break;
525 case static_cast<uint32_t>(BundleMgrInterfaceCode::COMPILE_RESET):
526 errCode = this->HandleCompileReset(data, reply);
527 break;
528 case static_cast<uint32_t>(BundleMgrInterfaceCode::CAN_OPEN_LINK):
529 errCode = this->HandleCanOpenLink(data, reply);
530 break;
531 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ODID):
532 errCode = this->HandleGetOdid(data, reply);
533 break;
534 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_PREINSTALLED_APPLICATION_INFO):
535 errCode = this->HandleGetAllPreinstalledApplicationInfos(data, reply);
536 break;
537 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_EXTEND_RESOURCE_MANAGER):
538 errCode = this->HandleGetExtendResourceManager(data, reply);
539 break;
540 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_BUNDLE_INFO_BY_DEVELOPER_ID):
541 errCode = this->HandleGetAllBundleInfoByDeveloperId(data, reply);
542 break;
543 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_DEVELOPER_IDS):
544 errCode = this->HandleGetDeveloperIds(data, reply);
545 break;
546 case static_cast<uint32_t>(BundleMgrInterfaceCode::SWITCH_UNINSTALL_STATE):
547 errCode = this->HandleSwitchUninstallState(data, reply);
548 break;
549 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_ABILITY_INFO_BY_CONTINUE_TYPE):
550 errCode = this->HandleQueryAbilityInfoByContinueType(data, reply);
551 break;
552 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_CLONE_ABILITY_INFO):
553 errCode = this->HandleQueryCloneAbilityInfo(data, reply);
554 break;
555 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_CLONE_BUNDLE_INFO):
556 errCode = this->HandleGetCloneBundleInfo(data, reply);
557 break;
558 case static_cast<uint32_t>(BundleMgrInterfaceCode::COPY_AP):
559 errCode = this->HandleCopyAp(data, reply);
560 break;
561 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_CLONE_APP_INDEXES):
562 errCode = this->HandleGetCloneAppIndexes(data, reply);
563 break;
564 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_LAUNCH_WANT):
565 errCode = this->HandleGetLaunchWant(data, reply);
566 break;
567 case static_cast<uint32_t>(BundleMgrInterfaceCode::QUERY_CLONE_EXTENSION_ABILITY_INFO_WITH_APP_INDEX):
568 errCode = this->HandleQueryCloneExtensionAbilityInfoWithAppIndex(data, reply);
569 break;
570 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_SIGNATURE_INFO):
571 errCode = this->HandleGetSignatureInfoByBundleName(data, reply);
572 break;
573 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_CLONE_APPLICATION_ENABLED):
574 errCode = this->HandleSetCloneApplicationEnabled(data, reply);
575 break;
576 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_CLONE_APPLICATION_ENABLED):
577 errCode = this->HandleIsCloneApplicationEnabled(data, reply);
578 break;
579 case static_cast<uint32_t>(BundleMgrInterfaceCode::SET_CLONE_ABILITY_ENABLED):
580 errCode = this->HandleSetCloneAbilityEnabled(data, reply);
581 break;
582 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_CLONE_ABILITY_ENABLED):
583 errCode = this->HandleIsCloneAbilityEnabled(data, reply);
584 break;
585 case static_cast<uint32_t>(BundleMgrInterfaceCode::ADD_DESKTOP_SHORTCUT_INFO):
586 errCode = this->HandleAddDesktopShortcutInfo(data, reply);
587 break;
588 case static_cast<uint32_t>(BundleMgrInterfaceCode::DELETE_DESKTOP_SHORTCUT_INFO):
589 errCode = this->HandleDeleteDesktopShortcutInfo(data, reply);
590 break;
591 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ALL_DESKTOP_SHORTCUT_INFO):
592 errCode = this->HandleGetAllDesktopShortcutInfo(data, reply);
593 break;
594 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_ODID_BY_BUNDLENAME):
595 errCode = this->HandleGetOdidByBundleName(data, reply);
596 break;
597 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_BUNDLE_INFOS_FOR_CONTINUATION):
598 errCode = this->HandleGetBundleInfosForContinuation(data, reply);
599 break;
600 case static_cast<uint32_t>(BundleMgrInterfaceCode::GET_CONTINUE_BUNDLE_NAMES):
601 errCode = HandleGetContinueBundleNames(data, reply);
602 break;
603 case static_cast<uint32_t>(BundleMgrInterfaceCode::IS_BUNDLE_INSTALLED):
604 errCode = HandleIsBundleInstalled(data, reply);
605 break;
606 default :
607 APP_LOGW("bundleMgr host receives unknown code %{public}u", code);
608 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
609 }
610 APP_LOGD("bundleMgr host finish to process message, errCode: %{public}d", errCode);
611 return (errCode == ERR_OK) ? NO_ERROR : UNKNOWN_ERROR;
612 }
613
HandleGetApplicationInfo(MessageParcel & data,MessageParcel & reply)614 ErrCode BundleMgrHost::HandleGetApplicationInfo(MessageParcel &data, MessageParcel &reply)
615 {
616 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
617 std::string name = data.ReadString();
618 ApplicationFlag flag = static_cast<ApplicationFlag>(data.ReadInt32());
619 int userId = data.ReadInt32();
620 APP_LOGD("name %{public}s, flag %{public}d, userId %{public}d", name.c_str(), flag, userId);
621
622 ApplicationInfo info;
623 bool ret = GetApplicationInfo(name, flag, userId, info);
624 if (!reply.WriteBool(ret)) {
625 APP_LOGE("write failed");
626 return ERR_APPEXECFWK_PARCEL_ERROR;
627 }
628 if (ret) {
629 if (!reply.WriteParcelable(&info)) {
630 APP_LOGE("write failed");
631 return ERR_APPEXECFWK_PARCEL_ERROR;
632 }
633 }
634 return ERR_OK;
635 }
636
HandleGetApplicationInfoWithIntFlags(MessageParcel & data,MessageParcel & reply)637 ErrCode BundleMgrHost::HandleGetApplicationInfoWithIntFlags(MessageParcel &data, MessageParcel &reply)
638 {
639 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
640 std::string name = data.ReadString();
641 int flags = data.ReadInt32();
642 int userId = data.ReadInt32();
643 APP_LOGD("name %{public}s, flags %{public}d, userId %{public}d", name.c_str(), flags, userId);
644
645 ApplicationInfo info;
646 bool ret = GetApplicationInfo(name, flags, userId, info);
647 if (!reply.WriteBool(ret)) {
648 APP_LOGE("write failed");
649 return ERR_APPEXECFWK_PARCEL_ERROR;
650 }
651 if (ret) {
652 if (!reply.WriteParcelable(&info)) {
653 APP_LOGE("write failed");
654 return ERR_APPEXECFWK_PARCEL_ERROR;
655 }
656 }
657 return ERR_OK;
658 }
659
HandleGetApplicationInfoWithIntFlagsV9(MessageParcel & data,MessageParcel & reply)660 ErrCode BundleMgrHost::HandleGetApplicationInfoWithIntFlagsV9(MessageParcel &data, MessageParcel &reply)
661 {
662 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
663 std::string name = data.ReadString();
664 int32_t flags = data.ReadInt32();
665 int32_t userId = data.ReadInt32();
666 APP_LOGD("name %{public}s, flags %{public}d, userId %{public}d", name.c_str(), flags, userId);
667
668 ApplicationInfo info;
669 auto ret = GetApplicationInfoV9(name, flags, userId, info);
670 if (!reply.WriteInt32(ret)) {
671 APP_LOGE("write failed");
672 return ERR_APPEXECFWK_PARCEL_ERROR;
673 }
674 if (ret == ERR_OK) {
675 if (!reply.WriteParcelable(&info)) {
676 APP_LOGE("write failed");
677 return ERR_APPEXECFWK_PARCEL_ERROR;
678 }
679 }
680 return ERR_OK;
681 }
682
HandleGetApplicationInfos(MessageParcel & data,MessageParcel & reply)683 ErrCode BundleMgrHost::HandleGetApplicationInfos(MessageParcel &data, MessageParcel &reply)
684 {
685 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
686 ApplicationFlag flag = static_cast<ApplicationFlag>(data.ReadInt32());
687 int userId = data.ReadInt32();
688 std::vector<ApplicationInfo> infos;
689 bool ret = GetApplicationInfos(flag, userId, infos);
690 if (!reply.WriteBool(ret)) {
691 APP_LOGE("write failed");
692 return ERR_APPEXECFWK_PARCEL_ERROR;
693 }
694 if (ret) {
695 if (!WriteParcelableVector(infos, reply)) {
696 APP_LOGE("write failed");
697 return ERR_APPEXECFWK_PARCEL_ERROR;
698 }
699 }
700 return ERR_OK;
701 }
702
HandleGetApplicationInfosWithIntFlags(MessageParcel & data,MessageParcel & reply)703 ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlags(MessageParcel &data, MessageParcel &reply)
704 {
705 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
706 int flags = data.ReadInt32();
707 int userId = data.ReadInt32();
708 std::vector<ApplicationInfo> infos;
709 bool ret = GetApplicationInfos(flags, userId, infos);
710 if (!reply.WriteBool(ret)) {
711 APP_LOGE("write failed");
712 return ERR_APPEXECFWK_PARCEL_ERROR;
713 }
714 if (ret) {
715 if (!WriteVectorToParcelIntelligent(infos, reply)) {
716 APP_LOGE("write failed");
717 return ERR_APPEXECFWK_PARCEL_ERROR;
718 }
719 }
720 return ERR_OK;
721 }
722
HandleGetApplicationInfosWithIntFlagsV9(MessageParcel & data,MessageParcel & reply)723 ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlagsV9(MessageParcel &data, MessageParcel &reply)
724 {
725 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
726 int32_t flags = data.ReadInt32();
727 int32_t userId = data.ReadInt32();
728 std::vector<ApplicationInfo> infos;
729 auto ret = GetApplicationInfosV9(flags, userId, infos);
730 if (!reply.WriteInt32(ret)) {
731 APP_LOGE("write failed");
732 return ERR_APPEXECFWK_PARCEL_ERROR;
733 }
734 if (ret == ERR_OK) {
735 if (!WriteVectorToParcelIntelligent(infos, reply)) {
736 APP_LOGE("write failed");
737 return ERR_APPEXECFWK_PARCEL_ERROR;
738 }
739 }
740 return ERR_OK;
741 }
742
HandleGetBundleInfo(MessageParcel & data,MessageParcel & reply)743 ErrCode BundleMgrHost::HandleGetBundleInfo(MessageParcel &data, MessageParcel &reply)
744 {
745 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
746 std::string name = data.ReadString();
747 BundleFlag flag = static_cast<BundleFlag>(data.ReadInt32());
748 int userId = data.ReadInt32();
749 APP_LOGD("name %{public}s, flag %{public}d", name.c_str(), flag);
750 BundleInfo info;
751 bool ret = GetBundleInfo(name, flag, info, userId);
752 if (ret) {
753 WRITE_PARCEL(reply.WriteInt32(ERR_OK));
754 return WriteParcelInfoIntelligent(info, reply);
755 }
756 WRITE_PARCEL(reply.WriteInt32(ERR_APPEXECFWK_PARCEL_ERROR));
757 return ERR_OK;
758 }
759
HandleGetBundleInfoForSelf(MessageParcel & data,MessageParcel & reply)760 ErrCode BundleMgrHost::HandleGetBundleInfoForSelf(MessageParcel &data, MessageParcel &reply)
761 {
762 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
763 int32_t flags = data.ReadInt32();
764 APP_LOGD("GetBundleInfoForSelf, flags %{public}d", flags);
765 BundleInfo info;
766 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
767 auto ret = GetBundleInfoForSelf(flags, info);
768 if (!reply.WriteInt32(ret)) {
769 APP_LOGE("write failed");
770 return ERR_APPEXECFWK_PARCEL_ERROR;
771 }
772 if (ret == ERR_OK && !reply.WriteParcelable(&info)) {
773 APP_LOGE("write failed");
774 return ERR_APPEXECFWK_PARCEL_ERROR;
775 }
776 return ERR_OK;
777 }
778
HandleGetDependentBundleInfo(MessageParcel & data,MessageParcel & reply)779 ErrCode BundleMgrHost::HandleGetDependentBundleInfo(MessageParcel &data, MessageParcel &reply)
780 {
781 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
782 std::string name = data.ReadString();
783 GetDependentBundleInfoFlag flag = static_cast<GetDependentBundleInfoFlag>(data.ReadUint32());
784 APP_LOGD("GetDependentBundleInfo, bundle %{public}s", name.c_str());
785 BundleInfo info;
786 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
787 auto ret = GetDependentBundleInfo(name, info, flag);
788 if (!reply.WriteInt32(ret)) {
789 APP_LOGE("write failed");
790 return ERR_APPEXECFWK_PARCEL_ERROR;
791 }
792 if (ret == ERR_OK && !reply.WriteParcelable(&info)) {
793 APP_LOGE("write failed");
794 return ERR_APPEXECFWK_PARCEL_ERROR;
795 }
796 return ERR_OK;
797 }
798
HandleGetBundleInfoWithIntFlags(MessageParcel & data,MessageParcel & reply)799 ErrCode BundleMgrHost::HandleGetBundleInfoWithIntFlags(MessageParcel &data, MessageParcel &reply)
800 {
801 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
802 std::string name = data.ReadString();
803 int flags = data.ReadInt32();
804 int userId = data.ReadInt32();
805 APP_LOGD("name %{public}s, flags %{public}d", name.c_str(), flags);
806 BundleInfo info;
807 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
808 bool ret = GetBundleInfo(name, flags, info, userId);
809 if (ret) {
810 WRITE_PARCEL(reply.WriteInt32(ERR_OK));
811 return WriteParcelInfoIntelligent(info, reply);
812 }
813 WRITE_PARCEL(reply.WriteInt32(ERR_APPEXECFWK_PARCEL_ERROR));
814 return ERR_OK;
815 }
816
HandleGetBundleInfoWithIntFlagsV9(MessageParcel & data,MessageParcel & reply)817 ErrCode BundleMgrHost::HandleGetBundleInfoWithIntFlagsV9(MessageParcel &data, MessageParcel &reply)
818 {
819 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
820 std::string name = data.ReadString();
821 if (name.empty()) {
822 APP_LOGE("bundleName is empty");
823 return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
824 }
825 int32_t flags = data.ReadInt32();
826 int32_t userId = data.ReadInt32();
827 APP_LOGD("name %{public}s, flags %{public}d", name.c_str(), flags);
828 BundleInfo info;
829 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
830 auto ret = GetBundleInfoV9(name, flags, info, userId);
831 if (!reply.WriteInt32(ret)) {
832 APP_LOGE("write failed");
833 return ERR_APPEXECFWK_PARCEL_ERROR;
834 }
835 if (ret == ERR_OK) {
836 return WriteParcelInfoIntelligent<BundleInfo>(info, reply);
837 }
838 return ERR_OK;
839 }
840
HandleBatchGetBundleInfo(MessageParcel & data,MessageParcel & reply)841 ErrCode BundleMgrHost::HandleBatchGetBundleInfo(MessageParcel &data, MessageParcel &reply)
842 {
843 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
844 int32_t bundleNameCount = data.ReadInt32();
845 if (bundleNameCount <= 0 || bundleNameCount > MAX_BATCH_QUERY_BUNDLE_SIZE) {
846 APP_LOGE("bundleName count is error");
847 return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
848 }
849 std::vector<std::string> bundleNames;
850 for (int i = 0; i < bundleNameCount; i++) {
851 std::string bundleName = data.ReadString();
852 if (bundleName.empty()) {
853 APP_LOGE("bundleName %{public}d is empty", i);
854 return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
855 }
856 bundleNames.push_back(bundleName);
857 }
858
859 int32_t flags = data.ReadInt32();
860 int32_t userId = data.ReadInt32();
861 std::vector<BundleInfo> bundleInfos;
862 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
863 auto ret = BatchGetBundleInfo(bundleNames, flags, bundleInfos, userId);
864 if (!reply.WriteInt32(ret)) {
865 APP_LOGE("write failed");
866 return ERR_APPEXECFWK_PARCEL_ERROR;
867 }
868 if (ret == ERR_OK) {
869 if (!WriteVectorToParcelIntelligent(bundleInfos, reply)) {
870 APP_LOGE("write failed");
871 return ERR_APPEXECFWK_PARCEL_ERROR;
872 }
873 }
874 return ERR_OK;
875 }
876
HandleGetBundlePackInfo(MessageParcel & data,MessageParcel & reply)877 ErrCode BundleMgrHost::HandleGetBundlePackInfo(MessageParcel &data, MessageParcel &reply)
878 {
879 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
880 std::string name = data.ReadString();
881 BundlePackFlag flag = static_cast<BundlePackFlag>(data.ReadInt32());
882 int userId = data.ReadInt32();
883 APP_LOGD("name %{public}s, flag %{public}d", name.c_str(), flag);
884 BundlePackInfo info;
885 ErrCode ret = GetBundlePackInfo(name, flag, info, userId);
886 if (!reply.WriteInt32(ret)) {
887 APP_LOGE("write failed");
888 return ERR_APPEXECFWK_PARCEL_ERROR;
889 }
890 if (ret == ERR_OK) {
891 if (!reply.WriteParcelable(&info)) {
892 APP_LOGE("write failed");
893 return ERR_APPEXECFWK_PARCEL_ERROR;
894 }
895 }
896 return ERR_OK;
897 }
898
HandleGetBundlePackInfoWithIntFlags(MessageParcel & data,MessageParcel & reply)899 ErrCode BundleMgrHost::HandleGetBundlePackInfoWithIntFlags(MessageParcel &data, MessageParcel &reply)
900 {
901 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
902 std::string name = data.ReadString();
903 int flags = data.ReadInt32();
904 int userId = data.ReadInt32();
905 APP_LOGD("name %{public}s, flags %{public}d", name.c_str(), flags);
906 BundlePackInfo info;
907 ErrCode ret = GetBundlePackInfo(name, flags, info, userId);
908 if (!reply.WriteInt32(ret)) {
909 APP_LOGE("write failed");
910 return ERR_APPEXECFWK_PARCEL_ERROR;
911 }
912 if (ret == ERR_OK) {
913 if (!reply.WriteParcelable(&info)) {
914 APP_LOGE("write failed");
915 return ERR_APPEXECFWK_PARCEL_ERROR;
916 }
917 }
918 return ERR_OK;
919 }
920
HandleGetBundleInfos(MessageParcel & data,MessageParcel & reply)921 ErrCode BundleMgrHost::HandleGetBundleInfos(MessageParcel &data, MessageParcel &reply)
922 {
923 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
924 BundleFlag flag = static_cast<BundleFlag>(data.ReadInt32());
925 int userId = data.ReadInt32();
926
927 std::vector<BundleInfo> infos;
928 reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
929 bool ret = GetBundleInfos(flag, infos, userId);
930 if (!reply.WriteBool(ret)) {
931 APP_LOGE("write failed");
932 return ERR_APPEXECFWK_PARCEL_ERROR;
933 }
934 if (ret) {
935 if (!WriteVectorToParcelIntelligent(infos, reply)) {
936 APP_LOGE("write failed");
937 return ERR_APPEXECFWK_PARCEL_ERROR;
938 }
939 }
940 APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize());
941 return ERR_OK;
942 }
943
HandleGetBundleInfosWithIntFlags(MessageParcel & data,MessageParcel & reply)944 ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlags(MessageParcel &data, MessageParcel &reply)
945 {
946 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
947 int flags = data.ReadInt32();
948 int userId = data.ReadInt32();
949
950 std::vector<BundleInfo> infos;
951 reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
952 bool ret = GetBundleInfos(flags, infos, userId);
953 if (!reply.WriteBool(ret)) {
954 APP_LOGE("write failed");
955 return ERR_APPEXECFWK_PARCEL_ERROR;
956 }
957 if (ret) {
958 if (!WriteVectorToParcelIntelligent(infos, reply)) {
959 APP_LOGE("write failed");
960 return ERR_APPEXECFWK_PARCEL_ERROR;
961 }
962 }
963 APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize());
964 return ERR_OK;
965 }
966
HandleGetBundleInfosWithIntFlagsV9(MessageParcel & data,MessageParcel & reply)967 ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlagsV9(MessageParcel &data, MessageParcel &reply)
968 {
969 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
970 int32_t flags = data.ReadInt32();
971 int32_t userId = data.ReadInt32();
972
973 std::vector<BundleInfo> infos;
974 auto ret = GetBundleInfosV9(flags, infos, userId);
975 if (!reply.WriteInt32(ret)) {
976 APP_LOGE("write failed");
977 return ERR_APPEXECFWK_PARCEL_ERROR;
978 }
979 if (ret == ERR_OK) {
980 if (!WriteVectorToParcelIntelligent(infos, reply)) {
981 APP_LOGE("write failed");
982 return ERR_APPEXECFWK_PARCEL_ERROR;
983 }
984 }
985 APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize());
986 return ERR_OK;
987 }
988
HandleGetBundleNameForUid(MessageParcel & data,MessageParcel & reply)989 ErrCode BundleMgrHost::HandleGetBundleNameForUid(MessageParcel &data, MessageParcel &reply)
990 {
991 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
992 auto uid = data.ReadInt32();
993 std::string name;
994 bool ret = GetBundleNameForUid(uid, name);
995 if (!reply.WriteBool(ret)) {
996 APP_LOGE("write failed");
997 return ERR_APPEXECFWK_PARCEL_ERROR;
998 }
999 if (ret) {
1000 if (!reply.WriteString(name)) {
1001 APP_LOGE("write failed");
1002 return ERR_APPEXECFWK_PARCEL_ERROR;
1003 }
1004 }
1005 return ERR_OK;
1006 }
1007
HandleGetBundlesForUid(MessageParcel & data,MessageParcel & reply)1008 ErrCode BundleMgrHost::HandleGetBundlesForUid(MessageParcel &data, MessageParcel &reply)
1009 {
1010 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1011 int uid = data.ReadInt32();
1012 std::vector<std::string> names;
1013 bool ret = GetBundlesForUid(uid, names);
1014 if (!reply.WriteBool(ret)) {
1015 APP_LOGE("write failed");
1016 return ERR_APPEXECFWK_PARCEL_ERROR;
1017 }
1018 if (ret) {
1019 if (!reply.WriteStringVector(names)) {
1020 APP_LOGE("write failed");
1021 return ERR_APPEXECFWK_PARCEL_ERROR;
1022 }
1023 }
1024 return ERR_OK;
1025 }
1026
HandleGetNameForUid(MessageParcel & data,MessageParcel & reply)1027 ErrCode BundleMgrHost::HandleGetNameForUid(MessageParcel &data, MessageParcel &reply)
1028 {
1029 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1030 int uid = data.ReadInt32();
1031 std::string name;
1032 ErrCode ret = GetNameForUid(uid, name);
1033 if (!reply.WriteInt32(ret)) {
1034 APP_LOGE("write failed");
1035 return ERR_APPEXECFWK_PARCEL_ERROR;
1036 }
1037 if (ret == ERR_OK) {
1038 if (!reply.WriteString(name)) {
1039 APP_LOGE("write failed");
1040 return ERR_APPEXECFWK_PARCEL_ERROR;
1041 }
1042 }
1043 return ERR_OK;
1044 }
1045
HandleGetNameAndIndexForUid(MessageParcel & data,MessageParcel & reply)1046 ErrCode BundleMgrHost::HandleGetNameAndIndexForUid(MessageParcel &data, MessageParcel &reply)
1047 {
1048 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1049 int uid = data.ReadInt32();
1050 std::string bundleName;
1051 int32_t appIndex;
1052 ErrCode ret = GetNameAndIndexForUid(uid, bundleName, appIndex);
1053 if (!reply.WriteInt32(ret)) {
1054 APP_LOGE("write failed");
1055 return ERR_APPEXECFWK_PARCEL_ERROR;
1056 }
1057 if (ret == ERR_OK) {
1058 if (!reply.WriteString(bundleName)) {
1059 APP_LOGE("write failed");
1060 return ERR_APPEXECFWK_PARCEL_ERROR;
1061 }
1062 if (!reply.WriteInt32(appIndex)) {
1063 APP_LOGE("write failed");
1064 return ERR_APPEXECFWK_PARCEL_ERROR;
1065 }
1066 }
1067 return ERR_OK;
1068 }
1069
HandleGetBundleGids(MessageParcel & data,MessageParcel & reply)1070 ErrCode BundleMgrHost::HandleGetBundleGids(MessageParcel &data, MessageParcel &reply)
1071 {
1072 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1073 std::string name = data.ReadString();
1074
1075 std::vector<int> gids;
1076 bool ret = GetBundleGids(name, gids);
1077 if (!reply.WriteBool(ret)) {
1078 APP_LOGE("write failed");
1079 return ERR_APPEXECFWK_PARCEL_ERROR;
1080 }
1081 if (ret) {
1082 if (!reply.WriteInt32Vector(gids)) {
1083 APP_LOGE("write failed");
1084 return ERR_APPEXECFWK_PARCEL_ERROR;
1085 }
1086 }
1087 return ERR_OK;
1088 }
1089
HandleGetBundleGidsByUid(MessageParcel & data,MessageParcel & reply)1090 ErrCode BundleMgrHost::HandleGetBundleGidsByUid(MessageParcel &data, MessageParcel &reply)
1091 {
1092 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1093 std::string name = data.ReadString();
1094 int uid = data.ReadInt32();
1095
1096 std::vector<int> gids;
1097 bool ret = GetBundleGidsByUid(name, uid, gids);
1098 if (!reply.WriteBool(ret)) {
1099 APP_LOGE("write failed");
1100 return ERR_APPEXECFWK_PARCEL_ERROR;
1101 }
1102 if (ret) {
1103 if (!reply.WriteInt32Vector(gids)) {
1104 APP_LOGE("write failed");
1105 return ERR_APPEXECFWK_PARCEL_ERROR;
1106 }
1107 }
1108 return ERR_OK;
1109 }
1110
HandleGetBundleInfosByMetaData(MessageParcel & data,MessageParcel & reply)1111 ErrCode BundleMgrHost::HandleGetBundleInfosByMetaData(MessageParcel &data, MessageParcel &reply)
1112 {
1113 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1114 std::string metaData = data.ReadString();
1115
1116 std::vector<BundleInfo> infos;
1117 bool ret = GetBundleInfosByMetaData(metaData, infos);
1118 if (!reply.WriteBool(ret)) {
1119 APP_LOGE("write failed");
1120 return ERR_APPEXECFWK_PARCEL_ERROR;
1121 }
1122 if (ret) {
1123 if (!WriteParcelableVector(infos, reply)) {
1124 APP_LOGE("write failed");
1125 return ERR_APPEXECFWK_PARCEL_ERROR;
1126 }
1127 }
1128 return ERR_OK;
1129 }
1130
HandleQueryAbilityInfo(MessageParcel & data,MessageParcel & reply)1131 ErrCode BundleMgrHost::HandleQueryAbilityInfo(MessageParcel &data, MessageParcel &reply)
1132 {
1133 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1134 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1135 if (want == nullptr) {
1136 APP_LOGE("ReadParcelable<want> failed");
1137 return ERR_APPEXECFWK_PARCEL_ERROR;
1138 }
1139
1140 AbilityInfo info;
1141 bool ret = QueryAbilityInfo(*want, info);
1142 if (!reply.WriteBool(ret)) {
1143 APP_LOGE("write failed");
1144 return ERR_APPEXECFWK_PARCEL_ERROR;
1145 }
1146 if (ret) {
1147 if (!reply.WriteParcelable(&info)) {
1148 APP_LOGE("write failed");
1149 return ERR_APPEXECFWK_PARCEL_ERROR;
1150 }
1151 }
1152 return ERR_OK;
1153 }
1154
HandleQueryAbilityInfoMutiparam(MessageParcel & data,MessageParcel & reply)1155 ErrCode BundleMgrHost::HandleQueryAbilityInfoMutiparam(MessageParcel &data, MessageParcel &reply)
1156 {
1157 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1158 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1159 if (want == nullptr) {
1160 APP_LOGE("ReadParcelable<want> failed");
1161 return ERR_APPEXECFWK_PARCEL_ERROR;
1162 }
1163 int32_t flags = data.ReadInt32();
1164 int32_t userId = data.ReadInt32();
1165 AbilityInfo info;
1166 bool ret = QueryAbilityInfo(*want, flags, userId, info);
1167 if (!reply.WriteBool(ret)) {
1168 APP_LOGE("write failed");
1169 return ERR_APPEXECFWK_PARCEL_ERROR;
1170 }
1171 if (ret) {
1172 if (!reply.WriteParcelable(&info)) {
1173 APP_LOGE("write failed");
1174 return ERR_APPEXECFWK_PARCEL_ERROR;
1175 }
1176 }
1177 return ERR_OK;
1178 }
1179
HandleQueryAbilityInfos(MessageParcel & data,MessageParcel & reply)1180 ErrCode BundleMgrHost::HandleQueryAbilityInfos(MessageParcel &data, MessageParcel &reply)
1181 {
1182 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1183 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1184 if (want == nullptr) {
1185 APP_LOGE("ReadParcelable<want> failed");
1186 return ERR_APPEXECFWK_PARCEL_ERROR;
1187 }
1188
1189 std::vector<AbilityInfo> abilityInfos;
1190 bool ret = QueryAbilityInfos(*want, abilityInfos);
1191 if (!reply.WriteBool(ret)) {
1192 APP_LOGE("write failed");
1193 return ERR_APPEXECFWK_PARCEL_ERROR;
1194 }
1195 if (ret) {
1196 if (!WriteParcelableVector(abilityInfos, reply)) {
1197 APP_LOGE("write failed");
1198 return ERR_APPEXECFWK_PARCEL_ERROR;
1199 }
1200 }
1201 return ERR_OK;
1202 }
1203
HandleQueryAbilityInfosMutiparam(MessageParcel & data,MessageParcel & reply)1204 ErrCode BundleMgrHost::HandleQueryAbilityInfosMutiparam(MessageParcel &data, MessageParcel &reply)
1205 {
1206 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1207 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1208 if (want == nullptr) {
1209 APP_LOGE("ReadParcelable<want> failed");
1210 return ERR_APPEXECFWK_PARCEL_ERROR;
1211 }
1212 int32_t flags = data.ReadInt32();
1213 int32_t userId = data.ReadInt32();
1214 std::vector<AbilityInfo> abilityInfos;
1215 bool ret = QueryAbilityInfos(*want, flags, userId, abilityInfos);
1216 if (!reply.WriteBool(ret)) {
1217 APP_LOGE("write failed");
1218 return ERR_APPEXECFWK_PARCEL_ERROR;
1219 }
1220 if (ret) {
1221 if (!WriteVectorToParcelIntelligent(abilityInfos, reply)) {
1222 APP_LOGE("write failed");
1223 return ERR_APPEXECFWK_PARCEL_ERROR;
1224 }
1225 }
1226 return ERR_OK;
1227 }
1228
HandleQueryAbilityInfosV9(MessageParcel & data,MessageParcel & reply)1229 ErrCode BundleMgrHost::HandleQueryAbilityInfosV9(MessageParcel &data, MessageParcel &reply)
1230 {
1231 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1232 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1233 if (want == nullptr) {
1234 APP_LOGE("ReadParcelable<want> failed");
1235 return ERR_APPEXECFWK_PARCEL_ERROR;
1236 }
1237 int32_t flags = data.ReadInt32();
1238 int32_t userId = data.ReadInt32();
1239 std::vector<AbilityInfo> abilityInfos;
1240 ErrCode ret = QueryAbilityInfosV9(*want, flags, userId, abilityInfos);
1241 if (!reply.WriteInt32(ret)) {
1242 APP_LOGE("write ret failed");
1243 return ERR_APPEXECFWK_PARCEL_ERROR;
1244 }
1245 if (ret == ERR_OK) {
1246 if (!WriteVectorToParcelIntelligent(abilityInfos, reply)) {
1247 APP_LOGE("WriteVectorToParcelIntelligent failed");
1248 return ERR_APPEXECFWK_PARCEL_ERROR;
1249 }
1250 }
1251 return ERR_OK;
1252 }
1253
HandleBatchQueryAbilityInfos(MessageParcel & data,MessageParcel & reply)1254 ErrCode BundleMgrHost::HandleBatchQueryAbilityInfos(MessageParcel &data, MessageParcel &reply)
1255 {
1256 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1257 int32_t wantCount = data.ReadInt32();
1258 if (wantCount <= 0 || wantCount > MAX_BATCH_QUERY_ABILITY_SIZE) {
1259 APP_LOGE("want count is error");
1260 return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
1261 }
1262 std::vector<Want> wants;
1263 for (int i = 0; i < wantCount; i++) {
1264 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1265 if (want == nullptr) {
1266 APP_LOGE("ReadParcelable<want> failed");
1267 return ERR_APPEXECFWK_PARCEL_ERROR;
1268 }
1269 wants.push_back(*want);
1270 }
1271
1272 int32_t flags = data.ReadInt32();
1273 int32_t userId = data.ReadInt32();
1274 std::vector<AbilityInfo> abilityInfos;
1275 ErrCode ret = BatchQueryAbilityInfos(wants, flags, userId, abilityInfos);
1276 if (!reply.WriteInt32(ret)) {
1277 APP_LOGE("write ret failed");
1278 return ERR_APPEXECFWK_PARCEL_ERROR;
1279 }
1280 if (ret == ERR_OK) {
1281 if (!WriteVectorToParcelIntelligent(abilityInfos, reply)) {
1282 APP_LOGE("WriteVectorToParcelIntelligent failed");
1283 return ERR_APPEXECFWK_PARCEL_ERROR;
1284 }
1285 }
1286 return ERR_OK;
1287 }
1288
HandleQueryLauncherAbilityInfos(MessageParcel & data,MessageParcel & reply)1289 ErrCode BundleMgrHost::HandleQueryLauncherAbilityInfos(MessageParcel &data, MessageParcel &reply)
1290 {
1291 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1292 if (want == nullptr) {
1293 APP_LOGE("ReadParcelable<want> failed");
1294 return ERR_APPEXECFWK_PARCEL_ERROR;
1295 }
1296 int32_t userId = data.ReadInt32();
1297 std::vector<AbilityInfo> abilityInfos;
1298 ErrCode ret = QueryLauncherAbilityInfos(*want, userId, abilityInfos);
1299 if (!reply.WriteInt32(ret)) {
1300 APP_LOGE("write ret failed");
1301 return ERR_APPEXECFWK_PARCEL_ERROR;
1302 }
1303 if (ret == ERR_OK) {
1304 if (!WriteVectorToParcelIntelligent(abilityInfos, reply)) {
1305 APP_LOGE("WriteVectorToParcelIntelligent failed");
1306 return ERR_APPEXECFWK_PARCEL_ERROR;
1307 }
1308 }
1309 return ERR_OK;
1310 }
1311
HandleQueryAllAbilityInfos(MessageParcel & data,MessageParcel & reply)1312 ErrCode BundleMgrHost::HandleQueryAllAbilityInfos(MessageParcel &data, MessageParcel &reply)
1313 {
1314 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1315 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1316 if (want == nullptr) {
1317 APP_LOGE("ReadParcelable<want> failed");
1318 return ERR_APPEXECFWK_PARCEL_ERROR;
1319 }
1320 int32_t userId = data.ReadInt32();
1321 std::vector<AbilityInfo> abilityInfos;
1322 bool ret = QueryAllAbilityInfos(*want, userId, abilityInfos);
1323 if (!reply.WriteBool(ret)) {
1324 APP_LOGE("write failed");
1325 return ERR_APPEXECFWK_PARCEL_ERROR;
1326 }
1327 if (ret) {
1328 if (!WriteVectorToParcelIntelligent(abilityInfos, reply)) {
1329 APP_LOGE("write failed");
1330 return ERR_APPEXECFWK_PARCEL_ERROR;
1331 }
1332 }
1333 return ERR_OK;
1334 }
1335
HandleQueryAbilityInfoByUri(MessageParcel & data,MessageParcel & reply)1336 ErrCode BundleMgrHost::HandleQueryAbilityInfoByUri(MessageParcel &data, MessageParcel &reply)
1337 {
1338 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1339 std::string abilityUri = data.ReadString();
1340 AbilityInfo info;
1341 bool ret = QueryAbilityInfoByUri(abilityUri, info);
1342 if (!reply.WriteBool(ret)) {
1343 APP_LOGE("write failed");
1344 return ERR_APPEXECFWK_PARCEL_ERROR;
1345 }
1346 if (ret) {
1347 if (!reply.WriteParcelable(&info)) {
1348 APP_LOGE("write failed");
1349 return ERR_APPEXECFWK_PARCEL_ERROR;
1350 }
1351 }
1352 return ERR_OK;
1353 }
1354
HandleQueryAbilityInfosByUri(MessageParcel & data,MessageParcel & reply)1355 ErrCode BundleMgrHost::HandleQueryAbilityInfosByUri(MessageParcel &data, MessageParcel &reply)
1356 {
1357 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1358 std::string abilityUri = data.ReadString();
1359 std::vector<AbilityInfo> abilityInfos;
1360 bool ret = QueryAbilityInfosByUri(abilityUri, abilityInfos);
1361 if (!reply.WriteBool(ret)) {
1362 APP_LOGE("write failed");
1363 return ERR_APPEXECFWK_PARCEL_ERROR;
1364 }
1365 if (ret) {
1366 if (!WriteParcelableVector(abilityInfos, reply)) {
1367 APP_LOGE("write failed");
1368 return ERR_APPEXECFWK_PARCEL_ERROR;
1369 }
1370 }
1371 return ERR_OK;
1372 }
1373
HandleQueryAbilityInfoByUriForUserId(MessageParcel & data,MessageParcel & reply)1374 ErrCode BundleMgrHost::HandleQueryAbilityInfoByUriForUserId(MessageParcel &data, MessageParcel &reply)
1375 {
1376 std::string abilityUri = data.ReadString();
1377 int32_t userId = data.ReadInt32();
1378 AbilityInfo info;
1379 bool ret = QueryAbilityInfoByUri(abilityUri, userId, info);
1380 if (!reply.WriteBool(ret)) {
1381 APP_LOGE("write failed");
1382 return ERR_APPEXECFWK_PARCEL_ERROR;
1383 }
1384 if (ret) {
1385 if (!reply.WriteParcelable(&info)) {
1386 APP_LOGE("write failed");
1387 return ERR_APPEXECFWK_PARCEL_ERROR;
1388 }
1389 }
1390 return ERR_OK;
1391 }
1392
HandleQueryKeepAliveBundleInfos(MessageParcel & data,MessageParcel & reply)1393 ErrCode BundleMgrHost::HandleQueryKeepAliveBundleInfos(MessageParcel &data, MessageParcel &reply)
1394 {
1395 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1396 std::vector<BundleInfo> infos;
1397 bool ret = QueryKeepAliveBundleInfos(infos);
1398 if (!reply.WriteBool(ret)) {
1399 APP_LOGE("write failed");
1400 return ERR_APPEXECFWK_PARCEL_ERROR;
1401 }
1402 if (ret) {
1403 if (!WriteParcelableVector(infos, reply)) {
1404 APP_LOGE("write failed");
1405 return ERR_APPEXECFWK_PARCEL_ERROR;
1406 }
1407 }
1408 return ERR_OK;
1409 }
1410
HandleGetAbilityLabel(MessageParcel & data,MessageParcel & reply)1411 ErrCode BundleMgrHost::HandleGetAbilityLabel(MessageParcel &data, MessageParcel &reply)
1412 {
1413 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1414 std::string bundleName = data.ReadString();
1415 std::string abilityName = data.ReadString();
1416
1417 APP_LOGD("bundleName %{public}s, abilityName %{public}s", bundleName.c_str(), abilityName.c_str());
1418 BundleInfo info;
1419 std::string label = GetAbilityLabel(bundleName, abilityName);
1420 if (!reply.WriteString(label)) {
1421 APP_LOGE("write failed");
1422 return ERR_APPEXECFWK_PARCEL_ERROR;
1423 }
1424 return ERR_OK;
1425 }
1426
HandleGetAbilityLabelWithModuleName(MessageParcel & data,MessageParcel & reply)1427 ErrCode BundleMgrHost::HandleGetAbilityLabelWithModuleName(MessageParcel &data, MessageParcel &reply)
1428 {
1429 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1430 std::string bundleName = data.ReadString();
1431 std::string moduleName = data.ReadString();
1432 std::string abilityName = data.ReadString();
1433 if (bundleName.empty() || moduleName.empty() || abilityName.empty()) {
1434 APP_LOGE("fail to GetAbilityLabel due to params empty");
1435 return ERR_BUNDLE_MANAGER_INVALID_PARAMETER;
1436 }
1437 APP_LOGD("GetAbilityLabe bundleName %{public}s, moduleName %{public}s, abilityName %{public}s",
1438 bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
1439 std::string label;
1440 ErrCode ret = GetAbilityLabel(bundleName, moduleName, abilityName, label);
1441 if (!reply.WriteInt32(ret)) {
1442 return ERR_APPEXECFWK_PARCEL_ERROR;
1443 }
1444 if ((ret == ERR_OK) && !reply.WriteString(label)) {
1445 APP_LOGE("write failed");
1446 return ERR_APPEXECFWK_PARCEL_ERROR;
1447 }
1448 return ERR_OK;
1449 }
1450
HandleCheckIsSystemAppByUid(MessageParcel & data,MessageParcel & reply)1451 ErrCode BundleMgrHost::HandleCheckIsSystemAppByUid(MessageParcel &data, MessageParcel &reply)
1452 {
1453 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1454 int uid = data.ReadInt32();
1455 bool ret = CheckIsSystemAppByUid(uid);
1456 if (!reply.WriteBool(ret)) {
1457 APP_LOGE("write failed");
1458 return ERR_APPEXECFWK_PARCEL_ERROR;
1459 }
1460 return ERR_OK;
1461 }
1462
HandleGetBundleArchiveInfo(MessageParcel & data,MessageParcel & reply)1463 ErrCode BundleMgrHost::HandleGetBundleArchiveInfo(MessageParcel &data, MessageParcel &reply)
1464 {
1465 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1466 std::string hapFilePath = data.ReadString();
1467 BundleFlag flag = static_cast<BundleFlag>(data.ReadInt32());
1468 APP_LOGD("hapFilePath %{private}s, flag %{public}d", hapFilePath.c_str(), flag);
1469
1470 BundleInfo info;
1471 bool ret = GetBundleArchiveInfo(hapFilePath, flag, info);
1472 if (!reply.WriteBool(ret)) {
1473 APP_LOGE("write failed");
1474 return ERR_APPEXECFWK_PARCEL_ERROR;
1475 }
1476 if (ret) {
1477 if (!reply.WriteParcelable(&info)) {
1478 APP_LOGE("write failed");
1479 return ERR_APPEXECFWK_PARCEL_ERROR;
1480 }
1481 }
1482 return ERR_OK;
1483 }
1484
HandleGetBundleArchiveInfoWithIntFlags(MessageParcel & data,MessageParcel & reply)1485 ErrCode BundleMgrHost::HandleGetBundleArchiveInfoWithIntFlags(MessageParcel &data, MessageParcel &reply)
1486 {
1487 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1488 std::string hapFilePath = data.ReadString();
1489 int32_t flags = data.ReadInt32();
1490 APP_LOGD("hapFilePath %{private}s, flagS %{public}d", hapFilePath.c_str(), flags);
1491
1492 BundleInfo info;
1493 bool ret = GetBundleArchiveInfo(hapFilePath, flags, info);
1494 if (!reply.WriteBool(ret)) {
1495 APP_LOGE("write failed");
1496 return ERR_APPEXECFWK_PARCEL_ERROR;
1497 }
1498 if (ret) {
1499 if (!reply.WriteParcelable(&info)) {
1500 APP_LOGE("write failed");
1501 return ERR_APPEXECFWK_PARCEL_ERROR;
1502 }
1503 }
1504 return ERR_OK;
1505 }
1506
HandleGetBundleArchiveInfoWithIntFlagsV9(MessageParcel & data,MessageParcel & reply)1507 ErrCode BundleMgrHost::HandleGetBundleArchiveInfoWithIntFlagsV9(MessageParcel &data, MessageParcel &reply)
1508 {
1509 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1510 std::string hapFilePath = data.ReadString();
1511 int32_t flags = data.ReadInt32();
1512 APP_LOGD("hapFilePath %{private}s, flags %{public}d", hapFilePath.c_str(), flags);
1513
1514 BundleInfo info;
1515 ErrCode ret = GetBundleArchiveInfoV9(hapFilePath, flags, info);
1516 if (!reply.WriteInt32(ret)) {
1517 APP_LOGE("write failed");
1518 return ERR_APPEXECFWK_PARCEL_ERROR;
1519 }
1520 if (ret == ERR_OK) {
1521 if (!reply.WriteParcelable(&info)) {
1522 APP_LOGE("write failed");
1523 return ERR_APPEXECFWK_PARCEL_ERROR;
1524 }
1525 }
1526 return ERR_OK;
1527 }
1528
HandleGetHapModuleInfo(MessageParcel & data,MessageParcel & reply)1529 ErrCode BundleMgrHost::HandleGetHapModuleInfo(MessageParcel &data, MessageParcel &reply)
1530 {
1531 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1532 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1533 if (!abilityInfo) {
1534 APP_LOGE("ReadParcelable<abilityInfo> failed");
1535 return ERR_APPEXECFWK_PARCEL_ERROR;
1536 }
1537
1538 HapModuleInfo info;
1539 bool ret = GetHapModuleInfo(*abilityInfo, info);
1540 if (!reply.WriteBool(ret)) {
1541 APP_LOGE("write failed");
1542 return ERR_APPEXECFWK_PARCEL_ERROR;
1543 }
1544 if (ret) {
1545 if (!reply.WriteParcelable(&info)) {
1546 APP_LOGE("write failed");
1547 return ERR_APPEXECFWK_PARCEL_ERROR;
1548 }
1549 }
1550 return ERR_OK;
1551 }
1552
HandleGetHapModuleInfoWithUserId(MessageParcel & data,MessageParcel & reply)1553 ErrCode BundleMgrHost::HandleGetHapModuleInfoWithUserId(MessageParcel &data, MessageParcel &reply)
1554 {
1555 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1556 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1557 if (abilityInfo == nullptr) {
1558 APP_LOGE("ReadParcelable<abilityInfo> failed");
1559 return ERR_APPEXECFWK_PARCEL_ERROR;
1560 }
1561
1562 int32_t userId = data.ReadInt32();
1563 HapModuleInfo info;
1564 bool ret = GetHapModuleInfo(*abilityInfo, userId, info);
1565 if (!reply.WriteBool(ret)) {
1566 APP_LOGE("write failed");
1567 return ERR_APPEXECFWK_PARCEL_ERROR;
1568 }
1569 if (ret) {
1570 if (!reply.WriteParcelable(&info)) {
1571 APP_LOGE("write failed");
1572 return ERR_APPEXECFWK_PARCEL_ERROR;
1573 }
1574 }
1575 return ERR_OK;
1576 }
1577
HandleGetLaunchWantForBundle(MessageParcel & data,MessageParcel & reply)1578 ErrCode BundleMgrHost::HandleGetLaunchWantForBundle(MessageParcel &data, MessageParcel &reply)
1579 {
1580 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1581 std::string bundleName = data.ReadString();
1582 int32_t userId = data.ReadInt32();
1583 APP_LOGD("name %{public}s", bundleName.c_str());
1584
1585 Want want;
1586 ErrCode ret = GetLaunchWantForBundle(bundleName, want, userId);
1587 if (!reply.WriteInt32(ret)) {
1588 APP_LOGE("write failed");
1589 return ERR_APPEXECFWK_PARCEL_ERROR;
1590 }
1591 if (ret == ERR_OK) {
1592 if (!reply.WriteParcelable(&want)) {
1593 APP_LOGE("write failed");
1594 return ERR_APPEXECFWK_PARCEL_ERROR;
1595 }
1596 }
1597 return ERR_OK;
1598 }
1599
HandleGetPermissionDef(MessageParcel & data,MessageParcel & reply)1600 ErrCode BundleMgrHost::HandleGetPermissionDef(MessageParcel &data, MessageParcel &reply)
1601 {
1602 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1603 std::string permissionName = data.ReadString();
1604 APP_LOGD("name %{public}s", permissionName.c_str());
1605
1606 PermissionDef permissionDef;
1607 ErrCode ret = GetPermissionDef(permissionName, permissionDef);
1608 if (!reply.WriteInt32(ret)) {
1609 APP_LOGE("write failed");
1610 return ERR_APPEXECFWK_PARCEL_ERROR;
1611 }
1612 if (ret == ERR_OK) {
1613 if (!reply.WriteParcelable(&permissionDef)) {
1614 APP_LOGE("write failed");
1615 return ERR_APPEXECFWK_PARCEL_ERROR;
1616 }
1617 }
1618 return ERR_OK;
1619 }
1620
HandleCleanBundleCacheFilesAutomatic(MessageParcel & data,MessageParcel & reply)1621 ErrCode BundleMgrHost::HandleCleanBundleCacheFilesAutomatic(MessageParcel &data, MessageParcel &reply)
1622 {
1623 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1624
1625 uint64_t cacheSize = data.ReadUint64();
1626 ErrCode ret = CleanBundleCacheFilesAutomatic(cacheSize);
1627
1628 if (!reply.WriteInt32(ret)) {
1629 APP_LOGE("WriteInt32 failed");
1630 return ERR_APPEXECFWK_PARCEL_ERROR;
1631 }
1632 return ERR_OK;
1633 }
1634
HandleCleanBundleCacheFiles(MessageParcel & data,MessageParcel & reply)1635 ErrCode BundleMgrHost::HandleCleanBundleCacheFiles(MessageParcel &data, MessageParcel &reply)
1636 {
1637 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1638 std::string bundleName = data.ReadString();
1639 sptr<IRemoteObject> object = data.ReadRemoteObject();
1640 if (object == nullptr) {
1641 APP_LOGE("read failed");
1642 return ERR_APPEXECFWK_PARCEL_ERROR;
1643 }
1644 sptr<ICleanCacheCallback> cleanCacheCallback = iface_cast<ICleanCacheCallback>(object);
1645 int32_t userId = data.ReadInt32();
1646 int32_t appIndex = data.ReadInt32();
1647
1648 ErrCode ret = CleanBundleCacheFiles(bundleName, cleanCacheCallback, userId, appIndex);
1649 if (!reply.WriteInt32(ret)) {
1650 APP_LOGE("write failed");
1651 return ERR_APPEXECFWK_PARCEL_ERROR;
1652 }
1653 return ERR_OK;
1654 }
1655
HandleCleanBundleDataFiles(MessageParcel & data,MessageParcel & reply)1656 ErrCode BundleMgrHost::HandleCleanBundleDataFiles(MessageParcel &data, MessageParcel &reply)
1657 {
1658 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1659 std::string bundleName = data.ReadString();
1660 int userId = data.ReadInt32();
1661 int appIndex = data.ReadInt32();
1662
1663 bool ret = CleanBundleDataFiles(bundleName, userId, appIndex);
1664 if (!reply.WriteBool(ret)) {
1665 APP_LOGE("write failed");
1666 return ERR_APPEXECFWK_PARCEL_ERROR;
1667 }
1668 return ERR_OK;
1669 }
1670
HandleRegisterBundleStatusCallback(MessageParcel & data,MessageParcel & reply)1671 ErrCode BundleMgrHost::HandleRegisterBundleStatusCallback(MessageParcel &data, MessageParcel &reply)
1672 {
1673 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1674 std::string bundleName = data.ReadString();
1675 int32_t userId = data.ReadInt32();
1676 sptr<IRemoteObject> object = data.ReadRemoteObject();
1677 if (object == nullptr) {
1678 APP_LOGE("read failed");
1679 return ERR_APPEXECFWK_PARCEL_ERROR;
1680 }
1681 sptr<IBundleStatusCallback> BundleStatusCallback = iface_cast<IBundleStatusCallback>(object);
1682
1683 bool ret = false;
1684 if (bundleName.empty() || !BundleStatusCallback) {
1685 APP_LOGE("Get BundleStatusCallback failed");
1686 } else {
1687 BundleStatusCallback->SetBundleName(bundleName);
1688 BundleStatusCallback->SetUserId(userId);
1689 ret = RegisterBundleStatusCallback(BundleStatusCallback);
1690 }
1691 if (!reply.WriteBool(ret)) {
1692 APP_LOGE("write failed");
1693 return ERR_APPEXECFWK_PARCEL_ERROR;
1694 }
1695 return ERR_OK;
1696 }
1697
HandleRegisterBundleEventCallback(MessageParcel & data,MessageParcel & reply)1698 ErrCode BundleMgrHost::HandleRegisterBundleEventCallback(MessageParcel &data, MessageParcel &reply)
1699 {
1700 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1701 sptr<IRemoteObject> object = data.ReadRemoteObject();
1702 if (object == nullptr) {
1703 APP_LOGE("read IRemoteObject failed");
1704 return ERR_APPEXECFWK_PARCEL_ERROR;
1705 }
1706 sptr<IBundleEventCallback> bundleEventCallback = iface_cast<IBundleEventCallback>(object);
1707 if (bundleEventCallback == nullptr) {
1708 APP_LOGE("Get bundleEventCallback failed");
1709 return ERR_APPEXECFWK_PARCEL_ERROR;
1710 }
1711 bool ret = RegisterBundleEventCallback(bundleEventCallback);
1712 if (!reply.WriteBool(ret)) {
1713 APP_LOGE("write ret failed");
1714 return ERR_APPEXECFWK_PARCEL_ERROR;
1715 }
1716 return ERR_OK;
1717 }
1718
HandleUnregisterBundleEventCallback(MessageParcel & data,MessageParcel & reply)1719 ErrCode BundleMgrHost::HandleUnregisterBundleEventCallback(MessageParcel &data, MessageParcel &reply)
1720 {
1721 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1722 sptr<IRemoteObject> object = data.ReadRemoteObject();
1723 if (object == nullptr) {
1724 APP_LOGE("read IRemoteObject failed");
1725 return ERR_APPEXECFWK_PARCEL_ERROR;
1726 }
1727 sptr<IBundleEventCallback> bundleEventCallback = iface_cast<IBundleEventCallback>(object);
1728
1729 bool ret = UnregisterBundleEventCallback(bundleEventCallback);
1730 if (!reply.WriteBool(ret)) {
1731 APP_LOGE("write ret failed");
1732 return ERR_APPEXECFWK_PARCEL_ERROR;
1733 }
1734 return ERR_OK;
1735 }
1736
HandleClearBundleStatusCallback(MessageParcel & data,MessageParcel & reply)1737 ErrCode BundleMgrHost::HandleClearBundleStatusCallback(MessageParcel &data, MessageParcel &reply)
1738 {
1739 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1740 sptr<IRemoteObject> object = data.ReadRemoteObject();
1741 if (object == nullptr) {
1742 APP_LOGE("read failed");
1743 return ERR_APPEXECFWK_PARCEL_ERROR;
1744 }
1745 sptr<IBundleStatusCallback> BundleStatusCallback = iface_cast<IBundleStatusCallback>(object);
1746
1747 bool ret = ClearBundleStatusCallback(BundleStatusCallback);
1748 if (!reply.WriteBool(ret)) {
1749 APP_LOGE("write failed");
1750 return ERR_APPEXECFWK_PARCEL_ERROR;
1751 }
1752 return ERR_OK;
1753 }
1754
HandleUnregisterBundleStatusCallback(MessageParcel & data,MessageParcel & reply)1755 ErrCode BundleMgrHost::HandleUnregisterBundleStatusCallback(MessageParcel &data, MessageParcel &reply)
1756 {
1757 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1758 bool ret = UnregisterBundleStatusCallback();
1759 if (!reply.WriteBool(ret)) {
1760 APP_LOGE("write failed");
1761 return ERR_APPEXECFWK_PARCEL_ERROR;
1762 }
1763 return ERR_OK;
1764 }
1765
HandleCompileProcessAOT(MessageParcel & data,MessageParcel & reply)1766 ErrCode BundleMgrHost::HandleCompileProcessAOT(MessageParcel &data, MessageParcel &reply)
1767 {
1768 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1769 std::string bundleName = data.ReadString();
1770 std::string compileMode = data.ReadString();
1771 bool isAllBundle = data.ReadBool();
1772 std::vector<std::string> compileResults;
1773
1774 APP_LOGI("compile info %{public}s", bundleName.c_str());
1775 ErrCode ret = CompileProcessAOT(bundleName, compileMode, isAllBundle, compileResults);
1776 APP_LOGI("ret %{public}d", ret);
1777 if (!reply.WriteInt32(ret)) {
1778 APP_LOGE("write failed");
1779 return ERR_APPEXECFWK_PARCEL_ERROR;
1780 }
1781 if (ret != ERR_OK) {
1782 if (!reply.WriteStringVector(compileResults)) {
1783 APP_LOGE("write compile process AOT results failed");
1784 return ERR_APPEXECFWK_PARCEL_ERROR;
1785 }
1786 }
1787 return ERR_OK;
1788 }
1789
HandleCompileReset(MessageParcel & data,MessageParcel & reply)1790 ErrCode BundleMgrHost::HandleCompileReset(MessageParcel &data, MessageParcel &reply)
1791 {
1792 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1793 std::string bundleName = data.ReadString();
1794 bool isAllBundle = data.ReadBool();
1795
1796 APP_LOGI("reset info %{public}s", bundleName.c_str());
1797 ErrCode ret = CompileReset(bundleName, isAllBundle);
1798 APP_LOGI("ret %{public}d", ret);
1799 if (!reply.WriteInt32(ret)) {
1800 APP_LOGE("write failed");
1801 return ERR_APPEXECFWK_PARCEL_ERROR;
1802 }
1803 return ERR_OK;
1804 }
1805
HandleCopyAp(MessageParcel & data,MessageParcel & reply)1806 ErrCode BundleMgrHost::HandleCopyAp(MessageParcel &data, MessageParcel &reply)
1807 {
1808 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1809 std::string bundleName = data.ReadString();
1810 bool isAllBundle = data.ReadBool();
1811 std::vector<std::string> results;
1812 ErrCode ret = CopyAp(bundleName, isAllBundle, results);
1813 APP_LOGI("ret %{public}d", ret);
1814 if (!reply.WriteInt32(ret)) {
1815 APP_LOGE("HandleCopyAp write failed");
1816 return ERR_APPEXECFWK_PARCEL_ERROR;
1817 }
1818 if (ret == ERR_OK && !reply.WriteStringVector(results)) {
1819 APP_LOGE("write HandleCopyAp results failed");
1820 return ERR_APPEXECFWK_PARCEL_ERROR;
1821 }
1822 return ERR_OK;
1823 }
1824
HandleDumpInfos(MessageParcel & data,MessageParcel & reply)1825 ErrCode BundleMgrHost::HandleDumpInfos(MessageParcel &data, MessageParcel &reply)
1826 {
1827 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1828 DumpFlag flag = static_cast<DumpFlag>(data.ReadInt32());
1829 std::string bundleName = data.ReadString();
1830 int32_t userId = data.ReadInt32();
1831
1832 std::string result;
1833 APP_LOGI("dump info %{public}s", bundleName.c_str());
1834 bool ret = DumpInfos(flag, bundleName, userId, result);
1835 (void)reply.SetMaxCapacity(MAX_PARCEL_CAPACITY);
1836 if (!reply.WriteBool(ret)) {
1837 APP_LOGE("write failed");
1838 return ERR_APPEXECFWK_PARCEL_ERROR;
1839 }
1840 if (ret) {
1841 std::vector<std::string> dumpInfos;
1842 SplitString(result, dumpInfos);
1843 if (!reply.WriteStringVector(dumpInfos)) {
1844 return ERR_APPEXECFWK_PARCEL_ERROR;
1845 }
1846 }
1847 return ERR_OK;
1848 }
1849
HandleIsApplicationEnabled(MessageParcel & data,MessageParcel & reply)1850 ErrCode BundleMgrHost::HandleIsApplicationEnabled(MessageParcel &data, MessageParcel &reply)
1851 {
1852 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1853 std::string bundleName = data.ReadString();
1854 if (bundleName.empty()) {
1855 APP_LOGE("fail to IsApplicationEnabled due to params empty");
1856 return ERR_BUNDLE_MANAGER_PARAM_ERROR;
1857 }
1858 bool isEnable = false;
1859 ErrCode ret = IsApplicationEnabled(bundleName, isEnable);
1860 if (!reply.WriteInt32(ret)) {
1861 APP_LOGE("WriteInt32 failed");
1862 return ERR_APPEXECFWK_PARCEL_ERROR;
1863 }
1864 if (!reply.WriteBool(isEnable)) {
1865 APP_LOGE("WriteBool failed");
1866 return ERR_APPEXECFWK_PARCEL_ERROR;
1867 }
1868 return ERR_OK;
1869 }
1870
HandleIsCloneApplicationEnabled(MessageParcel & data,MessageParcel & reply)1871 ErrCode BundleMgrHost::HandleIsCloneApplicationEnabled(MessageParcel &data, MessageParcel &reply)
1872 {
1873 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1874 std::string bundleName = data.ReadString();
1875 if (bundleName.empty()) {
1876 APP_LOGE("fail to HandleIsCloneApplicationEnabled due to params empty");
1877 return ERR_BUNDLE_MANAGER_PARAM_ERROR;
1878 }
1879 int32_t appIndex = data.ReadInt32();
1880 bool isEnable = false;
1881 ErrCode ret = IsCloneApplicationEnabled(bundleName, appIndex, isEnable);
1882 if (!reply.WriteInt32(ret)) {
1883 return ERR_APPEXECFWK_PARCEL_ERROR;
1884 }
1885 if ((ret == ERR_OK) && !reply.WriteBool(isEnable)) {
1886 return ERR_APPEXECFWK_PARCEL_ERROR;
1887 }
1888 return ERR_OK;
1889 }
1890
HandleSetApplicationEnabled(MessageParcel & data,MessageParcel & reply)1891 ErrCode BundleMgrHost::HandleSetApplicationEnabled(MessageParcel &data, MessageParcel &reply)
1892 {
1893 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1894 std::string bundleName = data.ReadString();
1895 if (bundleName.empty()) {
1896 APP_LOGE("fail to SetApplicationEnabled due to params empty");
1897 return ERR_BUNDLE_MANAGER_PARAM_ERROR;
1898 }
1899 bool isEnable = data.ReadBool();
1900 int32_t userId = data.ReadInt32();
1901 ErrCode ret = SetApplicationEnabled(bundleName, isEnable, userId);
1902 if (!reply.WriteInt32(ret)) {
1903 APP_LOGE("WriteInt32 failed");
1904 return ERR_APPEXECFWK_PARCEL_ERROR;
1905 }
1906 return ERR_OK;
1907 }
1908
HandleSetCloneApplicationEnabled(MessageParcel & data,MessageParcel & reply)1909 ErrCode BundleMgrHost::HandleSetCloneApplicationEnabled(MessageParcel &data, MessageParcel &reply)
1910 {
1911 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1912 std::string bundleName = data.ReadString();
1913 if (bundleName.empty()) {
1914 APP_LOGE("fail to SetCloneApplicationEnabled due to params empty");
1915 return ERR_BUNDLE_MANAGER_PARAM_ERROR;
1916 }
1917 int32_t appIndex = data.ReadInt32();
1918 bool isEnable = data.ReadBool();
1919 int32_t userId = data.ReadInt32();
1920 ErrCode ret = SetCloneApplicationEnabled(bundleName, appIndex, isEnable, userId);
1921 if (!reply.WriteInt32(ret)) {
1922 return ERR_APPEXECFWK_PARCEL_ERROR;
1923 }
1924 return ERR_OK;
1925 }
1926
HandleIsAbilityEnabled(MessageParcel & data,MessageParcel & reply)1927 ErrCode BundleMgrHost::HandleIsAbilityEnabled(MessageParcel &data, MessageParcel &reply)
1928 {
1929 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1930 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1931 if (abilityInfo == nullptr) {
1932 APP_LOGE("ReadParcelable<abilityInfo> failed");
1933 return ERR_APPEXECFWK_PARCEL_ERROR;
1934 }
1935 bool isEnable = false;
1936 ErrCode ret = IsAbilityEnabled(*abilityInfo, isEnable);
1937 if (!reply.WriteInt32(ret)) {
1938 APP_LOGE("WriteInt32 failed");
1939 return ERR_APPEXECFWK_PARCEL_ERROR;
1940 }
1941 if (!reply.WriteBool(isEnable)) {
1942 APP_LOGE("WriteBool failed");
1943 return ERR_APPEXECFWK_PARCEL_ERROR;
1944 }
1945 return ERR_OK;
1946 }
1947
HandleIsCloneAbilityEnabled(MessageParcel & data,MessageParcel & reply)1948 ErrCode BundleMgrHost::HandleIsCloneAbilityEnabled(MessageParcel &data, MessageParcel &reply)
1949 {
1950 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1951 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1952 if (abilityInfo == nullptr) {
1953 APP_LOGE("ReadParcelable<abilityInfo> failed");
1954 return ERR_APPEXECFWK_PARCEL_ERROR;
1955 }
1956 int32_t appIndex = data.ReadInt32();
1957 bool isEnable = false;
1958 ErrCode ret = IsCloneAbilityEnabled(*abilityInfo, appIndex, isEnable);
1959 if (!reply.WriteInt32(ret)) {
1960 return ERR_APPEXECFWK_PARCEL_ERROR;
1961 }
1962 if ((ret == ERR_OK) && !reply.WriteBool(isEnable)) {
1963 return ERR_APPEXECFWK_PARCEL_ERROR;
1964 }
1965 return ERR_OK;
1966 }
1967
HandleSetAbilityEnabled(MessageParcel & data,MessageParcel & reply)1968 ErrCode BundleMgrHost::HandleSetAbilityEnabled(MessageParcel &data, MessageParcel &reply)
1969 {
1970 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1971 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1972 if (abilityInfo == nullptr) {
1973 APP_LOGE("ReadParcelable<abilityInfo> failed");
1974 return ERR_APPEXECFWK_PARCEL_ERROR;
1975 }
1976 bool isEnabled = data.ReadBool();
1977 int32_t userId = data.ReadInt32();
1978 ErrCode ret = SetAbilityEnabled(*abilityInfo, isEnabled, userId);
1979 if (!reply.WriteInt32(ret)) {
1980 APP_LOGE("WriteInt32 failed");
1981 return ERR_APPEXECFWK_PARCEL_ERROR;
1982 }
1983 return ERR_OK;
1984 }
1985
HandleSetCloneAbilityEnabled(MessageParcel & data,MessageParcel & reply)1986 ErrCode BundleMgrHost::HandleSetCloneAbilityEnabled(MessageParcel &data, MessageParcel &reply)
1987 {
1988 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
1989 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
1990 if (abilityInfo == nullptr) {
1991 APP_LOGE("ReadParcelable<abilityInfo> failed");
1992 return ERR_APPEXECFWK_PARCEL_ERROR;
1993 }
1994 int32_t appIndex = data.ReadInt32();
1995 bool isEnabled = data.ReadBool();
1996 int32_t userId = data.ReadInt32();
1997 ErrCode ret = SetCloneAbilityEnabled(*abilityInfo, appIndex, isEnabled, userId);
1998 if (!reply.WriteInt32(ret)) {
1999 return ERR_APPEXECFWK_PARCEL_ERROR;
2000 }
2001 return ERR_OK;
2002 }
2003
HandleGetAbilityInfo(MessageParcel & data,MessageParcel & reply)2004 ErrCode BundleMgrHost::HandleGetAbilityInfo(MessageParcel &data, MessageParcel &reply)
2005 {
2006 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2007 AbilityInfo info;
2008 std::string bundleName = data.ReadString();
2009 std::string abilityName = data.ReadString();
2010 bool ret = GetAbilityInfo(bundleName, abilityName, info);
2011 if (!reply.WriteBool(ret)) {
2012 APP_LOGE("write failed");
2013 return ERR_APPEXECFWK_PARCEL_ERROR;
2014 }
2015 if (ret) {
2016 if (!reply.WriteParcelable(&info)) {
2017 APP_LOGE("write failed");
2018 return ERR_APPEXECFWK_PARCEL_ERROR;
2019 }
2020 }
2021 return ERR_OK;
2022 }
2023
HandleGetAbilityInfoWithModuleName(MessageParcel & data,MessageParcel & reply)2024 ErrCode BundleMgrHost::HandleGetAbilityInfoWithModuleName(MessageParcel &data, MessageParcel &reply)
2025 {
2026 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2027 AbilityInfo info;
2028 std::string bundleName = data.ReadString();
2029 std::string moduleName = data.ReadString();
2030 std::string abilityName = data.ReadString();
2031 bool ret = GetAbilityInfo(bundleName, moduleName, abilityName, info);
2032 if (!reply.WriteBool(ret)) {
2033 APP_LOGE("write failed");
2034 return ERR_APPEXECFWK_PARCEL_ERROR;
2035 }
2036 if (ret) {
2037 if (!reply.WriteParcelable(&info)) {
2038 APP_LOGE("write failed");
2039 return ERR_APPEXECFWK_PARCEL_ERROR;
2040 }
2041 }
2042 return ERR_OK;
2043 }
2044
HandleGetBundleInstaller(MessageParcel & data,MessageParcel & reply)2045 ErrCode BundleMgrHost::HandleGetBundleInstaller(MessageParcel &data, MessageParcel &reply)
2046 {
2047 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2048 sptr<IBundleInstaller> installer = GetBundleInstaller();
2049 if (installer == nullptr) {
2050 APP_LOGE("bundle installer is nullptr");
2051 return ERR_APPEXECFWK_INSTALL_HOST_INSTALLER_FAILED;
2052 }
2053
2054 if (!reply.WriteRemoteObject(installer->AsObject())) {
2055 APP_LOGE("failed to reply bundle installer to client, for write MessageParcel error");
2056 return ERR_APPEXECFWK_PARCEL_ERROR;
2057 }
2058 return ERR_OK;
2059 }
2060
HandleGetBundleUserMgr(MessageParcel & data,MessageParcel & reply)2061 ErrCode BundleMgrHost::HandleGetBundleUserMgr(MessageParcel &data, MessageParcel &reply)
2062 {
2063 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2064 sptr<IBundleUserMgr> bundleUserMgr = GetBundleUserMgr();
2065 if (bundleUserMgr == nullptr) {
2066 APP_LOGE("bundle installer is nullptr");
2067 return ERR_APPEXECFWK_INSTALL_HOST_INSTALLER_FAILED;
2068 }
2069
2070 if (!reply.WriteRemoteObject(bundleUserMgr->AsObject())) {
2071 APP_LOGE("failed to reply bundle installer to client, for write MessageParcel error");
2072 return ERR_APPEXECFWK_PARCEL_ERROR;
2073 }
2074 return ERR_OK;
2075 }
2076
HandleGetVerifyManager(MessageParcel & data,MessageParcel & reply)2077 ErrCode BundleMgrHost::HandleGetVerifyManager(MessageParcel &data, MessageParcel &reply)
2078 {
2079 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2080 sptr<IVerifyManager> verifyManager = GetVerifyManager();
2081 if (verifyManager == nullptr) {
2082 APP_LOGE("verifyManager is nullptr");
2083 return ERR_BUNDLE_MANAGER_VERIFY_GET_VERIFY_MGR_FAILED;
2084 }
2085
2086 if (!reply.WriteRemoteObject(verifyManager->AsObject())) {
2087 APP_LOGE("failed to reply bundle installer to client, for write MessageParcel error");
2088 return ERR_APPEXECFWK_PARCEL_ERROR;
2089 }
2090 return ERR_OK;
2091 }
2092
HandleGetExtendResourceManager(MessageParcel & data,MessageParcel & reply)2093 ErrCode BundleMgrHost::HandleGetExtendResourceManager(MessageParcel &data, MessageParcel &reply)
2094 {
2095 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2096 sptr<IExtendResourceManager> extendResourceManager = GetExtendResourceManager();
2097 if (extendResourceManager == nullptr) {
2098 APP_LOGE("extendResourceManager is nullptr");
2099 return ERR_EXT_RESOURCE_MANAGER_GET_EXT_RESOURCE_MGR_FAILED;
2100 }
2101
2102 if (!reply.WriteRemoteObject(extendResourceManager->AsObject())) {
2103 APP_LOGE("failed to reply extendResourceManager, for write MessageParcel error");
2104 return ERR_APPEXECFWK_PARCEL_ERROR;
2105 }
2106 return ERR_OK;
2107 }
2108
HandleGetAllFormsInfo(MessageParcel & data,MessageParcel & reply)2109 ErrCode BundleMgrHost::HandleGetAllFormsInfo(MessageParcel &data, MessageParcel &reply)
2110 {
2111 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2112 std::vector<FormInfo> infos;
2113 bool ret = GetAllFormsInfo(infos);
2114 if (!reply.WriteBool(ret)) {
2115 APP_LOGE("write failed");
2116 return ERR_APPEXECFWK_PARCEL_ERROR;
2117 }
2118
2119 if (ret) {
2120 if (!WriteParcelableVector(infos, reply)) {
2121 APP_LOGE("write failed");
2122 return ERR_APPEXECFWK_PARCEL_ERROR;
2123 }
2124 }
2125 return ERR_OK;
2126 }
2127
HandleGetFormsInfoByApp(MessageParcel & data,MessageParcel & reply)2128 ErrCode BundleMgrHost::HandleGetFormsInfoByApp(MessageParcel &data, MessageParcel &reply)
2129 {
2130 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2131 std::string bundlename = data.ReadString();
2132 std::vector<FormInfo> infos;
2133 bool ret = GetFormsInfoByApp(bundlename, infos);
2134 if (!reply.WriteBool(ret)) {
2135 APP_LOGE("write failed");
2136 return ERR_APPEXECFWK_PARCEL_ERROR;
2137 }
2138
2139 if (ret) {
2140 if (!WriteParcelableVector(infos, reply)) {
2141 APP_LOGE("write failed");
2142 return ERR_APPEXECFWK_PARCEL_ERROR;
2143 }
2144 }
2145 return ERR_OK;
2146 }
2147
HandleGetFormsInfoByModule(MessageParcel & data,MessageParcel & reply)2148 ErrCode BundleMgrHost::HandleGetFormsInfoByModule(MessageParcel &data, MessageParcel &reply)
2149 {
2150 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2151 std::string bundlename = data.ReadString();
2152 std::string modulename = data.ReadString();
2153 std::vector<FormInfo> infos;
2154 bool ret = GetFormsInfoByModule(bundlename, modulename, infos);
2155 if (!reply.WriteBool(ret)) {
2156 APP_LOGE("write failed");
2157 return ERR_APPEXECFWK_PARCEL_ERROR;
2158 }
2159
2160 if (ret) {
2161 if (!WriteParcelableVector(infos, reply)) {
2162 APP_LOGE("write failed");
2163 return ERR_APPEXECFWK_PARCEL_ERROR;
2164 }
2165 }
2166 return ERR_OK;
2167 }
2168
HandleGetShortcutInfos(MessageParcel & data,MessageParcel & reply)2169 ErrCode BundleMgrHost::HandleGetShortcutInfos(MessageParcel &data, MessageParcel &reply)
2170 {
2171 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2172 std::string bundlename = data.ReadString();
2173 std::vector<ShortcutInfo> infos;
2174 bool ret = GetShortcutInfos(bundlename, infos);
2175 if (!reply.WriteBool(ret)) {
2176 APP_LOGE("write failed");
2177 return ERR_APPEXECFWK_PARCEL_ERROR;
2178 }
2179
2180 if (ret) {
2181 if (!WriteParcelableVector(infos, reply)) {
2182 APP_LOGE("write failed");
2183 return ERR_APPEXECFWK_PARCEL_ERROR;
2184 }
2185 }
2186 return ERR_OK;
2187 }
2188
HandleGetShortcutInfoV9(MessageParcel & data,MessageParcel & reply)2189 ErrCode BundleMgrHost::HandleGetShortcutInfoV9(MessageParcel &data, MessageParcel &reply)
2190 {
2191 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2192 std::string bundlename = data.ReadString();
2193 int32_t userId = data.ReadInt32();
2194 std::vector<ShortcutInfo> infos;
2195 ErrCode ret = GetShortcutInfoV9(bundlename, infos, userId);
2196 if (!reply.WriteInt32(ret)) {
2197 APP_LOGE("write result failed");
2198 return ERR_APPEXECFWK_PARCEL_ERROR;
2199 }
2200 if (ret == ERR_OK && !WriteParcelableVector(infos, reply)) {
2201 APP_LOGE("write shortcut infos failed");
2202 return ERR_APPEXECFWK_PARCEL_ERROR;
2203 }
2204 return ERR_OK;
2205 }
2206
HandleGetAllCommonEventInfo(MessageParcel & data,MessageParcel & reply)2207 ErrCode BundleMgrHost::HandleGetAllCommonEventInfo(MessageParcel &data, MessageParcel &reply)
2208 {
2209 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2210 std::string eventKey = data.ReadString();
2211 std::vector<CommonEventInfo> infos;
2212 bool ret = GetAllCommonEventInfo(eventKey, infos);
2213 if (!reply.WriteBool(ret)) {
2214 APP_LOGE("write failed");
2215 return ERR_APPEXECFWK_PARCEL_ERROR;
2216 }
2217
2218 if (ret) {
2219 if (!WriteParcelableVector(infos, reply)) {
2220 APP_LOGE("write failed");
2221 return ERR_APPEXECFWK_PARCEL_ERROR;
2222 }
2223 }
2224 return ERR_OK;
2225 }
2226
HandleGetDistributedBundleInfo(MessageParcel & data,MessageParcel & reply)2227 ErrCode BundleMgrHost::HandleGetDistributedBundleInfo(MessageParcel &data, MessageParcel &reply)
2228 {
2229 std::string networkId = data.ReadString();
2230 std::string bundleName = data.ReadString();
2231 if (networkId.empty() || bundleName.empty()) {
2232 APP_LOGE("networkId or bundleName is invalid");
2233 return ERR_INVALID_VALUE;
2234 }
2235 DistributedBundleInfo distributedBundleInfo;
2236 bool ret = GetDistributedBundleInfo(networkId, bundleName, distributedBundleInfo);
2237 if (!reply.WriteBool(ret)) {
2238 APP_LOGE("write failed");
2239 return ERR_APPEXECFWK_PARCEL_ERROR;
2240 }
2241 if (ret) {
2242 if (!reply.WriteParcelable(&distributedBundleInfo)) {
2243 APP_LOGE("write failed");
2244 return ERR_APPEXECFWK_PARCEL_ERROR;
2245 }
2246 }
2247 return ERR_OK;
2248 }
2249
HandleGetAppPrivilegeLevel(MessageParcel & data,MessageParcel & reply)2250 ErrCode BundleMgrHost::HandleGetAppPrivilegeLevel(MessageParcel &data, MessageParcel &reply)
2251 {
2252 std::string bundleName = data.ReadString();
2253 int32_t userId = data.ReadInt32();
2254 auto ret = GetAppPrivilegeLevel(bundleName, userId);
2255 if (!reply.WriteString(ret)) {
2256 APP_LOGE("write failed");
2257 return ERR_APPEXECFWK_PARCEL_ERROR;
2258 }
2259 return ERR_OK;
2260 }
2261
HandleQueryExtAbilityInfosWithoutType(MessageParcel & data,MessageParcel & reply)2262 ErrCode BundleMgrHost::HandleQueryExtAbilityInfosWithoutType(MessageParcel &data, MessageParcel &reply)
2263 {
2264 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2265 if (!want) {
2266 APP_LOGE("ReadParcelable<want> failed");
2267 return ERR_APPEXECFWK_PARCEL_ERROR;
2268 }
2269
2270 int32_t flag = data.ReadInt32();
2271 int32_t userId = data.ReadInt32();
2272 std::vector<ExtensionAbilityInfo> infos;
2273 bool ret = QueryExtensionAbilityInfos(*want, flag, userId, infos);
2274 if (!reply.WriteBool(ret)) {
2275 APP_LOGE("write result failed");
2276 return ERR_APPEXECFWK_PARCEL_ERROR;
2277 }
2278 if (ret && !WriteParcelableVector(infos, reply)) {
2279 APP_LOGE("write extension infos failed");
2280
2281 return ERR_APPEXECFWK_PARCEL_ERROR;
2282 }
2283 return ERR_OK;
2284 }
2285
HandleQueryExtAbilityInfosWithoutTypeV9(MessageParcel & data,MessageParcel & reply)2286 ErrCode BundleMgrHost::HandleQueryExtAbilityInfosWithoutTypeV9(MessageParcel &data, MessageParcel &reply)
2287 {
2288 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2289 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2290 if (!want) {
2291 APP_LOGE("ReadParcelable<want> failed");
2292 return ERR_APPEXECFWK_PARCEL_ERROR;
2293 }
2294
2295 int32_t flags = data.ReadInt32();
2296 int32_t userId = data.ReadInt32();
2297 std::vector<ExtensionAbilityInfo> infos;
2298 ErrCode ret = QueryExtensionAbilityInfosV9(*want, flags, userId, infos);
2299 if (!reply.WriteInt32(ret)) {
2300 APP_LOGE("write result failed");
2301 return ERR_APPEXECFWK_PARCEL_ERROR;
2302 }
2303 if (ret == ERR_OK && !WriteParcelableVector(infos, reply)) {
2304 APP_LOGE("write extension infos failed");
2305 return ERR_APPEXECFWK_PARCEL_ERROR;
2306 }
2307 return ERR_OK;
2308 }
2309
HandleQueryExtAbilityInfos(MessageParcel & data,MessageParcel & reply)2310 ErrCode BundleMgrHost::HandleQueryExtAbilityInfos(MessageParcel &data, MessageParcel &reply)
2311 {
2312 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2313 if (want == nullptr) {
2314 APP_LOGE("ReadParcelable<want> failed");
2315 return ERR_APPEXECFWK_PARCEL_ERROR;
2316 }
2317
2318 ExtensionAbilityType type = static_cast<ExtensionAbilityType>(data.ReadInt32());
2319 int32_t flag = data.ReadInt32();
2320 int32_t userId = data.ReadInt32();
2321 std::vector<ExtensionAbilityInfo> infos;
2322 bool ret = QueryExtensionAbilityInfos(*want, type, flag, userId, infos);
2323 if (!reply.WriteBool(ret)) {
2324 APP_LOGE("write result failed");
2325 return ERR_APPEXECFWK_PARCEL_ERROR;
2326 }
2327 if (ret && !WriteParcelableVector(infos, reply)) {
2328 APP_LOGE("write extension infos failed");
2329 return ERR_APPEXECFWK_PARCEL_ERROR;
2330 }
2331 return ERR_OK;
2332 }
2333
HandleQueryExtAbilityInfosV9(MessageParcel & data,MessageParcel & reply)2334 ErrCode BundleMgrHost::HandleQueryExtAbilityInfosV9(MessageParcel &data, MessageParcel &reply)
2335 {
2336 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2337 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2338 if (want == nullptr) {
2339 APP_LOGE("ReadParcelable<want> failed");
2340 return ERR_APPEXECFWK_PARCEL_ERROR;
2341 }
2342
2343 ExtensionAbilityType type = static_cast<ExtensionAbilityType>(data.ReadInt32());
2344 int32_t flags = data.ReadInt32();
2345 int32_t userId = data.ReadInt32();
2346 std::vector<ExtensionAbilityInfo> infos;
2347 ErrCode ret = QueryExtensionAbilityInfosV9(*want, type, flags, userId, infos);
2348 if (!reply.WriteInt32(ret)) {
2349 APP_LOGE("write result failed");
2350 return ERR_APPEXECFWK_PARCEL_ERROR;
2351 }
2352 if (ret == ERR_OK && !WriteParcelableVector(infos, reply)) {
2353 APP_LOGE("write extension infos failed");
2354 return ERR_APPEXECFWK_PARCEL_ERROR;
2355 }
2356 return ERR_OK;
2357 }
2358
HandleQueryExtAbilityInfosByType(MessageParcel & data,MessageParcel & reply)2359 ErrCode BundleMgrHost::HandleQueryExtAbilityInfosByType(MessageParcel &data, MessageParcel &reply)
2360 {
2361 ExtensionAbilityType type = static_cast<ExtensionAbilityType>(data.ReadInt32());
2362 int32_t userId = data.ReadInt32();
2363 std::vector<ExtensionAbilityInfo> infos;
2364
2365 bool ret = QueryExtensionAbilityInfos(type, userId, infos);
2366 if (!reply.WriteBool(ret)) {
2367 APP_LOGE("write result failed");
2368 return ERR_APPEXECFWK_PARCEL_ERROR;
2369 }
2370 if (ret && !WriteParcelableVector(infos, reply)) {
2371 APP_LOGE("write extension infos failed");
2372 return ERR_APPEXECFWK_PARCEL_ERROR;
2373 }
2374 return ERR_OK;
2375 }
2376
HandleVerifyCallingPermission(MessageParcel & data,MessageParcel & reply)2377 ErrCode BundleMgrHost::HandleVerifyCallingPermission(MessageParcel &data, MessageParcel &reply)
2378 {
2379 std::string permission = data.ReadString();
2380
2381 bool ret = VerifyCallingPermission(permission);
2382 if (!reply.WriteBool(ret)) {
2383 APP_LOGE("write result failed");
2384 return ERR_APPEXECFWK_PARCEL_ERROR;
2385 }
2386 return ERR_OK;
2387 }
2388
HandleQueryExtensionAbilityInfoByUri(MessageParcel & data,MessageParcel & reply)2389 ErrCode BundleMgrHost::HandleQueryExtensionAbilityInfoByUri(MessageParcel &data, MessageParcel &reply)
2390 {
2391 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2392 std::string uri = data.ReadString();
2393 int32_t userId = data.ReadInt32();
2394 ExtensionAbilityInfo extensionAbilityInfo;
2395 bool ret = QueryExtensionAbilityInfoByUri(uri, userId, extensionAbilityInfo);
2396 if (!reply.WriteBool(ret)) {
2397 APP_LOGE("write failed");
2398 return ERR_APPEXECFWK_PARCEL_ERROR;
2399 }
2400 if (ret) {
2401 if (!reply.WriteParcelable(&extensionAbilityInfo)) {
2402 APP_LOGE("write failed");
2403 return ERR_APPEXECFWK_PARCEL_ERROR;
2404 }
2405 }
2406 return ERR_OK;
2407 }
2408
HandleGetAppIdByBundleName(MessageParcel & data,MessageParcel & reply)2409 ErrCode BundleMgrHost::HandleGetAppIdByBundleName(MessageParcel &data, MessageParcel &reply)
2410 {
2411 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2412 std::string bundleName = data.ReadString();
2413 int32_t userId = data.ReadInt32();
2414 std::string appId = GetAppIdByBundleName(bundleName, userId);
2415 APP_LOGD("appId is %{private}s", appId.c_str());
2416 if (!reply.WriteString(appId)) {
2417 APP_LOGE("write failed");
2418 return ERR_APPEXECFWK_PARCEL_ERROR;
2419 }
2420 return ERR_OK;
2421 }
2422
HandleGetAppType(MessageParcel & data,MessageParcel & reply)2423 ErrCode BundleMgrHost::HandleGetAppType(MessageParcel &data, MessageParcel &reply)
2424 {
2425 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2426 std::string bundleName = data.ReadString();
2427 std::string appType = GetAppType(bundleName);
2428 APP_LOGD("appType is %{public}s", appType.c_str());
2429 if (!reply.WriteString(appType)) {
2430 APP_LOGE("write failed");
2431 return ERR_APPEXECFWK_PARCEL_ERROR;
2432 }
2433 return ERR_OK;
2434 }
2435
HandleGetUidByBundleName(MessageParcel & data,MessageParcel & reply)2436 ErrCode BundleMgrHost::HandleGetUidByBundleName(MessageParcel &data, MessageParcel &reply)
2437 {
2438 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2439 std::string bundleName = data.ReadString();
2440 int32_t userId = data.ReadInt32();
2441 int32_t appIndex = data.ReadInt32();
2442 int32_t uid = GetUidByBundleName(bundleName, userId, appIndex);
2443 APP_LOGD("uid is %{public}d", uid);
2444 if (!reply.WriteInt32(uid)) {
2445 APP_LOGE("write failed");
2446 return ERR_APPEXECFWK_PARCEL_ERROR;
2447 }
2448 return ERR_OK;
2449 }
2450
HandleGetUidByDebugBundleName(MessageParcel & data,MessageParcel & reply)2451 ErrCode BundleMgrHost::HandleGetUidByDebugBundleName(MessageParcel &data, MessageParcel &reply)
2452 {
2453 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2454 std::string bundleName = data.ReadString();
2455 int32_t userId = data.ReadInt32();
2456 int32_t uid = GetUidByDebugBundleName(bundleName, userId);
2457 APP_LOGD("uid is %{public}d", uid);
2458 if (!reply.WriteInt32(uid)) {
2459 APP_LOGE("write failed");
2460 return ERR_APPEXECFWK_PARCEL_ERROR;
2461 }
2462 return ERR_OK;
2463 }
2464
HandleIsModuleRemovable(MessageParcel & data,MessageParcel & reply)2465 ErrCode BundleMgrHost::HandleIsModuleRemovable(MessageParcel &data, MessageParcel &reply)
2466 {
2467 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2468 std::string bundleName = data.ReadString();
2469 std::string moduleName = data.ReadString();
2470
2471 APP_LOGD("bundleName %{public}s, moduleName %{public}s", bundleName.c_str(), moduleName.c_str());
2472 bool isRemovable = false;
2473 ErrCode ret = IsModuleRemovable(bundleName, moduleName, isRemovable);
2474 if (!reply.WriteInt32(ret)) {
2475 APP_LOGE("write ret failed");
2476 return ERR_APPEXECFWK_PARCEL_ERROR;
2477 }
2478 if (!reply.WriteBool(isRemovable)) {
2479 APP_LOGE("write isRemovable failed");
2480 return ERR_APPEXECFWK_PARCEL_ERROR;
2481 }
2482 return ERR_OK;
2483 }
2484
HandleSetModuleRemovable(MessageParcel & data,MessageParcel & reply)2485 ErrCode BundleMgrHost::HandleSetModuleRemovable(MessageParcel &data, MessageParcel &reply)
2486 {
2487 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2488 std::string bundleName = data.ReadString();
2489 std::string moduleName = data.ReadString();
2490 bool isEnable = data.ReadBool();
2491 APP_LOGD("bundleName %{public}s, moduleName %{public}s", bundleName.c_str(), moduleName.c_str());
2492 bool ret = SetModuleRemovable(bundleName, moduleName, isEnable);
2493 if (!reply.WriteBool(ret)) {
2494 APP_LOGE("write failed");
2495 return ERR_APPEXECFWK_PARCEL_ERROR;
2496 }
2497 return ERR_OK;
2498 }
2499
HandleGetModuleUpgradeFlag(MessageParcel & data,MessageParcel & reply)2500 ErrCode BundleMgrHost::HandleGetModuleUpgradeFlag(MessageParcel &data, MessageParcel &reply)
2501 {
2502 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2503 std::string bundleName = data.ReadString();
2504 std::string moduleName = data.ReadString();
2505
2506 APP_LOGD("bundleName %{public}s, moduleName %{public}s", bundleName.c_str(), moduleName.c_str());
2507 bool ret = GetModuleUpgradeFlag(bundleName, moduleName);
2508 if (!reply.WriteBool(ret)) {
2509 APP_LOGE("write failed");
2510 return ERR_APPEXECFWK_PARCEL_ERROR;
2511 }
2512 return ERR_OK;
2513 }
2514
HandleSetModuleUpgradeFlag(MessageParcel & data,MessageParcel & reply)2515 ErrCode BundleMgrHost::HandleSetModuleUpgradeFlag(MessageParcel &data, MessageParcel &reply)
2516 {
2517 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2518 std::string bundleName = data.ReadString();
2519 std::string moduleName = data.ReadString();
2520 int32_t upgradeFlag = data.ReadInt32();
2521 APP_LOGD("bundleName %{public}s, moduleName %{public}s", bundleName.c_str(), moduleName.c_str());
2522 ErrCode ret = SetModuleUpgradeFlag(bundleName, moduleName, upgradeFlag);
2523 if (!reply.WriteInt32(ret)) {
2524 APP_LOGE("write failed");
2525 return ERR_APPEXECFWK_PARCEL_ERROR;
2526 }
2527 return ERR_OK;
2528 }
2529
HandleImplicitQueryInfoByPriority(MessageParcel & data,MessageParcel & reply)2530 ErrCode BundleMgrHost::HandleImplicitQueryInfoByPriority(MessageParcel &data, MessageParcel &reply)
2531 {
2532 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2533 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2534 if (want == nullptr) {
2535 APP_LOGE("ReadParcelable<want> failed");
2536 return ERR_APPEXECFWK_PARCEL_ERROR;
2537 }
2538 int32_t flags = data.ReadInt32();
2539 int32_t userId = data.ReadInt32();
2540 AbilityInfo abilityInfo;
2541 ExtensionAbilityInfo extensionInfo;
2542 bool ret = ImplicitQueryInfoByPriority(*want, flags, userId, abilityInfo, extensionInfo);
2543 if (!reply.WriteBool(ret)) {
2544 APP_LOGE("write failed");
2545 return ERR_APPEXECFWK_PARCEL_ERROR;
2546 }
2547 if (ret) {
2548 if (!reply.WriteParcelable(&abilityInfo)) {
2549 APP_LOGE("write AbilityInfo failed");
2550 return ERR_APPEXECFWK_PARCEL_ERROR;
2551 }
2552 if (!reply.WriteParcelable(&extensionInfo)) {
2553 APP_LOGE("write ExtensionAbilityInfo failed");
2554 return ERR_APPEXECFWK_PARCEL_ERROR;
2555 }
2556 }
2557 return ERR_OK;
2558 }
2559
HandleImplicitQueryInfos(MessageParcel & data,MessageParcel & reply)2560 ErrCode BundleMgrHost::HandleImplicitQueryInfos(MessageParcel &data, MessageParcel &reply)
2561 {
2562 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2563 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2564 if (want == nullptr) {
2565 APP_LOGE("ReadParcelable want failed");
2566 return ERR_APPEXECFWK_PARCEL_ERROR;
2567 }
2568 int32_t flags = data.ReadInt32();
2569 int32_t userId = data.ReadInt32();
2570 bool withDefault = data.ReadBool();
2571 bool findDefaultApp = false;
2572 std::vector<AbilityInfo> abilityInfos;
2573 std::vector<ExtensionAbilityInfo> extensionInfos;
2574 bool ret = ImplicitQueryInfos(*want, flags, userId, withDefault, abilityInfos, extensionInfos, findDefaultApp);
2575 if (!reply.WriteBool(ret)) {
2576 APP_LOGE("WriteBool ret failed");
2577 return ERR_APPEXECFWK_PARCEL_ERROR;
2578 }
2579 if (ret) {
2580 if (!WriteParcelableVector(abilityInfos, reply)) {
2581 APP_LOGE("WriteParcelableVector abilityInfos failed");
2582 return ERR_APPEXECFWK_PARCEL_ERROR;
2583 }
2584 if (!WriteParcelableVector(extensionInfos, reply)) {
2585 APP_LOGE("WriteParcelableVector extensionInfo failed");
2586 return ERR_APPEXECFWK_PARCEL_ERROR;
2587 }
2588 if (!reply.WriteBool(findDefaultApp)) {
2589 APP_LOGE("write findDefaultApp failed");
2590 return ERR_APPEXECFWK_PARCEL_ERROR;
2591 }
2592 }
2593 return ERR_OK;
2594 }
2595
HandleGetAllDependentModuleNames(MessageParcel & data,MessageParcel & reply)2596 ErrCode BundleMgrHost::HandleGetAllDependentModuleNames(MessageParcel &data, MessageParcel &reply)
2597 {
2598 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2599 std::string bundleName = data.ReadString();
2600 std::string moduleName = data.ReadString();
2601 std::vector<std::string> dependentModuleNames;
2602 bool ret = GetAllDependentModuleNames(bundleName, moduleName, dependentModuleNames);
2603 if (!reply.WriteBool(ret)) {
2604 APP_LOGE("write result failed");
2605 return ERR_APPEXECFWK_PARCEL_ERROR;
2606 }
2607 if (ret && !reply.WriteStringVector(dependentModuleNames)) {
2608 APP_LOGE("write dependentModuleNames failed");
2609 return ERR_APPEXECFWK_PARCEL_ERROR;
2610 }
2611 return ERR_OK;
2612 }
2613
HandleGetSandboxBundleInfo(MessageParcel & data,MessageParcel & reply)2614 ErrCode BundleMgrHost::HandleGetSandboxBundleInfo(MessageParcel &data, MessageParcel &reply)
2615 {
2616 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2617 std::string bundleName = data.ReadString();
2618 int32_t appIndex = data.ReadInt32();
2619 int32_t userId = data.ReadInt32();
2620
2621 BundleInfo info;
2622 auto res = GetSandboxBundleInfo(bundleName, appIndex, userId, info);
2623 if (!reply.WriteInt32(res)) {
2624 APP_LOGE("WriteInt32 failed");
2625 return ERR_APPEXECFWK_SANDBOX_INSTALL_WRITE_PARCEL_ERROR;
2626 }
2627 if ((res == ERR_OK) && (!reply.WriteParcelable(&info))) {
2628 return ERR_APPEXECFWK_SANDBOX_INSTALL_WRITE_PARCEL_ERROR;
2629 }
2630 return ERR_OK;
2631 }
2632
HandleObtainCallingBundleName(MessageParcel & data,MessageParcel & reply)2633 ErrCode BundleMgrHost::HandleObtainCallingBundleName(MessageParcel &data, MessageParcel &reply)
2634 {
2635 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2636 std::string bundleName = "";
2637 auto ret = ObtainCallingBundleName(bundleName);
2638 if (!reply.WriteBool(ret)) {
2639 APP_LOGE("write result failed");
2640 return ERR_APPEXECFWK_PARCEL_ERROR;
2641 }
2642 if (ret && !reply.WriteString(bundleName)) {
2643 APP_LOGE("write bundleName failed");
2644 return ERR_APPEXECFWK_PARCEL_ERROR;
2645 }
2646 return ERR_OK;
2647 }
2648
HandleCheckAbilityEnableInstall(MessageParcel & data,MessageParcel & reply)2649 ErrCode BundleMgrHost::HandleCheckAbilityEnableInstall(MessageParcel &data, MessageParcel &reply)
2650 {
2651 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2652 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2653 if (want == nullptr) {
2654 APP_LOGE("ReadParcelable<want> failed");
2655 return ERR_APPEXECFWK_PARCEL_ERROR;
2656 }
2657 int32_t missionId = data.ReadInt32();
2658 int32_t userId = data.ReadInt32();
2659 sptr<IRemoteObject> object = data.ReadRemoteObject();
2660
2661 auto ret = CheckAbilityEnableInstall(*want, missionId, userId, object);
2662 if (!reply.WriteBool(ret)) {
2663 APP_LOGE("write result failed");
2664 return ERR_APPEXECFWK_PARCEL_ERROR;
2665 }
2666
2667 return ERR_OK;
2668 }
2669
HandleGetStringById(MessageParcel & data,MessageParcel & reply)2670 ErrCode BundleMgrHost::HandleGetStringById(MessageParcel &data, MessageParcel &reply)
2671 {
2672 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2673 std::string bundleName = data.ReadString();
2674 std::string moduleName = data.ReadString();
2675 uint32_t resId = data.ReadUint32();
2676 int32_t userId = data.ReadInt32();
2677 std::string localeInfo = data.ReadString();
2678 APP_LOGD("GetStringById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d",
2679 bundleName.c_str(), moduleName.c_str(), resId);
2680 if (bundleName.empty() || moduleName.empty()) {
2681 APP_LOGW("fail to GetStringById due to params empty");
2682 return ERR_INVALID_VALUE;
2683 }
2684 std::string label = GetStringById(bundleName, moduleName, resId, userId, localeInfo);
2685 if (!reply.WriteString(label)) {
2686 APP_LOGE("write failed");
2687 return ERR_APPEXECFWK_PARCEL_ERROR;
2688 }
2689 return ERR_OK;
2690 }
2691
HandleGetIconById(MessageParcel & data,MessageParcel & reply)2692 ErrCode BundleMgrHost::HandleGetIconById(MessageParcel &data, MessageParcel &reply)
2693 {
2694 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2695 std::string bundleName = data.ReadString();
2696 std::string moduleName = data.ReadString();
2697 uint32_t resId = data.ReadUint32();
2698 uint32_t density = data.ReadUint32();
2699 int32_t userId = data.ReadInt32();
2700 APP_LOGD("GetStringById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d, density:%{public}d",
2701 bundleName.c_str(), moduleName.c_str(), resId, density);
2702 if (bundleName.empty() || moduleName.empty()) {
2703 APP_LOGW("fail to GetStringById due to params empty");
2704 return ERR_INVALID_VALUE;
2705 }
2706 std::string label = GetIconById(bundleName, moduleName, resId, density, userId);
2707 if (!reply.WriteString(label)) {
2708 APP_LOGE("write failed");
2709 return ERR_APPEXECFWK_PARCEL_ERROR;
2710 }
2711 return ERR_OK;
2712 }
2713
2714 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
HandleGetDefaultAppProxy(MessageParcel & data,MessageParcel & reply)2715 ErrCode BundleMgrHost::HandleGetDefaultAppProxy(MessageParcel &data, MessageParcel &reply)
2716 {
2717 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2718 sptr<IDefaultApp> defaultAppProxy = GetDefaultAppProxy();
2719 if (defaultAppProxy == nullptr) {
2720 APP_LOGE("defaultAppProxy is nullptr");
2721 return ERR_APPEXECFWK_PARCEL_ERROR;
2722 }
2723
2724 if (!reply.WriteRemoteObject(defaultAppProxy->AsObject())) {
2725 APP_LOGE("WriteRemoteObject failed");
2726 return ERR_APPEXECFWK_PARCEL_ERROR;
2727 }
2728 return ERR_OK;
2729 }
2730 #endif
2731
2732 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL
HandleGetAppControlProxy(MessageParcel & data,MessageParcel & reply)2733 ErrCode BundleMgrHost::HandleGetAppControlProxy(MessageParcel &data, MessageParcel &reply)
2734 {
2735 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2736 sptr<IAppControlMgr> appControlProxy = GetAppControlProxy();
2737 if (appControlProxy == nullptr) {
2738 APP_LOGE("appControlProxy is nullptr");
2739 return ERR_APPEXECFWK_PARCEL_ERROR;
2740 }
2741
2742 if (!reply.WriteRemoteObject(appControlProxy->AsObject())) {
2743 APP_LOGE("WriteRemoteObject failed");
2744 return ERR_APPEXECFWK_PARCEL_ERROR;
2745 }
2746 return ERR_OK;
2747 }
2748 #endif
2749
HandleGetSandboxAbilityInfo(MessageParcel & data,MessageParcel & reply)2750 ErrCode BundleMgrHost::HandleGetSandboxAbilityInfo(MessageParcel &data, MessageParcel &reply)
2751 {
2752 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2753 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2754 if (want == nullptr) {
2755 APP_LOGE("ReadParcelable<want> failed");
2756 return ERR_APPEXECFWK_PARCEL_ERROR;
2757 }
2758
2759 int32_t appIndex = data.ReadInt32();
2760 int32_t flag = data.ReadInt32();
2761 int32_t userId = data.ReadInt32();
2762 AbilityInfo info;
2763 auto res = GetSandboxAbilityInfo(*want, appIndex, flag, userId, info);
2764 if (!reply.WriteInt32(res)) {
2765 APP_LOGE("write result failed");
2766 return ERR_APPEXECFWK_PARCEL_ERROR;
2767 }
2768 if ((res == ERR_OK) && (!reply.WriteParcelable(&info))) {
2769 APP_LOGE("write ability info failed");
2770 return ERR_APPEXECFWK_PARCEL_ERROR;
2771 }
2772 return ERR_OK;
2773 }
2774
HandleGetSandboxExtAbilityInfos(MessageParcel & data,MessageParcel & reply)2775 ErrCode BundleMgrHost::HandleGetSandboxExtAbilityInfos(MessageParcel &data, MessageParcel &reply)
2776 {
2777 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2778 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2779 if (!want) {
2780 APP_LOGE("ReadParcelable<want> failed");
2781 return ERR_APPEXECFWK_PARCEL_ERROR;
2782 }
2783
2784 int32_t appIndex = data.ReadInt32();
2785 int32_t flag = data.ReadInt32();
2786 int32_t userId = data.ReadInt32();
2787 std::vector<ExtensionAbilityInfo> infos;
2788 auto res = GetSandboxExtAbilityInfos(*want, appIndex, flag, userId, infos);
2789 if (!reply.WriteInt32(res)) {
2790 APP_LOGE("write result failed");
2791 return ERR_APPEXECFWK_PARCEL_ERROR;
2792 }
2793 if ((res == ERR_OK) && (!WriteParcelableVector(infos, reply))) {
2794 APP_LOGE("write extension infos failed");
2795 return ERR_APPEXECFWK_PARCEL_ERROR;
2796 }
2797 return ERR_OK;
2798 }
2799
HandleGetSandboxHapModuleInfo(MessageParcel & data,MessageParcel & reply)2800 ErrCode BundleMgrHost::HandleGetSandboxHapModuleInfo(MessageParcel &data, MessageParcel &reply)
2801 {
2802 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2803 std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
2804 if (abilityInfo == nullptr) {
2805 APP_LOGE("ReadParcelable<abilityInfo> failed");
2806 return ERR_APPEXECFWK_PARCEL_ERROR;
2807 }
2808 int32_t appIndex = data.ReadInt32();
2809 int32_t userId = data.ReadInt32();
2810 HapModuleInfo info;
2811 auto res = GetSandboxHapModuleInfo(*abilityInfo, appIndex, userId, info);
2812 if (!reply.WriteInt32(res)) {
2813 APP_LOGE("write failed");
2814 return ERR_APPEXECFWK_PARCEL_ERROR;
2815 }
2816 if ((res == ERR_OK) && (!reply.WriteParcelable(&info))) {
2817 APP_LOGE("write hap module info failed");
2818 return ERR_APPEXECFWK_PARCEL_ERROR;
2819 }
2820 return ERR_OK;
2821 }
2822
HandleGetQuickFixManagerProxy(MessageParcel & data,MessageParcel & reply)2823 ErrCode BundleMgrHost::HandleGetQuickFixManagerProxy(MessageParcel &data, MessageParcel &reply)
2824 {
2825 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2826 sptr<IQuickFixManager> quickFixManagerProxy = GetQuickFixManagerProxy();
2827 if (quickFixManagerProxy == nullptr) {
2828 APP_LOGE("quickFixManagerProxy is nullptr");
2829 return ERR_APPEXECFWK_PARCEL_ERROR;
2830 }
2831
2832 if (!reply.WriteRemoteObject(quickFixManagerProxy->AsObject())) {
2833 APP_LOGE("WriteRemoteObject failed");
2834 return ERR_APPEXECFWK_PARCEL_ERROR;
2835 }
2836 return ERR_OK;
2837 }
2838
HandleVerifySystemApi(MessageParcel & data,MessageParcel & reply)2839 ErrCode BundleMgrHost::HandleVerifySystemApi(MessageParcel &data, MessageParcel &reply)
2840 {
2841 int32_t beginApiVersion = data.ReadInt32();
2842
2843 bool ret = VerifySystemApi(beginApiVersion);
2844 if (!reply.WriteBool(ret)) {
2845 APP_LOGE("write result failed");
2846 return ERR_APPEXECFWK_PARCEL_ERROR;
2847 }
2848 return ERR_OK;
2849 }
2850
2851 template<typename T>
WriteParcelableVector(std::vector<T> & parcelableVector,MessageParcel & reply)2852 bool BundleMgrHost::WriteParcelableVector(std::vector<T> &parcelableVector, MessageParcel &reply)
2853 {
2854 if (!reply.WriteInt32(parcelableVector.size())) {
2855 APP_LOGE("write ParcelableVector failed");
2856 return false;
2857 }
2858
2859 for (auto &parcelable : parcelableVector) {
2860 if (!reply.WriteParcelable(&parcelable)) {
2861 APP_LOGE("write ParcelableVector failed");
2862 return false;
2863 }
2864 }
2865 return true;
2866 }
2867
2868 template<typename T>
WriteVectorToParcelIntelligent(std::vector<T> & parcelableVector,MessageParcel & reply)2869 bool BundleMgrHost::WriteVectorToParcelIntelligent(std::vector<T> &parcelableVector, MessageParcel &reply)
2870 {
2871 Parcel tempParcel;
2872 (void)tempParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
2873 if (!tempParcel.WriteInt32(parcelableVector.size())) {
2874 APP_LOGE("write ParcelableVector failed");
2875 return false;
2876 }
2877
2878 for (auto &parcelable : parcelableVector) {
2879 if (!tempParcel.WriteParcelable(&parcelable)) {
2880 APP_LOGE("write ParcelableVector failed");
2881 return false;
2882 }
2883 }
2884
2885 size_t dataSize = tempParcel.GetDataSize();
2886 if (!reply.WriteInt32(static_cast<int32_t>(dataSize))) {
2887 APP_LOGE("write WriteInt32 failed");
2888 return false;
2889 }
2890
2891 if (!reply.WriteRawData(
2892 reinterpret_cast<uint8_t *>(tempParcel.GetData()), dataSize)) {
2893 APP_LOGE("Failed to write data");
2894 return false;
2895 }
2896
2897 return true;
2898 }
2899
AllocatAshmemNum()2900 int32_t BundleMgrHost::AllocatAshmemNum()
2901 {
2902 std::lock_guard<std::mutex> lock(bundleAshmemMutex_);
2903 return ashmemNum_++;
2904 }
2905
HandleQueryAbilityInfoWithCallback(MessageParcel & data,MessageParcel & reply)2906 ErrCode BundleMgrHost::HandleQueryAbilityInfoWithCallback(MessageParcel &data, MessageParcel &reply)
2907 {
2908 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2909 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2910 if (want == nullptr) {
2911 APP_LOGE("ReadParcelable<want> failed");
2912 return ERR_APPEXECFWK_PARCEL_ERROR;
2913 }
2914 int32_t flags = data.ReadInt32();
2915 int32_t userId = data.ReadInt32();
2916 sptr<IRemoteObject> object = data.ReadRemoteObject();
2917 AbilityInfo info;
2918 bool ret = QueryAbilityInfo(*want, flags, userId, info, object);
2919 if (!reply.WriteBool(ret)) {
2920 APP_LOGE("write ret failed");
2921 return ERR_APPEXECFWK_PARCEL_ERROR;
2922 }
2923 if (ret) {
2924 if (!reply.WriteParcelable(&info)) {
2925 APP_LOGE("write info failed");
2926 return ERR_APPEXECFWK_PARCEL_ERROR;
2927 }
2928 }
2929 return ERR_OK;
2930 }
2931
HandleSilentInstall(MessageParcel & data,MessageParcel & reply)2932 ErrCode BundleMgrHost::HandleSilentInstall(MessageParcel &data, MessageParcel &reply)
2933 {
2934 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2935 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2936 if (want == nullptr) {
2937 APP_LOGE("ReadParcelable<want> failed");
2938 return ERR_APPEXECFWK_PARCEL_ERROR;
2939 }
2940 int32_t userId = data.ReadInt32();
2941 sptr<IRemoteObject> object = data.ReadRemoteObject();
2942 bool ret = SilentInstall(*want, userId, object);
2943 if (!reply.WriteBool(ret)) {
2944 APP_LOGE("write ret failed");
2945 return ERR_APPEXECFWK_PARCEL_ERROR;
2946 }
2947 return ERR_OK;
2948 }
2949
HandleUpgradeAtomicService(MessageParcel & data,MessageParcel & reply)2950 ErrCode BundleMgrHost::HandleUpgradeAtomicService(MessageParcel &data, MessageParcel &reply)
2951 {
2952 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2953 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2954 if (want == nullptr) {
2955 APP_LOGE("read parcelable want failed");
2956 return ERR_APPEXECFWK_PARCEL_ERROR;
2957 }
2958 int32_t userId = data.ReadInt32();
2959 UpgradeAtomicService(*want, userId);
2960 return ERR_OK;
2961 }
2962
HandleGetBundleStats(MessageParcel & data,MessageParcel & reply)2963 ErrCode BundleMgrHost::HandleGetBundleStats(MessageParcel &data, MessageParcel &reply)
2964 {
2965 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2966 std::string bundleName = data.ReadString();
2967 int32_t userId = data.ReadInt32();
2968 int32_t appIndex = data.ReadInt32();
2969 uint32_t statFlag = data.ReadUint32();
2970 std::vector<int64_t> bundleStats;
2971 bool ret = GetBundleStats(bundleName, userId, bundleStats, appIndex, statFlag);
2972 if (!reply.WriteBool(ret)) {
2973 APP_LOGE("write result failed");
2974 return ERR_APPEXECFWK_PARCEL_ERROR;
2975 }
2976 if (ret && !reply.WriteInt64Vector(bundleStats)) {
2977 APP_LOGE("write bundleStats failed");
2978 return ERR_APPEXECFWK_PARCEL_ERROR;
2979 }
2980 return ERR_OK;
2981 }
2982
HandleGetAllBundleStats(MessageParcel & data,MessageParcel & reply)2983 ErrCode BundleMgrHost::HandleGetAllBundleStats(MessageParcel &data, MessageParcel &reply)
2984 {
2985 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
2986 int32_t userId = data.ReadInt32();
2987 std::vector<int64_t> bundleStats;
2988 bool ret = GetAllBundleStats(userId, bundleStats);
2989 if (!reply.WriteBool(ret)) {
2990 APP_LOGE("write result failed");
2991 return ERR_APPEXECFWK_PARCEL_ERROR;
2992 }
2993 if (ret && !reply.WriteInt64Vector(bundleStats)) {
2994 APP_LOGE("write bundleStats failed");
2995 return ERR_APPEXECFWK_PARCEL_ERROR;
2996 }
2997 return ERR_OK;
2998 }
2999
HandleGetMediaData(MessageParcel & data,MessageParcel & reply)3000 ErrCode BundleMgrHost::HandleGetMediaData(MessageParcel &data, MessageParcel &reply)
3001 {
3002 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3003 std::string bundleName = data.ReadString();
3004 std::string abilityName = data.ReadString();
3005 std::string moduleName = data.ReadString();
3006 int32_t userId = data.ReadInt32();
3007 APP_LOGD("HandleGetMediaData:%{public}s, %{public}s, %{public}s", bundleName.c_str(),
3008 abilityName.c_str(), moduleName.c_str());
3009 std::unique_ptr<uint8_t[]> mediaDataPtr = nullptr;
3010 size_t len = 0;
3011 ErrCode ret = GetMediaData(bundleName, moduleName, abilityName, mediaDataPtr, len, userId);
3012 if (!reply.WriteInt32(ret)) {
3013 APP_LOGE("write ret failed");
3014 return ERR_APPEXECFWK_PARCEL_ERROR;
3015 }
3016 if (ret != ERR_OK) {
3017 return ERR_OK;
3018 }
3019 if (mediaDataPtr == nullptr || len == 0) {
3020 return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
3021 }
3022 // write ashMem
3023 sptr<Ashmem> ashMem = Ashmem::CreateAshmem((__func__ + std::to_string(AllocatAshmemNum())).c_str(), len);
3024 if (ashMem == nullptr) {
3025 APP_LOGE("CreateAshmem failed");
3026 return ERR_APPEXECFWK_PARCEL_ERROR;
3027 }
3028 if (!ashMem->MapReadAndWriteAshmem()) {
3029 APP_LOGE("MapReadAndWriteAshmem failed");
3030 ClearAshmem(ashMem);
3031 return ERR_APPEXECFWK_PARCEL_ERROR;
3032 }
3033 int32_t offset = 0;
3034 if (!ashMem->WriteToAshmem(mediaDataPtr.get(), len, offset)) {
3035 APP_LOGE("MapReadAndWriteAshmem failed");
3036 ClearAshmem(ashMem);
3037 return ERR_APPEXECFWK_PARCEL_ERROR;
3038 }
3039 MessageParcel *messageParcel = &reply;
3040 if (messageParcel == nullptr || !messageParcel->WriteAshmem(ashMem)) {
3041 APP_LOGE("WriteAshmem failed");
3042 ClearAshmem(ashMem);
3043 return ERR_APPEXECFWK_PARCEL_ERROR;
3044 }
3045 ClearAshmem(ashMem);
3046 return ERR_OK;
3047 }
3048
HandleSetDebugMode(MessageParcel & data,MessageParcel & reply)3049 ErrCode BundleMgrHost::HandleSetDebugMode(MessageParcel &data, MessageParcel &reply)
3050 {
3051 APP_LOGI("start to process HandleSetDebugMode message");
3052 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3053 bool enable = data.ReadBool();
3054 auto ret = SetDebugMode(enable);
3055 if (ret != ERR_OK) {
3056 APP_LOGE("SetDebugMode failed");
3057 }
3058 if (!reply.WriteInt32(ret)) {
3059 APP_LOGE("write failed");
3060 return ERR_BUNDLEMANAGER_SET_DEBUG_MODE_PARCEL_ERROR;
3061 }
3062 return ERR_OK;
3063 }
3064
HandleGetOverlayManagerProxy(MessageParcel & data,MessageParcel & reply)3065 ErrCode BundleMgrHost::HandleGetOverlayManagerProxy(MessageParcel &data, MessageParcel &reply)
3066 {
3067 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3068 sptr<IOverlayManager> overlayManagerProxy = GetOverlayManagerProxy();
3069 if (overlayManagerProxy == nullptr) {
3070 APP_LOGE("overlayManagerProxy is nullptr");
3071 return ERR_APPEXECFWK_PARCEL_ERROR;
3072 }
3073
3074 if (!reply.WriteRemoteObject(overlayManagerProxy->AsObject())) {
3075 APP_LOGE("WriteRemoteObject failed");
3076 return ERR_APPEXECFWK_PARCEL_ERROR;
3077 }
3078 return ERR_OK;
3079 }
3080
HandleProcessPreload(MessageParcel & data,MessageParcel & reply)3081 ErrCode BundleMgrHost::HandleProcessPreload(MessageParcel &data, MessageParcel &reply)
3082 {
3083 APP_LOGD("start to process HandleProcessPreload message");
3084 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3085 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3086 if (want == nullptr) {
3087 APP_LOGE("ReadParcelable<want> failed");
3088 return ERR_APPEXECFWK_PARCEL_ERROR;
3089 }
3090 auto ret = ProcessPreload(*want);
3091 if (!reply.WriteBool(ret)) {
3092 APP_LOGE("write result failed");
3093 return ERR_APPEXECFWK_PARCEL_ERROR;
3094 }
3095 return ERR_OK;
3096 }
3097
HandleGetAppProvisionInfo(MessageParcel & data,MessageParcel & reply)3098 ErrCode BundleMgrHost::HandleGetAppProvisionInfo(MessageParcel &data, MessageParcel &reply)
3099 {
3100 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3101 std::string bundleName = data.ReadString();
3102 int32_t userId = data.ReadInt32();
3103 AppProvisionInfo appProvisionInfo;
3104 ErrCode ret = GetAppProvisionInfo(bundleName, userId, appProvisionInfo);
3105 if (!reply.WriteInt32(ret)) {
3106 APP_LOGE("HandleGetAppProvisionInfo write failed");
3107 return ERR_APPEXECFWK_PARCEL_ERROR;
3108 }
3109 if ((ret == ERR_OK) && !reply.WriteParcelable(&appProvisionInfo)) {
3110 APP_LOGE("write appProvisionInfo failed");
3111 return ERR_APPEXECFWK_PARCEL_ERROR;
3112 }
3113 return ERR_OK;
3114 }
3115
HandleGetProvisionMetadata(MessageParcel & data,MessageParcel & reply)3116 ErrCode BundleMgrHost::HandleGetProvisionMetadata(MessageParcel &data, MessageParcel &reply)
3117 {
3118 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3119 std::string bundleName = data.ReadString();
3120 int32_t userId = data.ReadInt32();
3121 APP_LOGD("start to get provision metadata, bundleName is %{public}s, userId is %{public}d",
3122 bundleName.c_str(), userId);
3123 std::vector<Metadata> provisionMetadatas;
3124 ErrCode ret = GetProvisionMetadata(bundleName, userId, provisionMetadatas);
3125 if (ret != ERR_OK) {
3126 APP_LOGE("GetProvisionMetadata failed");
3127 }
3128 if (!reply.WriteInt32(ret)) {
3129 APP_LOGE("write failed");
3130 return ERR_APPEXECFWK_PARCEL_ERROR;
3131 }
3132 if (ret == ERR_OK) {
3133 if (!WriteParcelableVector(provisionMetadatas, reply)) {
3134 APP_LOGE("write failed");
3135 return ERR_APPEXECFWK_PARCEL_ERROR;
3136 }
3137 }
3138 return ERR_OK;
3139 }
3140
HandleGetBaseSharedBundleInfos(MessageParcel & data,MessageParcel & reply)3141 ErrCode BundleMgrHost::HandleGetBaseSharedBundleInfos(MessageParcel &data, MessageParcel &reply)
3142 {
3143 APP_LOGD("start to process HandleGetBaseSharedBundleInfos message");
3144 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3145 std::string bundleName = data.ReadString();
3146 GetDependentBundleInfoFlag flag = static_cast<GetDependentBundleInfoFlag>(data.ReadUint32());
3147
3148 std::vector<BaseSharedBundleInfo> infos;
3149 ErrCode ret = GetBaseSharedBundleInfos(bundleName, infos, flag);
3150 if (!reply.WriteInt32(ret)) {
3151 APP_LOGE("write failed");
3152 return ERR_APPEXECFWK_PARCEL_ERROR;
3153 }
3154 if (ret != ERR_OK) {
3155 return ERR_OK;
3156 }
3157 if (!WriteParcelableVector(infos, reply)) {
3158 APP_LOGE("write failed");
3159 return ERR_APPEXECFWK_PARCEL_ERROR;
3160 }
3161 return ERR_OK;
3162 }
3163
HandleGetAllSharedBundleInfo(MessageParcel & data,MessageParcel & reply)3164 ErrCode BundleMgrHost::HandleGetAllSharedBundleInfo(MessageParcel &data, MessageParcel &reply)
3165 {
3166 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3167 std::vector<SharedBundleInfo> infos;
3168 ErrCode ret = GetAllSharedBundleInfo(infos);
3169 if (!reply.WriteInt32(ret)) {
3170 APP_LOGE("HandleGetAllSharedBundleInfo write failed");
3171 return ERR_APPEXECFWK_PARCEL_ERROR;
3172 }
3173 if ((ret == ERR_OK) && !WriteParcelableVector(infos, reply)) {
3174 APP_LOGE("write infos failed");
3175 return ERR_APPEXECFWK_PARCEL_ERROR;
3176 }
3177 return ERR_OK;
3178 }
3179
HandleGetSharedBundleInfo(MessageParcel & data,MessageParcel & reply)3180 ErrCode BundleMgrHost::HandleGetSharedBundleInfo(MessageParcel &data, MessageParcel &reply)
3181 {
3182 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3183 std::string bundleName = data.ReadString();
3184 std::string moduleName = data.ReadString();
3185 std::vector<SharedBundleInfo> infos;
3186 ErrCode ret = GetSharedBundleInfo(bundleName, moduleName, infos);
3187 if (!reply.WriteInt32(ret)) {
3188 APP_LOGE("HandleGetSharedBundleInfo write failed");
3189 return ERR_APPEXECFWK_PARCEL_ERROR;
3190 }
3191 if ((ret == ERR_OK) && !WriteParcelableVector(infos, reply)) {
3192 APP_LOGE("write infos failed");
3193 return ERR_APPEXECFWK_PARCEL_ERROR;
3194 }
3195 return ERR_OK;
3196 }
3197
HandleGetSharedBundleInfoBySelf(MessageParcel & data,MessageParcel & reply)3198 ErrCode BundleMgrHost::HandleGetSharedBundleInfoBySelf(MessageParcel &data, MessageParcel &reply)
3199 {
3200 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3201 std::string bundleName = data.ReadString();
3202 SharedBundleInfo shareBundleInfo;
3203 ErrCode ret = GetSharedBundleInfoBySelf(bundleName, shareBundleInfo);
3204 if (!reply.WriteInt32(ret)) {
3205 APP_LOGE("HandleGetSharedBundleInfoBySelf write failed");
3206 return ERR_APPEXECFWK_PARCEL_ERROR;
3207 }
3208 if ((ret == ERR_OK) && !reply.WriteParcelable(&shareBundleInfo)) {
3209 APP_LOGE("write failed");
3210 return ERR_APPEXECFWK_PARCEL_ERROR;
3211 }
3212 return ERR_OK;
3213 }
3214
HandleGetSharedDependencies(MessageParcel & data,MessageParcel & reply)3215 ErrCode BundleMgrHost::HandleGetSharedDependencies(MessageParcel &data, MessageParcel &reply)
3216 {
3217 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3218 std::string bundleName = data.ReadString();
3219 std::string moduleName = data.ReadString();
3220 std::vector<Dependency> dependencies;
3221 ErrCode ret = GetSharedDependencies(bundleName, moduleName, dependencies);
3222 if (!reply.WriteInt32(ret)) {
3223 APP_LOGE("HandleGetSharedDependencies write failed");
3224 return ERR_APPEXECFWK_PARCEL_ERROR;
3225 }
3226 if ((ret == ERR_OK) && !WriteParcelableVector(dependencies, reply)) {
3227 APP_LOGE("write dependencies failed");
3228 return ERR_APPEXECFWK_PARCEL_ERROR;
3229 }
3230 return ERR_OK;
3231 }
3232
HandleGetProxyDataInfos(MessageParcel & data,MessageParcel & reply)3233 ErrCode BundleMgrHost::HandleGetProxyDataInfos(MessageParcel &data, MessageParcel &reply)
3234 {
3235 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3236 std::string bundleName = data.ReadString();
3237 std::string moduleName = data.ReadString();
3238 int32_t userId = data.ReadInt32();
3239 std::vector<ProxyData> proxyDatas;
3240 ErrCode ret = GetProxyDataInfos(bundleName, moduleName, proxyDatas, userId);
3241 if (!reply.WriteInt32(ret)) {
3242 APP_LOGE("HandleGetProxyDataInfos write failed");
3243 return ERR_APPEXECFWK_PARCEL_ERROR;
3244 }
3245 if ((ret == ERR_OK) && !WriteParcelableVector(proxyDatas, reply)) {
3246 APP_LOGE("write proxyDatas failed");
3247 return ERR_APPEXECFWK_PARCEL_ERROR;
3248 }
3249 return ERR_OK;
3250 }
3251
HandleGetAllProxyDataInfos(MessageParcel & data,MessageParcel & reply)3252 ErrCode BundleMgrHost::HandleGetAllProxyDataInfos(MessageParcel &data, MessageParcel &reply)
3253 {
3254 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3255 std::vector<ProxyData> proxyDatas;
3256 int32_t userId = data.ReadInt32();
3257 ErrCode ret = GetAllProxyDataInfos(proxyDatas, userId);
3258 if (!reply.WriteInt32(ret)) {
3259 APP_LOGE("HandleGetProxyDataInfos write failed");
3260 return ERR_APPEXECFWK_PARCEL_ERROR;
3261 }
3262 if ((ret == ERR_OK) && !WriteParcelableVector(proxyDatas, reply)) {
3263 APP_LOGE("write proxyDatas failed");
3264 return ERR_APPEXECFWK_PARCEL_ERROR;
3265 }
3266 return ERR_OK;
3267 }
3268
HandleGetSpecifiedDistributionType(MessageParcel & data,MessageParcel & reply)3269 ErrCode BundleMgrHost::HandleGetSpecifiedDistributionType(MessageParcel &data, MessageParcel &reply)
3270 {
3271 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3272 std::string bundleName = data.ReadString();
3273 std::string specifiedDistributedType;
3274 ErrCode ret = GetSpecifiedDistributionType(bundleName, specifiedDistributedType);
3275 if (!reply.WriteInt32(ret)) {
3276 APP_LOGE("HandleGetSpecifiedDistributionType write failed");
3277 return ERR_APPEXECFWK_PARCEL_ERROR;
3278 }
3279 if ((ret == ERR_OK) && !reply.WriteString(specifiedDistributedType)) {
3280 APP_LOGE("write specifiedDistributedType failed");
3281 return ERR_APPEXECFWK_PARCEL_ERROR;
3282 }
3283 return ERR_OK;
3284 }
3285
HandleGetAdditionalInfo(MessageParcel & data,MessageParcel & reply)3286 ErrCode BundleMgrHost::HandleGetAdditionalInfo(MessageParcel &data, MessageParcel &reply)
3287 {
3288 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3289 std::string bundleName = data.ReadString();
3290 std::string additionalInfo;
3291 ErrCode ret = GetAdditionalInfo(bundleName, additionalInfo);
3292 if (!reply.WriteInt32(ret)) {
3293 APP_LOGE("HandleGetAdditionalInfo write failed");
3294 return ERR_APPEXECFWK_PARCEL_ERROR;
3295 }
3296 if ((ret == ERR_OK) && !reply.WriteString(additionalInfo)) {
3297 APP_LOGE("write additionalInfo failed");
3298 return ERR_APPEXECFWK_PARCEL_ERROR;
3299 }
3300 return ERR_OK;
3301 }
3302
HandleSetExtNameOrMIMEToApp(MessageParcel & data,MessageParcel & reply)3303 ErrCode BundleMgrHost::HandleSetExtNameOrMIMEToApp(MessageParcel &data, MessageParcel &reply)
3304 {
3305 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3306 std::string bundleName = data.ReadString();
3307 std::string moduleName = data.ReadString();
3308 std::string abilityName = data.ReadString();
3309 std::string extName = data.ReadString();
3310 std::string mimeType = data.ReadString();
3311 ErrCode ret = SetExtNameOrMIMEToApp(bundleName, moduleName, abilityName, extName, mimeType);
3312 if (!reply.WriteInt32(ret)) {
3313 APP_LOGE("HandleSetExtNameOrMIMEToApp write failed");
3314 return ERR_APPEXECFWK_PARCEL_ERROR;
3315 }
3316 return ERR_OK;
3317 }
3318
HandleDelExtNameOrMIMEToApp(MessageParcel & data,MessageParcel & reply)3319 ErrCode BundleMgrHost::HandleDelExtNameOrMIMEToApp(MessageParcel &data, MessageParcel &reply)
3320 {
3321 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3322 std::string bundleName = data.ReadString();
3323 std::string moduleName = data.ReadString();
3324 std::string abilityName = data.ReadString();
3325 std::string extName = data.ReadString();
3326 std::string mimeType = data.ReadString();
3327 ErrCode ret = DelExtNameOrMIMEToApp(bundleName, moduleName, abilityName, extName, mimeType);
3328 if (!reply.WriteInt32(ret)) {
3329 APP_LOGE("HandleDelExtNameOrMIMEToApp write failed");
3330 return ERR_APPEXECFWK_PARCEL_ERROR;
3331 }
3332 return ERR_OK;
3333 }
3334
HandleQueryDataGroupInfos(MessageParcel & data,MessageParcel & reply)3335 ErrCode BundleMgrHost::HandleQueryDataGroupInfos(MessageParcel &data, MessageParcel &reply)
3336 {
3337 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3338 std::string bundleName = data.ReadString();
3339 int32_t userId = data.ReadInt32();
3340
3341 std::vector<DataGroupInfo> infos;
3342 bool ret = QueryDataGroupInfos(bundleName, userId, infos);
3343 if (!reply.WriteBool(ret)) {
3344 APP_LOGE("write failed");
3345 return ERR_APPEXECFWK_PARCEL_ERROR;
3346 }
3347 if (ret && !WriteParcelableVector(infos, reply)) {
3348 APP_LOGE("write dataGroupInfo failed");
3349 return ERR_APPEXECFWK_PARCEL_ERROR;
3350 }
3351 return ERR_OK;
3352 }
3353
HandleGetPreferenceDirByGroupId(MessageParcel & data,MessageParcel & reply)3354 ErrCode BundleMgrHost::HandleGetPreferenceDirByGroupId(MessageParcel &data, MessageParcel &reply)
3355 {
3356 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3357 std::string dataGroupId = data.ReadString();
3358 std::string dir;
3359 bool ret = GetGroupDir(dataGroupId, dir);
3360 if (!reply.WriteBool(ret)) {
3361 APP_LOGE("write failed");
3362 return ERR_APPEXECFWK_PARCEL_ERROR;
3363 }
3364 if (ret) {
3365 if (!reply.WriteString(dir)) {
3366 APP_LOGE("write failed");
3367 return ERR_APPEXECFWK_PARCEL_ERROR;
3368 }
3369 }
3370 return ERR_OK;
3371 }
3372
HandleQueryAppGalleryBundleName(MessageParcel & data,MessageParcel & reply)3373 ErrCode BundleMgrHost::HandleQueryAppGalleryBundleName(MessageParcel &data, MessageParcel &reply)
3374 {
3375 APP_LOGD("QueryAppGalleryBundleName in bundle mgr hoxt start");
3376 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3377 std::string bundleName;
3378 bool ret = QueryAppGalleryBundleName(bundleName);
3379 if (!reply.WriteBool(ret)) {
3380 APP_LOGE("write failed");
3381 return ERR_APPEXECFWK_PARCEL_ERROR;
3382 }
3383 if (ret) {
3384 if (!reply.WriteString(bundleName)) {
3385 APP_LOGE("write failed");
3386 return ERR_APPEXECFWK_PARCEL_ERROR;
3387 }
3388 }
3389 APP_LOGD("BundleName is %{public}s", bundleName.c_str());
3390 return ERR_OK;
3391 }
3392
HandleQueryExtensionAbilityInfosWithTypeName(MessageParcel & data,MessageParcel & reply)3393 ErrCode BundleMgrHost::HandleQueryExtensionAbilityInfosWithTypeName(MessageParcel &data, MessageParcel &reply)
3394 {
3395 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3396 if (want == nullptr) {
3397 APP_LOGE("ReadParcelable<want> failed");
3398 return ERR_APPEXECFWK_PARCEL_ERROR;
3399 }
3400
3401 std::string extensionTypeName = data.ReadString();
3402 int32_t flags = data.ReadInt32();
3403 int32_t userId = data.ReadInt32();
3404 std::vector<ExtensionAbilityInfo> extensionAbilityInfos;
3405 ErrCode ret =
3406 QueryExtensionAbilityInfosWithTypeName(*want, extensionTypeName, flags, userId, extensionAbilityInfos);
3407 if (!reply.WriteInt32(ret)) {
3408 APP_LOGE("Write result failed");
3409 return ERR_APPEXECFWK_PARCEL_ERROR;
3410 }
3411 if (ret == ERR_OK && !WriteParcelableVector(extensionAbilityInfos, reply)) {
3412 APP_LOGE("Write extension infos failed");
3413 return ERR_APPEXECFWK_PARCEL_ERROR;
3414 }
3415 return ERR_OK;
3416 }
3417
HandleQueryExtensionAbilityInfosOnlyWithTypeName(MessageParcel & data,MessageParcel & reply)3418 ErrCode BundleMgrHost::HandleQueryExtensionAbilityInfosOnlyWithTypeName(MessageParcel &data, MessageParcel &reply)
3419 {
3420 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3421 std::string extensionTypeName = data.ReadString();
3422 uint32_t flags = data.ReadUint32();
3423 int32_t userId = data.ReadInt32();
3424 std::vector<ExtensionAbilityInfo> extensionAbilityInfos;
3425 ErrCode ret =
3426 QueryExtensionAbilityInfosOnlyWithTypeName(extensionTypeName, flags, userId, extensionAbilityInfos);
3427 if (!reply.WriteInt32(ret)) {
3428 APP_LOGE("Write result failed");
3429 return ERR_APPEXECFWK_PARCEL_ERROR;
3430 }
3431 if (ret == ERR_OK && !WriteVectorToParcelIntelligent(extensionAbilityInfos, reply)) {
3432 APP_LOGE("Write extension infos failed");
3433 return ERR_APPEXECFWK_PARCEL_ERROR;
3434 }
3435 return ERR_OK;
3436 }
3437
HandleResetAOTCompileStatus(MessageParcel & data,MessageParcel & reply)3438 ErrCode BundleMgrHost::HandleResetAOTCompileStatus(MessageParcel &data, MessageParcel &reply)
3439 {
3440 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3441 std::string bundleName = data.ReadString();
3442 std::string moduleName = data.ReadString();
3443 int32_t triggerMode = data.ReadInt32();
3444 APP_LOGD("bundleName : %{public}s, moduleName : %{public}s, triggerMode : %{public}d",
3445 bundleName.c_str(), moduleName.c_str(), triggerMode);
3446 ErrCode ret = ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
3447 APP_LOGD("ret : %{public}d", ret);
3448 if (!reply.WriteInt32(ret)) {
3449 APP_LOGE("write ret failed");
3450 return ERR_APPEXECFWK_PARCEL_ERROR;
3451 }
3452 return ERR_OK;
3453 }
3454
HandleGetJsonProfile(MessageParcel & data,MessageParcel & reply)3455 ErrCode BundleMgrHost::HandleGetJsonProfile(MessageParcel &data, MessageParcel &reply)
3456 {
3457 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3458 ProfileType profileType = static_cast<ProfileType>(data.ReadInt32());
3459 std::string bundleName = data.ReadString();
3460 std::string moduleName = data.ReadString();
3461 int32_t userId = data.ReadInt32();
3462 std::string profile;
3463 ErrCode ret = GetJsonProfile(profileType, bundleName, moduleName, profile, userId);
3464 if (!reply.WriteInt32(ret)) {
3465 APP_LOGE("write failed");
3466 return ERR_APPEXECFWK_PARCEL_ERROR;
3467 }
3468 if (ret == ERR_OK && WriteBigString(profile, reply) != ERR_OK) {
3469 APP_LOGE("write failed");
3470 return ERR_APPEXECFWK_PARCEL_ERROR;
3471 }
3472 return ERR_OK;
3473 }
3474
HandleGetBundleResourceProxy(MessageParcel & data,MessageParcel & reply)3475 ErrCode BundleMgrHost::HandleGetBundleResourceProxy(MessageParcel &data, MessageParcel &reply)
3476 {
3477 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3478 sptr<IBundleResource> bundleResourceProxy = GetBundleResourceProxy();
3479 if (bundleResourceProxy == nullptr) {
3480 APP_LOGE("bundleResourceProxy is nullptr");
3481 return ERR_APPEXECFWK_PARCEL_ERROR;
3482 }
3483
3484 if (!reply.WriteRemoteObject(bundleResourceProxy->AsObject())) {
3485 APP_LOGE("WriteRemoteObject failed");
3486 return ERR_APPEXECFWK_PARCEL_ERROR;
3487 }
3488 return ERR_OK;
3489 }
3490
HandleGetRecoverableApplicationInfo(MessageParcel & data,MessageParcel & reply)3491 ErrCode BundleMgrHost::HandleGetRecoverableApplicationInfo(MessageParcel &data, MessageParcel &reply)
3492 {
3493 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3494 std::vector<RecoverableApplicationInfo> infos;
3495 ErrCode ret = GetRecoverableApplicationInfo(infos);
3496 if (!reply.WriteInt32(ret)) {
3497 APP_LOGE("HandleGetRecoverableApplicationInfo write failed");
3498 return ERR_APPEXECFWK_PARCEL_ERROR;
3499 }
3500 if ((ret == ERR_OK) && !WriteParcelableVector(infos, reply)) {
3501 APP_LOGE("write infos failed");
3502 return ERR_APPEXECFWK_PARCEL_ERROR;
3503 }
3504 return ERR_OK;
3505 }
3506
HandleGetUninstalledBundleInfo(MessageParcel & data,MessageParcel & reply)3507 ErrCode BundleMgrHost::HandleGetUninstalledBundleInfo(MessageParcel &data, MessageParcel &reply)
3508 {
3509 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3510 std::string name = data.ReadString();
3511 if (name.empty()) {
3512 APP_LOGE("bundleName is empty");
3513 return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
3514 }
3515 BundleInfo info;
3516 reply.SetDataCapacity(Constants::CAPACITY_SIZE);
3517 auto ret = GetUninstalledBundleInfo(name, info);
3518 if (!reply.WriteInt32(ret)) {
3519 APP_LOGE("write failed");
3520 return ERR_APPEXECFWK_PARCEL_ERROR;
3521 }
3522 if (ret == ERR_OK && !reply.WriteParcelable(&info)) {
3523 APP_LOGE("write failed");
3524 return ERR_APPEXECFWK_PARCEL_ERROR;
3525 }
3526 return ERR_OK;
3527 }
3528
HandleSetAdditionalInfo(MessageParcel & data,MessageParcel & reply)3529 ErrCode BundleMgrHost::HandleSetAdditionalInfo(MessageParcel &data, MessageParcel &reply)
3530 {
3531 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3532 std::string bundleName = data.ReadString();
3533 std::string additionalInfo = data.ReadString();
3534 ErrCode ret = SetAdditionalInfo(bundleName, additionalInfo);
3535 if (!reply.WriteInt32(ret)) {
3536 APP_LOGE("Write reply failed");
3537 return ERR_APPEXECFWK_PARCEL_ERROR;
3538 }
3539 return ERR_OK;
3540 }
3541
HandleCreateBundleDataDir(MessageParcel & data,MessageParcel & reply)3542 ErrCode BundleMgrHost::HandleCreateBundleDataDir(MessageParcel &data, MessageParcel &reply)
3543 {
3544 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3545 APP_LOGI("CreateBundleDataDir called");
3546 int32_t userId = data.ReadInt32();
3547 ErrCode ret = CreateBundleDataDir(userId);
3548 if (!reply.WriteInt32(ret)) {
3549 APP_LOGE("Write reply failed");
3550 return ERR_APPEXECFWK_PARCEL_ERROR;
3551 }
3552 return ERR_OK;
3553 }
3554
3555 template<typename T>
WriteParcelableIntoAshmem(T & parcelable,const char * ashmemName,MessageParcel & reply)3556 bool BundleMgrHost::WriteParcelableIntoAshmem(
3557 T &parcelable, const char *ashmemName, MessageParcel &reply)
3558 {
3559 APP_LOGE("Write parcelable into ashmem");
3560 if (ashmemName == nullptr) {
3561 APP_LOGE("AshmemName is null");
3562 return false;
3563 }
3564
3565 MessageParcel *messageParcel = reinterpret_cast<MessageParcel *>(&reply);
3566 if (messageParcel == nullptr) {
3567 APP_LOGE("Type conversion failed");
3568 return false;
3569 }
3570
3571 int32_t totalSize = 0;
3572 auto infoStr = GetJsonStrFromInfo<T>(parcelable);
3573 totalSize += ASHMEM_LEN;
3574 totalSize += strlen(infoStr.c_str());
3575 if (totalSize <= 0) {
3576 APP_LOGE("The size of the ashmem is invalid or the content is empty");
3577 return false;
3578 }
3579
3580 // The ashmem name must be unique.
3581 sptr<Ashmem> ashmem = Ashmem::CreateAshmem(
3582 (ashmemName + std::to_string(AllocatAshmemNum())).c_str(), totalSize);
3583 if (ashmem == nullptr) {
3584 APP_LOGE("Create shared memory failed");
3585 return false;
3586 }
3587
3588 // Set the read/write mode of the ashme.
3589 bool ret = ashmem->MapReadAndWriteAshmem();
3590 if (!ret) {
3591 APP_LOGE("Map shared memory fail");
3592 return false;
3593 }
3594
3595 // Write the size and content of each item to the ashmem.
3596 // The size of item use ASHMEM_LEN.
3597 int32_t offset = 0;
3598 int itemLen = static_cast<int>(strlen(infoStr.c_str()));
3599 ret = ashmem->WriteToAshmem(std::to_string(itemLen).c_str(), ASHMEM_LEN, offset);
3600 if (!ret) {
3601 APP_LOGE("Write itemLen to shared memory fail");
3602 ClearAshmem(ashmem);
3603 return false;
3604 }
3605
3606 offset += ASHMEM_LEN;
3607 ret = ashmem->WriteToAshmem(infoStr.c_str(), itemLen, offset);
3608 if (!ret) {
3609 APP_LOGE("Write info to shared memory fail");
3610 ClearAshmem(ashmem);
3611 return false;
3612 }
3613
3614 ret = messageParcel->WriteAshmem(ashmem);
3615 ClearAshmem(ashmem);
3616 if (!ret) {
3617 APP_LOGE("Write ashmem to MessageParcel fail");
3618 return false;
3619 }
3620
3621 APP_LOGE("Write parcelable vector into ashmem success");
3622 return true;
3623 }
3624
3625 template<typename T>
WriteBigParcelable(T & parcelable,const char * ashmemName,MessageParcel & reply)3626 ErrCode BundleMgrHost::WriteBigParcelable(T &parcelable, const char *ashmemName, MessageParcel &reply)
3627 {
3628 auto size = sizeof(reply);
3629 APP_LOGD("reply size is %{public}lu", static_cast<unsigned long>(size));
3630 bool useAshMem = size > ASHMEM_THRESHOLD;
3631 if (!reply.WriteBool(useAshMem)) {
3632 APP_LOGE("write failed");
3633 return ERR_APPEXECFWK_PARCEL_ERROR;
3634 }
3635 if (useAshMem) {
3636 APP_LOGI("reply size %{public}lu, writing ashmem", static_cast<unsigned long>(size));
3637 if (!WriteParcelableIntoAshmem(parcelable, ashmemName, reply)) {
3638 APP_LOGE("write failed");
3639 return ERR_APPEXECFWK_PARCEL_ERROR;
3640 }
3641 } else {
3642 if (!reply.WriteParcelable(&parcelable)) {
3643 APP_LOGE("write failed");
3644 return ERR_APPEXECFWK_PARCEL_ERROR;
3645 }
3646 }
3647 return ERR_OK;
3648 }
3649
3650 template<typename T>
WriteParcelInfoIntelligent(const T & parcelInfo,MessageParcel & reply) const3651 ErrCode BundleMgrHost::WriteParcelInfoIntelligent(const T &parcelInfo, MessageParcel &reply) const
3652 {
3653 Parcel tmpParcel;
3654 (void)tmpParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
3655 if (!tmpParcel.WriteParcelable(&parcelInfo)) {
3656 APP_LOGE("write parcel failed");
3657 return ERR_APPEXECFWK_PARCEL_ERROR;
3658 }
3659 size_t dataSize = tmpParcel.GetDataSize();
3660 if (!reply.WriteUint32(dataSize)) {
3661 APP_LOGE("write parcel failed");
3662 return ERR_APPEXECFWK_PARCEL_ERROR;
3663 }
3664
3665 if (!reply.WriteRawData(reinterpret_cast<uint8_t *>(tmpParcel.GetData()), dataSize)) {
3666 APP_LOGE("write parcel failed");
3667 return ERR_APPEXECFWK_PARCEL_ERROR;
3668 }
3669 return ERR_OK;
3670 }
3671
3672 template<typename T>
WriteParcelInfo(const T & parcelInfo,MessageParcel & reply) const3673 ErrCode BundleMgrHost::WriteParcelInfo(const T &parcelInfo, MessageParcel &reply) const
3674 {
3675 Parcel tmpParcel;
3676 (void)tmpParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
3677 WRITE_PARCEL(tmpParcel.WriteParcelable(&parcelInfo));
3678 size_t dataSize = tmpParcel.GetDataSize();
3679
3680 WRITE_PARCEL(reply.WriteUint32(dataSize));
3681 WRITE_PARCEL(reply.WriteRawData(reinterpret_cast<uint8_t *>(tmpParcel.GetData()), dataSize));
3682 return ERR_OK;
3683 }
3684
WriteBigString(const std::string & str,MessageParcel & reply) const3685 ErrCode BundleMgrHost::WriteBigString(const std::string &str, MessageParcel &reply) const
3686 {
3687 WRITE_PARCEL(reply.WriteUint32(str.size() + 1));
3688 WRITE_PARCEL(reply.WriteRawData(str.c_str(), str.size() + 1));
3689 return ERR_OK;
3690 }
3691
3692 template<typename T>
ReadParcelInfoIntelligent(MessageParcel & data,T & parcelInfo)3693 ErrCode BundleMgrHost::ReadParcelInfoIntelligent(MessageParcel &data, T &parcelInfo)
3694 {
3695 size_t dataSize = data.ReadUint32();
3696 void *buffer = nullptr;
3697 if (!GetData(buffer, dataSize, data.ReadRawData(dataSize))) {
3698 APP_LOGE("GetData failed dataSize : %{public}zu", dataSize);
3699 return ERR_APPEXECFWK_PARCEL_ERROR;
3700 }
3701 MessageParcel tempParcel;
3702 if (!tempParcel.ParseFrom(reinterpret_cast<uintptr_t>(buffer), dataSize)) {
3703 APP_LOGE("ParseFrom failed");
3704 return ERR_APPEXECFWK_PARCEL_ERROR;
3705 }
3706 std::unique_ptr<T> info(tempParcel.ReadParcelable<T>());
3707 if (info == nullptr) {
3708 APP_LOGE("ReadParcelable failed");
3709 return ERR_APPEXECFWK_PARCEL_ERROR;
3710 }
3711 parcelInfo = *info;
3712 return ERR_OK;
3713 }
3714
HandleCanOpenLink(MessageParcel & data,MessageParcel & reply)3715 ErrCode BundleMgrHost::HandleCanOpenLink(MessageParcel &data, MessageParcel &reply)
3716 {
3717 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3718 std::string link = data.ReadString();
3719 bool canOpen = false;
3720 ErrCode ret = CanOpenLink(link, canOpen);
3721 if (!reply.WriteInt32(ret)) {
3722 APP_LOGE("write failed");
3723 return ERR_APPEXECFWK_PARCEL_ERROR;
3724 }
3725 if (!reply.WriteBool(canOpen)) {
3726 APP_LOGE("write failed");
3727 return ERR_APPEXECFWK_PARCEL_ERROR;
3728 }
3729 return ERR_OK;
3730 }
3731
HandleGetOdid(MessageParcel & data,MessageParcel & reply)3732 ErrCode BundleMgrHost::HandleGetOdid(MessageParcel &data, MessageParcel &reply)
3733 {
3734 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3735 std::string odid;
3736 auto ret = GetOdid(odid);
3737 if (!reply.WriteInt32(ret)) {
3738 APP_LOGE("write failed");
3739 return ERR_APPEXECFWK_PARCEL_ERROR;
3740 }
3741 if (!reply.WriteString(odid)) {
3742 APP_LOGE("write failed");
3743 return ERR_APPEXECFWK_PARCEL_ERROR;
3744 }
3745 APP_LOGD("odid is %{private}s", odid.c_str());
3746 return ERR_OK;
3747 }
3748
HandleGetAllPreinstalledApplicationInfos(MessageParcel & data,MessageParcel & reply)3749 ErrCode BundleMgrHost::HandleGetAllPreinstalledApplicationInfos(MessageParcel &data, MessageParcel &reply)
3750 {
3751 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3752 APP_LOGD("Called");
3753 std::vector<PreinstalledApplicationInfo> preinstalledApplicationInfos;
3754 ErrCode ret = GetAllPreinstalledApplicationInfos(preinstalledApplicationInfos);
3755 int32_t vectorSize = static_cast<int32_t>(preinstalledApplicationInfos.size());
3756 if (vectorSize > MAX_STATUS_VECTOR_NUM) {
3757 APP_LOGE("PreinstallApplicationInfos vector is over size");
3758 return ERR_APPEXECFWK_PARCEL_ERROR;
3759 }
3760
3761 constexpr int32_t VECTOR_SIZE_UNDER_DEFAULT_DATA = 500;
3762 if (vectorSize > VECTOR_SIZE_UNDER_DEFAULT_DATA &&
3763 !reply.SetDataCapacity(PREINSTALL_PARCEL_CAPACITY)) {
3764 APP_LOGE("SetDataCapacity failed");
3765 return ERR_APPEXECFWK_PARCEL_ERROR;
3766 }
3767 if (!reply.WriteInt32(ret)) {
3768 APP_LOGE("Write reply failed");
3769 return ERR_APPEXECFWK_PARCEL_ERROR;
3770 }
3771 if (ret == ERR_OK && !WriteParcelableVector(preinstalledApplicationInfos, reply)) {
3772 APP_LOGE("Write preinstalled app infos failed");
3773 return ERR_APPEXECFWK_PARCEL_ERROR;
3774 }
3775
3776 return ERR_OK;
3777 }
3778
HandleGetAllBundleInfoByDeveloperId(MessageParcel & data,MessageParcel & reply)3779 ErrCode BundleMgrHost::HandleGetAllBundleInfoByDeveloperId(MessageParcel &data, MessageParcel &reply)
3780 {
3781 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3782 std::string developerId = data.ReadString();
3783 int32_t userId = data.ReadInt32();
3784 std::vector<BundleInfo> infos;
3785 auto ret = GetAllBundleInfoByDeveloperId(developerId, infos, userId);
3786 if (!reply.WriteInt32(ret)) {
3787 APP_LOGE("write failed");
3788 return ERR_APPEXECFWK_PARCEL_ERROR;
3789 }
3790 if (ret == ERR_OK) {
3791 if (!WriteVectorToParcelIntelligent(infos, reply)) {
3792 APP_LOGE("write failed");
3793 return ERR_APPEXECFWK_PARCEL_ERROR;
3794 }
3795 }
3796 return ERR_OK;
3797 }
3798
HandleGetDeveloperIds(MessageParcel & data,MessageParcel & reply)3799 ErrCode BundleMgrHost::HandleGetDeveloperIds(MessageParcel &data, MessageParcel &reply)
3800 {
3801 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3802 std::string appDistributionType = data.ReadString();
3803 int32_t userId = data.ReadInt32();
3804 std::vector<std::string> developerIdList;
3805 auto ret = GetDeveloperIds(appDistributionType, developerIdList, userId);
3806 if (!reply.WriteInt32(ret)) {
3807 APP_LOGE("write failed");
3808 return ERR_APPEXECFWK_PARCEL_ERROR;
3809 }
3810 if (ret == ERR_OK) {
3811 if (!reply.WriteStringVector(developerIdList)) {
3812 APP_LOGE("write failed");
3813 return ERR_APPEXECFWK_PARCEL_ERROR;
3814 }
3815 }
3816 return ERR_OK;
3817 }
3818
HandleSwitchUninstallState(MessageParcel & data,MessageParcel & reply)3819 ErrCode BundleMgrHost::HandleSwitchUninstallState(MessageParcel &data, MessageParcel &reply)
3820 {
3821 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3822 std::string bundleName = data.ReadString();
3823 bool state = data.ReadBool();
3824 bool isNeedSendNotify = data.ReadBool();
3825 ErrCode ret = SwitchUninstallState(bundleName, state, isNeedSendNotify);
3826 if (!reply.WriteInt32(ret)) {
3827 APP_LOGE("write failed");
3828 return ERR_APPEXECFWK_PARCEL_ERROR;
3829 }
3830 return ERR_OK;
3831 }
3832
HandleQueryAbilityInfoByContinueType(MessageParcel & data,MessageParcel & reply)3833 ErrCode BundleMgrHost::HandleQueryAbilityInfoByContinueType(MessageParcel &data, MessageParcel &reply)
3834 {
3835 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3836 std::string bundleName = data.ReadString();
3837 std::string continueType = data.ReadString();
3838 int32_t userId = data.ReadInt32();
3839 AbilityInfo abilityInfo;
3840 auto ret = QueryAbilityInfoByContinueType(bundleName, continueType, abilityInfo, userId);
3841 if (!reply.WriteInt32(ret)) {
3842 APP_LOGE("write failed");
3843 return ERR_APPEXECFWK_PARCEL_ERROR;
3844 }
3845 if (ret == ERR_OK && !reply.WriteParcelable(&abilityInfo)) {
3846 APP_LOGE("write failed");
3847 return ERR_APPEXECFWK_PARCEL_ERROR;
3848 }
3849 return ERR_OK;
3850 }
3851
HandleQueryCloneAbilityInfo(MessageParcel & data,MessageParcel & reply)3852 ErrCode BundleMgrHost::HandleQueryCloneAbilityInfo(MessageParcel &data, MessageParcel &reply)
3853 {
3854 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3855
3856 std::unique_ptr<ElementName> elementNamePtr(data.ReadParcelable<ElementName>());
3857 if (!elementNamePtr) {
3858 APP_LOGE("ReadParcelable<ElementName> failed");
3859 return ERR_APPEXECFWK_PARCEL_ERROR;
3860 }
3861
3862 int32_t flags = data.ReadInt32();
3863 int32_t appIndex = data.ReadInt32();
3864 int32_t userId = data.ReadInt32();
3865
3866 AbilityInfo abilityInfo;
3867 auto ret = QueryCloneAbilityInfo(*elementNamePtr, flags, appIndex, abilityInfo, userId);
3868 if (!reply.WriteInt32(ret)) {
3869 APP_LOGE("write failed");
3870 return ERR_APPEXECFWK_PARCEL_ERROR;
3871 }
3872 if (ret == ERR_OK && !reply.WriteParcelable(&abilityInfo)) {
3873 APP_LOGE("write failed");
3874 return ERR_APPEXECFWK_PARCEL_ERROR;
3875 }
3876 return ERR_OK;
3877 }
3878
HandleGetCloneBundleInfo(MessageParcel & data,MessageParcel & reply)3879 ErrCode BundleMgrHost::HandleGetCloneBundleInfo(MessageParcel &data, MessageParcel &reply)
3880 {
3881 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3882 std::string bundleName = data.ReadString();
3883 int32_t flags = data.ReadInt32();
3884 int32_t appIndex = data.ReadInt32();
3885 int32_t userId = data.ReadInt32();
3886
3887 BundleInfo bundleInfo;
3888 auto ret = GetCloneBundleInfo(bundleName, flags, appIndex, bundleInfo, userId);
3889 if (!reply.WriteInt32(ret)) {
3890 APP_LOGE("write failed");
3891 return ERR_APPEXECFWK_PARCEL_ERROR;
3892 }
3893 if (ret == ERR_OK && !reply.WriteParcelable(&bundleInfo)) {
3894 APP_LOGE("write failed");
3895 return ERR_APPEXECFWK_PARCEL_ERROR;
3896 }
3897 return ERR_OK;
3898 }
3899
HandleGetCloneAppIndexes(MessageParcel & data,MessageParcel & reply)3900 ErrCode BundleMgrHost::HandleGetCloneAppIndexes(MessageParcel &data, MessageParcel &reply)
3901 {
3902 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3903 std::string bundleName = data.ReadString();
3904 int32_t userId = data.ReadInt32();
3905
3906 std::vector<int32_t> appIndexes;
3907 auto ret = GetCloneAppIndexes(bundleName, appIndexes, userId);
3908 if (!reply.WriteInt32(ret)) {
3909 APP_LOGE("write failed");
3910 return ERR_APPEXECFWK_PARCEL_ERROR;
3911 }
3912 if (ret == ERR_OK && !reply.WriteInt32Vector(appIndexes)) {
3913 APP_LOGE("write failed");
3914 return ERR_APPEXECFWK_PARCEL_ERROR;
3915 }
3916 return ERR_OK;
3917 }
3918
HandleGetLaunchWant(MessageParcel & data,MessageParcel & reply)3919 ErrCode BundleMgrHost::HandleGetLaunchWant(MessageParcel &data, MessageParcel &reply)
3920 {
3921 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3922 Want want;
3923 ErrCode ret = GetLaunchWant(want);
3924 if (!reply.WriteInt32(ret)) {
3925 APP_LOGE("write failed");
3926 return ERR_APPEXECFWK_PARCEL_ERROR;
3927 }
3928 if (ret == ERR_OK) {
3929 if (!reply.WriteParcelable(&want)) {
3930 APP_LOGE("write failed");
3931 return ERR_APPEXECFWK_PARCEL_ERROR;
3932 }
3933 }
3934 return ERR_OK;
3935 }
3936
HandleQueryCloneExtensionAbilityInfoWithAppIndex(MessageParcel & data,MessageParcel & reply)3937 ErrCode BundleMgrHost::HandleQueryCloneExtensionAbilityInfoWithAppIndex(MessageParcel &data, MessageParcel &reply)
3938 {
3939 std::unique_ptr<ElementName> element(data.ReadParcelable<ElementName>());
3940 if (!element) {
3941 APP_LOGE("ReadParcelable<ElementName> failed");
3942 return ERR_APPEXECFWK_PARCEL_ERROR;
3943 }
3944
3945 int32_t flag = data.ReadInt32();
3946 int32_t appIndex = data.ReadInt32();
3947 int32_t userId = data.ReadInt32();
3948 ExtensionAbilityInfo extensionAbilityInfo;
3949 auto ret = QueryCloneExtensionAbilityInfoWithAppIndex(*element, flag, appIndex, extensionAbilityInfo, userId);
3950 if (!reply.WriteInt32(ret)) {
3951 APP_LOGE("write result failed");
3952 return ERR_APPEXECFWK_PARCEL_ERROR;
3953 }
3954 if (ret == ERR_OK && !reply.WriteParcelable(&extensionAbilityInfo)) {
3955 APP_LOGE("write extension infos failed");
3956 return ERR_APPEXECFWK_PARCEL_ERROR;
3957 }
3958 return ERR_OK;
3959 }
3960
HandleGetSignatureInfoByBundleName(MessageParcel & data,MessageParcel & reply)3961 ErrCode BundleMgrHost::HandleGetSignatureInfoByBundleName(MessageParcel &data, MessageParcel &reply)
3962 {
3963 std::string name = data.ReadString();
3964 SignatureInfo info;
3965 ErrCode ret = GetSignatureInfoByBundleName(name, info);
3966 if (!reply.WriteInt32(ret)) {
3967 APP_LOGE("write failed");
3968 return ERR_APPEXECFWK_PARCEL_ERROR;
3969 }
3970 if (ret == ERR_OK) {
3971 return WriteParcelInfoIntelligent<SignatureInfo>(info, reply);
3972 }
3973 return ret;
3974 }
3975
HandleAddDesktopShortcutInfo(MessageParcel & data,MessageParcel & reply)3976 ErrCode BundleMgrHost::HandleAddDesktopShortcutInfo(MessageParcel &data, MessageParcel &reply)
3977 {
3978 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3979 ShortcutInfo shortcutInfo;
3980 auto ret = ReadParcelInfoIntelligent(data, shortcutInfo);
3981 if (ret != ERR_OK) {
3982 APP_LOGE("Read ParcelInfo failed");
3983 return ERR_APPEXECFWK_PARCEL_ERROR;
3984 }
3985 int32_t userId = data.ReadInt32();
3986 ret = AddDesktopShortcutInfo(shortcutInfo, userId);
3987 if (!reply.WriteInt32(ret)) {
3988 APP_LOGE("Write result failed");
3989 return ERR_APPEXECFWK_PARCEL_ERROR;
3990 }
3991 return ERR_OK;
3992 }
3993
HandleDeleteDesktopShortcutInfo(MessageParcel & data,MessageParcel & reply)3994 ErrCode BundleMgrHost::HandleDeleteDesktopShortcutInfo(MessageParcel &data, MessageParcel &reply)
3995 {
3996 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
3997 ShortcutInfo shortcutInfo;
3998 auto ret = ReadParcelInfoIntelligent(data, shortcutInfo);
3999 if (ret != ERR_OK) {
4000 APP_LOGE("Read ParcelInfo failed");
4001 return ERR_APPEXECFWK_PARCEL_ERROR;
4002 }
4003 int32_t userId = data.ReadInt32();
4004 ret = DeleteDesktopShortcutInfo(shortcutInfo, userId);
4005 if (!reply.WriteInt32(ret)) {
4006 APP_LOGE("Write result failed");
4007 return ERR_APPEXECFWK_PARCEL_ERROR;
4008 }
4009 return ERR_OK;
4010 }
4011
HandleGetAllDesktopShortcutInfo(MessageParcel & data,MessageParcel & reply)4012 ErrCode BundleMgrHost::HandleGetAllDesktopShortcutInfo(MessageParcel &data, MessageParcel &reply)
4013 {
4014 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
4015 int32_t userId = data.ReadInt32();
4016 std::vector<ShortcutInfo> infos;
4017 auto ret = GetAllDesktopShortcutInfo(userId, infos);
4018 if (!reply.WriteInt32(ret)) {
4019 APP_LOGE("Write result failed");
4020 return ERR_APPEXECFWK_PARCEL_ERROR;
4021 }
4022 if (ret == ERR_OK && !WriteVectorToParcelIntelligent(infos, reply)) {
4023 APP_LOGE("Write shortcut infos failed");
4024 return ERR_APPEXECFWK_PARCEL_ERROR;
4025 }
4026 return ERR_OK;
4027 }
4028
HandleGetOdidByBundleName(MessageParcel & data,MessageParcel & reply)4029 ErrCode BundleMgrHost::HandleGetOdidByBundleName(MessageParcel &data, MessageParcel &reply)
4030 {
4031 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
4032 std::string bundleName = data.ReadString();
4033 std::string odid;
4034 auto ret = GetOdidByBundleName(bundleName, odid);
4035 if (!reply.WriteInt32(ret)) {
4036 APP_LOGE("write failed");
4037 return ERR_APPEXECFWK_PARCEL_ERROR;
4038 }
4039 if (!reply.WriteString(odid)) {
4040 APP_LOGE("write failed");
4041 return ERR_APPEXECFWK_PARCEL_ERROR;
4042 }
4043 APP_LOGD("odid is %{private}s", odid.c_str());
4044 return ERR_OK;
4045 }
4046
HandleGetBundleInfosForContinuation(MessageParcel & data,MessageParcel & reply)4047 ErrCode BundleMgrHost::HandleGetBundleInfosForContinuation(MessageParcel &data, MessageParcel &reply)
4048 {
4049 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
4050 int flags = data.ReadInt32();
4051 int userId = data.ReadInt32();
4052
4053 std::vector<BundleInfo> infos;
4054 reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
4055 bool ret = GetBundleInfosForContinuation(flags, infos, userId);
4056 if (!reply.WriteBool(ret)) {
4057 APP_LOGE("write failed");
4058 return ERR_APPEXECFWK_PARCEL_ERROR;
4059 }
4060 if (ret) {
4061 if (!WriteVectorToParcelIntelligent(infos, reply)) {
4062 APP_LOGE("write failed");
4063 return ERR_APPEXECFWK_PARCEL_ERROR;
4064 }
4065 }
4066 return ERR_OK;
4067 }
4068
HandleGetContinueBundleNames(MessageParcel & data,MessageParcel & reply)4069 ErrCode BundleMgrHost::HandleGetContinueBundleNames(MessageParcel &data, MessageParcel &reply)
4070 {
4071 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
4072 std::string continueBundleName = data.ReadString();
4073 int userId = data.ReadInt32();
4074
4075 reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
4076 std::vector<std::string> bundleNames;
4077
4078 auto ret = GetContinueBundleNames(continueBundleName, bundleNames, userId);
4079 if (!reply.WriteInt32(ret)) {
4080 APP_LOGE("GetContinueBundleNames write failed");
4081 return ERR_APPEXECFWK_PARCEL_ERROR;
4082 }
4083 if (ret == ERR_OK && !reply.WriteStringVector(bundleNames)) {
4084 APP_LOGE("Write bundleNames results failed");
4085 return ERR_APPEXECFWK_PARCEL_ERROR;
4086 }
4087 return ERR_OK;
4088 }
4089
HandleIsBundleInstalled(MessageParcel & data,MessageParcel & reply)4090 ErrCode BundleMgrHost::HandleIsBundleInstalled(MessageParcel &data, MessageParcel &reply)
4091 {
4092 HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
4093 std::string bundleName = data.ReadString();
4094 int32_t userId = data.ReadInt32();
4095 int32_t apppIndex = data.ReadInt32();
4096 bool isBundleInstalled = false;
4097 auto ret = IsBundleInstalled(bundleName, userId, apppIndex, isBundleInstalled);
4098 if (!reply.WriteInt32(ret)) {
4099 APP_LOGE("IsBundleInstalled write failed");
4100 return ERR_APPEXECFWK_PARCEL_ERROR;
4101 }
4102 if ((ret == ERR_OK) && !reply.WriteBool(isBundleInstalled)) {
4103 APP_LOGE("Write isInstalled result failed");
4104 return ERR_APPEXECFWK_PARCEL_ERROR;
4105 }
4106 return ERR_OK;
4107 }
4108 } // namespace AppExecFwk
4109 } // namespace OHOS