代码整改,错误码整改

Signed-off-by: kuangmei <kuangmei1@huawei.com>
This commit is contained in:
kuangmei 2024-10-18 16:40:07 +08:00
parent 5f094d6bbb
commit 3df1a1510a
21 changed files with 243 additions and 184 deletions

View File

@ -1198,10 +1198,10 @@ enum class CaseType {
};
enum class MaximizePresentation {
FOLLOW_APP_IMMERSIVE_SETTING = 0, // follow app set imersiveStateEnable
EXIT_IMMERSIVE = 1, // imersiveStateEnable will be set as false
ENTER_IMMERSIVE = 2, // imersiveStateEnable will be set as true
// imersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
FOLLOW_APP_IMMERSIVE_SETTING = 0, // follow app set immersiveStateEnable
EXIT_IMMERSIVE = 1, // immersiveStateEnable will be set as false
ENTER_IMMERSIVE = 2, // immersiveStateEnable will be set as true
// immersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER = 3,
};

View File

@ -319,7 +319,7 @@ napi_value JsWindow::SetLayoutFullScreen(napi_env env, napi_callback_info info)
napi_value JsWindow::SetTitleAndDockHoverShown(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI] call");
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
return (me != nullptr) ? me->OnSetTitleAndDockHoverShown(env, info) : nullptr;
}
@ -1378,11 +1378,9 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info)
napi_value JsWindow::OnRestore(napi_env env, napi_callback_info info)
{
wptr<Window> weakToken(windowToken_);
NapiAsyncTask::CompleteCallback complete =
[weakToken](napi_env env, NapiAsyncTask& task, int32_t status) {
auto weakWindow = weakToken.promote();
if (weakWindow == nullptr) {
[weakToken = windowToken_](napi_env env, NapiAsyncTask& task, int32_t status) {
if (weakToken == nullptr) {
TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param");
task.Reject(env,
JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
@ -1394,18 +1392,18 @@ napi_value JsWindow::OnRestore(napi_env env, napi_callback_info info)
JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_CALLING));
return ;
}
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->Restore());
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakToken->Restore());
if (ret == WmErrorCode::WM_OK) {
task.Resolve(env, NapiGetUndefined(env));
} else {
task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window restore failed"));
}
};
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);
napi_value lastParam = (argc == 0) ? nullptr :
(argv[0] != nullptr && GetType(env, argv[0]) == napi_function ? argv[0] : nullptr);
(argv[INDEX_ZERO] != nullptr && GetType(env, argv[INDEX_ZERO]) == napi_function ? argv[INDEX_ZERO] : nullptr);
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::OnRestore",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
@ -2507,18 +2505,18 @@ napi_value JsWindow::OnSetLayoutFullScreen(napi_env env, napi_callback_info info
napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_info info)
{
size_t argc = 4; // 4: arg numer
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 > 2) { // 2: maximum params num
TLOGE(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc);
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
bool isTitleHoverShown = true;
bool isDockHoverShown = true;
if (argc > 0 && !ConvertFromJsValue(env, argv[INDEX_ZERO], isTitleHoverShown)) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isTitleHoverShown parameter");
}
bool isDockHoverShown = true;
if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter");
}
@ -2540,8 +2538,8 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf
} else {
task.Resolve(env, NapiGetUndefined(env));
}
TLOGNI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] [%{public}d, %{public}d]",
windowToken->GetWindowId(), windowToken->GetWindowName().c_str(),
TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]",
funcName, windowToken->GetWindowId(), windowToken->GetWindowName().c_str(),
isTitleHoverShown, isDockHoverShown);
};
napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[2]) == napi_function ? argv[2] : nullptr);

View File

@ -788,10 +788,10 @@ struct KeyboardAnimationConfig {
};
enum class MaximizePresentation {
FOLLOW_APP_IMMERSIVE_SETTING = 0, // follow app set imersiveStateEnable
EXIT_IMMERSIVE = 1, // imersiveStateEnable will be set as false
ENTER_IMMERSIVE = 2, // imersiveStateEnable will be set as true
// imersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
FOLLOW_APP_IMMERSIVE_SETTING = 0, // follow app set immersiveStateEnable
EXIT_IMMERSIVE = 1, // immersiveStateEnable will be set as false
ENTER_IMMERSIVE = 2, // immersiveStateEnable will be set as true
// immersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER = 3,
};

