mirror of
https://github.com/openharmony/utils_native_lite.git
synced 2026-07-19 22:43:34 -04:00
change param api
Change-Id: I43b8e4cd1a509310bd2a6c8c002a850d51aff95b
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+22
-6
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user