From b2edaf26f31dd4ede13c0fcfcd4476c9b9c81e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=A4=BC=E4=BA=AD?= Date: Tue, 26 Apr 2022 08:31:59 +0000 Subject: [PATCH] fixed dcc0fb7 from https://gitee.com/liubb940516/startup_appspawn_lite/pulls/29 Signed-off-by: zhouliting --- bundle.json | 2 +- services/BUILD.gn | 2 +- services/src/appspawn_service.c | 25 +++++-------------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/bundle.json b/bundle.json index bbef384..ea7c592 100644 --- a/bundle.json +++ b/bundle.json @@ -23,7 +23,7 @@ "components": [ "hilog_lite", "samgr_lite", - "ipc_lite", + "ipc_single", "kv_store", "aafwk_lite", "ace_engine_lite", diff --git a/services/BUILD.gn b/services/BUILD.gn index 7ab1d17..4d99cea 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -51,7 +51,7 @@ executable("appspawn") { deps = [ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite", "//build/lite/config/component/cJSON:cjson_shared", - "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//third_party/bounds_checking_function:libsec_shared", "//utils/native/lite/kv_store:kv_store", diff --git a/services/src/appspawn_service.c b/services/src/appspawn_service.c index 66ed3b0..6d6752b 100644 --- a/services/src/appspawn_service.c +++ b/services/src/appspawn_service.c @@ -24,7 +24,7 @@ #include "appspawn_process.h" #include "iproxy_server.h" #include "iunknown.h" -#include "liteipc_adapter.h" +#include "ipc_skeleton.h" #include "log.h" #include "message.h" #include "ohos_errno.h" @@ -99,29 +99,14 @@ static int GetMessageSt(MessageSt* msgSt, IpcIo* req) if (msgSt == NULL || req == NULL) { return EC_FAILURE; } -#ifdef __LINUX__ size_t len = 0; - char* str = IpcIoPopString(req, &len); + char* str = ReadString(req, &len); if (str == NULL || len == 0) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] invoke, get data failed."); return EC_FAILURE; } int ret = SplitMessage(str, len, msgSt); // after split message, str no need to free(linux version) -#else - BuffPtr* dataPtr = IpcIoPopDataBuff(req); - if (dataPtr == NULL) { - HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] invoke, get data failed."); - return EC_FAILURE; - } - - int ret = SplitMessage((char*)dataPtr->buff, dataPtr->buffSz, msgSt); - - // release buffer - if (FreeBuffer(NULL, dataPtr->buff) != LITEIPC_OK) { - HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] invoke, free buffer failed!"); - } -#endif return ret; } @@ -138,14 +123,14 @@ static int Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, Ip if (reply == NULL || funcId != ID_CALL_CREATE_SERVICE || req == NULL) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] invoke, funcId %{public}d invalid, reply %{public}d.", \ funcId, INVALID_PID); - IpcIoPushInt64(reply, INVALID_PID); + WriteInt64(reply, INVALID_PID); return EC_BADPTR; } MessageSt msgSt = {0}; if (GetMessageSt(&msgSt, req) != EC_SUCCESS) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] invoke, parse failed! reply %{public}d.", INVALID_PID); - IpcIoPushInt64(reply, INVALID_PID); + WriteInt64(reply, INVALID_PID); return EC_FAILURE; } @@ -154,7 +139,7 @@ static int Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, Ip pid_t newPid = CreateProcess(&msgSt); FreeMessageSt(&msgSt); - IpcIoPushInt64(reply, newPid); + WriteInt64(reply, newPid); #ifdef OHOS_DEBUG struct timespec tmEnd = {0}; -- Gitee