diff --git a/frameworks/datatransmitmgr/dev_slinfo_adpt.c b/frameworks/datatransmitmgr/dev_slinfo_adpt.c index b1775760d447faaf9a59079b658e77dd023d56d6..58b7226dab887c22fcf8acfb1eb85569fca39c91 100644 --- a/frameworks/datatransmitmgr/dev_slinfo_adpt.c +++ b/frameworks/datatransmitmgr/dev_slinfo_adpt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,73 +20,76 @@ #include "dev_slinfo_log.h" #include "dev_slinfo_mgr.h" -void *g_deviceSecLevelHanle = NULL; +#define MAX_LIST_LENGTH 128 + +void *g_deviceSecLevelHandle = NULL; DeviceSecEnv g_deviceSecEnv; -static struct DATASLListParams *g_callback = NULL; +static struct DATASLListParams *g_callbackList = NULL; static void DestroyDeviceSecEnv(void) { - if (g_deviceSecLevelHanle != NULL) { + if (g_deviceSecLevelHandle != NULL) { (void)memset_s(&g_deviceSecEnv, sizeof(g_deviceSecEnv), 0, sizeof(g_deviceSecEnv)); - dlclose(g_deviceSecLevelHanle); - g_deviceSecLevelHanle = NULL; + dlclose(g_deviceSecLevelHandle); + g_deviceSecLevelHandle = NULL; } - if (g_callback != NULL) { - ClearList(g_callback); + if (g_callbackList != NULL) { + ClearList(g_callbackList); + g_callbackList = NULL; } return; } static int32_t DlopenSDK(void) { - g_deviceSecLevelHanle = dlopen("libdslm_sdk.z.so", RTLD_LAZY | RTLD_NODELETE); - if (g_deviceSecLevelHanle == NULL) { + g_deviceSecLevelHandle = dlopen("libdslm_sdk.z.so", RTLD_LAZY | RTLD_NODELETE); + if (g_deviceSecLevelHandle == NULL) { DATA_SEC_LOG_ERROR("failed to load libdevicesecmgrsdktmp: %s", dlerror()); return DEVSL_ERROR; } - return SUCCESS; + return DEVSL_SUCCESS; } static int32_t InitDeviceSecEnv(void) { - if (g_deviceSecLevelHanle != NULL) { + if (g_deviceSecLevelHandle != NULL) { DATA_SEC_LOG_WARN("libdevicesecmgrsdk already loaded"); - return SUCCESS; + return DEVSL_SUCCESS; } int32_t ret = DlopenSDK(); - if (ret != SUCCESS) { + if (ret != DEVSL_SUCCESS) { return ret; } RequestDeviceSecurityInfoFunction requestDeviceSecurityInfo = (RequestDeviceSecurityInfoFunction)dlsym( - g_deviceSecLevelHanle, "RequestDeviceSecurityInfo"); + g_deviceSecLevelHandle, "RequestDeviceSecurityInfo"); if (requestDeviceSecurityInfo == NULL) { - dlclose(g_deviceSecLevelHanle); - g_deviceSecLevelHanle = NULL; + dlclose(g_deviceSecLevelHandle); + g_deviceSecLevelHandle = NULL; DATA_SEC_LOG_ERROR("failed to find symbol: %s", dlerror()); return DEVSL_ERROR; } - FreeDeviceSecurityInfoFunction freeDeviceSecurityInfo = (FreeDeviceSecurityInfoFunction)dlsym(g_deviceSecLevelHanle, - "FreeDeviceSecurityInfo"); + FreeDeviceSecurityInfoFunction freeDeviceSecurityInfo = (FreeDeviceSecurityInfoFunction)dlsym( + g_deviceSecLevelHandle, "FreeDeviceSecurityInfo"); if (freeDeviceSecurityInfo == NULL) { - dlclose(g_deviceSecLevelHanle); - g_deviceSecLevelHanle = NULL; + dlclose(g_deviceSecLevelHandle); + g_deviceSecLevelHandle = NULL; DATA_SEC_LOG_ERROR("failed to find symbol: %s", dlerror()); return DEVSL_ERROR; } GetDeviceSecurityLevelValueFunction getDeviceSecurityLevelValue = (GetDeviceSecurityLevelValueFunction)dlsym( - g_deviceSecLevelHanle, "GetDeviceSecurityLevelValue"); + g_deviceSecLevelHandle, "GetDeviceSecurityLevelValue"); if (getDeviceSecurityLevelValue == NULL) { - dlclose(g_deviceSecLevelHanle); - g_deviceSecLevelHanle = NULL; + dlclose(g_deviceSecLevelHandle); + g_deviceSecLevelHandle = NULL; DATA_SEC_LOG_ERROR("failed to find symbol: %s", dlerror()); return DEVSL_ERROR; } RequestDeviceSecurityInfoAsyncFunction requestDeviceSecurityInfoAsync = - (RequestDeviceSecurityInfoAsyncFunction)dlsym(g_deviceSecLevelHanle, "RequestDeviceSecurityInfoAsync"); + (RequestDeviceSecurityInfoAsyncFunction)dlsym(g_deviceSecLevelHandle, "RequestDeviceSecurityInfoAsync"); if (requestDeviceSecurityInfoAsync == NULL) { - dlclose(g_deviceSecLevelHanle); - g_deviceSecLevelHanle = NULL; + dlclose(g_deviceSecLevelHandle); + g_deviceSecLevelHandle = NULL; DATA_SEC_LOG_ERROR("failed to find symbol: %s", dlerror()); return DEVSL_ERROR; } @@ -95,31 +98,30 @@ static int32_t InitDeviceSecEnv(void) g_deviceSecEnv.freeDeviceSecurityInfo = freeDeviceSecurityInfo; g_deviceSecEnv.getDeviceSecurityLevelValue = getDeviceSecurityLevelValue; g_deviceSecEnv.requestDeviceSecurityInfoAsync = requestDeviceSecurityInfoAsync; - return SUCCESS; + return DEVSL_SUCCESS; } int32_t StartDevslEnv() { DATA_SEC_LOG_INFO("Enter InitDeviceSecEnv..."); int32_t ret = InitDeviceSecEnv(); - DATA_SEC_LOG_INFO("InitDeviceSecEnv done"); - if (ret != SUCCESS) { + DATA_SEC_LOG_INFO("InitDeviceSecEnv done!"); + if (ret != DEVSL_SUCCESS) { return DEVSL_ERR_DEVICE_SEC_SDK_INIT; } - if (g_callback == NULL) { + if (g_callbackList == NULL) { ret = InitPthreadMutex(); - g_callback = InitList(); - } - - if (ret != SUCCESS) { - return DEVSL_ERR_INIT_MUTEX_LOCK; + if (ret != DEVSL_SUCCESS) { + return DEVSL_ERR_MUTEX_LOCK_INIT; + } + g_callbackList = InitList(); } - if (g_callback == NULL) { - return DEVSL_ERR_MALLOC_FAIL; + if (g_callbackList == NULL) { + return DEVSL_ERR_OUT_OF_MEMORY; } - return SUCCESS; + return DEVSL_SUCCESS; } void FinishDevslEnv(void) @@ -131,7 +133,7 @@ void FinishDevslEnv(void) int32_t GetDeviceSecLevelByUdid(uint8_t *udid, uint32_t udidLen, int32_t *devLevel) { - DATA_SEC_LOG_INFO("Enter GetDeviceSecLevelByUdid!"); + DATA_SEC_LOG_INFO("Enter GetDeviceSecLevelByUdid..."); if (g_deviceSecEnv.requestDeviceSecurityInfo == NULL) { DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdid: requestDeviceSecurityInfo is invalid"); return DEVSL_ERROR; @@ -153,9 +155,10 @@ int32_t GetDeviceSecLevelByUdid(uint8_t *udid, uint32_t udidLen, int32_t *devLev struct DeviceIdentify devId; (void)memset_s(&devId, sizeof(devId), 0, sizeof(devId)); - if (memcpy_s(devId.identity, DEVICE_ID_MAX_LEN, udid, udidLen) != EOK) { - DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdid, udid memcpy failed"); - return DEVSL_ERR_MEM_CPY; + ret = memcpy_s(devId.identity, MAX_UDID_LENGTH, udid, udidLen); + if (ret != EOK) { + DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdid: udid memcpy failed, ret is %d", ret); + return DEVSL_ERR_OUT_OF_MEMORY; } devId.length = udidLen; @@ -168,32 +171,31 @@ int32_t GetDeviceSecLevelByUdid(uint8_t *udid, uint32_t udidLen, int32_t *devLev ret = g_deviceSecEnv.getDeviceSecurityLevelValue(info, devLevel); if (ret != SUCCESS) { - DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdid, get device Security value failed, %d", ret); + DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdid: get device Security value failed, %d", ret); g_deviceSecEnv.freeDeviceSecurityInfo(info); return ret; } g_deviceSecEnv.freeDeviceSecurityInfo(info); DATA_SEC_LOG_INFO("GetDeviceSecLevelByUdid done!"); - return SUCCESS; + return DEVSL_SUCCESS; } -// Async void OnApiDeviceSecInfoCallback(const DeviceIdentify *identify, struct DeviceSecurityInfo *info) { - DATA_SEC_LOG_INFO("Enter OnApiDeviceSecInfoCallback!"); + DATA_SEC_LOG_INFO("Enter OnApiDeviceSecInfoCallback..."); if (identify == NULL) { - DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback: DeviceIdentify is null!"); + DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback: DeviceIdentify is null"); return; } int32_t ret = DEVSL_SUCCESS; if (info == NULL) { - DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback: DeviceSecurityInfo is null!"); + DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback: DeviceSecurityInfo is null"); ret = DEVSL_ERROR; } if (g_deviceSecEnv.getDeviceSecurityLevelValue == NULL) { - DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback: getDeviceSecValue is invalid"); + DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback: getDeviceSecurityLevelValue is invalid"); ret = DEVSL_ERROR; } @@ -205,12 +207,12 @@ void OnApiDeviceSecInfoCallback(const DeviceIdentify *identify, struct DeviceSec int32_t devLevel = DEFAULT_DEV_SEC_LEVEL; uint32_t levelInfo = DATA_SEC_LEVEL0; - if (ret != DEVSL_ERROR) { + if (ret == DEVSL_SUCCESS) { ret = g_deviceSecEnv.getDeviceSecurityLevelValue(info, &devLevel); if (ret != SUCCESS) { - DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback, get device security level value, %d", ret); + DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback: get device security level value, %d", ret); } else { - levelInfo = GetDataSecLevelByDevSecLevel(devLevel); + levelInfo = GetDataSecLevelByDevSecLevel(devLevel); } g_deviceSecEnv.freeDeviceSecurityInfo(info); } @@ -218,21 +220,21 @@ void OnApiDeviceSecInfoCallback(const DeviceIdentify *identify, struct DeviceSec DEVSLQueryParams queryParams; (void)memset_s(&queryParams, sizeof(queryParams), 0, sizeof(queryParams)); - if (memcpy_s(queryParams.udid, DEVICE_ID_MAX_LEN, identify->identity, identify->length) != EOK) { - DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback, udid memcpy failed"); + if (memcpy_s(queryParams.udid, MAX_UDID_LENGTH, identify->identity, identify->length) != EOK) { + DATA_SEC_LOG_ERROR("OnApiDeviceSecInfoCallback: udid memcpy failed"); return; } queryParams.udidLen = identify->length; - if (g_callback != NULL) { - LookupCallback(g_callback, &queryParams, ret, levelInfo); + if (g_callbackList != NULL) { + LookupCallback(g_callbackList, &queryParams, ret, levelInfo); } - DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback done, ret %d!", ret); + DATA_SEC_LOG_INFO("OnApiDeviceSecInfoCallback done!"); } int32_t GetDeviceSecLevelByUdidAsync(uint8_t *udid, uint32_t udidLen) { - DATA_SEC_LOG_INFO("Enter GetDeviceSecLevelByUdidAsync!"); + DATA_SEC_LOG_INFO("Enter GetDeviceSecLevelByUdidAsync..."); if (g_deviceSecEnv.requestDeviceSecurityInfoAsync == NULL) { DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdidAsync: requestDeviceSecurityInfoAsync is invalid"); return DEVSL_ERROR; @@ -242,24 +244,25 @@ int32_t GetDeviceSecLevelByUdidAsync(uint8_t *udid, uint32_t udidLen) DeviceIdentify devId; (void)memset_s(&devId, sizeof(devId), 0, sizeof(devId)); - if (memcpy_s(devId.identity, DEVICE_ID_MAX_LEN, udid, udidLen) != EOK) { - DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdidAsync, udid memcpy failed"); - return DEVSL_ERR_MEM_CPY; + ret = memcpy_s(devId.identity, MAX_UDID_LENGTH, udid, udidLen); + if (ret != EOK) { + DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdidAsync: memcpy udid failed, ret is %d", ret); + return DEVSL_ERR_OUT_OF_MEMORY; } devId.length = udidLen; ret = g_deviceSecEnv.requestDeviceSecurityInfoAsync(&devId, NULL, OnApiDeviceSecInfoCallback); if (ret != SUCCESS) { - DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdidAsync, request device security Info for Async failed, %d", ret); + DATA_SEC_LOG_ERROR("GetDeviceSecLevelByUdidAsync: request device security Info for Async failed, %d", ret); return ret; } - DATA_SEC_LOG_INFO("GetDeviceSecLevelByUdidAsync done, ret %d!", ret); + DATA_SEC_LOG_INFO("GetDeviceSecLevelByUdidAsync done!"); return ret; } int32_t CompareUdid(DEVSLQueryParams *queryParamsL, DEVSLQueryParams *queryParamsR) { - DATA_SEC_LOG_INFO("DATASL: Enter CompareUdid!"); + DATA_SEC_LOG_INFO("Enter CompareUdid..."); uint32_t i; if (queryParamsL->udidLen != queryParamsR->udidLen) { @@ -270,7 +273,8 @@ int32_t CompareUdid(DEVSLQueryParams *queryParamsL, DEVSLQueryParams *queryParam return DEVSL_ERROR; } } - return SUCCESS; + DATA_SEC_LOG_INFO("CompareUdid done!"); + return DEVSL_SUCCESS; } int32_t GetDataSecLevelByDevSecLevel(int32_t devLevel) @@ -302,35 +306,33 @@ int32_t GetDataSecLevelByDevSecLevel(int32_t devLevel) int32_t UpdateCallbackListParams(DEVSLQueryParams *queryParams, HigestSecInfoCallback *callback) { + DATA_SEC_LOG_INFO("Enter UpdateCallbackListParams..."); int32_t ret; - int32_t result = DEVSL_ERR_SERVICES_TOO_MANY; + int32_t result = DEVSL_ERR_REQUEST_DEVICE_EXCEED_LIMIT; int32_t levelInfo = DEFAULT_DEV_SEC_LEVEL; struct DATASLCallbackParams *newListNode = (struct DATASLCallbackParams*)malloc(sizeof(struct DATASLCallbackParams)); if (newListNode == NULL) { - return DEVSL_ERR_MALLOC_FAIL; + return DEVSL_ERR_OUT_OF_MEMORY; } - if (memcpy_s(newListNode->queryParams.udid, MAX_UDID_LENGTH, queryParams->udid, queryParams->udidLen) != EOK) { - DATA_SEC_LOG_ERROR("UpdateCallbackListParams, udid memcpy failed"); + + ret = memcpy_s(newListNode->queryParams.udid, MAX_UDID_LENGTH, queryParams->udid, queryParams->udidLen); + if (ret != EOK) { + DATA_SEC_LOG_ERROR("UpdateCallbackListParams: memcpy udid failed, ret is %d", ret); free(newListNode); - return DEVSL_ERR_MEM_CPY; + return DEVSL_ERR_OUT_OF_MEMORY; } newListNode->queryParams.udidLen = queryParams->udidLen; newListNode->callback = callback; - ret = GetListLength(g_callback); - if (ret == MAX_LIST_SUM) { - g_callback->next->callbackParams->callback(queryParams, result, levelInfo); - PopList(g_callback, g_callback->next->callbackParams); + ret = GetListLength(g_callbackList); + if (ret == MAX_LIST_LENGTH) { + g_callbackList->next->callbackParams->callback(queryParams, result, levelInfo); + RemoveListNode(g_callbackList, g_callbackList->next->callbackParams); } - ret = FindList(g_callback, newListNode); - if (ret != SUCCESS) { - ret = PushList(g_callback, newListNode); - if (ret != SUCCESS) { - return ret; - } - } - return SUCCESS; + ret = PushListNode(g_callbackList, newListNode); + DATA_SEC_LOG_INFO("UpdateCallbackListParams done!"); + return ret; } \ No newline at end of file diff --git a/frameworks/datatransmitmgr/dev_slinfo_list.c b/frameworks/datatransmitmgr/dev_slinfo_list.c index 5c2f627278b5f7121a235328da28b24d11fd11b0..832902dae1fb7b89d4f26e60957b91c0d3bd0c15 100644 --- a/frameworks/datatransmitmgr/dev_slinfo_list.c +++ b/frameworks/datatransmitmgr/dev_slinfo_list.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,6 +15,7 @@ #include "dev_slinfo_list.h" #include +#include "securec.h" #include "dev_slinfo_adpt.h" #include "dev_slinfo_log.h" @@ -34,7 +35,7 @@ struct DATASLListParams* InitList(void) return list; } -static void Update(struct DATASLListParams *new, struct DATASLListParams *prev, struct DATASLListParams *next) +static void UpdateListNode(struct DATASLListParams *new, struct DATASLListParams *prev, struct DATASLListParams *next) { next->prev = new; new->next = next; @@ -42,36 +43,27 @@ static void Update(struct DATASLListParams *new, struct DATASLListParams *prev, prev->next = new; } -int32_t PushList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) +int32_t PushListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) { - DATA_SEC_LOG_INFO("PushList, ret!"); pthread_mutex_lock(&gMutex); struct DATASLListParams *newList = (struct DATASLListParams*)malloc(sizeof(struct DATASLListParams)); if (newList == NULL) { pthread_mutex_unlock(&gMutex); - return DEVSL_ERR_MALLOC_FAIL; - } - if (list->prev == NULL) { - list->prev = newList; - list->next = newList; - newList->prev = list; - newList->next = list; - } else { - Update(newList, list->prev, list); + return DEVSL_ERR_OUT_OF_MEMORY; } + + UpdateListNode(newList, list->prev, list); newList->callbackParams = (struct DATASLCallbackParams*)callbackParams; pthread_mutex_unlock(&gMutex); - DATA_SEC_LOG_INFO("PushList done, ret!"); - return SUCCESS; + return DEVSL_SUCCESS; } -void PopList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) +void RemoveListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) { - DATA_SEC_LOG_INFO("PopList, ret!"); pthread_mutex_lock(&gMutex); struct DATASLListParams *pList = list->next; while (pList != NULL && pList != list) { - if (CompareUdid(&(pList->callbackParams->queryParams), &(callbackParams->queryParams)) == SUCCESS) { + if (CompareUdid(&(pList->callbackParams->queryParams), &(callbackParams->queryParams)) == DEVSL_SUCCESS) { pList->prev->next = pList->next; pList->next->prev = pList->prev; free(pList->callbackParams); @@ -81,19 +73,20 @@ void PopList(struct DATASLListParams *list, struct DATASLCallbackParams *callba pList = pList->next; } pthread_mutex_unlock(&gMutex); - DATA_SEC_LOG_INFO("PopList done, ret!"); } void ClearList(struct DATASLListParams *list) { pthread_mutex_lock(&gMutex); struct DATASLListParams *pList = list->next; - while (pList == NULL || pList != list) { + while (pList != NULL && pList != list) { struct DATASLListParams *delList = pList; pList = pList->next; free(delList->callbackParams); free(delList); } + free(list->callbackParams); + free(list); pthread_mutex_unlock(&gMutex); } @@ -110,43 +103,47 @@ int32_t GetListLength(struct DATASLListParams *list) return listLength; } -int32_t FindList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) +int32_t FindListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams) { pthread_mutex_lock(&gMutex); - DATA_SEC_LOG_INFO("DATASL: FindList, ret!"); struct DATASLListParams *pList = list->next; - DATA_SEC_LOG_INFO("DATASL: list is not NULL!"); while (pList != NULL && pList != list) { - DATA_SEC_LOG_INFO("DATASL: while is ok!"); - if (CompareUdid(&(pList->callbackParams->queryParams), &(callbackParams->queryParams)) == SUCCESS) { - DATA_SEC_LOG_INFO("FindList fine done, ret!"); + if (CompareUdid(&(pList->callbackParams->queryParams), &(callbackParams->queryParams)) == DEVSL_SUCCESS) { pthread_mutex_unlock(&gMutex); - return SUCCESS; + return DEVSL_SUCCESS; } pList = pList->next; } - DATA_SEC_LOG_INFO("FindList not find, ret!"); pthread_mutex_unlock(&gMutex); return DEVSL_ERROR; } void LookupCallback(struct DATASLListParams *list, DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo) { + struct DATASLCallbackParams tmpCallbackParams; + (void)memset_s(&tmpCallbackParams, sizeof(struct DATASLCallbackParams), 0, sizeof(struct DATASLCallbackParams)); + int32_t ret = DEVSL_ERROR; pthread_mutex_lock(&gMutex); struct DATASLListParams *tmpCallback = list->next; while (tmpCallback != NULL && tmpCallback != list) { struct DATASLListParams *nextCallback = tmpCallback->next; - int32_t ret = CompareUdid(&(tmpCallback->callbackParams->queryParams), queryParams); - if (ret == SUCCESS) { - tmpCallback->callbackParams->callback(&(tmpCallback->callbackParams->queryParams), result, levelInfo); + ret = CompareUdid(&(tmpCallback->callbackParams->queryParams), queryParams); + if (ret == DEVSL_SUCCESS) { + (void)memcpy_s(&tmpCallbackParams.queryParams, sizeof(DEVSLQueryParams), + queryParams, sizeof(DEVSLQueryParams)); + tmpCallbackParams.callback = tmpCallback->callbackParams->callback; tmpCallback->prev->next = tmpCallback->next; tmpCallback->next->prev = tmpCallback->prev; free(tmpCallback->callbackParams); free(tmpCallback); + break; } tmpCallback = nextCallback; } pthread_mutex_unlock(&gMutex); + if (ret == DEVSL_SUCCESS) { + tmpCallbackParams.callback(&(tmpCallbackParams.queryParams), result, levelInfo); + } } int32_t InitPthreadMutex(void) diff --git a/frameworks/datatransmitmgr/dev_slinfo_mgr.c b/frameworks/datatransmitmgr/dev_slinfo_mgr.c index 664e6a1fc2727b0262322e0e5bd1aa6227ae739b..f55165b4398226dd85103ebc86ea030aa5621dbc 100644 --- a/frameworks/datatransmitmgr/dev_slinfo_mgr.c +++ b/frameworks/datatransmitmgr/dev_slinfo_mgr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,102 +20,97 @@ extern "C" { #endif -#define DEVSL_API __attribute__ ((visibility ("default"))) +#define DATASL_API __attribute__ ((visibility ("default"))) static int32_t GetHigestSecLevelByUdid(DEVSLQueryParams *queryParams, uint32_t *dataLevel) { - int32_t ret = 0; + int32_t ret; int32_t devLevel = DEFAULT_DEV_SEC_LEVEL; - DATA_SEC_LOG_INFO("GetHighestSecLevelByUdid by udid!"); - if ((queryParams->udidLen < 0u) || (queryParams->udidLen > 64u)) { - return ERR_INVALID_PARA; + if ((queryParams->udidLen <= 0u) || (queryParams->udidLen > 64u)) { + return DEVSL_ERR_BAD_PARAMETERS; } ret = GetDeviceSecLevelByUdid(queryParams->udid, queryParams->udidLen, &devLevel); - if (ret != SUCCESS) { + if (ret != DEVSL_SUCCESS) { *dataLevel = DATA_SEC_LEVEL0; - DATA_SEC_LOG_ERROR("GetHigestSecLevelByUdid, get device security level failed, error code: %d", ret); + DATA_SEC_LOG_ERROR("GetHigestSecLevelByUdid: get device security level failed, error code: %d", ret); return ret; } - *dataLevel = GetDataSecLevelByDevSecLevel(devLevel); + *dataLevel = GetDataSecLevelByDevSecLevel(devLevel); return ret; } -DEVSL_API int32_t DATASL_OnStart(void) +DATASL_API int32_t DATASL_OnStart(void) { int32_t ret; - DATA_SEC_LOG_INFO("Enter DATASL_Onstart"); + DATA_SEC_LOG_INFO("Enter DATASL_Onstart..."); ret = StartDevslEnv(); - if (ret != SUCCESS) { - DATA_SEC_LOG_ERROR("StartDevslEnv - failed, error code is %d", ret); + if (ret != DEVSL_SUCCESS) { + DATA_SEC_LOG_ERROR("DATASL_Onstart: StartDevslEnv - failed, error code is %d", ret); FinishDevslEnv(); return DEVSL_ERROR; } - DATA_SEC_LOG_INFO("DATASL_Onstart - success"); - return SUCCESS; + DATA_SEC_LOG_INFO("DATASL_Onstart done!"); + return DEVSL_SUCCESS; } -DEVSL_API void DATASL_OnStop(void) +DATASL_API void DATASL_OnStop(void) { - DATA_SEC_LOG_INFO("Enter DATASL_OnStop"); + DATA_SEC_LOG_INFO("Enter DATASL_OnStop..."); FinishDevslEnv(); - DATA_SEC_LOG_INFO("DATASL_OnStop done"); + DATA_SEC_LOG_INFO("DATASL_OnStop done!"); return; } -DEVSL_API int32_t DATASL_GetHighestSecLevel(DEVSLQueryParams *queryParams, uint32_t *levelInfo) +DATASL_API int32_t DATASL_GetHighestSecLevel(DEVSLQueryParams *queryParams, uint32_t *levelInfo) { int32_t ret = 0; - DATA_SEC_LOG_INFO("Enter DATASL_GetHighestSecLevel!"); + DATA_SEC_LOG_INFO("Enter DATASL_GetHighestSecLevel..."); if ((queryParams == NULL) || (levelInfo == NULL)) { - return ERR_INVALID_PARA; + return DEVSL_ERR_BAD_PARAMETERS; } ret = GetHigestSecLevelByUdid(queryParams, levelInfo); - DATA_SEC_LOG_INFO("DATASL_GetHighestSecLevel done, ret %d!", ret); + DATA_SEC_LOG_INFO("DATASL_GetHighestSecLevel done!"); return ret; } -// Async static int32_t GetHighestSecLevelByUdidAsync(DEVSLQueryParams *queryParams) { - DATA_SEC_LOG_INFO("Enter GetHighestSecLevelByUdidAsync!"); + DATA_SEC_LOG_INFO("Enter GetHighestSecLevelByUdidAsync..."); int32_t ret; - if ((queryParams->udidLen < 0u) || (queryParams->udidLen > 64u)) { - return ERR_INVALID_PARA; - } - ret = GetDeviceSecLevelByUdidAsync(queryParams->udid, queryParams->udidLen); - if (ret != SUCCESS) { - DATA_SEC_LOG_ERROR("GetHigestSecLevelByUdid, get device security level failed, error code: %d", ret); + if (ret != DEVSL_SUCCESS) { + DATA_SEC_LOG_ERROR("GetHighestSecLevelByUdidAsync: get device security level failed, error code: %d", ret); return ret; } - - DATA_SEC_LOG_INFO("GetHighestSecLevelByUdidAsync done, ret %d!", ret); + + DATA_SEC_LOG_INFO("GetHighestSecLevelByUdidAsync done!"); return ret; } -DEVSL_API int32_t DATASL_GetHighestSecLevelAsync(DEVSLQueryParams *queryParams, HigestSecInfoCallback *callback) +DATASL_API int32_t DATASL_GetHighestSecLevelAsync(DEVSLQueryParams *queryParams, HigestSecInfoCallback *callback) { - DATA_SEC_LOG_INFO("Enter DATASL_GetHighestSecLevelAsync!"); + DATA_SEC_LOG_INFO("Enter DATASL_GetHighestSecLevelAsync..."); int32_t ret; - if ((queryParams == NULL) || (callback == NULL)) { - return ERR_INVALID_PARA; + if ((queryParams == NULL) || (callback == NULL) || (queryParams->udidLen <= 0u) || (queryParams->udidLen > 64u)) { + return DEVSL_ERR_BAD_PARAMETERS; } ret = UpdateCallbackListParams(queryParams, callback); - if (ret != SUCCESS) { + if (ret != DEVSL_SUCCESS) { + DATA_SEC_LOG_ERROR("DATASL_GetHighestSecLevelAsync: Update Callback list params failed, error code: %d", ret); return ret; } ret = GetHighestSecLevelByUdidAsync(queryParams); - DATA_SEC_LOG_INFO("DATASL_GetHighestSecLevelAsync done, ret %d!", ret); + DATA_SEC_LOG_INFO("DATASL_GetHighestSecLevelAsync done!"); return ret; } diff --git a/interfaces/innerkits/datatransmitmgr/BUILD.gn b/interfaces/innerkits/datatransmitmgr/BUILD.gn index 91a30b5d4d51b14205d7e9d5bbf7b791649e6932..137b0d3323af050a4cc8115e1c3bf578b270968d 100644 --- a/interfaces/innerkits/datatransmitmgr/BUILD.gn +++ b/interfaces/innerkits/datatransmitmgr/BUILD.gn @@ -1,49 +1,45 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. - -import("//build/ohos.gni") - -################################################################ -# C, Main source file here. -################################################################ -config("datatransmitmgr_config") { - include_dirs = [ "include" ] -} - -ohos_shared_library("data_transit_mgr") { - subsystem_name = "security" - part_name = "dataclassification" - - public_configs = [ ":datatransmitmgr_config" ] - - include_dirs = [ - "include", - ] - - sources = [ - "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_mgr.c", - "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_list.c", - "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_adpt.c", - ] - - deps = [ - "//utils/native/base:utils", - ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "device_security_level:dslm_sdk", - ] - - cflags = [ "-Wall" ] -} + +import("//build/ohos.gni") + +################################################################ +# C, Main source file here. +################################################################ +config("datatransmitmgr_config") { + include_dirs = [ "include" ] +} + +ohos_shared_library("data_transit_mgr") { + subsystem_name = "security" + part_name = "dataclassification" + + public_configs = [ ":datatransmitmgr_config" ] + + include_dirs = [ "include" ] + + sources = [ + "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_adpt.c", + "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_list.c", + "//base/security/dataclassification/frameworks/datatransmitmgr/dev_slinfo_mgr.c", + ] + + deps = [ "//utils/native/base:utils" ] + + external_deps = [ + "device_security_level:dslm_sdk", + "hiviewdfx_hilog_native:libhilog", + ] + + cflags = [ "-Wall" ] +} diff --git a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_adpt.h b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_adpt.h index 6a8bc10faad90bf34569c3c6c04b44358e2b56f2..b93f9f8ce07e193b11367ed62ef7b832a6fdd156 100644 --- a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_adpt.h +++ b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_adpt.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_list.h b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_list.h index f7997d032408ac22f478ce8c71af92c00ac3d5db..11ee1db4c27adbfb196b33413dff1b6e218d2c0b 100644 --- a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_list.h +++ b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_list.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -32,15 +32,15 @@ struct DATASLListParams { struct DATASLListParams* InitList(void); -int32_t PushList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); +int32_t PushListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); -void PopList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); +void RemoveListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); void ClearList(struct DATASLListParams *list); -int GetListLength(struct DATASLListParams *list); +int32_t GetListLength(struct DATASLListParams *list); -int32_t FindList(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); +int32_t FindListNode(struct DATASLListParams *list, struct DATASLCallbackParams *callbackParams); int32_t InitPthreadMutex(void); diff --git a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_log.h b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_log.h index c5c0bea23576f2f2a36ee7c331035c612cb36387..3d3f7a9ea964489e9674fdc2b96294a598a4486a 100644 --- a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_log.h +++ b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_log.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_mgr.h b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_mgr.h index 612e4dff98a100256f22dfff50e046436edf5b3d..ccac98d821164d8d30e0bde6ec3178e606ee912d 100644 --- a/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_mgr.h +++ b/interfaces/innerkits/datatransmitmgr/include/dev_slinfo_mgr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,7 +22,6 @@ extern "C" { #endif -#define MAX_LIST_SUM 128 #define MAX_UDID_LENGTH 64 #define DATA_SEC_LEVEL0 0 /* s0 */ @@ -39,14 +38,11 @@ typedef struct { enum { DEVSL_SUCCESS = 0, DEVSL_ERROR = 100, - DEVSL_ERR_GET_DEV_SEC_NOT_ONLINE = 101, - DEVSL_ERR_SERVICES_TOO_MANY = 102, - DEVSL_ERR_REPEATED_SERVICES = 103, - DEVSL_ERR_MEM_CPY = 104, - DEVSL_ERR_DEVICE_SEC_SDK_INIT = 105, - DEVSL_ERR_MALLOC_FAIL = 106, - DEVSL_MUTEX_UNLOCK = 107, - DEVSL_ERR_INIT_MUTEX_LOCK = 108, + DEVSL_ERR_REQUEST_DEVICE_EXCEED_LIMIT = 101, + DEVSL_ERR_DEVICE_SEC_SDK_INIT = 102, + DEVSL_ERR_OUT_OF_MEMORY = 103, + DEVSL_ERR_MUTEX_LOCK_INIT = 104, + DEVSL_ERR_BAD_PARAMETERS = 105, }; int32_t DATASL_GetHighestSecLevel(DEVSLQueryParams *queryParams, uint32_t *levelInfo); @@ -55,7 +51,6 @@ int32_t DATASL_OnStart(void); void DATASL_OnStop(void); -// Async typedef void HigestSecInfoCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo); int32_t DATASL_GetHighestSecLevelAsync(DEVSLQueryParams *queryParams, HigestSecInfoCallback *callback); diff --git a/test/unittest/datatransmitmgr/BUILD.gn b/test/unittest/datatransmitmgr/BUILD.gn index 8e52ab82c52b2d8151258f16f1cb1da3381da4a2..062bc3cfd149cfe66926de79d25c1d5597645ad1 100644 --- a/test/unittest/datatransmitmgr/BUILD.gn +++ b/test/unittest/datatransmitmgr/BUILD.gn @@ -1,44 +1,44 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Copyright (C) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. - -import("//build/test.gni") -module_output_path = "dataclassification/datasecuritylevel" - -config("datatransmitmgr_test_config") { - visibility = [ ":*" ] - include_dirs = [ - "//base/security/dataclassification/test/unittest/datatransmitmgr", - "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr/include", - "//third_party/googletest/googletest/include", - "//utils/native/base/include", - ] - cflags = [ "-DHILOG_ENABLE" ] -} - -ohos_unittest("DevSLMgrTest") { - part_name = "dataclassification" - subsystem_name = "security" - module_out_path = module_output_path - - sources = [ "DevSLMgrTest.cpp" ] - - deps = [ - "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr:data_transit_mgr", - "//utils/native/base:utils", - ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "dsoftbus_standard:softbus_client", - "device_security_level:dslm_sdk", - ] -} \ No newline at end of file + +import("//build/test.gni") +module_output_path = "dataclassification/datasecuritylevel" + +config("datatransmitmgr_test_config") { + visibility = [ ":*" ] + include_dirs = [ + "//base/security/dataclassification/test/unittest/datatransmitmgr", + "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr/include", + "//third_party/googletest/googletest/include", + "//utils/native/base/include", + ] + cflags = [ "-DHILOG_ENABLE" ] +} + +ohos_unittest("DevSLMgrTest") { + part_name = "dataclassification" + subsystem_name = "security" + module_out_path = module_output_path + + sources = [ "DevSLMgrTest.cpp" ] + + deps = [ + "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr:data_transit_mgr", + "//utils/native/base:utils", + ] + external_deps = [ + "device_security_level:dslm_sdk", + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + ] +} diff --git a/test/unittest/datatransmitmgr/DevSLMgrTest.cpp b/test/unittest/datatransmitmgr/DevSLMgrTest.cpp index d5132c80bc750121d5db44d78eff4d88e3488b3c..b3f14b4fc061ecb98a35998af2ad46db9053f20a 100644 --- a/test/unittest/datatransmitmgr/DevSLMgrTest.cpp +++ b/test/unittest/datatransmitmgr/DevSLMgrTest.cpp @@ -1,6 +1,5 @@ - /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -32,7 +31,6 @@ protected: static void TearDownTestCase(); void SetUp() override; void TearDown() override; - private: }; @@ -55,7 +53,7 @@ static HWTEST_F(DevSLMgrTest, TestOnstart, TestSize.Level1) int32_t ret; ret = DATASL_OnStart(); - EXPECT_EQ(SUCCESS, ret); + EXPECT_EQ(DEVSL_SUCCESS, ret); } static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevel001, TestSize.Level1) @@ -65,22 +63,22 @@ static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevel001, TestSize.Level1) ret = DATASL_OnStart(); ret = DATASL_GetHighestSecLevel(nullptr, &levelInfo); - EXPECT_EQ(ERR_INVALID_PARA, ret); + EXPECT_EQ(DEVSL_ERR_BAD_PARAMETERS, ret); } static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevel002, TestSize.Level1) { int32_t ret; - + DEVSLQueryParams queryParams; (void)memset_s(&queryParams, sizeof(queryParams), 0, sizeof(queryParams)); DATASL_GetUdidByOpp(&queryParams); ret = DATASL_OnStart(); ret = DATASL_GetHighestSecLevel(&queryParams, nullptr); - EXPECT_EQ(ERR_INVALID_PARA, ret); + EXPECT_EQ(DEVSL_ERR_BAD_PARAMETERS, ret); } - + static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevel003, TestSize.Level1) { int32_t ret; @@ -96,10 +94,9 @@ static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevel003, TestSize.Level1) EXPECT_EQ(ERR_NOEXIST_DEVICE, ret); } -// Aysnc static void tmpCallback000(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo) { - EXPECT_EQ(ERR_INVALID_PARA, result); + EXPECT_EQ(DEVSL_ERR_BAD_PARAMETERS, result); } static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevelAsync001, TestSize.Level1) @@ -108,7 +105,7 @@ static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevelAsync001, TestSize.Level1) ret = DATASL_OnStart(); ret = DATASL_GetHighestSecLevelAsync(nullptr, &tmpCallback000); - EXPECT_EQ(ERR_INVALID_PARA, ret); + EXPECT_EQ(DEVSL_ERR_BAD_PARAMETERS, ret); } static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevelAsync002, TestSize.Level1) @@ -119,7 +116,7 @@ static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevelAsync002, TestSize.Level1) DATASL_GetUdidByOpp(&queryParams); ret = DATASL_GetHighestSecLevelAsync(&queryParams, nullptr); - EXPECT_EQ(ERR_INVALID_PARA, ret); + EXPECT_EQ(DEVSL_ERR_BAD_PARAMETERS, ret); } static void tmpCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo) @@ -127,6 +124,7 @@ static void tmpCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t EXPECT_EQ(ERR_NOEXIST_DEVICE, result); EXPECT_EQ(DATA_SEC_LEVEL0, static_cast(levelInfo)); } + static HWTEST_F(DevSLMgrTest, TestGetHighestSecLevelAsync003, TestSize.Level1) { int32_t ret; diff --git a/test/unittest/datatransmitmgr/DevSLMgrTest.h b/test/unittest/datatransmitmgr/DevSLMgrTest.h index 18563723599978907c4c8902852743d23852ce3e..45ea6022b4f2b2d6ae7264a7836d766e3499f8cb 100644 --- a/test/unittest/datatransmitmgr/DevSLMgrTest.h +++ b/test/unittest/datatransmitmgr/DevSLMgrTest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at