Merge branch 'master' of gitee.com:openharmony/window_window_manager into dev20241114am

Signed-off-by: yxn22 <yexinnian3@huawei.com>
This commit is contained in:
yxn22 2024-11-18 04:43:48 +00:00 committed by Gitee
commit 1d74ddef9b
178 changed files with 2777 additions and 1211 deletions

View File

@ -72,8 +72,7 @@
"libjpeg-turbo",
"libxml2",
"bounds_checking_function",
"device_status",
"ets_frontend"
"device_status"
],
"third_party": [
]

View File

@ -877,9 +877,9 @@ void DisplayManager::ShowDisplayIdList(bool isShowLog)
oss << iter.second << ",";
}
if (isShowLog) {
WLOGFD("%{public}s]", oss.str().c_str());
} else {
WLOGFI("%{public}s]", oss.str().c_str());
} else {
WLOGFD("%{public}s]", oss.str().c_str());
}
}

View File

@ -104,6 +104,7 @@ enum class DisplayManagerMessage : unsigned int {
TRANS_ID_SET_CLIENT = 2500,
TRANS_ID_GET_SCREEN_PROPERTY,
TRANS_ID_GET_DISPLAY_NODE,
TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO,
TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY,
TRANS_ID_UPDATE_AVAILABLE_AREA,
TRANS_ID_SET_SCREEN_OFF_DELAY_TIME,

View File

@ -466,6 +466,15 @@ struct ScrollableParam {
std::string friction_;
};
/**
* @brief screen direction info
*/
struct ScreenDirectionInfo {
int32_t notifyRotation_;
int32_t screenRotation_;
int32_t rotation_;
};
/**
* @brief displayRect
*/

View File

@ -1626,17 +1626,15 @@ public:
/**
* @brief Set requested mode support info.
*
* @param modeSupportInfo Mode of window supported.
* @param windowModeSupportType Mode of window supported.
*/
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) {}
virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) {}
/**
* @brief Get requested mode support info.
*
* @return Enumeration values under WindowModeSupport.
*/
virtual uint32_t GetRequestModeSupportInfo() const { return 0; }
virtual uint32_t GetRequestWindowModeSupportType() const { return 0; }
/**
* @brief Set touch hot areas.
*

View File

@ -713,6 +713,11 @@ struct Rect {
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
bool IsUninitializedSize() const
{
return width_ == 0 && height_ == 0;
}
bool IsInsideOf(const Rect& a) const
{
return (posX_ >= a.posX_ && posY_ >= a.posY_ &&

View File

@ -90,6 +90,7 @@ ohos_shared_library("extensionwindow_napi") {
":extension_window_kit_config",
"../../../../resources/config/build:coverage_flags",
]
public_configs = [ ":extension_window_kit_config" ]
include_dirs = [ "extension_window" ]
deps = [

View File

@ -28,6 +28,7 @@ namespace Rosen {
using namespace AbilityRuntime;
namespace {
const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange";
const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange";
const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange";
const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange";
const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent";
@ -70,7 +71,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r
{
TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u",
rect.width_, rect.height_, reason);
if (currentWidth_ == rect.width_ && currentHeight_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) {
if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ &&
reason != WindowSizeChangeReason::DRAG_END) {
TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]no need to change size");
return;
}
@ -111,8 +113,56 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r
eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnSizeChange", 0,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
currentWidth_ = rect.width_;
currentHeight_ = rect.height_;
currRect_ = rect;
}
void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason)
{
if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) {
TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update");
return;
}
RectChangeReason rectChangeReason = RectChangeReason::UNDEFINED;
if (JS_SIZE_CHANGE_REASON.count(reason) != 0 &&
!(reason == WindowSizeChangeReason::MAXIMIZE && rect.posX_ != 0)) {
rectChangeReason = JS_SIZE_CHANGE_REASON.at(reason);
}
if (currentRectChangeReason_ != RectChangeReason::DRAG && rectChangeReason == RectChangeReason::DRAG_END) {
rectChangeReason = RectChangeReason::MOVE;
}
// js callback should run in js thread
auto jsCallback = [self = weakRef_, rect, rectChangeReason, env = env_] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange");
auto thisListener = self.promote();
if (thisListener == nullptr || env == nullptr) {
TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr");
return;
}
HandleScope handleScope(env);
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
if (objValue == nullptr) {
TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create js object");
return;
}
napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect);
if (rectObjValue == nullptr) {
TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create rect js object");
return;
}
napi_set_named_property(env, objValue, "rect", rectObjValue);
napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangeReason));
napi_value argv[] = { objValue };
thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv));
};
if (!eventHandler_) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!");
return;
}
eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
currRect_ = rect;
currentRectChangeReason_ = rectChangeReason;
}
void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco)

View File

@ -27,10 +27,12 @@
#include "window_manager.h"
#include "wm_common.h"
#include "js_extension_window_utils.h"
#include "js_window_utils.h"
namespace OHOS {
namespace Rosen {
class JsExtensionWindowListener : public IWindowChangeListener,
public IWindowRectChangeListener,
public IAvoidAreaChangedListener,
public IWindowLifeCycle,
public IOccupiedAreaChangeListener {
@ -41,6 +43,7 @@ public:
~JsExtensionWindowListener();
void OnSizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
void OnRectChange(Rect rect, WindowSizeChangeReason reason) override;
void OnModeChange(WindowMode mode, bool hasDeco) override;
void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override;
void AfterForeground() override;
@ -56,8 +59,8 @@ public:
void SetMainEventHandler();
private:
uint32_t currentWidth_ = 0;
uint32_t currentHeight_ = 0;
Rect currRect_;
RectChangeReason currentRectChangeReason_ = RectChangeReason::UNDEFINED;
napi_env env_ = nullptr;
WindowState state_ {WindowState::STATE_INITIAL};
std::shared_ptr<NativeReference> jsCallBack_;

View File

@ -22,6 +22,7 @@ namespace OHOS {
namespace Rosen {
namespace {
const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange";
const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange";
const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange";
const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent";
const std::string WINDOW_EVENT_CB = "windowEvent";
@ -32,6 +33,7 @@ JsExtensionWindowRegisterManager::JsExtensionWindowRegisterManager()
// white register list for window
listenerCodeMap_[CaseType::CASE_WINDOW] = {
{WINDOW_SIZE_CHANGE_CB, ListenerType::WINDOW_SIZE_CHANGE_CB},
{WINDOW_RECT_CHANGE_CB, ListenerType::WINDOW_RECT_CHANGE_CB},
{AVOID_AREA_CHANGE_CB, ListenerType::AVOID_AREA_CHANGE_CB},
{WINDOW_EVENT_CB, ListenerType::WINDOW_EVENT_CB},
};
@ -62,6 +64,23 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr<J
return ret;
}
WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister(
const sptr<JsExtensionWindowListener>& listener, const sptr<Window>& window, bool isRegister)
{
if (window == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr");
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
sptr<IWindowRectChangeListener> thisListener(listener);
WmErrorCode ret = WmErrorCode::WM_OK;
if (isRegister) {
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowRectChangeListener(thisListener));
} else {
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowRectChangeListener(thisListener));
}
return ret;
}
WmErrorCode JsExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr<JsExtensionWindowListener> listener,
sptr<Window> window, bool isRegister)
{
@ -209,6 +228,9 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessRegister(CaseType caseType,
case ListenerType::WINDOW_SIZE_CHANGE_CB:
ret = ProcessWindowChangeRegister(listener, window, isRegister);
break;
case ListenerType::WINDOW_RECT_CHANGE_CB:
ret = ProcessWindowRectChangeRegister(listener, window, isRegister);
break;
case ListenerType::AVOID_AREA_CHANGE_CB:
ret = ProcessAvoidAreaChangeRegister(listener, window, isRegister);
break;

View File

@ -39,6 +39,7 @@ public:
private:
enum class ListenerType : uint32_t {
WINDOW_SIZE_CHANGE_CB,
WINDOW_RECT_CHANGE_CB,
AVOID_AREA_CHANGE_CB,
WINDOW_EVENT_CB,
WINDOW_STAGE_EVENT_CB,
@ -47,6 +48,8 @@ private:
bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject);
WmErrorCode ProcessWindowChangeRegister(sptr<JsExtensionWindowListener> listener,
sptr<Window> window, bool isRegister);
WmErrorCode ProcessWindowRectChangeRegister(const sptr<JsExtensionWindowListener>& listener,
const sptr<Window>& window, bool isRegister);
WmErrorCode ProcessAvoidAreaChangeRegister(sptr<JsExtensionWindowListener> listener,
sptr<Window> window, bool isRegister);
WmErrorCode ProcessLifeCycleEventRegister(sptr<JsExtensionWindowListener> listener,

View File

@ -2643,33 +2643,37 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf
if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter");
}
const char* const funcName = __func__;
NapiAsyncTask::CompleteCallback complete =
[weakToken = wptr<Window>(windowToken_), isTitleHoverShown, isDockHoverShown, funcName](napi_env env,
NapiAsyncTask& task, int32_t status) {
// 2: params num; 2: index of callback
napi_value lastParam = (argc <= 2) ? nullptr :
(GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr);
napi_value result = nullptr;
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result);
const char* const where = __func__;
auto asyncTask = [weakToken = wptr<Window>(windowToken_), isTitleHoverShown,
isDockHoverShown, env, task = napiAsyncTask, where] {
auto window = weakToken.promote();
if (window == nullptr) {
TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName);
task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", where);
task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
return;
}
WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown);
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode);
if (ret != WmErrorCode::WM_OK) {
TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName);
task.Reject(env, JsErrUtils::CreateJsError(env,
TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", where);
task->Reject(env, JsErrUtils::CreateJsError(env,
ret, "Window OnSetTitleAndDockHoverShown failed."));
} else {
task.Resolve(env, NapiGetUndefined(env));
return;
}
task->Resolve(env, NapiGetUndefined(env));
TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]",
funcName, window->GetWindowId(), window->GetWindowName().c_str(),
where, window->GetWindowId(), window->GetWindowName().c_str(),
isTitleHoverShown, isDockHoverShown);
};
napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[2]) == napi_function ? argv[2] : nullptr);
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::OnSetTitleAndDockHoverShown",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) {
napiAsyncTask->Reject(env, CreateJsError(env,
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed"));
}
return result;
}
@ -3629,7 +3633,7 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info
} else {
task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed"));
}
TLOGI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, state: %{public}d",
TLOGNI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d",
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
};
@ -5895,51 +5899,50 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info)
napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info)
{
WmErrorCode errCode = WmErrorCode::WM_OK;
errCode = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
size_t argc = FOUR_PARAMS_SIZE;
napi_value argv[FOUR_PARAMS_SIZE] = { nullptr };
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc > 1) {
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
}
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc);
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
if (errCode == WmErrorCode::WM_OK && WindowHelper::IsSubWindow(windowToken_->GetType())) {
WLOGFE("subWindow hide");
if (windowToken_ == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
if (WindowHelper::IsSubWindow(windowToken_->GetType())) {
TLOGI(WmsLogTag::WMS_LAYOUT, "subWindow use hide");
return HideWindowFunction(env, info, WmErrorCode::WM_OK);
}
wptr<Window> weakToken(windowToken_);
NapiAsyncTask::CompleteCallback complete =
[weakToken, errCode](napi_env env, NapiAsyncTask& task, int32_t status) mutable {
auto weakWindow = weakToken.promote();
errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode;
if (errCode != WmErrorCode::WM_OK) {
task.Reject(env,
JsErrUtils::CreateJsError(env, errCode, "OnMinimize failed."));
WLOGFE("window is nullptr");
napi_value lastParam = (argc == 0) ? nullptr :
(GetType(env, argv[INDEX_ZERO]) == napi_function ? argv[INDEX_ZERO] : nullptr);
napi_value result = nullptr;
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result);
const char* const where = __func__;
auto asyncTask = [weakToken = wptr<Window>(windowToken_), env, task = napiAsyncTask, where] {
auto window = weakToken.promote();
if (window == nullptr) {
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where);
task->Reject(env,
JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr"));
return;
}
WMError ret = weakWindow->Minimize();
WMError ret = window->Minimize();
if (ret == WMError::WM_OK) {
task.Resolve(env, NapiGetUndefined(env));
task->Resolve(env, NapiGetUndefined(env));
} else {
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret);
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed."));
task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed."));
}
WLOGI("[NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d",
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s Window [%{public}u, %{public}s] minimize end, ret = %{public}d",
where, window->GetWindowId(), window->GetWindowName().c_str(), ret);
};
napi_value lastParam = (argc == 0) ? nullptr :
(GetType(env, argv[0]) == napi_function ? argv[0] : nullptr);
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::OnMinimize",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) {
napiAsyncTask->Reject(env, CreateJsError(env,
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed"));
}
return result;
}
@ -6313,8 +6316,8 @@ napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_inf
napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = { nullptr };
size_t argc = FOUR_PARAMS_SIZE;
napi_value argv[FOUR_PARAMS_SIZE] = { nullptr };
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 1 || argc > 2) { // 1: the minimum param num 2: the maximum param num
TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc);
@ -6342,39 +6345,41 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
}
napi_value result = nullptr;
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
const char* const where = __func__;
NapiAsyncTask::CompleteCallback complete =
[where, window = windowToken_, isModal, modalityType](napi_env env, NapiAsyncTask& task, int32_t status) {
auto asyncTask = [where, weakToken = wptr<Window>(windowToken_), isModal, modalityType, env, task = napiAsyncTask] {
auto window = weakToken.promote();
if (window == nullptr) {
TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where);
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR);
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr."));
task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr."));
return;
}
if (!WindowHelper::IsSubWindow(window->GetType())) {
TLOGNE(WmsLogTag::WMS_SUB, "%{public}s invalid call, type:%{public}d",
where, window->GetType());
task.Reject(env, JsErrUtils::CreateJsError(env,
task->Reject(env, JsErrUtils::CreateJsError(env,
WmErrorCode::WM_ERROR_INVALID_CALLING, "invalid window type."));
return;
}
WMError ret = window->SetSubWindowModal(isModal, modalityType);
if (ret == WMError::WM_OK) {
task.Resolve(env, NapiGetUndefined(env));
task->Resolve(env, NapiGetUndefined(env));
} else {
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret);
TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d", where, wmErrorCode);
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed"));
task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed"));
return;
}
TLOGNI(WmsLogTag::WMS_SUB,
"%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}hhu",
where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType);
};
napi_value lastParam = nullptr;
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) {
napiAsyncTask->Reject(env,
CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed"));
}
return result;
}
@ -6583,51 +6588,54 @@ napi_value JsWindow::OnSetWindowTitleButtonVisible(napi_env env, napi_callback_i
napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
size_t argc = FOUR_PARAMS_SIZE;
napi_value argv[FOUR_PARAMS_SIZE] = { nullptr };
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 1) {
WLOGFE("Argc is invalid: %{public}zu", argc);
TLOGE(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc);
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
if (!CheckWindowMaskParams(env, argv[0])) {
if (!CheckWindowMaskParams(env, argv[INDEX_ZERO])) {
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
std::vector<std::vector<uint32_t>> windowMask;
if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) {
WLOGFE("GetWindowMaskFromJsValue failed");
if (!GetWindowMaskFromJsValue(env, argv[INDEX_ZERO], windowMask)) {
TLOGE(WmsLogTag::DEFAULT, "GetWindowMaskFromJsValue failed");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
wptr<Window> weakToken(windowToken_);
NapiAsyncTask::CompleteCallback complete =
[weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) {
auto weakWindow = weakToken.promote();
if (weakWindow == nullptr) {
WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate params"));
return;
}
if (!WindowHelper::IsSubWindow(weakWindow->GetType()) &&
!WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) {
WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING;
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type"));
return;
}
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask));
if (ret != WmErrorCode::WM_OK) {
task.Reject(env, JsErrUtils::CreateJsError(env, ret));
WLOGFE("Window [%{public}u, %{public}s] set window mask failed",
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
return;
}
task.Resolve(env, NapiGetUndefined(env));
WLOGI("Window [%{public}u, %{public}s] set window mask succeed",
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
};
napi_value lastParam = nullptr;
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::OnSetWindowMask",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
const char* const where = __func__;
auto asyncTask = [weakToken = wptr<Window>(windowToken_), windowMask = std::move(windowMask), env,
task = napiAsyncTask, where] {
auto window = weakToken.promote();
if (window == nullptr) {
TLOGNE(WmsLogTag::DEFAULT, "%{public}s window is nullptr", where);
WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr"));
return;
}
if (!WindowHelper::IsSubWindow(window->GetType()) &&
!WindowHelper::IsAppFloatingWindow(window->GetType())) {
WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING;
task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type"));
return;
}
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask));
if (ret != WmErrorCode::WM_OK) {
task->Reject(env, JsErrUtils::CreateJsError(env, ret));
TLOGNE(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask failed",
where, window->GetWindowId(), window->GetWindowName().c_str());
return;
}
task->Resolve(env, NapiGetUndefined(env));
TLOGNI(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask succeed",
where, window->GetWindowId(), window->GetWindowName().c_str());
};
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) {
napiAsyncTask->Reject(env,
CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed"));
}
return result;
}

View File

@ -73,18 +73,19 @@ napi_value JsWindowListener::CallJsMethod(const char* methodName, napi_value con
void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
WLOGI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason);
if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ &&
reason != WindowSizeChangeReason::DRAG_END) {
WLOGFD("[NAPI]no need to change size");
TLOGD(WmsLogTag::WMS_LAYOUT, "no need to change size");
return;
}
TLOGI(WmsLogTag::WMS_LAYOUT, "wh[%{public}u, %{public}u], reason = %{public}u",
rect.width_, rect.height_, reason);
// js callback should run in js thread
auto jsCallback = [self = weakRef_, rect, eng = env_] () {
auto jsCallback = [self = weakRef_, rect, eng = env_, funcName = __func__] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnSizeChange");
auto thisListener = self.promote();
if (thisListener == nullptr || eng == nullptr) {
WLOGFE("[NAPI]this listener or eng is nullptr");
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or eng is nullptr", funcName);
return;
}
napi_handle_scope scope = nullptr;
@ -92,7 +93,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason,
napi_value objValue = nullptr;
napi_create_object(eng, &objValue);
if (objValue == nullptr) {
WLOGFE("Failed to convert rect to jsObject");
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to convert rect to jsObject", funcName);
napi_close_handle_scope(eng, scope);
return;
}
@ -106,7 +107,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason,
jsCallback();
} else {
if (!eventHandler_) {
WLOGFE("get main event handler failed!");
TLOGE(WmsLogTag::WMS_LAYOUT, "get main event handler failed!");
return;
}
eventHandler_->PostTask(jsCallback, "wms:JsWindowListener::OnSizeChange", 0,
@ -524,11 +525,11 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason)
rectChangReason = RectChangeReason::MOVE;
}
// js callback should run in js thread
auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () {
auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_, funcName = __func__] () {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnRectChange");
auto thisListener = self.promote();
if (thisListener == nullptr || env == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "this listener or env is nullptr");
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or env is nullptr", funcName);
return;
}
napi_handle_scope scope = nullptr;
@ -536,12 +537,12 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason)
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
if (objValue == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create js object");
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create js object", funcName);
return;
}
napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect);
if (rectObjValue == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create rect js object");
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create rect js object", funcName);
return;
}
napi_set_named_property(env, objValue, "rect", rectObjValue);

View File

@ -566,6 +566,7 @@ napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInf
napi_set_named_property(env, objValue, "windowId", CreateJsValue(env, info->GetWindowId()));
napi_set_named_property(env, objValue, "windowStatusType",
CreateJsValue(env, static_cast<int32_t>(info->GetWindowStatus())));
napi_set_named_property(env, objValue, "isFocused", CreateJsValue(env, info->IsFocused()));
return objValue;
}

View File

@ -16,7 +16,7 @@
#ifndef OH_WINDOW_EVENT_FILTER_H
#define OH_WINDOW_EVENT_FILTER_H
#include "foundation/multimodalinput/input/interfaces/kits/c/input/oh_input_manager.h"
#include "oh_input_manager.h"
#include "key_event.h"
#include "oh_window_comm.h"
#include "stdint.h"

View File

@ -262,8 +262,8 @@ public:
virtual void OnNewWant(const AAFwk::Want& want) = 0;
virtual void SetRequestedOrientation(Orientation) = 0;
virtual Orientation GetRequestedOrientation() = 0;
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0;
virtual uint32_t GetRequestModeSupportInfo() const = 0;
virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) = 0;
virtual uint32_t GetRequestWindowModeSupportType() const = 0;
virtual WMError SetTouchHotAreas(const std::vector<Rect>& rects) = 0;
virtual void GetRequestedTouchHotAreas(std::vector<Rect>& rects) const = 0;
virtual bool IsMainHandlerAvailable() const = 0;

View File

@ -74,7 +74,7 @@ public:
virtual uint32_t GetWindowId() const override;
uint64_t GetDisplayId() const override;
virtual uint32_t GetWindowFlags() const override;
uint32_t GetRequestModeSupportInfo() const override;
uint32_t GetRequestWindowModeSupportType() const override;
bool IsMainHandlerAvailable() const override;
virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override;
virtual bool IsFullScreen() const override;
@ -167,7 +167,7 @@ public:
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override;
virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) override;
virtual void ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
virtual void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) override;
virtual void RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback) override;

View File

@ -511,6 +511,11 @@ struct Rect {
{
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
bool IsUninitializedSize() const
{
return width_ == 0 && height_ == 0;
}
};
/**

View File

@ -196,7 +196,7 @@ uint32_t WindowImpl::GetWindowFlags() const
return 0;
}
uint32_t WindowImpl::GetRequestModeSupportInfo() const
uint32_t WindowImpl::GetRequestWindowModeSupportType() const
{
return 0;
}
@ -786,7 +786,7 @@ void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
return;
}
void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo)
void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType)
{
return;
}

View File

@ -30,7 +30,7 @@ public:
MOCK_METHOD4(UpdateWindowRect, WMError(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction));
MOCK_METHOD1(UpdateWindowMode, WMError(WindowMode mode));
MOCK_METHOD1(UpdateWindowModeSupportInfo, WMError(uint32_t modeSupportInfo));
MOCK_METHOD1(UpdateWindowModeSupportType, WMError(uint32_t windowModeSupportType));
MOCK_METHOD1(UpdateFocusStatus, WMError(bool focused));
MOCK_METHOD2(UpdateAvoidArea, WMError(const sptr<AvoidArea>& avoidArea, AvoidAreaType type));
MOCK_METHOD1(UpdateWindowState, WMError(WindowState state));

View File

@ -461,9 +461,9 @@ void CheckWindowImplFunctionsPart3(sptr<WindowImpl> window, const uint8_t* data,
startPos += GetObject(mode, data + startPos, size - startPos);
window->UpdateMode(mode);
uint32_t modeSupportInfo;
startPos += GetObject(modeSupportInfo, data + startPos, size - startPos);
window->UpdateModeSupportInfo(modeSupportInfo);
uint32_t windowModeSupportType;
startPos += GetObject(windowModeSupportType, data + startPos, size - startPos);
window->UpdateWindowModeSupportType(windowModeSupportType);
WindowState windowState;
startPos += GetObject(windowState, data + startPos, size - startPos);
@ -596,7 +596,7 @@ void CheckWindowImplFunctionsPart6(sptr<WindowImpl> window, const uint8_t* data,
uint32_t uint32Val[2];
startPos += GetObject(uint32Val[0], data + startPos, size - startPos);
startPos += GetObject(uint32Val[1], data + startPos, size - startPos);
window->SetModeSupportInfo(uint32Val[0]);
window->SetWindowModeSupportType(uint32Val[0]);
float floatVal;
startPos += GetObject(floatVal, data + startPos, size - startPos);
@ -660,9 +660,9 @@ void CheckWindowImplFunctionsPart7(sptr<WindowImpl> window, const uint8_t* data,
window->UnregisterDialogDeathRecipientListener(dialogDeathRecipientListener);
sptr<IAceAbilityHandler> aceAbilityHandler = new AceAbilityHandler();
window->SetAceAbilityHandler(aceAbilityHandler);
uint32_t modeSupportInfo;
startPos += GetObject<uint32_t>(modeSupportInfo, data + startPos, size - startPos);
window->SetRequestModeSupportInfo(modeSupportInfo);
uint32_t windowModeSupportType;
startPos += GetObject<uint32_t>(windowModeSupportType, data + startPos, size - startPos);
window->SetRequestWindowModeSupportType(windowModeSupportType);
float ratio;
startPos += GetObject<float>(ratio, data + startPos, size - startPos);
window->SetAspectRatio(ratio);

View File

@ -61,9 +61,9 @@ void CheckWindowAgentFunctionsPart1(sptr<WindowAgent> agent, const uint8_t* data
startPos += GetObject<WindowMode>(mode, data + startPos, size - startPos);
agent->UpdateWindowMode(mode);
uint32_t modeSupportInfo;
startPos += GetObject<uint32_t>(modeSupportInfo, data + startPos, size - startPos);
agent->UpdateWindowModeSupportInfo(modeSupportInfo);
uint32_t windowModeSupportType;
startPos += GetObject<uint32_t>(windowModeSupportType, data + startPos, size - startPos);
agent->UpdateWindowModeSupportType(windowModeSupportType);
agent->UpdateFocusStatus(boolVal);
agent->NotifyForegroundInteractiveStatus(boolVal);

View File

@ -264,24 +264,6 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, Function | MediumTest | Level3)
window->Destroy();
}
/**
* @tc.name: DisplayZoom06
* @tc.desc: test speical window type
* @tc.type: FUNC
* @tc.require: issueI5NGWL
*/
HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3)
{
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2);
sleep(1);
windowInfo_.name = "DisplayZoom06";
windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT;
sptr<Window> window = Utils::CreateTestWindow(windowInfo_);
ASSERT_NE(nullptr, window);
sleep(1);
WindowAccessibilityController::GetInstance().OffWindowZoom();
window->Destroy();
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -63,55 +63,7 @@ void WindowInputMethodTest::TearDown()
}
namespace {
/**
* @tc.name: InputMethodWindow01
* @tc.desc: One InputMethod Floating Window
* @tc.type: FUNC
*/
HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3)
{
inputMethodWindowInfo_.name = "input_method.1";
const sptr<Window>& window = Utils::CreateTestWindow(inputMethodWindowInfo_);
ASSERT_NE(window, nullptr);
ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType());
window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0);
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_EQ(WMError::WM_OK, window->Hide());
window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0);
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_EQ(WMError::WM_OK, window->Hide());
}
/**
* @tc.name: InputMethodWindow02
* @tc.desc: One InputMethod Floating Window & One KeyGuard Window
* @tc.type: FUNC
*/
HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3)
{
inputMethodWindowInfo_.name = "input_method.2";
const sptr<Window>& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_);
ASSERT_NE(inputMethodWindow, nullptr);
inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0);
inputMethodWindow->Show();
if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) {
ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_);
}
if (inputMethodWindow->GetRect().height_ == Utils::customAppRect_.height_) {
ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_);
}
inputMethodWindow->Hide();
inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0);
inputMethodWindow->Show();
if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) {
ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_);
ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_);
}
inputMethodWindow->Hide();
}
} // namespace
} // namespace Rosen
} // namespace OHOS

