From 419952b0b2163ceddbadd8ffcac811569b106d4c Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:28:38 +0000 Subject: [PATCH 01/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 650bcfe..1e52e85 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -89,7 +89,7 @@ static const char *GetSysCapName(const SysCapImpl *serviceImpl) static void InitializeRegistry(void) { - HILOG_INFO(HILOG_MODULE_SAMGR, "Initialize Registry!"); + HILOG_INFO(HILOG_MODULE_SAMGR, "Initialize registry."); g_server.mtx = MUTEX_InitValue(); SASTORA_Init(&g_server.store); g_server.samgr = SAMGR_CreateEndpoint("samgr", RegisterSamgrEndpoint); @@ -140,7 +140,7 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // Cannot use PRI_BUTT directly, so minus 1 + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // PRI_BUTT cannot be used directly, so 1 is deducted return config; } @@ -211,7 +211,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, int index = SASTORA_FindHandleByUidPid(&server->store, uid, pid, &handle); if (index == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not register", pid); + HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not registered", pid); IpcIoPushInt32(reply, EC_NOSERVICE); return EC_NOSERVICE; } @@ -231,7 +231,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, if (ret != EC_SUCCESS || policy == NULL) { MUTEX_Unlock(server->mtx); SAMGR_Free(policy); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote Get Communication Strategy<%s, %s> No Permission<%d>!", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote get communication strategy<%s, %s> no permission<%d>!", service, feature, ret); IpcIoPushInt32(reply, EC_PERMISSION); return EC_PERMISSION; @@ -239,7 +239,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, ret = SASTORA_Save(&server->store, service, feature, identity); MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Register Feature<%s, %s> pid<%d>, id<%u, %u> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Register feature<%s, %s> pid<%d>, id<%u, %u> ret:%d", service, feature, pid, identity->handle, identity->token, ret); TransmitPolicy(ret, identity, reply, policy, policyNum); SAMGR_Free(policy); @@ -304,7 +304,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, *identity = SASTORA_Find(&server->store, service, feature); if (identity->handle == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot Find Feature<%s, %s> id<%u, %u> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find feature<%s, %s> id<%u, %u> ret:%d", service, feature, identity->handle, identity->token, EC_NOSERVICE); return EC_NOSERVICE; } @@ -312,7 +312,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, PidHandle providerPid = SASTORA_FindPidHandleByIpcHandle(&server->store, identity->handle); MUTEX_Unlock(server->mtx); if (providerPid.pid == INVALID_INDEX || providerPid.uid == INVALID_INDEX) { - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot Find PidHandle<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find PidHandle<%s, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_FAILURE); return EC_FAILURE; } @@ -328,7 +328,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, HILOG_DEBUG(HILOG_MODULE_SAMGR, "Judge Auth<%s, %s> ret:%d", service, feature, isAuth); int32 ret = (isAuth == EC_SUCCESS) ? AddServiceAccess(*identity, GetCallingTid(origin)) : EC_PERMISSION; - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Find Feature<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Find feature<%s, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, ret); return ret; } @@ -453,9 +453,9 @@ void ProcGetAllSysCap(SamgrServer *server, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_SAMGR, "ProcGetAllSysCap replyNum: %d, size: %d, startIdx: %u, nextRequestIdx: %d", replyNum, size, startIdx, nextRequestIdx); IpcIoPushInt32(reply, EC_SUCCESS); - // indicate is the last reply + // indication of the last reply IpcIoPushBool(reply, nextRequestIdx == size); - // indicate is the next start idx + // indication of the next start idx IpcIoPushUint32(reply, nextRequestIdx); IpcIoPushUint32(reply, replyNum); int32 cnt = 0; @@ -505,8 +505,8 @@ static int RegisterSamgrEndpoint(const IpcContext* context, SvcIdentity* identit { int ret = SetSaManager(context, MAX_SA_SIZE); if (ret != LITEIPC_OK) { - HILOG_FATAL(HILOG_MODULE_SAMGR, "Set sa manager<%d> failed!", ret); - // Set sa manager failed! We need restart to recover + HILOG_FATAL(HILOG_MODULE_SAMGR, "Setting sa manager<%d> failed!", ret); + // Setting sa manager failed. We need restart to recover. exit(-ret); } identity->handle = SAMGR_HANDLE; @@ -542,7 +542,7 @@ static int OnEndpointExit(const IpcContext *context, void* ipcMsg, IpcIo* data, BinderRelease(context, handle.handle); } #endif - HILOG_ERROR(HILOG_MODULE_SAMGR, "IPC pid<%d> exit! send clean request retry(%d), ret(%d)!", pid, retry, ret); + HILOG_ERROR(HILOG_MODULE_SAMGR, "IPC pid<%d> exit! Send clean request retry(%d), ret(%d)!", pid, retry, ret); return EC_SUCCESS; } @@ -608,7 +608,7 @@ static void ParseSysCap(void) int32_t sysCapNum = 0; for (int32_t i = 0; i < size; i++) { if (sysCapNum >= MAX_SYSCAP_NUM) { - HILOG_ERROR(HILOG_MODULE_SAMGR, "ParseSycCapMap system capability exceed"); + HILOG_ERROR(HILOG_MODULE_SAMGR, "ParseSycCapMap system capability exceeded"); break; } cJSON *item = cJSON_GetArrayItem(sysCaps, i); @@ -622,7 +622,7 @@ static void ParseSysCap(void) } char *nameStr = cJSON_GetStringValue(name); if (VECTOR_FindByKey(&(g_server.sysCapabilitys), nameStr) != INVALID_INDEX) { - HILOG_WARN(HILOG_MODULE_SAMGR, "Duplicate system capability %s register!", nameStr); + HILOG_WARN(HILOG_MODULE_SAMGR, "Duplicate system capability %s registered!", nameStr); continue; } SysCapImpl *impl = (SysCapImpl *)SAMGR_Malloc(sizeof(SysCapImpl)); @@ -636,7 +636,7 @@ static void ParseSysCap(void) impl->isRegister = cJSON_IsTrue(isRegister); if (VECTOR_Add(&(g_server.sysCapabilitys), impl) == INVALID_INDEX) { SAMGR_Free(impl); - HILOG_ERROR(HILOG_MODULE_SAMGR, "system capability %s register failed!", impl->name); + HILOG_ERROR(HILOG_MODULE_SAMGR, "Registering system capability %s failed!", impl->name); continue; } sysCapNum++; -- Gitee From 4040215a803bee974700e3a10c8fc208a0506321 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:36:18 +0000 Subject: [PATCH 02/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 68d2a80..9e18022 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -221,7 +221,7 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // Cannot use PRI_BUTT directly, so minus 1 + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // PRI_BUTT cannot be used directly, so 1 is deducted return config; } @@ -302,7 +302,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, int index = SASTORA_FindHandleByUidPid(&server->store, uid, pid, &handle); if (index == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not register", pid); + HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not registered", pid); WriteInt32(reply, EC_NOSERVICE); return EC_NOSERVICE; } @@ -322,7 +322,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, if (ret != EC_SUCCESS || policy == NULL) { MUTEX_Unlock(server->mtx); SAMGR_Free(policy); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote Get Communication Strategy<%s, %s> No Permission<%d>!", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote get communication strategy<%s, %s> no permission<%d>!", service, feature, ret); WriteInt32(reply, EC_PERMISSION); return EC_PERMISSION; @@ -330,7 +330,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, ret = SASTORA_Save(&server->store, service, feature, identity); MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Register Feature<%s, %s> pid<%d>, id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Register feature<%s, %s> pid<%d>, id<%d, %d> ret:%d", service, feature, pid, identity->handle, identity->token, ret); TransmitPolicy(ret, identity, reply, policy, policyNum); SAMGR_Free(policy); @@ -400,7 +400,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, *identity = SASTORA_Find(&server->store, service, feature); if (identity->handle == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot Find Feature<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find feature<%s, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_NOSERVICE); return EC_NOSERVICE; } @@ -408,7 +408,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, PidHandle providerPid = SASTORA_FindPidHandleByIpcHandle(&server->store, identity->handle); MUTEX_Unlock(server->mtx); if (providerPid.pid == INVALID_INDEX || providerPid.uid == INVALID_INDEX) { - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot Find PidHandle<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find PidHandle<%s, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_FAILURE); return EC_FAILURE; } @@ -421,7 +421,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, .providerUid = providerPid.uid }; int isAuth = g_server.ipcAuth->IsCommunicationAllowed(authParams); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Judge Auth<%s, %s> ret:%d", service, feature, isAuth); + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Check Auth<%s, %s> ret:%d", service, feature, isAuth); return isAuth; } @@ -546,9 +546,9 @@ void ProcGetAllSysCap(SamgrServer *server, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_SAMGR, "ProcGetAllSysCap replyNum: %d, size: %d, startIdx: %u, nextRequestIdx: %d", replyNum, size, startIdx, nextRequestIdx); WriteInt32(reply, EC_SUCCESS); - // indicate is the last reply + // indication of the last reply WriteBool(reply, nextRequestIdx == size); - // indicate is the next start idx + // indication of the next start idx WriteUint32(reply, nextRequestIdx); WriteUint32(reply, replyNum); int32 cnt = 0; @@ -705,7 +705,7 @@ static void ParseSysCap(void) } char *nameStr = cJSON_GetStringValue(name); if (VECTOR_FindByKey(&(g_server.sysCapabilitys), nameStr) != INVALID_INDEX) { - HILOG_WARN(HILOG_MODULE_SAMGR, "Duplicate system capability %s register!", nameStr); + HILOG_WARN(HILOG_MODULE_SAMGR, "Duplicate system capability %s registered!", nameStr); continue; } SysCapImpl *impl = (SysCapImpl *)SAMGR_Malloc(sizeof(SysCapImpl)); @@ -719,7 +719,7 @@ static void ParseSysCap(void) impl->isRegister = cJSON_IsTrue(isRegister); if (VECTOR_Add(&(g_server.sysCapabilitys), impl) == INVALID_INDEX) { SAMGR_Free(impl); - HILOG_ERROR(HILOG_MODULE_SAMGR, "system capability %s register failed!", impl->name); + HILOG_ERROR(HILOG_MODULE_SAMGR, "Registering system capability %s failed!", impl->name); continue; } sysCapNum++; -- Gitee From f675a94a454e0f745e6115bf69cd557110588160 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:39:47 +0000 Subject: [PATCH 03/18] update interfaces/kits/samgr/common.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/samgr/common.h b/interfaces/kits/samgr/common.h index adc924c..ed60b1d 100755 --- a/interfaces/kits/samgr/common.h +++ b/interfaces/kits/samgr/common.h @@ -56,11 +56,11 @@ typedef void *MutexId; typedef void *ThreadId; /** - * @brief Calculates the offset of the member in the T type. + * @brief Calculates the offset for the member of the T type. * * * - * @param Indicates the T type. + * @param T Indicates the T type. * @param member Indicates the name of the T member variable. * * @since 1.0 @@ -141,7 +141,7 @@ typedef struct SimpleVector { Vector VECTOR_Make(VECTOR_Key key, VECTOR_Compare compare); /** - * @brief Destruct a vector object. + * @brief Destructs a vector object. * * This function is used to clear the memory applied by the vector after the temporary vector in * the stack is used. \n -- Gitee From bd4ed3f91c051a3a460334fc9a11ec67ecb263d8 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:42:18 +0000 Subject: [PATCH 04/18] update interfaces/kits/samgr/iunknown.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/iunknown.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/samgr/iunknown.h b/interfaces/kits/samgr/iunknown.h index 7478086..9fdd49d 100755 --- a/interfaces/kits/samgr/iunknown.h +++ b/interfaces/kits/samgr/iunknown.h @@ -116,7 +116,7 @@ typedef struct IUnknown IUnknown; DEFAULT_IUNKNOWN_IMPL /** - * @brief IUnknown Defines the end macro for initializing the IUnknown implementation + * @brief Defines the end macro for initializing the IUnknown implementation * object. * * This macro is used when a subclass object of the IUnknown implementation class is @@ -149,11 +149,11 @@ typedef struct IUnknown IUnknown; */ struct IUnknown { /** - * Queries the subclass object of the IUnknown interface of a specified version + * Query the subclass object of the IUnknown interface of a specified version * (downcasting). */ int (*QueryInterface)(IUnknown *iUnknown, int version, void **target); - /** Adds the reference count. */ + /** Add the reference count. */ int (*AddRef)(IUnknown *iUnknown); /** Release the reference to an IUnknown interface. */ int (*Release)(IUnknown *iUnknown); @@ -213,7 +213,7 @@ int IUNKNOWN_AddRef(IUnknown *iUnknown); * @param version Indicates the version of the IUnknown interface object to be converted. * @param target Indicates the IUnknown subclass type required by the caller. This is an * output parameter. - * @return Returns EC_SUCCESS if the conversion is successful; returns other error codes + * @return Returns EC_SUCCESS if the conversion is successful; returns an error code * if the conversion fails. * * @since 1.0 -- Gitee From 00854717194f954960b3e3fb0f009251ac04d41e Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:45:14 +0000 Subject: [PATCH 05/18] update interfaces/kits/samgr/message.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/message.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/samgr/message.h b/interfaces/kits/samgr/message.h index 713fb28..9bd9916 100755 --- a/interfaces/kits/samgr/message.h +++ b/interfaces/kits/samgr/message.h @@ -34,7 +34,7 @@ * @brief Provides message communication APIs that help you to implement asynchronous functions * of {@link IUnknown}. * - * This API is used to implement asynchronous functions of {@link IUnknown}. \n + * This file is used to implement asynchronous functions of {@link IUnknown}. \n * * @since 1.0 * @version 1.0 @@ -65,7 +65,7 @@ typedef struct Response Response; */ typedef void (*Handler)(const Request *request, const Response *response); -// Will be used for message interaction, so use one-byte alignment +// Use one-byte alignment becasue this API will be used for message interaction. #pragma pack(1) /** * @brief Identifies a service and feature. -- Gitee From 2650eb7d431d8afecf6df3c982411b1d66d91add Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 2 May 2022 03:47:40 +0000 Subject: [PATCH 06/18] update interfaces/kits/samgr/samgr_lite.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/samgr_lite.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/samgr/samgr_lite.h b/interfaces/kits/samgr/samgr_lite.h index e8e1718..7f585f1 100755 --- a/interfaces/kits/samgr/samgr_lite.h +++ b/interfaces/kits/samgr/samgr_lite.h @@ -33,7 +33,7 @@ * * @brief Manages system capabilities. * - * This is used when services, features, and functions are registered with and discovered by Samgr. \n + * This file is used for Samgr to register and discover services, features, and functions. \n * * @since 1.0 * @version 1.0 @@ -72,7 +72,7 @@ extern "C" { /** * @brief Enumerates the IDs of the message to be processed for starting the bootstrap service. * - * This function is implemented by developers of the system service. \n + * This function is implemented by system service developers. \n * Messages sent to the bootstrap service when Samgr is started. \n * */ -- Gitee From f8d08ad37c2e74b8ee89f8398c134ef22e5584dd Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Fri, 20 May 2022 00:45:50 +0000 Subject: [PATCH 07/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 1e52e85..4f7965e 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -140,7 +140,7 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // PRI_BUTT cannot be used directly, so 1 is deducted + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // Minus 1 as PRI_BUTT cannot be used directly return config; } -- Gitee From 968e43dc82cde66cf5ebcad8e8c8e301826412f3 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Fri, 20 May 2022 00:46:36 +0000 Subject: [PATCH 08/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 9e18022..7c8ba9c 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -221,7 +221,7 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // PRI_BUTT cannot be used directly, so 1 is deducted + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // Minus 1 as PRI_BUTT cannot be used directly return config; } -- Gitee From 3f2167296271f924fdd5ec060b53b7b57c05c62d Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Fri, 20 May 2022 01:58:32 +0000 Subject: [PATCH 09/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 4f7965e..32b6b57 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -140,7 +140,8 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // Minus 1 as PRI_BUTT cannot be used directly + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; + // PRI_BUTT cannot be used directly, so 1 is minus return config; } @@ -453,9 +454,9 @@ void ProcGetAllSysCap(SamgrServer *server, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_SAMGR, "ProcGetAllSysCap replyNum: %d, size: %d, startIdx: %u, nextRequestIdx: %d", replyNum, size, startIdx, nextRequestIdx); IpcIoPushInt32(reply, EC_SUCCESS); - // indication of the last reply + // Indication of the last reply IpcIoPushBool(reply, nextRequestIdx == size); - // indication of the next start idx + // Indication of the next start idx IpcIoPushUint32(reply, nextRequestIdx); IpcIoPushUint32(reply, replyNum); int32 cnt = 0; @@ -506,7 +507,7 @@ static int RegisterSamgrEndpoint(const IpcContext* context, SvcIdentity* identit int ret = SetSaManager(context, MAX_SA_SIZE); if (ret != LITEIPC_OK) { HILOG_FATAL(HILOG_MODULE_SAMGR, "Setting sa manager<%d> failed!", ret); - // Setting sa manager failed. We need restart to recover. + // Setting SA manager failed. A restart is needed to recover. exit(-ret); } identity->handle = SAMGR_HANDLE; -- Gitee From 94f247233d024f91a9b36a601c5afbe80c5f1736 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Fri, 20 May 2022 02:00:09 +0000 Subject: [PATCH 10/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 7c8ba9c..5e5b5b7 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -221,7 +221,8 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // Minus 1 as PRI_BUTT cannot be used directly + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; + // PRI_BUTT cannot be used directly, so 1 is minus return config; } @@ -546,9 +547,9 @@ void ProcGetAllSysCap(SamgrServer *server, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_SAMGR, "ProcGetAllSysCap replyNum: %d, size: %d, startIdx: %u, nextRequestIdx: %d", replyNum, size, startIdx, nextRequestIdx); WriteInt32(reply, EC_SUCCESS); - // indication of the last reply + // Indication of the last reply WriteBool(reply, nextRequestIdx == size); - // indication of the next start idx + // Indication of the next start idx WriteUint32(reply, nextRequestIdx); WriteUint32(reply, replyNum); int32 cnt = 0; -- Gitee From e99d5d0ec8bddf623ab2df156c31f014cd085596 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Fri, 20 May 2022 02:24:11 +0000 Subject: [PATCH 11/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 5e5b5b7..a13ab0e 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -221,7 +221,7 @@ static BOOL MessageHandle(Service *service, Request *request) static TaskConfig GetTaskConfig(Service *service) { (void)service; - TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; + TaskConfig config = {LEVEL_HIGH, PRI_BUTT - 1, 0x4000, 20, SINGLE_TASK}; // PRI_BUTT cannot be used directly, so 1 is minus return config; } -- Gitee From 01e2f6f869705d28ded409d861d9ce502560bbd8 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:15:34 +0000 Subject: [PATCH 12/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 32b6b57..ffd8fea 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -305,7 +305,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, *identity = SASTORA_Find(&server->store, service, feature); if (identity->handle == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find feature<%s, %s> id<%u, %u> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Feature<%s not found, %s> id<%u, %u> ret:%d", service, feature, identity->handle, identity->token, EC_NOSERVICE); return EC_NOSERVICE; } @@ -313,7 +313,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, PidHandle providerPid = SASTORA_FindPidHandleByIpcHandle(&server->store, identity->handle); MUTEX_Unlock(server->mtx); if (providerPid.pid == INVALID_INDEX || providerPid.uid == INVALID_INDEX) { - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find PidHandle<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "PidHandle<%s not found, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_FAILURE); return EC_FAILURE; } @@ -329,7 +329,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, HILOG_DEBUG(HILOG_MODULE_SAMGR, "Judge Auth<%s, %s> ret:%d", service, feature, isAuth); int32 ret = (isAuth == EC_SUCCESS) ? AddServiceAccess(*identity, GetCallingTid(origin)) : EC_PERMISSION; - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Find feature<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Feature<%s found, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, ret); return ret; } -- Gitee From 0a02af52b642cb9a5c8338d61727ce2b70d3f6eb Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:18:50 +0000 Subject: [PATCH 13/18] update interfaces/kits/samgr/message.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/message.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/kits/samgr/message.h b/interfaces/kits/samgr/message.h index 9bd9916..21c2589 100755 --- a/interfaces/kits/samgr/message.h +++ b/interfaces/kits/samgr/message.h @@ -65,7 +65,6 @@ typedef struct Response Response; */ typedef void (*Handler)(const Request *request, const Response *response); -// Use one-byte alignment becasue this API will be used for message interaction. #pragma pack(1) /** * @brief Identifies a service and feature. -- Gitee From db676bae091fd8f3219594e73b49ffb8b7453271 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:30:27 +0000 Subject: [PATCH 14/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index a13ab0e..358c056 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -261,7 +261,7 @@ static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo * #ifdef __LINUX__ IpcMsg* data = (IpcMsg*)origin; if (data == NULL) { - HILOG_ERROR(HILOG_MODULE_SAMGR, "Register Endpoint origin null pointer!"); + HILOG_ERROR(HILOG_MODULE_SAMGR, "Registered endpoint origin null pointer!"); return EC_FAILURE; } identity.handle = data->target.handle; @@ -277,7 +277,7 @@ static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo * } MUTEX_Unlock(server->mtx); WriteUint32(reply, handle.handle); - HILOG_INFO(HILOG_MODULE_SAMGR, "Register Endpoint<%d, %d, %d>", handle.pid, handle.handle, handle.deadId); + HILOG_INFO(HILOG_MODULE_SAMGR, "Endpoint<%d registered, %d, %d>", handle.pid, handle.handle, handle.deadId); return EC_SUCCESS; } @@ -323,7 +323,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, if (ret != EC_SUCCESS || policy == NULL) { MUTEX_Unlock(server->mtx); SAMGR_Free(policy); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote get communication strategy<%s, %s> no permission<%d>!", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Failed to get communication strategy<%s, %s> no permission<%d>!", service, feature, ret); WriteInt32(reply, EC_PERMISSION); return EC_PERMISSION; @@ -331,7 +331,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, ret = SASTORA_Save(&server->store, service, feature, identity); MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Register feature<%s, %s> pid<%d>, id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Feature<%s registered, %s> pid<%d>, id<%d, %d> ret:%d", service, feature, pid, identity->handle, identity->token, ret); TransmitPolicy(ret, identity, reply, policy, policyNum); SAMGR_Free(policy); @@ -401,7 +401,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, *identity = SASTORA_Find(&server->store, service, feature); if (identity->handle == INVALID_INDEX) { MUTEX_Unlock(server->mtx); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find feature<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Feature<%s not found, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_NOSERVICE); return EC_NOSERVICE; } @@ -409,7 +409,7 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, PidHandle providerPid = SASTORA_FindPidHandleByIpcHandle(&server->store, identity->handle); MUTEX_Unlock(server->mtx); if (providerPid.pid == INVALID_INDEX || providerPid.uid == INVALID_INDEX) { - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Cannot find PidHandle<%s, %s> id<%d, %d> ret:%d", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "PidHandle<%s not found, %s> id<%d, %d> ret:%d", service, feature, identity->handle, identity->token, EC_FAILURE); return EC_FAILURE; } -- Gitee From 10e3e59d3f7d30fb124fe203a476c7d4bd8acac0 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:33:25 +0000 Subject: [PATCH 15/18] update interfaces/kits/samgr/samgr_lite.h. Signed-off-by: king_he <6384784@qq.com> --- interfaces/kits/samgr/samgr_lite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/samgr/samgr_lite.h b/interfaces/kits/samgr/samgr_lite.h index 7f585f1..b16e9cf 100755 --- a/interfaces/kits/samgr/samgr_lite.h +++ b/interfaces/kits/samgr/samgr_lite.h @@ -33,7 +33,7 @@ * * @brief Manages system capabilities. * - * This file is used for Samgr to register and discover services, features, and functions. \n + * This file is used for the Samgr client to register and discover services, features, and functions. \n * * @since 1.0 * @version 1.0 -- Gitee From 16e5d9969d26335e62fdaa78182ad6b530dd685e Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:41:33 +0000 Subject: [PATCH 16/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index ffd8fea..9fcc738 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -232,7 +232,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, if (ret != EC_SUCCESS || policy == NULL) { MUTEX_Unlock(server->mtx); SAMGR_Free(policy); - HILOG_DEBUG(HILOG_MODULE_SAMGR, "Remote get communication strategy<%s, %s> no permission<%d>!", + HILOG_DEBUG(HILOG_MODULE_SAMGR, "Failed to get communication strategy<%s, %s> no permission<%d>!", service, feature, ret); IpcIoPushInt32(reply, EC_PERMISSION); return EC_PERMISSION; -- Gitee From 8ba42616000720aa31804ce5499d5556b5afc5be Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:48:58 +0000 Subject: [PATCH 17/18] update samgr_server/source/samgr_server.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 9fcc738..31ebfa1 100755 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -89,15 +89,14 @@ static const char *GetSysCapName(const SysCapImpl *serviceImpl) static void InitializeRegistry(void) { - HILOG_INFO(HILOG_MODULE_SAMGR, "Initialize registry."); + HILOG_INFO(HILOG_MODULE_SAMGR, "Registry initialized."); g_server.mtx = MUTEX_InitValue(); SASTORA_Init(&g_server.store); - g_server.samgr = SAMGR_CreateEndpoint("samgr", RegisterSamgrEndpoint); SAMGR_GetInstance()->RegisterService((Service *)&g_server); g_server.sysCapMtx = MUTEX_InitValue(); g_server.sysCapabilitys = VECTOR_Make((VECTOR_Key)GetSysCapName, (VECTOR_Compare)strcmp); ParseSysCap(); - HILOG_INFO(HILOG_MODULE_SAMGR, "InitializeRegistry ParseSysCap size: %d", VECTOR_Size(&(g_server.sysCapabilitys))); + HILOG_INFO(HILOG_MODULE_SAMGR, "Registry initialized, ParseSysCap size: %d", VECTOR_Size(&(g_server.sysCapabilitys))); } SYS_SERVICE_INIT(InitializeRegistry); -- Gitee From bba24ea584c41b9861478fdc6aaf8d2b8c237748 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 02:54:03 +0000 Subject: [PATCH 18/18] update samgr_server/source/samgr_server_rpc.c. Signed-off-by: king_he <6384784@qq.com> --- samgr_server/source/samgr_server_rpc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 358c056..0ea7357 100755 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -258,10 +258,15 @@ static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo * int index = SASTORA_FindHandleByPid(&g_server.store, pid, &handle); if (index == INVALID_INDEX) { SvcIdentity identity = {(int32)INVALID_INDEX, (uint32)INVALID_INDEX, (uint32)INVALID_INDEX}; -#ifdef __LINUX__ - IpcMsg* data = (IpcMsg*)origin; - if (data == NULL) { - HILOG_ERROR(HILOG_MODULE_SAMGR, "Registered endpoint origin null pointer!"); +#ifndef MINI_SAMGR_LITE_RPC + bool ret = ReadRemoteObject(req, &identity); + if (ret) { + // identity.handle <= 0: In-process communication; identity.handle > 0: Cross-process communication + if ((identity.handle <= 0) && (identity.cookie != 0)) { + identity.handle = 0; + } + } else { + WriteInt32(reply, INVALID_INDEX); return EC_FAILURE; } identity.handle = data->target.handle; -- Gitee