diff --git a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp index 4845a09..5e57858 100755 --- a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp +++ b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp @@ -14,6 +14,7 @@ */ #include "nativeapi_deviceinfo.h" +#include #include "global.h" #include "js_async_work.h" #include "nativeapi_common.h" @@ -69,13 +70,11 @@ void InitDeviceModule(JSIValue exports) bool NativeapiDeviceInfo::GetAPILevel(JSIValue result) { - char* apiLevel = GetSdkApiLevel(); - if (apiLevel == nullptr) { + int apiLevel = GetSdkApiVersion(); + if (apiLevel < 1) { return false; } - JSI::SetStringProperty(result, "apiVersion", apiLevel); - free(apiLevel); - apiLevel = nullptr; + JSI::SetStringProperty(result, "apiVersion", std::to_string(apiLevel).c_str()); return true; } @@ -86,13 +85,11 @@ JSIValue NativeapiDeviceInfo::GetDeviceInfo(const JSIValue thisVal, const JSIVal bool NativeapiDeviceInfo::GetDeviceType(JSIValue result) { - char* deviceType = GetProductType(); + const char* deviceType = ::GetDeviceType(); if (deviceType == nullptr) { return false; } JSI::SetStringProperty(result, "deviceType", deviceType); - free(deviceType); - deviceType = nullptr; return true; } @@ -111,9 +108,9 @@ bool NativeapiDeviceInfo::GetLanguage(JSIValue result) bool NativeapiDeviceInfo::GetProductInfo(JSIValue result) { bool isSuccess = true; - char* brand = GetBrand(); - char* manufacture = GetManufacture(); - char* model = GetProductModel(); + const char* brand = GetBrand(); + const char* manufacture = GetManufacture(); + const char* model = GetProductModel(); if (brand == nullptr || manufacture == nullptr || model == nullptr) { isSuccess = false; } else { @@ -139,18 +136,6 @@ bool NativeapiDeviceInfo::GetProductInfo(JSIValue result) const char * const defaultScreenShape = "rect"; JSI::SetNumberProperty(result, "screenDensity", (double)defaultScreenDensity); JSI::SetStringProperty(result, "screenShape", defaultScreenShape); - if (brand != nullptr) { - free(brand); - brand = nullptr; - } - if (manufacture != nullptr) { - free(manufacture); - manufacture = nullptr; - } - if (model != nullptr) { - free(model); - model = nullptr; - } return isSuccess; } diff --git a/os_dump/dump_syspara.c b/os_dump/dump_syspara.c index 4646cf4..c6542c5 100644 --- a/os_dump/dump_syspara.c +++ b/os_dump/dump_syspara.c @@ -21,8 +21,26 @@ #include "wifiiot_at.h" #endif +#define API_VERSION_LEN 10 + +static const char* GetSdkApiLevel() +{ + static char sdkApiVersion[API_VERSION_LEN] = {0}; + int sdkApi = GetSdkApiVersion(); + sprintf_s(sdkApiVersion, API_VERSION_LEN, "%d", sdkApi); + return sdkApiVersion; +} + +static const char* GetFirstApiLevel() +{ + static char firstApiVersion[API_VERSION_LEN] = {0}; + int firstApi = GetSdkApiVersion(); + sprintf_s(firstApiVersion, API_VERSION_LEN, "%d", firstApi); + return firstApiVersion; +} + static const SysParaInfoItem SYSPARA_LIST[] = { - {"ProductType", GetProductType}, + {"DeviceType", GetDeviceType}, {"Manufacture", GetManufacture}, {"Brand", GetBrand}, {"MarketName", GetMarketName}, @@ -31,13 +49,13 @@ static const SysParaInfoItem SYSPARA_LIST[] = { {"SoftwareModel", GetSoftwareModel}, {"HardwareModel", GetHardwareModel}, {"Serial", GetSerial}, - {"OsName", GetOsName}, + {"OSFullName", GetOSFullName}, {"DisplayVersion", GetDisplayVersion}, {"BootloaderVersion", GetBootloaderVersion}, {"GetSecurityPatchTag", GetSecurityPatchTag}, {"AbiList", GetAbiList}, - {"SdkApiLevel", GetSdkApiLevel}, - {"FirstApiLevel", GetFirstApiLevel}, + {"SdkApiVersion", GetSdkApiLevel}, + {"FirstApiVersion", GetFirstApiLevel}, {"IncrementalVersion", GetIncrementalVersion}, {"VersionId", GetVersionId}, {"BuildType", GetBuildType}, @@ -64,8 +82,6 @@ int QuerySysparaCmd() while (index < dumpInfoItemNum) { temp = SYSPARA_LIST[index].getInfoValue(); pfnPrintf("%s:%s\r\n", SYSPARA_LIST[index].infoName, temp); - free(temp); - temp = NULL; index++; } pfnPrintf("=======================\r\n");