View File

@ -25,7 +25,7 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using Utils = WindowTestUtils;
class WindowModeSupportInfoTest : public testing::Test {
class WindowModeSupportTypeTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
@ -37,7 +37,7 @@ private:
static constexpr uint32_t WAIT_SYANC_US = 100000;
};
void WindowModeSupportInfoTest::SetUpTestCase()
void WindowModeSupportTypeTest::SetUpTestCase()
{
auto display = DisplayManager::GetInstance().GetDisplayById(0);
ASSERT_TRUE((display != nullptr));
@ -45,11 +45,11 @@ void WindowModeSupportInfoTest::SetUpTestCase()
Utils::InitByDisplayRect(displayRect);
}
void WindowModeSupportInfoTest::TearDownTestCase()
void WindowModeSupportTypeTest::TearDownTestCase()
{
}
void WindowModeSupportInfoTest::SetUp()
void WindowModeSupportTypeTest::SetUp()
{
fullAppInfo_1_ = {
.name = "FullWindow",
@ -71,39 +71,39 @@ void WindowModeSupportInfoTest::SetUp()
};
}
void WindowModeSupportInfoTest::TearDown()
void WindowModeSupportTypeTest::TearDown()
{
}
namespace {
/**
* @tc.name: WindowModeSupportInfo01
* @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo
* @tc.name: WindowModeSupportType01
* @tc.desc: SetRequestWindowModeSupportType | GetRequestWindowModeSupportType
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType01, Function | MediumTest | Level3)
{
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
if (window == nullptr) {
return;
}
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo());
window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestWindowModeSupportType());
window->Destroy();
}
/**
* @tc.name: WindowModeSupportInfo02
* @tc.desc: modeSupportInfo test for single window, only support fullScreen mode
* @tc.name: WindowModeSupportType02
* @tc.desc: windowModeSupportType test for single window, only support fullScreen mode
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType02, Function | MediumTest | Level3)
{
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
if (window == nullptr) {
return;
}
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
@ -121,17 +121,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe
}
/**
* @tc.name: WindowModeSupportInfo03
* @tc.desc: modeSupportInfo test for single window, support both fullScreen and floating mode
* @tc.name: WindowModeSupportType03
* @tc.desc: windowModeSupportType test for single window, support both fullScreen and floating mode
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, Function | MediumTest | Level3)
{
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
if (window == nullptr) {
return;
}
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
@ -153,17 +153,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe
}
/**
* @tc.name: WindowModeSupportInfo04
* @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed
* @tc.name: WindowModeSupportType04
* @tc.desc: windowModeSupportType test for single window, window mode is not supported when show, show failed
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, Function | MediumTest | Level3)
{
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
if (window == nullptr) {
return;
}
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
ASSERT_NE(WMError::WM_OK, window->Show());
@ -172,20 +172,20 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe
}
/**
* @tc.name: WindowModeSupportInfo05
* @tc.desc: modeSupportInfo test for layout cascade
* @tc.name: WindowModeSupportType05
* @tc.desc: windowModeSupportType test for layout cascade
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, Function | MediumTest | Level3)
{
const sptr<Window>& window1 = Utils::CreateTestWindow(fullAppInfo_1_);
if (window1 == nullptr) {
return;
}
window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
window1->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
const sptr<Window>& window2 = Utils::CreateTestWindow(fullAppInfo_2_);
ASSERT_NE(nullptr, window2);
window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
window2->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
ASSERT_EQ(WMError::WM_OK, window1->Show());
ASSERT_EQ(WMError::WM_OK, window2->Show());
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
@ -203,17 +203,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe
}
/**
* @tc.name: WindowModeSupportInfo06
* @tc.desc: modeSupportInfo test for layout tile
* @tc.name: WindowModeSupportType06
* @tc.desc: windowModeSupportType test for layout tile
* @tc.type: FUNC
*/
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3)
HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType06, Function | MediumTest | Level3)
{
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
if (window == nullptr) {
return;
}
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
ASSERT_EQ(WMError::WM_OK, window->Show());
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
usleep(WAIT_SYANC_US);

View File

@ -58,6 +58,7 @@ private:
std::shared_ptr<VSyncReceiver> GetOrCreateVsyncReceiver();
std::shared_ptr<VSyncReceiver> GetOrCreateVsyncReceiverLocked();
std::shared_ptr<RSFrameRateLinker> GetFrameRateLinker();
std::shared_ptr<RSFrameRateLinker> GetFrameRateLinkerLocked();
void VsyncCallbackInner(int64_t nanoTimestamp, int64_t frameCount);
void OnVsyncTimeOut();
@ -65,9 +66,6 @@ private:
std::shared_ptr<AppExecFwk::EventHandler> vsyncHandler_ = nullptr;
std::string vsyncTimeoutTaskName_;
std::shared_ptr<FrameRateRange> lastFrameRateRange_ = nullptr;
int32_t lastAnimatorExpectedFrameRate_ = 0;
std::mutex mutex_;
bool isFirstVsyncRequest_ = true;
bool isFirstVsyncBack_ = true;
@ -77,6 +75,8 @@ private:
std::shared_ptr<RSFrameRateLinker> frameRateLinker_ = nullptr;
using Callbacks = std::unordered_set<std::shared_ptr<VsyncCallback>>;
Callbacks vsyncCallbacks_;
std::shared_ptr<FrameRateRange> lastFrameRateRange_ = nullptr;
int32_t lastAnimatorExpectedFrameRate_ = 0;
// Above guarded by mutex_
std::atomic<int32_t> requestVsyncTimes_ {0};

View File

@ -208,19 +208,19 @@ public:
static_cast<uint32_t>(x_end - x_begin), static_cast<uint32_t>(y_end - y_begin) };
}
static bool IsWindowModeSupported(uint32_t modeSupportInfo, WindowMode mode)
static bool IsWindowModeSupported(uint32_t windowModeSupportType, WindowMode mode)
{
switch (mode) {
case WindowMode::WINDOW_MODE_FULLSCREEN:
return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & modeSupportInfo;
return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & windowModeSupportType;
case WindowMode::WINDOW_MODE_FLOATING:
return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & modeSupportInfo;
return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & windowModeSupportType;
case WindowMode::WINDOW_MODE_SPLIT_PRIMARY:
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & modeSupportInfo;
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & windowModeSupportType;
case WindowMode::WINDOW_MODE_SPLIT_SECONDARY:
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & modeSupportInfo;
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & windowModeSupportType;
case WindowMode::WINDOW_MODE_PIP:
return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & modeSupportInfo;
return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & windowModeSupportType;
case WindowMode::WINDOW_MODE_UNDEFINED:
return false;
default:
@ -228,10 +228,10 @@ public:
}
}
static WindowMode GetWindowModeFromModeSupportInfo(uint32_t modeSupportInfo)
static WindowMode GetWindowModeFromWindowModeSupportType(uint32_t windowModeSupportType)
{
// get the binary number consists of the last 1 and 0 behind it
uint32_t windowModeSupport = modeSupportInfo & (~modeSupportInfo + 1);
uint32_t windowModeSupport = windowModeSupportType & (~windowModeSupportType + 1);
switch (windowModeSupport) {
case WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN:
@ -249,20 +249,20 @@ public:
}
}
static uint32_t ConvertSupportModesToSupportInfo(const std::vector<AppExecFwk::SupportWindowMode>& supportModes)
static uint32_t ConvertSupportModesToSupportType(const std::vector<AppExecFwk::SupportWindowMode>& supportModes)
{
uint32_t modeSupportInfo = 0;
uint32_t windowModeSupportType = 0;
for (auto& mode : supportModes) {
if (mode == AppExecFwk::SupportWindowMode::FULLSCREEN) {
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN;
windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN;
} else if (mode == AppExecFwk::SupportWindowMode::SPLIT) {
modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
windowModeSupportType |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
} else if (mode == AppExecFwk::SupportWindowMode::FLOATING) {
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
}
}
return modeSupportInfo;
return windowModeSupportType;
}
static bool IsPointInTargetRect(int32_t pointPosX, int32_t pointPosY, const Rect& targetRect)
@ -522,11 +522,11 @@ public:
return false;
}
static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo)
static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t windowModeSupportType)
{
uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
uint32_t splitMode = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) {
if (isShowWhenLocked && (splitMode == windowModeSupportType)) {
return true;
}
return false;
@ -541,15 +541,15 @@ public:
return false;
}
static bool CheckSupportWindowMode(WindowMode winMode, uint32_t modeSupportInfo,
static bool CheckSupportWindowMode(WindowMode winMode, uint32_t windowModeSupportType,
const sptr<WindowTransitionInfo>& info)
{
if (!WindowHelper::IsMainWindow(info->GetWindowType())) {
return true;
}
if ((!IsWindowModeSupported(modeSupportInfo, winMode)) ||
(IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) {
if (!IsWindowModeSupported(windowModeSupportType, winMode) ||
IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), windowModeSupportType)) {
return false;
}
return true;

View File

@ -70,8 +70,8 @@ public:
void SetAnimationFlag(uint32_t animationFlag);
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
void SetTokenState(bool hasToken);
void SetModeSupportInfo(uint32_t modeSupportInfo);
void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo);
void SetWindowModeSupportType(uint32_t windowModeSupportType);
void SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType);
void SetDragType(DragType dragType);
void SetStretchable(bool stretchable);
void SetOriginRect(const Rect& rect);
@ -122,8 +122,8 @@ public:
bool GetDecorEnable() const;
const PointInfo& GetHitOffset() const;
uint32_t GetAnimationFlag() const;
uint32_t GetModeSupportInfo() const;
uint32_t GetRequestModeSupportInfo() const;
uint32_t GetWindowModeSupportType() const;
uint32_t GetRequestWindowModeSupportType() const;
DragType GetDragType() const;
bool GetStretchable() const;
const Rect& GetOriginRect() const;
@ -190,10 +190,10 @@ private:
uint32_t parentId_ = INVALID_WINDOW_ID;
PointInfo hitOffset_ { 0, 0 };
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
// modeSupportInfo_ means supported modes in runtime, which can be changed
uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
// requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed
uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
// windowModeSupportType_ means supported modes in runtime, which can be changed
uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
// requestWindowModeSupportType_ is configured in abilityInfo, usually can't be changed
uint32_t requestWindowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },

View File

