diff --git a/RELEASE-NOTE.txt b/RELEASE-NOTE.txt index d24a011dbdadc99e987be6aa8ce479b3ea5a4c17..08c9e97ba10beb3a6f7102b9912b071c1e06a527 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 4d28c17da9572b4b869807817c2cd3da0c4b6b9f..475dbc3efc1be22524e8bc35c53be8aae46619df 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -21,11 +21,11 @@ #define SINGLE_SYSCAP_LEN (256 + 17) typedef struct SystemCapabilityWithNum { - char syscapStr[SINGLE_SYSCAP_LEN]; + char str[SINGLE_SYSCAP_LEN]; uint16_t num; } SyscapWithNum; -/* add last */ +/* New syscap index must be added last */ typedef enum SystemCapabilityNum { ACCOUNT_APPACCOUNT, ACCOUNT_OSACCOUNT, @@ -177,11 +177,13 @@ typedef enum SystemCapabilityNum { USERIAM_USERAUTH_FINGERPRINTAUTH, USERIAM_USERAUTH_PINAUTH, USERIAM_USERIDM, + ARKUI_UIAPPEARANCE, + SECURITY_CERTIFICATE_MANAGER, SYSCAP_NUM_MAX = 960 } 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}, @@ -331,7 +333,8 @@ const static SyscapWithNum arraySyscap[] = { {"SystemCapability.UserIAM.UserAuth.FaceAuth", USERIAM_USERAUTH_FACEAUTH}, {"SystemCapability.UserIAM.UserAuth.FingerprintAuth", USERIAM_USERAUTH_FINGERPRINTAUTH}, {"SystemCapability.UserIAM.UserAuth.PinAuth", USERIAM_USERAUTH_PINAUTH}, - {"SystemCapability.UserIAM.UserIdm", USERIAM_USERIDM} + {"SystemCapability.UserIAM.UserIdm", USERIAM_USERIDM}, + {"SystemCapability.Security.CertificateManager", SECURITY_CERTIFICATE_MANAGER} }; #endif // _SYSCAP_DEFINE_H diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 0e2ece220051945e501b1b8a50e092e249e790bb..a42a7a5965ff8f02a8602da85572157527f4c634 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; } @@ -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; } @@ -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}; @@ -591,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); @@ -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 (int32_t)retFlag; } int32_t FreeCompareError(CompareError *result) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 8228f6e5e5293f4dbc34f51306e08082592148c0..09dc080241a6d1370efa7c3bac5ef3eba36d2ed4 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/create_pcid.c b/src/create_pcid.c index af2b2cef5ccfa54008b9b8bafa5dacc599d4f070..8710a952b7a6e35ae8589625f4fab03591dbe05a 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/main.c b/src/main.c index 3b3c9d1b0f6d00c7612e4af58c28eccb322632c0..72372c47ce5587b291ab192ea5d5b9c5beba4d22 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.2" #define OUTPUT_VERSION_LEN 200 #define ENCODE 0 #define DECODE 1 diff --git a/src/syscap_tool.c b/src/syscap_tool.c index d5cceca9fe630ed704912a43a9b0db518c39ea7e..54c7063bb7309cc9f4c1b922dffb137917dd89a8 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; } @@ -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; @@ -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; } }