remove deps on libwm

Signed-off-by: qpzeng <zengqingpeng6@huawei.com>
Change-Id: If58b5aca7247a9bb4467bf62f6fb0eecbfcd0173
This commit is contained in:
qpzeng 2023-06-09 17:02:27 +08:00
parent c161dda9dd
commit 9359054dc0
15 changed files with 56 additions and 94 deletions

View File

@ -33,6 +33,7 @@ config("libwmutil_public_config") {
ohos_static_library("libwmutil_static") {
sources = [
"src/agent_death_recipient.cpp",
"src/color_parser.cpp",
"src/cutout_info.cpp",
"src/display_info.cpp",
"src/perform_reporter.cpp",
@ -93,6 +94,7 @@ ohos_static_library("libwmutil_static") {
ohos_shared_library("libwmutil") {
sources = [
"src/agent_death_recipient.cpp",
"src/color_parser.cpp",
"src/cutout_info.cpp",
"src/display_info.cpp",
"src/perform_reporter.cpp",

View File

@ -26,10 +26,8 @@ public:
private:
static bool IsValidHexString(const std::string& colorStr);
ColorParser() = default;
~ColorParser() = default;
};
}
}
} // namespace Rosen
} // namespace OHOS
#endif // OHOS_ROSEN_COLOR_PARSER_H

View File

@ -14,6 +14,7 @@
{
global:
extern "C++" {
OHOS::Rosen::ColorParser*;
OHOS::Rosen::SingletonContainer::*;
*Unmarshalling*;
OHOS::Rosen::CutoutInfo::CutoutInfo*;

View File

@ -14,20 +14,14 @@
*/
#include "color_parser.h"
#include <cstdlib>
#include "window_manager_hilog.h"
#include <cstdlib>
namespace OHOS {
namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "ColorParser"};
}
bool ColorParser::Parse(const std::string& colorStr, uint32_t& colorValue)
{
if (colorStr.empty()) {
WLOGFE("color string is empty");
return false;
}
@ -36,8 +30,8 @@ bool ColorParser::Parse(const std::string& colorStr, uint32_t& colorValue)
if (!IsValidHexString(color)) {
return false;
}
char* ptr;
colorValue = std::strtoul(color.c_str(), &ptr, 16); // convert hex string to number
constexpr int HEX = 16;
colorValue = std::strtoul(color.c_str(), 0, HEX); // convert hex string to number
if (colorStr.size() == 7) { // #RRGGBB: RRGGBB -> AARRGGBB
colorValue |= 0xff000000;
return true;
@ -63,4 +57,4 @@ bool ColorParser::IsValidHexString(const std::string& colorStr)
return true;
}
} // namespace Rosen
} // namespace OHOS
} // namespace OHOS

View File