@ -72,9 +72,9 @@ public:
WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState,
WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName,
const std::string& abilityName) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState),
windowType_(winType), windowStatus_(windowStatus), rect_(rect), bundleName_(bundleName),
abilityName_(abilityName) {}
const std::string& abilityName, bool isFocused) : windowId_(winId), pid_(pid), uid_(uid),
visibilityState_(visibilityState), windowType_(winType), windowStatus_(windowStatus), rect_(rect),
bundleName_(bundleName), abilityName_(abilityName), isFocused_(isFocused) {}
/**
* @brief Deconstruct of WindowVisibilityInfo.
@ -111,6 +111,8 @@ public:
WindowVisibilityState GetWindowVisibilityState() const { return visibilityState_; }
bool IsFocused() const { return isFocused_; }
uint32_t windowId_ { INVALID_WINDOW_ID };
int32_t pid_ { 0 };
int32_t uid_ { 0 };
@ -120,6 +122,7 @@ public:
Rect rect_ = {0, 0, 0, 0};
std::string bundleName_;
std::string abilityName_;
bool isFocused_ = false;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H

View File

@ -99,7 +99,7 @@ struct ModeChangeHotZonesConfig {
struct SystemConfig : public Parcelable {
bool isSystemDecorEnable_ = true;
uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
bool isStretchable_ = false;
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
KeyboardAnimationCurve animationIn_;
@ -110,7 +110,7 @@ struct SystemConfig : public Parcelable {
virtual bool Marshalling(Parcel& parcel) const override
{
if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
!parcel.WriteUint32(decorModeSupportInfo_)) {
!parcel.WriteUint32(decorWindowModeSupportType_)) {
return false;
}
@ -135,7 +135,7 @@ struct SystemConfig : public Parcelable {
SystemConfig* config = new SystemConfig();
config->isSystemDecorEnable_ = parcel.ReadBool();
config->isStretchable_ = parcel.ReadBool();
config->decorModeSupportInfo_ = parcel.ReadUint32();
config->decorWindowModeSupportType_ = parcel.ReadUint32();
config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>();
if (animationIn == nullptr) {

View File

@ -151,7 +151,7 @@ __attribute__((no_sanitize("cfi"))) void VsyncStation::RequestVsync(
}
};
receiver->RequestNextVSync({
.userData_ = nullptr, .callbackWithId_ = task,
.userData_ = nullptr, .callbackWithId_ = std::move(task),
});
}
@ -204,6 +204,11 @@ void VsyncStation::OnVsyncTimeOut()
std::shared_ptr<RSFrameRateLinker> VsyncStation::GetFrameRateLinker()
{
std::lock_guard<std::mutex> lock(mutex_);
return GetFrameRateLinkerLocked();
}
std::shared_ptr<RSFrameRateLinker> VsyncStation::GetFrameRateLinkerLocked()
{
if (destroyed_) {
TLOGW(WmsLogTag::WMS_MAIN, "VsyncStation has been destroyed");
return nullptr;
@ -221,7 +226,8 @@ FrameRateLinkerId VsyncStation::GetFrameRateLinkerId()
void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType)
{
if (auto frameRateLinker = GetFrameRateLinker()) {
std::lock_guard<std::mutex> lock(mutex_);
if (auto frameRateLinker = GetFrameRateLinkerLocked()) {
if (lastFrameRateRange_ == nullptr) {
lastFrameRateRange_ = std::make_shared<FrameRateRange>(0, RANGE_MAX_REFRESHRATE, rate, rateType);
} else {
@ -237,7 +243,8 @@ void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRa
void VsyncStation::SetFrameRateLinkerEnable(bool enabled)
{
if (auto frameRateLinker = GetFrameRateLinker()) {
std::lock_guard<std::mutex> lock(mutex_);
if (auto frameRateLinker = GetFrameRateLinkerLocked()) {
if (!enabled) {
// clear frameRate vote
FrameRateRange range = {0, RANGE_MAX_REFRESHRATE, 0};

View File

@ -61,7 +61,7 @@ void WindowProperty::SetWindowType(WindowType type)
void WindowProperty::SetWindowMode(WindowMode mode)
{
if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) {
return;
}
if (!WindowHelper::IsSplitWindowMode(mode_)) {
@ -72,7 +72,7 @@ void WindowProperty::SetWindowMode(WindowMode mode)
void WindowProperty::SetLastWindowMode(WindowMode mode)
{
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) {
return;
}
lastMode_ = mode;
@ -331,8 +331,8 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
void WindowProperty::ResumeLastWindowMode()
{
// if lastMode isn't supported, get supported mode from supportModeInfo
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) {
auto mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo_);
if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, lastMode_)) {
auto mode = WindowHelper::GetWindowModeFromWindowModeSupportType(windowModeSupportType_);
if (!WindowHelper::IsSplitWindowMode(mode)) {
mode_ = mode;
}
@ -481,14 +481,14 @@ void WindowProperty::SetTokenState(bool hasToken)
tokenState_ = hasToken;
}
void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo)
void WindowProperty::SetWindowModeSupportType(uint32_t windowModeSupportType)
{
modeSupportInfo_ = modeSupportInfo;
windowModeSupportType_ = windowModeSupportType;
}
void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo)
void WindowProperty::SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType)
{
requestModeSupportInfo_ = requestModeSupportInfo;
requestWindowModeSupportType_ = requestWindowModeSupportType;
}
uint32_t WindowProperty::GetWindowId() const
@ -511,14 +511,14 @@ uint32_t WindowProperty::GetAnimationFlag() const
return animationFlag_;
}
uint32_t WindowProperty::GetModeSupportInfo() const
uint32_t WindowProperty::GetWindowModeSupportType() const
{
return modeSupportInfo_;
return windowModeSupportType_;
}
uint32_t WindowProperty::GetRequestModeSupportInfo() const
uint32_t WindowProperty::GetRequestWindowModeSupportType() const
{
return requestModeSupportInfo_;
return requestWindowModeSupportType_;
}
bool WindowProperty::GetTokenState() const
@ -729,7 +729,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
parcel.WriteUint32(static_cast<uint32_t>(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) &&
parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_)) &&
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) &&
parcel.WriteUint32(windowModeSupportType_) && parcel.WriteUint32(requestWindowModeSupportType_) &&
parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) &&
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) &&
@ -777,8 +777,8 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
property->SetRequestedOrientation(static_cast<Orientation>(parcel.ReadUint32()));
property->SetTurnScreenOn(parcel.ReadBool());
property->SetKeepScreenOn(parcel.ReadBool());
property->SetModeSupportInfo(parcel.ReadUint32());
property->SetRequestModeSupportInfo(parcel.ReadUint32());
property->SetWindowModeSupportType(parcel.ReadUint32());
property->SetRequestWindowModeSupportType(parcel.ReadUint32());
property->SetDragType(static_cast<DragType>(parcel.ReadUint32()));
uint32_t w = parcel.ReadUint32();
uint32_t h = parcel.ReadUint32();
@ -843,7 +843,7 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action)
ret = ret && parcel.WriteFloat(brightness_);
break;
case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO:
ret = ret && parcel.WriteUint32(modeSupportInfo_);
ret = ret && parcel.WriteUint32(windowModeSupportType_);
break;
case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA:
ret = ret && MarshallingTouchHotAreas(parcel);
@ -921,7 +921,7 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action)
SetBrightness(parcel.ReadFloat());
break;
case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO:
SetModeSupportInfo(parcel.ReadUint32());
SetWindowModeSupportType(parcel.ReadUint32());
break;
case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA:
UnmarshallingTouchHotAreas(parcel, this);
@ -990,8 +990,8 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
requestedOrientation_ = property->requestedOrientation_;
turnScreenOn_ = property->turnScreenOn_;
keepScreenOn_ = property->keepScreenOn_;
modeSupportInfo_ = property->modeSupportInfo_;
requestModeSupportInfo_ = property->requestModeSupportInfo_;
windowModeSupportType_ = property->windowModeSupportType_;
requestWindowModeSupportType_ = property->requestWindowModeSupportType_;
dragType_ = property->dragType_;
originRect_ = property->originRect_;
isStretchable_ = property->isStretchable_;

View File

@ -28,7 +28,7 @@ bool WindowVisibilityInfo::Marshalling(Parcel& parcel) const
parcel.WriteUint32(static_cast<uint32_t>(windowType_)) &&
parcel.WriteUint32(static_cast<uint32_t>(windowStatus_)) && parcel.WriteInt32(rect_.posX_) &&
parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_);
parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_);
}
WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel)
@ -52,6 +52,7 @@ WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel)
windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
windowVisibilityInfo->bundleName_ = parcel.ReadString();
windowVisibilityInfo->abilityName_ = parcel.ReadString();
windowVisibilityInfo->isFocused_ = parcel.ReadBool();
return windowVisibilityInfo;
}
} // namespace OHOS::Rosen

View File

@ -176,19 +176,19 @@ HWTEST_F(WindowPropertyTest, SetAbilityInfo, Function | SmallTest | Level2)
HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, Function | SmallTest | Level2)
{
WindowProperty winPropDst;
winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP;
winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP;
winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
winPropDst.ResumeLastWindowMode();
ASSERT_EQ(WindowMode::WINDOW_MODE_PIP, winPropDst.mode_);
winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY;
winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY;
winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
winPropDst.ResumeLastWindowMode();
ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, winPropDst.mode_);
winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
winPropDst.ResumeLastWindowMode();
@ -453,31 +453,31 @@ HWTEST_F(WindowPropertyTest, GetAnimationFlag018, Function | SmallTest | Level2)
}
/**
* @tc.name: GetModeSupportInfo019
* @tc.desc: GetModeSupportInfo test
* @tc.name: GetWindowModeSupportType019
* @tc.desc: GetWindowModeSupportType test
* @tc.type: FUNC
*/
HWTEST_F(WindowPropertyTest, GetModeSupportInfo019, Function | SmallTest | Level2)
HWTEST_F(WindowPropertyTest, GetWindowModeSupportType019, Function | SmallTest | Level2)
{
WindowProperty winPropSrc;
uint32_t modeSupportInfo = 1;
winPropSrc.SetModeSupportInfo(modeSupportInfo);
uint32_t res = winPropSrc.GetModeSupportInfo();
ASSERT_EQ(res, modeSupportInfo);
uint32_t windowModeSupportType = 1;
winPropSrc.SetWindowModeSupportType(windowModeSupportType);
uint32_t res = winPropSrc.GetWindowModeSupportType();
ASSERT_EQ(res, windowModeSupportType);
}
/**
* @tc.name: GetRequestModeSupportInfo020
* @tc.desc: GetRequestModeSupportInfo test
* @tc.name: GetRequestWindowModeSupportType020
* @tc.desc: GetRequestWindowModeSupportType test
* @tc.type: FUNC
*/
HWTEST_F(WindowPropertyTest, GetRequestModeSupportInfo020, Function | SmallTest | Level2)
HWTEST_F(WindowPropertyTest, GetRequestWindowModeSupportType020, Function | SmallTest | Level2)
{
WindowProperty winPropSrc;
uint32_t requestModeSupportInfo = 1;
winPropSrc.SetRequestModeSupportInfo(requestModeSupportInfo);
uint32_t res = winPropSrc.GetRequestModeSupportInfo();
ASSERT_EQ(res, requestModeSupportInfo);
uint32_t requestWindowModeSupportType = 1;
winPropSrc.SetRequestWindowModeSupportType(requestWindowModeSupportType);
uint32_t res = winPropSrc.GetRequestWindowModeSupportType();
ASSERT_EQ(res, requestWindowModeSupportType);
}
/**

View File

@ -24,6 +24,7 @@ namespace PermissionConstants {
constexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS";
constexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES";
constexpr const char* PERMISSION_MAIN_WINDOW_TOPMOST = "ohos.permission.WINDOW_TOPMOST";
constexpr const char* PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN = "ohos.permission.CALLED_UIEXTENSION_ON_LOCK_SCREEN";
}
class SessionPermission {
public:

View File

@ -22,7 +22,7 @@
namespace OHOS::Rosen {
void StartTraceForSyncTask(std::string name);
void StartTraceForSyncTask(const std::string& name);
void FinishTraceForSyncTask();
class TaskScheduler {
@ -31,11 +31,12 @@ public:
~TaskScheduler() = default;
std::shared_ptr<AppExecFwk::EventHandler> GetEventHandler();
using Task = std::function<void()>;
void PostAsyncTask(Task&& task, const std::string& name = "ssmTask", int64_t delayTime = 0);
void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask");
void PostAsyncTask(Task&& task, const std::string& name, int64_t delayTime = 0);
void PostTask(Task&& task, const std::string& name, int64_t delayTime = 0);
void RemoveTask(const std::string& name);
void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask");
template<typename SyncTask, typename Return = std::invoke_result_t<SyncTask>>
Return PostSyncTask(SyncTask&& task, const std::string& name = "ssmTask")
{
@ -46,7 +47,7 @@ public:
FinishTraceForSyncTask();
return ret;
}
auto syncTask = [this, &ret, task = std::move(task), name] {
auto syncTask = [this, &ret, &task, &name] {
StartTraceForSyncTask(name);
ret = task();
FinishTraceForSyncTask();

View File

@ -84,7 +84,7 @@ public:
void SetMainWindowTopmost(bool isTopmost);
bool IsMainWindowTopmost() const;
void AddWindowFlag(WindowFlag flag);
void SetModeSupportInfo(uint32_t modeSupportInfo);
void SetWindowModeSupportType(uint32_t windowModeSupportType);
void SetFloatingWindowAppType(bool isAppType);
void SetTouchHotAreas(const std::vector<Rect>& rects);
void KeepKeyboardOnFocus(bool keepKeyboardFlag);
@ -137,7 +137,7 @@ public:
WindowLimits GetUserWindowLimits() const;
WindowLimits GetConfigWindowLimitsVP() const;
float GetLastLimitsVpr() const;
uint32_t GetModeSupportInfo() const;
uint32_t GetWindowModeSupportType() const;
std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const;
bool IsDecorEnable();
uint32_t GetAnimationFlag() const;
@ -217,7 +217,7 @@ public:
bool GetIsUIExtAnySubWindow() const;
/**
* Multi instance
* Multi Instance
*/
void SetAppInstanceKey(const std::string& appInstanceKey);
std::string GetAppInstanceKey() const;
@ -248,7 +248,7 @@ private:
bool WriteActionUpdateWindowMask(Parcel& parcel);
bool WriteActionUpdateTopmost(Parcel& parcel);
bool WriteActionUpdateMainWindowTopmost(Parcel& parcel);
bool WriteActionUpdateModeSupportInfo(Parcel& parcel);
bool WriteActionUpdateWindowModeSupportType(Parcel& parcel);
void ReadActionUpdateTurnScreenOn(Parcel& parcel);
void ReadActionUpdateKeepScreenOn(Parcel& parcel);
void ReadActionUpdateFocusable(Parcel& parcel);
@ -272,7 +272,7 @@ private:
void ReadActionUpdateWindowMask(Parcel& parcel);
void ReadActionUpdateTopmost(Parcel& parcel);
void ReadActionUpdateMainWindowTopmost(Parcel& parcel);
void ReadActionUpdateModeSupportInfo(Parcel& parcel);
void ReadActionUpdateWindowModeSupportType(Parcel& parcel);
std::string windowName_;
SessionInfo sessionInfo_;
Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
@ -311,7 +311,7 @@ private:
float lastVpr_ = 0.0f;
PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}};
KeyboardLayoutParams keyboardLayoutParams_;
uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
@ -368,21 +368,21 @@ private:
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
/**
* Multi instance
* Multi Instance
*/
std::string appInstanceKey_;
};
struct FreeMultiWindowConfig : public Parcelable {
bool isSystemDecorEnable_ = true;
uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
uint32_t maxMainFloatingWindowNumber_ = 0;
virtual bool Marshalling(Parcel& parcel) const override
{
if (!parcel.WriteBool(isSystemDecorEnable_) ||
!parcel.WriteUint32(decorModeSupportInfo_)) {
!parcel.WriteUint32(decorWindowModeSupportType_)) {
return false;
}
@ -400,7 +400,7 @@ struct FreeMultiWindowConfig : public Parcelable {
return nullptr;
}
config->isSystemDecorEnable_ = parcel.ReadBool();
config->decorModeSupportInfo_ = parcel.ReadUint32();
config->decorWindowModeSupportType_ = parcel.ReadUint32();
config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
config->maxMainFloatingWindowNumber_ = parcel.ReadUint32();
return config;
@ -437,7 +437,7 @@ struct AppForceLandscapeConfig : public Parcelable {
struct SystemSessionConfig : public Parcelable {
bool isSystemDecorEnable_ = true;
uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
bool isStretchable_ = false;
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
KeyboardAnimationCurve animationIn_;
@ -462,7 +462,7 @@ struct SystemSessionConfig : public Parcelable {
virtual bool Marshalling(Parcel& parcel) const override
{
if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
!parcel.WriteUint32(decorModeSupportInfo_)) {
!parcel.WriteUint32(decorWindowModeSupportType_)) {
return false;
}
@ -508,7 +508,7 @@ struct SystemSessionConfig : public Parcelable {
}
config->isSystemDecorEnable_ = parcel.ReadBool();
config->isStretchable_ = parcel.ReadBool();
config->decorModeSupportInfo_ = parcel.ReadUint32();
config->decorWindowModeSupportType_ = parcel.ReadUint32();
config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>();
if (animationIn == nullptr) {

View File

@ -44,21 +44,6 @@ void TaskScheduler::PostAsyncTask(Task&& task, const std::string& name, int64_t
handler_->PostTask(std::move(localTask), "wms:" + name, delayTime, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name)
{
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
return;
}
auto localTask = [this, task = std::move(task), name] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
ExecuteExportTask();
};
handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
void TaskScheduler::PostTask(Task&& task, const std::string& name, int64_t delayTime)
{
PostAsyncTask(std::move(task), name, delayTime);
@ -69,6 +54,26 @@ void TaskScheduler::RemoveTask(const std::string& name)
handler_->RemoveTask("wms:" + name);
}
void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name)
{
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
return;
}
auto localTask = [this, &task, &name] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
ExecuteExportTask();
};
handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
void TaskScheduler::SetExportHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler)
{
exportHandler_ = handler;
}
void TaskScheduler::AddExportTask(std::string taskName, Task&& task)
{
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
@ -78,17 +83,9 @@ void TaskScheduler::AddExportTask(std::string taskName, Task&& task)
}
}
void TaskScheduler::SetExportHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler)
{
exportHandler_ = handler;
}
void TaskScheduler::ExecuteExportTask()
{
if (exportFuncMap_.empty()) {
return;
}
if (!exportHandler_) {
if (!exportHandler_ || exportFuncMap_.empty()) {
return;
}
auto task = [funcMap = std::move(exportFuncMap_)] {
@ -98,10 +95,10 @@ void TaskScheduler::ExecuteExportTask()
}
};
exportFuncMap_.clear();
exportHandler_->PostTask(task, "wms:exportTask");
exportHandler_->PostTask(std::move(task), "wms:exportTask");
}
void StartTraceForSyncTask(std::string name)
void StartTraceForSyncTask(const std::string& name)
{
StartTraceArgs(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
}

View File

@ -80,7 +80,7 @@ const std::map<uint32_t, HandlWritePropertyFunc> WindowSessionProperty::writeFun
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST),
&WindowSessionProperty::WriteActionUpdateTopmost),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO),
&WindowSessionProperty::WriteActionUpdateModeSupportInfo),
&WindowSessionProperty::WriteActionUpdateWindowModeSupportType),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST),
&WindowSessionProperty::WriteActionUpdateMainWindowTopmost),
};
@ -139,7 +139,7 @@ const std::map<uint32_t, HandlReadPropertyFunc> WindowSessionProperty::readFuncM
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST),
&WindowSessionProperty::ReadActionUpdateTopmost),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO),
&WindowSessionProperty::ReadActionUpdateModeSupportInfo),
&WindowSessionProperty::ReadActionUpdateWindowModeSupportType),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST),
&WindowSessionProperty::ReadActionUpdateMainWindowTopmost),
};
@ -544,14 +544,14 @@ bool WindowSessionProperty::IsDecorEnable()
return isDecorEnable_;
}
void WindowSessionProperty::SetModeSupportInfo(uint32_t modeSupportInfo)
void WindowSessionProperty::SetWindowModeSupportType(uint32_t windowModeSupportType)
{
modeSupportInfo_ = modeSupportInfo;
windowModeSupportType_ = windowModeSupportType;
}
uint32_t WindowSessionProperty::GetModeSupportInfo() const
uint32_t WindowSessionProperty::GetWindowModeSupportType() const
{
return modeSupportInfo_;
return windowModeSupportType_;
}
void WindowSessionProperty::SetAnimationFlag(uint32_t animationFlag)
@ -1169,6 +1169,7 @@ void WindowSessionProperty::CopyFrom(const sptr<WindowSessionProperty>& property
maximizeMode_ = property->maximizeMode_;
windowMode_ = property->windowMode_;
limits_ = property->limits_;
windowModeSupportType_ = property->windowModeSupportType_;
sysBarPropMap_ = property->sysBarPropMap_;
isDecorEnable_ = property->isDecorEnable_;
animationFlag_ = property->animationFlag_;
@ -1313,9 +1314,9 @@ bool WindowSessionProperty::WriteActionUpdateMainWindowTopmost(Parcel& parcel)
return MarshallingMainWindowTopmost(parcel);
}
bool WindowSessionProperty::WriteActionUpdateModeSupportInfo(Parcel& parcel)
bool WindowSessionProperty::WriteActionUpdateWindowModeSupportType(Parcel& parcel)
{
return parcel.WriteUint32(modeSupportInfo_);
return parcel.WriteUint32(windowModeSupportType_);
}
void WindowSessionProperty::Read(Parcel& parcel, WSPropertyChangeAction action)
@ -1449,9 +1450,9 @@ void WindowSessionProperty::ReadActionUpdateMainWindowTopmost(Parcel& parcel)
UnmarshallingMainWindowTopmost(parcel, this);
}
void WindowSessionProperty::ReadActionUpdateModeSupportInfo(Parcel& parcel)
void WindowSessionProperty::ReadActionUpdateWindowModeSupportType(Parcel& parcel)
{
SetModeSupportInfo(parcel.ReadUint32());
SetWindowModeSupportType(parcel.ReadUint32());
}
void WindowSessionProperty::SetTransform(const Transform& trans)