View File

@ -69,8 +69,8 @@ const std::string CONTEXT_TRANSPARENT_CB = "contextTransparent";
const std::string KEYBOARD_GRAVITY_CHANGE_CB = "keyboardGravityChange";
const std::string ADJUST_KEYBOARD_LAYOUT_CB = "adjustKeyboardLayout";
const std::string LAYOUT_FULL_SCREEN_CB = "layoutFullScreenChange";
const std::string RESTORE_MAIN_WINDOW_CB = "restoreMainWindow";
const std::string TITLE_DOCK_HOVER_SHOW_CB = "titleAndDockHoverShowChange";
const std::string RESTORE_MAIN_WINDOW_CB = "restoreMainWindow";
const std::string NEXT_FRAME_LAYOUT_FINISH_CB = "nextFrameLayoutFinish";
const std::string PRIVACY_MODE_CHANGE_CB = "privacyModeChange";
const std::string SESSION_MAIN_WINDOW_TOP_MOST_CHANGE_CB = "sessionMainWindowTopmostChange";
@ -671,6 +671,48 @@ void JsSceneSession::OnLayoutFullScreenChange(bool isLayoutFullScreen)
taskScheduler_->PostMainThreadTask(task, "OnLayoutFullScreenChange");
}
void JsSceneSession::ProcessTitleAndDockHoverShowChangeRegister()
{
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_IMMS, "session is nullptr, id:%{public}d", persistentId_);
return;
}
NotifyTitleAndDockHoverShowChangeFunc func = [weakThis = wptr(this)](
bool isTitleHoverShown, bool isDockHoverShown) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_IMMS, "jsSceneSession is null");
return;
}
jsSceneSession->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown);
};
session->SetTitleAndDockHoverShowChangeCallback(func);
TLOGI(WmsLogTag::WMS_IMMS, "Register success, persistent id %{public}d", persistentId_);
}
void JsSceneSession::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
{
auto task = [weakThis = wptr(this), persistentId = persistentId_, isTitleHoverShown, isDockHoverShown, env = env_] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
TLOGNE(WmsLogTag::WMS_IMMS, "jsSceneSession id:%{public}d has been destroyed",
persistentId);
return;
}
auto jsCallBack = jsSceneSession->GetJSCallback(TITLE_DOCK_HOVER_SHOW_CB);
if (!jsCallBack) {
TLOGNE(WmsLogTag::WMS_IMMS, "jsCallBack is nullptr");
return;
}
napi_value jsObjTitle = CreateJsValue(env, isTitleHoverShown);
napi_value jsObjDock = CreateJsValue(env, isDockHoverShown);
napi_value argv[] = {jsObjTitle, jsObjDock};
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
};
taskScheduler_->PostMainThreadTask(task, __func__);
}
void JsSceneSession::ProcessRestoreMainWindowRegister()
{
auto session = weakSession_.promote();
@ -678,10 +720,10 @@ void JsSceneSession::ProcessRestoreMainWindowRegister()
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_);
return;
}
NotifyRestoreMainWindowFunc func = [weakThis = wptr(this)]() {
NotifyRestoreMainWindowFunc func = [weakThis = wptr(this)] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGNE(WmsLogTag::WMS_LIFE, "ProcessRestoreMainWindowRegister jsSceneSession is null");
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", __func__);
return;
}
jsSceneSession->RestoreMainWindow();
@ -692,63 +734,22 @@ void JsSceneSession::ProcessRestoreMainWindowRegister()
void JsSceneSession::RestoreMainWindow()
{
auto task = [weakThis = wptr(this), persistentId = persistentId_, env = env_] {
const char* const funcName = __func__;
auto task = [weakThis = wptr(this), persistentId = persistentId_, env = env_, funcName] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
TLOGNE(WmsLogTag::WMS_LIFE, "RestoreMainWindow jsSceneSession id:%{public}d has been destroyed",
persistentId);
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession id:%{public}d has been destroyed",
funcName, persistentId);
return;
}
auto jsCallBack = jsSceneSession->GetJSCallback(RESTORE_MAIN_WINDOW_CB);
if (!jsCallBack) {
TLOGNE(WmsLogTag::WMS_LIFE, "RestoreMainWindow jsCallBack is nullptr");
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsCallBack is nullptr", funcName);
return;
}
napi_value argv[] = {};
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), 0, argv, nullptr);
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), 0, {}, nullptr);
};
taskScheduler_->PostMainThreadTask(task, "OnRestoreMainWindow");
}
void JsSceneSession::ProcessTitleAndDockHoverShowChangeRegister()
{
auto sessionchangeCallback = sessionchangeCallback_.promote();
if (sessionchangeCallback == nullptr) {
TLOGE(WmsLogTag::WMS_IMMS, "sessionchangeCallback is nullptr");
return;
}
sessionchangeCallback->onTitleAndDockHoverShowChangeFunc_ = [weakThis = wptr(this)](
bool isTitleHoverShown, bool isDockHoverShown) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "jsSceneSession is null");
return;
}
jsSceneSession->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown);
};
TLOGI(WmsLogTag::WMS_IMMS, "Register success, persistent id %{public}d", persistentId_);
}
void JsSceneSession::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
{
auto task = [weakThis = wptr(this), persistentId = persistentId_, isTitleHoverShown, isDockHoverShown, env = env_] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession id:%{public}d has been destroyed",
persistentId);
return;
}
auto jsCallBack = jsSceneSession->GetJSCallback(TITLE_DOCK_HOVER_SHOW_CB);
if (!jsCallBack) {
TLOGNE(WmsLogTag::WMS_IMMS, "jsCallBack is nullptr");
return;
}
napi_value paramsObjTitle = CreateJsValue(env, isTitleHoverShown);
napi_value paramsObjDock = CreateJsValue(env, isDockHoverShown);
napi_value argv[] = {paramsObjTitle, paramsObjDock};
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
};
taskScheduler_->PostMainThreadTask(task, "OnTitleAndDockHoverShowChange");
taskScheduler_->PostMainThreadTask(task, funcName);
}
void JsSceneSession::OnAdjustKeyboardLayout(const KeyboardLayoutParams& params)

