Issue: #I62859

Description: add syscap of cloud aaid
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No

Signed-off-by: xuanfeng8 <lifeng54@huawei.com>
This commit is contained in:
lifeng
2022-11-21 15:39:56 +08:00
parent 300e90913a
commit 92fce6ef77
2 changed files with 34 additions and 13 deletions
+3 -1
View File
@@ -258,6 +258,7 @@ typedef enum SystemCapabilityNum {
MULTIMEDIA_AVSESSION_MANAGER,
MULTIMEDIA_AUDIO_TONE,
MULTIMEDIA_AUDIO_INTERRUPT,
CLOUD_AAID,
SYSCAP_NUM_MAX = 960
} SyscapNum;
@@ -493,7 +494,8 @@ const static SyscapWithNum g_arraySyscap[] = {
{"SystemCapability.Multimedia.AVSession.Core", MULTIMEDIA_AVSESSION_CORE},
{"SystemCapability.Multimedia.AVSession.Manager", MULTIMEDIA_AVSESSION_MANAGER},
{"SystemCapability.Multimedia.Audio.Tone", MULTIMEDIA_AUDIO_TONE},
{"SystemCapability.Multimedia.Audio.Interrupt", MULTIMEDIA_AUDIO_INTERRUPT}
{"SystemCapability.Multimedia.Audio.Interrupt", MULTIMEDIA_AUDIO_INTERRUPT},
{"SystemCapability.Cloud.AAID", CLOUD_AAID}
};
#ifdef __cplusplus
+31 -12
View File
@@ -40,6 +40,7 @@ typedef struct RequiredProductCompatibilityIDHead {
#define PCID_OUT_BUFFER RPCID_OUT_BUFFER
#define BYTES_OF_OS_SYSCAP 120
#define U32_TO_STR_MAX_LEN 11
#define STRING_FORMAT_LEN_MAX 1024
#define PRINT_ERR(...) \
do { \
@@ -115,12 +116,12 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename
char path[PATH_MAX + 1] = {0x00};
#ifdef _POSIX_
if (strlen(outDirPath) > PATH_MAX || strncpy_s(path, PATH_MAX, outDirPath, strlen(outDirPath)) != EOK) {
if (strlen(outDirPath) >= PATH_MAX || strncpy_s(path, PATH_MAX, outDirPath, strlen(outDirPath)) != EOK) {
PRINT_ERR("get path(%s) failed\n", outDirPath);
return -1;
}
#else
if (strlen(outDirPath) > PATH_MAX || realpath(outDirPath, path) == NULL) {
if (strlen(outDirPath) >= PATH_MAX || realpath(outDirPath, path) == NULL) {
PRINT_ERR("get file(%s) real path failed\n", outDirPath);
return -1;
}
@@ -162,9 +163,9 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename
static cJSON *CreateWholeSyscapJsonObj(void)
{
size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
size_t allSyscapNum = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
cJSON *root = cJSON_CreateObject();
for (size_t i = 0; i < numOfSyscapAll; i++) {
for (size_t i = 0; i < allSyscapNum; i++) {
cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num));
}
return root;
@@ -281,6 +282,10 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson
uint32_t i;
int32_t ret = 0;
uint16_t sysCapLength = NtohsInter(*(uint16_t *)(input + sizeof(uint32_t)));
if (sysCapLength > inputLen - sizeof(uint32_t)) {
PRINT_ERR("Get sysCapLength(%u) error, inputLen = %u\n", sysCapLength, inputLen);
return -1;
}
uint16_t sysCapCount = sysCapLength / SINGLE_FEAT_LEN;
char *sysCapBegin = input + sizeof(RPCIDHead) + sizeof(uint32_t);
RPCIDHead *rpcidHeader = (RPCIDHead *)input;
@@ -421,7 +426,6 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath)
int32_t ret = 0;
int32_t sysCapArraySize;
uint32_t bufferLen, i;
uint16_t indexOs = 0;
uint16_t indexPri = 0;
uint16_t *osSysCapIndex;
char *contextBuffer = NULL;
@@ -475,8 +479,9 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath)
0, (size_t)(sysCapArraySize * SINGLE_SYSCAP_LEN));
priSyscap = priSyscapArray;
// part os syscap and ptivate syscap
for (i = 0; i < (uint32_t)sysCapArraySize; i++) {
cJSON *cJsonItem = cJSON_GetArrayItem(sysCapArray, (int)i);
uint16_t indexOs = 0;
for (int i = 0; i < sysCapArraySize; i++) {
cJSON *cJsonItem = cJSON_GetArrayItem(sysCapArray, i);
cJsonTemp = cJSON_GetObjectItem(sysCapDefine, cJsonItem->valuestring);
if (cJsonTemp != NULL) {
osSysCapIndex[indexOs++] = (uint16_t)(cJsonTemp->valueint);
@@ -557,7 +562,7 @@ int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uin
{
int32_t ret = 0;
uint32_t i;
size_t inputLen = strlen(inputString);
uint32_t count = 0;
char *temp = NULL;
char *tok = NULL;
@@ -568,7 +573,16 @@ int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uin
}
// copy to temp string input
char *input = (char *)malloc(strlen(inputString) + 1);
if (inputString == NULL) {
PRINT_ERR("inputString is null.\n");
return -1;
}
size_t inputLen = strlen(inputString);
if (inputLen > STRING_FORMAT_LEN_MAX) {
PRINT_ERR("input string too long(%zu).\n", inputLen);
return -1;
}
char *input = (char *)malloc(inputLen + 1);
if (input == NULL) {
PRINT_ERR("malloc failed.\n");
return -1;
@@ -650,6 +664,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ
bool priSysFound;
uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0};
uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0};
const size_t allSyscapNum = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
if (type == TYPE_FILE) {
if (GetFileContext(pcidFile, &pcidContent, &pcidContentLen)) {
@@ -692,9 +707,13 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ
continue;
}
for (uint8_t k = 0; k < INT_BIT; k++) {
if (temp2 & (0x1 << k)) {
// 2, header of pcid & rpcid
printf("Missing: %s\n", g_arraySyscap[(i - 2) * INT_BIT + k].str);
if (!(temp2 & (0x1 << k))) {
continue;
}
// 2, header of pcid & rpcid
size_t pos = (size_t)((i - 2) * INT_BIT + k);
if (pos < allSyscapNum) {
printf("Missing: %s\n", g_arraySyscap[pos].str);
ossyscapFlag += 1;
}
}