mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
Merge branch 'master' of gitee.com:openharmony/window_window_manager into master
Signed-off-by: duyulu <784928376@qq.com>
This commit is contained in:
commit
137c9d2949
@ -68,7 +68,7 @@
|
||||
"frame_aware_sched_override",
|
||||
"imf",
|
||||
"frame_aware_sched",
|
||||
"memmgr_plugin",
|
||||
"memmgr_override",
|
||||
"data_share",
|
||||
"accessibility",
|
||||
"security_component_manager",
|
||||
|
17
dm/BUILD.gn
17
dm/BUILD.gn
@ -31,16 +31,21 @@ config("libdm_public_config") {
|
||||
include_dirs = [
|
||||
"../interfaces/innerkits/dm",
|
||||
"../utils/include",
|
||||
"${multimedia_path}/interfaces/innerkits/include",
|
||||
]
|
||||
}
|
||||
|
||||
config("for_libdm_public_config") {
|
||||
include_dirs =
|
||||
[ "../../../multimedia/image_framework/interfaces/innerkits/include" ]
|
||||
}
|
||||
|
||||
## Build libdm_static.a
|
||||
ohos_static_library("libdm_static") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
@ -71,7 +76,10 @@ ohos_static_library("libdm_static") {
|
||||
"${window_base_path}/window_scene/interfaces/innerkits:libwsutils",
|
||||
]
|
||||
|
||||
public_external_deps = [ "graphic_2d:color_manager" ]
|
||||
public_external_deps = [
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
@ -107,7 +115,10 @@ ohos_shared_library("libdm") {
|
||||
"../resources/config/build:coverage_flags",
|
||||
]
|
||||
|
||||
public_configs = [ ":libdm_public_config" ]
|
||||
public_configs = [
|
||||
":for_libdm_public_config",
|
||||
":libdm_public_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
|
@ -406,7 +406,7 @@ void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
|
||||
WLOGFE("object is null");
|
||||
return;
|
||||
}
|
||||
WLOGFD("dms OnRemoteDied");
|
||||
WLOGFI("dms OnRemoteDied");
|
||||
adapter_.Clear();
|
||||
SingletonContainer::Get<DisplayManager>().OnRemoteDied();
|
||||
SingletonContainer::Get<ScreenManager>().OnRemoteDied();
|
||||
|
@ -83,7 +83,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, Function | Sm
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorGamut, Function | SmallTest |
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, Function | SmallTest | Le
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, Function | SmallTes
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, Function | SmallTest | Level
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, Function | SmallTest | Level
|
||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
|
||||
} else {
|
||||
ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
|
||||
ASSERT_EQ(err, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Leve
|
||||
{
|
||||
DisplayState state = DisplayState{1};
|
||||
bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
|
||||
ASSERT_FALSE(ret);
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +349,7 @@ HWTEST_F(DisplayManagerTest, GetScreenBrightness, Function | SmallTest | Level1)
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, GetDisplayById, Function | SmallTest | Level1)
|
||||
{
|
||||
DisplayId displayId = 0;
|
||||
DisplayId displayId = -1;
|
||||
DisplayManager::GetInstance().destroyed_ = true;
|
||||
auto ret = DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
ASSERT_EQ(ret, nullptr);
|
||||
@ -650,6 +650,81 @@ HWTEST_F(DisplayManagerTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest
|
||||
auto ret = DisplayManager::GetInstance().RemoveSurfaceNodeFromDisplay(0, surfaceNode);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_IPC_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterFoldAngleListener01
|
||||
* @tc.desc: RegisterFoldAngleListener01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, RegisterFoldAngleListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
sptr<DisplayManager::IFoldAngleListener> listener = nullptr;
|
||||
auto ret = DisplayManager::GetInstance().RegisterFoldAngleListener(listener);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
|
||||
listener = new DisplayManager::IFoldAngleListener();
|
||||
ret = DisplayManager::GetInstance().RegisterFoldAngleListener(listener);
|
||||
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->RegisterFoldAngleListener(listener));
|
||||
listener.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnregisterFoldAngleListener01
|
||||
* @tc.desc: UnregisterFoldAngleListener01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, UnregisterFoldAngleListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
sptr<DisplayManager::IFoldAngleListener> listener;
|
||||
auto ret = DisplayManager::GetInstance().UnregisterFoldAngleListener(listener);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
|
||||
listener = new DisplayManager::IFoldAngleListener();
|
||||
ret = DisplayManager::GetInstance().UnregisterFoldAngleListener(listener);
|
||||
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->UnregisterFoldAngleListener(listener));
|
||||
listener.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterCaptureStatusListener01
|
||||
* @tc.desc: RegisterCaptureStatusListener01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, RegisterCaptureStatusListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
sptr<DisplayManager::ICaptureStatusListener> listener = nullptr;
|
||||
auto ret = DisplayManager::GetInstance().RegisterCaptureStatusListener(listener);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
|
||||
listener = new DisplayManager::ICaptureStatusListener();
|
||||
ret = DisplayManager::GetInstance().RegisterCaptureStatusListener(listener);
|
||||
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->RegisterCaptureStatusListener(listener));
|
||||
listener.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnregisterCaptureStatusListener01
|
||||
* @tc.desc: UnregisterCaptureStatusListener01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, UnregisterCaptureStatusListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
sptr<DisplayManager::ICaptureStatusListener> listener;
|
||||
auto ret = DisplayManager::GetInstance().UnregisterCaptureStatusListener(listener);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
|
||||
listener = new DisplayManager::ICaptureStatusListener();
|
||||
ret = DisplayManager::GetInstance().UnregisterCaptureStatusListener(listener);
|
||||
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->UnregisterCaptureStatusListener(listener));
|
||||
listener.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCaptured01
|
||||
* @tc.desc: IsCaptured01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, IsCaptured01, Function | SmallTest | Level1)
|
||||
{
|
||||
auto ret = DisplayManager::GetInstance().IsCaptured();
|
||||
ASSERT_FALSE(ret);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -185,7 +185,7 @@ HWTEST_F(DisplayTest, HasImmersiveWindow, Function | SmallTest | Level1)
|
||||
{
|
||||
bool immersive = false;
|
||||
DMError ret = defaultDisplay_->HasImmersiveWindow(immersive);
|
||||
ASSERT_EQ(ret, DMError::DM_ERROR_DEVICE_NOT_SUPPORT);
|
||||
ASSERT_EQ(ret, DMError::DM_OK);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -543,7 +543,7 @@ HWTEST_F(ScreenManagerTest, GetVirtualScreenFlag01, Function | SmallTest | Level
|
||||
DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::CAST);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
VirtualScreenFlag screenFlag = ScreenManager::GetInstance().GetVirtualScreenFlag(screenId);
|
||||
ASSERT_EQ(VirtualScreenFlag::CAST, screenFlag);
|
||||
ASSERT_EQ(VirtualScreenFlag::DEFAULT, screenFlag);
|
||||
ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
@ -581,6 +581,38 @@ HWTEST_F(ScreenManagerTest, SetVirtualMirrorScreenScaleMode02, Function | SmallT
|
||||
ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCaptured02
|
||||
* @tc.desc: IsCaptured02 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, IsCaptured02, Function | SmallTest | Level1)
|
||||
{
|
||||
VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_,
|
||||
defaultDensity_, nullptr, defaultFlags_};
|
||||
ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||
bool isCapture = DisplayManager::GetInstance().IsCaptured();
|
||||
ASSERT_TRUE(isCapture);
|
||||
auto ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCaptured03
|
||||
* @tc.desc: IsCaptured03 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, IsCaptured03, Function | SmallTest | Level1)
|
||||
{
|
||||
VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_,
|
||||
defaultDensity_, nullptr, defaultFlags_};
|
||||
ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||
auto ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
bool isCapture = DisplayManager::GetInstance().IsCaptured();
|
||||
ASSERT_FALSE(isCapture);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -37,6 +37,7 @@ ohos_shared_library("libdm_lite") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -31,6 +31,7 @@ ohos_shared_library("libdms") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -78,9 +79,7 @@ ohos_shared_library("libdms") {
|
||||
]
|
||||
|
||||
if (defined(use_new_skia) && use_new_skia) {
|
||||
include_dirs = [ "//third_party/skia/src" ]
|
||||
} else {
|
||||
include_dirs = [ "//third_party/flutter/skia/src" ]
|
||||
include_dirs = [ "../../../../third_party/skia/src" ]
|
||||
}
|
||||
|
||||
defines = []
|
||||
|
@ -33,6 +33,7 @@ ohos_shared_library("libwindow_extension_client") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
install_enable = true
|
||||
|
@ -28,6 +28,7 @@ ohos_shared_library("libmodal_system_ui_extension_client") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
install_enable = true
|
||||
|
@ -35,6 +35,7 @@ ohos_shared_library("libwindow_extension") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -93,6 +94,7 @@ ohos_shared_library("window_extension_module") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "src/window_extension_module_loader.cpp" ]
|
||||
|
@ -53,6 +53,9 @@ int WindowExtensionStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
|
||||
sptr<IRemoteObject> object = data.ReadRemoteObject();
|
||||
sptr<IWindowExtensionClient> token = iface_cast<IWindowExtensionClient>(object);
|
||||
GetExtensionWindow(token);
|
||||
if (token == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -23,6 +23,7 @@ ohos_shared_library("wm_interface") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
public_configs = [ ":wm_interface_config" ]
|
||||
|
@ -445,6 +445,21 @@ public:
|
||||
virtual void OnRectChange(Rect rect, WindowSizeChangeReason reason) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @class IKeyboardPanelInfoChangeListener
|
||||
*
|
||||
* @brief IKeyboardPanelInfoChangeListener is used to observe the keyboard panel info.
|
||||
*/
|
||||
class IKeyboardPanelInfoChangeListener : virtual public RefBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Notify caller when keyboard info changed.
|
||||
*
|
||||
* @param KeyboardPanelInfo keyboardPanelInfo of the keyboard panel;
|
||||
*/
|
||||
virtual void OnKeyboardPanelInfoChanged(const KeyboardPanelInfo& keyboardPanelInfo) {}
|
||||
};
|
||||
|
||||
static WMError DefaultCreateErrCode = WMError::WM_OK;
|
||||
class Window : virtual public RefBase {
|
||||
public:
|
||||
@ -1795,6 +1810,17 @@ public:
|
||||
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set water mark flag.
|
||||
*
|
||||
* @param isEnable bool.
|
||||
* @return WMError
|
||||
*/
|
||||
virtual WMError SetWaterMarkFlag(bool isEnable)
|
||||
{
|
||||
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the modality of window.
|
||||
*
|
||||
@ -1814,22 +1840,6 @@ public:
|
||||
*/
|
||||
virtual WMError Recover(uint32_t reason) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
|
||||
/**
|
||||
* @brief Add uiextension window flag.
|
||||
*
|
||||
* @param flag Flag of uiextension window.
|
||||
* @return WM_OK means add success, others means failed.
|
||||
*/
|
||||
virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
|
||||
/**
|
||||
* @brief Remove uiextension window flag.
|
||||
*
|
||||
* @param flag Flag of uiextension window
|
||||
* @return WM_OK means remove success, others means failed.
|
||||
*/
|
||||
virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
|
||||
/**
|
||||
* @brief Make multi-window become landscape or not.
|
||||
*
|
||||
@ -1882,6 +1892,28 @@ public:
|
||||
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register keyboard panel info change listener.
|
||||
*
|
||||
* @param listener IKeyboardPanelInfoChangeListener.
|
||||
* @return WM_OK means register success, others means register failed.
|
||||
*/
|
||||
virtual WMError RegisterKeyboardPanelInfoChangeListener(const sptr<IKeyboardPanelInfoChangeListener>& listener)
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unregister keyboard panel info change listener.
|
||||
*
|
||||
* @param listener IKeyboardPanelInfoChangeListener.
|
||||
* @return WM_OK means unregister success, others means unregister failed.
|
||||
*/
|
||||
virtual WMError UnregisterKeyboardPanelInfoChangeListener(const sptr<IKeyboardPanelInfoChangeListener>& listener)
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get window by id
|
||||
*
|
||||
@ -1927,6 +1959,13 @@ public:
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set gray scale of window
|
||||
* @param grayScale gray scale of window.
|
||||
* @return WM_OK means set success, others means set failed.
|
||||
*/
|
||||
virtual WMError SetGrayScale(float grayScale) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -237,6 +237,20 @@ public:
|
||||
*/
|
||||
void SetExtensionTag(bool isExtensionTag);
|
||||
|
||||
/**
|
||||
* @brief Set Dialog Decor Enable Or Not.
|
||||
*
|
||||
* @param decorEnable true means enable, default disabled.
|
||||
*/
|
||||
void SetDialogDecorEnable(bool decorEnable);
|
||||
|
||||
/**
|
||||
* @brief Set Dialog title.
|
||||
*
|
||||
* @param dialogTitle true means enable, default disabled.
|
||||
*/
|
||||
void SetDialogTitle(const std::string& dialogTitle);
|
||||
|
||||
/**
|
||||
* @brief Get window rect.
|
||||
*
|
||||
@ -391,6 +405,20 @@ public:
|
||||
*/
|
||||
bool GetExtensionTag() const;
|
||||
|
||||
/**
|
||||
* @brief Get dialog decor enable
|
||||
*
|
||||
* @return true means the dialog decor is enabled, otherwise not.
|
||||
*/
|
||||
bool GetDialogDecorEnable() const;
|
||||
|
||||
/**
|
||||
* @brief Get dialog title
|
||||
*
|
||||
* @return Return the dialog title
|
||||
*/
|
||||
std::string GetDialogTitle() const;
|
||||
|
||||
private:
|
||||
Rect windowRect_ { 0, 0, 0, 0 };
|
||||
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||
@ -419,6 +447,8 @@ private:
|
||||
bool subWindowDecorEnable_ = false;
|
||||
bool onlySupportSceneBoard_ = false;
|
||||
bool isExtensionTag_ = false;
|
||||
bool dialogDecorEnable_ = false;
|
||||
std::string dialogTitle_ = { "" };
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -289,11 +289,19 @@ enum class WindowFlag : uint32_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates flag of uiextension window.
|
||||
* @brief Flag of uiextension window.
|
||||
*/
|
||||
enum class ExtensionWindowFlag : uint32_t {
|
||||
EXTENSION_WINDOW_FLAG_WATER_MARK = 1,
|
||||
EXTENSION_WINDOW_FLAG_END = 1 << 1,
|
||||
union ExtensionWindowFlags {
|
||||
uint32_t bitData;
|
||||
struct {
|
||||
// Each flag should be false default, true when active
|
||||
bool hideNonSecureWindowsFlag : 1;
|
||||
bool waterMarkFlag : 1;
|
||||
bool privacyModeFlag : 1;
|
||||
};
|
||||
ExtensionWindowFlags() : bitData(0) {}
|
||||
ExtensionWindowFlags(uint32_t bits) : bitData(bits) {}
|
||||
~ExtensionWindowFlags() {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -365,6 +373,7 @@ enum class WindowSessionType : uint32_t {
|
||||
enum class WindowGravity : uint32_t {
|
||||
WINDOW_GRAVITY_FLOAT = 0,
|
||||
WINDOW_GRAVITY_BOTTOM,
|
||||
WINDOW_GRAVITY_DEFAULT,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -550,6 +559,44 @@ struct Rect {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct KeyboardPanelInfo
|
||||
*
|
||||
* @brief Info of keyboard panel
|
||||
*/
|
||||
struct KeyboardPanelInfo : public Parcelable {
|
||||
Rect rect_ = {0, 0, 0, 0};
|
||||
WindowGravity gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
|
||||
bool isShowing_ = false;
|
||||
|
||||
bool Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) &&
|
||||
parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(gravity_)) &&
|
||||
parcel.WriteBool(isShowing_);
|
||||
}
|
||||
|
||||
static KeyboardPanelInfo* Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
KeyboardPanelInfo* keyboardPanelInfo = new(std::nothrow)KeyboardPanelInfo;
|
||||
if (keyboardPanelInfo == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
bool res = parcel.ReadInt32(keyboardPanelInfo->rect_.posX_) &&
|
||||
parcel.ReadInt32(keyboardPanelInfo->rect_.posY_) && parcel.ReadUint32(keyboardPanelInfo->rect_.width_) &&
|
||||
parcel.ReadUint32(keyboardPanelInfo->rect_.height_);
|
||||
if (!res) {
|
||||
delete keyboardPanelInfo;
|
||||
return nullptr;
|
||||
}
|
||||
keyboardPanelInfo->gravity_ = static_cast<WindowGravity>(parcel.ReadUint32());
|
||||
keyboardPanelInfo->isShowing_ = parcel.ReadBool();
|
||||
|
||||
return keyboardPanelInfo;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates avoid area type.
|
||||
*/
|
||||
|
@ -36,6 +36,7 @@ ohos_static_library("dm_napi_common") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
|
@ -20,9 +20,6 @@ config("display_config") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"../../../../utils/include",
|
||||
|
||||
# because of pixle_map.h
|
||||
"//foundation/multimedia/image_framework/interfaces/innerkits/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -32,6 +29,7 @@ ohos_shared_library("display_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -61,6 +59,8 @@ ohos_shared_library("display_napi") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
public_external_deps = [ "image_framework:image_native" ]
|
||||
|
||||
relative_install_dir = "module"
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
@ -45,7 +45,7 @@ explicit JsDisplayManager(napi_env env) {
|
||||
|
||||
static void Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
WLOGD("Finalizer is called");
|
||||
WLOGI("Finalizer is called");
|
||||
std::unique_ptr<JsDisplayManager>(static_cast<JsDisplayManager*>(data));
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ ohos_shared_library("embeddablewindowstage") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "embeddable_window_stage_module.cpp" ]
|
||||
@ -75,6 +76,7 @@ ohos_shared_library("embeddablewindowstage_kit") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "js_embeddable_window_stage.cpp" ]
|
||||
|
@ -39,6 +39,7 @@ ohos_shared_library("extensionwindow") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "extension_window_module.cpp" ]
|
||||
@ -74,6 +75,7 @@ ohos_shared_library("extensionwindow_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -24,6 +24,7 @@ ohos_shared_library("pipwindow_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -24,6 +24,7 @@ ohos_shared_library("pip_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -25,6 +25,7 @@ ohos_shared_library("screen_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -19,6 +19,7 @@ ohos_shared_library("screenshot") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "native_screenshot_module.cpp" ]
|
||||
|
@ -39,6 +39,7 @@ ohos_shared_library("windowextensionability_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "window_extension_ability_module.cpp" ]
|
||||
|
@ -39,6 +39,7 @@ ohos_shared_library("windowextensioncontext_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "window_extension_context_module.cpp" ]
|
||||
|
@ -44,6 +44,7 @@ ohos_shared_library("window_native_kit") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -101,6 +102,7 @@ ohos_shared_library("window_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -145,6 +147,7 @@ ohos_shared_library("windowstage_kit") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "window_stage_napi/js_window_stage.cpp" ]
|
||||
|
@ -416,8 +416,8 @@ napi_value JsWindowManager::OnCreate(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JsWindowManager::ParseConfigOption(napi_env env, napi_value jsObject,
|
||||
WindowOption& option, void*& contextPtr)
|
||||
bool JsWindowManager::ParseRequiredConfigOption(napi_env env, napi_value jsObject,
|
||||
WindowOption& option)
|
||||
{
|
||||
std::string windowName;
|
||||
if (ParseJsValue(jsObject, env, "name", windowName)) {
|
||||
@ -439,11 +439,18 @@ bool JsWindowManager::ParseConfigOption(napi_env env, napi_value jsObject,
|
||||
WLOGFE("Failed to convert parameter to winType");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsWindowManager::ParseConfigOption(napi_env env, napi_value jsObject,
|
||||
WindowOption& option, void*& contextPtr)
|
||||
{
|
||||
if (!ParseRequiredConfigOption(env, jsObject, option)) {
|
||||
return false;
|
||||
}
|
||||
if (!isConfigOptionWindowTypeValid(env, option)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_value value = nullptr;
|
||||
napi_get_named_property(env, jsObject, "ctx", &value);
|
||||
if (GetType(env, value) == napi_undefined) {
|
||||
@ -455,6 +462,16 @@ bool JsWindowManager::ParseConfigOption(napi_env env, napi_value jsObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dialogDecorEnable = false;
|
||||
if (ParseJsValue(jsObject, env, "decorEnable", dialogDecorEnable)) {
|
||||
option.SetDialogDecorEnable(dialogDecorEnable);
|
||||
}
|
||||
|
||||
std::string dialogTitle;
|
||||
if (ParseJsValue(jsObject, env, "title", dialogTitle)) {
|
||||
option.SetDialogTitle(dialogTitle);
|
||||
}
|
||||
|
||||
int64_t displayId = static_cast<int64_t>(DISPLAY_ID_INVALID);
|
||||
if (ParseJsValue(jsObject, env, "displayId", displayId)) {
|
||||
if (displayId < 0 ||
|
||||
|
@ -60,6 +60,8 @@ private:
|
||||
static napi_value OnSetGestureNavigationEnabled(napi_env env, napi_callback_info info);
|
||||
static napi_value OnSetWaterMarkImage(napi_env env, napi_callback_info info);
|
||||
static napi_value OnShiftAppWindowFocus(napi_env env, napi_callback_info info);
|
||||
static bool ParseRequiredConfigOption(
|
||||
napi_env env, napi_value jsObject, WindowOption& option);
|
||||
static bool ParseConfigOption(
|
||||
napi_env env, napi_value jsObject, WindowOption& option, void*& contextPtr);
|
||||
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
||||
|
@ -50,6 +50,8 @@ namespace {
|
||||
constexpr size_t INDEX_ZERO = 0;
|
||||
constexpr size_t INDEX_ONE = 1;
|
||||
constexpr size_t INDEX_TWO = 2;
|
||||
constexpr double MIN_GRAY_SCALE = 0.0;
|
||||
constexpr double MAX_GRAY_SCALE = 1.0;
|
||||
}
|
||||
|
||||
static thread_local std::map<std::string, std::shared_ptr<NativeReference>> g_jsWindowMap;
|
||||
@ -815,6 +817,13 @@ napi_value JsWindow::SetWindowMask(napi_env env, napi_callback_info info)
|
||||
return (me != nullptr) ? me->OnSetWindowMask(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindow::SetWindowGrayScale(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]SetWindowGrayScale");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
|
||||
return (me != nullptr) ? me->OnSetWindowGrayScale(env, info) : nullptr;
|
||||
}
|
||||
|
||||
static void UpdateSystemBarProperties(std::map<WindowType, SystemBarProperty>& systemBarProperties,
|
||||
const std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, sptr<Window> windowToken)
|
||||
{
|
||||
@ -1988,7 +1997,8 @@ napi_value JsWindow::OnSetFullScreen(napi_env env, napi_callback_info info)
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to isFullScreen");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isFullScreen);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isFullScreen));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2038,7 +2048,8 @@ napi_value JsWindow::OnSetLayoutFullScreen(napi_env env, napi_callback_info info
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to isLayoutFullScreen");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isLayoutFullScreen);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isLayoutFullScreen));
|
||||
}
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
@ -2087,7 +2098,8 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to isLayoutFullScreen");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isLayoutFullScreen);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isLayoutFullScreen));
|
||||
}
|
||||
}
|
||||
if (errCode != WmErrorCode::WM_OK) {
|
||||
@ -2519,7 +2531,8 @@ static void ParseAvoidAreaParam(napi_env env, napi_callback_info info, WMError&
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
uint32_t resultValue = 0;
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue));
|
||||
avoidAreaType = static_cast<AvoidAreaType>(resultValue);
|
||||
errCode = ((avoidAreaType > AvoidAreaType::TYPE_KEYBOARD) ||
|
||||
(avoidAreaType < AvoidAreaType::TYPE_SYSTEM)) ? WMError::WM_ERROR_INVALID_PARAM : WMError::WM_OK;
|
||||
@ -2592,7 +2605,8 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
uint32_t resultValue = 0;
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue));
|
||||
avoidAreaType = static_cast<AvoidAreaType>(resultValue);
|
||||
errCode = ((avoidAreaType > AvoidAreaType::TYPE_NAVIGATION_INDICATOR) ||
|
||||
(avoidAreaType < AvoidAreaType::TYPE_SYSTEM)) ?
|
||||
@ -2932,7 +2946,8 @@ napi_value JsWindow::OnSetBrightness(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to brightness");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_double(env, nativeVal, &brightness);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &brightness));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2984,7 +2999,8 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info
|
||||
WLOGFE("Failed to convert parameter to brightness");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_double(env, nativeVal, &brightness);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &brightness));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -3052,7 +3068,8 @@ napi_value JsWindow::OnSetFocusable(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to focusable");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &focusable);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &focusable));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3103,7 +3120,8 @@ napi_value JsWindow::OnSetWindowFocusable(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to focusable");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &focusable);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &focusable));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -3202,7 +3220,8 @@ napi_value JsWindow::OnSetKeepScreenOn(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to keepScreenOn");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &keepScreenOn);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &keepScreenOn));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3255,7 +3274,8 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in
|
||||
WLOGFE("Failed to convert parameter to keepScreenOn");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &keepScreenOn);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &keepScreenOn));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -3323,10 +3343,13 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to keepScreenOn");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &wakeUp);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &wakeUp));
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
windowToken_->SetTurnScreenOn(wakeUp);
|
||||
WLOGI("Window [%{public}u, %{public}s] set wake up screen %{public}d end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), wakeUp);
|
||||
@ -3367,7 +3390,8 @@ napi_value JsWindow::OnSetPrivacyMode(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to isPrivacyMode");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isPrivacyMode);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isPrivacyMode));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3415,7 +3439,8 @@ napi_value JsWindow::OnSetWindowPrivacyMode(napi_env env, napi_callback_info inf
|
||||
WLOGFE("Failed to convert parameter to isPrivacyMode");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isPrivacyMode);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isPrivacyMode));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -3469,7 +3494,8 @@ napi_value JsWindow::OnSetTouchable(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to touchable");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &touchable);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &touchable));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3562,7 +3588,8 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i
|
||||
WLOGFE("Failed to convert parameter to dragEnabled");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, argv[0], &dragEnabled);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, argv[0], &dragEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3616,10 +3643,11 @@ napi_value JsWindow::OnSetRaiseByClickEnabled(napi_env env, napi_callback_info i
|
||||
WLOGFE("Failed to convert parameter to raiseEnabled");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, argv[0], &raiseEnabled);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, argv[0], &raiseEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weakToken, raiseEnabled, errCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
@ -3787,7 +3815,8 @@ void GetSubWindowId(napi_env env, napi_value nativeVal, WmErrorCode &errCode, in
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
int32_t resultValue = 0;
|
||||
napi_get_value_int32(env, nativeVal, &resultValue);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_int32(env, nativeVal, &resultValue));
|
||||
if (resultValue <= 0) {
|
||||
WLOGFE("Failed to get subWindowId due to resultValue less than or equal to 0");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
@ -3859,7 +3888,12 @@ napi_value JsWindow::OnKeepKeyboardOnFocus(napi_env env, napi_callback_info info
|
||||
WLOGFE("Failed to get parameter keepKeyboardFlag");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &keepKeyboardFlag);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &keepKeyboardFlag));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
}
|
||||
|
||||
if (windowToken_ == nullptr) {
|
||||
@ -3901,7 +3935,8 @@ napi_value JsWindow::OnSetWindowTouchable(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to touchable");
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &touchable);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &touchable));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -3953,7 +3988,8 @@ napi_value JsWindow::OnSetTransparent(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to isTransparent");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isTransparent);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isTransparent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4071,7 +4107,8 @@ napi_value JsWindow::OnSetColorSpace(napi_env env, napi_callback_info info)
|
||||
WLOGFE("Failed to convert parameter to ColorSpace");
|
||||
} else {
|
||||
uint32_t resultValue = 0;
|
||||
napi_get_value_uint32(env, nativeType, &resultValue);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_uint32(env, nativeType, &resultValue));
|
||||
colorSpace = static_cast<ColorSpace>(resultValue);
|
||||
if (colorSpace > ColorSpace::COLOR_SPACE_WIDE_GAMUT || colorSpace < ColorSpace::COLOR_SPACE_DEFAULT) {
|
||||
WLOGFE("ColorSpace %{public}u invalid!", static_cast<uint32_t>(colorSpace));
|
||||
@ -4125,7 +4162,8 @@ napi_value JsWindow::OnSetWindowColorSpace(napi_env env, napi_callback_info info
|
||||
WLOGFE("Failed to convert parameter to ColorSpace");
|
||||
} else {
|
||||
uint32_t resultValue = 0;
|
||||
napi_get_value_uint32(env, nativeType, &resultValue);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_uint32(env, nativeType, &resultValue));
|
||||
colorSpace = static_cast<ColorSpace>(resultValue);
|
||||
if (colorSpace > ColorSpace::COLOR_SPACE_WIDE_GAMUT || colorSpace < ColorSpace::COLOR_SPACE_DEFAULT) {
|
||||
WLOGFE("ColorSpace %{public}u invalid!", static_cast<uint32_t>(colorSpace));
|
||||
@ -4262,7 +4300,8 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info)
|
||||
if (argv[0] == nullptr) {
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, argv[0], &isForbidSplitMove);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, argv[0], &isForbidSplitMove));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -4356,7 +4395,8 @@ napi_value JsWindow::OnSetSnapshotSkip(napi_env env, napi_callback_info info)
|
||||
if (nativeVal == nullptr) {
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_bool(env, nativeVal, &isSkip);
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isSkip));
|
||||
}
|
||||
}
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
@ -4437,7 +4477,12 @@ napi_value JsWindow::OnOpacity(napi_env env, napi_callback_info info)
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
double alpha = 0.0;
|
||||
napi_get_value_double(env, nativeVal, &alpha);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &alpha));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (MathHelper::LessNotEqual(alpha, 0.0) || MathHelper::GreatNotEqual(alpha, 1.0)) {
|
||||
WLOGFE("alpha should greater than 0 or smaller than 1.0");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -4744,7 +4789,12 @@ napi_value JsWindow::OnSetCornerRadius(napi_env env, napi_callback_info info)
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
double radius = 0.0;
|
||||
napi_get_value_double(env, nativeVal, &radius);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &radius));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
WLOGFE("SetCornerRadius invalid radius");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -4779,7 +4829,8 @@ napi_value JsWindow::OnSetShadow(napi_env env, napi_callback_info info)
|
||||
if (argv[0] == nullptr) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
napi_get_value_double(env, argv[0], &result);
|
||||
CHECK_NAPI_RETCODE(ret, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, argv[0], &result));
|
||||
if (MathHelper::LessNotEqual(result, 0.0)) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
@ -4835,7 +4886,12 @@ napi_value JsWindow::OnSetBlur(napi_env env, napi_callback_info info)
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
double radius = 0.0;
|
||||
napi_get_value_double(env, nativeVal, &radius);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &radius));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
WLOGFE("SetBlur invalid radius");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -4873,7 +4929,12 @@ napi_value JsWindow::OnSetBackdropBlur(napi_env env, napi_callback_info info)
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
double radius = 0.0;
|
||||
napi_get_value_double(env, nativeVal, &radius);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &radius));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
WLOGFE("SetBackdropBlur invalid radius");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -4912,7 +4973,12 @@ napi_value JsWindow::OnSetBackdropBlurStyle(napi_env env, napi_callback_info inf
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
uint32_t resultValue = 0;
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_uint32(env, nativeMode, &resultValue));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (resultValue > static_cast<uint32_t>(WindowBlurStyle::WINDOW_BLUR_THICK)) {
|
||||
WLOGFE("SetBackdropBlurStyle Invalid window blur style");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -4946,7 +5012,10 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
bool isAddSafetyLayer = false;
|
||||
napi_get_value_bool(env, nativeBool, &isAddSafetyLayer);
|
||||
napi_status statusCode = napi_get_value_bool(env, nativeBool, &isAddSafetyLayer);
|
||||
if (statusCode != napi_ok) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weakToken, isAddSafetyLayer](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
@ -5058,7 +5127,8 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info)
|
||||
if (nativeVal == nullptr) {
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
napi_get_value_double(env, nativeVal, &aspectRatio);
|
||||
CHECK_NAPI_RETCODE(errCode, WMError::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_double(env, nativeVal, &aspectRatio));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5410,7 +5480,12 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
bool isVisible = true;
|
||||
napi_get_value_bool(env, nativeVal, &isVisible);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_bool(env, nativeVal, &isVisible));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetDecorVisible(isVisible));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window decor set visible failed");
|
||||
@ -5495,7 +5570,13 @@ napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info inf
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
int32_t height = 0;
|
||||
napi_get_value_int32(env, nativeVal, &height);
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
napi_get_value_int32(env, nativeVal, &height));
|
||||
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
if (height < MIN_DECOR_HEIGHT || height > MAX_DECOR_HEIGHT) {
|
||||
WLOGFE("height should greater than 37 or smaller than 112");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
@ -5643,6 +5724,52 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsWindow::OnSetWindowGrayScale(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != 1) { // 1: the param num
|
||||
WLOGFE("Argc is invalid: %{public}zu", argc);
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
napi_value nativeVal = argv[0];
|
||||
if (nativeVal == nullptr) {
|
||||
WLOGFE("Failed to convert parameter to grayScale");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
double grayScale = 0.0;
|
||||
napi_get_value_double(env, nativeVal, &grayScale);
|
||||
constexpr double eps = 1e-6;
|
||||
if (grayScale < (MIN_GRAY_SCALE - eps) || grayScale > (MAX_GRAY_SCALE + eps)) {
|
||||
WLOGFE("grayScale should be greater than or equal to 0.0, and should be smaller than or equal to 1.0");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weakToken, grayScale](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto window = weakToken.promote();
|
||||
if (window == nullptr) {
|
||||
WLOGFE("window is nullptr");
|
||||
task.Reject(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||
return;
|
||||
}
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetGrayScale(static_cast<float>(grayScale)));
|
||||
if (ret == WmErrorCode::WM_OK) {
|
||||
task.Resolve(env, NapiGetUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, static_cast<int32_t>(ret), "Set window gray scale failed"));
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] OnSetWindowGrayScale end, grayScale = %{public}f",
|
||||
window->GetWindowId(), window->GetWindowName().c_str(), grayScale);
|
||||
};
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsWindow::OnSetWindowGrayScale",
|
||||
env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
void BindFunctions(napi_env env, napi_value object, const char *moduleName)
|
||||
{
|
||||
BindNativeFunction(env, object, "show", moduleName, JsWindow::Show);
|
||||
@ -5751,6 +5878,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName)
|
||||
BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect);
|
||||
BindNativeFunction(env, object, "setTitleButtonVisible", moduleName, JsWindow::SetTitleButtonVisible);
|
||||
BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask);
|
||||
BindNativeFunction(env, object, "setWindowGrayScale", moduleName, JsWindow::SetWindowGrayScale);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info);
|
||||
static napi_value SetTitleButtonVisible(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWindowMask(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWindowGrayScale(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
std::string GetWindowName();
|
||||
@ -269,6 +270,7 @@ private:
|
||||
napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetWindowMask(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetHandwritingFlag(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetWindowGrayScale(napi_env env, napi_callback_info info);
|
||||
|
||||
sptr<Window> windowToken_ = nullptr;
|
||||
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
||||
|
@ -39,6 +39,7 @@ ohos_shared_library("windowstage") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "window_stage_module.cpp" ]
|
||||
|
@ -327,6 +327,8 @@ public:
|
||||
{
|
||||
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
virtual WMError SetGrayScale(float grayScale) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ ohos_executable("snapshot_display") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
install_enable = true
|
||||
@ -53,6 +54,7 @@ ohos_shared_library("libsnapshot_util") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "src/snapshot_utils.cpp" ]
|
||||
|
@ -380,6 +380,10 @@ void CheckWindowImplFunctionsPart1(sptr<Window> window, const uint8_t* data, siz
|
||||
|
||||
startPos += GetObject(boolVal, data + startPos, size - startPos);
|
||||
window->UpdateSurfaceNodeAfterCustomAnimation(boolVal);
|
||||
|
||||
float grayScale;
|
||||
startPos += GetObject(grayScale, data + startPos, size - startPos);
|
||||
window->SetGrayScale(grayScale);
|
||||
}
|
||||
|
||||
void CheckWindowImplFunctionsPart2(sptr<WindowImpl> window, const uint8_t* data, size_t size)
|
||||
|
@ -191,8 +191,6 @@ HWTEST_F(WindowEffectTest, WindowEffect07, Function | MediumTest | Level3)
|
||||
ASSERT_NE(nullptr, window);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_REGULAR));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_THICK));
|
||||
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackdropBlurStyle(static_cast<WindowBlurStyle>(-1)));
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackdropBlurStyle(static_cast<WindowBlurStyle>(5)));
|
||||
@ -208,12 +206,13 @@ HWTEST_F(WindowEffectTest, WindowEffect07, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowEffectTest, WindowEffect08, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window> &window = Utils::CreateTestWindow(windowInfo_);
|
||||
ASSERT_NE(nullptr, window);
|
||||
|
||||
WindowAccessibilityController::GetInstance().OffWindowZoom();
|
||||
sleep(1);
|
||||
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2);
|
||||
sleep(1);
|
||||
WindowAccessibilityController::GetInstance().SetAnchorOffset(-100, -100);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -116,10 +116,6 @@ void WindowLayoutTest::SetUp()
|
||||
|
||||
void WindowLayoutTest::TearDown()
|
||||
{
|
||||
while (!activeWindows_.empty()) {
|
||||
ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy());
|
||||
activeWindows_.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -71,7 +71,9 @@ void WindowMoveDragTest::TearDownTestCase()
|
||||
void WindowMoveDragTest::SetUp()
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
if (display == nullptr) {
|
||||
return;
|
||||
}
|
||||
WLOGI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n",
|
||||
(unsigned long long)display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
@ -144,6 +146,9 @@ namespace {
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow01, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -162,6 +167,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow02, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -180,6 +188,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow02, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow03, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -199,6 +210,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow03, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow04, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -218,6 +232,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow04, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow05, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -236,6 +253,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow05, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow06, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -255,6 +275,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow06, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow07, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -272,6 +295,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow07, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow08, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -290,6 +316,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow08, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow09, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
@ -308,6 +337,9 @@ HWTEST_F(WindowMoveDragTest, DragWindow09, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow10, Function | MediumTest | Level3)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
usleep(WAIT_SYANC_MS);
|
||||
startPointRect_ = window_->GetRect();
|
||||
|
@ -174,8 +174,6 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "primary.3";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
ASSERT_FALSE(Utils::InitSplitRects());
|
||||
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
if (fullWindow == nullptr) {
|
||||
return;
|
||||
@ -210,8 +208,6 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "secondary.4";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
|
||||
ASSERT_FALSE(Utils::InitSplitRects());
|
||||
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
if (fullWindow == nullptr) {
|
||||
return;
|
||||
|
@ -35,6 +35,7 @@ ohos_static_library("libwmutil_static") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
@ -108,6 +109,7 @@ ohos_shared_library("libwmutil_base") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -24,13 +24,27 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
bool AccessibilityWindowInfo::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteInt32(wid_) && parcel.WriteInt32(innerWid_) && parcel.WriteInt32(uiNodeId_) &&
|
||||
auto touchHotAreas = touchHotAreas_;
|
||||
bool res = parcel.WriteInt32(wid_) && parcel.WriteInt32(innerWid_) && parcel.WriteInt32(uiNodeId_) &&
|
||||
parcel.WriteUint32(windowRect_.width_) &&
|
||||
parcel.WriteUint32(windowRect_.height_) && parcel.WriteInt32(windowRect_.posX_) &&
|
||||
parcel.WriteInt32(windowRect_.posY_) && parcel.WriteBool(focused_) && parcel.WriteBool(isDecorEnable_) &&
|
||||
parcel.WriteUint64(displayId_) && parcel.WriteUint32(layer_) && parcel.WriteFloat(scaleVal_) &&
|
||||
parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(mode_)) && parcel.WriteUint32(static_cast<uint32_t>(type_));
|
||||
parcel.WriteUint32(static_cast<uint32_t>(mode_)) && parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
|
||||
parcel.WriteString(bundleName_) && parcel.WriteUint32(touchHotAreas.size());
|
||||
if (!res) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& rect : touchHotAreas) {
|
||||
res = parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
|
||||
parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
|
||||
if (!res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
AccessibilityWindowInfo* AccessibilityWindowInfo::Unmarshalling(Parcel& parcel)
|
||||
@ -52,6 +66,12 @@ AccessibilityWindowInfo* AccessibilityWindowInfo::Unmarshalling(Parcel& parcel)
|
||||
}
|
||||
info->mode_ = static_cast<WindowMode>(parcel.ReadUint32());
|
||||
info->type_ = static_cast<WindowType>(parcel.ReadUint32());
|
||||
info->bundleName_ = parcel.ReadString();
|
||||
size_t touchHotAreasCnt = parcel.ReadUint32();
|
||||
for (size_t i = 0; i < touchHotAreasCnt; i++) {
|
||||
info->touchHotAreas_.push_back({.posX_ = parcel.ReadInt32(), .posY_ = parcel.ReadInt32(),
|
||||
.width_ = parcel.ReadUint32(), .height_ = parcel.ReadUint32()});
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ ohos_shared_library("window_scene_common") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -150,6 +150,8 @@ public:
|
||||
void SetSessionPropertyChangeCallback(std::function<void()>&& callback);
|
||||
bool IsLayoutFullScreen() const;
|
||||
void SetIsLayoutFullScreen(bool isLayoutFullScreen);
|
||||
int32_t GetCollaboratorType() const;
|
||||
void SetCollaboratorType(int32_t collaboratorType);
|
||||
|
||||
private:
|
||||
bool MarshallingTouchHotAreas(Parcel& parcel) const;
|
||||
@ -211,6 +213,7 @@ private:
|
||||
|
||||
bool isShaped_ = false;
|
||||
sptr<Media::PixelMap> windowMask_ = nullptr;
|
||||
int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
|
||||
};
|
||||
|
||||
struct FreeMultiWindowConfig : public Parcelable {
|
||||
|
@ -810,5 +810,15 @@ bool WindowSessionProperty::GetIsShaped() const
|
||||
{
|
||||
return isShaped_;
|
||||
}
|
||||
|
||||
int32_t WindowSessionProperty::GetCollaboratorType() const
|
||||
{
|
||||
return collaboratorType_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetCollaboratorType(int32_t collaboratorType)
|
||||
{
|
||||
collaboratorType_ = collaboratorType;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -19,6 +19,7 @@ ohos_shared_library("libintention_event") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
include_dirs = [
|
||||
@ -43,6 +44,7 @@ ohos_shared_library("libintention_event") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:libcomposer",
|
||||
"graphic_2d:window_animation",
|
||||
"hilog:libhilog",
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
void DispatchKeyEventCallback(
|
||||
int32_t focusedSessionId, std::shared_ptr<MMI::KeyEvent> keyEvent, bool consumed) const;
|
||||
void UpdateLastMouseEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
|
||||
bool CheckPointerEvent(const std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
|
||||
bool UpdatePointerEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
|
||||
void ProcessEnterLeaveEventAsync();
|
||||
bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
|
||||
Ace::UIContent* uiContent_ = nullptr;
|
||||
|
@ -35,6 +35,7 @@ ohos_shared_library("intention_event_anr_manager") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@ -60,7 +59,6 @@ private:
|
||||
std::atomic_int32_t anrTimerCount_ { 0 };
|
||||
std::mutex mtx_;
|
||||
std::unordered_map<int32_t, AppInfo> applicationMap_;
|
||||
std::shared_mutex applicationMapMutex_;
|
||||
std::function<void(int32_t)> anrObserver_;
|
||||
std::function<void(int32_t, std::string&, int32_t)> appInfoGetter_;
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ void ANRManager::MarkProcessed(int32_t eventId, int32_t persistentId)
|
||||
|
||||
bool ANRManager::IsANRTriggered(int32_t persistentId)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
if (DelayedSingleton<EventStage>::GetInstance()->CheckAnrStatus(persistentId)) {
|
||||
WLOGFE("Application not respond, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
@ -105,13 +105,9 @@ bool ANRManager::IsANRTriggered(int32_t persistentId)
|
||||
void ANRManager::OnSessionLost(int32_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("Disconnect session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s", persistentId,
|
||||
applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
}
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
WLOGFD("Disconnect session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
RemoveTimers(persistentId);
|
||||
RemovePersistentId(persistentId);
|
||||
}
|
||||
@ -119,20 +115,16 @@ void ANRManager::OnSessionLost(int32_t persistentId)
|
||||
void ANRManager::OnBackground(int32_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("Background session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s", persistentId,
|
||||
applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
}
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
WLOGFD("Background session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
RemoveTimers(persistentId);
|
||||
RemovePersistentId(persistentId);
|
||||
}
|
||||
|
||||
void ANRManager::SetApplicationInfo(int32_t persistentId, int32_t pid, const std::string& bundleName)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
WLOGFD("PersistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, pid, bundleName.c_str());
|
||||
applicationMap_[persistentId] = { pid, bundleName };
|
||||
@ -148,13 +140,10 @@ void ANRManager::SetAnrObserver(std::function<void(int32_t)> anrObserver)
|
||||
|
||||
ANRManager::AppInfo ANRManager::GetAppInfoByPersistentId(int32_t persistentId)
|
||||
{
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("PersistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
return applicationMap_[persistentId];
|
||||
}
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("PersistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
||||
return applicationMap_[persistentId];
|
||||
}
|
||||
WLOGFD("No application matches persistentId:%{public}d", persistentId);
|
||||
return ANRManager::AppInfo();
|
||||
@ -173,10 +162,7 @@ void ANRManager::RemoveTimers(int32_t persistentId)
|
||||
void ANRManager::RemovePersistentId(int32_t persistentId)
|
||||
{
|
||||
WLOGFD("RemovePersistentId:%{public}d", persistentId);
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(applicationMapMutex_);
|
||||
applicationMap_.erase(persistentId);
|
||||
}
|
||||
applicationMap_.erase(persistentId);
|
||||
DelayedSingleton<EventStage>::GetInstance()->OnSessionLost(persistentId);
|
||||
}
|
||||
|
||||
|
@ -169,8 +169,8 @@ void IntentionEventManager::InputEventListener::UpdateLastMouseEvent(
|
||||
}
|
||||
}
|
||||
|
||||
bool IntentionEventManager::InputEventListener::CheckPointerEvent(
|
||||
const std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
bool IntentionEventManager::InputEventListener::UpdatePointerEvent(
|
||||
std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
{
|
||||
if (pointerEvent == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is null");
|
||||
@ -186,13 +186,23 @@ bool IntentionEventManager::InputEventListener::CheckPointerEvent(
|
||||
pointerEvent->MarkProcessed();
|
||||
return false;
|
||||
}
|
||||
auto dispatchTimes = pointerEvent->GetDispatchTimes();
|
||||
if (dispatchTimes > 0) {
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
auto pointerId = pointerEvent->GetPointerId();
|
||||
if (pointerEvent->GetPointerItem(pointerId, pointerItem)) {
|
||||
pointerItem.SetPointerId(pointerId + dispatchTimes * TRANSPARENT_FINGER_ID);
|
||||
pointerEvent->UpdatePointerItem(pointerId, pointerItem);
|
||||
pointerEvent->SetPointerId(pointerId + dispatchTimes * TRANSPARENT_FINGER_ID);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void IntentionEventManager::InputEventListener::OnInputEvent(
|
||||
std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
{
|
||||
if (!CheckPointerEvent(pointerEvent)) {
|
||||
if (!UpdatePointerEvent(pointerEvent)) {
|
||||
return;
|
||||
}
|
||||
LogPointInfo(pointerEvent);
|
||||
@ -204,14 +214,11 @@ void IntentionEventManager::InputEventListener::OnInputEvent(
|
||||
pointerEvent->MarkProcessed();
|
||||
return;
|
||||
}
|
||||
auto dispatchTimes = pointerEvent->GetDispatchTimes();
|
||||
if (dispatchTimes > 0) {
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
auto pointerId = pointerEvent->GetPointerId();
|
||||
if (pointerEvent->GetPointerItem(pointerId, pointerItem)) {
|
||||
pointerItem.SetPointerId(pointerId + dispatchTimes * TRANSPARENT_FINGER_ID);
|
||||
pointerEvent->UpdatePointerItem(pointerId, pointerItem);
|
||||
pointerEvent->SetPointerId(pointerId + dispatchTimes * TRANSPARENT_FINGER_ID);
|
||||
if (action == MMI::PointerEvent::POINTER_ACTION_DOWN ||
|
||||
action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) {
|
||||
if (sceneSession->GetSessionInfo().bundleName_.find("SCBGestureBack") != std::string::npos ||
|
||||
sceneSession->GetSessionInfo().bundleName_.find("SCBGestureNavBar") != std::string::npos) {
|
||||
SceneSessionManager::GetInstance().UpdateLastDownEventDeviceId(pointerEvent->GetDeviceId());
|
||||
}
|
||||
}
|
||||
if (action != MMI::PointerEvent::POINTER_ACTION_MOVE) {
|
||||
|
@ -394,6 +394,12 @@ struct StartingWindowAnimationConfig {
|
||||
float opacityEnd_ = 0;
|
||||
};
|
||||
|
||||
struct SystemUIStatusBarConfig {
|
||||
bool showInLandscapeMode_ = false;
|
||||
std::string immersiveStatusBarBgColor_ = "#4c000000";
|
||||
std::string immersiveStatusBarContentColor_ = "#ffffff";
|
||||
};
|
||||
|
||||
struct AppWindowSceneConfig {
|
||||
float floatCornerRadius_ = 0.0f;
|
||||
|
||||
@ -403,6 +409,7 @@ struct AppWindowSceneConfig {
|
||||
KeyboardSceneAnimationConfig keyboardAnimationOut_;
|
||||
WindowAnimationConfig windowAnimation_;
|
||||
StartingWindowAnimationConfig startingWindowAnimationConfig_;
|
||||
SystemUIStatusBarConfig systemUIStatusBarConfig_;
|
||||
};
|
||||
|
||||
struct DeviceScreenConfig {
|
||||
|
@ -24,6 +24,7 @@ ohos_shared_library("libwsutils") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [ "src/scene_board_judgement.cpp" ]
|
||||
|
@ -24,6 +24,7 @@ ohos_shared_library("scenesessionmanager_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -57,6 +58,7 @@ ohos_shared_library("scenesessionmanager_napi") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
|
@ -213,6 +213,7 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptr<SessionIn
|
||||
{
|
||||
auto iter = jsCbMap_.find(PENDING_SCENE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
WLOGFE("[NAPI]PendingSessionActivationInner find callback failed.");
|
||||
return;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
@ -250,7 +251,7 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info)
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "sceneSession is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (info.want != nullptr) {
|
||||
bool isNeedBackToOther = info.want->GetBoolParam(AAFwk::Want::PARAM_BACK_TO_OTHER_MISSION_STACK, false);
|
||||
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]session: %{public}d isNeedBackToOther: %{public}d",
|
||||
|
@ -49,14 +49,14 @@ const std::string SYSTEMBAR_PROPERTY_CHANGE_CB = "systemBarPropertyChange";
|
||||
const std::string NEED_AVOID_CB = "needAvoid";
|
||||
const std::string PENDING_SESSION_TO_FOREGROUND_CB = "pendingSessionToForeground";
|
||||
const std::string PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB = "pendingSessionToBackgroundForDelegator";
|
||||
const std::string NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB = "needDefaultAnimationFlagChange";
|
||||
const std::string CUSTOM_ANIMATION_PLAYING_CB = "isCustomAnimationPlaying";
|
||||
const std::string NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB = "needDefaultAnimationFlagChange";
|
||||
const std::string SHOW_WHEN_LOCKED_CB = "sessionShowWhenLockedChange";
|
||||
const std::string REQUESTED_ORIENTATION_CHANGE_CB = "sessionRequestedOrientationChange";
|
||||
const std::string RAISE_ABOVE_TARGET_CB = "raiseAboveTarget";
|
||||
const std::string FORCE_HIDE_CHANGE_CB = "sessionForceHideChange";
|
||||
const std::string TOUCH_OUTSIDE_CB = "touchOutside";
|
||||
const std::string WINDOW_DRAG_HOT_AREA_CB = "windowDragHotArea";
|
||||
const std::string TOUCH_OUTSIDE_CB = "touchOutside";
|
||||
const std::string SESSIONINFO_LOCKEDSTATE_CHANGE_CB = "sessionInfoLockedStateChange";
|
||||
const std::string PREPARE_CLOSE_PIP_SESSION = "prepareClosePiPSession";
|
||||
const std::string LANDSCAPE_MULTI_WINDOW_CB = "landscapeMultiWindow";
|
||||
@ -110,6 +110,8 @@ napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& sessio
|
||||
CreateJsValue(env, static_cast<uint32_t>(GetApiType(session->GetWindowType()))));
|
||||
napi_set_named_property(env, objValue, "isAppType", CreateJsValue(env, session->IsFloatingWindowAppType()));
|
||||
napi_set_named_property(env, objValue, "pipTemplateInfo", CreatePipTemplateInfo(env, session));
|
||||
napi_set_named_property(env, objValue, "keyboardGravity",
|
||||
CreateJsValue(env, static_cast<int32_t>(session->GetKeyboardGravity())));
|
||||
|
||||
const char* moduleName = "JsSceneSession";
|
||||
BindNativeFunction(env, objValue, "on", moduleName, JsSceneSession::RegisterCallback);
|
||||
@ -119,17 +121,19 @@ napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& sessio
|
||||
BindNativeFunction(env, objValue, "setTouchable", moduleName, JsSceneSession::SetTouchable);
|
||||
BindNativeFunction(env, objValue, "setSystemActive", moduleName, JsSceneSession::SetSystemActive);
|
||||
BindNativeFunction(env, objValue, "setPrivacyMode", moduleName, JsSceneSession::SetPrivacyMode);
|
||||
BindNativeFunction(env, objValue, "setSystemSceneOcclusionAlpha",
|
||||
moduleName, JsSceneSession::SetSystemSceneOcclusionAlpha);
|
||||
BindNativeFunction(env, objValue, "setFloatingScale", moduleName, JsSceneSession::SetFloatingScale);
|
||||
BindNativeFunction(env, objValue, "setSystemSceneOcclusionAlpha", moduleName,
|
||||
JsSceneSession::SetSystemSceneOcclusionAlpha);
|
||||
BindNativeFunction(env, objValue, "setFocusable", moduleName, JsSceneSession::SetFocusable);
|
||||
BindNativeFunction(env, objValue, "setSystemSceneBlockingFocus", moduleName,
|
||||
JsSceneSession::SetSystemSceneBlockingFocus);
|
||||
BindNativeFunction(env, objValue, "setSCBKeepKeyboard", moduleName, JsSceneSession::SetSCBKeepKeyboard);
|
||||
BindNativeFunction(env, objValue, "setOffset", moduleName, JsSceneSession::SetOffset);
|
||||
BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale);
|
||||
BindNativeFunction(env, objValue, "requestHideKeyboard", moduleName, JsSceneSession::RequestHideKeyboard);
|
||||
BindNativeFunction(env, objValue, "setSCBKeepKeyboard", moduleName, JsSceneSession::SetSCBKeepKeyboard);
|
||||
BindNativeFunction(env, objValue, "setOffset", moduleName, JsSceneSession::SetOffset);
|
||||
BindNativeFunction(env, objValue, "setPipActionEvent", moduleName, JsSceneSession::SetPipActionEvent);
|
||||
BindNativeFunction(env, objValue, "notifyDisplayStatusBarTemporarily", moduleName,
|
||||
JsSceneSession::NotifyDisplayStatusBarTemporarily);
|
||||
napi_ref jsRef = nullptr;
|
||||
napi_status status = napi_create_reference(env, objValue, 1, &jsRef);
|
||||
if (status != napi_ok) {
|
||||
@ -150,12 +154,8 @@ JsSceneSession::JsSceneSession(napi_env env, const sptr<SceneSession>& session)
|
||||
if (session != nullptr) {
|
||||
session->RegisterSessionChangeCallback(sessionchangeCallback);
|
||||
}
|
||||
sessionchangeCallback->clearCallbackFunc_ = [weak = weak_from_this()](bool needRemove, int32_t persistentId) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) {
|
||||
weakJsSceneSession->ClearCbMap(needRemove, persistentId);
|
||||
}
|
||||
};
|
||||
sessionchangeCallback->clearCallbackFunc_ = std::bind(&JsSceneSession::ClearCbMap, this,
|
||||
std::placeholders::_1, std::placeholders::_2);
|
||||
sessionchangeCallback_ = sessionchangeCallback;
|
||||
WLOGFD("RegisterSessionChangeCallback success");
|
||||
}
|
||||
@ -204,14 +204,14 @@ void JsSceneSession::InitListenerFuncs()
|
||||
{ PENDING_SESSION_TO_FOREGROUND_CB, &JsSceneSession::ProcessPendingSessionToForegroundRegister },
|
||||
{ PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB,
|
||||
&JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister },
|
||||
{ NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB, &JsSceneSession::ProcessSessionDefaultAnimationFlagChangeRegister },
|
||||
{ CUSTOM_ANIMATION_PLAYING_CB, &JsSceneSession::ProcessIsCustomAnimationPlaying },
|
||||
{ NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB, &JsSceneSession::ProcessSessionDefaultAnimationFlagChangeRegister },
|
||||
{ SHOW_WHEN_LOCKED_CB, &JsSceneSession::ProcessShowWhenLockedRegister },
|
||||
{ REQUESTED_ORIENTATION_CHANGE_CB, &JsSceneSession::ProcessRequestedOrientationChange },
|
||||
{ RAISE_ABOVE_TARGET_CB, &JsSceneSession::ProcessRaiseAboveTargetRegister },
|
||||
{ FORCE_HIDE_CHANGE_CB, &JsSceneSession::ProcessForceHideChangeRegister },
|
||||
{ TOUCH_OUTSIDE_CB, &JsSceneSession::ProcessTouchOutsideRegister },
|
||||
{ WINDOW_DRAG_HOT_AREA_CB, &JsSceneSession::ProcessWindowDragHotAreaRegister },
|
||||
{ TOUCH_OUTSIDE_CB, &JsSceneSession::ProcessTouchOutsideRegister },
|
||||
{ SESSIONINFO_LOCKEDSTATE_CHANGE_CB, &JsSceneSession::ProcessSessionInfoLockedStateChangeRegister },
|
||||
{ PREPARE_CLOSE_PIP_SESSION, &JsSceneSession::ProcessPrepareClosePiPSessionRegister},
|
||||
{ LANDSCAPE_MULTI_WINDOW_CB, &JsSceneSession::ProcessLandscapeMultiWindowRegister },
|
||||
@ -220,13 +220,25 @@ void JsSceneSession::InitListenerFuncs()
|
||||
};
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
|
||||
{
|
||||
NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) {
|
||||
this->PendingSessionActivation(info);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetPendingSessionActivationEventListener(func);
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessWindowDragHotAreaRegister()
|
||||
{
|
||||
|
||||
WLOGFI("[NAPI]ProcessWindowDragHotAreaRegister");
|
||||
NotifyWindowDragHotAreaFunc func = [weak = weak_from_this()](int32_t type, const SizeChangeReason& reason) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnWindowDragHotArea(type, reason);
|
||||
NotifyWindowDragHotAreaFunc func = [this](int32_t type, const SizeChangeReason& reason) {
|
||||
this->OnWindowDragHotArea(type, reason);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -274,7 +286,7 @@ void JsSceneSession::OnWindowDragHotArea(int32_t type, const SizeChangeReason& r
|
||||
WLOGFE("[NAPI]jsHotAreaRect is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value argv[] = {jsHotAreaType, jsHotAreaReason, jsHotAreaRect};
|
||||
napi_value argv[] = {[0] = jsHotAreaType, [1] = jsHotAreaReason, [2] = jsHotAreaRect};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnWindowDragHotArea");
|
||||
@ -282,9 +294,8 @@ void JsSceneSession::OnWindowDragHotArea(int32_t type, const SizeChangeReason& r
|
||||
|
||||
void JsSceneSession::ProcessSessionInfoLockedStateChangeRegister()
|
||||
{
|
||||
NotifySessionInfoLockedStateChangeFunc func = [weak = weak_from_this()](bool lockedState) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionInfoLockedStateChange(lockedState);
|
||||
NotifySessionInfoLockedStateChangeFunc func = [this](bool lockedState) {
|
||||
this->OnSessionInfoLockedStateChange(lockedState);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -311,11 +322,15 @@ void JsSceneSession::ProcessLandscapeMultiWindowRegister()
|
||||
void JsSceneSession::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
|
||||
{
|
||||
WLOGFI("[NAPI]SetLandScapeMultiWindow, isLandscapeMultiWindow: %{public}u", isLandscapeMultiWindow);
|
||||
auto iter = jsCbMap_.find(LANDSCAPE_MULTI_WINDOW_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(LANDSCAPE_MULTI_WINDOW_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [isLandscapeMultiWindow, jsCallBack, env = env_]() {
|
||||
if (!jsCallBack) {
|
||||
WLOGFE("[NAPI]jsCallBack is nullptr");
|
||||
@ -420,10 +435,8 @@ void JsSceneSession::ProcessSessionDefaultAnimationFlagChangeRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onWindowAnimationFlagChange_ = [weak = weak_from_this()](bool isNeedDefaultAnimationFlag) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnDefaultAnimationFlagChange(isNeedDefaultAnimationFlag);
|
||||
};
|
||||
sessionchangeCallback->onWindowAnimationFlagChange_ = std::bind(
|
||||
&JsSceneSession::OnDefaultAnimationFlagChange, this, std::placeholders::_1);
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -450,7 +463,8 @@ void JsSceneSession::OnDefaultAnimationFlagChange(bool isNeedDefaultAnimationFla
|
||||
napi_value argv[] = {jsSessionDefaultAnimationFlagObj};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnDefaultAnimationFlagChange, flag:" + std::to_string(isNeedDefaultAnimationFlag));
|
||||
std::string info = "OnDefaultAnimationFlagChange, flag:" + std::to_string(isNeedDefaultAnimationFlag);
|
||||
taskScheduler_->PostMainThreadTask(task, info);
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessChangeSessionVisibilityWithStatusBarRegister()
|
||||
@ -467,25 +481,10 @@ void JsSceneSession::ProcessChangeSessionVisibilityWithStatusBarRegister()
|
||||
WLOGFD("ProcessChangeSessionVisibilityWithStatusBarRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
|
||||
{
|
||||
NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) {
|
||||
this->PendingSessionActivation(info);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetPendingSessionActivationEventListener(func);
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionStateChangeRegister()
|
||||
{
|
||||
NotifySessionStateChangeFunc func = [weak = weak_from_this()](const SessionState& state) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionStateChange(state);
|
||||
NotifySessionStateChangeFunc func = [this](const SessionState& state) {
|
||||
this->OnSessionStateChange(state);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -498,9 +497,8 @@ void JsSceneSession::ProcessSessionStateChangeRegister()
|
||||
|
||||
void JsSceneSession::ProcessBufferAvailableChangeRegister()
|
||||
{
|
||||
NotifyBufferAvailableChangeFunc func = [weak = weak_from_this()](const bool isAvailable) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnBufferAvailableChange(isAvailable);
|
||||
NotifyBufferAvailableChangeFunc func = [this](const bool isAvailable) {
|
||||
this->OnBufferAvailableChange(isAvailable);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -513,9 +511,8 @@ void JsSceneSession::ProcessBufferAvailableChangeRegister()
|
||||
|
||||
void JsSceneSession::ProcessCreateSubSessionRegister()
|
||||
{
|
||||
NotifyCreateSubSessionFunc func = [weak = weak_from_this()](const sptr<SceneSession>& sceneSession) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnCreateSubSession(sceneSession);
|
||||
NotifyCreateSubSessionFunc func = [this](const sptr<SceneSession>& sceneSession) {
|
||||
this->OnCreateSubSession(sceneSession);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -533,18 +530,15 @@ void JsSceneSession::ProcessBindDialogTargetRegister()
|
||||
TLOGE(WmsLogTag::WMS_DIALOG, "sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onBindDialogTarget_ = [weak = weak_from_this()](const sptr<SceneSession>& sceneSession) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnBindDialogTarget(sceneSession);
|
||||
};
|
||||
sessionchangeCallback->onBindDialogTarget_ = std::bind(&JsSceneSession::OnBindDialogTarget,
|
||||
this, std::placeholders::_1);
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "ProcessBindDialogTargetRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionRectChangeRegister()
|
||||
{
|
||||
NotifySessionRectChangeFunc func = [weak = weak_from_this()](const WSRect& rect, const SizeChangeReason& reason) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionRectChange(rect, reason);
|
||||
NotifySessionRectChangeFunc func = [this](const WSRect& rect, const SizeChangeReason& reason) {
|
||||
this->OnSessionRectChange(rect, reason);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -562,22 +556,14 @@ void JsSceneSession::ProcessRaiseToTopRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onRaiseToTop_ = [weak = weak_from_this()]() {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) {
|
||||
weakJsSceneSession->OnRaiseToTop();
|
||||
}
|
||||
};
|
||||
sessionchangeCallback->onRaiseToTop_ = std::bind(&JsSceneSession::OnRaiseToTop, this);
|
||||
WLOGFD("ProcessRaiseToTopRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessRaiseToTopForPointDownRegister()
|
||||
{
|
||||
NotifyRaiseToTopForPointDownFunc func = [weak = weak_from_this()]() {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) {
|
||||
weakJsSceneSession->OnRaiseToTopForPointDown();
|
||||
}
|
||||
NotifyRaiseToTopForPointDownFunc func = [this]() {
|
||||
this->OnRaiseToTopForPointDown();
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -595,12 +581,8 @@ void JsSceneSession::ProcessRaiseAboveTargetRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onRaiseAboveTarget_ = [weak = weak_from_this()](int32_t subWindowId){
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) {
|
||||
weakJsSceneSession->OnRaiseAboveTarget(subWindowId);
|
||||
}
|
||||
};
|
||||
sessionchangeCallback->onRaiseAboveTarget_ = std::bind(&JsSceneSession::OnRaiseAboveTarget,
|
||||
this, std::placeholders::_1);
|
||||
WLOGFD("ProcessRaiseToTopRegister success");
|
||||
}
|
||||
|
||||
@ -611,19 +593,15 @@ void JsSceneSession::ProcessSessionEventRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnSessionEvent_ = [weak = weak_from_this()](uint32_t eventId) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionEvent(eventId);
|
||||
};
|
||||
sessionchangeCallback->OnSessionEvent_ = std::bind(&JsSceneSession::OnSessionEvent, this, std::placeholders::_1);
|
||||
WLOGFD("ProcessSessionEventRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessTerminateSessionRegister()
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "begin");
|
||||
NotifyTerminateSessionFunc func = [weak = weak_from_this()](const SessionInfo& info) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->TerminateSession(info);
|
||||
NotifyTerminateSessionFunc func = [this](const SessionInfo& info) {
|
||||
this->TerminateSession(info);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -637,9 +615,8 @@ void JsSceneSession::ProcessTerminateSessionRegister()
|
||||
void JsSceneSession::ProcessTerminateSessionRegisterNew()
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "begin");
|
||||
NotifyTerminateSessionFuncNew func = [weak = weak_from_this()](const SessionInfo& info, bool needStartCaller) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->TerminateSessionNew(info, needStartCaller);
|
||||
NotifyTerminateSessionFuncNew func = [this](const SessionInfo& info, bool needStartCaller) {
|
||||
this->TerminateSessionNew(info, needStartCaller);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -653,9 +630,8 @@ void JsSceneSession::ProcessTerminateSessionRegisterNew()
|
||||
void JsSceneSession::ProcessTerminateSessionRegisterTotal()
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "begin");
|
||||
NotifyTerminateSessionFuncTotal func = [weak = weak_from_this()](const SessionInfo& info, TerminateType terminateType) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->TerminateSessionTotal(info, terminateType);
|
||||
NotifyTerminateSessionFuncTotal func = [this](const SessionInfo& info, TerminateType terminateType) {
|
||||
this->TerminateSessionTotal(info, terminateType);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -669,9 +645,8 @@ void JsSceneSession::ProcessTerminateSessionRegisterTotal()
|
||||
void JsSceneSession::ProcessPendingSessionToForegroundRegister()
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "begin");
|
||||
NotifyPendingSessionToForegroundFunc func = [weak = weak_from_this()](const SessionInfo& info) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->PendingSessionToForeground(info);
|
||||
NotifyPendingSessionToForegroundFunc func = [this](const SessionInfo& info) {
|
||||
this->PendingSessionToForeground(info);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -686,9 +661,8 @@ void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "begin");
|
||||
auto weak = weak_from_this();
|
||||
NotifyPendingSessionToBackgroundForDelegatorFunc func = [weak = weak_from_this()](const SessionInfo& info) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->PendingSessionToBackgroundForDelegator(info);
|
||||
NotifyPendingSessionToBackgroundForDelegatorFunc func = [this](const SessionInfo& info) {
|
||||
this->PendingSessionToBackgroundForDelegator(info);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -699,19 +673,19 @@ void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionFocusableChangeRegister()
|
||||
void JsSceneSession::ProcessSessionExceptionRegister()
|
||||
{
|
||||
NotifySessionFocusableChangeFunc func = [weak = weak_from_this()](bool isFocusable) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionFocusableChange(isFocusable);
|
||||
WLOGFD("begin to run ProcessSessionExceptionRegister");
|
||||
NotifySessionExceptionFunc func = [this](const SessionInfo& info, bool needRemoveSession) {
|
||||
this->OnSessionException(info, needRemoveSession);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[WMSComm]session is nullptr");
|
||||
WLOGFE("session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetSessionFocusableChangeListener(func);
|
||||
TLOGD(WmsLogTag::WMS_FOCUS, "ProcessSessionFocusableChangeRegister success");
|
||||
session->SetSessionExceptionListener(func, true);
|
||||
WLOGFD("ProcessSessionExceptionRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionTopmostChangeRegister()
|
||||
@ -732,11 +706,24 @@ void JsSceneSession::ProcessSessionTopmostChangeRegister()
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "ProcessSessionTopmostChangeRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionFocusableChangeRegister()
|
||||
{
|
||||
NotifySessionFocusableChangeFunc func = [this](bool isFocusable) {
|
||||
this->OnSessionFocusableChange(isFocusable);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[WMSComm]session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetSessionFocusableChangeListener(func);
|
||||
TLOGD(WmsLogTag::WMS_FOCUS, "ProcessSessionFocusableChangeRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionTouchableChangeRegister()
|
||||
{
|
||||
NotifySessionTouchableChangeFunc func = [weak = weak_from_this()](bool touchable) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionTouchableChange(touchable);
|
||||
NotifySessionTouchableChangeFunc func = [this](bool touchable) {
|
||||
this->OnSessionTouchableChange(touchable);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -747,27 +734,10 @@ void JsSceneSession::ProcessSessionTouchableChangeRegister()
|
||||
WLOGFD("ProcessSessionTouchableChangeRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionExceptionRegister()
|
||||
{
|
||||
WLOGFD("begin to run ProcessSessionExceptionRegister");
|
||||
NotifySessionExceptionFunc func = [weak = weak_from_this()](const SessionInfo& info, bool needRemoveSession) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSessionException(info, needRemoveSession);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetSessionExceptionListener(func, true);
|
||||
WLOGFD("ProcessSessionExceptionRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessClickRegister()
|
||||
{
|
||||
NotifyClickFunc func = [weak = weak_from_this()]() {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnClick();
|
||||
NotifyClickFunc func = [this]() {
|
||||
this->OnClick();
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -815,9 +785,8 @@ void JsSceneSession::OnSessionEvent(uint32_t eventId)
|
||||
|
||||
void JsSceneSession::ProcessBackPressedRegister()
|
||||
{
|
||||
NotifyBackPressedFunc func = [weak = weak_from_this()](bool needMoveToBackground) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnBackPressed(needMoveToBackground);
|
||||
NotifyBackPressedFunc func = [this](bool needMoveToBackground) {
|
||||
this->OnBackPressed(needMoveToBackground);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -834,11 +803,8 @@ void JsSceneSession::ProcessSystemBarPropertyChangeRegister()
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnSystemBarPropertyChange_ = [weak = weak_from_this()]
|
||||
(const std::unordered_map<WindowType, SystemBarProperty>& propertyMap) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnSystemBarPropertyChange(propertyMap);
|
||||
};
|
||||
sessionchangeCallback->OnSystemBarPropertyChange_ = std::bind(
|
||||
&JsSceneSession::OnSystemBarPropertyChange, this, std::placeholders::_1);
|
||||
TLOGD(WmsLogTag::WMS_IMMS, "ProcessSystemBarPropertyChangeRegister success");
|
||||
}
|
||||
|
||||
@ -849,10 +815,8 @@ void JsSceneSession::ProcessNeedAvoidRegister()
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnNeedAvoid_ = [weak = weak_from_this()](bool status) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnNeedAvoid(status);
|
||||
};
|
||||
sessionchangeCallback->OnNeedAvoid_ = std::bind(
|
||||
&JsSceneSession::OnNeedAvoid, this, std::placeholders::_1);
|
||||
TLOGD(WmsLogTag::WMS_IMMS, "ProcessNeedAvoidRegister success");
|
||||
}
|
||||
|
||||
@ -863,10 +827,8 @@ void JsSceneSession::ProcessIsCustomAnimationPlaying()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onIsCustomAnimationPlaying_ = [weak = weak_from_this()](bool status) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnIsCustomAnimationPlaying(status);
|
||||
};
|
||||
sessionchangeCallback->onIsCustomAnimationPlaying_ = std::bind(
|
||||
&JsSceneSession::OnIsCustomAnimationPlaying, this, std::placeholders::_1);
|
||||
WLOGFD("ProcessIsCustomAnimationPlaying success");
|
||||
}
|
||||
|
||||
@ -877,10 +839,8 @@ void JsSceneSession::ProcessShowWhenLockedRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnShowWhenLocked_ = [weak = weak_from_this()](bool showWhenLocked) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnShowWhenLocked(showWhenLocked);
|
||||
};
|
||||
sessionchangeCallback->OnShowWhenLocked_ = std::bind(
|
||||
&JsSceneSession::OnShowWhenLocked, this, std::placeholders::_1);
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -897,10 +857,8 @@ void JsSceneSession::ProcessRequestedOrientationChange()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnRequestedOrientationChange_ = [weak = weak_from_this()](uint32_t orientation) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnReuqestedOrientationChange(orientation);
|
||||
};
|
||||
sessionchangeCallback->OnRequestedOrientationChange_ = std::bind(
|
||||
&JsSceneSession::OnReuqestedOrientationChange, this, std::placeholders::_1);
|
||||
WLOGFD("ProcessRequestedOrientationChange success");
|
||||
}
|
||||
|
||||
@ -911,10 +869,8 @@ void JsSceneSession::ProcessForceHideChangeRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnForceHideChange_ = [weak = weak_from_this()](bool hide) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnForceHideChange(hide);
|
||||
};
|
||||
sessionchangeCallback->OnForceHideChange_ = std::bind(&JsSceneSession::OnForceHideChange,
|
||||
this, std::placeholders::_1);
|
||||
WLOGFD("ProcessForceHideChangeRegister success");
|
||||
}
|
||||
|
||||
@ -949,10 +905,7 @@ void JsSceneSession::ProcessTouchOutsideRegister()
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnTouchOutside_ = [weak = weak_from_this()]() {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnTouchOutside();
|
||||
};
|
||||
sessionchangeCallback->OnTouchOutside_ = std::bind(&JsSceneSession::OnTouchOutside, this);
|
||||
WLOGFD("ProcessTouchOutsideRegister success");
|
||||
}
|
||||
|
||||
@ -1074,7 +1027,8 @@ napi_value JsSceneSession::SetSCBKeepKeyboard(napi_env env, napi_callback_info i
|
||||
return (me != nullptr) ? me->OnSetSCBKeepKeyboard(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::SetOffset(napi_env env, napi_callback_info info) {
|
||||
napi_value JsSceneSession::SetOffset(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]SetOffset");
|
||||
JsSceneSession *me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||
return (me != nullptr) ? me->OnSetOffset(env, info) : nullptr;
|
||||
@ -1087,6 +1041,12 @@ napi_value JsSceneSession::SetPipActionEvent(napi_env env, napi_callback_info in
|
||||
return (me != nullptr) ? me->OnSetPipActionEvent(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::NotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsSceneSession *me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||
return (me != nullptr) ? me->OnNotifyDisplayStatusBarTemporarily(env, info) : nullptr;
|
||||
}
|
||||
|
||||
bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
@ -1231,7 +1191,7 @@ napi_value JsSceneSession::OnSetPrivacyMode(napi_env env, napi_callback_info inf
|
||||
|
||||
napi_value JsSceneSession::OnSetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 0;
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 1) { // 1: params num
|
||||
@ -1240,7 +1200,6 @@ napi_value JsSceneSession::OnSetSystemSceneOcclusionAlpha(napi_env env, napi_cal
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
double alpha = 0.f;
|
||||
if (!ConvertFromJsValue(env, argv[0], alpha)) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to bool");
|
||||
@ -1387,7 +1346,8 @@ void JsSceneSession::OnCreateSubSession(const sptr<SceneSession>& sceneSession)
|
||||
napi_value argv[] = {jsSceneSessionObj};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnCreateSpecificSession PID:" + std::to_string(sceneSession->GetPersistentId()));
|
||||
std::string info = "OnCreateSpecificSession PID:" + std::to_string(sceneSession->GetPersistentId());
|
||||
taskScheduler_->PostMainThreadTask(task, info);
|
||||
}
|
||||
|
||||
void JsSceneSession::OnBindDialogTarget(const sptr<SceneSession>& sceneSession)
|
||||
@ -1487,7 +1447,7 @@ void JsSceneSession::OnBufferAvailableChange(const bool isBufferAvailable)
|
||||
|
||||
void JsSceneSession::OnSessionRectChange(const WSRect& rect, const SizeChangeReason& reason)
|
||||
{
|
||||
if (rect.IsEmpty()) {
|
||||
if (reason != SizeChangeReason::MOVE && rect.IsEmpty()) {
|
||||
WLOGFD("Rect is empty, there is no need to notify");
|
||||
return;
|
||||
}
|
||||
@ -1584,7 +1544,7 @@ void JsSceneSession::OnRaiseAboveTarget(int32_t subWindowId)
|
||||
WLOGFE("[NAPI]jsSceneSessionObj is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value argv[] = {CreateJsError(env, 0), jsSceneSessionObj};
|
||||
napi_value argv[] = {[0] = CreateJsError(env, 0), [1] = jsSceneSessionObj};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnRaiseAboveTarget: " + std::to_string(subWindowId));
|
||||
@ -1993,9 +1953,8 @@ void JsSceneSession::UpdateSessionLabel(const std::string &label)
|
||||
void JsSceneSession::ProcessUpdateSessionLabelRegister()
|
||||
{
|
||||
WLOGFD("begin to run ProcessUpdateSessionLabelRegister");
|
||||
NofitySessionLabelUpdatedFunc func = [weak = weak_from_this()](const std::string& label) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->UpdateSessionLabel(label);
|
||||
NofitySessionLabelUpdatedFunc func = [this](const std::string& label) {
|
||||
this->UpdateSessionLabel(label);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -2009,9 +1968,8 @@ void JsSceneSession::ProcessUpdateSessionLabelRegister()
|
||||
void JsSceneSession::ProcessUpdateSessionIconRegister()
|
||||
{
|
||||
WLOGFD("begin to run ProcessUpdateSessionIconRegister");
|
||||
NofitySessionIconUpdatedFunc func = [weak = weak_from_this()](const std::string& iconPath) {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->UpdateSessionIcon(iconPath);
|
||||
NofitySessionIconUpdatedFunc func = [this](const std::string& iconPath) {
|
||||
this->UpdateSessionIcon(iconPath);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
@ -2079,7 +2037,7 @@ void JsSceneSession::OnSessionException(const SessionInfo& info, bool needRemove
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value argv[] = {jsSessionInfo, jsNeedRemoveSession};
|
||||
napi_value argv[] = {[0] = jsSessionInfo, [1] = jsNeedRemoveSession};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnSessionException, name" + info.bundleName_);
|
||||
@ -2282,35 +2240,6 @@ napi_value JsSceneSession::OnSetShowRecent(napi_env env, napi_callback_info info
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetSystemActive(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 1) {
|
||||
WLOGFE("[NAPI]argc is invalid : %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
bool scbSystemActive = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], scbSystemActive)){
|
||||
WLOGFE("[NAPI] Failed to convert parameter to bool");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[NAPI] session_ is null");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY),
|
||||
"session is null"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
session->SetSystemActive(scbSystemActive);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetZOrder(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
@ -2369,38 +2298,6 @@ napi_value JsSceneSession::OnSetFloatingScale(napi_env env, napi_callback_info i
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetTouchable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != 1) {
|
||||
WLOGFE("[NAPI] Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input Parameter is missing or invalid" ));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
bool touchable = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], touchable)) {
|
||||
WLOGFE("[NAPI] Failed to convert parameter to touchable");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid" ));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[NAPI] Session is null");
|
||||
napi_throw(env, CreateJsError(env,
|
||||
static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "session is null"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
session->SetSystemTouchable(touchable);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetSCBKeepKeyboard(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
@ -2476,10 +2373,7 @@ void JsSceneSession::ProcessPrepareClosePiPSessionRegister()
|
||||
TLOGE(WmsLogTag::WMS_PIP, "sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onPrepareClosePiPSession_ = [weak = weak_from_this()]() {
|
||||
auto weakJsSceneSession = weak.lock();
|
||||
if (weakJsSceneSession) weakJsSceneSession->OnPrepareClosePiPSession();
|
||||
};
|
||||
sessionchangeCallback->onPrepareClosePiPSession_ = std::bind(&JsSceneSession::OnPrepareClosePiPSession, this);
|
||||
TLOGD(WmsLogTag::WMS_PIP, "ProcessPrepareClosePiPSessionRegister success");
|
||||
}
|
||||
|
||||
@ -2506,6 +2400,67 @@ void JsSceneSession::OnPrepareClosePiPSession()
|
||||
taskScheduler_->PostMainThreadTask(task, "OnPrepareClosePiPSession");
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetSystemActive(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 1) {
|
||||
WLOGFE("[NAPI]argc is invalid : %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
bool scbSystemActive = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], scbSystemActive)){
|
||||
WLOGFE("[NAPI] Failed to convert parameter to bool");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[NAPI] session_ is null");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY),
|
||||
"session is null"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
session->SetSystemActive(scbSystemActive);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetTouchable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != 1) {
|
||||
WLOGFE("[NAPI] Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input Parameter is missing or invalid" ));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
bool touchable = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], touchable)) {
|
||||
WLOGFE("[NAPI] Failed to convert parameter to touchable");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid" ));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("[NAPI] Session is null");
|
||||
napi_throw(env, CreateJsError(env,
|
||||
static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "session is null"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
session->SetSystemTouchable(touchable);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::SetScale(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]SetScale");
|
||||
@ -2593,14 +2548,14 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info
|
||||
if (argc < 1) {
|
||||
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
std::string action;
|
||||
if (!ConvertFromJsValue(env, argv[0], action)) {
|
||||
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to string");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t status = -1;
|
||||
@ -2608,7 +2563,7 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info
|
||||
if (!ConvertFromJsValue(env, argv[1], status)) {
|
||||
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to int");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
}
|
||||
@ -2622,6 +2577,31 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnNotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]session is nullptr");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
bool isTempDisplay = false;
|
||||
if (argc == ARGC_ONE && GetType(env, argv[0]) == napi_boolean) {
|
||||
if (!ConvertFromJsValue(env, argv[0], isTempDisplay)) {
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]failed to convert parameter to bool");
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
}
|
||||
session->SetIsDisplayStatusBarTemporarily(isTempDisplay);
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "Set success with id:%{public}u name:%{public}s isTempDisplay:%{public}u",
|
||||
session->GetPersistentId(), session->GetWindowName().c_str(), isTempDisplay);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
sptr<SceneSession> JsSceneSession::GetNativeSession() const
|
||||
{
|
||||
return weakSession_.promote();
|
||||
|
@ -54,11 +54,12 @@ private:
|
||||
static napi_value SetFocusable(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemSceneBlockingFocus(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateSizeChangeReason(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value SetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value SetScale(napi_env env, napi_callback_info info);
|
||||
static napi_value RequestHideKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value SetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value SetPipActionEvent(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateNativeVisibility(napi_env env, napi_callback_info info);
|
||||
@ -72,11 +73,12 @@ private:
|
||||
napi_value OnSetFocusable(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetSystemSceneBlockingFocus(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateSizeChangeReason(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetOffset(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetScale(napi_env env, napi_callback_info info);
|
||||
napi_value OnRequestHideKeyboard(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetOffset(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetPipActionEvent(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info);
|
||||
|
||||
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
|
||||
void ProcessChangeSessionVisibilityWithStatusBarRegister();
|
||||
@ -113,8 +115,8 @@ private:
|
||||
void ProcessRequestedOrientationChange();
|
||||
void ProcessRaiseAboveTargetRegister();
|
||||
void ProcessForceHideChangeRegister();
|
||||
void ProcessTouchOutsideRegister();
|
||||
void ProcessWindowDragHotAreaRegister();
|
||||
void ProcessTouchOutsideRegister();
|
||||
void ProcessSessionInfoLockedStateChangeRegister();
|
||||
void ProcessPrepareClosePiPSessionRegister();
|
||||
void ProcessLandscapeMultiWindowRegister();
|
||||
@ -154,8 +156,8 @@ private:
|
||||
void OnShowWhenLocked(bool showWhenLocked);
|
||||
void OnReuqestedOrientationChange(uint32_t orientation);
|
||||
void OnForceHideChange(bool hide);
|
||||
void OnTouchOutside();
|
||||
void OnWindowDragHotArea(int32_t type, const SizeChangeReason& reason);
|
||||
void OnTouchOutside();
|
||||
void OnSessionInfoLockedStateChange(bool lockedState);
|
||||
void OnPrepareClosePiPSession();
|
||||
void OnContextTransparent();
|
||||
|
@ -45,7 +45,6 @@ namespace OHOS::Rosen {
|
||||
using namespace AbilityRuntime;
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsSceneSessionManager" };
|
||||
constexpr int WAIT_FOR_SECONDS = 2;
|
||||
constexpr int MIN_ARG_COUNT = 3;
|
||||
constexpr int ARG_INDEX_1 = 1;
|
||||
constexpr int ARG_INDEX_TWO = 2;
|
||||
@ -53,6 +52,7 @@ constexpr int ARG_INDEX_3 = 3;
|
||||
constexpr int32_t RESTYPE_RECLAIM = 100001;
|
||||
const std::string RES_PARAM_RECLAIM_TAG = "reclaimTag";
|
||||
const std::string CREATE_SYSTEM_SESSION_CB = "createSpecificSession";
|
||||
const std::string CREATE_KEYBOARD_SESSION_CB = "createKeyboardSession";
|
||||
const std::string RECOVER_SCENE_SESSION_CB = "recoverSceneSession";
|
||||
const std::string STATUS_BAR_ENABLED_CHANGE_CB = "statusBarEnabledChange";
|
||||
const std::string GESTURE_NAVIGATION_ENABLED_CHANGE_CB = "gestureNavigationEnabledChange";
|
||||
@ -122,13 +122,14 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
||||
BindNativeFunction(env, exportObj, "getRootSceneUIContext", moduleName,
|
||||
JsSceneSessionManager::GetRootSceneUIContext);
|
||||
BindNativeFunction(env, exportObj, "sendTouchEvent", moduleName, JsSceneSessionManager::SendTouchEvent);
|
||||
BindNativeFunction(env, exportObj, "addWindowDragHotArea", moduleName, JsSceneSessionManager::AddWindowDragHotArea);
|
||||
BindNativeFunction(env, exportObj, "preloadInLakeApp", moduleName, JsSceneSessionManager::PreloadInLakeApp);
|
||||
BindNativeFunction(env, exportObj, "requestFocusStatus", moduleName, JsSceneSessionManager::RequestFocusStatus);
|
||||
BindNativeFunction(env, exportObj, "requestAllAppSessionUnfocus", moduleName,
|
||||
JsSceneSessionManager::RequestAllAppSessionUnfocus);
|
||||
BindNativeFunction(env, exportObj, "preloadInLakeApp", moduleName, JsSceneSessionManager::PreloadInLakeApp);
|
||||
BindNativeFunction(env, exportObj, "addWindowDragHotArea", moduleName, JsSceneSessionManager::AddWindowDragHotArea);
|
||||
BindNativeFunction(env, exportObj, "setScreenLocked", moduleName, JsSceneSessionManager::SetScreenLocked);
|
||||
BindNativeFunction(env, exportObj, "updateMaximizeMode", moduleName, JsSceneSessionManager::UpdateMaximizeMode);
|
||||
BindNativeFunction(env, exportObj, "reportData", moduleName, JsSceneSessionManager::ReportData);
|
||||
BindNativeFunction(env, exportObj, "updateSessionDisplayId", moduleName,
|
||||
JsSceneSessionManager::UpdateSessionDisplayId);
|
||||
BindNativeFunction(env, exportObj, "updateConfig", moduleName,
|
||||
@ -138,7 +139,6 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
||||
BindNativeFunction(env, exportObj, "notifyAINavigationBarShowStatus", moduleName,
|
||||
JsSceneSessionManager::NotifyAINavigationBarShowStatus);
|
||||
BindNativeFunction(env, exportObj, "updateTitleInTargetPos", moduleName, JsSceneSessionManager::UpdateTitleInTargetPos);
|
||||
BindNativeFunction(env, exportObj, "reportData", moduleName, JsSceneSessionManager::ReportData);
|
||||
BindNativeFunction(env, exportObj, "setSystemAnimatedScenes", moduleName,
|
||||
JsSceneSessionManager::SetSystemAnimatedScenes);
|
||||
BindNativeFunction(env, exportObj, "getSessionSnapshotPixelMap", moduleName,
|
||||
@ -149,6 +149,7 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
||||
JsSceneSessionManager::SwitchFreeMultiWindow);
|
||||
BindNativeFunction(env, exportObj, "getFreeMultiWindowConfig", moduleName,
|
||||
JsSceneSessionManager::GetFreeMultiWindowConfig);
|
||||
BindNativeFunction(env, exportObj, "getCustomDecorHeight", moduleName, JsSceneSessionManager::GetCustomDecorHeight);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
@ -156,14 +157,15 @@ JsSceneSessionManager::JsSceneSessionManager(napi_env env) : env_(env)
|
||||
{
|
||||
listenerFunc_ = {
|
||||
{ CREATE_SYSTEM_SESSION_CB, &JsSceneSessionManager::ProcessCreateSystemSessionRegister },
|
||||
{ RECOVER_SCENE_SESSION_CB, &JsSceneSessionManager::ProcessRecoverSceneSessionRegister },
|
||||
{ CREATE_KEYBOARD_SESSION_CB, &JsSceneSessionManager::ProcessCreateKeyboardSessionRegister },
|
||||
{ RECOVER_SCENE_SESSION_CB, &JsSceneSessionManager::ProcessRecoverSceneSessionRegister },
|
||||
{ STATUS_BAR_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessStatusBarEnabledChangeListener},
|
||||
{ OUTSIDE_DOWN_EVENT_CB, &JsSceneSessionManager::ProcessOutsideDownEvent },
|
||||
{ SHIFT_FOCUS_CB, &JsSceneSessionManager::ProcessShiftFocus },
|
||||
{ CALLING_WINDOW_ID_CHANGE_CB, &JsSceneSessionManager::ProcessCallingSessionIdChangeRegister},
|
||||
{ START_UI_ABILITY_ERROR, &JsSceneSessionManager::ProcessStartUIAbilityErrorRegister},
|
||||
{ GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
||||
&JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener },
|
||||
{ CALLING_WINDOW_ID_CHANGE_CB, &JsSceneSessionManager::ProcessCallingSessionIdChangeRegister},
|
||||
};
|
||||
taskScheduler_ = std::make_shared<MainThreadScheduler>(env);
|
||||
}
|
||||
@ -174,14 +176,17 @@ void JsSceneSessionManager::OnCreateSystemSession(const sptr<SceneSession>& scen
|
||||
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]sceneSession is nullptr");
|
||||
return;
|
||||
}
|
||||
auto iter = jsCbMap_.find(CREATE_SYSTEM_SESSION_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Can't find callback, id: %{public}d", sceneSession->GetPersistentId());
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(CREATE_SYSTEM_SESSION_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Can't find callback, id: %{public}d", sceneSession->GetPersistentId());
|
||||
return;
|
||||
}
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]OnCreateSystemSession, id: %{public}d", sceneSession->GetPersistentId());
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]OnCreateSystemSession, id: %{public}d", sceneSession->GetPersistentId());
|
||||
auto jsCallBack = iter->second;
|
||||
wptr<SceneSession> weakSession(sceneSession);
|
||||
auto task = [this, weakSession, jsCallBack, env = env_]() {
|
||||
auto specificSession = weakSession.promote();
|
||||
@ -200,6 +205,51 @@ void JsSceneSessionManager::OnCreateSystemSession(const sptr<SceneSession>& scen
|
||||
taskScheduler_->PostMainThreadTask(task, "OnCreateSystemSession");
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::OnCreateKeyboardSession(const sptr<SceneSession>& keyboardSession,
|
||||
const sptr<SceneSession>& panelSession)
|
||||
{
|
||||
if (keyboardSession == nullptr || panelSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboard or panel session is nullptr");
|
||||
return;
|
||||
}
|
||||
auto iter = jsCbMap_.find(CREATE_KEYBOARD_SESSION_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]Can't find callback, id: %{public}d", keyboardSession->GetPersistentId());
|
||||
return;
|
||||
}
|
||||
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboardId: %{public}d, panelId: %{public}d",
|
||||
keyboardSession->GetPersistentId(), panelSession->GetPersistentId());
|
||||
auto jsCallBack = iter->second;
|
||||
wptr<SceneSession> weakKeyboardSession(keyboardSession);
|
||||
wptr<SceneSession> weakPanelSession(panelSession);
|
||||
auto task = [this, weakKeyboardSession, weakPanelSession, jsCallBack, env = env_]() {
|
||||
if (!jsCallBack) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]jsCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
auto keyboardSession = weakKeyboardSession.promote();
|
||||
auto panelSession = weakPanelSession.promote();
|
||||
if (keyboardSession == nullptr || panelSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboard or panel session is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value keyboardSessionObj = JsSceneSession::Create(env, keyboardSession);
|
||||
if (keyboardSessionObj == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboardSessionObj is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value panelSessionObj = JsSceneSession::Create(env, panelSession);
|
||||
if (panelSessionObj == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]panelSessionObj is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value argv[] = { keyboardSessionObj, panelSessionObj };
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
taskScheduler_->PostMainThreadTask(task, "OnCreateKeyboardSession");
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::OnRecoverSceneSession(const sptr<SceneSession>& sceneSession, const SessionInfo& info)
|
||||
{
|
||||
if (sceneSession == nullptr) {
|
||||
@ -252,12 +302,15 @@ void JsSceneSessionManager::OnRecoverSceneSession(const sptr<SceneSession>& scen
|
||||
void JsSceneSessionManager::OnStatusBarEnabledUpdate(bool enable)
|
||||
{
|
||||
WLOGFI("[NAPI]OnStatusBarEnabledUpdate");
|
||||
auto iter = jsCbMap_.find(STATUS_BAR_ENABLED_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(STATUS_BAR_ENABLED_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, enable, jsCallBack, env = env_]() {
|
||||
napi_value argv[] = {CreateJsValue(env, enable)};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
@ -268,12 +321,15 @@ void JsSceneSessionManager::OnStatusBarEnabledUpdate(bool enable)
|
||||
void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable)
|
||||
{
|
||||
WLOGFI("[NAPI]OnGestureNavigationEnabledUpdate");
|
||||
auto iter = jsCbMap_.find(GESTURE_NAVIGATION_ENABLED_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(GESTURE_NAVIGATION_ENABLED_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, enable, jsCallBack, env = env_]() {
|
||||
napi_value argv[] = {CreateJsValue(env, enable)};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
@ -284,11 +340,15 @@ void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable)
|
||||
void JsSceneSessionManager::OnStartUIAbilityError(const uint32_t errorCode)
|
||||
{
|
||||
WLOGFI("[NAPI]OnStartUIAbilityError");
|
||||
auto iter = jsCbMap_.find(START_UI_ABILITY_ERROR);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(START_UI_ABILITY_ERROR);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, errorCode, jsCallBack, env = env_]() {
|
||||
napi_value argv[] = {CreateJsValue(env, errorCode)};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
@ -299,12 +359,15 @@ void JsSceneSessionManager::OnStartUIAbilityError(const uint32_t errorCode)
|
||||
void JsSceneSessionManager::OnOutsideDownEvent(int32_t x, int32_t y)
|
||||
{
|
||||
WLOGFD("[NAPI]OnOutsideDownEvent");
|
||||
auto iter = jsCbMap_.find(OUTSIDE_DOWN_EVENT_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(OUTSIDE_DOWN_EVENT_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, x, y, jsCallBack, env = env_]() {
|
||||
napi_value objValue = nullptr;
|
||||
napi_create_object(env, &objValue);
|
||||
@ -325,12 +388,15 @@ void JsSceneSessionManager::OnOutsideDownEvent(int32_t x, int32_t y)
|
||||
void JsSceneSessionManager::OnShiftFocus(int32_t persistentId)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]OnShiftFocus");
|
||||
auto iter = jsCbMap_.find(SHIFT_FOCUS_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(SHIFT_FOCUS_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, persistentId, jsCallBack, env = env_]() {
|
||||
napi_value argv[] = {CreateJsValue(env, persistentId)};
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
@ -341,11 +407,15 @@ void JsSceneSessionManager::OnShiftFocus(int32_t persistentId)
|
||||
void JsSceneSessionManager::OnCallingSessionIdChange(uint32_t windowId)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_KEYBOARD, "[NAPI]OnCallingSessionIdChange");
|
||||
auto iter = jsCbMap_.find(CALLING_WINDOW_ID_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
std::shared_ptr<NativeReference> jsCallBack = nullptr;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
auto iter = jsCbMap_.find(CALLING_WINDOW_ID_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
jsCallBack = iter->second;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto task = [this, windowId, jsCallBack, env = env_]() {
|
||||
napi_value argv[] = { CreateJsValue(env, windowId) };
|
||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||
@ -362,6 +432,15 @@ void JsSceneSessionManager::ProcessCreateSystemSessionRegister()
|
||||
SceneSessionManager::GetInstance().SetCreateSystemSessionListener(func);
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::ProcessCreateKeyboardSessionRegister()
|
||||
{
|
||||
NotifyCreateKeyboardSessionFunc func = [this](const sptr<SceneSession>& keyboardSession,
|
||||
const sptr<SceneSession>& panelSession) {
|
||||
this->OnCreateKeyboardSession(keyboardSession, panelSession);
|
||||
};
|
||||
SceneSessionManager::GetInstance().SetCreateKeyboardSessionListener(func);
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::ProcessStartUIAbilityErrorRegister()
|
||||
{
|
||||
ProcessStartUIAbilityErrorFunc func = [this](uint32_t startUIAbilityError) {
|
||||
@ -647,6 +726,13 @@ napi_value JsSceneSessionManager::SendTouchEvent(napi_env env, napi_callback_inf
|
||||
return (me != nullptr) ? me->OnSendTouchEvent(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::PreloadInLakeApp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]PreloadInLakeApp");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnPreloadInLakeApp(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::RequestFocusStatus(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_FOCUS, "RequestFocusStatus");
|
||||
@ -668,13 +754,6 @@ napi_value JsSceneSessionManager::SetScreenLocked(napi_env env, napi_callback_in
|
||||
return (me != nullptr) ? me->OnSetScreenLocked(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::PreloadInLakeApp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]PreloadInLakeApp");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnPreloadInLakeApp(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::UpdateMaximizeMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]UpdateMaximizeMode");
|
||||
@ -682,6 +761,13 @@ napi_value JsSceneSessionManager::UpdateMaximizeMode(napi_env env, napi_callback
|
||||
return (me != nullptr) ? me->OnUpdateMaximizeMode(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::ReportData(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]ReportData");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnReportData(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::UpdateSessionDisplayId(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]UpdateSessionDisplayId");
|
||||
@ -717,13 +803,6 @@ napi_value JsSceneSessionManager::UpdateTitleInTargetPos(napi_env env, napi_call
|
||||
return (me != nullptr) ? me->OnUpdateTitleInTargetPos(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::ReportData(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]ReportData");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnReportData(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::GetSessionSnapshotPixelMap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("[NAPI]GetSessionSnapshotPixelMap");
|
||||
@ -754,6 +833,7 @@ napi_value JsSceneSessionManager::GetFreeMultiWindowConfig(napi_env env, napi_ca
|
||||
|
||||
bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(jsCbMapMutex_);
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
return false;
|
||||
}
|
||||
@ -984,21 +1064,21 @@ napi_value JsSceneSessionManager::OnSwitchUser(napi_env env, napi_callback_info
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t oldUserId;
|
||||
if (!ConvertFromJsValue(env, argv[0], oldUserId)) {
|
||||
if (!ConvertFromJsValue(env, argv[0], oldUserId)) { // 0: params num
|
||||
WLOGFE("[NAPI]Failed to convert parameter to oldUserId");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t newUserId;
|
||||
if (!ConvertFromJsValue(env, argv[1], newUserId)) {
|
||||
if (!ConvertFromJsValue(env, argv[1], newUserId)) { // 1: params num
|
||||
WLOGFE("[NAPI]Failed to convert parameter to newUserId");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
std::string fileDir;
|
||||
if (!ConvertFromJsValue(env, argv[ARGC_TWO], fileDir)) {
|
||||
if (!ConvertFromJsValue(env, argv[2], fileDir)) { // 2: params num
|
||||
WLOGFE("[NAPI]Failed to convert parameter to fileDir");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
@ -1017,12 +1097,12 @@ void JsSceneSessionManager::RegisterDumpRootSceneElementInfoListener()
|
||||
{
|
||||
DumpRootSceneElementInfoFunc func = [this](const std::vector<std::string>& params,
|
||||
std::vector<std::string>& infos) {
|
||||
if (params.size() == 1 && params[0] == ARG_DUMP_HELP) {
|
||||
if (params.size() == 1 && params[0] == ARG_DUMP_HELP) { // 1 params num
|
||||
Ace::UIContent::ShowDumpHelp(infos);
|
||||
WLOGFD("Dump arkUI help info");
|
||||
WLOGFD("Dump ArkUI help info");
|
||||
} else if (RootScene::staticRootScene_->GetUIContent()) {
|
||||
RootScene::staticRootScene_->GetUIContent()->DumpInfo(params, infos);
|
||||
WLOGFD("Dump arkUI element info");
|
||||
WLOGFD("Dump ArkUI element info");
|
||||
}
|
||||
};
|
||||
SceneSessionManager::GetInstance().SetDumpRootSceneElementInfoListener(func);
|
||||
@ -1206,14 +1286,8 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env,
|
||||
bool isNewActive = true;
|
||||
ConvertFromJsValue(env, argv[1], isNewActive);
|
||||
|
||||
int32_t errCode = static_cast<int32_t>(WSErrorCode::WS_ERROR_TIMEOUT);
|
||||
auto future = SceneSessionManager::GetInstance().RequestSceneSessionActivation(sceneSession, isNewActive);
|
||||
if (future.wait_for(std::chrono::seconds(WAIT_FOR_SECONDS)) == std::future_status::ready) {
|
||||
errCode = future.get();
|
||||
}
|
||||
napi_value number = nullptr;
|
||||
napi_create_int32(env, errCode, &number);
|
||||
return number;
|
||||
SceneSessionManager::GetInstance().RequestSceneSessionActivation(sceneSession, isNewActive);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, napi_callback_info info)
|
||||
@ -1409,9 +1483,11 @@ napi_value JsSceneSessionManager::OnIsSceneSessionValid(napi_env env, napi_callb
|
||||
return result;
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::SetIsClearSession(napi_env env, napi_value jsSceneSessionObj, sptr<SceneSession>& sceneSession)
|
||||
void JsSceneSessionManager::SetIsClearSession(napi_env env, napi_value jsSceneSessionObj,
|
||||
sptr<SceneSession>& sceneSession)
|
||||
{
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("[NAPI]SetIsClearSession: sceneSession is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value jsOperatorType = nullptr;
|
||||
@ -1716,7 +1792,7 @@ napi_value JsSceneSessionManager::OnPerfRequestEx(napi_env env, napi_callback_in
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 2) {
|
||||
if (argc < ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
@ -1751,7 +1827,7 @@ napi_value JsSceneSessionManager::OnUpdateWindowMode(napi_env env, napi_callback
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 2) {
|
||||
if (argc < ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
@ -1829,7 +1905,6 @@ napi_value JsSceneSessionManager::OnGetRootSceneUIContext(napi_env env, napi_cal
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value uiContext = uiContent->GetUINapiContext();
|
||||
if (uiContext == nullptr) {
|
||||
WLOGFE("uiContext obtained from jsEngine is nullptr");
|
||||
@ -1874,6 +1949,32 @@ napi_value JsSceneSessionManager::OnSendTouchEvent(napi_env env, napi_callback_i
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnPreloadInLakeApp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_ONE) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
std::string bundleName = "";
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to bundleName");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto localScheduler = SceneSessionManager::GetInstance().GetTaskScheduler();
|
||||
auto preloadTask = [bundleName] () {
|
||||
SceneSessionManager::GetInstance().PreloadInLakeApp(bundleName);
|
||||
};
|
||||
localScheduler->PostAsyncTask(preloadTask);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnRequestFocusStatus(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
@ -1947,28 +2048,6 @@ napi_value JsSceneSessionManager::OnSetScreenLocked(napi_env env, napi_callback_
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnPreloadInLakeApp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_ONE) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
std::string bundleName = "";
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to bundleName");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
SceneSessionManager::GetInstance().PreloadInLakeApp(bundleName);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnUpdateMaximizeMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
@ -2096,7 +2175,8 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(isVisible, barArea, displayId);
|
||||
SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(
|
||||
isVisible, barArea, static_cast<uint64_t>(displayId));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
@ -2105,7 +2185,7 @@ napi_value JsSceneSessionManager::OnNotifySessionRecoverStatus(napi_env env, nap
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < ARGC_ONE) {
|
||||
if (argc != ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
@ -2129,14 +2209,8 @@ napi_value JsSceneSessionManager::OnNotifySessionRecoverStatus(napi_env env, nap
|
||||
}
|
||||
if (!isRecovering) {
|
||||
// Sceneboard recover finished
|
||||
if (argc != ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Recovered persistentId List not received"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
SceneSessionManager::GetInstance().UpdateRecoveredSessionInfo(recoveredPersistentIds);
|
||||
SceneSessionManager::GetInstance().NotifyRecoveringFinished();
|
||||
SceneSessionManager::GetInstance().UpdateRecoveredSessionInfo(recoveredPersistentIds);
|
||||
} else {
|
||||
SceneSessionManager::GetInstance().SetAlivePersistentIds(recoveredPersistentIds);
|
||||
}
|
||||
@ -2315,4 +2389,35 @@ napi_value JsSceneSessionManager::OnGetFreeMultiWindowConfig(napi_env env, napi_
|
||||
auto systemConfig = SceneSessionManager::GetInstance().GetSystemSessionConfig();
|
||||
return JsWindowSceneConfig::CreateFreeMultiWindowConfig(env, systemConfig);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::GetCustomDecorHeight(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]GetCustomDecorHeight");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnGetCustomDecorHeight(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnGetCustomDecorHeight(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
napi_value argv[4] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < 1) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t persistentId;
|
||||
if (!ConvertFromJsValue(env, argv[0], persistentId)) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert parameter to persistentId");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t customDecorHeight = SceneSessionManager::GetInstance().GetCustomDecorHeight(persistentId);
|
||||
napi_value result = nullptr;
|
||||
napi_create_int32(env, customDecorHeight, &result);
|
||||
return result;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -62,23 +62,25 @@ public:
|
||||
static napi_value UpdateWindowMode(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRootSceneUIContext(napi_env env, napi_callback_info info);
|
||||
static napi_value SendTouchEvent(napi_env env, napi_callback_info info);
|
||||
static napi_value AddWindowDragHotArea(napi_env env, napi_callback_info info);
|
||||
static napi_value PreloadInLakeApp(napi_env env, napi_callback_info info);
|
||||
static napi_value RequestFocusStatus(napi_env env, napi_callback_info info);
|
||||
static napi_value RequestAllAppSessionUnfocus(napi_env env, napi_callback_info info);
|
||||
static napi_value SetScreenLocked(napi_env env, napi_callback_info info);
|
||||
static napi_value PreloadInLakeApp(napi_env env, napi_callback_info info);
|
||||
static napi_value AddWindowDragHotArea(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateTitleInTargetPos(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateMaximizeMode(napi_env env, napi_callback_info info);
|
||||
static napi_value ReportData(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifySessionRecoverStatus(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateSessionDisplayId(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateConfig(napi_env env, napi_callback_info info);
|
||||
static napi_value ReportData(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemAnimatedScenes(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSessionSnapshotPixelMap(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIsLayoutFullScreen(napi_env env, napi_callback_info info);
|
||||
static napi_value SwitchFreeMultiWindow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFreeMultiWindowConfig(napi_env env, napi_callback_info info);
|
||||
static napi_value GetCustomDecorHeight(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetRootSceneSession(napi_env env, napi_callback_info info);
|
||||
@ -110,33 +112,36 @@ private:
|
||||
napi_value OnUpdateWindowMode(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetRootSceneUIContext(napi_env env, napi_callback_info info);
|
||||
napi_value OnSendTouchEvent(napi_env env, napi_callback_info info);
|
||||
napi_value OnAddWindowDragHotArea(napi_env env, napi_callback_info info);
|
||||
napi_value OnPreloadInLakeApp(napi_env env, napi_callback_info info);
|
||||
napi_value OnRequestFocusStatus(napi_env env, napi_callback_info info);
|
||||
napi_value OnRequestAllAppSessionUnfocus(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetScreenLocked(napi_env env, napi_callback_info info);
|
||||
napi_value OnPreloadInLakeApp(napi_env env, napi_callback_info info);
|
||||
napi_value OnAddWindowDragHotArea(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateMaximizeMode(napi_env env, napi_callback_info info);
|
||||
napi_value OnReportData(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifySessionRecoverStatus(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateSessionDisplayId(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateConfig(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateTitleInTargetPos(napi_env env, napi_callback_info info);
|
||||
napi_value OnReportData(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetSystemAnimatedScenes(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetSessionSnapshotPixelMap(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetIsLayoutFullScreen(napi_env env, napi_callback_info info);
|
||||
napi_value OnSwitchFreeMultiWindow(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetFreeMultiWindowConfig(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetCustomDecorHeight(napi_env env, napi_callback_info info);
|
||||
|
||||
void OnStatusBarEnabledUpdate(bool enable);
|
||||
void OnGestureNavigationEnabledUpdate(bool enable);
|
||||
void OnCreateSystemSession(const sptr<SceneSession>& sceneSession);
|
||||
void OnCreateKeyboardSession(const sptr<SceneSession>& keyboardSession, const sptr<SceneSession>& panelSession);
|
||||
void OnRecoverSceneSession(const sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo);
|
||||
void OnOutsideDownEvent(int32_t x, int32_t y);
|
||||
void OnStartUIAbilityError(const uint32_t errorCode);
|
||||
void OnShiftFocus(int32_t persistentId);
|
||||
void OnCallingSessionIdChange(uint32_t callingSessionId);
|
||||
void ProcessCreateSystemSessionRegister();
|
||||
void ProcessCreateKeyboardSessionRegister();
|
||||
void ProcessRecoverSceneSessionRegister();
|
||||
void ProcessStatusBarEnabledChangeListener();
|
||||
void ProcessGestureNavigationEnabledChangeListener();
|
||||
|
@ -49,6 +49,20 @@ int32_t GetMMITouchType(int32_t aceType)
|
||||
return MMI::PointerEvent::POINTER_ACTION_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t GetMMISourceType(int32_t sourceType)
|
||||
{
|
||||
switch (sourceType) {
|
||||
case 1:
|
||||
return MMI::PointerEvent::SOURCE_TYPE_MOUSE;
|
||||
case NUMBER_2:
|
||||
return MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
|
||||
case NUMBER_3:
|
||||
return MMI::PointerEvent::SOURCE_TYPE_TOUCHPAD;
|
||||
default:
|
||||
return MMI::PointerEvent::SOURCE_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
napi_value NapiGetUndefined(napi_env env)
|
||||
@ -557,7 +571,7 @@ bool ConvertPointerEventFromJs(napi_env env, napi_value jsObject, MMI::PointerEv
|
||||
WLOGFE("[NAPI]Failed to convert parameter to sourceType");
|
||||
return false;
|
||||
}
|
||||
pointerEvent.SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
|
||||
pointerEvent.SetSourceType(GetMMISourceType(sourceType));
|
||||
double timestamp;
|
||||
if (!ConvertFromJsValue(env, jsTimestamp, timestamp)) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to timestamp");
|
||||
|
@ -42,6 +42,8 @@ napi_value JsWindowSceneConfig::CreateWindowSceneConfig(napi_env env, const AppW
|
||||
napi_set_named_property(env, objValue, "keyboardAnimationOut",
|
||||
CreateKeyboardAnimationValue(env, config.keyboardAnimationOut_));
|
||||
napi_set_named_property(env, objValue, "windowAnimation", CreateWindowAnimationValue(env, config));
|
||||
napi_set_named_property(env, objValue, "systemUIStatusBar", CreateSystemUIStatusBarValue(env,
|
||||
config.systemUIStatusBarConfig_));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@ -113,6 +115,23 @@ napi_value JsWindowSceneConfig::CreateKeyboardAnimationValue(napi_env env,
|
||||
return objValue;
|
||||
}
|
||||
|
||||
napi_value JsWindowSceneConfig::CreateSystemUIStatusBarValue(napi_env env,
|
||||
const SystemUIStatusBarConfig& config)
|
||||
{
|
||||
napi_value objValue = nullptr;
|
||||
napi_create_object(env, &objValue);
|
||||
if (objValue == nullptr) {
|
||||
WLOGFE("[NAPI]Object is null!");
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
napi_set_named_property(env, objValue, "showInLandscapeMode", CreateJsValue(env, config.showInLandscapeMode_));
|
||||
napi_set_named_property(env, objValue, "immersiveStatusBarBgColor",
|
||||
CreateJsValue(env, config.immersiveStatusBarBgColor_));
|
||||
napi_set_named_property(env, objValue, "immersiveStatusBarContentColor",
|
||||
CreateJsValue(env, config.immersiveStatusBarContentColor_));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
JsWindowSceneConfig::JsWindowSceneConfig()
|
||||
{
|
||||
WLOGFD("Construct JsWindowSceneConfig");
|
||||
|
@ -35,6 +35,7 @@ private:
|
||||
static napi_value CreateShadowValue(napi_env env, const AppWindowSceneConfig& config, bool focused);
|
||||
static napi_value CreateKeyboardAnimationValue(napi_env env, const KeyboardSceneAnimationConfig& config);
|
||||
static napi_value CreateWindowAnimationValue(napi_env env, const AppWindowSceneConfig& config);
|
||||
static napi_value CreateSystemUIStatusBarValue(napi_env env, const SystemUIStatusBarConfig& config);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -28,6 +28,7 @@ ohos_shared_library("sessionmanagerservice_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -25,6 +25,7 @@ ohos_shared_library("transactionmanager_napi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -46,6 +47,7 @@ ohos_shared_library("transactionmanager_napi") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
|
@ -32,6 +32,7 @@ ohos_shared_library("screen_session_manager_client") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -109,7 +109,12 @@ void ScreenSessionManagerClientProxy::OnPowerStatusChanged(DisplayPowerEvent eve
|
||||
WLOGFE("Write reason failed");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFE("SendRequest failed, Remote is nullptr");
|
||||
return;
|
||||
}
|
||||
if (remote->SendRequest(
|
||||
static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_POWER_STATUS_CHANGED),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
|
@ -37,6 +37,7 @@ ohos_shared_library("scene_session") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -69,14 +70,11 @@ ohos_shared_library("scene_session") {
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/window_scene/common:window_scene_common",
|
||||
"${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager",
|
||||
"${window_base_path}/window_scene/interfaces/innerkits:libwsutils",
|
||||
"${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client",
|
||||
"${window_base_path}/window_scene/session:screen_session",
|
||||
]
|
||||
|
||||
# for ability_runtime used
|
||||
public_deps =
|
||||
[ "${window_base_path}/window_scene/interfaces/innerkits:libwsutils" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:session_info",
|
||||
@ -141,6 +139,7 @@ ohos_shared_library("screen_session") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -113,6 +113,7 @@ public:
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
virtual void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) {}
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
|
||||
|
@ -49,6 +49,7 @@ enum class SessionStageInterfaceCode {
|
||||
TRANS_ID_NOTIFY_DISPLAYID_CHANGE,
|
||||
TRANS_ID_NOTIFY_DISPLAY_MOVE,
|
||||
TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW,
|
||||
TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE,
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
WSError UpdateDisplayId(uint64_t displayId) override;
|
||||
void NotifyDisplayMove(DisplayId from, DisplayId to) override;
|
||||
WSError SwitchFreeMultiWindow(bool enable) override;
|
||||
void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SessionStageProxy> delegator_;
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
int HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H
|
||||
|
@ -681,4 +681,25 @@ void SessionStageProxy::NotifyDisplayMove(DisplayId from, DisplayId to)
|
||||
}
|
||||
}
|
||||
|
||||
void SessionStageProxy::NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&keyboardPanelInfo)) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest notify keyboard panel info change failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -81,6 +81,8 @@ const std::map<uint32_t, SessionStageStubFunc> SessionStageStub::stubFuncMap_{
|
||||
&SessionStageStub::HandleNotifyDisplayMove),
|
||||
std::make_pair(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW),
|
||||
&SessionStageStub::HandleSwitchFreeMultiWindow),
|
||||
std::make_pair(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE),
|
||||
&SessionStageStub::HandleNotifyKeyboardPanelInfoChange),
|
||||
};
|
||||
|
||||
int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
@ -376,6 +378,20 @@ int SessionStageStub::HandleSwitchFreeMultiWindow(MessageParcel& data, MessagePa
|
||||
bool enable = data.ReadBool();
|
||||
WSError errCode = SwitchFreeMultiWindow(enable);
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStageStub::HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyKeyboardPanelInfoChange!");
|
||||
sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
|
||||
if (keyboardPanelInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
NotifyKeyboardPanelInfoChange(*keyboardPanelInfo);
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -39,6 +39,10 @@ public:
|
||||
WSError Hide() override;
|
||||
WSError Disconnect(bool isFromClient = false) override;
|
||||
WSError NotifyClientToUpdateRect(std::shared_ptr<RSTransaction> rsTransaction) override;
|
||||
void BindKeyboardPanelSession(sptr<SceneSession> panelSession) override;
|
||||
sptr<SceneSession> GetKeyboardPanelSession() const override;
|
||||
SessionGravity GetKeyboardGravity() const override;
|
||||
void OnKeyboardPanelUpdated() override;
|
||||
|
||||
private:
|
||||
sptr<SceneSession> GetSceneSession(uint32_t persistentId);
|
||||
@ -46,22 +50,21 @@ private:
|
||||
|
||||
WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent) override;
|
||||
void SetCallingSessionId(uint32_t callingSessionId) override;
|
||||
sptr<SceneSession> GetCallingSession();
|
||||
uint32_t GetCallingSessionId();
|
||||
|
||||
bool IsStatusBarVisible(const sptr<SceneSession>& session);
|
||||
int32_t GetStatusBarHeight();
|
||||
void NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>& callingSession, const WSRect& rect,
|
||||
const WSRect& occupiedArea);
|
||||
void RaiseCallingSession(bool isKeyboardUpdated = false);
|
||||
void RaiseCallingSession();
|
||||
void RestoreCallingSession();
|
||||
void UseFocusIdIfCallingSessionIdInvalid();
|
||||
void OnKeyboardSessionShown();
|
||||
void UpdateCallingSessionIdAndPosition(uint32_t callingSessionId);
|
||||
void RelayoutKeyBoard();
|
||||
void NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboardPanelShow);
|
||||
bool CheckIfNeedRaiseCallingSession(sptr<SceneSession> callingSession, bool isCallingSessionFloating);
|
||||
|
||||
sptr<KeyboardSessionCallback> keyboardCallback_ = nullptr;
|
||||
WSRect callingSessionRestoringRect_ = {0, 0, 0, 0};
|
||||
WSRect callingSessionRaisedRect_ = {0, 0, 0, 0};
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_KEYBOARD_SESSION_H
|
@ -19,6 +19,7 @@
|
||||
#include "session/host/include/scene_session.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
using KeyboardPanelRectUpdateCallback = std::function<void()>;
|
||||
class SCBSystemSession : public SceneSession {
|
||||
public:
|
||||
SCBSystemSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback);
|
||||
@ -32,9 +33,15 @@ public:
|
||||
WSError UpdateFocus(bool isFocused) override;
|
||||
WSError UpdateWindowMode(WindowMode mode) override;
|
||||
WSError SetSystemSceneBlockingFocus(bool blocking) override;
|
||||
void BindKeyboardSession(sptr<SceneSession> session) override;
|
||||
sptr<SceneSession> GetKeyboardSession() const override;
|
||||
void SetKeyboardPanelRectUpdateCallback(const KeyboardPanelRectUpdateCallback& func);
|
||||
|
||||
protected:
|
||||
void UpdatePointerArea(const WSRect& rect) override;
|
||||
|
||||
private:
|
||||
KeyboardPanelRectUpdateCallback keyboardPanelRectUpdateCallback_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_SCB_SYSTEM_SESSION_H
|
||||
|
@ -63,7 +63,7 @@ using NotifyTouchOutsideFunc = std::function<void()>;
|
||||
using ClearCallbackMapFunc = std::function<void(bool needRemove, int32_t persistentId)>;
|
||||
using NotifyPrepareClosePiPSessionFunc = std::function<void()>;
|
||||
using OnOutsideDownEvent = std::function<void(int32_t x, int32_t y)>;
|
||||
using NotifyAddOrRemoveSecureSessionFunc = std::function<WSError(const sptr<SceneSession>& sceneSession)>;
|
||||
using HandleSecureSessionShouldHideCallback = std::function<WSError(const sptr<SceneSession>& sceneSession)>;
|
||||
using CameraSessionChangeCallback = std::function<void(uint32_t accessTokenId, bool isShowing)>;
|
||||
using NotifyLandscapeMultiWindowSessionFunc = std::function<void(bool isLandscapeMultiWindow)>;
|
||||
using NotifyKeyboardGravityChangeFunc = std::function<void(SessionGravity gravity)>;
|
||||
@ -81,7 +81,7 @@ public:
|
||||
NotifySessionTouchOutsideCallback onSessionTouchOutside_;
|
||||
GetAINavigationBarArea onGetAINavigationBarArea_;
|
||||
OnOutsideDownEvent onOutsideDownEvent_;
|
||||
NotifyAddOrRemoveSecureSessionFunc onHandleSecureSessionShouldHide_;
|
||||
HandleSecureSessionShouldHideCallback onHandleSecureSessionShouldHide_;
|
||||
CameraSessionChangeCallback onCameraSessionChange_;
|
||||
};
|
||||
|
||||
@ -125,6 +125,12 @@ public:
|
||||
WSError Foreground(sptr<WindowSessionProperty> property) override;
|
||||
WSError Background() override;
|
||||
WSError Disconnect(bool isFromClient = false) override;
|
||||
virtual void BindKeyboardPanelSession(sptr<SceneSession> panelSession) {};
|
||||
virtual sptr<SceneSession> GetKeyboardPanelSession() const { return nullptr; };
|
||||
virtual void BindKeyboardSession(sptr<SceneSession> session) {};
|
||||
virtual sptr<SceneSession> GetKeyboardSession() const { return nullptr; };
|
||||
virtual SessionGravity GetKeyboardGravity() const { return SessionGravity::SESSION_GRAVITY_DEFAULT; };
|
||||
virtual void OnKeyboardPanelUpdated() {};
|
||||
|
||||
WSError UpdateActiveStatus(bool isActive) override;
|
||||
WSError OnSessionEvent(SessionEvent event) override;
|
||||
@ -180,6 +186,8 @@ public:
|
||||
void SetAbilitySessionInfo(std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo);
|
||||
void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func);
|
||||
void SetSessionRectChangeCallback(const NotifySessionRectChangeFunc& func);
|
||||
void SetIsDisplayStatusBarTemporarily(bool isTemporary);
|
||||
void SetRestoringRectForKeyboard(WSRect rect);
|
||||
|
||||
int32_t GetCollaboratorType() const;
|
||||
sptr<IRemoteObject> GetSelfToken() const;
|
||||
@ -194,6 +202,7 @@ public:
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> GetAbilityInfo() const;
|
||||
const std::string& GetWindowNameAllType() const;
|
||||
PiPTemplateInfo GetPiPTemplateInfo() const;
|
||||
WSRect GetRestoringRectForKeyboard() const;
|
||||
|
||||
bool IsVisible() const;
|
||||
bool IsDecorEnable() const;
|
||||
@ -207,6 +216,7 @@ public:
|
||||
void NotifyUILostFocus() override;
|
||||
void SetSystemTouchable(bool touchable) override;
|
||||
bool IsVisibleForAccessibility() const;
|
||||
bool GetIsDisplayStatusBarTemporarily() const;
|
||||
|
||||
WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
WSError OnShowWhenLocked(bool showWhenLocked);
|
||||
@ -230,13 +240,12 @@ public:
|
||||
bool SendKeyEventToUI(std::shared_ptr<MMI::KeyEvent> keyEvent, bool isPreImeEvent = false);
|
||||
bool IsStartMoving() const;
|
||||
void SetIsStartMoving(const bool startMoving);
|
||||
bool ShouldHideNonSecureWindows() const;
|
||||
void SetShouldHideNonSecureWindows(bool shouldHide);
|
||||
WSError AddOrRemoveSecureExtSession(int32_t persistentId, bool shouldHide);
|
||||
WSError SetPipActionEvent(const std::string& action, int32_t status);
|
||||
void UpdateExtWindowFlags(int32_t extPersistentId, uint32_t extWindowFlags);
|
||||
bool IsExtWindowHasWaterMarkFlag();
|
||||
void RomoveExtWindowFlags(int32_t extPersistentId);
|
||||
void UpdateExtWindowFlags(int32_t extPersistentId, const ExtensionWindowFlags& extWindowFlags,
|
||||
const ExtensionWindowFlags& extWindowActions);
|
||||
ExtensionWindowFlags GetCombinedExtWindowFlags() const;
|
||||
void RemoveExtWindowFlags(int32_t extPersistentId);
|
||||
void ClearExtWindowFlags();
|
||||
void NotifyDisplayMove(DisplayId from, DisplayId to);
|
||||
|
||||
@ -252,6 +261,15 @@ public:
|
||||
WSError UpdateRectChangeListenerRegistered(bool isRegister) override;
|
||||
void SetForceHideState(bool hideFlag);
|
||||
bool GetForceHideState() const;
|
||||
int32_t GetCustomDecorHeight() override
|
||||
{
|
||||
return customDecorHeight_;
|
||||
}
|
||||
|
||||
void SetCustomDecorHeight(int32_t height) override
|
||||
{
|
||||
customDecorHeight_ = height;
|
||||
}
|
||||
|
||||
protected:
|
||||
void NotifyIsCustomAnimationPlaying(bool isPlaying);
|
||||
@ -266,11 +284,11 @@ protected:
|
||||
+ to_string(rect.posX_) + ", " + to_string(rect.posY_) + "]";
|
||||
}
|
||||
|
||||
mutable std::shared_mutex sessionChangeCallbackMutex_;
|
||||
sptr<SpecificSessionCallback> specificCallback_ = nullptr;
|
||||
sptr<SessionChangeCallback> sessionChangeCallback_ = nullptr;
|
||||
mutable std::shared_mutex moveDragControllerMutex_;
|
||||
sptr<MoveDragController> moveDragController_ = nullptr;
|
||||
sptr<SceneSession> keyboardPanelSession_ = nullptr;
|
||||
sptr<SceneSession> keyboardSession_ = nullptr;
|
||||
|
||||
private:
|
||||
void NotifyAccessibilityVisibilityChange();
|
||||
@ -278,6 +296,7 @@ private:
|
||||
void GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
void GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
void GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
void CalculateCombinedExtWindowFlags();
|
||||
void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea);
|
||||
void HandleStyleEvent(MMI::WindowArea area) override;
|
||||
WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY);
|
||||
@ -294,12 +313,13 @@ private:
|
||||
void UpdateWinRectForSystemBar(WSRect& rect);
|
||||
bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect);
|
||||
void HandleCastScreenConnection(SessionInfo& info, sptr<SceneSession> session);
|
||||
|
||||
void FixKeyboardPositionByKeyboardPanel(sptr<SceneSession> panelSession, sptr<SceneSession> keyboardSession);
|
||||
|
||||
NotifySessionRectChangeFunc sessionRectChangeFunc_;
|
||||
static wptr<SceneSession> enterSession_;
|
||||
static std::mutex enterSessionMutex_;
|
||||
mutable std::mutex sessionChangeCbMutex_;
|
||||
int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
|
||||
mutable std::shared_mutex selfTokenMutex_;
|
||||
sptr<IRemoteObject> selfToken_ = nullptr;
|
||||
WSRect lastSafeRect = { 0, 0, 0, 0 };
|
||||
std::vector<sptr<SceneSession>> subSession_;
|
||||
@ -307,10 +327,13 @@ private:
|
||||
PiPTemplateInfo pipTemplateInfo_;
|
||||
std::atomic_bool isStartMoving_ { false };
|
||||
std::atomic_bool isVisibleForAccessibility_ { true };
|
||||
std::atomic_bool isDisplayStatusBarTemporarily_ { false };
|
||||
std::atomic_bool shouldHideNonSecureWindows_ { false };
|
||||
std::set<int32_t> secureExtSessionSet_;
|
||||
std::map<int32_t, uint32_t> extWindowFlagsMap_;
|
||||
ExtensionWindowFlags combinedExtWindowFlags_ { 0 };
|
||||
std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
|
||||
bool forceHideState_ = false;
|
||||
int32_t customDecorHeight_ = 0;
|
||||
WSRect restoringRectForKeyboard_ = {0, 0, 0, 0};
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H
|
@ -96,12 +96,23 @@ enum class LifeCycleTaskType : uint32_t {
|
||||
STOP
|
||||
};
|
||||
|
||||
enum class DetectTaskState : uint32_t {
|
||||
NO_TASK,
|
||||
ATTACH_TASK,
|
||||
DETACH_TASK
|
||||
};
|
||||
|
||||
struct DetectTaskInfo {
|
||||
WindowMode taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED;
|
||||
DetectTaskState taskState = DetectTaskState::NO_TASK;
|
||||
};
|
||||
|
||||
class Session : public SessionStub {
|
||||
public:
|
||||
using Task = std::function<void()>;
|
||||
explicit Session(const SessionInfo& info);
|
||||
virtual ~Session() = default;
|
||||
|
||||
bool isKeyboardPanelEnabled_ = false;
|
||||
void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler,
|
||||
const std::shared_ptr<AppExecFwk::EventHandler>& exportHandler = nullptr);
|
||||
|
||||
@ -380,7 +391,8 @@ public:
|
||||
bool GetForegroundInteractiveStatus() const;
|
||||
virtual void SetForegroundInteractiveStatus(bool interactive);
|
||||
void RegisterWindowModeChangedCallback(const std::function<void()>& callback);
|
||||
void SetAttachState(bool isAttach);
|
||||
void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED);
|
||||
bool GetAttachState() const;
|
||||
void RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback);
|
||||
void RegisterWindowBackHomeCallback(const std::function<void()>& callback) {};
|
||||
SystemSessionConfig GetSystemConfig() const;
|
||||
@ -388,7 +400,17 @@ public:
|
||||
virtual void RectCheck(uint32_t curWidth, uint32_t curHeight) {};
|
||||
void RectSizeCheckProcess(uint32_t curWidth, uint32_t curHeight, uint32_t minWidth,
|
||||
uint32_t minHeight, uint32_t maxFloatingWindowSize);
|
||||
DetectTaskInfo GetDetectTaskInfo() const;
|
||||
void SetDetectTaskInfo(const DetectTaskInfo& detectTaskInfo);
|
||||
void CreateWindowStateDetectTask(bool isAttach, WindowMode windowMode);
|
||||
void RegisterIsScreenLockedCallback(const std::function<bool()>& callback);
|
||||
std::string GetWindowDetectTaskName() const;
|
||||
void RemoveWindowDetectTask();
|
||||
WSError SwitchFreeMultiWindow(bool enable);
|
||||
virtual int32_t GetCustomDecorHeight()
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
class SessionLifeCycleTask : public virtual RefBase {
|
||||
@ -438,7 +460,7 @@ protected:
|
||||
}
|
||||
|
||||
int32_t persistentId_ = INVALID_SESSION_ID;
|
||||
SessionState state_ = SessionState::STATE_DISCONNECT;
|
||||
std::atomic<SessionState> state_ = SessionState::STATE_DISCONNECT;
|
||||
SessionInfo sessionInfo_;
|
||||
std::recursive_mutex sessionInfoMutex_;
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode_;
|
||||
@ -504,7 +526,6 @@ protected:
|
||||
float pivotY_ = 0.0f;
|
||||
mutable std::shared_mutex dialogVecMutex_;
|
||||
std::vector<sptr<Session>> dialogVec_;
|
||||
mutable std::shared_mutex parentSessionMutex_;
|
||||
sptr<Session> parentSession_;
|
||||
sptr<IWindowEventChannel> windowEventChannel_;
|
||||
|
||||
@ -523,7 +544,11 @@ private:
|
||||
bool RegisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener);
|
||||
template<typename T>
|
||||
bool UnregisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener);
|
||||
|
||||
bool IsStateMatch(bool isAttach) const;
|
||||
bool IsSupportDetectWindow(bool isAttach);
|
||||
bool ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const;
|
||||
bool ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const;
|
||||
void CreateDetectStateTask(bool isAttach, WindowMode windowMode);
|
||||
template<typename T1, typename T2, typename Ret>
|
||||
using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type;
|
||||
template<typename T>
|
||||
@ -544,6 +569,7 @@ private:
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> exportHandler_;
|
||||
std::function<void()> windowModeCallback_;
|
||||
std::function<bool()> isScreenLockedCallback_;
|
||||
|
||||
mutable std::shared_mutex propertyMutex_;
|
||||
sptr<WindowSessionProperty> property_;
|
||||
@ -567,11 +593,13 @@ private:
|
||||
bool forceTouchable_ { true };
|
||||
bool systemTouchable_ { true };
|
||||
std::atomic_bool foregroundInteractiveStatus_ { true };
|
||||
bool isAttach_{ false };
|
||||
std::atomic<bool> isAttach_{ false };
|
||||
sptr<IPatternDetachCallback> detachCallback_ = nullptr;
|
||||
|
||||
std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_;
|
||||
mutable std::mutex leashWinSurfaceNodeMutex;
|
||||
DetectTaskInfo detectTaskInfo_;
|
||||
mutable std::shared_mutex detectTaskInfoMutex_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
void RectCheck(uint32_t curWidth, uint32_t curHeight) override;
|
||||
protected:
|
||||
bool CheckKeyEventDispatch(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
|
||||
|
||||
void UpdatePointerArea(const WSRect& rect) override;
|
||||
bool CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const override;
|
||||
private:
|
||||
void UpdateCameraWindowStatus(bool isShowing);
|
||||
bool NeedSystemPermission(WindowType type);
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
virtual void SetCallingSessionId(uint32_t callingSessionId) {};
|
||||
virtual void SetCustomDecorHeight(int32_t height) {};
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -54,6 +54,7 @@ enum class SessionInterfaceCode {
|
||||
TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED,
|
||||
TRANS_ID_SET_KEYBOARD_SESSION_GRAVITY,
|
||||
TRANS_ID_SET_CALLING_SESSION_ID,
|
||||
TRANS_ID_SET_CUSTOM_DECOR_HEIGHT,
|
||||
|
||||
// Extension
|
||||
TRANS_ID_TRANSFER_ABILITY_RESULT = 500,
|
||||
|
@ -78,6 +78,8 @@ public:
|
||||
WSError UpdateRectChangeListenerRegistered(bool isRegister) override;
|
||||
WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent) override;
|
||||
void SetCallingSessionId(uint32_t callingSessionId) override;
|
||||
void SetCustomDecorHeight(int32_t height) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SessionProxy> delegator_;
|
||||
};
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
int HandleUpdateRectChangeListenerRegistered(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSetKeyboardSessionGravity(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSetCallingSessionId(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSetCustomDecorHeight(MessageParcel& data, MessageParcel& reply);
|
||||
|
||||
// extension extension
|
||||
int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -38,6 +38,32 @@ KeyboardSession::~KeyboardSession()
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "~KeyboardSession");
|
||||
}
|
||||
|
||||
void KeyboardSession::BindKeyboardPanelSession(sptr<SceneSession> panelSession)
|
||||
{
|
||||
if (panelSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "panelSession is nullptr");
|
||||
return;
|
||||
}
|
||||
keyboardPanelSession_ = panelSession;
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Success, panelId: %{public}d", panelSession->GetPersistentId());
|
||||
}
|
||||
|
||||
sptr<SceneSession> KeyboardSession::GetKeyboardPanelSession() const
|
||||
{
|
||||
return keyboardPanelSession_;
|
||||
}
|
||||
|
||||
SessionGravity KeyboardSession::GetKeyboardGravity() const
|
||||
{
|
||||
SessionGravity gravity = SessionGravity::SESSION_GRAVITY_DEFAULT;
|
||||
uint32_t percent = 0;
|
||||
if (GetSessionProperty()) {
|
||||
GetSessionProperty()->GetSessionGravity(gravity, percent);
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}d", gravity);
|
||||
return gravity;
|
||||
}
|
||||
|
||||
WSError KeyboardSession::Show(sptr<WindowSessionProperty> property)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), property]() {
|
||||
@ -47,9 +73,13 @@ WSError KeyboardSession::Show(sptr<WindowSessionProperty> property)
|
||||
return WSError::WS_ERROR_DESTROYED_OBJECT;
|
||||
}
|
||||
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Show keyboard session, id: %{public}d", session->GetPersistentId());
|
||||
auto ret = session->SceneSession::Foreground(property);
|
||||
session->OnKeyboardSessionShown();
|
||||
session->UseFocusIdIfCallingSessionIdInvalid();
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Show keyboard session, id: %{public}d, calling session id: %{public}d",
|
||||
session->GetPersistentId(), session->GetCallingSessionId());
|
||||
if (!session->isKeyboardPanelEnabled_) {
|
||||
session->RaiseCallingSession();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
PostTask(task, "Show");
|
||||
@ -73,6 +103,8 @@ WSError KeyboardSession::Hide()
|
||||
return ret;
|
||||
}
|
||||
ret = session->SceneSession::Background();
|
||||
WSRect rect = {0, 0, 0, 0};
|
||||
session->NotifyKeyboardPanelInfoChange(rect, false);
|
||||
session->RestoreCallingSession();
|
||||
if (session->GetSessionProperty()) {
|
||||
session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID);
|
||||
@ -94,6 +126,8 @@ WSError KeyboardSession::Disconnect(bool isFromClient)
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Disconnect keyboard session, id: %{public}d, isFromClient: %{public}d",
|
||||
session->GetPersistentId(), isFromClient);
|
||||
session->SceneSession::Disconnect(isFromClient);
|
||||
WSRect rect = {0, 0, 0, 0};
|
||||
session->NotifyKeyboardPanelInfoChange(rect, false);
|
||||
session->RestoreCallingSession();
|
||||
if (session->GetSessionProperty()) {
|
||||
session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID);
|
||||
@ -112,9 +146,11 @@ WSError KeyboardSession::NotifyClientToUpdateRect(std::shared_ptr<RSTransaction>
|
||||
if (ret != WSError::WS_OK) {
|
||||
return ret;
|
||||
}
|
||||
session->RaiseCallingSession(true);
|
||||
if (session->specificCallback_ != nullptr && session->specificCallback_->onUpdateAvoidArea_ != nullptr) {
|
||||
session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId());
|
||||
if (!session->isKeyboardPanelEnabled_) {
|
||||
session->RaiseCallingSession();
|
||||
if (session->specificCallback_ != nullptr && session->specificCallback_->onUpdateAvoidArea_ != nullptr) {
|
||||
session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId());
|
||||
}
|
||||
}
|
||||
if (session->reason_ != SizeChangeReason::DRAG) {
|
||||
session->reason_ = SizeChangeReason::UNDEFINED;
|
||||
@ -126,6 +162,19 @@ WSError KeyboardSession::NotifyClientToUpdateRect(std::shared_ptr<RSTransaction>
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void KeyboardSession::OnKeyboardPanelUpdated()
|
||||
{
|
||||
if (!isKeyboardPanelEnabled_) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is not enabled");
|
||||
return;
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "id: %{public}d", GetPersistentId());
|
||||
RaiseCallingSession();
|
||||
if (specificCallback_ != nullptr && specificCallback_->onUpdateAvoidArea_ != nullptr) {
|
||||
specificCallback_->onUpdateAvoidArea_(GetPersistentId());
|
||||
}
|
||||
}
|
||||
|
||||
WSError KeyboardSession::SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), gravity, percent]() -> WSError {
|
||||
@ -151,7 +200,7 @@ WSError KeyboardSession::SetKeyboardSessionGravity(SessionGravity gravity, uint3
|
||||
}
|
||||
} else {
|
||||
session->SetWindowAnimationFlag(true);
|
||||
if (session->IsSessionForeground()) {
|
||||
if (session->IsSessionForeground() && !session->isKeyboardPanelEnabled_) {
|
||||
session->RaiseCallingSession();
|
||||
}
|
||||
}
|
||||
@ -165,13 +214,21 @@ void KeyboardSession::SetCallingSessionId(uint32_t callingSessionId)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session id: %{public}d", callingSessionId);
|
||||
UpdateCallingSessionIdAndPosition(callingSessionId);
|
||||
if (keyboardCallback_ == nullptr || keyboardCallback_->onCallingSessionIdChange_ == nullptr ||
|
||||
GetSessionProperty() == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardCallback_ or sessionProperty is null, callingSessionId: %{public}d",
|
||||
if (keyboardCallback_ == nullptr || keyboardCallback_->onCallingSessionIdChange_ == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardCallback_, callingSessionId: %{public}d",
|
||||
callingSessionId);
|
||||
return;
|
||||
}
|
||||
keyboardCallback_->onCallingSessionIdChange_(GetSessionProperty()->GetCallingSessionId());
|
||||
keyboardCallback_->onCallingSessionIdChange_(GetCallingSessionId());
|
||||
}
|
||||
|
||||
uint32_t KeyboardSession::GetCallingSessionId()
|
||||
{
|
||||
if (GetSessionProperty() == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "Session property is null");
|
||||
return INVALID_SESSION_ID;
|
||||
}
|
||||
return GetSessionProperty()->GetCallingSessionId();
|
||||
}
|
||||
|
||||
sptr<SceneSession> KeyboardSession::GetSceneSession(uint32_t persistentId)
|
||||
@ -253,103 +310,129 @@ void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>& cal
|
||||
callingSession->NotifyOccupiedAreaChangeInfo(info);
|
||||
}
|
||||
|
||||
sptr<SceneSession> KeyboardSession::GetCallingSession()
|
||||
void KeyboardSession::NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboardPanelShow)
|
||||
{
|
||||
sptr<SceneSession> callingSession = nullptr;
|
||||
if (GetSessionProperty() != nullptr) {
|
||||
callingSession = GetSceneSession(GetSessionProperty()->GetCallingSessionId());
|
||||
if (!isKeyboardPanelEnabled_) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is not enabled");
|
||||
return;
|
||||
}
|
||||
if (!sessionStage_) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionStage_ is nullptr, notify keyboard panel rect change failed");
|
||||
return;
|
||||
}
|
||||
KeyboardPanelInfo keyboardPanelInfo;
|
||||
keyboardPanelInfo.rect_ = SessionHelper::TransferToRect(rect);
|
||||
keyboardPanelInfo.gravity_ = static_cast<WindowGravity>(GetKeyboardGravity());
|
||||
keyboardPanelInfo.isShowing_ = isKeyboardPanelShow;
|
||||
|
||||
return callingSession;
|
||||
sessionStage_->NotifyKeyboardPanelInfoChange(keyboardPanelInfo);
|
||||
}
|
||||
|
||||
void KeyboardSession::RaiseCallingSession(bool isKeyboardUpdated)
|
||||
bool KeyboardSession::CheckIfNeedRaiseCallingSession(sptr<SceneSession> callingSession, bool isCallingSessionFloating)
|
||||
{
|
||||
sptr<SceneSession> callingSession = GetCallingSession();
|
||||
if (callingSession == nullptr) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr");
|
||||
return;
|
||||
}
|
||||
SessionGravity gravity = SessionGravity::SESSION_GRAVITY_DEFAULT;
|
||||
uint32_t percent = 0;
|
||||
GetSessionProperty()->GetSessionGravity(gravity, percent);
|
||||
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "No need to raise calling session, gravity: %{public}d", gravity);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
WSRect callingSessionRect = callingSession->GetSessionRect();
|
||||
bool isCallingSessionFloating = (callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING);
|
||||
SessionGravity gravity = GetKeyboardGravity();
|
||||
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "No need to raise calling session, gravity: %{public}d", gravity);
|
||||
return false;
|
||||
}
|
||||
bool isMainOrParentFloating = WindowHelper::IsMainWindow(callingSession->GetWindowType()) ||
|
||||
(WindowHelper::IsSubWindow(callingSession->GetWindowType()) && callingSession->GetParentSession() != nullptr &&
|
||||
callingSession->GetParentSession()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (isCallingSessionFloating && isMainOrParentFloating &&
|
||||
(system::GetParameter("const.product.devicetype", "unknown") == "phone" ||
|
||||
system::GetParameter("const.product.devicetype", "unknown") == "tablet")) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "No need to raise calling session in float window.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeyboardSession::RaiseCallingSession()
|
||||
{
|
||||
sptr<SceneSession> callingSession = GetSceneSession(GetCallingSessionId());
|
||||
if (callingSession == nullptr) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isKeyboardUpdated && isCallingSessionFloating) {
|
||||
callingSessionRect = callingSessionRestoringRect_;
|
||||
WSRect keyboardPanelRect = {0, 0, 0, 0};
|
||||
if (!isKeyboardPanelEnabled_) {
|
||||
keyboardPanelRect = (GetSessionRect().height_ != 0) ? GetSessionRect() : GetSessionRequestRect();
|
||||
} else if (keyboardPanelSession_ != nullptr) {
|
||||
keyboardPanelRect = keyboardPanelSession_->GetSessionRect();
|
||||
NotifyKeyboardPanelInfoChange(keyboardPanelRect, true);
|
||||
}
|
||||
const WSRect& keyboardSessionRect = (GetSessionRect().height_ != 0) ? GetSessionRect() : GetSessionRequestRect();
|
||||
if (SessionHelper::IsEmptyRect(SessionHelper::GetOverlap(keyboardSessionRect, callingSessionRect, 0, 0))) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "No overlap area, keyboardRect: %{public}s, callingSessionRect: %{public}s",
|
||||
keyboardSessionRect.ToString().c_str(), callingSessionRect.ToString().c_str());
|
||||
|
||||
bool isCallingSessionFloating = (callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (!CheckIfNeedRaiseCallingSession(callingSession, isCallingSessionFloating)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isKeyboardUpdated) {
|
||||
callingSessionRestoringRect_ = callingSessionRect;
|
||||
WSRect callingSessionRect = callingSession->GetSessionRect();
|
||||
WSRect callingSessionRestoringRect = callingSession->GetRestoringRectForKeyboard();
|
||||
if (!SessionHelper::IsEmptyRect(callingSessionRestoringRect) && isCallingSessionFloating) {
|
||||
callingSessionRect = callingSessionRestoringRect;
|
||||
}
|
||||
if (SessionHelper::IsEmptyRect(SessionHelper::GetOverlap(keyboardPanelRect, callingSessionRect, 0, 0)) &&
|
||||
SessionHelper::IsEmptyRect(callingSessionRestoringRect)) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "No overlap area, keyboardRect: %{public}s, callingRect: %{public}s",
|
||||
keyboardPanelRect.ToString().c_str(), callingSessionRect.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
if (SessionHelper::IsEmptyRect(callingSessionRestoringRect)) {
|
||||
callingSessionRestoringRect = callingSessionRect;
|
||||
callingSession->SetRestoringRectForKeyboard(callingSessionRect);
|
||||
}
|
||||
|
||||
WSRect newRect = callingSessionRect;
|
||||
int32_t statusHeight = GetStatusBarHeight();
|
||||
if (isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) {
|
||||
// calculate new rect of calling window
|
||||
newRect.posY_ = std::max(keyboardSessionRect.posY_ - static_cast<int32_t>(newRect.height_), statusHeight);
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, newRect, keyboardSessionRect);
|
||||
// calculate new rect of calling session
|
||||
newRect.posY_ = std::max(keyboardPanelRect.posY_ - static_cast<int32_t>(newRect.height_), statusHeight);
|
||||
newRect.posY_ = std::min(callingSessionRestoringRect.posY_, newRect.posY_);
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, newRect, keyboardPanelRect);
|
||||
callingSession->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED);
|
||||
callingSessionRaisedRect_ = newRect;
|
||||
} else {
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, newRect, keyboardSessionRect);
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, newRect, keyboardPanelRect);
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "keyboardRect: %{public}s, OriCallingRect: %{public}s, NewCallingRect: %{public}s"
|
||||
", callingRestoreRect_: %{public}s, isCallingSessionFloating: %{public}d, isKeyboardUpdated: %{public}d",
|
||||
keyboardSessionRect.ToString().c_str(), callingSessionRect.ToString().c_str(), newRect.ToString().c_str(),
|
||||
callingSessionRestoringRect_.ToString().c_str(), isCallingSessionFloating, isKeyboardUpdated);
|
||||
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "keyboardRect: %{public}s, CallSession OriRect: %{public}s, NewRect: %{public}s"
|
||||
", RestoreRect_: %{public}s, isCallingSessionFloating: %{public}d",
|
||||
keyboardPanelRect.ToString().c_str(), callingSessionRect.ToString().c_str(), newRect.ToString().c_str(),
|
||||
callingSessionRestoringRect.ToString().c_str(), isCallingSessionFloating);
|
||||
}
|
||||
|
||||
void KeyboardSession::RestoreCallingSession()
|
||||
{
|
||||
sptr<SceneSession> callingSession = GetCallingSession();
|
||||
sptr<SceneSession> callingSession = GetSceneSession(GetCallingSessionId());
|
||||
if (callingSession == nullptr) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session, RestoringRect_: %{public}s, RaisedRect_: %{public}s"
|
||||
", curRect_: %{public}s, sessionMode: %{public}d", callingSessionRestoringRect_.ToString().c_str(),
|
||||
callingSessionRaisedRect_.ToString().c_str(), callingSession->GetSessionRect().ToString().c_str(),
|
||||
callingSession->GetWindowMode());
|
||||
WSRect overlapRect = { 0, 0, 0, 0 };
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, callingSessionRestoringRect_, overlapRect);
|
||||
if (!SessionHelper::IsEmptyRect(callingSessionRestoringRect_) &&
|
||||
callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING &&
|
||||
callingSession->GetSessionRect() == callingSessionRaisedRect_) {
|
||||
callingSession->UpdateSessionRect(callingSessionRestoringRect_, SizeChangeReason::UNDEFINED);
|
||||
WSRect callingSessionRestoringRect = callingSession->GetRestoringRectForKeyboard();
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "callingSessionRestoringRect: %{public}s, sessionMode: %{public}d",
|
||||
callingSessionRestoringRect.ToString().c_str(), callingSession->GetWindowMode());
|
||||
WSRect keyboardRect = { 0, 0, 0, 0 };
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, callingSessionRestoringRect, keyboardRect);
|
||||
if (!SessionHelper::IsEmptyRect(callingSessionRestoringRect) &&
|
||||
callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) {
|
||||
callingSession->UpdateSessionRect(callingSessionRestoringRect, SizeChangeReason::UNDEFINED);
|
||||
}
|
||||
callingSessionRestoringRect_ = { 0, 0, 0, 0 };
|
||||
callingSessionRaisedRect_ = { 0, 0, 0, 0 };
|
||||
callingSession->SetRestoringRectForKeyboard(keyboardRect);
|
||||
}
|
||||
|
||||
// Use focused session id when calling session id is invalid.
|
||||
void KeyboardSession::UseFocusIdIfCallingSessionIdInvalid()
|
||||
{
|
||||
if (GetCallingSession() != nullptr) {
|
||||
if (GetSceneSession(GetCallingSessionId()) != nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t focusedSessionId = GetFocusedSessionId();
|
||||
int32_t focusedSessionId = GetFocusedSessionId();
|
||||
if (GetSceneSession(focusedSessionId) == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "Focused session is null, id: %{public}d", focusedSessionId);
|
||||
} else {
|
||||
@ -358,18 +441,6 @@ void KeyboardSession::UseFocusIdIfCallingSessionIdInvalid()
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardSession::OnKeyboardSessionShown()
|
||||
{
|
||||
if (GetSessionProperty() == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "Keyboard session property is nullptr, raise calling session failed.");
|
||||
return;
|
||||
}
|
||||
UseFocusIdIfCallingSessionIdInvalid();
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Raise keyboard session, persistentId: %{public}d, callingSessionId: %{public}d",
|
||||
GetPersistentId(), GetSessionProperty()->GetCallingSessionId());
|
||||
RaiseCallingSession();
|
||||
}
|
||||
|
||||
void KeyboardSession::UpdateCallingSessionIdAndPosition(uint32_t callingSessionId)
|
||||
{
|
||||
if (GetSessionProperty() == nullptr) {
|
||||
@ -419,7 +490,7 @@ void KeyboardSession::RelayoutKeyBoard()
|
||||
requestRect.posX_ = 0;
|
||||
if (percent != 0) {
|
||||
// 100: for calc percent.
|
||||
requestRect.height_ = static_cast<uint32_t>(screenHeight) * percent / 100u;
|
||||
requestRect.height_ = static_cast<uint32_t>(screenHeight * percent / 100u);
|
||||
}
|
||||
}
|
||||
requestRect.posY_ = screenHeight - static_cast<int32_t>(requestRect.height_);
|
||||
|
@ -37,13 +37,10 @@ MainSession::MainSession(const SessionInfo& info, const sptr<SpecificSessionCall
|
||||
// persistentId changed due to id conflicts. Need to rename the old snapshot if exists
|
||||
scenePersistence_->RenameSnapshotFromOldPersistentId(info.persistentId_);
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
if (moveDragController_ != nullptr && specificCallback != nullptr &&
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
if (moveDragController_ != nullptr && specificCallback != nullptr &&
|
||||
specificCallback->onWindowInputPidChangeCallback_ != nullptr) {
|
||||
moveDragController_->SetNotifyWindowPidChangeCallback(specificCallback->onWindowInputPidChangeCallback_);
|
||||
}
|
||||
moveDragController_->SetNotifyWindowPidChangeCallback(specificCallback->onWindowInputPidChangeCallback_);
|
||||
}
|
||||
SetMoveDragCallback();
|
||||
std::string key = GetRatioPreferenceKey();
|
||||
@ -149,7 +146,7 @@ bool MainSession::CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEv
|
||||
sessionState != SessionState::STATE_ACTIVE &&
|
||||
action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) {
|
||||
WLOGFW("Current Session Info: [persistentId: %{public}d, "
|
||||
"state: %{public}d, action:%{public}d]", GetPersistentId(), state_, action);
|
||||
"state: %{public}d, action:%{public}d]", GetPersistentId(), GetSessionState(), action);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -391,9 +391,9 @@ WSRect MoveDragController::CalcFreeformTargetRect(AreaType type, int32_t tranX,
|
||||
}
|
||||
if ((static_cast<uint32_t>(type) & static_cast<uint32_t>(AreaType::LEFT)) ||
|
||||
(static_cast<uint32_t>(type) & static_cast<uint32_t>(AreaType::RIGHT))) {
|
||||
targetRect.height_ = static_cast<uint32_t>(static_cast<float>(targetRect.width_) / newRatio);
|
||||
targetRect.height_ = static_cast<int32_t>(static_cast<float>(targetRect.width_) / newRatio);
|
||||
} else {
|
||||
targetRect.width_ = static_cast<uint32_t>(static_cast<float>(targetRect.height_) * newRatio);
|
||||
targetRect.width_ = static_cast<int32_t>(static_cast<float>(targetRect.height_) * newRatio);
|
||||
}
|
||||
return targetRect;
|
||||
}
|
||||
@ -558,8 +558,11 @@ void MoveDragController::InitDecorValue(const sptr<WindowSessionProperty> proper
|
||||
const SystemSessionConfig& sysConfig)
|
||||
{
|
||||
auto windowType = property->GetWindowType();
|
||||
isDecorEnable_ = (WindowHelper::IsMainWindow(windowType) ||
|
||||
(WindowHelper::IsSubWindow(windowType) && property->IsDecorEnable())) &&
|
||||
bool isMainWindow = WindowHelper::IsMainWindow(windowType);
|
||||
bool isSubWindow = WindowHelper::IsSubWindow(windowType);
|
||||
bool isDialogWindow = WindowHelper::IsDialogWindow(windowType);
|
||||
isDecorEnable_ = (isMainWindow ||
|
||||
((isSubWindow || isDialogWindow) && property->IsDecorEnable())) &&
|
||||
sysConfig.isSystemDecorEnable_ &&
|
||||
WindowHelper::IsWindowModeSupported(sysConfig.decorModeSupportInfo_, property->GetWindowMode());
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ WSError SCBSystemSession::NotifyClientToUpdateRect(std::shared_ptr<RSTransaction
|
||||
if (session->specificCallback_ != nullptr && session->specificCallback_->onUpdateAvoidArea_ != nullptr) {
|
||||
session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId());
|
||||
}
|
||||
if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYBOARD_PANEL &&
|
||||
session->keyboardPanelRectUpdateCallback_ && session->isKeyboardPanelEnabled_) {
|
||||
session->keyboardPanelRectUpdateCallback_();
|
||||
}
|
||||
// clear after use
|
||||
if (session->reason_ != SizeChangeReason::DRAG) {
|
||||
session->reason_ = SizeChangeReason::UNDEFINED;
|
||||
@ -73,6 +77,32 @@ WSError SCBSystemSession::NotifyClientToUpdateRect(std::shared_ptr<RSTransaction
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void SCBSystemSession::SetKeyboardPanelRectUpdateCallback(const KeyboardPanelRectUpdateCallback& func)
|
||||
{
|
||||
keyboardPanelRectUpdateCallback_ = func;
|
||||
}
|
||||
|
||||
void SCBSystemSession::BindKeyboardSession(sptr<SceneSession> session)
|
||||
{
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "session is nullptr");
|
||||
return;
|
||||
}
|
||||
keyboardSession_ = session;
|
||||
KeyboardPanelRectUpdateCallback onKeyboardPanelRectUpdate = [this]() {
|
||||
if (this->keyboardSession_ != nullptr) {
|
||||
this->keyboardSession_->OnKeyboardPanelUpdated();
|
||||
}
|
||||
};
|
||||
SetKeyboardPanelRectUpdateCallback(onKeyboardPanelRectUpdate);
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Success, id: %{public}d", keyboardSession_->GetPersistentId());
|
||||
}
|
||||
|
||||
sptr<SceneSession> SCBSystemSession::GetKeyboardSession() const
|
||||
{
|
||||
return keyboardSession_;
|
||||
}
|
||||
|
||||
void SCBSystemSession::PresentFocusIfPointDown()
|
||||
{
|
||||
WLOGFI("PresentFocusIfPointDown, id: %{public}d, type: %{public}d", GetPersistentId(), GetWindowType());
|
||||
@ -131,7 +161,7 @@ WSError SCBSystemSession::UpdateFocus(bool isFocused)
|
||||
WSError SCBSystemSession::UpdateWindowMode(WindowMode mode)
|
||||
{
|
||||
WLOGFD("session is system, id: %{public}d, mode: %{public}d, name: %{public}s, state: %{public}u",
|
||||
GetPersistentId(), static_cast<int32_t>(mode), sessionInfo_.bundleName_.c_str(), state_);
|
||||
GetPersistentId(), static_cast<int32_t>(mode), sessionInfo_.bundleName_.c_str(), GetSessionState());
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <transaction/rs_transaction.h>
|
||||
#include <ui/rs_surface_node.h>
|
||||
|
||||
#include "../../proxy/include/window_info.h"
|
||||
#include "proxy/include/window_info.h"
|
||||
|
||||
#include "common/include/session_permission.h"
|
||||
#include "interfaces/include/ws_common.h"
|
||||
@ -85,6 +85,9 @@ WSError SceneSession::Connect(const sptr<ISessionStage>& sessionStage, const spt
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "session is null");
|
||||
return WSError::WS_ERROR_DESTROYED_OBJECT;
|
||||
}
|
||||
if (property) {
|
||||
property->SetCollaboratorType(session->GetCollaboratorType());
|
||||
}
|
||||
auto ret = session->Session::Connect(
|
||||
sessionStage, eventChannel, surfaceNode, systemConfig, property, token, pid, uid);
|
||||
if (ret != WSError::WS_OK) {
|
||||
@ -306,7 +309,7 @@ WSError SceneSession::OnSessionEvent(SessionEvent event)
|
||||
void SceneSession::RegisterSessionChangeCallback(const sptr<SceneSession::SessionChangeCallback>&
|
||||
sessionChangeCallback)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
std::lock_guard<std::mutex> guard(sessionChangeCbMutex_);
|
||||
sessionChangeCallback_ = sessionChangeCallback;
|
||||
}
|
||||
|
||||
@ -449,6 +452,46 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void SceneSession::FixKeyboardPositionByKeyboardPanel(sptr<SceneSession> panelSession,
|
||||
sptr<SceneSession> keyboardSession)
|
||||
{
|
||||
if (panelSession == nullptr || keyboardSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "keyboard or panel session is null");
|
||||
return;
|
||||
}
|
||||
|
||||
SessionGravity gravity = keyboardSession->GetKeyboardGravity();
|
||||
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
|
||||
keyboardSession->winRect_.posX_ = panelSession->winRect_.posX_;
|
||||
} else {
|
||||
if (keyboardSession->GetSessionProperty() == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "keyboard property is null");
|
||||
return;
|
||||
}
|
||||
static bool isPhone = system::GetParameter("const.product.devicetype", "unknown") == "phone";
|
||||
static bool isFoldable = ScreenSessionManagerClient::GetInstance().IsFoldable();
|
||||
bool isFolded = ScreenSessionManagerClient::GetInstance().GetFoldStatus() == OHOS::Rosen::FoldStatus::FOLDED;
|
||||
const auto& screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(
|
||||
keyboardSession->GetSessionProperty()->GetDisplayId());
|
||||
Rotation rotation = (screenSession != nullptr) ? screenSession->GetRotation() : Rotation::ROTATION_0;
|
||||
bool isKeyboardNeedLeftOffset = (isPhone && (!isFoldable || (isFoldable && isFolded)) &&
|
||||
(rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270));
|
||||
if (isKeyboardNeedLeftOffset) {
|
||||
keyboardSession->winRect_.posX_ += panelSession->winRect_.posX_;
|
||||
} else {
|
||||
keyboardSession->winRect_.posX_ = panelSession->winRect_.posX_;
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "isPhone:%{public}d, isFoldable:%{public}d, isFolded:%{public}d, "
|
||||
"rotation:%{public}d, isKeyboardNeedLeftOffset:%{public}d", isPhone, isFoldable,
|
||||
isFolded, rotation, isKeyboardNeedLeftOffset);
|
||||
}
|
||||
keyboardSession->winRect_.posY_ = panelSession->winRect_.posY_;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "panelId:%{public}d, keyboardId:%{public}d, panelRect:%{public}s, "
|
||||
"keyboardRect:%{public}s, gravity:%{public}d", panelSession->GetPersistentId(),
|
||||
keyboardSession->GetPersistentId(), panelSession->winRect_.ToString().c_str(),
|
||||
keyboardSession->winRect_.ToString().c_str(), gravity);
|
||||
}
|
||||
|
||||
WSError SceneSession::NotifyClientToUpdateRectTask(
|
||||
wptr<SceneSession> weakThis, std::shared_ptr<RSTransaction> rsTransaction)
|
||||
{
|
||||
@ -470,6 +513,18 @@ WSError SceneSession::NotifyClientToUpdateRectTask(
|
||||
"SceneSession::NotifyClientToUpdateRect%d [%d, %d, %u, %u] reason:%u",
|
||||
session->GetPersistentId(), session->winRect_.posX_,
|
||||
session->winRect_.posY_, session->winRect_.width_, session->winRect_.height_, session->reason_);
|
||||
|
||||
if (isKeyboardPanelEnabled_) {
|
||||
if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYBOARD_PANEL) {
|
||||
const auto& keyboardSession = session->GetKeyboardSession();
|
||||
FixKeyboardPositionByKeyboardPanel(session, keyboardSession);
|
||||
ret = keyboardSession->Session::UpdateRect(keyboardSession->winRect_, session->reason_, rsTransaction);
|
||||
}
|
||||
if (session->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) {
|
||||
FixKeyboardPositionByKeyboardPanel(session->GetKeyboardPanelSession(), session);
|
||||
}
|
||||
}
|
||||
|
||||
// once reason is undefined, not use rsTransaction
|
||||
// when rotation, sync cnt++ in marshalling. Although reason is undefined caused by resize
|
||||
if (session->reason_ == SizeChangeReason::UNDEFINED || session->reason_ == SizeChangeReason::MOVE ||
|
||||
@ -520,7 +575,7 @@ bool SceneSession::UpdateInputMethodSessionRect(const WSRect&rect, WSRect& newWi
|
||||
defaultDisplayInfo->GetWidth() : rect.width_;
|
||||
newRequestRect.width_ = newWinRect.width_;
|
||||
newWinRect.height_ = (gravity == SessionGravity::SESSION_GRAVITY_BOTTOM && percent != 0) ?
|
||||
static_cast<int32_t>(defaultDisplayInfo->GetHeight()) * percent / 100u : rect.height_;
|
||||
static_cast<int32_t>(defaultDisplayInfo->GetHeight() * percent / 100u) : rect.height_;
|
||||
newRequestRect.height_ = newWinRect.height_;
|
||||
newWinRect.posX_ = (gravity == SessionGravity::SESSION_GRAVITY_BOTTOM) ? 0 : newRequestRect.posX_;
|
||||
newRequestRect.posX_ = newWinRect.posX_;
|
||||
@ -572,7 +627,9 @@ WSError SceneSession::UpdateSessionRect(const WSRect& rect, const SizeChangeReas
|
||||
newWinRect.posY_ = rect.posY_;
|
||||
newRequestRect.posX_ = rect.posX_;
|
||||
newRequestRect.posY_ = rect.posY_;
|
||||
session->SetSessionRect(newWinRect);
|
||||
if (!WindowHelper::IsMainWindow(session->GetWindowType())) {
|
||||
session->SetSessionRect(newWinRect);
|
||||
}
|
||||
session->SetSessionRequestRect(newRequestRect);
|
||||
session->NotifySessionRectChange(newRequestRect, reason);
|
||||
} else if (reason == SizeChangeReason::RESIZE) {
|
||||
@ -653,7 +710,6 @@ WSError SceneSession::BindDialogSessionTarget(const sptr<SceneSession>& sceneSes
|
||||
TLOGE(WmsLogTag::WMS_DIALOG, "dialog session is null");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->onBindDialogTarget_) {
|
||||
TLOGI(WmsLogTag::WMS_DIALOG, "id: %{public}d", sceneSession->GetPersistentId());
|
||||
sessionChangeCallback_->onBindDialogTarget_(sceneSession);
|
||||
@ -674,7 +730,6 @@ WSError SceneSession::SetSystemBarProperty(WindowType type, SystemBarProperty sy
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
property->SetSystemBarProperty(type, systemBarProperty);
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->OnSystemBarPropertyChange_) {
|
||||
sessionChangeCallback_->OnSystemBarPropertyChange_(property->GetSystemBarProperty());
|
||||
}
|
||||
@ -732,7 +787,6 @@ WSError SceneSession::OnNeedAvoid(bool status)
|
||||
WSError SceneSession::OnShowWhenLocked(bool showWhenLocked)
|
||||
{
|
||||
WLOGFD("SceneSession ShowWhenLocked status:%{public}d", static_cast<int32_t>(showWhenLocked));
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->OnShowWhenLocked_) {
|
||||
sessionChangeCallback_->OnShowWhenLocked_(showWhenLocked);
|
||||
}
|
||||
@ -807,7 +861,10 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
vpr = display->GetVirtualPixelRatio();
|
||||
int32_t floatingBarHeight = 32; // 32: floating windowBar Height
|
||||
avoidArea.topRect_.height_ = vpr * floatingBarHeight;
|
||||
avoidArea.topRect_.width_ = display->GetWidth();
|
||||
avoidArea.topRect_.width_ = static_cast<uint32_t>(display->GetWidth());
|
||||
return;
|
||||
}
|
||||
if (isDisplayStatusBarTemporarily_.load()) {
|
||||
return;
|
||||
}
|
||||
std::vector<sptr<SceneSession>> statusBarVector;
|
||||
@ -857,8 +914,16 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
|
||||
continue;
|
||||
}
|
||||
WSRect inputMethodRect = inputMethod->GetSessionRect();
|
||||
CalculateAvoidAreaRect(rect, inputMethodRect, avoidArea);
|
||||
if (isKeyboardPanelEnabled_) {
|
||||
WSRect keyboardRect = {0, 0, 0, 0};
|
||||
if (inputMethod && inputMethod->GetKeyboardPanelSession()) {
|
||||
keyboardRect = inputMethod->GetKeyboardPanelSession()->GetSessionRect();
|
||||
}
|
||||
CalculateAvoidAreaRect(rect, keyboardRect, avoidArea);
|
||||
} else {
|
||||
WSRect inputMethodRect = inputMethod->GetSessionRect();
|
||||
CalculateAvoidAreaRect(rect, inputMethodRect, avoidArea);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@ -896,6 +961,9 @@ void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
|
||||
void SceneSession::GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea)
|
||||
{
|
||||
if (isDisplayStatusBarTemporarily_.load()) {
|
||||
return;
|
||||
}
|
||||
if (Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING ||
|
||||
Session::GetWindowMode() == WindowMode::WINDOW_MODE_PIP) {
|
||||
return;
|
||||
@ -1166,16 +1234,19 @@ WSError SceneSession::TransferPointerEvent(const std::shared_ptr<MMI::PointerEve
|
||||
}
|
||||
|
||||
auto windowType = property->GetWindowType();
|
||||
if (property->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING &&
|
||||
(WindowHelper::IsMainWindow(windowType) || WindowHelper::IsSubWindow(windowType)) &&
|
||||
property->GetMaximizeMode() != MaximizeMode::MODE_AVOID_SYSTEM_BAR) {
|
||||
bool isWindowModeFloating = property->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING;
|
||||
bool isMainWindow = WindowHelper::IsMainWindow(windowType);
|
||||
bool isSubWindow = WindowHelper::IsSubWindow(windowType);
|
||||
bool isDialog = WindowHelper::IsDialogWindow(windowType);
|
||||
bool isMaxModeAvoidSysBar = property->GetMaximizeMode() == MaximizeMode::MODE_AVOID_SYSTEM_BAR;
|
||||
if (isWindowModeFloating && (isMainWindow || isSubWindow || isDialog) &&
|
||||
!isMaxModeAvoidSysBar) {
|
||||
if (CheckDialogOnForeground() && isPointDown) {
|
||||
HandlePointDownDialog();
|
||||
pointerEvent->MarkProcessed();
|
||||
TLOGI(WmsLogTag::WMS_DIALOG, "There is dialog window foreground");
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (!moveDragController_) {
|
||||
WLOGE("moveDragController_ is null");
|
||||
return Session::TransferPointerEvent(pointerEvent, needNotifyClient);
|
||||
@ -1283,10 +1354,15 @@ bool SceneSession::IsDecorEnable() const
|
||||
return false;
|
||||
}
|
||||
auto windowType = property->GetWindowType();
|
||||
return (WindowHelper::IsMainWindow(windowType) ||
|
||||
(WindowHelper::IsSubWindow(windowType) && property->IsDecorEnable())) &&
|
||||
systemConfig_.isSystemDecorEnable_ &&
|
||||
WindowHelper::IsWindowModeSupported(systemConfig_.decorModeSupportInfo_, property->GetWindowMode());
|
||||
bool isMainWindow = WindowHelper::IsMainWindow(windowType);
|
||||
bool isSubWindow = WindowHelper::IsSubWindow(windowType);
|
||||
bool isDialogWindow = WindowHelper::IsDialogWindow(windowType);
|
||||
bool isValidWindow = isMainWindow ||
|
||||
((isSubWindow || isDialogWindow) && property->IsDecorEnable());
|
||||
bool isWindowModeSupported = WindowHelper::IsWindowModeSupported(
|
||||
systemConfig_.decorModeSupportInfo_, property->GetWindowMode());
|
||||
bool enable = isValidWindow && systemConfig_.isSystemDecorEnable_ && isWindowModeSupported;
|
||||
return enable;
|
||||
}
|
||||
|
||||
std::string SceneSession::GetRatioPreferenceKey()
|
||||
@ -1390,7 +1466,6 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
|
||||
void SceneSession::SetMoveDragCallback()
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (moveDragController_) {
|
||||
MoveDragCallback callBack = [this](const SizeChangeReason& reason) {
|
||||
this->OnMoveDragCallback(reason);
|
||||
@ -1401,11 +1476,6 @@ void SceneSession::SetMoveDragCallback()
|
||||
|
||||
void SceneSession::OnMoveDragCallback(const SizeChangeReason& reason)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (!moveDragController_) {
|
||||
WLOGE("moveDragController_ is null");
|
||||
return;
|
||||
}
|
||||
WSRect rect = moveDragController_->GetTargetRect();
|
||||
WLOGFD("OnMoveDragCallback rect: [%{public}d, %{public}d, %{public}u, %{public}u], reason : %{public}d",
|
||||
rect.posX_, rect.posY_, rect.width_, rect.height_, reason);
|
||||
@ -1420,6 +1490,11 @@ void SceneSession::OnMoveDragCallback(const SizeChangeReason& reason)
|
||||
UpdateRect(rect, reason);
|
||||
}
|
||||
if (reason == SizeChangeReason::DRAG_END) {
|
||||
if (!SessionHelper::IsEmptyRect(GetRestoringRectForKeyboard())) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is moved and reset restoringRectForKeyboard_");
|
||||
WSRect restoringRect = {0, 0, 0, 0};
|
||||
SetRestoringRectForKeyboard(restoringRect);
|
||||
}
|
||||
NotifySessionRectChange(rect, reason);
|
||||
OnSessionEvent(SessionEvent::EVENT_END_MOVE);
|
||||
}
|
||||
@ -1480,6 +1555,10 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect)
|
||||
WLOGFD("subwindow setSurfaceBounds");
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsDialogWindow(GetWindowType()) && surfaceNode_) {
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "dialogWindow setSurfaceBounds");
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else {
|
||||
WLOGE("SetSurfaceBounds surfaceNode is null!");
|
||||
}
|
||||
@ -1707,7 +1786,6 @@ WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
|
||||
void SceneSession::SetWindowAnimationFlag(bool needDefaultAnimationFlag)
|
||||
{
|
||||
needDefaultAnimationFlag_ = needDefaultAnimationFlag;
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ && sessionChangeCallback_->onWindowAnimationFlagChange_) {
|
||||
sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag);
|
||||
}
|
||||
@ -1733,7 +1811,6 @@ bool SceneSession::IsAppSession() const
|
||||
void SceneSession::NotifyIsCustomAnimationPlaying(bool isPlaying)
|
||||
{
|
||||
WLOGFI("id %{public}d %{public}u", GetPersistentId(), isPlaying);
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->onIsCustomAnimationPlaying_) {
|
||||
sessionChangeCallback_->onIsCustomAnimationPlaying_(isPlaying);
|
||||
}
|
||||
@ -1807,7 +1884,6 @@ void SceneSession::NotifyTouchOutside()
|
||||
WLOGFD("Notify sessionStage TouchOutside");
|
||||
sessionStage_->NotifyTouchOutside();
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ && sessionChangeCallback_->OnTouchOutside_) {
|
||||
WLOGFD("Notify sessionChangeCallback TouchOutside");
|
||||
sessionChangeCallback_->OnTouchOutside_();
|
||||
@ -1825,7 +1901,6 @@ void SceneSession::NotifyWindowVisibility()
|
||||
|
||||
bool SceneSession::CheckOutTouchOutsideRegister()
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ && sessionChangeCallback_->OnTouchOutside_) {
|
||||
return true;
|
||||
}
|
||||
@ -1836,7 +1911,6 @@ void SceneSession::SetRequestedOrientation(Orientation orientation)
|
||||
{
|
||||
WLOGFI("id: %{public}d orientation: %{public}u", GetPersistentId(), static_cast<uint32_t>(orientation));
|
||||
GetSessionProperty()->SetRequestedOrientation(orientation);
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ && sessionChangeCallback_->OnRequestedOrientationChange_) {
|
||||
sessionChangeCallback_->OnRequestedOrientationChange_(static_cast<uint32_t>(orientation));
|
||||
}
|
||||
@ -1851,7 +1925,6 @@ void SceneSession::NotifyForceHideChange(bool hide)
|
||||
return;
|
||||
}
|
||||
property->SetForceHide(hide);
|
||||
std::shared_lock<std::shared_mutex> lock(sessionChangeCallbackMutex_);
|
||||
if (sessionChangeCallback_ && sessionChangeCallback_->OnForceHideChange_) {
|
||||
sessionChangeCallback_->OnForceHideChange_(hide);
|
||||
}
|
||||
@ -1912,13 +1985,11 @@ void SceneSession::SetAbilitySessionInfo(std::shared_ptr<AppExecFwk::AbilityInfo
|
||||
|
||||
void SceneSession::SetSelfToken(sptr<IRemoteObject> selfToken)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(selfTokenMutex_);
|
||||
selfToken_ = selfToken;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> SceneSession::GetSelfToken() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(selfTokenMutex_);
|
||||
return selfToken_;
|
||||
}
|
||||
|
||||
@ -2205,6 +2276,16 @@ void SceneSession::SetLastSafeRect(WSRect rect)
|
||||
return;
|
||||
}
|
||||
|
||||
WSRect SceneSession::GetRestoringRectForKeyboard() const
|
||||
{
|
||||
return restoringRectForKeyboard_;
|
||||
}
|
||||
|
||||
void SceneSession::SetRestoringRectForKeyboard(WSRect rect)
|
||||
{
|
||||
restoringRectForKeyboard_ = rect;
|
||||
}
|
||||
|
||||
bool SceneSession::AddSubSession(const sptr<SceneSession>& subSession)
|
||||
{
|
||||
if (subSession == nullptr) {
|
||||
@ -2293,7 +2374,6 @@ std::vector<sptr<SceneSession>> SceneSession::GetSubSession() const
|
||||
WSRect SceneSession::GetSessionTargetRect() const
|
||||
{
|
||||
WSRect rect;
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (moveDragController_) {
|
||||
rect = moveDragController_->GetTargetRect();
|
||||
} else {
|
||||
@ -2304,7 +2384,6 @@ WSRect SceneSession::GetSessionTargetRect() const
|
||||
|
||||
void SceneSession::SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (moveDragController_) {
|
||||
moveDragController_->SetWindowDragHotAreaFunc(func);
|
||||
}
|
||||
@ -2397,7 +2476,6 @@ bool SceneSession::IsDirtyWindow()
|
||||
|
||||
void SceneSession::NotifyUILostFocus()
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
if (moveDragController_) {
|
||||
moveDragController_->OnLostFocus();
|
||||
}
|
||||
@ -2455,60 +2533,42 @@ void SceneSession::SetIsStartMoving(const bool startMoving)
|
||||
isStartMoving_.store(startMoving);
|
||||
}
|
||||
|
||||
bool SceneSession::ShouldHideNonSecureWindows() const
|
||||
{
|
||||
return IsSessionForeground() && (shouldHideNonSecureWindows_.load() || !secureExtSessionSet_.empty());
|
||||
}
|
||||
|
||||
void SceneSession::SetShouldHideNonSecureWindows(bool shouldHide)
|
||||
{
|
||||
shouldHideNonSecureWindows_.store(shouldHide);
|
||||
}
|
||||
|
||||
WSError SceneSession::AddOrRemoveSecureExtSession(int32_t persistentId, bool shouldHide)
|
||||
void SceneSession::CalculateCombinedExtWindowFlags()
|
||||
{
|
||||
auto task = [weakThis = wptr(this), persistentId, shouldHide]() {
|
||||
auto session = weakThis.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "session is nullptr");
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
|
||||
auto& sessionSet = session->secureExtSessionSet_;
|
||||
if (shouldHide) {
|
||||
sessionSet.insert(persistentId);
|
||||
} else {
|
||||
sessionSet.erase(persistentId);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
return PostSyncTask(task, "AddOrRemoveSecureExtSession");
|
||||
// Only correct when each flag is true when active, and once a uiextension is active, the host is active
|
||||
combinedExtWindowFlags_.bitData = 0;
|
||||
for (const auto& iter: extWindowFlagsMap_) {
|
||||
combinedExtWindowFlags_.bitData |= iter.second.bitData;
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSession::UpdateExtWindowFlags(int32_t extPersistentId, uint32_t extWindowFlags)
|
||||
void SceneSession::UpdateExtWindowFlags(int32_t extPersistentId, const ExtensionWindowFlags& extWindowFlags,
|
||||
const ExtensionWindowFlags& extWindowActions)
|
||||
{
|
||||
auto iter = extWindowFlagsMap_.find(extPersistentId);
|
||||
if (iter == extWindowFlagsMap_.end()) {
|
||||
extWindowFlagsMap_.insert({ extPersistentId, extWindowFlags });
|
||||
// Each flag is false when inactive, 0 means all flags are inactive
|
||||
auto oldFlags = iter != extWindowFlagsMap_.end() ? iter->second : ExtensionWindowFlags();
|
||||
ExtensionWindowFlags newFlags((extWindowFlags.bitData & extWindowActions.bitData) |
|
||||
(oldFlags.bitData & ~extWindowActions.bitData));
|
||||
if (newFlags.bitData == 0) {
|
||||
extWindowFlagsMap_.erase(extPersistentId);
|
||||
} else {
|
||||
extWindowFlagsMap_[iter->first] = extWindowFlags;
|
||||
extWindowFlagsMap_[extPersistentId] = newFlags;
|
||||
}
|
||||
CalculateCombinedExtWindowFlags();
|
||||
}
|
||||
bool SceneSession::IsExtWindowHasWaterMarkFlag()
|
||||
|
||||
ExtensionWindowFlags SceneSession::GetCombinedExtWindowFlags() const
|
||||
{
|
||||
bool isExtWindowHasWaterMarkFlag = false;
|
||||
for (const auto& iter: extWindowFlagsMap_) {
|
||||
auto& extWindowFlags = iter.second;
|
||||
if (!extWindowFlags) {
|
||||
continue;
|
||||
}
|
||||
if (extWindowFlags & static_cast<uint32_t>(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)) {
|
||||
isExtWindowHasWaterMarkFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isExtWindowHasWaterMarkFlag;
|
||||
auto combinedExtWindowFlags = combinedExtWindowFlags_;
|
||||
combinedExtWindowFlags.hideNonSecureWindowsFlag = IsSessionForeground() &&
|
||||
(combinedExtWindowFlags.hideNonSecureWindowsFlag || shouldHideNonSecureWindows_.load());
|
||||
return combinedExtWindowFlags;
|
||||
}
|
||||
|
||||
void SceneSession::NotifyDisplayMove(DisplayId from, DisplayId to)
|
||||
@ -2520,16 +2580,16 @@ void SceneSession::NotifyDisplayMove(DisplayId from, DisplayId to)
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSession::RomoveExtWindowFlags(int32_t extPersistentId)
|
||||
void SceneSession::RemoveExtWindowFlags(int32_t extPersistentId)
|
||||
{
|
||||
auto iter = extWindowFlagsMap_.find(extPersistentId);
|
||||
if (iter != extWindowFlagsMap_.end()) {
|
||||
extWindowFlagsMap_.erase(iter);
|
||||
}
|
||||
extWindowFlagsMap_.erase(extPersistentId);
|
||||
CalculateCombinedExtWindowFlags();
|
||||
}
|
||||
|
||||
void SceneSession::ClearExtWindowFlags()
|
||||
{
|
||||
extWindowFlagsMap_.clear();
|
||||
combinedExtWindowFlags_.bitData = 0;
|
||||
}
|
||||
|
||||
WSError SceneSession::UpdateRectChangeListenerRegistered(bool isRegister)
|
||||
@ -2556,4 +2616,15 @@ bool SceneSession::GetForceHideState() const
|
||||
{
|
||||
return forceHideState_;
|
||||
}
|
||||
|
||||
void SceneSession::SetIsDisplayStatusBarTemporarily(bool isTemporary)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "SetIsTemporarily:%{public}u", isTemporary);
|
||||
isDisplayStatusBarTemporarily_.store(isTemporary);
|
||||
}
|
||||
|
||||
bool SceneSession::GetIsDisplayStatusBarTemporarily() const
|
||||
{
|
||||
return isDisplayStatusBarTemporarily_.load();
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <transaction/rs_interfaces.h>
|
||||
#include <transaction/rs_transaction.h>
|
||||
#include <ui/rs_surface_node.h>
|
||||
#include "../../proxy/include/window_info.h"
|
||||
#include "proxy/include/window_info.h"
|
||||
|
||||
#include "anr_manager.h"
|
||||
#include "session_helper.h"
|
||||
@ -50,16 +50,31 @@ constexpr float INNER_ANGLE_VP = 16.0f;
|
||||
constexpr uint32_t MAX_LIFE_CYCLE_TASK_IN_QUEUE = 15;
|
||||
constexpr int64_t LIFE_CYCLE_TASK_EXPIRED_TIME_LIMIT = 350;
|
||||
static bool g_enableForceUIFirst = system::GetParameter("window.forceUIFirst.enabled", "1") == "1";
|
||||
constexpr int64_t STATE_DETECT_DELAYTIME = 3 * 1000;
|
||||
const std::map<SessionState, bool> ATTACH_MAP = {
|
||||
{ SessionState::STATE_DISCONNECT, false },
|
||||
{ SessionState::STATE_CONNECT, false },
|
||||
{ SessionState::STATE_FOREGROUND, true },
|
||||
{ SessionState::STATE_ACTIVE, true },
|
||||
{ SessionState::STATE_INACTIVE, false },
|
||||
{ SessionState::STATE_BACKGROUND, false },
|
||||
};
|
||||
const std::map<SessionState, bool> DETACH_MAP = {
|
||||
{ SessionState::STATE_DISCONNECT, true },
|
||||
{ SessionState::STATE_CONNECT, false },
|
||||
{ SessionState::STATE_FOREGROUND, false },
|
||||
{ SessionState::STATE_ACTIVE, false },
|
||||
{ SessionState::STATE_INACTIVE, true },
|
||||
{ SessionState::STATE_BACKGROUND, true },
|
||||
};
|
||||
static std::string g_deviceType = system::GetParameter("const.product.devicetype", "unknown");
|
||||
std::shared_ptr<AppExecFwk::EventHandler> g_mainHandler;
|
||||
} // namespace
|
||||
|
||||
Session::Session(const SessionInfo& info) : sessionInfo_(info)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(propertyMutex_);
|
||||
property_ = new WindowSessionProperty();
|
||||
property_->SetWindowType(static_cast<WindowType>(info.windowType_));
|
||||
}
|
||||
property_ = new WindowSessionProperty();
|
||||
property_->SetWindowType(static_cast<WindowType>(info.windowType_));
|
||||
if (!g_mainHandler) {
|
||||
auto runner = AppExecFwk::EventRunner::GetMainEventRunner();
|
||||
g_mainHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
@ -404,6 +419,12 @@ void Session::SetSessionState(SessionState state)
|
||||
|
||||
void Session::UpdateSessionState(SessionState state)
|
||||
{
|
||||
// Remove unexecuted detection tasks when the window state changes to background or destroyed.
|
||||
if (state == SessionState::STATE_DISCONNECT ||
|
||||
state == SessionState::STATE_INACTIVE ||
|
||||
state == SessionState::STATE_BACKGROUND) {
|
||||
RemoveWindowDetectTask();
|
||||
}
|
||||
state_ = state;
|
||||
NotifySessionStateChange(state);
|
||||
}
|
||||
@ -579,14 +600,14 @@ bool Session::IsSessionValid() const
|
||||
{
|
||||
if (sessionInfo_.isSystem_) {
|
||||
WLOGFD("session is system, id: %{public}d, name: %{public}s, state: %{public}u",
|
||||
GetPersistentId(), sessionInfo_.bundleName_.c_str(), state_);
|
||||
GetPersistentId(), sessionInfo_.bundleName_.c_str(), GetSessionState());
|
||||
return false;
|
||||
}
|
||||
bool res = state_ > SessionState::STATE_DISCONNECT && state_ < SessionState::STATE_END;
|
||||
if (!res) {
|
||||
if (state_ == SessionState::STATE_DISCONNECT && sessionStage_) {
|
||||
WLOGFI("session is already destroyed or not created! id: %{public}d state: %{public}u",
|
||||
GetPersistentId(), state_);
|
||||
GetPersistentId(), GetSessionState());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@ -799,7 +820,6 @@ __attribute__((no_sanitize("cfi"))) WSError Session::Connect(const sptr<ISession
|
||||
surfaceNode_ = surfaceNode;
|
||||
abilityToken_ = token;
|
||||
systemConfig = systemConfig_;
|
||||
std::shared_lock<std::shared_mutex> lock(propertyMutex_);
|
||||
if (property_ && property_->GetIsNeedUpdateWindowMode() && property) {
|
||||
property->SetIsNeedUpdateWindowMode(true);
|
||||
property->SetWindowMode(property_->GetWindowMode());
|
||||
@ -1032,8 +1052,9 @@ bool Session::GetForegroundInteractiveStatus() const
|
||||
return foregroundInteractiveStatus_.load();
|
||||
}
|
||||
|
||||
void Session::SetAttachState(bool isAttach)
|
||||
void Session::SetAttachState(bool isAttach, WindowMode windowMode)
|
||||
{
|
||||
isAttach_ = isAttach;
|
||||
auto task = [weakThis = wptr(this), isAttach]() {
|
||||
auto session = weakThis.promote();
|
||||
if (session == nullptr) {
|
||||
@ -1042,14 +1063,31 @@ void Session::SetAttachState(bool isAttach)
|
||||
}
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "SetAttachState:%{public}d persistentId:%{public}d", isAttach,
|
||||
session->GetPersistentId());
|
||||
session->isAttach_ = isAttach;
|
||||
if (!session->isAttach_ && session->detachCallback_ != nullptr) {
|
||||
if (isAttach && session->detachCallback_ != nullptr) {
|
||||
TLOGI(WmsLogTag::WMS_LIFE, "Session detach, persistentId:%{public}d", session->GetPersistentId());
|
||||
session->detachCallback_->OnPatternDetach(session->GetPersistentId());
|
||||
session->detachCallback_ = nullptr;
|
||||
}
|
||||
};
|
||||
PostTask(task, "SetAttachState");
|
||||
CreateDetectStateTask(isAttach, windowMode);
|
||||
}
|
||||
|
||||
void Session::CreateDetectStateTask(bool isAttach, WindowMode windowMode)
|
||||
{
|
||||
if (!IsSupportDetectWindow(isAttach)) {
|
||||
return;
|
||||
}
|
||||
if (showRecent_) {
|
||||
return;
|
||||
}
|
||||
if (!ShouldCreateDetectTask(isAttach, windowMode)) {
|
||||
RemoveWindowDetectTask();
|
||||
DetectTaskInfo detectTaskInfo;
|
||||
SetDetectTaskInfo(detectTaskInfo);
|
||||
return;
|
||||
}
|
||||
CreateWindowStateDetectTask(isAttach, windowMode);
|
||||
}
|
||||
|
||||
void Session::RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback)
|
||||
@ -1351,7 +1389,6 @@ void Session::SetParentSession(const sptr<Session>& session)
|
||||
WLOGFW("Session is nullptr");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
parentSession_ = session;
|
||||
TLOGD(WmsLogTag::WMS_SUB, "[WMSDialog][WMSSub]Set parent success, parentId: %{public}d, id: %{public}d",
|
||||
session->GetPersistentId(), GetPersistentId());
|
||||
@ -1359,7 +1396,6 @@ void Session::SetParentSession(const sptr<Session>& session)
|
||||
|
||||
sptr<Session> Session::GetParentSession() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
return parentSession_;
|
||||
}
|
||||
|
||||
@ -1496,15 +1532,19 @@ bool Session::IfNotNeedAvoidKeyBoardForSplit()
|
||||
void Session::HandlePointDownDialog()
|
||||
{
|
||||
auto dialogVec = GetDialogVector();
|
||||
sptr<Session> lastValidDialog = nullptr;
|
||||
for (auto dialog : dialogVec) {
|
||||
if (dialog && (dialog->GetSessionState() == SessionState::STATE_FOREGROUND ||
|
||||
dialog->GetSessionState() == SessionState::STATE_ACTIVE)) {
|
||||
dialog->RaiseToAppTopForPointDown();
|
||||
dialog->PresentFocusIfPointDown();
|
||||
lastValidDialog = dialog;
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "Point main window, raise to top and dialog need focus, "
|
||||
"id: %{public}d, dialogId: %{public}d", GetPersistentId(), dialog->GetPersistentId());
|
||||
}
|
||||
}
|
||||
if (lastValidDialog != nullptr) {
|
||||
lastValidDialog->PresentFocusIfPointDown();
|
||||
}
|
||||
}
|
||||
|
||||
void Session::NotifyPointerEventToRs(int32_t pointAction)
|
||||
@ -1517,14 +1557,10 @@ void Session::NotifyPointerEventToRs(int32_t pointAction)
|
||||
|
||||
WSError Session::HandleSubWindowClick(int32_t action)
|
||||
{
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground()) {
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "Its main window has dialog on foreground, id: %{public}d", GetPersistentId());
|
||||
return WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground()) {
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "Its main window has dialog on foreground, id: %{public}d", GetPersistentId());
|
||||
return WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(propertyMutex_);
|
||||
bool raiseEnabled = property_->GetRaiseEnabled() &&
|
||||
(action == MMI::PointerEvent::POINTER_ACTION_DOWN || action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
|
||||
if (raiseEnabled) {
|
||||
@ -1558,7 +1594,6 @@ WSError Session::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>&
|
||||
return ret;
|
||||
}
|
||||
} else if (GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) {
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground() && isPointDown) {
|
||||
parentSession_->HandlePointDownDialog();
|
||||
if (!IsTopDialog()) {
|
||||
@ -1707,7 +1742,7 @@ std::shared_ptr<Media::PixelMap> Session::Snapshot(const float scaleParam) const
|
||||
void Session::SetSessionStateChangeListenser(const NotifySessionStateChangeFunc& func)
|
||||
{
|
||||
sessionStateChangeFunc_ = func;
|
||||
auto changedState = state_;
|
||||
auto changedState = GetSessionState();
|
||||
if (changedState == SessionState::STATE_ACTIVE) {
|
||||
changedState = SessionState::STATE_FOREGROUND;
|
||||
} else if (changedState == SessionState::STATE_INACTIVE) {
|
||||
@ -1717,7 +1752,7 @@ void Session::SetSessionStateChangeListenser(const NotifySessionStateChangeFunc&
|
||||
}
|
||||
NotifySessionStateChange(changedState);
|
||||
WLOGFD("SetSessionStateChangeListenser, id: %{public}d, state_: %{public}d, changedState: %{public}d",
|
||||
GetPersistentId(), state_, changedState);
|
||||
GetPersistentId(), GetSessionState(), changedState);
|
||||
}
|
||||
|
||||
void Session::SetBufferAvailableChangeListener(const NotifyBufferAvailableChangeFunc& func)
|
||||
@ -1935,7 +1970,6 @@ WSError Session::UpdateWindowMode(WindowMode mode)
|
||||
{
|
||||
WLOGFD("Session update window mode, id: %{public}d, mode: %{public}d", GetPersistentId(),
|
||||
static_cast<int32_t>(mode));
|
||||
std::shared_lock<std::shared_mutex> lock(propertyMutex_);
|
||||
if (property_ == nullptr) {
|
||||
WLOGFD("id: %{public}d property is nullptr", persistentId_);
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
@ -1943,7 +1977,7 @@ WSError Session::UpdateWindowMode(WindowMode mode)
|
||||
|
||||
if (state_ == SessionState::STATE_END) {
|
||||
WLOGFI("session is already destroyed or property is nullptr! id: %{public}d state: %{public}u",
|
||||
GetPersistentId(), state_);
|
||||
GetPersistentId(), GetSessionState());
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
} else if (state_ == SessionState::STATE_DISCONNECT) {
|
||||
property_->SetWindowMode(mode);
|
||||
@ -2216,7 +2250,6 @@ WSError Session::UpdateMaximizeMode(bool isMaximize)
|
||||
} else if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
mode = MaximizeMode::MODE_FULL_FILL;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(propertyMutex_);
|
||||
property_->SetMaximizeMode(mode);
|
||||
return sessionStage_->UpdateMaximizeMode(mode);
|
||||
}
|
||||
@ -2254,7 +2287,17 @@ uint32_t Session::GetUINodeId() const
|
||||
|
||||
void Session::SetShowRecent(bool showRecent)
|
||||
{
|
||||
bool isAttach = GetAttachState();
|
||||
if (!IsSupportDetectWindow(isAttach) ||
|
||||
!ShouldCreateDetectTaskInRecent(showRecent, showRecent_, isAttach)) {
|
||||
showRecent_ = showRecent;
|
||||
return;
|
||||
}
|
||||
showRecent_ = showRecent;
|
||||
WindowMode windowMode = GetWindowMode();
|
||||
if (!showRecent_ && ShouldCreateDetectTask(isAttach, windowMode)) {
|
||||
CreateWindowStateDetectTask(isAttach, windowMode);
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::GetShowRecent() const
|
||||
@ -2262,6 +2305,129 @@ bool Session::GetShowRecent() const
|
||||
return showRecent_;
|
||||
}
|
||||
|
||||
bool Session::GetAttachState() const
|
||||
{
|
||||
return isAttach_;
|
||||
}
|
||||
|
||||
DetectTaskInfo Session::GetDetectTaskInfo() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(detectTaskInfoMutex_);
|
||||
return detectTaskInfo_;
|
||||
}
|
||||
|
||||
void Session::SetDetectTaskInfo(const DetectTaskInfo& detectTaskInfo)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(detectTaskInfoMutex_);
|
||||
detectTaskInfo_ = detectTaskInfo;
|
||||
}
|
||||
|
||||
bool Session::IsStateMatch(bool isAttach) const
|
||||
{
|
||||
return isAttach ? ATTACH_MAP.at(GetSessionState()) : DETACH_MAP.at(GetSessionState());
|
||||
}
|
||||
|
||||
bool Session::IsSupportDetectWindow(bool isAttach)
|
||||
{
|
||||
bool isPc = g_deviceType == "2in1";
|
||||
bool isPhone = g_deviceType == "phone";
|
||||
if (!isPc && !isPhone) {
|
||||
WLOGFI("Window state detect not support: device type not support, persistentId:%{public}d", persistentId_);
|
||||
return false;
|
||||
}
|
||||
if (isScreenLockedCallback_ && isScreenLockedCallback_()) {
|
||||
WLOGFI("Window state detect not support: Screen is locked, persistentId:%{public}d", persistentId_);
|
||||
return false;
|
||||
}
|
||||
if (!SessionHelper::IsMainWindow(GetWindowType())) {
|
||||
WLOGFI("Window state detect not support: Only support mainwindow, "
|
||||
"persistentId:%{public}d", persistentId_);
|
||||
return false;
|
||||
}
|
||||
// Only detecting cold start scenarios on PC
|
||||
if (isPc && (!isAttach || state_ != SessionState::STATE_DISCONNECT)) {
|
||||
RemoveWindowDetectTask();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Session::RemoveWindowDetectTask()
|
||||
{
|
||||
if (handler_) {
|
||||
handler_->RemoveTask(GetWindowDetectTaskName());
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const
|
||||
{
|
||||
// Create detect task directy without pre-exiting tasks.
|
||||
if (GetDetectTaskInfo().taskState == DetectTaskState::NO_TASK) {
|
||||
return true;
|
||||
}
|
||||
// If the taskState matches the attach detach state, it will be create detect task directly.
|
||||
if ((GetDetectTaskInfo().taskState == DetectTaskState::ATTACH_TASK && isAttach) ||
|
||||
(GetDetectTaskInfo().taskState == DetectTaskState::DETACH_TASK && !isAttach)) {
|
||||
return true;
|
||||
} else {
|
||||
// Do not create detect task if the windowMode changes.
|
||||
return GetDetectTaskInfo().taskWindowMode == windowMode;
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const
|
||||
{
|
||||
if (newShowRecent) {
|
||||
return false;
|
||||
}
|
||||
return oldShowRecent ? isAttach : false;
|
||||
}
|
||||
|
||||
void Session::RegisterIsScreenLockedCallback(const std::function<bool()>& callback)
|
||||
{
|
||||
isScreenLockedCallback_ = callback;
|
||||
}
|
||||
|
||||
std::string Session::GetWindowDetectTaskName() const
|
||||
{
|
||||
return "wms:WindowStateDetect" + std::to_string(persistentId_);
|
||||
}
|
||||
|
||||
void Session::CreateWindowStateDetectTask(bool isAttach, WindowMode windowMode)
|
||||
{
|
||||
if (!handler_) {
|
||||
return;
|
||||
}
|
||||
std::string taskName = GetWindowDetectTaskName();
|
||||
RemoveWindowDetectTask();
|
||||
auto detectTask = [weakThis = wptr(this), isAttach]() {
|
||||
auto session = weakThis.promote();
|
||||
if (session == nullptr) {
|
||||
if (isAttach) {
|
||||
WLOGFE("Window attach state and session"
|
||||
"state mismatch, session is nullptr, attach:%{public}d", isAttach);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Skip state detect when screen locked.
|
||||
if (session->isScreenLockedCallback_ && !session->isScreenLockedCallback_()) {
|
||||
if (!session->IsStateMatch(isAttach)) {
|
||||
WLOGFE("Window attach state and session state mismatch, "
|
||||
"attach:%{public}d, sessioniState:%{public}d, persistenId:%{public}d, bundleName:%{public}s",
|
||||
isAttach, static_cast<uint32_t>(session->GetSessionState()),
|
||||
session->GetPersistentId(), session->GetSessionInfo().bundleName_.c_str());
|
||||
}
|
||||
}
|
||||
DetectTaskInfo detectTaskInfo;
|
||||
session->SetDetectTaskInfo(detectTaskInfo);
|
||||
};
|
||||
handler_->PostTask(detectTask, taskName, STATE_DETECT_DELAYTIME);
|
||||
DetectTaskInfo detectTaskInfo;
|
||||
detectTaskInfo.taskWindowMode = windowMode;
|
||||
detectTaskInfo.taskState = isAttach ? DetectTaskState::ATTACH_TASK : DetectTaskState::DETACH_TASK;
|
||||
SetDetectTaskInfo(detectTaskInfo);
|
||||
}
|
||||
|
||||
void Session::SetBufferAvailable(bool bufferAvailable)
|
||||
{
|
||||
WLOGFI("SetBufferAvailable: %{public}d", bufferAvailable);
|
||||
|
@ -30,9 +30,10 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SubSes
|
||||
SubSession::SubSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback)
|
||||
: SceneSession(info, specificCallback)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(moveDragControllerMutex_);
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
if (moveDragController_ != nullptr && specificCallback != nullptr &&
|
||||
specificCallback->onWindowInputPidChangeCallback_ != nullptr) {
|
||||
moveDragController_->SetNotifyWindowPidChangeCallback(specificCallback->onWindowInputPidChangeCallback_);
|
||||
}
|
||||
SetMoveDragCallback();
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "Create SubSession");
|
||||
@ -114,7 +115,6 @@ WSError SubSession::Reconnect(const sptr<ISessionStage>& sessionStage, const spt
|
||||
WSError SubSession::ProcessPointDownSession(int32_t posX, int32_t posY)
|
||||
{
|
||||
const auto& id = GetPersistentId();
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
WLOGFI("id: %{public}d, type: %{public}d", id, GetWindowType());
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground()) {
|
||||
WLOGFI("Has dialog foreground, id: %{public}d, type: %{public}d", id, GetWindowType());
|
||||
@ -136,7 +136,6 @@ WSError SubSession::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEv
|
||||
WLOGFE("KeyEvent is nullptr");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground()) {
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "Its main window has dialog on foreground, not transfer pointer event");
|
||||
return WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
@ -148,7 +147,6 @@ WSError SubSession::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEv
|
||||
|
||||
int32_t SubSession::GetMissionId() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
return parentSession_ != nullptr ? parentSession_->GetPersistentId() : SceneSession::GetMissionId();
|
||||
}
|
||||
|
||||
@ -170,7 +168,7 @@ bool SubSession::CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEve
|
||||
sessionState != SessionState::STATE_ACTIVE &&
|
||||
action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) {
|
||||
WLOGFW("Current Session Info: [persistentId: %{public}d, "
|
||||
"state: %{public}d, action:%{public}d]", GetPersistentId(), state_, action);
|
||||
"state: %{public}d, action:%{public}d]", GetPersistentId(), GetSessionState(), action);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -20,7 +20,8 @@
|
||||
#include "session/host/include/session.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
#include "parameters.h"
|
||||
#include "pointer_event.h"
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SystemSession" };
|
||||
@ -33,6 +34,11 @@ SystemSession::SystemSession(const SessionInfo& info, const sptr<SpecificSession
|
||||
: SceneSession(info, specificCallback)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "Create SystemSession");
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
if (moveDragController_ != nullptr && specificCallback != nullptr &&
|
||||
specificCallback->onWindowInputPidChangeCallback_ != nullptr) {
|
||||
moveDragController_->SetNotifyWindowPidChangeCallback(specificCallback_->onWindowInputPidChangeCallback_);
|
||||
}
|
||||
SetMoveDragCallback();
|
||||
}
|
||||
|
||||
@ -195,7 +201,6 @@ WSError SystemSession::ProcessPointDownSession(int32_t posX, int32_t posY)
|
||||
const auto& id = GetPersistentId();
|
||||
const auto& type = GetWindowType();
|
||||
WLOGFI("id: %{public}d, type: %{public}d", id, type);
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground()) {
|
||||
WLOGFI("Parent has dialog foreground, id: %{public}d, type: %{public}d", id, type);
|
||||
parentSession_->HandlePointDownDialog();
|
||||
@ -223,7 +228,6 @@ WSError SystemSession::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& ke
|
||||
if (keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_BACK) {
|
||||
return WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
if (parentSession_ && parentSession_->CheckDialogOnForeground() &&
|
||||
!IsTopDialog()) {
|
||||
return WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
@ -273,7 +277,6 @@ WSError SystemSession::NotifyClientToUpdateRect(std::shared_ptr<RSTransaction> r
|
||||
|
||||
int32_t SystemSession::GetMissionId() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(parentSessionMutex_);
|
||||
return parentSession_ != nullptr ? parentSession_->GetPersistentId() : SceneSession::GetMissionId();
|
||||
}
|
||||
|
||||
@ -299,7 +302,7 @@ bool SystemSession::CheckKeyEventDispatch(const std::shared_ptr<MMI::KeyEvent>&
|
||||
state_ != SessionState::STATE_ACTIVE)) {
|
||||
TLOGE(WmsLogTag::WMS_DIALOG, "Dialog's parent info : [persistentId: %{publicd}d, state:%{public}d];"
|
||||
"Dialog info:[persistentId: %{publicd}d, state:%{public}d]",
|
||||
parentSession->GetPersistentId(), parentSessionState, GetPersistentId(), state_);
|
||||
parentSession->GetPersistentId(), parentSessionState, GetPersistentId(), GetSessionState());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -313,6 +316,31 @@ bool SystemSession::NeedSystemPermission(WindowType type)
|
||||
type == WindowType::WINDOW_TYPE_PIP);
|
||||
}
|
||||
|
||||
bool SystemSession::CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const
|
||||
{
|
||||
auto sessionState = GetSessionState();
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1";
|
||||
bool isDialog = WindowHelper::IsDialogWindow(GetWindowType());
|
||||
if (isPC && isDialog && sessionState != SessionState::STATE_FOREGROUND &&
|
||||
sessionState != SessionState::STATE_ACTIVE &&
|
||||
action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) {
|
||||
WLOGFW("CheckPointerEventDispatch false, Current Session Info: [persistentId: %{public}d, "
|
||||
"state: %{public}d, action:%{public}d]", GetPersistentId(), GetSessionState(), action);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SystemSession::UpdatePointerArea(const WSRect& rect)
|
||||
{
|
||||
auto property = GetSessionProperty();
|
||||
if (!(property->IsDecorEnable() && GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
return;
|
||||
}
|
||||
Session::UpdatePointerArea(rect);
|
||||
}
|
||||
|
||||
void SystemSession::RectCheck(uint32_t curWidth, uint32_t curHeight)
|
||||
{
|
||||
uint32_t minWidth = MIN_SYSTEM_WINDOW_WIDTH;
|
||||
|
@ -216,9 +216,15 @@ WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const spt
|
||||
}
|
||||
Rect preRect = property->GetWindowRect();
|
||||
Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() };
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "updateRect when connect."
|
||||
"preRect:[%{public}d, %{public}d, %{public}u, %{public}u]"
|
||||
"rect:[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
preRect.posX_, preRect.posY_, preRect.width_, preRect.height_,
|
||||
rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
if (preRect.IsUninitializedRect() && !rect.IsUninitializedRect()) {
|
||||
property->SetWindowRect(rect);
|
||||
}
|
||||
property->SetCollaboratorType(reply.ReadInt32());
|
||||
}
|
||||
int32_t ret = reply.ReadInt32();
|
||||
return static_cast<WSError>(ret);
|
||||
@ -1145,4 +1151,24 @@ void SessionProxy::SetCallingSessionId(const uint32_t callingSessionId)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void SessionProxy::SetCustomDecorHeight(int32_t height)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "writeInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(height)) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Write height failed.");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CUSTOM_DECOR_HEIGHT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -101,6 +101,8 @@ const std::map<uint32_t, SessionStubFunc> SessionStub::stubFuncMap_ {
|
||||
&SessionStub::HandleSetKeyboardSessionGravity),
|
||||
std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CALLING_SESSION_ID),
|
||||
&SessionStub::HandleSetCallingSessionId),
|
||||
std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CUSTOM_DECOR_HEIGHT),
|
||||
&SessionStub::HandleSetCustomDecorHeight),
|
||||
|
||||
std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_ABILITY_RESULT),
|
||||
&SessionStub::HandleTransferAbilityResult),
|
||||
@ -251,6 +253,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply)
|
||||
reply.WriteInt32(winRect.posY_);
|
||||
reply.WriteUint32(winRect.width_);
|
||||
reply.WriteUint32(winRect.height_);
|
||||
reply.WriteInt32(property->GetCollaboratorType());
|
||||
}
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
@ -601,8 +604,8 @@ int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply)
|
||||
int SessionStub::HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGFD("HandleProcessPointDownSession!");
|
||||
uint32_t posX = data.ReadInt32();
|
||||
uint32_t posY = data.ReadInt32();
|
||||
int32_t posX = data.ReadInt32();
|
||||
int32_t posY = data.ReadInt32();
|
||||
WSError errCode = ProcessPointDownSession(posX, posY);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
@ -648,4 +651,12 @@ int SessionStub::HandleSetCallingSessionId(MessageParcel& data, MessageParcel& r
|
||||
reply.WriteInt32(static_cast<int32_t>(WSError::WS_OK));
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStub::HandleSetCustomDecorHeight(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "run HandleSetCustomDecorHeight!");
|
||||
int32_t height = data.ReadInt32();
|
||||
SetCustomDecorHeight(height);
|
||||
return ERR_NONE;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -61,6 +61,7 @@ ohos_shared_library("scene_session_manager") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -140,8 +141,8 @@ ohos_shared_library("scene_session_manager") {
|
||||
|
||||
defines = []
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_memmgr_plugin)) {
|
||||
external_deps += [ "memmgr_plugin:memmgrclient" ]
|
||||
defined(global_parts_info.resourceschedule_memmgr_override)) {
|
||||
external_deps += [ "memmgr_override:memmgrclient" ]
|
||||
defines += [ "MEMMGR_WINDOW_ENABLE" ]
|
||||
}
|
||||
|
||||
@ -196,6 +197,7 @@ ohos_shared_library("screen_session_manager") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -297,6 +299,7 @@ ohos_shared_library("session_manager") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
@ -347,6 +350,7 @@ ohos_shared_library("session_manager_lite") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcal_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
|
@ -64,6 +64,8 @@ namespace AncoConsts {
|
||||
class SceneSession;
|
||||
class AccessibilityWindowInfo;
|
||||
using NotifyCreateSystemSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
|
||||
using NotifyCreateKeyboardSessionFunc = std::function<void(const sptr<SceneSession>& keyboardSession,
|
||||
const sptr<SceneSession>& panelSession)>;
|
||||
using NotifyCreateSubSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
|
||||
using NotifyRecoverSceneSessionFunc =
|
||||
std::function<void(const sptr<SceneSession>& session, const SessionInfo& sessionInfo)>;
|
||||
@ -143,6 +145,7 @@ public:
|
||||
const sptr<IRemoteObject>& callback) override;
|
||||
WMError UpdateSessionProperty(const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action) override;
|
||||
void SetCreateSystemSessionListener(const NotifyCreateSystemSessionFunc& func);
|
||||
void SetCreateKeyboardSessionListener(const NotifyCreateKeyboardSessionFunc& func);
|
||||
void SetStatusBarEnabledChangeListener(const ProcessStatusBarEnabledChangeFunc& func);
|
||||
void SetStartUIAbilityErrorListener(const ProcessStartUIAbilityErrorFunc& func);
|
||||
void SetRecoverSceneSessionListener(const NotifyRecoverSceneSessionFunc& func);
|
||||
@ -173,7 +176,7 @@ public:
|
||||
void RequestAllAppSessionUnfocus();
|
||||
WSError UpdateFocus(int32_t persistentId, bool isFocused);
|
||||
WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode);
|
||||
WSError SendTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex);
|
||||
WSError SendTouchEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex);
|
||||
void SetScreenLocked(const bool isScreenLocked);
|
||||
bool IsScreenLocked() const;
|
||||
WSError RaiseWindowToTop(int32_t persistentId) override;
|
||||
@ -292,12 +295,12 @@ public:
|
||||
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
|
||||
int32_t parentId) override;
|
||||
WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override;
|
||||
WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override;
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
|
||||
uint32_t extWindowActions) override;
|
||||
void CheckSceneZOrder();
|
||||
int32_t StartUIAbilityBySCB(sptr<AAFwk::SessionInfo>& abilitySessionInfo);
|
||||
int32_t StartUIAbilityBySCB(sptr<SceneSession>& sceneSessions);
|
||||
int32_t ChangeUIAbilityVisibilityBySCB(sptr<SceneSession>& sceneSessions, bool visibility);
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override;
|
||||
WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override;
|
||||
int32_t ReclaimPurgeableCleanMem();
|
||||
WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus) override;
|
||||
@ -310,11 +313,16 @@ public:
|
||||
std::shared_ptr<TaskScheduler> GetTaskScheduler() {return taskScheduler_;};
|
||||
WSError SwitchFreeMultiWindow(bool enable);
|
||||
const SystemSessionConfig& GetSystemSessionConfig() const;
|
||||
void UpdateLastDownEventDeviceId(int32_t deviceId);
|
||||
int32_t GetCustomDecorHeight(int32_t persistentId);
|
||||
|
||||
protected:
|
||||
SceneSessionManager();
|
||||
virtual ~SceneSessionManager() = default;
|
||||
|
||||
private:
|
||||
bool isKeyboardPanelEnabled_ = false;
|
||||
int32_t lastDownEventDeviceId_ { -1 };
|
||||
void Init();
|
||||
void InitScheduleUtils();
|
||||
void RegisterAppListener();
|
||||
@ -326,6 +334,7 @@ private:
|
||||
void ConfigDefaultKeyboardAnimation();
|
||||
bool ConfigAppWindowCornerRadius(const WindowSceneConfig::ConfigItem& item, float& out);
|
||||
bool ConfigAppWindowShadow(const WindowSceneConfig::ConfigItem& shadowConfig, WindowShadowConfig& outShadow);
|
||||
void ConfigSystemUIStatusBar(const WindowSceneConfig::ConfigItem& statusBarConfig);
|
||||
void ConfigDecor(const WindowSceneConfig::ConfigItem& decorConfig, bool mainConfig = true);
|
||||
void ConfigWindowAnimation(const WindowSceneConfig::ConfigItem& windowAnimationConfig);
|
||||
void ConfigStartingWindowAnimation(const WindowSceneConfig::ConfigItem& startingWindowConfig);
|
||||
@ -474,6 +483,7 @@ private:
|
||||
std::map<int32_t, std::map<AvoidAreaType, AvoidArea>> lastUpdatedAvoidArea_;
|
||||
|
||||
NotifyCreateSystemSessionFunc createSystemSessionFunc_;
|
||||
NotifyCreateKeyboardSessionFunc createKeyboardSessionFunc_;
|
||||
std::map<int32_t, NotifyCreateSubSessionFunc> createSubSessionFuncMap_;
|
||||
std::map<int32_t, std::vector<sptr<SceneSession>>> recoverSubSessionCacheMap_;
|
||||
bool recoveringFinished_ = false;
|
||||
@ -525,6 +535,8 @@ private:
|
||||
bool isReportTaskStart_ = false;
|
||||
std::vector<std::pair<uint64_t, WindowVisibilityState> > lastVisibleData_;
|
||||
RSInterfaces& rsInterface_;
|
||||
void ClearUnrecoveredSessions(const std::vector<int32_t>& recoveredPersistentIds);
|
||||
SessionInfo RecoverSessionInfo(const sptr<WindowSessionProperty>& property);
|
||||
bool isNeedRecover(const int32_t persistentId);
|
||||
void RegisterSessionStateChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession);
|
||||
void RegisterSessionInfoChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession);
|
||||
@ -582,6 +594,7 @@ private:
|
||||
void NotifyCreateSpecificSession(sptr<SceneSession> session,
|
||||
sptr<WindowSessionProperty> property, const WindowType& type);
|
||||
sptr<SceneSession> CreateSceneSession(const SessionInfo& sessionInfo, sptr<WindowSessionProperty> property);
|
||||
void CreateKeyboardPanelSession(sptr<SceneSession> keyboardSession);
|
||||
bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState);
|
||||
bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState);
|
||||
WSError GetAppMainSceneSession(sptr<SceneSession>& sceneSession, int32_t persistentId);
|
||||
@ -602,6 +615,7 @@ private:
|
||||
const sptr<WindowSessionProperty>& property);
|
||||
void ProcessBackHomeStatus();
|
||||
bool IsBackHomeStatus();
|
||||
void DeleteStateDetectTask();
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -99,7 +99,6 @@ public:
|
||||
TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
|
||||
TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB,
|
||||
TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION,
|
||||
TRANS_ID_ADD_OR_REMOVE_SECURE_EXT_SESSION,
|
||||
TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS,
|
||||
TRANS_ID_GET_HOST_WINDOW_RECT,
|
||||
TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION_WITH_DETACH_CALLBACK,
|
||||
@ -220,11 +219,8 @@ public:
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
|
||||
uint32_t extWindowActions) override
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ public:
|
||||
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
|
||||
int32_t parentId) override;
|
||||
WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override;
|
||||
WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override;
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override;
|
||||
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
|
||||
uint32_t extWindowActions) override;
|
||||
WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override;
|
||||
WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus) override;
|
||||
WMError GetCallingWindowRect(int32_t persistentId, Rect& rect) override;
|
||||
|
@ -90,7 +90,6 @@ private:
|
||||
int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleAddExtensionWindowStageToSCB(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleAddOrRemoveSecureSession(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleAddOrRemoveSecureExtSession(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetCallingWindowWindowStatus(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -187,15 +187,15 @@ void SceneSessionDirtyManager::UpdateDefaultHotAreas(sptr<SceneSession> sceneSes
|
||||
MMI::Rect touchRect = {
|
||||
.x = -touchOffset,
|
||||
.y = -touchOffset,
|
||||
.width = windowRect.width_ + touchOffset * 2, // 2 : double touchOffset
|
||||
.height = windowRect.height_ + touchOffset * 2 // 2 : double touchOffset
|
||||
.width = static_cast<int>(windowRect.width_ + touchOffset * 2), // 2 : double touchOffset
|
||||
.height = static_cast<int>(windowRect.height_ + touchOffset * 2) // 2 : double touchOffset
|
||||
};
|
||||
|
||||
MMI::Rect pointerRect = {
|
||||
.x = -pointerOffset,
|
||||
.y = -pointerOffset,
|
||||
.width = windowRect.width_ + pointerOffset * 2, // 2 : double pointerOffset
|
||||
.height = windowRect.height_ + pointerOffset * 2 // 2 : double pointerOffset
|
||||
.width = static_cast<int>(windowRect.width_ + pointerOffset * 2), // 2 : double pointerOffset
|
||||
.height = static_cast<int>(windowRect.height_ + pointerOffset * 2) // 2 : double pointerOffset
|
||||
};
|
||||
|
||||
touchHotAreas.emplace_back(touchRect);
|
||||
@ -216,8 +216,8 @@ void SceneSessionDirtyManager::UpdateHotAreas(sptr<SceneSession> sceneSession, s
|
||||
MMI::Rect rect;
|
||||
rect.x = area.posX_;
|
||||
rect.y = area.posY_;
|
||||
rect.width = area.width_;
|
||||
rect.height = area.height_;
|
||||
rect.width = static_cast<int>(area.width_);
|
||||
rect.height = static_cast<int>(area.height_);
|
||||
auto iter = std::find_if(touchHotAreas.begin(), touchHotAreas.end(),
|
||||
[&rect](const MMI::Rect& var) { return rect == var; });
|
||||
if (iter != touchHotAreas.end()) {
|
||||
@ -225,7 +225,7 @@ void SceneSessionDirtyManager::UpdateHotAreas(sptr<SceneSession> sceneSession, s
|
||||
}
|
||||
touchHotAreas.emplace_back(rect);
|
||||
pointerHotAreas.emplace_back(rect);
|
||||
if (touchHotAreas.size() == static_cast<int>(MMI::WindowInfo::MAX_HOTAREA_COUNT)) {
|
||||
if (touchHotAreas.size() == static_cast<u_int32_t>(MMI::WindowInfo::MAX_HOTAREA_COUNT)) {
|
||||
auto sessionid = sceneSession->GetWindowId();
|
||||
WLOGFE("id = %{public}d hotAreas size > %{public}d", sessionid, static_cast<int>(hotAreas.size()));
|
||||
break;
|
||||
@ -332,7 +332,8 @@ std::vector<MMI::WindowInfo> SceneSessionDirtyManager::GetFullWindowInfoList()
|
||||
auto iter = (sceneSessionValue->GetParentPersistentId() == INVALID_SESSION_ID) ?
|
||||
dialogMap.find(sceneSessionValue->GetPersistentId()) :
|
||||
dialogMap.find(sceneSessionValue->GetParentPersistentId());
|
||||
if (iter != dialogMap.end() && iter->second != nullptr) {
|
||||
if (iter != dialogMap.end() && iter->second != nullptr &&
|
||||
sceneSessionValue->GetPersistentId() != iter->second->GetPersistentId()) {
|
||||
windowInfo.agentWindowId = static_cast<int32_t>(iter->second->GetPersistentId());
|
||||
windowInfo.pid = static_cast<int32_t>(iter->second->GetCallingPid());
|
||||
TLOGI(WmsLogTag::WMS_EVENT, "Change agentId, dialogId: %{public}d, parentId: %{public}d"
|
||||
|
@ -257,6 +257,7 @@ void SceneSessionManager::Init()
|
||||
WLOGI("SceneSessionManager init success.");
|
||||
RegisterAppListener();
|
||||
openDebugTrace = std::atoi((system::GetParameter("persist.sys.graphic.openDebugTrace", "0")).c_str()) != 0;
|
||||
isKeyboardPanelEnabled_ = system::GetParameter("persist.sceneboard.keyboardPanel.enabled", "0") == "1";
|
||||
}
|
||||
|
||||
void SceneSessionManager::InitScheduleUtils()
|
||||
@ -297,11 +298,13 @@ void SceneSessionManager::RegisterAppListener()
|
||||
if (appMgrClient_ == nullptr) {
|
||||
WLOGFE("appMgrClient_ is nullptr.");
|
||||
} else {
|
||||
auto flag = static_cast<int32_t>(appMgrClient_->RegisterAppDebugListener(appAnrListener_));
|
||||
if (flag != ERR_OK) {
|
||||
WLOGFE("Register app debug listener failed.");
|
||||
} else {
|
||||
WLOGFI("Register app debug listener success.");
|
||||
if (appAnrListener_ != nullptr) {
|
||||
auto flag = static_cast<int32_t>(appMgrClient_->RegisterAppDebugListener(appAnrListener_));
|
||||
if (flag != ERR_OK) {
|
||||
WLOGFE("Register app debug listener failed.");
|
||||
} else {
|
||||
WLOGFI("Register app debug listener success.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -377,6 +380,11 @@ void SceneSessionManager::ConfigWindowSceneXml()
|
||||
ConfigFreeMultiWindow();
|
||||
ConfigWindowSizeLimits();
|
||||
ConfigSnapshotScale();
|
||||
|
||||
item = config["systemUIStatusBar"];
|
||||
if (item.IsMap()) {
|
||||
ConfigSystemUIStatusBar(item);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSessionManager::ConfigFreeMultiWindow()
|
||||
@ -596,6 +604,18 @@ bool SceneSessionManager::IsInputEventEnabled()
|
||||
return enableInputEvent_;
|
||||
}
|
||||
|
||||
void SceneSessionManager::ClearUnrecoveredSessions(const std::vector<int32_t>& recoveredPersistentIds)
|
||||
{
|
||||
for (const auto& persistentId : alivePersistentIds_) {
|
||||
auto it = std::find(recoveredPersistentIds.begin(), recoveredPersistentIds.end(), persistentId);
|
||||
if (it == recoveredPersistentIds.end()) {
|
||||
TLOGI(WmsLogTag::WMS_RECOVER, "Clear unrecovered session with persistentId=%{public}d", persistentId);
|
||||
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
sceneSessionMap_.erase(persistentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector<int32_t>& recoveredPersistentIds)
|
||||
{
|
||||
WLOGFI("[WMSRecover] Number of persistentIds recovered = %{public}zu. CurrentUserId = "
|
||||
@ -603,6 +623,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector<int32_t>&
|
||||
recoveredPersistentIds.size(), currentUserId_);
|
||||
|
||||
auto task = [this, recoveredPersistentIds]() {
|
||||
ClearUnrecoveredSessions(recoveredPersistentIds);
|
||||
std::list<AAFwk::SessionInfo> abilitySessionInfos;
|
||||
for (const auto& persistentId : recoveredPersistentIds) {
|
||||
auto sceneSession = GetSceneSession(persistentId);
|
||||
@ -922,6 +943,42 @@ void SceneSessionManager::ConfigSnapshotScale()
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::ConfigItem& statusBarConfig)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "load ConfigSystemUIStatusBar");
|
||||
WindowSceneConfig::ConfigItem item = statusBarConfig["showInLandscapeMode"];
|
||||
if (item.IsInts() && item.intsValue_->size() == 1) {
|
||||
bool showInLandscapeMode = (*item.intsValue_)[0] > 0;
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_ = showInLandscapeMode;
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar showInLandscapeMode:%{public}d",
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_);
|
||||
}
|
||||
|
||||
item = statusBarConfig["immersiveStatusBarBgColor"];
|
||||
if (item.IsString()) {
|
||||
auto color = item.stringValue_;
|
||||
uint32_t colorValue;
|
||||
if (!ColorParser::Parse(color, colorValue)) {
|
||||
return;
|
||||
}
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_ = color;
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarBgColor:%{public}s",
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str());
|
||||
}
|
||||
|
||||
item = statusBarConfig["immersiveStatusBarContentColor"];
|
||||
if (item.IsString()) {
|
||||
auto color = item.stringValue_;
|
||||
uint32_t colorValue;
|
||||
if (!ColorParser::Parse(color, colorValue)) {
|
||||
return;
|
||||
}
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_ = color;
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarContentColor:%{public}s",
|
||||
appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSessionManager::SetRootSceneContext(const std::weak_ptr<AbilityRuntime::Context>& contextWeak)
|
||||
{
|
||||
rootSceneContextWeak_ = contextWeak;
|
||||
@ -1089,6 +1146,47 @@ WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t &pid)
|
||||
return taskScheduler_->PostSyncTask(task, "CheckWindowId:" + std::to_string(windowId));
|
||||
}
|
||||
|
||||
void SceneSessionManager::CreateKeyboardPanelSession(sptr<SceneSession> keyboardSession)
|
||||
{
|
||||
if (!isKeyboardPanelEnabled_) {
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is not enabled");
|
||||
return;
|
||||
}
|
||||
if (keyboardSession == nullptr || keyboardSession->GetSessionProperty() == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardSession or property is nullptr");
|
||||
return;
|
||||
}
|
||||
DisplayId displayId = keyboardSession->GetSessionProperty()->GetDisplayId();
|
||||
const auto& panelVec = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL, displayId);
|
||||
sptr<SceneSession> panelSession;
|
||||
if (panelVec.size() > 1) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "Error size of keyboardPanel, size: %{public}zu", panelVec.size());
|
||||
return;
|
||||
} else if (panelVec.size() == 1) {
|
||||
panelSession = panelVec.front();
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is created, panelId:%{public}d", panelSession->GetPersistentId());
|
||||
} else {
|
||||
SessionInfo panelInfo = {
|
||||
.bundleName_ = "SCBKeyboardPanel",
|
||||
.moduleName_ = "SCBKeyboardPanel",
|
||||
.abilityName_ = "SCBKeyboardPanel",
|
||||
.isSystem_ = true,
|
||||
.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_KEYBOARD_PANEL),
|
||||
.isSystemInput_ = true,
|
||||
.screenId_ = static_cast<uint64_t>(displayId)
|
||||
};
|
||||
panelSession = RequestSceneSession(panelInfo, nullptr);
|
||||
if (panelSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_KEYBOARD, "PanelSession is nullptr");
|
||||
return;
|
||||
}
|
||||
}
|
||||
keyboardSession->BindKeyboardPanelSession(panelSession);
|
||||
panelSession->BindKeyboardSession(keyboardSession);
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "success, panelId:%{public}d, keyboardId:%{public}d",
|
||||
panelSession->GetPersistentId(), keyboardSession->GetPersistentId());
|
||||
}
|
||||
|
||||
sptr<SceneSession> SceneSessionManager::CreateSceneSession(const SessionInfo& sessionInfo,
|
||||
sptr<WindowSessionProperty> property)
|
||||
{
|
||||
@ -1106,6 +1204,7 @@ sptr<SceneSession> SceneSessionManager::CreateSceneSession(const SessionInfo& se
|
||||
} else if (property != nullptr && property->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) {
|
||||
sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb = CreateKeyboardSessionCallback();
|
||||
sceneSession = new (std::nothrow) KeyboardSession(sessionInfo, specificCb, keyboardCb);
|
||||
CreateKeyboardPanelSession(sceneSession);
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "Create KeyboardSession, type: %{public}d", property->GetWindowType());
|
||||
} else if (property != nullptr && SessionHelper::IsSystemWindow(property->GetWindowType())) {
|
||||
sceneSession = new (std::nothrow) SystemSession(sessionInfo, specificCb);
|
||||
@ -1115,6 +1214,7 @@ sptr<SceneSession> SceneSessionManager::CreateSceneSession(const SessionInfo& se
|
||||
}
|
||||
if (sceneSession != nullptr) {
|
||||
sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId());
|
||||
sceneSession->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_;
|
||||
}
|
||||
return sceneSession;
|
||||
}
|
||||
@ -1151,7 +1251,11 @@ sptr<SceneSession> SceneSessionManager::RequestSceneSession(const SessionInfo& s
|
||||
auto windowModeCallback = [this]() {
|
||||
ProcessSplitFloating();
|
||||
};
|
||||
auto isScreenLockedCallback = [this]() {
|
||||
return IsScreenLocked();
|
||||
};
|
||||
sceneSession->RegisterWindowModeChangedCallback(windowModeCallback);
|
||||
sceneSession->RegisterIsScreenLockedCallback(isScreenLockedCallback);
|
||||
if (sessionInfo.isSystem_) {
|
||||
sceneSession->SetCallingPid(IPCSkeleton::GetCallingRealPid());
|
||||
sceneSession->SetCallingUid(IPCSkeleton::GetCallingUid());
|
||||
@ -1827,13 +1931,18 @@ void SceneSessionManager::DestroyExtensionSession(const sptr<IRemoteObject>& rem
|
||||
TLOGD(WmsLogTag::WMS_UIEXT, "Remote died, id: %{public}d", persistentId);
|
||||
auto sceneSession = GetSceneSession(parentId);
|
||||
if (sceneSession != nullptr) {
|
||||
auto oldWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag();
|
||||
sceneSession->RomoveExtWindowFlags(persistentId);
|
||||
if (oldWaterMark) {
|
||||
auto oldFlags = sceneSession->GetCombinedExtWindowFlags();
|
||||
sceneSession->RemoveExtWindowFlags(persistentId);
|
||||
if (oldFlags.hideNonSecureWindowsFlag) {
|
||||
HandleSecureSessionShouldHide(sceneSession);
|
||||
}
|
||||
if (oldFlags.waterMarkFlag) {
|
||||
CheckAndNotifyWaterMarkChangedResult();
|
||||
}
|
||||
if (oldFlags.privacyModeFlag) {
|
||||
UpdatePrivateStateAndNotify(parentId);
|
||||
}
|
||||
}
|
||||
AddOrRemoveSecureExtSession(persistentId, parentId, false);
|
||||
remoteExtSessionMap_.erase(iter);
|
||||
};
|
||||
taskScheduler_->PostAsyncTask(task, "DestroyExtensionSession");
|
||||
@ -1854,9 +1963,10 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISession
|
||||
return WSError::WS_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) ||
|
||||
(SessionHelper::IsSubWindow(property->GetWindowType()) &&
|
||||
secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end());
|
||||
bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT &&
|
||||
property->IsFloatingWindowAppType() && !secureSessionSet_.empty()) ||
|
||||
(SessionHelper::IsSubWindow(property->GetWindowType()) &&
|
||||
secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end());
|
||||
if (shouldBlock) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure window permission denied!");
|
||||
return WSError::WS_ERROR_INVALID_OPERATION;
|
||||
@ -1911,7 +2021,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISession
|
||||
info.bundleName_ = property->GetSessionInfo().bundleName_;
|
||||
info.abilityName_ = property->GetSessionInfo().abilityName_;
|
||||
info.moduleName_ = property->GetSessionInfo().moduleName_;
|
||||
|
||||
|
||||
ClosePipWindowIfExist(type);
|
||||
sptr<SceneSession> newSession = RequestSceneSession(info, property);
|
||||
if (newSession == nullptr) {
|
||||
@ -2003,6 +2113,30 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr<WindowSessionPr
|
||||
return false;
|
||||
}
|
||||
|
||||
SessionInfo SceneSessionManager::RecoverSessionInfo(const sptr<WindowSessionProperty>& property)
|
||||
{
|
||||
SessionInfo sessionInfo;
|
||||
if (property == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_RECOVER, "property is nullptr");
|
||||
return sessionInfo;
|
||||
}
|
||||
sessionInfo = property->GetSessionInfo();
|
||||
sessionInfo.persistentId_ = property->GetPersistentId();
|
||||
sessionInfo.windowMode = static_cast<int32_t>(property->GetWindowMode());
|
||||
sessionInfo.windowType_ = static_cast<uint32_t>(property->GetWindowType());
|
||||
sessionInfo.requestOrientation_ = static_cast<uint32_t>(property->GetRequestedOrientation());
|
||||
sessionInfo.sessionState_ = (property->GetWindowState() == WindowState::STATE_SHOWN)
|
||||
? SessionState::STATE_ACTIVE
|
||||
: SessionState::STATE_BACKGROUND;
|
||||
TLOGI(WmsLogTag::WMS_RECOVER,
|
||||
"Recover and reconnect session with: bundleName=%{public}s, moduleName=%{public}s, "
|
||||
"abilityName=%{public}s, windowMode=%{public}d, windowType=%{public}u, persistentId=%{public}d, "
|
||||
"windowState=%{public}u",
|
||||
sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(),
|
||||
sessionInfo.windowMode, sessionInfo.windowType_, sessionInfo.persistentId_, sessionInfo.sessionState_);
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
void SceneSessionManager::SetAlivePersistentIds(const std::vector<int32_t>& alivePersistentIds)
|
||||
{
|
||||
WLOGFI("[WMSRecover] Number of persistentIds need to be recovered = %{public}zu. CurrentUserId = "
|
||||
@ -2034,22 +2168,15 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptr<ISessio
|
||||
auto pid = IPCSkeleton::GetCallingRealPid();
|
||||
auto uid = IPCSkeleton::GetCallingUid();
|
||||
auto task = [this, sessionStage, eventChannel, surfaceNode, property, &session, token, pid, uid]() {
|
||||
if (recoveringFinished_) {
|
||||
TLOGW(WmsLogTag::WMS_RECOVER, "Recover finished, not recovery anymore");
|
||||
return WSError::WS_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
// recover specific session
|
||||
const auto& type = property->GetWindowType();
|
||||
SessionInfo info = property->GetSessionInfo();
|
||||
SessionInfo info = RecoverSessionInfo(property);
|
||||
info.isPersistentRecover_ = true;
|
||||
info.persistentId_ = property->GetPersistentId();
|
||||
info.windowMode = static_cast<int32_t>(property->GetWindowMode());
|
||||
info.windowType_ = static_cast<uint32_t>(type);
|
||||
info.requestOrientation_ = static_cast<uint32_t>(property->GetRequestedOrientation());
|
||||
info.sessionState_ = (property->GetWindowState() == WindowState::STATE_SHOWN) ? SessionState::STATE_ACTIVE
|
||||
: SessionState::STATE_BACKGROUND;
|
||||
|
||||
WLOGI("[WMSRecover] RecoverAndConnectSpecificSession windowName = %{public}s, windowMode = %{public}d, "
|
||||
"windowType = %{public}u, persistentId = %{public}d, windowState = %{public}u, "
|
||||
"callingSessionId = %{public}" PRIu32, property->GetWindowName().c_str(), info.windowMode,
|
||||
info.windowType_, info.persistentId_, property->GetWindowState(), property->GetCallingSessionId());
|
||||
|
||||
TLOGI(WmsLogTag::WMS_RECOVER, "callingSessionId = %{public}" PRIu32, property->GetCallingSessionId());
|
||||
ClosePipWindowIfExist(type);
|
||||
sptr<SceneSession> sceneSession = RequestSceneSession(info, property);
|
||||
if (sceneSession == nullptr) {
|
||||
@ -2077,7 +2204,6 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptr<ISessio
|
||||
session = sceneSession;
|
||||
return errCode;
|
||||
};
|
||||
|
||||
return taskScheduler_->PostSyncTask(task, "RecoverAndConnectSpecificSession");
|
||||
}
|
||||
|
||||
@ -2156,47 +2282,44 @@ WSError SceneSessionManager::RecoverAndReconnectSceneSession(const sptr<ISession
|
||||
if (!isNeedRecover(property->GetPersistentId())) {
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
}
|
||||
SessionInfo sessionInfo = property->GetSessionInfo();
|
||||
sessionInfo.persistentId_ = property->GetPersistentId();
|
||||
sessionInfo.windowMode = static_cast<int32_t>(property->GetWindowMode());
|
||||
sessionInfo.windowType_ = static_cast<uint32_t>(property->GetWindowType());
|
||||
sessionInfo.requestOrientation_ = static_cast<uint32_t>(property->GetRequestedOrientation());
|
||||
WindowState windowState = property->GetWindowState();
|
||||
WLOGFI("[WMSRecover] Recover and reconnect sceneSession with: bundleName=%{public}s, moduleName=%{public}s, "
|
||||
"abilityName=%{public}s, windowMode=%{public}d, windowType=%{public}u, persistentId=%{public}d, "
|
||||
"windowState=%{public}u",
|
||||
sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(),
|
||||
sessionInfo.windowMode, sessionInfo.windowType_, sessionInfo.persistentId_, static_cast<uint32_t>(windowState));
|
||||
sptr<SceneSession> sceneSession = nullptr;
|
||||
if (SessionHelper::IsMainWindow(property->GetWindowType())) {
|
||||
sceneSession = RequestSceneSession(sessionInfo, nullptr);
|
||||
} else {
|
||||
sceneSession = RequestSceneSession(sessionInfo, property);
|
||||
}
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("[WMSRecover] Request sceneSession failed");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
auto ret = sceneSession->Reconnect(sessionStage, eventChannel, surfaceNode, property, token,
|
||||
IPCSkeleton::GetCallingRealPid(), IPCSkeleton::GetCallingUid());
|
||||
if (ret != WSError::WS_OK) {
|
||||
WLOGFE("[WMSRecover] Reconnect failed");
|
||||
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
sceneSessionMap_.erase(sessionInfo.persistentId_);
|
||||
return ret;
|
||||
}
|
||||
sessionInfo.sessionState_ = sceneSession->GetSessionState();
|
||||
if (recoverSceneSessionFunc_) {
|
||||
recoverSceneSessionFunc_(sceneSession, sessionInfo);
|
||||
} else {
|
||||
WLOGFE("[WMSRecover] recoverSceneSessionFunc_ is null");
|
||||
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
sceneSessionMap_.erase(sessionInfo.persistentId_);
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
NotifySessionUnfocusedToClient(sceneSession->GetPersistentId());
|
||||
session = sceneSession;
|
||||
return WSError::WS_OK;
|
||||
auto pid = IPCSkeleton::GetCallingRealPid();
|
||||
auto uid = IPCSkeleton::GetCallingUid();
|
||||
auto task = [this, sessionStage, eventChannel, surfaceNode, &session, property, token, pid, uid]() {
|
||||
if (recoveringFinished_) {
|
||||
TLOGW(WmsLogTag::WMS_RECOVER, "Recover finished, not recovery anymore");
|
||||
return WSError::WS_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
SessionInfo sessionInfo = RecoverSessionInfo(property);
|
||||
sptr<SceneSession> sceneSession = nullptr;
|
||||
if (SessionHelper::IsMainWindow(property->GetWindowType())) {
|
||||
sceneSession = RequestSceneSession(sessionInfo, nullptr);
|
||||
} else {
|
||||
sceneSession = RequestSceneSession(sessionInfo, property);
|
||||
}
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("[WMSRecover] Request sceneSession failed");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
auto ret = sceneSession->Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid);
|
||||
if (ret != WSError::WS_OK) {
|
||||
WLOGFE("[WMSRecover] Reconnect failed");
|
||||
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
sceneSessionMap_.erase(sessionInfo.persistentId_);
|
||||
return ret;
|
||||
}
|
||||
if (recoverSceneSessionFunc_) {
|
||||
recoverSceneSessionFunc_(sceneSession, sessionInfo);
|
||||
} else {
|
||||
WLOGFE("[WMSRecover] recoverSceneSessionFunc_ is null");
|
||||
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
sceneSessionMap_.erase(sessionInfo.persistentId_);
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
NotifySessionUnfocusedToClient(sceneSession->GetPersistentId());
|
||||
session = sceneSession;
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
return taskScheduler_->PostSyncTask(task, "RecoverAndReconnectSceneSession");
|
||||
}
|
||||
|
||||
void SceneSessionManager::SetRecoverSceneSessionListener(const NotifyRecoverSceneSessionFunc& func)
|
||||
@ -2210,6 +2333,11 @@ void SceneSessionManager::SetCreateSystemSessionListener(const NotifyCreateSyste
|
||||
createSystemSessionFunc_ = func;
|
||||
}
|
||||
|
||||
void SceneSessionManager::SetCreateKeyboardSessionListener(const NotifyCreateKeyboardSessionFunc& func)
|
||||
{
|
||||
createKeyboardSessionFunc_ = func;
|
||||
}
|
||||
|
||||
void SceneSessionManager::RegisterCreateSubSessionListener(int32_t persistentId,
|
||||
const NotifyCreateSubSessionFunc& func)
|
||||
{
|
||||
@ -2245,10 +2373,13 @@ void SceneSessionManager::NotifyCreateSpecificSession(sptr<SceneSession> newSess
|
||||
newSession->SetParentSession(parentSession);
|
||||
}
|
||||
}
|
||||
if (createSystemSessionFunc_ && type != WindowType::WINDOW_TYPE_DIALOG) {
|
||||
if (type != WindowType::WINDOW_TYPE_DIALOG) {
|
||||
if (WindowHelper::IsSystemSubWindow(type)) {
|
||||
NotifyCreateSubSession(property->GetParentPersistentId(), newSession);
|
||||
} else {
|
||||
} else if (isKeyboardPanelEnabled_ && type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT
|
||||
&& createKeyboardSessionFunc_) {
|
||||
createKeyboardSessionFunc_(newSession, newSession->GetKeyboardPanelSession());
|
||||
} else if (createSystemSessionFunc_) {
|
||||
createSystemSessionFunc_(newSession);
|
||||
}
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "Create system session, id:%{public}d, type: %{public}d",
|
||||
@ -2362,7 +2493,7 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId)
|
||||
}
|
||||
if (sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
|
||||
sceneSession->GetSessionProperty() != nullptr) {
|
||||
callingSessionId = sceneSession->GetSessionProperty()->GetCallingSessionId();
|
||||
callingSessionId = static_cast<int32_t>(sceneSession->GetSessionProperty()->GetCallingSessionId());
|
||||
TLOGI(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, callingSessionId: %{public}d",
|
||||
persistentId, callingSessionId);
|
||||
}
|
||||
@ -2850,7 +2981,7 @@ WMError SceneSessionManager::GetTopWindowId(uint32_t mainWinId, uint32_t& topWin
|
||||
for (const auto& subSession : subVec) {
|
||||
if (subSession != nullptr && (subSession->GetSessionState() == SessionState::STATE_FOREGROUND ||
|
||||
subSession->GetSessionState() == SessionState::STATE_ACTIVE) && subSession->GetZOrder() > zOrder) {
|
||||
topWinId = subSession->GetPersistentId();
|
||||
topWinId = static_cast<uint32_t>(subSession->GetPersistentId());
|
||||
zOrder = subSession->GetZOrder();
|
||||
WLOGFD("[GetTopWin] Current zorder is larger than mainWin, mainId: %{public}d, topWinId: %{public}d, "
|
||||
"zOrder: %{public}d", mainWinId, topWinId, zOrder);
|
||||
@ -4303,9 +4434,12 @@ void SceneSessionManager::NotifyFocusStatusByMission(sptr<SceneSession>& prevSes
|
||||
|
||||
bool SceneSessionManager::MissionChanged(sptr<SceneSession>& prevSession, sptr<SceneSession>& currSession)
|
||||
{
|
||||
if (prevSession == nullptr || currSession == nullptr) {
|
||||
if (prevSession == nullptr && currSession == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (prevSession == nullptr || currSession == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return prevSession->GetMissionId() != currSession->GetMissionId();
|
||||
}
|
||||
|
||||
@ -4415,7 +4549,14 @@ static void FillSecCompEnhanceData(const std::shared_ptr<MMI::PointerEvent>& poi
|
||||
}
|
||||
#endif // SECURITY_COMPONENT_MANAGER_ENABLE
|
||||
|
||||
WSError SceneSessionManager::SendTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex)
|
||||
void SceneSessionManager::UpdateLastDownEventDeviceId(int32_t deviceId)
|
||||
{
|
||||
lastDownEventDeviceId_ = deviceId;
|
||||
TLOGD(WmsLogTag::WMS_EVENT, "deviceId:%{public}d", lastDownEventDeviceId_);
|
||||
return;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::SendTouchEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex)
|
||||
{
|
||||
if (!pointerEvent) {
|
||||
WLOGFE("pointerEvent is null");
|
||||
@ -4429,8 +4570,9 @@ WSError SceneSessionManager::SendTouchEvent(const std::shared_ptr<MMI::PointerEv
|
||||
#ifdef SECURITY_COMPONENT_MANAGER_ENABLE
|
||||
FillSecCompEnhanceData(pointerEvent, pointerItem);
|
||||
#endif
|
||||
WLOGFI("[EventDispatch] SendTouchEvent PointerId = %{public}d, action = %{public}d",
|
||||
pointerEvent->GetPointerId(), pointerEvent->GetPointerAction());
|
||||
TLOGI(WmsLogTag::WMS_EVENT, "PointerId:%{public}d,action:%{public}d,deviceId:%{public}d",
|
||||
pointerEvent->GetPointerId(), pointerEvent->GetPointerAction(), lastDownEventDeviceId_);
|
||||
pointerEvent->SetDeviceId(lastDownEventDeviceId_);
|
||||
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent, static_cast<float>(zIndex));
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
@ -4438,6 +4580,23 @@ WSError SceneSessionManager::SendTouchEvent(const std::shared_ptr<MMI::PointerEv
|
||||
void SceneSessionManager::SetScreenLocked(const bool isScreenLocked)
|
||||
{
|
||||
isScreenLocked_ = isScreenLocked;
|
||||
DeleteStateDetectTask();
|
||||
}
|
||||
|
||||
void SceneSessionManager::DeleteStateDetectTask()
|
||||
{
|
||||
if (!IsScreenLocked()) {
|
||||
return;
|
||||
}
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
for (auto iter : sceneSessionMap_) {
|
||||
auto& session = iter.second;
|
||||
if (session->GetDetectTaskInfo().taskState != DetectTaskState::NO_TASK) {
|
||||
taskScheduler_->GetEventHandler()->RemoveTask(session->GetWindowDetectTaskName());
|
||||
DetectTaskInfo detectTaskInfo;
|
||||
session->SetDetectTaskInfo(detectTaskInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneSessionManager::IsScreenLocked() const
|
||||
@ -4464,11 +4623,13 @@ int SceneSessionManager::GetSceneSessionPrivacyModeCount()
|
||||
bool isForeground = sceneSession->GetSessionState() == SessionState::STATE_FOREGROUND ||
|
||||
sceneSession->GetSessionState() == SessionState::STATE_ACTIVE;
|
||||
if (isForeground && sceneSession->GetParentSession() != nullptr) {
|
||||
isForeground &= sceneSession->GetParentSession()->GetSessionState() == SessionState::STATE_FOREGROUND ||
|
||||
sceneSession->GetParentSession()->GetSessionState() == SessionState::STATE_ACTIVE;
|
||||
isForeground = isForeground &&
|
||||
(sceneSession->GetParentSession()->GetSessionState() == SessionState::STATE_FOREGROUND ||
|
||||
sceneSession->GetParentSession()->GetSessionState() == SessionState::STATE_ACTIVE);
|
||||
}
|
||||
bool isPrivate = sceneSession->GetSessionProperty() != nullptr &&
|
||||
sceneSession->GetSessionProperty()->GetPrivacyMode();
|
||||
(sceneSession->GetSessionProperty()->GetPrivacyMode() ||
|
||||
sceneSession->GetCombinedExtWindowFlags().privacyModeFlag);
|
||||
bool IsSystemWindowVisible = sceneSession->GetSessionInfo().isSystem_ && sceneSession->IsVisible();
|
||||
return (isForeground || IsSystemWindowVisible) && isPrivate;
|
||||
};
|
||||
@ -4822,7 +4983,7 @@ void SceneSessionManager::CheckAndNotifyWaterMarkChangedResult()
|
||||
}
|
||||
bool hasWaterMark = session->GetSessionProperty()->GetWindowFlags()
|
||||
& static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK);
|
||||
bool isExtWindowHasWaterMarkFlag = session->IsExtWindowHasWaterMarkFlag();
|
||||
bool isExtWindowHasWaterMarkFlag = session->GetCombinedExtWindowFlags().waterMarkFlag;
|
||||
if ((hasWaterMark && session->GetVisible()) || isExtWindowHasWaterMarkFlag) {
|
||||
currentWaterMarkShowState = true;
|
||||
break;
|
||||
@ -6512,6 +6673,7 @@ void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentI
|
||||
return;
|
||||
}
|
||||
AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR);
|
||||
sceneSession->SetIsDisplayStatusBarTemporarily(false);
|
||||
if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, avoidArea,
|
||||
sceneSession->GetSessionRect().posY_ + sceneSession->GetSessionRect().height_)) {
|
||||
return;
|
||||
@ -7617,7 +7779,7 @@ WSError SceneSessionManager::HandleSecureSessionShouldHide(const sptr<SceneSessi
|
||||
}
|
||||
|
||||
auto persistentId = sceneSession->GetPersistentId();
|
||||
auto shouldHide = sceneSession->ShouldHideNonSecureWindows();
|
||||
auto shouldHide = sceneSession->GetCombinedExtWindowFlags().hideNonSecureWindowsFlag;
|
||||
size_t sizeBefore = 0;
|
||||
size_t sizeAfter = 0;
|
||||
AddSecureSession(persistentId, shouldHide, sizeBefore, sizeAfter);
|
||||
@ -7640,6 +7802,11 @@ WSError SceneSessionManager::HandleSecureExtSessionShouldHide(int32_t persistent
|
||||
WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, shouldHide=%{public}u", persistentId, shouldHide);
|
||||
if (!SessionPermission::IsSystemCalling()) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows permission denied!");
|
||||
return WSError::WS_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
auto task = [this, persistentId, shouldHide]() {
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
auto iter = sceneSessionMap_.find(persistentId);
|
||||
@ -7658,58 +7825,57 @@ WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide)
|
||||
WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
|
||||
uint32_t extWindowActions)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, parentId=%{public}d, shouldHide=%{public}u", persistentId,
|
||||
parentId, shouldHide);
|
||||
if (!SessionPermission::IsSystemCalling()) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows permission denied!");
|
||||
return WSError::WS_ERROR_NOT_SYSTEM_APP;
|
||||
TLOGI(WmsLogTag::WMS_UIEXT, "parentId=%{public}d, persistentId=%{public}d, extWindowFlags=%{public}d, "
|
||||
"actions=%{public}d", parentId, persistentId, extWindowFlags, extWindowActions);
|
||||
|
||||
ExtensionWindowFlags actions(extWindowActions);
|
||||
auto ret = WSError::WS_OK;
|
||||
bool needSystemCalling = actions.hideNonSecureWindowsFlag || actions.waterMarkFlag;
|
||||
if (needSystemCalling && !SessionPermission::IsSystemCalling()) {
|
||||
actions.hideNonSecureWindowsFlag = false;
|
||||
actions.waterMarkFlag = false;
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "system calling permission denied!");
|
||||
ret = WSError::WS_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
auto needPrivacyWindow = actions.privacyModeFlag;
|
||||
if (needPrivacyWindow && !SessionPermission::VerifyCallingPermission("ohos.permission.PRIVACY_WINDOW")) {
|
||||
actions.privacyModeFlag = false;
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "privacy window permission denied!");
|
||||
ret = WSError::WS_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
if (actions.bitData == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto task = [this, persistentId, parentId, shouldHide]() {
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
auto iter = sceneSessionMap_.find(parentId);
|
||||
if (iter == sceneSessionMap_.end()) {
|
||||
TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureExtSession: Parent session with persistentId %{public}d not "
|
||||
"found", parentId);
|
||||
// process UIExtension that created by SceneBoard
|
||||
return HandleSecureExtSessionShouldHide(persistentId, shouldHide);
|
||||
}
|
||||
|
||||
auto sceneSession = iter->second;
|
||||
sceneSession->AddOrRemoveSecureExtSession(persistentId, shouldHide);
|
||||
return HandleSecureSessionShouldHide(sceneSession);
|
||||
};
|
||||
|
||||
taskScheduler_->PostAsyncTask(task, "AddOrRemoveSecureExtSession");
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags, parentId:%{public}d, persistentId:%{public}d, \
|
||||
extWindowFlags:%{public}d", parentId, persistentId, extWindowFlags);
|
||||
if (!SessionPermission::IsSystemCalling()) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags permission denied!");
|
||||
return WSError::WS_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
auto task = [this, parentId, persistentId, extWindowFlags]() {
|
||||
ExtensionWindowFlags flags(extWindowFlags);
|
||||
auto task = [this, parentId, persistentId, flags, actions]() {
|
||||
auto sceneSession = GetSceneSession(parentId);
|
||||
if (sceneSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", parentId);
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
TLOGD(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags: Parent session with persistentId %{public}d not found",
|
||||
parentId);
|
||||
return HandleSecureExtSessionShouldHide(persistentId, flags.hideNonSecureWindowsFlag);
|
||||
}
|
||||
auto oldWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag();
|
||||
sceneSession->UpdateExtWindowFlags(persistentId, extWindowFlags);
|
||||
auto newWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag();
|
||||
if (oldWaterMark != newWaterMark) {
|
||||
|
||||
auto oldFlags = sceneSession->GetCombinedExtWindowFlags();
|
||||
sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
|
||||
auto newFlags = sceneSession->GetCombinedExtWindowFlags();
|
||||
if (oldFlags.hideNonSecureWindowsFlag != newFlags.hideNonSecureWindowsFlag) {
|
||||
HandleSecureSessionShouldHide(sceneSession);
|
||||
}
|
||||
if (oldFlags.waterMarkFlag != newFlags.waterMarkFlag) {
|
||||
CheckAndNotifyWaterMarkChangedResult();
|
||||
}
|
||||
if (oldFlags.privacyModeFlag != newFlags.privacyModeFlag) {
|
||||
UpdatePrivateStateAndNotify(parentId);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
taskScheduler_->PostAsyncTask(task, "UpdateExtWindowFlags");
|
||||
return WSError::WS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SceneSessionManager::ReportWindowProfileInfos()
|
||||
@ -7890,7 +8056,6 @@ bool SceneSessionManager::IsCovered(const sptr<SceneSession>& sceneSession,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void SceneSessionManager::FilterSceneSessionForAccessibility(std::vector<sptr<SceneSession>>& sceneSessionList)
|
||||
{
|
||||
for (auto it = sceneSessionList.begin(); it != sceneSessionList.end();) {
|
||||
@ -7916,6 +8081,10 @@ void SceneSessionManager::NotifyAllAccessibilityInfo()
|
||||
bundle=%{public}s,bounds=(x = %{public}d, y = %{public}d, w = %{public}d, h = %{public}d)",
|
||||
item->wid_, item->innerWid_, item->bundleName_.c_str(),
|
||||
item->windowRect_.posX_, item->windowRect_.posY_, item->windowRect_.width_, item->windowRect_.height_);
|
||||
for (const auto& rect : item->touchHotAreas_) {
|
||||
TLOGD(WmsLogTag::WMS_MAIN, "window touch hot areas rect[x=%{public}d,y=%{public}d," \
|
||||
"w=%{public}d,h=%{public}d]", rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
}
|
||||
}
|
||||
|
||||
SessionManagerAgentController::GetInstance().NotifyAccessibilityWindowInfo(accessibilityInfo,
|
||||
@ -8045,4 +8214,17 @@ WMError SceneSessionManager::GetWindowBackHomeStatus(bool &isBackHome)
|
||||
WLOGFI("Get back home status success, isBackHome: %{public}d", isBackHome);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
int32_t SceneSessionManager::GetCustomDecorHeight(int32_t persistentId)
|
||||
{
|
||||
int32_t height = 0;
|
||||
auto sceneSession = GetSceneSession(persistentId);
|
||||
if (sceneSession == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Session with persistentId %{public}d not found", persistentId);
|
||||
return 0;
|
||||
}
|
||||
height = sceneSession->GetCustomDecorHeight();
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "GetCustomDecorHeight: %{public}d", height);
|
||||
return height;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user