View File

@ -245,8 +245,8 @@ private:
void ProcessKeyboardGravityChangeRegister();
void ProcessAdjustKeyboardLayoutRegister();
void ProcessLayoutFullScreenChangeRegister();
void ProcessRestoreMainWindowRegister();
void ProcessTitleAndDockHoverShowChangeRegister();
void ProcessRestoreMainWindowRegister();
void ProcessFrameLayoutFinishRegister();
void ProcessRegisterCallback(ListenerFuncType listenerFuncType);
@ -299,8 +299,8 @@ private:
void OnKeyboardGravityChange(SessionGravity gravity);
void OnAdjustKeyboardLayout(const KeyboardLayoutParams& params);
void OnLayoutFullScreenChange(bool isLayoutFullScreen);
void RestoreMainWindow();
void OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, bool isDockHoverShown = true);
void RestoreMainWindow();
void NotifyFrameLayoutFinish();
void ProcessPrivacyModeChangeRegister();
void NotifyPrivacyModeChange(bool isPrivacyMode);

View File

@ -77,9 +77,9 @@ using NotifyKeyboardLayoutAdjustFunc = std::function<void(const KeyboardLayoutPa
using SessionChangeByActionNotifyManagerFunc = std::function<void(const sptr<SceneSession>& sceneSession,
const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)>;
using NotifyLayoutFullScreenChangeFunc = std::function<void(bool isLayoutFullScreen)>;
using NotifyRestoreMainWindowFunc = std::function<void()>;
using NotifyTitleAndDockHoverShowChangeFunc = std::function<void(bool isTitleHoverShown,
bool isDockHoverShown)>;
using NotifyRestoreMainWindowFunc = std::function<void()>;
using SetSkipSelfWhenShowOnVirtualScreenCallback = std::function<void(uint64_t surfaceNodeId, bool isSkip)>;
using NotifyForceSplitFunc = std::function<AppForceLandscapeConfig(const std::string& bundleName)>;
using UpdatePrivateStateAndNotifyFunc = std::function<void(int32_t persistentId)>;
@ -133,8 +133,6 @@ public:
NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_;
NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_;
NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_;
NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_;
NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_;
};
// func for change window scene pattern property
@ -290,6 +288,7 @@ public:
void SetSessionEventParam(SessionEventParam param);
void SetSessionRectChangeCallback(const NotifySessionRectChangeFunc& func);
void SetKeyboardGravityChangeCallback(const NotifyKeyboardGravityChangeFunc& func);
void SetTitleAndDockHoverShowChangeCallback(const NotifyTitleAndDockHoverShowChangeFunc& func);
void SetRestoreMainWindowCallback(const NotifyRestoreMainWindowFunc& func);
void SetAdjustKeyboardLayoutCallback(const NotifyKeyboardLayoutAdjustFunc& func);
void SetSkipDraw(bool skip);
@ -377,6 +376,7 @@ public:
*/
void ClearJsSceneSessionCbMap(bool needRemove); // ONLY Accessed on OS_sceneSession thread
void ClearSpecificSessionCbMap();
NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_;
void SendPointerEventToUI(std::shared_ptr<MMI::PointerEvent> pointerEvent);
bool SendKeyEventToUI(std::shared_ptr<MMI::KeyEvent> keyEvent, bool isPreImeEvent = false);
@ -658,6 +658,11 @@ private:
ExtensionWindowFlags combinedExtWindowFlags_ { 0 };
std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
/**
* Window Immersive
*/
NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_;
/*
* Window Decor
*/