View File

@ -32,12 +32,14 @@ class StartWindowOption;
}
namespace OHOS::AppExecFwk {
struct AbilityInfo;
enum class SupportWindowMode;
}
namespace OHOS::Rosen {
class RSTransaction;
constexpr int32_t ROTATE_ANIMATION_DURATION = 400;
constexpr int32_t INVALID_SESSION_ID = 0;
constexpr int32_t WINDOW_SUPPORT_MODE_MAX_SIZE = 4;
enum class WSError : int32_t {
WS_OK = 0,
@ -377,10 +379,16 @@ struct SessionInfo {
SessionViewportConfig config_;
/**
* Multi instance
* Multi Instance
*/
bool isNewAppInstance_ = false;
std::string appInstanceKey_;
/**
* PC Window
*/
std::vector<AppExecFwk::SupportWindowMode> supportWindowModes;
uint32_t windowModeSupportType = 0;
};
enum class SessionFlag : uint32_t {

View File

@ -118,10 +118,9 @@ napi_value JsRootSceneSession::OnRegisterCallback(napi_env env, napi_callback_in
return NapiGetUndefined(env);
}
NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) {
rootSceneSession_->SetPendingSessionActivationEventListener([this](SessionInfo& info) {
this->PendingSessionActivation(info);
};
rootSceneSession_->SetPendingSessionActivationEventListener(func);
});
std::shared_ptr<NativeReference> callbackRef;
napi_ref result = nullptr;
napi_create_reference(env, value, 1, &result);

View File

@ -322,6 +322,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
moduleName, JsSceneSession::SetSystemSceneOcclusionAlpha);
BindNativeFunction(env, objValue, "setSystemSceneForceUIFirst",
moduleName, JsSceneSession::SetSystemSceneForceUIFirst);
BindNativeFunction(env, objValue, "markSystemSceneUIFirst",
moduleName, JsSceneSession::MarkSystemSceneUIFirst);
BindNativeFunction(env, objValue, "setFloatingScale", moduleName, JsSceneSession::SetFloatingScale);
BindNativeFunction(env, objValue, "setIsMidScene", moduleName, JsSceneSession::SetIsMidScene);
BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale);
@ -452,20 +454,20 @@ JsSceneSession::~JsSceneSession()
void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
{
NotifyPendingSessionActivationFunc func = [weakThis = wptr(this)](SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSceneSessionActivationRegister jsSceneSession is null");
return;
}
jsSceneSession->PendingSessionActivation(info);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetPendingSessionActivationEventListener(func);
const char* const where = __func__;
session->SetPendingSessionActivationEventListener([weakThis = wptr(this), where](SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->PendingSessionActivation(info);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
@ -1190,125 +1192,124 @@ void JsSceneSession::ProcessSessionEventRegister()
void JsSceneSession::ProcessTerminateSessionRegister()
{
TLOGD(WmsLogTag::WMS_LIFE, "in");
NotifyTerminateSessionFunc func = [weakThis = wptr(this)](const SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegister jsSceneSession is null");
return;
}
jsSceneSession->TerminateSession(info);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetTerminateSessionListener(func);
const char* const where = __func__;
session->SetTerminateSessionListener([weakThis = wptr(this), where](const SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->TerminateSession(info);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
void JsSceneSession::ProcessTerminateSessionRegisterNew()
{
TLOGD(WmsLogTag::WMS_LIFE, "in");
NotifyTerminateSessionFuncNew func = [weakThis = wptr(this)](
const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterNew jsSceneSession is null");
return;
}
jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetTerminateSessionListenerNew(func);
const char* const where = __func__;
session->SetTerminateSessionListenerNew([weakThis = wptr(this), where](
const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
void JsSceneSession::ProcessTerminateSessionRegisterTotal()
{
TLOGD(WmsLogTag::WMS_LIFE, "in");
NotifyTerminateSessionFuncTotal func = [weakThis = wptr(this)](
const SessionInfo& info, TerminateType terminateType) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterTotal jsSceneSession is null");
return;
}
jsSceneSession->TerminateSessionTotal(info, terminateType);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetTerminateSessionListenerTotal(func);
const char* const where = __func__;
session->SetTerminateSessionListenerTotal([weakThis = wptr(this), where](
const SessionInfo& info, TerminateType terminateType) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->TerminateSessionTotal(info, terminateType);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
void JsSceneSession::ProcessPendingSessionToForegroundRegister()
{
TLOGD(WmsLogTag::WMS_LIFE, "in");
NotifyPendingSessionToForegroundFunc func = [weakThis = wptr(this)](const SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSessionToForegroundRegister jsSceneSession is null");
return;
}
jsSceneSession->PendingSessionToForeground(info);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetPendingSessionToForegroundListener(func);
const char* const where = __func__;
session->SetPendingSessionToForegroundListener([weakThis = wptr(this), where](const SessionInfo& info) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->PendingSessionToForeground(info);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
{
TLOGD(WmsLogTag::WMS_LIFE, "in");
NotifyPendingSessionToBackgroundForDelegatorFunc func = [weakThis = wptr(this)](const SessionInfo& info,
bool shouldBackToCaller) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null");
return;
}
jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller);
};
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetPendingSessionToBackgroundForDelegatorListener(func);
const char* const where = __func__;
session->SetPendingSessionToBackgroundForDelegatorListener([weakThis = wptr(this), where](
const SessionInfo& info, bool shouldBackToCaller) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller);
});
TLOGD(WmsLogTag::WMS_LIFE, "success");
}
void JsSceneSession::ProcessSessionExceptionRegister()
{
WLOGFD("in");
NotifySessionExceptionFunc func = [weakThis = wptr(this)](
const SessionInfo& info, bool needRemoveSession, bool startFail) {
TLOGD(WmsLogTag::WMS_LIFE, "in");
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
const char* const where = __func__;
session->SetSessionExceptionListener([weakThis = wptr(this), where](const SessionInfo& info,
bool needRemoveSession, bool startFail) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionExceptionRegister jsSceneSession is null");
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->OnSessionException(info, needRemoveSession, startFail);
};
auto session = weakSession_.promote();
if (session == nullptr) {
WLOGFE("session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetSessionExceptionListener(func, true);
WLOGFD("success");
}, true);
}
/** @note @window.hierarchy */
@ -1497,20 +1498,20 @@ void JsSceneSession::OnSessionEvent(uint32_t eventId, const SessionEventParam& p
void JsSceneSession::ProcessBackPressedRegister()
{
NotifyBackPressedFunc func = [weakThis = wptr(this)](bool needMoveToBackground) {
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
const char* const where = __func__;
session->SetBackPressedListenser([weakThis = wptr(this), where](bool needMoveToBackground) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessBackPressedRegister jsSceneSession is null");
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where);
return;
}
jsSceneSession->OnBackPressed(needMoveToBackground);
};
auto session = weakSession_.promote();
if (session == nullptr) {
WLOGFE("session is nullptr, id:%{public}d", persistentId_);
return;
}
session->SetBackPressedListenser(func);
});
}
void JsSceneSession::ProcessSystemBarPropertyChangeRegister()
@ -1810,6 +1811,13 @@ napi_value JsSceneSession::SetSystemSceneForceUIFirst(napi_env env, napi_callbac
return (me != nullptr) ? me->OnSetSystemSceneForceUIFirst(env, info) : nullptr;
}
napi_value JsSceneSession::MarkSystemSceneUIFirst(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::DEFAULT, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnMarkSystemSceneUIFirst(env, info) : nullptr;
}
napi_value JsSceneSession::SetFocusable(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]");
@ -2482,6 +2490,40 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info)
{
size_t argc = ARG_COUNT_4;
napi_value argv[ARG_COUNT_4] = { nullptr };
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_TWO) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
bool isForced = false;
if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForced)) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForced");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
bool isUIFirstEnabled = false;
if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], isUIFirstEnabled)) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirstEnabled");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_);
return NapiGetUndefined(env);
}
session->MarkSystemSceneUIFirst(isForced, isUIFirstEnabled);
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSetFocusable(napi_env env, napi_callback_info info)
{
size_t argc = 4;

View File

@ -105,6 +105,7 @@ private:
static napi_value SetIsMidScene(napi_env env, napi_callback_info info);
static napi_value SetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info);
static napi_value SetSystemSceneForceUIFirst(napi_env env, napi_callback_info info);
static napi_value MarkSystemSceneUIFirst(napi_env env, napi_callback_info info);
static napi_value SetFocusable(napi_env env, napi_callback_info info);
static napi_value SetFocusableOnShow(napi_env env, napi_callback_info info);
static napi_value SetSystemFocusable(napi_env env, napi_callback_info info);
@ -169,6 +170,7 @@ private:
napi_value OnSetIsMidScene(napi_env env, napi_callback_info info);
napi_value OnSetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info);
napi_value OnSetSystemSceneForceUIFirst(napi_env env, napi_callback_info info);
napi_value OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info);
napi_value OnSetFocusable(napi_env env, napi_callback_info info);
napi_value OnSetFocusableOnShow(napi_env env, napi_callback_info info);
napi_value OnSetSystemFocusable(napi_env env, napi_callback_info info);

View File

