mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
Merge branch 'master' of gitee.com:openharmony/window_window_manager into master
Signed-off-by: zhouminghui <zhouminghui8@huawei.com>
This commit is contained in:
commit
39eb31734d
@ -28,7 +28,7 @@
|
||||
"components": [
|
||||
"sensor",
|
||||
"ability_base",
|
||||
"graphic_standard",
|
||||
"graphic_2d",
|
||||
"hisysevent",
|
||||
"ability_runtime",
|
||||
"napi",
|
||||
|
@ -29,6 +29,7 @@ config("libdm_public_config") {
|
||||
include_dirs = [
|
||||
"../interfaces/innerkits/dm",
|
||||
"../utils/include",
|
||||
"${multimedia_path}/interfaces/innerkits/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ ohos_static_library("libdm_static") {
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"multimedia_image_framework:image_native",
|
||||
@ -101,7 +102,7 @@ ohos_shared_library("libdm") {
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"multimedia_image_framework:image_native",
|
||||
|
@ -62,8 +62,8 @@ ohos_shared_library("libdms") {
|
||||
"c_utils:utils",
|
||||
"config_policy:configpolicy_util",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_standard:surface",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_single",
|
||||
|
@ -77,7 +77,8 @@ void DisplayManagerService::OnStart()
|
||||
WLOGFE("Init failed");
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<DisplayManagerService> dms = this;
|
||||
dms->IncStrongRef(nullptr);
|
||||
if (!Publish(this)) {
|
||||
WLOGFE("Publish failed");
|
||||
}
|
||||
@ -93,6 +94,7 @@ bool DisplayManagerService::Init()
|
||||
}
|
||||
abstractScreenController_->Init();
|
||||
abstractDisplayController_->Init(abstractScreenController_);
|
||||
SetGravitySensorSubscriptionEnabled();
|
||||
WLOGFI("DisplayManagerService::Init success");
|
||||
return true;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ ohos_unittest("dmserver_display_manager_proxy_test") {
|
||||
|
||||
deps = [ ":dmserver_unittest_common" ]
|
||||
|
||||
external_deps = [ "graphic_standard:surface" ]
|
||||
external_deps = [ "graphic_2d:surface" ]
|
||||
}
|
||||
|
||||
ohos_unittest("dmserver_screen_rotation_controller_test") {
|
||||
|
@ -52,7 +52,7 @@ ohos_shared_library("libwindow_extension_client") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hitrace:hitrace_meter",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
|
@ -62,11 +62,12 @@ ohos_shared_library("libwindow_extension") {
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
part_name = "window_manager"
|
||||
@ -97,6 +98,7 @@ ohos_shared_library("window_extension_module") {
|
||||
"ability_runtime:abilitykit_native",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
relative_install_dir = "extensionability/"
|
||||
subsystem_name = "window"
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
*
|
||||
* @param info Screenshot info.
|
||||
*/
|
||||
virtual void OnScreenshot(const ScreenshotInfo info) {}
|
||||
virtual void OnScreenshot([[maybe_unused]]const ScreenshotInfo info) {}
|
||||
};
|
||||
|
||||
class IPrivateWindowListener : public virtual RefBase {
|
||||
@ -65,7 +65,7 @@ public:
|
||||
*
|
||||
* @param hasPrivate True means the display has private window, false means the opposite.
|
||||
*/
|
||||
virtual void OnPrivateWindow(bool hasPrivate) {};
|
||||
virtual void OnPrivateWindow([[maybe_unused]]bool hasPrivate) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
*
|
||||
* @param info Change info of screen mirror.
|
||||
*/
|
||||
virtual void OnMirrorChange(const ChangeInfo& info) {}
|
||||
virtual void OnMirrorChange([[maybe_unused]]const ChangeInfo& info) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1265,7 +1265,7 @@ public:
|
||||
* @param level memory level
|
||||
* @return the error code of window
|
||||
*/
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const { return WMError::WM_OK; }
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) { return WMError::WM_OK; }
|
||||
|
||||
/**
|
||||
* @brief Update configuration for all windows
|
||||
@ -1313,6 +1313,11 @@ public:
|
||||
* @param func Function to notify transfer component data.
|
||||
*/
|
||||
virtual void RegisterTransferComponentDataListener(const NotifyTransferComponentDataFunc& func) {}
|
||||
/**
|
||||
* @brief Perform back event.
|
||||
*
|
||||
*/
|
||||
virtual void PerformBack() {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
* @param level memory level
|
||||
* @return the error code of window
|
||||
*/
|
||||
WMError NotifyMemoryLevel(int32_t level) const;
|
||||
WMError NotifyMemoryLevel(int32_t level);
|
||||
|
||||
public:
|
||||
static const DisplayId DEFAULT_DISPLAY_ID = 0;
|
||||
|
@ -41,7 +41,7 @@ ohos_shared_library("screen_napi") {
|
||||
external_deps = [
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:surface", # use for SurfaceUtils
|
||||
"graphic_2d:surface", # use for SurfaceUtils
|
||||
"hilog:libhilog",
|
||||
"hiview:libxpower_event_js",
|
||||
"napi:ace_napi",
|
||||
|
@ -70,25 +70,30 @@ NativeValue* JsTransitionContext::OnCompleteTransition(NativeEngine& engine, Nat
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WMError ret = WMError::WM_OK;
|
||||
auto state = windowToken_->GetWindowState();
|
||||
auto window = windowToken_.promote();
|
||||
if (window == nullptr) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
auto state = window->GetWindowState();
|
||||
if (!isShownTransContext_) {
|
||||
if (state != WindowState::STATE_HIDDEN) {
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] Hidden context called but window is not hidden: %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), static_cast<uint32_t>(state));
|
||||
window->GetWindowId(), window->GetWindowName().c_str(), static_cast<uint32_t>(state));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->UpdateSurfaceNodeAfterCustomAnimation(false); // remove from rs tree after animation
|
||||
window->UpdateSurfaceNodeAfterCustomAnimation(false); // remove from rs tree after animation
|
||||
if (!transitionCompleted) {
|
||||
ret = windowToken_->Show(); // hide aborted
|
||||
ret = window->Show(); // hide aborted
|
||||
}
|
||||
} else {
|
||||
if (state != WindowState::STATE_SHOWN) {
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] shown context called but window is not shown: %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), static_cast<uint32_t>(state));
|
||||
window->GetWindowId(), window->GetWindowName().c_str(), static_cast<uint32_t>(state));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!transitionCompleted) {
|
||||
ret = windowToken_->Hide(); // show aborted
|
||||
ret = window->Hide(); // show aborted
|
||||
}
|
||||
}
|
||||
if (ret != WMError::WM_OK) {
|
||||
@ -96,7 +101,7 @@ NativeValue* JsTransitionContext::OnCompleteTransition(NativeEngine& engine, Nat
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] CompleteTransition %{public}d end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), transitionCompleted);
|
||||
window->GetWindowId(), window->GetWindowName().c_str(), transitionCompleted);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ if (!ispreview) {
|
||||
|
||||
external_deps = [
|
||||
"ace_engine:ace_uicontent",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"previewer:ide_extension",
|
||||
]
|
||||
|
@ -58,6 +58,7 @@ class RSSurfaceNode;
|
||||
class RSTransaction;
|
||||
using NotifyNativeWinDestroyFunc = std::function<void(std::string windowName)>;
|
||||
using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t);
|
||||
using ContentInfoCallback = std::function<void(std::string contentInfo)>;
|
||||
|
||||
class IWindowLifeCycle : virtual public RefBase {
|
||||
};
|
||||
@ -225,7 +226,7 @@ public:
|
||||
virtual ColorSpace GetColorSpace() = 0;
|
||||
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() = 0;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const = 0;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) = 0;
|
||||
virtual bool IsAllowHaveSystemSubWindow() = 0;
|
||||
virtual WMError SetAspectRatio(float ratio) = 0;
|
||||
virtual WMError ResetAspectRatio() = 0;
|
||||
@ -239,6 +240,7 @@ public:
|
||||
virtual void SetDensity(float density) = 0;
|
||||
|
||||
virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) = 0;
|
||||
virtual void SetContentInfoCallback(const ContentInfoCallback& callback) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public:
|
||||
|
||||
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const override;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) override;
|
||||
virtual bool IsAllowHaveSystemSubWindow() override;
|
||||
WmErrorCode RaiseToAppTop() override;
|
||||
virtual WMError SetAspectRatio(float ratio) override;
|
||||
@ -204,7 +204,7 @@ public:
|
||||
virtual void SetDensity(float density) override;
|
||||
|
||||
virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) override;
|
||||
|
||||
virtual void SetContentInfoCallback(const ContentInfoCallback& callback) override;
|
||||
private:
|
||||
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;
|
||||
static std::map<uint32_t, std::vector<sptr<WindowImpl>>> subWindowMap_;
|
||||
@ -215,6 +215,7 @@ private:
|
||||
std::unique_ptr<Ace::UIContent> uiContent_;
|
||||
KeyboardAnimationConfig keyboardAnimationConfig_;
|
||||
bool needRemoveWindowInputChannel_ = false;
|
||||
ContentInfoCallback contentInfoCallback_;
|
||||
Transform transform_;
|
||||
int32_t width_ = 0;
|
||||
int32_t height_ = 0;
|
||||
|
@ -58,6 +58,11 @@ void WindowImpl::CreateSurfaceNode(const std::string name, const SendRenderDataC
|
||||
surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig);
|
||||
}
|
||||
|
||||
void WindowImpl::SetContentInfoCallback(const ContentInfoCallback& callback)
|
||||
{
|
||||
contentInfoCallback_ = callback;
|
||||
}
|
||||
|
||||
sptr<Window> WindowImpl::Find(const std::string& name)
|
||||
{
|
||||
return nullptr;
|
||||
@ -255,6 +260,9 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
UpdateViewportConfig();
|
||||
if (contentInfoCallback_) {
|
||||
contentInfoCallback_(contentInfo);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@ -731,7 +739,7 @@ WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::NotifyMemoryLevel(int32_t level) const
|
||||
WMError WindowImpl::NotifyMemoryLevel(int32_t level)
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
@ -21,7 +21,10 @@ declare_args() {
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("window_manager_config") {
|
||||
if (window_manager_dayu200_resource_config) {
|
||||
if (is_emulator) {
|
||||
source = "./other/window_manager_config.xml"
|
||||
install_enable = false
|
||||
} else if (window_manager_dayu200_resource_config) {
|
||||
source = "./rk3568/window_manager_config.xml"
|
||||
install_enable = true
|
||||
} else if (window_manager_dayu210_resource_config) {
|
||||
@ -37,7 +40,10 @@ ohos_prebuilt_etc("window_manager_config") {
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("display_manager_config") {
|
||||
if (window_manager_dayu200_resource_config) {
|
||||
if (is_emulator) {
|
||||
source = "./other/display_manager_config.xml"
|
||||
install_enable = false
|
||||
} else if (window_manager_dayu200_resource_config) {
|
||||
source = "./rk3568/display_manager_config.xml"
|
||||
install_enable = true
|
||||
} else if (window_manager_dayu210_resource_config) {
|
||||
|
@ -35,7 +35,7 @@ ohos_static_library("libtestutil") {
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:surface",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
"multimedia_image_framework:image_native",
|
||||
]
|
||||
|
@ -32,6 +32,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ScreenshotListener : public DisplayManager::IScreenshotListener {
|
||||
public:
|
||||
void OnScreenshot(const ScreenshotInfo info) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class PrivateWindowListener : public DisplayManager::IPrivateWindowListener {
|
||||
public:
|
||||
void OnPrivateWindow(bool hasPrivate) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DisplayPowerEventListener : public IDisplayPowerEventListener {
|
||||
public:
|
||||
virtual void OnDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) override
|
||||
@ -68,8 +82,17 @@ bool DisplayFuzzTest(const uint8_t* data, size_t size)
|
||||
displayManager.GetDisplayById(displayId);
|
||||
startPos += GetObject<ScreenId>(screenId, data + startPos, size - startPos);
|
||||
displayManager.GetDisplayByScreen(screenId);
|
||||
bool flag = true;
|
||||
startPos += GetObject<bool>(flag, data + startPos, size - startPos);
|
||||
displayManager.HasPrivateWindow(displayId, flag);
|
||||
displayManager.RegisterDisplayListener(displayListener);
|
||||
displayManager.UnregisterDisplayListener(displayListener);
|
||||
sptr<ScreenshotListener> screenshotListener = new ScreenshotListener();
|
||||
displayManager.RegisterScreenshotListener(screenshotListener);
|
||||
displayManager.UnregisterScreenshotListener(screenshotListener);
|
||||
sptr<PrivateWindowListener> privateWindowListener = new PrivateWindowListener();
|
||||
displayManager.RegisterPrivateWindowListener(privateWindowListener);
|
||||
displayManager.UnregisterPrivateWindowListener(privateWindowListener);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,34 @@ bool SetVirtualScreenSurfaceFuzzTest(const uint8_t *data, size_t size)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetScreenRotationLockedFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
ScreenId screenId;
|
||||
if (data == nullptr || size < sizeof(screenId)) {
|
||||
return false;
|
||||
}
|
||||
size_t startPos = 0;
|
||||
ScreenManager &screenManager = ScreenManager::GetInstance();
|
||||
bool flag = true;
|
||||
startPos += GetObject<bool>(flag, data + startPos, size - startPos);
|
||||
screenManager.SetScreenRotationLocked(flag);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsScreenRotationLocked(const uint8_t *data, size_t size)
|
||||
{
|
||||
ScreenId screenId;
|
||||
if (data == nullptr || size < sizeof(screenId)) {
|
||||
return false;
|
||||
}
|
||||
size_t startPos = 0;
|
||||
ScreenManager &screenManager = ScreenManager::GetInstance();
|
||||
bool flag = true;
|
||||
startPos += GetObject<bool>(flag, data + startPos, size - startPos);
|
||||
screenManager.IsScreenRotationLocked(flag);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveVirtualScreenFromGroupFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
ScreenId screenId;
|
||||
|
@ -17,6 +17,7 @@ group("fuzztest") {
|
||||
deps = [
|
||||
"window_fuzzer:fuzztest",
|
||||
"windowagent_fuzzer:fuzztest",
|
||||
"windowimpl_fuzzer:fuzztest",
|
||||
"windowipc_fuzzer:fuzztest",
|
||||
"windowmanager_fuzzer:fuzztest",
|
||||
"windowscene_fuzzer:fuzztest",
|
||||
|
@ -60,7 +60,7 @@ ohos_fuzztest("WindowFuzzTest") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:window_animation",
|
||||
"graphic_2d:window_animation",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
|
@ -60,7 +60,7 @@ ohos_fuzztest("WindowAgentFuzzTest") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:window_animation",
|
||||
"graphic_2d:window_animation",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
|
95
test/fuzztest/wms/windowimpl_fuzzer/BUILD.gn
Normal file
95
test/fuzztest/wms/windowimpl_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,95 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("../../../../windowmanager_aafwk.gni")
|
||||
|
||||
module_output_path = "window_manager/wms"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("WindowImplFuzzTest") {
|
||||
fuzz_config_file = "."
|
||||
module_out_path = module_output_path
|
||||
include_dirs = [
|
||||
"../window_scene/intention_event/service/anr_manager/include",
|
||||
"../window_scene/intention_event/framework/anr_handler/include",
|
||||
"${window_base_path}/window_scene/intention_event/include",
|
||||
"${window_base_path}/test/common/mock",
|
||||
"${window_base_path}/dm/include",
|
||||
"${window_base_path}/dmserver/include",
|
||||
"${window_base_path}/wm/include",
|
||||
"${window_base_path}/wm/include/zidl",
|
||||
"${window_base_path}/wmserver/include",
|
||||
"${window_base_path}/wmserver/include/window_snapshot",
|
||||
"${window_base_path}/interfaces/innerkits/wm",
|
||||
"${window_base_path}/utils/include",
|
||||
"${window_base_path}/window_scene",
|
||||
"${window_base_path}/window_scene/test/mock",
|
||||
"//third_party/googletest/googlemock/include",
|
||||
|
||||
# for abilityContext
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"//third_party/node/deps/icu-small/source/common",
|
||||
"${ability_runtime_inner_api_path}/ability_manager/include",
|
||||
|
||||
# abilityContext end
|
||||
]
|
||||
|
||||
configs = [
|
||||
"../..:configs_cc_ld",
|
||||
"../../../../resources/config/build:coverage_flags",
|
||||
"../../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
sources = [ "windowimpl_fuzzer.cpp" ]
|
||||
deps = [
|
||||
# need delete it for abilitycontext
|
||||
"${window_base_path}/dm:libdm",
|
||||
"${window_base_path}/dmserver:libdms",
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
"${window_base_path}/wm:libwm",
|
||||
"${window_base_path}/wmserver:libwms",
|
||||
"//third_party/googletest:gmock",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_2d:window_animation",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
":WindowImplFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
14
test/fuzztest/wms/windowimpl_fuzzer/corpus/init
Normal file
14
test/fuzztest/wms/windowimpl_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
25
test/fuzztest/wms/windowimpl_fuzzer/project.xml
Normal file
25
test/fuzztest/wms/windowimpl_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
163
test/fuzztest/wms/windowimpl_fuzzer/windowimpl_fuzzer.cpp
Normal file
163
test/fuzztest/wms/windowimpl_fuzzer/windowimpl_fuzzer.cpp
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "windowimpl_fuzzer.h"
|
||||
#include <parcel.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include "marshalling_helper.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_impl.h"
|
||||
#include <refbase.h>
|
||||
|
||||
using namespace OHOS::Rosen;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t DATA_MIN_SIZE = 2;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
{
|
||||
size_t objectSize = sizeof(object);
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
class OccupiedAreaChangeListener : public IOccupiedAreaChangeListener {
|
||||
public:
|
||||
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
|
||||
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class TouchOutsideListener : public ITouchOutsideListener {
|
||||
public:
|
||||
void OnTouchOutside() const override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class AnimationTransitionController : public IAnimationTransitionController {
|
||||
public:
|
||||
void AnimationForShown() override
|
||||
{
|
||||
}
|
||||
|
||||
void AnimationForHidden() override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ScreenshotListener : public IScreenshotListener {
|
||||
public:
|
||||
void OnScreenshot() override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DialogTargetTouchListener : public IDialogTargetTouchListener {
|
||||
public:
|
||||
void OnDialogTargetTouch() const override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DialogDeathRecipientListener : public IDialogDeathRecipientListener {
|
||||
public:
|
||||
void OnDialogDeathRecipient() const override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class AceAbilityHandler : public IAceAbilityHandler {
|
||||
public:
|
||||
void SetBackgroundColor(uint32_t color) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual uint32_t GetBackgroundColor() override
|
||||
{
|
||||
return 0xffffffff;
|
||||
}
|
||||
};
|
||||
|
||||
bool WindowImplFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < DATA_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
NotifyNativeWinDestroyFunc func = [](std::string) {};
|
||||
window->RegisterWindowDestroyedListener(func);
|
||||
|
||||
sptr<IOccupiedAreaChangeListener> occupiedAreaChangeListener = new OccupiedAreaChangeListener();
|
||||
window->RegisterOccupiedAreaChangeListener(occupiedAreaChangeListener);
|
||||
window->UnregisterOccupiedAreaChangeListener(occupiedAreaChangeListener);
|
||||
sptr<ITouchOutsideListener> touchOutsideListener = new TouchOutsideListener();
|
||||
window->RegisterTouchOutsideListener(touchOutsideListener);
|
||||
window->UnregisterTouchOutsideListener(touchOutsideListener);
|
||||
sptr<IAnimationTransitionController> animationTransitionController = new AnimationTransitionController();
|
||||
window->RegisterAnimationTransitionController(animationTransitionController);
|
||||
sptr<IScreenshotListener> screenshotListener = new IScreenshotListener();
|
||||
window->RegisterScreenshotListener(screenshotListener);
|
||||
window->UnregisterScreenshotListener(screenshotListener);
|
||||
sptr<IDialogTargetTouchListener> dialogTargetTouchListener = new DialogTargetTouchListener();
|
||||
window->RegisterDialogTargetTouchListener(dialogTargetTouchListener);
|
||||
window->UnregisterDialogTargetTouchListener(dialogTargetTouchListener);
|
||||
sptr<IDialogDeathRecipientListener> dialogDeathRecipientListener = new DialogDeathRecipientListener();
|
||||
window->RegisterDialogDeathRecipientListener(dialogDeathRecipientListener);
|
||||
window->UnregisterDialogDeathRecipientListener(dialogDeathRecipientListener);
|
||||
sptr<IAceAbilityHandler> aceAbilityHandler = new AceAbilityHandler();
|
||||
window->SetAceAbilityHandler(aceAbilityHandler);
|
||||
size_t startPos = 0;
|
||||
uint32_t modeSupportInfo;
|
||||
startPos += GetObject<uint32_t>(modeSupportInfo, data + startPos, size - startPos);
|
||||
window->SetRequestModeSupportInfo(modeSupportInfo);
|
||||
float ratio;
|
||||
startPos += GetObject<float>(ratio, data + startPos, size - startPos);
|
||||
window->SetAspectRatio(ratio);
|
||||
AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM;
|
||||
AvoidArea avoidArea;
|
||||
startPos += GetObject<AvoidAreaType>(avoidAreaType, data + startPos, size - startPos);
|
||||
startPos += GetObject<AvoidArea>(avoidArea, data + startPos, size - startPos);
|
||||
window->GetAvoidAreaByType(avoidAreaType, avoidArea);
|
||||
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
|
||||
uint32_t invalidGravityPercent = 0;
|
||||
startPos += GetObject<WindowGravity>(gravity, data + startPos, size - startPos);
|
||||
startPos += GetObject<uint32_t>(invalidGravityPercent, data + startPos, size - startPos);
|
||||
window->SetWindowGravity(gravity, invalidGravityPercent);
|
||||
sptr<IRemoteObject> targetToken;
|
||||
window->BindDialogTarget(targetToken);
|
||||
std::string color = "#FF22EE44";
|
||||
window->SetShadowColor(color);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace.OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::WindowImplFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
21
test/fuzztest/wms/windowimpl_fuzzer/windowimpl_fuzzer.h
Normal file
21
test/fuzztest/wms/windowimpl_fuzzer/windowimpl_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_WINDOW_IMPL_FUZZER_H
|
||||
#define TEST_FUZZTEST_WINDOW_IMPL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "windowimpl_fuzzer"
|
||||
|
||||
#endif
|
@ -76,6 +76,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class WaterMarkFlagChangedListener : public IWaterMarkFlagChangedListener {
|
||||
public:
|
||||
void OnWaterMarkFlagUpdate(bool showWaterMark) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class GestureNavigationEnabledChangedListener : public IGestureNavigationEnabledChangedListener {
|
||||
public:
|
||||
void OnGestureNavigationEnabledUpdate(bool enable) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
bool DoSomethingForWindowManagerImpl(WindowManager& windowManager, const uint8_t* data, size_t size)
|
||||
{
|
||||
@ -88,6 +101,9 @@ bool DoSomethingForWindowManagerImpl(WindowManager& windowManager, const uint8_t
|
||||
startPos += GetObject<uint32_t>(accessTokenId, data + startPos, size - startPos);
|
||||
startPos += GetObject<bool>(isShowing, data + startPos, size - startPos);
|
||||
windowManager.UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
|
||||
bool enable;
|
||||
startPos += GetObject<bool>(enable, data + startPos, size - startPos);
|
||||
windowManager.SetGestureNavigaionEnabled(enable);
|
||||
|
||||
Parcel windowVisibilityInfosParcel;
|
||||
if (windowVisibilityInfosParcel.WriteBuffer(data, size)) {
|
||||
@ -170,6 +186,12 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
windowManager.UnregisterVisibilityChangedListener(visibilityChangedListener);
|
||||
windowManager.UnregisterWindowUpdateListener(windowUpdateListener);
|
||||
windowManager.UnregisterCameraFloatWindowChangedListener(cameraFloatWindowChanagedListener);
|
||||
sptr<IWaterMarkFlagChangedListener> waterMarkFlagChangedListener = new WaterMarkFlagChangedListener();
|
||||
windowManager.RegisterWaterMarkFlagChangedListener(waterMarkFlagChangedListener);
|
||||
windowManager.UnregisterWaterMarkFlagChangedListener(waterMarkFlagChangedListener);
|
||||
sptr<IGestureNavigationEnabledChangedListener> gestureListener = new GestureNavigationEnabledChangedListener();
|
||||
windowManager.RegisterGestureNavigationEnabledChangedListener(gestureListener);
|
||||
windowManager.UnregisterGestureNavigationEnabledChangedListener(gestureListener);
|
||||
return true;
|
||||
}
|
||||
} // namespace.OHOS
|
||||
|
@ -16,11 +16,13 @@
|
||||
#include "windowscene_fuzzer.h"
|
||||
|
||||
#include <securec.h>
|
||||
#include <new>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "window.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_scene.h"
|
||||
#include "window_option.h"
|
||||
|
||||
using namespace OHOS::Rosen;
|
||||
|
||||
@ -102,6 +104,11 @@ size_t InitWindowOption2(WindowOption &windowOption, const uint8_t *data, size_t
|
||||
uint32_t flags;
|
||||
startPos += GetObject<uint32_t>(flags, data + startPos, size - startPos);
|
||||
windowOption.SetWindowFlags(flags);
|
||||
WindowFlag windowFlag;
|
||||
startPos += GetObject<WindowFlag>(windowFlag, data + startPos, size - startPos);
|
||||
windowOption.AddWindowFlag(windowFlag);
|
||||
startPos += GetObject<WindowFlag>(windowFlag, data + startPos, size - startPos);
|
||||
windowOption.RemoveWindowFlag(windowFlag);
|
||||
PointInfo hitOffset;
|
||||
startPos += GetObject<PointInfo>(hitOffset, data + startPos, size - startPos);
|
||||
windowOption.SetHitOffset(hitOffset.x, hitOffset.y);
|
||||
@ -178,6 +185,9 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
window->Destroy();
|
||||
}
|
||||
windowScene->GoDestroy();
|
||||
uint32_t level;
|
||||
startPos += GetObject<uint32_t>(level, data + startPos, size - startPos);
|
||||
windowScene->NotifyMemoryLevel(level);
|
||||
return true;
|
||||
}
|
||||
} // namespace.OHOS
|
||||
|
@ -76,8 +76,8 @@ ohos_static_library("libwmutil_static") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_standard:surface",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
@ -135,9 +135,9 @@ ohos_shared_library("libwmutil") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:2d_graphics",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_standard:surface",
|
||||
"graphic_2d:2d_graphics",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
|
@ -303,8 +303,6 @@ bool SurfaceDraw::DoDrawImageRect(sptr<OHOS::SurfaceBuffer> buffer, const Rect&
|
||||
// actual width of the surface buffer after alignment
|
||||
auto bufferStride = buffer->GetStride();
|
||||
int32_t alignWidth = bufferStride / static_cast<int32_t>(IMAGE_BYTES_STRIDE);
|
||||
WLOGFD("drawing image rect win width: %{public}d win height: %{public}d align width:%{public}d.",
|
||||
winWidth, winHeight, alignWidth);
|
||||
if (pixelMap == nullptr) {
|
||||
WLOGFE("drawing pixel map failed, because pixel map is nullptr.");
|
||||
return false;
|
||||
@ -313,21 +311,6 @@ bool SurfaceDraw::DoDrawImageRect(sptr<OHOS::SurfaceBuffer> buffer, const Rect&
|
||||
WLOGFE("drawing pixel map failed, because width or height is invalid.");
|
||||
return false;
|
||||
}
|
||||
float xAxis = static_cast<float>(winWidth) / pixelMap->GetWidth();
|
||||
float yAxis = static_cast<float>(winHeight) / pixelMap->GetHeight();
|
||||
float axis = std::min(xAxis, yAxis);
|
||||
if (axis < 1.0) {
|
||||
// scale when the size of the pixel map is larger than the window
|
||||
// use axis to scale equally
|
||||
pixelMap->scale(axis, axis);
|
||||
} else if (fillWindow) {
|
||||
// scale snapshot to whole window
|
||||
pixelMap->scale(xAxis, yAxis);
|
||||
}
|
||||
int left = (winWidth - pixelMap->GetWidth()) / 2; // 2 is the left and right boundaries of the window
|
||||
int top = (winHeight - pixelMap->GetHeight()) / 2; // 2 is the top and bottom boundaries of the window
|
||||
WLOGFD("pixelMap width: %{public}d win height: %{public}d left:%{public}d top:%{public}d.",
|
||||
pixelMap->GetWidth(), pixelMap->GetHeight(), left, top);
|
||||
Drawing::Bitmap bitmap;
|
||||
Drawing::BitmapFormat format { Drawing::ColorType::COLORTYPE_RGBA_8888,
|
||||
Drawing::AlphaType::ALPHATYPE_OPAQUE };
|
||||
@ -335,6 +318,25 @@ bool SurfaceDraw::DoDrawImageRect(sptr<OHOS::SurfaceBuffer> buffer, const Rect&
|
||||
Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
canvas.Clear(color);
|
||||
float xAxis = static_cast<float>(winWidth) / pixelMap->GetWidth();
|
||||
float yAxis = static_cast<float>(winHeight) / pixelMap->GetHeight();
|
||||
float axis = std::min(xAxis, yAxis);
|
||||
int scaledPixelMapW = pixelMap->GetWidth();
|
||||
int scaledPixelMapH = pixelMap->GetHeight();
|
||||
if (axis < 1.0) {
|
||||
canvas.Scale(axis, axis);
|
||||
scaledPixelMapW = scaledPixelMapW * axis;
|
||||
scaledPixelMapH = scaledPixelMapH * axis;
|
||||
} else if (fillWindow) {
|
||||
// scale snapshot to whole window
|
||||
canvas.Scale(xAxis, yAxis);
|
||||
scaledPixelMapW = winWidth;
|
||||
scaledPixelMapH = winHeight;
|
||||
}
|
||||
int left = (winWidth - scaledPixelMapW) / 2; // 2 is the left and right boundaries of the win
|
||||
int top = (winHeight - scaledPixelMapH) / 2; // 2 is the top and bottom boundaries of the win
|
||||
WLOGFD("pixelMap width: %{public}d win height: %{public}d left:%{public}d top:%{public}d.",
|
||||
pixelMap->GetWidth(), pixelMap->GetHeight(), left, top);
|
||||
canvas.DrawBitmap(*pixelMap, left, top);
|
||||
// bufferSize is actual size of the surface buffer after alignment
|
||||
int32_t bufferSize = bufferStride * winHeight;
|
||||
|
@ -50,7 +50,7 @@ ohos_unittest("utils_screen_info_test") {
|
||||
|
||||
deps = [ ":utils_unittest_common" ]
|
||||
|
||||
external_deps = [ "graphic_standard:surface" ]
|
||||
external_deps = [ "graphic_2d:surface" ]
|
||||
}
|
||||
|
||||
ohos_unittest("utils_screen_group_info_test") {
|
||||
@ -60,7 +60,7 @@ ohos_unittest("utils_screen_group_info_test") {
|
||||
|
||||
deps = [ ":utils_unittest_common" ]
|
||||
|
||||
external_deps = [ "graphic_standard:surface" ]
|
||||
external_deps = [ "graphic_2d:surface" ]
|
||||
}
|
||||
|
||||
ohos_unittest("utils_string_test") {
|
||||
@ -103,6 +103,7 @@ ohos_unittest("utils_surface_draw_test") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class Permission {
|
||||
public:
|
||||
static bool IsSystemServiceCalling(bool needPrintLog = true);
|
||||
static bool IsSystemCalling();
|
||||
static bool IsStartByHdcd();
|
||||
static bool IsStartedByInputMethod();
|
||||
};
|
||||
} // Rosen
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <unordered_map>
|
||||
#include <parcel.h>
|
||||
#include "interfaces/include/ws_common.h"
|
||||
#include "interfaces/include/ws_common_inner.h"
|
||||
#include "wm_common.h"
|
||||
#include "dm_common.h"
|
||||
#include <cfloat>
|
||||
@ -78,7 +79,8 @@ public:
|
||||
void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
|
||||
void SetSessionGravity(SessionGravity gravity_, uint32_t percent);
|
||||
void SetDecorEnable(bool isDecorEnable);
|
||||
void SetZOrder(uint32_t zOrder);
|
||||
void SetAnimationFlag(uint32_t animationFlag);
|
||||
void SetTransform(const Transform& trans);
|
||||
void SetWindowFlags(uint32_t flags);
|
||||
void AddWindowFlag(WindowFlag flag);
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
@ -110,7 +112,8 @@ public:
|
||||
const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const;
|
||||
void GetSessionGravity(SessionGravity& gravity, uint32_t& percent);
|
||||
bool IsDecorEnable();
|
||||
uint32_t GetZOrder();
|
||||
uint32_t GetAnimationFlag() const;
|
||||
const Transform& GetTransform() const;
|
||||
|
||||
bool MarshallingWindowLimits(Parcel& parcel) const;
|
||||
static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
|
||||
@ -118,6 +121,7 @@ public:
|
||||
static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property);
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowSessionProperty* Unmarshalling(Parcel& parcel);
|
||||
|
||||
private:
|
||||
std::string windowName_;
|
||||
SessionInfo sessionInfo_;
|
||||
@ -148,8 +152,10 @@ private:
|
||||
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
|
||||
};
|
||||
uint32_t zOrder_ = 0;
|
||||
bool isDecorEnable_ = false;
|
||||
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
|
||||
// Transform info
|
||||
Transform trans_;
|
||||
};
|
||||
|
||||
struct SystemSessionConfig : public Parcelable {
|
||||
|
@ -55,6 +55,18 @@ bool Permission::IsSystemCalling()
|
||||
return isSystemApp;
|
||||
}
|
||||
|
||||
bool Permission::IsStartByHdcd()
|
||||
{
|
||||
OHOS::Security::AccessToken::NativeTokenInfo info;
|
||||
if (Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(IPCSkeleton::GetCallingTokenID(), info) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (info.processName.compare("hdcd") == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Permission::IsStartedByInputMethod()
|
||||
{
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "common/include/window_session_property.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -283,16 +284,6 @@ void WindowSessionProperty::GetSessionGravity(SessionGravity& gravity, uint32_t&
|
||||
percent = sessionGravitySizePercent_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetZOrder(uint32_t zOrder)
|
||||
{
|
||||
zOrder_ = zOrder;
|
||||
}
|
||||
|
||||
uint32_t WindowSessionProperty::GetZOrder()
|
||||
{
|
||||
return zOrder_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetDecorEnable(bool isDecorEnable)
|
||||
{
|
||||
isDecorEnable_ = isDecorEnable;
|
||||
@ -313,6 +304,16 @@ uint32_t WindowSessionProperty::GetModeSupportInfo() const
|
||||
return modeSupportInfo_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetAnimationFlag(uint32_t animationFlag)
|
||||
{
|
||||
animationFlag_ = animationFlag;
|
||||
}
|
||||
|
||||
uint32_t WindowSessionProperty::GetAnimationFlag() const
|
||||
{
|
||||
return animationFlag_;
|
||||
}
|
||||
|
||||
bool WindowSessionProperty::MarshallingWindowLimits(Parcel& parcel) const
|
||||
{
|
||||
if (parcel.WriteUint32(limits_.maxWidth_) &&
|
||||
@ -378,10 +379,10 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteFloat(brightness_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowMode_)) &&
|
||||
parcel.WriteUint32(zOrder_) &&
|
||||
parcel.WriteUint32(flags_) &&
|
||||
parcel.WriteBool(isDecorEnable_) &&
|
||||
MarshallingWindowLimits(parcel) &&
|
||||
MarshallingSystemBarMap(parcel);
|
||||
MarshallingSystemBarMap(parcel) && parcel.WriteUint32(animationFlag_);
|
||||
}
|
||||
|
||||
WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
||||
@ -413,10 +414,11 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetBrightness(parcel.ReadFloat());
|
||||
property->SetRequestedOrientation(static_cast<Orientation>(parcel.ReadUint32()));
|
||||
property->SetWindowMode(static_cast<WindowMode>(parcel.ReadUint32()));
|
||||
property->SetZOrder(parcel.ReadUint32());
|
||||
property->SetWindowFlags(parcel.ReadUint32());
|
||||
property->SetDecorEnable(parcel.ReadBool());
|
||||
UnmarshallingWindowLimits(parcel, property);
|
||||
UnMarshallingSystemBarMap(parcel, property);
|
||||
property->SetAnimationFlag(parcel.ReadUint32());
|
||||
return property;
|
||||
}
|
||||
|
||||
@ -430,17 +432,34 @@ void WindowSessionProperty::CopyFrom(const sptr<WindowSessionProperty>& property
|
||||
focusable_= property->focusable_;
|
||||
touchable_ = property->touchable_;
|
||||
tokenState_ = property->tokenState_;
|
||||
turnScreenOn_ = property->turnScreenOn_;
|
||||
keepScreenOn_ = property->keepScreenOn_;
|
||||
brightness_ = property->brightness_;
|
||||
requestedOrientation_ = property->requestedOrientation_;
|
||||
isPrivacyMode_ = property->isPrivacyMode_;
|
||||
isSystemPrivacyMode_ = property->isSystemPrivacyMode_;
|
||||
displayId_ = property->displayId_;
|
||||
parentId_ = property->parentId_;
|
||||
flags_ = property->flags_;
|
||||
persistentId_ = property->persistentId_;
|
||||
parentPersistentId_ = property->parentPersistentId_;
|
||||
accessTokenId_ = property->accessTokenId_;
|
||||
maximizeMode_ = property->maximizeMode_;
|
||||
brightness_ = property->brightness_;
|
||||
requestedOrientation_ = property->requestedOrientation_;
|
||||
sysBarPropMap_ = property->sysBarPropMap_;
|
||||
windowMode_ = property->windowMode_;
|
||||
limits_ = property->limits_;
|
||||
sysBarPropMap_ = property->sysBarPropMap_;
|
||||
isDecorEnable_ = property->isDecorEnable_;
|
||||
animationFlag_ = property->animationFlag_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetTransform(const Transform& trans)
|
||||
{
|
||||
trans_ = trans;
|
||||
}
|
||||
|
||||
const Transform& WindowSessionProperty::GetTransform() const
|
||||
{
|
||||
return trans_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -33,8 +33,8 @@ ohos_shared_library("libintention_event") {
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:libcomposer",
|
||||
"graphic_standard:window_animation",
|
||||
"graphic_2d:libcomposer",
|
||||
"graphic_2d:window_animation",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
|
@ -22,7 +22,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DfxHisysevent {
|
||||
public:
|
||||
static void ApplicationBlockInput(int32_t eventId, int32_t pid, int32_t persistentId);
|
||||
static void ApplicationBlockInput(int32_t eventId, int32_t pid, uint64_t persistentId);
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -23,7 +23,7 @@ namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "DfxHisysevent" };
|
||||
} // namespace
|
||||
|
||||
void DfxHisysevent::ApplicationBlockInput(int32_t eventId, int32_t pid, int32_t persistentId)
|
||||
void DfxHisysevent::ApplicationBlockInput(int32_t eventId, int32_t pid, uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = HiSysEventWrite(
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "nocopyable.h"
|
||||
@ -31,7 +32,7 @@ class ANRHandler {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(ANRHandler);
|
||||
|
||||
void SetSessionStage(const wptr<ISessionStage> &sessionStage);
|
||||
void SetSessionStage(int32_t eventId, const wptr<ISessionStage> &sessionStage);
|
||||
void SetLastProcessedEventId(int32_t eventId, int64_t actionTime);
|
||||
|
||||
private:
|
||||
@ -40,9 +41,7 @@ private:
|
||||
void SetLastProcessedEventStatus(bool status);
|
||||
int32_t GetLastProcessedEventId();
|
||||
void SendEvent(int64_t delayTime);
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ { nullptr };
|
||||
wptr<ISessionStage> sessionStage_ = nullptr;
|
||||
|
||||
void ClearExpiredEvents(int32_t eventId);
|
||||
private:
|
||||
std::mutex anrMtx_;
|
||||
struct ANREvent {
|
||||
@ -51,6 +50,8 @@ private:
|
||||
int32_t lastReportId { -1 };
|
||||
};
|
||||
ANREvent event_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ { nullptr };
|
||||
std::unordered_map<int32_t, wptr<ISessionStage>> sessionStageMap_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -47,28 +47,24 @@ ANRHandler::ANRHandler()
|
||||
|
||||
ANRHandler::~ANRHandler() {}
|
||||
|
||||
void ANRHandler::SetSessionStage(const wptr<ISessionStage> &sessionStage)
|
||||
void ANRHandler::SetSessionStage(int32_t eventId, const wptr<ISessionStage> &sessionStage)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(anrMtx_);
|
||||
sessionStage_ = sessionStage;
|
||||
sessionStageMap_[eventId] = sessionStage;
|
||||
}
|
||||
|
||||
void ANRHandler::SetLastProcessedEventStatus(bool status)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
event_.sendStatus = status;
|
||||
}
|
||||
|
||||
void ANRHandler::UpdateLastProcessedEventId(int32_t eventId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
event_.lastEventId = eventId;
|
||||
}
|
||||
|
||||
void ANRHandler::SetLastProcessedEventId(int32_t eventId, int64_t actionTime)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(anrMtx_);
|
||||
if (event_.lastEventId > eventId) {
|
||||
WLOGFE("Event id %{public}d less then last processed lastEventId %{public}d", eventId, event_.lastEventId);
|
||||
@ -98,7 +94,6 @@ void ANRHandler::SetLastProcessedEventId(int32_t eventId, int64_t actionTime)
|
||||
|
||||
int32_t ANRHandler::GetLastProcessedEventId()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (event_.lastEventId == INVALID_OR_PROCESSED_ID
|
||||
|| event_.lastEventId < event_.lastReportId) {
|
||||
WLOGFD("Invalid or processed, lastEventId:%{public}d, lastReportId:%{public}d",
|
||||
@ -112,26 +107,28 @@ int32_t ANRHandler::GetLastProcessedEventId()
|
||||
|
||||
void ANRHandler::MarkProcessed()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t eventId = GetLastProcessedEventId();
|
||||
if (eventId == INVALID_OR_PROCESSED_ID) {
|
||||
return;
|
||||
}
|
||||
WLOGFD("Processed eventId:%{public}d", eventId);
|
||||
if (sessionStage_ == nullptr) {
|
||||
WLOGFE("sessionStage is nullptr");
|
||||
if (sessionStageMap_.find(eventId) == sessionStageMap_.end()) {
|
||||
WLOGFE("sessionStage for eventId:%{public}d is not in sessionStageMap", eventId);
|
||||
return;
|
||||
}
|
||||
if (WSError ret = sessionStage_->MarkProcessed(eventId); ret != WSError::WS_OK) {
|
||||
if (sessionStageMap_[eventId] == nullptr) {
|
||||
WLOGFE("sessionStage for eventId:%{public}d is nullptr", eventId);
|
||||
return;
|
||||
}
|
||||
if (WSError ret = sessionStageMap_[eventId]->MarkProcessed(eventId); ret != WSError::WS_OK) {
|
||||
WLOGFE("Send to sceneBoard failed, ret:%{public}d", ret);
|
||||
}
|
||||
ClearExpiredEvents(eventId);
|
||||
SetLastProcessedEventStatus(false);
|
||||
}
|
||||
|
||||
void ANRHandler::SendEvent(int64_t delayTime)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
WLOGFD("Event delayTime:%{public}" PRId64, delayTime);
|
||||
SetLastProcessedEventStatus(true);
|
||||
if (eventHandler_ == nullptr) {
|
||||
WLOGFE("eventHandler is nullptr");
|
||||
@ -142,5 +139,16 @@ void ANRHandler::SendEvent(int64_t delayTime)
|
||||
WLOGFE("Send dispatch event failed");
|
||||
}
|
||||
}
|
||||
|
||||
void ANRHandler::ClearExpiredEvents(int32_t eventId)
|
||||
{
|
||||
for (auto iter = sessionStageMap_.begin(); iter != sessionStageMap_.end();) {
|
||||
if (iter->first < eventId) {
|
||||
sessionStageMap_.erase(iter++);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -34,20 +34,20 @@ class ANRManager final {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(ANRManager);
|
||||
void Init();
|
||||
void AddTimer(int32_t id, int64_t currentTime, int32_t persistentId);
|
||||
void MarkProcessed(int32_t eventId, int32_t persistentId);
|
||||
bool IsANRTriggered(int64_t time, int32_t persistentId);
|
||||
void OnSessionLost(int32_t persistentId);
|
||||
void SetApplicationPid(int32_t persistentId, int32_t applicationPid);
|
||||
void AddTimer(int32_t id, int64_t currentTime, uint64_t persistentId);
|
||||
void MarkProcessed(int32_t eventId, uint64_t persistentId);
|
||||
bool IsANRTriggered(int64_t time, uint64_t persistentId);
|
||||
void OnSessionLost(uint64_t persistentId);
|
||||
void SetApplicationPid(uint64_t persistentId, int32_t applicationPid);
|
||||
void SetAnrObserver(std::function<void(int32_t)> anrObserver);
|
||||
private:
|
||||
int32_t GetPidByPersistentId(int32_t persistentId);
|
||||
void RemoveTimers(int32_t persistentId);
|
||||
void RemovePersistentId(int32_t persistentId);
|
||||
int32_t GetPidByPersistentId(uint64_t persistentId);
|
||||
void RemoveTimers(uint64_t persistentId);
|
||||
void RemovePersistentId(uint64_t persistentId);
|
||||
private:
|
||||
std::mutex mtx_;
|
||||
int32_t anrTimerCount_ { 0 };
|
||||
std::unordered_map<int32_t, int32_t> applicationMap_;
|
||||
std::unordered_map<uint64_t, int32_t> applicationMap_;
|
||||
std::function<void(int32_t)> anrObserver_;
|
||||
EventStage eventStage_;
|
||||
};
|
||||
|
@ -39,20 +39,19 @@ void ANRManager::Init()
|
||||
TimerMgr->Init();
|
||||
}
|
||||
|
||||
void ANRManager::AddTimer(int32_t id, int64_t currentTime, int32_t persistentId)
|
||||
void ANRManager::AddTimer(int32_t id, int64_t currentTime, uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
if (anrTimerCount_ >= MAX_ANR_TIMER_COUNT) {
|
||||
WLOGFD("AddAnrTimer failed, anrTimerCount exceeded %{public}d", MAX_ANR_TIMER_COUNT);
|
||||
return;
|
||||
}
|
||||
int32_t timerId = TimerMgr->AddTimer(ANRTimeOutTime::INPUT_UI_TIMEOUT_TIME, [this, id, persistentId]() {
|
||||
WLOGFD("Anr callback enter. persistentId:%{public}d, eventId:%{public}d", persistentId, id);
|
||||
WLOGFD("Anr callback enter. persistentId:%{public}" PRIu64 ", eventId:%{public}d", persistentId, id);
|
||||
eventStage_.SetAnrStatus(persistentId, true);
|
||||
int32_t pid = GetPidByPersistentId(persistentId);
|
||||
DfxHisysevent::ApplicationBlockInput(id, pid, persistentId);
|
||||
WLOGFE("Application not responding. persistentId:%{public}d, eventId:%{public}d, applicationId:%{public}d",
|
||||
WLOGFE("Application not responding. persistentId:%{public}" PRIu64 ", eventId:%{public}d, pid:%{public}d",
|
||||
persistentId, id, pid);
|
||||
if (anrObserver_ != nullptr) {
|
||||
anrObserver_(pid);
|
||||
@ -61,53 +60,42 @@ void ANRManager::AddTimer(int32_t id, int64_t currentTime, int32_t persistentId)
|
||||
}
|
||||
std::vector<int32_t> timerIds = eventStage_.GetTimerIds(persistentId);
|
||||
for (int32_t item : timerIds) {
|
||||
WLOGFD("timer %{public}d will be removed", item);
|
||||
if (item != -1) {
|
||||
TimerMgr->RemoveTimer(item);
|
||||
anrTimerCount_--;
|
||||
WLOGFD("Clear anr timer, timer id:%{public}d, count:%{public}d", item, anrTimerCount_);
|
||||
}
|
||||
}
|
||||
WLOGFD("Anr callback leave. persistentId:%{public}d, eventId:%{public}d", persistentId, id);
|
||||
WLOGFD("Anr callback leave. persistentId:%{public}" PRIu64 ", eventId:%{public}d", persistentId, id);
|
||||
});
|
||||
anrTimerCount_++;
|
||||
WLOGFI("Add anr timer success, eventId:%{public}d, timer id:%{public}d, persistentId:%{public}d, count:%{public}d",
|
||||
id, timerId, persistentId, anrTimerCount_);
|
||||
eventStage_.SaveANREvent(persistentId, id, currentTime, timerId);
|
||||
}
|
||||
|
||||
void ANRManager::MarkProcessed(int32_t eventId, int32_t persistentId)
|
||||
void ANRManager::MarkProcessed(int32_t eventId, uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
WLOGFD("eventId:%{public}d, persistentId:%{public}d", eventId, persistentId);
|
||||
WLOGFD("eventId:%{public}d, persistentId:%{public}" PRIu64 "", eventId, persistentId);
|
||||
std::list<int32_t> timerIds = eventStage_.DelEvents(persistentId, eventId);
|
||||
if (timerIds.empty()) {
|
||||
WLOGFD("timerIds to remove is empty");
|
||||
}
|
||||
for (int32_t item : timerIds) {
|
||||
if (item != -1) {
|
||||
TimerMgr->RemoveTimer(item);
|
||||
anrTimerCount_--;
|
||||
WLOGFD("Remove anr timer, eventId:%{public}d, timer id:%{public}d,"
|
||||
"count:%{public}d", eventId, item, anrTimerCount_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ANRManager::IsANRTriggered(int64_t time, int32_t persistentId)
|
||||
bool ANRManager::IsANRTriggered(int64_t time, uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
if (eventStage_.CheckAnrStatus(persistentId)) {
|
||||
WLOGFD("Application not responding. persistentId:%{public}d", persistentId);
|
||||
WLOGFD("Application not responding. persistentId:%{public}" PRIu64 "", persistentId);
|
||||
return true;
|
||||
}
|
||||
WLOGFD("Event dispatch normal");
|
||||
return false;
|
||||
}
|
||||
|
||||
void ANRManager::OnSessionLost(int32_t persistentId)
|
||||
void ANRManager::OnSessionLost(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
@ -115,11 +103,10 @@ void ANRManager::OnSessionLost(int32_t persistentId)
|
||||
RemovePersistentId(persistentId);
|
||||
}
|
||||
|
||||
void ANRManager::SetApplicationPid(int32_t persistentId, int32_t applicationPid)
|
||||
void ANRManager::SetApplicationPid(uint64_t persistentId, int32_t applicationPid)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
WLOGFD("persistentId:%{public}d -> applicationPid:%{public}d", persistentId, applicationPid);
|
||||
WLOGFD("persistentId:%{public}" PRIu64 " -> applicationPid:%{public}d", persistentId, applicationPid);
|
||||
applicationMap_[persistentId] = applicationPid;
|
||||
}
|
||||
|
||||
@ -130,20 +117,18 @@ void ANRManager::SetAnrObserver(std::function<void(int32_t)> anrObserver)
|
||||
anrObserver_ = anrObserver;
|
||||
}
|
||||
|
||||
int32_t ANRManager::GetPidByPersistentId(int32_t persistentId)
|
||||
int32_t ANRManager::GetPidByPersistentId(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("persistentId:%{public}d -> applicationPid:%{public}d", persistentId, applicationMap_[persistentId]);
|
||||
WLOGFD("persistentId:%{public}" PRIu64 " -> pid:%{public}d", persistentId, applicationMap_[persistentId]);
|
||||
return applicationMap_[persistentId];
|
||||
}
|
||||
WLOGFD("No application matches persistentId:%{public}d", persistentId);
|
||||
WLOGFD("No application matches persistentId:%{public}" PRIu64 "", persistentId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ANRManager::RemoveTimers(int32_t persistentId)
|
||||
void ANRManager::RemoveTimers(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::vector<int32_t> timerIds = eventStage_.GetTimerIds(persistentId);
|
||||
for (int32_t item : timerIds) {
|
||||
if (item != -1) {
|
||||
@ -153,15 +138,15 @@ void ANRManager::RemoveTimers(int32_t persistentId)
|
||||
}
|
||||
}
|
||||
|
||||
void ANRManager::RemovePersistentId(int32_t persistentId)
|
||||
void ANRManager::RemovePersistentId(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
||||
WLOGFD("Remove persistentId:%{public}d -> applicationPid:%{public}d",
|
||||
persistentId, applicationMap_[persistentId]);
|
||||
applicationMap_.erase(persistentId);
|
||||
if (applicationMap_.find(persistentId) == applicationMap_.end()) {
|
||||
WLOGFD("No persistentId:%{public}" PRIu64 " in applicationMap", persistentId);
|
||||
return;
|
||||
}
|
||||
WLOGFD("No persistentId:%{public}d in applicationMap", persistentId);
|
||||
WLOGFD("Remove persistentId:%{public}" PRIu64 " -> applicationPid:%{public}d",
|
||||
persistentId, applicationMap_[persistentId]);
|
||||
applicationMap_.erase(persistentId);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -23,11 +23,11 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
class EventStage {
|
||||
public:
|
||||
void SetAnrStatus(int32_t persistentId, bool status);
|
||||
bool CheckAnrStatus(int32_t persistentId);
|
||||
void SaveANREvent(int32_t persistentId, int32_t id, int64_t time, int32_t timerId);
|
||||
std::vector<int32_t> GetTimerIds(int32_t persistentId);
|
||||
std::list<int32_t> DelEvents(int32_t persistentId, int32_t id);
|
||||
void SetAnrStatus(uint64_t persistentId, bool status);
|
||||
bool CheckAnrStatus(uint64_t persistentId);
|
||||
void SaveANREvent(uint64_t persistentId, int32_t id, int64_t time, int32_t timerId);
|
||||
std::vector<int32_t> GetTimerIds(uint64_t persistentId);
|
||||
std::list<int32_t> DelEvents(uint64_t persistentId, int32_t id);
|
||||
private:
|
||||
struct EventTime {
|
||||
int32_t id { 0 };
|
||||
|
@ -29,35 +29,30 @@ namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "EventStage" };
|
||||
} // namespace
|
||||
|
||||
void EventStage::SetAnrStatus(int32_t persistentId, bool status)
|
||||
void EventStage::SetAnrStatus(uint64_t persistentId, bool status)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
isAnrProcess_[persistentId] = status;
|
||||
}
|
||||
|
||||
bool EventStage::CheckAnrStatus(int32_t persistentId)
|
||||
bool EventStage::CheckAnrStatus(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (isAnrProcess_.find(persistentId) != isAnrProcess_.end()) {
|
||||
return isAnrProcess_[persistentId];
|
||||
}
|
||||
WLOGFD("Current persistentId:%{public}d is not in event stage", persistentId);
|
||||
WLOGFD("Current persistentId:%{public}" PRIu64 " is not in event stage", persistentId);
|
||||
return false;
|
||||
}
|
||||
|
||||
void EventStage::SaveANREvent(int32_t persistentId, int32_t id, int64_t time, int32_t timerId)
|
||||
void EventStage::SaveANREvent(uint64_t persistentId, int32_t id, int64_t time, int32_t timerId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
WLOGFD("Current persistentId:%{public}d, eventId:%{public}d, timerId:%{public}d", persistentId, id, timerId);
|
||||
EventTime eventTime { id, time, timerId };
|
||||
events_[persistentId].push_back(eventTime);
|
||||
}
|
||||
|
||||
std::vector<int32_t> EventStage::GetTimerIds(int32_t persistentId)
|
||||
std::vector<int32_t> EventStage::GetTimerIds(uint64_t persistentId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (events_.find(persistentId) == events_.end()) {
|
||||
WLOGFD("Current events have no event for persistentId:%{public}d", persistentId);
|
||||
WLOGFD("Current events have no event for persistentId:%{public}" PRIu64 "", persistentId);
|
||||
return {};
|
||||
}
|
||||
std::vector<int32_t> timers;
|
||||
@ -68,12 +63,11 @@ std::vector<int32_t> EventStage::GetTimerIds(int32_t persistentId)
|
||||
return timers;
|
||||
}
|
||||
|
||||
std::list<int32_t> EventStage::DelEvents(int32_t persistentId, int32_t id)
|
||||
std::list<int32_t> EventStage::DelEvents(uint64_t persistentId, int32_t id)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
WLOGFD("Delete events, persistentId:%{public}d, id:%{public}d", persistentId, id);
|
||||
WLOGFD("Delete events, persistentId:%{public}" PRIu64 ", id:%{public}d", persistentId, id);
|
||||
if (events_.find(persistentId) == events_.end()) {
|
||||
WLOGFD("Current events have no event persistentId:%{public}d", persistentId);
|
||||
WLOGFD("Current events have no event persistentId:%{public}" PRIu64 "", persistentId);
|
||||
return {};
|
||||
}
|
||||
auto &events = events_[persistentId];
|
||||
@ -82,7 +76,6 @@ std::list<int32_t> EventStage::DelEvents(int32_t persistentId, int32_t id)
|
||||
});
|
||||
std::list<int32_t> timerIds;
|
||||
for (auto iter = events.begin(); iter != fistMatchIter; iter++) {
|
||||
WLOGFD("Push timer:%{public}d, eventId:%{public}d in timerIds to remove", iter->timerId, iter->id);
|
||||
timerIds.push_back(iter->timerId);
|
||||
}
|
||||
events.erase(events.begin(), fistMatchIter);
|
||||
|
@ -42,7 +42,6 @@ public:
|
||||
void Stop();
|
||||
int32_t AddTimer(int32_t intervalMs, std::function<void()> callback);
|
||||
int32_t RemoveTimer(int32_t timerId);
|
||||
bool IsExist(int32_t timerId);
|
||||
int32_t CalcNextDelay();
|
||||
void ProcessTimers();
|
||||
|
||||
@ -59,7 +58,6 @@ private:
|
||||
int32_t TakeNextTimerId();
|
||||
int32_t AddTimerInternal(int32_t intervalMs, std::function<void()> callback);
|
||||
int32_t RemoveTimerInternal(int32_t timerId);
|
||||
bool IsExistInternal(int32_t timerId);
|
||||
void InsertTimerInternal(std::unique_ptr<TimerItem>& timer);
|
||||
int32_t CalcNextDelayInternal();
|
||||
void ProcessTimersInternal();
|
||||
|
@ -54,22 +54,14 @@ void TimerManager::Stop()
|
||||
|
||||
int32_t TimerManager::AddTimer(int32_t intervalMs, std::function<void()> callback)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
return AddTimerInternal(intervalMs, callback);
|
||||
}
|
||||
|
||||
int32_t TimerManager::RemoveTimer(int32_t timerId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
return RemoveTimerInternal(timerId);
|
||||
}
|
||||
|
||||
bool TimerManager::IsExist(int32_t timerId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
return IsExistInternal(timerId);
|
||||
}
|
||||
|
||||
int32_t TimerManager::CalcNextDelay()
|
||||
{
|
||||
return CalcNextDelayInternal();
|
||||
@ -154,16 +146,6 @@ int32_t TimerManager::RemoveTimerInternal(int32_t timerId)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool TimerManager::IsExistInternal(int32_t timerId)
|
||||
{
|
||||
for (auto it = timers_.begin(); it != timers_.end(); ++it) {
|
||||
if ((*it)->id == timerId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TimerManager::InsertTimerInternal(std::unique_ptr<TimerItem>& timer)
|
||||
{
|
||||
for (auto it = timers_.begin(); it != timers_.end(); ++it) {
|
||||
|
@ -49,6 +49,20 @@ void IntentionEventManager::InputEventListener::OnInputEvent(
|
||||
WLOGFE("uiContent_ is null");
|
||||
return;
|
||||
}
|
||||
if (pointerEvent != nullptr) {
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
if (action == MMI::PointerEvent::POINTER_ACTION_DOWN ||
|
||||
action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) {
|
||||
int32_t pointerId = pointerEvent->GetPointerId();
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
|
||||
WLOGFE("uiContent_ is null");
|
||||
} else {
|
||||
SceneSessionManager::GetInstance().OnOutsideDownEvent(
|
||||
pointerItem.GetDisplayX(), pointerItem.GetDisplayY());
|
||||
}
|
||||
}
|
||||
}
|
||||
uiContent_->ProcessPointerEvent(pointerEvent);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ enum class WSError : int32_t {
|
||||
WS_ERROR_SET_SESSION_LABEL_FAILED,
|
||||
WS_ERROR_SET_SESSION_ICON_FAILED,
|
||||
WS_ERROR_INVALID_SESSION_LISTENER,
|
||||
WS_ERROR_START_UI_EXTENSION_ABILITY_FAILED,
|
||||
WS_ERROR_MIN_UI_EXTENSION_ABILITY_FAILED,
|
||||
WS_ERROR_TERMINATE_UI_EXTENSION_ABILITY_FAILED,
|
||||
};
|
||||
|
||||
enum class WSErrorCode : int32_t {
|
||||
|
@ -41,7 +41,7 @@ enum class WSPropertyChangeAction : uint32_t {
|
||||
ACTION_UPDATE_ANIMATION_FLAG = 1 << 14,
|
||||
ACTION_UPDATE_PRIVACY_MODE = 1 << 15,
|
||||
ACTION_UPDATE_ASPECT_RATIO = 1 << 16,
|
||||
ACTION_UPDATE_MAXIMIZE_STATE = 1 << 17,
|
||||
ACTION_UPDATE_MAXIMIZE_STATE = 1 << 17
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ ohos_shared_library("scenesessionmanager_napi") {
|
||||
"ability_runtime:napi_common",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:window_animation",
|
||||
"graphic_2d:window_animation",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
|
@ -35,11 +35,15 @@ const std::string SESSION_FOCUSABLE_CHANGE_CB = "sessionFocusableChange";
|
||||
const std::string SESSION_TOUCHABLE_CHANGE_CB = "sessionTouchableChange";
|
||||
const std::string CLICK_CB = "click";
|
||||
const std::string TERMINATE_SESSION_CB = "terminateSession";
|
||||
const std::string TERMINATE_SESSION_CB_NEW = "terminateSessionNew";
|
||||
const std::string SESSION_EXCEPTION_CB = "sessionException";
|
||||
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_BACKROUND_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 SHOW_WHEN_LOCKED_CB = "sessionShowWhenLockedChange";
|
||||
} // namespace
|
||||
|
||||
NativeValue* JsSceneSession::Create(NativeEngine& engine, const sptr<SceneSession>& session)
|
||||
@ -89,11 +93,15 @@ JsSceneSession::JsSceneSession(NativeEngine& engine, const sptr<SceneSession>& s
|
||||
{ SESSION_TOUCHABLE_CHANGE_CB, &JsSceneSession::ProcessSessionTouchableChangeRegister },
|
||||
{ CLICK_CB, &JsSceneSession::ProcessClickRegister },
|
||||
{ TERMINATE_SESSION_CB, &JsSceneSession::ProcessTerminateSessionRegister },
|
||||
{ TERMINATE_SESSION_CB_NEW, &JsSceneSession::ProcessTerminateSessionRegisterNew },
|
||||
{ SESSION_EXCEPTION_CB, &JsSceneSession::ProcessSessionExceptionRegister },
|
||||
{ SYSTEMBAR_PROPERTY_CHANGE_CB, &JsSceneSession::ProcessSystemBarPropertyChangeRegister },
|
||||
{ NEED_AVOID_CB, &JsSceneSession::ProcessNeedAvoidRegister },
|
||||
{ PENDING_SESSION_TO_FOREGROUND_CB, &JsSceneSession::ProcessPendingSessionToForegroundRegister },
|
||||
{ PENDING_SESSION_TO_BACKROUND_FOR_DELEGATOR_CB, &JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister },
|
||||
{ NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB, &JsSceneSession::ProcessSessionDefaultAnimationFlagChangeRegister },
|
||||
{ CUSTOM_ANIMATION_PLAYING_CB, &JsSceneSession::ProcessIsCustomAnimationPlaying },
|
||||
{ SHOW_WHEN_LOCKED_CB, &JsSceneSession::ProcessShowWhenLockedRegister },
|
||||
};
|
||||
|
||||
sptr<SceneSession::SessionChangeCallback> sessionchangeCallback = new (std::nothrow)
|
||||
@ -112,6 +120,40 @@ JsSceneSession::~JsSceneSession()
|
||||
WLOGD("~JsSceneSession");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessSessionDefaultAnimationFlagChangeRegister()
|
||||
{
|
||||
auto sessionchangeCallback = sessionchangeCallback_.promote();
|
||||
if (sessionchangeCallback == nullptr) {
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onWindowAnimationFlagChange_ = std::bind(
|
||||
&JsSceneSession::OnDefaultAnimationFlagChange, this, std::placeholders::_1);
|
||||
WLOGFD("ProcessSessionDefaultAnimationFlagChangeRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::OnDefaultAnimationFlagChange(bool isNeedDefaultAnimationFlag)
|
||||
{
|
||||
WLOGFI("[NAPI]OnDefaultAnimationFlagChange, flag: %{public}u", isNeedDefaultAnimationFlag);
|
||||
auto iter = jsCbMap_.find(NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[isNeedDefaultAnimationFlag, jsCallBack, eng = &engine_](
|
||||
NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
NativeValue* jsSessionDefaultAnimationFlagObj = CreateJsValue(engine, isNeedDefaultAnimationFlag);
|
||||
NativeValue* argv[] = { jsSessionDefaultAnimationFlagObj };
|
||||
engine.CallFunction(engine.CreateUndefined(), jsCallBack->Get(), argv, ArraySize(argv));
|
||||
});
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSession::OnDefaultAnimationFlagChange", engine_,
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
|
||||
{
|
||||
NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) {
|
||||
@ -200,6 +242,21 @@ void JsSceneSession::ProcessTerminateSessionRegister()
|
||||
WLOGFD("ProcessTerminateSessionRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessTerminateSessionRegisterNew()
|
||||
{
|
||||
WLOGFD("begin to run ProcessTerminateSessionRegisterNew");
|
||||
NotifyTerminateSessionFuncNew func = [this](const SessionInfo& info, bool needStartCaller) {
|
||||
this->TerminateSessionNew(info, needStartCaller);
|
||||
};
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
return;
|
||||
}
|
||||
session->SetTerminateSessionListenerNew(func);
|
||||
WLOGFD("ProcessTerminateSessionRegisterNew success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessPendingSessionToForegroundRegister()
|
||||
{
|
||||
WLOGFD("begin to run ProcessPendingSessionToForegroundRegister");
|
||||
@ -353,6 +410,33 @@ void JsSceneSession::ProcessNeedAvoidRegister()
|
||||
WLOGFD("ProcessNeedAvoidRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessIsCustomAnimationPlaying()
|
||||
{
|
||||
auto sessionchangeCallback = sessionchangeCallback_.promote();
|
||||
if (sessionchangeCallback == nullptr) {
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->onIsCustomAnimationPlaying_ = std::bind(
|
||||
&JsSceneSession::OnIsCustomAnimationPlaying, this, std::placeholders::_1);
|
||||
WLOGFD("ProcessIsCustomAnimationPlaying success");
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessShowWhenLockedRegister()
|
||||
{
|
||||
auto sessionchangeCallback = sessionchangeCallback_.promote();
|
||||
if (sessionchangeCallback == nullptr) {
|
||||
WLOGFE("sessionchangeCallback is nullptr");
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnShowWhenLocked_ = std::bind(
|
||||
&JsSceneSession::OnShowWhenLocked, this, std::placeholders::_1);
|
||||
auto session = weakSession_.promote();
|
||||
sessionchangeCallback->OnShowWhenLocked_(
|
||||
session->IsShowWhenLocked() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED));
|
||||
WLOGFD("ProcessShowWhenLockedRegister success");
|
||||
}
|
||||
|
||||
void JsSceneSession::Finalizer(NativeEngine* engine, void* data, void* hint)
|
||||
{
|
||||
WLOGI("[NAPI]Finalizer");
|
||||
@ -710,6 +794,36 @@ void JsSceneSession::TerminateSession(const SessionInfo& info)
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSession::TerminateSessionNew(const SessionInfo& info, bool needStartCaller)
|
||||
{
|
||||
WLOGFI("[NAPI]run TerminateSessionNew, bundleName = %{public}s, id = %{public}s",
|
||||
info.bundleName_.c_str(), info.abilityName_.c_str());
|
||||
auto iter = jsCbMap_.find(TERMINATE_SESSION_CB_NEW);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[info, needStartCaller, jsCallBack](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (!jsCallBack) {
|
||||
WLOGFE("[NAPI]jsCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
NativeValue* jsNeedStartCaller = CreateJsValue(engine, needStartCaller);
|
||||
if (jsNeedStartCaller == nullptr) {
|
||||
WLOGFE("[NAPI]this target jsNeedStartCaller is nullptr");
|
||||
return;
|
||||
}
|
||||
NativeValue* argv[] = { jsNeedStartCaller };
|
||||
engine.CallFunction(engine.CreateUndefined(), jsCallBack->Get(), argv, ArraySize(argv));
|
||||
});
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSession::TerminateSessionNew", engine_,
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSession::OnSessionException(const SessionInfo& info)
|
||||
{
|
||||
WLOGFI("[NAPI]run OnSessionException, bundleName = %{public}s, id = %{public}s",
|
||||
@ -844,6 +958,48 @@ void JsSceneSession::OnNeedAvoid(bool status)
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSession::OnIsCustomAnimationPlaying(bool status)
|
||||
{
|
||||
WLOGFI("[NAPI]OnIsCustomAnimationPlaying %{public}d", status);
|
||||
auto iter = jsCbMap_.find(CUSTOM_ANIMATION_PLAYING_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[jsCallBack, isPlaying = status, eng = &engine_](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
NativeValue* jsSessionStateObj = CreateJsValue(engine, isPlaying);
|
||||
NativeValue* argv[] = { jsSessionStateObj };
|
||||
engine.CallFunction(engine.CreateUndefined(), jsCallBack->Get(), argv, ArraySize(argv));
|
||||
});
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSession::OnIsCustomAnimationPlaying", engine_,
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSession::OnShowWhenLocked(bool showWhenLocked)
|
||||
{
|
||||
WLOGFI("[NAPI]OnShowWhenLocked %{public}d", showWhenLocked);
|
||||
auto iter = jsCbMap_.find(SHOW_WHEN_LOCKED_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
auto jsCallBack = iter->second;
|
||||
auto complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[jsCallBack, flag = showWhenLocked, eng = &engine_](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
NativeValue* jsSessionStateObj = CreateJsValue(engine, flag);
|
||||
NativeValue* argv[] = { jsSessionStateObj };
|
||||
engine.CallFunction(engine.CreateUndefined(), jsCallBack->Get(), argv, ArraySize(argv));
|
||||
});
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSession::OnShowWhenLocked", engine_,
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
sptr<SceneSession> JsSceneSession::GetNativeSession() const
|
||||
{
|
||||
return weakSession_.promote();
|
||||
|
@ -55,11 +55,15 @@ private:
|
||||
void ProcessSessionTouchableChangeRegister();
|
||||
void ProcessClickRegister();
|
||||
void ProcessTerminateSessionRegister();
|
||||
void ProcessTerminateSessionRegisterNew();
|
||||
void ProcessSessionExceptionRegister();
|
||||
void ProcessSystemBarPropertyChangeRegister();
|
||||
void ProcessNeedAvoidRegister();
|
||||
void ProcessPendingSessionToForegroundRegister();
|
||||
void ProcessPendingSessionToBackgroundForDelegatorRegister();
|
||||
void ProcessSessionDefaultAnimationFlagChangeRegister();
|
||||
void ProcessIsCustomAnimationPlaying();
|
||||
void ProcessShowWhenLockedRegister();
|
||||
|
||||
void PendingSessionActivation(SessionInfo& info);
|
||||
void OnSessionStateChange(const SessionState& state);
|
||||
@ -72,12 +76,16 @@ private:
|
||||
void OnSessionTouchableChange(bool touchable);
|
||||
void OnClick();
|
||||
void TerminateSession(const SessionInfo& info);
|
||||
void TerminateSessionNew(const SessionInfo& info, bool needStartCaller);
|
||||
void OnSessionException(const SessionInfo& info);
|
||||
static JsSessionType GetApiType(WindowType type);
|
||||
void OnSystemBarPropertyChange(const std::unordered_map<WindowType, SystemBarProperty>& propertyMap);
|
||||
void OnNeedAvoid(bool status);
|
||||
void PendingSessionToForeground(const SessionInfo& info);
|
||||
void PendingSessionToBackgroundForDelegator(const SessionInfo& info);
|
||||
void OnDefaultAnimationFlagChange(bool isNeedDefaultAnimationFlag);
|
||||
void OnIsCustomAnimationPlaying(bool status);
|
||||
void OnShowWhenLocked(bool showWhenLocked);
|
||||
|
||||
NativeEngine& engine_;
|
||||
wptr<SceneSession> weakSession_ = nullptr;
|
||||
|
@ -36,6 +36,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsSceneSessionManager" };
|
||||
const std::string CREATE_SPECIFIC_SCENE_CB = "createSpecificSession";
|
||||
const std::string GESTURE_NAVIGATION_ENABLED_CHANGE_CB = "gestureNavigationEnabledChange";
|
||||
const std::string OUTSIDE_DOWN_EVENT_CB = "outsideDownEvent";
|
||||
constexpr int32_t STATE_ABNORMALLY = static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY);
|
||||
} // namespace
|
||||
|
||||
@ -89,6 +90,7 @@ JsSceneSessionManager::JsSceneSessionManager(NativeEngine& engine) : engine_(eng
|
||||
{ CREATE_SPECIFIC_SCENE_CB, &JsSceneSessionManager::ProcessCreateSpecificSessionRegister },
|
||||
{ GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
||||
&JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener },
|
||||
{ OUTSIDE_DOWN_EVENT_CB, &JsSceneSessionManager::ProcessOutsideDownEvent },
|
||||
};
|
||||
}
|
||||
|
||||
@ -129,7 +131,6 @@ void JsSceneSessionManager::OnCreateSpecificSession(const sptr<SceneSession>& sc
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
|
||||
void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable)
|
||||
{
|
||||
WLOGFI("[NAPI]OnGestureNavigationEnabledUpdate");
|
||||
@ -151,6 +152,36 @@ void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable)
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::OnOutsideDownEvent(int32_t x, int32_t y)
|
||||
{
|
||||
WLOGFI("[NAPI]OnOutsideDownEvent");
|
||||
auto iter = jsCbMap_.find(OUTSIDE_DOWN_EVENT_CB);
|
||||
if (iter == jsCbMap_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto jsCallBack = iter->second;
|
||||
auto complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[this, x, y, jsCallBack, eng = &engine_](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
NativeValue* objValue = engine.CreateObject();
|
||||
NativeObject* object = ConvertNativeValueTo<NativeObject>(objValue);
|
||||
if (object == nullptr) {
|
||||
WLOGFE("[NAPI]Object is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
object->SetProperty("x", CreateJsValue(engine_, x));
|
||||
object->SetProperty("y", CreateJsValue(engine_, y));
|
||||
NativeValue* argv[] = { objValue };
|
||||
engine.CallFunction(engine.CreateUndefined(), jsCallBack->Get(), argv, ArraySize(argv));
|
||||
});
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSessionManager::OnOutsideDownEvent", engine_,
|
||||
std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::ProcessCreateSpecificSessionRegister()
|
||||
{
|
||||
NotifyCreateSpecificSessionFunc func = [this](const sptr<SceneSession>& session) {
|
||||
@ -169,6 +200,15 @@ void JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener()
|
||||
SceneSessionManager::GetInstance().SetGestureNavigationEnabledChangeListener(func);
|
||||
}
|
||||
|
||||
void JsSceneSessionManager::ProcessOutsideDownEvent()
|
||||
{
|
||||
ProcessOutsideDownEventFunc func = [this](int32_t x, int32_t y) {
|
||||
WLOGFD("ProcessOutsideDownEvent called");
|
||||
this->OnOutsideDownEvent(x, y);
|
||||
};
|
||||
SceneSessionManager::GetInstance().SetOutsideDownEventListener(func);
|
||||
}
|
||||
|
||||
NativeValue* JsSceneSessionManager::RegisterCallback(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]RegisterCallback");
|
||||
@ -476,55 +516,46 @@ NativeValue* JsSceneSessionManager::OnRequestSceneSession(NativeEngine& engine,
|
||||
NativeValue* JsSceneSessionManager::OnRequestSceneSessionActivation(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("[NAPI]OnRequestSceneSessionActivation");
|
||||
WSErrorCode errCode = WSErrorCode::WS_OK;
|
||||
if (info.argc < 1) { // 1: params num
|
||||
if (info.argc < 2) { // 2: params num
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WSErrorCode::WS_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
sptr<SceneSession> sceneSession = nullptr;
|
||||
if (errCode == WSErrorCode::WS_OK) {
|
||||
auto jsSceneSessionObj = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (jsSceneSessionObj == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to get js scene session object");
|
||||
errCode = WSErrorCode::WS_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
auto jsSceneSession = static_cast<JsSceneSession*>(jsSceneSessionObj->GetNativePointer());
|
||||
if (jsSceneSession == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to get scene session from js object");
|
||||
errCode = WSErrorCode::WS_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
sceneSession = jsSceneSession->GetNativeSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == WSErrorCode::WS_ERROR_INVALID_PARAM) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid"));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete = [sceneSession](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto jsSceneSessionObj = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (jsSceneSessionObj == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to get js scene session object");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid"));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
auto jsSceneSession = static_cast<JsSceneSession*>(jsSceneSessionObj->GetNativePointer());
|
||||
if (jsSceneSession == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to get scene session from js object");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid"));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
sptr<SceneSession> sceneSession = jsSceneSession->GetNativeSession();
|
||||
bool isNewActive = true;
|
||||
ConvertFromJsValue(engine, info.argv[1], isNewActive);
|
||||
AsyncTask::CompleteCallback complete = [sceneSession, isNewActive](NativeEngine& engine, AsyncTask& task,
|
||||
int32_t status) {
|
||||
if (sceneSession == nullptr) {
|
||||
task.Reject(engine, CreateJsError(engine, STATE_ABNORMALLY, "Invalid params."));
|
||||
return;
|
||||
}
|
||||
WSErrorCode ret =
|
||||
WS_JS_TO_ERROR_CODE_MAP.at(SceneSessionManager::GetInstance().RequestSceneSessionActivation(sceneSession));
|
||||
WSErrorCode ret = WS_JS_TO_ERROR_CODE_MAP.at(
|
||||
SceneSessionManager::GetInstance().RequestSceneSessionActivation(sceneSession, isNewActive));
|
||||
if (ret == WSErrorCode::WS_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(
|
||||
engine, CreateJsError(engine, static_cast<int32_t>(ret), "Request scene session activation failed"));
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "RequestActivation failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]request scene session activation end: [%{public}s, %{public}s, %{public}s]",
|
||||
sceneSession->GetSessionInfo().bundleName_.c_str(), sceneSession->GetSessionInfo().moduleName_.c_str(),
|
||||
sceneSession->GetSessionInfo().abilityName_.c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
((info.argv[1] != nullptr && info.argv[1]->TypeOf() == NATIVE_FUNCTION) ? info.argv[1] : nullptr);
|
||||
NativeValue* lastParam = (info.argc <= 2) ? nullptr : // 2: params num
|
||||
((info.argv[2] != nullptr && info.argv[2]->TypeOf() == NATIVE_FUNCTION) ? info.argv[2] : nullptr);
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsSceneSessionManager::OnRequestSceneSessionActivation", engine,
|
||||
CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
|
@ -66,8 +66,10 @@ private:
|
||||
|
||||
void OnGestureNavigationEnabledUpdate(bool enable);
|
||||
void OnCreateSpecificSession(const sptr<SceneSession>& sceneSession);
|
||||
void OnOutsideDownEvent(int32_t x, int32_t y);
|
||||
void ProcessCreateSpecificSessionRegister();
|
||||
void ProcessGestureNavigationEnabledChangeListener();
|
||||
void ProcessOutsideDownEvent();
|
||||
bool IsCallbackRegistered(const std::string& type, NativeValue* jsListenerObject);
|
||||
|
||||
NativeEngine& engine_;
|
||||
|
@ -37,7 +37,7 @@ ohos_shared_library("screensessionmanager_napi") {
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:runtime",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -42,7 +42,7 @@ ohos_shared_library("sessionmanagerservice_napi") {
|
||||
external_deps = [
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:surface", # use for SurfaceUtils
|
||||
"graphic_2d:surface", # use for SurfaceUtils
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_napi_common",
|
||||
"napi:ace_napi",
|
||||
|
@ -72,7 +72,7 @@ ohos_shared_library("scene_session") {
|
||||
"ability_runtime:ability_start_setting",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
@ -96,7 +96,7 @@ ohos_shared_library("screen_session") {
|
||||
|
||||
deps = [ "${window_base_path}/utils:libwmutil" ]
|
||||
|
||||
external_deps = [ "graphic_standard:librender_service_client" ]
|
||||
external_deps = [ "graphic_2d:librender_service_client" ]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
|
||||
WSError TransferFocusActiveEvent(bool isFocusActive) override;
|
||||
WSError TransferFocusWindowId(uint32_t windowId) override;
|
||||
WSError TransferFocusState(bool focusState) override;
|
||||
|
||||
private:
|
||||
static void OnDispatchEventProcessed(int32_t eventId, int64_t actionTime);
|
||||
|
||||
|
@ -41,12 +41,14 @@ public:
|
||||
TRANS_ID_NOTIFY_TOUCH_DIALOG_TARGET,
|
||||
TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA,
|
||||
TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO,
|
||||
TRANS_ID_UPDATE_AVOID_AREA
|
||||
};
|
||||
|
||||
virtual void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
|
||||
virtual void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) {}
|
||||
virtual void NotifyFocusActiveEvent(bool isFocusActive) {}
|
||||
virtual void NotifyFocusWindowIdEvent(uint32_t windowId) {}
|
||||
virtual void NotifyFocusStateEvent(bool focusState) {}
|
||||
virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams)
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
@ -60,6 +62,7 @@ public:
|
||||
virtual WSError NotifyDestroy() = 0;
|
||||
virtual void NotifyTouchDialogTarget() = 0;
|
||||
virtual void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info) = 0;
|
||||
virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
|
||||
|
@ -37,9 +37,9 @@ public:
|
||||
void NotifyTouchDialogTarget() override;
|
||||
WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override;
|
||||
void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info) override;
|
||||
WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
private:
|
||||
static inline BrokerDelegator<SessionStageProxy> delegator_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_RPOXY_H
|
||||
|
||||
|
@ -45,6 +45,7 @@ private:
|
||||
int HandleNotifyTouchDialogTarget(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleNotifyTransferComponentData(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleNotifyOccupiedAreaChange(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H
|
||||
|
@ -24,7 +24,7 @@ namespace OHOS::MMI {
|
||||
class PointerEvent;
|
||||
class KeyEvent;
|
||||
class AxisEvent;
|
||||
}
|
||||
} // namespace OHOS::MMI
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class IWindowEventChannel : public IRemoteBroker {
|
||||
@ -36,6 +36,7 @@ public:
|
||||
TRANS_ID_TRANSFER_POINTER_EVENT,
|
||||
TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT,
|
||||
TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT,
|
||||
TRANS_ID_TRANSFER_FOCUS_STATE_EVENT,
|
||||
};
|
||||
|
||||
virtual WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) = 0;
|
||||
@ -45,6 +46,7 @@ public:
|
||||
virtual WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) = 0;
|
||||
virtual WSError TransferFocusActiveEvent(bool isFocusActive) = 0;
|
||||
virtual WSError TransferFocusWindowId(uint32_t windowId) = 0;
|
||||
virtual WSError TransferFocusState(bool focusState) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_SESSION_WINDOW_EVENT_CHANNEL_INTERFACE_H
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
|
||||
WSError TransferFocusActiveEvent(bool isFocusActive) override;
|
||||
WSError TransferFocusWindowId(uint32_t windowId) override;
|
||||
WSError TransferFocusState(bool focusState) override;
|
||||
private:
|
||||
static inline BrokerDelegator<WindowEventChannelProxy> delegator_;
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ private:
|
||||
int HandleGetApplicationPid(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleTransferFocusActiveEvent(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleTransferFocusWindowIdEvent(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleTransferFocusStateEvent(MessageParcel& data, MessageParcel& reply);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_STUB_H
|
||||
|
@ -46,7 +46,7 @@ WSError WindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::Poin
|
||||
WLOGFE("session stage is null!");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(sessionStage_);
|
||||
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(pointerEvent->GetId(), sessionStage_);
|
||||
if (pointerEvent != nullptr) {
|
||||
WLOGFD("SetProcessedCallback enter");
|
||||
pointerEvent->SetProcessedCallback(dispatchCallback_);
|
||||
@ -64,7 +64,7 @@ WSError WindowEventChannel::TransferKeyEventForConsumed(
|
||||
WLOGFE("session stage is null!");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(sessionStage_);
|
||||
DelayedSingleton<ANRHandler>::GetInstance()->SetSessionStage(keyEvent->GetId(), sessionStage_);
|
||||
if (keyEvent != nullptr) {
|
||||
WLOGFD("SetProcessedCallback enter");
|
||||
keyEvent->SetProcessedCallback(dispatchCallback_);
|
||||
@ -150,4 +150,15 @@ WSError WindowEventChannel::TransferFocusWindowId(uint32_t windowId)
|
||||
sessionStage_->NotifyFocusWindowIdEvent(windowId);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError WindowEventChannel::TransferFocusState(bool focusState)
|
||||
{
|
||||
WLOGFD("WindowEventChannel receive focus state event: %{public}d", static_cast<int>(focusState));
|
||||
if (!sessionStage_) {
|
||||
WLOGFE("session stage is null!");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
sessionStage_->NotifyFocusStateEvent(focusState);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -209,4 +209,29 @@ void SessionStageProxy::NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo
|
||||
}
|
||||
return;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
WSError SessionStageProxy::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteStrongParcelable(avoidArea)) {
|
||||
WLOGFE("Write AvoidArea failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
|
||||
WLOGFE("Write AvoidAreaType failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionStageMessage::TRANS_ID_UPDATE_AVOID_AREA),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -41,6 +41,8 @@ const std::map<uint32_t, SessionStageStubFunc> SessionStageStub::stubFuncMap_{
|
||||
&SessionStageStub::HandleNotifyTransferComponentData),
|
||||
std::make_pair(static_cast<uint32_t>(SessionStageMessage::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO),
|
||||
&SessionStageStub::HandleNotifyOccupiedAreaChange),
|
||||
std::make_pair(static_cast<uint32_t>(SessionStageMessage::TRANS_ID_UPDATE_AVOID_AREA),
|
||||
&SessionStageStub::HandleUpdateAvoidArea)
|
||||
};
|
||||
|
||||
int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
@ -135,4 +137,16 @@ int SessionStageStub::HandleNotifyOccupiedAreaChange(MessageParcel& data, Messag
|
||||
NotifyOccupiedAreaChangeInfo(info);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStageStub::HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGFD("HandleUpdateAvoidArea!");
|
||||
sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
|
||||
uint32_t type;
|
||||
if (!data.ReadUint32(type)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
|
||||
return ERR_NONE;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -147,4 +147,26 @@ WSError WindowEventChannelProxy::TransferFocusWindowId(uint32_t windowId)
|
||||
int32_t ret = reply.ReadUint32();
|
||||
return static_cast<WSError>(ret);
|
||||
}
|
||||
|
||||
WSError WindowEventChannelProxy::TransferFocusState(bool focusState)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(focusState)) {
|
||||
WLOGFE("Write focusState failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_STATE_EVENT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
int32_t ret = reply.ReadUint32();
|
||||
return static_cast<WSError>(ret);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -35,7 +35,9 @@ const std::map<uint32_t, WindowEventChannelStubFunc> WindowEventChannelStub::stu
|
||||
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT),
|
||||
&WindowEventChannelStub::HandleTransferFocusActiveEvent),
|
||||
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT),
|
||||
&WindowEventChannelStub::HandleTransferFocusWindowIdEvent)
|
||||
&WindowEventChannelStub::HandleTransferFocusWindowIdEvent),
|
||||
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_STATE_EVENT),
|
||||
&WindowEventChannelStub::HandleTransferFocusStateEvent)
|
||||
};
|
||||
|
||||
int WindowEventChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
@ -108,4 +110,12 @@ int WindowEventChannelStub::HandleTransferFocusWindowIdEvent(MessageParcel& data
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int WindowEventChannelStub::HandleTransferFocusStateEvent(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
bool focusState = data.ReadBool();
|
||||
WSError errCode = TransferFocusState(focusState);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,20 @@ class SceneSession;
|
||||
using SpecificSessionCreateCallback = std::function<sptr<SceneSession>(const SessionInfo& info, sptr<WindowSessionProperty> property)>;
|
||||
using SpecificSessionDestroyCallback = std::function<WSError(const uint64_t& persistentId)>;
|
||||
using CameraFloatSessionChangeCallback = std::function<void(uint32_t accessTokenId, bool isShowing)>;
|
||||
using GetSceneSessionVectorByTypeCallback = std::function<std::vector<sptr<SceneSession>>(WindowType type)>;
|
||||
using UpdateAvoidAreaCallback = std::function<bool(const uint64_t& persistentId)>;
|
||||
|
||||
using NotifyCreateSpecificSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
|
||||
using NotifySessionRectChangeFunc = std::function<void(const WSRect& rect)>;
|
||||
using NotifySessionEventFunc = std::function<void(int32_t eventId)>;
|
||||
using NotifyRaiseToTopFunc = std::function<void()>;
|
||||
using SetWindowPatternOpacityFunc = std::function<void(float opacity)>;
|
||||
using NotifyIsCustomAnimationPlayingCallback = std::function<void(bool isFinish)>;
|
||||
using NotifySystemBarPropertyChangeFunc = std::function<void(
|
||||
const std::unordered_map<WindowType, SystemBarProperty>& propertyMap)>;
|
||||
using NotifyNeedAvoidFunc = std::function<void(bool status)>;
|
||||
using NotifyWindowAnimationFlagChangeFunc = std::function<void(const bool flag)>;
|
||||
using NotifyShowWhenLockedFunc = std::function<void(bool showWhenLocked)>;
|
||||
class SceneSession : public Session {
|
||||
public:
|
||||
// callback for notify SceneSessionManager
|
||||
@ -43,6 +50,8 @@ public:
|
||||
SpecificSessionCreateCallback onCreate_;
|
||||
SpecificSessionDestroyCallback onDestroy_;
|
||||
CameraFloatSessionChangeCallback onCameraFloatSessionChange_;
|
||||
GetSceneSessionVectorByTypeCallback onGetSceneSessionVectorByType_;
|
||||
UpdateAvoidAreaCallback onUpdateAvoidArea_;
|
||||
};
|
||||
|
||||
// callback for notify SceneBoard
|
||||
@ -53,6 +62,14 @@ public:
|
||||
NotifySessionEventFunc OnSessionEvent_;
|
||||
NotifySystemBarPropertyChangeFunc OnSystemBarPropertyChange_;
|
||||
NotifyNeedAvoidFunc OnNeedAvoid_;
|
||||
NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
|
||||
NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_;
|
||||
NotifyShowWhenLockedFunc OnShowWhenLocked_;
|
||||
};
|
||||
|
||||
// func for change window scene pattern property
|
||||
struct SetWindowScenePatternFunc : public RefBase {
|
||||
SetWindowPatternOpacityFunc setOpacityFunc_;
|
||||
};
|
||||
|
||||
SceneSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback);
|
||||
@ -62,8 +79,9 @@ public:
|
||||
sessionChangeCallbackList_.shrink_to_fit();
|
||||
}
|
||||
|
||||
WSError Foreground() override;
|
||||
WSError Foreground(sptr<WindowSessionProperty> property) override;
|
||||
WSError Background() override;
|
||||
WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
|
||||
|
||||
WSError OnSessionEvent(SessionEvent event) override;
|
||||
WSError RaiseToAppTop() override;
|
||||
@ -75,13 +93,26 @@ public:
|
||||
WSError DestroyAndDisconnectSpecificSession(const uint64_t& persistentId) override;
|
||||
WSError SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty);
|
||||
WSError OnNeedAvoid(bool status) override;
|
||||
void CalculateAvoidAreaRect(WSRect& rect, WSRect& avoidRect, AvoidArea& avoidArea);
|
||||
void GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
void GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
void GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea);
|
||||
AvoidArea GetAvoidAreaByType(AvoidAreaType type) override;
|
||||
WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type);
|
||||
WSError OnShowWhenLocked(bool showWhenLocked);
|
||||
bool IsShowWhenLocked() const;
|
||||
void RegisterSessionChangeCallback(const sptr<SceneSession::SessionChangeCallback>& sessionChangeCallback);
|
||||
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
|
||||
WSError SetAspectRatio(float ratio) override;
|
||||
WSError SetGlobalMaximizeMode(MaximizeMode mode) override;
|
||||
WSError GetGlobalMaximizeMode(MaximizeMode& mode) override;
|
||||
std::string GetSessionSnapshot();
|
||||
void RegisterSetWindowPatternFunc(sptr<SetWindowScenePatternFunc> func)
|
||||
{
|
||||
setWindowScenePatternFunc_ = func;
|
||||
};
|
||||
WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
|
||||
|
||||
static MaximizeMode maximizeMode_;
|
||||
|
||||
WSError SetTurnScreenOn(bool turnScreenOn);
|
||||
@ -99,9 +130,11 @@ private:
|
||||
void OnVsyncHandle();
|
||||
bool FixRectByAspectRatio(WSRect& rect);
|
||||
bool SaveAspectRatio(float ratio);
|
||||
void NotifyIsCustomAnimatiomPlaying(bool isPlaying);
|
||||
sptr<SpecificSessionCallback> specificCallback_ = nullptr;
|
||||
std::vector<sptr<SessionChangeCallback>> sessionChangeCallbackList_;
|
||||
sptr<MoveDragController> moveDragController_ = nullptr;
|
||||
sptr<SetWindowScenePatternFunc> setWindowScenePatternFunc_ = nullptr;
|
||||
bool isFirstStart_ = true;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -49,9 +49,12 @@ using NotifySessionFocusableChangeFunc = std::function<void(const bool isFocusab
|
||||
using NotifySessionTouchableChangeFunc = std::function<void(const bool touchable)>;
|
||||
using NotifyClickFunc = std::function<void()>;
|
||||
using NotifyTerminateSessionFunc = std::function<void(const SessionInfo& info)>;
|
||||
using NotifyTerminateSessionFuncNew = std::function<void(const SessionInfo& info, bool needStartCaller)>;
|
||||
using NotifySessionExceptionFunc = std::function<void(const SessionInfo& info)>;
|
||||
using NotifyPendingSessionToForegroundFunc = std::function<void(const SessionInfo& info)>;
|
||||
using NotifyPendingSessionToBackgroundForDelegatorFunc = std::function<void(const SessionInfo& info)>;
|
||||
using NotifyCallingSessionForegroundFunc = std::function<void(const uint64_t& persistentId)>;
|
||||
using NotifyCallingSessionBackgroundFunc = std::function<void()>;
|
||||
|
||||
class ILifecycleListener {
|
||||
public:
|
||||
@ -89,7 +92,7 @@ public:
|
||||
WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
|
||||
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
|
||||
sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr) override;
|
||||
WSError Foreground() override;
|
||||
WSError Foreground(sptr<WindowSessionProperty> property) override;
|
||||
WSError Background() override;
|
||||
WSError Disconnect() override;
|
||||
|
||||
@ -109,6 +112,7 @@ public:
|
||||
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed);
|
||||
WSError TransferFocusActiveEvent(bool isFocusActive);
|
||||
WSError TransferFocusWindowIdEvent(uint32_t windowId);
|
||||
WSError TransferFocusStateEvent(bool focusState);
|
||||
|
||||
bool RegisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener);
|
||||
bool UnregisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener);
|
||||
@ -116,9 +120,11 @@ public:
|
||||
|
||||
WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> info) override;
|
||||
|
||||
void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func);
|
||||
WSError TerminateSession(const sptr<AAFwk::SessionInfo> info) override;
|
||||
void SetSessionExceptionListener(const NotifyTerminateSessionFunc& func);
|
||||
void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func);
|
||||
WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller);
|
||||
void SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func);
|
||||
void SetSessionExceptionListener(const NotifySessionExceptionFunc& func);
|
||||
WSError NotifySessionException(const sptr<AAFwk::SessionInfo> info) override;
|
||||
void SetSessionStateChangeListenser(const NotifySessionStateChangeFunc& func);
|
||||
void SetSessionStateChangeNotifyManagerListener(const NotifySessionStateChangeNotifyManagerFunc& func);
|
||||
@ -177,7 +183,15 @@ public:
|
||||
sptr<IRemoteObject> GetAbilityToken() const;
|
||||
WindowMode GetWindowMode();
|
||||
void SetZOrder(uint32_t zOrder);
|
||||
uint32_t GetZOrder();
|
||||
WSError UpdateSnapshot();
|
||||
WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
|
||||
WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
|
||||
|
||||
void SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func);
|
||||
void NotifyCallingSessionForeground();
|
||||
void SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func);
|
||||
void NotifyCallingSessionBackground();
|
||||
protected:
|
||||
void GeneratePersistentId(const bool isExtension, const SessionInfo& sessionInfo);
|
||||
void UpdateSessionState(SessionState state);
|
||||
@ -198,9 +212,12 @@ protected:
|
||||
NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_;
|
||||
NotifyClickFunc clickFunc_;
|
||||
NotifyTerminateSessionFunc terminateSessionFunc_;
|
||||
NotifyTerminateSessionFuncNew terminateSessionFuncNew_;
|
||||
NotifySessionExceptionFunc sessionExceptionFunc_;
|
||||
NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_;
|
||||
NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_;
|
||||
NotifyCallingSessionForegroundFunc notifyCallingSessionForegroundFunc_;
|
||||
NotifyCallingSessionBackgroundFunc notifyCallingSessionBackgroundFunc_;
|
||||
sptr<WindowSessionProperty> property_ = nullptr;
|
||||
SystemSessionConfig systemConfig_;
|
||||
sptr<ScenePersistence> scenePersistence_ = nullptr;
|
||||
@ -236,6 +253,7 @@ private:
|
||||
static std::set<uint32_t> persistIdSet_;
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode_ = nullptr;
|
||||
SessionState state_ = SessionState::STATE_DISCONNECT;
|
||||
uint32_t zOrder_ = 0;
|
||||
|
||||
std::recursive_mutex mutex_;
|
||||
std::vector<std::shared_ptr<ILifecycleListener>> lifecycleListeners_;
|
||||
|
@ -29,16 +29,17 @@
|
||||
#include "wm_single_instance.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class VsyncStation {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(VsyncStation);
|
||||
class SessionVsyncStation {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(SessionVsyncStation);
|
||||
public:
|
||||
~VsyncStation()
|
||||
~SessionVsyncStation()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
destroyed_ = true;
|
||||
}
|
||||
void RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback);
|
||||
void RemoveCallback();
|
||||
void RemoveCallback(const std::shared_ptr<VsyncCallback>& vsyncCallback);
|
||||
void RemoveAllCallbacks();
|
||||
void SetIsMainHandlerAvailable(bool available)
|
||||
{
|
||||
isMainHandlerAvailable_ = available;
|
||||
@ -50,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
VsyncStation() = default;
|
||||
SessionVsyncStation() = default;
|
||||
static void OnVsync(int64_t nanoTimestamp, void* client);
|
||||
void VsyncCallbackInner(int64_t nanoTimestamp);
|
||||
void OnVsyncTimeOut();
|
||||
@ -68,7 +69,7 @@ private:
|
||||
.callback_ = OnVsync,
|
||||
};
|
||||
std::shared_ptr<AppExecFwk::EventHandler> vsyncHandler_ = nullptr;
|
||||
AppExecFwk::EventHandler::Callback vsyncTimeoutCallback_ = std::bind(&VsyncStation::OnVsyncTimeOut, this);
|
||||
AppExecFwk::EventHandler::Callback vsyncTimeoutCallback_ = std::bind(&SessionVsyncStation::OnVsyncTimeOut, this);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_VSYNC_STATION_H
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_VSYNC_STATION_H
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
TRANS_ID_GET_AVOID_AREA,
|
||||
TRANS_ID_UPDATE_WINDOW_SESSION_PROPERTY,
|
||||
TRANS_ID_SET_ASPECT_RATIO,
|
||||
TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG,
|
||||
TRANS_ID_UPDATE_CUSTOM_ANIMATION,
|
||||
|
||||
// Extension
|
||||
TRANS_ID_TRANSFER_ABILITY_RESULT = 500,
|
||||
@ -66,7 +68,7 @@ public:
|
||||
virtual WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
|
||||
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
|
||||
sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr) = 0;
|
||||
virtual WSError Foreground() = 0;
|
||||
virtual WSError Foreground(sptr<WindowSessionProperty> property) = 0;
|
||||
virtual WSError Background() = 0;
|
||||
virtual WSError Disconnect() = 0;
|
||||
virtual WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) = 0;
|
||||
@ -90,6 +92,8 @@ public:
|
||||
virtual WSError GetGlobalMaximizeMode(MaximizeMode& mode) = 0;
|
||||
virtual WSError UpdateWindowSessionProperty(sptr<WindowSessionProperty>) = 0;
|
||||
virtual WSError SetAspectRatio(float ratio) = 0;
|
||||
virtual WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) = 0;
|
||||
virtual WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) = 0;
|
||||
|
||||
// extension session
|
||||
virtual WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) = 0;
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
explicit SessionProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<ISession>(impl) {};
|
||||
~SessionProxy() {};
|
||||
|
||||
WSError Foreground() override;
|
||||
WSError Foreground(sptr<WindowSessionProperty> property) override;
|
||||
WSError Background() override;
|
||||
WSError Disconnect() override;
|
||||
WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
|
||||
@ -51,9 +51,12 @@ public:
|
||||
WSError GetGlobalMaximizeMode(MaximizeMode& mode) override;
|
||||
WSError UpdateWindowSessionProperty(sptr<WindowSessionProperty> property) override;
|
||||
WSError SetAspectRatio(float ratio) override;
|
||||
WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
|
||||
|
||||
WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;
|
||||
WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override;
|
||||
void NotifyRemoteReady() override;
|
||||
WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
|
||||
private:
|
||||
static inline BrokerDelegator<SessionProxy> delegator_;
|
||||
};
|
||||
|
@ -57,6 +57,8 @@ private:
|
||||
int HandleGetAvoidAreaByType(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateWindowSessionProperty(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSetAspectRatio(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleSetWindowAnimationFlag(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data, MessageParcel& reply);
|
||||
|
||||
// for extension
|
||||
int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "session/host/include/extension_session.h"
|
||||
|
||||
#include "ws_common.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
|
@ -491,12 +491,12 @@ void MoveDragController::InitDecorValue(const sptr<WindowSessionProperty> proper
|
||||
|
||||
void MoveDragController::RequestVsync()
|
||||
{
|
||||
VsyncStation::GetInstance().RequestVsync(vsyncCallback_);
|
||||
SessionVsyncStation::GetInstance().RequestVsync(vsyncCallback_);
|
||||
}
|
||||
|
||||
void MoveDragController::RemoveVsync()
|
||||
{
|
||||
VsyncStation::GetInstance().RemoveCallback();
|
||||
SessionVsyncStation::GetInstance().RemoveCallback(vsyncCallback_);
|
||||
}
|
||||
|
||||
void MoveDragController::OnReceiveVsync(int64_t timeStamp)
|
||||
|
@ -39,7 +39,7 @@ ScenePersistence::ScenePersistence(const SessionInfo &info, const uint64_t persi
|
||||
|
||||
void ScenePersistence::SaveSnapshot(const std::shared_ptr<Media::PixelMap> &pixelMap)
|
||||
{
|
||||
if (pixelMap == nullptr) {
|
||||
if (pixelMap == nullptr || strSnapshotFile_.find('/') == std::string::npos) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "session/host/include/scene_persistent_storage.h"
|
||||
#include "session/host/include/session_utils.h"
|
||||
#include "session_manager/include/screen_session_manager.h"
|
||||
#include "session_manager/include/scene_session_manager.h"
|
||||
#include "session_helper.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common.h"
|
||||
@ -37,7 +39,9 @@ SceneSession::SceneSession(const SessionInfo& info, const sptr<SpecificSessionCa
|
||||
: Session(info)
|
||||
{
|
||||
GeneratePersistentId(false, info);
|
||||
scenePersistence_ = new ScenePersistence(info, GetPersistentId());
|
||||
if (!info.bundleName_.empty()) {
|
||||
scenePersistence_ = new (std::nothrow) ScenePersistence(info, GetPersistentId());
|
||||
}
|
||||
specificCallback_ = specificCallback;
|
||||
moveDragController_ = new (std::nothrow) MoveDragController(GetPersistentId());
|
||||
ProcessVsyncHandleRegister();
|
||||
@ -57,18 +61,33 @@ SceneSession::SceneSession(const SessionInfo& info, const sptr<SpecificSessionCa
|
||||
}
|
||||
}
|
||||
|
||||
WSError SceneSession::Foreground()
|
||||
WSError SceneSession::Foreground(sptr<WindowSessionProperty> property)
|
||||
{
|
||||
WSError ret = Session::Foreground();
|
||||
// use property from client
|
||||
if (property && property->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
|
||||
property_->SetAnimationFlag(static_cast<uint32_t>(WindowAnimation::CUSTOM));
|
||||
NotifyIsCustomAnimatiomPlaying(true);
|
||||
if (setWindowScenePatternFunc_ && setWindowScenePatternFunc_->setOpacityFunc_) {
|
||||
setWindowScenePatternFunc_->setOpacityFunc_(0.0f);
|
||||
}
|
||||
}
|
||||
WSError ret = Session::Foreground(property);
|
||||
if (ret != WSError::WS_OK) {
|
||||
return ret;
|
||||
}
|
||||
UpdateCameraFloatWindowStatus(true);
|
||||
specificCallback_->onUpdateAvoidArea_(GetPersistentId());
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError SceneSession::Background()
|
||||
{
|
||||
// background will remove surfaceNode, custom not execute
|
||||
// not animation playing when already background; inactive may be animation playing
|
||||
if (property_ && property_->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
|
||||
NotifyIsCustomAnimatiomPlaying(true);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
WSError ret = Session::Background();
|
||||
if (ret != WSError::WS_OK) {
|
||||
return ret;
|
||||
@ -77,6 +96,7 @@ WSError SceneSession::Background()
|
||||
scenePersistence_->SaveSnapshot(GetSnapshot());
|
||||
}
|
||||
UpdateCameraFloatWindowStatus(false);
|
||||
specificCallback_->onUpdateAvoidArea_(GetPersistentId());
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
@ -125,7 +145,7 @@ WSError SceneSession::SetAspectRatio(float ratio)
|
||||
}
|
||||
float vpr = 1.5f; // 1.5f: default virtual pixel ratio
|
||||
auto display = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo();
|
||||
if (!display) {
|
||||
if (display) {
|
||||
vpr = display->GetVirtualPixelRatio();
|
||||
WLOGD("vpr = %{public}f", vpr);
|
||||
}
|
||||
@ -181,6 +201,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason)
|
||||
return Session::UpdateRect(newRect, reason);
|
||||
}
|
||||
}
|
||||
specificCallback_->onUpdateAvoidArea_(GetPersistentId());
|
||||
return Session::UpdateRect(rect, reason);
|
||||
}
|
||||
|
||||
@ -269,18 +290,122 @@ WSError SceneSession::OnNeedAvoid(bool status)
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError SceneSession::OnShowWhenLocked(bool showWhenLocked)
|
||||
{
|
||||
WLOGFD("SceneSession ShowWhenLocked status:%{public}d", static_cast<int32_t>(showWhenLocked));
|
||||
for (auto& sessionChangeCallback : sessionChangeCallbackList_) {
|
||||
if (sessionChangeCallback != nullptr && sessionChangeCallback->OnShowWhenLocked_) {
|
||||
sessionChangeCallback->OnShowWhenLocked_(showWhenLocked);
|
||||
}
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
bool SceneSession::IsShowWhenLocked() const
|
||||
{
|
||||
return property_->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
|
||||
}
|
||||
|
||||
void SceneSession::CalculateAvoidAreaRect(WSRect& rect, WSRect& avoidRect, AvoidArea& avoidArea)
|
||||
{
|
||||
if (SessionHelper::IsEmptyRect(rect) || SessionHelper::IsEmptyRect(avoidRect)) {
|
||||
return;
|
||||
}
|
||||
Rect avoidAreaRect = SessionHelper::TransferToRect(SessionHelper::GetOverlap(rect, avoidRect, 0, 0));
|
||||
if (WindowHelper::IsEmptyRect(avoidAreaRect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t avoidAreaCenterX = avoidAreaRect.posX_ + (avoidAreaRect.width_ >> 1);
|
||||
uint32_t avoidAreaCenterY = avoidAreaRect.posY_ + (avoidAreaRect.height_ >> 1);
|
||||
float res1 = float(avoidAreaCenterY) - float(rect.height_) / float(rect.width_) *
|
||||
float(avoidAreaCenterX);
|
||||
float res2 = float(avoidAreaCenterY) + float(rect.height_) / float(rect.width_) *
|
||||
float(avoidAreaCenterX) - float(rect.height_);
|
||||
if (res1 < 0) {
|
||||
if (res2 < 0) {
|
||||
avoidArea.topRect_ = avoidAreaRect;
|
||||
} else {
|
||||
avoidArea.rightRect_ = avoidAreaRect;
|
||||
}
|
||||
} else {
|
||||
if (res2 < 0) {
|
||||
avoidArea.leftRect_ = avoidAreaRect;
|
||||
} else {
|
||||
avoidArea.bottomRect_ = avoidAreaRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
{
|
||||
if (property_->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)) {
|
||||
return;
|
||||
}
|
||||
std::vector<sptr<SceneSession>> statusBarVector =
|
||||
specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_STATUS_BAR);
|
||||
for (auto& statusBar : statusBarVector) {
|
||||
WSRect statusBarRect = statusBar->GetSessionRect();
|
||||
CalculateAvoidAreaRect(rect, statusBarRect, avoidArea);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
{
|
||||
std::vector<sptr<SceneSession>> inputMethodVector =
|
||||
specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
|
||||
for (auto& inputMethod : inputMethodVector) {
|
||||
WSRect inputMethodRect = inputMethod->GetSessionRect();
|
||||
CalculateAvoidAreaRect(rect, inputMethodRect, avoidArea);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea)
|
||||
{
|
||||
sptr<CutoutInfo> cutoutInfo = ScreenSessionManager::GetInstance().
|
||||
GetCutoutInfo(property_->GetDisplayId());
|
||||
if (cutoutInfo == nullptr) {
|
||||
WLOGFI("GetCutoutAvoidArea There is no CutoutInfo");
|
||||
return;
|
||||
}
|
||||
std::vector<DMRect> cutoutAreas = cutoutInfo->GetBoundingRects();
|
||||
if (cutoutAreas.empty()) {
|
||||
WLOGFI("GetCutoutAvoidArea There is no cutoutAreas");
|
||||
return;
|
||||
}
|
||||
for (auto& cutoutArea : cutoutAreas) {
|
||||
WSRect cutoutAreaRect = {
|
||||
cutoutArea.posX_,
|
||||
cutoutArea.posY_,
|
||||
cutoutArea.width_,
|
||||
cutoutArea.height_
|
||||
};
|
||||
CalculateAvoidAreaRect(rect, cutoutAreaRect, avoidArea);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type)
|
||||
{
|
||||
AvoidArea avoidArea;
|
||||
WSRect rect = GetSessionRect();
|
||||
WLOGFD("GetAvoidAreaByType avoidAreaType:%{public}u", type);
|
||||
switch (type) {
|
||||
case AvoidAreaType::TYPE_SYSTEM : {
|
||||
GetSystemAvoidArea(rect, avoidArea);
|
||||
return avoidArea;
|
||||
}
|
||||
case AvoidAreaType::TYPE_KEYBOARD : {
|
||||
GetKeyboardAvoidArea(rect, avoidArea);
|
||||
return avoidArea;
|
||||
}
|
||||
case AvoidAreaType::TYPE_CUTOUT : {
|
||||
GetCutoutAvoidArea(rect, avoidArea);
|
||||
return avoidArea;
|
||||
}
|
||||
default : {
|
||||
@ -290,6 +415,14 @@ AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type)
|
||||
}
|
||||
}
|
||||
|
||||
WSError SceneSession::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
|
||||
{
|
||||
if (!sessionStage_) {
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
return sessionStage_->UpdateAvoidArea(avoidArea, type);
|
||||
}
|
||||
|
||||
WSError SceneSession::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
WLOGFD("SceneSession TransferPointEvent");
|
||||
@ -346,8 +479,8 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MathHelper::NearZero(aspectRatio_ || aspectRatio_ == MathHelper::INF ||
|
||||
aspectRatio_ == MathHelper::NAG_INF)) {
|
||||
if (MathHelper::NearZero(aspectRatio_) || aspectRatio_ == MathHelper::INF ||
|
||||
aspectRatio_ == MathHelper::NAG_INF) {
|
||||
return false;
|
||||
}
|
||||
float vpr = 1.5f; // 1.5f: default virtual pixel ratio
|
||||
@ -444,4 +577,42 @@ std::string SceneSession::GetSessionSnapshot()
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
|
||||
{
|
||||
for (auto& sessionChangeCallback : sessionChangeCallbackList_) {
|
||||
if (sessionChangeCallback != nullptr && sessionChangeCallback->onWindowAnimationFlagChange_) {
|
||||
sessionChangeCallback -> onWindowAnimationFlagChange_(needDefaultAnimationFlag);
|
||||
}
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void SceneSession::NotifyIsCustomAnimatiomPlaying(bool isPlaying)
|
||||
{
|
||||
WLOGFI("id %{public}" PRIu64 " %{public}u", GetPersistentId(), isPlaying);
|
||||
for (auto& sessionChangeCallback : sessionChangeCallbackList_) {
|
||||
if (sessionChangeCallback != nullptr && sessionChangeCallback->onIsCustomAnimationPlaying_) {
|
||||
sessionChangeCallback->onIsCustomAnimationPlaying_(isPlaying);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WSError SceneSession::UpdateWindowSceneAfterCustomAnimation(bool isAdd)
|
||||
{
|
||||
WLOGFI("id %{public}" PRIu64 "", GetPersistentId());
|
||||
if (isAdd) {
|
||||
if (!setWindowScenePatternFunc_ || !setWindowScenePatternFunc_->setOpacityFunc_) {
|
||||
WLOGFE("SetOpacityFunc not register %{public}" PRIu64 "", GetPersistentId());
|
||||
return WSError::WS_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
setWindowScenePatternFunc_->setOpacityFunc_(1.0f);
|
||||
} else {
|
||||
WLOGFI("background after custom animation id %{public}" PRIu64 "", GetPersistentId());
|
||||
// since background will remove surfaceNode
|
||||
Background();
|
||||
NotifyIsCustomAnimatiomPlaying(false);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -323,7 +323,6 @@ WSError Session::Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWi
|
||||
NotifyConnect();
|
||||
int32_t applicationPid = IPCSkeleton::GetCallingPid();
|
||||
DelayedSingleton<ANRManager>::GetInstance()->SetApplicationPid(persistentId_, applicationPid);
|
||||
WLOGFI("SetApplicationPid pid:%{public}d", applicationPid);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
@ -333,7 +332,7 @@ WSError Session::UpdateWindowSessionProperty(sptr<WindowSessionProperty> propert
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError Session::Foreground()
|
||||
WSError Session::Foreground(sptr<WindowSessionProperty> property)
|
||||
{
|
||||
SessionState state = GetSessionState();
|
||||
WLOGFI("Foreground session, id: %{public}" PRIu64 ", state: %{public}u", GetPersistentId(),
|
||||
@ -347,10 +346,22 @@ WSError Session::Foreground()
|
||||
if (!isActive_) {
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
if (GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) {
|
||||
NotifyCallingSessionForeground();
|
||||
}
|
||||
NotifyForeground();
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void Session::NotifyCallingSessionForeground()
|
||||
{
|
||||
if (notifyCallingSessionForegroundFunc_) {
|
||||
WLOGFI("Notify calling window that input method shown");
|
||||
notifyCallingSessionForegroundFunc_(persistentId_);
|
||||
}
|
||||
}
|
||||
|
||||
WSError Session::Background()
|
||||
{
|
||||
SessionState state = GetSessionState();
|
||||
@ -361,11 +372,22 @@ WSError Session::Background()
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
UpdateSessionState(SessionState::STATE_BACKGROUND);
|
||||
if (GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) {
|
||||
NotifyCallingSessionBackground();
|
||||
}
|
||||
snapshot_ = Snapshot();
|
||||
NotifyBackground();
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void Session::NotifyCallingSessionBackground()
|
||||
{
|
||||
if (notifyCallingSessionBackgroundFunc_) {
|
||||
WLOGFI("Notify calling window that input method hide");
|
||||
notifyCallingSessionBackgroundFunc_();
|
||||
}
|
||||
}
|
||||
|
||||
WSError Session::Disconnect()
|
||||
{
|
||||
SessionState state = GetSessionState();
|
||||
@ -468,6 +490,30 @@ void Session::SetTerminateSessionListener(const NotifyTerminateSessionFunc& func
|
||||
terminateSessionFunc_ = func;
|
||||
}
|
||||
|
||||
WSError Session::TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needStartCaller)
|
||||
{
|
||||
if (abilitySessionInfo == nullptr) {
|
||||
WLOGFE("abilitySessionInfo is null");
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
SessionInfo info;
|
||||
info.abilityName_ = abilitySessionInfo->want.GetElement().GetAbilityName();
|
||||
info.bundleName_ = abilitySessionInfo->want.GetElement().GetBundleName();
|
||||
info.callerToken_ = abilitySessionInfo->callerToken;
|
||||
info.persistentId_ = abilitySessionInfo->persistentId;
|
||||
sessionInfo_.want = new AAFwk::Want(abilitySessionInfo->want);
|
||||
sessionInfo_.resultCode = abilitySessionInfo->resultCode;
|
||||
if (terminateSessionFuncNew_) {
|
||||
terminateSessionFuncNew_(info, needStartCaller);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void Session::SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func)
|
||||
{
|
||||
terminateSessionFuncNew_ = func;
|
||||
}
|
||||
|
||||
WSError Session::NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo)
|
||||
{
|
||||
if (abilitySessionInfo == nullptr) {
|
||||
@ -525,6 +571,16 @@ WSError Session::PendingSessionToBackgroundForDelegator()
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
void Session::SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func)
|
||||
{
|
||||
notifyCallingSessionForegroundFunc_ = func;
|
||||
}
|
||||
|
||||
void Session::SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func)
|
||||
{
|
||||
notifyCallingSessionBackgroundFunc_ = func;
|
||||
}
|
||||
|
||||
void Session::NotifyTouchDialogTarget()
|
||||
{
|
||||
if (!sessionStage_) {
|
||||
@ -675,6 +731,15 @@ WSError Session::TransferFocusWindowIdEvent(uint32_t windowId)
|
||||
return windowEventChannel_->TransferFocusWindowId(windowId);
|
||||
}
|
||||
|
||||
WSError Session::TransferFocusStateEvent(bool focusState)
|
||||
{
|
||||
if (!windowEventChannel_) {
|
||||
WLOGFE("windowEventChannel_ is null");
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
return windowEventChannel_->TransferFocusState(focusState);
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> Session::GetSnapshot() const
|
||||
{
|
||||
return snapshot_;
|
||||
@ -723,11 +788,13 @@ void Session::NotifySessionStateChange(const SessionState& state)
|
||||
void Session::SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func)
|
||||
{
|
||||
sessionFocusableChangeFunc_ = func;
|
||||
sessionFocusableChangeFunc_(GetFocusable());
|
||||
}
|
||||
|
||||
void Session::SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func)
|
||||
{
|
||||
sessionTouchableChangeFunc_ = func;
|
||||
sessionTouchableChangeFunc_(GetTouchable());
|
||||
}
|
||||
|
||||
void Session::SetClickListener(const NotifyClickFunc& func)
|
||||
@ -762,14 +829,14 @@ void Session::NotifyClick()
|
||||
WSError Session::UpdateFocus(bool isFocused)
|
||||
{
|
||||
WLOGFI("Session update focus id: %{public}" PRIu64, GetPersistentId());
|
||||
if (!IsSessionValid()) {
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
if (isFocused_ == isFocused) {
|
||||
WLOGFD("Session focus do not change: [%{public}d]", isFocused);
|
||||
return WSError::WS_DO_NOTHING;
|
||||
}
|
||||
isFocused_ = isFocused;
|
||||
if (!IsSessionValid()) {
|
||||
return WSError::WS_ERROR_INVALID_SESSION;
|
||||
}
|
||||
sessionStage_->UpdateFocus(isFocused);
|
||||
|
||||
return WSError::WS_OK;
|
||||
@ -883,8 +950,8 @@ WSError Session::ProcessBackEvent()
|
||||
|
||||
WSError Session::MarkProcessed(int32_t eventId)
|
||||
{
|
||||
int32_t persistentId = GetPersistentId();
|
||||
WLOGFI("persistentId:%{public}d, eventId:%{public}d", persistentId, eventId);
|
||||
uint64_t persistentId = GetPersistentId();
|
||||
WLOGFI("persistentId:%{public}" PRIu64 ", eventId:%{public}d", persistentId, eventId);
|
||||
DelayedSingleton<ANRManager>::GetInstance()->MarkProcessed(eventId, persistentId);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
@ -962,11 +1029,12 @@ WindowMode Session::GetWindowMode()
|
||||
|
||||
void Session::SetZOrder(uint32_t zOrder)
|
||||
{
|
||||
if (property_ == nullptr) {
|
||||
WLOGFW("null property.");
|
||||
return;
|
||||
}
|
||||
property_->SetZOrder(zOrder);
|
||||
zOrder_ = zOrder;
|
||||
}
|
||||
|
||||
uint32_t Session::GetZOrder()
|
||||
{
|
||||
return zOrder_;
|
||||
}
|
||||
|
||||
WSError Session::UpdateSnapshot()
|
||||
@ -974,4 +1042,15 @@ WSError Session::UpdateSnapshot()
|
||||
snapshot_ = Snapshot();
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError Session::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
|
||||
{
|
||||
WLOGFD("UpdateWindowAnimationFlag");
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
WSError Session::UpdateWindowSceneAfterCustomAnimation(bool isAdd)
|
||||
{
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -20,13 +20,13 @@
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "VsyncStation"};
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionVsyncStation"};
|
||||
const std::string VSYNC_TIME_OUT_TASK = "vsync_time_out_task";
|
||||
constexpr int64_t VSYNC_TIME_OUT_MILLISECONDS = 600;
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(VsyncStation)
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(SessionVsyncStation)
|
||||
|
||||
void VsyncStation::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
|
||||
void SessionVsyncStation::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
@ -66,14 +66,21 @@ void VsyncStation::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallb
|
||||
receiver_->RequestNextVSync(frameCallback_);
|
||||
}
|
||||
|
||||
void VsyncStation::RemoveCallback()
|
||||
void SessionVsyncStation::RemoveCallback(const std::shared_ptr<VsyncCallback>& vsyncCallback)
|
||||
{
|
||||
WLOGI("Remove Vsync callback");
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
vsyncCallbacks_.erase(vsyncCallback);
|
||||
}
|
||||
|
||||
void SessionVsyncStation::RemoveAllCallbacks()
|
||||
{
|
||||
WLOGI("Remove all vsync callback");
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
vsyncCallbacks_.clear();
|
||||
}
|
||||
|
||||
void VsyncStation::VsyncCallbackInner(int64_t timestamp)
|
||||
void SessionVsyncStation::VsyncCallbackInner(int64_t timestamp)
|
||||
{
|
||||
std::unordered_set<std::shared_ptr<VsyncCallback>> vsyncCallbacks;
|
||||
{
|
||||
@ -88,9 +95,9 @@ void VsyncStation::VsyncCallbackInner(int64_t timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
void VsyncStation::OnVsync(int64_t timestamp, void* client)
|
||||
void SessionVsyncStation::OnVsync(int64_t timestamp, void* client)
|
||||
{
|
||||
auto vsyncClient = static_cast<VsyncStation*>(client);
|
||||
auto vsyncClient = static_cast<SessionVsyncStation*>(client);
|
||||
if (vsyncClient) {
|
||||
vsyncClient->VsyncCallbackInner(timestamp);
|
||||
} else {
|
||||
@ -98,7 +105,7 @@ void VsyncStation::OnVsync(int64_t timestamp, void* client)
|
||||
}
|
||||
}
|
||||
|
||||
void VsyncStation::OnVsyncTimeOut()
|
||||
void SessionVsyncStation::OnVsyncTimeOut()
|
||||
{
|
||||
WLOGW("Vsync time out");
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
|
@ -30,7 +30,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionProxy"};
|
||||
}
|
||||
|
||||
WSError SessionProxy::Foreground()
|
||||
WSError SessionProxy::Foreground(sptr<WindowSessionProperty> property)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -40,6 +40,18 @@ WSError SessionProxy::Foreground()
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (property) {
|
||||
if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
|
||||
WLOGFE("Write property failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
} else {
|
||||
if (!data.WriteBool(false)) {
|
||||
WLOGFE("Write property failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionMessage::TRANS_ID_FOREGROUND),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
@ -488,7 +500,7 @@ AvoidArea SessionProxy::GetAvoidAreaByType(AvoidAreaType type)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
AvoidArea avoidArea;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
@ -532,7 +544,7 @@ WSError SessionProxy::MarkProcessed(int32_t eventId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
@ -634,6 +646,28 @@ WSError SessionProxy::SetAspectRatio(float ratio)
|
||||
return static_cast<WSError>(ret);
|
||||
}
|
||||
|
||||
WSError SessionProxy::UpdateWindowSceneAfterCustomAnimation(bool isAdd)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(isAdd)) {
|
||||
WLOGFE("Write isAdd failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionMessage::TRANS_ID_UPDATE_CUSTOM_ANIMATION),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
int32_t ret = reply.ReadInt32();
|
||||
return static_cast<WSError>(ret);
|
||||
}
|
||||
|
||||
WSError SessionProxy::TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -697,4 +731,26 @@ void SessionProxy::NotifyRemoteReady()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WSError SessionProxy::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(needDefaultAnimationFlag)) {
|
||||
WLOGFE("wantParams write failed.");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(SessionMessage::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
int32_t ret = reply.ReadInt32();
|
||||
return static_cast<WSError>(ret);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -63,7 +63,11 @@ const std::map<uint32_t, SessionStubFunc> SessionStub::stubFuncMap_{
|
||||
&SessionStub::HandleUpdateWindowSessionProperty),
|
||||
std::make_pair(static_cast<uint32_t>(SessionMessage::TRANS_ID_SET_ASPECT_RATIO),
|
||||
&SessionStub::HandleSetAspectRatio),
|
||||
std::make_pair(static_cast<uint32_t>(SessionMessage::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG),
|
||||
&SessionStub::HandleSetWindowAnimationFlag),
|
||||
|
||||
std::make_pair(static_cast<uint32_t>(SessionMessage::TRANS_ID_UPDATE_CUSTOM_ANIMATION),
|
||||
&SessionStub::HandleUpdateWindowSceneAfterCustomAnimation),
|
||||
// for extension only
|
||||
std::make_pair(static_cast<uint32_t>(SessionMessage::TRANS_ID_TRANSFER_ABILITY_RESULT),
|
||||
&SessionStub::HandleTransferAbilityResult),
|
||||
@ -90,10 +94,26 @@ int SessionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParc
|
||||
return (this->*(func->second))(data, reply);
|
||||
}
|
||||
|
||||
int SessionStub::HandleSetWindowAnimationFlag(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGFD("HandleSetWindowAnimationFlag!");
|
||||
bool isNeedWindowAnimationFlag = data.ReadBool();
|
||||
const WSError& errCode = UpdateWindowAnimationFlag(isNeedWindowAnimationFlag);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStub::HandleForeground(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGFD("Foreground!");
|
||||
const WSError& errCode = Foreground();
|
||||
sptr<WindowSessionProperty> property = nullptr;
|
||||
if (data.ReadBool()) {
|
||||
property = data.ReadStrongParcelable<WindowSessionProperty>();
|
||||
} else {
|
||||
WLOGFW("Property not exist!");
|
||||
property = new WindowSessionProperty();
|
||||
}
|
||||
const WSError& errCode = Foreground(property);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
@ -362,6 +382,15 @@ int SessionStub::HandleSetAspectRatio(MessageParcel& data, MessageParcel& reply)
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStub::HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGD("HandleUpdateWindowSceneAfterCustomAnimation!");
|
||||
bool isAdd = data.ReadBool();
|
||||
const WSError& errCode = UpdateWindowSceneAfterCustomAnimation(isAdd);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SessionStub::HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
WLOGFD("HandleTransferAbilityResult!");
|
||||
|
@ -94,6 +94,7 @@ public:
|
||||
int32_t GetPrivateSessionCount() const;
|
||||
DMError SetPrivateSessionCount(int32_t count);
|
||||
bool HasPrivateSession() const;
|
||||
void SetDisplayBoundary(const RectF& rect, const uint32_t& offsetY);
|
||||
|
||||
std::string name_ { "UNKNOW" };
|
||||
ScreenId screenId_;
|
||||
|
@ -100,11 +100,11 @@ void ScreenProperty::SetScreenRotation(Rotation rotation)
|
||||
int32_t width = bounds_.rect_.width_;
|
||||
int32_t height = bounds_.rect_.height_;
|
||||
if (IsVertical(screenRotation_)) {
|
||||
bounds_.rect_.left_ -= (width - height) / HALF_VALUE;
|
||||
bounds_.rect_.top_ += (width - height) / HALF_VALUE;
|
||||
bounds_.rect_.left_ -= static_cast<float>((width - height) / HALF_VALUE - offsetY_);
|
||||
bounds_.rect_.top_ += static_cast<float>((width - height) / HALF_VALUE);
|
||||
} else {
|
||||
bounds_.rect_.left_ += (height - width) / HALF_VALUE;
|
||||
bounds_.rect_.top_ -= (height - width) / HALF_VALUE;
|
||||
bounds_.rect_.left_ += static_cast<float>((height - width) / HALF_VALUE);
|
||||
bounds_.rect_.top_ -= static_cast<float>((height - width) / HALF_VALUE + offsetY_);
|
||||
}
|
||||
}
|
||||
if (rotation == Rotation::ROTATION_0) {
|
||||
|
@ -601,5 +601,9 @@ sptr<ScreenGroupInfo> ScreenSessionGroup::ConvertToScreenGroupInfo() const
|
||||
return screenGroupInfo;
|
||||
}
|
||||
|
||||
|
||||
void ScreenSession::SetDisplayBoundary(const RectF& rect, const uint32_t& offsetY)
|
||||
{
|
||||
property_.SetOffsetY(offsetY);
|
||||
property_.SetBounds(RRect(rect, 0.0f, 0.0f));
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -91,8 +91,8 @@ ohos_shared_library("scene_session_manager") {
|
||||
"display_manager:displaymgr",
|
||||
"eventhandler:libeventhandler",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_standard:window_animation",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_2d:window_animation",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
@ -110,6 +110,12 @@ ohos_shared_library("scene_session_manager") {
|
||||
defines += [ "MEMMGR_WINDOW_ENABLE" ]
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_soc_perf)) {
|
||||
external_deps += [ "resource_schedule_service:ressched_client" ]
|
||||
defines += [ "RES_SCHED_ENABLE" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
@ -142,7 +148,7 @@ ohos_shared_library("screen_session_manager") {
|
||||
"c_utils:utils",
|
||||
"config_policy:configpolicy_util",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
@ -189,7 +195,7 @@ ohos_shared_library("session_manager") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"graphic_standard:librender_service_client",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"multimedia_image_framework:image_native",
|
||||
|
@ -43,6 +43,7 @@ class SceneSession;
|
||||
class AccessibilityWindowInfo;
|
||||
using NotifyCreateSpecificSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
|
||||
using ProcessGestureNavigationEnabledChangeFunc = std::function<void(bool enable)>;
|
||||
using ProcessOutsideDownEventFunc = std::function<void(int32_t x, int32_t y)>;
|
||||
using NotifySetFocusSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
|
||||
using EventHandler = OHOS::AppExecFwk::EventHandler;
|
||||
using EventRunner = OHOS::AppExecFwk::EventRunner;
|
||||
@ -51,7 +52,7 @@ class SceneSessionManager : public SceneSessionManagerStub {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(SceneSessionManager)
|
||||
public:
|
||||
sptr<SceneSession> RequestSceneSession(const SessionInfo& sessionInfo, sptr<WindowSessionProperty> property = nullptr);
|
||||
WSError RequestSceneSessionActivation(const sptr<SceneSession>& sceneSession);
|
||||
WSError RequestSceneSessionActivation(const sptr<SceneSession>& sceneSession, bool isNewActive);
|
||||
WSError RequestSceneSessionBackground(const sptr<SceneSession>& sceneSession, const bool isDelegator = false);
|
||||
WSError RequestSceneSessionDestruction(const sptr<SceneSession>& sceneSession);
|
||||
WSError RequestSceneSessionByCall(const sptr<SceneSession>& sceneSession);
|
||||
@ -65,6 +66,7 @@ public:
|
||||
WSError UpdateProperty(sptr<WindowSessionProperty>& property, WSPropertyChangeAction action);
|
||||
void SetCreateSpecificSessionListener(const NotifyCreateSpecificSessionFunc& func);
|
||||
void SetGestureNavigationEnabledChangeListener(const ProcessGestureNavigationEnabledChangeFunc& func);
|
||||
void SetOutsideDownEventListener(const ProcessOutsideDownEventFunc& func);
|
||||
const AppWindowSceneConfig& GetWindowSceneConfig() const;
|
||||
WSError ProcessBackEvent();
|
||||
void GetStartPage(const SessionInfo& sessionInfo, std::string& path, uint32_t& bgColor);
|
||||
@ -92,10 +94,13 @@ public:
|
||||
WSError PendingSessionToForeground(const sptr<IRemoteObject> &token);
|
||||
WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject> &token);
|
||||
WSError GetFocusSessionToken(sptr<IRemoteObject> &token);
|
||||
WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller);
|
||||
WSError UpdateSessionAvoidAreaListener(uint64_t& persistentId, bool haveListener);
|
||||
|
||||
void UpdatePrivateStateAndNotify(bool isAddingPrivateSession);
|
||||
void InitPersistentStorage();
|
||||
std::string GetSessionSnapshot(uint64_t persistentId);
|
||||
void OnOutsideDownEvent(int32_t x, int32_t y);
|
||||
|
||||
WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos);
|
||||
WSError SetWindowFlags(const sptr<SceneSession>& sceneSession, uint32_t flags);
|
||||
@ -127,6 +132,10 @@ private:
|
||||
WSError UpdateParentSession(const sptr<SceneSession>& sceneSession, sptr<WindowSessionProperty> property);
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing);
|
||||
void UpdateFocusableProperty(uint64_t persistentId);
|
||||
std::vector<sptr<SceneSession>> GetSceneSessionVectorByType(WindowType type);
|
||||
bool UpdateSessionAvoidAreaIfNeed(const uint64_t& persistentId,
|
||||
const AvoidArea& avoidArea, AvoidAreaType avoidAreaType);
|
||||
bool UpdateAvoidArea(const uint64_t& persistentId);
|
||||
|
||||
sptr<AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
std::shared_ptr<Global::Resource::ResourceManager> CreateResourceManager(
|
||||
@ -149,12 +158,18 @@ private:
|
||||
void WindowVisibilityChangeCallback(std::shared_ptr<RSOcclusionData> occlusiontionData);
|
||||
void RegisterSessionRectChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession);
|
||||
void OnSessionRectChange(uint64_t persistentId, const WSRect& rect);
|
||||
void RegisterInputMethodShownFunc(const sptr<SceneSession>& sceneSession);
|
||||
void OnInputMethodShown(const uint64_t& persistentId);
|
||||
void RegisterInputMethodHideFunc(const sptr<SceneSession>& sceneSession);
|
||||
|
||||
sptr<RootSceneSession> rootSceneSession_;
|
||||
std::map<uint64_t, sptr<SceneSession>> sceneSessionMap_;
|
||||
std::set<sptr<SceneSession>> avoidAreaListenerSessionSet_;
|
||||
std::map<uint64_t, std::map<AvoidAreaType, AvoidArea>> lastUpdatedAvoidArea_;
|
||||
|
||||
NotifyCreateSpecificSessionFunc createSpecificSessionFunc_;
|
||||
ProcessGestureNavigationEnabledChangeFunc gestureNavigationEnabledChangeFunc_;
|
||||
ProcessOutsideDownEventFunc outsideDownEventFunc_;
|
||||
AppWindowSceneConfig appWindowSceneConfig_;
|
||||
SystemSessionConfig systemConfig_;
|
||||
uint64_t activeSessionId_ = INVALID_SESSION_ID;
|
||||
|
@ -19,21 +19,39 @@
|
||||
#include <refbase.h>
|
||||
|
||||
#include "cutout_info.h"
|
||||
#include "session/screen/include/screen_property.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
enum class DeviceRotationValue: int32_t {
|
||||
INVALID = -1,
|
||||
ROTATION_PORTRAIT = 0,
|
||||
ROTATION_LANDSCAPE,
|
||||
ROTATION_PORTRAIT_INVERTED,
|
||||
ROTATION_LANDSCAPE_INVERTED,
|
||||
};
|
||||
class ScreenCutoutController : public RefBase {
|
||||
public:
|
||||
ScreenCutoutController() {};
|
||||
sptr<CutoutInfo> GetScreenCutoutInfo();
|
||||
RectF CalculateCurvedCompression(const ScreenProperty& screenProperty);
|
||||
uint32_t GetOffsetY();
|
||||
|
||||
private:
|
||||
void CalcWaterfallRects();
|
||||
void ProcessRotationMapping();
|
||||
void CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth,
|
||||
std::vector<uint32_t> realNumVec);
|
||||
void CheckBoundaryRects(std::vector<DMRect>& boundaryRects, sptr<DisplayInfo> displayInfo);
|
||||
void ConvertBoundaryRectsByRotation(std::vector<DMRect>& boundaryRects);
|
||||
bool IsDisplayRotationHorizontal(Rotation rotation);
|
||||
DMRect CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height);
|
||||
Rotation ConvertDeviceToDisplayRotation(DeviceRotationValue deviceRotation);
|
||||
Rotation GetCurrentDisplayRotation();
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, WaterfallDisplayCompressionStatus, waterfallDisplayCompressionStatus, false);
|
||||
|
||||
static uint32_t defaultDeviceRotation_;
|
||||
static std::map<DeviceRotationValue, Rotation> deviceToDisplayRotationMap_;
|
||||
uint32_t offsetY_;
|
||||
WaterfallDisplayAreaRects waterfallDisplayAreaRects_ = {};
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
static std::vector<DMRect> GetCutoutBoundaryRect();
|
||||
static void SetCutoutSvgPath(const std::string& svgPath);
|
||||
static bool IsWaterfallDisplay();
|
||||
static void SetCurvedCompressionAreaInLandscape();
|
||||
static std::vector<int> GetCurvedScreenBoundaryConfig();
|
||||
static uint32_t GetCurvedCompressionAreaInLandscape();
|
||||
|
||||
private:
|
||||
static std::map<std::string, bool> enableConfig_;
|
||||
@ -44,6 +47,8 @@ private:
|
||||
static std::map<std::string, std::string> stringConfig_;
|
||||
static std::vector<DMRect> cutoutBoundaryRect_;
|
||||
static bool isWaterfallDisplay_;
|
||||
static bool isScreenCompressionEnableInLandscape_;
|
||||
static uint32_t curvedAreaInLandscape_;
|
||||
|
||||
static bool IsValidNode(const xmlNode& currNode);
|
||||
static void ReadEnableConfigInfo(const xmlNodePtr& currNode);
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
const std::vector<sptr<ScreenInfo>>& screenInfos, ScreenGroupChangeEvent groupEvent);
|
||||
void OnScreenshot(sptr<ScreenshotInfo> info);
|
||||
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
void SetDisplayBoundary(const sptr<ScreenSession> screenSession);
|
||||
|
||||
protected:
|
||||
ScreenSessionManager();
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include "session/container/include/zidl/session_stage_interface.h"
|
||||
#include "session/container/include/zidl/window_event_channel_interface.h"
|
||||
#include "session/host/include/session.h"
|
||||
|
||||
#include "focus_change_info.h"
|
||||
#include "session_listener_interface.h"
|
||||
#include "window_manager.h"
|
||||
#include "zidl/window_manager_interface.h"
|
||||
#include "session_info.h"
|
||||
|
||||
namespace OHOS::Media {
|
||||
class PixelMap;
|
||||
@ -56,6 +56,8 @@ public:
|
||||
TRANS_ID_PENDING_SESSION_TO_FOREGROUND,
|
||||
TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR,
|
||||
TRANS_ID_GET_FOCUS_SESSION_TOKEN,
|
||||
TRANS_ID_TERMINATE_SESSION_NEW,
|
||||
TRANS_ID_UPDATE_AVOIDAREA_LISTENER,
|
||||
};
|
||||
|
||||
virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
|
||||
@ -71,6 +73,7 @@ public:
|
||||
virtual WSError PendingSessionToForeground(const sptr<IRemoteObject> &token) = 0;
|
||||
virtual WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject> &token) = 0;
|
||||
virtual WSError GetFocusSessionToken(sptr<IRemoteObject> &token) = 0;
|
||||
virtual WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller) = 0;
|
||||
|
||||
// interfaces of IWindowManager
|
||||
WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
WSError PendingSessionToForeground(const sptr<IRemoteObject> &token) override;
|
||||
WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject> &token) override;
|
||||
WSError GetFocusSessionToken(sptr<IRemoteObject> &token) override;
|
||||
WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller) override;
|
||||
WSError UpdateSessionAvoidAreaListener(uint64_t& persistentId, bool haveListener) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SceneSessionManagerProxy> delegator_;
|
||||
|
@ -51,6 +51,8 @@ private:
|
||||
int HandleGetFocusSessionToken(MessageParcel &data, MessageParcel &reply);
|
||||
int HandleSetGestureNavigationEnabled(MessageParcel &data, MessageParcel &reply);
|
||||
int HandleSetSessionGravity(MessageParcel &data, MessageParcel &reply);
|
||||
int HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateSessionAvoidAreaListener(MessageParcel& data, MessageParcel& reply);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_STUB_H
|
||||
|
@ -83,7 +83,8 @@ sptr<ExtensionSession> ExtensionSessionManager::RequestExtensionSession(const Se
|
||||
WSError ExtensionSessionManager::RequestExtensionSessionActivation(const sptr<ExtensionSession>& extensionSession)
|
||||
{
|
||||
wptr<ExtensionSession> weakExtSession(extensionSession);
|
||||
auto task = [this, weakExtSession]() {
|
||||
WSError ret = WSError::WS_OK;
|
||||
auto task = [this, weakExtSession, &ret]() {
|
||||
auto extSession = weakExtSession.promote();
|
||||
if (extSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -99,19 +100,20 @@ WSError ExtensionSessionManager::RequestExtensionSessionActivation(const sptr<Ex
|
||||
if (extSessionInfo == nullptr) {
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
AAFwk::AbilityManagerClient::GetInstance()->StartUIExtensionAbility(extSessionInfo,
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIExtensionAbility(extSessionInfo,
|
||||
AAFwk::DEFAULT_INVAL_VALUE);
|
||||
return WSError::WS_OK;
|
||||
ret = (errorCode == ERR_OK) ? WSError::WS_OK : WSError::WS_ERROR_START_UI_EXTENSION_ABILITY_FAILED;
|
||||
return ret;
|
||||
};
|
||||
|
||||
taskScheduler_->PostAsyncTask(task);
|
||||
return WSError::WS_OK;
|
||||
taskScheduler_->PostSyncTask(task);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WSError ExtensionSessionManager::RequestExtensionSessionBackground(const sptr<ExtensionSession>& extensionSession)
|
||||
{
|
||||
wptr<ExtensionSession> weakExtSession(extensionSession);
|
||||
auto task = [this, weakExtSession]() {
|
||||
WSError ret = WSError::WS_OK;
|
||||
auto task = [this, weakExtSession, &ret]() {
|
||||
auto extSession = weakExtSession.promote();
|
||||
if (extSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -129,18 +131,19 @@ WSError ExtensionSessionManager::RequestExtensionSessionBackground(const sptr<Ex
|
||||
if (!extSessionInfo) {
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIExtensionAbility(extSessionInfo);
|
||||
return WSError::WS_OK;
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIExtensionAbility(extSessionInfo);
|
||||
ret = (errorCode == ERR_OK) ? WSError::WS_OK : WSError::WS_ERROR_MIN_UI_EXTENSION_ABILITY_FAILED;
|
||||
return ret;
|
||||
};
|
||||
|
||||
taskScheduler_->PostAsyncTask(task);
|
||||
return WSError::WS_OK;
|
||||
taskScheduler_->PostSyncTask(task);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WSError ExtensionSessionManager::RequestExtensionSessionDestruction(const sptr<ExtensionSession>& extensionSession)
|
||||
{
|
||||
wptr<ExtensionSession> weakExtSession(extensionSession);
|
||||
auto task = [this, weakExtSession]() {
|
||||
WSError ret = WSError::WS_OK;
|
||||
auto task = [this, weakExtSession, &ret]() {
|
||||
auto extSession = weakExtSession.promote();
|
||||
if (extSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -157,12 +160,12 @@ WSError ExtensionSessionManager::RequestExtensionSessionDestruction(const sptr<E
|
||||
if (!extSessionInfo) {
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(extSessionInfo);
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(extSessionInfo);
|
||||
extensionSessionMap_.erase(persistentId);
|
||||
return WSError::WS_OK;
|
||||
ret = (errorCode == ERR_OK) ? WSError::WS_OK : WSError::WS_ERROR_TERMINATE_UI_EXTENSION_ABILITY_FAILED;
|
||||
return ret;
|
||||
};
|
||||
|
||||
taskScheduler_->PostAsyncTask(task);
|
||||
return WSError::WS_OK;
|
||||
taskScheduler_->PostSyncTask(task);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "session_manager/include/scene_session_manager.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ability_info.h>
|
||||
#include <ability_manager_client.h>
|
||||
@ -35,6 +36,11 @@
|
||||
#include <transaction/rs_transaction.h>
|
||||
#include <transaction/rs_interfaces.h>
|
||||
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
#include "res_type.h"
|
||||
#include "res_sched_client.h"
|
||||
#endif
|
||||
|
||||
#include "ability_start_setting.h"
|
||||
#include "color_parser.h"
|
||||
#include "common/include/permission.h"
|
||||
@ -66,6 +72,9 @@
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManager" };
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
|
||||
#endif
|
||||
const std::string SCENE_SESSION_MANAGER_THREAD = "SceneSessionManager";
|
||||
constexpr uint32_t MAX_BRIGHTNESS = 255;
|
||||
constexpr int32_t DEFAULT_USERID = -1;
|
||||
@ -91,6 +100,18 @@ SceneSessionManager::SceneSessionManager() : rsInterface_(RSInterfaces::GetInsta
|
||||
WLOGFW("Add thread %{public}s to watchdog failed.", SCENE_SESSION_MANAGER_THREAD.c_str());
|
||||
}
|
||||
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
std::unordered_map<std::string, std::string> payload {
|
||||
{ "pid", std::to_string(getpid()) },
|
||||
{ "tid", std::to_string(gettid()) },
|
||||
{ "uid", std::to_string(getuid()) },
|
||||
{ "bundleName", SCENE_BOARD_BUNDLE_NAME },
|
||||
};
|
||||
uint32_t type = OHOS::ResourceSchedule::ResType::RES_TYPE_REPORT_SCENE_BOARD;
|
||||
int64_t value = 0;
|
||||
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(type, value, payload);
|
||||
#endif
|
||||
|
||||
bundleMgr_ = GetBundleManager();
|
||||
currentUserId_ = DEFAULT_USERID;
|
||||
LoadWindowSceneXml();
|
||||
@ -459,6 +480,20 @@ sptr<SceneSession> SceneSessionManager::GetSceneSession(uint64_t persistentId)
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<sptr<SceneSession>> SceneSessionManager::GetSceneSessionVectorByType(WindowType type)
|
||||
{
|
||||
std::vector<sptr<SceneSession>> sceneSessionVector;
|
||||
|
||||
for (const auto &item : sceneSessionMap_) {
|
||||
auto sceneSession = item.second;
|
||||
if (sceneSession->GetWindowType() == type) {
|
||||
sceneSessionVector.emplace_back(sceneSession);
|
||||
}
|
||||
}
|
||||
|
||||
return sceneSessionVector;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::UpdateParentSession(const sptr<SceneSession>& sceneSession, sptr<WindowSessionProperty> property)
|
||||
{
|
||||
if (property == nullptr) {
|
||||
@ -510,6 +545,10 @@ sptr<SceneSession> SceneSessionManager::RequestSceneSession(const SessionInfo& s
|
||||
this, std::placeholders::_1);
|
||||
specificCallback->onCameraFloatSessionChange_ = std::bind(&SceneSessionManager::UpdateCameraFloatWindowStatus,
|
||||
this, std::placeholders::_1, std::placeholders::_2);
|
||||
specificCallback->onGetSceneSessionVectorByType_ = std::bind(&SceneSessionManager::GetSceneSessionVectorByType,
|
||||
this, std::placeholders::_1);
|
||||
specificCallback->onUpdateAvoidArea_ = std::bind(&SceneSessionManager::UpdateAvoidArea,
|
||||
this, std::placeholders::_1);
|
||||
auto task = [this, sessionInfo, specificCallback, property]() {
|
||||
WLOGFI("sessionInfo: bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, type %{public}u",
|
||||
sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(),
|
||||
@ -526,6 +565,8 @@ sptr<SceneSession> SceneSessionManager::RequestSceneSession(const SessionInfo& s
|
||||
sceneSessionMap_.insert({ persistentId, sceneSession });
|
||||
RegisterSessionStateChangeNotifyManagerFunc(sceneSession);
|
||||
RegisterSessionRectChangeNotifyManagerFunc(sceneSession);
|
||||
RegisterInputMethodShownFunc(sceneSession);
|
||||
RegisterInputMethodHideFunc(sceneSession);
|
||||
WLOGFI("create session persistentId: %{public}" PRIu64 "", persistentId);
|
||||
return sceneSession;
|
||||
};
|
||||
@ -533,6 +574,43 @@ sptr<SceneSession> SceneSessionManager::RequestSceneSession(const SessionInfo& s
|
||||
return taskScheduler_->PostSyncTask(task);
|
||||
}
|
||||
|
||||
void SceneSessionManager::RegisterInputMethodShownFunc(const sptr<SceneSession>& sceneSession)
|
||||
{
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
return;
|
||||
}
|
||||
NotifyCallingSessionForegroundFunc onInputMethodShown = [this](uint64_t persistentId) {
|
||||
this->OnInputMethodShown(persistentId);
|
||||
};
|
||||
sceneSession->SetNotifyCallingSessionForegroundFunc(onInputMethodShown);
|
||||
WLOGFD("RegisterInputMethodShownFunc success");
|
||||
}
|
||||
|
||||
void SceneSessionManager::OnInputMethodShown(const uint64_t& persistentId)
|
||||
{
|
||||
WLOGFD("Resize input method calling window");
|
||||
auto scnSession = GetSceneSession(persistentId);
|
||||
if (scnSession == nullptr) {
|
||||
WLOGFE("Input method is null");
|
||||
return;
|
||||
}
|
||||
ResizeSoftInputCallingSessionIfNeed(scnSession);
|
||||
}
|
||||
|
||||
void SceneSessionManager::RegisterInputMethodHideFunc(const sptr<SceneSession>& sceneSession)
|
||||
{
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
return;
|
||||
}
|
||||
NotifyCallingSessionBackgroundFunc onInputMethodHide = [this]() {
|
||||
this->RestoreCallingSessionSizeIfNeed();
|
||||
};
|
||||
sceneSession->SetNotifyCallingSessionBackgroundFunc(onInputMethodHide);
|
||||
WLOGFD("RegisterInputMethodHideFunc success");
|
||||
}
|
||||
|
||||
sptr<AAFwk::SessionInfo> SceneSessionManager::SetAbilitySessionInfo(const sptr<SceneSession>& scnSession)
|
||||
{
|
||||
sptr<AAFwk::SessionInfo> abilitySessionInfo = new (std::nothrow) AAFwk::SessionInfo();
|
||||
@ -558,10 +636,10 @@ sptr<AAFwk::SessionInfo> SceneSessionManager::SetAbilitySessionInfo(const sptr<S
|
||||
return abilitySessionInfo;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::RequestSceneSessionActivation(const sptr<SceneSession>& sceneSession)
|
||||
WSError SceneSessionManager::RequestSceneSessionActivation(const sptr<SceneSession>& sceneSession, bool isNewActive)
|
||||
{
|
||||
wptr<SceneSession> weakSceneSession(sceneSession);
|
||||
auto task = [this, weakSceneSession]() {
|
||||
auto task = [this, weakSceneSession, isNewActive]() {
|
||||
auto scnSession = weakSceneSession.promote();
|
||||
if (scnSession == nullptr) {
|
||||
WLOGFE("session is nullptr");
|
||||
@ -578,6 +656,7 @@ WSError SceneSessionManager::RequestSceneSessionActivation(const sptr<SceneSessi
|
||||
if (!scnSessionInfo) {
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
scnSessionInfo->isNewWant = isNewActive;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(scnSessionInfo);
|
||||
activeSessionId_ = persistentId;
|
||||
NotifyWindowInfoChange(persistentId, WindowUpdateType::WINDOW_UPDATE_ADDED);
|
||||
@ -640,8 +719,8 @@ WSError SceneSessionManager::DestroyDialogWithMainWindow(const sptr<SceneSession
|
||||
}
|
||||
dialog->NotifyDestroy();
|
||||
dialog->Disconnect();
|
||||
sceneSessionMap_.erase(dialog->GetPersistentId());
|
||||
NotifyWindowInfoChange(dialog->GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_REMOVED);
|
||||
sceneSessionMap_.erase(dialog->GetPersistentId());
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
@ -671,8 +750,8 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptr<SceneSess
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
AAFwk::AbilityManagerClient::GetInstance()->CloseUIAbilityBySCB(scnSessionInfo);
|
||||
sceneSessionMap_.erase(persistentId);
|
||||
NotifyWindowInfoChange(persistentId, WindowUpdateType::WINDOW_UPDATE_REMOVED);
|
||||
sceneSessionMap_.erase(persistentId);
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
@ -724,6 +803,20 @@ void SceneSessionManager::SetGestureNavigationEnabledChangeListener(
|
||||
gestureNavigationEnabledChangeFunc_ = func;
|
||||
}
|
||||
|
||||
void SceneSessionManager::OnOutsideDownEvent(int32_t x, int32_t y)
|
||||
{
|
||||
WLOGFI("OnOutsideDownEvent x = %{public}d, y = %{public}d", x, y);
|
||||
if (outsideDownEventFunc_) {
|
||||
outsideDownEventFunc_(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSessionManager::SetOutsideDownEventListener(const ProcessOutsideDownEventFunc& func)
|
||||
{
|
||||
WLOGFD("SetOutsideDownEventListener");
|
||||
outsideDownEventFunc_ = func;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::DestroyAndDisconnectSpecificSession(const uint64_t& persistentId)
|
||||
{
|
||||
auto task = [this, persistentId]() {
|
||||
@ -739,8 +832,8 @@ WSError SceneSessionManager::DestroyAndDisconnectSpecificSession(const uint64_t&
|
||||
sceneSession->NotifyDestroy();
|
||||
}
|
||||
ret = sceneSession->Disconnect();
|
||||
sceneSessionMap_.erase(persistentId);
|
||||
NotifyWindowInfoChange(persistentId, WindowUpdateType::WINDOW_UPDATE_REMOVED);
|
||||
sceneSessionMap_.erase(persistentId);
|
||||
return ret;
|
||||
};
|
||||
|
||||
@ -978,6 +1071,12 @@ void SceneSessionManager::HandleUpdateProperty(const sptr<WindowSessionProperty>
|
||||
NotifyWindowInfoChange(property->GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY);
|
||||
break;
|
||||
}
|
||||
case WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG: {
|
||||
if (sceneSession->GetSessionProperty() != nullptr) {
|
||||
sceneSession->GetSessionProperty()->SetAnimationFlag(property->GetAnimationFlag());
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1104,7 +1203,7 @@ float SceneSessionManager::GetDisplayBrightness() const
|
||||
|
||||
WMError SceneSessionManager::SetGestureNavigaionEnabled(bool enable)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("SetGestureNavigationEnabled permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
@ -1162,11 +1261,6 @@ WSError SceneSessionManager::UpdateFocus(uint64_t persistentId, bool isFocused)
|
||||
WLOGFE("could not find window");
|
||||
return WSError::WS_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
WSError res = WSError::WS_OK;
|
||||
res = sceneSession->UpdateFocus(isFocused);
|
||||
if (res != WSError::WS_OK) {
|
||||
return res;
|
||||
}
|
||||
// focusId change
|
||||
if (isFocused) {
|
||||
SetFocusedSession(persistentId);
|
||||
@ -1183,6 +1277,11 @@ WSError SceneSessionManager::UpdateFocus(uint64_t persistentId, bool isFocused)
|
||||
sceneSession->GetAbilityToken()
|
||||
);
|
||||
SessionManagerAgentController::GetInstance().UpdateFocusChangeInfo(focusChangeInfo, isFocused);
|
||||
WSError res = WSError::WS_OK;
|
||||
res = sceneSession->UpdateFocus(isFocused);
|
||||
if (res != WSError::WS_OK) {
|
||||
return res;
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
|
||||
@ -1278,7 +1377,10 @@ WSError SceneSessionManager::SetWindowFlags(const sptr<SceneSession>& sceneSessi
|
||||
if ((oldFlags ^ flags) == static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK)) {
|
||||
CheckAndNotifyWaterMarkChangedResult(flags & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK));
|
||||
}
|
||||
WLOGFI("SetWindowFlags end");
|
||||
if ((oldFlags ^ flags) == static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED)) {
|
||||
sceneSession->OnShowWhenLocked(flags & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED));
|
||||
}
|
||||
WLOGFI("SetWindowFlags end, flags: %{public}u", flags);
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
@ -1341,6 +1443,22 @@ WSError SceneSessionManager::SetSessionIcon(const sptr<IRemoteObject> &token,
|
||||
return WSError::WS_ERROR_SET_SESSION_ICON_FAILED;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller)
|
||||
{
|
||||
WLOGFI("run SetSessionIcon");
|
||||
if (info == nullptr) {
|
||||
WLOGFI("sessionInfo is nullptr.");
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
}
|
||||
sptr<SceneSession> sceneSession = FindSessionByToken(info->sessionToken);
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFI("fail to find session by token.");
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
}
|
||||
const WSError& errCode = sceneSession->TerminateSessionNew(info, needStartCaller);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::RegisterSessionListener(const sptr<ISessionListener> sessionListener)
|
||||
{
|
||||
WLOGFI("run RegisterSessionListener");
|
||||
@ -1486,7 +1604,7 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed(const sptr<SceneSe
|
||||
|
||||
callingWindowRestoringRect_ = callingSessionRect;
|
||||
NotifyOccupiedAreaChangeInfo(callingSession, newRect, softInputSessionRect);
|
||||
callingSession->UpdateSessionRect(callingWindowRestoringRect_, SizeChangeReason::UNDEFINED);
|
||||
callingSession->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED);
|
||||
}
|
||||
|
||||
void SceneSessionManager::NotifyOccupiedAreaChangeInfo(const sptr<SceneSession> callingSession,
|
||||
@ -1496,11 +1614,14 @@ void SceneSessionManager::NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>
|
||||
const WSRect& safeRect = SessionHelper::GetOverlap(occupiedArea, rect, 0, 0);
|
||||
sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT,
|
||||
SessionHelper::TransferToRect(occupiedArea), safeRect.height_);
|
||||
WLOGFD("OccupiedAreaChangeInfo rect: %{public}u %{public}u %{public}u %{public}u",
|
||||
occupiedArea.posX_, occupiedArea.posY_, occupiedArea.width_, occupiedArea.height_);
|
||||
callingSession->NotifyOccupiedAreaChangeInfo(info);
|
||||
}
|
||||
|
||||
void SceneSessionManager::RestoreCallingSessionSizeIfNeed()
|
||||
{
|
||||
WLOGFD("RestoreCallingSessionSizeIfNeed");
|
||||
auto callingSession = GetSceneSession(focusedSessionId_);
|
||||
if (!SessionHelper::IsEmptyRect(callingWindowRestoringRect_) && callingSession != nullptr &&
|
||||
callingSession->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) {
|
||||
@ -1623,10 +1744,10 @@ void SceneSessionManager::FillWindowInfo(std::vector<sptr<AccessibilityWindowInf
|
||||
info->focused_ = sceneSession->GetPersistentId() == focusedSessionId_;
|
||||
info->type_ = sceneSession->GetWindowType();
|
||||
info->mode_ = sceneSession->GetWindowMode();
|
||||
info->layer_ = sceneSession->GetZOrder();
|
||||
auto property = sceneSession->GetSessionProperty();
|
||||
if (property != nullptr) {
|
||||
info->displayId_ = property->GetDisplayId();
|
||||
info->layer_ = property->GetZOrder();
|
||||
info->isDecorEnable_ = property->IsDecorEnable();
|
||||
}
|
||||
infos.emplace_back(info);
|
||||
@ -1801,4 +1922,94 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr<IRemoteObject> &token)
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
WSError SceneSessionManager::UpdateSessionAvoidAreaListener(uint64_t& persistentId, bool haveListener)
|
||||
{
|
||||
WLOGFI("UpdateSessionAvoidAreaListener persistentId: %{public}" PRIu64 " haveListener:%{public}d",
|
||||
persistentId, haveListener);
|
||||
auto sceneSession = GetSceneSession(persistentId);
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("sceneSession is nullptr.");
|
||||
return WSError::WS_DO_NOTHING;
|
||||
}
|
||||
if (haveListener) {
|
||||
avoidAreaListenerSessionSet_.insert(sceneSession);
|
||||
} else {
|
||||
lastUpdatedAvoidArea_.erase(persistentId);
|
||||
avoidAreaListenerSessionSet_.erase(sceneSession);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
bool SceneSessionManager::UpdateSessionAvoidAreaIfNeed(const uint64_t& persistentId,
|
||||
const AvoidArea& avoidArea, AvoidAreaType avoidAreaType)
|
||||
{
|
||||
auto iter = lastUpdatedAvoidArea_.find(persistentId);
|
||||
bool needUpdate = true;
|
||||
|
||||
if (iter != lastUpdatedAvoidArea_.end()) {
|
||||
auto avoidAreaIter = iter->second.find(avoidAreaType);
|
||||
if (avoidAreaIter != iter->second.end()) {
|
||||
needUpdate = avoidAreaIter->second != avoidArea;
|
||||
} else {
|
||||
if (avoidArea.isEmptyAvoidArea()) {
|
||||
needUpdate = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (avoidArea.isEmptyAvoidArea()) {
|
||||
needUpdate = false;
|
||||
}
|
||||
}
|
||||
if (needUpdate) {
|
||||
auto sceneSession = GetSceneSession(persistentId);
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("sceneSession is nullptr.");
|
||||
return false;
|
||||
}
|
||||
lastUpdatedAvoidArea_[persistentId][avoidAreaType] = avoidArea;
|
||||
sceneSession->UpdateAvoidArea(new AvoidArea(avoidArea), avoidAreaType);
|
||||
}
|
||||
|
||||
return needUpdate;
|
||||
}
|
||||
|
||||
bool SceneSessionManager::UpdateAvoidArea(const uint64_t& persistentId)
|
||||
{
|
||||
bool needUpdate = true;
|
||||
auto sceneSession = GetSceneSession(persistentId);
|
||||
if (sceneSession == nullptr) {
|
||||
WLOGFE("sceneSession is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
WindowType type = sceneSession->GetWindowType();
|
||||
SessionGravity gravity;
|
||||
uint32_t percent = 0;
|
||||
sceneSession->GetSessionProperty()->GetSessionGravity(gravity, percent);
|
||||
if (type == WindowType::WINDOW_TYPE_STATUS_BAR ||
|
||||
type == WindowType::WINDOW_TYPE_NAVIGATION_BAR ||
|
||||
(type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
|
||||
gravity == SessionGravity::SESSION_GRAVITY_BOTTOM)) {
|
||||
AvoidAreaType avoidType = (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) ?
|
||||
AvoidAreaType::TYPE_KEYBOARD : AvoidAreaType::TYPE_SYSTEM;
|
||||
for (auto& session : avoidAreaListenerSessionSet_) {
|
||||
AvoidArea avoidArea = session->GetAvoidAreaByType(avoidType);
|
||||
needUpdate |= UpdateSessionAvoidAreaIfNeed(session->GetPersistentId(), avoidArea, avoidType);
|
||||
}
|
||||
} else {
|
||||
if (avoidAreaListenerSessionSet_.find(sceneSession) == avoidAreaListenerSessionSet_.end()) {
|
||||
WLOGD("id:%{public}" PRIu64" is not in avoidAreaListenerNodes, don't update avoid area.", persistentId);
|
||||
return false;
|
||||
}
|
||||
uint32_t start = static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM);
|
||||
uint32_t end = static_cast<uint32_t>(AvoidAreaType::TYPE_KEYBOARD);
|
||||
for (uint32_t avoidType = start; avoidType <= end; avoidType++) {
|
||||
AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(static_cast<AvoidAreaType>(avoidType));
|
||||
needUpdate |= UpdateSessionAvoidAreaIfNeed(persistentId, avoidArea, static_cast<AvoidAreaType>(avoidType));
|
||||
}
|
||||
}
|
||||
|
||||
return needUpdate;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -25,11 +25,14 @@ constexpr std::vector<int>::size_type LEFT = 0;
|
||||
constexpr std::vector<int>::size_type TOP = 1;
|
||||
constexpr std::vector<int>::size_type RIGHT = 2;
|
||||
constexpr std::vector<int>::size_type BOTTOM = 3;
|
||||
constexpr char CURVED_SCREEN_BOUNDARY[] = "curvedScreenBoundary";
|
||||
constexpr uint32_t HALF_SCREEN = 2;
|
||||
constexpr uint8_t HALF_SCREEN = 2;
|
||||
constexpr uint8_t QUARTER_SCREEN = 4;
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenCutoutController" };
|
||||
}
|
||||
|
||||
uint32_t ScreenCutoutController::defaultDeviceRotation_ = 0;
|
||||
std::map<DeviceRotationValue, Rotation> ScreenCutoutController::deviceToDisplayRotationMap_;
|
||||
|
||||
sptr<CutoutInfo> ScreenCutoutController::GetScreenCutoutInfo()
|
||||
{
|
||||
WLOGFD("get screen cutout info.");
|
||||
@ -76,15 +79,15 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector<DMRect>&
|
||||
}
|
||||
case Rotation::ROTATION_180: {
|
||||
for (DMRect rect : displayBoundaryRects) {
|
||||
finalVector.emplace_back(DMRect {displayWidth - rect.posX_ - rect.width_,
|
||||
displayHeight - rect.posY_ - rect.height_, rect.width_, rect.height_});
|
||||
finalVector.emplace_back(DMRect{ displayWidth - rect.posX_ - rect.width_,
|
||||
displayHeight - rect.posY_ - rect.height_, rect.width_, rect.height_ });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Rotation::ROTATION_270: {
|
||||
for (DMRect rect : displayBoundaryRects) {
|
||||
finalVector.emplace_back(
|
||||
DMRect{ rect.posY_, displayWidth - rect.posX_ - rect.width_, rect.height_, rect.width_});
|
||||
DMRect{ rect.posY_, displayWidth - rect.posX_ - rect.width_, rect.height_, rect.width_ });
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -127,8 +130,7 @@ void ScreenCutoutController::CalcWaterfallRects()
|
||||
return;
|
||||
}
|
||||
|
||||
auto initConfig = ScreenSceneConfig::GetIntNumbersConfig();
|
||||
std::vector<int> numberVec = initConfig[CURVED_SCREEN_BOUNDARY];
|
||||
std::vector<int> numberVec = ScreenSceneConfig::GetCurvedScreenBoundaryConfig();
|
||||
if (numberVec.empty()) {
|
||||
WLOGFI("curved screen boundary is empty");
|
||||
waterfallDisplayAreaRects_ = emptyRects;
|
||||
@ -161,9 +163,8 @@ void ScreenCutoutController::CalcWaterfallRects()
|
||||
return;
|
||||
}
|
||||
|
||||
CalcWaterfallRectsByRotation(
|
||||
ScreenSessionManager::GetInstance().GetDefaultDisplayInfo()->GetRotation(), displayHeight,
|
||||
displayWidth, realNumVec);
|
||||
CalcWaterfallRectsByRotation(ScreenSessionManager::GetInstance().GetDefaultDisplayInfo()->GetRotation(),
|
||||
displayHeight, displayWidth, realNumVec);
|
||||
}
|
||||
|
||||
void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight,
|
||||
@ -177,7 +178,7 @@ void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uin
|
||||
CreateWaterfallRect(displayWidth - realNumVec[RIGHT], 0, realNumVec[RIGHT], displayHeight);
|
||||
DMRect bottomRect =
|
||||
CreateWaterfallRect(0, displayHeight - realNumVec[BOTTOM], displayWidth, realNumVec[BOTTOM]);
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect};
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects{ leftRect, topRect, rightRect, bottomRect };
|
||||
return;
|
||||
}
|
||||
case Rotation::ROTATION_90: {
|
||||
@ -186,7 +187,7 @@ void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uin
|
||||
DMRect rightRect = CreateWaterfallRect(displayHeight - realNumVec[TOP], 0, realNumVec[TOP], displayWidth);
|
||||
DMRect bottomRect =
|
||||
CreateWaterfallRect(0, displayWidth - realNumVec[RIGHT], displayHeight, realNumVec[RIGHT]);
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect};
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects{ leftRect, topRect, rightRect, bottomRect };
|
||||
return;
|
||||
}
|
||||
case Rotation::ROTATION_180: {
|
||||
@ -194,7 +195,7 @@ void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uin
|
||||
DMRect topRect = CreateWaterfallRect(0, 0, realNumVec[BOTTOM], displayWidth);
|
||||
DMRect rightRect = CreateWaterfallRect(displayWidth - realNumVec[LEFT], 0, realNumVec[LEFT], displayHeight);
|
||||
DMRect bottomRect = CreateWaterfallRect(0, displayHeight - realNumVec[TOP], displayWidth, realNumVec[TOP]);
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect};
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects{ leftRect, topRect, rightRect, bottomRect };
|
||||
return;
|
||||
}
|
||||
case Rotation::ROTATION_270: {
|
||||
@ -204,7 +205,7 @@ void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uin
|
||||
CreateWaterfallRect(displayHeight - realNumVec[BOTTOM], 0, realNumVec[BOTTOM], displayWidth);
|
||||
DMRect bottomRect =
|
||||
CreateWaterfallRect(0, displayWidth - realNumVec[LEFT], displayHeight, realNumVec[LEFT]);
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect};
|
||||
waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects{ leftRect, topRect, rightRect, bottomRect };
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
@ -215,8 +216,105 @@ void ScreenCutoutController::CalcWaterfallRectsByRotation(Rotation rotation, uin
|
||||
DMRect ScreenCutoutController::CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height)
|
||||
{
|
||||
if (width == 0 || height == 0) {
|
||||
return DMRect {0, 0, 0, 0};
|
||||
return DMRect{ 0, 0, 0, 0 };
|
||||
}
|
||||
return DMRect {left, top, width, height};
|
||||
}
|
||||
|
||||
RectF ScreenCutoutController::CalculateCurvedCompression(const ScreenProperty& screenProperty)
|
||||
{
|
||||
WLOGFI("calculate curved compression");
|
||||
RectF finalRect = RectF(0, 0, 0, 0);
|
||||
sptr<DisplayInfo> displayInfo = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo();
|
||||
uint32_t iCurvedSize = ScreenSceneConfig::GetCurvedCompressionAreaInLandscape();
|
||||
if (!displayInfo || iCurvedSize == 0) {
|
||||
WLOGFE("display Info. invalid or curved area config value is zero");
|
||||
return finalRect;
|
||||
}
|
||||
|
||||
uint32_t screenWidth = displayInfo->GetWidth();
|
||||
uint32_t screenHeight = displayInfo->GetHeight();
|
||||
uint32_t realWidth = static_cast<uint32_t>(iCurvedSize * screenProperty.GetVirtualPixelRatio());
|
||||
if (realWidth >= screenHeight / QUARTER_SCREEN || realWidth >= screenWidth / QUARTER_SCREEN) {
|
||||
WLOGFW("curved area is beyond the edge limit");
|
||||
return finalRect;
|
||||
}
|
||||
|
||||
Rotation rotation = displayInfo->GetRotation();
|
||||
WLOGFI("realWidth : %{public}u rotation : %{public}u", realWidth, rotation);
|
||||
bool isLandscape = screenHeight < screenWidth ? true : false;
|
||||
uint32_t totalCompressedSize = realWidth * HALF_SCREEN; // *2 for both sides.
|
||||
uint32_t displayHeightAfter =
|
||||
isLandscape ? screenHeight - totalCompressedSize : screenWidth - totalCompressedSize;
|
||||
finalRect.left_ = screenProperty.GetBounds().rect_.GetLeft();
|
||||
finalRect.top_ = screenProperty.GetBounds().rect_.GetTop();
|
||||
if (!IsDisplayRotationHorizontal(rotation)) {
|
||||
finalRect.width_ = displayHeightAfter;
|
||||
finalRect.height_ = screenProperty.GetBounds().rect_.GetHeight();
|
||||
offsetY_ = realWidth;
|
||||
SetWaterfallDisplayCompressionStatus(true);
|
||||
} else {
|
||||
if (GetWaterfallDisplayCompressionStatus()) {
|
||||
displayHeightAfter =
|
||||
isLandscape ? screenHeight + totalCompressedSize : screenWidth + totalCompressedSize;
|
||||
}
|
||||
finalRect.width_ = screenProperty.GetBounds().rect_.GetWidth();
|
||||
finalRect.height_ = displayHeightAfter;
|
||||
SetWaterfallDisplayCompressionStatus(false);
|
||||
}
|
||||
return finalRect;
|
||||
}
|
||||
|
||||
bool ScreenCutoutController::IsDisplayRotationHorizontal(Rotation rotation)
|
||||
{
|
||||
return (rotation == ConvertDeviceToDisplayRotation(DeviceRotationValue::ROTATION_LANDSCAPE)) ||
|
||||
(rotation == ConvertDeviceToDisplayRotation(DeviceRotationValue::ROTATION_LANDSCAPE_INVERTED));
|
||||
}
|
||||
|
||||
Rotation ScreenCutoutController::ConvertDeviceToDisplayRotation(DeviceRotationValue deviceRotation)
|
||||
{
|
||||
if (deviceRotation == DeviceRotationValue::INVALID) {
|
||||
return GetCurrentDisplayRotation();
|
||||
}
|
||||
if (deviceToDisplayRotationMap_.empty()) {
|
||||
ProcessRotationMapping();
|
||||
}
|
||||
return deviceToDisplayRotationMap_.at(deviceRotation);
|
||||
}
|
||||
|
||||
Rotation ScreenCutoutController::GetCurrentDisplayRotation()
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo();
|
||||
if (!displayInfo) {
|
||||
WLOGFE("Cannot get default display info");
|
||||
return defaultDeviceRotation_ == 0 ? ConvertDeviceToDisplayRotation(DeviceRotationValue::ROTATION_PORTRAIT) :
|
||||
ConvertDeviceToDisplayRotation(DeviceRotationValue::ROTATION_LANDSCAPE);
|
||||
}
|
||||
return displayInfo->GetRotation();
|
||||
}
|
||||
|
||||
void ScreenCutoutController::ProcessRotationMapping()
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo();
|
||||
// 0 means PORTRAIT, 1 means LANDSCAPE.
|
||||
defaultDeviceRotation_ =
|
||||
(!displayInfo || (displayInfo && (displayInfo->GetWidth() < displayInfo->GetHeight()))) ? 0 : 1;
|
||||
if (deviceToDisplayRotationMap_.empty()) {
|
||||
deviceToDisplayRotationMap_ = {
|
||||
{DeviceRotationValue::ROTATION_PORTRAIT,
|
||||
defaultDeviceRotation_ == 0 ? Rotation::ROTATION_0 : Rotation::ROTATION_90},
|
||||
{DeviceRotationValue::ROTATION_LANDSCAPE,
|
||||
defaultDeviceRotation_ == 1 ? Rotation::ROTATION_0 : Rotation::ROTATION_90},
|
||||
{DeviceRotationValue::ROTATION_PORTRAIT_INVERTED,
|
||||
defaultDeviceRotation_ == 0 ? Rotation::ROTATION_180 : Rotation::ROTATION_270},
|
||||
{DeviceRotationValue::ROTATION_LANDSCAPE_INVERTED,
|
||||
defaultDeviceRotation_ == 1 ? Rotation::ROTATION_180 : Rotation::ROTATION_270},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ScreenCutoutController::GetOffsetY()
|
||||
{
|
||||
return offsetY_;
|
||||
}
|
||||
} // 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