提交 6f6e087f 编写于 作者: O openharmony_ci 提交者: Gitee

!47 启动恢复子系统--系统属性API整改

Merge pull request !47 from lanxueyuan/lanxueyuan-change-param-api
......@@ -14,6 +14,7 @@
*/
#include "nativeapi_deviceinfo.h"
#include <string>
#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;
}
......
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册