@ -224,6 +224,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
JsSceneSessionManager::ResetPcFoldScreenArrangeRule);
BindNativeFunction(env, exportObj, "setIsWindowRectAutoSave", moduleName,
JsSceneSessionManager::SetIsWindowRectAutoSave);
BindNativeFunction(env, exportObj, "NotifyAboveLockScreen", moduleName,
JsSceneSessionManager::NotifyAboveLockScreen);
return NapiGetUndefined(env);
}
@ -1158,6 +1160,16 @@ napi_value JsSceneSessionManager::SetIsWindowRectAutoSave(napi_env env, napi_cal
return (me != nullptr) ? me->OnSetIsWindowRectAutoSave(env, info) : nullptr;
}
napi_value JsSceneSessionManager::NotifyAboveLockScreen(napi_env env, napi_callback_info info)
{
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
if (me == nullptr) {
TLOGW(WmsLogTag::WMS_SCB, "me is null");
return nullptr;
}
return me->OnNotifyAboveLockScreen(env, info);
}
bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSessionManager::IsCallbackRegistered[%s]", type.c_str());
@ -1545,6 +1557,7 @@ napi_value JsSceneSessionManager::OnGetAbilityInfo(napi_env env, napi_callback_i
if (ret != WSErrorCode::WS_OK) {
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY),
"System is abnormal"));
return NapiGetUndefined(env);
}
return CreateSCBAbilityInfo(env, scbAbilityInfo);
}
@ -2590,7 +2603,7 @@ napi_value JsSceneSessionManager::OnPreloadInLakeApp(napi_env env, napi_callback
auto preloadTask = [bundleName = std::move(bundleName)] {
SceneSessionManager::GetInstance().PreloadInLakeApp(bundleName);
};
localScheduler->PostAsyncTask(preloadTask);
localScheduler->PostAsyncTask(preloadTask, __func__);
return NapiGetUndefined(env);
}
@ -3407,6 +3420,41 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback
return result;
}
napi_value JsSceneSessionManager::OnNotifyAboveLockScreen(napi_env env, napi_callback_info info)
{
size_t argc = ARGC_FOUR;
napi_value argv[ARGC_FOUR] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != ARGC_ONE) {
TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
std::vector<int32_t> windowIds;
if (!ConvertInt32ArrayFromJs(env, argv[0], windowIds)) {
TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert windowIds");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
std::string windowIdListStr = "none";
if (!windowIds.empty()) {
windowIdListStr = std::accumulate(windowIds.begin() + 1,
windowIds.end(),
std::to_string(windowIds[0]),
[](const std::string &str, int32_t windowId) { return str + "," + std::to_string(windowId); });
}
TLOGI(WmsLogTag::WMS_UIEXT,
"UIExtOnLock: OnNotifyAboveLockScreen, window list: %{public}s",
windowIdListStr.c_str());
SceneSessionManager::GetInstance().OnNotifyAboveLockScreen(windowIds);
return NapiGetUndefined(env);
}
napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info)
{
size_t argc = 4;
@ -3587,7 +3635,7 @@ napi_value JsSceneSessionManager::OnUpdatePcFoldScreenStatus(napi_env env, napi_
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
ScreenFoldStatus status = static_cast<ScreenFoldStatus>(statusNum);
SuperFoldStatus status = static_cast<SuperFoldStatus>(statusNum);
WSRect defaultDisplayRect;
if (argv[ARG_INDEX_TWO] == nullptr || !ConvertRectInfoFromJs(env, argv[ARG_INDEX_TWO], defaultDisplayRect)) {

View File

@ -118,9 +118,10 @@ public:
static napi_value UpdatePcFoldScreenStatus(napi_env env, napi_callback_info info);
static napi_value ResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info);
static napi_value SetIsWindowRectAutoSave(napi_env env, napi_callback_info info);
static napi_value NotifyAboveLockScreen(napi_env env, napi_callback_info info);
/*
* Multi instance
* Multi Instance
*/
static napi_value GetMaxInstanceCount(napi_env env, napi_callback_info info);
static napi_value GetInstanceCount(napi_env env, napi_callback_info info);
@ -194,9 +195,10 @@ private:
napi_value OnUpdatePcFoldScreenStatus(napi_env env, napi_callback_info info);
napi_value OnResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info);
napi_value OnSetIsWindowRectAutoSave(napi_env env, napi_callback_info info);
napi_value OnNotifyAboveLockScreen(napi_env env, napi_callback_info info);
/*
* multi instance
* Multi Instance
*/
napi_value OnGetMaxInstanceCount(napi_env env, napi_callback_info info);
napi_value OnGetInstanceCount(napi_env env, napi_callback_info info);

View File

@ -894,6 +894,22 @@ JsSessionType GetApiType(WindowType type)
}
}
static napi_value CreateSupportWindowModes(napi_env env,
const std::vector<AppExecFwk::SupportWindowMode>& supportWindowModes)
{
napi_value arrayValue = nullptr;
napi_create_array_with_length(env, supportWindowModes.size(), &arrayValue);
if (arrayValue == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "Failed to create napi array");
return NapiGetUndefined(env);
}
int32_t index = 0;
for (const auto supportWindowMode : supportWindowModes) {
napi_set_element(env, arrayValue, index++, CreateJsValue(env, static_cast<int32_t>(supportWindowMode)));
}
return arrayValue;
}
napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo)
{
napi_value objValue = nullptr;
@ -942,6 +958,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo)
CreateJsValue(env, sessionInfo.errorReason));
napi_set_named_property(env, objValue, "isFromIcon", CreateJsValue(env, sessionInfo.isFromIcon_));
SetJsSessionInfoByWant(env, sessionInfo, objValue);
napi_set_named_property(env, objValue, "supportWindowModes",
CreateSupportWindowModes(env, sessionInfo.supportWindowModes));
return objValue;
}
@ -1569,20 +1587,14 @@ MainThreadScheduler::MainThreadScheduler(napi_env env)
inline void MainThreadScheduler::GetMainEventHandler()
{
if (handler_ != nullptr) {
return;
}
auto runner = OHOS::AppExecFwk::EventRunner::GetMainEventRunner();
if (runner == nullptr) {
return;
}
handler_ = std::make_shared<OHOS::AppExecFwk::EventHandler>(runner);
}
void MainThreadScheduler::PostMainThreadTask(Task&& localTask, std::string traceInfo, int64_t delayTime)
{
GetMainEventHandler();
auto task = [env = env_, localTask, traceInfo, envChecker = std::weak_ptr<int>(envChecker_)]() {
auto task = [env = env_, localTask = std::move(localTask), traceInfo,
envChecker = std::weak_ptr<int>(envChecker_)] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SCBCb:%s", traceInfo.c_str());
if (envChecker.expired()) {
TLOGNE(WmsLogTag::WMS_MAIN, "post task expired because of invalid scheduler");

View File

@ -43,8 +43,10 @@ ohos_shared_library("screensessionmanager_napi") {
]
external_deps = [
"ability_runtime:ability_context_native",
"ability_runtime:app_manager",
"ability_runtime:runtime",
"ace_engine:ace_uicontent",
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_2d:librender_service_base",

View File

@ -17,6 +17,7 @@
#include <hitrace_meter.h>
#include <js_runtime_utils.h>
#include <ui_content.h>
#include "interfaces/include/ws_common.h"
#include "js_screen_utils.h"
@ -68,6 +69,8 @@ napi_value JsScreenSession::Create(napi_env env, const sptr<ScreenSession>& scre
BindNativeFunction(env, objValue, "setTouchEnabled", moduleName,
JsScreenSession::SetTouchEnabled);
BindNativeFunction(env, objValue, "loadContent", moduleName, JsScreenSession::LoadContent);
BindNativeFunction(env, objValue, "getScreenUIContext", moduleName,
JsScreenSession::GetScreenUIContext);
return objValue;
}
@ -338,6 +341,45 @@ napi_value JsScreenSession::OnRegisterCallback(napi_env env, napi_callback_info
return NapiGetUndefined(env);
}
napi_value JsScreenSession::GetScreenUIContext(napi_env env, napi_callback_info info)
{
JsScreenSession* me = CheckParamsAndGetThis<JsScreenSession>(env, info);
return (me != nullptr) ? me->OnGetScreenUIContext(env, info) : nullptr;
}
napi_value JsScreenSession::OnGetScreenUIContext(napi_env env, napi_callback_info info)
{
WLOGI("[NAPI]OnGetScreenUIContext");
size_t argc = 1;
napi_value argv[1] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc > 0) { // 0: params num
WLOGFE("Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM)));
return NapiGetUndefined(env);
}
if (screenScene_ == nullptr) {
WLOGFE("screenScene_ is nullptr");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
return NapiGetUndefined(env);
}
const auto& uiContent = screenScene_->GetUIContent();
if (uiContent == nullptr) {
WLOGFE("uiContent is nullptr");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
return NapiGetUndefined(env);
}
napi_value uiContext = uiContent->GetUINapiContext();
if (uiContext == nullptr) {
WLOGFE("uiContext obtained from jsEngine is nullptr");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
return NapiGetUndefined(env);
}
WLOGI("success");
return uiContext;
}
void JsScreenSession::CallJsCallback(const std::string& callbackType)
{
WLOGI("Call js callback: %{public}s.", callbackType.c_str());

View File

@ -43,6 +43,8 @@ private:
napi_value OnSetScreenRotationLocked(napi_env env, napi_callback_info info);
static napi_value SetTouchEnabled(napi_env env, napi_callback_info info);
napi_value OnSetTouchEnabled(napi_env env, napi_callback_info info);
static napi_value GetScreenUIContext(napi_env env, napi_callback_info info);
napi_value OnGetScreenUIContext(napi_env env, napi_callback_info info);
void CallJsCallback(const std::string& callbackType);
void RegisterScreenChangeListener();
void UnRegisterScreenChangeListener();

View File

@ -439,11 +439,14 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env,
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to get bounds from js object");
return NapiGetUndefined(env);
}
int rotation;
if (!ConvertFromJsValue(env, argv[2], rotation)) { // 2: the 3rd argv
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to rotation");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
ScreenDirectionInfo directionInfo;
napi_value nativeObject = argv[2];
if (nativeObject == nullptr) {
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo,the param is null");
return NapiGetUndefined(env);
}
if (!ConvertScreenDirectionInfoFromJs(env, nativeObject, directionInfo)) {
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo");
return NapiGetUndefined(env);
}
ScreenPropertyChangeType type = ScreenPropertyChangeType::UNSPECIFIED;
@ -456,7 +459,7 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env,
return NapiGetUndefined(env);
}
}
ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, rotation,
ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, directionInfo,
type);
return NapiGetUndefined(env);
}

View File

@ -242,6 +242,39 @@ bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound)
return true;
}
bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo)
{
napi_value jsNotifyRotation = nullptr, jsScreenRotation = nullptr, jsRotation = nullptr;
napi_get_named_property(env, jsObject, "notifyRotation", &jsNotifyRotation);
napi_get_named_property(env, jsObject, "screenRotation", &jsScreenRotation);
napi_get_named_property(env, jsObject, "rotation", &jsRotation);
if (GetType(env, jsNotifyRotation) != napi_undefined) {
int32_t notifyRotation;
if (!ConvertFromJsValue(env, jsNotifyRotation, notifyRotation)) {
WLOGFE("[NAPI]Failed to convert parameter to notifyRotation");
return false;
}
directionInfo.notifyRotation_ = notifyRotation;
}
if (GetType(env, jsScreenRotation) != napi_undefined) {
int32_t screenRotation;
if (!ConvertFromJsValue(env, jsScreenRotation, screenRotation)) {
WLOGFE("[NAPI]Failed to convert parameter to screenRotation");
return false;
}
directionInfo.screenRotation_ = screenRotation;
}
if (GetType(env, jsRotation) != napi_undefined) {
int32_t rotation;
if (!ConvertFromJsValue(env, jsRotation, rotation)) {
WLOGFE("[NAPI]Failed to convert parameter to rotation");
return false;
}
directionInfo.rotation_ = rotation;
}
return true;
}
bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect)
{

View File

@ -25,6 +25,7 @@
namespace OHOS::Rosen {
bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound);
bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect);
bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo);
napi_value NapiGetUndefined(napi_env env);
bool NapiIsCallable(napi_env env, napi_value value);
class JsScreenUtils {

View File

@ -98,15 +98,13 @@ napi_value JsTransactionManager::OnOpenSyncTransaction(napi_env env, napi_callba
napi_value JsTransactionManager::OnCloseSyncTransaction(napi_env env, napi_callback_info info)
{
auto task = []() {
auto transactionController = RSSyncTransactionController::GetInstance();
if (transactionController) {
auto task = [] {
if (auto transactionController = RSSyncTransactionController::GetInstance()) {
transactionController->CloseSyncTransaction();
}
};
auto handler = SceneSessionManager::GetInstance().GetTaskScheduler();
if (handler) {
handler->PostAsyncTask(task);
if (auto handler = SceneSessionManager::GetInstance().GetTaskScheduler()) {
handler->PostAsyncTask(task, __func__);
} else {
task();
}

View File

@ -123,6 +123,9 @@ ohos_shared_library("screen_session_manager") {
"ability_runtime:app_manager",
"ability_runtime:dataobs_manager",
"ability_runtime:extension_manager",
"access_token:libaccesstoken_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",

View File

@ -26,11 +26,14 @@
#include "dm_common.h"
#include "wm_single_instance.h"
#include "transaction/rs_interfaces.h"
namespace OHOS {
namespace Rosen {
class RSInterfaces;
class SuperFoldStateManager final {
WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldStateManager)
public:

View File

@ -273,6 +273,7 @@ public:
std::shared_ptr<RSDisplayNode> GetDisplayNode(ScreenId screenId) override;
void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType) override;
void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override;
uint32_t GetCurvedCompressionArea() override;
ScreenProperty GetPhyScreenProperty(ScreenId screenId) override;
void SetScreenPrivacyState(bool hasPrivate) override;
@ -393,6 +394,7 @@ private:
DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
std::vector<uint64_t>& windowIdList) override;
void GetInternalAndExternalSession(sptr<ScreenSession>& internalSession, sptr<ScreenSession>& externalSession);
void AddPermissionUsedRecord(const std::string& permission, int32_t successCount, int32_t failCount);
#ifdef DEVICE_STATUS_ENABLE
void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId);
#endif // DEVICE_STATUS_ENABLE

View File

@ -164,6 +164,7 @@ public:
virtual std::shared_ptr<RSDisplayNode> GetDisplayNode(ScreenId screenId) { return nullptr; }
virtual void UpdateScreenRotationProperty(ScreenId screenId, const RRectT<float>& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType) {}
virtual void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) {}
virtual void UpdateAvailableArea(ScreenId screenId, DMRect area) {}
virtual int32_t SetScreenOffDelayTime(int32_t delay) { return 0; }
virtual uint32_t GetCurvedCompressionArea() { return 0; }

View File

@ -156,6 +156,7 @@ public:
std::shared_ptr<RSDisplayNode> GetDisplayNode(ScreenId screenId) override;
void UpdateScreenRotationProperty(ScreenId screenId, const RRectT<float>& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType) override;
void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override;
void UpdateAvailableArea(ScreenId ScreenId, DMRect area) override;
int32_t SetScreenOffDelayTime(int32_t delay) override;
uint32_t GetCurvedCompressionArea() override;

View File

@ -121,7 +121,9 @@ bool ScreenSessionAbilityConnectionStub::IsAbilityConnected()
bool ScreenSessionAbilityConnectionStub::IsAbilityConnectedSync()
{
std::unique_lock<std::mutex> lock(connectedMutex_);
if (!isConnected_) {
connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME));
}
return IsAbilityConnected();
}
@ -129,7 +131,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSync(int32_t transCode,
MessageParcel &data, MessageParcel &reply)
{
std::unique_lock<std::mutex> lock(connectedMutex_);
if (!isConnected_) {
connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME));
}
if (!IsAbilityConnected()) {
TLOGE(WmsLogTag::DMS, "ability connection is not established");
lock.unlock();
@ -154,7 +158,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSyncBlock(int32_t transCo
MessageParcel &data, MessageParcel &reply)
{
std::unique_lock<std::mutex> lock(connectedMutex_);
if (!isConnected_) {
connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME));
}
if (!IsAbilityConnected()) {
TLOGE(WmsLogTag::DMS, "ability connection is not established");
lock.unlock();

View File

@ -236,6 +236,7 @@ void SingleDisplayFoldPolicy::ReportFoldStatusChangeBegin(int32_t offScreen, int
void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession,
DisplayModeChangeReason reason)
{
RSInterfaces::GetInstance().SetScreenSwitching(true);
if (onBootAnimation_) {
ChangeScreenDisplayModeToMainOnBootAnimation(screenSession);
return;
@ -288,6 +289,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession>
void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession,
DisplayModeChangeReason reason)
{
RSInterfaces::GetInstance().SetScreenSwitching(true);
if (onBootAnimation_) {
ChangeScreenDisplayModeToFullOnBootAnimation(screenSession);
return;

View File

@ -310,6 +310,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenO
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession,
DisplayModeChangeReason reason)
{
RSInterfaces::GetInstance().SetScreenSwitching(true);
SetdisplayModeChangeStatus(true);
if (onBootAnimation_) {
ChangeScreenDisplayModeToMainOnBootAnimation(screenSession);
@ -328,6 +329,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSes
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession,
DisplayModeChangeReason reason)
{
RSInterfaces::GetInstance().SetScreenSwitching(true);
SetdisplayModeChangeStatus(true);
if (onBootAnimation_) {
ChangeScreenDisplayModeToFullOnBootAnimation(screenSession);

View File

@ -24,6 +24,14 @@ namespace Rosen {
WM_IMPLEMENT_SINGLE_INSTANCE(SuperFoldStateManager)
namespace {
#ifdef TP_FEATURE_ENABLE
const int32_t TP_TYPE = 12;
const char* KEYBOARD_ON_CONFIG = "version:3+main";
const char* KEYBOARD_OFF_CONFIG = "version:3+whole";
#endif
}
void SuperFoldStateManager::DoAngleChangeFolded(SuperFoldStatusChangeEvents event)
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeFolded()");
@ -41,14 +49,60 @@ void SuperFoldStateManager::DoAngleChangeExpanded(SuperFoldStatusChangeEvents ev
void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event)
{
sptr<ScreenSession> meScreenSession = ScreenSessionManager::GetInstance().
GetDefaultScreenSession();
if (meScreenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "screen session is null!");
return;
}
auto screenProperty = meScreenSession->GetScreenProperty();
auto screenWidth = screenProperty.GetFakeBounds().rect_.GetWidth();
auto screenHeight = screenProperty.GetFakeBounds().rect_.GetHeight();
OHOS::Rect rectCur{
.x = 0,
.y = 0,
.w = static_cast<int>(screenWidth),
.h = static_cast<int>(screenHeight),
};
// SCREEN_ID_FULL = 0
auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur);
ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(true);
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()");
#ifdef TP_FEATURE_ENABLE
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE,
KEYBOARD_ON_CONFIG, TpFeatureConfigType::AFT_TP_FEATURE);
#endif
TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld",
screenWidth, screenHeight, static_cast<long>(response));
}
void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event)
{
sptr<ScreenSession> meScreenSession = ScreenSessionManager::GetInstance().
GetDefaultScreenSession();
if (meScreenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "screen session is null!");
return;
}
auto screenProperty = meScreenSession->GetScreenProperty();
auto screenWidth = screenProperty.GetBounds().rect_.GetWidth();
auto screenHeight = screenProperty.GetBounds().rect_.GetHeight();
OHOS::Rect rectCur{
.x = 0,
.y = 0,
.w = static_cast<int>(screenWidth),
.h = static_cast<int>(screenHeight),
};
// SCREEN_ID_FULL = 0
auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur);
ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(false);
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()");
#ifdef TP_FEATURE_ENABLE
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE,
KEYBOARD_OFF_CONFIG, TpFeatureConfigType::DEFAULT_TP_FEATURE);
#endif
TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld",
screenWidth, screenHeight, static_cast<long>(response));
}
void SuperFoldStateManager::DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event)

View File

@ -153,6 +153,17 @@ void ScreenSessionDumper::ExcuteDumpCmd()
void ScreenSessionDumper::ExcuteInjectCmd()
{
bool isDeveloperMode = system::GetBoolParameter("const.security.developermode.state", false);
if (isDeveloperMode) {
if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) {
int errCode = SetFoldDisplayMode();
if (errCode != 0) {
ShowIllegalArgsInfo();
}
return;
}
}
bool isDebugMode = system::GetBoolParameter("dms.hidumper.supportdebug", false);
if (!isDebugMode) {
TLOGI(WmsLogTag::DMS, "Can't use DMS hidumper inject methods.");
@ -171,12 +182,6 @@ void ScreenSessionDumper::ExcuteInjectCmd()
} else if (params_[0].find(ARG_PUBLISH_CAST_EVENT) != std::string::npos) {
MockSendCastPublishEvent(params_[0]);
return;
} else if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) {
int errCode = SetFoldDisplayMode();
if (errCode != 0) {
ShowIllegalArgsInfo();
}
return;
} else if (params_.size() == 1 && (params_[0] == ARG_LOCK_FOLD_DISPLAY_STATUS
|| params_[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) {
int errCode = SetFoldStatusLocked();
@ -746,12 +751,12 @@ void ScreenSessionDumper::SetHallAndPostureValue(std::string input)
.angle = postureVal,
};
SensorEvent hallEvent = {
.dataLen = sizeof(ExtHallData),
.data = reinterpret_cast<uint8_t *>(&hallData),
.dataLen = sizeof(ExtHallData),
};
SensorEvent postureEvent = {
.dataLen = sizeof(PostureData),
.data = reinterpret_cast<uint8_t *>(&postureData),
.dataLen = sizeof(PostureData),
};
OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandleHallData(&hallEvent);
OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandlePostureData(&postureEvent);

View File

@ -29,6 +29,7 @@
#include <ipc_skeleton.h>
#include <parameter.h>
#include <parameters.h>
#include <privacy_kit.h>
#include <system_ability_definition.h>
#include <transaction/rs_interfaces.h>
#include <xcollie/watchdog.h>
@ -2637,6 +2638,20 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr<DisplayInfo> displayInfo,
IPCSkeleton::SetCallingIdentity(identity);
}
void ScreenSessionManager::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation)
{
sptr<ScreenSession> screenSession = GetScreenSession(screenId);
if (screenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "fail, cannot find screen %{public}" PRIu64"",
screenId);
return;
}
screenSession->SetPhysicalRotation(rotation, GetFoldStatus());
screenSession->SetScreenComponentRotation(screenComponentRotation);
TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 ", rotation: %{public}f, screenComponentRotation: %{public}f",
screenId, rotation, screenComponentRotation);
}
void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType)
{
@ -2685,7 +2700,6 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const
}
{
std::lock_guard<std::recursive_mutex> lock_info(displayInfoMutex_);
screenSession->SetPhysicalRotation(rotation, GetFoldStatus());
screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode());
}
sptr<DisplayInfo> displayInfo = screenSession->ConvertToDisplayInfo();
@ -4400,13 +4414,13 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetDisplaySnapshotWithOpt
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetDisplaySnapshot(%" PRIu64")", option.displayId_);
auto res = GetScreenSnapshot(option.displayId_);
if (res != nullptr) {
NotifyScreenshot(option.displayId_);
if (SessionPermission::IsBetaVersion()) {
CheckAndSendHiSysEvent("GET_DISPLAY_SNAPSHOT", "hmos.screenshot");
}
TLOGI(WmsLogTag::DMS, "isNeedNotify_:%{public}d", option.isNeedNotify_);
if (option.isNeedNotify_) {
isScreenShot_ = true;
NotifyScreenshot(option.displayId_);
NotifyCaptureStatusChanged();
}
}
@ -6118,7 +6132,6 @@ void ScreenSessionManager::InitFakeScreenSession(sptr<ScreenSession> screenSessi
uint32_t screenHeight = screenProperty.GetBounds().rect_.GetHeight();
fakeScreenSession->UpdatePropertyByResolution(screenWidth, screenHeight / HALF_SCREEN_PARAM);
screenSession->UpdatePropertyByFakeBounds(screenWidth, screenHeight / HALF_SCREEN_PARAM);
screenSession->UpdatePropertyByFakeInUse(true);
screenSession->SetFakeScreenSession(fakeScreenSession);
screenSession->SetIsFakeInUse(true);
}
@ -6360,6 +6373,17 @@ void ScreenSessionManager::OnScreenCaptureNotify(ScreenId mainScreenId, int32_t
clientProxy_->ScreenCaptureNotify(mainScreenId, uid, clientName);
}
void ScreenSessionManager::AddPermissionUsedRecord(const std::string& permission, int32_t successCount,
int32_t failCount)
{
int32_t ret = Security::AccessToken::PrivacyKit::AddPermissionUsedRecord(IPCSkeleton::GetCallingTokenID(),
permission, successCount, failCount);
if (ret != 0) {
TLOGW(WmsLogTag::DMS, "AddPermissionUsedRecord failed, permission:%{public}s, \
successCount %{public}d, failedCount %{public}d", permission.c_str(), successCount, failCount);
}
}
std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode)
{
@ -6391,6 +6415,8 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenCapture(const Ca
}
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetScreenCapture(%" PRIu64")", captureOption.displayId_);
auto res = GetScreenSnapshot(captureOption.displayId_);
AddPermissionUsedRecord(CUSTOM_SCREEN_CAPTURE_PERMISSION,
static_cast<int32_t>(res != nullptr), static_cast<int32_t>(res == nullptr));
if (res == nullptr) {
TLOGE(WmsLogTag::DMS, "get capture null.");
*errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL;

View File

@ -2493,6 +2493,41 @@ std::shared_ptr<RSDisplayNode> ScreenSessionManagerProxy::GetDisplayNode(ScreenI
return displayNode;
}
void ScreenSessionManagerProxy::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation,
float rotation)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("UpdateScreenDirectionInfo: remote is null");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return;
}
if (!data.WriteUint64(screenId)) {
WLOGFE("Write screenId failed");
return;
}
if (!data.WriteFloat(screenComponentRotation)) {
WLOGFE("Write screenComponentRotation failed");
return;
}
if (!data.WriteFloat(rotation)) {
WLOGFE("Write rotation failed");
return;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return;
}
}
void ScreenSessionManagerProxy::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType)
{

View File

@ -709,6 +709,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
}
break;
}
case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO: {
auto screenId = static_cast<ScreenId>(data.ReadUint64());
auto screenComponentRotation = data.ReadFloat();
auto rotation = data.ReadFloat();
UpdateScreenDirectionInfo(screenId, screenComponentRotation, rotation);
break;
}
case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY: {
auto screenId = static_cast<ScreenId>(data.ReadUint64());
RRect bounds;

View File

@ -52,6 +52,7 @@ ohos_shared_library("screen_session_manager_client") {
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_base",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"hitrace:hitrace_meter",

View File

@ -50,7 +50,7 @@ public:
std::map<ScreenId, ScreenProperty> GetAllScreensProperties() const;
FoldDisplayMode GetFoldDisplayMode() const;
void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, ScreenDirectionInfo directionInfo,
ScreenPropertyChangeType screenPropertyChangeType);
uint32_t GetCurvedCompressionArea();
ScreenProperty GetPhyScreenProperty(ScreenId screenId);

View File

@ -20,7 +20,7 @@
#include <system_ability_definition.h>
#include <transaction/rs_transaction.h>
#include <transaction/rs_interfaces.h>
#include "dm_common.h"
#include "pipeline/rs_node_map.h"
#include "window_manager_hilog.h"
@ -301,14 +301,16 @@ FoldDisplayMode ScreenSessionManagerClient::GetFoldDisplayMode() const
return displayMode_;
}
void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
ScreenPropertyChangeType screenPropertyChangeType)
void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds,
ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType)
{
if (!screenSessionManager_) {
WLOGFE("screenSessionManager_ is null");
return;
}
screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, screenPropertyChangeType);
screenSessionManager_->UpdateScreenDirectionInfo(screenId, directionInfo.screenRotation_, directionInfo.rotation_);
screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, directionInfo.notifyRotation_,
screenPropertyChangeType);
// not need update property to input manager
if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_END ||
@ -322,8 +324,9 @@ void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId,
}
auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode();
auto foldStatus = screenSessionManager_->GetFoldStatus();
screenSession->SetPhysicalRotation(rotation, foldStatus);
screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode);
screenSession->SetPhysicalRotation(directionInfo.rotation_, foldStatus);
screenSession->SetScreenComponentRotation(directionInfo.screenRotation_);
screenSession->UpdateToInputManager(bounds, directionInfo.notifyRotation_, foldDisplayMode);
}
void ScreenSessionManagerClient::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId)

