diff --git a/BUILD.gn b/BUILD.gn index 5137892..f38e04b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -94,10 +94,14 @@ ohos_shared_library("syscap_tool_shared") { part_name = "syscap_codec" } +config("syscap_interface_public_config") { + include_dirs = [ "./interfaces/inner_api/" ] +} + if (defined(ohos_lite)) { shared_library("syscap_interface_shared") { - include_dirs = [ "./interfaces/inner_api/" ] - public_configs = [ ":pubilc" ] + include_dirs = [ "include" ] + public_configs = [ ":syscap_interface_public_config" ] sources = [ "./interfaces/inner_api/syscap_interface.c" ] deps = [ @@ -107,8 +111,8 @@ if (defined(ohos_lite)) { } } else { ohos_shared_library("syscap_interface_shared") { - include_dirs = [ "./interfaces/inner_api/" ] - public_configs = [ ":pubilc" ] + include_dirs = [ "include" ] + public_configs = [ ":syscap_interface_public_config" ] sources = [ "./interfaces/inner_api/syscap_interface.c" ] deps = [ diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index c6dc419..fb99393 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -21,7 +21,6 @@ #include #include #include -#include "create_pcid.h" #include "syscap_define.h" #include "syscap_interface.h" @@ -85,12 +84,12 @@ static uint32_t GetFileContext(char **contextBufPtr, uint32_t *bufferLen) return 0; } -bool EncodeOsSyscap(int **output) +bool EncodeOsSyscap(char **output) { int32_t ret; int32_t res; char *contextBuffer = NULL; - int *outputArray = NULL; + char *outputArray = NULL; uint32_t bufferLen; ret = GetFileContext(&contextBuffer, &bufferLen); @@ -99,7 +98,7 @@ bool EncodeOsSyscap(int **output) return false; } - outputArray = (int *)malloc(PCID_MAIN_LEN); + outputArray = (char *)malloc(PCID_MAIN_LEN); if (outputArray == NULL) { PRINT_ERR("malloc buffer failed, size = %d\n", PCID_MAIN_LEN); return false; @@ -152,13 +151,13 @@ bool EncodePrivateSyscap(char **output, int *outputLen) return true; } -bool DecodeOsSyscap(int input[32], char (**output)[128], int *outputCnt) +bool DecodeOsSyscap(char input[128], char (**output)[128], int *outputCnt) { errno_t nRet = 0; uint16_t indexOfSyscap[OS_SYSCAP_BYTES * OS_SYSCAP_BYTES] = {0}; int countOfSyscap = 0, i, j; - uint8_t *osSyscap = (uint8_t *)(input + 2); // 2, int[2] of pcid header + uint8_t *osSyscap = (uint8_t *)(input + 8); // 8, int[2] of pcid header for (i = 0; i < OS_SYSCAP_BYTES; i++) { for (j = 0; j < BITS_OF_BYTE; j++) { diff --git a/interfaces/inner_api/syscap_interface.h b/interfaces/inner_api/syscap_interface.h index a0b7610..c45895e 100644 --- a/interfaces/inner_api/syscap_interface.h +++ b/interfaces/inner_api/syscap_interface.h @@ -25,8 +25,8 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -bool EncodeOsSyscap(int **output); -bool DecodeOsSyscap(int input[32], char (**output)[128], int *outputCnt); +bool EncodeOsSyscap(char **output); +bool DecodeOsSyscap(char input[128], char (**output)[128], int *outputCnt); bool EncodePrivateSyscap(char **output, int *outputLen); bool DecodePrivateSyscap(char *input, char (**output)[128], int *outputCnt); diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 71dc4a4..2a2face 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -61,7 +61,7 @@ static char* getSystemCapability() bool retBool; int retError, priOutputLen, priCapArrayCnt, sumLen; int i = 0; - int *osOutput = nullptr; + char *osOutput = nullptr; errno_t err = EOK; uint32_t *osCapU32 = nullptr; char *priOutput = nullptr; @@ -81,7 +81,7 @@ static char* getSystemCapability() goto FREE_PRIOUTPUT; } - osCapU32 = reinterpret_cast(osOutput + 2); // 2, header of pcid.sc + osCapU32 = reinterpret_cast(osOutput + 8); // 8, header of pcid.sc for (i = 0; i < OS_SYSCAP_U32_NUM; i++) { retError = sprintf_s(osCapArray[i], U32_TO_STR_MAX_LEN, "%u", osCapU32[i]); if (retError == -1) { diff --git a/test/unittest/common/syscap_codec_test.cpp b/test/unittest/common/syscap_codec_test.cpp index f761abb..fe7eac1 100644 --- a/test/unittest/common/syscap_codec_test.cpp +++ b/test/unittest/common/syscap_codec_test.cpp @@ -34,9 +34,9 @@ void SyscapCodecTest::TearDown() {} */ HWTEST_F(SyscapCodecTest, EncodeOsSyscap, TestSize.Level1) { - int *intOsInput = NULL; - EXPECT_TRUE(EncodeOsSyscap(&intOsInput)); - free(intOsInput); + char *OsInput = NULL; + EXPECT_TRUE(EncodeOsSyscap(&OsInput)); + free(OsInput); } /*