View File

@ -77,13 +77,6 @@ public:
*/
virtual WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) { return WSError::WS_OK; }
/**
* @brief Callback for processing restore main window.
*
* @return Returns WSError::WS_OK if called success, otherwise failed.
*/
virtual WSError OnRestoreMainWindow() { return WSError::WS_OK; }
/**
* @brief Callback for processing title and dock hover show changes.
*
@ -97,6 +90,13 @@ public:
return WSError::WS_OK;
}
/**
* @brief Callback for processing restore main window.
*
* @return Returns WSError::WS_OK if called success, otherwise failed.
*/
virtual WSError OnRestoreMainWindow() { return WSError::WS_OK; }
/**
* @brief Raise the application subwindow to the top layer of the application.
*

View File

@ -68,8 +68,8 @@ enum class SessionInterfaceCode {
TRANS_ID_GET_START_MOVE_FLAG,
TRANS_ID_GET_ALL_AVOID_AREAS,
TRANS_ID_UPDATE_CLIENT_RECT,
TRANS_ID_RESTORE_MAIN_WINDOW,
TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE,
TRANS_ID_RESTORE_MAIN_WINDOW,
TRANS_ID_SET_GESTURE_BACK_ENABLE,
TRANS_ID_MODAL_TYPE_CHANGE,

View File

@ -48,9 +48,9 @@ public:
WSError OnSessionEvent(SessionEvent event) override;
WSError OnSystemSessionEvent(SessionEvent event) override;
WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override;
WSError OnRestoreMainWindow() override;
WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true,
bool isDockHoverShown = true) override;
WSError OnRestoreMainWindow() override;
WSError RaiseToAppTop() override;
WSError UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false) override;
WSError UpdateClientRect(const WSRect& rect) override;

View File

@ -73,8 +73,8 @@ private:
int HandleAdjustKeyboardLayout(MessageParcel& data, MessageParcel& reply);
int HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel& reply);
int HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel& reply);
int HandleRestoreMainWindow(MessageParcel& data, MessageParcel& reply);
int HandleTitleAndDockHoverShowChange(MessageParcel& data, MessageParcel& reply);
int HandleRestoreMainWindow(MessageParcel& data, MessageParcel& reply);
int HandleGetAppForceLandscapeConfig(MessageParcel& data, MessageParcel& reply);
int HandleGetStatusBarHeight(MessageParcel& data, MessageParcel& reply);
int HandleNotifyFrameLayoutFinish(MessageParcel& data, MessageParcel& reply);

View File

@ -238,18 +238,17 @@ void MainSession::NotifyClientToUpdateInteractive(bool interactive)
WSError MainSession::OnRestoreMainWindow()
{
auto task = [weakThis = wptr(this)]() {
auto task = [weakThis = wptr(this)] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_LIFE, "session is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
return;
}
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onRestoreMainWindowFunc_) {
session->sessionChangeCallback_->onRestoreMainWindowFunc_();
if (session->onRestoreMainWindowFunc_) {
session->onRestoreMainWindowFunc_();
}
return WSError::WS_OK;
};
PostTask(task, "OnRestoreMainWindow");
PostTask(task, __func__);
return WSError::WS_OK;
}

View File

@ -1046,22 +1046,36 @@ void SceneSession::SetKeyboardGravityChangeCallback(const NotifyKeyboardGravityC
PostTask(task, "SetKeyboardGravityChangeCallback");
}
void SceneSession::SetTitleAndDockHoverShowChangeCallback(const NotifyTitleAndDockHoverShowChangeFunc& func)
{
const char* const funcName = __func__;
auto task = [weakThis = wptr(this), func, funcName] {
auto session = weakThis.promote();
if (!session || !func) {
TLOGNE(WmsLogTag::WMS_IMMS, "session or TitleAndDockHoverShowChangeFunc is null");
return;
}
session->onTitleAndDockHoverShowChangeFunc_ = func;
TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s id: %{public}d",
funcName, session->GetPersistentId());
};
PostTask(task, funcName);
}
void SceneSession::SetRestoreMainWindowCallback(const NotifyRestoreMainWindowFunc& func)
{
auto task = [weakThis = wptr(this), func]() {
const char* const funcName = __func__;
auto task = [weakThis = wptr(this), func, funcName] {
auto session = weakThis.promote();
if (!session || !func) {
TLOGNE(WmsLogTag::WMS_LIFE, "session or RestoreMainWindowFunc is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
return;
}
if (session->sessionChangeCallback_) {
session->sessionChangeCallback_->onRestoreMainWindowFunc_ = func;
}
TLOGNI(WmsLogTag::WMS_LIFE, "RestoreMainWindow id: %{public}d",
session->GetPersistentId());
return WSError::WS_OK;
session->onRestoreMainWindowFunc_ = func;
TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s id: %{public}d",
funcName, session->GetPersistentId());
};
PostTask(task, "SetRestoreMainWindowCallback");
PostTask(task, funcName);
}
void SceneSession::SetAdjustKeyboardLayoutCallback(const NotifyKeyboardLayoutAdjustFunc& func)
@ -4582,21 +4596,19 @@ WSError SceneSession::OnLayoutFullScreenChange(bool isLayoutFullScreen)
WSError SceneSession::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
{
const char* const funcName = __func__;
auto task = [weakThis = wptr(this), isTitleHoverShown, isDockHoverShown, funcName]() {
auto task = [weakThis = wptr(this), isTitleHoverShown, isDockHoverShown, funcName] {
auto session = weakThis.promote();
if (!session) {
TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s session is null", funcName);
return WSError::WS_ERROR_DESTROYED_OBJECT;
return;
}
TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s isTitleHoverShown: %{public}d, isDockHoverShown: %{public}d", funcName,
isTitleHoverShown, isDockHoverShown);
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onTitleAndDockHoverShowChangeFunc_) {
session->sessionChangeCallback_->onTitleAndDockHoverShowChangeFunc_(
isTitleHoverShown, isDockHoverShown);
if (session->onTitleAndDockHoverShowChangeFunc_) {
session->onTitleAndDockHoverShowChangeFunc_(isTitleHoverShown, isDockHoverShown);
}
return WSError::WS_OK;
};
PostTask(task, "OnTitleAndDockHoverShowChange");
PostTask(task, funcName);
return WSError::WS_OK;
}
@ -5066,8 +5078,9 @@ void SceneSession::UnregisterSessionChangeListeners()
session->sessionChangeCallback_->onPrepareClosePiPSession_ = nullptr;
session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr;
session->sessionChangeCallback_->onLayoutFullScreenChangeFunc_ = nullptr;
session->sessionChangeCallback_->onRestoreMainWindowFunc_ = nullptr;
}
session->onTitleAndDockHoverShowChangeFunc_ = nullptr;
session->onRestoreMainWindowFunc_ = nullptr;
session->Session::UnregisterSessionChangeListeners();
};
PostTask(task, "UnregisterSessionChangeListeners");

View File

@ -648,29 +648,6 @@ WSError SessionProxy::OnLayoutFullScreenChange(bool isLayoutFullScreen)
return static_cast<WSError>(ret);
}
WSError SessionProxy::OnRestoreMainWindow()
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
return WSError::WS_ERROR_IPC_FAILED;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
return WSError::WS_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WSError>(ret);
}
WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
{
MessageParcel data;
@ -694,7 +671,30 @@ WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool
TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
int32_t ret = reply.ReadUint32();
return static_cast<WSError>(ret);
}
WSError SessionProxy::OnRestoreMainWindow()
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
return WSError::WS_ERROR_IPC_FAILED;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
return WSError::WS_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadUint32();
return static_cast<WSError>(ret);
}

View File

@ -432,23 +432,16 @@ int SessionStub::HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel
return ERR_NONE;
}
int SessionStub::HandleRestoreMainWindow(MessageParcel& data, MessageParcel& reply)
{
WSError errCode = OnRestoreMainWindow();
reply.WriteUint32(static_cast<uint32_t>(errCode));
return ERR_NONE;
}
int SessionStub::HandleTitleAndDockHoverShowChange(MessageParcel& data, MessageParcel& reply)
{
bool isTitleHoverShown = true;
if (!data.ReadBool(isTitleHoverShown)) {
TLOGE(WmsLogTag::WMS_LIFE, "Read isTitleHoverShown failed.");
TLOGE(WmsLogTag::WMS_IMMS, "Read isTitleHoverShown failed.");
return ERR_INVALID_DATA;
}
bool isDockHoverShown = true;
if (!data.ReadBool(isDockHoverShown)) {
TLOGE(WmsLogTag::WMS_LIFE, "Read isDockHoverShown failed.");
TLOGE(WmsLogTag::WMS_IMMS, "Read isDockHoverShown failed.");
return ERR_INVALID_DATA;
}
TLOGD(WmsLogTag::WMS_IMMS, "isTitleHoverShown: %{public}d, isDockHoverShown: %{public}d",
@ -458,6 +451,13 @@ int SessionStub::HandleTitleAndDockHoverShowChange(MessageParcel& data, MessageP
return ERR_NONE;
}
int SessionStub::HandleRestoreMainWindow(MessageParcel& data, MessageParcel& reply)
{
WSError errCode = OnRestoreMainWindow();
reply.WriteUint32(static_cast<uint32_t>(errCode));
return ERR_NONE;
}
int SessionStub::HandleTerminateSession(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::WMS_LIFE, "In");

View File

@ -382,16 +382,13 @@ HWTEST_F(MainSessionTest, OnRestoreMainWindow, Function | SmallTest | Level2)
EXPECT_NE(session, nullptr);
EXPECT_EQ(WSError::WS_OK, session->OnRestoreMainWindow());
sptr<SceneSession::SessionChangeCallback> sessionChangeCallback =
sptr<SceneSession::SessionChangeCallback>::MakeSptr();
session->RegisterSessionChangeCallback(sessionChangeCallback);
sessionChangeCallback->onRestoreMainWindowFunc_ = nullptr;
session->onRestoreMainWindowFunc_ = nullptr;
EXPECT_EQ(WSError::WS_OK, session->OnRestoreMainWindow());
NotifyRestoreMainWindowFunc func = []() {
return;
};
sessionChangeCallback->onRestoreMainWindowFunc_ = func;
session->onRestoreMainWindowFunc_ = func;
EXPECT_EQ(WSError::WS_OK, session->OnRestoreMainWindow());
}

View File

@ -1534,14 +1534,14 @@ HWTEST_F(SceneSessionTest, OnTitleAndDockHoverShowChange, Function | SmallTest |
SessionInfo info;
info.abilityName_ = "OnTitleAndDockHoverShowChange";
info.bundleName_ = "OnTitleAndDockHoverShowChange";
sptr<Rosen::ISession> session_;
sptr<SceneSession> scensession = sptr<MainSession>::MakeSptr(info, nullptr);
ASSERT_NE(scensession, nullptr);
sptr<Rosen::ISession> session;
sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
ASSERT_NE(sceneSession, nullptr);
sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
scensession->SetSessionProperty(property);
auto result = scensession->OnTitleAndDockHoverShowChange(true, true);
sceneSession->SetSessionProperty(property);
auto result = sceneSession->OnTitleAndDockHoverShowChange(true, true);
EXPECT_EQ(result, WSError::WS_OK);
}

View File

@ -2028,6 +2028,45 @@ HWTEST_F(SceneSessionTest2, SetWindowAnimationFlag, Function | SmallTest | Level
sceneSession->SetWindowAnimationFlag(true);
ASSERT_EQ(true, sceneSession->needDefaultAnimationFlag_);
}
/**
* @tc.name: SetTitleAndDockHoverShowChangeCallback
* @tc.desc: SetTitleAndDockHoverShowChangeCallback
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest2, SetTitleAndDockHoverShowChangeCallback, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "SetTitleAndDockHoverShowChangeCallback";
info.bundleName_ = "SetTitleAndDockHoverShowChangeCallback";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
NotifyTitleAndDockHoverShowChangeFunc func = [](bool isTitleHoverShown, bool isDockHoverShown) {
return WSError::WS_OK;
};
sceneSession->SetTitleAndDockHoverShowChangeCallback(func);
EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr);
}
/**
* @tc.name: OnTitleAndDockHoverShowChange
* @tc.desc: OnTitleAndDockHoverShowChange
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest2, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "OnTitleAndDockHoverShowChange";
info.bundleName_ = "OnTitleAndDockHoverShowChange";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
NotifyTitleAndDockHoverShowChangeFunc func = [](bool isTitleHoverShown, bool isDockHoverShown) {
return WSError::WS_OK;
};
sceneSession->SetTitleAndDockHoverShowChangeCallback(func);
EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr);
EXPECT_EQ(sceneSession->OnTitleAndDockHoverShowChange(true, true), WSError::WS_OK);
}
}
}
}

View File

@ -73,8 +73,10 @@ HWTEST_F(SessionProxyTest, UpdateSessionRect, Function | SmallTest | Level2)
HWTEST_F(SessionProxyTest, OnRestoreMainWindow, Function | SmallTest | Level2)
{
GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow start";
sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker);
auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
ASSERT_NE(iRemoteObjectMocker, nullptr);
auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker);
ASSERT_NE(sProxy, nullptr);
WSError res = sProxy->OnRestoreMainWindow();
ASSERT_EQ(res, WSError::WS_OK);
GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow end";
@ -424,8 +426,10 @@ HWTEST_F(SessionProxyTest, TransferAccessibilityEvent, Function | SmallTest | Le
HWTEST_F(SessionProxyTest, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2)
{
GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange start";
sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker);
auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
ASSERT_NE(iRemoteObjectMocker, nullptr);
auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker);
ASSERT_NE(sProxy, nullptr);
bool isTitleHoverShown = true;
bool isDockHoverShown = true;
WSError res = sProxy->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown);

View File

@ -62,10 +62,15 @@ public:
WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) override;
SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override;
WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override;
/**
* Window Immersive
*/
WMError SetLayoutFullScreen(bool status) override;
WMError SetTitleAndDockHoverShown(bool isTitleHoverShown = true,
bool isDockHoverShown = true) override;
WMError SetFullScreen(bool status) override;
WMError BindDialogTarget(sptr<IRemoteObject> targetToken) override;
WMError SetDialogBackGestureEnabled(bool isEnabled) override;
WMError GetWindowLimits(WindowLimits& windowLimits) override;

