mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-21 09:45:22 -04:00
+96
-12
@@ -49,18 +49,21 @@ void StageContext::ParseAppInfo(const Json::Value& root)
|
||||
}
|
||||
appInfo.apiReleaseType = JsonReader::GetString(root, "apiReleaseType");
|
||||
appInfo.bundleName = JsonReader::GetString(root, "bundleName");
|
||||
appInfo.bundleType = JsonReader::GetString(root, "bundleType");
|
||||
appInfo.icon = JsonReader::GetString(root, "icon");
|
||||
appInfo.label = JsonReader::GetString(root, "label");
|
||||
appInfo.vendor = JsonReader::GetString(root, "vendor");
|
||||
appInfo.versionName = JsonReader::GetString(root, "versionName");
|
||||
appInfo.compileSdkType = JsonReader::GetString(root, "compileSdkType");
|
||||
appInfo.compileSdkVersion = JsonReader::GetString(root, "compileSdkVersion");
|
||||
appInfo.debug = JsonReader::GetBool(root, "debug", false);
|
||||
appInfo.distributedNotificationEnabled = JsonReader::GetBool(root, "distributedNotificationEnabled", true);
|
||||
appInfo.icon = JsonReader::GetString(root, "icon");
|
||||
appInfo.iconId = JsonReader::GetUInt(root, "iconId", 0);
|
||||
appInfo.label = JsonReader::GetString(root, "label");
|
||||
appInfo.labelId = JsonReader::GetUInt(root, "labelId", 0);
|
||||
appInfo.minAPIVersion = JsonReader::GetUInt(root, "minAPIVersion", 0);
|
||||
appInfo.targetAPIVersion = JsonReader::GetUInt(root, "targetAPIVersion", 0);
|
||||
appInfo.vendor = JsonReader::GetString(root, "vendor");
|
||||
appInfo.versionCode = JsonReader::GetUInt(root, "versionCode", 0);
|
||||
appInfo.versionName = JsonReader::GetString(root, "versionName");
|
||||
// from arkui
|
||||
appInfo.bundleType = JsonReader::GetString(root, "bundleType");
|
||||
appInfo.distributedNotificationEnabled = JsonReader::GetBool(root, "distributedNotificationEnabled", true);
|
||||
}
|
||||
|
||||
void StageContext::ParseHapModuleInfo(const Json::Value& root)
|
||||
@@ -69,9 +72,27 @@ void StageContext::ParseHapModuleInfo(const Json::Value& root)
|
||||
ELOG("The information of stage model hap module info is null.");
|
||||
return;
|
||||
}
|
||||
ParseAbilityInfo(root);
|
||||
hapModuleInfo.compileMode = JsonReader::GetString(root, "compileMode");
|
||||
hapModuleInfo.moduleName = JsonReader::GetString(root, "name");
|
||||
hapModuleInfo.pageProfile = JsonReader::GetString(root, "pages");
|
||||
hapModuleInfo.deliveryWithInstall = JsonReader::GetBool(root, "deliveryWithInstall", false);
|
||||
hapModuleInfo.description = JsonReader::GetString(root, "description");
|
||||
hapModuleInfo.descriptionId = JsonReader::GetUInt(root, "descriptionId", 0);
|
||||
std::vector<std::string> deviceTypes;
|
||||
std::unique_ptr<Json::Value> deviceTypesArr = JsonReader::GetArray(root, "deviceTypes");
|
||||
if (deviceTypesArr) {
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*deviceTypesArr); ++index) {
|
||||
deviceTypes.push_back((*deviceTypesArr)[index].asString());
|
||||
}
|
||||
}
|
||||
hapModuleInfo.deviceTypes = deviceTypes;
|
||||
hapModuleInfo.installationFree = JsonReader::GetBool(root, "installationFree", false);
|
||||
hapModuleInfo.mainElement = JsonReader::GetString(root, "mainElement");
|
||||
hapModuleInfo.name = JsonReader::GetString(root, "name");
|
||||
hapModuleInfo.pages = JsonReader::GetString(root, "pages");
|
||||
hapModuleInfo.type = JsonReader::GetString(root, "type");
|
||||
hapModuleInfo.virtualMachine = JsonReader::GetString(root, "virtualMachine");
|
||||
hapModuleInfo.srcEntry = JsonReader::GetString(root, "srcEntry");
|
||||
// from arkui
|
||||
std::unique_ptr<Json::Value> metaData = JsonReader::GetArray(root, "metadata");
|
||||
if (metaData) {
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*metaData); ++index) {
|
||||
@@ -80,11 +101,64 @@ void StageContext::ParseHapModuleInfo(const Json::Value& root)
|
||||
}
|
||||
}
|
||||
}
|
||||
std::unique_ptr<Json::Value> abilities = JsonReader::GetArray(root, "abilities");
|
||||
if (abilities) {
|
||||
if ((*abilities)[0]) {
|
||||
hapModuleInfo.labelId = JsonReader::GetUInt((*abilities)[0], "labelId", 0);
|
||||
}
|
||||
|
||||
void StageContext::ParseAbilityInfo(const Json::Value& root)
|
||||
{
|
||||
std::unique_ptr<Json::Value> abilitiesArr = JsonReader::GetArray(root, "abilities");
|
||||
std::vector<AbilityInfo> abilities;
|
||||
if (!abilitiesArr) {
|
||||
return;
|
||||
}
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*abilitiesArr); ++index) {
|
||||
AbilityInfo ability;
|
||||
ability.description = JsonReader::GetString((*abilitiesArr)[index], "description");
|
||||
ability.descriptionId = JsonReader::GetUInt((*abilitiesArr)[index], "descriptionId", 0);
|
||||
ability.exported = JsonReader::GetBool((*abilitiesArr)[index], "exported");
|
||||
ability.icon = JsonReader::GetString((*abilitiesArr)[index], "icon");
|
||||
ability.iconId = JsonReader::GetUInt((*abilitiesArr)[index], "iconId");
|
||||
ability.label = JsonReader::GetString((*abilitiesArr)[index], "label");
|
||||
ability.labelId = JsonReader::GetUInt((*abilitiesArr)[index], "labelId");
|
||||
ability.name = JsonReader::GetString((*abilitiesArr)[index], "name");
|
||||
std::unique_ptr<Json::Value> skillsArr = JsonReader::GetArray((*abilitiesArr)[index], "skills");
|
||||
std::vector<SkillInfo> skills;
|
||||
ParseSkillsInfo(skillsArr, skills);
|
||||
ability.skills = skills;
|
||||
ability.srcEntrty = JsonReader::GetString((*abilitiesArr)[index], "srcEntrty");
|
||||
ability.startWindowBackground = JsonReader::GetString((*abilitiesArr)[index], "startWindowBackground");
|
||||
ability.startWindowBackgroundId = JsonReader::GetUInt((*abilitiesArr)[index], "startWindowBackgroundId");
|
||||
ability.startWindowIcon = JsonReader::GetString((*abilitiesArr)[index], "startWindowIcon");
|
||||
ability.startWindowIconId = JsonReader::GetUInt((*abilitiesArr)[index], "startWindowIconId");
|
||||
abilities.push_back(ability);
|
||||
}
|
||||
hapModuleInfo.abilities = abilities;
|
||||
}
|
||||
|
||||
void StageContext::ParseSkillsInfo(const std::unique_ptr<Json::Value>& skillsArr,
|
||||
std::vector<SkillInfo>& skills)
|
||||
{
|
||||
if (!skillsArr) {
|
||||
return;
|
||||
}
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*skillsArr); ++index) {
|
||||
SkillInfo skill;
|
||||
std::unique_ptr<Json::Value> actionsArr = JsonReader::GetArray((*skillsArr)[index], "actions");
|
||||
if (actionsArr) {
|
||||
std::vector<std::string> actions;
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*actionsArr); ++index) {
|
||||
actions.push_back((*actionsArr)[index].asString());
|
||||
}
|
||||
skill.actions = actions;
|
||||
}
|
||||
std::unique_ptr<Json::Value> entitiesArr = JsonReader::GetArray((*skillsArr)[index], "entities");
|
||||
if (entitiesArr) {
|
||||
std::vector<std::string> entities;
|
||||
for (auto index = 0; index < JsonReader::GetArraySize(*entitiesArr); ++index) {
|
||||
entities.push_back((*entitiesArr)[index].asString());
|
||||
}
|
||||
skill.entities = entities;
|
||||
}
|
||||
skills.push_back(skill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +171,14 @@ const HapModuleInfo& StageContext::GetHapModuleInfo() const
|
||||
{
|
||||
return hapModuleInfo;
|
||||
}
|
||||
|
||||
const AbilityInfo& StageContext::GetAbilityInfo(const std::string srcEntryVal) const
|
||||
{
|
||||
for (AbilityInfo ability : hapModuleInfo.abilities) {
|
||||
if (srcEntryVal == ability.srcEntrty) {
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
return hapModuleInfo.abilities[0];
|
||||
}
|
||||
}
|
||||
+51
-10
@@ -17,32 +17,71 @@
|
||||
#define STAGE_CONTEXT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "JsonReader.h"
|
||||
|
||||
namespace OHOS::Ide {
|
||||
struct SkillInfo {
|
||||
std::vector<std::string> actions;
|
||||
std::vector<std::string> entities;
|
||||
};
|
||||
|
||||
struct AbilityInfo {
|
||||
std::string description;
|
||||
uint32_t descriptionId;
|
||||
bool exported = false;
|
||||
std::string icon;
|
||||
uint32_t iconId = 0;
|
||||
std::string label;
|
||||
uint32_t labelId = 0;
|
||||
std::string name;
|
||||
std::vector<SkillInfo> skills;
|
||||
std::string srcEntrty;
|
||||
std::string startWindowBackground;
|
||||
uint32_t startWindowBackgroundId;
|
||||
std::string startWindowIcon;
|
||||
uint32_t startWindowIconId;
|
||||
};
|
||||
|
||||
struct HapModuleInfo {
|
||||
std::vector<AbilityInfo> abilities;
|
||||
std::string compileMode;
|
||||
std::string moduleName;
|
||||
bool deliveryWithInstall = false;
|
||||
std::vector<std::string> dependencies;
|
||||
std::string description;
|
||||
uint32_t descriptionId;
|
||||
std::vector<std::string> deviceTypes;
|
||||
bool installationFree = false;
|
||||
std::string mainElement;
|
||||
std::string name;
|
||||
std::string pages;
|
||||
std::string type;
|
||||
std::string virtualMachine;
|
||||
std::string srcEntry;
|
||||
// from arkui
|
||||
bool isPartialUpdate = true;
|
||||
uint32_t labelId = 0;
|
||||
std::string pageProfile;
|
||||
};
|
||||
|
||||
struct AppInfo {
|
||||
// form mudule.json
|
||||
std::string apiReleaseType;
|
||||
std::string bundleName;
|
||||
std::string bundleType;
|
||||
std::string icon;
|
||||
std::string label;
|
||||
std::string vendor;
|
||||
std::string versionName;
|
||||
std::string compileSdkType;
|
||||
std::string compileSdkVersion;
|
||||
bool debug = false;
|
||||
bool distributedNotificationEnabled = true;
|
||||
uint32_t iconId;
|
||||
std::string icon;
|
||||
uint32_t iconId = 0;
|
||||
std::string label;
|
||||
uint32_t labelId = 0;
|
||||
uint32_t minAPIVersion = 0;
|
||||
uint32_t targetAPIVersion = 0;
|
||||
std::string vendor;
|
||||
uint32_t versionCode = 0;
|
||||
std::string versionName;
|
||||
// from arkui
|
||||
std::string bundleType;
|
||||
bool distributedNotificationEnabled = true;
|
||||
};
|
||||
|
||||
class StageContext {
|
||||
@@ -51,9 +90,11 @@ public:
|
||||
void ParseJsonFile(const std::string& filePath);
|
||||
void ParseAppInfo(const Json::Value& root);
|
||||
void ParseHapModuleInfo(const Json::Value& root);
|
||||
void ParseAbilityInfo(const Json::Value& root);
|
||||
void ParseSkillsInfo(const std::unique_ptr<Json::Value>& skillsArr, std::vector<SkillInfo>& skills);
|
||||
const AppInfo& GetAppInfo() const;
|
||||
const HapModuleInfo& GetHapModuleInfo() const;
|
||||
|
||||
const AbilityInfo& GetAbilityInfo(const std::string srcEntryVal) const;
|
||||
private:
|
||||
StageContext() = default;
|
||||
~StageContext() = default;
|
||||
|
||||
+123
-32
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::Ace;
|
||||
|
||||
JsAppImpl::JsAppImpl() noexcept : ability(nullptr), isStop(false)
|
||||
@@ -262,14 +263,70 @@ void JsAppImpl::RunDebugAbility()
|
||||
window->CreateSurfaceNode(options.moduleName, std::move(VirtualScreenImpl::CallBack));
|
||||
}
|
||||
|
||||
static void ConvertAbilityInfo(const Ide::AbilityInfo &info, AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
abilityInfo.name = info.name;
|
||||
abilityInfo.iconPath = info.icon;
|
||||
abilityInfo.labelId = info.iconId;
|
||||
abilityInfo.label = info.label;
|
||||
abilityInfo.labelId = info.labelId;
|
||||
abilityInfo.srcEntrance = info.srcEntrty;
|
||||
abilityInfo.description = info.description;
|
||||
abilityInfo.descriptionId = info.descriptionId;
|
||||
abilityInfo.startWindowBackground = info.startWindowBackground;
|
||||
abilityInfo.startWindowBackgroundId = info.startWindowBackgroundId;
|
||||
abilityInfo.startWindowIconId = info.startWindowIconId;
|
||||
abilityInfo.startWindowIcon = info.startWindowIcon;
|
||||
}
|
||||
|
||||
static void ConvertApplicationInfo(const Ide::AppInfo &info, AppExecFwk::ApplicationInfo &applicationInfo)
|
||||
{
|
||||
applicationInfo.apiReleaseType = info.apiReleaseType;
|
||||
applicationInfo.bundleName = info.bundleName;
|
||||
applicationInfo.compileSdkType = info.compileSdkType;
|
||||
applicationInfo.compileSdkVersion = info.compileSdkVersion;
|
||||
applicationInfo.debug = info.debug;
|
||||
applicationInfo.icon = info.icon;
|
||||
applicationInfo.iconId = info.iconId;
|
||||
applicationInfo.label = info.label;
|
||||
applicationInfo.labelId = info.labelId;
|
||||
applicationInfo.minCompatibleVersionCode = info.minAPIVersion;
|
||||
applicationInfo.apiTargetVersion = info.targetAPIVersion;
|
||||
applicationInfo.vendor = info.vendor;
|
||||
applicationInfo.vendor = info.vendor;
|
||||
applicationInfo.versionName = info.versionName;
|
||||
applicationInfo.distributedNotificationEnabled = info.distributedNotificationEnabled;
|
||||
}
|
||||
|
||||
static void ConvertHapModuleInfo(const Ide::HapModuleInfo &info, AppExecFwk::HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
hapModuleInfo.labelId = info.labelId;
|
||||
hapModuleInfo.virtualMachine = info.virtualMachine;
|
||||
hapModuleInfo.pages = info.pages;
|
||||
hapModuleInfo.name = info.name;
|
||||
hapModuleInfo.mainElementName = info.mainElement;
|
||||
hapModuleInfo.installationFree = info.installationFree;
|
||||
hapModuleInfo.descriptionId = info.descriptionId;
|
||||
hapModuleInfo.description = info.description;
|
||||
hapModuleInfo.deliveryWithInstall = info.deliveryWithInstall;
|
||||
hapModuleInfo.compileMode = AppExecFwk::CompileMode::ES_MODULE;
|
||||
hapModuleInfo.deviceTypes = info.deviceTypes;
|
||||
hapModuleInfo.srcEntrance = info.srcEntry;
|
||||
for (auto &ability : info.abilities) {
|
||||
AppExecFwk::AbilityInfo aInfo;
|
||||
ConvertAbilityInfo(ability, aInfo);
|
||||
hapModuleInfo.abilityInfos.emplace_back(aInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAppImpl::SetSimulatorParams(OHOS::AbilityRuntime::Options& options)
|
||||
{
|
||||
std::string abilityPath = CommandParser::GetInstance().GetAbilityPath();
|
||||
const string path = CommandParser::GetInstance().GetAppResourcePath() +
|
||||
FileSystem::GetSeparator() + "module.json";
|
||||
GetModuleJsonInfo(path);
|
||||
options.bundleName = OHOS::Ide::StageContext::GetInstance().GetAppInfo().bundleName;
|
||||
options.moduleName = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().moduleName;
|
||||
options.moduleName = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().name;
|
||||
options.modulePath = aceRunArgs.assetPath + FileSystem::GetSeparator() + "modules.abc";
|
||||
options.resourcePath = CommandParser::GetInstance().GetAppResourcePath() +
|
||||
FileSystem::GetSeparator() + "resources.index";
|
||||
@@ -297,15 +354,47 @@ void JsAppImpl::SetSimulatorParams(OHOS::AbilityRuntime::Options& options)
|
||||
options.compatibleVersion = OHOS::Ide::StageContext::GetInstance().GetAppInfo().minAPIVersion;
|
||||
options.installationFree =
|
||||
OHOS::Ide::StageContext::GetInstance().GetAppInfo().bundleType == "atomicService" ? true : false;
|
||||
options.labelId = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().labelId;
|
||||
options.labelId = OHOS::Ide::StageContext::GetInstance().GetAbilityInfo(abilityPath).labelId;
|
||||
options.compileMode = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().compileMode;
|
||||
options.pageProfile = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().pageProfile;
|
||||
options.pageProfile = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().pages;
|
||||
options.targetVersion = OHOS::Ide::StageContext::GetInstance().GetAppInfo().targetAPIVersion;
|
||||
options.releaseType = OHOS::Ide::StageContext::GetInstance().GetAppInfo().apiReleaseType;
|
||||
options.enablePartialUpdate = OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo().isPartialUpdate;
|
||||
// new add
|
||||
AppExecFwk::ApplicationInfo applicationInfo;
|
||||
ConvertApplicationInfo(Ide::StageContext::GetInstance().GetAppInfo(), applicationInfo);
|
||||
options.applicationInfo = applicationInfo;
|
||||
AppExecFwk::HapModuleInfo hapModuleInfo;
|
||||
ConvertHapModuleInfo(OHOS::Ide::StageContext::GetInstance().GetHapModuleInfo(), hapModuleInfo);
|
||||
options.hapModuleInfo = hapModuleInfo;
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
ConvertAbilityInfo(OHOS::Ide::StageContext::GetInstance().GetAbilityInfo(abilityPath), abilityInfo);
|
||||
options.abilityInfo = abilityInfo;
|
||||
|
||||
ILOG("setted bundleName:%s moduleName:%s", options.bundleName.c_str(), options.moduleName.c_str());
|
||||
}
|
||||
|
||||
void JsAppImpl::UpdateConfiguration(OHOS::Ace::Platform::AceRunArgs& args)
|
||||
{
|
||||
OHOS::AppExecFwk::Configuration configuration;
|
||||
configuration.AddItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE,
|
||||
SharedData<string>::GetData(SharedDataType::LANGUAGE));
|
||||
string colorMode = "light";
|
||||
if (aceRunArgs.deviceConfig.colorMode == ColorMode::DARK) {
|
||||
colorMode = "dark";
|
||||
}
|
||||
configuration.AddItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, colorMode);
|
||||
string direction = "portrait";
|
||||
if (aceRunArgs.deviceConfig.orientation == DeviceOrientation::LANDSCAPE) {
|
||||
orientation = "landscape";
|
||||
}
|
||||
configuration.AddItem(OHOS::AppExecFwk::ConfigurationInner::APPLICATION_DIRECTION, direction);
|
||||
string density = std::to_string(aceRunArgs.deviceConfig.density);
|
||||
configuration.AddItem(OHOS::AppExecFwk::ConfigurationInner::APPLICATION_DENSITYDPI, density);
|
||||
simulator->UpdateConfiguration(configuration);
|
||||
}
|
||||
|
||||
|
||||
void JsAppImpl::SetWindowParams() const
|
||||
{
|
||||
windowModel->isRound = aceRunArgs.isRound;
|
||||
@@ -511,36 +600,10 @@ void JsAppImpl::AssignValueForWidthAndHeight(const int32_t origWidth,
|
||||
ILOG("AssignValueForWidthAndHeight: %d %d %d %d", orignalWidth, orignalHeight, width, height);
|
||||
}
|
||||
|
||||
void JsAppImpl::ResolutionChanged(int32_t changedOriginWidth,
|
||||
int32_t changedOriginHeight,
|
||||
int32_t changedWidth,
|
||||
int32_t changedHeight,
|
||||
int32_t screenDensity)
|
||||
void JsAppImpl::ResolutionChanged(int32_t changedOriginWidth, int32_t changedOriginHeight, int32_t changedWidth,
|
||||
int32_t changedHeight, int32_t screenDensity)
|
||||
{
|
||||
SetDeviceWidth(aceRunArgs, changedWidth);
|
||||
SetDeviceHeight(aceRunArgs, changedHeight);
|
||||
orignalWidth = changedOriginWidth;
|
||||
orignalHeight = changedOriginHeight;
|
||||
VirtualScreenImpl::GetInstance().SetVirtualScreenWidthAndHeight(changedOriginWidth, changedOriginHeight,
|
||||
changedWidth, changedHeight);
|
||||
SetDeviceScreenDensity(screenDensity,
|
||||
CommandParser::GetInstance().GetDeviceType());
|
||||
AdaptDeviceType(aceRunArgs, CommandParser::GetInstance().GetDeviceType(),
|
||||
VirtualScreenImpl::GetInstance().GetOrignalWidth());
|
||||
AssignValueForWidthAndHeight(VirtualScreenImpl::GetInstance().GetOrignalWidth(),
|
||||
VirtualScreenImpl::GetInstance().GetOrignalHeight(),
|
||||
VirtualScreenImpl::GetInstance().GetCompressionWidth(),
|
||||
VirtualScreenImpl::GetInstance().GetCompressionHeight());
|
||||
// Runtime change device orientation
|
||||
if (changedWidth <= changedHeight) {
|
||||
JsAppImpl::GetInstance().SetDeviceOrentation("portrait");
|
||||
} else {
|
||||
JsAppImpl::GetInstance().SetDeviceOrentation("landscape");
|
||||
}
|
||||
SetOrientation(aceRunArgs, orientation);
|
||||
|
||||
ILOG("ResolutionChanged: %s %d %d %f", orientation.c_str(), aceRunArgs.deviceWidth,
|
||||
aceRunArgs.deviceHeight, aceRunArgs.deviceConfig.density);
|
||||
SetResolutionParams(changedOriginWidth, changedOriginHeight, changedWidth, changedHeight, screenDensity);
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
SetWindowParams();
|
||||
@@ -558,6 +621,7 @@ void JsAppImpl::ResolutionChanged(int32_t changedOriginWidth,
|
||||
OHOS::AppExecFwk::EventHandler::PostTask([this]() {
|
||||
glfwRenderContext->SetWindowSize(width, height);
|
||||
});
|
||||
UpdateConfiguration(aceRunArgs);
|
||||
window->SetViewportConfig(config);
|
||||
#endif
|
||||
} else {
|
||||
@@ -571,6 +635,33 @@ void JsAppImpl::ResolutionChanged(int32_t changedOriginWidth,
|
||||
}
|
||||
}
|
||||
|
||||
void JsAppImpl::SetResolutionParams(int32_t changedOriginWidth, int32_t changedOriginHeight, int32_t changedWidth,
|
||||
int32_t changedHeight, int32_t screenDensity)
|
||||
{
|
||||
SetDeviceWidth(aceRunArgs, changedWidth);
|
||||
SetDeviceHeight(aceRunArgs, changedHeight);
|
||||
orignalWidth = changedOriginWidth;
|
||||
orignalHeight = changedOriginHeight;
|
||||
VirtualScreenImpl::GetInstance().SetVirtualScreenWidthAndHeight(changedOriginWidth, changedOriginHeight,
|
||||
changedWidth, changedHeight);
|
||||
SetDeviceScreenDensity(screenDensity,
|
||||
CommandParser::GetInstance().GetDeviceType());
|
||||
AdaptDeviceType(aceRunArgs, CommandParser::GetInstance().GetDeviceType(),
|
||||
VirtualScreenImpl::GetInstance().GetOrignalWidth());
|
||||
AssignValueForWidthAndHeight(VirtualScreenImpl::GetInstance().GetOrignalWidth(),
|
||||
VirtualScreenImpl::GetInstance().GetOrignalHeight(),
|
||||
VirtualScreenImpl::GetInstance().GetCompressionWidth(),
|
||||
VirtualScreenImpl::GetInstance().GetCompressionHeight());
|
||||
if (changedWidth <= changedHeight) {
|
||||
JsAppImpl::GetInstance().SetDeviceOrentation("portrait");
|
||||
} else {
|
||||
JsAppImpl::GetInstance().SetDeviceOrentation("landscape");
|
||||
}
|
||||
SetOrientation(aceRunArgs, orientation);
|
||||
ILOG("ResolutionChanged: %s %d %d %f", orientation.c_str(), aceRunArgs.deviceWidth,
|
||||
aceRunArgs.deviceHeight, aceRunArgs.deviceConfig.density);
|
||||
}
|
||||
|
||||
void JsAppImpl::SetArgsColorMode(const string& value)
|
||||
{
|
||||
colorMode = value;
|
||||
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
void OrientationChanged(std::string commandOrientation) override;
|
||||
void ResolutionChanged(int32_t changedOriginWidth, int32_t changedOriginHeight,
|
||||
int32_t changedWidth, int32_t changedHeight, int32_t screenDensity) override;
|
||||
void SetResolutionParams(int32_t changedOriginWidth, int32_t changedOriginHeight,
|
||||
int32_t changedWidth, int32_t changedHeight, int32_t screenDensity);
|
||||
void SetArgsColorMode(const std::string& value) override;
|
||||
void SetArgsAceVersion(const std::string& value) override;
|
||||
void SetDeviceOrentation(const std::string& value);
|
||||
@@ -132,6 +134,7 @@ private:
|
||||
std::unique_ptr<OHOS::AbilityRuntime::Simulator> simulator;
|
||||
int64_t debugAbilityId = -1;
|
||||
void SetSimulatorParams(OHOS::AbilityRuntime::Options& options);
|
||||
void UpdateConfiguration(OHOS::Ace::Platform::AceRunArgs& args);
|
||||
|
||||
std::shared_ptr<OHOS::Previewer::PreviewerWindowModel> windowModel;
|
||||
void SetWindowParams() const;
|
||||
|
||||
Reference in New Issue
Block a user