fix @system.device getInfo

Signed-off-by: laiguizhong <laiguizhong@huawei.com>
Change-Id: I7164240dbf58c1c6d35a3dc168a4c4c282400048
This commit is contained in:
laiguizhong
2022-04-17 08:12:52 +08:00
parent cb4640775a
commit b74e2755f4
4 changed files with 42 additions and 14 deletions
+18 -7
View File
@@ -202,13 +202,14 @@ void SystemProperties::InitDeviceInfo(
resolution_ = resolution;
deviceWidth_ = deviceWidth;
deviceHeight_ = deviceHeight;
brand_ = system::GetParameter("ro.product.brand", INVALID_PARAM);
manufacturer_ = system::GetParameter("ro.product.manufacturer", INVALID_PARAM);
model_ = system::GetParameter("ro.product.model", INVALID_PARAM);
product_ = system::GetParameter("ro.product.name", INVALID_PARAM);
apiVersion_ = system::GetParameter("hw_sc.build.os.apiversion", INVALID_PARAM);
releaseType_ = system::GetParameter("hw_sc.build.os.releasetype", INVALID_PARAM);
paramDeviceType_ = system::GetParameter("hw_sc.build.os.devicetype", INVALID_PARAM);
brand_ = system::GetParameter("const.product.brand", INVALID_PARAM);
manufacturer_ = system::GetParameter("const.product.manufacturer", INVALID_PARAM);
model_ = system::GetParameter("const.product.model", INVALID_PARAM);
product_ = system::GetParameter("const.product.name", INVALID_PARAM);
apiVersion_ = system::GetParameter("const.ohos.apiversion", INVALID_PARAM);
releaseType_ = system::GetParameter("const.ohos.releasetype", INVALID_PARAM);
paramDeviceType_ = system::GetParameter("const.build.characteristics", INVALID_PARAM);
debugEnabled_ = IsDebugEnabled();
traceEnabled_ = IsTraceEnabled();
accessibilityEnabled_ = IsAccessibilityEnabled();
@@ -254,4 +255,14 @@ bool SystemProperties::GetDebugEnabled()
{
return debugEnabled_;
}
std::string SystemProperties::GetLanguage()
{
return system::GetParameter("const.global.language", INVALID_PARAM);
}
std::string SystemProperties::GetRegion()
{
return system::GetParameter("const.global.region", INVALID_PARAM);
}
} // namespace OHOS::Ace
@@ -156,4 +156,14 @@ bool SystemProperties::GetDebugEnabled()
{
return false;
}
std::string SystemProperties::GetLanguage()
{
return UNDEFINED_PARAM;
}
std::string SystemProperties::GetRegion()
{
return UNDEFINED_PARAM;
}
} // namespace OHOS::Ace
@@ -172,6 +172,10 @@ public:
return paramDeviceType_;
}
static std::string GetLanguage();
static std::string GetRegion();
static bool GetRosenBackendEnabled()
{
return rosenBackendEnabled_;
@@ -52,6 +52,16 @@ void PluginBridge::ProcessSystemParam(std::unique_ptr<JsonValue>& infoList)
if (tmp != SystemProperties::INVALID_PARAM) {
infoList->Put("deviceType", tmp.c_str());
}
tmp = SystemProperties::GetLanguage();
if (tmp != SystemProperties::INVALID_PARAM) {
infoList->Put("language", tmp.c_str());
}
tmp = SystemProperties::GetRegion();
if (tmp != SystemProperties::INVALID_PARAM) {
infoList->Put("region", tmp.c_str());
}
}
std::pair<std::string, bool> PluginBridge::GetDeviceInfo()
@@ -60,13 +70,6 @@ std::pair<std::string, bool> PluginBridge::GetDeviceInfo()
auto infoList = JsonUtil::Create(true);
ProcessSystemParam(infoList);
if (!AceApplicationInfo::GetInstance().GetLanguage().empty()) {
infoList->Put("language", AceApplicationInfo::GetInstance().GetLanguage().c_str());
}
if (!AceApplicationInfo::GetInstance().GetCountryOrRegion().empty()) {
infoList->Put("region", AceApplicationInfo::GetInstance().GetCountryOrRegion().c_str());
}
auto container = Container::Current();
int32_t width = container ? container->GetViewWidth() : 0;
if (width != 0) {