View File

@ -1924,8 +1924,7 @@ WMError WindowSceneSessionImpl::SetTitleAndDockHoverShown(
return WMError::WM_ERROR_INVALID_WINDOW;
}
TLOGI(WmsLogTag::WMS_IMMS, "winId:%{public}u %{public}s isTitleHoverShown:%{public}d, "
"isDockHoverShown:%{public}d", GetWindowId(), GetWindowName().c_str(),
static_cast<int32_t>(isTitleHoverShown), static_cast<int32_t>(isDockHoverShown));
"isDockHoverShown:%{public}d", GetWindowId(), GetWindowName().c_str(), isTitleHoverShown, isDockHoverShown);
if (WindowHelper::IsSystemWindow(GetType())) {
TLOGI(WmsLogTag::WMS_IMMS, "system window is not supported");
return WMError::WM_ERROR_INVALID_CALLING;
@ -1939,13 +1938,12 @@ WMError WindowSceneSessionImpl::SetTitleAndDockHoverShown(
WindowType winType = property_->GetWindowType();
if (!WindowHelper::IsMainWindow(winType)) {
TLOGE(WmsLogTag::WMS_IMMS, "window is not main window");
return WMError::WM_ERROR_INVALID_WINDOW;
return WMError::WM_ERROR_INVALID_CALLING;
}
titleHoverShowEnabled_ = isTitleHoverShown;
dockHoverShowEnabled_ = isDockHoverShown;
auto hostSession = GetHostSession();
if (hostSession != nullptr) {
hostSession->OnTitleAndDockHoverShowChange(titleHoverShowEnabled_, dockHoverShowEnabled_);
if (auto hostSession = GetHostSession()) {
hostSession->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown);
}
return WMError::WM_OK;
}
@ -2313,11 +2311,11 @@ WMError WindowSceneSessionImpl::Restore()
return WMError::WM_ERROR_INVALID_CALLING;
}
if (!(windowSystemConfig_.IsPcWindow() || property_->GetIsPcAppInPad())) {
TLOGE(WmsLogTag::WMS_LIFE, "This is not PC or PcAppInPad,The device is not supported");
TLOGE(WmsLogTag::WMS_LIFE, "This is not PC or PcAppInPad, not supported");
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
}
if (property_->GetIsAppSupportPhoneInPc()) {
TLOGE(WmsLogTag::WMS_LIFE, "This is PhoneAppSupportOnPc,The device is not supported");
TLOGE(WmsLogTag::WMS_LIFE, "This is PhoneAppSupportOnPc, not supported");
return WMError::WM_ERROR_INVALID_CALLING;
}
auto hostSession = GetHostSession();

