change 2in1 default device

Signed-off-by: fupengfei001 <fupengfei6@huawei.com>
This commit is contained in:
fupengfei001
2023-08-22 12:48:33 +08:00
parent ec45e8fa43
commit 315a0ac4bf
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -450,13 +450,20 @@ void JsAppImpl::AdaptDeviceType(Platform::AceRunArgs& args, const std::string ty
args.deviceConfig.density = args.deviceWidth / adaptWidthTv;
return;
}
if (type == "phone" || type == "2in1" || type == "default") {
if (type == "phone" || type == "default") {
args.deviceConfig.deviceType = DeviceType::PHONE;
double density = screenDendity > 0 ? screenDendity : phoneScreenDensity;
double adaptWidthPhone = realDeviceWidth * BASE_SCREEN_DENSITY / density;
args.deviceConfig.density = args.deviceWidth / adaptWidthPhone;
return;
}
if (type == "2in1") {
args.deviceConfig.deviceType = DeviceType::TABLET;
double density = screenDendity > 0 ? screenDendity : twoInOneScreenDensity;
double adaptWidthPhone = realDeviceWidth * BASE_SCREEN_DENSITY / density;
args.deviceConfig.density = args.deviceWidth / adaptWidthPhone;
return;
}
if (type == "tablet") {
args.deviceConfig.deviceType = DeviceType::TABLET;
double density = screenDendity > 0 ? screenDendity : tabletScreenDensity;
@@ -715,10 +722,14 @@ void JsAppImpl::SetDeviceScreenDensity(const int32_t screenDensity, const std::s
tvScreenDensity = screenDensity;
return;
}
if ((type == "phone" || type == "2in1" || type == "default") && screenDensity != 0) {
if ((type == "phone" || type == "default") && screenDensity != 0) {
phoneScreenDensity = screenDensity;
return;
}
if (type == "2in1" && screenDensity != 0) {
twoInOneScreenDensity = screenDensity;
return;
}
if (type == "tablet" && screenDensity != 0) {
tabletScreenDensity = screenDensity;
return;
+1
View File
@@ -91,6 +91,7 @@ protected:
double tvScreenDensity = 320; // TV Screen Density
double tabletScreenDensity = 400; // Tablet Screen Density
double carScreenDensity = 320; // Car Screen Density
double twoInOneScreenDensity = 240; // Car Screen Density
private:
void SetAssetPath(OHOS::Ace::Platform::AceRunArgs& args, const std::string) const;