@ -14,9 +14,9 @@
import("//build/ohos.gni")
import("../../../../../windowmanager_aafwk.gni")
config("scene_session_manager_napi_public_config") {
config("scene_session_manager_napi_config") {
visibility = [ ":*" ]
include_dirs = [ "${window_base_path}/window_scene/interfaces/kits/napi" ]
include_dirs = [ "${window_base_path}/wm/include" ]
}
ohos_shared_library("scenesessionmanager_napi") {
@ -29,13 +29,7 @@ ohos_shared_library("scenesessionmanager_napi") {
"scene_session_manager_module.cpp",
]
public_configs = [ ":scene_session_manager_napi_public_config" ]
deps = [
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/session:scene_session",
"${window_base_path}/window_scene/session_manager:scene_session_manager",
]
configs = [ ":scene_session_manager_napi_config" ]
external_deps = [
"ability_base:configuration",
@ -45,6 +39,9 @@ ohos_shared_library("scenesessionmanager_napi") {
"hilog_native:libhilog",
"ipc:ipc_single",
"napi:ace_napi",
"window_manager:libwm",
"window_manager:scene_session",
"window_manager:scene_session_manager",
]
relative_install_dir = "module"

View File

@ -18,7 +18,6 @@
#include <native_engine/native_engine.h>
#include <native_engine/native_value.h>
#include <refbase.h>
#include "session/host/include/root_scene_session.h"
namespace OHOS::Rosen {

View File

@ -15,7 +15,9 @@
#include "js_scene_session_manager.h"
#include <ability_context.h>
#include <js_runtime_utils.h>
#include "session/host/include/scene_persistence.h"
#include "session/host/include/session.h"
#include "session_manager/include/scene_session_manager.h"
#include "window_manager_hilog.h"
@ -48,7 +50,7 @@ NativeValue* JsSceneSessionManager::Init(NativeEngine* engine, NativeValue* expo
std::unique_ptr<JsSceneSessionManager> jsSceneSessionManager = std::make_unique<JsSceneSessionManager>(*engine);
object->SetNativePointer(jsSceneSessionManager.release(), JsSceneSessionManager::Finalizer, nullptr);
object->SetProperty("SessionState", SessionStateInit(engine));
object->SetProperty("SessionState", CreateJsSessionState(*engine));
const char* moduleName = "JsSceneSessionManager";
BindNativeFunction(*engine, *object, "getRootSceneSession", moduleName, JsSceneSessionManager::GetRootSceneSession);
@ -239,21 +241,33 @@ NativeValue* JsSceneSessionManager::OnProcessBackEvent(NativeEngine& engine, Nat
NativeValue* JsSceneSessionManager::OnGetRootSceneSession(NativeEngine& engine, NativeCallbackInfo& info)
{
WLOGFI("[NAPI]OnGetRootSceneSession");
WLOGI("[NAPI]OnGetRootSceneSession");
sptr<RootSceneSession> rootSceneSession = SceneSessionManager::GetInstance().GetRootSceneSession();
if (rootSceneSession == nullptr) {
engine.Throw(
CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "System is abnormal"));
return engine.CreateUndefined();
} else {
NativeValue* jsRootSceneSessionObj = JsRootSceneSession::Create(engine, rootSceneSession);
if (jsRootSceneSessionObj == nullptr) {
WLOGFE("[NAPI]jsRootSceneSessionObj is nullptr");
engine.Throw(CreateJsError(
engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "System is abnormal"));
}
return jsRootSceneSessionObj;
}
if (rootScene_ == nullptr) {
rootScene_ = new RootScene();
}
rootSceneSession->SetLoadContentFunc([rootScene = rootScene_]
(const std::string& contentUrl, NativeEngine* engine, NativeValue* storage, AbilityRuntime::Context* context) {
rootScene->LoadContent(contentUrl, engine, storage, context);
if (!ScenePersistence::CreateSnapshotDir(context->GetFilesDir())) {
WLOGFD("snapshot dir existed");
}
});
NativeValue* jsRootSceneSessionObj = JsRootSceneSession::Create(engine, rootSceneSession);
if (jsRootSceneSessionObj == nullptr) {
WLOGFE("[NAPI]jsRootSceneSessionObj is nullptr");
engine.Throw(
CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "System is abnormal"));
return engine.CreateUndefined();
}
return jsRootSceneSessionObj;
}
NativeValue* JsSceneSessionManager::OnRequestSceneSession(NativeEngine& engine, NativeCallbackInfo& info)

View File

@ -18,10 +18,10 @@
#include <map>
#include "interfaces/include/ws_common.h"
#include <native_engine/native_engine.h>
#include <native_engine/native_value.h>
#include "interfaces/include/ws_common.h"
#include "root_scene.h"
#include "session/host/include/scene_session.h"
namespace OHOS::Rosen {
@ -60,6 +60,8 @@ private:
std::map<std::string, std::shared_ptr<NativeReference>> jsCbMap_;
using Func = void(JsSceneSessionManager::*)();
std::map<std::string, Func> listenerFunc_;
sptr<RootScene> rootScene_;
};
} // namespace OHOS::Rosen

View File

@ -91,46 +91,28 @@ NativeValue* CreateJsSessionInfo(NativeEngine& engine, const SessionInfo& sessio
return objValue;
}
NativeValue* CreateJsSessionState(NativeEngine& engine, const SessionState& state)
NativeValue* CreateJsSessionState(NativeEngine& engine)
{
WLOGFI("[NAPI]CreateJsSessionState");
NativeValue* objValue = engine.CreateObject();
NativeObject* object = ConvertNativeValueTo<NativeObject>(objValue);
if (object == nullptr) {
WLOGFE("[NAPI]Failed to convert sessionInfo to jsObject");
return nullptr;
}
object->SetProperty("sessionState", CreateJsValue(engine, state));
return objValue;
}
NativeValue* SessionStateInit(NativeEngine* engine)
{
if (engine == nullptr) {
WLOGFE("Engine is nullptr");
return nullptr;
}
NativeValue *objValue = engine->CreateObject();
NativeValue *objValue = engine.CreateObject();
NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
if (object == nullptr) {
WLOGFE("Failed to get object");
return nullptr;
}
object->SetProperty("STATE_DISCONNECT", CreateJsValue(*engine,
object->SetProperty("STATE_DISCONNECT", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_DISCONNECT)));
object->SetProperty("STATE_CONNECT", CreateJsValue(*engine,
object->SetProperty("STATE_CONNECT", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_CONNECT)));
object->SetProperty("STATE_FOREGROUND", CreateJsValue(*engine,
object->SetProperty("STATE_FOREGROUND", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_FOREGROUND)));
object->SetProperty("STATE_ACTIVE", CreateJsValue(*engine,
object->SetProperty("STATE_ACTIVE", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_ACTIVE)));
object->SetProperty("STATE_INACTIVE", CreateJsValue(*engine,
object->SetProperty("STATE_INACTIVE", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_INACTIVE)));
object->SetProperty("STATE_BACKGROUND", CreateJsValue(*engine,
object->SetProperty("STATE_BACKGROUND", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_BACKGROUND)));
object->SetProperty("STATE_END", CreateJsValue(*engine,
object->SetProperty("STATE_END", CreateJsValue(engine,
static_cast<int32_t>(SessionState::STATE_END)));
return objValue;

View File

@ -25,8 +25,7 @@
namespace OHOS::Rosen {
bool ConvertSessionInfoFromJs(NativeEngine& engine, NativeObject* jsObject, SessionInfo& sessionInfo);
NativeValue* CreateJsSessionInfo(NativeEngine& engine, const SessionInfo& sessionInfo);
NativeValue* CreateJsSessionState(NativeEngine& engine, const SessionState& state);
NativeValue* SessionStateInit(NativeEngine* engine);
NativeValue* CreateJsSessionState(NativeEngine& engine);
NativeValue* CreateJsSessionRect(NativeEngine& engine, const WSRect& rect);
} // namespace OHOS::Rosen

View File

@ -14,13 +14,6 @@
import("//build/ohos.gni")
import("../../windowmanager_aafwk.gni")
config("session_manager_private_config") {
include_dirs = [
"${window_base_path}/interfaces/innerkits/wm",
"${window_base_path}/wm/include",
]
}
config("session_manager_public_config") {
include_dirs = [
"${window_base_path}/window_scene",
@ -53,8 +46,6 @@ ohos_shared_library("scene_session_manager") {
"src/zidl/scene_session_manager_stub.cpp",
]
configs = [ ":session_manager_private_config" ]
public_configs = [ ":session_manager_public_config" ]
deps = [
@ -81,7 +72,6 @@ ohos_shared_library("scene_session_manager") {
"ipc:ipc_single",
"resource_management:global_resmgr",
"samgr:samgr_proxy",
"window_manager:libwm",
]
innerapi_tags = [ "platformsdk" ]

View File

@ -38,7 +38,6 @@ class ResourceManager;
} // namespace OHOS::Global::Resource
namespace OHOS::Rosen {
class RootScene;
class SceneSession;
using NotifyCreateSpecificSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
class SceneSessionManager : public SceneSessionManagerStub,
@ -83,7 +82,6 @@ private:
std::map<uint64_t, sptr<SceneSession>> abilitySceneMap_;
sptr<RootSceneSession> rootSceneSession_;
sptr<RootScene> rootScene_;
NotifyCreateSpecificSessionFunc createSpecificSessionFunc_;
AppWindowSceneConfig appWindowSceneConfig_;
SystemSessionConfig systemConfig_;

View File

@ -28,12 +28,9 @@
#include <system_ability_definition.h>
#include <want.h>
#include "ability_context.h"
#include "color_parser.h"
#include "common/include/message_scheduler.h"
#include "common/include/permission.h"
#include "root_scene.h"
#include "session/host/include/scene_persistence.h"
#include "session/host/include/scene_session.h"
#include "window_manager_hilog.h"
#include "wm_math.h"
@ -251,18 +248,10 @@ sptr<RootSceneSession> SceneSessionManager::GetRootSceneSession()
system::SetParameter("bootevent.boot.completed", "true");
SessionInfo info;
rootSceneSession_ = new (std::nothrow) RootSceneSession(info);
rootScene_ = new (std::nothrow) RootScene();
if (!rootSceneSession_ || !rootScene_) {
WLOGFE("rootSceneSession or rootScene is nullptr");
if (!rootSceneSession_) {
WLOGFE("rootSceneSession is nullptr");
return sptr<RootSceneSession>(nullptr);
}
rootSceneSession_->SetLoadContentFunc([rootScene = rootScene_](const std::string &contentUrl,
NativeEngine *engine, NativeValue *storage, AbilityRuntime::Context *context) {
rootScene->LoadContent(contentUrl, engine, storage, context);
if (!ScenePersistence::CreateSnapshotDir(context->GetFilesDir())) {
WLOGFD("snapshot dir existed");
}
});
AAFwk::AbilityManagerClient::GetInstance()->SetRootSceneSession(rootSceneSession_);
return rootSceneSession_;
};

View File

@ -39,7 +39,6 @@ ohos_static_library("libwm_static") {
sources = [
"../wmserver/src/zidl/window_manager_proxy.cpp",
"src/color_parser.cpp",
"src/input_transfer_station.cpp",
"src/root_scene.cpp",
"src/static_call.cpp",
@ -142,7 +141,6 @@ ohos_shared_library("libwm") {
sources = [
"../wmserver/src/zidl/window_manager_proxy.cpp",
"src/color_parser.cpp",
"src/input_transfer_station.cpp",
"src/root_scene.cpp",
"src/static_call.cpp",

View File

@ -14,7 +14,6 @@
{
global:
extern "C++" {
OHOS::Rosen::ColorParser*;
OHOS::Rosen::WindowScene*;
*GetInstance*;
OHOS::Rosen::VsyncStation*;