mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
for pcid dp.
Signed-off-by: yudechen <chenyude@huawei.com> Change-Id: I1a89895bf5697ab999c2c417538a26522c1acf09
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <securec.h>
|
||||
#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++) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<uint32_t *>(osOutput + 2); // 2, header of pcid.sc
|
||||
osCapU32 = reinterpret_cast<uint32_t *>(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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user