View File

@ -1611,24 +1611,6 @@ HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen01, Function | SmallTest
ASSERT_EQ(false, window->IsLayoutFullScreen());
}
/*
* @tc.name: SetLayoutFullScreen02
* @tc.desc: SetLayoutFullScreen test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen02, Function | SmallTest | Level3)
{
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
window->property_->SetWindowName("SetLayoutFullScreen02");
window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
window->hostSession_ = nullptr;
window->property_->SetCompatibleModeInPc(true);
WMError res = window->SetLayoutFullScreen(false);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, res);
}
/*
* @tc.name: SetTitleAndDockHoverShown
* @tc.desc: SetTitleAndDockHoverShown test
@ -1660,6 +1642,24 @@ HWTEST_F(WindowSceneSessionImplTest, SetTitleAndDockHoverShown, Function | Small
EXPECT_EQ(WMError::WM_OK, window->SetTitleAndDockHoverShown(true, true));
}
/*
* @tc.name: SetLayoutFullScreen02
* @tc.desc: SetLayoutFullScreen test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen02, Function | SmallTest | Level3)
{
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
window->property_->SetWindowName("SetLayoutFullScreen02");
window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
window->hostSession_ = nullptr;
window->property_->SetCompatibleModeInPc(true);
WMError res = window->SetLayoutFullScreen(false);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, res);
}
/*
* @tc.name: SetFullScreen
* @tc.desc: SetFullScreen test