mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-12-01 02:52:44 +00:00
!10317 OnNeedAvoid_ 数据竞争修复
Merge pull request !10317 from l30067243/master
This commit is contained in:
commit
b530e1d925
@ -1460,20 +1460,19 @@ void JsSceneSession::ProcessSystemBarPropertyChangeRegister()
|
||||
|
||||
void JsSceneSession::ProcessNeedAvoidRegister()
|
||||
{
|
||||
auto sessionchangeCallback = sessionchangeCallback_.promote();
|
||||
if (sessionchangeCallback == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "sessionchangeCallback is nullptr");
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_IMMS, "session is null, id: %{public}d", persistentId_);
|
||||
return;
|
||||
}
|
||||
sessionchangeCallback->OnNeedAvoid_ = [weakThis = wptr(this)](bool status) {
|
||||
session->RegisterNeedAvoidCallback([weakThis = wptr(this)](bool status) {
|
||||
auto jsSceneSession = weakThis.promote();
|
||||
if (!jsSceneSession) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "ProcessNeedAvoidRegister jsSceneSession is null");
|
||||
TLOGNE(WmsLogTag::WMS_IMMS, "jsSceneSession is null");
|
||||
return;
|
||||
}
|
||||
jsSceneSession->OnNeedAvoid(status);
|
||||
};
|
||||
TLOGD(WmsLogTag::WMS_IMMS, "success");
|
||||
});
|
||||
}
|
||||
|
||||
void JsSceneSession::ProcessIsCustomAnimationPlaying()
|
||||
|
@ -123,7 +123,6 @@ public:
|
||||
NotifySessionModalTypeChangeFunc onSessionModalTypeChange_;
|
||||
NotifyRaiseToTopFunc onRaiseToTop_;
|
||||
NotifySessionEventFunc OnSessionEvent_;
|
||||
NotifyNeedAvoidFunc OnNeedAvoid_;
|
||||
NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_;
|
||||
NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
|
||||
NotifyShowWhenLockedFunc OnShowWhenLocked_;
|
||||
@ -292,6 +291,7 @@ public:
|
||||
bool GetIsDisplayStatusBarTemporarily() const;
|
||||
void SetIsDisplayStatusBarTemporarily(bool isTemporary);
|
||||
void SetIsLastFrameLayoutFinishedFunc(IsLastFrameLayoutFinishedFunc&& func);
|
||||
void RegisterNeedAvoidCallback(NotifyNeedAvoidFunc&& callback);
|
||||
|
||||
void SetAbilitySessionInfo(std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo);
|
||||
void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func);
|
||||
@ -555,6 +555,7 @@ protected:
|
||||
* Window Immersive
|
||||
*/
|
||||
NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_;
|
||||
NotifyNeedAvoidFunc onNeedAvoid_;
|
||||
|
||||
/**
|
||||
* Window Hierarchy
|
||||
|
@ -658,6 +658,19 @@ void SceneSession::RegisterSystemBarPropertyChangeCallback(NotifySystemBarProper
|
||||
PostTask(task, __func__);
|
||||
}
|
||||
|
||||
void SceneSession::RegisterNeedAvoidCallback(NotifyNeedAvoidFunc&& callback)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), callback = std::move(callback)] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGNE(WmsLogTag::WMS_IMMS, "session is null");
|
||||
return;
|
||||
}
|
||||
session->onNeedAvoid_ = std::move(callback);
|
||||
};
|
||||
PostTask(task, __func__);
|
||||
}
|
||||
|
||||
WSError SceneSession::SetGlobalMaximizeMode(MaximizeMode mode)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), mode]() {
|
||||
@ -1394,8 +1407,8 @@ WSError SceneSession::OnNeedAvoid(bool status)
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_IMMS, "SceneSession OnNeedAvoid status:%{public}d, id:%{public}d",
|
||||
static_cast<int32_t>(status), session->GetPersistentId());
|
||||
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->OnNeedAvoid_) {
|
||||
session->sessionChangeCallback_->OnNeedAvoid_(status);
|
||||
if (session->onNeedAvoid_) {
|
||||
session->onNeedAvoid_(status);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
@ -5203,7 +5216,6 @@ void SceneSession::UnregisterSessionChangeListeners()
|
||||
session->sessionChangeCallback_->onSessionModalTypeChange_ = nullptr;
|
||||
session->sessionChangeCallback_->onRaiseToTop_ = nullptr;
|
||||
session->sessionChangeCallback_->OnSessionEvent_ = nullptr;
|
||||
session->sessionChangeCallback_->OnNeedAvoid_ = nullptr;
|
||||
session->sessionChangeCallback_->onIsCustomAnimationPlaying_ = nullptr;
|
||||
session->sessionChangeCallback_->onWindowAnimationFlagChange_ = nullptr;
|
||||
session->sessionChangeCallback_->OnShowWhenLocked_ = nullptr;
|
||||
|
@ -1258,9 +1258,7 @@ HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2)
|
||||
EXPECT_NE(sceneSession, nullptr);
|
||||
ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK);
|
||||
|
||||
sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
|
||||
EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr);
|
||||
sceneSession->sessionChangeCallback_->OnNeedAvoid_ = [](bool state){};
|
||||
sceneSession->onNeedAvoid_ = [](bool state) {};
|
||||
ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user