mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
!1279 支持ability处理内存水线
Merge pull request !1279 from 邢亚楠/memory_level_dev
This commit is contained in:
@@ -455,6 +455,14 @@ public:
|
||||
* @return std::shared_ptr<Media::PixelMap> snapshot pixel
|
||||
*/
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() = 0;
|
||||
|
||||
/**
|
||||
* @brief Handle and notify memory level.
|
||||
*
|
||||
* @param level memory level
|
||||
* @return the error code of window
|
||||
*/
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,14 @@ public:
|
||||
*/
|
||||
std::string GetContentInfo() const;
|
||||
|
||||
/**
|
||||
* @brief Handle and notify memory.
|
||||
*
|
||||
* @param level memory level
|
||||
* @return the error code of window
|
||||
*/
|
||||
WMError NotifyMemoryLevel(int32_t level) const;
|
||||
|
||||
public:
|
||||
static const DisplayId DEFAULT_DISPLAY_ID = 0;
|
||||
static const std::string MAIN_WINDOW_ID;
|
||||
|
||||
@@ -249,6 +249,7 @@ public:
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
|
||||
void PostListenerTask(ListenerTaskCallback &&callback, Priority priority = Priority::LOW,
|
||||
const std::string taskName = "");
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const override;
|
||||
|
||||
private:
|
||||
inline std::vector<sptr<IWindowLifeCycle>> GetLifecycleListeners()
|
||||
|
||||
@@ -2803,5 +2803,16 @@ WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::NotifyMemoryLevel(int32_t level) const
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
WLOGFE("[Client] Window %{public}s notify memory level failed, because uicontent is null.", name_.c_str());
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
// notify memory level
|
||||
uiContent_->NotifyMemoryLevel(level);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
+18
-4
@@ -92,7 +92,7 @@ const sptr<Window>& WindowScene::GetMainWindow() const
|
||||
std::vector<sptr<Window>> WindowScene::GetSubWindow()
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("WindowScene mainWindow_ is nullptr");
|
||||
WLOGFE("Get sub window failed, because main window is null");
|
||||
return std::vector<sptr<Window>>();
|
||||
}
|
||||
uint32_t parentId = mainWindow_->GetWindowId();
|
||||
@@ -103,6 +103,7 @@ WMError WindowScene::GoForeground(uint32_t reason)
|
||||
{
|
||||
WLOGFI("GoForeground reason:%{public}u", reason);
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("Go foreground failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainWindow_->Show(reason);
|
||||
@@ -112,6 +113,7 @@ WMError WindowScene::GoBackground(uint32_t reason)
|
||||
{
|
||||
WLOGFI("GoBackground reason:%{public}u", reason);
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("Go background failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainWindow_->Hide(reason);
|
||||
@@ -125,7 +127,7 @@ WMError WindowScene::GoDestroy()
|
||||
|
||||
WMError ret = mainWindow_->Destroy();
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("WindowScene GoDestroy Failed Name: %{public}s", mainWindow_->GetWindowName().c_str());
|
||||
WLOGFE("WindowScene go destroy failed name: %{public}s", mainWindow_->GetWindowName().c_str());
|
||||
return ret;
|
||||
}
|
||||
mainWindow_ = nullptr;
|
||||
@@ -135,6 +137,7 @@ WMError WindowScene::GoDestroy()
|
||||
WMError WindowScene::OnNewWant(const AAFwk::Want& want)
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("On new want failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
mainWindow_->OnNewWant(want);
|
||||
@@ -144,6 +147,7 @@ WMError WindowScene::OnNewWant(const AAFwk::Want& want)
|
||||
WMError WindowScene::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) const
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("Set systembar property failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainWindow_->SetSystemBarProperty(type, property);
|
||||
@@ -152,6 +156,7 @@ WMError WindowScene::SetSystemBarProperty(WindowType type, const SystemBarProper
|
||||
WMError WindowScene::RequestFocus() const
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("Request focus failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainWindow_->RequestFocus();
|
||||
@@ -160,7 +165,7 @@ WMError WindowScene::RequestFocus() const
|
||||
void WindowScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("mainWindow_ is null");
|
||||
WLOGFE("Update configuration failed, because main window is null");
|
||||
return;
|
||||
}
|
||||
WLOGFI("notify mainWindow winId:%{public}u", mainWindow_->GetWindowId());
|
||||
@@ -170,10 +175,19 @@ void WindowScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configur
|
||||
std::string WindowScene::GetContentInfo() const
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("WindowScene::GetContentInfo mainWindow_ is null");
|
||||
WLOGFE("Get content info failed, because main window is null");
|
||||
return "";
|
||||
}
|
||||
return mainWindow_->GetContentInfo();
|
||||
}
|
||||
|
||||
WMError WindowScene::NotifyMemoryLevel(int32_t level) const
|
||||
{
|
||||
if (mainWindow_ == nullptr) {
|
||||
WLOGFE("Notify memory level failed, because main window is null");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainWindow_->NotifyMemoryLevel(level);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -216,6 +216,35 @@ HWTEST_F(WindowSceneTest, RequestFocus01, Function | SmallTest | Level2)
|
||||
sptr<WindowScene> scene = new WindowScene();
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->RequestFocus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NotifyMemoryLevel01
|
||||
* @tc.desc: NotifyMemoryLevel without mainWindow
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowSceneTest, NotifyMemoryLevel01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowScene> scene = new WindowScene();
|
||||
int32_t level = 0;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(level));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NotifyMemoryLevel02
|
||||
* @tc.desc: NotifyMemoryLevel with level
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowSceneTest, NotifyMemoryLevel02, Function | SmallTest | Level2)
|
||||
{
|
||||
DisplayId displayId = 0;
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<IWindowLifeCycle> listener = nullptr;
|
||||
sptr<WindowScene> scene = new WindowScene();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(option)));
|
||||
ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(0)); // ui content is null
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user