mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
!10712 修复窗口可绘制状态最后一次不通知
Merge pull request !10712 from ZihaoWU/wzh1111HAP
This commit is contained in:
commit
b7ce19cddd
@ -3633,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);
|
||||
};
|
||||
|
||||
|
@ -388,7 +388,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;
|
||||
@ -430,6 +429,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 +496,6 @@ public:
|
||||
std::string GetLastInstanceKey(const std::string& bundleName);
|
||||
void RefreshAppInfo(const std::string& bundleName);
|
||||
|
||||
/*
|
||||
* Window Property
|
||||
*/
|
||||
WMError ReleaseForegroundSessionScreenLock() override;
|
||||
|
||||
/*
|
||||
* PiP Window
|
||||
*/
|
||||
@ -674,8 +674,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 +684,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 +930,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);
|
||||
@ -1039,6 +1046,16 @@ private:
|
||||
};
|
||||
std::unordered_map<SessionInfoList, std::shared_ptr<AppExecFwk::AbilityInfo>, SessionHasher> abilityInfoMap_;
|
||||
|
||||
/*
|
||||
* Window Property
|
||||
*/
|
||||
struct DrawingSessionInfo {
|
||||
uint64_t surfaceId_ = 0;
|
||||
int32_t pid_ = 0;
|
||||
int32_t uid_ = 0;
|
||||
};
|
||||
std::vector<DrawingSessionInfo> lastDrawingSessionInfoVec_;
|
||||
|
||||
/**
|
||||
* PC Window
|
||||
*/
|
||||
|
@ -3890,7 +3890,7 @@ void SceneSessionManager::HandleKeepScreenOn(const sptr<SceneSession>& sceneSess
|
||||
return;
|
||||
}
|
||||
bool shouldLock = requireLock && IsSessionVisibleForeground(sceneSession);
|
||||
TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d], %{public}d], %{public}d]",
|
||||
TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
sceneSession->GetWindowName().c_str(), sceneSession->GetSessionState(),
|
||||
sceneSession->IsVisible(), requireLock, shouldLock);
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:HandleKeepScreenOn");
|
||||
@ -3964,7 +3964,7 @@ void SceneSessionManager::PostBrightnessTask(float brightness)
|
||||
SetDisplayBrightness(brightness);
|
||||
}
|
||||
if (!postTaskRet) {
|
||||
TLOGI(WmsLogTag::DEFAULT, "Report post listener callback task failed. the task name is SetBrightness");
|
||||
TLOGE(WmsLogTag::DEFAULT, "post task failed. task is SetBrightness");
|
||||
}
|
||||
}
|
||||
|
||||
@ -7881,21 +7881,30 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector<std::pa
|
||||
drawingContentChangeInfo)
|
||||
{
|
||||
std::vector<sptr<WindowDrawingContentInfo>> windowDrawingContenInfos;
|
||||
for (const auto& elem : drawingContentChangeInfo) {
|
||||
uint64_t surfaceId = elem.first;
|
||||
bool drawingState = elem.second;
|
||||
for (const auto& [surfaceId, drawingState] : drawingContentChangeInfo) {
|
||||
int32_t windowId = 0;
|
||||
int32_t pid = 0;
|
||||
int32_t uid = 0;
|
||||
WindowType type = WindowType::APP_WINDOW_BASE;
|
||||
sptr<SceneSession> session = SelectSesssionFromMap(surfaceId);
|
||||
if (session == nullptr) {
|
||||
continue;
|
||||
if (!GetSpecifiedDrawingData(surfaceId, pid, uid)) {
|
||||
continue;
|
||||
}
|
||||
RemoveSpecifiedDrawingData(surfaceId);
|
||||
} else {
|
||||
windowId = session->GetWindowId();
|
||||
pid = session->GetCallingPid();
|
||||
uid = session->GetCallingUid();
|
||||
type = session->GetWindowType();
|
||||
}
|
||||
windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(session->GetWindowId(),
|
||||
session->GetCallingPid(), session->GetCallingUid(), drawingState, session->GetWindowType()));
|
||||
windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(windowId, pid, uid, drawingState, type));
|
||||
if (openDebugTrace_) {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Drawing status changed pid:(%d ) surfaceId:(%" PRIu64 ")"
|
||||
"drawingState:(%d )", session->GetCallingPid(), surfaceId, drawingState);
|
||||
"drawingState:(%d )", pid, surfaceId, drawingState);
|
||||
}
|
||||
WLOGFD("drawing status changed pid:%{public}d, "
|
||||
"surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", session->GetCallingPid(), surfaceId, drawingState);
|
||||
"surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", pid, surfaceId, drawingState);
|
||||
}
|
||||
if (windowDrawingContenInfos.size() != 0) {
|
||||
WLOGFD("Notify WindowDrawingContenInfo changed start");
|
||||
@ -7903,44 +7912,66 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector<std::pa
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid)
|
||||
{
|
||||
auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(),
|
||||
[surfaceId](const DrawingSessionInfo& info) { return info.surfaceId_ == surfaceId; });
|
||||
if (it != lastDrawingSessionInfoVec_.end()) {
|
||||
pid = it->pid_;
|
||||
uid = it->uid_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t surfaceId)
|
||||
{
|
||||
auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(),
|
||||
[surfaceId](const DrawingSessionInfo& info) { return info.surfaceId_ == surfaceId; });
|
||||
if (it != lastDrawingSessionInfoVec_.end()) {
|
||||
lastDrawingSessionInfoVec_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<uint64_t, bool>> SceneSessionManager::GetWindowDrawingContentChangeInfo(
|
||||
std::vector<std::pair<uint64_t, bool>> currDrawingContentData)
|
||||
const std::vector<std::pair<uint64_t, bool>>& currDrawingContentData)
|
||||
{
|
||||
std::vector<std::pair<uint64_t, bool>> processDrawingContentChangeInfo;
|
||||
for (const auto& data : currDrawingContentData) {
|
||||
uint64_t windowId = data.first;
|
||||
bool currentDrawingContentState = data.second;
|
||||
for (const auto& [surfaceId, isWindowDrawing] : currDrawingContentData) {
|
||||
int32_t pid = 0;
|
||||
bool isChange = false;
|
||||
if (GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) {
|
||||
continue;
|
||||
} else {
|
||||
isChange = GetProcessDrawingState(windowId, pid, currentDrawingContentState);
|
||||
}
|
||||
|
||||
if (isChange) {
|
||||
processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentState);
|
||||
bool isPreWindowDrawing = GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid);
|
||||
bool isProcessDrawingStateChanged = GetProcessDrawingState(surfaceId, pid);
|
||||
sptr<SceneSession> session = SelectSesssionFromMap(surfaceId);
|
||||
bool isDrawingStateChanged =
|
||||
session == nullptr || (isPreWindowDrawing != isWindowDrawing && isProcessDrawingStateChanged);
|
||||
if (isDrawingStateChanged) {
|
||||
processDrawingContentChangeInfo.emplace_back(surfaceId, isWindowDrawing);
|
||||
}
|
||||
}
|
||||
return processDrawingContentChangeInfo;
|
||||
}
|
||||
|
||||
bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState)
|
||||
bool SceneSessionManager::GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid)
|
||||
{
|
||||
bool preWindowDrawingState = true;
|
||||
sptr<SceneSession> session = SelectSesssionFromMap(windowId);
|
||||
sptr<SceneSession> session = SelectSesssionFromMap(surfaceId);
|
||||
if (session == nullptr) {
|
||||
return false;
|
||||
}
|
||||
pid = session->GetCallingPid();
|
||||
preWindowDrawingState = session->GetDrawingContentState();
|
||||
session->SetDrawingContentState(currentDrawingContentState);
|
||||
return preWindowDrawingState;
|
||||
bool preWindowDrawing = session->GetDrawingContentState();
|
||||
session->SetDrawingContentState(currentWindowDrawing);
|
||||
UpdateWindowDrawingData(surfaceId, pid, session->GetCallingUid());
|
||||
return preWindowDrawing;
|
||||
}
|
||||
|
||||
bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState)
|
||||
void SceneSessionManager::UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid)
|
||||
{
|
||||
RemoveSpecifiedDrawingData(surfaceId);
|
||||
lastDrawingSessionInfoVec_.push_back({ surfaceId, pid, uid });
|
||||
}
|
||||
|
||||
bool SceneSessionManager::GetProcessDrawingState(uint64_t surfaceId, int32_t pid)
|
||||
{
|
||||
bool isChange = true;
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
for (const auto& item : sceneSessionMap_) {
|
||||
auto sceneSession = item.second;
|
||||
@ -7948,16 +7979,15 @@ bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid,
|
||||
continue;
|
||||
}
|
||||
if (sceneSession->GetCallingPid() == pid && sceneSession->GetSurfaceNode() != nullptr &&
|
||||
windowId != sceneSession->GetSurfaceNode()->GetId()) {
|
||||
if (sceneSession->GetDrawingContentState()) {
|
||||
return false;
|
||||
}
|
||||
surfaceId != sceneSession->GetSurfaceNode()->GetId()) {
|
||||
if (sceneSession->GetDrawingContentState()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return isChange;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SceneSessionManager::InitWithRenderServiceAdded()
|
||||
{
|
||||
auto windowVisibilityChangeCb = [this](std::shared_ptr<RSOcclusionData> occlusiontionData) {
|
||||
|
@ -772,7 +772,6 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest
|
||||
ASSERT_NE(nullptr, ssm_);
|
||||
uint64_t windowId = 10;
|
||||
int32_t pid = 1;
|
||||
bool currentDrawingContentState = true;
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "SetBrightness";
|
||||
sptr<SceneSession> sceneSession01 = nullptr;
|
||||
@ -793,7 +792,7 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest
|
||||
sceneSession03->SetCallingPid(pid);
|
||||
sceneSession03->surfaceNode_ = nullptr;
|
||||
sceneSession04->SetCallingPid(6);
|
||||
auto result = ssm_->GetProcessDrawingState(windowId, pid, currentDrawingContentState);
|
||||
auto result = ssm_->GetProcessDrawingState(windowId, pid);
|
||||
EXPECT_EQ(result, true);
|
||||
}
|
||||
|
||||
@ -807,7 +806,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes
|
||||
ASSERT_NE(nullptr, ssm_);
|
||||
uint64_t surfaceId = 0;
|
||||
int32_t pid = 10;
|
||||
bool result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true);
|
||||
bool result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid);
|
||||
EXPECT_EQ(result, false);
|
||||
|
||||
SessionInfo info;
|
||||
@ -820,7 +819,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes
|
||||
ASSERT_NE(sceneSession01->surfaceNode_, nullptr);
|
||||
sceneSession01->surfaceNode_->id_ = 10;
|
||||
surfaceId = 10;
|
||||
result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true);
|
||||
result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
|
||||
@ -858,6 +857,28 @@ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function |
|
||||
EXPECT_NE(result, currDrawingContentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetWindowDrawingContentChangeInfo02
|
||||
* @tc.desc: GetWindowDrawingContentChangeInfo02
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo02, Function | SmallTest | Level3)
|
||||
{
|
||||
ASSERT_NE(nullptr, ssm_);
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "GetWindowDrawingContentChangeInfo02";
|
||||
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
ASSERT_NE(sceneSession, nullptr);
|
||||
ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
|
||||
|
||||
std::vector<std::pair<uint64_t, bool>> currDrawingContentData;
|
||||
currDrawingContentData.push_back(std::make_pair(0, false));
|
||||
currDrawingContentData.push_back(std::make_pair(1, true));
|
||||
|
||||
auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
|
||||
EXPECT_EQ(result, currDrawingContentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealwithDrawingContentChange
|
||||
* @tc.desc: DealwithDrawingContentChange
|
||||
|
@ -222,7 +222,7 @@ HWTEST_F(WindowManagerTest, GetSnapshotByWindowId01, Function | SmallTest | Leve
|
||||
WMError ret = windowManager.GetSnapshotByWindowId(windowId, pixelMap);
|
||||
if (SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
|
||||
}else {
|
||||
} else {
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user