View File

@ -79,6 +79,7 @@ ohos_shared_library("scene_session") {
]
external_deps = [
"ability_runtime:ability_manager",
"ability_runtime:ability_start_setting",
"ability_runtime:process_options",
"ability_runtime:start_window_option",

View File

@ -59,6 +59,7 @@ using NotifyAsyncOnFunc = std::function<void()>;
using NotifyGetAvoidAreaByTypeFunc = std::function<AvoidArea(AvoidAreaType type)>;
using NotifyBindModalFunc = std::function<void()>;
using NotifyExtensionEventFunc = std::function<void(uint32_t notifyEvent)>;
using GetStatusBarHeightFunc = std::function<int32_t()>;
class ExtensionSession : public Session {
public:
@ -71,6 +72,7 @@ public:
NotifyGetAvoidAreaByTypeFunc notifyGetAvoidAreaByTypeFunc_;
NotifyBindModalFunc notifyBindModalFunc_;
NotifyExtensionEventFunc notifyExtensionEventFunc_;
GetStatusBarHeightFunc getStatusBarHeightFunc_;
};
explicit ExtensionSession(const SessionInfo& info);
@ -86,6 +88,7 @@ public:
const std::string& identityToken = "") override;
AvoidArea GetAvoidAreaByType(AvoidAreaType type) override;
int32_t GetStatusBarHeight() override;
WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;

View File

@ -34,14 +34,6 @@ class SceneSession;
using RectRecordsVector =
std::vector<std::pair<std::chrono::time_point<std::chrono::high_resolution_clock>, WSRect>>;
enum class ScreenFoldStatus : uint8_t {
UNKNOWN = 0,
EXPANDED = 1,
FOLDED = 2,
HALF_FOLDED = 3,
HALF_FOLDED_KEYBOARD = 4,
};
enum class ScreenSide : uint8_t {
EXPAND = 0,
FOLD_B = 1,
@ -51,7 +43,7 @@ enum class ScreenSide : uint8_t {
class PcFoldScreenManager {
WM_DECLARE_SINGLE_INSTANCE(PcFoldScreenManager);
public:
void UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status,
void UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status,
const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect);
bool IsHalfFolded(DisplayId displayId);
@ -85,7 +77,7 @@ public:
const WSRect& limitRect, int32_t titleHeight);
private:
void SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status);
void SetDisplayInfo(DisplayId displayId, SuperFoldStatus status);
void SetDisplayRects(
const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect);
float GetVpr();
@ -97,7 +89,7 @@ private:
std::shared_mutex displayInfoMutex_; // protect display infos
DisplayId displayId_ { SCREEN_ID_INVALID };
float vpr_ { 1.5f }; // display vp ratio
ScreenFoldStatus screenFoldStatus_ { ScreenFoldStatus::UNKNOWN };
SuperFoldStatus screenFoldStatus_ { SuperFoldStatus::UNKNOWN };
std::shared_mutex rectsMutex_; // protect rects
WSRect defaultDisplayRect_;
WSRect virtualDisplayRect_;
@ -117,6 +109,7 @@ class PcFoldScreenController : public RefBase {
public:
explicit PcFoldScreenController(wptr<SceneSession> weakSession);
bool IsHalfFolded(DisplayId displayId);
bool NeedFollowHandAnimation();
void RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen);
void RecordMoveRects(const WSRect& rect);
bool ThrowSlip(DisplayId displayId, WSRect& rect, int32_t topAvoidHeight, int32_t botAvoidHeight);

View File

@ -98,6 +98,12 @@ using NotifySetWindowRectAutoSaveFunc = std::function<void(bool enabled)>;
class SceneSession : public Session {
public:
struct UIExtensionTokenInfo {
bool canShowOnLockScreen{false};
uint32_t callingTokenId{0};
sptr<IRemoteObject> abilityToken;
};
friend class HidumpController;
// callback for notify SceneSessionManager
struct SpecificSessionCallback : public RefBase {
@ -126,7 +132,6 @@ public:
NotifySessionTopmostChangeFunc onSessionTopmostChange_;
NotifyRaiseToTopFunc onRaiseToTop_;
NotifySessionEventFunc OnSessionEvent_;
NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
NotifyRaiseAboveTargetFunc onRaiseAboveTarget_;
NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_;
};
@ -211,6 +216,8 @@ public:
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
bool needNotifyClient = true) override;
WSError TransferPointerEventInner(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
bool needNotifyClient = true);
WSError RequestSessionBack(bool needMoveToBackground) override;
WSError SetAspectRatio(float ratio) override;
WSError SetGlobalMaximizeMode(MaximizeMode mode) override;
@ -260,6 +267,7 @@ public:
void SetSnapshotSkip(bool isSkip);
void SetSystemSceneOcclusionAlpha(double alpha);
void SetSystemSceneForceUIFirst(bool forceUIFirst);
void MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled);
void SetRequestedOrientation(Orientation orientation);
WSError SetDefaultRequestedOrientation(Orientation orientation);
void SetWindowAnimationFlag(bool needDefaultAnimationFlag);
@ -378,7 +386,6 @@ public:
void NotifySessionForeground(uint32_t reason, bool withAnimation);
void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits);
void RegisterSessionChangeCallback(const sptr<SceneSession::SessionChangeCallback>& sessionChangeCallback);
void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback);
void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback);
void RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback);
void RegisterForceSplitListener(const NotifyForceSplitFunc& func);
@ -404,11 +411,16 @@ public:
* Window Animation
*/
void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback);
void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback);
/**
* Window Visibility
*/
void SetNotifyVisibleChangeFunc(const NotifyVisibleChangeFunc& func);
virtual WSError HideSync()
{
return WSError::WS_DO_NOTHING;
};
/**
* Window Lifecycle
@ -460,6 +472,15 @@ public:
WSPropertyChangeAction action) override;
void SetSessionChangeByActionNotifyManagerListener(const SessionChangeByActionNotifyManagerFunc& func);
/**
* UIExtension
*/
bool IsShowOnLockScreen(uint32_t lockScreenZOrder);
void AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo);
void RemoveExtensionTokenInfo(sptr<IRemoteObject> abilityToken);
void CheckExtensionOnLockScreenToClose();
void CloseExtensionSync(const SceneSession::UIExtensionTokenInfo& tokenInfo);
void OnNotifyAboveLockScreen();
void AddModalUIExtension(const ExtensionWindowEventInfo& extensionInfo);
void RemoveModalUIExtension(int32_t persistentId);
bool HasModalUIExtension();
@ -555,6 +576,7 @@ protected:
bool PipelineNeedNotifyClientToUpdateRect() const;
bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason);
bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason);
bool IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY);
bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY);
bool UpdateZOrderInner(uint32_t zOrder);
@ -608,6 +630,7 @@ protected:
* PC Fold Screen
*/
sptr<PcFoldScreenController> pcFoldScreenController_ = nullptr;
std::atomic_bool throwSlipFullScreenFlag_ = false;
/**
* PC Window
@ -734,7 +757,7 @@ private:
WSPropertyChangeAction action);
WMError HandleActionUpdateMainWindowTopmost(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action);
WMError HandleActionUpdateModeSupportInfo(const sptr<WindowSessionProperty>& property,
WMError HandleActionUpdateWindowModeSupportType(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action);
WMError ProcessUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action);
@ -765,10 +788,16 @@ private:
std::atomic_bool isStartMoving_ { false };
std::atomic_bool isVisibleForAccessibility_ { true };
bool isSystemSpecificSession_ { false };
/**
* UIExtension
*/
std::atomic_bool shouldHideNonSecureWindows_ { false };
std::shared_mutex combinedExtWindowFlagsMutex_;
ExtensionWindowFlags combinedExtWindowFlags_ { 0 };
std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
mutable std::recursive_mutex extensionTokenInfosMutex_;
std::vector<UIExtensionTokenInfo> extensionTokenInfos_;
/**
* Window Decor
@ -841,6 +870,7 @@ private:
* Window Animation
*/
NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_;
NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
/**
* Window Layout

View File

@ -101,6 +101,7 @@ public:
virtual void OnRemoveBlank() {}
virtual void OnDrawingCompleted() {}
virtual void OnExtensionDied() {}
virtual void OnExtensionDetachToDisplay() {}
virtual void OnExtensionTimeout(int32_t errorCode) {}
virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
int64_t uiExtensionIdLevel) {}
@ -133,6 +134,9 @@ public:
void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler,
const std::shared_ptr<AppExecFwk::EventHandler>& exportHandler = nullptr);
/**
* Window LifeCycle
*/
virtual WSError ConnectInner(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr,
@ -149,9 +153,21 @@ public:
WSError DrawingCompleted() override;
void ResetSessionConnectState();
void ResetIsActive();
WSError PendingSessionToForeground();
WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller);
bool RegisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener);
bool UnregisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener);
void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func);
void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func);
void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func);
void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene);
void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func);
void SetBackPressedListenser(NotifyBackPressedFunc&& func);
void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func);
void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& func);
void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func);
WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker);
WSError TerminateSessionTotal(const sptr<AAFwk::SessionInfo> info, TerminateType terminateType);
/**
* Callbacks for ILifecycleListener
@ -167,6 +183,7 @@ public:
void NotifyExtensionTimeout(int32_t errorCode) override;
void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
int64_t uiExtensionIdLevel) override;
void NotifyExtensionDetachToDisplay() override;
/**
* Cross Display Move Drag
@ -255,16 +272,8 @@ public:
virtual bool IsExitSplitOnBackground() const;
virtual bool NeedStartingWindowExitAnimation() const { return true; }
void SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func);
void SetChangeSessionVisibilityWithStatusBarEventListener(
const NotifyChangeSessionVisibilityWithStatusBarFunc& func);
void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func);
WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker);
void SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func);
void SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene);
void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func);
WSError TerminateSessionTotal(const sptr<AAFwk::SessionInfo> info, TerminateType terminateType);
void SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func);
WSError Clear(bool needStartCaller = false);
WSError SetSessionLabel(const std::string& label);
void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func);
@ -283,7 +292,6 @@ public:
void SetSystemConfig(const SystemSessionConfig& systemConfig);
void SetSnapshotScale(const float snapshotScale);
void SetBackPressedListenser(const NotifyBackPressedFunc& func);
virtual WSError ProcessBackEvent(); // send back event to session_stage
sptr<ScenePersistence> GetScenePersistence() const;
@ -297,12 +305,6 @@ public:
WSError NotifyDestroy();
WSError NotifyCloseExistPipWindow();
void SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func);
WSError PendingSessionToForeground();
void SetPendingSessionToBackgroundForDelegatorListener(const NotifyPendingSessionToBackgroundForDelegatorFunc&
func);
WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller);
void SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func);
void SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func);
void SetClickListener(const NotifyClickFunc& func);
@ -537,6 +539,12 @@ public:
void ProcessClickModalWindowOutside(int32_t posX, int32_t posY);
void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func);
/**
* Window Layout
*/
void SetClientDragEnable(bool dragEnable);
std::optional<bool> GetClientDragEnable() const;
protected:
class SessionLifeCycleTask : public virtual RefBase {
public:
@ -581,7 +589,7 @@ protected:
FinishTraceForSyncTask();
return ret;
}
auto syncTask = [&ret, &task, name]() {
auto syncTask = [&ret, &task, &name] {
StartTraceForSyncTask(name);
ret = task();
FinishTraceForSyncTask();
@ -618,7 +626,6 @@ protected:
SizeChangeReason reason_ = SizeChangeReason::UNDEFINED;
NotifySessionRectChangeFunc sessionRectChangeFunc_;
NotifyPendingSessionActivationFunc pendingSessionActivationFunc_;
NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_;
NotifySessionStateChangeFunc sessionStateChangeFunc_;
NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_;
@ -629,20 +636,12 @@ protected:
NotifyUIRequestFocusFunc requestFocusFunc_;
NotifyUILostFocusFunc lostFocusFunc_;
GetStateFromManagerFunc getStateFromManagerFunc_;
NotifyBackPressedFunc backPressedFunc_;
NotifySessionFocusableChangeFunc sessionFocusableChangeFunc_;
NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_;
NotifyClickFunc clickFunc_;
NotifyTerminateSessionFunc terminateSessionFunc_;
NotifyTerminateSessionFuncNew terminateSessionFuncNew_;
NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_;
NofitySessionLabelUpdatedFunc updateSessionLabelFunc_;
NofitySessionIconUpdatedFunc updateSessionIconFunc_;
std::shared_ptr<NotifySessionExceptionFunc> sessionExceptionFunc_;
std::shared_ptr<NotifySessionExceptionFunc> jsSceneSessionExceptionFunc_;
NotifySessionSnapshotFunc notifySessionSnapshotFunc_;
NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_;
NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_;
NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_;
NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_;
NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_;
@ -651,6 +650,19 @@ protected:
NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_;
VisibilityChangedDetectFunc visibilityChangedDetectFunc_;
/**
* Window LifeCycle
*/
NotifyPendingSessionActivationFunc pendingSessionActivationFunc_;
NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_;
NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_;
NotifyBackPressedFunc backPressedFunc_;
NotifyTerminateSessionFunc terminateSessionFunc_;
NotifyTerminateSessionFuncNew terminateSessionFuncNew_;
NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_;
NotifySessionExceptionFunc sessionExceptionFunc_;
NotifySessionExceptionFunc jsSceneSessionExceptionFunc_;
/**
* Window Rotate Animation
*/
@ -663,6 +675,15 @@ protected:
float snapshotScale_ = 0.5;
sptr<ScenePersistence> scenePersistence_ = nullptr;
/**
* Window Layout
*/
float clientScaleX_ = 1.0f;
float clientScaleY_ = 1.0f;
float clientPivotX_ = 0.0f;
float clientPivotY_ = 0.0f;
void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY);
/**
* Window ZOrder
*/
@ -814,6 +835,11 @@ private:
bool enableRemoveStartingWindow_ { false };
bool appBufferReady_ { false };
bool useStartingWindowAboveLocked_ { false };
/**
* Window Layout
*/
std::optional<bool> clientDragEnable_;
};
} // namespace OHOS::Rosen

View File

@ -26,6 +26,8 @@ public:
WSError Show(sptr<WindowSessionProperty> property) override;
WSError Hide() override;
WSError HideSync() override;
WSError Hide(bool needSyncHide);
WSError ProcessPointDownSession(int32_t posX, int32_t posY) override;
int32_t GetMissionId() const override;
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;

View File

