1 /*
2 * Copyright (c) 2021-2025 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 "ams_mgr_stub.h"
17 #include "ability_manager_errors.h"
18 #include "ability_info.h"
19 #include "app_debug_listener_interface.h"
20 #include "app_mgr_proxy.h"
21 #include "app_scheduler_interface.h"
22 #include "appexecfwk_errors.h"
23 #include "hilog_tag_wrapper.h"
24 #include "hitrace_meter.h"
25 #include "iapp_state_callback.h"
26 #include "ipc_skeleton.h"
27 #include "ipc_types.h"
28 #include "iremote_object.h"
29 #include "param.h"
30 #include "string_ex.h"
31
32 namespace OHOS {
33 namespace AppExecFwk {
34 namespace {
35 constexpr int32_t MAX_APP_DEBUG_COUNT = 100;
36 constexpr int32_t MAX_KILL_PROCESS_PID_COUNT = 100;
37 }
38
AmsMgrStub()39 AmsMgrStub::AmsMgrStub()
40 {
41 CreateMemberFuncMap();
42 }
43
~AmsMgrStub()44 AmsMgrStub::~AmsMgrStub() {}
45
CreateMemberFuncMap()46 void AmsMgrStub::CreateMemberFuncMap() {}
47
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)48 int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
49 {
50 if (code != static_cast<uint32_t>(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID)) {
51 TAG_LOGI(AAFwkTag::APPMGR, "OnReceived, code: %{public}u, flags: %{public}d", code,
52 option.GetFlags());
53 }
54 std::u16string descriptor = AmsMgrStub::GetDescriptor();
55 std::u16string remoteDescriptor = data.ReadInterfaceToken();
56 if (descriptor != remoteDescriptor) {
57 TAG_LOGE(AAFwkTag::APPMGR, "invalid descriptor");
58 return ERR_INVALID_STATE;
59 }
60 return OnRemoteRequestInner(code, data, reply, option);
61 }
62
OnRemoteRequestInner(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)63 int32_t AmsMgrStub::OnRemoteRequestInner(uint32_t code, MessageParcel &data,
64 MessageParcel &reply, MessageOption &option)
65 {
66 int retCode = ERR_OK;
67 retCode = OnRemoteRequestInnerFirst(code, data, reply, option);
68 if (retCode != AAFwk::ERR_CODE_NOT_EXIST) {
69 return retCode;
70 }
71 retCode = OnRemoteRequestInnerSecond(code, data, reply, option);
72 if (retCode != AAFwk::ERR_CODE_NOT_EXIST) {
73 return retCode;
74 }
75 retCode = OnRemoteRequestInnerThird(code, data, reply, option);
76 if (retCode != AAFwk::ERR_CODE_NOT_EXIST) {
77 return retCode;
78 }
79 retCode = OnRemoteRequestInnerFourth(code, data, reply, option);
80 if (retCode != AAFwk::ERR_CODE_NOT_EXIST) {
81 return retCode;
82 }
83 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
84 }
85
OnRemoteRequestInnerFirst(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)86 int32_t AmsMgrStub::OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
87 MessageParcel &reply, MessageOption &option)
88 {
89 switch (static_cast<uint32_t>(code)) {
90 case static_cast<uint32_t>(IAmsMgr::Message::LOAD_ABILITY):
91 return HandleLoadAbility(data, reply);
92 case static_cast<uint32_t>(IAmsMgr::Message::TERMINATE_ABILITY):
93 return HandleTerminateAbility(data, reply);
94 case static_cast<uint32_t>(IAmsMgr::Message::UPDATE_ABILITY_STATE):
95 return HandleUpdateAbilityState(data, reply);
96 case static_cast<uint32_t>(IAmsMgr::Message::UPDATE_EXTENSION_STATE):
97 return HandleUpdateExtensionState(data, reply);
98 case static_cast<uint32_t>(IAmsMgr::Message::REGISTER_APP_STATE_CALLBACK):
99 return HandleRegisterAppStateCallback(data, reply);
100 case static_cast<uint32_t>(IAmsMgr::Message::KILL_PEOCESS_BY_ABILITY_TOKEN):
101 return HandleKillProcessByAbilityToken(data, reply);
102 case static_cast<uint32_t>(IAmsMgr::Message::KILL_PROCESSES_BY_USERID):
103 return HandleKillProcessesByUserId(data, reply);
104 case static_cast<uint32_t>(IAmsMgr::Message::KILL_PROCESS_WITH_ACCOUNT):
105 return HandleKillProcessWithAccount(data, reply);
106 case static_cast<uint32_t>(IAmsMgr::Message::KILL_APPLICATION):
107 return HandleKillApplication(data, reply);
108 case static_cast<uint32_t>(IAmsMgr::Message::ABILITY_ATTACH_TIMEOUT):
109 return HandleAbilityAttachTimeOut(data, reply);
110 case static_cast<uint32_t>(IAmsMgr::Message::PREPARE_TERMINATE_ABILITY):
111 return HandlePrepareTerminate(data, reply);
112 case static_cast<uint32_t>(IAmsMgr::Message::KILL_APPLICATION_BYUID):
113 return HandleKillApplicationByUid(data, reply);
114 case static_cast<uint32_t>(IAmsMgr::Message::KILL_APPLICATION_SELF):
115 return HandleKillApplicationSelf(data, reply);
116 case static_cast<uint32_t>(IAmsMgr::Message::GET_RUNNING_PROCESS_INFO_BY_TOKEN):
117 return HandleGetRunningProcessInfoByToken(data, reply);
118 }
119 return AAFwk::ERR_CODE_NOT_EXIST;
120 }
121
OnRemoteRequestInnerSecond(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)122 int32_t AmsMgrStub::OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data,
123 MessageParcel &reply, MessageOption &option)
124 {
125 switch (static_cast<uint32_t>(code)) {
126 case static_cast<uint32_t>(IAmsMgr::Message::SET_ABILITY_FOREGROUNDING_FLAG):
127 return HandleSetAbilityForegroundingFlagToAppRecord(data, reply);
128 case static_cast<uint32_t>(IAmsMgr::Message::START_SPECIFIED_ABILITY):
129 return HandleStartSpecifiedAbility(data, reply);
130 case static_cast<uint32_t>(IAmsMgr::Message::REGISTER_START_SPECIFIED_ABILITY_RESPONSE):
131 return HandleRegisterStartSpecifiedAbilityResponse(data, reply);
132 case static_cast<uint32_t>(IAmsMgr::Message::GET_APPLICATION_INFO_BY_PROCESS_ID):
133 return HandleGetApplicationInfoByProcessID(data, reply);
134 case static_cast<uint32_t>(IAmsMgr::Message::NOTIFY_APP_MGR_RECORD_EXIT_REASON):
135 return HandleNotifyAppMgrRecordExitReason(data, reply);
136 case static_cast<uint32_t>(IAmsMgr::Message::UPDATE_APPLICATION_INFO_INSTALLED):
137 return HandleUpdateApplicationInfoInstalled(data, reply);
138 case static_cast<uint32_t>(IAmsMgr::Message::SET_CURRENT_USER_ID):
139 return HandleSetCurrentUserId(data, reply);
140 case static_cast<uint32_t>(IAmsMgr::Message::ENABLE_START_PROCESS_FLAG_BY_USER_ID):
141 return HandleSetEnableStartProcessFlagByUserId(data, reply);
142 case static_cast<uint32_t>(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID):
143 return HandleGetBundleNameByPid(data, reply);
144 case static_cast<uint32_t>(IAmsMgr::Message::REGISTER_APP_DEBUG_LISTENER):
145 return HandleRegisterAppDebugListener(data, reply);
146 case static_cast<uint32_t>(IAmsMgr::Message::UNREGISTER_APP_DEBUG_LISTENER):
147 return HandleUnregisterAppDebugListener(data, reply);
148 case static_cast<uint32_t>(IAmsMgr::Message::ATTACH_APP_DEBUG):
149 return HandleAttachAppDebug(data, reply);
150 case static_cast<uint32_t>(IAmsMgr::Message::DETACH_APP_DEBUG):
151 return HandleDetachAppDebug(data, reply);
152 case static_cast<uint32_t>(IAmsMgr::Message::SET_APP_WAITING_DEBUG):
153 return HandleSetAppWaitingDebug(data, reply);
154 case static_cast<uint32_t>(IAmsMgr::Message::CANCEL_APP_WAITING_DEBUG):
155 return HandleCancelAppWaitingDebug(data, reply);
156 case static_cast<uint32_t>(IAmsMgr::Message::GET_WAITING_DEBUG_APP):
157 return HandleGetWaitingDebugApp(data, reply);
158 case static_cast<uint32_t>(IAmsMgr::Message::IS_WAITING_DEBUG_APP):
159 return HandleIsWaitingDebugApp(data, reply);
160 }
161 return AAFwk::ERR_CODE_NOT_EXIST;
162 }
163
OnRemoteRequestInnerThird(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)164 int32_t AmsMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data,
165 MessageParcel &reply, MessageOption &option)
166 {
167 switch (static_cast<uint32_t>(code)) {
168 case static_cast<uint32_t>(IAmsMgr::Message::CLEAR_NON_PERSIST_WAITING_DEBUG_FLAG):
169 return HandleClearNonPersistWaitingDebugFlag(data, reply);
170 case static_cast<uint32_t>(IAmsMgr::Message::REGISTER_ABILITY_DEBUG_RESPONSE):
171 return HandleRegisterAbilityDebugResponse(data, reply);
172 case static_cast<uint32_t>(IAmsMgr::Message::IS_ATTACH_DEBUG):
173 return HandleIsAttachDebug(data, reply);
174 case static_cast<uint32_t>(IAmsMgr::Message::CLEAR_PROCESS_BY_TOKEN):
175 return HandleClearProcessByToken(data, reply);
176 case static_cast<uint32_t>(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS):
177 return HandleKillProcessesByPids(data, reply);
178 case static_cast<uint32_t>(IAmsMgr::Message::ATTACH_PID_TO_PARENT):
179 return HandleAttachPidToParent(data, reply);
180 case static_cast<uint32_t>(IAmsMgr::Message::IS_MEMORY_SIZE_SUFFICIENT):
181 return HandleIsMemorySizeSufficent(data, reply);
182 case static_cast<uint32_t>(IAmsMgr::Message::SET_KEEP_ALIVE_ENABLE_STATE):
183 return HandleSetKeepAliveEnableState(data, reply);
184 case static_cast<uint32_t>(IAmsMgr::Message::ATTACHED_TO_STATUS_BAR):
185 return HandleAttachedToStatusBar(data, reply);
186 case static_cast<uint32_t>(IAmsMgr::Message::UPDATE_CONFIGURATION):
187 return 0;
188 case static_cast<uint32_t>(IAmsMgr::Message::GET_CONFIGURATION):
189 return 0;
190 case static_cast<uint32_t>(IAmsMgr::Message::START_SPECIFIED_PROCESS):
191 return 0;
192 case static_cast<uint32_t>(IAmsMgr::Message::REGISTER_ABILITY_MS_DELEGATE):
193 return 0;
194 case static_cast<uint32_t>(IAmsMgr::Message::BLOCK_PROCESS_CACHE_BY_PIDS):
195 return HandleBlockProcessCacheByPids(data, reply);
196 case static_cast<uint32_t>(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB):
197 return HandleIsKilledForUpgradeWeb(data, reply);
198 case static_cast<uint32_t>(IAmsMgr::Message::PREPARE_TERMINATE_APP):
199 return HandlePrepareTerminateApp(data, reply);
200 }
201 return AAFwk::ERR_CODE_NOT_EXIST;
202 }
203
OnRemoteRequestInnerFourth(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)204 int32_t AmsMgrStub::OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data,
205 MessageParcel &reply, MessageOption &option)
206 {
207 switch (static_cast<uint32_t>(code)) {
208 case static_cast<uint32_t>(IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION):
209 return HandleIsProcessContainsOnlyUIAbility(data, reply);
210 case static_cast<uint32_t>(IAmsMgr::Message::FORCE_KILL_APPLICATION):
211 return HandleForceKillApplication(data, reply);
212 case static_cast<uint32_t>(IAmsMgr::Message::CLEAN_UIABILITY_BY_USER_REQUEST):
213 return HandleCleanAbilityByUserRequest(data, reply);
214 case static_cast<uint32_t>(IAmsMgr::Message::FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID):
215 return HandleKillProcessesByAccessTokenId(data, reply);
216 case static_cast<uint32_t>(IAmsMgr::Message::IS_PROCESS_ATTACHED):
217 return HandleIsProcessAttached(data, reply);
218 case static_cast<uint32_t>(IAmsMgr::Message::IS_CALLER_KILLING):
219 return HandleIsCallerKilling(data, reply);
220 case static_cast<uint32_t>(IAmsMgr::Message::SET_KEEP_ALIVE_DKV):
221 return HandleSetKeepAliveDkv(data, reply);
222 case static_cast<uint32_t>(IAmsMgr::Message::KILL_PROCESSES_IN_BATCH):
223 return HandleKillProcessesInBatch(data, reply);
224 }
225 return AAFwk::ERR_CODE_NOT_EXIST;
226 }
227
HandleLoadAbility(MessageParcel & data,MessageParcel & reply)228 ErrCode AmsMgrStub::HandleLoadAbility(MessageParcel &data, MessageParcel &reply)
229 {
230 HITRACE_METER(HITRACE_TAG_APP);
231 std::shared_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
232 if (!abilityInfo) {
233 TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable<AbilityInfo> failed");
234 return ERR_APPEXECFWK_PARCEL_ERROR;
235 }
236
237 std::shared_ptr<ApplicationInfo> appInfo(data.ReadParcelable<ApplicationInfo>());
238 if (!appInfo) {
239 TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable<ApplicationInfo> failed");
240 return ERR_APPEXECFWK_PARCEL_ERROR;
241 }
242
243 std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
244 if (!want) {
245 TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable want failed");
246 return ERR_APPEXECFWK_PARCEL_ERROR;
247 }
248 std::shared_ptr<AbilityRuntime::LoadParam> loadParam(data.ReadParcelable<AbilityRuntime::LoadParam>());
249 if (!loadParam) {
250 TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable loadParam failed");
251 return ERR_APPEXECFWK_PARCEL_ERROR;
252 }
253
254 LoadAbility(abilityInfo, appInfo, want, loadParam);
255 return NO_ERROR;
256 }
257
HandleTerminateAbility(MessageParcel & data,MessageParcel & reply)258 ErrCode AmsMgrStub::HandleTerminateAbility(MessageParcel &data, MessageParcel &reply)
259 {
260 HITRACE_METER(HITRACE_TAG_APP);
261 sptr<IRemoteObject> token = data.ReadRemoteObject();
262 bool clearMissionFlag = data.ReadBool();
263 TerminateAbility(token, clearMissionFlag);
264 return NO_ERROR;
265 }
266
HandleUpdateAbilityState(MessageParcel & data,MessageParcel & reply)267 ErrCode AmsMgrStub::HandleUpdateAbilityState(MessageParcel &data, MessageParcel &reply)
268 {
269 HITRACE_METER(HITRACE_TAG_APP);
270 sptr<IRemoteObject> token = data.ReadRemoteObject();
271 int32_t state = data.ReadInt32();
272 UpdateAbilityState(token, static_cast<AbilityState>(state));
273 return NO_ERROR;
274 }
275
HandleUpdateExtensionState(MessageParcel & data,MessageParcel & reply)276 ErrCode AmsMgrStub::HandleUpdateExtensionState(MessageParcel &data, MessageParcel &reply)
277 {
278 sptr<IRemoteObject> token = data.ReadRemoteObject();
279 int32_t state = data.ReadInt32();
280 UpdateExtensionState(token, static_cast<ExtensionState>(state));
281 return NO_ERROR;
282 }
283
HandleRegisterAppStateCallback(MessageParcel & data,MessageParcel & reply)284 ErrCode AmsMgrStub::HandleRegisterAppStateCallback(MessageParcel &data, MessageParcel &reply)
285 {
286 HITRACE_METER(HITRACE_TAG_APP);
287 sptr<IAppStateCallback> callback = nullptr;
288 if (data.ReadBool()) {
289 sptr<IRemoteObject> obj = data.ReadRemoteObject();
290 callback = iface_cast<IAppStateCallback>(obj);
291 }
292 RegisterAppStateCallback(callback);
293 return NO_ERROR;
294 }
295
HandleKillProcessByAbilityToken(MessageParcel & data,MessageParcel & reply)296 ErrCode AmsMgrStub::HandleKillProcessByAbilityToken(MessageParcel &data, MessageParcel &reply)
297 {
298 HITRACE_METER(HITRACE_TAG_APP);
299 sptr<IRemoteObject> token = data.ReadRemoteObject();
300
301 KillProcessByAbilityToken(token);
302 return NO_ERROR;
303 }
304
HandleKillProcessesByUserId(MessageParcel & data,MessageParcel & reply)305 ErrCode AmsMgrStub::HandleKillProcessesByUserId(MessageParcel &data, MessageParcel &reply)
306 {
307 HITRACE_METER(HITRACE_TAG_APP);
308 int32_t userId = data.ReadInt32();
309 sptr<AAFwk::IUserCallback> callback = nullptr;
310 bool isWithCallback = data.ReadBool();
311 if (isWithCallback) {
312 callback = iface_cast<AAFwk::IUserCallback>(data.ReadRemoteObject());
313 }
314
315 KillProcessesByUserId(userId, callback);
316 return NO_ERROR;
317 }
318
HandleKillProcessesByPids(MessageParcel & data,MessageParcel & reply)319 ErrCode AmsMgrStub::HandleKillProcessesByPids(MessageParcel &data, MessageParcel &reply)
320 {
321 HITRACE_METER(HITRACE_TAG_APP);
322 auto size = data.ReadUint32();
323 if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) {
324 TAG_LOGE(AAFwkTag::APPMGR, "Invalid size");
325 return ERR_INVALID_VALUE;
326 }
327 std::vector<int32_t> pids;
328 for (uint32_t i = 0; i < size; i++) {
329 pids.emplace_back(data.ReadInt32());
330 }
331 std::string reason = data.ReadString();
332
333 KillProcessesByPids(pids, reason);
334 return NO_ERROR;
335 }
336
HandleAttachPidToParent(MessageParcel & data,MessageParcel & reply)337 ErrCode AmsMgrStub::HandleAttachPidToParent(MessageParcel &data, MessageParcel &reply)
338 {
339 HITRACE_METER(HITRACE_TAG_APP);
340 sptr<IRemoteObject> token = data.ReadRemoteObject();
341 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
342 AttachPidToParent(token, callerToken);
343 return NO_ERROR;
344 }
345
HandleKillProcessWithAccount(MessageParcel & data,MessageParcel & reply)346 ErrCode AmsMgrStub::HandleKillProcessWithAccount(MessageParcel &data, MessageParcel &reply)
347 {
348 TAG_LOGI(AAFwkTag::APPMGR, "enter");
349
350 HITRACE_METER(HITRACE_TAG_APP);
351
352 std::string bundleName = data.ReadString();
353 int accountId = data.ReadInt32();
354 bool clearPageStack = data.ReadBool();
355 auto appIndex = data.ReadInt32();
356
357 TAG_LOGI(AAFwkTag::APPMGR,
358 "bundleName = %{public}s, accountId = %{public}d, clearPageStack = %{public}d",
359 bundleName.c_str(), accountId, clearPageStack);
360
361 int32_t result = KillProcessWithAccount(bundleName, accountId, clearPageStack, appIndex);
362 reply.WriteInt32(result);
363
364 TAG_LOGI(AAFwkTag::APPMGR, "end");
365
366 return NO_ERROR;
367 }
368
HandleKillProcessesInBatch(MessageParcel & data,MessageParcel & reply)369 ErrCode AmsMgrStub::HandleKillProcessesInBatch(MessageParcel &data, MessageParcel &reply)
370 {
371 TAG_LOGI(AAFwkTag::APPMGR, "enter");
372
373 HITRACE_METER(HITRACE_TAG_APP);
374
375 auto size = data.ReadUint32();
376 TAG_LOGI(AAFwkTag::APPMGR, "pids.size=%{public}d", size);
377 if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) {
378 TAG_LOGE(AAFwkTag::APPMGR, "Invalid size");
379 return ERR_INVALID_VALUE;
380 }
381 std::vector<int32_t> pids;
382 for (uint32_t i = 0; i < size; i++) {
383 pids.emplace_back(data.ReadInt32());
384 }
385
386 int32_t result = KillProcessesInBatch(pids);
387 reply.WriteInt32(result);
388
389 TAG_LOGI(AAFwkTag::APPMGR, "end");
390
391 return NO_ERROR;
392 }
393
HandleKillApplication(MessageParcel & data,MessageParcel & reply)394 ErrCode AmsMgrStub::HandleKillApplication(MessageParcel &data, MessageParcel &reply)
395 {
396 HITRACE_METER(HITRACE_TAG_APP);
397 std::string bundleName = data.ReadString();
398 bool clearPageStack = data.ReadBool();
399 auto appIndex = data.ReadInt32();
400
401 TAG_LOGW(AAFwkTag::APPMGR,
402 "KillApplication,callingPid=%{public}d,bundleName=%{public}s,clearPageStack=%{public}d",
403 IPCSkeleton::GetCallingPid(), bundleName.c_str(), clearPageStack);
404
405 int32_t result = KillApplication(bundleName, clearPageStack, appIndex);
406 reply.WriteInt32(result);
407 return NO_ERROR;
408 }
409
HandleForceKillApplication(MessageParcel & data,MessageParcel & reply)410 ErrCode AmsMgrStub::HandleForceKillApplication(MessageParcel &data, MessageParcel &reply)
411 {
412 HITRACE_METER(HITRACE_TAG_APP);
413 std::string bundleName = data.ReadString();
414 int userId = data.ReadInt32();
415 int appIndex = data.ReadInt32();
416
417 TAG_LOGI(AAFwkTag::APPMGR, "bundleName = %{public}s,userId=%{public}d,appIndex=%{public}d",
418 bundleName.c_str(), userId, appIndex);
419
420 int32_t result = ForceKillApplication(bundleName, userId, appIndex);
421 reply.WriteInt32(result);
422 return NO_ERROR;
423 }
424
HandleKillProcessesByAccessTokenId(MessageParcel & data,MessageParcel & reply)425 ErrCode AmsMgrStub::HandleKillProcessesByAccessTokenId(MessageParcel &data, MessageParcel &reply)
426 {
427 HITRACE_METER(HITRACE_TAG_APP);
428 int accessTokenId = data.ReadInt32();
429
430 TAG_LOGI(AAFwkTag::APPMGR, "accessTokenId=%{public}d", accessTokenId);
431
432 int32_t result = KillProcessesByAccessTokenId(accessTokenId);
433 reply.WriteInt32(result);
434 return NO_ERROR;
435 }
436
HandleKillApplicationByUid(MessageParcel & data,MessageParcel & reply)437 ErrCode AmsMgrStub::HandleKillApplicationByUid(MessageParcel &data, MessageParcel &reply)
438 {
439 HITRACE_METER(HITRACE_TAG_APP);
440 std::string bundleName = data.ReadString();
441 int uid = data.ReadInt32();
442 std::string reason = data.ReadString();
443 TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationByUid,callingPid=%{public}d", IPCSkeleton::GetCallingPid());
444 int32_t result = KillApplicationByUid(bundleName, uid, reason);
445 reply.WriteInt32(result);
446 return NO_ERROR;
447 }
448
HandleKillApplicationSelf(MessageParcel & data,MessageParcel & reply)449 ErrCode AmsMgrStub::HandleKillApplicationSelf(MessageParcel &data, MessageParcel &reply)
450 {
451 HITRACE_METER(HITRACE_TAG_APP);
452 TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationSelf,callingPid=%{public}d", IPCSkeleton::GetCallingPid());
453 bool clearPageStack = data.ReadBool();
454 std::string reason = data.ReadString();
455 int32_t result = KillApplicationSelf(clearPageStack, reason);
456 if (!reply.WriteInt32(result)) {
457 TAG_LOGE(AAFwkTag::APPMGR, "result write failed.");
458 return ERR_INVALID_VALUE;
459 }
460 return NO_ERROR;
461 }
462
HandleAbilityAttachTimeOut(MessageParcel & data,MessageParcel & reply)463 int32_t AmsMgrStub::HandleAbilityAttachTimeOut(MessageParcel &data, MessageParcel &reply)
464 {
465 HITRACE_METER(HITRACE_TAG_APP);
466 sptr<IRemoteObject> token = data.ReadRemoteObject();
467 AbilityAttachTimeOut(token);
468 return NO_ERROR;
469 }
470
HandlePrepareTerminate(MessageParcel & data,MessageParcel & reply)471 int32_t AmsMgrStub::HandlePrepareTerminate(MessageParcel &data, MessageParcel &reply)
472 {
473 sptr<IRemoteObject> token = data.ReadRemoteObject();
474 bool clearMissionFlag = data.ReadBool();
475 PrepareTerminate(token, clearMissionFlag);
476 return NO_ERROR;
477 }
478
UpdateExtensionState(const sptr<IRemoteObject> & token,const ExtensionState state)479 void AmsMgrStub::UpdateExtensionState(const sptr<IRemoteObject> &token, const ExtensionState state)
480 {}
481
HandleGetRunningProcessInfoByToken(MessageParcel & data,MessageParcel & reply)482 int32_t AmsMgrStub::HandleGetRunningProcessInfoByToken(MessageParcel &data, MessageParcel &reply)
483 {
484 RunningProcessInfo processInfo;
485 auto token = data.ReadRemoteObject();
486 GetRunningProcessInfoByToken(token, processInfo);
487 if (reply.WriteParcelable(&processInfo)) {
488 TAG_LOGE(AAFwkTag::APPMGR, "process info write failed.");
489 return ERR_INVALID_VALUE;
490 }
491 return NO_ERROR;
492 }
493
HandleSetAbilityForegroundingFlagToAppRecord(MessageParcel & data,MessageParcel & reply)494 int32_t AmsMgrStub::HandleSetAbilityForegroundingFlagToAppRecord(MessageParcel &data, MessageParcel &reply)
495 {
496 RunningProcessInfo processInfo;
497 auto pid = static_cast<pid_t>(data.ReadInt32());
498 SetAbilityForegroundingFlagToAppRecord(pid);
499 return NO_ERROR;
500 }
501
HandlePrepareTerminateApp(MessageParcel & data,MessageParcel & reply)502 int32_t AmsMgrStub::HandlePrepareTerminateApp(MessageParcel &data, MessageParcel &reply)
503 {
504 TAG_LOGD(AAFwkTag::APPMGR, "called");
505 auto pid = static_cast<pid_t>(data.ReadInt32());
506 auto moduleName = data.ReadString();
507 PrepareTerminateApp(pid, moduleName);
508 return NO_ERROR;
509 }
510
HandleStartSpecifiedAbility(MessageParcel & data,MessageParcel & reply)511 int32_t AmsMgrStub::HandleStartSpecifiedAbility(MessageParcel &data, MessageParcel &reply)
512 {
513 AAFwk::Want *want = data.ReadParcelable<AAFwk::Want>();
514 if (want == nullptr) {
515 TAG_LOGE(AAFwkTag::APPMGR, "want is nullptr");
516 return ERR_INVALID_VALUE;
517 }
518
519 AbilityInfo *abilityInfo = data.ReadParcelable<AbilityInfo>();
520 if (abilityInfo == nullptr) {
521 TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo is nullptr.");
522 delete want;
523 return ERR_INVALID_VALUE;
524 }
525 StartSpecifiedAbility(*want, *abilityInfo, data.ReadInt32());
526 delete want;
527 delete abilityInfo;
528 return NO_ERROR;
529 }
530
HandleRegisterStartSpecifiedAbilityResponse(MessageParcel & data,MessageParcel & reply)531 int32_t AmsMgrStub::HandleRegisterStartSpecifiedAbilityResponse(MessageParcel &data, MessageParcel &reply)
532 {
533 sptr<IRemoteObject> obj = data.ReadRemoteObject();
534 sptr<IStartSpecifiedAbilityResponse> response = iface_cast<IStartSpecifiedAbilityResponse>(obj);
535 RegisterStartSpecifiedAbilityResponse(response);
536 return NO_ERROR;
537 }
538
HandleGetApplicationInfoByProcessID(MessageParcel & data,MessageParcel & reply)539 int32_t AmsMgrStub::HandleGetApplicationInfoByProcessID(MessageParcel &data, MessageParcel &reply)
540 {
541 HITRACE_METER(HITRACE_TAG_APP);
542 int32_t pid = data.ReadInt32();
543 AppExecFwk::ApplicationInfo application;
544 bool debug;
545 int32_t result = GetApplicationInfoByProcessID(pid, application, debug);
546 if (!reply.WriteInt32(result)) {
547 TAG_LOGE(AAFwkTag::APPMGR, "write result error.");
548 return ERR_INVALID_VALUE;
549 }
550 if (!reply.WriteParcelable(&application)) {
551 TAG_LOGE(AAFwkTag::APPMGR, "write application info failed");
552 return ERR_INVALID_VALUE;
553 }
554 if (!reply.WriteBool(debug)) {
555 TAG_LOGE(AAFwkTag::APPMGR, "write debug info failed");
556 return ERR_INVALID_VALUE;
557 }
558 return NO_ERROR;
559 }
560
HandleNotifyAppMgrRecordExitReason(MessageParcel & data,MessageParcel & reply)561 int32_t AmsMgrStub::HandleNotifyAppMgrRecordExitReason(MessageParcel &data, MessageParcel &reply)
562 {
563 TAG_LOGD(AAFwkTag::APPMGR, "called");
564 int32_t pid = data.ReadInt32();
565 int32_t reason = data.ReadInt32();
566 std::string exitMsg = Str16ToStr8(data.ReadString16());
567 int32_t result = NotifyAppMgrRecordExitReason(pid, reason, exitMsg);
568 if (!reply.WriteInt32(result)) {
569 TAG_LOGE(AAFwkTag::APPMGR, "Write result failed.");
570 return IPC_PROXY_ERR;
571 }
572 return NO_ERROR;
573 }
574
HandleUpdateApplicationInfoInstalled(MessageParcel & data,MessageParcel & reply)575 int32_t AmsMgrStub::HandleUpdateApplicationInfoInstalled(MessageParcel &data, MessageParcel &reply)
576 {
577 HITRACE_METER(HITRACE_TAG_APP);
578 std::string bundleName = data.ReadString();
579 int uid = data.ReadInt32();
580 std::string moduleName = data.ReadString();
581 int32_t result = UpdateApplicationInfoInstalled(bundleName, uid, moduleName);
582 reply.WriteInt32(result);
583 return NO_ERROR;
584 }
585
HandleSetCurrentUserId(MessageParcel & data,MessageParcel & reply)586 int32_t AmsMgrStub::HandleSetCurrentUserId(MessageParcel &data, MessageParcel &reply)
587 {
588 int32_t userId = data.ReadInt32();
589 SetCurrentUserId(userId);
590 return NO_ERROR;
591 }
592
HandleSetEnableStartProcessFlagByUserId(MessageParcel & data,MessageParcel & reply)593 int32_t AmsMgrStub::HandleSetEnableStartProcessFlagByUserId(MessageParcel &data, MessageParcel &reply)
594 {
595 int32_t userId = data.ReadInt32();
596 bool enableStartProcess = data.ReadBool();
597 SetEnableStartProcessFlagByUserId(userId, enableStartProcess);
598 return NO_ERROR;
599 }
600
HandleGetBundleNameByPid(MessageParcel & data,MessageParcel & reply)601 int32_t AmsMgrStub::HandleGetBundleNameByPid(MessageParcel &data, MessageParcel &reply)
602 {
603 int32_t pid = data.ReadInt32();
604 std::string bundleName;
605 int32_t uid;
606 GetBundleNameByPid(pid, bundleName, uid);
607
608 reply.WriteString(bundleName);
609 reply.WriteInt32(uid);
610 return NO_ERROR;
611 }
612
HandleRegisterAppDebugListener(MessageParcel & data,MessageParcel & reply)613 int32_t AmsMgrStub::HandleRegisterAppDebugListener(MessageParcel &data, MessageParcel &reply)
614 {
615 TAG_LOGD(AAFwkTag::APPMGR, "called");
616 auto appDebugLister = iface_cast<IAppDebugListener>(data.ReadRemoteObject());
617 if (appDebugLister == nullptr) {
618 TAG_LOGE(AAFwkTag::APPMGR, "App debug lister is null.");
619 return ERR_INVALID_VALUE;
620 }
621
622 auto result = RegisterAppDebugListener(appDebugLister);
623 if (!reply.WriteInt32(result)) {
624 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
625 return ERR_INVALID_VALUE;
626 }
627 return NO_ERROR;
628 }
629
HandleUnregisterAppDebugListener(MessageParcel & data,MessageParcel & reply)630 int32_t AmsMgrStub::HandleUnregisterAppDebugListener(MessageParcel &data, MessageParcel &reply)
631 {
632 TAG_LOGD(AAFwkTag::APPMGR, "called");
633 auto appDebugLister = iface_cast<IAppDebugListener>(data.ReadRemoteObject());
634 if (appDebugLister == nullptr) {
635 TAG_LOGE(AAFwkTag::APPMGR, "App debug lister is nullptr.");
636 return ERR_INVALID_VALUE;
637 }
638
639 auto result = UnregisterAppDebugListener(appDebugLister);
640 if (!reply.WriteInt32(result)) {
641 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
642 return ERR_INVALID_VALUE;
643 }
644 return NO_ERROR;
645 }
646
HandleAttachAppDebug(MessageParcel & data,MessageParcel & reply)647 int32_t AmsMgrStub::HandleAttachAppDebug(MessageParcel &data, MessageParcel &reply)
648 {
649 TAG_LOGD(AAFwkTag::APPMGR, "called");
650 auto bundleName = data.ReadString();
651 if (bundleName.empty()) {
652 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
653 return ERR_INVALID_VALUE;
654 }
655 auto isDebugFromLocal = data.ReadBool();
656
657 auto result = AttachAppDebug(bundleName, isDebugFromLocal);
658 if (!reply.WriteInt32(result)) {
659 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
660 return ERR_INVALID_VALUE;
661 }
662 return NO_ERROR;
663 }
664
HandleDetachAppDebug(MessageParcel & data,MessageParcel & reply)665 int32_t AmsMgrStub::HandleDetachAppDebug(MessageParcel &data, MessageParcel &reply)
666 {
667 TAG_LOGD(AAFwkTag::APPMGR, "called");
668 auto bundleName = data.ReadString();
669 if (bundleName.empty()) {
670 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
671 return ERR_INVALID_VALUE;
672 }
673
674 auto result = DetachAppDebug(bundleName);
675 if (!reply.WriteInt32(result)) {
676 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
677 return ERR_INVALID_VALUE;
678 }
679 return NO_ERROR;
680 }
681
HandleSetAppWaitingDebug(MessageParcel & data,MessageParcel & reply)682 int32_t AmsMgrStub::HandleSetAppWaitingDebug(MessageParcel &data, MessageParcel &reply)
683 {
684 TAG_LOGD(AAFwkTag::APPMGR, "called");
685 auto bundleName = data.ReadString();
686 if (bundleName.empty()) {
687 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
688 return ERR_INVALID_VALUE;
689 }
690 auto isPersist = data.ReadBool();
691 auto result = SetAppWaitingDebug(bundleName, isPersist);
692 if (!reply.WriteInt32(result)) {
693 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
694 return ERR_INVALID_VALUE;
695 }
696 return NO_ERROR;
697 }
698
HandleCancelAppWaitingDebug(MessageParcel & data,MessageParcel & reply)699 int32_t AmsMgrStub::HandleCancelAppWaitingDebug(MessageParcel &data, MessageParcel &reply)
700 {
701 TAG_LOGD(AAFwkTag::APPMGR, "called");
702 auto result = CancelAppWaitingDebug();
703 if (!reply.WriteInt32(result)) {
704 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
705 return ERR_INVALID_VALUE;
706 }
707 return NO_ERROR;
708 }
709
HandleGetWaitingDebugApp(MessageParcel & data,MessageParcel & reply)710 int32_t AmsMgrStub::HandleGetWaitingDebugApp(MessageParcel &data, MessageParcel &reply)
711 {
712 TAG_LOGD(AAFwkTag::APPMGR, "called");
713 std::vector<std::string> debugInfoList;
714 auto result = GetWaitingDebugApp(debugInfoList);
715 if (!reply.WriteInt32(result)) {
716 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
717 return ERR_INVALID_VALUE;
718 }
719
720 int32_t listSize = static_cast<int32_t>(debugInfoList.size());
721 if (listSize > MAX_APP_DEBUG_COUNT) {
722 TAG_LOGE(AAFwkTag::APPMGR, "Max app debug count is %{public}d.", listSize);
723 return ERR_INVALID_VALUE;
724 }
725
726 if (!reply.WriteInt32(listSize)) {
727 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write list size.");
728 return ERR_INVALID_VALUE;
729 }
730
731 if (!reply.WriteStringVector(debugInfoList)) {
732 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write string vector debug info list.");
733 return ERR_INVALID_VALUE;
734 }
735 return NO_ERROR;
736 }
737
HandleIsWaitingDebugApp(MessageParcel & data,MessageParcel & reply)738 int32_t AmsMgrStub::HandleIsWaitingDebugApp(MessageParcel &data, MessageParcel &reply)
739 {
740 TAG_LOGD(AAFwkTag::APPMGR, "called");
741 auto bundleName = data.ReadString();
742 if (bundleName.empty()) {
743 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
744 return ERR_INVALID_VALUE;
745 }
746
747 auto result = IsWaitingDebugApp(bundleName);
748 if (!reply.WriteBool(result)) {
749 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
750 return ERR_INVALID_VALUE;
751 }
752 return NO_ERROR;
753 }
754
HandleSetKeepAliveEnableState(MessageParcel & data,MessageParcel & reply)755 int32_t AmsMgrStub::HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply)
756 {
757 TAG_LOGD(AAFwkTag::APPMGR, "called");
758 auto bundleName = data.ReadString();
759 auto enable = data.ReadBool();
760 auto uid = data.ReadInt32();
761 SetKeepAliveEnableState(bundleName, enable, uid);
762 return NO_ERROR;
763 }
764
HandleSetKeepAliveDkv(MessageParcel & data,MessageParcel & reply)765 int32_t AmsMgrStub::HandleSetKeepAliveDkv(MessageParcel &data, MessageParcel &reply)
766 {
767 TAG_LOGD(AAFwkTag::APPMGR, "called");
768 auto bundleName = data.ReadString();
769 auto enable = data.ReadBool();
770 auto uid = data.ReadInt32();
771 SetKeepAliveDkv(bundleName, enable, uid);
772 return NO_ERROR;
773 }
774
HandleClearNonPersistWaitingDebugFlag(MessageParcel & data,MessageParcel & reply)775 int32_t AmsMgrStub::HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply)
776 {
777 TAG_LOGD(AAFwkTag::APPMGR, "called");
778 ClearNonPersistWaitingDebugFlag();
779 return NO_ERROR;
780 }
781
HandleRegisterAbilityDebugResponse(MessageParcel & data,MessageParcel & reply)782 int32_t AmsMgrStub::HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply)
783 {
784 TAG_LOGD(AAFwkTag::APPMGR, "called");
785 auto response = iface_cast<IAbilityDebugResponse>(data.ReadRemoteObject());
786 if (response == nullptr) {
787 TAG_LOGE(AAFwkTag::APPMGR, "Response is nullptr.");
788 return ERR_INVALID_VALUE;
789 }
790
791 auto result = RegisterAbilityDebugResponse(response);
792 if (!reply.WriteInt32(result)) {
793 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
794 return ERR_INVALID_VALUE;
795 }
796 return NO_ERROR;
797 }
798
HandleIsAttachDebug(MessageParcel & data,MessageParcel & reply)799 int32_t AmsMgrStub::HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply)
800 {
801 TAG_LOGD(AAFwkTag::APPMGR, "called");
802 auto bundleName = data.ReadString();
803 if (bundleName.empty()) {
804 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
805 return ERR_INVALID_VALUE;
806 }
807
808 auto result = IsAttachDebug(bundleName);
809 if (!reply.WriteBool(result)) {
810 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
811 return ERR_INVALID_VALUE;
812 }
813 return NO_ERROR;
814 }
815
HandleClearProcessByToken(MessageParcel & data,MessageParcel & reply)816 int32_t AmsMgrStub::HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply)
817 {
818 HITRACE_METER(HITRACE_TAG_APP);
819 sptr<IRemoteObject> token = data.ReadRemoteObject();
820 ClearProcessByToken(token);
821 return NO_ERROR;
822 }
823
HandleIsMemorySizeSufficent(MessageParcel & data,MessageParcel & reply)824 int32_t AmsMgrStub::HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply)
825 {
826 auto result = IsMemorySizeSufficent();
827 if (!reply.WriteBool(result)) {
828 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
829 return ERR_INVALID_VALUE;
830 }
831 return NO_ERROR;
832 }
833
HandleAttachedToStatusBar(MessageParcel & data,MessageParcel & reply)834 ErrCode AmsMgrStub::HandleAttachedToStatusBar(MessageParcel &data, MessageParcel &reply)
835 {
836 HITRACE_METER(HITRACE_TAG_APP);
837 sptr<IRemoteObject> token = data.ReadRemoteObject();
838 AttachedToStatusBar(token);
839 return NO_ERROR;
840 }
841
HandleBlockProcessCacheByPids(MessageParcel & data,MessageParcel & reply)842 ErrCode AmsMgrStub::HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply)
843 {
844 HITRACE_METER(HITRACE_TAG_APP);
845 auto size = data.ReadUint32();
846 if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) {
847 TAG_LOGE(AAFwkTag::APPMGR, "Invalid size.");
848 return ERR_INVALID_VALUE;
849 }
850 std::vector<int32_t> pids;
851 for (uint32_t i = 0; i < size; i++) {
852 pids.emplace_back(data.ReadInt32());
853 }
854
855 BlockProcessCacheByPids(pids);
856 return NO_ERROR;
857 }
858
HandleIsKilledForUpgradeWeb(MessageParcel & data,MessageParcel & reply)859 int32_t AmsMgrStub::HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply)
860 {
861 TAG_LOGD(AAFwkTag::APPMGR, "called");
862 auto bundleName = data.ReadString();
863 if (bundleName.empty()) {
864 TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty.");
865 return ERR_INVALID_VALUE;
866 }
867
868 auto result = IsKilledForUpgradeWeb(bundleName);
869 if (!reply.WriteBool(result)) {
870 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result.");
871 return ERR_INVALID_VALUE;
872 }
873 return NO_ERROR;
874 }
875
HandleCleanAbilityByUserRequest(MessageParcel & data,MessageParcel & reply)876 ErrCode AmsMgrStub::HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply)
877 {
878 HITRACE_METER(HITRACE_TAG_APP);
879 sptr<IRemoteObject> token = data.ReadRemoteObject();
880 auto result = CleanAbilityByUserRequest(token);
881 if (!reply.WriteBool(result)) {
882 TAG_LOGE(AAFwkTag::APPMGR, "fail to write the result.");
883 return ERR_INVALID_VALUE;
884 }
885 return NO_ERROR;
886 }
887
HandleIsProcessContainsOnlyUIAbility(MessageParcel & data,MessageParcel & reply)888 int32_t AmsMgrStub::HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply)
889 {
890 auto pid = data.ReadUint32();
891
892 auto result = IsProcessContainsOnlyUIAbility(pid);
893 if (!reply.WriteBool(result)) {
894 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result in HandleIsProcessContainsOnlyUIAbility.");
895 return ERR_INVALID_VALUE;
896 }
897 return NO_ERROR;
898 }
899
HandleIsProcessAttached(MessageParcel & data,MessageParcel & reply)900 int32_t AmsMgrStub::HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply)
901 {
902 HITRACE_METER(HITRACE_TAG_APP);
903 sptr<IRemoteObject> token = data.ReadRemoteObject();
904 auto isAttached = IsProcessAttached(token);
905 if (!reply.WriteBool(isAttached)) {
906 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result");
907 return ERR_INVALID_VALUE;
908 }
909 return NO_ERROR;
910 }
911
HandleIsCallerKilling(MessageParcel & data,MessageParcel & reply)912 int32_t AmsMgrStub::HandleIsCallerKilling(MessageParcel &data, MessageParcel &reply)
913 {
914 HITRACE_METER(HITRACE_TAG_APP);
915 auto callerKey = data.ReadString();
916 auto isCallerKilling = IsCallerKilling(callerKey);
917 if (!reply.WriteBool(isCallerKilling)) {
918 TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result");
919 return ERR_INVALID_VALUE;
920 }
921 return NO_ERROR;
922 }
923 } // namespace AppExecFwk
924 } // namespace OHOS
925