From dfb095c57d29be0e2baa140cccda971f596288f7 Mon Sep 17 00:00:00 2001 From: jerry Date: Sat, 8 Jan 2022 09:07:32 +0000 Subject: [PATCH] multi-user Signed-off-by: jerry --- services/abilitymgr/src/ability_manager_proxy.cpp | 12 +++++++++--- services/abilitymgr/src/ability_manager_stub.cpp | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 83c95acc54..6e100a6561 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -1813,9 +1813,15 @@ int AbilityManagerProxy::StopUser(int userId, const sptr &cal HILOG_ERROR("StopUser:WriteInt32 fail."); return ERR_INVALID_VALUE; } - if (!data.WriteParcelable(callback->AsObject())) { - HILOG_ERROR("StopUser:write IStopUserCallback fail."); - return ERR_INVALID_VALUE; + + if (!callback) { + data.WriteBool(false); + } else { + data.WriteBool(true); + if (!data.WriteParcelable(callback->AsObject())) { + HILOG_ERROR("StopUser:write IStopUserCallback fail."); + return ERR_INVALID_VALUE; + } } error = Remote()->SendRequest(IAbilityManager::STOP_USER, data, reply, option); if (error != NO_ERROR) { diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 7e74892c8b..feaa7ef555 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -1066,7 +1066,10 @@ int AbilityManagerStub::StartUserInner(MessageParcel &data, MessageParcel &reply int AbilityManagerStub::StopUserInner(MessageParcel &data, MessageParcel &reply) { int32_t userId = data.ReadInt32(); - auto callback = iface_cast(data.ReadParcelable()); + sptr callback = nullptr; + if (data.ReadBool()) { + callback = iface_cast(data.ReadParcelable()); + } int result = StopUser(userId, callback); if (!reply.WriteInt32(result)) { HILOG_ERROR("StopUser failed.");