@ -273,7 +273,7 @@ public:
virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; }
virtual int32_t GetStatusBarHeight() { return 0; }
virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; }
virtual void NotifyExtensionDetachToDisplay() {}
/**
* @brief Request to get focus or lose focus.
*

View File

@ -86,6 +86,7 @@ enum class SessionInterfaceCode {
TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION,
TRANS_ID_NOTIFY_EXTENSION_TIMEOUT,
TRANS_ID_NOTIFY_EXTENSION_EVENT_ASYNC,
TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY,
// PictureInPicture
TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800,

View File

@ -103,6 +103,7 @@ public:
WMError SetSystemWindowEnableDrag(bool enableDrag) override;
WSError RequestFocus(bool isFocused) override;
void NotifyExtensionEventAsync(uint32_t notifyEvent) override;
void NotifyExtensionDetachToDisplay() override;
WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) override;
WSError OnMainSessionModalTypeChange(bool isModal) override;

View File

@ -98,6 +98,7 @@ private:
int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply);
int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply);
int HandleNotifyExtensionEventAsync(MessageParcel& data, MessageParcel& reply);
int HandleNotifyExtensionDetachToDisplay(MessageParcel& data, MessageParcel& reply);
// PictureInPicture
int HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply);

View File

@ -477,4 +477,13 @@ WSError ExtensionSession::NotifyDumpInfo(const std::vector<std::string>& params,
}
return sessionStage_->NotifyDumpInfo(params, info);
}
int32_t ExtensionSession::GetStatusBarHeight()
{
TLOGI(WmsLogTag::WMS_UIEXT, "persistenId=%{public}d", GetPersistentId());
if (extSessionEventCallback_ != nullptr && extSessionEventCallback_->getStatusBarHeightFunc_ != nullptr) {
return extSessionEventCallback_->getStatusBarHeightFunc_();
}
return 0;
}
} // namespace OHOS::Rosen

View File

@ -823,7 +823,7 @@ void MoveDragController::InitDecorValue(const sptr<WindowSessionProperty> proper
bool isDialogWindow = WindowHelper::IsDialogWindow(windowType);
isDecorEnable_ = (isMainWindow || ((isSubWindow || isDialogWindow) && property->IsDecorEnable())) &&
sysConfig.isSystemDecorEnable_ &&
WindowHelper::IsWindowModeSupported(sysConfig.decorModeSupportInfo_, property->GetWindowMode());
WindowHelper::IsWindowModeSupported(sysConfig.decorWindowModeSupportType_, property->GetWindowMode());
}
void MoveDragController::ProcessSessionRectChange(SizeChangeReason reason)

View File

@ -14,6 +14,7 @@
*/
#include "session/host/include/pc_fold_screen_controller.h"
#include <parameters.h>
#include "display_manager.h"
#include "session/host/include/scene_session.h"
#include "window_manager_hilog.h"
@ -50,14 +51,14 @@ const WSRect RECT_ZERO = { 0, 0, 0, 0 };
WM_IMPLEMENT_SINGLE_INSTANCE(PcFoldScreenManager);
void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status,
void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status,
const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect)
{
SetDisplayInfo(displayId, status);
SetDisplayRects(defaultDisplayRect, virtualDisplayRect, foldCreaseRect);
}
void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status)
void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, SuperFoldStatus status)
{
std::unique_lock<std::shared_mutex> lock(displayInfoMutex_);
if (displayId_ == displayId && screenFoldStatus_ == status) {
@ -89,7 +90,7 @@ void PcFoldScreenManager::SetDisplayRects(
bool PcFoldScreenManager::IsHalfFolded(DisplayId displayId)
{
std::shared_lock<std::shared_mutex> lock(displayInfoMutex_);
return screenFoldStatus_ == ScreenFoldStatus::HALF_FOLDED && displayId_ == displayId;
return screenFoldStatus_ == SuperFoldStatus::HALF_FOLDED && displayId_ == displayId;
}
float PcFoldScreenManager::GetVpr()
@ -348,6 +349,13 @@ bool PcFoldScreenController::IsHalfFolded(DisplayId displayId)
return PcFoldScreenManager::GetInstance().IsHalfFolded(displayId);
}
bool PcFoldScreenController::NeedFollowHandAnimation()
{
static bool needFollowHandAnimation =
system::GetParameter("persist.window.throw_slip_follow_animation.enabled", "0") == "1";
return needFollowHandAnimation;
}
void PcFoldScreenController::RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen)
{
TLOGI(WmsLogTag::WMS_LAYOUT, "rect: %{public}s, isStartFullScreen: %{public}d",

View File

@ -199,6 +199,127 @@ WSError SceneSession::ReconnectInner(sptr<WindowSessionProperty> property)
return ret;
}
bool SceneSession::IsShowOnLockScreen(uint32_t lockScreenZorder)
{
TLOGD(WmsLogTag::WMS_UIEXT,
"UIExtOnLock: lockScreenZorder: %{public}d, zOrder_: %{public}d",
lockScreenZorder,
zOrder_);
// must be default screen
ScreenId defaultScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
auto sessionProperty = GetSessionProperty();
if (sessionProperty != nullptr && defaultScreenId != sessionProperty->GetDisplayId()) {
TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not default display");
return false;
}
if (!GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED)) {
TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in lock screen");
return false;
}
// current window on lock screen jurded by zorder
if (zOrder_ > lockScreenZorder) {
TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: zOrder_ is bigger");
return true;
}
return false;
}
void SceneSession::AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo)
{
{
std::lock_guard lock(extensionTokenInfosMutex_);
extensionTokenInfos_.push_back(tokenInfo);
}
TLOGI(WmsLogTag::WMS_UIEXT,
"UIExtOnLock: canShowOnLockScreen: %{public}u, persistentId: %{public}u",
tokenInfo.canShowOnLockScreen,
GetPersistentId());
}
void SceneSession::RemoveExtensionTokenInfo(sptr<IRemoteObject> abilityToken)
{
std::lock_guard lock(extensionTokenInfosMutex_);
auto persistentId = GetPersistentId();
auto itr = std::remove_if(
extensionTokenInfos_.begin(), extensionTokenInfos_.end(), [&abilityToken, persistentId](const auto &tokenInfo) {
TLOGI(WmsLogTag::WMS_UIEXT,
"UIExtOnLock: need remove, calling token: %{public}u, persistentId: %{public}u",
tokenInfo.callingTokenId,
persistentId);
return tokenInfo.abilityToken == abilityToken;
});
extensionTokenInfos_.erase(itr, extensionTokenInfos_.end());
}
void SceneSession::OnNotifyAboveLockScreen()
{
CheckExtensionOnLockScreenToClose();
}
void SceneSession::CheckExtensionOnLockScreenToClose()
{
TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: %{public}u", GetPersistentId());
// 1. check sub session
for (auto session : GetSubSession()) {
if (!session) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null");
continue;
}
session->CheckExtensionOnLockScreenToClose();
}
// 2. check self permission
std::vector<SceneSession::UIExtensionTokenInfo> tokenInfosToClose;
{
std::lock_guard lock(extensionTokenInfosMutex_);
for (auto &tokenInfo : extensionTokenInfos_) {
if (tokenInfo.canShowOnLockScreen) {
continue;
}
tokenInfosToClose.push_back(tokenInfo);
}
}
// 3. close ui extension without lock screen permisson
std::for_each(tokenInfosToClose.rbegin(),
tokenInfosToClose.rend(),
[this](SceneSession::UIExtensionTokenInfo &tokenInfo) { CloseExtensionSync(tokenInfo); });
}
void SceneSession::CloseExtensionSync(const SceneSession::UIExtensionTokenInfo &tokenInfo)
{
TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock");
// hide sub window
auto subSceneSessions = GetSubSession();
for (auto session : subSceneSessions) {
if (!session) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null");
continue;
}
// hide sub window of ui extension
if (session->GetAbilityToken() == tokenInfo.abilityToken) {
TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: hide sub window %{public}u", session->GetWindowId());
session->HideSync();
}
}
TLOGI(WmsLogTag::WMS_UIEXT,
"UIExtOnLock: close ui extension, callerToken: %{public}u, persistent id %{public}u",
tokenInfo.callingTokenId,
GetPersistentId());
// kill ui extension ability
AAFwk::AbilityManagerClient::GetInstance()->CloseUIExtensionAbilityBySCB(tokenInfo.abilityToken);
}
WSError SceneSession::Foreground(
sptr<WindowSessionProperty> property, bool isFromClient, const std::string& identityToken)
{
@ -724,16 +845,13 @@ void SceneSession::RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimat
auto task = [weakThis = wptr(this), callback = std::move(callback)] {
auto session = weakThis.promote();
if (!session) {
TLOGE(WmsLogTag::WMS_LIFE, "session is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
TLOGNE(WmsLogTag::WMS_LIFE, "session is null");
return;
}
if (session->sessionChangeCallback_) {
session->sessionChangeCallback_->onWindowAnimationFlagChange_ = std::move(callback);
session->sessionChangeCallback_->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation());
}
return WSError::WS_OK;
session->onWindowAnimationFlagChange_ = std::move(callback);
session->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation());
};
PostTask(task, "RegisterDefaultAnimationFlagChangeCallback");
PostTask(task, __func__);
}
void SceneSession::RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback)
@ -2127,6 +2245,20 @@ void SceneSession::NotifyOutsideDownEvent(const std::shared_ptr<MMI::PointerEven
WSError SceneSession::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
bool needNotifyClient)
{
auto task = [weakThis = wptr(this), pointerEvent, needNotifyClient] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::DEFAULT, "session is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
}
return session->TransferPointerEventInner(pointerEvent, needNotifyClient);
};
return PostSyncTask(std::move(task), __func__);
}
WSError SceneSession::TransferPointerEventInner(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
bool needNotifyClient)
{
WLOGFD("[WMSCom] TransferPointEvent, id: %{public}d, type: %{public}d, needNotifyClient: %{public}d",
GetPersistentId(), GetWindowType(), needNotifyClient);
@ -2224,7 +2356,7 @@ bool SceneSession::IsFullScreenMovable()
return false;
}
return property->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
WindowHelper::IsWindowModeSupported(property->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING);
WindowHelper::IsWindowModeSupported(property->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING);
}
bool SceneSession::IsMovable()
@ -2322,7 +2454,7 @@ bool SceneSession::IsDecorEnable() const
bool isValidWindow = isMainWindow ||
((isSubWindow || isDialogWindow) && property->IsDecorEnable());
bool isWindowModeSupported = WindowHelper::IsWindowModeSupported(
systemConfig_.decorModeSupportInfo_, property->GetWindowMode());
systemConfig_.decorWindowModeSupportType_, property->GetWindowMode());
bool enable = isValidWindow && systemConfig_.isSystemDecorEnable_ && isWindowModeSupported;
return enable;
}
@ -2525,10 +2657,15 @@ void SceneSession::InitializeCrossMoveDrag()
void SceneSession::HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, SizeChangeReason reason,
bool isGlobal, bool needFlush)
{
throwSlipFullScreenFlag_.store(false);
if (pcFoldScreenController_ && pcFoldScreenController_->IsHalfFolded(GetScreenId())) {
if (pcFoldScreenController_->NeedFollowHandAnimation()) {
auto movingPair = std::make_pair(pcFoldScreenController_->GetMovingTimingProtocol(),
pcFoldScreenController_->GetMovingTimingCurve());
SetSurfaceBoundsWithAnimation(movingPair, globalRect, nullptr, isGlobal, needFlush);
} else {
SetSurfaceBounds(globalRect, isGlobal, needFlush);
}
if (reason == SizeChangeReason::MOVE) {
pcFoldScreenController_->RecordMoveRects(rect);
}
@ -2612,6 +2749,14 @@ bool SceneSession::MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeR
TLOGNW(WmsLogTag::WMS_LAYOUT, "session is nullptr");
return;
}
if (!session->IsVisibleForeground()) {
TLOGNW(WmsLogTag::WMS_LAYOUT, "session go background when throw");
return;
}
if (!session->throwSlipFullScreenFlag_.load()) {
TLOGNW(WmsLogTag::WMS_LAYOUT, "session moved when throw");
return;
}
session->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE_WITHOUT_ANIMATION,
SessionEventParam {rect.posX_, rect.posY_, rect.width_, rect.height_});
};
@ -3149,28 +3294,47 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst)
}
}
void SceneSession::MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst");
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
if (leashWinSurfaceNode == nullptr && surfaceNode_ == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "leashWindow and surfaceNode are nullptr");
return;
}
if (leashWinSurfaceNode != nullptr) {
TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d",
leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForced, isUIFirstEnabled);
leashWinSurfaceNode->MarkUifirstNode(isForced, isUIFirstEnabled);
} else {
TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d",
surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForced, isUIFirstEnabled);
surfaceNode_->MarkUifirstNode(isForced, isUIFirstEnabled);
}
}
WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
{
auto task = [weakThis = wptr(this), needDefaultAnimationFlag]() {
auto task = [weakThis = wptr(this), needDefaultAnimationFlag] {
auto session = weakThis.promote();
if (!session) {
WLOGFE("session is null");
TLOGNE(WmsLogTag::WMS_LIFE, "session is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
}
session->needDefaultAnimationFlag_ = needDefaultAnimationFlag;
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onWindowAnimationFlagChange_) {
session->sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag);
if (session->onWindowAnimationFlagChange_) {
session->onWindowAnimationFlagChange_(needDefaultAnimationFlag);
}
return WSError::WS_OK;
};
return PostSyncTask(task, "UpdateWindowAnimationFlag");
return PostSyncTask(task, __func__);
}
void SceneSession::SetWindowAnimationFlag(bool needDefaultAnimationFlag)
{
needDefaultAnimationFlag_ = needDefaultAnimationFlag;
if (sessionChangeCallback_ && sessionChangeCallback_->onWindowAnimationFlagChange_) {
sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag);
if (onWindowAnimationFlagChange_) {
onWindowAnimationFlagChange_(needDefaultAnimationFlag);
}
return;
}
@ -3610,6 +3774,9 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr<AAFwk::Sess
info.isFoundationCall_ = isFoundationCall;
if (session->IsPcOrPadEnableActivation()) {
info.startWindowOption = abilitySessionInfo->startWindowOption;
info.supportWindowModes.assign(abilitySessionInfo->supportWindowModes.begin(),
abilitySessionInfo->supportWindowModes.end());
info.windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(info.supportWindowModes);
}
if (info.want != nullptr) {
info.windowMode = info.want->GetIntParam(AAFwk::Want::PARAM_RESV_WINDOW_MODE, 0);
@ -3622,11 +3789,13 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr<AAFwk::Sess
}
TLOGI(WmsLogTag::WMS_LIFE, "bundleName:%{public}s, moduleName:%{public}s, abilityName:%{public}s, "
"appIndex:%{public}d, affinity:%{public}s. callState:%{public}d, want persistentId:%{public}d, "
"uiAbilityId:%{public}" PRIu64 ", windowMode:%{public}d, callerId:%{public}d "
"needClearInNotShowRecent:%{public}u, appInstanceKey: %{public}s, isFromIcon:%{public}d",
"uiAbilityId:%{public}" PRIu64 ", windowMode:%{public}d, callerId:%{public}d, "
"needClearInNotShowRecent:%{public}u, appInstanceKey: %{public}s, isFromIcon:%{public}d, "
"supportWindowModes.size:%{public}zu, windowModeSupportType:%{public}u",
info.bundleName_.c_str(), info.moduleName_.c_str(), info.abilityName_.c_str(), info.appIndex_,
info.sessionAffinity.c_str(), info.callState_, info.persistentId_, info.uiAbilityId_, info.windowMode,
info.callerPersistentId_, info.needClearInNotShowRecent_, info.appInstanceKey_.c_str(), info.isFromIcon_);
info.callerPersistentId_, info.needClearInNotShowRecent_, info.appInstanceKey_.c_str(), info.isFromIcon_,
info.supportWindowModes.size(), info.windowModeSupportType);
return info;
}
@ -3915,7 +4084,7 @@ WMError SceneSession::ProcessUpdatePropertyByAction(const sptr<WindowSessionProp
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST):
return HandleActionUpdateMainWindowTopmost(property, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO):
return HandleActionUpdateModeSupportInfo(property, action);
return HandleActionUpdateWindowModeSupportType(property, action);
default:
TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!");
return WMError::WM_DO_NOTHING;
@ -4335,12 +4504,10 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr<AAFwk::SessionInfo>
session->sessionInfo_.errorReason = abilitySessionInfo->errorReason;
}
if (session->sessionExceptionFunc_) {
auto exceptionFunc = *(session->sessionExceptionFunc_);
exceptionFunc(info, needRemoveSession, false);
session->sessionExceptionFunc_(info, needRemoveSession, false);
}
if (session->jsSceneSessionExceptionFunc_) {
auto exceptionFunc = *(session->jsSceneSessionExceptionFunc_);
exceptionFunc(info, needRemoveSession, startFail);
session->jsSceneSessionExceptionFunc_(info, needRemoveSession, startFail);
}
return WSError::WS_OK;
};
@ -5061,6 +5228,7 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag)
TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null");
return;
}
session->SetClientDragEnable(enableDrag);
TLOGNI(WmsLogTag::WMS_LAYOUT, "id: %{public}d, enableDrag: %{public}d",
session->GetPersistentId(), enableDrag);
auto sessionProperty = session->GetSessionProperty();
@ -5077,17 +5245,17 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag)
return WMError::WM_OK;
}
WMError SceneSession::HandleActionUpdateModeSupportInfo(const sptr<WindowSessionProperty>& property,
WMError SceneSession::HandleActionUpdateWindowModeSupportType(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action)
{
if (!property->GetSystemCalling()) {
TLOGE(WmsLogTag::DEFAULT, "Update property modeSupportInfo permission denied!");
TLOGE(WmsLogTag::DEFAULT, "permission denied!");
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
auto sessionProperty = GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetModeSupportInfo(property->GetModeSupportInfo());
sessionProperty->SetWindowModeSupportType(property->GetWindowModeSupportType());
}
return WMError::WM_OK;
}
@ -5383,13 +5551,25 @@ void SceneSession::NotifyClientToUpdateAvoidArea()
}
}
bool SceneSession::IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY)
{
bool nearEqual = NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) &&
NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY) &&
NearEqual(clientScaleX_, scaleX) && NearEqual(clientScaleY_, scaleY) &&
NearEqual(clientPivotX_, pivotX) && NearEqual(clientPivotY_, pivotY);
return !nearEqual;
}
bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY)
{
if (NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) &&
NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY)) {
if (!IsTransformNeedChange(scaleX, scaleY, pivotX, pivotY)) {
return false;
}
Session::SetScale(scaleX, scaleY, pivotX, pivotY);
if (!IsSessionForeground()) {
TLOGD(WmsLogTag::WMS_LAYOUT, "id:%{public}d, session is not foreground!", GetPersistentId());
return false;
}
if (sessionStage_ != nullptr) {
Transform transform;
transform.scaleX_ = scaleX;
@ -5397,6 +5577,7 @@ bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, fl
transform.pivotX_ = pivotX;
transform.pivotY_ = pivotY;
sessionStage_->NotifyTransformChange(transform);
Session::SetClientScale(scaleX, scaleY, pivotX, pivotY);
} else {
WLOGFE("sessionStage is nullptr");
}
@ -5481,7 +5662,6 @@ void SceneSession::UnregisterSessionChangeListeners()
session->sessionChangeCallback_->onSessionTopmostChange_ = nullptr;
session->sessionChangeCallback_->onRaiseToTop_ = nullptr;
session->sessionChangeCallback_->OnSessionEvent_ = nullptr;
session->sessionChangeCallback_->onWindowAnimationFlagChange_ = nullptr;
session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr;
session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr;
}

View File

@ -121,7 +121,7 @@ void Session::PostTask(Task&& task, const std::string& name, int64_t delayTime)
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str());
return task();
}
auto localTask = [task = std::move(task), name]() {
auto localTask = [task = std::move(task), name] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str());
task();
};
@ -134,7 +134,7 @@ void Session::PostExportTask(Task&& task, const std::string& name, int64_t delay
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str());
return task();
}
auto localTask = [task = std::move(task), name]() {
auto localTask = [task = std::move(task), name] {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str());
task();
};
@ -471,6 +471,23 @@ void Session::NotifyTransferAccessibilityEvent(const Accessibility::Accessibilit
}
}
void Session::NotifyExtensionDetachToDisplay()
{
if (!SessionPermission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_UIEXT, "permission denied!");
return;
}
auto lifecycleListeners = GetListeners<ILifecycleListener>();
for (auto &listener : lifecycleListeners) {
if (auto listenerPtr = listener.lock()) {
listenerPtr->OnExtensionDetachToDisplay();
}
}
TLOGI(WmsLogTag::WMS_UIEXT, "called");
}
float Session::GetAspectRatio() const
{
return aspectRatio_;
@ -1071,6 +1088,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>&
property->SetWindowRect(rect);
property->SetPersistentId(GetPersistentId());
property->SetFullScreenStart(GetSessionInfo().fullScreenStart_);
property->SetWindowModeSupportType(GetSessionInfo().windowModeSupportType);
}
if (sessionProperty && property) {
property->SetRequestedOrientation(sessionProperty->GetRequestedOrientation());
@ -1089,7 +1107,10 @@ void Session::InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>&
property->SetCompatibleWindowSizeInPc(sessionProperty->GetCompatibleInPcPortraitWidth(),
sessionProperty->GetCompatibleInPcPortraitHeight(), sessionProperty->GetCompatibleInPcLandscapeWidth(),
sessionProperty->GetCompatibleInPcLandscapeHeight());
property->SetDragEnabled(sessionProperty->GetDragEnabled());
std::optional<bool> clientDragEnable = GetClientDragEnable();
if (clientDragEnable.has_value()) {
property->SetDragEnabled(clientDragEnable.value());
}
}
if (sessionProperty && SessionHelper::IsMainWindow(GetWindowType())) {
property->SetIsPcAppInPad(sessionProperty->GetIsPcAppInPad());
@ -1368,6 +1389,16 @@ void Session::SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFu
PostTask(task, __func__);
}
void Session::SetClientDragEnable(bool dragEnable)
{
clientDragEnable_ = dragEnable;
}
std::optional<bool> Session::GetClientDragEnable() const
{
return clientDragEnable_;
}
void Session::NotifyForegroundInteractiveStatus(bool interactive)
{
SetForegroundInteractiveStatus(interactive);
@ -1469,19 +1500,46 @@ void Session::SetChangeSessionVisibilityWithStatusBarEventListener(
changeSessionVisibilityWithStatusBarFunc_ = func;
}
void Session::SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func)
void Session::SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func)
{
pendingSessionActivationFunc_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->pendingSessionActivationFunc_ = std::move(func);
};
PostTask(task, where);
}
void Session::SetBackPressedListenser(const NotifyBackPressedFunc& func)
void Session::SetBackPressedListenser(NotifyBackPressedFunc&& func)
{
backPressedFunc_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->backPressedFunc_ = std::move(func);
};
PostTask(task, where);
}
void Session::SetTerminateSessionListener(const NotifyTerminateSessionFunc& func)
void Session::SetTerminateSessionListener(NotifyTerminateSessionFunc&& func)
{
terminateSessionFunc_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->terminateSessionFunc_ = std::move(func);
};
PostTask(task, where);
}
void Session::RemoveLifeCycleTask(const LifeCycleTaskType& taskType)
@ -1585,9 +1643,18 @@ WSError Session::TerminateSessionNew(
return WSError::WS_OK;
}
void Session::SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func)
void Session::SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func)
{
terminateSessionFuncNew_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->terminateSessionFuncNew_ = std::move(func);
};
PostTask(task, where);
}
WSError Session::TerminateSessionTotal(const sptr<AAFwk::SessionInfo> abilitySessionInfo, TerminateType terminateType)
@ -1617,9 +1684,18 @@ WSError Session::TerminateSessionTotal(const sptr<AAFwk::SessionInfo> abilitySes
return WSError::WS_OK;
}
void Session::SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func)
void Session::SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func)
{
terminateSessionFuncTotal_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->terminateSessionFuncTotal_ = std::move(func);
};
PostTask(task, where);
}
WSError Session::SetSessionLabel(const std::string& label)
@ -1675,18 +1751,22 @@ WSError Session::Clear(bool needStartCaller)
return WSError::WS_OK;
}
void Session::SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene)
void Session::SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene)
{
if (func == nullptr) {
WLOGFE("func is nullptr");
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where, fromJsScene] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
std::shared_ptr<NotifySessionExceptionFunc> funcSptr = std::make_shared<NotifySessionExceptionFunc>(func);
if (fromJsScene) {
jsSceneSessionExceptionFunc_ = funcSptr;
session->jsSceneSessionExceptionFunc_ = std::move(func);
} else {
sessionExceptionFunc_ = funcSptr;
session->sessionExceptionFunc_ = std::move(func);
}
};
PostTask(task, where);
}
void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func)
@ -1698,9 +1778,18 @@ void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func)
notifySessionSnapshotFunc_ = func;
}
void Session::SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func)
void Session::SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func)
{
pendingSessionToForegroundFunc_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->pendingSessionToForegroundFunc_ = std::move(func);
};
PostTask(task, where);
}
WSError Session::PendingSessionToForeground()
@ -1714,9 +1803,18 @@ WSError Session::PendingSessionToForeground()
}
void Session::SetPendingSessionToBackgroundForDelegatorListener(
const NotifyPendingSessionToBackgroundForDelegatorFunc& func)
NotifyPendingSessionToBackgroundForDelegatorFunc&& func)
{
pendingSessionToBackgroundForDelegatorFunc_ = func;
const char* const where = __func__;
auto task = [weakThis = wptr(this), func = std::move(func), where] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where);
return;
}
session->pendingSessionToBackgroundForDelegatorFunc_ = std::move(func);
};
PostTask(task, where);
}
WSError Session::PendingSessionToBackgroundForDelegator(bool shouldBackToCaller)
@ -3250,6 +3348,16 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY)
pivotY_ = pivotY;
}
void Session::SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY)
{
TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, preScaleX:%{public}f, preScaleY:%{public}f, "
"newScaleX:%{public}f, newScaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY);
clientScaleX_ = scaleX;
clientScaleY_ = scaleY;
clientPivotX_ = pivotX;
clientPivotY_ = pivotY;
}
float Session::GetScaleX() const
{
return scaleX_;

View File

@ -69,6 +69,16 @@ WSError SubSession::Show(sptr<WindowSessionProperty> property)
}
WSError SubSession::Hide()
{
return Hide(false); // async mode
}
WSError SubSession::HideSync()
{
return Hide(true); // sync mode
}
WSError SubSession::Hide(bool needSyncHide)
{
if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) {
return WSError::WS_ERROR_NOT_SYSTEM_APP;
@ -95,7 +105,12 @@ WSError SubSession::Hide()
ret = session->SceneSession::Background();
return ret;
};
PostTask(task, "Hide");
if (needSyncHide) {
return PostSyncTask(task, "HideSync");
}
PostTask(task, "HideAsync");
return WSError::WS_OK;
}

