From 898ed7d2a0983713cc25f39902960ebba872b49c Mon Sep 17 00:00:00 2001 From: yudechen Date: Mon, 11 Jul 2022 18:38:24 +0800 Subject: [PATCH 01/10] modify for coding style. Signed-off-by: yudechen Change-Id: I741db340849990f6925020f894b7ac148ac94e46 --- interfaces/inner_api/syscap_interface.c | 4 ++-- src/syscap_tool.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 0e2ece2..4eba410 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -378,7 +378,7 @@ FREE_SYSCAP_OUT: return ret; } -static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *Len) +static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len) { uint32_t bufferLen; uint16_t sysCaptype, sysCapLength; @@ -410,7 +410,7 @@ static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t * } *buffer = contextBuffer; - *Len = bufferLen; + *len = bufferLen; return 0; } diff --git a/src/syscap_tool.c b/src/syscap_tool.c index d5cceca..1ed89fd 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -569,7 +569,7 @@ int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uin { int32_t ret = 0; uint32_t i; - uint32_t inputLen = strlen(inputString); + size_t inputLen = strlen(inputString); uint32_t count = 0; char *temp = NULL; char *tok = NULL; -- Gitee From 83673ddff26080bca94d1fc4f9436d838f4f65d1 Mon Sep 17 00:00:00 2001 From: yudechen Date: Mon, 11 Jul 2022 18:49:50 +0800 Subject: [PATCH 02/10] signed type cannot be involved in the bit operation. Signed-off-by: yudechen Change-Id: Ie5bd5a9983348cd469b7cc72bc24549927feaa9b --- interfaces/inner_api/syscap_interface.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 4eba410..e4d881a 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -556,6 +556,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa bool priSysFound; uint32_t pcidPriSyscapLen, rpcidPriSyscapLen; uint32_t i, j, temp1, temp2; + uint32_t retFlag = 0; uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0}; uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0}; @@ -632,13 +633,13 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa } if (versionFlag > 0) { - ret |= 0x1 << 0; + retFlag |= 0x1 << 0; } if (ossyscapFlag > 0 || prisyscapFlag > 0) { - ret |= 0x1 << 1; + retFlag |= 0x1 << 1; result->missSyscapNum = ossyscapFlag + prisyscapFlag; } - return ret; + return retFlag; } int32_t FreeCompareError(CompareError *result) -- Gitee From 608261605e072650a216cd3832acacaa94fcb558 Mon Sep 17 00:00:00 2001 From: yudechen Date: Tue, 12 Jul 2022 11:15:25 +0800 Subject: [PATCH 03/10] change global variable arraySyscap to g_arraySyscap. Signed-off-by: yudechen Change-Id: Ia723dfc0bb1d78500e57ae823f33978c81ebd36b --- include/syscap_define.h | 4 ++-- interfaces/inner_api/syscap_interface.c | 12 ++++++------ src/create_pcid.c | 20 ++++++++++---------- src/syscap_tool.c | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/syscap_define.h b/include/syscap_define.h index 4d28c17..9e1c899 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -21,7 +21,7 @@ #define SINGLE_SYSCAP_LEN (256 + 17) typedef struct SystemCapabilityWithNum { - char syscapStr[SINGLE_SYSCAP_LEN]; + char str[SINGLE_SYSCAP_LEN]; uint16_t num; } SyscapWithNum; @@ -181,7 +181,7 @@ typedef enum SystemCapabilityNum { } SyscapNum; /* sort by enum */ -const static SyscapWithNum arraySyscap[] = { +const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Account.AppAccount", ACCOUNT_APPACCOUNT}, {"SystemCapability.Account.OsAccount", ACCOUNT_OSACCOUNT}, {"SystemCapability.Ace.UiAppearance", ACE_UIAPPEARANCE}, diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index e4d881a..db288e7 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -219,9 +219,9 @@ bool DecodeOsSyscap(const char input[PCID_MAIN_BYTES], char (**output)[SINGLE_SY *output = strSyscap; for (i = 0; i < countOfSyscap; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (arraySyscap[j].num == indexOfSyscap[i]) { - nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, arraySyscap[j].syscapStr); + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (g_arraySyscap[j].num == indexOfSyscap[i]) { + nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, g_arraySyscap[j].str); if (nRet != EOK) { printf("strcpy_s failed. error = %d\n", nRet); *outputCnt = 0; @@ -322,10 +322,10 @@ static int SetOsSysCapBitMap(uint8_t *out, uint16_t outLen, uint16_t *index, uin static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -592,7 +592,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa return -1; } ret = strcpy_s(temp, sizeof(char) * SINGLE_SYSCAP_LEN, - arraySyscap[(i - 2) * INT_BIT + k].syscapStr); // 2, header of pcid & rpcid + g_arraySyscap[(i - 2) * INT_BIT + k].str); // 2, header of pcid & rpcid if (ret != EOK) { PRINT_ERR("strcpy_s failed.\n"); FreeCompareError(result); diff --git a/src/create_pcid.c b/src/create_pcid.c index af2b2ce..8710a95 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -158,10 +158,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -393,9 +393,9 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) } } for (i = 0; i < countOfSyscap; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (arraySyscap[j].num == indexOfSyscap[i]) { - if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(arraySyscap[j].syscapStr))) { + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (g_arraySyscap[j].num == indexOfSyscap[i]) { + if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(g_arraySyscap[j].str))) { printf("cJSON_AddItemToArray or cJSON_CreateString failed\n"); ret = -1; goto FREE_VECTOR_OUT; @@ -614,11 +614,11 @@ static int32_t AddOsSyscapToJsonObj(uint32_t *osSyscapArray, uint32_t osSyscapAr } for (i = 0; i < osSyscapCount; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (index[i] != arraySyscap[j].num) { + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (index[i] != g_arraySyscap[j].num) { continue; } - if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(arraySyscap[j].syscapStr))) { + if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(g_arraySyscap[j].str))) { PRINT_ERR("Add os syscap string to json failed.\n"); free(sysCapArray); return -1; @@ -732,8 +732,8 @@ PARSE_FAILED: int32_t EncodePcidscToString(char *inputFile, char *outDirPath) { int32_t ret = 0; - size_t bufferLen, privateSyscapLen; - uint32_t i, j, outputLen; + size_t bufferLen, privateSyscapLen, outputLen; + uint32_t i, j; uint32_t *mainSyscap = NULL; uint16_t priSyscapCount = 0; char *contextBuffer = NULL; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 1ed89fd..54c7063 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -174,10 +174,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -699,7 +699,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile) for (uint8_t k = 0; k < INT_BIT; k++) { if (temp2 & (0x1 << k)) { // 2, header of pcid & rpcid - printf("Missing: %s\n", arraySyscap[(i - 2) * INT_BIT + k].syscapStr); + printf("Missing: %s\n", g_arraySyscap[(i - 2) * INT_BIT + k].str); ossyscapFlag += 1; } } -- Gitee From 87e6fb02185251baddcc56da1ed74d9f17013645 Mon Sep 17 00:00:00 2001 From: yudechen Date: Thu, 14 Jul 2022 09:13:34 +0800 Subject: [PATCH 04/10] fix data type conversion problem. Signed-off-by: yudechen Change-Id: I4bbb49df814f6d791d0d3eed7933005c0ab0ba51 --- interfaces/inner_api/syscap_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index db288e7..a42a7a5 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -639,7 +639,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa retFlag |= 0x1 << 1; result->missSyscapNum = ossyscapFlag + prisyscapFlag; } - return retFlag; + return (int32_t)retFlag; } int32_t FreeCompareError(CompareError *result) -- Gitee From 1e3732b5f89f9737ed39f050b80d0111368808a1 Mon Sep 17 00:00:00 2001 From: yudechen Date: Tue, 19 Jul 2022 10:17:20 +0800 Subject: [PATCH 05/10] feat: syscap compare function support input string directly. Signed-off-by: yudechen Change-Id: Id80a3439972a17aadcbcaa3e216f6774d04e1ef4 --- include/syscap_tool.h | 5 ++++- src/main.c | 9 ++++++--- src/syscap_tool.c | 25 ++++++++++++++++--------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/syscap_tool.h b/include/syscap_tool.h index 2d12987..8ec1899 100644 --- a/include/syscap_tool.h +++ b/include/syscap_tool.h @@ -18,6 +18,9 @@ #include "stdint.h" +#define TYPE_FILE (0U) +#define TYPE_STRING (1U) + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -35,7 +38,7 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath); /* in: inputFile, out: outputPath/rpcid.json */ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath); /* in: pcidFile, rpcidFile */ -int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile); +int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type); int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uint32_t osArraySize, char **priSyscap, uint32_t *priSyscapLen); diff --git a/src/main.c b/src/main.c index 3b3c9d1..9cdd88b 100644 --- a/src/main.c +++ b/src/main.c @@ -29,7 +29,7 @@ printf("ERROR: [%s: %d] -> ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ } while (0) -#define SYSCAP_VERSION "1.0.1" +#define SYSCAP_VERSION "1.1.1" #define OUTPUT_VERSION_LEN 200 #define ENCODE 0 #define DECODE 1 @@ -130,7 +130,9 @@ int main(int argc, char **argv) case 0x115: // 0x115, -Pesi inputfile ret = EncodePcidscToString(inputfile, outputpath); break; case 0x60: // 0x60, -C PCID.txt RPCID.txt - ret = ComparePcidWithRpcidString(pcidfile, rpcidfile); break; + ret = ComparePcidWithRpcidString(pcidfile, rpcidfile, TYPE_FILE); break; + case 0x64: // 0x64, -sC "pcidstring" "rpcidstring" + ret = ComparePcidWithRpcidString(pcidfile, rpcidfile, TYPE_STRING); break; case 0x111: // 0x111, -Pei inputfile ret = CreatePCID(inputfile, outputpath); break; case 0x112: // 0x112, -Pdi inputfile @@ -168,7 +170,8 @@ void PrintHelp(void) printf("-h, --help\t: how to use\n"); printf("-R, --RPCID\t: encode or decode RPCID\n"); printf("-P, --PCID\t: encode or decode PCID\n"); - printf("-C, --compare\t: compare pcid with rpcid string format.\n"); + printf("-C, --compare\t: compare pcid with rpcid string format.\n\t" + "-s, --string : input string.\n"); printf("-e, --encode\t: encode to sc format.\n\t-s, --string : encode to string format.\n"); printf("-d, --decode\t: decode to json format.\n\t-s, --string : decode string format.\n"); printf("-i filepath, --input filepath\t: input file\n"); diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 54c7063..fdfceb2 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -647,7 +647,7 @@ SKIP_PRI_SYSCAP: return 0; } -int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile) +int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type) { int32_t ret; int32_t versionFlag = 0; @@ -663,14 +663,21 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile) uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0}; uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0}; - if (GetFileContext(pcidFile, &pcidContent, &pcidContentLen)) { - PRINT_ERR("Get pcid file context failed, input file : %s\n", pcidFile); - return -1; - } - - if (GetFileContext(rpcidFile, &rpcidContent, &rpcidContentLen)) { - PRINT_ERR("Get rpcid file context failed, input file : %s\n", rpcidFile); - free(pcidContent); + if (type == TYPE_FILE) { + if (GetFileContext(pcidFile, &pcidContent, &pcidContentLen)) { + PRINT_ERR("Get pcid file context failed, input file : %s\n", pcidFile); + return -1; + } + if (GetFileContext(rpcidFile, &rpcidContent, &rpcidContentLen)) { + PRINT_ERR("Get rpcid file context failed, input file : %s\n", rpcidFile); + free(pcidContent); + return -1; + } + } else if (type == TYPE_STRING) { + pcidContent = pcidFile; + rpcidContent = rpcidFile; + } else { + PRINT_ERR("Input file type error, type=%d\n", type); return -1; } -- Gitee From 2ab5656e73ccde6abe26fd7757d5ff2b5921b0ce Mon Sep 17 00:00:00 2001 From: yudechen Date: Tue, 19 Jul 2022 18:35:56 +0800 Subject: [PATCH 06/10] docs: add a description of the new features. Signed-off-by: yudechen Change-Id: I8aa1b6b38f46b7b9d324b10e5b44d88342cc7b51 --- README_ZH.md | 104 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 33 deletions(-) diff --git a/README_ZH.md b/README_ZH.md index 6b336e3..31b27cc 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -6,7 +6,7 @@ 提供的主要功能: -1. PCID编码:对描述SysCap集合的文件编码生成PCID。 +1. PCID编码:对描述SysCap集合的文件编码生成PCID。 2. PCID解码:对编码后的PCID文件解码获取SysCap集合。 @@ -14,71 +14,109 @@ 4. RPCID解码:对编码后的RPCID文件解码获取应用所需的SysCap集合。 -## 目录 +5. 编码字符串:将sc后缀形式的PCID/RPCID编码为字符串形式。 + +6. PCID与RPCID比较:查询PCID是否满足RPCID的要求,并输出不满足的地方。 + +## 代码目录 ``` /developtools ├── syscap_codec # syscap codec代码目录 -│ ├── include -│ │ └── syscap_tool.h # syscap_tool_shared对外接口定义 +│ ├── include # syscap_tool_shared对外接口定义 +│ │ ├── syscap_define.h +│ │ └── syscap_tool.h +│ ├── interfaces/inner_api # 提供部件之间的接口 +│ │ ├── syscap_interface.c +│ │ └── syscap_interface.h +│ ├── napi # napi 接口实现 +│ │ ├── BUILD.gn +│ │ ├── napi_query_syscap.cpp +│ │ └── syscap_interface.h │ ├── src │ │ ├── endian_internel.h # 内部实现的大小端转换接口定义(便于win、mac、linux平台通用) │ │ ├── endian_internel.c # 大小端转换实现 │ │ ├── main.c # syscap_tool命令行工具代码实现 │ │ └── syscap_tool.c # syscap_tool编解码接口的实现 │ └── test -│ └── syscap_tool_test.c # syscap_tool功能测试代码实现 +│ │ ├── unittest/common # inner 接口测试代码实现 +│ │ │ ├── BUILD.gn +│ │ │ ├── include +│ │ │ │ └── syscap_codec_test.h +│ │ │ └── syscap_codec_test.cpp +│ │ └── syscap_tool_test.c # syscap_tool功能测试代码实现 ``` -### API +## API PC端工具,不对外提供API。 -### PC端编译说明 +## PC端编译说明 syscap_tool PC端可执行文件编译步骤: +1. 编译命令:参考[编译构建](https://gitee.com/openharmony/build/blob/master/README_zh.md)文档,执行其指定的sdk编译命令来编译整个sdk,syscap_tool会被编译打包到里面。 +2. 编译:在目标开发机上运行上面调整好的sdk编译命令,正常编译syscap_tool会输出到sdk平台相关目录下。 -1. 编译命令:参考https://gitee.com/openharmony/build/blob/master/README_zh.md ,执行其指定的sdk编译命令来编译整个sdk, syscap_tool会被编译打包到里面。 - -2. 编译:在目标开发机上运行上面调整好的sdk编译命令, 正常编译syscap_tool会输出到sdk平台相关目录下。 - -注意: ubuntu环境下只能编译windows/linux版本工具,mac版需要在macos开发机上编译。 - -### PC端获取说明 - -1. 下载sdk获取(建议) - -通过访问本社区网站http://ci.openharmony.cn/dailybuilds ,下载sdk压缩包,从中根据自己平台到相应的目录toolchain下解压提取。 - -2. 支持运行环境 +注意:ubuntu环境下只能编译windows/linux版本工具,mac版需要在macos开发机上编译。 +## PC端获取说明 +1. 下载sdk获取(建议) +通过访问本社区门禁[每日构建](http://ci.openharmony.cn/dailys/dailybuilds)网站,下载最新的ohos-sdk压缩包,并从相应平台的toolchains压缩包中提取syscap_tool。 +2. 支持运行环境 Windows x86_64/Linux x86_64/Darwin x86_64 -### 命令帮助 - +## 命令帮助 本工具一般被IDE、应用市场和包管理器集成,手工调试时可参考以下说明。 使用./syscap_tool -h或者./syscap_tool --help查看: +```shell +syscap_tool -R/P -e/d -i filepath [-o outpath] +-h, --help : how to use +-R, --RPCID : encode or decode RPCID +-P, --PCID : encode or decode PCID +-C, --compare : compare pcid with rpcid string format. + -s, --string : input string. +-e, --encode : encode to sc format. + -s, --string : encode to string format. +-d, --decode : decode to json format. + -s, --string : decode string format. +-i filepath, --input filepath : input file +-o outpath, --input outpath : output path +-v, --version : print syscap_tool version information. + +syscap_tool v1.1.1 ``` -./syscap_tool --help +### 使用示例 +```shell +# 将 RPCID.json 编码为SC格式,文件名RPCID.sc +syscap_tool -Rei RPCID.json -o path/ -./syscap_tool -R/P -e/d -i filepath [-o outpath] +# 将 RPCID.sc 编码为JSON格式,文件名RPCID.json +syscap_tool -Rdi RPCID.sc -o path/ --h, --help : how to use +# 将 PCID.json 编码为SC格式,文件名PCID.sc +syscap_tool -Pei PCID.json -o path/ --R, --RPCID : encode or decode RPCID +# 将 PCID.sc 编码为JSON格式,文件名PCID.json +syscap_tool -Pdi PCID.sc -o path/ --P, --PCID : encode or decode PCID +# 将 RPCID.sc 编码为字符串格式,文件名RPCID.txt +syscap_tool -Resi RPCID.sc -o path/ --e, --encode : to encode +# 将 PCID.sc 编码为字符串格式,文件名PCID.txt +syscap_tool -Pesi PCID.sc -o path/ --d, --encode : to decode +# 比较字符串格式的PCID和RPCID,pcid 符合条件返回成功提示,不符合则提示原因。 +syscap_tool -C pcid.txt rpcid.txt --i filepath, --input filepath : input file +# 功能类似 -C 选项,区别为 -SC 选项为直接输入字符串。 +syscap_tool -sC "pcidstring" "rpcidstring" --o outpath, --input outpath : output path +# 将字符串格式的 pcid 转为 json 格式,文件名 PCID.json。 +syscap_tool -Pdsi pcid.txt -o path/ ``` +**说明:** -o 选项指定输出目录,缺省为当前目录。 -### Release Note - +## Release Note +v1.1.0 2022-6-17 添加转字符串格式以及比较功能。 v1.0.0 2022-3-8 首版本,提供Windows/Linux/Mac平台的系统能力编解码。 \ No newline at end of file -- Gitee From 557d82705ddd24ac264c2ac17f26a1b2a0cbc50e Mon Sep 17 00:00:00 2001 From: yudechen Date: Tue, 19 Jul 2022 19:04:36 +0800 Subject: [PATCH 07/10] docs: adjust some details. Signed-off-by: yudechen Change-Id: Ia982d93f4367f890744fe6c6852fca5a14d6af39 --- README_ZH.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README_ZH.md b/README_ZH.md index 31b27cc..3a7e5c3 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,5 +1,4 @@ # 系统能力编解码工具 - 系统能力(SystemCapability, 本文中使用SysCap缩写)编解码工具应用场景如下: 应用开发时,IDE会根据应用配置的SysCap和API版本生成描述RPCID(Required Product Compatibility ID)的json文件,并调用编解码工具syscap_tool将该json文件编码成RPCID。另一方面,IDE拿到开发者导入PCID(Product Compatibility ID),使用该工具解码出设备的SysCap集合。该工具仅供IDE使用,对用户不可见。 @@ -19,7 +18,6 @@ 6. PCID与RPCID比较:查询PCID是否满足RPCID的要求,并输出不满足的地方。 ## 代码目录 - ``` /developtools ├── syscap_codec # syscap codec代码目录 @@ -48,11 +46,9 @@ ``` ## API - PC端工具,不对外提供API。 -## PC端编译说明 - +## PC端编译说明 syscap_tool PC端可执行文件编译步骤: 1. 编译命令:参考[编译构建](https://gitee.com/openharmony/build/blob/master/README_zh.md)文档,执行其指定的sdk编译命令来编译整个sdk,syscap_tool会被编译打包到里面。 2. 编译:在目标开发机上运行上面调整好的sdk编译命令,正常编译syscap_tool会输出到sdk平台相关目录下。 @@ -61,9 +57,9 @@ syscap_tool PC端可执行文件编译步骤: ## PC端获取说明 1. 下载sdk获取(建议) -通过访问本社区门禁[每日构建](http://ci.openharmony.cn/dailys/dailybuilds)网站,下载最新的ohos-sdk压缩包,并从相应平台的toolchains压缩包中提取syscap_tool。 + 通过访问本社区门禁[每日构建](http://ci.openharmony.cn/dailys/dailybuilds)网站,下载最新的ohos-sdk压缩包,并从相应平台的toolchains压缩包中提取syscap_tool。 2. 支持运行环境 -Windows x86_64/Linux x86_64/Darwin x86_64 + Windows x86_64/Linux x86_64/Darwin x86_64 ## 命令帮助 本工具一般被IDE、应用市场和包管理器集成,手工调试时可参考以下说明。 -- Gitee From b57e1250ffa2f9f75dc60964e58477ae55ae1139 Mon Sep 17 00:00:00 2001 From: benb365 Date: Wed, 20 Jul 2022 15:26:01 +0800 Subject: [PATCH 08/10] Modify syscap of the uiAppearance. Signed-off-by: benb365 --- include/syscap_define.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/syscap_define.h b/include/syscap_define.h index 9e1c899..4216f0f 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -30,7 +30,7 @@ typedef enum SystemCapabilityNum { ACCOUNT_APPACCOUNT, ACCOUNT_OSACCOUNT, ACE_ACEENGINELITE, - ACE_UIAPPEARANCE, + ARKUI_UIAPPEARANCE, AI_AIENGINE, APPLICATIONS_CONTACTSDATA, BARRIERFREE_ACCESSIBILITY_CORE, @@ -184,7 +184,7 @@ typedef enum SystemCapabilityNum { const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Account.AppAccount", ACCOUNT_APPACCOUNT}, {"SystemCapability.Account.OsAccount", ACCOUNT_OSACCOUNT}, - {"SystemCapability.Ace.UiAppearance", ACE_UIAPPEARANCE}, + {"SystemCapability.ArkUI.UiAppearance", ARKUI_UIAPPEARANCE}, {"SystemCapability.Ace.AceEngineLite", ACE_ACEENGINELITE}, {"SystemCapability.Ai.AiEngine", AI_AIENGINE}, {"SystemCapability.Applications.ContactsData", APPLICATIONS_CONTACTSDATA}, -- Gitee From 2b8f9e670ae7d81b5fea520e3bee6ef85d035909 Mon Sep 17 00:00:00 2001 From: liukaii Date: Wed, 20 Jul 2022 16:20:55 +0800 Subject: [PATCH 09/10] Modify syscap of the uiAppearance. Signed-off-by: liukaii --- include/syscap_define.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/syscap_define.h b/include/syscap_define.h index 4216f0f..4e8740d 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -30,6 +30,7 @@ typedef enum SystemCapabilityNum { ACCOUNT_APPACCOUNT, ACCOUNT_OSACCOUNT, ACE_ACEENGINELITE, + ACE_UIAPPEARANCE, ARKUI_UIAPPEARANCE, AI_AIENGINE, APPLICATIONS_CONTACTSDATA, @@ -184,6 +185,7 @@ typedef enum SystemCapabilityNum { const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Account.AppAccount", ACCOUNT_APPACCOUNT}, {"SystemCapability.Account.OsAccount", ACCOUNT_OSACCOUNT}, + {"SystemCapability.Ace.UiAppearance", ACE_UIAPPEARANCE}, {"SystemCapability.ArkUI.UiAppearance", ARKUI_UIAPPEARANCE}, {"SystemCapability.Ace.AceEngineLite", ACE_ACEENGINELITE}, {"SystemCapability.Ai.AiEngine", AI_AIENGINE}, -- Gitee From 6ae563ee7c56e827d10bf073053ccdb840a77f99 Mon Sep 17 00:00:00 2001 From: yudechen Date: Thu, 21 Jul 2022 11:47:27 +0800 Subject: [PATCH 10/10] fix: modify syscap_define.h and clear compile warnings. Signed-off-by: yudechen Change-Id: I1e5abe8d15aa4096d2c48621a7fdb790c0dd4697 --- RELEASE-NOTE.txt | 3 +++ include/syscap_define.h | 5 +++-- napi/napi_query_syscap.cpp | 11 +++++------ src/main.c | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTE.txt b/RELEASE-NOTE.txt index d24a011..08c9e97 100644 --- a/RELEASE-NOTE.txt +++ b/RELEASE-NOTE.txt @@ -1 +1,4 @@ +v1.1.2 add syscap "SystemCapability.ArkUI.UiAppearance". +v1.1.1 add compare string pcid with rpcid function. +v1.1.0 add encode/decode string format PCID/RPCID. v1.0.0 first release. \ No newline at end of file diff --git a/include/syscap_define.h b/include/syscap_define.h index 4e8740d..d70718a 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -25,13 +25,12 @@ typedef struct SystemCapabilityWithNum { uint16_t num; } SyscapWithNum; -/* add last */ +/* New syscap index must be added last */ typedef enum SystemCapabilityNum { ACCOUNT_APPACCOUNT, ACCOUNT_OSACCOUNT, ACE_ACEENGINELITE, ACE_UIAPPEARANCE, - ARKUI_UIAPPEARANCE, AI_AIENGINE, APPLICATIONS_CONTACTSDATA, BARRIERFREE_ACCESSIBILITY_CORE, @@ -178,6 +177,8 @@ typedef enum SystemCapabilityNum { USERIAM_USERAUTH_FINGERPRINTAUTH, USERIAM_USERAUTH_PINAUTH, USERIAM_USERIDM, + ARKUI_UIAPPEARANCE, + // Add here SYSCAP_NUM_MAX = 960 } SyscapNum; diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 8228f6e..09dc080 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -60,7 +60,6 @@ static char* getSystemCapability() { bool retBool; int retError, priOutputLen, priCapArrayCnt, sumLen; - int i = 0; char osOutput[SINGLE_SYSCAP_LEN] = {}; errno_t err = EOK; uint32_t *osCapU32 = nullptr; @@ -82,7 +81,7 @@ static char* getSystemCapability() } osCapU32 = reinterpret_cast(osOutput); - for (i = 0; i < PCID_MAIN_U32; i++) { // 2, header of pcid.sc + for (size_t i = 0; i < PCID_MAIN_U32; i++) { // 2, header of pcid.sc retError = sprintf_s(osCapArray[i], U32_TO_STR_MAX_LEN, "%u", osCapU32[i]); if (retError == -1) { PRINT_ERR("get uint32_t syscap string failed."); @@ -98,10 +97,10 @@ static char* getSystemCapability() // calculate all string length sumLen = 0; - for (i = 0; i < PCID_MAIN_U32; i++) { + for (size_t i = 0; i < PCID_MAIN_U32; i++) { sumLen += strlen(osCapArray[i]); } - for (i = 0; i < priCapArrayCnt; i++) { + for (int i = 0; i < priCapArrayCnt; i++) { sumLen += strlen(*(priCapArray + i)); } sumLen += (PCID_MAIN_U32 + priCapArrayCnt + 1); // split with ',' @@ -121,7 +120,7 @@ static char* getSystemCapability() } temp = *osCapArray; - for (i = 1; i < PCID_MAIN_U32; i++) { + for (size_t i = 1; i < PCID_MAIN_U32; i++) { retError = sprintf_s(allSyscapBUffer, sumLen, "%s,%s", temp, osCapArray[i]); if (retError == -1) { PRINT_ERR("splicing os syscap string failed."); @@ -131,7 +130,7 @@ static char* getSystemCapability() } temp = allSyscapBUffer; } - for (i = 0; i < priCapArrayCnt; i++) { + for (int i = 0; i < priCapArrayCnt; i++) { retError = sprintf_s(allSyscapBUffer, sumLen, "%s,%s", temp, *(priCapArray + i)); if (retError == -1) { PRINT_ERR("splicing pri syscap string failed."); diff --git a/src/main.c b/src/main.c index 9cdd88b..d44dd06 100644 --- a/src/main.c +++ b/src/main.c @@ -29,7 +29,7 @@ printf("ERROR: [%s: %d] -> ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ } while (0) -#define SYSCAP_VERSION "1.1.1" +#define SYSCAP_VERSION "1.1.2" #define OUTPUT_VERSION_LEN 200 #define ENCODE 0 #define DECODE 1 -- Gitee