Merge branch 'master' of gitee.com:openharmony/window_window_manager into mrsong_branch

Signed-off-by: Bumblebee <songliangliang5@huawei.com>
This commit is contained in:
Bumblebee 2024-07-13 07:51:39 +00:00 committed by Gitee
commit 7a840a86a3
145 changed files with 6783 additions and 1581 deletions

View File

@ -687,6 +687,10 @@ std::shared_ptr<Media::PixelMap> DisplayManager::GetSnapshotByPicker(Media::Rect
WLOGFI("snapshot area left:%{public}d, top:%{public}d, width:%{public}d, height:%{public}d",
rect.left, rect.top, rect.width, rect.height);
// create crop pixel map
if (rect.width == 0 || rect.height == 0) {
WLOGFE("width or height is invalid!");
return nullptr;
}
Media::InitializationOptions opt;
opt.size.width = rect.width;
opt.size.height = rect.height;
@ -1886,4 +1890,4 @@ DMError DisplayManager::Impl::ResetAllFreezeStatus()
{
return SingletonContainer::Get<DisplayManagerAdapter>().ResetAllFreezeStatus();
}
} // namespace OHOS::Rosen
} // namespace OHOS::Rosen

View File

@ -702,7 +702,7 @@ HWTEST_F(DisplayManagerTest, AddSurfaceNodeToDisplay, Function | SmallTest | Lev
sptr<DisplayManager::IDisplayListener> listener = new DmMockDisplayListener();
std::shared_ptr<class RSSurfaceNode> surfaceNode;
auto ret = DisplayManager::GetInstance().AddSurfaceNodeToDisplay(0, surfaceNode);
ASSERT_EQ(ret, DMError::DM_ERROR_IPC_FAILED);
ASSERT_NE(ret, DMError::DM_ERROR_IPC_FAILED);
}
/**
@ -716,7 +716,7 @@ HWTEST_F(DisplayManagerTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest
std::shared_ptr<class RSSurfaceNode> surfaceNode;
DisplayManager::GetInstance().OnRemoteDied();
auto ret = DisplayManager::GetInstance().RemoveSurfaceNodeFromDisplay(0, surfaceNode);
ASSERT_EQ(ret, DMError::DM_ERROR_IPC_FAILED);
ASSERT_NE(ret, DMError::DM_ERROR_IPC_FAILED);
}
/**
@ -836,6 +836,145 @@ HWTEST_F(DisplayManagerTest, GetAllDisplayPhysicalResolution, Function | SmallTe
ASSERT_TRUE(allSize.empty());
}
}
/**
* @tc.name: ClearDisplayStateCallback
* @tc.desc: ClearDisplayStateCallback test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ClearDisplayStateCallback, Function | SmallTest | Level1)
{
DisplayManager::GetInstance().pImpl_->ClearDisplayStateCallback();
ASSERT_TRUE(DisplayManager::GetInstance().pImpl_->displayStateAgent_ == nullptr);
}
/**
* @tc.name: ClearFoldStatusCallback
* @tc.desc: ClearFoldStatusCallback test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ClearFoldStatusCallback, Function | SmallTest | Level1)
{
DisplayManager::GetInstance().pImpl_->ClearFoldStatusCallback();
ASSERT_TRUE(DisplayManager::GetInstance().pImpl_->foldStatusListenerAgent_ == nullptr);
}
/**
* @tc.name: ClearFoldAngleCallback
* @tc.desc: ClearFoldAngleCallback test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ClearFoldAngleCallback, Function | SmallTest | Level1)
{
DisplayManager::GetInstance().pImpl_->ClearFoldAngleCallback();
ASSERT_TRUE(DisplayManager::GetInstance().pImpl_->foldAngleListenerAgent_ == nullptr);
}
/**
* @tc.name: ClearCaptureStatusCallback
* @tc.desc: ClearCaptureStatusCallback test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ClearCaptureStatusCallback, Function | SmallTest | Level1)
{
DisplayManager::GetInstance().pImpl_->ClearCaptureStatusCallback();
ASSERT_TRUE(DisplayManager::GetInstance().pImpl_->captureStatusListenerAgent_ == nullptr);
}
/**
* @tc.name: ClearDisplayModeCallback
* @tc.desc: ClearDisplayModeCallback test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ClearDisplayModeCallback, Function | SmallTest | Level1)
{
DisplayManager::GetInstance().pImpl_->ClearDisplayModeCallback();
ASSERT_TRUE(DisplayManager::GetInstance().pImpl_->displayModeListenerAgent_ == nullptr);
}
/**
* @tc.name: GetDisplayByScreenId
* @tc.desc: GetDisplayByScreenId test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetDisplayByScreenId, Function | SmallTest | Level1)
{
ScreenId screenId = -1;
auto ret = DisplayManager::GetInstance().pImpl_->GetDisplayByScreenId(screenId);
ASSERT_TRUE(ret == nullptr);
}
/**
* @tc.name: UnregisterDisplayUpdateListener
* @tc.desc: UnregisterDisplayUpdateListener fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterDisplayUpdateListener, Function | SmallTest | Level1)
{
sptr<DisplayManager::IDisplayUpdateListener> listener;
auto ret = DisplayManager::GetInstance().UnregisterDisplayUpdateListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
listener = new DisplayManager::IDisplayUpdateListener();
ret = DisplayManager::GetInstance().UnregisterDisplayUpdateListener(listener);
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->UnregisterDisplayUpdateListener(listener));
listener.clear();
}
/**
* @tc.name: RegisterAvailableAreaListener
* @tc.desc: RegisterAvailableAreaListener fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterAvailableAreaListener, Function | SmallTest | Level1)
{
sptr<DisplayManager::IAvailableAreaListener> listener;
auto ret = DisplayManager::GetInstance().RegisterAvailableAreaListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
listener = new DisplayManager::IAvailableAreaListener();
ret = DisplayManager::GetInstance().RegisterAvailableAreaListener(listener);
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->RegisterAvailableAreaListener(listener));
listener.clear();
}
/**
* @tc.name: UnregisterAvailableAreaListener
* @tc.desc: UnregisterAvailableAreaListener fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterAvailableAreaListener, Function | SmallTest | Level1)
{
sptr<DisplayManager::IAvailableAreaListener> listener;
auto ret = DisplayManager::GetInstance().UnregisterAvailableAreaListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
listener = new DisplayManager::IAvailableAreaListener();
ret = DisplayManager::GetInstance().UnregisterAvailableAreaListener(listener);
ASSERT_EQ(ret, DisplayManager::GetInstance().pImpl_->UnregisterAvailableAreaListener(listener));
listener.clear();
}
/**
* @tc.name: GetDisplayInfoSrting
* @tc.desc: GetDisplayInfoSrting fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetDisplayInfoSrting, Function | SmallTest | Level1)
{
sptr<DisplayInfo> displayInfo = nullptr;
auto ret =DisplayManager::GetInstance().pImpl_->GetDisplayInfoSrting(displayInfo);
ASSERT_EQ(displayInfo, nullptr);
}
/**
* @tc.name: OnRemoteDied
* @tc.desc: OnRemoteDied fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, OnRemoteDied, Function | SmallTest | Level1)
{
g_dmIsDestroyed = true;
DisplayManager::GetInstance().OnRemoteDied();
ASSERT_EQ(g_dmIsDestroyed, true);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -72,11 +72,11 @@ namespace {
HWTEST_F(ScreenTest, GetBasicProperty01, Function | SmallTest | Level1)
{
ASSERT_GT(screen_->GetName().size(), 0);
ASSERT_EQ(screen_->GetWidth(), 0);
ASSERT_EQ(screen_->GetHeight(), 0);
ASSERT_EQ(screen_->GetVirtualWidth(), 0);
ASSERT_EQ(screen_->GetVirtualHeight(), 0);
ASSERT_EQ(screen_->GetVirtualPixelRatio(), 0);
ASSERT_GT(screen_->GetWidth(), 0);
ASSERT_GT(screen_->GetHeight(), 0);
ASSERT_GT(screen_->GetVirtualWidth(), 0);
ASSERT_GT(screen_->GetVirtualHeight(), 0);
ASSERT_GT(screen_->GetVirtualPixelRatio(), 0);
ASSERT_EQ(screen_->IsReal(), true);
ASSERT_NE(screen_->GetScreenInfo(), nullptr);
}

View File

@ -31,6 +31,10 @@ public:
void OnDestroy(DisplayId) override {}
void OnChange(DisplayId) override {}
};
class DmMockFoldStatusListener : public DisplayManagerLite::IFoldStatusListener {
public:
virtual void OnFoldStatusChanged([[maybe_unused]]FoldStatus foldStatus) {}
};
class DisplayManagerTest : public testing::Test {
public:
static void SetUpTestCase();
@ -141,6 +145,249 @@ HWTEST_F(DisplayManagerTest, ImplUpdateDisplayInfoLocked, Function | SmallTest |
displayInfo.clear();
}
/**
* @tc.name: ImplUpdateDisplayInfoLocked
* @tc.desc: ImplUpdateDisplayInfoLocked fun
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, ImplUpdateDisplayInfoLocked01, Function | SmallTest | Level1)
{
sptr<DisplayInfo> displayInfo = nullptr;
auto ret = DisplayManagerLite::GetInstance().pImpl_->UpdateDisplayInfoLocked(displayInfo);
ASSERT_EQ(ret, false);
displayInfo.clear();
}
/**
* @tc.name: RegisterDisplayListener
* @tc.desc: displayManagerListener_ == nullptr, ret == DMError::DM_OK
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterDisplayListener01, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
sptr<DisplayManagerLite::IDisplayListener> listener = new DmMockDisplayListener();
DisplayManagerLite::GetInstance().pImpl_->displayManagerListener_ = nullptr;
DisplayManagerLite::GetInstance().RegisterDisplayListener(listener);
auto displayManagerListener = DisplayManagerLite::GetInstance().pImpl_->displayManagerListener_;
ASSERT_NE(displayManagerListener, nullptr);
}
/**
* @tc.name: RegisterDisplayListener
* @tc.desc: ret ! = DMError::DM_OK
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterDisplayListener02, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_ERROR_IPC_FAILED));
sptr<DisplayManagerLite::IDisplayListener> listener = new DmMockDisplayListener();
DisplayManagerLite::GetInstance().pImpl_->displayManagerListener_ = nullptr;
DisplayManagerLite::GetInstance().RegisterDisplayListener(listener);
auto displayManagerListener = DisplayManagerLite::GetInstance().pImpl_->displayManagerListener_;
ASSERT_EQ(displayManagerListener, nullptr);
}
/**
* @tc.name: RegisterDisplayListener
* @tc.desc: listener == nullptr
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterDisplayListener03, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IDisplayListener> listener = nullptr;
auto ret = DisplayManagerLite::GetInstance().RegisterDisplayListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: RegisterDisplayListener
* @tc.desc: displayManagerListener_ != nullptr
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterDisplayListener04, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
sptr<DisplayManagerLite::IDisplayListener> listener = new DmMockDisplayListener();
sptr<DisplayManagerLite::IDisplayListener> listener1 = new DmMockDisplayListener();
DisplayManagerLite::GetInstance().RegisterDisplayListener(listener);
auto ret = DisplayManagerLite::GetInstance().RegisterDisplayListener(listener1);
ASSERT_EQ(ret, DMError::DM_OK);
}
/**
* @tc.name: UnregisterDisplayListener
* @tc.desc: listener == nullptr
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterDisplayListener01, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IDisplayListener> listener = nullptr;
auto ret = DisplayManagerLite::GetInstance().UnregisterDisplayListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: UnregisterDisplayListener
* @tc.desc: iter == displayListeners_.end()
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterDisplayListener02, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IDisplayListener> listener = new DmMockDisplayListener();
auto ret = DisplayManagerLite::GetInstance().UnregisterDisplayListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: UnregisterDisplayListener
* @tc.desc: iter == displayListeners_.end()
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterDisplayListener03, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IDisplayListener> listener = new DmMockDisplayListener();
DisplayManagerLite::GetInstance().pImpl_->displayListeners_.insert(listener);
auto ret = DisplayManagerLite::GetInstance().UnregisterDisplayListener(listener);
ASSERT_EQ(ret, DMError::DM_OK);
}
/**
* @tc.name: RegisterFoldStatusListener
* @tc.desc: listener == nullptr
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterFoldStatusListener01, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IFoldStatusListener> listener = nullptr;
auto ret = DisplayManagerLite::GetInstance().RegisterFoldStatusListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: RegisterFoldStatusListener
* @tc.desc: listener == nullptr
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterFoldStatusListener02, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
sptr<DisplayManagerLite::IFoldStatusListener> listener = new DmMockFoldStatusListener();
auto ret = DisplayManagerLite::GetInstance().RegisterFoldStatusListener(listener);
ASSERT_EQ(ret, DMError::DM_OK);
DisplayManagerLite::GetInstance().pImpl_->foldStatusListenerAgent_ = nullptr;
}
/**
* @tc.name: RegisterFoldStatusListener
* @tc.desc: foldStatusListenerAgent_ == nullptr, ret != DMError::DM_OK
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterFoldStatusListener03, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_ERROR_IPC_FAILED));
sptr<DisplayManagerLite::IFoldStatusListener> listener = new DmMockFoldStatusListener();
DisplayManagerLite::GetInstance().RegisterFoldStatusListener(listener);
ASSERT_EQ(DisplayManagerLite::GetInstance().pImpl_->foldStatusListenerAgent_, nullptr);
}
/**
* @tc.name: RegisterFoldStatusListener
* @tc.desc: foldStatusListenerAgent_ != nullptr, ret == DMError::DM_OK
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, RegisterFoldStatusListener04, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
sptr<DisplayManagerLite::IFoldStatusListener> listener = new DmMockFoldStatusListener();
sptr<DisplayManagerLite::IFoldStatusListener> listener1 = new DmMockFoldStatusListener();
DisplayManagerLite::GetInstance().RegisterFoldStatusListener(listener);
auto ret = DisplayManagerLite::GetInstance().RegisterFoldStatusListener(listener1);
ASSERT_EQ(ret, DMError::DM_OK);
}
/**
* @tc.name: UnregisterFoldStatusListener
* @tc.desc: foldStatusListenerAgent_ != nullptr, ret == DMError::DM_OK
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterFoldStatusListener01, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IFoldStatusListener> listener = nullptr;
auto ret = DisplayManagerLite::GetInstance().UnregisterFoldStatusListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: UnregisterFoldStatusListener
* @tc.desc: iter == foldStatusListeners_.end()
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterFoldStatusListener02, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IFoldStatusListener> listener = new DmMockFoldStatusListener();
auto ret = DisplayManagerLite::GetInstance().UnregisterFoldStatusListener(listener);
ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
}
/**
* @tc.name: UnregisterFoldStatusListener
* @tc.desc: iter != foldStatusListeners_.end()
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, UnregisterFoldStatusListener03, Function | SmallTest | Level1)
{
sptr<DisplayManagerLite::IFoldStatusListener> listener = new DmMockFoldStatusListener();
DisplayManagerLite::GetInstance().pImpl_->foldStatusListeners_.insert(listener);
auto ret = DisplayManagerLite::GetInstance().UnregisterFoldStatusListener(listener);
ASSERT_EQ(ret, DMError::DM_OK);
}
/**
* @tc.name: GetDefaultDisplay
* @tc.desc: GetDefaultDisplay
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetDefaultDisplay, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), GetDefaultDisplayInfo()).Times(1).WillOnce(Return(nullptr));
auto ret = DisplayManagerLite::GetInstance().GetDefaultDisplay();
ASSERT_EQ(ret, nullptr);
}
/**
* @tc.name: GetDisplayById
* @tc.desc: destroyed_ == false
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetDisplayById01, Function | SmallTest | Level1)
{
DisplayId displayId = 1000;
auto ret = DisplayManagerLite::GetInstance().GetDisplayById(displayId);
ASSERT_EQ(ret, nullptr);
}
/**
* @tc.name: GetDisplayById
* @tc.desc: UpdateDisplayInfoLocked
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetDisplayById02, Function | SmallTest | Level1)
{
DisplayManagerLite::GetInstance().destroyed_ = false;
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), GetDisplayInfo(_)).Times(1).WillOnce(Return(nullptr));
DisplayId displayId = 1000;
auto ret = DisplayManagerLite::GetInstance().GetDisplayById(displayId);
ASSERT_EQ(ret, nullptr);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -1057,10 +1057,10 @@ public:
* @brief flush frame rate of linker.
*
* @param rate frame rate.
* @param isAnimatorStopped animator status.
* @param animatorExpectedFrameRate animator expected frame rate.
* @param rateType frame rate type.
*/
virtual void FlushFrameRate(uint32_t rate, bool isAnimatorStopped, uint32_t rateType) {}
virtual void FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType) {}
/**
* @brief Update Configuration.
*
@ -1156,7 +1156,7 @@ public:
*/
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) {}
/**
* @brief Register window destroyed listener.
* @brief Unregister window destroyed listener.
*
*/
virtual void UnregisterWindowDestroyedListener() {}
@ -1336,7 +1336,6 @@ public:
* @brief Get ui content object.
*
* @param winId window id.
*
* @return UIContent object of ACE.
*/
virtual Ace::UIContent* GetUIContentWithId(uint32_t winId) const { return nullptr; }
@ -1611,13 +1610,6 @@ public:
*/
virtual bool IsFloatingWindowAppType() const { return false; }
/**
* @brief Set Text Field Avoid Info.
*
* @return Errorcode of window.
*/
virtual WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) { return WMError::WM_OK; }
/**
* @brief Register transfer component data callback.
*
@ -1625,6 +1617,13 @@ public:
*/
virtual void RegisterTransferComponentDataForResultListener(const NotifyTransferComponentDataForResultFunc& func) {}
/**
* @brief Set Text Field Avoid Info.
*
* @return Errorcode of window.
*/
virtual WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) { return WMError::WM_OK; }
/**
* @brief Transfer accessibility event data
*
@ -1663,23 +1662,10 @@ public:
* @param keepKeyboardFlag true means the keyboard should be preserved, otherwise means the opposite.
* @return WM_OK means set keep keyboard flag success, others means failed.
*/
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) { return WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Get the window limits of current window.
*
* @param windowLimits.
* @return WMError.
*/
virtual WMError GetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Set the window limits of current window.
*
* @param windowLimits.
* @return WMError.
*/
virtual WMError SetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag)
{
return WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT;
}
/**
* @brief Register window visibility change listener.
@ -1704,6 +1690,22 @@ public:
}
/**
* @brief Get the window limits of current window.
*
* @param windowLimits.
* @return WMError.
*/
virtual WMError GetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Set the window limits of current window.
*
* @param windowLimits.
* @return WMError.
*/
virtual WMError SetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/*
* @brief Register listener, if timeout(seconds) pass with no interaction, the listener will be executed.
*
* @param listener IWindowNoInteractionListenerSptr.
@ -1917,38 +1919,21 @@ public:
*/
virtual WMError Recover(uint32_t reason) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Get the rect of host window.
*
* @param hostWindowId window Id of the host window.
* @return Rect of window.
*/
virtual Rect GetHostWindowRect(int32_t hostWindowId) { return {}; }
/**
* @brief Make multi-window become landscape or not.
*
* @param isLandscapeMultiWindow means whether multi-window's scale is landscape.
* @return WMError WM_OK means set success, others means failed.
*/
virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
{
return WMError::WM_OK;
}
/**
* @brief Register window rect change listener.
*
* @param listener IWindowRectChangeListener.
* @return WM_OK means register success, others means register failed.
*/
virtual WMError RegisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
{
return WMError::WM_OK;
}
/**
* @brief Unregister window rect change listener.
*
* @param listener IWindowRectChangeListener.
* @return WM_OK means unregister success, others means unregister failed.
*/
virtual WMError UnregisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
{
return WMError::WM_OK;
}
virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WMError::WM_OK; }
/**
* @brief Register subwindow close listener.
@ -1968,14 +1953,6 @@ public:
virtual WMError UnregisterSubWindowCloseListeners(
const sptr<ISubWindowCloseListener>& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Get the rect of host window.
*
* @param hostWindowId window Id of the host window.
* @return Rect of window.
*/
virtual Rect GetHostWindowRect(int32_t hostWindowId) { return {}; }
/**
* @brief Set Shaped Window Mask.
*
@ -2035,6 +2012,28 @@ public:
*/
virtual WMError ClearKeyEventFilter() { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;}
/**
* @brief Register window rect change listener.
*
* @param listener IWindowRectChangeListener.
* @return WM_OK means register success, others means register failed.
*/
virtual WMError RegisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
{
return WMError::WM_OK;
}
/**
* @brief Unregister window rect change listener.
*
* @param listener IWindowRectChangeListener.
* @return WM_OK means unregister success, others means unregister failed.
*/
virtual WMError UnregisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
{
return WMError::WM_OK;
}
/**
* @brief get callingWindow windowStatus.
* @param windowStatus
@ -2068,15 +2067,14 @@ public:
* @return WM_OK means set success, others means set failed
*/
virtual WMError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WMError::WM_OK; }
/*
* @brief Set the Dvsync Switch
*
* @param dvsyncSwitch bool.
* @return * void
*/
virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) {};
virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) {}
/**
* @brief Set whether to enable immersive mode.
* @param enable the value true means to enable immersive mode, and false means the opposite.

View File

@ -673,6 +673,15 @@ struct ExtensionWindowEventInfo {
Rect windowRect {0, 0, 0, 0};
};
/**
* @brief UIExtension info from ability
*/
struct ExtensionWindowAbilityInfo {
int32_t persistentId { 0 };
int32_t parentId { 0 };
UIExtensionUsage usage { UIExtensionUsage::UIEXTENSION_USAGE_END };
};
/**
* @struct KeyboardPanelInfo
*

View File

@ -16,6 +16,7 @@
#include "js_display.h"
#include <cinttypes>
#include <hitrace_meter.h>
#include <map>
#include <set>
@ -213,6 +214,7 @@ napi_value JsDisplay::OnGetCutoutInfo(napi_env env, napi_callback_info info)
}
std::unique_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result);
auto asyncTask = [this, env, task = napiAsyncTask.get()]() {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsDisplay::OnGetCutoutInfo");
sptr<CutoutInfo> cutoutInfo = display_->GetCutoutInfo();
if (cutoutInfo != nullptr) {
task->Resolve(env, CreateJsCutoutInfoObject(env, cutoutInfo));

View File

@ -12,7 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "js_display_listener.h"
#include <hitrace_meter.h>
#include "dm_common.h"
#include "js_runtime_utils.h"
#include "window_manager_hilog.h"
@ -180,6 +184,7 @@ void JsDisplayListener::OnChange(DisplayId id)
}
sptr<JsDisplayListener> listener = this; // Avoid this be destroyed when using.
auto napiTask = [this, listener, id, env = env_]() {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsDisplayListener::OnChange");
napi_value argv[] = {CreateJsValue(env, static_cast<uint32_t>(id))};
CallJsMethod(EVENT_CHANGE, argv, ArraySize(argv));
};
@ -234,9 +239,10 @@ void JsDisplayListener::OnFoldStatusChanged(FoldStatus foldStatus)
}
sptr<JsDisplayListener> listener = this; // Avoid this be destroyed when using.
auto napiTask = [this, listener, foldStatus, env = env_] () {
napi_value argv[] = {CreateJsValue(env, foldStatus)};
CallJsMethod(EVENT_FOLD_STATUS_CHANGED, argv, ArraySize(argv));
};
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsDisplayListener::OnFoldStatusChanged");
napi_value argv[] = {CreateJsValue(env, foldStatus)};
CallJsMethod(EVENT_FOLD_STATUS_CHANGED, argv, ArraySize(argv));
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);
@ -312,9 +318,10 @@ void JsDisplayListener::OnDisplayModeChanged(FoldDisplayMode displayMode)
}
sptr<JsDisplayListener> listener = this; // Avoid this be destroyed when using.
auto napiTask = [this, listener, displayMode, env = env_] () {
napi_value argv[] = {CreateJsValue(env, displayMode)};
CallJsMethod(EVENT_DISPLAY_MODE_CHANGED, argv, ArraySize(argv));
};
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsDisplayListener::OnDisplayModeChanged");
napi_value argv[] = {CreateJsValue(env, displayMode)};
CallJsMethod(EVENT_DISPLAY_MODE_CHANGED, argv, ArraySize(argv));
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);

View File

@ -30,6 +30,7 @@ ohos_shared_library("pipwindow_napi") {
sources = [
"js_pip_controller.cpp",
"js_pip_utils.cpp",
"js_pip_window_listener.cpp",
"js_pip_window_manager.cpp",
"js_pipwindow_module.cpp",
]

View File

@ -71,7 +71,7 @@ napi_value JsPipManager::OnInitXComponentController(napi_env env, napi_callback_
}
napi_value xComponentController = argv[0];
std::shared_ptr<XComponentController> xComponentControllerResult =
XComponentController::GetXComponentControllerFromNapiValue(xComponentController);
XComponentController::GetXComponentControllerFromNapiValue(env, xComponentController);
sptr<Window> pipWindow = Window::Find(PIP_WINDOW_NAME);
if (!pipWindow) {
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to find pip window");

View File

@ -15,19 +15,20 @@
#include "js_pip_controller.h"
#include <refbase.h>
#include "js_pip_utils.h"
#include "js_pip_window_listener.h"
#include "js_runtime_utils.h"
#include "picture_in_picture_controller.h"
#include "picture_in_picture_interface.h"
#include "picture_in_picture_manager.h"
#include "window_manager_hilog.h"
#include "wm_common.h"
#include "picture_in_picture_interface.h"
namespace OHOS {
namespace Rosen {
using namespace AbilityRuntime;
namespace {
constexpr int32_t NUMBER_ONE = 1;
constexpr int32_t NUMBER_TWO = 2;
constexpr int32_t NUMBER_FOUR = 4;
const std::string STATE_CHANGE_CB = "stateChange";
@ -53,15 +54,15 @@ napi_value CreateJsPipControllerObject(napi_env env, sptr<PictureInPictureContro
napi_create_object(env, &objValue);
TLOGI(WmsLogTag::WMS_PIP, "CreateJsPipController");
std::unique_ptr<JsPipController> jsPipController = std::make_unique<JsPipController>(pipController, env);
std::unique_ptr<JsPipController> jsPipController = std::make_unique<JsPipController>(pipController);
napi_wrap(env, objValue, jsPipController.release(), JsPipController::Finalizer, nullptr, nullptr);
BindFunctions(env, objValue, "JsPipController");
return objValue;
}
JsPipController::JsPipController(const sptr<PictureInPictureController>& pipController, napi_env env)
: pipController_(pipController), env_(env)
JsPipController::JsPipController(const sptr<PictureInPictureController>& pipController)
: pipController_(pipController)
{
listenerCodeMap_ = {
{STATE_CHANGE_CB, ListenerType::STATE_CHANGE_CB},
@ -348,21 +349,28 @@ WmErrorCode JsPipController::RegisterListenerWithType(napi_env env, const std::s
napi_ref result = nullptr;
napi_create_reference(env, value, 1, &result);
callbackRef.reset(reinterpret_cast<NativeReference*>(result));
jsCbMap_[type] = callbackRef;
auto pipWindowListener = sptr<JsPiPWindowListener>::MakeSptr(env, callbackRef);
if (pipWindowListener == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "New JsPiPWindowListener failed");
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
jsCbMap_[type][callbackRef] = pipWindowListener;
switch (listenerCodeMap_[type]) {
case ListenerType::STATE_CHANGE_CB:
ProcessStateChangeRegister();
ProcessStateChangeRegister(pipWindowListener);
break;
case ListenerType::CONTROL_PANEL_ACTION_EVENT_CB:
ProcessActionEventRegister();
ProcessActionEventRegister(pipWindowListener);
break;
case ListenerType::CONTROL_EVENT_CB:
ProcessControlEventRegister();
ProcessControlEventRegister(pipWindowListener);
break;
default:
break;
}
TLOGI(WmsLogTag::WMS_PIP, "Register type %{public}s success! callback map size: %{public}zu",
type.c_str(), jsCbMap_[type].size());
return WmErrorCode::WM_OK;
}
@ -372,10 +380,9 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type
TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str());
return false;
}
for (auto iter = jsCbMap_.begin(); iter != jsCbMap_.end(); ++iter) {
for (auto iter = jsCbMap_[type].begin(); iter != jsCbMap_[type].end(); ++iter) {
bool isEquals = false;
napi_strict_equals(env, jsListenerObject, iter->second->GetNapiValue(), &isEquals);
napi_strict_equals(env, jsListenerObject, iter->first->GetNapiValue(), &isEquals);
if (isEquals) {
TLOGE(WmsLogTag::WMS_PIP, "Callback already registered!");
return true;
@ -384,80 +391,64 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type
return false;
}
void JsPipController::ProcessStateChangeRegister()
void JsPipController::ProcessStateChangeRegister(const sptr<JsPiPWindowListener>& listener)
{
if (jsCbMap_.empty() || jsCbMap_.find(STATE_CHANGE_CB) == jsCbMap_.end()) {
TLOGE(WmsLogTag::WMS_PIP, "Register state change error");
return;
}
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
sptr<IPiPLifeCycle> lifeCycle = new JsPipController::PiPLifeCycleImpl(env_, jsCbMap_[STATE_CHANGE_CB]);
pipController_->SetPictureInPictureLifecycle(lifeCycle);
sptr<IPiPLifeCycle> thisListener(listener);
pipController_->RegisterPiPLifecycle(thisListener);
}
void JsPipController::ProcessActionEventRegister()
void JsPipController::ProcessActionEventRegister(const sptr<JsPiPWindowListener>& listener)
{
if (jsCbMap_.empty() || jsCbMap_.find(CONTROL_PANEL_ACTION_EVENT_CB) == jsCbMap_.end()) {
TLOGE(WmsLogTag::WMS_PIP, "Register action event error");
return;
}
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
sptr<IPiPActionObserver> actionObserver =
new JsPipController::PiPActionObserverImpl(env_, jsCbMap_[CONTROL_PANEL_ACTION_EVENT_CB]);
pipController_->SetPictureInPictureActionObserver(actionObserver);
sptr<IPiPActionObserver> thisListener(listener);
pipController_->RegisterPiPActionObserver(listener);
}
void JsPipController::ProcessControlEventRegister()
void JsPipController::ProcessControlEventRegister(const sptr<JsPiPWindowListener>& listener)
{
if (jsCbMap_.empty() || jsCbMap_.find(CONTROL_EVENT_CB) == jsCbMap_.end()) {
TLOGE(WmsLogTag::WMS_PIP, "Register control event error");
return;
}
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
auto controlObserver = sptr<JsPipController::PiPControlObserverImpl>::MakeSptr(env_, jsCbMap_[CONTROL_EVENT_CB]);
if (controlObserver == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controlObserver is nullptr");
return;
}
pipController_->SetPictureInPictureControlObserver(controlObserver);
TLOGI(WmsLogTag::WMS_PIP, "Register control event success");
sptr<IPiPControlObserver> thisListener(listener);
pipController_->RegisterPiPControlObserver(thisListener);
}
void JsPipController::ProcessStateChangeUnRegister()
void JsPipController::ProcessStateChangeUnRegister(const sptr<JsPiPWindowListener>& listener)
{
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
pipController_->SetPictureInPictureLifecycle(nullptr);
sptr<IPiPLifeCycle> thisListener(listener);
pipController_->UnregisterPiPLifecycle(thisListener);
}
void JsPipController::ProcessActionEventUnRegister()
void JsPipController::ProcessActionEventUnRegister(const sptr<JsPiPWindowListener>& listener)
{
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
pipController_->SetPictureInPictureActionObserver(nullptr);
sptr<IPiPActionObserver> thisListener(listener);
pipController_->UnregisterPiPActionObserver(thisListener);
}
void JsPipController::ProcessControlEventUnRegister()
void JsPipController::ProcessControlEventUnRegister(const sptr<JsPiPWindowListener>& listener)
{
if (pipController_ == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr");
return;
}
pipController_->SetPictureInPictureControlObserver(nullptr);
TLOGI(WmsLogTag::WMS_PIP, "UnRegister control event success");
sptr<IPiPControlObserver> thisListener(listener);
pipController_->UnregisterPiPControlObserver(thisListener);
}
napi_value JsPipController::UnregisterCallback(napi_env env, napi_callback_info info)
@ -471,7 +462,7 @@ napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_inf
size_t argc = NUMBER_FOUR;
napi_value argv[NUMBER_FOUR] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != 1) {
if (argc > NUMBER_TWO) {
TLOGE(WmsLogTag::WMS_PIP, "JsPipController Params not match: %{public}zu", argc);
return NapiThrowInvalidParam(env);
}
@ -480,31 +471,75 @@ napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_inf
TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to string");
return NapiThrowInvalidParam(env);
}
WmErrorCode ret = UnRegisterListenerWithType(env, cbType);
if (ret != WmErrorCode::WM_OK) {
TLOGE(WmsLogTag::WMS_PIP, "OnUnregisterCallback failed");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(ret)));
if (argc == NUMBER_ONE) {
UnRegisterListenerWithType(env, cbType, nullptr);
return NapiGetUndefined(env);
}
napi_value value = argv[NUMBER_ONE];
if (value != nullptr && NapiIsCallable(env, value)) {
UnRegisterListenerWithType(env, cbType, value);
}
return NapiGetUndefined(env);
}
WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std::string& type)
WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std::string& type, napi_value value)
{
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str());
return WmErrorCode::WM_ERROR_INVALID_CALLING;
}
jsCbMap_.erase(type);
if (value == nullptr) {
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
WmErrorCode ret = UnRegisterListener(type, it->second);
if (ret != WmErrorCode::WM_OK) {
TLOGE(WmsLogTag::WMS_PIP, "Unregister type %{public}s failed, no value", type.c_str());
return ret;
}
jsCbMap_[type].erase(it++);
}
} else {
bool foundCallbackValue = false;
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
bool isEquals = false;
napi_strict_equals(env, value, it->first->GetNapiValue(), &isEquals);
if (!isEquals) {
++it;
continue;
}
foundCallbackValue = true;
WmErrorCode ret = UnRegisterListener(type, it->second);
if (ret != WmErrorCode::WM_OK) {
TLOGE(WmsLogTag::WMS_PIP, "Unregister type %{public}s failed", type.c_str());
return ret;
}
it = jsCbMap_[type].erase(it);
break;
}
if (!foundCallbackValue) {
TLOGE(WmsLogTag::WMS_PIP, "Unregister type %{public}s failed because not found callback!", type.c_str());
return WmErrorCode::WM_OK;
}
}
TLOGI(WmsLogTag::WMS_PIP, "Unregister type %{public}s success! callback map size: %{public}zu",
type.c_str(), jsCbMap_[type].size());
if (jsCbMap_[type].empty()) {
jsCbMap_.erase(type);
}
return WmErrorCode::WM_OK;
}
WmErrorCode JsPipController::UnRegisterListener(const std::string& type,
const sptr<JsPiPWindowListener>& pipWindowListener)
{
switch (listenerCodeMap_[type]) {
case ListenerType::STATE_CHANGE_CB:
ProcessStateChangeUnRegister();
ProcessStateChangeUnRegister(pipWindowListener);
break;
case ListenerType::CONTROL_PANEL_ACTION_EVENT_CB:
ProcessActionEventUnRegister();
ProcessActionEventUnRegister(pipWindowListener);
break;
case ListenerType::CONTROL_EVENT_CB:
ProcessControlEventUnRegister();
ProcessControlEventUnRegister(pipWindowListener);
break;
default:
break;
@ -565,7 +600,6 @@ void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PiPState state, in
CallJsMethod(env, jsCallback->GetNapiValue(), argv, ArraySize(argv));
}
);
napi_ref callback = nullptr;
std::unique_ptr<NapiAsyncTask::ExecuteCallback> execute = nullptr;
NapiAsyncTask::Schedule("JsPipController::PiPLifeCycleImpl::OnPipListenerCallback",
@ -582,7 +616,6 @@ void JsPipController::PiPActionObserverImpl::OnActionEvent(const std::string& ac
CallJsMethod(env, jsCallback->GetNapiValue(), argv, ArraySize(argv));
}
);
napi_ref callback = nullptr;
std::unique_ptr<NapiAsyncTask::ExecuteCallback> execute = nullptr;
NapiAsyncTask::Schedule("JsPipController::PiPActionObserverImpl::OnActionEvent",

View File

@ -21,13 +21,14 @@
#include "js_runtime_utils.h"
#include "picture_in_picture_controller.h"
#include "wm_common.h"
#include "js_pip_window_listener.h"
namespace OHOS {
namespace Rosen {
napi_value CreateJsPipControllerObject(napi_env env, sptr<PictureInPictureController>& pipController);
class JsPipController {
public:
explicit JsPipController(const sptr<PictureInPictureController>& pipController, napi_env env);
explicit JsPipController(const sptr<PictureInPictureController>& pipController);
~JsPipController();
static void Finalizer(napi_env env, void* data, void* hint);
static napi_value StartPictureInPicture(napi_env env, napi_callback_info info);
@ -56,19 +57,19 @@ private:
bool IfCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
WmErrorCode RegisterListenerWithType(napi_env env, const std::string& type, napi_value value);
WmErrorCode UnRegisterListenerWithType(napi_env env, const std::string& type);
WmErrorCode UnRegisterListenerWithType(napi_env env, const std::string& type, napi_value value);
WmErrorCode UnRegisterListener(const std::string& type, const sptr<JsPiPWindowListener>& pipWindowListener);
void ProcessStateChangeRegister();
void ProcessActionEventRegister();
void ProcessControlEventRegister();
void ProcessStateChangeUnRegister();
void ProcessActionEventUnRegister();
void ProcessControlEventUnRegister();
void ProcessStateChangeRegister(const sptr<JsPiPWindowListener>& listener);
void ProcessActionEventRegister(const sptr<JsPiPWindowListener>& listener);
void ProcessControlEventRegister(const sptr<JsPiPWindowListener>& listener);
void ProcessStateChangeUnRegister(const sptr<JsPiPWindowListener>& listener);
void ProcessActionEventUnRegister(const sptr<JsPiPWindowListener>& listener);
void ProcessControlEventUnRegister(const sptr<JsPiPWindowListener>& listener);
sptr<PictureInPictureController> pipController_;
napi_env env_;
std::map<std::string, ListenerType> listenerCodeMap_;
std::map<std::string, std::shared_ptr<NativeReference>> jsCbMap_;
std::map<std::string, std::map<std::shared_ptr<NativeReference>, sptr<JsPiPWindowListener>>> jsCbMap_;
public:
class PiPLifeCycleImpl : public IPiPLifeCycle {

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "js_pip_window_listener.h"
#include "js_pip_controller.h"
#include "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
using namespace AbilityRuntime;
static napi_value CallJsFunction(napi_env env, napi_value method, napi_value const * argv, size_t argc)
{
if (env == nullptr || method == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "env nullptr or method is nullptr");
return nullptr;
}
napi_value result = nullptr;
napi_value callResult = nullptr;
napi_get_undefined(env, &result);
napi_get_undefined(env, &callResult);
napi_call_function(env, result, method, argc, argv, &callResult);
TLOGD(WmsLogTag::WMS_PIP, "called.");
return callResult;
}
JsPiPWindowListener::~JsPiPWindowListener()
{
TLOGI(WmsLogTag::WMS_PIP, "~JsWindowListener");
}
void JsPiPWindowListener::OnPreparePictureInPictureStart()
{
OnPipListenerCallback(PiPState::ABOUT_TO_START, 0);
}
void JsPiPWindowListener::OnPictureInPictureStart()
{
OnPipListenerCallback(PiPState::STARTED, 0);
}
void JsPiPWindowListener::OnPreparePictureInPictureStop()
{
OnPipListenerCallback(PiPState::ABOUT_TO_STOP, 0);
}
void JsPiPWindowListener::OnPictureInPictureStop()
{
OnPipListenerCallback(PiPState::STOPPED, 0);
}
void JsPiPWindowListener::OnRestoreUserInterface()
{
OnPipListenerCallback(PiPState::ABOUT_TO_RESTORE, 0);
}
void JsPiPWindowListener::OnPictureInPictureOperationError(int32_t errorCode)
{
OnPipListenerCallback(PiPState::ERROR, errorCode);
}
void JsPiPWindowListener::OnPipListenerCallback(PiPState state, int32_t errorCode)
{
TLOGI(WmsLogTag::WMS_PIP, "state: %{public}d", static_cast<int32_t>(state));
auto napiTask = [jsCallback = jsCallBack_, state, errorCode, env = env_]() {
napi_value argv[] = {CreateJsValue(env, static_cast<uint32_t>(state)), CreateJsValue(env, errorCode)};
CallJsFunction(env, jsCallback->GetNapiValue(), argv, ArraySize(argv));
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);
if (ret != napi_status::napi_ok) {
TLOGE(WmsLogTag::WMS_PIP, "Failed to SendEvent");
}
} else {
TLOGE(WmsLogTag::WMS_PIP, "env is nullptr");
}
}
void JsPiPWindowListener::OnActionEvent(const std::string& actionEvent, int32_t statusCode)
{
TLOGI(WmsLogTag::WMS_PIP, "called, actionEvent: %{public}s", actionEvent.c_str());
auto napiTask = [jsCallback = jsCallBack_, actionEvent, statusCode, env = env_]() {
napi_value argv[] = {CreateJsValue(env, actionEvent), CreateJsValue(env, statusCode)};
CallJsFunction(env, jsCallback->GetNapiValue(), argv, ArraySize(argv));
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);
if (ret != napi_status::napi_ok) {
TLOGE(WmsLogTag::WMS_PIP, "Failed to SendEvent");
}
} else {
TLOGE(WmsLogTag::WMS_PIP, "env is nullptr");
}
}
void JsPiPWindowListener::OnControlEvent(PiPControlType controlType, PiPControlStatus statusCode)
{
TLOGI(WmsLogTag::WMS_PIP, "controlType:%{public}u, statusCode:%{public}d", controlType, statusCode);
auto napiTask = [jsCallback = jsCallBack_, controlType, statusCode, env = env_]() {
napi_value argv[] = {CreateJsValue(env, controlType), CreateJsValue(env, statusCode)};
CallJsFunction(env, jsCallback->GetNapiValue(), argv, ArraySize(argv));
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);
if (ret != napi_status::napi_ok) {
TLOGE(WmsLogTag::WMS_PIP, "Failed to SendEvent");
}
} else {
TLOGE(WmsLogTag::WMS_PIP, "env is nullptr");
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_JS_PIP_WINDOW_LISTENER_H
#define OHOS_JS_PIP_WINDOW_LISTENER_H
#include "native_engine/native_value.h"
#include "picture_in_picture_interface.h"
#include "refbase.h"
namespace OHOS {
namespace Rosen {
class JsPiPWindowListener : public IPiPLifeCycle,
public IPiPActionObserver,
public IPiPControlObserver {
public:
JsPiPWindowListener(napi_env env, const std::shared_ptr<NativeReference>& callback)
: env_(env), jsCallBack_(callback) {}
~JsPiPWindowListener();
void OnPreparePictureInPictureStart() override;
void OnPictureInPictureStart() override;
void OnPreparePictureInPictureStop() override;
void OnPictureInPictureStop() override;
void OnPictureInPictureOperationError(int32_t errorCode) override;
void OnRestoreUserInterface() override;
void OnActionEvent(const std::string& actionEvent, int32_t statusCode) override;
void OnControlEvent(PiPControlType controlType, PiPControlStatus statusCode) override;
private:
void OnPipListenerCallback(PiPState state, int32_t errorCode);
napi_env env_ = nullptr;
std::shared_ptr<NativeReference> jsCallBack_ = nullptr;
};
} // namespace Rosen
} // namespace OHOS
#endif /* OHOS_JS_PIP_WINDOW_LISTENER_H */

View File

@ -174,7 +174,7 @@ static int32_t GetPictureInPictureOptionFromJs(napi_env env, napi_value optionOb
ConvertFromJsValue(env, heightValue, height);
GetControlGroupFromJs(env, controlGroup, controls, templateType);
std::shared_ptr<XComponentController> xComponentControllerResult =
XComponentController::GetXComponentControllerFromNapiValue(xComponentControllerValue);
XComponentController::GetXComponentControllerFromNapiValue(env, xComponentControllerValue);
option.SetContext(contextPtr);
option.SetNavigationId(navigationId);
option.SetPipTemplate(templateType);

View File

@ -88,6 +88,7 @@ ohos_shared_library("window_native_kit") {
"ability_runtime:extensionkit_native",
"ability_runtime:runtime",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"ace_engine:ace_uicontent",
"bundle_framework:appexecfwk_base",
"c_utils:utils",

View File

@ -143,6 +143,12 @@ napi_value JsWindowManager::ShiftAppWindowFocus(napi_env env, napi_callback_info
return (me != nullptr) ? me->OnShiftAppWindowFocus(env, info) : nullptr;
}
napi_value JsWindowManager::GetVisibleWindowInfo(napi_env env, napi_callback_info info)
{
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
return (me != nullptr) ? me->OnGetVisibleWindowInfo(env, info) : nullptr;
}
static void GetNativeContext(napi_env env, napi_value nativeContext, void*& contextPtr, WMError& errCode)
{
AppExecFwk::Ability* ability = nullptr;
@ -1152,6 +1158,32 @@ napi_value JsWindowManager::OnShiftAppWindowFocus(napi_env env, napi_callback_in
return result;
}
napi_value JsWindowManager::OnGetVisibleWindowInfo(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
napi_value lastParam = argc <= 0 || GetType(env, argv[0]) != napi_function ? nullptr : argv[0];
napi_value result = nullptr;
NapiAsyncTask::CompleteCallback complete =
[](napi_env env, NapiAsyncTask& task, int32_t status) {
std::vector<sptr<WindowVisibilityInfo>> infos;
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(
SingletonContainer::Get<WindowManager>().GetVisibilityWindowInfo(infos));
if (ret == WmErrorCode::WM_OK) {
task.Resolve(env, CreateJsWindowInfoArrayObject(env, infos));
TLOGD(WmsLogTag::DEFAULT, "OnGetVisibleWindowInfo success");
} else {
TLOGE(WmsLogTag::DEFAULT, "OnGetVisibleWindowInfo failed");
task.Reject(env, JsErrUtils::CreateJsError(env, ret, "OnGetVisibleWindowInfo failed"));
}
};
NapiAsyncTask::Schedule("JsWindowManager::OnGetVisibleWindowInfo",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
return result;
}
napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
{
WLOGFD("JsWindowManagerInit");
@ -1194,6 +1226,7 @@ napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
JsWindowManager::SetGestureNavigationEnabled);
BindNativeFunction(env, exportObj, "setWaterMarkImage", moduleName, JsWindowManager::SetWaterMarkImage);
BindNativeFunction(env, exportObj, "shiftAppWindowFocus", moduleName, JsWindowManager::ShiftAppWindowFocus);
BindNativeFunction(env, exportObj, "getVisibleWindowInfo", moduleName, JsWindowManager::GetVisibleWindowInfo);
return NapiGetUndefined(env);
}
} // namespace Rosen

View File

@ -46,6 +46,8 @@ public:
static napi_value SetGestureNavigationEnabled(napi_env env, napi_callback_info info);
static napi_value SetWaterMarkImage(napi_env env, napi_callback_info info);
static napi_value ShiftAppWindowFocus(napi_env env, napi_callback_info info);
static napi_value GetVisibleWindowInfo(napi_env env, napi_callback_info info);
private:
static napi_value OnCreate(napi_env env, napi_callback_info info);
static napi_value OnCreateWindow(napi_env env, napi_callback_info info);
@ -62,6 +64,7 @@ private:
static napi_value OnSetGestureNavigationEnabled(napi_env env, napi_callback_info info);
static napi_value OnSetWaterMarkImage(napi_env env, napi_callback_info info);
static napi_value OnShiftAppWindowFocus(napi_env env, napi_callback_info info);
static napi_value OnGetVisibleWindowInfo(napi_env env, napi_callback_info info);
static bool ParseRequiredConfigOption(
napi_env env, napi_value jsObject, WindowOption& option);
static bool ParseConfigOption(

View File

@ -20,6 +20,7 @@
#include "window_manager_hilog.h"
#include "window_option.h"
#include "js_window.h"
#include "permission.h"
namespace OHOS {
namespace Rosen {
using namespace AbilityRuntime;
@ -58,20 +59,22 @@ napi_value JsTransitionContext::CompleteTransition(napi_env env, napi_callback_i
napi_value JsTransitionContext::OnCompleteTransition(napi_env env, napi_callback_info info)
{
WmErrorCode errCode = WmErrorCode::WM_OK;
if (!Permission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_SYSTEM, "not system app, permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 1) {
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
}
bool transitionCompleted = false;
if (errCode == WmErrorCode::WM_OK && !ConvertFromJsValue(env, argv[0], transitionCompleted)) {
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
}
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
bool transitionCompleted = false;
if (!ConvertFromJsValue(env, argv[0], transitionCompleted)) {
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
WMError ret = WMError::WM_OK;
auto window = windowToken_.promote();
if (window == nullptr) {

View File

@ -39,6 +39,8 @@
#include "permission.h"
#include "request_info.h"
#include "ui_content.h"
#include "foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_skeleton.h"
#include "base/security/access_token/interfaces/innerkits/accesstoken/include/tokenid_kit.h"
namespace OHOS {
namespace Rosen {
@ -251,14 +253,14 @@ napi_value JsWindow::BindDialogTarget(napi_env env, napi_callback_info info)
napi_value JsWindow::LoadContent(napi_env env, napi_callback_info info)
{
WLOGD("LoadContent");
WLOGI("LoadContent");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
return (me != nullptr) ? me->OnLoadContent(env, info, false) : nullptr;
}
napi_value JsWindow::LoadContentByName(napi_env env, napi_callback_info info)
{
WLOGD("LoadContentByName");
WLOGI("LoadContentByName");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
return (me != nullptr) ? me->OnLoadContent(env, info, true) : nullptr;
}
@ -1762,6 +1764,20 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info
return NapiGetUndefined(env);
}
static napi_value CheckBindDialogWindow(sptr<Window> weakWindow, napi_env env)
{
if (weakWindow == nullptr) {
return JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
uint64_t accessTokenIDEx = IPCSkeleton::GetCallingFullTokenID();
bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx);
if (!isSystemApp) {
return JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP,
"Permission verification failed. A non-system application calls a system API.");
}
return nullptr;
}
napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info)
{
WmErrorCode errCode = WmErrorCode::WM_OK;
@ -1795,11 +1811,11 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info)
wptr<Window> weakToken(windowToken_);
NapiAsyncTask::CompleteCallback complete =
[weakToken, token, errCode](napi_env env, NapiAsyncTask& task, int32_t status) mutable {
[weakToken, token](napi_env env, NapiAsyncTask& task, int32_t status) mutable {
auto weakWindow = weakToken.promote();
errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode;
if (errCode != WmErrorCode::WM_OK) {
task.Reject(env, JsErrUtils::CreateJsError(env, errCode));
napi_value checkResult = CheckBindDialogWindow(weakWindow, env);
if (checkResult != nullptr) {
task.Reject(env, checkResult);
return;
}
@ -2229,6 +2245,8 @@ void SetSystemBarEnableTask(NapiAsyncTask::ExecuteCallback& execute, NapiAsyncTa
WindowType::WINDOW_TYPE_STATUS_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR));
*errCodePtr = spWindow->SetSystemBarProperty(
WindowType::WINDOW_TYPE_NAVIGATION_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR));
*errCodePtr = spWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR,
systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR));
TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set set system bar enalbe end, ret = %{public}d",
spWindow->GetWindowId(), spWindow->GetWindowName().c_str(), *errCodePtr);
};
@ -3407,7 +3425,12 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info)
if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) {
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
windowToken_->SetTurnScreenOn(wakeUp);
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTurnScreenOn(wakeUp));
if (ret != WmErrorCode::WM_OK) {
return NapiThrowError(env, ret);
}
WLOGI("Window [%{public}u, %{public}s] set wake up screen %{public}d end",
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), wakeUp);
return NapiGetUndefined(env);
@ -4594,6 +4617,11 @@ bool JsWindow::ParseScaleOption(napi_env env, napi_value jsObject, Transform& tr
napi_value JsWindow::OnScale(napi_env env, napi_callback_info info)
{
if (!Permission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_SYSTEM, "not system app, permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -4660,6 +4688,11 @@ bool JsWindow::ParseRotateOption(napi_env env, napi_value jsObject, Transform& t
napi_value JsWindow::OnRotate(napi_env env, napi_callback_info info)
{
if (!Permission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_SYSTEM, "not system app, permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -4716,6 +4749,11 @@ bool JsWindow::ParseTranslateOption(napi_env env, napi_value jsObject, Transform
napi_value JsWindow::OnTranslate(napi_env env, napi_callback_info info)
{
if (!Permission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_SYSTEM, "not system app, permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -4792,6 +4830,11 @@ WmErrorCode JsWindow::CreateTransitionController(napi_env env)
napi_value JsWindow::OnGetTransitionController(napi_env env, napi_callback_info info)
{
if (!Permission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_SYSTEM, "not system app, permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
if (windowToken_ == nullptr) {
WLOGFE("WindowToken_ is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
@ -4816,6 +4859,7 @@ napi_value JsWindow::OnSetCornerRadius(napi_env env, napi_callback_info info)
WLOGFE("set corner radius permission denied!");
return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -5674,9 +5718,9 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info)
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
TitleButtonRect titleButtonRect;
WMError ret = windowToken_->GetTitleButtonArea(titleButtonRect);
if (ret != WMError::WM_OK) {
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetTitleButtonArea(titleButtonRect));
if (ret != WmErrorCode::WM_OK) {
return NapiThrowError(env, ret);
}
WLOGI("Window [%{public}u, %{public}s] OnGetTitleButtonRect end",
window->GetWindowId(), window->GetWindowName().c_str());

View File

@ -495,14 +495,7 @@ void JsWindowListener::OnWindowTitleButtonRectChanged(const TitleButtonRect& tit
if (titleButtonRectValue == nullptr) {
return;
}
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
if (objValue == nullptr) {
WLOGFE("Failed to get object");
return;
}
napi_set_named_property(env, objValue, "titleButtonRect", titleButtonRectValue);
napi_value argv[] = { objValue };
napi_value argv[] = { titleButtonRectValue };
thisListener->CallJsMethod(WINDOW_TITLE_BUTTON_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv));
}
);

View File

@ -22,39 +22,46 @@ namespace Rosen {
using namespace AbilityRuntime;
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsRegisterManager"};
const std::map<std::string, RegisterListenerType> WINDOW_MANAGER_LISTENER_MAP {
// white register list for window manager
{SYSTEM_BAR_TINT_CHANGE_CB, RegisterListenerType::SYSTEM_BAR_TINT_CHANGE_CB},
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB, RegisterListenerType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB},
{WATER_MARK_FLAG_CHANGE_CB, RegisterListenerType::WATER_MARK_FLAG_CHANGE_CB},
};
const std::map<std::string, RegisterListenerType> WINDOW_LISTENER_MAP {
// white register list for window
{WINDOW_SIZE_CHANGE_CB, RegisterListenerType::WINDOW_SIZE_CHANGE_CB},
{SYSTEM_AVOID_AREA_CHANGE_CB, RegisterListenerType::SYSTEM_AVOID_AREA_CHANGE_CB},
{AVOID_AREA_CHANGE_CB, RegisterListenerType::AVOID_AREA_CHANGE_CB},
{LIFECYCLE_EVENT_CB, RegisterListenerType::LIFECYCLE_EVENT_CB},
{WINDOW_EVENT_CB, RegisterListenerType::WINDOW_EVENT_CB},
{KEYBOARD_HEIGHT_CHANGE_CB, RegisterListenerType::KEYBOARD_HEIGHT_CHANGE_CB},
{TOUCH_OUTSIDE_CB, RegisterListenerType::TOUCH_OUTSIDE_CB},
{SCREENSHOT_EVENT_CB, RegisterListenerType::SCREENSHOT_EVENT_CB},
{DIALOG_TARGET_TOUCH_CB, RegisterListenerType::DIALOG_TARGET_TOUCH_CB},
{DIALOG_DEATH_RECIPIENT_CB, RegisterListenerType::DIALOG_DEATH_RECIPIENT_CB},
{WINDOW_STATUS_CHANGE_CB, RegisterListenerType::WINDOW_STATUS_CHANGE_CB},
{WINDOW_TITLE_BUTTON_RECT_CHANGE_CB, RegisterListenerType::WINDOW_TITLE_BUTTON_RECT_CHANGE_CB},
{WINDOW_VISIBILITY_CHANGE_CB, RegisterListenerType::WINDOW_VISIBILITY_CHANGE_CB},
{WINDOW_NO_INTERACTION_DETECT_CB, RegisterListenerType::WINDOW_NO_INTERACTION_DETECT_CB},
{WINDOW_RECT_CHANGE_CB, RegisterListenerType::WINDOW_RECT_CHANGE_CB},
{SUB_WINDOW_CLOSE_CB, RegisterListenerType::SUB_WINDOW_CLOSE_CB},
};
const std::map<std::string, RegisterListenerType> WINDOW_STAGE_LISTENER_MAP {
// white register list for window stage
{WINDOW_STAGE_EVENT_CB, RegisterListenerType::WINDOW_STAGE_EVENT_CB},
};
const std::map<CaseType, std::map<std::string, RegisterListenerType>> LISTENER_CODE_MAP {
{CaseType::CASE_WINDOW_MANAGER, WINDOW_MANAGER_LISTENER_MAP},
{CaseType::CASE_WINDOW, WINDOW_LISTENER_MAP},
{CaseType::CASE_STAGE, WINDOW_STAGE_LISTENER_MAP},
};
}
JsWindowRegisterManager::JsWindowRegisterManager()
{
// white register list for window manager
listenerProcess_[CaseType::CASE_WINDOW_MANAGER] = {
{SYSTEM_BAR_TINT_CHANGE_CB, &JsWindowRegisterManager::ProcessSystemBarChangeRegister },
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB, &JsWindowRegisterManager::ProcessGestureNavigationEnabledChangeRegister},
{WATER_MARK_FLAG_CHANGE_CB, &JsWindowRegisterManager::ProcessWaterMarkFlagChangeRegister },
};
// white register list for window
listenerProcess_[CaseType::CASE_WINDOW] = {
{ WINDOW_SIZE_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowChangeRegister },
{ SYSTEM_AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister },
{ AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessAvoidAreaChangeRegister },
{ LIFECYCLE_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister },
{ WINDOW_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister },
{ KEYBOARD_HEIGHT_CHANGE_CB, &JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister },
{ TOUCH_OUTSIDE_CB, &JsWindowRegisterManager::ProcessTouchOutsideRegister },
{ SCREENSHOT_EVENT_CB, &JsWindowRegisterManager::ProcessScreenshotRegister },
{ DIALOG_TARGET_TOUCH_CB, &JsWindowRegisterManager::ProcessDialogTargetTouchRegister },
{ DIALOG_DEATH_RECIPIENT_CB, &JsWindowRegisterManager::ProcessDialogDeathRecipientRegister },
{ WINDOW_STATUS_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowStatusChangeRegister },
{ WINDOW_TITLE_BUTTON_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowTitleButtonRectChangeRegister},
{ WINDOW_VISIBILITY_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister },
{ WINDOW_NO_INTERACTION_DETECT_CB, &JsWindowRegisterManager::ProcessWindowNoInteractionRegister },
{ WINDOW_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowRectChangeRegister },
{ SUB_WINDOW_CLOSE_CB, &JsWindowRegisterManager::ProcessSubWindowCloseRegister },
};
// white register list for window stage
listenerProcess_[CaseType::CASE_STAGE] = {
{WINDOW_STAGE_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister }
};
}
JsWindowRegisterManager::~JsWindowRegisterManager()
@ -352,10 +359,17 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
if (IsCallbackRegistered(env, type, callback)) {
return WmErrorCode::WM_OK;
}
if (listenerProcess_[caseType].count(type) == 0) {
auto iterCaseType = LISTENER_CODE_MAP.find(caseType);
if (iterCaseType == LISTENER_CODE_MAP.end()) {
WLOGFE("[NAPI]CaseType %{public}u is not supported", static_cast<uint32_t>(caseType));
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
auto iterCallbackType = iterCaseType->second.find(type);
if (iterCallbackType == iterCaseType->second.end()) {
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
RegisterListenerType listenerType = iterCallbackType->second;
napi_ref result = nullptr;
napi_create_reference(env, callback, 1, &result);
std::shared_ptr<NativeReference> callbackRef(reinterpret_cast<NativeReference*>(result));
@ -365,7 +379,8 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
windowManagerListener->SetMainEventHandler();
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true, env, parameter);
WmErrorCode ret = ProcessListener(listenerType, caseType, windowManagerListener, window, true,
env, parameter);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Register type %{public}s failed", type.c_str());
return ret;
@ -376,6 +391,72 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
return WmErrorCode::WM_OK;
}
WmErrorCode JsWindowRegisterManager::ProcessListener(RegisterListenerType registerListenerType, CaseType caseType,
const sptr<JsWindowListener>& windowManagerListener, const sptr<Window>& window, bool isRegister,
napi_env env, napi_value parameter)
{
if (caseType == CaseType::CASE_WINDOW_MANAGER) {
switch (static_cast<uint32_t>(registerListenerType)) {
case static_cast<uint32_t>(RegisterListenerType::SYSTEM_BAR_TINT_CHANGE_CB):
return ProcessSystemBarChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB):
return ProcessGestureNavigationEnabledChangeRegister(windowManagerListener, window, isRegister,
env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WATER_MARK_FLAG_CHANGE_CB):
return ProcessWaterMarkFlagChangeRegister(windowManagerListener, window, isRegister, env, parameter);
default:
WLOGFE("[NAPI]RegisterListenerType %{public}u is not supported",
static_cast<uint32_t>(registerListenerType));
return WmErrorCode::WM_ERROR_INVALID_PARAM;
}
} else if (caseType == CaseType::CASE_WINDOW) {
switch (static_cast<uint32_t>(registerListenerType)) {
case static_cast<uint32_t>(RegisterListenerType::WINDOW_SIZE_CHANGE_CB):
return ProcessWindowChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::SYSTEM_AVOID_AREA_CHANGE_CB):
return ProcessSystemAvoidAreaChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::AVOID_AREA_CHANGE_CB):
return ProcessAvoidAreaChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::LIFECYCLE_EVENT_CB):
return ProcessLifeCycleEventRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_EVENT_CB):
return ProcessLifeCycleEventRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::KEYBOARD_HEIGHT_CHANGE_CB):
return ProcessOccupiedAreaChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::TOUCH_OUTSIDE_CB):
return ProcessTouchOutsideRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::SCREENSHOT_EVENT_CB):
return ProcessScreenshotRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::DIALOG_TARGET_TOUCH_CB):
return ProcessDialogTargetTouchRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::DIALOG_DEATH_RECIPIENT_CB):
return ProcessDialogDeathRecipientRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_STATUS_CHANGE_CB):
return ProcessWindowStatusChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_TITLE_BUTTON_RECT_CHANGE_CB):
return ProcessWindowTitleButtonRectChangeRegister(windowManagerListener, window, isRegister, env,
parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_VISIBILITY_CHANGE_CB):
return ProcessWindowVisibilityChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_NO_INTERACTION_DETECT_CB):
return ProcessWindowNoInteractionRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::WINDOW_RECT_CHANGE_CB):
return ProcessWindowRectChangeRegister(windowManagerListener, window, isRegister, env, parameter);
case static_cast<uint32_t>(RegisterListenerType::SUB_WINDOW_CLOSE_CB):
return ProcessSubWindowCloseRegister(windowManagerListener, window, isRegister, env, parameter);
default:
WLOGFE("[NAPI]RegisterListenerType %{public}u is not supported",
static_cast<uint32_t>(registerListenerType));
return WmErrorCode::WM_ERROR_INVALID_PARAM;
}
} else if (caseType == CaseType::CASE_STAGE) {
if (registerListenerType == RegisterListenerType::WINDOW_STAGE_EVENT_CB) {
return ProcessLifeCycleEventRegister(windowManagerListener, window, isRegister, env, parameter);
}
}
return WmErrorCode::WM_OK;
}
WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
CaseType caseType, napi_env env, napi_value value)
{
@ -384,13 +465,21 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std
WLOGFW("[NAPI]Type %{public}s was not registerted", type.c_str());
return WmErrorCode::WM_OK;
}
if (listenerProcess_[caseType].count(type) == 0) {
auto iterCaseType = LISTENER_CODE_MAP.find(caseType);
if (iterCaseType == LISTENER_CODE_MAP.end()) {
WLOGFE("[NAPI]CaseType %{public}u is not supported", static_cast<uint32_t>(caseType));
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
auto iterCallbackType = iterCaseType->second.find(type);
if (iterCallbackType == iterCaseType->second.end()) {
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
RegisterListenerType listenerType = iterCallbackType->second;
if (value == nullptr) {
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr);
WmErrorCode ret = ProcessListener(listenerType, caseType, it->second, window,
false, env, nullptr);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str());
return ret;
@ -406,7 +495,8 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std
continue;
}
findFlag = true;
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr);
WmErrorCode ret = ProcessListener(listenerType, caseType, it->second, window,
false, env, nullptr);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str());
return ret;

View File

@ -24,6 +24,29 @@
#include "window.h"
namespace OHOS {
namespace Rosen {
enum class RegisterListenerType : uint32_t {
SYSTEM_BAR_TINT_CHANGE_CB,
GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
WATER_MARK_FLAG_CHANGE_CB,
WINDOW_SIZE_CHANGE_CB,
SYSTEM_AVOID_AREA_CHANGE_CB,
AVOID_AREA_CHANGE_CB,
LIFECYCLE_EVENT_CB,
WINDOW_EVENT_CB,
KEYBOARD_HEIGHT_CHANGE_CB,
TOUCH_OUTSIDE_CB,
SCREENSHOT_EVENT_CB,
DIALOG_TARGET_TOUCH_CB,
DIALOG_DEATH_RECIPIENT_CB,
WINDOW_STATUS_CHANGE_CB,
WINDOW_TITLE_BUTTON_RECT_CHANGE_CB,
WINDOW_VISIBILITY_CHANGE_CB,
WINDOW_NO_INTERACTION_DETECT_CB,
WINDOW_RECT_CHANGE_CB,
SUB_WINDOW_CLOSE_CB,
WINDOW_STAGE_EVENT_CB,
};
class JsWindowRegisterManager {
public:
JsWindowRegisterManager();
@ -70,11 +93,11 @@ private:
bool isRegister, napi_env env, napi_value parameter = nullptr);
WmErrorCode ProcessSubWindowCloseRegister(sptr<JsWindowListener> listener, sptr<Window> window,
bool isRegister, napi_env env, napi_value parameter = nullptr);
using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr<JsWindowListener>, sptr<Window> window, bool,
WmErrorCode ProcessListener(RegisterListenerType registerListenerType, CaseType caseType,
const sptr<JsWindowListener>& windowManagerListener, const sptr<Window>& window, bool isRegister,
napi_env env, napi_value parameter);
std::map<std::string, std::map<std::shared_ptr<NativeReference>, sptr<JsWindowListener>>> jsCbMap_;
std::mutex mtx_;
std::map<CaseType, std::map<std::string, Func>> listenerProcess_;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -530,6 +530,38 @@ static napi_value CreateJsSystemBarRegionTintObject(napi_env env, const SystemBa
return objValue;
}
napi_value CreateJsWindowInfoArrayObject(napi_env env, const std::vector<sptr<WindowVisibilityInfo>>& infos)
{
napi_value arrayValue = nullptr;
napi_create_array_with_length(env, infos.size(), &arrayValue);
if (arrayValue == nullptr) {
WLOGFE("[NAPI]Failed to convert windowVisibilityInfo to jsArrayObject");
return nullptr;
}
uint32_t index = 0;
for (size_t i = 0; i < infos.size(); i++) {
auto info = infos[i];
auto windowType = info->GetWindowType();
if (windowType >= WindowType::APP_MAIN_WINDOW_BASE && windowType < WindowType::APP_MAIN_WINDOW_END) {
napi_set_element(env, arrayValue, index++, CreateJsWindowInfoObject(env, info));
}
}
return arrayValue;
}
napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInfo>& info)
{
napi_value objValue = nullptr;
CHECK_NAPI_CREATE_OBJECT_RETURN_IF_NULL(env, objValue);
napi_set_named_property(env, objValue, "rect", GetRectAndConvertToJsValue(env, info->GetRect()));
napi_set_named_property(env, objValue, "bundleName", CreateJsValue(env, info->GetBundleName()));
napi_set_named_property(env, objValue, "abilityName", CreateJsValue(env, info->GetAbilityName()));
napi_set_named_property(env, objValue, "windowId", CreateJsValue(env, info->GetWindowId()));
napi_set_named_property(env, objValue, "windowStatusType",
CreateJsValue(env, static_cast<int32_t>(info->GetWindowStatus())));
return objValue;
}
napi_value CreateJsSystemBarRegionTintArrayObject(napi_env env, const SystemBarRegionTints& tints)
{
if (tints.empty()) {
@ -569,12 +601,16 @@ bool GetSystemBarStatus(std::map<WindowType, SystemBarProperty>& systemBarProper
}
auto statusProperty = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
auto navProperty = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
auto navIndicatorProperty = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR);
statusProperty.enable_ = false;
navProperty.enable_ = false;
navIndicatorProperty.enable_ = false;
systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR] = statusProperty;
systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR] = navProperty;
systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = navIndicatorProperty;
systemBarpropertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR] = SystemBarPropertyFlag();
systemBarpropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_BAR] = SystemBarPropertyFlag();
systemBarpropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = SystemBarPropertyFlag();
for (uint32_t i = 0; i < size; i++) {
std::string name;
napi_value getElementValue = nullptr;
@ -585,12 +621,14 @@ bool GetSystemBarStatus(std::map<WindowType, SystemBarProperty>& systemBarProper
}
if (name.compare("status") == 0) {
systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = true;
systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enable_ = true;
} else if (name.compare("navigation") == 0) {
systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enable_ = true;
}
}
systemBarpropertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR].enableFlag = true;
systemBarpropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enableFlag = true;
systemBarpropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enableFlag = true;
return true;
}

View File

@ -28,6 +28,7 @@
#endif
#include "window_option.h"
#include "window_visibility_info.h"
#include "wm_common.h"
namespace OHOS {
namespace Rosen {
@ -268,6 +269,8 @@ const std::map<WindowSizeChangeReason, RectChangeReason> JS_SIZE_CHANGE_REASON {
{ WindowSizeChangeReason::END, RectChangeReason::UNDEFINED },
};
napi_value CreateJsWindowInfoArrayObject(napi_env env, const std::vector<sptr<WindowVisibilityInfo>>& infos);
napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInfo>& window);
napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect);
napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window, const Rect& drawableRect);
napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr<Window>& window);

View File

@ -617,7 +617,7 @@ napi_value JsWindowStage::OnSetDefaultDensityEnabled(napi_env env, napi_callback
}
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetDefaultDensityEnabled(enabled));
TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] SetDefaultDensityEnabled=%{public}u, ret=%{public}u",
TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u,%{public}s] SetDefaultDensityEnabled=%{public}u ret=%{public}u",
window->GetWindowId(), window->GetWindowName().c_str(), enabled, ret);
return CreateJsValue(env, static_cast<int32_t>(ret));

View File

@ -200,7 +200,7 @@ public:
virtual void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) = 0;
virtual void RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback) = 0;
virtual int64_t GetVSyncPeriod() = 0;
virtual void FlushFrameRate(uint32_t rate, bool isAnimatorStopped, uint32_t rateType) {}
virtual void FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType) {}
virtual void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration) = 0;
virtual WMError RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
virtual WMError UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;

View File

@ -225,9 +225,10 @@ public:
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) override;
virtual WMError SetSingleFrameComposerEnabled(bool enable) override;
virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) override;
virtual WMError UpdateSystemBarProperty(bool status);
virtual WMError SetImmersiveModeEnabledState(bool enable) override;
virtual bool GetImmersiveModeEnabledState() const override;
virtual WMError UpdateSystemBarProperty(bool status);
private:
static sptr<Window> FindWindowById(uint32_t windowId);

View File

@ -19,14 +19,19 @@ namespace OHOS {
namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsRegisterManager"};
const std::map<std::string, ListenerFunctionType> WindowListenerFunctionMap {
{SYSTEM_AVOID_AREA_CHANGE_CB, ListenerFunctionType::SYSTEM_AVOID_AREA_CHANGE_CB},
{AVOID_AREA_CHANGE_CB, ListenerFunctionType::AVOID_AREA_CHANGE_CB},
};
const std::map<CaseType, std::map<std::string, ListenerFunctionType>> ListenerFunctionMap {
{CaseType::CASE_WINDOW, WindowListenerFunctionMap},
};
}
JsWindowRegisterManager::JsWindowRegisterManager()
{
listenerProcess_[CaseType::CASE_WINDOW] = {
{ SYSTEM_AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister },
{ AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessAvoidAreaChangeRegister },
};
}
JsWindowRegisterManager::~JsWindowRegisterManager()
@ -79,10 +84,17 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
if (IsCallbackRegistered(env, type, callback)) {
return WmErrorCode::WM_OK;
}
if (listenerProcess_[caseType].count(type) == 0) {
auto iterCaseType = ListenerFunctionMap.find(caseType);
if (iterCaseType == ListenerFunctionMap.end()) {
WLOGFE("[NAPI]CaseType %{public}u is not supported", static_cast<uint32_t>(caseType));
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
auto iterCallbackType = iterCaseType->second.find(type);
if (iterCallbackType == iterCaseType->second.end()) {
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
ListenerFunctionType listenerFunctionType = iterCallbackType->second;
napi_ref result = nullptr;
napi_create_reference(env, callback, 1, &result);
std::shared_ptr<NativeReference> callbackRef(reinterpret_cast<NativeReference*>(result));
@ -92,7 +104,8 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
windowManagerListener->SetMainEventHandler();
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true, env, parameter);
WmErrorCode ret = ProcessRegisterCallback(listenerFunctionType, caseType, windowManagerListener, window,
true, env, parameter);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Register type %{public}s failed", type.c_str());
return ret;
@ -103,6 +116,23 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::
return WmErrorCode::WM_OK;
}
WmErrorCode JsWindowRegisterManager::ProcessRegisterCallback(ListenerFunctionType listenerFunctionType,
CaseType caseType, const sptr<JsWindowListener>& listener, const sptr<Window>& window, bool isRegister,
napi_env env, napi_value parameter)
{
if (caseType == CaseType::CASE_WINDOW) {
switch (listenerFunctionType) {
case ListenerFunctionType::SYSTEM_AVOID_AREA_CHANGE_CB:
return ProcessSystemAvoidAreaChangeRegister(listener, window, isRegister, env, parameter);
case ListenerFunctionType::AVOID_AREA_CHANGE_CB:
return ProcessAvoidAreaChangeRegister(listener, window, isRegister, env, parameter);
default:
return WmErrorCode::WM_ERROR_INVALID_PARAM;
}
}
return WmErrorCode::WM_ERROR_INVALID_PARAM;
}
WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
CaseType caseType, napi_env env, napi_value value)
{
@ -111,13 +141,21 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std
WLOGFE("[NAPI]Type %{public}s was not registerted", type.c_str());
return WmErrorCode::WM_OK;
}
if (listenerProcess_[caseType].count(type) == 0) {
auto iterCaseType = ListenerFunctionMap.find(caseType);
if (iterCaseType == ListenerFunctionMap.end()) {
WLOGFE("[NAPI]CaseType %{public}u is not supported", static_cast<uint32_t>(caseType));
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
auto iterCallbackType = iterCaseType->second.find(type);
if (iterCallbackType == iterCaseType->second.end()) {
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
}
ListenerFunctionType listenerFunctionType = iterCallbackType->second;
if (value == nullptr) {
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr);
WmErrorCode ret = ProcessRegisterCallback(listenerFunctionType, caseType, it->second, window, false,
env, nullptr);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str());
return ret;
@ -133,7 +171,8 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std
continue;
}
findFlag = true;
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr);
WmErrorCode ret = ProcessRegisterCallback(listenerFunctionType, caseType, it->second, window, false,
env, nullptr);
if (ret != WmErrorCode::WM_OK) {
WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str());
return ret;

View File

@ -29,6 +29,12 @@ enum class CaseType {
CASE_WINDOW,
CASE_STAGE
};
enum class ListenerFunctionType : uint32_t {
SYSTEM_AVOID_AREA_CHANGE_CB,
AVOID_AREA_CHANGE_CB,
};
class JsWindowRegisterManager {
public:
JsWindowRegisterManager();
@ -44,11 +50,11 @@ private:
bool isRegister, napi_env env, napi_value parameter = nullptr);
WmErrorCode ProcessAvoidAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister,
napi_env env, napi_value parameter = nullptr);
using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr<JsWindowListener>, sptr<Window> window, bool,
napi_env env, napi_value parameter);
WmErrorCode ProcessRegisterCallback(ListenerFunctionType listenerFunctionType, CaseType caseType,
const sptr<JsWindowListener>& listener, const sptr<Window>& window, bool isRegister, napi_env env,
napi_value parameter);
std::map<std::string, std::map<std::shared_ptr<NativeReference>, sptr<JsWindowListener>>> jsCbMap_;
std::mutex mtx_;
std::map<CaseType, std::map<std::string, Func>> listenerProcess_;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -1128,6 +1128,10 @@ WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
return WMError::WM_OK;
}
void WindowImpl::SetUiDvsyncSwitch(bool dvsyncSwitch)
{
}
WMError WindowImpl::SetImmersiveModeEnabledState(bool enable)
{
return WMError::WM_OK;

View File

@ -44,12 +44,12 @@ int main(int argc, char *argv[])
cmdArguments.fileName = "";
if (!SnapShotUtils::ProcessArgs(argc, argv, cmdArguments)) {
return 0;
_exit(-1);
}
if (DEVELOPER_MODE_STATE_ON_DEFAULT == IS_DEVELOPER_MODE) {
std::cout << "current mode is not developer mode, just return." << std::endl;
return 0;
_exit(-1);
}
auto display = DisplayManager::GetInstance().GetDisplayById(cmdArguments.displayId);

View File

@ -28,6 +28,8 @@ public:
DisplayManagerAgentType type));
MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type));
MOCK_METHOD0(GetDefaultDisplayInfo, sptr<DisplayInfo>());
MOCK_METHOD1(GetDisplayInfo, sptr<DisplayInfo>(DisplayId displayId));
};
}
} // namespace OHOS

View File

@ -106,6 +106,7 @@ public:
MOCK_METHOD0(IsUIExtensionAbilityProcess, bool());
MOCK_METHOD4(NotifyExecuteAction, bool(int64_t elementId, const std::map<std::string, std::string>& actionAguments,
int32_t action, int64_t baseParent));
MOCK_METHOD1(SetForceSplitEnable, void(bool isForceSplit));
};
} // namespace Ace
} // namespace OHOS

View File

@ -401,21 +401,25 @@ public:
{
TransformHelper::Matrix4 ret = TransformHelper::Matrix4::Identity;
// set scale
if ((transform.scaleX_ - 1) || (transform.scaleY_ - 1) || (transform.scaleY_ - 1)) {
if (MathHelper::LessNotEqual(transform.scaleX_, 1.0) ||
MathHelper::LessNotEqual(transform.scaleY_, 1.0) ||
MathHelper::LessNotEqual(transform.scaleZ_, 1.0)) {
ret *= TransformHelper::CreateScale(transform.scaleX_, transform.scaleY_, transform.scaleZ_);
}
// set rotation
if (transform.rotationX_) {
if (MathHelper::LessNotEqual(transform.rotationX_, 0.0)) {
ret *= TransformHelper::CreateRotationX(MathHelper::ToRadians(transform.rotationX_));
}
if (transform.rotationY_) {
if (MathHelper::LessNotEqual(transform.rotationY_, 0.0)) {
ret *= TransformHelper::CreateRotationY(MathHelper::ToRadians(transform.rotationY_));
}
if (transform.rotationZ_) {
if (MathHelper::LessNotEqual(transform.rotationZ_, 0.0)) {
ret *= TransformHelper::CreateRotationZ(MathHelper::ToRadians(transform.rotationZ_));
}
// set translation
if (transform.translateX_ || transform.translateY_ || transform.translateZ_) {
if (MathHelper::LessNotEqual(transform.translateX_, 0.0) ||
MathHelper::LessNotEqual(transform.translateY_, 0.0) ||
MathHelper::LessNotEqual(transform.translateZ_, 0.0)) {
ret *= TransformHelper::CreateTranslation(TransformHelper::Vector3(transform.translateX_,
transform.translateY_, transform.translateZ_));
}

View File

@ -68,6 +68,13 @@ public:
WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState,
WindowType winType) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState),
windowType_(winType) {};
WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState,
WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName,
const std::string& abilityName) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState),
windowType_(winType), windowStatus_(windowStatus), rect_(rect), bundleName_(bundleName),
abilityName_(abilityName) {}
/**
* @brief Deconstruct of WindowVisibilityInfo.
*/
@ -88,11 +95,27 @@ public:
*/
static WindowVisibilityInfo* Unmarshalling(Parcel& parcel);
uint32_t GetWindowId() const { return windowId_; }
const Rect& GetRect() const { return rect_; }
const std::string& GetBundleName() const { return bundleName_; }
const std::string& GetAbilityName() const { return abilityName_; }
WindowStatus GetWindowStatus() const { return windowStatus_; }
WindowType GetWindowType() const { return windowType_; }
uint32_t windowId_ { INVALID_WINDOW_ID };
int32_t pid_ { 0 };
int32_t uid_ { 0 };
WindowVisibilityState visibilityState_ = WINDOW_LAYER_STATE_MAX;
WindowType windowType_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
WindowStatus windowStatus_ = WindowStatus::WINDOW_STATUS_UNDEFINED;
Rect rect_ = {0, 0, 0, 0};
std::string bundleName_;
std::string abilityName_;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H

View File

@ -56,7 +56,12 @@ static bool GetTypeCFileNode(const std::vector<std::string>& allDirName, std::st
{
for (const auto& dir : allDirName) {
std::string absoluteTypePath = dir + "/type";
std::ifstream srcFile(absoluteTypePath.c_str(), std::ifstream::in);
char realPathResult[PATH_MAX] = { 0 };
if (!realpath(absoluteTypePath.c_str(), realPathResult)) {
return false;
}
std::ifstream srcFile(realPathResult, std::ifstream::in);
if (!srcFile.is_open()) {
continue;
}
@ -84,7 +89,12 @@ bool TypeCPortInfo::GetTypeCThermal(int32_t& thermal)
}
}
std::ifstream typeCThermalFile(typeCMappingPath.c_str(), std::ifstream::in);
char realPathResult[PATH_MAX] = { 0 };
if (!realpath(typeCMappingPath.c_str(), realPathResult)) {
return false;
}
std::ifstream typeCThermalFile(realPathResult, std::ifstream::in);
if (!typeCThermalFile.is_open()) {
return false;
}

View File

@ -25,7 +25,10 @@ bool WindowVisibilityInfo::Marshalling(Parcel &parcel) const
{
return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) &&
parcel.WriteInt32(uid_) && parcel.WriteUint32(static_cast<uint32_t>(visibilityState_)) &&
parcel.WriteUint32(static_cast<uint32_t>(windowType_));
parcel.WriteUint32(static_cast<uint32_t>(windowType_)) &&
parcel.WriteUint32(static_cast<uint32_t>(windowStatus_)) && parcel.WriteInt32(rect_.posX_) &&
parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_);
}
WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel &parcel)
@ -45,6 +48,10 @@ WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel &parcel)
}
windowVisibilityInfo->visibilityState_ = static_cast<WindowVisibilityState>(visibilityState);
windowVisibilityInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32());
windowVisibilityInfo->windowStatus_ = static_cast<WindowStatus>(parcel.ReadUint32());
windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
windowVisibilityInfo->bundleName_ = parcel.ReadString();
windowVisibilityInfo->abilityName_ = parcel.ReadString();
return windowVisibilityInfo;
}
} // namespace OHOS::Rosen

View File

@ -256,6 +256,7 @@ bool SessionPermission::IsSameBundleNameAsCalling(const std::string& bundleName)
std::string identity = IPCSkeleton::ResetCallingIdentity();
std::string callingBundleName;
bundleManagerServiceProxy_->GetNameForUid(uid, callingBundleName);
IPCSkeleton::SetCallingIdentity(identity);
if (callingBundleName == bundleName) {
WLOGFI("verify bundle name success");
return true;

View File

@ -244,7 +244,7 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptr<SessionIn
return;
}
napi_value argv[] = {jsSessionInfo};
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]PendingSessionActivationInner task success, id: %{public}d",
TLOGI(WmsLogTag::WMS_LIFE, "pend active success, id:%{public}d",
sessionInfo->persistentId_);
napi_call_function(env_ref, NapiGetUndefined(env_ref),
jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);

View File

@ -70,6 +70,52 @@ constexpr int ARG_INDEX_0 = 0;
constexpr int ARG_INDEX_1 = 1;
constexpr int ARG_INDEX_2 = 2;
constexpr int ARG_INDEX_3 = 3;
const std::map<std::string, ListenerFuncType> ListenerFuncMap {
{PENDING_SCENE_CB, ListenerFuncType::PENDING_SCENE_CB},
{CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR,
ListenerFuncType::CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR},
{SESSION_STATE_CHANGE_CB, ListenerFuncType::SESSION_STATE_CHANGE_CB},
{BUFFER_AVAILABLE_CHANGE_CB, ListenerFuncType::BUFFER_AVAILABLE_CHANGE_CB},
{SESSION_EVENT_CB, ListenerFuncType::SESSION_EVENT_CB},
{SESSION_RECT_CHANGE_CB, ListenerFuncType::SESSION_RECT_CHANGE_CB},
{SESSION_PIP_CONTROL_STATUS_CHANGE_CB, ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB},
{CREATE_SUB_SESSION_CB, ListenerFuncType::CREATE_SUB_SESSION_CB},
{BIND_DIALOG_TARGET_CB, ListenerFuncType::BIND_DIALOG_TARGET_CB},
{RAISE_TO_TOP_CB, ListenerFuncType::RAISE_TO_TOP_CB},
{RAISE_TO_TOP_POINT_DOWN_CB, ListenerFuncType::RAISE_TO_TOP_POINT_DOWN_CB},
{BACK_PRESSED_CB, ListenerFuncType::BACK_PRESSED_CB},
{SESSION_FOCUSABLE_CHANGE_CB, ListenerFuncType::SESSION_FOCUSABLE_CHANGE_CB},
{SESSION_TOUCHABLE_CHANGE_CB, ListenerFuncType::SESSION_TOUCHABLE_CHANGE_CB},
{SESSION_TOP_MOST_CHANGE_CB, ListenerFuncType::SESSION_TOP_MOST_CHANGE_CB},
{CLICK_CB, ListenerFuncType::CLICK_CB},
{TERMINATE_SESSION_CB, ListenerFuncType::TERMINATE_SESSION_CB},
{TERMINATE_SESSION_CB_NEW, ListenerFuncType::TERMINATE_SESSION_CB_NEW},
{TERMINATE_SESSION_CB_TOTAL, ListenerFuncType::TERMINATE_SESSION_CB_TOTAL},
{SESSION_EXCEPTION_CB, ListenerFuncType::SESSION_EXCEPTION_CB},
{UPDATE_SESSION_LABEL_CB, ListenerFuncType::UPDATE_SESSION_LABEL_CB},
{UPDATE_SESSION_ICON_CB, ListenerFuncType::UPDATE_SESSION_ICON_CB},
{SYSTEMBAR_PROPERTY_CHANGE_CB, ListenerFuncType::SYSTEMBAR_PROPERTY_CHANGE_CB},
{NEED_AVOID_CB, ListenerFuncType::NEED_AVOID_CB},
{PENDING_SESSION_TO_FOREGROUND_CB, ListenerFuncType::PENDING_SESSION_TO_FOREGROUND_CB},
{PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB,
ListenerFuncType::PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB},
{CUSTOM_ANIMATION_PLAYING_CB, ListenerFuncType::CUSTOM_ANIMATION_PLAYING_CB},
{NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB, ListenerFuncType::NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB},
{SHOW_WHEN_LOCKED_CB, ListenerFuncType::SHOW_WHEN_LOCKED_CB},
{REQUESTED_ORIENTATION_CHANGE_CB, ListenerFuncType::REQUESTED_ORIENTATION_CHANGE_CB},
{RAISE_ABOVE_TARGET_CB, ListenerFuncType::RAISE_ABOVE_TARGET_CB},
{FORCE_HIDE_CHANGE_CB, ListenerFuncType::FORCE_HIDE_CHANGE_CB},
{WINDOW_DRAG_HOT_AREA_CB, ListenerFuncType::WINDOW_DRAG_HOT_AREA_CB},
{TOUCH_OUTSIDE_CB, ListenerFuncType::TOUCH_OUTSIDE_CB},
{SESSIONINFO_LOCKEDSTATE_CHANGE_CB, ListenerFuncType::SESSIONINFO_LOCKEDSTATE_CHANGE_CB},
{PREPARE_CLOSE_PIP_SESSION, ListenerFuncType::PREPARE_CLOSE_PIP_SESSION},
{LANDSCAPE_MULTI_WINDOW_CB, ListenerFuncType::LANDSCAPE_MULTI_WINDOW_CB},
{CONTEXT_TRANSPARENT_CB, ListenerFuncType::CONTEXT_TRANSPARENT_CB},
{KEYBOARD_GRAVITY_CHANGE_CB, ListenerFuncType::KEYBOARD_GRAVITY_CHANGE_CB},
{ADJUST_KEYBOARD_LAYOUT_CB, ListenerFuncType::ADJUST_KEYBOARD_LAYOUT_CB},
{LAYOUT_FULL_SCREEN_CB, ListenerFuncType::LAYOUT_FULL_SCREEN_CB},
};
} // namespace
std::map<int32_t, napi_ref> JsSceneSession::jsSceneSessionMap_;
@ -222,6 +268,9 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
JsSceneSession::CloseKeyboardSyncTransaction);
BindNativeFunction(env, objValue, "setCompatibleModeInPc", moduleName,
JsSceneSession::SetCompatibleModeInPc);
BindNativeFunction(env, objValue, "setBlankFlag", moduleName, JsSceneSession::SetBlankFlag);
BindNativeFunction(env, objValue, "setBufferAvailableCallbackEnable", moduleName,
JsSceneSession::SetBufferAvailableCallbackEnable);
}
JsSceneSession::JsSceneSession(napi_env env, const sptr<SceneSession>& session)
@ -257,51 +306,6 @@ JsSceneSession::~JsSceneSession()
void JsSceneSession::InitListenerFuncs()
{
listenerFuncMap_ = {
{PENDING_SCENE_CB, ListenerFunctionType::PENDING_SCENE_CB},
{CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR,
ListenerFunctionType::CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR},
{SESSION_STATE_CHANGE_CB, ListenerFunctionType::SESSION_STATE_CHANGE_CB},
{BUFFER_AVAILABLE_CHANGE_CB, ListenerFunctionType::BUFFER_AVAILABLE_CHANGE_CB},
{SESSION_EVENT_CB, ListenerFunctionType::SESSION_EVENT_CB},
{SESSION_RECT_CHANGE_CB, ListenerFunctionType::SESSION_RECT_CHANGE_CB},
{SESSION_PIP_CONTROL_STATUS_CHANGE_CB, ListenerFunctionType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB},
{CREATE_SUB_SESSION_CB, ListenerFunctionType::CREATE_SUB_SESSION_CB},
{BIND_DIALOG_TARGET_CB, ListenerFunctionType::BIND_DIALOG_TARGET_CB},
{RAISE_TO_TOP_CB, ListenerFunctionType::RAISE_TO_TOP_CB},
{RAISE_TO_TOP_POINT_DOWN_CB, ListenerFunctionType::RAISE_TO_TOP_POINT_DOWN_CB},
{BACK_PRESSED_CB, ListenerFunctionType::BACK_PRESSED_CB},
{SESSION_FOCUSABLE_CHANGE_CB, ListenerFunctionType::SESSION_FOCUSABLE_CHANGE_CB},
{SESSION_TOUCHABLE_CHANGE_CB, ListenerFunctionType::SESSION_TOUCHABLE_CHANGE_CB},
{SESSION_TOP_MOST_CHANGE_CB, ListenerFunctionType::SESSION_TOP_MOST_CHANGE_CB},
{CLICK_CB, ListenerFunctionType::CLICK_CB},
{TERMINATE_SESSION_CB, ListenerFunctionType::TERMINATE_SESSION_CB},
{TERMINATE_SESSION_CB_NEW, ListenerFunctionType::TERMINATE_SESSION_CB_NEW},
{TERMINATE_SESSION_CB_TOTAL, ListenerFunctionType::TERMINATE_SESSION_CB_TOTAL},
{SESSION_EXCEPTION_CB, ListenerFunctionType::SESSION_EXCEPTION_CB},
{UPDATE_SESSION_LABEL_CB, ListenerFunctionType::UPDATE_SESSION_LABEL_CB},
{UPDATE_SESSION_ICON_CB, ListenerFunctionType::UPDATE_SESSION_ICON_CB},
{SYSTEMBAR_PROPERTY_CHANGE_CB, ListenerFunctionType::SYSTEMBAR_PROPERTY_CHANGE_CB},
{NEED_AVOID_CB, ListenerFunctionType::NEED_AVOID_CB},
{PENDING_SESSION_TO_FOREGROUND_CB, ListenerFunctionType::PENDING_SESSION_TO_FOREGROUND_CB},
{PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB,
ListenerFunctionType::PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB},
{CUSTOM_ANIMATION_PLAYING_CB, ListenerFunctionType::CUSTOM_ANIMATION_PLAYING_CB},
{NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB, ListenerFunctionType::NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB},
{SHOW_WHEN_LOCKED_CB, ListenerFunctionType::SHOW_WHEN_LOCKED_CB},
{REQUESTED_ORIENTATION_CHANGE_CB, ListenerFunctionType::REQUESTED_ORIENTATION_CHANGE_CB},
{RAISE_ABOVE_TARGET_CB, ListenerFunctionType::RAISE_ABOVE_TARGET_CB},
{FORCE_HIDE_CHANGE_CB, ListenerFunctionType::FORCE_HIDE_CHANGE_CB},
{WINDOW_DRAG_HOT_AREA_CB, ListenerFunctionType::WINDOW_DRAG_HOT_AREA_CB},
{TOUCH_OUTSIDE_CB, ListenerFunctionType::TOUCH_OUTSIDE_CB},
{SESSIONINFO_LOCKEDSTATE_CHANGE_CB, ListenerFunctionType::SESSIONINFO_LOCKEDSTATE_CHANGE_CB},
{PREPARE_CLOSE_PIP_SESSION, ListenerFunctionType::PREPARE_CLOSE_PIP_SESSION},
{LANDSCAPE_MULTI_WINDOW_CB, ListenerFunctionType::LANDSCAPE_MULTI_WINDOW_CB},
{CONTEXT_TRANSPARENT_CB, ListenerFunctionType::CONTEXT_TRANSPARENT_CB},
{KEYBOARD_GRAVITY_CHANGE_CB, ListenerFunctionType::KEYBOARD_GRAVITY_CHANGE_CB},
{ADJUST_KEYBOARD_LAYOUT_CB, ListenerFunctionType::ADJUST_KEYBOARD_LAYOUT_CB},
{LAYOUT_FULL_SCREEN_CB, ListenerFunctionType::LAYOUT_FULL_SCREEN_CB},
};
}
void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
@ -1228,6 +1232,20 @@ napi_value JsSceneSession::SetCompatibleModeInPc(napi_env env, napi_callback_inf
return (me != nullptr) ? me->OnSetCompatibleModeInPc(env, info) : nullptr;
}
napi_value JsSceneSession::SetBlankFlag(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]SetBlankFlag");
JsSceneSession *me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnSetBlankFlag(env, info) : nullptr;
}
napi_value JsSceneSession::SetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]SetBufferAvailableCallbackEnable");
JsSceneSession *me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnSetBufferAvailableCallbackEnable(env, info) : nullptr;
}
bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSession::IsCallbackRegistered[%s]", type.c_str());
@ -1247,11 +1265,6 @@ bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type,
return false;
}
bool JsSceneSession::IsCallbackTypeSupported(const std::string& type)
{
return listenerFuncMap_.find(type) != listenerFuncMap_.end();
}
napi_value JsSceneSession::OnRegisterCallback(napi_env env, napi_callback_info info)
{
size_t argc = 4;
@ -1271,10 +1284,12 @@ napi_value JsSceneSession::OnRegisterCallback(napi_env env, napi_callback_info i
WLOGFE("[NAPI]Invalid argument");
return NapiGetUndefined(env);
}
if (!IsCallbackTypeSupported(cbType)) {
auto iterFunctionType = ListenerFuncMap.find(cbType);
if (iterFunctionType == ListenerFuncMap.end()) {
WLOGFE("[NAPI]callback type is not supported, type = %{public}s", cbType.c_str());
return NapiGetUndefined(env);
}
ListenerFuncType listenerFuncType = iterFunctionType->second;
if (IsCallbackRegistered(env, cbType, value)) {
WLOGFE("[NAPI]callback is registered, type = %{public}s", cbType.c_str());
return NapiGetUndefined(env);
@ -1294,140 +1309,138 @@ napi_value JsSceneSession::OnRegisterCallback(napi_env env, napi_callback_info i
std::unique_lock<std::shared_mutex> lock(jsCbMapMutex_);
jsCbMap_[cbType] = callbackRef;
}
ProcessRegisterCallback(cbType);
ProcessRegisterCallback(listenerFuncType);
WLOGFD("[NAPI]Register end, type = %{public}s", cbType.c_str());
return NapiGetUndefined(env);
}
void JsSceneSession::ProcessRegisterCallback(const std::string& cbType)
void JsSceneSession::ProcessRegisterCallback(ListenerFuncType listenerFuncType)
{
ListenerFunctionType listenerFuncType = listenerFuncMap_[cbType];
switch (listenerFuncType) {
case ListenerFunctionType::PENDING_SCENE_CB:
switch (static_cast<uint32_t>(listenerFuncType)) {
case static_cast<uint32_t>(ListenerFuncType::PENDING_SCENE_CB):
ProcessPendingSceneSessionActivationRegister();
break;
case ListenerFunctionType::CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR:
case static_cast<uint32_t>(ListenerFuncType::CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR):
ProcessChangeSessionVisibilityWithStatusBarRegister();
break;
case ListenerFunctionType::SESSION_STATE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_STATE_CHANGE_CB):
ProcessSessionStateChangeRegister();
break;
case ListenerFunctionType::BUFFER_AVAILABLE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::BUFFER_AVAILABLE_CHANGE_CB):
ProcessBufferAvailableChangeRegister();
break;
case ListenerFunctionType::SESSION_EVENT_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_EVENT_CB):
ProcessSessionEventRegister();
break;
case ListenerFunctionType::SESSION_RECT_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_RECT_CHANGE_CB):
ProcessSessionRectChangeRegister();
break;
case ListenerFunctionType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB):
ProcessSessionPiPControlStatusChangeRegister();
break;
case ListenerFunctionType::CREATE_SUB_SESSION_CB:
case static_cast<uint32_t>(ListenerFuncType::CREATE_SUB_SESSION_CB):
ProcessCreateSubSessionRegister();
break;
case ListenerFunctionType::BIND_DIALOG_TARGET_CB:
case static_cast<uint32_t>(ListenerFuncType::BIND_DIALOG_TARGET_CB):
ProcessBindDialogTargetRegister();
break;
case ListenerFunctionType::RAISE_TO_TOP_CB:
case static_cast<uint32_t>(ListenerFuncType::RAISE_TO_TOP_CB):
ProcessRaiseToTopRegister();
break;
case ListenerFunctionType::RAISE_TO_TOP_POINT_DOWN_CB:
case static_cast<uint32_t>(ListenerFuncType::RAISE_TO_TOP_POINT_DOWN_CB):
ProcessRaiseToTopForPointDownRegister();
break;
case ListenerFunctionType::BACK_PRESSED_CB:
case static_cast<uint32_t>(ListenerFuncType::BACK_PRESSED_CB):
ProcessBackPressedRegister();
break;
case ListenerFunctionType::SESSION_FOCUSABLE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_FOCUSABLE_CHANGE_CB):
ProcessSessionFocusableChangeRegister();
break;
case ListenerFunctionType::SESSION_TOUCHABLE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_TOUCHABLE_CHANGE_CB):
ProcessSessionTouchableChangeRegister();
break;
case ListenerFunctionType::SESSION_TOP_MOST_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_TOP_MOST_CHANGE_CB):
ProcessSessionTopmostChangeRegister();
break;
case ListenerFunctionType::CLICK_CB:
case static_cast<uint32_t>(ListenerFuncType::CLICK_CB):
ProcessClickRegister();
break;
case ListenerFunctionType::TERMINATE_SESSION_CB:
case static_cast<uint32_t>(ListenerFuncType::TERMINATE_SESSION_CB):
ProcessTerminateSessionRegister();
break;
case ListenerFunctionType::TERMINATE_SESSION_CB_NEW:
case static_cast<uint32_t>(ListenerFuncType::TERMINATE_SESSION_CB_NEW):
ProcessTerminateSessionRegisterNew();
break;
case ListenerFunctionType::TERMINATE_SESSION_CB_TOTAL:
case static_cast<uint32_t>(ListenerFuncType::TERMINATE_SESSION_CB_TOTAL):
ProcessTerminateSessionRegisterTotal();
break;
case ListenerFunctionType::SESSION_EXCEPTION_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSION_EXCEPTION_CB):
ProcessSessionExceptionRegister();
break;
case ListenerFunctionType::UPDATE_SESSION_LABEL_CB:
case static_cast<uint32_t>(ListenerFuncType::UPDATE_SESSION_LABEL_CB):
ProcessUpdateSessionLabelRegister();
break;
case ListenerFunctionType::UPDATE_SESSION_ICON_CB:
case static_cast<uint32_t>(ListenerFuncType::UPDATE_SESSION_ICON_CB):
ProcessUpdateSessionIconRegister();
break;
case ListenerFunctionType::SYSTEMBAR_PROPERTY_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SYSTEMBAR_PROPERTY_CHANGE_CB):
ProcessSystemBarPropertyChangeRegister();
break;
case ListenerFunctionType::NEED_AVOID_CB:
case static_cast<uint32_t>(ListenerFuncType::NEED_AVOID_CB):
ProcessNeedAvoidRegister();
break;
case ListenerFunctionType::PENDING_SESSION_TO_FOREGROUND_CB:
case static_cast<uint32_t>(ListenerFuncType::PENDING_SESSION_TO_FOREGROUND_CB):
ProcessPendingSessionToForegroundRegister();
break;
case ListenerFunctionType::PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB:
case static_cast<uint32_t>(ListenerFuncType::PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB):
ProcessPendingSessionToBackgroundForDelegatorRegister();
break;
case ListenerFunctionType::CUSTOM_ANIMATION_PLAYING_CB:
case static_cast<uint32_t>(ListenerFuncType::CUSTOM_ANIMATION_PLAYING_CB):
ProcessIsCustomAnimationPlaying();
break;
case ListenerFunctionType::NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB):
ProcessSessionDefaultAnimationFlagChangeRegister();
break;
case ListenerFunctionType::SHOW_WHEN_LOCKED_CB:
case static_cast<uint32_t>(ListenerFuncType::SHOW_WHEN_LOCKED_CB):
ProcessShowWhenLockedRegister();
break;
case ListenerFunctionType::REQUESTED_ORIENTATION_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::REQUESTED_ORIENTATION_CHANGE_CB):
ProcessRequestedOrientationChange();
break;
case ListenerFunctionType::RAISE_ABOVE_TARGET_CB:
case static_cast<uint32_t>(ListenerFuncType::RAISE_ABOVE_TARGET_CB):
ProcessRaiseAboveTargetRegister();
break;
case ListenerFunctionType::FORCE_HIDE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::FORCE_HIDE_CHANGE_CB):
ProcessForceHideChangeRegister();
break;
case ListenerFunctionType::WINDOW_DRAG_HOT_AREA_CB:
case static_cast<uint32_t>(ListenerFuncType::WINDOW_DRAG_HOT_AREA_CB):
ProcessWindowDragHotAreaRegister();
break;
case ListenerFunctionType::TOUCH_OUTSIDE_CB:
case static_cast<uint32_t>(ListenerFuncType::TOUCH_OUTSIDE_CB):
ProcessTouchOutsideRegister();
break;
case ListenerFunctionType::SESSIONINFO_LOCKEDSTATE_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::SESSIONINFO_LOCKEDSTATE_CHANGE_CB):
ProcessSessionInfoLockedStateChangeRegister();
break;
case ListenerFunctionType::PREPARE_CLOSE_PIP_SESSION:
case static_cast<uint32_t>(ListenerFuncType::PREPARE_CLOSE_PIP_SESSION):
ProcessPrepareClosePiPSessionRegister();
break;
case ListenerFunctionType::LANDSCAPE_MULTI_WINDOW_CB:
case static_cast<uint32_t>(ListenerFuncType::LANDSCAPE_MULTI_WINDOW_CB):
ProcessLandscapeMultiWindowRegister();
break;
case ListenerFunctionType::CONTEXT_TRANSPARENT_CB:
case static_cast<uint32_t>(ListenerFuncType::CONTEXT_TRANSPARENT_CB):
ProcessContextTransparentRegister();
break;
case ListenerFunctionType::KEYBOARD_GRAVITY_CHANGE_CB:
case static_cast<uint32_t>(ListenerFuncType::KEYBOARD_GRAVITY_CHANGE_CB):
ProcessKeyboardGravityChangeRegister();
break;
case ListenerFunctionType::ADJUST_KEYBOARD_LAYOUT_CB:
case static_cast<uint32_t>(ListenerFuncType::ADJUST_KEYBOARD_LAYOUT_CB):
ProcessAdjustKeyboardLayoutRegister();
break;
case ListenerFunctionType::LAYOUT_FULL_SCREEN_CB:
case static_cast<uint32_t>(ListenerFuncType::LAYOUT_FULL_SCREEN_CB):
ProcessLayoutFullScreenChangeRegister();
break;
default:
WLOGFE("Failed to find function handler! type = %{public}s", cbType.c_str());
break;
}
}
@ -2100,7 +2113,7 @@ void JsSceneSession::OnBackPressed(bool needMoveToBackground)
void JsSceneSession::TerminateSession(const SessionInfo& info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName = %{public}s, abilityName = %{public}s, persistentId = %{public}d",
TLOGI(WmsLogTag::WMS_LIFE, "bundle:%{public}s, ability:%{public}s, id:%{public}d",
info.bundleName_.c_str(), info.abilityName_.c_str(), info.persistentId_);
std::shared_ptr<SessionInfo> sessionInfo = std::make_shared<SessionInfo>(info);
@ -3097,4 +3110,64 @@ napi_value JsSceneSession::OnSetCompatibleModeInPc(napi_env env, napi_callback_i
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSetBlankFlag(napi_env env, napi_callback_info info)
{
size_t argc = ARGC_FOUR;
napi_value argv[ARGC_FOUR] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_ONE) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
bool isAddBlank = false;
if (!ConvertFromJsValue(env, argv[0], isAddBlank)) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert parameter to isAddBlank");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]session is nullptr");
return NapiGetUndefined(env);
}
session->SetBlankFlag(isAddBlank);
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info)
{
size_t argc = ARGC_FOUR;
napi_value argv[ARGC_FOUR] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_ONE) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
bool enable = false;
if (!ConvertFromJsValue(env, argv[0], enable)) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert parameter to enable");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]session is nullptr");
return NapiGetUndefined(env);
}
session->SetBufferAvailableCallbackEnable(enable);
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen

View File

@ -29,6 +29,50 @@
#include "task_scheduler.h"
namespace OHOS::Rosen {
enum class ListenerFuncType : uint32_t {
PENDING_SCENE_CB,
CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR,
SESSION_STATE_CHANGE_CB,
BUFFER_AVAILABLE_CHANGE_CB,
SESSION_EVENT_CB,
SESSION_RECT_CHANGE_CB,
SESSION_PIP_CONTROL_STATUS_CHANGE_CB,
CREATE_SUB_SESSION_CB,
BIND_DIALOG_TARGET_CB,
RAISE_TO_TOP_CB,
RAISE_TO_TOP_POINT_DOWN_CB,
BACK_PRESSED_CB,
SESSION_FOCUSABLE_CHANGE_CB,
SESSION_TOUCHABLE_CHANGE_CB,
SESSION_TOP_MOST_CHANGE_CB,
CLICK_CB,
TERMINATE_SESSION_CB,
TERMINATE_SESSION_CB_NEW,
TERMINATE_SESSION_CB_TOTAL,
SESSION_EXCEPTION_CB,
UPDATE_SESSION_LABEL_CB,
UPDATE_SESSION_ICON_CB,
SYSTEMBAR_PROPERTY_CHANGE_CB,
NEED_AVOID_CB,
PENDING_SESSION_TO_FOREGROUND_CB,
PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB,
CUSTOM_ANIMATION_PLAYING_CB,
NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB,
SHOW_WHEN_LOCKED_CB,
REQUESTED_ORIENTATION_CHANGE_CB,
RAISE_ABOVE_TARGET_CB,
FORCE_HIDE_CHANGE_CB,
WINDOW_DRAG_HOT_AREA_CB,
TOUCH_OUTSIDE_CB,
SESSIONINFO_LOCKEDSTATE_CHANGE_CB,
PREPARE_CLOSE_PIP_SESSION,
LANDSCAPE_MULTI_WINDOW_CB,
CONTEXT_TRANSPARENT_CB,
KEYBOARD_GRAVITY_CHANGE_CB,
ADJUST_KEYBOARD_LAYOUT_CB,
LAYOUT_FULL_SCREEN_CB,
};
class SceneSession;
class JsSceneSession : public std::enable_shared_from_this<JsSceneSession> {
public:
@ -42,50 +86,6 @@ public:
sptr<SceneSession> GetNativeSession() const;
private:
enum class ListenerFunctionType : uint32_t {
PENDING_SCENE_CB,
CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR,
SESSION_STATE_CHANGE_CB,
BUFFER_AVAILABLE_CHANGE_CB,
SESSION_EVENT_CB,
SESSION_RECT_CHANGE_CB,
SESSION_PIP_CONTROL_STATUS_CHANGE_CB,
CREATE_SUB_SESSION_CB,
BIND_DIALOG_TARGET_CB,
RAISE_TO_TOP_CB,
RAISE_TO_TOP_POINT_DOWN_CB,
BACK_PRESSED_CB,
SESSION_FOCUSABLE_CHANGE_CB,
SESSION_TOUCHABLE_CHANGE_CB,
SESSION_TOP_MOST_CHANGE_CB,
CLICK_CB,
TERMINATE_SESSION_CB,
TERMINATE_SESSION_CB_NEW,
TERMINATE_SESSION_CB_TOTAL,
SESSION_EXCEPTION_CB,
UPDATE_SESSION_LABEL_CB,
UPDATE_SESSION_ICON_CB,
SYSTEMBAR_PROPERTY_CHANGE_CB,
NEED_AVOID_CB,
PENDING_SESSION_TO_FOREGROUND_CB,
PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB,
CUSTOM_ANIMATION_PLAYING_CB,
NEED_DEFAULT_ANIMATION_FLAG_CHANGE_CB,
SHOW_WHEN_LOCKED_CB,
REQUESTED_ORIENTATION_CHANGE_CB,
RAISE_ABOVE_TARGET_CB,
FORCE_HIDE_CHANGE_CB,
WINDOW_DRAG_HOT_AREA_CB,
TOUCH_OUTSIDE_CB,
SESSIONINFO_LOCKEDSTATE_CHANGE_CB,
PREPARE_CLOSE_PIP_SESSION,
LANDSCAPE_MULTI_WINDOW_CB,
CONTEXT_TRANSPARENT_CB,
KEYBOARD_GRAVITY_CHANGE_CB,
ADJUST_KEYBOARD_LAYOUT_CB,
LAYOUT_FULL_SCREEN_CB,
};
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
static napi_value UpdateNativeVisibility(napi_env env, napi_callback_info info);
static napi_value SetShowRecent(napi_env env, napi_callback_info info);
@ -115,6 +115,8 @@ private:
static void BindNativeMethod(napi_env env, napi_value objValue, const char* moduleName);
static napi_value SetSkipSelfWhenShowOnVirtualScreen(napi_env env, napi_callback_info info);
static napi_value SetCompatibleModeInPc(napi_env env, napi_callback_info info);
static napi_value SetBlankFlag(napi_env env, napi_callback_info info);
static napi_value SetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info);
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
napi_value OnUpdateNativeVisibility(napi_env env, napi_callback_info info);
@ -144,11 +146,11 @@ private:
napi_value OnSetSkipDraw(napi_env env, napi_callback_info info);
napi_value OnSetSkipSelfWhenShowOnVirtualScreen(napi_env env, napi_callback_info info);
napi_value OnSetCompatibleModeInPc(napi_env env, napi_callback_info info);
napi_value OnSetBlankFlag(napi_env env, napi_callback_info info);
napi_value OnSetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info);
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
void ProcessChangeSessionVisibilityWithStatusBarRegister();
bool IsCallbackTypeSupported(const std::string& type);
void InitListenerFuncs();
void ProcessPendingSceneSessionActivationRegister();
void ProcessSessionStateChangeRegister();
@ -190,7 +192,7 @@ private:
void ProcessKeyboardGravityChangeRegister();
void ProcessAdjustKeyboardLayoutRegister();
void ProcessLayoutFullScreenChangeRegister();
void ProcessRegisterCallback(const std::string& cbType);
void ProcessRegisterCallback(ListenerFuncType listenerFunctionType);
void ChangeSessionVisibilityWithStatusBar(SessionInfo& info, bool visible);
void ChangeSessionVisibilityWithStatusBarInner(std::shared_ptr<SessionInfo> sessionInfo, bool visible);
@ -244,7 +246,6 @@ private:
wptr<SceneSession::SessionChangeCallback> sessionchangeCallback_ = nullptr;
std::shared_mutex jsCbMapMutex_;
std::map<std::string, std::shared_ptr<NativeReference>> jsCbMap_;
std::map<std::string, ListenerFunctionType> listenerFuncMap_;
std::shared_ptr<MainThreadScheduler> taskScheduler_;
static std::map<int32_t, napi_ref> jsSceneSessionMap_;
};

View File

@ -60,6 +60,19 @@ const std::string START_UI_ABILITY_ERROR = "startUIAbilityError";
const std::string ARG_DUMP_HELP = "-h";
const std::string SHIFT_FOCUS_CB = "shiftFocus";
const std::string CALLING_WINDOW_ID_CHANGE_CB = "callingWindowIdChange";
const std::map<std::string, ListenerFunctionType> ListenerFunctionTypeMap {
{CREATE_SYSTEM_SESSION_CB, ListenerFunctionType::CREATE_SYSTEM_SESSION_CB},
{CREATE_KEYBOARD_SESSION_CB, ListenerFunctionType::CREATE_KEYBOARD_SESSION_CB},
{RECOVER_SCENE_SESSION_CB, ListenerFunctionType::RECOVER_SCENE_SESSION_CB},
{STATUS_BAR_ENABLED_CHANGE_CB, ListenerFunctionType::STATUS_BAR_ENABLED_CHANGE_CB},
{OUTSIDE_DOWN_EVENT_CB, ListenerFunctionType::OUTSIDE_DOWN_EVENT_CB},
{SHIFT_FOCUS_CB, ListenerFunctionType::SHIFT_FOCUS_CB},
{CALLING_WINDOW_ID_CHANGE_CB, ListenerFunctionType::CALLING_WINDOW_ID_CHANGE_CB},
{START_UI_ABILITY_ERROR, ListenerFunctionType::START_UI_ABILITY_ERROR},
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
ListenerFunctionType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB},
};
} // namespace
napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
@ -160,23 +173,13 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
JsSceneSessionManager::UpdateDisplayHookInfo);
BindNativeFunction(env, exportObj, "initScheduleUtils", moduleName,
JsSceneSessionManager::InitScheduleUtils);
BindNativeFunction(env, exportObj, "SetAppForceLandscapeMode", moduleName,
JsSceneSessionManager::SetAppForceLandscapeMode);
return NapiGetUndefined(env);
}
JsSceneSessionManager::JsSceneSessionManager(napi_env env) : env_(env)
{
listenerFuncTypeMap_ = {
{CREATE_SYSTEM_SESSION_CB, ListenerFunctionType::CREATE_SYSTEM_SESSION_CB},
{CREATE_KEYBOARD_SESSION_CB, ListenerFunctionType::CREATE_KEYBOARD_SESSION_CB},
{RECOVER_SCENE_SESSION_CB, ListenerFunctionType::RECOVER_SCENE_SESSION_CB},
{STATUS_BAR_ENABLED_CHANGE_CB, ListenerFunctionType::STATUS_BAR_ENABLED_CHANGE_CB},
{OUTSIDE_DOWN_EVENT_CB, ListenerFunctionType::OUTSIDE_DOWN_EVENT_CB},
{SHIFT_FOCUS_CB, ListenerFunctionType::SHIFT_FOCUS_CB},
{CALLING_WINDOW_ID_CHANGE_CB, ListenerFunctionType::CALLING_WINDOW_ID_CHANGE_CB},
{START_UI_ABILITY_ERROR, ListenerFunctionType::START_UI_ABILITY_ERROR},
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
ListenerFunctionType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB},
};
taskScheduler_ = std::make_shared<MainThreadScheduler>(env);
}
@ -557,7 +560,11 @@ napi_value JsSceneSessionManager::RequestSceneSession(napi_env env, napi_callbac
{
WLOGFD("[NAPI]");
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnRequestSceneSession(env, info) : nullptr;
if (me == nullptr) {
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
return nullptr;
}
return me->OnRequestSceneSession(env, info);
}
napi_value JsSceneSessionManager::UpdateSceneSessionWant(napi_env env, napi_callback_info info)
@ -571,21 +578,33 @@ napi_value JsSceneSessionManager::RequestSceneSessionActivation(napi_env env, na
{
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]");
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnRequestSceneSessionActivation(env, info) : nullptr;
if (me == nullptr) {
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
return nullptr;
}
return me->OnRequestSceneSessionActivation(env, info);
}
napi_value JsSceneSessionManager::RequestSceneSessionBackground(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]");
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnRequestSceneSessionBackground(env, info) : nullptr;
if (me == nullptr) {
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
return nullptr;
}
return me->OnRequestSceneSessionBackground(env, info);
}
napi_value JsSceneSessionManager::RequestSceneSessionDestruction(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]");
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnRequestSceneSessionDestruction(env, info) : nullptr;
if (me == nullptr) {
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
return nullptr;
}
return me->OnRequestSceneSessionDestruction(env, info);
}
napi_value JsSceneSessionManager::NotifyForegroundInteractiveStatus(napi_env env, napi_callback_info info)
@ -887,7 +906,15 @@ napi_value JsSceneSessionManager::OnRegisterCallback(napi_env env, napi_callback
if (IsCallbackRegistered(env, cbType, value)) {
return NapiGetUndefined(env);
}
ProcessRegisterCallback(cbType);
auto iterFuncType = ListenerFunctionTypeMap.find(cbType);
if (iterFuncType == ListenerFunctionTypeMap.end()) {
WLOGFE("Failed to find function handler! type = %{public}s", cbType.c_str());
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
ListenerFunctionType listenerFunctionType = iterFuncType->second;
ProcessRegisterCallback(listenerFunctionType);
std::shared_ptr<NativeReference> callbackRef;
napi_ref result = nullptr;
napi_create_reference(env, value, 1, &result);
@ -901,13 +928,9 @@ napi_value JsSceneSessionManager::OnRegisterCallback(napi_env env, napi_callback
return NapiGetUndefined(env);
}
void JsSceneSessionManager::ProcessRegisterCallback(const std::string& cbType)
void JsSceneSessionManager::ProcessRegisterCallback(ListenerFunctionType listenerFunctionType)
{
ListenerFunctionType listenerFuncType = ListenerFunctionType::INVALID;
if (listenerFuncTypeMap_.count(cbType) != 0) {
listenerFuncType = listenerFuncTypeMap_[cbType];
}
switch (listenerFuncType) {
switch (listenerFunctionType) {
case ListenerFunctionType::CREATE_SYSTEM_SESSION_CB:
ProcessCreateSystemSessionRegister();
break;
@ -936,7 +959,6 @@ void JsSceneSessionManager::ProcessRegisterCallback(const std::string& cbType)
ProcessGestureNavigationEnabledChangeListener();
break;
default:
WLOGFE("Failed to find function handler! type = %{public}s", cbType.c_str());
break;
}
}
@ -1177,7 +1199,7 @@ void JsSceneSessionManager::RegisterVirtualPixelRatioChangeListener()
napi_value JsSceneSessionManager::OnGetRootSceneSession(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
WLOGFI("in");
sptr<RootSceneSession> rootSceneSession = SceneSessionManager::GetInstance().GetRootSceneSession();
if (rootSceneSession == nullptr) {
napi_throw(env,
@ -1216,7 +1238,7 @@ napi_value JsSceneSessionManager::OnGetRootSceneSession(napi_env env, napi_callb
napi_value JsSceneSessionManager::OnRequestSceneSession(napi_env env, napi_callback_info info)
{
WLOGFD("[NAPI]");
TLOGD(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1268,7 +1290,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSession(napi_env env, napi_callb
napi_value JsSceneSessionManager::OnUpdateSceneSessionWant(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_MAIN, "[NAPI]");
TLOGD(WmsLogTag::WMS_MAIN, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1309,7 +1331,7 @@ napi_value JsSceneSessionManager::OnUpdateSceneSessionWant(napi_env env, napi_ca
napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -1348,7 +1370,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env,
napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1414,7 +1436,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env,
napi_value JsSceneSessionManager::OnRequestSceneSessionDestruction(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1475,7 +1497,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionDestruction(napi_env env,
napi_value JsSceneSessionManager::OnNotifyForegroundInteractiveStatus(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -1515,7 +1537,7 @@ napi_value JsSceneSessionManager::OnNotifyForegroundInteractiveStatus(napi_env e
napi_value JsSceneSessionManager::OnIsSceneSessionValid(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -1566,7 +1588,7 @@ void JsSceneSessionManager::SetIsClearSession(napi_env env, napi_value jsSceneSe
napi_value JsSceneSessionManager::OnRequestSceneSessionByCall(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1613,7 +1635,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionByCall(napi_env env, napi
napi_value JsSceneSessionManager::OnStartAbilityBySpecified(napi_env env, napi_callback_info info)
{
WLOGFD("[NAPI]");
TLOGD(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1654,7 +1676,7 @@ napi_value JsSceneSessionManager::OnStartAbilityBySpecified(napi_env env, napi_c
napi_value JsSceneSessionManager::OnStartUIAbilityBySCB(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1700,7 +1722,7 @@ napi_value JsSceneSessionManager::OnStartUIAbilityBySCB(napi_env env, napi_callb
napi_value JsSceneSessionManager::OnChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
WLOGFI("in");
WSErrorCode errCode = WSErrorCode::WS_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -1749,7 +1771,7 @@ napi_value JsSceneSessionManager::OnChangeUIAbilityVisibilityBySCB(napi_env env,
napi_value JsSceneSessionManager::OnGetWindowSceneConfig(napi_env env, napi_callback_info info)
{
WLOGFD("[NAPI]");
WLOGFD("in");
const AppWindowSceneConfig& windowSceneConfig = SceneSessionManager::GetInstance().GetWindowSceneConfig();
napi_value jsWindowSceneConfigObj = JsWindowSceneConfig::CreateWindowSceneConfig(env, windowSceneConfig);
if (jsWindowSceneConfigObj == nullptr) {
@ -1786,7 +1808,7 @@ napi_value JsSceneSessionManager::OnGetSessionSnapshotFilePath(napi_env env, nap
napi_value JsSceneSessionManager::OnInitWithRenderServiceAdded(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
WLOGFI("in");
SceneSessionManager::GetInstance().InitWithRenderServiceAdded();
return NapiGetUndefined(env);
}
@ -1882,7 +1904,7 @@ napi_value JsSceneSessionManager::OnSetSystemAnimatedScenes(napi_env env, napi_c
napi_value JsSceneSessionManager::OnPrepareTerminate(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI]");
TLOGI(WmsLogTag::WMS_LIFE, "in");
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -1908,7 +1930,7 @@ napi_value JsSceneSessionManager::OnPrepareTerminate(napi_env env, napi_callback
napi_value JsSceneSessionManager::OnPerfRequestEx(napi_env env, napi_callback_info info)
{
WLOGFD("[NAPI]");
WLOGFD("in");
#ifdef SOC_PERF_ENABLE
size_t argc = 4;
napi_value argv[4] = {nullptr};
@ -2664,4 +2686,41 @@ napi_value JsSceneSessionManager::OnUpdateDisplayHookInfo(napi_env env, napi_cal
SceneSessionManager::GetInstance().UpdateDisplayHookInfo(uid, width, height, static_cast<float_t>(density), enable);
return NapiGetUndefined(env);
}
napi_value JsSceneSessionManager::SetAppForceLandscapeMode(napi_env env, napi_callback_info info)
{
WLOGFI("[NAPI] SetAppForceLandscapeMode");
JsSceneSessionManager *me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnSetAppForceLandscapeMode(env, info) : nullptr;
}
napi_value JsSceneSessionManager::OnSetAppForceLandscapeMode(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_TWO) {
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
WLOGFE("[NAPI]Failed to convert parameter to bundleName");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
int32_t mode;
if (!ConvertFromJsValue(env, argv[1], mode)) {
WLOGFE("[NAPI]Failed to convert parameter to forceLandscapeMode");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
SceneSessionManager::GetInstance().SetAppForceLandscapeMode(bundleName, mode);
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen

View File

@ -29,6 +29,18 @@
#include "session_manager/include/scene_session_manager.h"
namespace OHOS::Rosen {
enum class ListenerFunctionType : uint32_t {
CREATE_SYSTEM_SESSION_CB,
CREATE_KEYBOARD_SESSION_CB,
RECOVER_SCENE_SESSION_CB,
STATUS_BAR_ENABLED_CHANGE_CB,
OUTSIDE_DOWN_EVENT_CB,
SHIFT_FOCUS_CB,
CALLING_WINDOW_ID_CHANGE_CB,
START_UI_ABILITY_ERROR,
GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
};
class JsSceneSessionManager final {
public:
explicit JsSceneSessionManager(napi_env env);
@ -86,21 +98,9 @@ public:
static napi_value NotifyEnterRecentTask(napi_env env, napi_callback_info info);
static napi_value UpdateDisplayHookInfo(napi_env env, napi_callback_info info);
static napi_value InitScheduleUtils(napi_env env, napi_callback_info info);
static napi_value SetAppForceLandscapeMode(napi_env env, napi_callback_info info);
private:
enum class ListenerFunctionType : uint32_t {
CREATE_SYSTEM_SESSION_CB,
CREATE_KEYBOARD_SESSION_CB,
RECOVER_SCENE_SESSION_CB,
STATUS_BAR_ENABLED_CHANGE_CB,
OUTSIDE_DOWN_EVENT_CB,
SHIFT_FOCUS_CB,
CALLING_WINDOW_ID_CHANGE_CB,
START_UI_ABILITY_ERROR,
GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
INVALID
};
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
napi_value OnGetRootSceneSession(napi_env env, napi_callback_info info);
napi_value OnRequestSceneSession(napi_env env, napi_callback_info info);
@ -155,6 +155,7 @@ private:
napi_value OnNotifyEnterRecentTask(napi_env env, napi_callback_info info);
napi_value OnUpdateDisplayHookInfo(napi_env env, napi_callback_info info);
napi_value OnInitScheduleUtils(napi_env env, napi_callback_info info);
napi_value OnSetAppForceLandscapeMode(napi_env env, napi_callback_info info);
void OnStatusBarEnabledUpdate(bool enable);
void OnGestureNavigationEnabledUpdate(bool enable);
@ -174,7 +175,7 @@ private:
void ProcessOutsideDownEvent();
void ProcessShiftFocus();
void ProcessCallingSessionIdChangeRegister();
void ProcessRegisterCallback(const std::string& cbType);
void ProcessRegisterCallback(ListenerFunctionType listenerFunctionType);
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
void RegisterDumpRootSceneElementInfoListener();
void RegisterVirtualPixelRatioChangeListener();
@ -184,7 +185,6 @@ private:
napi_env env_;
std::shared_mutex jsCbMapMutex_;
std::map<std::string, std::shared_ptr<NativeReference>> jsCbMap_;
std::map<std::string, ListenerFunctionType> listenerFuncTypeMap_;
sptr<RootScene> rootScene_;
std::shared_ptr<MainThreadScheduler> taskScheduler_;

View File

@ -15,6 +15,7 @@
#include "js_screen_session.h"
#include <hitrace_meter.h>
#include <js_runtime_utils.h>
#include "interfaces/include/ws_common.h"
@ -373,6 +374,7 @@ void JsScreenSession::OnSensorRotationChange(float sensorRotation, ScreenId scre
auto jsCallbackRef = mCallback_[callbackType];
wptr<ScreenSession> screenSessionWeak(screenSession_);
auto napiTask = [jsCallbackRef, callbackType, screenSessionWeak, sensorRotation, env = env_]() {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnSensorRotationChange");
if (jsCallbackRef == nullptr) {
WLOGFE("Call js callback %{public}s failed, jsCallbackRef is null!", callbackType.c_str());
return;
@ -452,6 +454,7 @@ void JsScreenSession::OnPropertyChange(const ScreenProperty& newProperty, Screen
auto jsCallbackRef = mCallback_[callbackType];
wptr<ScreenSession> screenSessionWeak(screenSession_);
auto napiTask = [jsCallbackRef, callbackType, screenSessionWeak, newProperty, reason, env = env_]() {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnPropertyChange");
if (jsCallbackRef == nullptr) {
WLOGFE("Call js callback %{public}s failed, jsCallbackRef is null!", callbackType.c_str());
return;
@ -532,6 +535,7 @@ void JsScreenSession::OnPowerStatusChange(DisplayPowerEvent event, EventStatus e
auto jsCallbackRef = mCallback_[callbackType];
wptr<ScreenSession> screenSessionWeak(screenSession_);
auto napiTask = [jsCallbackRef, callbackType, screenSessionWeak, event, eventStatus, reason, env = env_]() {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnPowerStatusChange");
if (jsCallbackRef == nullptr) {
WLOGFE("[UL_POWER]Call js callback %{public}s failed, jsCallbackRef is null!", callbackType.c_str());
return;

View File

@ -18,6 +18,7 @@
#include <iservice_registry.h>
#include <system_ability_definition.h>
#include <transaction/rs_transaction.h>
#include <transaction/rs_interfaces.h>
#include "pipeline/rs_node_map.h"
#include "window_manager_hilog.h"
@ -122,6 +123,9 @@ void ScreenSessionManagerClient::OnScreenConnectionChanged(ScreenId screenId, Sc
}
if (screenConnectionListener_) {
screenConnectionListener_->OnScreenConnected(screenSession);
WLOGFI("screenId: %{public}" PRIu64 " density: %{public}f ",
screenId, config.property.GetDensity());
screenSession->SetScreenSceneDpi(config.property.GetDensity());
}
screenSession->Connect();
return;
@ -389,17 +393,26 @@ void ScreenSessionManagerClient::SwitchUserCallback(std::vector<int32_t> oldScbP
return;
}
if (oldScbPids.size() == 0) {
WLOGFI("oldScbPids size 0");
WLOGFE("oldScbPids size 0");
return;
}
std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
for (const auto& iter : screenSessionMap_) {
auto displayNode = screenSessionManager_->GetDisplayNode(iter.first);
if (displayNode == nullptr) {
WLOGFI("display node is null");
WLOGFE("display node is null");
continue;
}
displayNode->SetScbNodePid(oldScbPids, currentScbPid);
auto transactionProxy = RSTransactionProxy::GetInstance();
if (transactionProxy != nullptr) {
transactionProxy->Begin();
displayNode->SetScbNodePid(oldScbPids, currentScbPid);
transactionProxy->Commit();
transactionProxy->FlushImplicitTransaction();
} else {
displayNode->SetScbNodePid(oldScbPids, currentScbPid);
WLOGFW("transactionProxy is null");
}
}
WLOGFI("switch user callback end");
}

View File

@ -74,6 +74,7 @@ private:
void PrintPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event);
void PrintInfoPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event);
static void OnDispatchEventProcessed(int32_t eventId, int64_t actionTime);
bool IsUIExtensionKeyEventBlocked(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
private:
sptr<ISessionStage> sessionStage_ = nullptr;

View File

@ -14,6 +14,7 @@
*/
#include "session/container/include/window_event_channel.h"
#include "scene_board_judgement.h"
#include <functional>
#include <utility>
@ -24,11 +25,16 @@
#include "anr_handler.h"
#include "window_manager_hilog.h"
#include "scene_board_judgement.h"
#include "session_permission.h"
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannel" };
const std::set<int32_t> VALID_KEYCODE_FOR_CONSTRAINED_EMBEDDED_UIEXTENSION({ MMI::KeyEvent::KEYCODE_HOME,
MMI::KeyEvent::KEYCODE_TAB, MMI::KeyEvent::KEYCODE_ESCAPE, MMI::KeyEvent::KEYCODE_DPAD_UP,
MMI::KeyEvent::KEYCODE_DPAD_DOWN, MMI::KeyEvent::KEYCODE_DPAD_LEFT, MMI::KeyEvent::KEYCODE_DPAD_RIGHT,
MMI::KeyEvent::KEYCODE_MOVE_HOME, MMI::KeyEvent::KEYCODE_MOVE_END });
constexpr int32_t SIZE_TWO = 2;
}
void WindowEventChannelListenerProxy::OnTransferKeyEventForConsumed(int32_t keyEventId, bool isPreImeEvent,
@ -87,9 +93,16 @@ WSError WindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::Poin
{
WLOGFD("WindowEventChannel receive pointer event");
PrintPointerEvent(pointerEvent);
if (isUIExtension_ && uiExtensionUsage_ == UIExtensionUsage::MODAL && SceneBoardJudgement::IsSceneBoardEnabled()) {
TLOGE(WmsLogTag::WMS_EVENT, "event blocked because of modal UIExtension");
return WSError::WS_ERROR_INVALID_PERMISSION;
if (SceneBoardJudgement::IsSceneBoardEnabled() && isUIExtension_ &&
(uiExtensionUsage_ == UIExtensionUsage::MODAL ||
uiExtensionUsage_ == UIExtensionUsage::CONSTRAINED_EMBEDDED)) {
if (!SessionPermission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_EVENT, "Point event blocked because of modal/constrained UIExtension:%{public}u",
uiExtensionUsage_);
return WSError::WS_ERROR_INVALID_PERMISSION;
} else {
TLOGW(WmsLogTag::WMS_EVENT, "SystemCalling UIExtension:%{public}u", uiExtensionUsage_);
}
}
if (!sessionStage_) {
WLOGFE("session stage is null!");
@ -139,8 +152,7 @@ WSError WindowEventChannel::TransferKeyEventForConsumed(
WLOGFE("keyEvent is nullptr");
return WSError::WS_ERROR_NULLPTR;
}
if (isUIExtension_ && uiExtensionUsage_ == UIExtensionUsage::MODAL && SceneBoardJudgement::IsSceneBoardEnabled()) {
TLOGE(WmsLogTag::WMS_EVENT, "event blocked because of modal UIExtension");
if (SceneBoardJudgement::IsSceneBoardEnabled() && isUIExtension_ && IsUIExtensionKeyEventBlocked(keyEvent)) {
return WSError::WS_ERROR_INVALID_PERMISSION;
}
if (isPreImeEvent) {
@ -155,6 +167,38 @@ WSError WindowEventChannel::TransferKeyEventForConsumed(
return WSError::WS_OK;
}
bool WindowEventChannel::IsUIExtensionKeyEventBlocked(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
if (uiExtensionUsage_ == UIExtensionUsage::MODAL) {
if (!SessionPermission::IsSystemCalling()) {
TLOGE(WmsLogTag::WMS_EVENT, "Unsupported keyCode due to Modal UIExtension.");
return true;
} else {
TLOGW(WmsLogTag::WMS_EVENT, "SystemCalling UIExtension.");
return false;
}
}
if (uiExtensionUsage_ == UIExtensionUsage::CONSTRAINED_EMBEDDED) {
auto keyCode = keyEvent->GetKeyCode();
if (VALID_KEYCODE_FOR_CONSTRAINED_EMBEDDED_UIEXTENSION.find(keyCode) ==
VALID_KEYCODE_FOR_CONSTRAINED_EMBEDDED_UIEXTENSION.end()) {
TLOGE(WmsLogTag::WMS_EVENT, "Unsupported keyCode due to Constrained embedded UIExtension.");
return true;
}
auto pressedKeys = keyEvent->GetPressedKeys();
if (pressedKeys.size() == SIZE_TWO && keyCode == MMI::KeyEvent::KEYCODE_TAB &&
(pressedKeys[0] == MMI::KeyEvent::KEYCODE_SHIFT_LEFT ||
pressedKeys[0] == MMI::KeyEvent::KEYCODE_SHIFT_RIGHT)) {
// only allows combined keys SHIFT+TAB
return false;
} else if (pressedKeys.size() >= SIZE_TWO) {
TLOGE(WmsLogTag::WMS_EVENT, "Invalid size of PressedKeys due to Constrained embedded UIExtension.");
return true;
}
}
return false;
}
WSError WindowEventChannel::TransferKeyEventForConsumedAsync(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
@ -271,10 +315,8 @@ void WindowEventChannel::PrintInfoPointerEvent(const std::shared_ptr<MMI::Pointe
WLOGFE("Invalid pointer: %{public}d.", pointerId);
return;
}
WLOGFI("pointerId:%{public}d,DownTime:%{public}" PRId64 ",IsPressed:%{public}d,"
"DisplayX:%{public}d,DisplayY:%{public}d,WindowX:%{public}d,WindowY:%{public}d,",
pointerId, item.GetDownTime(), item.IsPressed(), item.GetDisplayX(), item.GetDisplayY(),
item.GetWindowX(), item.GetWindowY());
WLOGFI("pointerId:%{public}d,DownTime:%{public}" PRId64 ",IsPressed:%{public}d",
pointerId, item.GetDownTime(), item.IsPressed());
}
}

View File

@ -75,13 +75,12 @@ using CameraSessionChangeCallback = std::function<void(uint32_t accessTokenId, b
using NotifyLandscapeMultiWindowSessionFunc = std::function<void(bool isLandscapeMultiWindow)>;
using NotifyKeyboardGravityChangeFunc = std::function<void(SessionGravity gravity)>;
using NotifyKeyboardLayoutAdjustFunc = std::function<void(const KeyboardLayoutParams& params)>;
using HandleUpdatePropertyFunc = WMError (SceneSession::*)(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action);
using SessionChangeByActionNotifyManagerFunc = std::function<void(const sptr<SceneSession>& sceneSession,
const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)>;
using SystemSessionBufferAvailableCallback = std::function<void()>;
using NotifyLayoutFullScreenChangeFunc = std::function<void(bool isLayoutFullScreen)>;
using SetSkipSelfWhenShowOnVirtualScreenCallback = std::function<void(uint64_t surfaceNodeId, bool isSkip)>;
using NotifyForceSplitFunc = std::function<int32_t(const std::string& bundleName)>;
class SceneSession : public Session {
public:
// callback for notify SceneSessionManager
@ -227,6 +226,10 @@ public:
virtual void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip);
bool IsAnco() const override;
void SetBlankFlag(bool isAddBlank) override;
bool GetBlankFlag() const override;
void SetBufferAvailableCallbackEnable(bool enable);
bool GetBufferAvailableCallbackEnable() const override;
int32_t GetCollaboratorType() const;
WSRect GetLastSafeRect() const;
WSRect GetSessionTargetRect() const;
@ -278,6 +281,7 @@ public:
void NotifySessionForeground(uint32_t reason, bool withAnimation);
void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits);
void RegisterSessionChangeCallback(const sptr<SceneSession::SessionChangeCallback>& sessionChangeCallback);
void RegisterForceSplitListener(const NotifyForceSplitFunc& func);
void ClearSpecificSessionCbMap();
void SendPointerEventToUI(std::shared_ptr<MMI::PointerEvent> pointerEvent);
bool SendKeyEventToUI(std::shared_ptr<MMI::KeyEvent> keyEvent, bool isPreImeEvent = false);
@ -333,6 +337,10 @@ public:
void UpdateModalUIExtension(const ExtensionWindowEventInfo& extensionInfo);
ExtensionWindowEventInfo GetLastModalUIExtensionEventInfo();
Vector2f GetPosition(bool useUIExtension);
void AddUIExtSurfaceNodeId(uint64_t surfaceNodeId, int32_t persistentId);
void RemoveUIExtSurfaceNodeId(int32_t persistentId);
int32_t GetUIExtPersistentIdBySurfaceNodeId(uint64_t surfaceNodeId) const;
int32_t GetAppForceLandscapeMode(const std::string& bundleName) override;
protected:
void NotifyIsCustomAnimationPlaying(bool isPlaying);
@ -443,6 +451,8 @@ private:
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action);
WMError HandleActionUpdateModeSupportInfo(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action);
WMError ProcessUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action);
void HandleSpecificSystemBarProperty(WindowType type, const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession);
void SetWindowFlags(const sptr<SceneSession>& sceneSession,
@ -452,6 +462,7 @@ private:
NotifySessionRectChangeFunc sessionRectChangeFunc_;
NotifySessionPiPControlStatusChangeFunc sessionPiPControlStatusChangeFunc_;
NotifyForceSplitFunc forceSplitFunc_;
static wptr<SceneSession> enterSession_;
static std::mutex enterSessionMutex_;
mutable std::mutex sessionChangeCbMutex_;
@ -478,9 +489,12 @@ private:
std::atomic_bool isTemporarilyShowWhenLocked_ { false };
std::shared_mutex modalUIExtensionInfoListMutex_;
std::vector<ExtensionWindowEventInfo> modalUIExtensionInfoList_;
mutable std::shared_mutex uiExtNodeIdToPersistentIdMapMutex_;
std::map<uint64_t, int32_t> uiExtNodeIdToPersistentIdMap_;
std::string clientIdentityToken_ = { "" };
static const std::map<uint32_t, HandleUpdatePropertyFunc> sessionFuncMap_;
SessionChangeByActionNotifyManagerFunc sessionChangeByActionNotifyManagerFunc_;
bool isAddBlank_ = false;
bool bufferAvailableCallbackEnable_ = false;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H

View File

@ -319,6 +319,9 @@ public:
bool IsTerminated() const;
bool IsSessionForeground() const;
virtual bool IsAnco() const { return false; }
virtual void SetBlankFlag(bool isAddBlank) {};
virtual bool GetBlankFlag() const { return false; }
virtual bool GetBufferAvailableCallbackEnable() const { return false; }
sptr<IRemoteObject> dialogTargetToken_ = nullptr;
int32_t GetWindowId() const;

View File

@ -111,6 +111,7 @@ public:
virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; }
virtual WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action) { return WMError::WM_OK; }
virtual int32_t GetAppForceLandscapeMode(const std::string& bundleName) { return 0; }
};
} // namespace OHOS::Rosen

View File

@ -58,6 +58,7 @@ enum class SessionInterfaceCode {
TRANS_ID_ADJUST_KEYBOARD_LAYOUT,
TRANS_ID_UPDATE_SESSION_PROPERTY,
TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE,
TRANS_ID_GET_FORCE_LANDSCAPE_MODE,
// Extension
TRANS_ID_TRANSFER_ABILITY_RESULT = 500,

View File

@ -84,6 +84,8 @@ public:
WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) override;
WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action) override;
int32_t GetAppForceLandscapeMode(const std::string& bundleName) override;
private:
static inline BrokerDelegator<SessionProxy> delegator_;
};

View File

@ -71,6 +71,7 @@ private:
int HandleAdjustKeyboardLayout(MessageParcel& data, MessageParcel& reply);
int HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel& reply);
int HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel& reply);
int HandleGetAppForceLandscapeMode(MessageParcel& data, MessageParcel& reply);
// extension extension
int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply);

View File

@ -57,8 +57,9 @@ SessionGravity KeyboardSession::GetKeyboardGravity() const
{
SessionGravity gravity = SessionGravity::SESSION_GRAVITY_DEFAULT;
uint32_t percent = 0;
if (GetSessionProperty()) {
GetSessionProperty()->GetSessionGravity(gravity, percent);
auto sessionProperty = GetSessionProperty();
if (sessionProperty) {
sessionProperty->GetSessionGravity(gravity, percent);
}
TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}d", gravity);
return gravity;
@ -104,8 +105,9 @@ WSError KeyboardSession::Hide()
session->NotifyKeyboardPanelInfoChange(rect, false);
if (session->systemConfig_.uiType_ == "pc") {
session->RestoreCallingSession();
if (session->GetSessionProperty()) {
session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID);
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetCallingSessionId(INVALID_WINDOW_ID);
}
}
return ret;
@ -128,8 +130,9 @@ WSError KeyboardSession::Disconnect(bool isFromClient)
WSRect rect = {0, 0, 0, 0};
session->NotifyKeyboardPanelInfoChange(rect, false);
session->RestoreCallingSession();
if (session->GetSessionProperty()) {
session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID);
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetCallingSessionId(INVALID_WINDOW_ID);
}
return WSError::WS_OK;
};
@ -188,8 +191,9 @@ WSError KeyboardSession::SetKeyboardSessionGravity(SessionGravity gravity, uint3
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onKeyboardGravityChange_) {
session->sessionChangeCallback_->onKeyboardGravityChange_(gravity);
}
if (session->GetSessionProperty()) {
session->GetSessionProperty()->SetKeyboardSessionGravity(gravity, percent);
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetKeyboardSessionGravity(gravity, percent);
}
session->RelayoutKeyBoard();
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
@ -220,11 +224,12 @@ void KeyboardSession::SetCallingSessionId(uint32_t callingSessionId)
uint32_t KeyboardSession::GetCallingSessionId()
{
if (GetSessionProperty() == nullptr) {
auto sessionProperty = GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "Session property is null");
return INVALID_SESSION_ID;
}
return GetSessionProperty()->GetCallingSessionId();
return sessionProperty->GetCallingSessionId();
}
WSError KeyboardSession::AdjustKeyboardLayout(const KeyboardLayoutParams& params)
@ -240,8 +245,9 @@ WSError KeyboardSession::AdjustKeyboardLayout(const KeyboardLayoutParams& params
"PortraitPanelRect: %{public}s", session->GetPersistentId(), static_cast<uint32_t>(params.gravity_),
params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(),
params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str());
if (session->GetSessionProperty()) {
session->GetSessionProperty()->SetKeyboardLayoutParams(params);
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetKeyboardLayoutParams(params);
}
if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onAdjustKeyboardLayout_) {
session->sessionChangeCallback_->onAdjustKeyboardLayout_(params);
@ -274,8 +280,9 @@ int32_t KeyboardSession::GetFocusedSessionId()
int32_t KeyboardSession::GetStatusBarHeight()
{
int32_t statusBarHeight = 0;
auto sessionProperty = GetSessionProperty();
if (specificCallback_ == nullptr || specificCallback_->onGetSceneSessionVectorByType_ == nullptr ||
GetSessionProperty() == nullptr) {
sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardCallback_ or session property is null, get statusBarHeight failed!");
return statusBarHeight;
}
@ -304,9 +311,10 @@ void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>& cal
callingSession->SetLastSafeRect(safeRect);
double textFieldPositionY = 0.0;
double textFieldHeight = 0.0;
if (GetSessionProperty() != nullptr) {
textFieldPositionY = GetSessionProperty()->GetTextFieldPositionY();
textFieldHeight = GetSessionProperty()->GetTextFieldHeight();
auto sessionProperty = GetSessionProperty();
if (sessionProperty != nullptr) {
textFieldPositionY = sessionProperty->GetTextFieldPositionY();
textFieldHeight = sessionProperty->GetTextFieldHeight();
}
sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT,
SessionHelper::TransferToRect(safeRect), safeRect.height_, textFieldPositionY, textFieldHeight);
@ -443,41 +451,43 @@ void KeyboardSession::UseFocusIdIfCallingSessionIdInvalid()
void KeyboardSession::UpdateCallingSessionIdAndPosition(uint32_t callingSessionId)
{
if (GetSessionProperty() == nullptr) {
auto sessionProperty = GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "Session property is nullptr.");
return;
}
uint32_t curSessionId = GetSessionProperty()->GetCallingSessionId();
uint32_t curSessionId = sessionProperty->GetCallingSessionId();
// When calling window id changes, restore the old calling session, raise the new calling session.
if (curSessionId != INVALID_WINDOW_ID && callingSessionId != curSessionId && IsSessionForeground()) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "CallingSession curId: %{public}d, newId: %{public}d",
curSessionId, callingSessionId);
RestoreCallingSession();
GetSessionProperty()->SetCallingSessionId(callingSessionId);
sessionProperty->SetCallingSessionId(callingSessionId);
UseFocusIdIfCallingSessionIdInvalid();
WSRect panelRect = { 0, 0, 0, 0 };
panelRect = (keyboardPanelSession_ == nullptr) ? panelRect : keyboardPanelSession_->GetSessionRect();
RaiseCallingSession(panelRect);
} else {
GetSessionProperty()->SetCallingSessionId(callingSessionId);
sessionProperty->SetCallingSessionId(callingSessionId);
}
}
void KeyboardSession::RelayoutKeyBoard()
{
if (GetSessionProperty() == nullptr) {
auto sessionProperty = GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "Session property is nullptr, relayout keyboard failed");
return;
}
SessionGravity gravity = SessionGravity::SESSION_GRAVITY_DEFAULT;
uint32_t percent = 0;
GetSessionProperty()->GetSessionGravity(gravity, percent);
sessionProperty->GetSessionGravity(gravity, percent);
TLOGI(WmsLogTag::WMS_KEYBOARD, "Gravity: %{public}d, percent: %{public}d", gravity, percent);
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
return;
}
auto displayId = GetSessionProperty()->GetDisplayId();
auto displayId = sessionProperty->GetDisplayId();
auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId);
uint32_t screenWidth = 0;
uint32_t screenHeight = 0;
@ -486,7 +496,7 @@ void KeyboardSession::RelayoutKeyBoard()
screenHeight = screenSession->GetScreenProperty().GetBounds().rect_.height_;
}
auto requestRect = GetSessionProperty()->GetRequestRect();
auto requestRect = sessionProperty->GetRequestRect();
if (gravity == SessionGravity::SESSION_GRAVITY_BOTTOM) {
requestRect.width_ = screenWidth;
requestRect.posX_ = 0;
@ -496,7 +506,7 @@ void KeyboardSession::RelayoutKeyBoard()
}
}
requestRect.posY_ = static_cast<int32_t>(screenHeight - requestRect.height_);
GetSessionProperty()->SetRequestRect(requestRect);
sessionProperty->SetRequestRect(requestRect);
TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, rect: %{public}s", GetPersistentId(),
SessionHelper::TransferToWSRect(requestRect).ToString().c_str());
UpdateSessionRect(SessionHelper::TransferToWSRect(requestRect), SizeChangeReason::UNDEFINED);
@ -542,8 +552,9 @@ void KeyboardSession::CloseKeyboardSyncTransaction(const WSRect& keyboardPanelRe
}
} else {
session->RestoreCallingSession(rsTransaction);
if (session->GetSessionProperty()) {
session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID);
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetCallingSessionId(INVALID_WINDOW_ID);
}
}

View File

@ -66,62 +66,6 @@ std::mutex SceneSession::enterSessionMutex_;
std::shared_mutex SceneSession::windowDragHotAreaMutex_;
std::map<uint32_t, WSRect> SceneSession::windowDragHotAreaMap_;
static bool g_enableForceUIFirst = system::GetParameter("window.forceUIFirst.enabled", "1") == "1";
const std::map<uint32_t, HandleUpdatePropertyFunc> SceneSession::sessionFuncMap_ {
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON),
&SceneSession::HandleActionUpdateTurnScreenOn),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON),
&SceneSession::HandleActionUpdateKeepScreenOn),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE),
&SceneSession::HandleActionUpdateFocusable),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE),
&SceneSession::HandleActionUpdateTouchable),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS),
&SceneSession::HandleActionUpdateSetBrightness),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION),
&SceneSession::HandleActionUpdateOrientation),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE),
&SceneSession::HandleActionUpdatePrivacyMode),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE),
&SceneSession::HandleActionUpdatePrivacyMode),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP),
&SceneSession::HandleActionUpdateSnapshotSkip),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE),
&SceneSession::HandleActionUpdateMaximizeState),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS),
&SceneSession::HandleActionUpdateOtherProps),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS),
&SceneSession::HandleActionUpdateStatusProps),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS),
&SceneSession::HandleActionUpdateNavigationProps),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS),
&SceneSession::HandleActionUpdateNavigationIndicatorProps),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FLAGS),
&SceneSession::HandleActionUpdateFlags),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE),
&SceneSession::HandleActionUpdateMode),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG),
&SceneSession::HandleActionUpdateAnimationFlag),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA),
&SceneSession::HandleActionUpdateTouchHotArea),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE),
&SceneSession::HandleActionUpdateDecorEnable),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS),
&SceneSession::HandleActionUpdateWindowLimits),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED),
&SceneSession::HandleActionUpdateDragenabled),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED),
&SceneSession::HandleActionUpdateRaiseenabled),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS),
&SceneSession::HandleActionUpdateHideNonSystemFloatingWindows),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO),
&SceneSession::HandleActionUpdateTextfieldAvoidInfo),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK),
&SceneSession::HandleActionUpdateWindowMask),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST),
&SceneSession::HandleActionUpdateTopmost),
std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO),
&SceneSession::HandleActionUpdateModeSupportInfo),
};
SceneSession::SceneSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback)
: Session(info)
@ -227,9 +171,10 @@ WSError SceneSession::Foreground(sptr<WindowSessionProperty> property, bool isFr
return WSError::WS_ERROR_DESTROYED_OBJECT;
}
if (property && session->GetSessionProperty()) {
session->GetSessionProperty()->SetWindowMode(property->GetWindowMode());
session->GetSessionProperty()->SetDecorEnable(property->IsDecorEnable());
auto sessionProperty = session->GetSessionProperty();
if (property && sessionProperty) {
sessionProperty->SetWindowMode(property->GetWindowMode());
sessionProperty->SetDecorEnable(property->IsDecorEnable());
}
int32_t persistentId = session->GetPersistentId();
auto ret = session->Session::Foreground(property);
@ -238,7 +183,6 @@ WSError SceneSession::Foreground(sptr<WindowSessionProperty> property, bool isFr
ret, persistentId);
return ret;
}
auto sessionProperty = session->GetSessionProperty();
auto leashWinSurfaceNode = session->GetLeashWinSurfaceNode();
if (leashWinSurfaceNode && sessionProperty) {
bool lastPrivacyMode = sessionProperty->GetPrivacyMode() || sessionProperty->GetSystemPrivacyMode();
@ -528,7 +472,14 @@ static WSError CheckAspectRatioValid(const sptr<SceneSession>& session, float ra
if (MathHelper::NearZero(ratio)) {
return WSError::WS_OK;
}
auto limits = session->GetSessionProperty()->GetWindowLimits();
if (!session) {
return WSError::WS_ERROR_INVALID_PARAM;
}
auto sessionProperty = session->GetSessionProperty();
if (!sessionProperty) {
return WSError::WS_ERROR_INVALID_PARAM;
}
auto limits = sessionProperty->GetWindowLimits();
if (session->IsDecorEnable()) {
if (limits.minWidth_ && limits.maxHeight_ &&
MathHelper::LessNotEqual(ratio, SessionUtils::ToLayoutWidth(limits.minWidth_, vpr) /
@ -652,7 +603,8 @@ void SceneSession::FixKeyboardPositionByKeyboardPanel(sptr<SceneSession> panelSe
if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) {
keyboardSession->winRect_.posX_ = panelSession->winRect_.posX_;
} else {
if (keyboardSession->GetSessionProperty() == nullptr) {
auto sessionProperty = keyboardSession->GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "keyboard property is null");
return;
}
@ -660,7 +612,7 @@ void SceneSession::FixKeyboardPositionByKeyboardPanel(sptr<SceneSession> panelSe
static bool isFoldable = ScreenSessionManagerClient::GetInstance().IsFoldable();
bool isFolded = ScreenSessionManagerClient::GetInstance().GetFoldStatus() == OHOS::Rosen::FoldStatus::FOLDED;
const auto& screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(
keyboardSession->GetSessionProperty()->GetDisplayId());
sessionProperty->GetDisplayId());
Rotation rotation = (screenSession != nullptr) ? screenSession->GetRotation() : Rotation::ROTATION_0;
bool isKeyboardNeedLeftOffset = (isPhone && (!isFoldable || (isFolded)) &&
(rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270));
@ -760,7 +712,12 @@ bool SceneSession::UpdateInputMethodSessionRect(const WSRect&rect, WSRect& newWi
{
SessionGravity gravity;
uint32_t percent = 0;
GetSessionProperty()->GetSessionGravity(gravity, percent);
auto sessionProperty = GetSessionProperty();
if (!sessionProperty) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionProperty is null");
return false;
}
sessionProperty->GetSessionGravity(gravity, percent);
if (GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
(gravity == SessionGravity::SESSION_GRAVITY_BOTTOM || gravity == SessionGravity::SESSION_GRAVITY_DEFAULT)) {
auto defaultDisplayInfo = DisplayManager::GetInstance().GetDefaultDisplay();
@ -859,8 +816,8 @@ void SceneSession::UpdateSessionRectInner(const WSRect& rect, const SizeChangeRe
SetSessionRect(rect);
NotifySessionRectChange(rect, reason);
}
TLOGI(WmsLogTag::WMS_LAYOUT, "Id: %{public}d, reason: %{public}d, newReason: %{public}d, rect: %{public}s, "
"newRequestRect: %{public}s, newWinRect: %{public}s", GetPersistentId(), reason,
TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d reason:%{public}d newReason:%{public}d rect:%{public}s "
"newRequestRect:%{public}s newWinRect:%{public}s", GetPersistentId(), reason,
newReason, rect.ToString().c_str(), newRequestRect.ToString().c_str(), newWinRect.ToString().c_str());
}
@ -1073,10 +1030,12 @@ void SceneSession::CalculateAvoidAreaRect(WSRect& rect, WSRect& avoidRect, Avoid
void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea)
{
if (GetSessionProperty()->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)) {
auto sessionProperty = GetSessionProperty();
if (sessionProperty == nullptr ||
(sessionProperty->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID))) {
return;
}
uint64_t displayId = GetSessionProperty()->GetDisplayId();
uint64_t displayId = sessionProperty->GetDisplayId();
auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId);
if ((Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING ||
Session::GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ||
@ -1111,7 +1070,7 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea)
std::vector<sptr<SceneSession>> statusBarVector;
if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) {
statusBarVector = specificCallback_->onGetSceneSessionVectorByType_(
WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId());
WindowType::WINDOW_TYPE_STATUS_BAR, sessionProperty->GetDisplayId());
}
for (auto& statusBar : statusBarVector) {
if (!(statusBar->isVisible_)) {
@ -1133,14 +1092,15 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea)
(systemConfig_.uiType_ == "phone" || (systemConfig_.uiType_ == "pad" && !IsFreeMultiWindowMode()))) {
return;
}
if (!GetSessionProperty()) {
auto sessionProperty = GetSessionProperty();
if (!sessionProperty) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property");
return;
}
std::vector<sptr<SceneSession>> inputMethodVector;
if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) {
inputMethodVector = specificCallback_->onGetSceneSessionVectorByType_(
WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, GetSessionProperty()->GetDisplayId());
WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, sessionProperty->GetDisplayId());
}
for (auto& inputMethod : inputMethodVector) {
if (inputMethod->GetSessionState() != SessionState::STATE_FOREGROUND &&
@ -1206,13 +1166,14 @@ void SceneSession::GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea)
TLOGI(WmsLogTag::WMS_IMMS, "window mode pip return");
return;
}
if (!GetSessionProperty()) {
auto sessionProperty = GetSessionProperty();
if (!sessionProperty) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property");
return;
}
WSRect barArea;
if (specificCallback_ != nullptr && specificCallback_->onGetAINavigationBarArea_) {
barArea = specificCallback_->onGetAINavigationBarArea_(GetSessionProperty()->GetDisplayId());
barArea = specificCallback_->onGetAINavigationBarArea_(sessionProperty->GetDisplayId());
}
CalculateAvoidAreaRect(rect, barArea, avoidArea);
}
@ -1316,6 +1277,43 @@ Vector2f SceneSession::GetPosition(bool useUIExtension)
return position;
}
void SceneSession::AddUIExtSurfaceNodeId(uint64_t surfaceNodeId, int32_t persistentId)
{
std::unique_lock<std::shared_mutex> lock(uiExtNodeIdToPersistentIdMapMutex_);
TLOGI(WmsLogTag::WMS_UIEXT, "Add uiExtension pair surfaceNodeId=%{public}" PRIu64 ", persistentId=%{public}d",
surfaceNodeId, persistentId);
uiExtNodeIdToPersistentIdMap_.insert(std::make_pair(surfaceNodeId, persistentId));
}
void SceneSession::RemoveUIExtSurfaceNodeId(int32_t persistentId)
{
std::unique_lock<std::shared_mutex> lock(uiExtNodeIdToPersistentIdMapMutex_);
TLOGI(WmsLogTag::WMS_UIEXT, "Remove uiExtension by persistentId=%{public}d", persistentId);
auto iter = uiExtNodeIdToPersistentIdMap_.cbegin();
while (iter != uiExtNodeIdToPersistentIdMap_.cend()) {
if (iter->second == persistentId) {
TLOGI(WmsLogTag::WMS_UIEXT,
"Successfully removed uiExtension pair surfaceNodeId=%{public}" PRIu64 ", persistentId=%{public}d",
iter->first, persistentId);
uiExtNodeIdToPersistentIdMap_.erase(iter);
return;
}
++iter;
}
TLOGE(WmsLogTag::WMS_UIEXT, "Failed to remove uiExtension by persistentId=%{public}d", persistentId);
}
int32_t SceneSession::GetUIExtPersistentIdBySurfaceNodeId(uint64_t surfaceNodeId) const
{
std::shared_lock<std::shared_mutex> lock(uiExtNodeIdToPersistentIdMapMutex_);
auto ret = uiExtNodeIdToPersistentIdMap_.find(surfaceNodeId);
if (ret == uiExtNodeIdToPersistentIdMap_.end()) {
TLOGE(WmsLogTag::WMS_UIEXT, "Failed to find uiExtension by surfaceNodeId=%{public}" PRIu64 "", surfaceNodeId);
return 0;
}
return ret->second;
}
AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type)
{
auto task = [weakThis = wptr(this), type]() -> AvoidArea {
@ -1494,7 +1492,7 @@ WSError SceneSession::HandlePointerStyle(const std::shared_ptr<MMI::PointerEvent
WSError SceneSession::ProcessPointDownSession(int32_t posX, int32_t posY)
{
const auto& id = GetPersistentId();
WLOGFI("id: %{public}d, type: %{public}d, pos: [%{public}d, %{public}d]", id, GetWindowType(), posX, posY);
WLOGFI("id: %{public}d, type: %{public}d", id, GetWindowType());
// notify touch outside
if (specificCallback_ != nullptr && specificCallback_->onSessionTouchOutside_ &&
@ -1874,6 +1872,8 @@ void SceneSession::HandleCompatibleModeMoveDrag(WSRect& rect, const SizeChangeRe
rect.width_ = compatibleInPcLandscapeWidth;
rect.height_ = compatibleInPcLandscapeHeight;
}
SetSurfaceBounds(rect);
UpdateSizeChangeReason(reason);
}
} else {
SetSurfaceBounds(rect);
@ -1940,7 +1940,8 @@ void SceneSession::UpdateWinRectForSystemBar(WSRect& rect)
WLOGFE("specificCallback_ is null!");
return;
}
if (!GetSessionProperty()) {
auto sessionProperty = GetSessionProperty();
if (!sessionProperty) {
WLOGFE("get session property is null!");
return;
}
@ -1948,7 +1949,7 @@ void SceneSession::UpdateWinRectForSystemBar(WSRect& rect)
std::vector<sptr<SceneSession>> statusBarVector;
if (specificCallback_->onGetSceneSessionVectorByType_) {
statusBarVector = specificCallback_->onGetSceneSessionVectorByType_(
WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId());
WindowType::WINDOW_TYPE_STATUS_BAR, sessionProperty->GetDisplayId());
}
for (auto& statusBar : statusBarVector) {
if (!(statusBar->isVisible_)) {
@ -2424,6 +2425,26 @@ bool SceneSession::IsAnco() const
return collaboratorType_ == static_cast<int32_t>(CollaboratorType::RESERVE_TYPE);
}
void SceneSession::SetBlankFlag(bool isAddBlank)
{
isAddBlank_ = isAddBlank;
}
bool SceneSession::GetBlankFlag() const
{
return isAddBlank_;
}
void SceneSession::SetBufferAvailableCallbackEnable(bool enable)
{
bufferAvailableCallbackEnable_ = enable;
}
bool SceneSession::GetBufferAvailableCallbackEnable() const
{
return bufferAvailableCallbackEnable_;
}
int32_t SceneSession::GetCollaboratorType() const
{
return collaboratorType_;
@ -2732,6 +2753,14 @@ WMError SceneSession::UpdateSessionPropertyByAction(const sptr<WindowSessionProp
if (!SessionPermission::IsSystemCalling()) {
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
} else if (action == WSPropertyChangeAction::ACTION_UPDATE_FLAGS) {
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
} else if (action == WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP) {
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
}
bool isSystemCalling = SessionPermission::IsSystemCalling() || SessionPermission::IsStartByHdcd();
@ -2771,12 +2800,72 @@ WMError SceneSession::HandleUpdatePropertyByAction(const sptr<WindowSessionPrope
TLOGE(WmsLogTag::DEFAULT, "property is nullptr");
return WMError::WM_ERROR_NULLPTR;
}
const auto funcIter = sessionFuncMap_.find(static_cast<uint32_t>(action));
if (funcIter == sessionFuncMap_.end()) {
TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!");
return WMError::WM_DO_NOTHING;
return ProcessUpdatePropertyByAction(property, sceneSession, action);
}
WMError SceneSession::ProcessUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
switch (static_cast<uint32_t>(action)) {
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON):
return HandleActionUpdateTurnScreenOn(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON):
return HandleActionUpdateKeepScreenOn(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE):
return HandleActionUpdateFocusable(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE):
return HandleActionUpdateTouchable(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS):
return HandleActionUpdateSetBrightness(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION):
return HandleActionUpdateOrientation(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE):
return HandleActionUpdatePrivacyMode(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE):
return HandleActionUpdatePrivacyMode(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP):
return HandleActionUpdateSnapshotSkip(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE):
return HandleActionUpdateMaximizeState(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS):
return HandleActionUpdateOtherProps(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS):
return HandleActionUpdateStatusProps(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS):
return HandleActionUpdateNavigationProps(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS):
return HandleActionUpdateNavigationIndicatorProps(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FLAGS):
return HandleActionUpdateFlags(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE):
return HandleActionUpdateMode(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG):
return HandleActionUpdateAnimationFlag(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA):
return HandleActionUpdateTouchHotArea(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE):
return HandleActionUpdateDecorEnable(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS):
return HandleActionUpdateWindowLimits(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED):
return HandleActionUpdateDragenabled(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED):
return HandleActionUpdateRaiseenabled(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS):
return HandleActionUpdateHideNonSystemFloatingWindows(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO):
return HandleActionUpdateTextfieldAvoidInfo(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK):
return HandleActionUpdateWindowMask(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST):
return HandleActionUpdateTopmost(property, sceneSession, action);
case static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO):
return HandleActionUpdateModeSupportInfo(property, sceneSession, action);
default:
TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!");
return WMError::WM_DO_NOTHING;
}
return (this->*(funcIter->second))(property, sceneSession, action);
}
WMError SceneSession::HandleActionUpdateTurnScreenOn(const sptr<WindowSessionProperty>& property,
@ -2878,9 +2967,10 @@ WMError SceneSession::HandleActionUpdateSnapshotSkip(const sptr<WindowSessionPro
WMError SceneSession::HandleActionUpdateMaximizeState(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetMaximizeMode(property->GetMaximizeMode());
sceneSession->GetSessionProperty()->SetIsLayoutFullScreen(property->IsLayoutFullScreen());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetMaximizeMode(property->GetMaximizeMode());
sessionProperty->SetIsLayoutFullScreen(property->IsLayoutFullScreen());
}
return WMError::WM_OK;
}
@ -2931,8 +3021,9 @@ WMError SceneSession::HandleActionUpdateFlags(const sptr<WindowSessionProperty>&
WMError SceneSession::HandleActionUpdateMode(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetWindowMode(property->GetWindowMode());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetWindowMode(property->GetWindowMode());
}
sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession, property, action);
return WMError::WM_OK;
@ -2941,8 +3032,9 @@ WMError SceneSession::HandleActionUpdateMode(const sptr<WindowSessionProperty>&
WMError SceneSession::HandleActionUpdateAnimationFlag(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetAnimationFlag(property->GetAnimationFlag());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetAnimationFlag(property->GetAnimationFlag());
}
return WMError::WM_OK;
}
@ -2950,10 +3042,11 @@ WMError SceneSession::HandleActionUpdateAnimationFlag(const sptr<WindowSessionPr
WMError SceneSession::HandleActionUpdateTouchHotArea(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
std::vector<Rect> touchHotAreas;
property->GetTouchHotAreas(touchHotAreas);
sceneSession->GetSessionProperty()->SetTouchHotAreas(touchHotAreas);
sessionProperty->SetTouchHotAreas(touchHotAreas);
}
return WMError::WM_OK;
}
@ -2965,8 +3058,9 @@ WMError SceneSession::HandleActionUpdateDecorEnable(const sptr<WindowSessionProp
TLOGE(WmsLogTag::DEFAULT, "update decor enable permission denied!");
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetDecorEnable(property->IsDecorEnable());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetDecorEnable(property->IsDecorEnable());
}
return WMError::WM_OK;
}
@ -2974,9 +3068,10 @@ WMError SceneSession::HandleActionUpdateDecorEnable(const sptr<WindowSessionProp
WMError SceneSession::HandleActionUpdateWindowLimits(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetWindowLimits(property->GetWindowLimits());
WindowLimits windowLimits = sceneSession->GetSessionProperty()->GetWindowLimits();
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetWindowLimits(property->GetWindowLimits());
WindowLimits windowLimits = sessionProperty->GetWindowLimits();
TLOGI(WmsLogTag::WMS_LAYOUT, "UpdateWindowLimits minWidth:%{public}u, minHeight:%{public}u, "
"maxWidth:%{public}u, maxHeight:%{public}u, vpRatio:%{public}f", windowLimits.minWidth_,
windowLimits.minHeight_, windowLimits.maxWidth_, windowLimits.maxHeight_, windowLimits.vpRatio_);
@ -2992,8 +3087,9 @@ WMError SceneSession::HandleActionUpdateDragenabled(const sptr<WindowSessionProp
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetDragEnabled(property->GetDragEnabled());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetDragEnabled(property->GetDragEnabled());
}
return WMError::WM_OK;
}
@ -3006,8 +3102,9 @@ WMError SceneSession::HandleActionUpdateRaiseenabled(const sptr<WindowSessionPro
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetRaiseEnabled(property->GetRaiseEnabled());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetRaiseEnabled(property->GetRaiseEnabled());
}
return WMError::WM_OK;
}
@ -3030,9 +3127,10 @@ WMError SceneSession::HandleActionUpdateHideNonSystemFloatingWindows(const sptr<
WMError SceneSession::HandleActionUpdateTextfieldAvoidInfo(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetTextFieldPositionY(property->GetTextFieldPositionY());
sceneSession->GetSessionProperty()->SetTextFieldHeight(property->GetTextFieldHeight());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetTextFieldPositionY(property->GetTextFieldPositionY());
sessionProperty->SetTextFieldHeight(property->GetTextFieldHeight());
}
return WMError::WM_OK;
}
@ -3040,9 +3138,10 @@ WMError SceneSession::HandleActionUpdateTextfieldAvoidInfo(const sptr<WindowSess
WMError SceneSession::HandleActionUpdateWindowMask(const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession, WSPropertyChangeAction action)
{
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetWindowMask(property->GetWindowMask());
sceneSession->GetSessionProperty()->SetIsShaped(property->GetIsShaped());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetWindowMask(property->GetWindowMask());
sessionProperty->SetIsShaped(property->GetIsShaped());
sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession, property, action);
}
return WMError::WM_OK;
@ -3748,4 +3847,17 @@ WMError SceneSession::HandleActionUpdateModeSupportInfo(const sptr<WindowSession
}
return WMError::WM_OK;
}
void SceneSession::RegisterForceSplitListener(const NotifyForceSplitFunc& func)
{
forceSplitFunc_ = func;
}
int32_t SceneSession::GetAppForceLandscapeMode(const std::string& bundleName)
{
if (forceSplitFunc_ == nullptr) {
return 0;
}
return forceSplitFunc_(bundleName);
}
} // namespace OHOS::Rosen

View File

@ -917,9 +917,8 @@ WSError Session::Reconnect(const sptr<ISessionStage>& sessionStage, const sptr<I
TLOGE(WmsLogTag::WMS_RECOVER, "property is nullptr");
return WSError::WS_ERROR_NULLPTR;
}
TLOGI(WmsLogTag::WMS_RECOVER, "session with: persistentId=%{public}d, windowState=%{public}u"
" callingPid:%{public}d", property->GetPersistentId(),
static_cast<uint32_t>(property->GetWindowState()), pid);
TLOGI(WmsLogTag::WMS_RECOVER, "id:%{public}d, state:%{public}u, pid:%{public}d",
property->GetPersistentId(), static_cast<uint32_t>(property->GetWindowState()), pid);
if (sessionStage == nullptr || eventChannel == nullptr) {
TLOGE(WmsLogTag::WMS_RECOVER, "session stage or eventChannel is nullptr");
return WSError::WS_ERROR_NULLPTR;
@ -941,8 +940,8 @@ WSError Session::Foreground(sptr<WindowSessionProperty> property, bool isFromCli
{
HandleDialogForeground();
SessionState state = GetSessionState();
TLOGI(WmsLogTag::WMS_LIFE, "Foreground session, id: %{public}d, state: %{public}" PRIu32"", GetPersistentId(),
static_cast<uint32_t>(state));
TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d, state:%{public}u",
GetPersistentId(), static_cast<uint32_t>(state));
if (state != SessionState::STATE_CONNECT && state != SessionState::STATE_BACKGROUND &&
state != SessionState::STATE_INACTIVE) {
TLOGE(WmsLogTag::WMS_LIFE, "Foreground state invalid! state:%{public}u", state);
@ -1093,7 +1092,7 @@ WSError Session::DrawingCompleted()
WSError Session::SetActive(bool active)
{
SessionState state = GetSessionState();
TLOGI(WmsLogTag::WMS_LIFE, "new active: %{public}d, id: %{public}d, state: %{public}" PRIu32,
TLOGI(WmsLogTag::WMS_LIFE, "new active:%{public}d, id:%{public}d, state:%{public}" PRIu32,
active, GetPersistentId(), static_cast<uint32_t>(state));
if (!IsSessionValid()) {
TLOGW(WmsLogTag::WMS_LIFE, "Session is invalid, id: %{public}d state: %{public}u",
@ -2534,24 +2533,20 @@ bool Session::IsSupportDetectWindow(bool isAttach)
bool isPc = systemConfig_.uiType_ == "pc";
bool isPhone = systemConfig_.uiType_ == "phone";
if (!isPc && !isPhone) {
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: device type not support, "
"persistentId:%{public}d", persistentId_);
TLOGI(WmsLogTag::WMS_LIFE, "device type not support, id:%{public}d", persistentId_);
return false;
}
if (isScreenLockedCallback_ && isScreenLockedCallback_()) {
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: Screen is locked, "
"persistentId:%{public}d", persistentId_);
TLOGI(WmsLogTag::WMS_LIFE, "screen locked, id:%{public}d", persistentId_);
return false;
}
if (!SessionHelper::IsMainWindow(GetWindowType())) {
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: Only support mainwindow, "
"persistentId:%{public}d", persistentId_);
TLOGI(WmsLogTag::WMS_LIFE, "only support main window, id:%{public}d", persistentId_);
return false;
}
// Only detecting cold start scenarios on PC
if (isPc && (!isAttach || state_ != SessionState::STATE_DISCONNECT)) {
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: Only support cold start on pc, "
"persistentId:%{public}d", persistentId_);
TLOGI(WmsLogTag::WMS_LIFE, "pc only support cold start, id:%{public}d", persistentId_);
RemoveWindowDetectTask();
return false;
}

View File

@ -55,8 +55,10 @@ WSError SubSession::Show(sptr<WindowSessionProperty> property)
TLOGI(WmsLogTag::WMS_LIFE, "Show session, id: %{public}d", session->GetPersistentId());
// use property from client
if (property && property->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
session->GetSessionProperty()->SetAnimationFlag(static_cast<uint32_t>(WindowAnimation::CUSTOM));
auto sessionProperty = session->GetSessionProperty();
if (property && property->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM) &&
sessionProperty) {
sessionProperty->SetAnimationFlag(static_cast<uint32_t>(WindowAnimation::CUSTOM));
session->NotifyIsCustomAnimationPlaying(true);
}
auto ret = session->SceneSession::Foreground(property);
@ -81,8 +83,9 @@ WSError SubSession::Hide()
}
// background will remove surfaceNode, custom not execute
// not animation playing when already background; inactive may be animation playing
if (session->GetSessionProperty() &&
session->GetSessionProperty()->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty &&
sessionProperty->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
session->NotifyIsCustomAnimationPlaying(true);
return WSError::WS_OK;
}
@ -152,7 +155,8 @@ WSError SubSession::ProcessPointDownSession(int32_t posX, int32_t posY)
WLOGFI("Has dialog foreground, id: %{public}d, type: %{public}d", id, GetWindowType());
return WSError::WS_OK;
}
if (GetSessionProperty() && GetSessionProperty()->GetRaiseEnabled()) {
auto sessionProperty = GetSessionProperty();
if (sessionProperty && sessionProperty->GetRaiseEnabled()) {
RaiseToAppTopForPointDown();
}
PresentFocusIfPointDown();
@ -219,8 +223,9 @@ void SubSession::RectCheck(uint32_t curWidth, uint32_t curHeight)
bool SubSession::IsTopmost() const
{
bool isTopmost = false;
if (GetSessionProperty()) {
isTopmost = GetSessionProperty()->IsTopmost();
auto sessionProperty = GetSessionProperty();
if (sessionProperty) {
isTopmost = sessionProperty->IsTopmost();
}
TLOGI(WmsLogTag::WMS_SUB, "isTopmost: %{public}d", isTopmost);
return isTopmost;

View File

@ -49,7 +49,6 @@ SystemSession::~SystemSession()
void SystemSession::UpdateCameraWindowStatus(bool isShowing)
{
TLOGI(WmsLogTag::WMS_SYSTEM, "isShowing: %{public}d", static_cast<int>(isShowing));
if (specificCallback_ == nullptr) {
return;
}
@ -70,7 +69,7 @@ void SystemSession::UpdateCameraWindowStatus(bool isShowing)
specificCallback_->onCameraSessionChange_(GetSessionProperty()->GetAccessTokenId(), isShowing);
}
} else {
TLOGI(WmsLogTag::WMS_SYSTEM, "skip window type");
TLOGI(WmsLogTag::WMS_SYSTEM, "Skip window type, isShowing: %{public}d", isShowing);
}
}
@ -135,8 +134,9 @@ WSError SystemSession::Hide()
}
// background will remove surfaceNode, custom not execute
// not animation playing when already background; inactive may be animation playing
if (session->GetSessionProperty() &&
session->GetSessionProperty()->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty &&
sessionProperty->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
session->NotifyIsCustomAnimationPlaying(true);
return WSError::WS_OK;
}
@ -200,7 +200,6 @@ WSError SystemSession::ProcessPointDownSession(int32_t posX, int32_t posY)
{
const auto& id = GetPersistentId();
const auto& type = GetWindowType();
WLOGFI("id: %{public}d, type: %{public}d", id, type);
auto parentSession = GetParentSession();
if (parentSession && parentSession->CheckDialogOnForeground()) {
WLOGFI("Parent has dialog foreground, id: %{public}d, type: %{public}d", id, type);
@ -209,9 +208,11 @@ WSError SystemSession::ProcessPointDownSession(int32_t posX, int32_t posY)
return WSError::WS_OK;
}
}
if (type == WindowType::WINDOW_TYPE_DIALOG && GetSessionProperty() && GetSessionProperty()->GetRaiseEnabled()) {
auto sessionProperty = GetSessionProperty();
if (type == WindowType::WINDOW_TYPE_DIALOG && sessionProperty && sessionProperty->GetRaiseEnabled()) {
RaiseToAppTopForPointDown();
}
TLOGI(WmsLogTag::WMS_LIFE, "id: %{public}d, type: %{public}d", id, type);
PresentFocusIfPointDown();
return SceneSession::ProcessPointDownSession(posX, posY);
}

View File

@ -229,8 +229,8 @@ WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const spt
Rect preRect = property->GetWindowRect();
Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() };
TLOGI(WmsLogTag::WMS_LAYOUT, "updateRect when connect."
"preRect:[%{public}d, %{public}d, %{public}u, %{public}u]"
"rect:[%{public}d, %{public}d, %{public}u, %{public}u]",
"preRect:[%{public}d,%{public}d,%{public}u,%{public}u]"
"rect:[%{public}d,%{public}d,%{public}u,%{public}u]",
preRect.posX_, preRect.posY_, preRect.width_, preRect.height_,
rect.posX_, rect.posY_, rect.width_, rect.height_);
if (preRect.IsUninitializedRect() && !rect.IsUninitializedRect()) {
@ -1284,4 +1284,26 @@ WMError SessionProxy::UpdateSessionPropertyByAction(const sptr<WindowSessionProp
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
int32_t SessionProxy::GetAppForceLandscapeMode(const std::string& bundleName)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
return 0;
}
if (!data.WriteString(bundleName)) {
TLOGE(WmsLogTag::DEFAULT, "bundle name write failed");
return 0;
}
if (Remote()->SendRequest(static_cast<uint32_t>(
SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_MODE),
data, reply, option) != ERR_NONE) {
TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
return 0;
}
return reply.ReadInt32();
}
} // namespace OHOS::Rosen

View File

@ -145,6 +145,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag
return HandleUpdatePiPControlStatus(data, reply);
case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE):
return HandleLayoutFullScreenChange(data, reply);
case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_MODE):
return HandleGetAppForceLandscapeMode(data, reply);
default:
WLOGFE("Failed to find function handler!");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@ -753,4 +755,17 @@ int SessionStub::HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel
reply.WriteInt32(static_cast<int32_t>(ret));
return ERR_NONE;
}
int SessionStub::HandleGetAppForceLandscapeMode(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::DEFAULT, "called");
std::string bundleName = data.ReadString();
if (bundleName.empty()) {
TLOGE(WmsLogTag::DEFAULT, "read bundle name filed");
return ERR_INVALID_DATA;
}
int32_t ret = GetAppForceLandscapeMode(bundleName);
reply.WriteInt32(ret);
return ERR_NONE;
}
} // namespace OHOS::Rosen

View File

@ -535,9 +535,7 @@ void ScreenSession::ReportNotifyModeChange(DisplayOrientation displayOrientation
void ScreenSession::UpdateRotationAfterBoot(bool foldToExpand)
{
if (foldToExpand) {
if (property_.GetRotation() != currentSensorRotation_) {
SensorRotationChange(currentSensorRotation_);
}
SensorRotationChange(currentSensorRotation_);
}
}

View File

@ -28,7 +28,7 @@
namespace OHOS {
namespace Rosen {
class SceneSessionDirtyManager;
struct SecSurfaceInfo;
class SceneInputManager : public std::enable_shared_from_this<SceneInputManager> {
WM_DECLARE_SINGLE_INSTANCE_BASE(SceneInputManager)
public:
@ -40,6 +40,7 @@ public:
void SetUserBackground(bool userBackground);
bool IsUserBackground();
void SetCurrentUserId(int32_t userId);
void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap);
protected:
SceneInputManager() = default;

View File

@ -27,7 +27,11 @@
#include "input_manager.h"
namespace OHOS::Rosen {
struct SecSurfaceInfo;
struct SecRectInfo;
MMI::Direction ConvertDegreeToMMIRotation(float degree, MMI::DisplayMode displayMode);
std::string DumpWindowInfo(const MMI::WindowInfo& info);
std::string DumpRect(const std::vector<MMI::Rect>& rects);
class SceneSessionDirtyManager {
private:
enum WindowAction : uint32_t {
@ -49,6 +53,7 @@ public:
std::vector<MMI::WindowInfo> GetFullWindowInfoList();
void RegisterFlushWindowInfoCallback(const FlushWindowInfoCallback &&callback);
void ResetSessionDirty();
void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap);
private:
std::vector<MMI::WindowInfo> FullSceneSessionInfoUpdate() const;
@ -68,14 +73,24 @@ private:
void UpdatePointerAreas(sptr<SceneSession> sceneSession, std::vector<int32_t>& pointerChangeAreas) const;
void UpdateWindowFlags(DisplayId displayId, const sptr<SceneSession> sceneSession,
MMI::WindowInfo& windowInfo) const;
void UpdateModalExtensionWindowInfo(const sptr<SceneSession> sceneSession, MMI::WindowInfo& windowInfo);
void AddModalExtensionWindowInfo(std::vector<MMI::WindowInfo>& windowInfoList, MMI::WindowInfo windowInfo,
const sptr<SceneSession> sceneSession);
std::vector<MMI::WindowInfo> GetSecSurfaceWindowinfoList(const sptr<SceneSession>& sceneSession,
const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTranform) const;
MMI::WindowInfo GetSecComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo,
const MMI::WindowInfo& hostWindowinfo, const sptr<SceneSession>& sceneSession,
const Matrix3f hostTranform) const;
MMI::WindowInfo GetHostComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo,
const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTranform) const;
MMI::WindowInfo MakeWindowInfoFormHostWindow(const SecRectInfo& secRectInfo,
const MMI::WindowInfo& hostWindowinfo) const;
std::mutex mutexlock_;
mutable std::shared_mutex secSurfaceInfoMutex_;
FlushWindowInfoCallback flushWindowInfoCallback_;
std::atomic_bool sessionDirty_ { false };
std::atomic_bool hasPostTask_ { false };
std::map<uint64_t, std::vector<SecSurfaceInfo>> secSurfaceInfoMap_;
};
} //namespace OHOS::Rosen

View File

@ -69,6 +69,8 @@ struct SCBAbilityInfo {
uint32_t sdkVersion_;
};
class SceneSession;
struct SecSurfaceInfo;
class RSUIExtensionData;
class AccessibilityWindowInfo;
class UnreliableWindowInfo;
using NotifyCreateSystemSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
@ -307,13 +309,13 @@ public:
void GetAllWindowVisibilityInfos(std::vector<std::pair<int32_t, uint32_t>>& windowVisibilityInfos);
void FlushWindowInfoToMMI(const bool forceFlush = false);
void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string taskName, const int delayTime);
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
int32_t parentId, UIExtensionUsage usage) override;
void UpdateModalExtensionRect(int32_t persistentId, int32_t parentId, Rect rect) override;
void ProcessModalExtensionPointDown(int32_t persistentId, int32_t parentId,
int32_t posX, int32_t posY) override;
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId) override;
void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) override;
void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) override;
WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override;
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
WSError CheckExtWindowFlagsPermission(ExtensionWindowFlags& actions) const;
WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
uint32_t extWindowActions) override;
void CheckSceneZOrder();
int32_t StartUIAbilityBySCB(sptr<AAFwk::SessionInfo>& abilitySessionInfo);
@ -340,6 +342,9 @@ public:
WMError UpdateDisplayHookInfo(int32_t uid, uint32_t width, uint32_t height, float_t density, bool enable);
void InitScheduleUtils();
WMError ReportScreenFoldStatusChange(const std::vector<std::string>& screenFoldInfo);
void UpdateSecSurfaceInfo(std::shared_ptr<RSUIExtensionData> secExtensionData, uint64_t userid);
WSError SetAppForceLandscapeMode(const std::string& bundleName, int32_t mode);
int32_t GetAppForceLandscapeMode(const std::string& bundleName);
protected:
SceneSessionManager();
@ -484,6 +489,7 @@ private:
const std::vector<std::string>& params, std::string& dumpInfo);
void AddClientDeathRecipient(const sptr<ISessionStage>& sessionStage, const sptr<SceneSession>& sceneSession);
void DestroySpecificSession(const sptr<IRemoteObject>& remoteObject);
bool GetExtensionWindowIds(const sptr<IRemoteObject>& token, int32_t& persistentId, int32_t& parentId);
void DestroyExtensionSession(const sptr<IRemoteObject>& remoteExtSession);
void EraseSceneSessionMapById(int32_t persistentId);
WSError GetAbilityInfosFromBundleInfo(std::vector<AppExecFwk::BundleInfo> &bundleInfos,
@ -506,7 +512,7 @@ private:
void NotifyAllAccessibilityInfo();
void removeFailRecoveredSession();
void SetSkipSelfWhenShowOnVirtualScreen(uint64_t surfaceNodeId, bool isSkip);
void RegisterSecSurfaceInfoListener();
sptr<RootSceneSession> rootSceneSession_;
std::weak_ptr<AbilityRuntime::Context> rootSceneContextWeak_;
mutable std::shared_mutex sceneSessionMapMutex_;
@ -516,7 +522,8 @@ private:
sptr<ScbSessionHandler> scbSessionHandler_;
std::shared_ptr<SessionListenerController> listenerController_;
std::map<sptr<IRemoteObject>, int32_t> remoteObjectMap_;
std::map<sptr<IRemoteObject>, std::pair<int32_t, int32_t>> remoteExtSessionMap_;
std::map<sptr<IRemoteObject>, sptr<IRemoteObject>> remoteExtSessionMap_;
std::map<sptr<IRemoteObject>, ExtensionWindowAbilityInfo> extSessionInfoMap_;
std::set<int32_t> avoidAreaListenerSessionSet_;
std::set<int32_t> touchOutsideListenerSessionSet_;
std::set<int32_t> windowVisibilityListenerSessionSet_;
@ -568,6 +575,8 @@ private:
std::shared_mutex startingWindowMapMutex_;
const size_t MAX_CACHE_COUNT = 100;
std::map<std::string, std::map<std::string, StartingWindowInfo>> startingWindowMap_;
std::map<std::string, int32_t> appForceLandscapeMap_;
std::shared_mutex appForceLandscapeMutex_;
std::mutex privacyBundleMapMutex_;
std::unordered_map<DisplayId, std::unordered_set<std::string>> privacyBundleMap_;

View File

@ -247,6 +247,7 @@ public:
DMError GetAvailableArea(DisplayId displayId, DMRect& area) override;
void NotifyAvailableAreaChanged(DMRect area);
void NotifyFoldToExpandCompletion(bool foldToExpand) override;
bool GetSnapshotArea(Media::Rect &rect, DmErrorCode* errorCode, ScreenId &screenId);
VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override;
DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override;
@ -293,6 +294,7 @@ private:
void AddVirtualScreenDeathRecipient(const sptr<IRemoteObject>& displayManagerAgent, ScreenId smsScreenId);
void PublishCastEvent(const bool &isPlugIn);
void HandleScreenEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
void ScbStatusRecoveryWhenSwitchUser(int32_t newScbPid);
void SetClientInner();
void GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight, bool& isReset, const ScreenId& screenid);
@ -352,6 +354,7 @@ private:
int32_t currentUserId_ { 0 };
int32_t currentScbPId_ { -1 };
std::mutex oldScbPidsMutex_;
std::vector<int32_t> oldScbPids_ {};
mutable std::mutex currentUserIdMutex_;
std::map<int32_t, sptr<IScreenSessionManagerClient>> clientProxyMap_;
@ -418,6 +421,8 @@ private:
std::atomic<bool> buttonBlock_ = false;
std::atomic<bool> isScreenLockSuspend_ = false;
std::atomic<bool> gotScreenlockFingerprint_ = false;
std::atomic<bool> isPhyScreenConnected_ = false;
std::atomic<bool> isInGetSnapshotByPicker_ = false;
// Fold Screen
std::map<ScreenId, ScreenProperty> phyScreenPropMap_;

View File

@ -16,13 +16,13 @@
#ifndef OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_H
#define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_H
#include <shared_mutex>
#include <iremote_stub.h>
#include <shared_mutex>
#include "session_manager_service_interface.h"
#include "mock_session_manager_service_interface.h"
#include "zidl/scene_session_manager_interface.h"
#include "session_manager_service_interface.h"
#include "wm_single_instance.h"
#include "zidl/scene_session_manager_interface.h"
namespace OHOS::Rosen {
class SSMDeathRecipient : public IRemoteObject::DeathRecipient {
@ -35,7 +35,8 @@ public:
};
class SessionManager {
WM_DECLARE_SINGLE_INSTANCE_BASE(SessionManager);
WM_DECLARE_SINGLE_INSTANCE_BASE(SessionManager);
public:
using SessionRecoverCallbackFunc = std::function<void()>;
using WindowManagerRecoverCallbackFunc = std::function<void()>;

View File

@ -50,10 +50,8 @@ public:
sptr<ISessionManagerService> GetSessionManagerServiceProxy();
#ifndef USE_ADAPTER_LITE
void SaveSessionListener(const sptr<ISessionListener>& listener);
void DeleteSessionListener(const sptr<ISessionListener>& listener);
#endif
void RecoverSessionManagerService(const sptr<ISessionManagerService>& sessionManagerService);
void RegisterUserSwitchListener(const UserSwitchCallbackFunc& callbackFunc);
void OnWMSConnectionChanged(
@ -92,9 +90,7 @@ private:
// above guarded by mutex_
std::recursive_mutex listenerLock_;
#ifndef USE_ADAPTER_LITE
std::vector<sptr<ISessionListener>> sessionListeners_;
#endif
// above guarded by listenerLock_
std::mutex wmsConnectionMutex_;

View File

@ -222,16 +222,15 @@ public:
{
return WSError::WS_OK;
}
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
int32_t parentId, UIExtensionUsage usage) override {}
void UpdateModalExtensionRect(int32_t persistentId, int32_t parentId, Rect rect) override {}
void ProcessModalExtensionPointDown(int32_t persistentId, int32_t parentId,
int32_t posX, int32_t posY) override {}
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId) override {}
void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) override {}
void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) override {}
WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override
{
return WSError::WS_OK;
}
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
uint32_t extWindowActions) override
{
return WSError::WS_OK;

View File

@ -17,27 +17,23 @@
#define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
#include <iremote_broker.h>
#ifndef USE_ADAPTER_LITE
#include "common/include/window_session_property.h"
#include "iability_manager_collaborator.h"
#include "interfaces/include/ws_common.h"
#include "interfaces/include/ws_common_inner.h"
#include "mission_info.h"
#include "mission_listener_interface.h"
#include "mission_snapshot.h"
#include "session_info.h"
#include "iability_manager_collaborator.h"
namespace OHOS::Rosen {
using ISessionListener = AAFwk::IMissionListener;
using SessionInfoBean = AAFwk::MissionInfo;
using SessionSnapshot = AAFwk::MissionSnapshot;
}
#endif
#include "interfaces/include/ws_common.h"
#include "interfaces/include/ws_common_inner.h"
#include "zidl/window_manager_lite_interface.h"
namespace OHOS::Media {
class PixelMap;
} // namespace OHOS::Media
namespace OHOS::Rosen {
using ISessionListener = AAFwk::IMissionListener;
using SessionInfoBean = AAFwk::MissionInfo;
using SessionSnapshot = AAFwk::MissionSnapshot;
class ISceneSessionManagerLite : public OHOS::Rosen::IWindowManagerLite {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManagerLite");
@ -80,7 +76,6 @@ public:
TRANS_ID_UNREGISTER_COLLABORATOR,
};
#ifndef USE_ADAPTER_LITE
virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
virtual WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) = 0;
virtual WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) = 0;
@ -107,11 +102,10 @@ public:
virtual WSError MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds, int32_t topSessionId) = 0;
virtual WSError MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
std::vector<std::int32_t>& result) = 0;
virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
#endif
virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H

View File

@ -27,7 +27,6 @@ public:
: IRemoteProxy<ISceneSessionManagerLite>(impl) {}
virtual ~SceneSessionManagerLiteProxy() = default;
#ifndef USE_ADAPTER_LITE
WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) override;
WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) override;
WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) override;
@ -53,7 +52,7 @@ public:
WSError MoveSessionsToBackground(const std::vector<int32_t>& sessionIds, std::vector<int32_t>& result) override;
WSError ClearSession(int32_t persistentId) override;
WSError ClearAllSessions() override;
#endif
void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
@ -66,11 +65,9 @@ public:
WMError GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) override;
WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds) override;
WSError RaiseWindowToTop(int32_t persistentId) override;
#ifndef USE_ADAPTER_LITE
WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
#endif
private:
template<typename T>

View File

@ -99,13 +99,12 @@ public:
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override;
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
int32_t parentId, UIExtensionUsage usage) override;
void UpdateModalExtensionRect(int32_t persistentId, int32_t parentId, Rect rect) override;
void ProcessModalExtensionPointDown(int32_t persistentId, int32_t parentId,
int32_t posX, int32_t posY) override;
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId) override;
void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) override;
void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) override;
WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override;
WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
uint32_t extWindowActions) override;
WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override;
WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus) override;

View File

@ -23,6 +23,7 @@
#include "session_manager/include/scene_session_manager.h"
#include "session_manager/include/screen_session_manager.h"
#include "window_manager_hilog.h"
#include "transaction/rs_uiextension_data.h"
namespace OHOS {
namespace Rosen {
@ -41,17 +42,7 @@ constexpr int MAX_WINDOWINFO_NUM = 15;
constexpr int DEFALUT_DISPLAYID = 0;
constexpr int EMPTY_FOCUS_WINDOW_ID = -1;
std::string DumpRect(const std::vector<MMI::Rect>& rects)
{
std::string rectStr = "";
for (const auto& rect : rects) {
rectStr = rectStr + " hot : [ " + std::to_string(rect.x) +" , " + std::to_string(rect.y) +
" , " + std::to_string(rect.width) + " , " + std::to_string(rect.height) + "]";
}
return rectStr;
}
bool IsEqualUiExtentionWindowInfo(const std::vector<MMI::WindowInfo>& a, const std::vector<MMI::WindowInfo>& b);
bool operator!=(const MMI::Rect& a, const MMI::Rect& b)
{
if (a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height) {
@ -134,19 +125,32 @@ bool operator==(const MMI::WindowInfo& a, const MMI::WindowInfo& b)
if (a.transform != b.transform) {
return false;
}
if (!IsEqualUiExtentionWindowInfo(a.uiExtentionWindowInfo, b.uiExtentionWindowInfo)) {
return false;
}
return true;
}
std::string DumpWindowInfo(const MMI::WindowInfo& info)
bool operator!=(const MMI::WindowInfo& a, const MMI::WindowInfo& b)
{
std::string infoStr = "windowInfo:";
infoStr = infoStr + "windowId: " + std::to_string(info.id) + " pid : " + std::to_string(info.pid) +
" uid: " + std::to_string(info.uid) + " area: [ " + std::to_string(info.area.x) + " , " +
std::to_string(info.area.y) + " , " + std::to_string(info.area.width) + " , " +
std::to_string(info.area.height) + "] agentWindowId:" + std::to_string(info.agentWindowId) + " flags:" +
std::to_string(info.flags) +" displayId: " + std::to_string(info.displayId) +
" action: " + std::to_string(static_cast<int>(info.action)) + " zOrder: " + std::to_string(info.zOrder);
return infoStr + DumpRect(info.defaultHotAreas);
if (a == b) {
return false;
}
return true;
}
bool IsEqualUiExtentionWindowInfo(const std::vector<MMI::WindowInfo>& a, const std::vector<MMI::WindowInfo>& b)
{
if (a.size() != b.size()) {
return false;
}
int size = static_cast<int>(a.size());
for (int i = 0; i < size; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
std::string DumpDisplayInfo(const MMI::DisplayInfo& info)
@ -244,11 +248,11 @@ void SceneInputManager::FlushFullInfoToMMI(const std::vector<MMI::DisplayInfo>&
for (const auto& displayInfo : displayGroupInfo.displaysInfo) {
TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %{public}s", DumpDisplayInfo(displayInfo).c_str());
}
std::string windowinfolst = "windowinfo ";
std::string windowInfoListDump = "windowinfo ";
for (const auto& windowInfo : displayGroupInfo.windowsInfo) {
windowinfolst.append(DumpWindowInfo(windowInfo).append(" || "));
windowInfoListDump.append(DumpWindowInfo(windowInfo).append(" || "));
}
TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %{public}s", windowinfolst.c_str());
TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %{public}s", windowInfoListDump.c_str());
MMI::InputManager::GetInstance()->UpdateDisplayInfo(displayGroupInfo);
}
@ -299,11 +303,11 @@ void SceneInputManager::FlushChangeInfoToMMI(const std::map<uint64_t, std::vecto
for (auto& iter : screenId2Windows) {
auto displayId = iter.first;
auto& windowInfos = iter.second;
std::string windowinfolst = "windowinfo ";
std::string windowInfoListDump = "windowinfo ";
for (auto& windowInfo : windowInfos) {
windowinfolst.append(DumpWindowInfo(windowInfo).append(" || "));
windowInfoListDump.append(DumpWindowInfo(windowInfo).append(" || "));
}
TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] --- %{public}s", windowinfolst.c_str());
TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] --- %{public}s", windowInfoListDump.c_str());
MMI::WindowGroupInfo windowGroup = {focusedSessionId_, displayId, windowInfos};
MMI::InputManager::GetInstance()->UpdateWindowInfo(windowGroup);
}
@ -450,6 +454,7 @@ void SceneInputManager::FlushDisplayInfoToMMI(const bool forceFlush)
return;
}
if (sceneSessionDirty_ == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSessionDirty_ is nullptr");
return;
}
sceneSessionDirty_->ResetSessionDirty();
@ -470,5 +475,14 @@ void SceneInputManager::FlushDisplayInfoToMMI(const bool forceFlush)
eventHandler_->PostTask(task);
}
}
void SceneInputManager::UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap)
{
if (sceneSessionDirty_ == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSessionDirty_ is nullptr");
return;
}
sceneSessionDirty_->UpdateSecSurfaceInfo(secSurfaceInfoMap);
}
}
} // namespace OHOS::Rosen

View File

@ -25,6 +25,7 @@
#include "session_manager/include/scene_session_manager.h"
#include "window_helper.h"
#include "wm_common_inner.h"
#include "transaction/rs_uiextension_data.h"
namespace OHOS::Rosen {
namespace {
@ -94,11 +95,16 @@ bool CmpMMIWindowInfo(const MMI::WindowInfo& a, const MMI::WindowInfo& b)
void SceneSessionDirtyManager::CalNotRotateTramform(const sptr<SceneSession> sceneSession, Matrix3f& tranform,
bool useUIExtension) const
{
if (sceneSession == nullptr || sceneSession->GetSessionProperty() == nullptr) {
WLOGFE("SceneSession or SessionProperty is nullptr");
if (sceneSession == nullptr) {
WLOGFE("sceneSession is nullptr");
return;
}
auto displayId = sceneSession->GetSessionProperty()->GetDisplayId();
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty == nullptr) {
WLOGFE("sessionProperty is nullptr");
return;
}
auto displayId = sessionProperty->GetDisplayId();
auto displayMode = Rosen::ScreenSessionManagerClient::GetInstance().GetFoldDisplayMode();
std::map<ScreenId, ScreenProperty> screensProperties =
Rosen::ScreenSessionManagerClient::GetInstance().GetAllScreensProperties();
@ -181,8 +187,9 @@ void SceneSessionDirtyManager::UpdateDefaultHotAreas(sptr<SceneSession> sceneSes
if ((sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) ||
(sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_PIP)) {
float vpr = 1.5f; // 1.5: default vp
if (sceneSession->GetSessionProperty() != nullptr) {
auto displayId = sceneSession->GetSessionProperty()->GetDisplayId();
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
auto displayId = sessionProperty->GetDisplayId();
auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId);
if (screenSession != nullptr) {
vpr = screenSession->GetScreenProperty().GetDensity();
@ -328,29 +335,6 @@ void SceneSessionDirtyManager::NotifyWindowInfoChange(const sptr<SceneSession>&
}
}
void SceneSessionDirtyManager::UpdateModalExtensionWindowInfo(const sptr<SceneSession> sceneSession,
MMI::WindowInfo& windowInfo)
{
if (sceneSession == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is nullptr");
return;
}
auto extensionInfo = sceneSession->GetLastModalUIExtensionEventInfo();
windowInfo.agentWindowId = extensionInfo.persistentId;
windowInfo.pid = extensionInfo.pid;
std::vector<MMI::Rect> touchHotAreas;
WSRect windowRect = sceneSession->GetSessionRect();
MMI::Rect touchRect = {
.x = 0,
.y = 0,
.width = windowRect.width_,
.height = windowRect.height_
};
touchHotAreas.emplace_back(touchRect);
windowInfo.defaultHotAreas = touchHotAreas;
windowInfo.pointerHotAreas = touchHotAreas;
}
void SceneSessionDirtyManager::AddModalExtensionWindowInfo(std::vector<MMI::WindowInfo>& windowInfoList,
MMI::WindowInfo windowInfo, const sptr<SceneSession> sceneSession)
{
@ -419,11 +403,7 @@ std::vector<MMI::WindowInfo> SceneSessionDirtyManager::GetFullWindowInfoList()
windowInfo.agentWindowId = static_cast<int32_t>(iter->second->GetPersistentId());
windowInfo.pid = static_cast<int32_t>(iter->second->GetCallingPid());
} else if (sceneSessionValue->HasModalUIExtension()) {
if (sceneSessionValue->GetSessionProperty()->IsDecorEnable()) {
AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSessionValue);
} else {
UpdateModalExtensionWindowInfo(sceneSessionValue, windowInfo);
}
AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSessionValue);
}
windowInfoList.emplace_back(windowInfo);
if (windowInfo.defaultHotAreas.size() > maxHotAreasNum) {
@ -439,15 +419,22 @@ std::vector<MMI::WindowInfo> SceneSessionDirtyManager::GetFullWindowInfoList()
void SceneSessionDirtyManager::UpdatePointerAreas(sptr<SceneSession> sceneSession,
std::vector<int32_t>& pointerChangeAreas) const
{
bool dragEnabled = sceneSession->GetSessionProperty()->GetDragEnabled();
if (!sceneSession) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is null");
return;
}
auto sessionProperty = sceneSession->GetSessionProperty();
if (!sessionProperty) {
TLOGE(WmsLogTag::WMS_EVENT, "sessionProperty is null");
return;
}
bool dragEnabled = sessionProperty->GetDragEnabled();
if (dragEnabled) {
float vpr = 1.5f; // 1.5: default vp
if (sceneSession->GetSessionProperty() != nullptr) {
auto displayId = sceneSession->GetSessionProperty()->GetDisplayId();
auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId);
if (screenSession != nullptr) {
vpr = screenSession->GetScreenProperty().GetDensity();
}
auto displayId = sessionProperty->GetDisplayId();
auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId);
if (screenSession != nullptr) {
vpr = screenSession->GetScreenProperty().GetDensity();
}
int32_t pointerAreaFivePx = static_cast<int32_t>(POINTER_CHANGE_AREA_FIVE * vpr);
int32_t pointerAreaSixteenPx = static_cast<int32_t>(POINTER_CHANGE_AREA_SIXTEEN * vpr);
@ -458,7 +445,7 @@ void SceneSessionDirtyManager::UpdatePointerAreas(sptr<SceneSession> sceneSessio
pointerAreaFivePx, pointerAreaSixteenPx, pointerAreaFivePx};
return;
}
auto limits = sceneSession->GetSessionProperty()->GetWindowLimits();
auto limits = sessionProperty->GetWindowLimits();
if (limits.minWidth_ == limits.maxWidth_ && limits.minHeight_ != limits.maxHeight_) {
pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx,
POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT,
@ -558,7 +545,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr<SceneSession>
.transform = transformData,
.pixelMap = pixelMap,
.windowInputType = static_cast<MMI::WindowInputType>(sceneSession->GetSessionInfo().windowInputType_),
.windowType = static_cast<int32_t>(windowType)
.windowType = static_cast<int32_t>(windowType),
};
UpdateWindowFlags(displayId, sceneSession, windowInfo);
if (windowSessionProperty != nullptr && (windowSessionProperty->GetWindowFlags() &
@ -566,6 +553,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr<SceneSession>
windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING;
}
UpdatePrivacyMode(sceneSession, windowInfo);
windowInfo.uiExtentionWindowInfo = GetSecSurfaceWindowinfoList(sceneSession, windowInfo, tranform);
return windowInfo;
}
@ -578,4 +566,206 @@ void SceneSessionDirtyManager::ResetSessionDirty()
{
sessionDirty_.store(false);
}
std::string DumpRect(const std::vector<MMI::Rect>& rects)
{
std::string rectStr = "";
for (const auto& rect : rects) {
rectStr = rectStr + " hot : [ " + std::to_string(rect.x) +" , " + std::to_string(rect.y) +
" , " + std::to_string(rect.width) + " , " + std::to_string(rect.height) + "]";
}
return rectStr;
}
std::string DumpWindowInfo(const MMI::WindowInfo& info)
{
std::string infoStr = "windowInfo:";
infoStr = infoStr + "windowId: " + std::to_string(info.id) + " pid : " + std::to_string(info.pid) +
" uid: " + std::to_string(info.uid) + " area: [ " + std::to_string(info.area.x) + " , " +
std::to_string(info.area.y) + " , " + std::to_string(info.area.width) + " , " +
std::to_string(info.area.height) + "] agentWindowId:" + std::to_string(info.agentWindowId) + " flags:" +
std::to_string(info.flags) +" displayId: " + std::to_string(info.displayId) +
" action: " + std::to_string(static_cast<int>(info.action)) + " zOrder: " + std::to_string(info.zOrder);
return infoStr + DumpRect(info.defaultHotAreas);
}
std::string DumpSecRectInfo(const SecRectInfo & secRectInfo)
{
std::string infoStr = " area: [ " + std::to_string(secRectInfo.relativeCoords.GetLeft()) + " , " +
std::to_string(secRectInfo.relativeCoords.GetTop()) + " , " +
std::to_string(secRectInfo.relativeCoords.GetWidth()) + " , " +
std::to_string(secRectInfo.relativeCoords.GetHeight()) + "]" +
" scaleX:" + std::to_string(secRectInfo.scale[0]) + " scaleY:" + std::to_string(secRectInfo.scale[1]) +
" anchorX:" + std::to_string(secRectInfo.anchor[0]) + " anchorY:" + std::to_string(secRectInfo.anchor[1]);
return infoStr;
}
std::string DumpSecSurfaceInfo(const SecSurfaceInfo& secSurfaceInfo)
{
std::string infoStr = "hostPid:" + std::to_string(secSurfaceInfo.hostPid) +
" uiExtensionPid:" + std::to_string(secSurfaceInfo.uiExtensionPid) +
" hostNodeId:" + std::to_string(secSurfaceInfo.hostNodeId) +
" uiExtensionNodeId:" + std::to_string(secSurfaceInfo.uiExtensionNodeId);
return infoStr;
}
MMI::WindowInfo SceneSessionDirtyManager::MakeWindowInfoFormHostWindow(const SecRectInfo& secRectInfo,
const MMI::WindowInfo& hostWindowinfo) const
{
MMI::WindowInfo windowinfo;
windowinfo.id = hostWindowinfo.id;
windowinfo.pid = hostWindowinfo.pid;
windowinfo.uid = hostWindowinfo.uid;
windowinfo.area = hostWindowinfo.area;
windowinfo.agentWindowId = hostWindowinfo.agentWindowId;
windowinfo.action = hostWindowinfo.action;
windowinfo.displayId = hostWindowinfo.displayId;
windowinfo.flags = hostWindowinfo.flags;
windowinfo.privacyMode = hostWindowinfo.privacyMode;
windowinfo.transform = hostWindowinfo.transform;
return windowinfo;
}
Matrix3f CoordinateSystemHostWindowToScreen(const Matrix3f hostTranform, const SecRectInfo& secRectInfo)
{
Matrix3f transform = Matrix3f::IDENTITY;
Vector2f translate(secRectInfo.relativeCoords.GetLeft(), secRectInfo.relativeCoords.GetTop());
transform = transform.Translate(translate);
Vector2f scale(secRectInfo.scale[0], secRectInfo.scale[1]);
transform = transform.Scale(scale, secRectInfo.anchor[0], secRectInfo.anchor[1]);
transform = hostTranform.Inverse() * transform;
return transform;
}
MMI::Rect CalRectInScreen(const Matrix3f& transform, const SecRectInfo& secRectInfo)
{
auto value1 = transform * Vector3f(0, 0, 1.0);
auto value2 = transform * Vector3f(secRectInfo.relativeCoords.GetWidth(),
secRectInfo.relativeCoords.GetHeight(), 1.0);
auto left = std::min(value1[0], value2[0]);
auto top = std::min(value1[1], value2[1]);
if (INT32_MIN + value2[0] > value1[0]) {
TLOGE(WmsLogTag::WMS_EVENT, "data overflows value1:%{public}d value2:%{public}d",
static_cast<int32_t>(value1[0]), static_cast<int32_t>(value1[1]));
return {};
}
if (INT32_MAX + value2[0] < value1[0]) {
TLOGE(WmsLogTag::WMS_EVENT, "data overflows value1:%{public}d value2:%{public}d",
static_cast<int32_t>(value1[0]), static_cast<int32_t>(value1[1]));
return {};
}
auto width = std::abs(value1[0] - value2[0]);
auto height = std::abs(value1[1] - value2[1]);
return MMI::Rect{ left, top, width, height};
}
MMI::WindowInfo SceneSessionDirtyManager::GetHostComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo,
const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTranform) const
{
MMI::WindowInfo windowinfo;
const auto& secRectInfoList = secSurfaceInfo.upperNodes;
if (secRectInfoList.size() > 0) {
windowinfo = MakeWindowInfoFormHostWindow(secRectInfoList[0], hostWindowinfo);
}
for (const auto& secRectInfo : secRectInfoList) {
auto infoStr = DumpSecRectInfo(secRectInfo);
TLOGI(WmsLogTag::WMS_EVENT, "HostsecRectInfo:%{public}s", infoStr.c_str());
windowinfo.pid = secSurfaceInfo.hostPid;
MMI::Rect hotArea = { secRectInfo.relativeCoords.GetLeft(), secRectInfo.relativeCoords.GetTop(),
secRectInfo.relativeCoords.GetWidth(), secRectInfo.relativeCoords.GetHeight() };
windowinfo.defaultHotAreas.emplace_back(hotArea);
windowinfo.pointerHotAreas.emplace_back(hotArea);
}
auto str = DumpWindowInfo(windowinfo);
TLOGI(WmsLogTag::WMS_EVENT, "host:%{public}s", str.c_str());
return windowinfo;
}
MMI::WindowInfo SceneSessionDirtyManager::GetSecComponentWindowInfo(const SecSurfaceInfo& secSurfaceInfo,
const MMI::WindowInfo& hostWindowinfo, const sptr<SceneSession>& sceneSession, const Matrix3f hostTranform) const
{
if (sceneSession == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is nullptr");
return {};
}
MMI::WindowInfo windowinfo;
const auto& secRectInfo = secSurfaceInfo.uiExtensionRectInfo;
auto infoStr = DumpSecRectInfo(secRectInfo);
TLOGI(WmsLogTag::WMS_EVENT, "secRectInfo:%{public}s", infoStr.c_str());
windowinfo = MakeWindowInfoFormHostWindow(secRectInfo, hostWindowinfo);
windowinfo.id = sceneSession->GetUIExtPersistentIdBySurfaceNodeId(secSurfaceInfo.uiExtensionNodeId);
if (windowinfo.id == 0) {
TLOGE(WmsLogTag::WMS_EVENT, "GetUIExtPersistentId ERROR");
return {};
}
windowinfo.agentWindowId = windowinfo.id;
windowinfo.pid = secSurfaceInfo.uiExtensionPid;
windowinfo.privacyUIFlag = true;
auto transform = CoordinateSystemHostWindowToScreen(hostTranform, secRectInfo);
windowinfo.area = CalRectInScreen(transform, secRectInfo);
MMI::Rect hotArea = { 0, 0, secRectInfo.relativeCoords.GetWidth(), secRectInfo.relativeCoords.GetHeight() };
windowinfo.defaultHotAreas.emplace_back(hotArea);
windowinfo.pointerHotAreas.emplace_back(hotArea);
// 屏幕坐标系到控件坐标系转换
transform = transform.Inverse();
std::vector<float> transformData(transform.GetData(), transform.GetData() + TRANSFORM_DATA_LEN);
windowinfo.transform = transformData;
auto str = DumpWindowInfo(windowinfo);
TLOGI(WmsLogTag::WMS_EVENT, "sec:%{public}s", str.c_str());
return windowinfo;
}
void SceneSessionDirtyManager::UpdateSecSurfaceInfo(const std::map<uint64_t,
std::vector<SecSurfaceInfo>>& secSurfaceInfoMap)
{
std::unique_lock<std::shared_mutex> lock(secSurfaceInfoMutex_);
TLOGD(WmsLogTag::WMS_EVENT, "secSurfaceInfoMap size:%{public}d", int(secSurfaceInfoMap.size()));
secSurfaceInfoMap_ = secSurfaceInfoMap;
}
std::vector<MMI::WindowInfo> SceneSessionDirtyManager::GetSecSurfaceWindowinfoList(
const sptr<SceneSession>& sceneSession, const MMI::WindowInfo& hostWindowinfo, const Matrix3f hostTranform) const
{
if (secSurfaceInfoMap_.size() == 0) {
return {};
}
if (sceneSession == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is nullptr");
return {};
}
auto surfaceNode = sceneSession->GetSurfaceNode();
if (surfaceNode == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "surfaceNode is nullptr");
return {};
}
std::vector<SecSurfaceInfo> secSurfaceInfoList;
auto surfaceNodeId = surfaceNode->GetId();
{
std::shared_lock<std::shared_mutex> lock(secSurfaceInfoMutex_);
auto iter = secSurfaceInfoMap_.find(surfaceNodeId);
if (iter == secSurfaceInfoMap_.end()) {
return {};
}
secSurfaceInfoList = iter->second;
}
TLOGI(WmsLogTag::WMS_EVENT, "hostWindowId:%{public}d secSurfaceInfoList:%{public}d secSurfaceInfoMap:%{public}d",
hostWindowinfo.id, static_cast<int>(secSurfaceInfoList.size()), static_cast<int>(secSurfaceInfoMap_.size()));
std::vector<MMI::WindowInfo> windowinfoList;
int seczOrder = 0;
MMI::WindowInfo windowinfo;
for (const auto& secSurfaceInfo : secSurfaceInfoList) {
auto infoStr = DumpSecSurfaceInfo(secSurfaceInfo);
TLOGI(WmsLogTag::WMS_EVENT, "secSurfaceInfo:%{public}s", infoStr.c_str());
windowinfo = GetSecComponentWindowInfo(secSurfaceInfo, hostWindowinfo, sceneSession, hostTranform);
windowinfo.zOrder = seczOrder++;
windowinfoList.emplace_back(windowinfo);
windowinfo = GetHostComponentWindowInfo(secSurfaceInfo, hostWindowinfo, hostTranform);
windowinfo.zOrder = seczOrder++;
windowinfoList.emplace_back(windowinfo);
}
TLOGI(WmsLogTag::WMS_EVENT, "surfaceNodeId:%{public}" PRIu64" windowinfoList:%{public}d",
surfaceNodeId, int(windowinfoList.size()));
return windowinfoList;
}
} //namespace OHOS::Rosen

View File

@ -53,6 +53,7 @@
#include "screen.h"
#include "singleton.h"
#include "transaction/rs_sync_transaction_controller.h"
#include "transaction/rs_uiextension_data.h"
#ifdef POWERMGR_DISPLAY_MANAGER_ENABLE
#include <display_power_mgr_client.h>
@ -251,7 +252,7 @@ void SceneSessionManager::Init()
sptr<IDisplayChangeListener> listener = new DisplayChangeListener();
ScreenSessionManagerClient::GetInstance().RegisterDisplayChangeListener(listener);
InitPrepareTerminateConfig();
RegisterSecSurfaceInfoListener();
// create handler for inner command at server
eventLoop_ = AppExecFwk::EventRunner::Create(WINDOW_INFO_REPORT_THREAD);
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(eventLoop_);
@ -1310,14 +1311,19 @@ WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t &pid)
void SceneSessionManager::CreateKeyboardPanelSession(sptr<SceneSession> keyboardSession)
{
if (!isKeyboardPanelEnabled_) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is not enabled");
TLOGI(WmsLogTag::WMS_KEYBOARD, "keyboardPanel is not enabled");
return;
}
if (keyboardSession == nullptr || keyboardSession->GetSessionProperty() == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardSession or property is nullptr");
if (keyboardSession == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardSession is nullptr");
return;
}
DisplayId displayId = keyboardSession->GetSessionProperty()->GetDisplayId();
auto sessionProperty = keyboardSession->GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionProperty is null");
return;
}
DisplayId displayId = sessionProperty->GetDisplayId();
const auto& panelVec = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL, displayId);
sptr<SceneSession> panelSession;
if (panelVec.size() > 1) {
@ -1325,7 +1331,7 @@ void SceneSessionManager::CreateKeyboardPanelSession(sptr<SceneSession> keyboard
return;
} else if (panelVec.size() == 1) {
panelSession = panelVec.front();
TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is created, panelId:%{public}d", panelSession->GetPersistentId());
TLOGI(WmsLogTag::WMS_KEYBOARD, "keyboardPanel is created, panelId:%{public}d", panelSession->GetPersistentId());
} else {
SessionInfo panelInfo = {
.bundleName_ = "SCBKeyboardPanel",
@ -1401,6 +1407,8 @@ sptr<SceneSession> SceneSessionManager::CreateSceneSession(const SessionInfo& se
if (sceneSession != nullptr) {
sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId());
sceneSession->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_;
sceneSession->RegisterForceSplitListener(std::bind(&SceneSessionManager::GetAppForceLandscapeMode,
this, std::placeholders::_1));
}
return sceneSession;
}
@ -1465,11 +1473,15 @@ void SceneSessionManager::InitSceneSession(sptr<SceneSession>& sceneSession, con
DisplayId curDisplayId = DISPLAY_ID_INVALID;
if (sessionInfo.screenId_ != SCREEN_ID_INVALID) {
curDisplayId = sessionInfo.screenId_;
} else if (callerSession && callerSession->GetSessionProperty()) {
curDisplayId = callerSession->GetSessionProperty()->GetDisplayId();
} else if (callerSession) {
auto callerSessionProperty = callerSession->GetSessionProperty();
if (callerSessionProperty) {
curDisplayId = callerSessionProperty->GetDisplayId();
}
}
if (sceneSession->GetSessionProperty()) {
sceneSession->GetSessionProperty()->SetDisplayId(curDisplayId);
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty) {
sessionProperty->SetDisplayId(curDisplayId);
sceneSession->SetScreenId(curDisplayId);
TLOGD(WmsLogTag::WMS_LIFE, "synchronous screenId with displayid %{public}" PRIu64,
curDisplayId);
@ -1598,9 +1610,10 @@ sptr<AAFwk::SessionInfo> SceneSessionManager::SetAbilitySessionInfo(const sptr<S
abilitySessionInfo->want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_,
sessionInfo.moduleName_);
}
if (scnSession->GetSessionProperty()) {
auto sessionProperty = scnSession->GetSessionProperty();
if (sessionProperty) {
abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID,
static_cast<int>(scnSession->GetSessionProperty()->GetDisplayId()));
static_cast<int>(sessionProperty->GetDisplayId()));
}
return abilitySessionInfo;
}
@ -2075,6 +2088,9 @@ WSError SceneSessionManager::RequestSceneSessionDestructionInner(
} else {
// if terminate, reset want. so start from recent, start a new one.
TLOGI(WmsLogTag::WMS_MAIN, "reset want: %{public}d", persistentId);
if (CheckCollaboratorType(scnSession->GetCollaboratorType())) {
scnSession->SetSessionInfoWant(nullptr);
}
auto& sessionInfo = scnSession->GetSessionInfo();
if (sessionInfo.want != nullptr) {
const auto& bundleName = sessionInfo.want->GetElement().GetBundleName();
@ -2138,41 +2154,6 @@ void SceneSessionManager::DestroySpecificSession(const sptr<IRemoteObject>& remo
taskScheduler_->PostAsyncTask(task, "DestroySpecificSession");
}
void SceneSessionManager::DestroyExtensionSession(const sptr<IRemoteObject>& remoteExtSession)
{
auto task = [this, remoteExtSession]() {
auto iter = remoteExtSessionMap_.find(remoteExtSession);
if (iter == remoteExtSessionMap_.end()) {
TLOGE(WmsLogTag::WMS_UIEXT, "Invalid remoteExtSession");
return;
}
auto persistentId = iter->second.first;
auto parentId = iter->second.second;
TLOGD(WmsLogTag::WMS_UIEXT, "Remote died, id: %{public}d", persistentId);
auto sceneSession = GetSceneSession(parentId);
if (sceneSession != nullptr) {
auto oldFlags = sceneSession->GetCombinedExtWindowFlags();
sceneSession->RemoveExtWindowFlags(persistentId);
if (oldFlags.hideNonSecureWindowsFlag) {
HandleSecureSessionShouldHide(sceneSession);
}
if (oldFlags.waterMarkFlag) {
CheckAndNotifyWaterMarkChangedResult();
}
if (oldFlags.privacyModeFlag) {
UpdatePrivateStateAndNotify(parentId);
}
sceneSession->RemoveModalUIExtension(persistentId);
} else {
ExtensionWindowFlags actions;
actions.SetAllActive();
HandleSpecialExtWindowFlagsChange(persistentId, ExtensionWindowFlags(), actions);
}
remoteExtSessionMap_.erase(iter);
};
taskScheduler_->PostAsyncTask(task, "DestroyExtensionSession");
}
WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
@ -2812,9 +2793,10 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId)
if (sceneSession == nullptr) {
continue;
}
auto sessionProperty = sceneSession->GetSessionProperty();
if (sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
sceneSession->GetSessionProperty() != nullptr) {
callingSessionId = static_cast<int32_t>(sceneSession->GetSessionProperty()->GetCallingSessionId());
sessionProperty != nullptr) {
callingSessionId = static_cast<int32_t>(sessionProperty->GetCallingSessionId());
TLOGI(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, callingSessionId: %{public}d",
persistentId, callingSessionId);
}
@ -2981,6 +2963,7 @@ WSError SceneSessionManager::InitUserInfo(int32_t userId, std::string &fileDir)
ScenePersistence::CreateUpdatedIconDir(fileDir);
currentUserId_ = userId;
SceneInputManager::GetInstance().SetCurrentUserId(currentUserId_);
RegisterSecSurfaceInfoListener();
return WSError::WS_OK;
};
return taskScheduler_->PostSyncTask(task, "InitUserInfo");
@ -3282,8 +3265,9 @@ WMError SceneSessionManager::UpdatePropertyDragEnabled(const sptr<WindowSessionP
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetDragEnabled(property->GetDragEnabled());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetDragEnabled(property->GetDragEnabled());
}
return WMError::WM_OK;
}
@ -3296,8 +3280,9 @@ WMError SceneSessionManager::UpdatePropertyRaiseEnabled(const sptr<WindowSession
return WMError::WM_ERROR_NOT_SYSTEM_APP;
}
if (sceneSession->GetSessionProperty() != nullptr) {
sceneSession->GetSessionProperty()->SetRaiseEnabled(property->GetRaiseEnabled());
auto sessionProperty = sceneSession->GetSessionProperty();
if (sessionProperty != nullptr) {
sessionProperty->SetRaiseEnabled(property->GetRaiseEnabled());
}
return WMError::WM_OK;
}
@ -3768,7 +3753,8 @@ bool SceneSessionManager::IsSessionVisible(const sptr<SceneSession>& session)
return false;
}
if (session->IsVisible() || state == SessionState::STATE_ACTIVE || state == SessionState::STATE_FOREGROUND) {
if (session->IsVisible() || (session->GetAttachState() && (state == SessionState::STATE_ACTIVE ||
state == SessionState::STATE_FOREGROUND))) {
WLOGFD("Window is at foreground, id: %{public}d", session->GetPersistentId());
return true;
}
@ -3791,9 +3777,10 @@ void SceneSessionManager::DumpSessionInfo(const sptr<SceneSession>& session, std
}
uint32_t flag = 0;
uint64_t displayId = INVALID_SCREEN_ID;
if (session->GetSessionProperty()) {
flag = session->GetSessionProperty()->GetWindowFlags();
displayId = session->GetSessionProperty()->GetDisplayId();
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty) {
flag = sessionProperty->GetWindowFlags();
displayId = sessionProperty->GetDisplayId();
}
uint32_t orientation = 0;
const std::string& windowName = sName.size() <= WINDOW_NAME_MAX_LENGTH ?
@ -3915,14 +3902,17 @@ WSError SceneSessionManager::GetSpecifiedSessionDumpInfo(std::string& dumpInfo,
if (session == nullptr) {
return WSError::WS_ERROR_INVALID_PARAM;
}
auto sessionProperty = session->GetSessionProperty();
if (sessionProperty == nullptr) {
return WSError::WS_ERROR_INVALID_PARAM;
}
WSRect rect = session->GetSessionRect();
std::string isVisible = session->GetVisible() ? "true" : "false";
std::string Focusable = session->GetFocusable() ? "true" : "false";
std::string DecoStatus = session->GetSessionProperty()->IsDecorEnable() ? "true" : "false";
bool PrivacyMode = session->GetSessionProperty()->GetSystemPrivacyMode() ||
session->GetSessionProperty()->GetPrivacyMode();
std::string isPrivacyMode = PrivacyMode ? "true" : "false";
std::string focusable = session->GetFocusable() ? "true" : "false";
std::string decoStatus = sessionProperty->IsDecorEnable() ? "true" : "false";
bool privacyMode = sessionProperty->GetSystemPrivacyMode() || sessionProperty->GetPrivacyMode();
std::string isPrivacyMode = privacyMode ? "true" : "false";
bool isFirstFrameAvailable = true;
std::ostringstream oss;
oss << "WindowName: " << session->GetWindowName() << std::endl;
@ -3931,12 +3921,12 @@ WSError SceneSessionManager::GetSpecifiedSessionDumpInfo(std::string& dumpInfo,
oss << "Pid: " << session->GetCallingPid() << std::endl;
oss << "Type: " << static_cast<uint32_t>(session->GetWindowType()) << std::endl;
oss << "Mode: " << static_cast<uint32_t>(session->GetWindowMode()) << std::endl;
oss << "Flag: " << session->GetSessionProperty()->GetWindowFlags() << std::endl;
oss << "Flag: " << sessionProperty->GetWindowFlags() << std::endl;
oss << "Orientation: " << static_cast<uint32_t>(session->GetRequestedOrientation()) << std::endl;
oss << "FirstFrameCallbackCalled: " << isFirstFrameAvailable << std::endl;
oss << "IsVisible: " << isVisible << std::endl;
oss << "Focusable: " << Focusable << std::endl;
oss << "DecoStatus: " << DecoStatus << std::endl;
oss << "Focusable: " << focusable << std::endl;
oss << "DecoStatus: " << decoStatus << std::endl;
oss << "isPrivacyMode: " << isPrivacyMode << std::endl;
oss << "WindowRect: " << "[ "
<< rect.posX_ << ", " << rect.posY_ << ", " << rect.width_ << ", " << rect.height_
@ -4552,6 +4542,12 @@ void SceneSessionManager::NotifyFocusStatus(sptr<SceneSession>& sceneSession, bo
}
int32_t persistentId = sceneSession->GetPersistentId();
TLOGI(WmsLogTag::WMS_FOCUS,
"name: %{public}s/%{public}s/%{public}s, id: %{public}d, isFocused: %{public}d",
sceneSession->GetSessionInfo().bundleName_.c_str(),
sceneSession->GetSessionInfo().abilityName_.c_str(),
sceneSession->GetWindowNameAllType().c_str(),
persistentId, isFocused);
if (isFocused) {
if (IsSessionVisible(sceneSession)) {
NotifyWindowInfoChange(persistentId, WindowUpdateType::WINDOW_UPDATE_FOCUSED);
@ -5338,11 +5334,15 @@ void SceneSessionManager::CheckAndNotifyWaterMarkChangedResult()
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
for (const auto& iter: sceneSessionMap_) {
auto& session = iter.second;
if (!session || !session->GetSessionProperty()) {
if (!session) {
continue;
}
bool hasWaterMark = session->GetSessionProperty()->GetWindowFlags()
& static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK);
auto sessionProperty = session->GetSessionProperty();
if (!sessionProperty) {
continue;
}
bool hasWaterMark = sessionProperty->GetWindowFlags() &
static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK);
bool isExtWindowHasWaterMarkFlag = session->GetCombinedExtWindowFlags().waterMarkFlag;
if ((hasWaterMark && session->GetVisible()) || isExtWindowHasWaterMarkFlag) {
currentWaterMarkShowState = true;
@ -6055,7 +6055,6 @@ WSError SceneSessionManager::RequestSceneSessionByCall(const sptr<SceneSession>&
return WSError::WS_ERROR_NULLPTR;
}
auto persistentId = scnSession->GetPersistentId();
TLOGI(WmsLogTag::WMS_MAIN, "RequestSceneSessionByCall persistentId: %{public}d", persistentId);
if (!GetSceneSession(persistentId)) {
WLOGFE("session is invalid with %{public}d", persistentId);
return WSError::WS_ERROR_INVALID_SESSION;
@ -6063,6 +6062,8 @@ WSError SceneSessionManager::RequestSceneSessionByCall(const sptr<SceneSession>&
auto sessionInfo = scnSession->GetSessionInfo();
auto abilitySessionInfo = SetAbilitySessionInfo(scnSession);
if (!abilitySessionInfo) {
TLOGE(WmsLogTag::WMS_MAIN,
"RequestSceneSessionByCall abilitySessionInfo is null, id:%{public}d", persistentId);
return WSError::WS_ERROR_NULLPTR;
}
if (sessionInfo.callState_ == static_cast<uint32_t>(AAFwk::CallToState::BACKGROUND)) {
@ -6072,7 +6073,7 @@ WSError SceneSessionManager::RequestSceneSessionByCall(const sptr<SceneSession>&
} else {
WLOGFE("wrong callState_");
}
TLOGI(WmsLogTag::WMS_MAIN, "RequestSceneSessionByCall callState:%{public}d, persistentId: %{public}d",
TLOGI(WmsLogTag::WMS_MAIN, "RequestSceneSessionByCall state:%{public}d, id:%{public}d",
sessionInfo.callState_, persistentId);
bool isColdStart = false;
AAFwk::AbilityManagerClient::GetInstance()->CallUIAbilityBySCB(abilitySessionInfo, isColdStart);
@ -7956,11 +7957,12 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64
}
auto fromScreenId = scnSession->GetSessionInfo().screenId_;
scnSession->SetScreenId(screenId);
if (!scnSession->GetSessionProperty()) {
auto sessionProperty = scnSession->GetSessionProperty();
if (!sessionProperty) {
WLOGFE("Property is null, synchronous screenId failed");
return WSError::WS_ERROR_NULLPTR;
}
scnSession->GetSessionProperty()->SetDisplayId(screenId);
sessionProperty->SetDisplayId(screenId);
WLOGFD("Session move display %{public}" PRIu64 " from %{public}" PRIu64, screenId, fromScreenId);
NotifySessionUpdate(scnSession->GetSessionInfo(), ActionType::MOVE_DISPLAY, fromScreenId);
scnSession->NotifyDisplayMove(fromScreenId, screenId);
@ -8282,8 +8284,14 @@ WMError SceneSessionManager::GetVisibilityWindowInfo(std::vector<sptr<WindowVisi
if (session == nullptr) {
continue;
}
infos.emplace_back(new WindowVisibilityInfo(session->GetWindowId(), session->GetCallingPid(),
session->GetCallingUid(), session->GetVisibilityState(), session->GetWindowType()));
WSRect hostRect = session->GetSessionRect();
Rect rect = {hostRect.posX_, hostRect.posY_,
static_cast<uint32_t>(hostRect.width_), static_cast<uint32_t>(hostRect.height_)};
auto windowStatus = GetWindowStatus(session->GetWindowMode(), session->GetSessionState(),
session->GetSessionProperty());
infos.emplace_back(sptr<WindowVisibilityInfo>::MakeSptr(session->GetWindowId(), session->GetCallingPid(),
session->GetCallingUid(), session->GetVisibilityState(), session->GetWindowType(), windowStatus, rect,
session->GetSessionInfo().bundleName_, session->GetSessionInfo().abilityName_));
}
return WMError::WM_OK;
};
@ -8308,14 +8316,74 @@ void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask &&task,
taskScheduler_->PostAsyncTask(std::move(task), taskName, delayTime);
}
void SceneSessionManager::UpdateModalExtensionRect(int32_t persistentId, int32_t parentId, Rect rect)
bool SceneSessionManager::GetExtensionWindowIds(const sptr<IRemoteObject>& token, int32_t& persistentId,
int32_t& parentId)
{
// This function should be called in task
auto iter = extSessionInfoMap_.find(token);
if (iter == extSessionInfoMap_.end()) {
return false;
}
persistentId = iter->second.persistentId;
parentId = iter->second.parentId;
return true;
}
void SceneSessionManager::DestroyExtensionSession(const sptr<IRemoteObject>& remoteExtSession)
{
auto task = [this, remoteExtSession]() {
auto iter = remoteExtSessionMap_.find(remoteExtSession);
if (iter == remoteExtSessionMap_.end()) {
TLOGE(WmsLogTag::WMS_UIEXT, "Invalid remoteExtSession");
return;
}
int32_t persistentId = INVALID_SESSION_ID;
int32_t parentId = INVALID_SESSION_ID;
if (!GetExtensionWindowIds(iter->second, persistentId, parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed");
return;
}
TLOGD(WmsLogTag::WMS_UIEXT, "Remote died, id: %{public}d", persistentId);
auto sceneSession = GetSceneSession(parentId);
if (sceneSession != nullptr) {
auto oldFlags = sceneSession->GetCombinedExtWindowFlags();
sceneSession->RemoveExtWindowFlags(persistentId);
if (oldFlags.hideNonSecureWindowsFlag) {
HandleSecureSessionShouldHide(sceneSession);
}
if (oldFlags.waterMarkFlag) {
CheckAndNotifyWaterMarkChangedResult();
}
if (oldFlags.privacyModeFlag) {
UpdatePrivateStateAndNotify(parentId);
}
sceneSession->RemoveModalUIExtension(persistentId);
sceneSession->RemoveUIExtSurfaceNodeId(persistentId);
} else {
ExtensionWindowFlags actions;
actions.SetAllActive();
HandleSpecialExtWindowFlagsChange(persistentId, ExtensionWindowFlags(), actions);
}
remoteExtSessionMap_.erase(iter);
extSessionInfoMap_.erase(iter->second);
};
taskScheduler_->PostAsyncTask(task, "DestroyExtensionSession");
}
void SceneSessionManager::UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect)
{
auto pid = IPCSkeleton::GetCallingRealPid();
TLOGI(WmsLogTag::WMS_UIEXT, "pid=%{public}d, persistentId=%{public}d, parentId=%{public}d, "
"Rect:[%{public}d %{public}d %{public}d %{public}d]",
pid, persistentId, parentId, rect.posX_, rect.posY_, rect.width_, rect.height_);
auto task = [this, persistentId, parentId, pid, rect]() {
auto task = [this, token, pid, rect]() {
int32_t persistentId = INVALID_SESSION_ID;
int32_t parentId = INVALID_SESSION_ID;
if (!GetExtensionWindowIds(token, persistentId, parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed");
return;
}
TLOGI(WmsLogTag::WMS_UIEXT, "UpdateModalExtensionRect: pid=%{public}d, persistentId=%{public}d, "
"parentId=%{public}d, Rect:[%{public}d %{public}d %{public}d %{public}d]",
pid, persistentId, parentId, rect.posX_, rect.posY_, rect.width_, rect.height_);
auto parentSession = GetSceneSession(parentId);
if (parentSession) {
ExtensionWindowEventInfo extensionInfo {persistentId, pid, rect};
@ -8325,14 +8393,18 @@ void SceneSessionManager::UpdateModalExtensionRect(int32_t persistentId, int32_t
taskScheduler_->PostAsyncTask(task, "UpdateModalExtensionRect");
}
void SceneSessionManager::ProcessModalExtensionPointDown(int32_t persistentId, int32_t parentId,
int32_t posX, int32_t posY)
void SceneSessionManager::ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY)
{
auto pid = IPCSkeleton::GetCallingRealPid();
TLOGI(WmsLogTag::WMS_UIEXT, "pid=%{public}d, persistentId=%{public}d, parentId=%{public}d, "
"posX:%{public}d posY:%{public}d",
pid, persistentId, parentId, posX, posY);
auto task = [this, persistentId, parentId, pid, posX, posY]() {
auto task = [this, token, pid, posX, posY]() {
int32_t persistentId = INVALID_SESSION_ID;
int32_t parentId = INVALID_SESSION_ID;
if (!GetExtensionWindowIds(token, persistentId, parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed");
return;
}
TLOGI(WmsLogTag::WMS_UIEXT, "ProcessModalExtensionPointDown: pid=%{public}d, persistentId=%{public}d, "
"parentId=%{public}d", pid, persistentId, parentId);
auto parentSession = GetSceneSession(parentId);
if (parentSession && parentSession->HasModalUIExtension()) {
auto modalUIExtension = parentSession->GetLastModalUIExtensionEventInfo();
@ -8344,21 +8416,20 @@ void SceneSessionManager::ProcessModalExtensionPointDown(int32_t persistentId, i
taskScheduler_->PostAsyncTask(task, "ProcessModalExtensionPointDown");
}
void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, int32_t persistentId,
int32_t parentId, UIExtensionUsage usage)
void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId)
{
auto pid = IPCSkeleton::GetCallingRealPid();
TLOGI(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, parentId=%{public}d, usage=%{public}u, pid=%{public}d",
persistentId, parentId, usage, pid);
auto task = [this, sessionStage, persistentId, parentId, usage, pid]() {
if (sessionStage == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "sessionStage is nullptr");
auto task = [this, sessionStage, token, surfaceNodeId, pid]() {
if (sessionStage == nullptr || token == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr");
return;
}
auto remoteExtSession = sessionStage->AsObject();
remoteExtSessionMap_.insert(std::make_pair(remoteExtSession, std::make_pair(persistentId, parentId)));
if (remoteExtSession == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "sessionStage object is nullptr");
return;
}
if (extensionDeath_ == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "failed to create death recipient");
return;
@ -8368,7 +8439,27 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr<ISessionStage>
return;
}
AAFwk::UIExtensionSessionInfo info;
AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info);
if (info.persistentId == INVALID_SESSION_ID || info.hostWindowId == INVALID_SESSION_ID) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension session info failed");
return;
}
int32_t persistentId = info.persistentId;
int32_t parentId = info.hostWindowId;
UIExtensionUsage usage = static_cast<UIExtensionUsage>(info.uiExtensionUsage);
TLOGI(WmsLogTag::WMS_UIEXT, "AddExtensionWindowStageToSCB: persistentId=%{public}d, parentId=%{public}d, "
"usage=%{public}u, surfaceNodeId=%{public}" PRIu64", pid=%{public}d", persistentId, parentId, usage,
surfaceNodeId, pid);
remoteExtSessionMap_.insert(std::make_pair(remoteExtSession, token));
extSessionInfoMap_.insert(std::make_pair(token, ExtensionWindowAbilityInfo{ persistentId, parentId, usage }));
auto parentSession = GetSceneSession(parentId);
if (parentSession) {
parentSession->AddUIExtSurfaceNodeId(surfaceNodeId, persistentId);
}
if (usage == UIExtensionUsage::MODAL && parentSession) {
ExtensionWindowEventInfo extensionInfo {
.persistentId = persistentId,
@ -8376,9 +8467,6 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr<ISessionStage>
};
parentSession->AddModalUIExtension(extensionInfo);
}
TLOGD(WmsLogTag::WMS_UIEXT, "add extension window stage Id: %{public}d, parent Id: %{public}d",
persistentId, parentId);
};
taskScheduler_->PostAsyncTask(task, "AddExtensionWindowStageToSCB");
}
@ -8526,13 +8614,8 @@ WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool
return WSError::WS_OK;
}
WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
uint32_t extWindowActions)
WSError SceneSessionManager::CheckExtWindowFlagsPermission(ExtensionWindowFlags& actions) const
{
TLOGI(WmsLogTag::WMS_UIEXT, "parentId=%{public}d, persistentId=%{public}d, extWindowFlags=%{public}d, "
"actions=%{public}d", parentId, persistentId, extWindowFlags, extWindowActions);
ExtensionWindowFlags actions(extWindowActions);
auto ret = WSError::WS_OK;
bool needSystemCalling = actions.hideNonSecureWindowsFlag || actions.waterMarkFlag;
if (needSystemCalling && !SessionPermission::IsSystemCalling()) {
@ -8547,12 +8630,29 @@ WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t pers
TLOGE(WmsLogTag::WMS_UIEXT, "privacy window permission denied!");
ret = WSError::WS_ERROR_INVALID_PERMISSION;
}
return ret;
}
WSError SceneSessionManager::UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
uint32_t extWindowActions)
{
ExtensionWindowFlags actions(extWindowActions);
auto ret = CheckExtWindowFlagsPermission(actions);
if (actions.bitData == 0) {
return ret;
}
ExtensionWindowFlags flags(extWindowFlags);
auto task = [this, parentId, persistentId, flags, actions]() {
auto task = [this, token, flags, actions]() {
int32_t persistentId = INVALID_SESSION_ID;
int32_t parentId = INVALID_SESSION_ID;
if (!GetExtensionWindowIds(token, persistentId, parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed");
return WSError::WS_ERROR_INVALID_OPERATION;
}
TLOGI(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags: parentId=%{public}d, persistentId=%{public}d, "
"extWindowFlags=%{public}d, actions=%{public}d", parentId, persistentId, flags.bitData, actions.bitData);
auto sceneSession = GetSceneSession(parentId);
if (sceneSession == nullptr) {
TLOGD(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags: Parent session with persistentId %{public}d not found",
@ -8921,11 +9021,12 @@ WMError SceneSessionManager::GetCallingWindowWindowStatus(int32_t persistentId,
TLOGD(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, windowType: %{public}d",
persistentId, scnSession->GetWindowType());
if (scnSession->GetSessionProperty() == nullptr) {
auto sessionProperty = scnSession->GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "session property is null");
return WMError::WM_ERROR_INVALID_WINDOW;
}
uint32_t callingWindowId = scnSession->GetSessionProperty()->GetCallingSessionId();
uint32_t callingWindowId = sessionProperty->GetCallingSessionId();
auto callingSession = GetSceneSession(callingWindowId);
if (callingSession == nullptr) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "callingsSession is null");
@ -8959,11 +9060,12 @@ WMError SceneSessionManager::GetCallingWindowRect(int32_t persistentId, Rect& re
}
TLOGD(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, windowType: %{public}d",
persistentId, scnSession->GetWindowType());
if (scnSession->GetSessionProperty() == nullptr) {
auto sessionProperty = scnSession->GetSessionProperty();
if (sessionProperty == nullptr) {
TLOGE(WmsLogTag::WMS_KEYBOARD, "session property is null");
return WMError::WM_ERROR_INVALID_WINDOW;
}
uint32_t callingWindowId = scnSession->GetSessionProperty()->GetCallingSessionId();
uint32_t callingWindowId = sessionProperty->GetCallingSessionId();
auto callingSession = GetSceneSession(callingWindowId);
if (callingSession == nullptr) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "callingsSession is null");
@ -9180,7 +9282,7 @@ WMError SceneSessionManager::MakeScreenFoldData(const std::vector<std::string>&
TLOGI(WmsLogTag::DMS, "Error: fail to get typeC thermal.");
return WMError::WM_DO_NOTHING;
}
AppExecFwk::ElementName element;
AppExecFwk::ElementName element = {};
WSError ret = GetFocusSessionElement(element);
if (ret != WSError::WS_OK) {
TLOGI(WmsLogTag::DMS, "Error: fail to get focused package name.");
@ -9238,4 +9340,55 @@ WMError SceneSessionManager::ReportScreenFoldStatus(const ScreenFoldData& data)
}
return WMError::WM_OK;
}
void SceneSessionManager::UpdateSecSurfaceInfo(std::shared_ptr<RSUIExtensionData> secExtensionData, uint64_t userid)
{
if (currentUserId_ != userid) {
TLOGW(WmsLogTag::WMS_MULTI_USER, "currentUserId_:%{public}d userid:%{public}" PRIu64"", currentUserId_, userid);
return;
}
auto secSurfaceInfoMap = secExtensionData->GetSecData();
auto task = [secSurfaceInfoMap]()-> WSError {
SceneInputManager::GetInstance().UpdateSecSurfaceInfo(secSurfaceInfoMap);
return WSError::WS_OK;
};
return taskScheduler_->PostAsyncTask(task, "UpdateSecSurfaceInfo");
}
void SceneSessionManager::RegisterSecSurfaceInfoListener()
{
auto callBack = [this](std::shared_ptr<RSUIExtensionData> secExtensionData, uint64_t userid) {
this->UpdateSecSurfaceInfo(secExtensionData, userid);
};
TLOGI(WmsLogTag::WMS_EVENT, "RegisterSecSurfaceInfoListener");
if (rsInterface_.RegisterUIExtensionCallback(currentUserId_, callBack) != WM_OK) {
TLOGE(WmsLogTag::WMS_EVENT, "RegisterSecSurfaceInfoListener failed");
}
}
WSError SceneSessionManager::SetAppForceLandscapeMode(const std::string& bundleName, int32_t mode)
{
if (bundleName.empty()) {
WLOGFE("bundle name is empty");
return WSError::WS_ERROR_NULLPTR;
}
WLOGFD("set app force landscape mode, app: %{public}s, mode: %{public}d", bundleName.c_str(), mode);
std::unique_lock<std::shared_mutex> lock(appForceLandscapeMutex_);
appForceLandscapeMap_.emplace(bundleName, mode);
return WSError::WS_OK;
}
int32_t SceneSessionManager::GetAppForceLandscapeMode(const std::string& bundleName)
{
if (bundleName.empty()) {
WLOGFE("bundle name is empty");
return 0;
}
std::shared_lock<std::shared_mutex> lock(appForceLandscapeMutex_);
if (appForceLandscapeMap_.empty()
|| appForceLandscapeMap_.find(bundleName) == appForceLandscapeMap_.end()) {
return 0;
}
return appForceLandscapeMap_[bundleName];
}
} // namespace OHOS::Rosen

View File

@ -98,6 +98,7 @@ const unsigned int XCOLLIE_TIMEOUT_S = 10;
constexpr int32_t CAST_WIRED_PROJECTION_START = 1005;
constexpr int32_t CAST_WIRED_PROJECTION_STOP = 1007;
constexpr int32_t RES_FAILURE_FOR_PRIVACY_WINDOW = -2;
constexpr int32_t ROTATE_ANIMATION_TIME_MS = 600;
bool JudgeIsBeta()
{
@ -566,16 +567,17 @@ void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED,
screenSession->GetRSScreenId(), screenSession->GetName());
}
if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) {
if (phyMirrorEnable) {
NotifyScreenConnected(screenSession->ConvertToScreenInfo());
auto task = [this]() { PublishCastEvent(true); };
taskScheduler_->PostAsyncTask(task, "PublishCastEventTrue");
TLOGI(WmsLogTag::DMS, "PostAsyncTask PublishCastEventTrue");
isPhyScreenConnected_ = true;
}
return;
}
if (screenEvent == ScreenEvent::DISCONNECTED) {
if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) {
if (phyMirrorEnable) {
NotifyScreenDisconnected(screenSession->GetScreenId());
auto task = [this]() { PublishCastEvent(false); };
taskScheduler_->PostAsyncTask(task, "PublishCastEventFalse");
@ -583,6 +585,7 @@ void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
}
if (phyMirrorEnable) {
FreeDisplayMirrorNodeInner(screenSession);
isPhyScreenConnected_ = false;
}
if (clientProxy_) {
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::DISCONNECTED,
@ -680,7 +683,7 @@ sptr<DisplayInfo> ScreenSessionManager::GetDisplayInfoById(DisplayId displayId)
return displayInfo;
}
}
TLOGE(WmsLogTag::DMS, "GetDisplayInfoById failed.");
TLOGE(WmsLogTag::DMS, "GetDisplayInfoById failed. displayId: %{public}" PRIu64" ", displayId);
return nullptr;
}
@ -703,7 +706,7 @@ sptr<DisplayInfo> ScreenSessionManager::GetDisplayInfoByScreen(ScreenId screenId
return displayInfo;
}
}
TLOGE(WmsLogTag::DMS, "GetDisplayInfoByScreen failed.");
TLOGE(WmsLogTag::DMS, "GetDisplayInfoByScreen failed. screenId: %{public}" PRIu64" ", screenId);
return nullptr;
}
@ -1045,7 +1048,6 @@ sptr<ScreenSession> ScreenSessionManager::CreatePhysicalMirrorSessionInner(Scree
.property = property,
};
screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR);
screenSession->SetVirtualScreenFlag(VirtualScreenFlag::CAST);
screenSession->SetName("CastEngine");
screenSession->SetMirrorScreenType(MirrorScreenType::PHYSICAL_MIRROR);
screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
@ -1078,7 +1080,7 @@ sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenI
void ScreenSessionManager::CreateScreenProperty(ScreenId screenId, ScreenProperty& property)
{
int id = HiviewDFX::XCollie::GetInstance().SetTimer("CreateScreenPropertyCallRS", XCOLLIE_TIMEOUT_S, nullptr,
nullptr, HiviewDFX::XCOLLIE_FLAG_LOG);
nullptr, HiviewDFX::XCOLLIE_FLAG_RECOVERY);
auto screenMode = rsInterface_.GetScreenActiveMode(screenId);
auto screenBounds = RRect({ 0, 0, screenMode.GetScreenWidth(), screenMode.GetScreenHeight() }, 0.0f, 0.0f);
auto screenRefreshRate = screenMode.GetScreenRefreshRate();
@ -1722,8 +1724,12 @@ void ScreenSessionManager::NotifyDisplayEvent(DisplayEvent event)
if (event == DisplayEvent::SCREEN_LOCK_SUSPEND) {
TLOGI(WmsLogTag::DMS, "[UL_POWER]screen lock suspend");
gotScreenOffNotify_ = true;
isScreenLockSuspend_ = true;
TLOGI(WmsLogTag::DMS, "[UL_POWER]isScreenLockSuspend_ is true");
if (isPhyScreenConnected_) {
isScreenLockSuspend_ = false;
TLOGI(WmsLogTag::DMS, "[UL_POWER]isScreenLockSuspend__ is false");
} else {
isScreenLockSuspend_ = true;
}
if (needScreenOffNotify_) {
ScreenOffCVNotify();
}
@ -3103,7 +3109,6 @@ sptr<ScreenSessionGroup> ScreenSessionManager::AddAsFirstScreenLocked(sptr<Scree
smsScreenGroupMap_.erase(iter);
}
smsScreenGroupMap_.insert(std::make_pair(smsGroupScreenId, screenGroup));
screenSessionMap_.insert(std::make_pair(smsGroupScreenId, screenGroup));
screenGroup->mirrorScreenId_ = newScreen->screenId_;
TLOGI(WmsLogTag::DMS, "connect new group screen, screenId: %{public}" PRIu64", screenGroupId: %{public}" PRIu64", "
"combination:%{public}u", newScreen->screenId_, smsGroupScreenId,
@ -3428,40 +3433,33 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetSnapshotByPicker(Media
{
TLOGD(WmsLogTag::DMS, "ENTER!");
*errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL;
if (isInGetSnapshotByPicker_ == true) {
isInGetSnapshotByPicker_ = false;
return nullptr;
}
isInGetSnapshotByPicker_ = true;
if (system::GetBoolParameter("persist.edm.disallow_screenshot", false)) {
*errorCode = DmErrorCode::DM_ERROR_NO_PERMISSION;
TLOGI(WmsLogTag::DMS, "snapshot was disabled by edm!");
isInGetSnapshotByPicker_ = false;
return nullptr;
}
ScreenId screenId = SCREEN_ID_INVALID;
// get snapshot area frome Screenshot extension
ConfigureScreenSnapshotParams();
if (ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerConnectExtension()) {
int32_t ret = ScreenSnapshotPickerConnection::GetInstance().GetScreenSnapshotInfo(rect, screenId);
if (ret != 0) {
TLOGE(WmsLogTag::DMS, "GetScreenSnapshotInfo failed");
ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension();
if (ret == RES_FAILURE_FOR_PRIVACY_WINDOW) {
*errorCode = DmErrorCode::DM_ERROR_INVALID_CALLING;
} else {
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
}
return nullptr;
}
ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension();
} else {
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
TLOGE(WmsLogTag::DMS, "SnapshotPickerConnectExtension failed");
if (!GetSnapshotArea(rect, errorCode, screenId)) {
isInGetSnapshotByPicker_ = false;
return nullptr;
}
auto screenSession = GetScreenSession(screenId);
if (screenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "can not get screen session");
isInGetSnapshotByPicker_ = false;
return nullptr;
}
sptr<DisplayInfo> displayInfo = screenSession->ConvertToDisplayInfo();
if (displayInfo == nullptr) {
TLOGE(WmsLogTag::DMS, "can not get default display");
isInGetSnapshotByPicker_ = false;
return nullptr;
}
DisplayId displayId = displayInfo->GetDisplayId();
@ -3473,9 +3471,34 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetSnapshotByPicker(Media
isScreenShot_ = true;
NotifyCaptureStatusChanged();
*errorCode = DmErrorCode::DM_OK;
isInGetSnapshotByPicker_ = false;
return pixelMap;
}
bool ScreenSessionManager::GetSnapshotArea(Media::Rect &rect, DmErrorCode* errorCode, ScreenId &screenId)
{
ConfigureScreenSnapshotParams();
if (ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerConnectExtension()) {
int32_t ret = ScreenSnapshotPickerConnection::GetInstance().GetScreenSnapshotInfo(rect, screenId);
if (ret != 0) {
TLOGE(WmsLogTag::DMS, "GetScreenSnapshotInfo failed");
ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension();
if (ret == RES_FAILURE_FOR_PRIVACY_WINDOW) {
*errorCode = DmErrorCode::DM_ERROR_INVALID_CALLING;
} else {
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
}
return false;
}
ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension();
} else {
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
TLOGE(WmsLogTag::DMS, "SnapshotPickerConnectExtension failed");
return false;
}
return true;
}
bool ScreenSessionManager::OnRemoteDied(const sptr<IRemoteObject>& agent)
{
if (agent == nullptr) {
@ -4212,6 +4235,7 @@ void ScreenSessionManager::NotifyClientProxyUpdateFoldDisplayMode(FoldDisplayMod
void ScreenSessionManager::ScbClientDeathCallback(int32_t deathScbPid)
{
std::lock_guard<std::mutex> lock(oldScbPidsMutex_);
if (oldScbPids_.empty()) {
return;
}
@ -4251,6 +4275,7 @@ void ScreenSessionManager::SwitchUser()
TLOGI(WmsLogTag::DMS, "switch user not change");
return;
}
std::lock_guard<std::mutex> lockScb(oldScbPidsMutex_);
if (clientProxy_) {
auto pidIter = std::find(oldScbPids_.begin(), oldScbPids_.end(), currentScbPId_);
if (pidIter == oldScbPids_.end() && currentScbPId_ > 0) {
@ -4265,12 +4290,54 @@ void ScreenSessionManager::SwitchUser()
clientProxy_ = it->second;
}
if (clientProxy_) {
clientProxy_->SwitchUserCallback(oldScbPids_, newScbPid);
ScbStatusRecoveryWhenSwitchUser(newScbPid);
}
}
MockSessionManagerService::GetInstance().NotifyWMSConnected(currentUserId_, GetDefaultScreenId(), false);
}
void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(int32_t newScbPid)
{
NotifyFoldStatusChanged(GetFoldStatus());
NotifyDisplayModeChanged(GetFoldDisplayMode());
sptr<ScreenSession> screenSession = GetDefaultScreenSession();
if (screenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "fail to get default screenSession");
return;
}
if (g_foldScreenFlag) {
auto displayMode = GetFoldDisplayMode();
// fold device will be callback NotifyFoldToExpandCompletion to UpdateRotationAfterBoot
if (displayMode == FoldDisplayMode::FULL) {
screenSession->UpdatePropertyByFoldControl(GetPhyScreenProperty(SCREEN_ID_FULL));
screenSession->PropertyChange(screenSession->GetScreenProperty(),
ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND);
} else if (displayMode == FoldDisplayMode::MAIN) {
screenSession->UpdatePropertyByFoldControl(GetPhyScreenProperty(SCREEN_ID_MAIN));
screenSession->PropertyChange(screenSession->GetScreenProperty(),
ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING);
} else {
TLOGE(WmsLogTag::DMS, "unsuport displaymode: %{public}u", displayMode);
}
} else {
screenSession->UpdateRotationAfterBoot(true);
}
if (oldScbPids_.size() == 0) {
screenEventTracker_.RecordEvent("swicth user failed, oldScbPids is null");
TLOGE(WmsLogTag::DMS, "swicth user failed, oldScbPids is null");
return;
}
auto delayTask = [this, oldScbPids = oldScbPids_, newScbPid] {
if (!clientProxy_) {
TLOGE(WmsLogTag::DMS, "clientProxy is null");
return;
}
clientProxy_->SwitchUserCallback(oldScbPids, newScbPid);
};
// Wait for the display to stabilize
taskScheduler_->PostAsyncTask(delayTask, "SwitchUserCallback", ROTATE_ANIMATION_TIME_MS);
}
void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& client)
{
if (!SessionPermission::IsSystemCalling()) {
@ -4359,7 +4426,10 @@ void ScreenSessionManager::GetCurrentScreenPhyBounds(float& phyWidth, float& phy
isReset = false;
}
} else {
int id = HiviewDFX::XCollie::GetInstance().SetTimer("GetCurrentScreenPhyBounds", XCOLLIE_TIMEOUT_S, nullptr,
nullptr, HiviewDFX::XCOLLIE_FLAG_RECOVERY);
auto remoteScreenMode = rsInterface_.GetScreenActiveMode(screenid);
HiviewDFX::XCollie::GetInstance().CancelTimer(id);
phyWidth = remoteScreenMode.GetScreenWidth();
phyHeight = remoteScreenMode.GetScreenHeight();
}

View File

@ -26,19 +26,19 @@
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionManager" };
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "SessionManager" };
}
class SessionManagerServiceRecoverListener : public IRemoteStub<ISessionManagerServiceRecoverListener> {
public:
explicit SessionManagerServiceRecoverListener() = default;
virtual int32_t OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option) override
{
if (data.ReadInterfaceToken() != GetDescriptor()) {
WLOGFE("InterfaceToken check failed");
return -1;
WLOGFE("InterfaceToken check failed");
return -1;
}
auto msgId = static_cast<SessionManagerServiceRecoverMessage>(code);
switch (msgId) {
@ -155,8 +155,7 @@ void SessionManager::ClearSessionManagerProxy()
sceneSessionManagerProxy_ = nullptr;
}
__attribute__((no_sanitize("cfi")))
sptr<ISceneSessionManager> SessionManager::GetSceneSessionManagerProxy()
__attribute__((no_sanitize("cfi"))) sptr<ISceneSessionManager> SessionManager::GetSceneSessionManagerProxy()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
InitSessionManagerServiceProxy();
@ -220,8 +219,7 @@ WMError SessionManager::InitMockSMSProxy()
return WMError::WM_OK;
}
__attribute__((no_sanitize("cfi")))
void SessionManager::InitSceneSessionManagerProxy()
__attribute__((no_sanitize("cfi"))) void SessionManager::InitSceneSessionManagerProxy()
{
if (sceneSessionManagerProxy_) {
return;
@ -281,7 +279,7 @@ void SessionManager::RecoverSessionManagerService(const sptr<ISessionManagerServ
std::lock_guard<std::recursive_mutex> lock(mutex_);
sessionManagerServiceProxy_ = sessionManagerService;
}
{
std::lock_guard<std::recursive_mutex> lock(recoverMutex_);
TLOGI(WmsLogTag::WMS_RECOVER, "Run recover");

View File

@ -88,7 +88,6 @@ public:
: SceneSessionManagerLiteProxy(impl) {}
virtual ~SceneSessionManagerLiteProxyMock() = default;
#ifndef USE_ADAPTER_LITE
WSError RegisterSessionListener(const sptr<ISessionListener>& listener) override
{
TLOGI(WmsLogTag::DEFAULT, "called");
@ -106,7 +105,6 @@ public:
SessionManagerLite::GetInstance().DeleteSessionListener(listener);
return ret;
}
#endif
private:
static inline BrokerDelegator<SceneSessionManagerLiteProxyMock> delegator_;
};
@ -162,7 +160,6 @@ sptr<ISessionManagerService> SessionManagerLite::GetSessionManagerServiceProxy()
return sessionManagerServiceProxy_;
}
#ifndef USE_ADAPTER_LITE
void SessionManagerLite::SaveSessionListener(const sptr<ISessionListener>& listener)
{
std::lock_guard<std::recursive_mutex> guard(listenerLock_);
@ -188,14 +185,11 @@ void SessionManagerLite::DeleteSessionListener(const sptr<ISessionListener>& lis
sessionListeners_.erase(it);
}
}
#endif
void SessionManagerLite::DeleteAllSessionListeners()
{
#ifndef USE_ADAPTER_LITE
std::lock_guard<std::recursive_mutex> guard(listenerLock_);
sessionListeners_.clear();
#endif
}
void SessionManagerLite::RecoverSessionManagerService(const sptr<ISessionManagerService>& sessionManagerService)
@ -218,7 +212,7 @@ void SessionManagerLite::ReregisterSessionListener() const
TLOGE(WmsLogTag::WMS_RECOVER, "sceneSessionManagerLiteProxy_ is null");
return;
}
#ifndef USE_ADAPTER_LITE
TLOGI(WmsLogTag::WMS_RECOVER, "RecoverSessionListeners, listener count = %{public}" PRIu64,
static_cast<int64_t>(sessionListeners_.size()));
for (const auto& listener : sessionListeners_) {
@ -227,7 +221,6 @@ void SessionManagerLite::ReregisterSessionListener() const
TLOGW(WmsLogTag::WMS_RECOVER, "failed, ret = %{public}" PRId32, ret);
}
}
#endif
}
void SessionManagerLite::RegisterUserSwitchListener(const UserSwitchCallbackFunc& callbackFunc)

View File

@ -22,9 +22,7 @@
#include "marshalling_helper.h"
#include "window_manager_hilog.h"
#ifndef USE_ADAPTER_LITE
#include "window_session_property.h"
#endif
namespace OHOS::Rosen {
namespace {
@ -32,7 +30,7 @@ constexpr int32_t CYCLE_LIMIT = 1000;
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerLiteProxy"};
constexpr int32_t MAX_TOPN_INFO_SIZE = 200;
}
#ifndef USE_ADAPTER_LITE
WSError SceneSessionManagerLiteProxy::SetSessionLabel(const sptr<IRemoteObject> &token, const std::string &label)
{
WLOGFD("run SceneSessionManagerLiteProxy::SetSessionLabel");
@ -313,6 +311,25 @@ WSError SceneSessionManagerLiteProxy::GetSessionInfoByContinueSessionId(
return static_cast<WSError>(reply.ReadInt32());
}
template<typename T>
WSError SceneSessionManagerLiteProxy::GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos)
{
int32_t infoSize = reply.ReadInt32();
if (infoSize > CYCLE_LIMIT) {
WLOGFE("infoSize is too large");
return WSError::WS_ERROR_IPC_FAILED;
}
for (int32_t i = 0; i < infoSize; i++) {
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
WLOGFE("Read Parcelable infos failed.");
return WSError::WS_ERROR_IPC_FAILED;
}
parcelableInfos.emplace_back(*info);
}
return WSError::WS_OK;
}
WSError SceneSessionManagerLiteProxy::TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
bool needStartCaller, bool isFromBroker)
@ -604,27 +621,6 @@ WSError SceneSessionManagerLiteProxy::ClearAllSessions()
}
return static_cast<WSError>(reply.ReadInt32());
}
#endif
template<typename T>
WSError SceneSessionManagerLiteProxy::GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos)
{
int32_t infoSize = reply.ReadInt32();
if (infoSize > CYCLE_LIMIT) {
WLOGFE("infoSize is too large");
return WSError::WS_ERROR_IPC_FAILED;
}
for (int32_t i = 0; i < infoSize; i++) {
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
WLOGFE("Read Parcelable infos failed.");
return WSError::WS_ERROR_IPC_FAILED;
}
parcelableInfos.emplace_back(*info);
}
return WSError::WS_OK;
}
void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo)
{
@ -904,7 +900,6 @@ WSError SceneSessionManagerLiteProxy::RaiseWindowToTop(int32_t persistentId)
return static_cast<WSError>(ret);
}
#ifndef USE_ADAPTER_LITE
WSError SceneSessionManagerLiteProxy::RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl)
{
@ -963,5 +958,4 @@ WSError SceneSessionManagerLiteProxy::UnregisterIAbilityManagerCollaborator(int3
}
return static_cast<WSError>(reply.ReadInt32());
}
#endif
} // namespace OHOS::Rosen

View File

@ -364,7 +364,7 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel &d
int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply)
{
WLOGFI("run HandleGetFocusSessionInfo lite!");
WLOGFD("run HandleGetFocusSessionInfo lite!");
FocusChangeInfo focusInfo;
GetFocusWindowInfo(focusInfo);
reply.WriteParcelable(&focusInfo);

View File

@ -1542,7 +1542,7 @@ WSError SceneSessionManagerProxy::ShiftAppWindowFocus(int32_t sourcePersistentId
return static_cast<WSError>(reply.ReadInt32());
}
void SceneSessionManagerProxy::UpdateModalExtensionRect(int32_t persistentId, int32_t parentId, Rect rect)
void SceneSessionManagerProxy::UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect)
{
MessageOption option(MessageOption::TF_SYNC);
MessageParcel data;
@ -1551,12 +1551,8 @@ void SceneSessionManagerProxy::UpdateModalExtensionRect(int32_t persistentId, in
TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
return;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
return;
}
if (!data.WriteInt32(parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write parentId failed");
if (!data.WriteRemoteObject(token)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
return;
}
if (!data.WriteInt32(rect.posX_)) {
@ -1582,8 +1578,8 @@ void SceneSessionManagerProxy::UpdateModalExtensionRect(int32_t persistentId, in
}
}
void SceneSessionManagerProxy::ProcessModalExtensionPointDown(int32_t persistentId, int32_t parentId,
int32_t posX, int32_t posY)
void SceneSessionManagerProxy::ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX,
int32_t posY)
{
MessageOption option(MessageOption::TF_SYNC);
MessageParcel data;
@ -1592,12 +1588,8 @@ void SceneSessionManagerProxy::ProcessModalExtensionPointDown(int32_t persistent
TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
return;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
return;
}
if (!data.WriteInt32(parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write parentId failed");
if (!data.WriteRemoteObject(token)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
return;
}
if (!data.WriteInt32(posX)) {
@ -1616,7 +1608,7 @@ void SceneSessionManagerProxy::ProcessModalExtensionPointDown(int32_t persistent
}
void SceneSessionManagerProxy::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
int32_t persistentId, int32_t parentId, UIExtensionUsage usage)
const sptr<IRemoteObject>& token, uint64_t surfaceNodeId)
{
MessageOption option(MessageOption::TF_SYNC);
MessageParcel data;
@ -1629,16 +1621,12 @@ void SceneSessionManagerProxy::AddExtensionWindowStageToSCB(const sptr<ISessionS
TLOGE(WmsLogTag::WMS_UIEXT, "Write ISessionStage failed!");
return;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
if (!data.WriteRemoteObject(token)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
return;
}
if (!data.WriteInt32(parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write parentId failed");
return;
}
if (!data.WriteUint32(static_cast<uint32_t>(usage))) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write usage failed");
if (!data.WriteUint64(static_cast<uint64_t>(surfaceNodeId))) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write surfaceNodeId failed");
return;
}
if (Remote()->SendRequest(static_cast<uint32_t>(
@ -1674,7 +1662,7 @@ WSError SceneSessionManagerProxy::AddOrRemoveSecureSession(int32_t persistentId,
return static_cast<WSError>(reply.ReadInt32());
}
WSError SceneSessionManagerProxy::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags,
WSError SceneSessionManagerProxy::UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
uint32_t extWindowActions)
{
TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::UpdateExtWindowFlags");
@ -1685,12 +1673,8 @@ WSError SceneSessionManagerProxy::UpdateExtWindowFlags(int32_t parentId, int32_t
TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(parentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write parentId failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(persistentId)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
if (!data.WriteRemoteObject(token)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(extWindowFlags)) {

View File

@ -149,6 +149,10 @@ int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel&
return HandleGetVisibilityWindowInfo(data, reply);
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB):
return HandleAddExtensionWindowStageToSCB(data, reply);
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB):
return HandleUpdateModalExtensionRect(data, reply);
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB):
return HandleProcessModalExtensionPointDown(data, reply);
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION):
return HandleAddOrRemoveSecureSession(data, reply);
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS):
@ -865,33 +869,30 @@ int SceneSessionManagerStub::HandleAddExtensionWindowStageToSCB(MessageParcel& d
if (sessionStage == nullptr) {
return ERR_INVALID_DATA;
}
int32_t persistentId = data.ReadInt32();
int32_t parentId = data.ReadInt32();
UIExtensionUsage usage = static_cast<UIExtensionUsage>(data.ReadUint32());
AddExtensionWindowStageToSCB(sessionStage, persistentId, parentId, usage);
sptr<IRemoteObject> token = data.ReadRemoteObject();
uint64_t surfaceNodeId = data.ReadUint64();
AddExtensionWindowStageToSCB(sessionStage, token, surfaceNodeId);
return ERR_NONE;
}
int SceneSessionManagerStub::HandleUpdateModalExtensionRect(MessageParcel& data, MessageParcel& reply)
{
int32_t persistentId = data.ReadInt32();
int32_t parentId = data.ReadInt32();
sptr<IRemoteObject> token = data.ReadRemoteObject();
int32_t rectX = data.ReadInt32();
int32_t rectY = data.ReadInt32();
int32_t rectWidth = data.ReadInt32();
int32_t rectHeight = data.ReadInt32();
Rect windowRect{rectX, rectY, rectWidth, rectHeight};
UpdateModalExtensionRect(persistentId, parentId, windowRect);
UpdateModalExtensionRect(token, windowRect);
return ERR_NONE;
}
int SceneSessionManagerStub::HandleProcessModalExtensionPointDown(MessageParcel& data, MessageParcel& reply)
{
int32_t persistentId = data.ReadInt32();
int32_t parentId = data.ReadInt32();
sptr<IRemoteObject> token = data.ReadRemoteObject();
int32_t posX = data.ReadInt32();
int32_t posY = data.ReadInt32();
ProcessModalExtensionPointDown(persistentId, parentId, posX, posY);
ProcessModalExtensionPointDown(token, posX, posY);
return ERR_NONE;
}
@ -906,11 +907,10 @@ int SceneSessionManagerStub::HandleAddOrRemoveSecureSession(MessageParcel& data,
int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply)
{
int32_t parentId = data.ReadInt32();
int32_t persistentId = data.ReadInt32();
sptr<IRemoteObject> token = data.ReadRemoteObject();
uint32_t extWindowFlags = data.ReadUint32();
uint32_t extWindowActions = data.ReadUint32();
WSError ret = UpdateExtWindowFlags(parentId, persistentId, extWindowFlags, extWindowActions);
WSError ret = UpdateExtWindowFlags(token, extWindowFlags, extWindowActions);
reply.WriteInt32(static_cast<int32_t>(ret));
return ERR_NONE;
}

View File

@ -70,6 +70,7 @@ group("unittest") {
":ws_screen_session_test",
":ws_screen_setting_helper_test",
":ws_screen_snapshot_picker_connection_test",
":ws_sensor_fold_state_manager_test",
":ws_session_display_power_controller_test",
":ws_session_listener_controller_test",
":ws_session_manager_agent_controller_test",
@ -87,6 +88,7 @@ group("unittest") {
":ws_setting_observer_test",
":ws_setting_provider_test",
":ws_single_display_fold_policy_test",
":ws_single_display_pocket_fold_policy_test",
":ws_single_display_sensor_fold_state_manager_test",
":ws_sub_session_test",
":ws_system_session_test",
@ -182,6 +184,35 @@ ohos_unittest("ws_single_display_fold_policy_test") {
]
}
ohos_unittest("ws_single_display_pocket_fold_policy_test") {
module_out_path = module_out_path
sources = [ "single_display_pocket_fold_policy_test.cpp" ]
deps = [ ":ws_unittest_common" ]
external_deps = [
"ability_runtime:app_manager",
"c_utils:utils",
"hilog:libhilog",
]
}
ohos_unittest("ws_sensor_fold_state_manager_test") {
module_out_path = module_out_path
sources = [ "sensor_fold_state_manager_test.cpp" ]
deps = [ ":ws_unittest_common" ]
external_deps = [
"ability_runtime:app_manager",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",
]
}
ohos_unittest("ws_dual_display_fold_policy_test") {
module_out_path = module_out_path
@ -987,7 +1018,7 @@ ohos_unittest("ws_screen_rotation_property_test") {
ohos_unittest("ws_screen_session_dumper_test") {
module_out_path = module_out_path
sources = [ "ws_screen_session_dumper_test.cpp" ]
sources = [ "screen_session_dumper_test.cpp" ]
deps = [ ":ws_unittest_common" ]
@ -1432,7 +1463,6 @@ ohos_static_library("ws_unittest_common") {
]
deps = [
"${bundlefwk_inner_api_path}/appexecfwk_base:appexecfwk_base",
"${window_base_path}/dm:libdm",
"${window_base_path}/utils:libwmutil",
"${window_base_path}/utils:libwmutil_base",

View File

@ -61,11 +61,11 @@ void FoldScreenStateMachineTest::TearDown()
namespace {
/**
* @tc.name: RegistrationTransitionCallback
* @tc.desc: RegistrationTransitionCallback func
* @tc.name: RegistrationTransitionCallback01
* @tc.desc: RegistrationTransitionCallback01 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, RegistrationTransitionCallback, Function | SmallTest | Level1)
HWTEST_F(FoldScreenStateMachineTest, RegistrationTransitionCallback01, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback;
FoldScreenStateMachine fsm;
@ -74,11 +74,38 @@ HWTEST_F(FoldScreenStateMachineTest, RegistrationTransitionCallback, Function |
}
/**
* @tc.name: UnRegistrationTransitionCallback
* @tc.desc: UnRegistrationTransitionCallback func
* @tc.name: RegistrationTransitionCallback02
* @tc.desc: RegistrationTransitionCallback02 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, UnRegistrationTransitionCallback, Function | SmallTest | Level1)
HWTEST_F(FoldScreenStateMachineTest, RegistrationTransitionCallback02, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback = std::make_shared<TransitionCallback>();
FoldScreenStateMachine fsm;
fsm.RegistrationTransitionCallback(callback);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: RegistrationTransitionCallback03
* @tc.desc: RegistrationTransitionCallback03 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, RegistrationTransitionCallback03, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback = std::make_shared<TransitionCallback>();
FoldScreenStateMachine fsm;
fsm.callbacks_.push_back(callback);
fsm.RegistrationTransitionCallback(callback);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: UnRegistrationTransitionCallback01
* @tc.desc: UnRegistrationTransitionCallback01 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, UnRegistrationTransitionCallback01, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback;
FoldScreenStateMachine fsm;
@ -87,11 +114,38 @@ HWTEST_F(FoldScreenStateMachineTest, UnRegistrationTransitionCallback, Function
}
/**
* @tc.name: TransitionTo
* @tc.desc: TransitionTo func
* @tc.name: UnRegistrationTransitionCallback02
* @tc.desc: UnRegistrationTransitionCallback02 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, TransitionTo, Function | SmallTest | Level1)
HWTEST_F(FoldScreenStateMachineTest, UnRegistrationTransitionCallback02, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback = std::make_shared<TransitionCallback>();
FoldScreenStateMachine fsm;
fsm.UnRegistrationTransitionCallback(callback);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: UnRegistrationTransitionCallback03
* @tc.desc: UnRegistrationTransitionCallback03 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, UnRegistrationTransitionCallback03, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback = std::make_shared<TransitionCallback>();
FoldScreenStateMachine fsm;
fsm.callbacks_.push_back(callback);
fsm.UnRegistrationTransitionCallback(callback);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: TransitionTo01
* @tc.desc: TransitionTo01 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, TransitionTo01, Function | SmallTest | Level1)
{
FoldScreenState state = FoldScreenState::UNKNOWN;
FoldScreenStateMachine fsm;
@ -102,6 +156,24 @@ HWTEST_F(FoldScreenStateMachineTest, TransitionTo, Function | SmallTest | Level1
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: TransitionTo02
* @tc.desc: TransitionTo02 func
* @tc.type: FUNC
*/
HWTEST_F(FoldScreenStateMachineTest, TransitionTo02, Function | SmallTest | Level1)
{
std::shared_ptr<TransitionCallback> callback = std::make_shared<TransitionCallback>();
FoldScreenState state = FoldScreenState::UNKNOWN;
FoldScreenStateMachine fsm;
fsm.callbacks_.push_back(callback);
fsm.TransitionTo(state);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
state = FoldScreenState::FOLDED;
fsm.TransitionTo(state);
ASSERT_EQ(fsm.GetCurrentState(), fsm.currState_);
}
/**
* @tc.name: GetCurrentState
* @tc.desc: GetCurrentState func

View File

@ -72,7 +72,7 @@ HWTEST_F(KeyboardSessionTest, GetKeyboardGravity, Function | SmallTest | Level1)
sptr<KeyboardSession> keyboardSession = new (std::nothrow) KeyboardSession(info, nullptr, nullptr);
ASSERT_TRUE((keyboardSession != nullptr));
ASSERT_EQ(SessionGravity::SESSION_GRAVITY_DEFAULT, keyboardSession->GetKeyboardGravity());
sptr<SceneSession::SpecificSessionCallback> specificCb =
new (std::nothrow) SceneSession::SpecificSessionCallback();
EXPECT_NE(specificCb, nullptr);
@ -455,7 +455,7 @@ HWTEST_F(KeyboardSessionTest, GetStatusBarHeight, Function | SmallTest | Level1)
EXPECT_NE(keyboardSession, nullptr);
statusBarHeight = keyboardSession->GetStatusBarHeight();
ASSERT_EQ(statusBarHeight, 0);
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCb);
EXPECT_NE(sceneSession, nullptr);
WSRect rect({0, 0, 0, 0});
@ -535,7 +535,7 @@ HWTEST_F(KeyboardSessionTest, OnKeyboardPanelUpdated, Function | SmallTest | Lev
{
WLOGFI("OnKeyboardPanelUpdated begin!");
int ret = 0;
SessionInfo info;
info.abilityName_ = "OnKeyboardPanelUpdated";
info.bundleName_ = "OnKeyboardPanelUpdated";
@ -549,7 +549,7 @@ HWTEST_F(KeyboardSessionTest, OnKeyboardPanelUpdated, Function | SmallTest | Lev
EXPECT_NE(keyboardSession, nullptr);
keyboardSession->isKeyboardPanelEnabled_ = false;
keyboardSession->OnKeyboardPanelUpdated();
keyboardSession->isKeyboardPanelEnabled_ = true;
keyboardSession->specificCallback_ = nullptr;
keyboardSession->OnKeyboardPanelUpdated();
@ -591,7 +591,7 @@ HWTEST_F(KeyboardSessionTest, SetCallingSessionId, Function | SmallTest | Level1
keyboardSession->keyboardCallback_ = nullptr;
keyboardSession->SetCallingSessionId(0);
keyboardSession->keyboardCallback_ = keyboardCb;
auto onCallingSessionIdChange = keyboardSession->keyboardCallback_->onCallingSessionIdChange_;
if (onCallingSessionIdChange == nullptr) {
@ -641,21 +641,21 @@ HWTEST_F(KeyboardSessionTest, AdjustKeyboardLayout, Function | SmallTest | Level
EXPECT_NE(keyboardCb, nullptr);
sptr<KeyboardSession> keyboardSession = new (std::nothrow) KeyboardSession(info, specificCb, keyboardCb);
EXPECT_NE(keyboardSession, nullptr);
sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
keyboardSession->SetSessionProperty(property);
keyboardSession->RegisterSessionChangeCallback(nullptr);
KeyboardLayoutParams params;
ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
sptr<SceneSession::SessionChangeCallback> sessionChangeCallback =
new (std::nothrow) SceneSession::SessionChangeCallback();
EXPECT_NE(sessionChangeCallback, nullptr);
sessionChangeCallback->onAdjustKeyboardLayout_ = nullptr;
keyboardSession->RegisterSessionChangeCallback(sessionChangeCallback);
ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
sessionChangeCallback->onAdjustKeyboardLayout_ = [](const KeyboardLayoutParams& params){};
ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
@ -684,9 +684,9 @@ HWTEST_F(KeyboardSessionTest, CheckIfNeedRaiseCallingSession, Function | SmallTe
sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
keyboardSession->SetSessionProperty(property);
ASSERT_FALSE(keyboardSession->CheckIfNeedRaiseCallingSession(nullptr, true));
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCb);
EXPECT_NE(sceneSession, nullptr);
property->sessionGravity_ = SessionGravity::SESSION_GRAVITY_FLOAT;
@ -706,6 +706,62 @@ HWTEST_F(KeyboardSessionTest, CheckIfNeedRaiseCallingSession, Function | SmallTe
WLOGFI("CheckIfNeedRaiseCallingSession end!");
}
/**
* @tc.name: OpenKeyboardSyncTransaction
* @tc.desc: OpenKeyboardSyncTransaction
* @tc.type: FUNC
*/
HWTEST_F(KeyboardSessionTest, OpenKeyboardSyncTransaction, Function | SmallTest | Level1)
{
SessionInfo info;
info.abilityName_ = "OpenKeyboardSyncTransaction";
info.bundleName_ = "OpenKeyboardSyncTransaction";
sptr<SceneSession::SpecificSessionCallback> specificCb =
new (std::nothrow) SceneSession::SpecificSessionCallback();
EXPECT_NE(specificCb, nullptr);
sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
new (std::nothrow) KeyboardSession::KeyboardSessionCallback();
EXPECT_NE(keyboardCb, nullptr);
sptr<KeyboardSession> keyboardSession = new (std::nothrow) KeyboardSession(info, specificCb, keyboardCb);
EXPECT_NE(keyboardSession, nullptr);
// isKeyBoardSyncTransactionOpen_ is false
keyboardSession->OpenKeyboardSyncTransaction();
// isKeyBoardSyncTransactionOpen_ is true
keyboardSession->OpenKeyboardSyncTransaction();
}
/**
* @tc.name: CloseKeyboardSyncTransaction1
* @tc.desc: CloseKeyboardSyncTransaction1
* @tc.type: FUNC
*/
HWTEST_F(KeyboardSessionTest, CloseKeyboardSyncTransaction1, Function | SmallTest | Level1)
{
SessionInfo info;
info.abilityName_ = "CloseKeyboardSyncTransaction1";
info.bundleName_ = "CloseKeyboardSyncTransaction1";
sptr<SceneSession::SpecificSessionCallback> specificCb =
new (std::nothrow) SceneSession::SpecificSessionCallback();
EXPECT_NE(specificCb, nullptr);
sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
new (std::nothrow) KeyboardSession::KeyboardSessionCallback();
EXPECT_NE(keyboardCb, nullptr);
sptr<KeyboardSession> keyboardSession = new (std::nothrow) KeyboardSession(info, specificCb, keyboardCb);
EXPECT_NE(keyboardSession, nullptr);
sptr<WindowSessionProperty> keyboardProperty = new (std::nothrow) WindowSessionProperty();
keyboardProperty->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
keyboardSession->SetSessionProperty(keyboardProperty);
WSRect keyboardPanelRect = { 0, 0, 0, 0 };
bool isKeyboardShow = true;
bool isRotating = false;
keyboardSession->CloseKeyboardSyncTransaction(keyboardPanelRect, isKeyboardShow, isRotating);
}
}
} // namespace
} // namespace Rosen
} // namespace OHOS

View File

@ -52,7 +52,7 @@ void SCBSystemSessionTest::SetUp()
info.abilityName_ = "testSCBSystemSession1";
info.moduleName_ = "testSCBSystemSession2";
info.bundleName_ = "testSCBSystemSession3";
scbSystemSession_ = new SCBSystemSession(info, specificCallback);
scbSystemSession_ = new (std::nothrow) SCBSystemSession(info, specificCallback);
EXPECT_NE(nullptr, scbSystemSession_);
}
@ -176,8 +176,8 @@ HWTEST_F(SCBSystemSessionTest, BindKeyboardSession02, Function | SmallTest | Lev
info.moduleName_ = "InputEventListener";
info.isSystem_ = true;
sptr<SceneSession::SpecificSessionCallback> callback =
new SceneSession::SpecificSessionCallback();
sptr<SceneSession> session = new SceneSession(info, callback);
new (std::nothrow) SceneSession::SpecificSessionCallback();
sptr<SceneSession> session = new (std::nothrow) SceneSession(info, callback);
scbSystemSession_->BindKeyboardSession(session);
int ret = 0;
ASSERT_EQ(0, ret);

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "transaction/rs_uiextension_data.h"
#include "input_manager.h"
#include "session_manager/include/scene_session_dirty_manager.h"
#include <gtest/gtest.h>
@ -524,44 +524,6 @@ HWTEST_F(SceneSessionDirtyManagerTest, UpdateWindowFlags, Function | SmallTest |
manager_->UpdateWindowFlags(screenId, sceneSession, windowinfo);
}
/**
* @tc.name: UpdateModalExtensionWindowInfo
* @tc.desc: UpdateModalExtensionWindowInfo
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionDirtyManagerTest, UpdateModalExtensionWindowInfo, Function | SmallTest | Level2)
{
SessionInfo info;
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(sceneSession, nullptr);
MMI::WindowInfo windowInfo;
manager_->UpdateModalExtensionWindowInfo(nullptr, windowInfo);
EXPECT_TRUE(windowInfo.defaultHotAreas.empty());
EXPECT_TRUE(windowInfo.pointerHotAreas.empty());
ExtensionWindowEventInfo extensionInfo = {
.persistentId = 12345,
.pid = 1234
};
sceneSession->AddModalUIExtension(extensionInfo);
sceneSession->SetSessionRect({ 5, 6, 7, 8 });
manager_->UpdateModalExtensionWindowInfo(sceneSession, windowInfo);
EXPECT_EQ(windowInfo.agentWindowId, extensionInfo.persistentId);
EXPECT_EQ(windowInfo.pid, extensionInfo.pid);
MMI::Rect resultRect { 0, 0, 7, 8 };
ASSERT_EQ(windowInfo.defaultHotAreas.size(), 1);
EXPECT_EQ(windowInfo.defaultHotAreas.front().x, resultRect.x);
EXPECT_EQ(windowInfo.defaultHotAreas.front().y, resultRect.y);
EXPECT_EQ(windowInfo.defaultHotAreas.front().width, resultRect.width);
EXPECT_EQ(windowInfo.defaultHotAreas.front().height, resultRect.height);
ASSERT_EQ(windowInfo.pointerHotAreas.size(), 1);
EXPECT_EQ(windowInfo.pointerHotAreas.front().x, resultRect.x);
EXPECT_EQ(windowInfo.pointerHotAreas.front().y, resultRect.y);
EXPECT_EQ(windowInfo.pointerHotAreas.front().width, resultRect.width);
EXPECT_EQ(windowInfo.pointerHotAreas.front().height, resultRect.height);
}
/**
* @tc.name: AddModalExtensionWindowInfo
* @tc.desc: AddModalExtensionWindowInfo

View File

@ -551,10 +551,11 @@ HWTEST_F(sceneSessionManagerProxyTest, UpdateModalExtensionRect, Function | Smal
sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
ASSERT_NE(sceneSessionManagerProxy, nullptr);
int32_t persistentId = 12345;
int32_t parentId = 1234;
sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
ASSERT_NE(token, nullptr);
Rect rect { 1, 2, 3, 4 };
sceneSessionManagerProxy->UpdateModalExtensionRect(persistentId, parentId, rect);
sceneSessionManagerProxy->UpdateModalExtensionRect(token, rect);
sceneSessionManagerProxy->UpdateModalExtensionRect(nullptr, rect);
sceneSessionManagerProxy = nullptr;
}
@ -571,9 +572,10 @@ HWTEST_F(sceneSessionManagerProxyTest, ProcessModalExtensionPointDown, Function
sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
ASSERT_NE(sceneSessionManagerProxy, nullptr);
int32_t persistentId = 12345;
int32_t parentId = 1234;
sceneSessionManagerProxy->ProcessModalExtensionPointDown(persistentId, parentId, 0, 0);
sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
ASSERT_NE(token, nullptr);
sceneSessionManagerProxy->ProcessModalExtensionPointDown(token, 0, 0);
sceneSessionManagerProxy->ProcessModalExtensionPointDown(nullptr, 0, 0);
sceneSessionManagerProxy = nullptr;
}
@ -606,9 +608,10 @@ HWTEST_F(sceneSessionManagerProxyTest, UpdateExtWindowFlags, Function | SmallTes
new (std::nothrow) SceneSessionManagerProxy(iRemoteObjectMocker);
EXPECT_NE(sceneSessionManagerProxy_, nullptr);
int32_t parentId = 1234;
int32_t persistentId = 12345;
ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy_->UpdateExtWindowFlags(parentId, persistentId, 7, 7));
sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
ASSERT_NE(token, nullptr);
ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy_->UpdateExtWindowFlags(token, 7, 7));
ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sceneSessionManagerProxy_->UpdateExtWindowFlags(nullptr, 7, 7));
sceneSessionManagerProxy_ = nullptr;
}

View File

@ -1116,14 +1116,8 @@ HWTEST_F(SceneSessionManagerStubTest, HandleAddExtensionWindowStageToSCB, Functi
sptr<ISessionStage> sessionStage = new SessionStageMocker();
data.WriteRemoteObject(sessionStage->AsObject());
int32_t persistentId = 65535;
data.WriteInt32(persistentId);
int32_t parentId = 12345;
data.WriteInt32(parentId);
uint32_t usage = 0;
data.WriteUint32(usage);
sptr<IRemoteObject> token = nullptr;
data.WriteRemoteObject(token);
int res = stub_->HandleAddExtensionWindowStageToSCB(data, reply);
EXPECT_EQ(res, ERR_NONE);
@ -1141,10 +1135,8 @@ HWTEST_F(SceneSessionManagerStubTest, HandleUpdateModalExtensionRect, Function |
MessageParcel data;
MessageParcel reply;
int32_t persistentId = 12345;
data.WriteInt32(persistentId);
int32_t parentId = 1234;
data.WriteInt32(parentId);
sptr<IRemoteObject> token = nullptr;
data.WriteRemoteObject(token);
Rect rect { 1, 2, 3, 4 };
data.WriteInt32(rect.posX_);
data.WriteInt32(rect.posY_);
@ -1167,10 +1159,8 @@ HWTEST_F(SceneSessionManagerStubTest, HandleProcessModalExtensionPointDown, Func
MessageParcel data;
MessageParcel reply;
int32_t persistentId = 12345;
data.WriteInt32(persistentId);
int32_t parentId = 1234;
data.WriteInt32(parentId);
sptr<IRemoteObject> token = nullptr;
data.WriteRemoteObject(token);
int32_t posX = 114;
data.WriteInt32(posX);
int32_t posY = 514;
@ -1237,8 +1227,8 @@ HWTEST_F(SceneSessionManagerStubTest, HandleUpdateExtWindowFlags, Function | Sma
MessageParcel data;
MessageParcel reply;
data.WriteInt32(1234);
data.WriteInt32(12345);
sptr<IRemoteObject> token = nullptr;
data.WriteRemoteObject(token);
data.WriteInt32(7);
data.WriteInt32(7);

View File

@ -17,8 +17,8 @@
#include <regex>
#include <bundle_mgr_interface.h>
#include <bundlemgr/launcher_service.h>
#include "../utils/include/screen_fold_data.h"
#include "interfaces/include/ws_common.h"
#include "screen_fold_data.h"
#include "session_manager/include/scene_session_manager.h"
#include "session_info.h"
#include "session/host/include/scene_session.h"
@ -710,18 +710,24 @@ HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest
sptr<SceneSession> sceneSession;
sceneSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
ASSERT_NE(sceneSession, nullptr);
sceneSession->state_ = SessionState::STATE_FOREGROUND;
sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
sptr<SceneSession> subSession;
subSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(subSession, nullptr);
ASSERT_NE(subSession, nullptr);
ASSERT_NE(subSession->GetSessionProperty(), nullptr);
sceneSession->AddSubSession(subSession);
subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide());
sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
ssm_->HideNonSecureSubWindows(sceneSession);
EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
ssm_->sceneSessionMap_.clear();
}
/**
@ -737,18 +743,23 @@ HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | Smal
sptr<SceneSession> sceneSession;
sceneSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
ASSERT_NE(sceneSession, nullptr);
sceneSession->state_ = SessionState::STATE_FOREGROUND;
ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
sptr<SceneSession> subSession;
subSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(subSession, nullptr);
ASSERT_NE(subSession, nullptr);
ASSERT_NE(subSession->GetSessionProperty(), nullptr);
sceneSession->AddSubSession(subSession);
subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
sptr<SceneSession> floatSession;
floatSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(floatSession, nullptr);
ASSERT_NE(floatSession, nullptr);
ASSERT_NE(floatSession->GetSessionProperty(), nullptr);
floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
@ -822,10 +833,9 @@ HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, Function | SmallTest
info.abilityName_ = "UpdateModalExtensionRect";
info.bundleName_ = "UpdateModalExtensionRect";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
int32_t persistentId = 12345;
ASSERT_NE(sceneSession, nullptr);
Rect rect { 1, 2, 3, 4 };
ssm_->UpdateModalExtensionRect(persistentId, sceneSession->GetPersistentId(), rect);
ssm_->UpdateModalExtensionRect(nullptr, rect);
EXPECT_FALSE(sceneSession->HasModalUIExtension());
}
@ -840,12 +850,30 @@ HWTEST_F(SceneSessionManagerTest, ProcessModalExtensionPointDown, Function | Sma
info.abilityName_ = "ProcessModalExtensionPointDown";
info.bundleName_ = "ProcessModalExtensionPointDown";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(sceneSession, nullptr);
int32_t persistentId = 12345;
ssm_->ProcessModalExtensionPointDown(persistentId, sceneSession->GetPersistentId(), 0, 0);
ssm_->ProcessModalExtensionPointDown(nullptr, 0, 0);
EXPECT_FALSE(sceneSession->HasModalUIExtension());
}
/**
* @tc.name: GetExtensionWindowIds
* @tc.desc: SceneSesionManager get extension window ids
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest, GetExtensionWindowIds, Function | SmallTest | Level3)
{
SessionInfo info;
info.abilityName_ = "GetExtensionWindowIds";
info.bundleName_ = "GetExtensionWindowIds";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(sceneSession, nullptr);
int32_t persistentId = 0;
int32_t parentId = 0;
EXPECT_FALSE(ssm_->GetExtensionWindowIds(nullptr, persistentId, parentId));
}
/**
* @tc.name: AddOrRemoveSecureSession
* @tc.desc: SceneSesionManager hide non-secure windows by scene session
@ -873,9 +901,7 @@ HWTEST_F(SceneSessionManagerTest, UpdateExtWindowFlags, Function | SmallTest | L
info.abilityName_ = "UpdateExtWindowFlags";
info.bundleName_ = "UpdateExtWindowFlags";
int32_t parentId = 1234;
int32_t persistentId = 12345;
auto ret = ssm_->UpdateExtWindowFlags(parentId, persistentId, 7, 7);
auto ret = ssm_->UpdateExtWindowFlags(nullptr, 7, 7);
EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
}

View File

@ -118,12 +118,10 @@ void SceneSessionManagerTest2::TearDownTestCase()
void SceneSessionManagerTest2::SetUp()
{
ssm_->sceneSessionMap_.clear();
}
void SceneSessionManagerTest2::TearDown()
{
ssm_->sceneSessionMap_.clear();
usleep(WAIT_SYNC_IN_NS);
}

View File

@ -1470,16 +1470,10 @@ HWTEST_F(SceneSessionManagerTest4, GetIsLayoutFullScreen, Function | SmallTest |
HWTEST_F(SceneSessionManagerTest4, UpdateExtWindowFlags, Function | SmallTest | Level3)
{
ASSERT_NE(ssm_, nullptr);
int32_t parentId = 1;
int32_t persistentId = 0;
SessionInfo info;
info.abilityName_ = "UpdateExtWindowFlags";
info.bundleName_ = "UpdateExtWindowFlags";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(sceneSession, nullptr);
ssm_->sceneSessionMap_.insert(std::make_pair(parentId, sceneSession));
auto ret = ssm_->UpdateExtWindowFlags(parentId, persistentId, 7, 7);
EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
uint32_t extWindowFlags = 0;
uint32_t extWindowActions = 0;
auto ret = ssm_->UpdateExtWindowFlags(nullptr, extWindowFlags, extWindowActions);
EXPECT_EQ(ret, WSError::WS_OK);
}
/**
@ -1502,8 +1496,9 @@ HWTEST_F(SceneSessionManagerTest4, AddOrRemoveSecureSession02, Function | SmallT
auto result = ssm_->AddOrRemoveSecureSession(0, shouldHide);
EXPECT_EQ(result, WSError::WS_OK);
result = ssm_->AddOrRemoveSecureSession(persistentId, shouldHide);
ssm_->AddExtensionWindowStageToSCB(nullptr, 1, 1, UIExtensionUsage::MODAL);
EXPECT_EQ(result, WSError::WS_OK);
static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
usleep(WAIT_SYNC_IN_NS);
}
/**

View File

@ -717,6 +717,56 @@ HWTEST_F(SceneSessionManagerTest6, NotifyCompleteFirstFrameDrawing, Function | S
ssm_->NotifyCompleteFirstFrameDrawing(1);
}
/**
* @tc.name: NotifyCompleteFirstFrameDrawing02
* @tc.desc: NotifyCompleteFirstFrameDrawing02:AtomicService free-install start.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest6, NotifyCompleteFirstFrameDrawing02, Function | SmallTest | Level3)
{
ASSERT_NE(nullptr, ssm_);
ssm_->sceneSessionMap_.clear();
SessionInfo sessionInfo;
sessionInfo.bundleName_ = "SceneSessionManagerTest2";
sessionInfo.abilityName_ = "DumpSessionWithId";
sessionInfo.abilityInfo = nullptr;
sessionInfo.isAtomicService_ = true;
unsigned int flags = 11111111;
sessionInfo.want = std::make_shared<AAFwk::Want>();
ASSERT_NE(nullptr, sessionInfo.want);
sessionInfo.want->SetFlags(flags);
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
ASSERT_NE(nullptr, sceneSession);
ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
ssm_->NotifyCompleteFirstFrameDrawing(1);
ASSERT_EQ(nullptr, sessionInfo.abilityInfo);
}
/**
* @tc.name: InitSceneSession01
* @tc.desc: InitSceneSession01:AtomicService free-install start.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest6, InitSceneSession01, Function | SmallTest | Level3)
{
ASSERT_NE(nullptr, ssm_);
ssm_->sceneSessionMap_.clear();
SessionInfo sessionInfo;
sessionInfo.bundleName_ = "SceneSessionManagerTest2";
sessionInfo.abilityName_ = "DumpSessionWithId";
sessionInfo.abilityInfo = nullptr;
sessionInfo.isAtomicService_ = true;
unsigned int flags = 11111111;
sessionInfo.want = std::make_shared<AAFwk::Want>();
ASSERT_NE(nullptr, sessionInfo.want);
sessionInfo.want->SetFlags(flags);
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
ASSERT_NE(nullptr, sceneSession);
ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
ssm_->InitSceneSession(sceneSession, sessionInfo, nullptr);
ASSERT_EQ(nullptr, sessionInfo.abilityInfo);
}
/**
* @tc.name: CheckAndNotifyWaterMarkChangedResult
* @tc.desc: CheckAndNotifyWaterMarkChangedResult

View File

@ -489,6 +489,78 @@ HWTEST_F(SceneSessionTest3, IsMovableWindowType, Function | SmallTest | Level2)
EXPECT_EQ(scensession->IsMovableWindowType(), false);
}
/**
* @tc.name: SetBlankFlag
* @tc.desc: check func SetBlankFlag
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest3, SetBlankFlag, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "SetBlankFlag";
info.bundleName_ = "SetBlankFlag";
sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(nullptr, scensession);
bool isAddBlank = true;
scensession->SetBlankFlag(isAddBlank);
ASSERT_EQ(isAddBlank, scensession->GetBlankFlag());
}
/**
* @tc.name: GetBlankFlag
* @tc.desc: check func GetBlankFlag
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest3, GetBlankFlag, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "GetBlankFlag";
info.bundleName_ = "GetBlankFlag";
sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(nullptr, scensession);
bool isAddBlank = true;
scensession->SetBlankFlag(isAddBlank);
ASSERT_EQ(isAddBlank, scensession->GetBlankFlag());
}
/**
* @tc.name: SetBufferAvailableCallbackEnable
* @tc.desc: check func SetBufferAvailableCallbackEnable
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest3, SetBufferAvailableCallbackEnable, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "SetBufferAvailableCallbackEnable";
info.bundleName_ = "SetBufferAvailableCallbackEnable";
sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(nullptr, scensession);
bool enable = true;
scensession->SetBufferAvailableCallbackEnable(enable);
ASSERT_EQ(enable, scensession->GetBufferAvailableCallbackEnable());
}
/**
* @tc.name: GetBufferAvailableCallbackEnable
* @tc.desc: check func GetBufferAvailableCallbackEnable
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest3, GetBufferAvailableCallbackEnable, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "GetBufferAvailableCallbackEnable";
info.bundleName_ = "GetBufferAvailableCallbackEnable";
sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(nullptr, scensession);
bool enable = true;
scensession->SetBufferAvailableCallbackEnable(enable);
ASSERT_EQ(enable, scensession->GetBufferAvailableCallbackEnable());
}
}
}
}

View File

@ -560,7 +560,6 @@ HWTEST_F(SceneSessionTest5, UpdateSessionPropertyByAction, Function | SmallTest
SessionInfo info;
info.abilityName_ = "UpdateSessionPropertyByAction";
info.bundleName_ = "UpdateSessionPropertyByAction";
info.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(session, nullptr);
@ -937,6 +936,26 @@ HWTEST_F(SceneSessionTest5, SetSnapshotSkip, Function | SmallTest | Level2)
EXPECT_EQ(nullptr, session->GetSessionProperty());
}
/**
* @tc.name: UIExtSurfaceNodeIdCache
* @tc.desc: UIExtSurfaceNodeIdCache
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest5, UIExtSurfaceNodeIdCache, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "UIExtSurfaceNodeIdCache";
info.bundleName_ = "UIExtSurfaceNodeIdCache";
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(session, nullptr);
session->AddUIExtSurfaceNodeId(1, 2);
EXPECT_EQ(session->GetUIExtPersistentIdBySurfaceNodeId(1), 2);
session->RemoveUIExtSurfaceNodeId(2);
EXPECT_EQ(session->GetUIExtPersistentIdBySurfaceNodeId(1), 0);
}
/**
* @tc.name: SetSystemSceneOcclusionAlpha
* @tc.desc: SetSystemSceneOcclusionAlpha function01

View File

@ -547,7 +547,7 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape01, Function
ScreenSceneConfig::isWaterfallDisplay_ = false;
ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
auto result = ScreenSceneConfig::GetCurvedCompressionAreaInLandscape();
ASSERT_FALSE(result == 0);
ASSERT_TRUE(result == 0);
}
/**
@ -560,7 +560,7 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape02, Function
ScreenSceneConfig::isWaterfallDisplay_ = true;
ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
auto result = ScreenSceneConfig::GetCurvedCompressionAreaInLandscape();
ASSERT_FALSE(result == 0);
ASSERT_TRUE(result == 0);
}
/**

View File

@ -23,6 +23,9 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace {
constexpr uint32_t SLEEP_TIME_US = 100000;
}
class ScreenSessionDumperTest : public testing::Test {
public:
static void SetUpTestCase();
@ -45,6 +48,7 @@ void ScreenSessionDumperTest::SetUp()
void ScreenSessionDumperTest::TearDown()
{
usleep(SLEEP_TIME_US);
}
namespace {
@ -117,7 +121,280 @@ HWTEST_F(ScreenSessionDumperTest, Dump05, Function | SmallTest | Level1)
ASSERT_TRUE(true);
}
/**
* @tc.name: OutputDumpInfo
* @tc.desc: test function : OutputDumpInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, OutputDumpInfo, Function | SmallTest | Level1)
{
int fd = -1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->OutputDumpInfo();
ASSERT_EQ(dumper->fd_, -1);
}
/**
* @tc.name: ExcuteDumpCmd
* @tc.desc: test function : ExcuteDumpCmd
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, ExcuteDumpCmd, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args;
sptr<ScreenSessionDumper> dumper1 = new ScreenSessionDumper(fd, args);
dumper1->ExcuteDumpCmd();
ASSERT_EQ(dumper1->fd_, 1);
fd = 1;
args = {u"-h"};
sptr<ScreenSessionDumper> dumper2 = new ScreenSessionDumper(fd, args);
dumper2->ExcuteDumpCmd();
ASSERT_EQ(dumper2->fd_, 1);
fd = 1;
args = {u"-a"};
sptr<ScreenSessionDumper> dumper3 = new ScreenSessionDumper(fd, args);
dumper3->ExcuteDumpCmd();
ASSERT_EQ(dumper3->fd_, 1);
fd = 1;
args = {u"-f"};
sptr<ScreenSessionDumper> dumper4 = new ScreenSessionDumper(fd, args);
dumper4->ExcuteDumpCmd();
ASSERT_EQ(dumper4->fd_, 1);
fd = 1;
args = {u"-z"};
sptr<ScreenSessionDumper> dumper5 = new ScreenSessionDumper(fd, args);
dumper5->ExcuteDumpCmd();
ASSERT_EQ(dumper5->fd_, 1);
fd = 1;
args = {u"-y"};
sptr<ScreenSessionDumper> dumper6 = new ScreenSessionDumper(fd, args);
dumper6->ExcuteDumpCmd();
ASSERT_EQ(dumper6->fd_, 1);
fd = 1;
args = {u"-p"};
sptr<ScreenSessionDumper> dumper7 = new ScreenSessionDumper(fd, args);
dumper7->ExcuteDumpCmd();
ASSERT_EQ(dumper7->fd_, 1);
fd = 1;
args = {u"-g"};
sptr<ScreenSessionDumper> dumper8 = new ScreenSessionDumper(fd, args);
dumper8->ExcuteDumpCmd();
ASSERT_EQ(dumper8->fd_, 1);
}
/**
* @tc.name: DumpEventTracker
* @tc.desc: test function : DumpEventTracker
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpEventTracker, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
EventTracker tracker;
dumper->DumpEventTracker(tracker);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpFreezedPidList
* @tc.desc: test function : DumpFreezedPidList
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpFreezedPidList, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
std::set<int32_t> pidList = {1, 2, 3};
dumper->DumpFreezedPidList(pidList);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: ShowHelpInfo
* @tc.desc: test function : ShowHelpInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, ShowHelpInfo, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->ShowHelpInfo();
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: ShowAllScreenInfo
* @tc.desc: test function : ShowAllScreenInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, ShowAllScreenInfo, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->ShowAllScreenInfo();
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpFoldStatus
* @tc.desc: test function : DumpFoldStatus
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpFoldStatus, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->DumpFoldStatus();
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpScreenSessionById
* @tc.desc: test function : DumpScreenSessionById
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpScreenSessionById, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
ScreenId id = 0;
dumper->DumpScreenSessionById(id);
ASSERT_EQ(dumper->fd_, 1);
id = 5;
dumper->DumpScreenSessionById(id);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpRsInfoById
* @tc.desc: test function : DumpRsInfoById
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpRsInfoById, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
ScreenId id = 0;
dumper->DumpRsInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
id = 5;
dumper->DumpRsInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpCutoutInfoById
* @tc.desc: test function : DumpCutoutInfoById
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpCutoutInfoById, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
ScreenId id = 0;
dumper->DumpCutoutInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
id = 5;
dumper->DumpCutoutInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpScreenInfoById
* @tc.desc: test function : DumpScreenInfoById
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpScreenInfoById, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
ScreenId id = 0;
dumper->DumpScreenInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
id = 5;
dumper->DumpScreenInfoById(id);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: DumpScreenPropertyById
* @tc.desc: test function : DumpScreenPropertyById
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, DumpScreenPropertyById, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
ScreenId id = 0;
dumper->DumpScreenPropertyById(id);
ASSERT_EQ(dumper->fd_, 1);
id = 5;
dumper->DumpScreenPropertyById(id);
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: ShowNotifyFoldStatusChangedInfo
* @tc.desc: test function : ShowNotifyFoldStatusChangedInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, ShowNotifyFoldStatusChangedInfo, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->params_[0] = "0";
dumper->ShowNotifyFoldStatusChangedInfo();
ASSERT_EQ(dumper->fd_, 1);
dumper->params_[0] = "1";
dumper->ShowNotifyFoldStatusChangedInfo();
ASSERT_EQ(dumper->fd_, 1);
dumper->params_[0] = "5";
dumper->ShowNotifyFoldStatusChangedInfo();
ASSERT_EQ(dumper->fd_, 1);
}
/**
* @tc.name: ShowIllegalArgsInfo
* @tc.desc: test function : ShowIllegalArgsInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionDumperTest, ShowIllegalArgsInfo, Function | SmallTest | Level1)
{
int fd = 1;
std::vector<std::u16string> args = {u"-h"};
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->params_[0] = "0";
dumper->ShowIllegalArgsInfo();
ASSERT_EQ(dumper->fd_, 1);
}
}
}
}

View File

@ -484,5 +484,357 @@ HWTEST_F(ScreenSessionManagerClientTest, GetScreenSessionById, Function | SmallT
sptr<ScreenSession> ret = screenSessionManagerClient_->GetScreenSessionById(screenId);
EXPECT_EQ(nullptr, ret);
}
/**
* @tc.name: ConnectToServer
* @tc.desc: ConnectToServer test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, ConnectToServer, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->ConnectToServer();
}
/**
* @tc.name: OnPropertyChanged
* @tc.desc: OnPropertyChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnPropertyChanged, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
ScreenProperty property;
ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::UNDEFINED;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnPropertyChanged(screenId, property, reason);
}
/**
* @tc.name: OnSensorRotationChanged
* @tc.desc: OnSensorRotationChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnSensorRotationChanged, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
float sensorRotation = 0;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnSensorRotationChanged(screenId, sensorRotation);
}
/**
* @tc.name: OnScreenOrientationChanged
* @tc.desc: OnScreenOrientationChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnScreenOrientationChanged, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
float screenOrientation = 0;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnSensorRotationChanged(screenId, screenOrientation);
}
/**
* @tc.name: OnScreenRotationLockedChanged
* @tc.desc: OnScreenRotationLockedChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnScreenRotationLockedChanged, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
bool isLocked = false;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnSensorRotationChanged(screenId, isLocked);
}
/**
* @tc.name: RegisterDisplayChangeListener
* @tc.desc: RegisterDisplayChangeListener test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, RegisterDisplayChangeListener, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->RegisterDisplayChangeListener(nullptr);
}
/**
* @tc.name: OnDisplayStateChanged
* @tc.desc: OnDisplayStateChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnDisplayStateChanged, Function | SmallTest | Level2)
{
DisplayId defaultDisplayId = 0;
sptr<DisplayInfo> displayInfo = new DisplayInfo();
std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap {
{ displayInfo->GetDisplayId(), displayInfo },
};
DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnDisplayStateChanged(defaultDisplayId, displayInfo, displayInfoMap, type);
}
/**
* @tc.name: OnGetSurfaceNodeIdsFromMissionIdsChanged
* @tc.desc: OnGetSurfaceNodeIdsFromMissionIdsChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnGetSurfaceNodeIdsFromMissionIdsChanged, Function | SmallTest | Level2)
{
std::vector<uint64_t> missionIds = {0, 1};
std::vector<uint64_t> surfaceNodeIds;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnGetSurfaceNodeIdsFromMissionIdsChanged(missionIds, surfaceNodeIds);
}
/**
* @tc.name: OnScreenshot
* @tc.desc: OnScreenshot test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnScreenshot, Function | SmallTest | Level2)
{
DisplayId displayId = 0;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnScreenshot(displayId);
}
/**
* @tc.name: OnImmersiveStateChanged
* @tc.desc: OnImmersiveStateChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnImmersiveStateChanged, Function | SmallTest | Level2)
{
bool immersive = false;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnImmersiveStateChanged(immersive);
}
/**
* @tc.name: SetDisplayNodeScreenId
* @tc.desc: SetDisplayNodeScreenId test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SetDisplayNodeScreenId, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
ScreenId displayNodeScreenId = 0;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId);
}
/**
* @tc.name: GetCurvedCompressionArea
* @tc.desc: GetCurvedCompressionArea test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, GetCurvedCompressionArea, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->GetCurvedCompressionArea();
}
/**
* @tc.name: GetPhyScreenProperty
* @tc.desc: GetPhyScreenProperty test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, GetPhyScreenProperty, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->GetPhyScreenProperty(screenId);
}
/**
* @tc.name: NotifyDisplayChangeInfoChanged
* @tc.desc: NotifyDisplayChangeInfoChanged test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, NotifyDisplayChangeInfoChanged, Function | SmallTest | Level2)
{
sptr<DisplayChangeInfo> info = new DisplayChangeInfo();
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->NotifyDisplayChangeInfoChanged(info);
}
/**
* @tc.name: SetScreenPrivacyState
* @tc.desc: SetScreenPrivacyState test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SetScreenPrivacyState, Function | SmallTest | Level2)
{
bool hasPrivate = false;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SetScreenPrivacyState(hasPrivate);
}
/**
* @tc.name: SetPrivacyStateByDisplayId
* @tc.desc: SetPrivacyStateByDisplayId test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SetPrivacyStateByDisplayId, Function | SmallTest | Level2)
{
DisplayId id = 0;
bool hasPrivate = false;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SetPrivacyStateByDisplayId(id, hasPrivate);
}
/**
* @tc.name: UpdateAvailableArea
* @tc.desc: UpdateAvailableArea test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, UpdateAvailableArea, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
DMRect area;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->UpdateAvailableArea(screenId, area);
}
/**
* @tc.name: NotifyFoldToExpandCompletion
* @tc.desc: NotifyFoldToExpandCompletion test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, NotifyFoldToExpandCompletion, Function | SmallTest | Level2)
{
bool foldToExpand = true;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->NotifyFoldToExpandCompletion(foldToExpand);
}
/**
* @tc.name: SwitchUserCallback01
* @tc.desc: SwitchUserCallback test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SwitchUserCallback01, Function | SmallTest | Level2)
{
std::vector<int32_t> oldScbPids = {0, 1};
int32_t currentScbPid = 1;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SwitchUserCallback(oldScbPids, currentScbPid);
}
/**
* @tc.name: SwitchUserCallback02
* @tc.desc: SwitchUserCallback test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SwitchUserCallback02, Function | SmallTest | Level2)
{
std::vector<int32_t> oldScbPids = {};
int32_t currentScbPid = 1;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SwitchUserCallback(oldScbPids, currentScbPid);
}
/**
* @tc.name: SwitchingCurrentUser
* @tc.desc: SwitchingCurrentUser test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SwitchingCurrentUser, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SwitchingCurrentUser();
}
/**
* @tc.name: GetFoldStatus
* @tc.desc: GetFoldStatus test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, GetFoldStatus, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->GetFoldStatus();
}
/**
* @tc.name: GetDefaultScreenId
* @tc.desc: GetDefaultScreenId test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, GetDefaultScreenId, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->GetDefaultScreenId();
}
/**
* @tc.name: IsFoldable
* @tc.desc: IsFoldable test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, IsFoldable, Function | SmallTest | Level2)
{
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->IsFoldable();
}
/**
* @tc.name: SetVirtualPixelRatioSystem
* @tc.desc: SetVirtualPixelRatioSystem test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, SetVirtualPixelRatioSystem, Function | SmallTest | Level2)
{
ScreenId screenId = 0;
float virtualPixelRatio = 1.0f;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->SetVirtualPixelRatioSystem(screenId, virtualPixelRatio);
}
/**
* @tc.name: UpdateDisplayHookInfo
* @tc.desc: UpdateDisplayHookInfo test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, UpdateDisplayHookInfo, Function | SmallTest | Level2)
{
int32_t uid = 0;
bool enable = false;
DMHookInfo hookInfo;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->UpdateDisplayHookInfo(uid, enable, hookInfo);
}
/**
* @tc.name: OnFoldStatusChangedReportUE
* @tc.desc: OnFoldStatusChangedReportUE test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerClientTest, OnFoldStatusChangedReportUE, Function | SmallTest | Level2)
{
std::vector<std::string> screenFoldInfo;
ASSERT_TRUE(screenSessionManagerClient_ != nullptr);
screenSessionManagerClient_->OnFoldStatusChangedReportUE(screenFoldInfo);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -274,6 +274,64 @@ HWTEST_F(ScreenSessionManagerTest, ScreenPower, Function | SmallTest | Level3)
ASSERT_EQ(DisplayState::ON, ssm_->GetDisplayState(0));
}
/**
* @tc.name: GetScreenPower
* @tc.desc: GetScreenPower screen power
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenPower, Function | SmallTest | Level3)
{
DisplayId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_EQ(ScreenPowerState::POWER_ON, ssm_->GetScreenPower(0));
}
/**
* @tc.name: IsScreenRotationLocked
* @tc.desc: IsScreenRotationLocked test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, IsScreenRotationLocked, Function | SmallTest | Level3)
{
bool isLocked = false;
DisplayId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_EQ(DMError::DM_OK, ssm_->IsScreenRotationLocked(isLocked));
}
/**
* @tc.name: SetOrientation
* @tc.desc: SetOrientation test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetOrientation, Function | SmallTest | Level3)
{
Orientation orientation = Orientation::HORIZONTAL;
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_EQ(DMError::DM_OK, ssm_->SetOrientation(id, orientation));
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->SetOrientation(SCREEN_ID_INVALID, orientation));
Orientation invalidOrientation = Orientation{20};
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetOrientation(id, invalidOrientation));
}
/**
* @tc.name: SetRotationFromWindow
* @tc.desc: SetRotationFromWindow test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetRotationFromWindow, Function | SmallTest | Level3)
{
Rotation targetRotation = Rotation::ROTATION_0;
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_EQ(ssm_->SetRotationFromWindow(targetRotation), ssm_->SetRotation(id, targetRotation, true));
}
/**
* @tc.name: GetDisplaySnapshot
* @tc.desc: ScreenSesionManager screen shot
@ -493,6 +551,20 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualPixelRatio, Function | SmallTest |
ASSERT_EQ(DMError::DM_OK, ssm_->SetVirtualPixelRatio(screenId, 0.1));
}
/**
* @tc.name: SetVirtualPixelRatioSystem
* @tc.desc: SetVirtualPixelRatioSystem virtual screen
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualPixelRatioSystem, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "SetVirtualPixelRatioSystem";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
ASSERT_EQ(DMError::DM_OK, ssm_->SetVirtualPixelRatioSystem(screenId, 0.1));
}
/**
* @tc.name: SetResolution
* @tc.desc: SetResolution virtual screen
@ -951,6 +1023,78 @@ HWTEST_F(ScreenSessionManagerTest, SetScreenColorGamut, Function | SmallTest | L
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetScreenColorGamut(SCREEN_ID_INVALID, 2));
}
/**
* @tc.name: SetScreenColorTransform
* @tc.desc: SetScreenColorTransform virtual screen
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetScreenColorTransform, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "SetScreenColorTransform";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
auto rsid = ssm_->screenIdManager_.ConvertToRsScreenId(screenId);
sptr<ScreenSession> screenSession =
new (std::nothrow) ScreenSession("SetScreenColorTransform", screenId, rsid, 0);
ASSERT_EQ(DMError::DM_OK, ssm_->SetScreenColorTransform(screenId));
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetScreenColorTransform(SCREEN_ID_INVALID));
}
/**
* @tc.name: IsValidDisplayModeCommand
* @tc.desc: IsValidDisplayModeCommand test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, IsValidDisplayModeCommand, Function | SmallTest | Level3)
{
ASSERT_EQ(true, ssm_->IsValidDisplayModeCommand("-f"));
ASSERT_EQ(true, ssm_->IsValidDisplayModeCommand("-m"));
ASSERT_EQ(true, ssm_->IsValidDisplayModeCommand("-sub"));
ASSERT_EQ(true, ssm_->IsValidDisplayModeCommand("-coor"));
ASSERT_EQ(false, ssm_->IsValidDisplayModeCommand("-a"));
}
/**
* @tc.name: SetFoldDisplayMode
* @tc.desc: SetFoldDisplayMode test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetFoldDisplayMode, Function | SmallTest | Level3)
{
std::string modeParam = "";
ASSERT_EQ(-1, ssm_->SetFoldDisplayMode(modeParam));
std::string displayFull = "-f";
std::string displayMain = "-m";
std::string displaySub = "-sub";
std::string displayCoor = "-coor";
ASSERT_EQ(0, ssm_->SetFoldDisplayMode(displayFull));
ASSERT_EQ(0, ssm_->SetFoldDisplayMode(displayMain));
ASSERT_EQ(0, ssm_->SetFoldDisplayMode(displaySub));
ASSERT_EQ(0, ssm_->SetFoldDisplayMode(displayCoor));
ASSERT_EQ(-1, ssm_->SetFoldDisplayMode("-a"));
}
/**
* @tc.name: SetFoldStatusLocked
* @tc.desc: SetFoldStatusLocked test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetFoldStatusLocked, Function | SmallTest | Level3)
{
std::string lockParam;
ASSERT_EQ(-1, ssm_->SetFoldStatusLocked(lockParam));
std::string lockStatus = "-l";
std::string unLockStatus = "-u";
lockParam = "-a";
ASSERT_EQ(0, ssm_->SetFoldStatusLocked(lockStatus));
ASSERT_EQ(0, ssm_->SetFoldStatusLocked(unLockStatus));
ASSERT_EQ(-1, ssm_->SetFoldStatusLocked(lockParam));
}
/**
* @tc.name: SetScreenRotationLocked
* @tc.desc: SetScreenRotationLocked virtual screen
@ -958,14 +1102,12 @@ HWTEST_F(ScreenSessionManagerTest, SetScreenColorGamut, Function | SmallTest | L
*/
HWTEST_F(ScreenSessionManagerTest, SetScreenRotationLocked, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "SetScreenRotationLocked";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
ScreenId id = 0;
ssm_->screenSessionMap_[id] = nullptr;
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetScreenRotationLocked(false));
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_EQ(DMError::DM_OK, ssm_->SetScreenRotationLocked(false));
}
/**
@ -1161,6 +1303,317 @@ HWTEST_F(ScreenSessionManagerTest, GetAllScreenIds, Function | SmallTest | Level
EXPECT_EQ(res[0], 1);
}
/**
* @tc.name: GetAllScreenInfos
* @tc.desc: GetAllScreenInfos test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetAllScreenInfos, Function | SmallTest | Level3)
{
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
std::vector<sptr<ScreenInfo>> screenInfos;
EXPECT_EQ(DMError::DM_OK, ssm_->GetAllScreenInfos(screenInfos));
}
/**
* @tc.name: GetScreenSupportedColorGamuts
* @tc.desc: GetScreenSupportedColorGamuts test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level3)
{
std::vector<ScreenColorGamut> colorGamuts;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetScreenSupportedColorGamuts(SCREEN_ID_INVALID, colorGamuts));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetScreenSupportedColorGamuts(id, colorGamuts),
screenSession->GetScreenSupportedColorGamuts(colorGamuts));
}
/**
* @tc.name: GetPixelFormat
* @tc.desc: GetPixelFormat test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetPixelFormat, Function | SmallTest | Level3)
{
GraphicPixelFormat pixelFormat;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetPixelFormat(SCREEN_ID_INVALID, pixelFormat));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetPixelFormat(id, pixelFormat), screenSession->GetPixelFormat(pixelFormat));
}
/**
* @tc.name: SetPixelFormat
* @tc.desc: SetPixelFormat test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetPixelFormat, Function | SmallTest | Level3)
{
GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetPixelFormat(SCREEN_ID_INVALID, pixelFormat));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->SetPixelFormat(id, pixelFormat), screenSession->SetPixelFormat(pixelFormat));
}
/**
* @tc.name: GetSupportedHDRFormats
* @tc.desc: GetSupportedHDRFormats test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetSupportedHDRFormats, Function | SmallTest | Level3)
{
std::vector<ScreenHDRFormat> hdrFormats;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetSupportedHDRFormats(SCREEN_ID_INVALID, hdrFormats));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetSupportedHDRFormats(id, hdrFormats), screenSession->GetSupportedHDRFormats(hdrFormats));
}
/**
* @tc.name: GetScreenHDRFormat
* @tc.desc: GetScreenHDRFormat test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenHDRFormat, Function | SmallTest | Level3)
{
ScreenHDRFormat hdrFormat;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetScreenHDRFormat(SCREEN_ID_INVALID, hdrFormat));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetScreenHDRFormat(id, hdrFormat), screenSession->GetScreenHDRFormat(hdrFormat));
}
/**
* @tc.name: SetScreenHDRFormat
* @tc.desc: SetScreenHDRFormat test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetScreenHDRFormat, Function | SmallTest | Level3)
{
int32_t modeIdx {0};
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetScreenHDRFormat(SCREEN_ID_INVALID, modeIdx));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->SetScreenHDRFormat(id, modeIdx), screenSession->SetScreenHDRFormat(modeIdx));
}
/**
* @tc.name: GetSupportedColorSpaces
* @tc.desc: GetSupportedColorSpaces test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetSupportedColorSpaces, Function | SmallTest | Level3)
{
std::vector<GraphicCM_ColorSpaceType> colorSpaces;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetSupportedColorSpaces(SCREEN_ID_INVALID, colorSpaces));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetSupportedColorSpaces(id, colorSpaces), screenSession->GetSupportedColorSpaces(colorSpaces));
}
/**
* @tc.name: GetScreenColorSpace
* @tc.desc: GetScreenColorSpace test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenColorSpace, Function | SmallTest | Level3)
{
GraphicCM_ColorSpaceType colorSpace;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->GetScreenColorSpace(SCREEN_ID_INVALID, colorSpace));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->GetScreenColorSpace(id, colorSpace), screenSession->GetScreenColorSpace(colorSpace));
}
/**
* @tc.name: SetScreenColorSpace
* @tc.desc: SetScreenColorSpace test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetScreenColorSpace, Function | SmallTest | Level3)
{
GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetScreenColorSpace(SCREEN_ID_INVALID, colorSpace));
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(ssm_->SetScreenColorSpace(id, colorSpace), screenSession->SetScreenColorSpace(colorSpace));
}
/**
* @tc.name: HasPrivateWindow
* @tc.desc: HasPrivateWindow test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, HasPrivateWindow, Function | SmallTest | Level3)
{
bool hasPrivateWindow;
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->HasPrivateWindow(SCREEN_ID_INVALID, hasPrivateWindow));
DisplayId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(DMError::DM_OK, ssm_->HasPrivateWindow(id, hasPrivateWindow));
}
/**
* @tc.name: GetAvailableArea
* @tc.desc: GetAvailableArea test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetAvailableArea, Function | SmallTest | Level3)
{
DMRect area;
EXPECT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->GetAvailableArea(SCREEN_ID_INVALID, area));
DisplayId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
ASSERT_NE(nullptr, screenSession);
EXPECT_EQ(DMError::DM_OK, ssm_->GetAvailableArea(id, area));
}
/**
* @tc.name: ResetAllFreezeStatus
* @tc.desc: ResetAllFreezeStatus test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, ResetAllFreezeStatus, Function | SmallTest | Level3)
{
EXPECT_EQ(DMError::DM_OK, ssm_->ResetAllFreezeStatus());
}
/**
* @tc.name: SetVirtualScreenRefreshRate
* @tc.desc: SetVirtualScreenRefreshRate test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenRefreshRate, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
ScreenId id = 0;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0);
ssm_->screenSessionMap_[id] = screenSession;
uint32_t refreshInterval {2};
VirtualScreenOption virtualOption;
virtualOption.name_ = "createVirtualOption";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetVirtualScreenRefreshRate(id, refreshInterval));
EXPECT_EQ(DMError::DM_OK, ssm_->SetVirtualScreenRefreshRate(screenId, refreshInterval));
uint32_t invalidRefreshInterval {0};
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->SetVirtualScreenRefreshRate(screenId, invalidRefreshInterval));
}
/**
* @tc.name: SetVirtualScreenFlag
* @tc.desc: SetVirtualScreenFlag test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenFlag, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenFlag screenFlag = VirtualScreenFlag::DEFAULT;
VirtualScreenOption virtualOption;
virtualOption.name_ = "createVirtualOption";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
EXPECT_EQ(DMError::DM_OK, ssm_->SetVirtualScreenFlag(screenId, screenFlag));
}
/**
* @tc.name: GetVirtualScreenFlag
* @tc.desc: GetVirtualScreenFlag test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetVirtualScreenFlag, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenFlag screenFlag = VirtualScreenFlag::DEFAULT;
VirtualScreenOption virtualOption;
virtualOption.name_ = "createVirtualOption";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
EXPECT_EQ(DMError::DM_OK, ssm_->SetVirtualScreenFlag(screenId, screenFlag));
EXPECT_EQ(screenFlag, ssm_->GetVirtualScreenFlag(screenId));
}
/**
* @tc.name: ResizeVirtualScreen
* @tc.desc: ResizeVirtualScreen test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, ResizeVirtualScreen, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "createVirtualOption";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
uint32_t width {100};
uint32_t height {100};
EXPECT_EQ(DMError::DM_OK, ssm_->ResizeVirtualScreen(screenId, width, height));
}
/**
* @tc.name: SetVirtualMirrorScreenScaleMode
* @tc.desc: SetVirtualMirrorScreenScaleMode test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualMirrorScreenScaleMode, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "createVirtualOption";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
ScreenScaleMode scaleMode = ScreenScaleMode::FILL_MODE;
EXPECT_EQ(DMError::DM_OK, ssm_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode));
}
/**
* @tc.name: StopMirror
* @tc.desc: StopMirror test
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, StopMirror, Function | SmallTest | Level3)
{
std::vector<ScreenId> mirrorScreenIds {0, 1, 2, 3, 4, 5};
EXPECT_EQ(DMError::DM_OK, ssm_->StopMirror(mirrorScreenIds));
}
/**
* @tc.name: GetDensityInCurResolution
* @tc.desc: GetDensityInCurResolution screen power
@ -1180,52 +1633,6 @@ HWTEST_F(ScreenSessionManagerTest, GetDensityInCurResolution, Function | SmallTe
EXPECT_EQ(DMError::DM_OK, res);
}
/**
* @tc.name: SetScreenColorTransform
* @tc.desc: SetScreenColorTransform screen power
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, SetScreenColorTransform, Function | SmallTest | Level3)
{
sptr<ScreenSession> screenSession = new ScreenSession();
ASSERT_NE(nullptr, screenSession);
ssm_->screenSessionMap_.insert(std::make_pair(1, screenSession));
ScreenId screenId = SCREEN_ID_INVALID;
auto res = ssm_->SetScreenColorTransform(screenId);
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, res);
screenId = 100;
res = ssm_->SetScreenColorTransform(screenId);
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, res);
screenId = 1;
res = ssm_->SetScreenColorTransform(screenId);
EXPECT_EQ(DMError::DM_OK, res);
}
/**
* @tc.name: GetPixelFormat
* @tc.desc: GetPixelFormat screen power
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetPixelFormat, Function | SmallTest | Level3)
{
GraphicPixelFormat format = { GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8 };
sptr<ScreenSession> screenSession = new ScreenSession();
ASSERT_NE(nullptr, screenSession);
ssm_->screenSessionMap_.insert(std::make_pair(1, screenSession));
ScreenId screenId = SCREEN_ID_INVALID;
auto res = ssm_->GetPixelFormat(screenId, format);
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, res);
screenId = 100;
res = ssm_->GetPixelFormat(screenId, format);
EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, res);
screenId = 1;
res = ssm_->GetPixelFormat(screenId, format);
EXPECT_EQ(DMError::DM_OK, res);
}
/**
* @tc.name: SetScreenOffDelayTime
* @tc.desc: SetScreenOffDelayTime test

Some files were not shown because too many files have changed in this diff Show More