View File

@ -299,6 +299,7 @@ WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const spt
}
property->SetCollaboratorType(reply.ReadInt32());
property->SetFullScreenStart(reply.ReadBool());
property->SetWindowModeSupportType(reply.ReadUint32());
property->SetCompatibleModeInPc(reply.ReadBool());
property->SetCompatibleWindowSizeInPc(reply.ReadInt32(), reply.ReadInt32(),
reply.ReadInt32(), reply.ReadInt32());
@ -484,6 +485,21 @@ WSError SessionProxy::PendingSessionActivation(sptr<AAFwk::SessionInfo> abilityS
return WSError::WS_ERROR_IPC_FAILED;
}
}
auto size = abilitySessionInfo->supportWindowModes.size();
if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
if (!data.WriteUint32(static_cast<uint32_t>(size))) {
return WSError::WS_ERROR_IPC_FAILED;
}
for (decltype(size) i = 0; i < size; i++) {
if (!data.WriteInt32(static_cast<int32_t>(abilitySessionInfo->supportWindowModes[i]))) {
return WSError::WS_ERROR_IPC_FAILED;
}
}
} else {
if (!data.WriteUint32(0)) {
return WSError::WS_ERROR_IPC_FAILED;
}
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("remote is null");
@ -1997,6 +2013,27 @@ void SessionProxy::NotifyExtensionEventAsync(uint32_t notifyEvent)
}
}
void SessionProxy::NotifyExtensionDetachToDisplay()
{
TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: UIExtcalled");
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: WriteInterfaceToken failed");
return;
}
sptr<IRemoteObject> remote = Remote();
auto ret = remote->SendRequest(
static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY), data, reply, option);
if (ret != ERR_NONE) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: SendRequest failed");
}
}
WMError SessionProxy::SetGestureBackEnabled(bool isEnabled)
{
MessageParcel data;

View File

@ -222,6 +222,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag
return HandleMainSessionModalTypeChange(data, reply);
case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_RECT_AUTO_SAVE):
return HandleSetWindowRectAutoSave(data, reply);
case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY):
return HandleNotifyExtensionDetachToDisplay(data, reply);
default:
WLOGFE("Failed to find function handler!");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@ -375,6 +377,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply)
reply.WriteUint32(winRect.height_);
reply.WriteInt32(property->GetCollaboratorType());
reply.WriteBool(property->GetFullScreenStart());
reply.WriteUint32(property->GetWindowModeSupportType());
reply.WriteBool(property->GetCompatibleModeInPc());
reply.WriteInt32(property->GetCompatibleInPcPortraitWidth());
reply.WriteInt32(property->GetCompatibleInPcPortraitHeight());
@ -654,6 +657,14 @@ int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParc
auto startWindowOption = data.ReadParcelable<AAFwk::StartWindowOption>();
abilitySessionInfo->startWindowOption.reset(startWindowOption);
}
uint32_t size = data.ReadUint32();
if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
abilitySessionInfo->supportWindowModes.reserve(size);
for (uint32_t i = 0; i < size; i++) {
abilitySessionInfo->supportWindowModes.push_back(
static_cast<AppExecFwk::SupportWindowMode>(data.ReadInt32()));
}
}
WSError errCode = PendingSessionActivation(abilitySessionInfo);
reply.WriteUint32(static_cast<uint32_t>(errCode));
return ERR_NONE;
@ -1202,6 +1213,13 @@ int SessionStub::HandleSetDialogSessionBackGestureEnabled(MessageParcel& data, M
return ERR_NONE;
}
int SessionStub::HandleNotifyExtensionDetachToDisplay(MessageParcel &data, MessageParcel &reply)
{
TLOGD(WmsLogTag::WMS_UIEXT, "in");
NotifyExtensionDetachToDisplay();
return ERR_NONE;
}
int SessionStub::HandleRequestFocus(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::WMS_FOCUS, "in");

View File

@ -119,6 +119,9 @@ public:
void SetPhysicalRotation(float rotation);
float GetPhysicalRotation() const;
void SetScreenComponentRotation(float rotation);
float GetScreenComponentRotation() const;
float GetXDpi() const;
float GetYDpi() const;
@ -160,6 +163,7 @@ private:
}
float rotation_ { 0.0f };
float physicalRotation_ { 0.0f };
float screenComponentRotation_ { 0.0f };
RRect bounds_;
RRect phyBounds_;
RRect fakeBounds_;

View File

@ -251,6 +251,7 @@ public:
MirrorScreenType GetMirrorScreenType();
Rotation ConvertIntToRotation(int rotation);
void SetPhysicalRotation(int rotation, FoldStatus foldStatus);
void SetScreenComponentRotation(int rotation);
void SetStartPosition(uint32_t startX, uint32_t startY);
void SetMirrorScreenRegion(ScreenId screenId, DMRect screenRegion);
std::pair<ScreenId, DMRect> GetMirrorScreenRegion();

View File

@ -47,6 +47,16 @@ float ScreenProperty::GetPhysicalRotation() const
return physicalRotation_;
}
void ScreenProperty::SetScreenComponentRotation(float rotation)
{
screenComponentRotation_ = rotation;
}
float ScreenProperty::GetScreenComponentRotation() const
{
return screenComponentRotation_;
}
void ScreenProperty::SetBounds(const RRect& bounds)
{
bounds_ = bounds;

View File

@ -688,6 +688,12 @@ void ScreenSession::SetPhysicalRotation(int rotation, FoldStatus foldStatus)
property_.GetPhysicalRotation(), rotation, offsetRotation);
}
void ScreenSession::SetScreenComponentRotation(int rotation)
{
property_.SetScreenComponentRotation(static_cast<float>(rotation));
WLOGFI("screenComponentRotation :%{public}f ", property_.GetScreenComponentRotation());
}
void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode)
{
Rotation targetRotation = ConvertIntToRotation(rotation);

View File

@ -174,7 +174,7 @@ public:
sptr<SceneSession> GetSceneSession(int32_t persistentId);
sptr<SceneSession> GetMainParentSceneSession(int32_t persistentId,
const std::map<int32_t, sptr<SceneSession>>& sessionMap);
void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string taskName, const int delayTime);
void PostFlushWindowInfoTask(FlushWindowInfoTask&& task, const std::string& taskName, const int delayTime);
sptr<SceneSession> GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info);
sptr<SceneSession> GetSceneSessionByType(WindowType type);
@ -352,7 +352,6 @@ public:
void UpdateRecoveredSessionInfo(const std::vector<int32_t>& recoveredPersistentIds);
void SetAlivePersistentIds(const std::vector<int32_t>& alivePersistentIds);
void NotifyRecoveringFinished();
WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
void GetSceneSessionPrivacyModeBundles(DisplayId displayId, std::unordered_set<std::string>& privacyBundles);
BrokerStates CheckIfReuseSession(SessionInfo& sessionInfo);
@ -388,7 +387,6 @@ public:
WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override;
void DealwithVisibilityChange(const std::vector<std::pair<uint64_t, WindowVisibilityState>>& visibilityChangeInfos,
const std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData);
void DealwithDrawingContentChange(const std::vector<std::pair<uint64_t, bool>>& drawingChangeInfos);
void NotifyUpdateRectAfterLayout();
void FlushUIParams(ScreenId screenId, std::unordered_map<int32_t, SessionUIParam>&& uiParams);
WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override;
@ -404,6 +402,16 @@ public:
int32_t StartUIAbilityBySCB(sptr<AAFwk::SessionInfo>& abilitySessionInfo);
int32_t StartUIAbilityBySCB(sptr<SceneSession>& sceneSessions);
int32_t ChangeUIAbilityVisibilityBySCB(sptr<SceneSession>& sceneSessions, bool visibility);
/*
* UIExtension
*/
uint32_t GetLockScreenZorder();
WMError CheckUIExtensionCreation(int32_t windowId,
uint32_t tokenId,
const AppExecFwk::ElementName& element,
int32_t& pid);
void OnNotifyAboveLockScreen(const std::vector<int32_t>& windowIds);
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId) override;
void RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
@ -430,6 +438,12 @@ public:
int32_t GetCustomDecorHeight(int32_t persistentId);
/**
* Window Property
*/
WMError ReleaseForegroundSessionScreenLock() override;
void DealwithDrawingContentChange(const std::vector<std::pair<uint64_t, bool>>& drawingContentChangeInfo);
/**
* Free Multi Window
*/
@ -491,11 +505,6 @@ public:
std::string GetLastInstanceKey(const std::string& bundleName);
void RefreshAppInfo(const std::string& bundleName);
/**
* Window Property
*/
WMError ReleaseForegroundSessionScreenLock() override;
/**
* PiP Window
*/
@ -674,8 +683,6 @@ private:
const sptr<SceneSession>& sceneSession);
std::vector<std::pair<uint64_t, WindowVisibilityState>> GetWindowVisibilityChangeInfo(
std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData);
std::vector<std::pair<uint64_t, bool>> GetWindowDrawingContentChangeInfo(
std::vector<std::pair<uint64_t, bool>> currDrawingContentData);
void GetWindowLayerChangeInfo(std::shared_ptr<RSOcclusionData> occlusionData,
std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData,
std::vector<std::pair<uint64_t, bool>>& currDrawingContentData);
@ -686,6 +693,17 @@ private:
void RegisterSessionSnapshotFunc(const sptr<SceneSession>& sceneSession);
void ResetWantInfo(const sptr<SceneSession>& sceneSession);
/**
* Window Property
*/
std::vector<std::pair<uint64_t, bool>> GetWindowDrawingContentChangeInfo(
const std::vector<std::pair<uint64_t, bool>>& currDrawingContentData);
bool GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid);
bool GetProcessDrawingState(uint64_t surfaceId, int32_t pid);
void UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid);
bool GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid);
void RemoveSpecifiedDrawingData(uint64_t surfaceId);
/**
* Window Rotate Animation
*/
@ -921,8 +939,6 @@ private:
sptr<WindowSessionProperty> property, const WindowType& type);
sptr<SceneSession> CreateSceneSession(const SessionInfo& sessionInfo, sptr<WindowSessionProperty> property);
void CreateKeyboardPanelSession(sptr<SceneSession> keyboardSession);
bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState);
bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState);
void ClearSpecificSessionRemoteObjectMap(int32_t persistentId);
WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId);
WSError GetAppMainSceneSession(sptr<SceneSession>& sceneSession, int32_t persistentId);
@ -979,7 +995,7 @@ private:
std::unordered_set<int32_t> snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread
std::unordered_set<std::string> snapshotSkipBundleNameSet_ GUARDED_BY(SCENE_GUARD);
int32_t sessionMapDirty_ { 0 };
uint32_t sessionMapDirty_ { 0 };
std::condition_variable nextFlushCompletedCV_;
std::mutex nextFlushCompletedMutex_;
RootSceneProcessBackEventFunc rootSceneProcessBackEventFunc_ = nullptr;
@ -1039,6 +1055,15 @@ private:
};
std::unordered_map<SessionInfoList, std::shared_ptr<AppExecFwk::AbilityInfo>, SessionHasher> abilityInfoMap_;
/**
* Window Property
*/
struct DrawingSessionInfo {
int32_t pid_ = 0;
int32_t uid_ = 0;
};
std::unordered_map<uint64_t, DrawingSessionInfo> lastDrawingSessionInfoMap_;
/**
* PC Window
*/

View File

@ -58,6 +58,8 @@ public:
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
WMError CheckUIExtensionCreation(
int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override;
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode);
WMError GetWindowModeType(WindowModeType& windowModeType) override;

View File

@ -81,6 +81,7 @@ public:
TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO,
TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID,
TRANS_ID_GET_ROOT_MAIN_WINDOW_ID,
TRANS_ID_UI_EXTENSION_CREATION_CHECK,
};
virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;

View File

@ -69,6 +69,8 @@ public:
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
WMError CheckUIExtensionCreation(
int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override;
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
WMError GetWindowModeType(WindowModeType& windowModeType) override;
WMError GetMainWindowInfos(int32_t topNum, std::vector<MainWindowInfo>& topNInfo) override;

View File

@ -59,6 +59,7 @@ private:
int HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply);
int HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply);
int HandleCheckWindowId(MessageParcel& data, MessageParcel& reply);
int HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply);
int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply);
int HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply);
int HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply);

View File

@ -101,7 +101,8 @@ void HidumpController::DumpSessionParamList(std::ostringstream& oss)
<< std::endl
<< "callingPid callingUid isSystem reuse lockedState time type isSystemCalling topmost"
<< std::endl
<< "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode state modeSupportInfo animationFlag"
<< "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode "
<< "state windowModeSupportType animationFlag"
<< std::endl
<< "isFloatingAppType isNonSystemFloating forceHide isNeedUpdateMode "
<< "meedDefaultAnimationFlag shouldHideNonSecure forceHideState"
@ -130,7 +131,7 @@ void HidumpController::DumpSessionParam(
<< property->GetParentPersistentId() << "|"
<< static_cast<uint32_t>(property->GetWindowMode()) << "|"
<< static_cast<uint32_t>(property->GetWindowState()) << "|"
<< property->GetModeSupportInfo() << "|"
<< property->GetWindowModeSupportType() << "|"
<< property->GetAnimationFlag() << "|"
<< std::endl
<< property->IsFloatingWindowAppType() << "|"
@ -343,7 +344,7 @@ void HidumpController::DumpSysconfigParamList(std::ostringstream& oss)
{
oss << "Sysconfig:"
<< std::endl
<< "isSystemDecorEnable decorModeSupportInfo isStretchable defaultWindowMode "
<< "isSystemDecorEnable decorWindowModeSupportType isStretchable defaultWindowMode "
<< "keyboardAnimationConfig maxFloatingWindowSize windowUIType"
<< std::endl
<< "miniWidthOfMainWindow miniHeightOfMainWindow miniWidthOfSubWindow miniHeightOfSubWindow backgroundswitch "
@ -358,7 +359,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr<SceneSes
oss << "Sysconfig:"
<< std::endl
<< systemConfig.isSystemDecorEnable_ << "|"
<< systemConfig.decorModeSupportInfo_ << "|"
<< systemConfig.decorWindowModeSupportType_ << "|"
<< systemConfig.isStretchable_ << "|"
<< static_cast<uint32_t>(systemConfig.defaultWindowMode_) << "|"
<< "[" << systemConfig.animationIn_.curveType_ << " "
@ -377,7 +378,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr<SceneSes
<< systemConfig.freeMultiWindowSupport_ << "|"
<< systemConfig.supportTypeFloatWindow_ << "|"
<< "[" << freeMultiWindowConfig.isSystemDecorEnable_ << " "
<< freeMultiWindowConfig.decorModeSupportInfo_ << " "
<< freeMultiWindowConfig.decorWindowModeSupportType_ << " "
<< static_cast<uint32_t>(freeMultiWindowConfig.defaultWindowMode_) << " "
<< freeMultiWindowConfig.maxMainFloatingWindowNumber_<< "]|"
<< std::endl;

File diff suppressed because it is too large Load Diff

View File

@ -190,6 +190,12 @@ WMError SceneSessionManagerLite::CheckWindowId(int32_t windowId, int32_t& pid)
return SceneSessionManager::GetInstance().CheckWindowId(windowId, pid);
}
WMError SceneSessionManagerLite::CheckUIExtensionCreation(
int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid)
{
return SceneSessionManager::GetInstance().CheckUIExtensionCreation(windowId, tokenId, element, pid);
}
WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
{
return SceneSessionManager::GetInstance().GetVisibilityWindowInfo(infos);

View File

@ -890,6 +890,59 @@ WMError SceneSessionManagerLiteProxy::CheckWindowId(int32_t windowId, int32_t& p
return WMError::WM_OK;
}
WMError SceneSessionManagerLiteProxy::CheckUIExtensionCreation(
int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write interfaceToken");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(windowId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write windowId");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(tokenId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId");
return WMError::WM_ERROR_IPC_FAILED;
}
data.WriteParcelable(&element);
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId");
return WMError::WM_ERROR_NULLPTR;
}
int32_t ret =
remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK),
data,
reply,
option);
if (ret != ERR_NONE) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Send request failed, ret:%{public}d", ret);
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t errCode = 0;
if (!reply.ReadInt32(errCode)) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read errcode");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!reply.ReadInt32(pid)) {
TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read pid");
return WMError::WM_ERROR_IPC_FAILED;
}
TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: errcode %{public}u", errCode);
return static_cast<WMError>(errCode);
}
WMError SceneSessionManagerLiteProxy::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
{
MessageParcel data;

Some files were not shown because too many files have changed in this diff Show More