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 "app_mgr_client.h"
17
18 #include <cstdio>
19 #include <string>
20 #include <unistd.h>
21
22 #include "if_system_ability_manager.h"
23 #include "ipc_skeleton.h"
24
25 #include "app_mem_info.h"
26 #include "app_mgr_interface.h"
27 #include "app_service_manager.h"
28 #include "hilog_tag_wrapper.h"
29 #include "hitrace_meter.h"
30 #include "param.h"
31
32 namespace OHOS {
33 namespace AppExecFwk {
34 class AppMgrRemoteHolder : public std::enable_shared_from_this<AppMgrRemoteHolder> {
35 public:
36 AppMgrRemoteHolder() = default;
37
38 virtual ~AppMgrRemoteHolder() = default;
39
SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)40 void SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)
41 {
42 std::lock_guard<std::mutex> lock(mutex_);
43 serviceManager_ = std::move(serviceMgr);
44 }
45
ConnectAppMgrService()46 AppMgrResultCode ConnectAppMgrService()
47 {
48 std::lock_guard<std::mutex> lock(mutex_);
49 return ConnectAppMgrServiceInner();
50 }
51
GetRemoteObject()52 sptr<IRemoteObject> GetRemoteObject()
53 {
54 std::lock_guard<std::mutex> lock(mutex_);
55 if (!remote_) {
56 (void) ConnectAppMgrServiceInner();
57 }
58 return remote_;
59 }
60
61 private:
HandleRemoteDied(const wptr<IRemoteObject> & remote)62 void HandleRemoteDied(const wptr<IRemoteObject>& remote)
63 {
64 std::lock_guard<std::mutex> lock(mutex_);
65 if (!remote_) {
66 return;
67 }
68
69 if (remote_ == remote.promote()) {
70 remote_->RemoveDeathRecipient(deathRecipient_);
71 remote_ = nullptr;
72 }
73 }
74
ConnectAppMgrServiceInner()75 AppMgrResultCode ConnectAppMgrServiceInner()
76 {
77 if (!serviceManager_) {
78 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
79 }
80 remote_ = serviceManager_->GetAppMgrService();
81 if (!remote_) {
82 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
83 }
84
85 auto me = shared_from_this();
86 deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new AppMgrDeathRecipient(me));
87 if (deathRecipient_ == nullptr) {
88 TAG_LOGE(AAFwkTag::APPMGR, "create AppMgrDeathRecipient failed");
89 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
90 }
91 if ((remote_->IsProxyObject()) && (!remote_->AddDeathRecipient(deathRecipient_))) {
92 TAG_LOGE(AAFwkTag::APPMGR, "AddDeathRecipient to AppMs failed");
93 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
94 }
95
96 return AppMgrResultCode::RESULT_OK;
97 }
98
99 class AppMgrDeathRecipient : public IRemoteObject::DeathRecipient {
100 public:
AppMgrDeathRecipient(const std::shared_ptr<AppMgrRemoteHolder> & holder)101 explicit AppMgrDeathRecipient(const std::shared_ptr<AppMgrRemoteHolder>& holder) : owner_(holder) {}
102
103 virtual ~AppMgrDeathRecipient() = default;
104
OnRemoteDied(const wptr<IRemoteObject> & remote)105 void OnRemoteDied(const wptr<IRemoteObject>& remote) override
106 {
107 std::shared_ptr<AppMgrRemoteHolder> holder = owner_.lock();
108 if (holder) {
109 holder->HandleRemoteDied(remote);
110 }
111 }
112
113 private:
114 std::weak_ptr<AppMgrRemoteHolder> owner_;
115 };
116
117 private:
118 std::unique_ptr<AppServiceManager> serviceManager_;
119 sptr<IRemoteObject> remote_;
120 std::mutex mutex_;
121 sptr<IRemoteObject::DeathRecipient> deathRecipient_;
122 };
123
AppMgrClient()124 AppMgrClient::AppMgrClient()
125 {
126 SetServiceManager(std::make_unique<AppServiceManager>());
127 }
128
~AppMgrClient()129 AppMgrClient::~AppMgrClient()
130 {}
131
LoadAbility(const AbilityInfo & abilityInfo,const ApplicationInfo & appInfo,const AAFwk::Want & want,AbilityRuntime::LoadParam loadParam)132 AppMgrResultCode AppMgrClient::LoadAbility(const AbilityInfo &abilityInfo, const ApplicationInfo &appInfo,
133 const AAFwk::Want &want, AbilityRuntime::LoadParam loadParam)
134 {
135 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
136 if (service != nullptr) {
137 sptr<IAmsMgr> amsService = service->GetAmsMgr();
138 if (amsService != nullptr) {
139 // From here, separate AbilityInfo and ApplicationInfo from AA.
140 std::shared_ptr<AbilityInfo> abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
141 std::shared_ptr<ApplicationInfo> appInfoPtr = std::make_shared<ApplicationInfo>(appInfo);
142 std::shared_ptr<AAFwk::Want> wantPtr = std::make_shared<AAFwk::Want>(want);
143 auto loadParamPtr = std::make_shared<AbilityRuntime::LoadParam>(loadParam);
144 amsService->LoadAbility(abilityInfoPtr, appInfoPtr, wantPtr, loadParamPtr);
145 return AppMgrResultCode::RESULT_OK;
146 }
147 }
148 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
149 }
150
TerminateAbility(const sptr<IRemoteObject> & token,bool clearMissionFlag)151 AppMgrResultCode AppMgrClient::TerminateAbility(const sptr<IRemoteObject> &token, bool clearMissionFlag)
152 {
153 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
154 if (service != nullptr) {
155 sptr<IAmsMgr> amsService = service->GetAmsMgr();
156 if (amsService != nullptr) {
157 amsService->TerminateAbility(token, clearMissionFlag);
158 return AppMgrResultCode::RESULT_OK;
159 }
160 }
161 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
162 }
163
UpdateAbilityState(const sptr<IRemoteObject> & token,const AbilityState state)164 AppMgrResultCode AppMgrClient::UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state)
165 {
166 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
167 if (service != nullptr) {
168 sptr<IAmsMgr> amsService = service->GetAmsMgr();
169 if (amsService != nullptr) {
170 amsService->UpdateAbilityState(token, state);
171 return AppMgrResultCode::RESULT_OK;
172 }
173 }
174 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
175 }
176
UpdateExtensionState(const sptr<IRemoteObject> & token,const ExtensionState state)177 AppMgrResultCode AppMgrClient::UpdateExtensionState(const sptr<IRemoteObject> &token, const ExtensionState state)
178 {
179 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
180 if (service != nullptr) {
181 sptr<IAmsMgr> amsService = service->GetAmsMgr();
182 if (amsService != nullptr) {
183 amsService->UpdateExtensionState(token, state);
184 return AppMgrResultCode::RESULT_OK;
185 }
186 }
187 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
188 }
189
RegisterAppStateCallback(const sptr<IAppStateCallback> & callback)190 AppMgrResultCode AppMgrClient::RegisterAppStateCallback(const sptr<IAppStateCallback> &callback)
191 {
192 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
193 if (service != nullptr) {
194 sptr<IAmsMgr> amsService = service->GetAmsMgr();
195 if (amsService != nullptr) {
196 amsService->RegisterAppStateCallback(callback);
197 return AppMgrResultCode::RESULT_OK;
198 }
199 }
200 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
201 }
202
AbilityBehaviorAnalysis(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & preToken,const int32_t visibility,const int32_t perceptibility,const int32_t connectionState)203 AppMgrResultCode AppMgrClient::AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token,
204 const sptr<IRemoteObject> &preToken, const int32_t visibility, const int32_t perceptibility,
205 const int32_t connectionState)
206 {
207 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
208 if (service != nullptr) {
209 sptr<IAmsMgr> amsService = service->GetAmsMgr();
210 if (amsService != nullptr) {
211 amsService->AbilityBehaviorAnalysis(token, preToken, visibility, perceptibility, connectionState);
212 return AppMgrResultCode::RESULT_OK;
213 }
214 }
215 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
216 }
217
KillProcessByAbilityToken(const sptr<IRemoteObject> & token)218 AppMgrResultCode AppMgrClient::KillProcessByAbilityToken(const sptr<IRemoteObject> &token)
219 {
220 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
221 if (service != nullptr) {
222 sptr<IAmsMgr> amsService = service->GetAmsMgr();
223 if (amsService != nullptr) {
224 amsService->KillProcessByAbilityToken(token);
225 return AppMgrResultCode::RESULT_OK;
226 }
227 }
228 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
229 }
230
KillProcessesByUserId(int32_t userId)231 AppMgrResultCode AppMgrClient::KillProcessesByUserId(int32_t userId)
232 {
233 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
234 if (service != nullptr) {
235 sptr<IAmsMgr> amsService = service->GetAmsMgr();
236 if (amsService != nullptr) {
237 amsService->KillProcessesByUserId(userId);
238 return AppMgrResultCode::RESULT_OK;
239 }
240 }
241 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
242 }
243
KillProcessesByPids(std::vector<int32_t> & pids)244 AppMgrResultCode AppMgrClient::KillProcessesByPids(std::vector<int32_t> &pids)
245 {
246 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
247 if (service != nullptr) {
248 sptr<IAmsMgr> amsService = service->GetAmsMgr();
249 if (amsService != nullptr) {
250 amsService->KillProcessesByPids(pids);
251 return AppMgrResultCode::RESULT_OK;
252 }
253 }
254 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
255 }
256
AttachPidToParent(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & callerToken)257 AppMgrResultCode AppMgrClient::AttachPidToParent(const sptr<IRemoteObject> &token,
258 const sptr<IRemoteObject> &callerToken)
259 {
260 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
261 if (service != nullptr) {
262 sptr<IAmsMgr> amsService = service->GetAmsMgr();
263 if (amsService != nullptr) {
264 amsService->AttachPidToParent(token, callerToken);
265 return AppMgrResultCode::RESULT_OK;
266 }
267 }
268 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
269 }
270
UpdateApplicationInfoInstalled(const std::string & bundleName,const int uid)271 AppMgrResultCode AppMgrClient::UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid)
272 {
273 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
274 if (service != nullptr) {
275 sptr<IAmsMgr> amsService = service->GetAmsMgr();
276 if (amsService != nullptr) {
277 int32_t result = amsService->UpdateApplicationInfoInstalled(bundleName, uid);
278 if (result == ERR_OK) {
279 return AppMgrResultCode::RESULT_OK;
280 }
281 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
282 }
283 }
284 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
285 }
286
KillApplication(const std::string & bundleName,bool const clearPageStack)287 AppMgrResultCode AppMgrClient::KillApplication(const std::string &bundleName, bool const clearPageStack)
288 {
289 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
290 if (service != nullptr) {
291 sptr<IAmsMgr> amsService = service->GetAmsMgr();
292 if (amsService != nullptr) {
293 int32_t result = amsService->KillApplication(bundleName, clearPageStack);
294 if (result == ERR_OK) {
295 return AppMgrResultCode::RESULT_OK;
296 }
297 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
298 }
299 }
300 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
301 }
302
ForceKillApplication(const std::string & bundleName,const int userId,const int appIndex)303 AppMgrResultCode AppMgrClient::ForceKillApplication(const std::string &bundleName,
304 const int userId, const int appIndex)
305 {
306 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
307 if (service != nullptr) {
308 sptr<IAmsMgr> amsService = service->GetAmsMgr();
309 if (amsService != nullptr) {
310 int32_t result = amsService->ForceKillApplication(bundleName, userId, appIndex);
311 if (result == ERR_OK) {
312 return AppMgrResultCode::RESULT_OK;
313 }
314 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
315 }
316 }
317 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
318 }
319
KillProcessesByAccessTokenId(const uint32_t accessTokenId)320 AppMgrResultCode AppMgrClient::KillProcessesByAccessTokenId(const uint32_t accessTokenId)
321 {
322 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
323 if (service != nullptr) {
324 sptr<IAmsMgr> amsService = service->GetAmsMgr();
325 if (amsService != nullptr) {
326 int32_t result = amsService->KillProcessesByAccessTokenId(accessTokenId);
327 if (result == ERR_OK) {
328 return AppMgrResultCode::RESULT_OK;
329 }
330 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
331 }
332 }
333 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
334 }
335
KillApplicationByUid(const std::string & bundleName,const int uid,const std::string & reason)336 AppMgrResultCode AppMgrClient::KillApplicationByUid(const std::string &bundleName, const int uid,
337 const std::string& reason)
338 {
339 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
340 if (service != nullptr) {
341 sptr<IAmsMgr> amsService = service->GetAmsMgr();
342 if (amsService != nullptr) {
343 int32_t result = amsService->KillApplicationByUid(bundleName, uid, reason);
344 if (result == ERR_OK) {
345 return AppMgrResultCode::RESULT_OK;
346 }
347 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
348 }
349 }
350 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
351 }
352
KillApplicationSelf(const bool clearPageStack,const std::string & reason)353 AppMgrResultCode AppMgrClient::KillApplicationSelf(const bool clearPageStack, const std::string& reason)
354 {
355 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
356 if (service != nullptr) {
357 sptr<IAmsMgr> amsService = service->GetAmsMgr();
358 if (amsService != nullptr) {
359 int32_t result = amsService->KillApplicationSelf(clearPageStack, reason);
360 if (result == ERR_OK) {
361 return AppMgrResultCode::RESULT_OK;
362 }
363 return AppMgrResultCode::ERROR_KILL_APPLICATION;
364 }
365 }
366 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
367 }
368
ClearUpApplicationData(const std::string & bundleName,int32_t appCloneIndex,int32_t userId)369 AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleName, int32_t appCloneIndex,
370 int32_t userId)
371 {
372 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
373 if (service != nullptr) {
374 int32_t result = service->ClearUpApplicationData(bundleName, appCloneIndex, userId);
375 if (result == ERR_OK) {
376 return AppMgrResultCode::RESULT_OK;
377 }
378 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
379 }
380 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
381 }
382
ClearUpApplicationDataBySelf(int32_t userId)383 AppMgrResultCode AppMgrClient::ClearUpApplicationDataBySelf(int32_t userId)
384 {
385 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
386 if (service != nullptr) {
387 int32_t result = service->ClearUpApplicationDataBySelf(userId);
388 if (result == ERR_OK) {
389 return AppMgrResultCode::RESULT_OK;
390 }
391 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
392 }
393 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
394 }
395
GetAllRunningProcesses(std::vector<RunningProcessInfo> & info)396 AppMgrResultCode AppMgrClient::GetAllRunningProcesses(std::vector<RunningProcessInfo> &info)
397 {
398 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
399 if (service != nullptr) {
400 int32_t result = service->GetAllRunningProcesses(info);
401 if (result == ERR_OK) {
402 return AppMgrResultCode::RESULT_OK;
403 }
404 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
405 }
406 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
407 }
408
GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> & info,int32_t userId)409 AppMgrResultCode AppMgrClient::GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> &info, int32_t userId)
410 {
411 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
412 if (service != nullptr) {
413 int32_t result = service->GetProcessRunningInfosByUserId(info, userId);
414 if (result == ERR_OK) {
415 return AppMgrResultCode::RESULT_OK;
416 }
417 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
418 }
419 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
420 }
421
GetProcessRunningInformation(AppExecFwk::RunningProcessInfo & info)422 AppMgrResultCode AppMgrClient::GetProcessRunningInformation(AppExecFwk::RunningProcessInfo &info)
423 {
424 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
425 if (service != nullptr) {
426 int32_t result = service->GetProcessRunningInformation(info);
427 if (result == ERR_OK) {
428 return AppMgrResultCode::RESULT_OK;
429 }
430 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
431 }
432 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
433 }
434
GetAllRunningInstanceKeysBySelf(std::vector<std::string> & instanceKeys)435 AppMgrResultCode AppMgrClient::GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys)
436 {
437 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
438 if (service != nullptr) {
439 int32_t result = service->GetAllRunningInstanceKeysBySelf(instanceKeys);
440 if (result == ERR_OK) {
441 return AppMgrResultCode::RESULT_OK;
442 }
443 TAG_LOGE(AAFwkTag::APPMGR, "GetAllRunningInstanceKeysBySelf returns result=%{public}d", result);
444 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
445 }
446 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
447 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
448 }
449
GetAllRunningInstanceKeysByBundleName(const std::string & bundleName,std::vector<std::string> & instanceKeys,int32_t userId)450 AppMgrResultCode AppMgrClient::GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
451 std::vector<std::string> &instanceKeys, int32_t userId)
452 {
453 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
454 if (service != nullptr) {
455 int32_t result = service->GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys, userId);
456 if (result == ERR_OK) {
457 return AppMgrResultCode::RESULT_OK;
458 }
459 TAG_LOGE(AAFwkTag::APPMGR, "GetAllRunningInstanceKeysByBundleName returns result=%{public}d", result);
460 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
461 }
462 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
463 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
464 }
465
GetAllRenderProcesses(std::vector<RenderProcessInfo> & info)466 AppMgrResultCode AppMgrClient::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
467 {
468 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
469 if (service != nullptr) {
470 int32_t result = service->GetAllRenderProcesses(info);
471 if (result == ERR_OK) {
472 return AppMgrResultCode::RESULT_OK;
473 }
474 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
475 }
476 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
477 }
478
GetAllChildrenProcesses(std::vector<ChildProcessInfo> & info)479 AppMgrResultCode AppMgrClient::GetAllChildrenProcesses(std::vector<ChildProcessInfo> &info)
480 {
481 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
482 if (service == nullptr) {
483 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
484 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
485 }
486 int32_t result = service->GetAllChildrenProcesses(info);
487 if (result != ERR_OK) {
488 TAG_LOGE(AAFwkTag::APPMGR, "service->GetAllChildrenProcesses failed,result=%{public}d", result);
489 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
490 }
491 return AppMgrResultCode::RESULT_OK;
492 }
493
NotifyMemoryLevel(MemoryLevel level)494 AppMgrResultCode AppMgrClient::NotifyMemoryLevel(MemoryLevel level)
495 {
496 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
497
498 if (service == nullptr) {
499 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
500 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
501 }
502 return AppMgrResultCode(service->NotifyMemoryLevel(level));
503 }
504
NotifyProcMemoryLevel(const std::map<pid_t,MemoryLevel> & procLevelMap) const505 AppMgrResultCode AppMgrClient::NotifyProcMemoryLevel(const std::map<pid_t, MemoryLevel> &procLevelMap) const
506 {
507 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
508
509 if (service == nullptr) {
510 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
511 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
512 }
513 return AppMgrResultCode(service->NotifyProcMemoryLevel(procLevelMap));
514 }
515
DumpHeapMemory(const int32_t pid,OHOS::AppExecFwk::MallocInfo & mallocInfo)516 AppMgrResultCode AppMgrClient::DumpHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo)
517 {
518 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
519 if (service == nullptr) {
520 TAG_LOGE(AAFwkTag::APPMGR, "DumpHeapMemory: service is nullptr");
521 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
522 }
523 return AppMgrResultCode(service->DumpHeapMemory(pid, mallocInfo));
524 }
525
DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo & info)526 AppMgrResultCode AppMgrClient::DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info)
527 {
528 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
529 if (service == nullptr) {
530 TAG_LOGE(AAFwkTag::APPMGR, "DumpJsHeapMemory: service is nullptr");
531 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
532 }
533 return AppMgrResultCode(service->DumpJsHeapMemory(info));
534 }
535
GetConfiguration(Configuration & config)536 AppMgrResultCode AppMgrClient::GetConfiguration(Configuration& config)
537 {
538 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
539 if (service != nullptr) {
540 int32_t result = service->GetConfiguration(config);
541 if (result == ERR_OK) {
542 return AppMgrResultCode::RESULT_OK;
543 }
544 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
545 }
546 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
547 }
548
ConnectAppMgrService()549 AppMgrResultCode AppMgrClient::ConnectAppMgrService()
550 {
551 if (mgrHolder_) {
552 return mgrHolder_->ConnectAppMgrService();
553 }
554 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
555 }
556
IsProcessContainsOnlyUIAbility(const pid_t pid)557 bool AppMgrClient::IsProcessContainsOnlyUIAbility(const pid_t pid)
558 {
559 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
560 if (service != nullptr) {
561 sptr<IAmsMgr> amsService = service->GetAmsMgr();
562 if (amsService != nullptr) {
563 return amsService->IsProcessContainsOnlyUIAbility(pid);
564 }
565 }
566 return false;
567 }
568
SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)569 void AppMgrClient::SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)
570 {
571 if (!mgrHolder_) {
572 mgrHolder_ = std::make_shared<AppMgrRemoteHolder>();
573 }
574 mgrHolder_->SetServiceManager(std::move(serviceMgr));
575 }
576
AbilityAttachTimeOut(const sptr<IRemoteObject> & token)577 void AppMgrClient::AbilityAttachTimeOut(const sptr<IRemoteObject> &token)
578 {
579 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
580 if (service == nullptr) {
581 return;
582 }
583 sptr<IAmsMgr> amsService = service->GetAmsMgr();
584 if (amsService == nullptr) {
585 return;
586 }
587 amsService->AbilityAttachTimeOut(token);
588 }
589
PrepareTerminate(const sptr<IRemoteObject> & token,bool clearMissionFlag)590 void AppMgrClient::PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag)
591 {
592 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
593 if (service == nullptr) {
594 return;
595 }
596 sptr<IAmsMgr> amsService = service->GetAmsMgr();
597 if (amsService == nullptr) {
598 return;
599 }
600 amsService->PrepareTerminate(token, clearMissionFlag);
601 }
602
GetRunningProcessInfoByToken(const sptr<IRemoteObject> & token,AppExecFwk::RunningProcessInfo & info)603 void AppMgrClient::GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info)
604 {
605 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
606 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
607 if (service != nullptr) {
608 sptr<IAmsMgr> amsService = service->GetAmsMgr();
609 if (amsService != nullptr) {
610 amsService->GetRunningProcessInfoByToken(token, info);
611 }
612 }
613 }
614
GetRunningProcessInfoByPid(const pid_t pid,OHOS::AppExecFwk::RunningProcessInfo & info) const615 int32_t AppMgrClient::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const
616 {
617 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
618 if (service == nullptr) {
619 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
620 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
621 }
622 return service->GetRunningProcessInfoByPid(pid, info);
623 }
624
SetAbilityForegroundingFlagToAppRecord(const pid_t pid) const625 void AppMgrClient::SetAbilityForegroundingFlagToAppRecord(const pid_t pid) const
626 {
627 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
628 if (service != nullptr) {
629 sptr<IAmsMgr> amsService = service->GetAmsMgr();
630 if (amsService != nullptr) {
631 amsService->SetAbilityForegroundingFlagToAppRecord(pid);
632 }
633 }
634 }
635
AddAbilityStageDone(const int32_t recordId)636 void AppMgrClient::AddAbilityStageDone(const int32_t recordId)
637 {
638 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
639 if (service == nullptr) {
640 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
641 return;
642 }
643
644 service->AddAbilityStageDone(recordId);
645 }
646
StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> & bundleInfos)647 void AppMgrClient::StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos)
648 {
649 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
650 if (service == nullptr) {
651 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
652 return;
653 }
654
655 service->StartupResidentProcess(bundleInfos);
656 }
657
StartUserTestProcess(const AAFwk::Want & want,const sptr<IRemoteObject> & observer,const BundleInfo & bundleInfo,int32_t userId)658 int AppMgrClient::StartUserTestProcess(
659 const AAFwk::Want &want, const sptr<IRemoteObject> &observer, const BundleInfo &bundleInfo, int32_t userId)
660 {
661 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
662 if (service == nullptr) {
663 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
664 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
665 }
666 return service->StartUserTestProcess(want, observer, bundleInfo, userId);
667 }
668
FinishUserTest(const std::string & msg,const int64_t & resultCode,const std::string & bundleName)669 int AppMgrClient::FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName)
670 {
671 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
672 if (service == nullptr) {
673 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
674 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
675 }
676 return service->FinishUserTest(msg, resultCode, bundleName);
677 }
678
StartSpecifiedAbility(const AAFwk::Want & want,const AppExecFwk::AbilityInfo & abilityInfo,int32_t requestId)679 void AppMgrClient::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
680 int32_t requestId)
681 {
682 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
683 if (service == nullptr) {
684 return;
685 }
686 sptr<IAmsMgr> amsService = service->GetAmsMgr();
687 if (amsService == nullptr) {
688 return;
689 }
690 amsService->StartSpecifiedAbility(want, abilityInfo, requestId);
691 }
692
SetKeepAliveEnableState(const std::string & bundleName,bool enable,int32_t uid)693 void AppMgrClient::SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid)
694 {
695 if (!IsAmsServiceReady()) {
696 return;
697 }
698 amsService_->SetKeepAliveEnableState(bundleName, enable, uid);
699 }
700
StartSpecifiedProcess(const AAFwk::Want & want,const AppExecFwk::AbilityInfo & abilityInfo,int32_t requestId)701 void AppMgrClient::StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
702 int32_t requestId)
703 {
704 TAG_LOGD(AAFwkTag::APPMGR, "call.");
705 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
706 if (service == nullptr) {
707 return;
708 }
709 sptr<IAmsMgr> amsService = service->GetAmsMgr();
710 if (amsService == nullptr) {
711 return;
712 }
713 amsService->StartSpecifiedProcess(want, abilityInfo, requestId);
714 }
715
RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> & response)716 void AppMgrClient::RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> &response)
717 {
718 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
719 if (service == nullptr) {
720 return;
721 }
722 sptr<IAmsMgr> amsService = service->GetAmsMgr();
723 if (amsService == nullptr) {
724 return;
725 }
726 amsService->RegisterStartSpecifiedAbilityResponse(response);
727 }
728
ScheduleAcceptWantDone(const int32_t recordId,const AAFwk::Want & want,const std::string & flag)729 void AppMgrClient::ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag)
730 {
731 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
732 if (service == nullptr) {
733 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
734 return;
735 }
736
737 service->ScheduleAcceptWantDone(recordId, want, flag);
738 }
739
UpdateConfiguration(const Configuration & config,const int32_t userId)740 AppMgrResultCode AppMgrClient::UpdateConfiguration(const Configuration &config, const int32_t userId)
741 {
742 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
743 if (service == nullptr) {
744 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
745 }
746 service->UpdateConfiguration(config, userId);
747 return AppMgrResultCode::RESULT_OK;
748 }
749
UpdateConfigurationByBundleName(const Configuration & config,const std::string & name)750 AppMgrResultCode AppMgrClient::UpdateConfigurationByBundleName(const Configuration &config, const std::string &name)
751 {
752 if (!mgrHolder_) {
753 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
754 }
755 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
756 if (service == nullptr) {
757 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
758 }
759 service->UpdateConfigurationByBundleName(config, name);
760 return AppMgrResultCode::RESULT_OK;
761 }
762
RegisterConfigurationObserver(const sptr<IConfigurationObserver> & observer)763 AppMgrResultCode AppMgrClient::RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer)
764 {
765 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
766 if (service != nullptr) {
767 int32_t result = service->RegisterConfigurationObserver(observer);
768 if (result == ERR_OK) {
769 return AppMgrResultCode::RESULT_OK;
770 }
771 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
772 }
773 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
774 }
775
UnregisterConfigurationObserver(const sptr<IConfigurationObserver> & observer)776 AppMgrResultCode AppMgrClient::UnregisterConfigurationObserver(const sptr<IConfigurationObserver> &observer)
777 {
778 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
779 if (service != nullptr) {
780 int32_t result = service->UnregisterConfigurationObserver(observer);
781 if (result == ERR_OK) {
782 return AppMgrResultCode::RESULT_OK;
783 }
784 return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
785 }
786 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
787 }
788
GetAbilityRecordsByProcessID(const int pid,std::vector<sptr<IRemoteObject>> & tokens)789 int AppMgrClient::GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens)
790 {
791 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
792 if (service == nullptr) {
793 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
794 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
795 }
796
797 return service->GetAbilityRecordsByProcessID(pid, tokens);
798 }
799
GetApplicationInfoByProcessID(const int pid,AppExecFwk::ApplicationInfo & application,bool & debug)800 int AppMgrClient::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug)
801 {
802 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
803 if (service == nullptr) {
804 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
805 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
806 }
807 sptr<IAmsMgr> amsService = service->GetAmsMgr();
808 if (amsService == nullptr) {
809 TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr");
810 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
811 }
812 return amsService->GetApplicationInfoByProcessID(pid, application, debug);
813 }
814
NotifyAppMgrRecordExitReason(int32_t pid,int32_t reason,const std::string & exitMsg)815 int32_t AppMgrClient::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg)
816 {
817 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
818 if (service == nullptr) {
819 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
820 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
821 }
822 sptr<IAmsMgr> amsService = service->GetAmsMgr();
823 if (amsService == nullptr) {
824 TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr");
825 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
826 }
827 return amsService->NotifyAppMgrRecordExitReason(pid, reason, exitMsg);
828 }
829
StartNativeProcessForDebugger(const AAFwk::Want & want)830 int32_t AppMgrClient::StartNativeProcessForDebugger(const AAFwk::Want &want)
831 {
832 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
833 if (service == nullptr) {
834 TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
835 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
836 }
837 return service->StartNativeProcessForDebugger(want);
838 }
839
PreStartNWebSpawnProcess()840 int AppMgrClient::PreStartNWebSpawnProcess()
841 {
842 TAG_LOGI(AAFwkTag::APPMGR, "PreStartNWebSpawnProcess");
843
844 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
845 if (service != nullptr) {
846 return service->PreStartNWebSpawnProcess();
847 }
848 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
849 }
850
StartRenderProcess(const std::string & renderParam,int32_t ipcFd,int32_t sharedFd,int32_t crashFd,pid_t & renderPid,bool isGPU)851 int AppMgrClient::StartRenderProcess(const std::string &renderParam,
852 int32_t ipcFd, int32_t sharedFd,
853 int32_t crashFd, pid_t &renderPid, bool isGPU)
854 {
855 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
856 if (service != nullptr) {
857 return service->StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd,
858 renderPid, isGPU);
859 }
860 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
861 }
862
AttachRenderProcess(const sptr<IRenderScheduler> & renderScheduler)863 void AppMgrClient::AttachRenderProcess(const sptr<IRenderScheduler> &renderScheduler)
864 {
865 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
866 if (!renderScheduler) {
867 TAG_LOGI(AAFwkTag::APPMGR, "renderScheduler is nullptr");
868 return;
869 }
870
871 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
872 if (service != nullptr) {
873 TAG_LOGI(AAFwkTag::APPMGR, "AttachRenderProcess");
874 service->AttachRenderProcess(renderScheduler->AsObject());
875 }
876 }
877
GetRenderProcessTerminationStatus(pid_t renderPid,int & status)878 int AppMgrClient::GetRenderProcessTerminationStatus(pid_t renderPid, int &status)
879 {
880 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
881 if (service != nullptr) {
882 return service->GetRenderProcessTerminationStatus(renderPid, status);
883 }
884 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
885 }
886
GetRemoteObject()887 sptr<IRemoteObject> AppMgrClient::GetRemoteObject()
888 {
889 return mgrHolder_->GetRemoteObject();
890 }
891
SetCurrentUserId(const int32_t userId)892 void AppMgrClient::SetCurrentUserId(const int32_t userId)
893 {
894 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
895 if (service == nullptr) {
896 return;
897 }
898 sptr<IAmsMgr> amsService = service->GetAmsMgr();
899 if (amsService == nullptr) {
900 return;
901 }
902 amsService->SetCurrentUserId(userId);
903 }
904
SetEnableStartProcessFlagByUserId(int32_t userId,bool enableStartProcess)905 void AppMgrClient::SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess)
906 {
907 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
908 if (service == nullptr) {
909 return;
910 }
911 sptr<IAmsMgr> amsService = service->GetAmsMgr();
912 if (amsService == nullptr) {
913 return;
914 }
915 amsService->SetEnableStartProcessFlagByUserId(userId, enableStartProcess);
916 }
917
GetBundleNameByPid(const int pid,std::string & bundleName,int32_t & uid)918 int32_t AppMgrClient::GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid)
919 {
920 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
921 if (service == nullptr) {
922 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
923 }
924
925 sptr<IAmsMgr> amsService = service->GetAmsMgr();
926 if (amsService != nullptr) {
927 return amsService->GetBundleNameByPid(pid, bundleName, uid);
928 }
929 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
930 }
931
NotifyAppFault(const FaultData & faultData)932 int32_t AppMgrClient::NotifyAppFault(const FaultData &faultData)
933 {
934 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
935 if (service == nullptr) {
936 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
937 }
938 return service->NotifyAppFault(faultData);
939 }
940
NotifyAppFaultBySA(const AppFaultDataBySA & faultData)941 int32_t AppMgrClient::NotifyAppFaultBySA(const AppFaultDataBySA &faultData)
942 {
943 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
944 if (service == nullptr) {
945 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
946 }
947 return service->NotifyAppFaultBySA(faultData);
948 }
949
SetAppFreezeFilter(int32_t pid)950 bool AppMgrClient::SetAppFreezeFilter(int32_t pid)
951 {
952 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
953 if (service == nullptr) {
954 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
955 }
956 return service->SetAppFreezeFilter(pid);
957 }
958
ChangeAppGcState(pid_t pid,int32_t state)959 int32_t AppMgrClient::ChangeAppGcState(pid_t pid, int32_t state)
960 {
961 if (mgrHolder_ == nullptr) {
962 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
963 }
964 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
965 if (service == nullptr) {
966 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
967 }
968 return service->ChangeAppGcState(pid, state);
969 }
970
RegisterAppDebugListener(const sptr<IAppDebugListener> & listener)971 int32_t AppMgrClient::RegisterAppDebugListener(const sptr<IAppDebugListener> &listener)
972 {
973 if (!IsAmsServiceReady()) {
974 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
975 }
976 return amsService_->RegisterAppDebugListener(listener);
977 }
978
UnregisterAppDebugListener(const sptr<IAppDebugListener> & listener)979 int32_t AppMgrClient::UnregisterAppDebugListener(const sptr<IAppDebugListener> &listener)
980 {
981 if (!IsAmsServiceReady()) {
982 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
983 }
984 return amsService_->UnregisterAppDebugListener(listener);
985 }
986
AttachAppDebug(const std::string & bundleName)987 int32_t AppMgrClient::AttachAppDebug(const std::string &bundleName)
988 {
989 if (!IsAmsServiceReady()) {
990 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
991 }
992 return amsService_->AttachAppDebug(bundleName);
993 }
994
DetachAppDebug(const std::string & bundleName)995 int32_t AppMgrClient::DetachAppDebug(const std::string &bundleName)
996 {
997 if (!IsAmsServiceReady()) {
998 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
999 }
1000 return amsService_->DetachAppDebug(bundleName);
1001 }
1002
SetAppWaitingDebug(const std::string & bundleName,bool isPersist)1003 int32_t AppMgrClient::SetAppWaitingDebug(const std::string &bundleName, bool isPersist)
1004 {
1005 if (!IsAmsServiceReady()) {
1006 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready.");
1007 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1008 }
1009 return amsService_->SetAppWaitingDebug(bundleName, isPersist);
1010 }
1011
CancelAppWaitingDebug()1012 int32_t AppMgrClient::CancelAppWaitingDebug()
1013 {
1014 if (!IsAmsServiceReady()) {
1015 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready.");
1016 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1017 }
1018 return amsService_->CancelAppWaitingDebug();
1019 }
1020
GetWaitingDebugApp(std::vector<std::string> & debugInfoList)1021 int32_t AppMgrClient::GetWaitingDebugApp(std::vector<std::string> &debugInfoList)
1022 {
1023 if (!IsAmsServiceReady()) {
1024 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready.");
1025 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1026 }
1027 return amsService_->GetWaitingDebugApp(debugInfoList);
1028 }
1029
IsWaitingDebugApp(const std::string & bundleName)1030 bool AppMgrClient::IsWaitingDebugApp(const std::string &bundleName)
1031 {
1032 if (!IsAmsServiceReady()) {
1033 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready.");
1034 return false;
1035 }
1036 return amsService_->IsWaitingDebugApp(bundleName);
1037 }
1038
ClearNonPersistWaitingDebugFlag()1039 void AppMgrClient::ClearNonPersistWaitingDebugFlag()
1040 {
1041 if (!IsAmsServiceReady()) {
1042 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready.");
1043 return;
1044 }
1045 amsService_->ClearNonPersistWaitingDebugFlag();
1046 }
1047
RegisterAbilityDebugResponse(const sptr<IAbilityDebugResponse> & response)1048 int32_t AppMgrClient::RegisterAbilityDebugResponse(const sptr<IAbilityDebugResponse> &response)
1049 {
1050 if (!IsAmsServiceReady()) {
1051 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1052 }
1053 return amsService_->RegisterAbilityDebugResponse(response);
1054 }
1055
IsAttachDebug(const std::string & bundleName)1056 bool AppMgrClient::IsAttachDebug(const std::string &bundleName)
1057 {
1058 if (!IsAmsServiceReady()) {
1059 return false;
1060 }
1061 return amsService_->IsAttachDebug(bundleName);
1062 }
1063
IsAmsServiceReady()1064 bool AppMgrClient::IsAmsServiceReady()
1065 {
1066 if (mgrHolder_ == nullptr) {
1067 TAG_LOGE(AAFwkTag::APPMGR, "mgrHolder_ is nullptr.");
1068 return false;
1069 }
1070
1071 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1072 if (service == nullptr) {
1073 TAG_LOGE(AAFwkTag::APPMGR, "App manager service is nullptr.");
1074 return false;
1075 }
1076
1077 amsService_ = service->GetAmsMgr();
1078 if (amsService_ == nullptr) {
1079 TAG_LOGE(AAFwkTag::APPMGR, "amsService_ is nullptr.");
1080 return false;
1081 }
1082 return true;
1083 }
1084
RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> & observer,const std::vector<std::string> & bundleNameList)1085 int32_t AppMgrClient::RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer,
1086 const std::vector<std::string> &bundleNameList)
1087 {
1088 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1089 if (service == nullptr) {
1090 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1091 }
1092 return service->RegisterApplicationStateObserver(observer, bundleNameList);
1093 }
1094
UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> & observer)1095 int32_t AppMgrClient::UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer)
1096 {
1097 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1098 if (service == nullptr) {
1099 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1100 }
1101 return service->UnregisterApplicationStateObserver(observer);
1102 }
1103
NotifyPageShow(const sptr<IRemoteObject> & token,const PageStateData & pageStateData)1104 int32_t AppMgrClient::NotifyPageShow(const sptr<IRemoteObject> &token, const PageStateData &pageStateData)
1105 {
1106 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1107 if (service == nullptr) {
1108 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1109 }
1110 return service->NotifyPageShow(token, pageStateData);
1111 }
1112
NotifyPageHide(const sptr<IRemoteObject> & token,const PageStateData & pageStateData)1113 int32_t AppMgrClient::NotifyPageHide(const sptr<IRemoteObject> &token, const PageStateData &pageStateData)
1114 {
1115 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1116 if (service == nullptr) {
1117 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1118 }
1119 return service->NotifyPageHide(token, pageStateData);
1120 }
1121
RegisterAppRunningStatusListener(const sptr<IRemoteObject> & listener)1122 int32_t AppMgrClient::RegisterAppRunningStatusListener(const sptr<IRemoteObject> &listener)
1123 {
1124 if (listener == nullptr) {
1125 TAG_LOGE(AAFwkTag::APPMGR, "Listener is nullptr.");
1126 return ERR_INVALID_DATA;
1127 }
1128
1129 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1130 if (service == nullptr) {
1131 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1132 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1133 }
1134 return service->RegisterAppRunningStatusListener(listener);
1135 }
1136
UnregisterAppRunningStatusListener(const sptr<IRemoteObject> & listener)1137 int32_t AppMgrClient::UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener)
1138 {
1139 if (listener == nullptr) {
1140 TAG_LOGE(AAFwkTag::APPMGR, "Listener is nullptr.");
1141 return ERR_INVALID_DATA;
1142 }
1143
1144 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1145 if (service == nullptr) {
1146 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1147 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1148 }
1149 return service->UnregisterAppRunningStatusListener(listener);
1150 }
1151
ClearProcessByToken(sptr<IRemoteObject> token) const1152 void AppMgrClient::ClearProcessByToken(sptr<IRemoteObject> token) const
1153 {
1154 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1155 if (service == nullptr) {
1156 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1157 return;
1158 }
1159 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1160 if (amsService == nullptr) {
1161 TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr.");
1162 return;
1163 }
1164 amsService->ClearProcessByToken(token);
1165 }
1166
IsFinalAppProcess()1167 bool AppMgrClient::IsFinalAppProcess()
1168 {
1169 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1170 if (service == nullptr) {
1171 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1172 return false;
1173 }
1174 return service->IsFinalAppProcess();
1175 }
1176
RegisterRenderStateObserver(const sptr<IRenderStateObserver> & observer)1177 int32_t AppMgrClient::RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer)
1178 {
1179 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1180 if (service == nullptr) {
1181 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1182 }
1183 return service->RegisterRenderStateObserver(observer);
1184 }
1185
UnregisterRenderStateObserver(const sptr<IRenderStateObserver> & observer)1186 int32_t AppMgrClient::UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer)
1187 {
1188 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1189 if (service == nullptr) {
1190 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1191 }
1192 return service->UnregisterRenderStateObserver(observer);
1193 }
1194
UpdateRenderState(pid_t renderPid,int32_t state)1195 int32_t AppMgrClient::UpdateRenderState(pid_t renderPid, int32_t state)
1196 {
1197 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1198 if (service == nullptr) {
1199 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1200 }
1201 return service->UpdateRenderState(renderPid, state);
1202 }
1203
GetAppRunningUniqueIdByPid(pid_t pid,std::string & appRunningUniqueId)1204 int32_t AppMgrClient::GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId)
1205 {
1206 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1207 if (service == nullptr) {
1208 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1209 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1210 }
1211 return service->GetAppRunningUniqueIdByPid(pid, appRunningUniqueId);
1212 }
1213
GetAllUIExtensionRootHostPid(pid_t pid,std::vector<pid_t> & hostPids)1214 int32_t AppMgrClient::GetAllUIExtensionRootHostPid(pid_t pid, std::vector<pid_t> &hostPids)
1215 {
1216 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1217 if (service == nullptr) {
1218 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1219 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1220 }
1221 return service->GetAllUIExtensionRootHostPid(pid, hostPids);
1222 }
1223
GetAllUIExtensionProviderPid(pid_t hostPid,std::vector<pid_t> & providerPids)1224 int32_t AppMgrClient::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids)
1225 {
1226 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1227 if (service == nullptr) {
1228 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1229 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1230 }
1231 return service->GetAllUIExtensionProviderPid(hostPid, providerPids);
1232 }
1233
NotifyMemorySizeStateChanged(bool isMemorySizeSufficent)1234 int32_t AppMgrClient::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent)
1235 {
1236 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1237 if (service == nullptr) {
1238 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1239 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1240 }
1241 return service->NotifyMemorySizeStateChanged(isMemorySizeSufficent);
1242 }
1243
IsMemorySizeSufficent() const1244 bool AppMgrClient::IsMemorySizeSufficent() const
1245 {
1246 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1247 if (service == nullptr) {
1248 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1249 return true;
1250 }
1251 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1252 if (amsService == nullptr) {
1253 TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr.");
1254 return true;
1255 }
1256 return amsService->IsMemorySizeSufficent();
1257 }
1258
PreloadApplication(const std::string & bundleName,int32_t userId,AppExecFwk::PreloadMode preloadMode,int32_t appIndex)1259 int32_t AppMgrClient::PreloadApplication(const std::string &bundleName, int32_t userId,
1260 AppExecFwk::PreloadMode preloadMode, int32_t appIndex)
1261 {
1262 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1263 if (service == nullptr) {
1264 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1265 }
1266 return service->PreloadApplication(bundleName, userId, preloadMode, appIndex);
1267 }
1268
SetSupportedProcessCacheSelf(bool isSupport)1269 int32_t AppMgrClient::SetSupportedProcessCacheSelf(bool isSupport)
1270 {
1271 TAG_LOGI(AAFwkTag::APPMGR, "Called");
1272 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1273 if (service == nullptr) {
1274 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1275 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1276 }
1277 return service->SetSupportedProcessCacheSelf(isSupport);
1278 }
1279
SetSupportedProcessCache(int32_t pid,bool isSupport)1280 int32_t AppMgrClient::SetSupportedProcessCache(int32_t pid, bool isSupport)
1281 {
1282 TAG_LOGI(AAFwkTag::APPMGR, "Called");
1283 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1284 if (service == nullptr) {
1285 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1286 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1287 }
1288 return service->SetSupportedProcessCache(pid, isSupport);
1289 }
1290
SaveBrowserChannel(sptr<IRemoteObject> browser)1291 void AppMgrClient::SaveBrowserChannel(sptr<IRemoteObject> browser)
1292 {
1293 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1294 if (service == nullptr) {
1295 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1296 return;
1297 }
1298 service->SaveBrowserChannel(browser);
1299 }
1300
CheckCallingIsUserTestMode(const pid_t pid,bool & isUserTest)1301 int32_t AppMgrClient::CheckCallingIsUserTestMode(const pid_t pid, bool &isUserTest)
1302 {
1303 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1304 if (service != nullptr) {
1305 return service->CheckCallingIsUserTestMode(pid, isUserTest);
1306 }
1307 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1308 }
1309
AttachedToStatusBar(const sptr<IRemoteObject> & token)1310 AppMgrResultCode AppMgrClient::AttachedToStatusBar(const sptr<IRemoteObject> &token)
1311 {
1312 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1313 if (service != nullptr) {
1314 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1315 if (amsService != nullptr) {
1316 amsService->AttachedToStatusBar(token);
1317 return AppMgrResultCode::RESULT_OK;
1318 }
1319 }
1320 TAG_LOGE(AAFwkTag::APPMGR, "Service is not connected.");
1321 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1322 }
1323
NotifyProcessDependedOnWeb()1324 int32_t AppMgrClient::NotifyProcessDependedOnWeb()
1325 {
1326 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1327 if (service == nullptr) {
1328 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1329 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1330 }
1331 TAG_LOGD(AAFwkTag::APPMGR, "call");
1332 return service->NotifyProcessDependedOnWeb();
1333 }
1334
KillProcessDependedOnWeb()1335 void AppMgrClient::KillProcessDependedOnWeb()
1336 {
1337 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1338 if (service == nullptr) {
1339 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1340 return;
1341 }
1342 TAG_LOGD(AAFwkTag::APPMGR, "call");
1343 service->KillProcessDependedOnWeb();
1344 }
1345
BlockProcessCacheByPids(const std::vector<int32_t> & pids)1346 AppMgrResultCode AppMgrClient::BlockProcessCacheByPids(const std::vector<int32_t> &pids)
1347 {
1348 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1349 if (service != nullptr) {
1350 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1351 if (amsService != nullptr) {
1352 amsService->BlockProcessCacheByPids(pids);
1353 return AppMgrResultCode::RESULT_OK;
1354 }
1355 }
1356 return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
1357 }
1358
IsKilledForUpgradeWeb(const std::string & bundleName)1359 bool AppMgrClient::IsKilledForUpgradeWeb(const std::string &bundleName)
1360 {
1361 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1362 if (service == nullptr) {
1363 TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
1364 return false;
1365 }
1366 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1367 if (amsService == nullptr) {
1368 TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr.");
1369 return false;
1370 }
1371 TAG_LOGD(AAFwkTag::APPMGR, "call");
1372 return amsService->IsKilledForUpgradeWeb(bundleName);
1373 }
1374
CleanAbilityByUserRequest(const sptr<IRemoteObject> & token)1375 bool AppMgrClient::CleanAbilityByUserRequest(const sptr<IRemoteObject> &token)
1376 {
1377 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1378 if (service == nullptr) {
1379 TAG_LOGE(AAFwkTag::APPMGR, "get appmgrservice is nullptr.");
1380 return false;
1381 }
1382 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1383 if (amsService == nullptr) {
1384 TAG_LOGE(AAFwkTag::APPMGR, "get abilityms service is nullptr.");
1385 return false;
1386 }
1387 TAG_LOGD(AAFwkTag::APPMGR, "call");
1388 return amsService->CleanAbilityByUserRequest(token);
1389 }
1390
IsProcessAttached(sptr<IRemoteObject> token) const1391 bool AppMgrClient::IsProcessAttached(sptr<IRemoteObject> token) const
1392 {
1393 sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
1394 if (service == nullptr) {
1395 return false;
1396 }
1397 sptr<IAmsMgr> amsService = service->GetAmsMgr();
1398 if (amsService == nullptr) {
1399 return false;
1400 }
1401 return amsService->IsProcessAttached(token);
1402 }
1403 } // namespace AppExecFwk
1404 } // namespace OHOS
1405