mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
Camera float window listerner
Signed-off-by: qianlf <qianliangfang@huawei.com> Change-Id: Ie8e60de9f294fc171a9ba4fea0b9a5832874641b
This commit is contained in:
@@ -125,6 +125,11 @@ public:
|
||||
virtual void OnWindowUpdate(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) = 0;
|
||||
};
|
||||
|
||||
class ICameraFloatWindowChangedListener : virtual public RefBase {
|
||||
public:
|
||||
virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0;
|
||||
};
|
||||
|
||||
class WindowManager {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager);
|
||||
friend class WindowManagerAgent;
|
||||
@@ -137,6 +142,8 @@ public:
|
||||
void UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
|
||||
void RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
void UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
void RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
void UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
WMError ToggleShownStateForAllAppWindows();
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
@@ -155,6 +162,7 @@ private:
|
||||
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) const;
|
||||
void UpdateWindowVisibilityInfo(
|
||||
const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos) const;
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
void SetStretchable(bool stretchable);
|
||||
void SetOriginRect(const Rect& rect);
|
||||
void SetTouchHotAreas(const std::vector<Rect>& rects);
|
||||
void SetAccessTokenId(uint32_t accessTokenId);
|
||||
WindowSizeChangeReason GetWindowSizeChangeReason() const;
|
||||
|
||||
const std::string& GetWindowName() const;
|
||||
@@ -107,6 +108,7 @@ public:
|
||||
bool GetStretchable() const;
|
||||
const Rect& GetOriginRect() const;
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowProperty* Unmarshalling(Parcel& parcel);
|
||||
@@ -155,6 +157,7 @@ private:
|
||||
bool isStretchable_ {false};
|
||||
DragType dragType_ = DragType::DRAG_UNDEFINED;
|
||||
std::vector<Rect> touchHotAreas_; // coordinates relative to window.
|
||||
uint32_t accessTokenId_ { 0 };
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -180,6 +180,11 @@ void WindowProperty::SetOriginRect(const Rect& rect)
|
||||
originRect_ = rect;
|
||||
}
|
||||
|
||||
void WindowProperty::SetAccessTokenId(uint32_t accessTokenId)
|
||||
{
|
||||
accessTokenId_ = accessTokenId;
|
||||
}
|
||||
|
||||
WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
|
||||
{
|
||||
return windowSizeChangeReason_;
|
||||
@@ -375,6 +380,11 @@ void WindowProperty::GetTouchHotAreas(std::vector<Rect>& rects) const
|
||||
rects = touchHotAreas_;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetAccessTokenId() const
|
||||
{
|
||||
return accessTokenId_;
|
||||
}
|
||||
|
||||
bool WindowProperty::MapMarshalling(Parcel& parcel) const
|
||||
{
|
||||
auto size = sysBarPropMap_.size();
|
||||
@@ -450,7 +460,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
|
||||
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
|
||||
parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) &&
|
||||
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel);
|
||||
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_);
|
||||
}
|
||||
|
||||
WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
@@ -498,6 +508,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetOriginRect(Rect { 0, 0, w, h });
|
||||
property->SetStretchable(parcel.ReadBool());
|
||||
UnmarshallingTouchHotAreas(parcel, property);
|
||||
property->SetAccessTokenId(parcel.ReadUint32());
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -643,6 +654,7 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
|
||||
originRect_ = property->originRect_;
|
||||
isStretchable_ = property->isStretchable_;
|
||||
touchHotAreas_ = property->touchHotAreas_;
|
||||
accessTokenId_ = property->accessTokenId_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& props) override;
|
||||
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) override;
|
||||
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) override;
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -27,6 +27,7 @@ enum class WindowManagerAgentType : uint32_t {
|
||||
WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR,
|
||||
WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE,
|
||||
WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY,
|
||||
WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
|
||||
};
|
||||
|
||||
class IWindowManagerAgent : public IRemoteBroker {
|
||||
@@ -38,6 +39,7 @@ public:
|
||||
TRANS_ID_UPDATE_SYSTEM_BAR_PROPS,
|
||||
TRANS_ID_UPDATE_WINDOW_STATUS,
|
||||
TRANS_ID_UPDATE_WINDOW_VISIBILITY,
|
||||
TRANS_ID_UPDATE_CAMERA_FLOAT,
|
||||
};
|
||||
|
||||
virtual void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) = 0;
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
virtual void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo,
|
||||
WindowUpdateType type) = 0;
|
||||
virtual void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) = 0;
|
||||
virtual void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) override;
|
||||
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) override;
|
||||
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) override;
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<WindowManagerAgentProxy> delegator_;
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
#include "window_impl.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include <hisysevent.h>
|
||||
#include <sstream>
|
||||
#include "ipc_skeleton.h"
|
||||
|
||||
#include "color_parser.h"
|
||||
#include "display_manager.h"
|
||||
@@ -2341,6 +2342,9 @@ bool WindowImpl::CheckCameraFloatingWindowMultiCreated(WindowType type)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
uint32_t accessTokenId = static_cast<uint32_t>(IPCSkeleton::GetCallingTokenID());
|
||||
property_->SetAccessTokenId(accessTokenId);
|
||||
WLOGFI("Create camera float window, accessTokenId = %{public}u", accessTokenId);
|
||||
return false;
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -146,6 +146,7 @@ public:
|
||||
void NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints);
|
||||
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type);
|
||||
void NotifyWindowVisibilityInfoChanged(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos);
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing);
|
||||
static inline SingletonDelegator<WindowManager> delegator_;
|
||||
|
||||
bool isHandlerRunning_ = false;
|
||||
@@ -159,6 +160,8 @@ public:
|
||||
sptr<WindowManagerAgent> windowUpdateListenerAgent_;
|
||||
std::vector<sptr<IVisibilityChangedListener>> windowVisibilityListeners_;
|
||||
sptr<WindowManagerAgent> windowVisibilityListenerAgent_;
|
||||
std::vector<sptr<ICameraFloatWindowChangedListener>> cameraFloatWindowChangedListeners_;
|
||||
sptr<WindowManagerAgent> cameraFloatWindowChangedListenerAgent_;
|
||||
};
|
||||
|
||||
void WindowManager::Impl::PostTask(ListenerTaskCallback &&callback, EventPriority priority = EventPriority::LOW,
|
||||
@@ -270,6 +273,16 @@ void WindowManager::Impl::NotifyWindowVisibilityInfoChanged(
|
||||
}, EventPriority::LOW, "AccessibilityWindowInfo");
|
||||
}
|
||||
|
||||
void WindowManager::Impl::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
|
||||
{
|
||||
WLOGFI("Camera float window, accessTokenId = %{public}u, isShowing = %{public}u", accessTokenId, isShowing);
|
||||
PostTask([this, accessTokenId, isShowing]() mutable {
|
||||
for (auto& listener : cameraFloatWindowChangedListeners_) {
|
||||
listener->OnCameraFloatWindowChange(accessTokenId, isShowing);
|
||||
}
|
||||
}, EventPriority::LOW, "CameraFloatWindowStatus");
|
||||
}
|
||||
|
||||
WindowManager::WindowManager() : pImpl_(std::make_unique<Impl>())
|
||||
{
|
||||
}
|
||||
@@ -467,6 +480,53 @@ void WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityCh
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(),
|
||||
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
|
||||
if (iter != pImpl_->cameraFloatWindowChangedListeners_.end()) {
|
||||
WLOGFI("Listener is already registered.");
|
||||
return;
|
||||
}
|
||||
pImpl_->cameraFloatWindowChangedListeners_.push_back(listener);
|
||||
if (pImpl_->cameraFloatWindowChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ = new WindowManagerAgent();
|
||||
SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(),
|
||||
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
|
||||
if (iter == pImpl_->cameraFloatWindowChangedListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return;
|
||||
}
|
||||
pImpl_->cameraFloatWindowChangedListeners_.erase(iter);
|
||||
if (pImpl_->cameraFloatWindowChangedListeners_.empty() &&
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ != nullptr) {
|
||||
SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_);
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) const
|
||||
{
|
||||
if (focusChangeInfo == nullptr) {
|
||||
@@ -511,5 +571,11 @@ WMError WindowManager::GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>&
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WindowManager::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
pImpl_->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -40,5 +40,10 @@ void WindowManagerAgent::UpdateWindowVisibilityInfo(const std::vector<sptr<Windo
|
||||
{
|
||||
SingletonContainer::Get<WindowManager>().UpdateWindowVisibilityInfo(visibilityInfos);
|
||||
}
|
||||
|
||||
void WindowManagerAgent::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
|
||||
{
|
||||
SingletonContainer::Get<WindowManager>().UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -144,6 +144,32 @@ void WindowManagerAgentProxy::UpdateWindowVisibilityInfo(
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerAgentProxy::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(accessTokenId)) {
|
||||
WLOGFE("Write accessTokenId failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteBool(isShowing)) {
|
||||
WLOGFE("Write is showing status failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -84,6 +84,12 @@ int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
|
||||
UpdateWindowVisibilityInfo(infos);
|
||||
break;
|
||||
}
|
||||
case WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT: {
|
||||
uint32_t accessTokenId = data.ReadUint32();
|
||||
bool isShowing = data.ReadBool();
|
||||
UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_context_impl.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "window.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_option.h"
|
||||
#include "window_scene.h"
|
||||
#include "window_test_utils.h"
|
||||
@@ -27,6 +29,17 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest"};
|
||||
}
|
||||
|
||||
class TestCameraFloatWindowChangedListener : public ICameraFloatWindowChangedListener {
|
||||
public:
|
||||
uint32_t accessTokenId_ = 0;
|
||||
bool isShowing_ = false;
|
||||
void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) override;
|
||||
};
|
||||
|
||||
class WindowAppFloatingWindowTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -36,8 +49,19 @@ public:
|
||||
|
||||
static inline float virtualPixelRatio_ = 1.0;
|
||||
static inline std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_ = nullptr;
|
||||
static sptr<TestCameraFloatWindowChangedListener> testCameraFloatWindowChangedListener_;
|
||||
};
|
||||
|
||||
sptr<TestCameraFloatWindowChangedListener> WindowAppFloatingWindowTest::testCameraFloatWindowChangedListener_ =
|
||||
new TestCameraFloatWindowChangedListener();
|
||||
|
||||
void TestCameraFloatWindowChangedListener::OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing)
|
||||
{
|
||||
WLOGFI("TestCameraFloatWindowChangedListener [%{public}u, %{public}u]", accessTokenId, isShowing);
|
||||
accessTokenId_ = accessTokenId;
|
||||
isShowing_ = isShowing;
|
||||
}
|
||||
|
||||
void WindowAppFloatingWindowTest::SetUpTestCase()
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
@@ -308,5 +332,65 @@ HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, Function | MediumTest
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow10
|
||||
* @tc.desc: Camera AppFloatingWindow multi create
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow10, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
sptr<Window> fltWin2 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_EQ(nullptr, fltWin2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
sptr<Window> fltWin3 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin3);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin3->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow11
|
||||
* @tc.desc: Camera AppFloatingWindow listener
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow11, Function | MediumTest | Level2)
|
||||
{
|
||||
uint32_t tokenId = static_cast<uint32_t>(IPCSkeleton::GetCallingTokenID());
|
||||
WindowManager::GetInstance().RegisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_);
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
usleep(500000); // 500000us = 0.5s
|
||||
ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_);
|
||||
ASSERT_EQ(true, testCameraFloatWindowChangedListener_->isShowing_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
|
||||
usleep(500000); // 500000us = 0.5s
|
||||
ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_);
|
||||
ASSERT_EQ(false, testCameraFloatWindowChangedListener_->isShowing_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
|
||||
WindowManager::GetInstance().UnregisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints);
|
||||
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type);
|
||||
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos);
|
||||
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing);
|
||||
|
||||
private:
|
||||
WindowManagerAgentController() {}
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
const Rect& GetOriginRect() const;
|
||||
void ResetWindowSizeChangeReason();
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
|
||||
sptr<WindowNode> parent_;
|
||||
std::vector<sptr<WindowNode>> children_;
|
||||
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
sptr<DisplayGroupController> GetMultiDisplayController() const;
|
||||
sptr<WindowNode> GetRootNode(WindowRootNodeType type) const;
|
||||
void NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable);
|
||||
void UpdateCameraFloatWindowStatus(const sptr<WindowNode>& node, bool isShowing);
|
||||
|
||||
private:
|
||||
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
|
||||
|
||||
@@ -74,5 +74,13 @@ void WindowManagerAgentController::UpdateWindowVisibilityInfo(
|
||||
agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
|
||||
{
|
||||
for (auto& agent : wmAgentContainer_.GetAgentsByType(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) {
|
||||
agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -348,5 +348,10 @@ void WindowNode::GetTouchHotAreas(std::vector<Rect>& rects) const
|
||||
{
|
||||
rects = touchHotAreas_;
|
||||
}
|
||||
|
||||
uint32_t WindowNode::GetAccessTokenId() const
|
||||
{
|
||||
return property_->GetAccessTokenId();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -183,7 +183,7 @@ WMError WindowNodeContainer::AddWindowNode(sptr<WindowNode>& node, sptr<WindowNo
|
||||
UpdateWindowVisibilityInfos(infos);
|
||||
DumpScreenWindowTree();
|
||||
NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_ADDED);
|
||||
WLOGFI("AddWindowNode windowId: %{public}u end", node->GetWindowId());
|
||||
UpdateCameraFloatWindowStatus(node, true);
|
||||
if (WindowHelper::IsAppWindow(node->GetWindowType())) {
|
||||
backupWindowIds_.clear();
|
||||
}
|
||||
@@ -191,6 +191,7 @@ WMError WindowNodeContainer::AddWindowNode(sptr<WindowNode>& node, sptr<WindowNo
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) {
|
||||
isScreenLocked_ = true;
|
||||
}
|
||||
WLOGFI("AddWindowNode windowId: %{public}u end", node->GetWindowId());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -301,6 +302,7 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
|
||||
DumpScreenWindowTree();
|
||||
NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_REMOVED);
|
||||
RecoverScreenDefaultOrientationIfNeed(node->GetDisplayId());
|
||||
UpdateCameraFloatWindowStatus(node, false);
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) {
|
||||
isScreenLocked_ = false;
|
||||
}
|
||||
@@ -1880,5 +1882,12 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation()
|
||||
}
|
||||
return Orientation::UNSPECIFIED;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr<WindowNode>& node, bool isShowing)
|
||||
{
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user