mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-10-07 04:03:37 +00:00
This commit is contained in:
commit
7c14e7b22c
@ -67,6 +67,8 @@ public:
|
|||||||
virtual bool WakeUpEnd();
|
virtual bool WakeUpEnd();
|
||||||
virtual bool SuspendBegin(PowerStateChangeReason reason);
|
virtual bool SuspendBegin(PowerStateChangeReason reason);
|
||||||
virtual bool SuspendEnd();
|
virtual bool SuspendEnd();
|
||||||
|
virtual ScreenId GetInternalScreenId();
|
||||||
|
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
|
||||||
virtual bool SetDisplayState(DisplayState state);
|
virtual bool SetDisplayState(DisplayState state);
|
||||||
virtual DisplayState GetDisplayState(DisplayId displayId);
|
virtual DisplayState GetDisplayState(DisplayId displayId);
|
||||||
virtual bool TryToCancelScreenOff();
|
virtual bool TryToCancelScreenOff();
|
||||||
|
@ -759,8 +759,86 @@ sptr<Display> DisplayManager::GetDefaultDisplay()
|
|||||||
return pImpl_->GetDefaultDisplay();
|
return pImpl_->GetDefaultDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr<Display> DisplayManager::GetDefaultDisplaySync()
|
void DisplayManager::AddDisplayIdFromAms(DisplayId displayId, const wptr<IRemoteObject>& abilityToken)
|
||||||
{
|
{
|
||||||
|
if (abilityToken == nullptr || displayId == DISPLAY_ID_INVALID) {
|
||||||
|
WLOGFE("abilityToken is nullptr or display id invalid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::lock_guard<std::mutex> lock(displayOperateMutex_);
|
||||||
|
auto iter = std::find_if(displayIdList_.begin(), displayIdList_.end(),
|
||||||
|
[displayId, abilityToken](const auto &item) -> bool {
|
||||||
|
return item.first == abilityToken && item.second == displayId;
|
||||||
|
});
|
||||||
|
if (iter != displayIdList_.end()) {
|
||||||
|
WLOGFI("abilityToken and display has been added.");
|
||||||
|
} else {
|
||||||
|
displayIdList_.push_back(std::make_pair(abilityToken, displayId));
|
||||||
|
}
|
||||||
|
ShowDisplayIdList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayManager::RemoveDisplayIdFromAms(const wptr<IRemoteObject>& abilityToken)
|
||||||
|
{
|
||||||
|
if (abilityToken == nullptr) {
|
||||||
|
WLOGFE("abilityToken is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::lock_guard<std::mutex> lock(displayOperateMutex_);
|
||||||
|
if (displayIdList_.empty()) {
|
||||||
|
WLOGFI("displayIdList_ is empty.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto iter = std::find_if(displayIdList_.begin(), displayIdList_.end(),
|
||||||
|
[abilityToken](const auto &item) -> bool {
|
||||||
|
return item.first == abilityToken;
|
||||||
|
});
|
||||||
|
if (iter != displayIdList_.end()) {
|
||||||
|
displayIdList_.erase(iter);
|
||||||
|
}
|
||||||
|
ShowDisplayIdList();
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayId DisplayManager::GetCallingAbilityDisplayId()
|
||||||
|
{
|
||||||
|
DisplayId displayId = DISPLAY_ID_INVALID;
|
||||||
|
std::lock_guard<std::mutex> lock(displayOperateMutex_);
|
||||||
|
if (displayIdList_.empty()) {
|
||||||
|
WLOGFI("displayIdList is empty.");
|
||||||
|
return displayId;
|
||||||
|
}
|
||||||
|
int displayCount = 0;
|
||||||
|
for (const auto &iter : displayIdList_) {
|
||||||
|
if (displayId == DISPLAY_ID_INVALID || displayId != iter.second) {
|
||||||
|
displayCount++;
|
||||||
|
}
|
||||||
|
displayId = iter.second;
|
||||||
|
if (displayCount > 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ShowDisplayIdList();
|
||||||
|
return displayCount == 1 ? displayId : DISPLAY_ID_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayManager::ShowDisplayIdList()
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "current display id list:[";
|
||||||
|
for (const auto &iter : displayIdList_) {
|
||||||
|
oss << iter.second << ",";
|
||||||
|
}
|
||||||
|
WLOGFD("%{public}s", oss.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr<Display> DisplayManager::GetDefaultDisplaySync(bool isFromNapi)
|
||||||
|
{
|
||||||
|
if (isFromNapi) {
|
||||||
|
DisplayId displayId = GetCallingAbilityDisplayId();
|
||||||
|
if (displayId != DISPLAY_ID_INVALID) {
|
||||||
|
return pImpl_->GetDisplayById(displayId);
|
||||||
|
}
|
||||||
|
}
|
||||||
return pImpl_->GetDefaultDisplaySync();
|
return pImpl_->GetDefaultDisplaySync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1763,6 +1841,18 @@ bool DisplayManager::SuspendEnd()
|
|||||||
return SingletonContainer::Get<DisplayManagerAdapter>().SuspendEnd();
|
return SingletonContainer::Get<DisplayManagerAdapter>().SuspendEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenId DisplayManager::GetInternalScreenId()
|
||||||
|
{
|
||||||
|
WLOGFD("[UL_POWER]GetInternalScreenId start");
|
||||||
|
return SingletonContainer::Get<DisplayManagerAdapter>().GetInternalScreenId();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayManager::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
|
||||||
|
{
|
||||||
|
WLOGFD("[UL_POWER]SetScreenPowerById start");
|
||||||
|
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenPowerById(screenId, state, reason);
|
||||||
|
}
|
||||||
|
|
||||||
bool DisplayManager::Impl::SetDisplayState(DisplayState state, DisplayStateCallback callback)
|
bool DisplayManager::Impl::SetDisplayState(DisplayState state, DisplayStateCallback callback)
|
||||||
{
|
{
|
||||||
WLOGFD("[UL_POWER]state:%{public}u", state);
|
WLOGFD("[UL_POWER]state:%{public}u", state);
|
||||||
|
@ -339,6 +339,21 @@ bool DisplayManagerAdapter::SuspendEnd()
|
|||||||
return displayManagerServiceProxy_->SuspendEnd();
|
return displayManagerServiceProxy_->SuspendEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenId DisplayManagerAdapter::GetInternalScreenId()
|
||||||
|
{
|
||||||
|
INIT_PROXY_CHECK_RETURN(false);
|
||||||
|
|
||||||
|
return displayManagerServiceProxy_->GetInternalScreenId();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayManagerAdapter::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
|
||||||
|
PowerStateChangeReason reason)
|
||||||
|
{
|
||||||
|
INIT_PROXY_CHECK_RETURN(false);
|
||||||
|
|
||||||
|
return displayManagerServiceProxy_->SetScreenPowerById(screenId, state, reason);
|
||||||
|
}
|
||||||
|
|
||||||
bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
|
bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
|
||||||
{
|
{
|
||||||
INIT_PROXY_CHECK_RETURN(false);
|
INIT_PROXY_CHECK_RETURN(false);
|
||||||
|
@ -583,8 +583,12 @@ HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Leve
|
|||||||
{
|
{
|
||||||
DisplayState state = DisplayState{1};
|
DisplayState state = DisplayState{1};
|
||||||
bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
|
bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
|
||||||
|
if (SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||||
|
ASSERT_TRUE(ret);
|
||||||
|
} else {
|
||||||
ASSERT_FALSE(ret);
|
ASSERT_FALSE(ret);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @tc.name: MakeMirror
|
* @tc.name: MakeMirror
|
||||||
@ -714,12 +718,11 @@ HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | Sma
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)
|
HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)
|
||||||
{
|
{
|
||||||
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(0, 100);
|
VirtualScreenOption defaultOption = {"virtualScreen02", 480, 320, 2.0, nullptr, 0};
|
||||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||||
|
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(id, 100);
|
||||||
ASSERT_EQ(err, DMError::DM_OK);
|
ASSERT_EQ(err, DMError::DM_OK);
|
||||||
} else {
|
SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
|
||||||
ASSERT_EQ(err, DMError::DM_OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -729,12 +732,11 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest |
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
|
HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
|
||||||
{
|
{
|
||||||
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualPixelRatio(0, 0);
|
VirtualScreenOption defaultOption = {"virtualScreen03", 480, 320, 2.0, nullptr, 0};
|
||||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||||
|
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualPixelRatio(id, 0);
|
||||||
ASSERT_EQ(err, DMError::DM_OK);
|
ASSERT_EQ(err, DMError::DM_OK);
|
||||||
} else {
|
SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
|
||||||
ASSERT_EQ(err, DMError::DM_OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -744,12 +746,15 @@ HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest |
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)
|
HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)
|
||||||
{
|
{
|
||||||
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetResolution(0, 70, 100, 50);
|
VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0};
|
||||||
|
ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||||
|
DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetResolution(id, 70, 100, 1);
|
||||||
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||||
ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
|
ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
|
||||||
} else {
|
} else {
|
||||||
ASSERT_EQ(err, DMError::DM_ERROR_NULLPTR);
|
ASSERT_EQ(err, DMError::DM_OK);
|
||||||
}
|
}
|
||||||
|
SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,13 +185,11 @@ HWTEST_F(DisplayTest, GetDpi01, Function | SmallTest | Level1)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(DisplayTest, HasImmersiveWindow, Function | SmallTest | Level1)
|
HWTEST_F(DisplayTest, HasImmersiveWindow, Function | SmallTest | Level1)
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||||
|
EXPECT_CALL(m->Mock(), HasImmersiveWindow(_)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||||
bool immersive = false;
|
bool immersive = false;
|
||||||
DMError ret = defaultDisplay_->HasImmersiveWindow(immersive);
|
DMError ret = defaultDisplay_->HasImmersiveWindow(immersive);
|
||||||
if (SceneBoardJudgement::IsSceneBoardEnabled()) {
|
|
||||||
ASSERT_EQ(ret, DMError::DM_OK);
|
ASSERT_EQ(ret, DMError::DM_OK);
|
||||||
} else {
|
|
||||||
ASSERT_NE(ret, DMError::DM_OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
TRANS_ID_WAKE_UP_END,
|
TRANS_ID_WAKE_UP_END,
|
||||||
TRANS_ID_SUSPEND_BEGIN,
|
TRANS_ID_SUSPEND_BEGIN,
|
||||||
TRANS_ID_SUSPEND_END,
|
TRANS_ID_SUSPEND_END,
|
||||||
|
TRANS_ID_GET_INTERNAL_SCREEN_ID,
|
||||||
|
TRANS_ID_SET_SCREEN_POWER_BY_ID,
|
||||||
TRANS_ID_SET_SPECIFIED_SCREEN_POWER,
|
TRANS_ID_SET_SPECIFIED_SCREEN_POWER,
|
||||||
TRANS_ID_SET_SCREEN_POWER_FOR_ALL,
|
TRANS_ID_SET_SCREEN_POWER_FOR_ALL,
|
||||||
TRANS_ID_GET_SCREEN_POWER,
|
TRANS_ID_GET_SCREEN_POWER,
|
||||||
@ -227,6 +229,11 @@ public:
|
|||||||
virtual bool WakeUpEnd() = 0;
|
virtual bool WakeUpEnd() = 0;
|
||||||
virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
|
virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
|
||||||
virtual bool SuspendEnd() = 0;
|
virtual bool SuspendEnd() = 0;
|
||||||
|
virtual ScreenId GetInternalScreenId() { return SCREEN_ID_INVALID; }
|
||||||
|
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0;
|
virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0;
|
||||||
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
|
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
|
||||||
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0;
|
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <ipc_skeleton.h>
|
||||||
#include <pixel_map.h>
|
#include <pixel_map.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -179,7 +180,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Default display id.
|
* @return Default display id.
|
||||||
*/
|
*/
|
||||||
sptr<Display> GetDefaultDisplaySync();
|
sptr<Display> GetDefaultDisplaySync(bool isFromNapi = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the display object by id.
|
* @brief Get the display object by id.
|
||||||
@ -275,6 +276,23 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool SuspendEnd();
|
bool SuspendEnd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get id of internal screen.
|
||||||
|
*
|
||||||
|
* @return Internal screen id.
|
||||||
|
*/
|
||||||
|
ScreenId GetInternalScreenId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the screen power state by screen id.
|
||||||
|
*
|
||||||
|
* @param screenId Screen id.
|
||||||
|
* @param state Screen power state.
|
||||||
|
* @param reason Reason for power state change.
|
||||||
|
* @return True means set success, false means set failed.
|
||||||
|
*/
|
||||||
|
bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the Display State object
|
* @brief Set the Display State object
|
||||||
*
|
*
|
||||||
@ -666,11 +684,31 @@ public:
|
|||||||
|
|
||||||
constexpr static int32_t MAX_RESOLUTION_SIZE_SCREENSHOT = 3840; // max resolution, 4K
|
constexpr static int32_t MAX_RESOLUTION_SIZE_SCREENSHOT = 3840; // max resolution, 4K
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add displayId for current ability through Ability Management.
|
||||||
|
*
|
||||||
|
* @param displayId Identifier of the current display.
|
||||||
|
* @param abilityToken Token of the ability.
|
||||||
|
*/
|
||||||
|
void AddDisplayIdFromAms(DisplayId displayId, const wptr<IRemoteObject>& abilityToken);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes the display identifier through the Ability Management.
|
||||||
|
*
|
||||||
|
* @param abilityToken Token of ability.
|
||||||
|
*/
|
||||||
|
void RemoveDisplayIdFromAms(const wptr<IRemoteObject>& abilityToken);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayManager();
|
DisplayManager();
|
||||||
~DisplayManager();
|
~DisplayManager();
|
||||||
void OnRemoteDied();
|
void OnRemoteDied();
|
||||||
|
|
||||||
|
void ShowDisplayIdList();
|
||||||
|
std::mutex displayOperateMutex_;
|
||||||
|
DisplayId GetCallingAbilityDisplayId();
|
||||||
|
std::vector<std::pair<wptr<IRemoteObject>, DisplayId>> displayIdList_ {};
|
||||||
|
|
||||||
class Impl;
|
class Impl;
|
||||||
std::recursive_mutex mutex_;
|
std::recursive_mutex mutex_;
|
||||||
sptr<Impl> pImpl_;
|
sptr<Impl> pImpl_;
|
||||||
|
@ -461,6 +461,21 @@ public:
|
|||||||
virtual void OnSubWindowClose(bool& terminateCloseProcess) {}
|
virtual void OnSubWindowClose(bool& terminateCloseProcess) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class IMainWindowCloseListener
|
||||||
|
*
|
||||||
|
* @brief IMainWindowCloseListener is used for preprocessing when the main window exits.
|
||||||
|
*/
|
||||||
|
class IMainWindowCloseListener : virtual public RefBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Notify caller when main window closed.
|
||||||
|
*
|
||||||
|
* @param terminateCloseProcess Whether need to terminate the main window close process.
|
||||||
|
*/
|
||||||
|
virtual void OnMainWindowClose(bool& terminateCloseProcess) {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ISwitchFreeMultiWindowListener
|
* @class ISwitchFreeMultiWindowListener
|
||||||
*
|
*
|
||||||
@ -539,6 +554,15 @@ public:
|
|||||||
* @return sptr<Window> Return the window instance founded
|
* @return sptr<Window> Return the window instance founded
|
||||||
*/
|
*/
|
||||||
static sptr<Window> Find(const std::string& windowName);
|
static sptr<Window> Find(const std::string& windowName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get parent main windowId, which is used for mainWindow,subWindow or dialog
|
||||||
|
*
|
||||||
|
* @param windowId window id that need to get parent main window
|
||||||
|
* @return uint32_t Return the parent main window id
|
||||||
|
*/
|
||||||
|
static uint32_t GetParentMainWindowId(uint32_t windowId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the final show window by context. Its implemented in api8
|
* @brief Get the final show window by context. Its implemented in api8
|
||||||
*
|
*
|
||||||
@ -1676,6 +1700,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool IsFloatingWindowAppType() const { return false; }
|
virtual bool IsFloatingWindowAppType() const { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Is pc window of app type or not.
|
||||||
|
*
|
||||||
|
* @return True means pc window of app type, false means the opposite.
|
||||||
|
*/
|
||||||
|
virtual bool IsPcOrPadCapabilityEnabled() const { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Register transfer component data callback.
|
* @brief Register transfer component data callback.
|
||||||
*
|
*
|
||||||
@ -1722,6 +1753,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void UpdatePiPControlStatus(PiPControlType controlType, PiPControlStatus status) {}
|
virtual void UpdatePiPControlStatus(PiPControlType controlType, PiPControlStatus status) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief set auto start status for window.
|
||||||
|
*
|
||||||
|
* @param isAutoStart true means auto start pip window when background, otherwise means the opposite.
|
||||||
|
*/
|
||||||
|
virtual void SetAutoStartPiP(bool isAutoStart) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief When get focused, keep the keyboard created by other windows, support system window and app subwindow.
|
* @brief When get focused, keep the keyboard created by other windows, support system window and app subwindow.
|
||||||
*
|
*
|
||||||
@ -2042,6 +2080,24 @@ public:
|
|||||||
virtual WMError UnregisterSubWindowCloseListeners(
|
virtual WMError UnregisterSubWindowCloseListeners(
|
||||||
const sptr<ISubWindowCloseListener>& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
const sptr<ISubWindowCloseListener>& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register main window close listener.
|
||||||
|
*
|
||||||
|
* @param listener IMainWindowCloseListener.
|
||||||
|
* @return WM_OK means register success, others means register failed.
|
||||||
|
*/
|
||||||
|
virtual WMError RegisterMainWindowCloseListeners(
|
||||||
|
const sptr<IMainWindowCloseListener>& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unregister main window close listener.
|
||||||
|
*
|
||||||
|
* @param listener IMainWindowCloseListener.
|
||||||
|
* @return WM_OK means unregister success, others means unregister failed.
|
||||||
|
*/
|
||||||
|
virtual WMError UnregisterMainWindowCloseListeners(
|
||||||
|
const sptr<IMainWindowCloseListener>& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Register switch free multi-window listener.
|
* @brief Register switch free multi-window listener.
|
||||||
*
|
*
|
||||||
@ -2127,7 +2183,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual WMError RegisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
|
virtual WMError RegisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
|
||||||
{
|
{
|
||||||
return WMError::WM_OK;
|
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2138,7 +2194,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual WMError UnregisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
|
virtual WMError UnregisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener)
|
||||||
{
|
{
|
||||||
return WMError::WM_OK;
|
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2262,6 +2318,34 @@ public:
|
|||||||
* @return * void
|
* @return * void
|
||||||
*/
|
*/
|
||||||
virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {}
|
virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get IsUIExtensionFlag of window.
|
||||||
|
*
|
||||||
|
* @return true - is UIExtension window, flase - is not UIEXtension window.
|
||||||
|
*/
|
||||||
|
virtual bool GetIsUIExtensionFlag() const { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get IsUIExtensionSubWindowFlag of window.
|
||||||
|
*
|
||||||
|
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
|
||||||
|
*/
|
||||||
|
virtual bool GetIsUIExtensionSubWindowFlag() const { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set whether to enable gesture back.
|
||||||
|
* @param enable the value true means to enable gesture back, and false means the opposite.
|
||||||
|
* @return WM_OK means set success, others means set failed.
|
||||||
|
*/
|
||||||
|
virtual WMError SetGestureBackEnabled(bool enable) { return WMError::WM_OK; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get whether the gesture back is enabled or not.
|
||||||
|
*
|
||||||
|
* @return the value true means to enable gesture back, and false means the opposite.
|
||||||
|
*/
|
||||||
|
virtual bool GetGestureBackEnabled() const { return true; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,6 +802,26 @@ public:
|
|||||||
*/
|
*/
|
||||||
WMError SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled);
|
WMError SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get window ids by coordinate.
|
||||||
|
*
|
||||||
|
* @param displayId display id
|
||||||
|
* @param windowNumber indicates the number of query windows
|
||||||
|
* @param x x-coordinate of the window
|
||||||
|
* @param y y-coordinate of the window
|
||||||
|
* @param windowIds array of window id
|
||||||
|
* @return WM_OK means get success, others means get failed.
|
||||||
|
*/
|
||||||
|
WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
|
||||||
|
int32_t x, int32_t y, std::vector<int32_t>& windowIds) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Release screen lock of foreground sessions.
|
||||||
|
*
|
||||||
|
* @return WM_OK means release success, others means failed.
|
||||||
|
*/
|
||||||
|
WMError ReleaseForegroundSessionScreenLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowManager();
|
WindowManager();
|
||||||
~WindowManager();
|
~WindowManager();
|
||||||
|
@ -475,6 +475,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual WindowType GetParentWindowType() const;
|
virtual WindowType GetParentWindowType() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set whether this window is a sub window of the UIExtension.
|
||||||
|
*
|
||||||
|
* @return isUIExtensionSubWindowFlag.
|
||||||
|
*/
|
||||||
|
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
|
||||||
|
/**
|
||||||
|
* @brief Get IsUIExtensionSubWindowFlag of window.
|
||||||
|
*
|
||||||
|
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
|
||||||
|
*/
|
||||||
|
bool GetIsUIExtensionSubWindowFlag() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rect windowRect_ { 0, 0, 0, 0 };
|
Rect windowRect_ { 0, 0, 0, 0 };
|
||||||
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||||
@ -512,6 +525,7 @@ private:
|
|||||||
int32_t realParentId_ = INVALID_WINDOW_ID;
|
int32_t realParentId_ = INVALID_WINDOW_ID;
|
||||||
uint32_t uiExtensionUsage_ = static_cast<uint32_t>(UIExtensionUsage::EMBEDDED);
|
uint32_t uiExtensionUsage_ = static_cast<uint32_t>(UIExtensionUsage::EMBEDDED);
|
||||||
bool isExtensionTag_ = false;
|
bool isExtensionTag_ = false;
|
||||||
|
bool isUIExtensionSubWindowFlag_ = false;
|
||||||
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
|
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
|
||||||
};
|
};
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
|
@ -272,6 +272,12 @@ enum class SystemBarSettingFlag : uint32_t {
|
|||||||
FOLLOW_SETTING = 1 << 2
|
FOLLOW_SETTING = 1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline SystemBarSettingFlag operator|(SystemBarSettingFlag lhs, SystemBarSettingFlag rhs)
|
||||||
|
{
|
||||||
|
using T = std::underlying_type_t<SystemBarSettingFlag>;
|
||||||
|
return static_cast<SystemBarSettingFlag>(static_cast<T>(lhs) | static_cast<T>(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumerates flag of multiWindowUIType.
|
* @brief Enumerates flag of multiWindowUIType.
|
||||||
*/
|
*/
|
||||||
@ -428,6 +434,15 @@ enum class WindowStyleType : uint8_t {
|
|||||||
WINDOW_STYLE_FREE_MULTI_WINDOW = 1,
|
WINDOW_STYLE_FREE_MULTI_WINDOW = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable Gesture Back Type
|
||||||
|
*/
|
||||||
|
enum class GestureBackType : uint8_t {
|
||||||
|
GESTURE_SIDE = 0,
|
||||||
|
GESTURE_SWIPE_UP = 1,
|
||||||
|
GESTURE_ALL = 2,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct PointInfo.
|
* @struct PointInfo.
|
||||||
*
|
*
|
||||||
|
@ -135,7 +135,9 @@ napi_value AsyncProcess(napi_env env,
|
|||||||
napi_value resourceName = nullptr;
|
napi_value resourceName = nullptr;
|
||||||
if (!NAPICall(env, napi_create_string_latin1(env, funcname.c_str(), NAPI_AUTO_LENGTH, &resourceName))) {
|
if (!NAPICall(env, napi_create_string_latin1(env, funcname.c_str(), NAPI_AUTO_LENGTH, &resourceName))) {
|
||||||
delete info;
|
delete info;
|
||||||
napi_delete_reference(env, callbackRef);
|
if (callbackRef != nullptr) {
|
||||||
|
static_cast<void>(napi_delete_reference(env, callbackRef));
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,19 +150,25 @@ napi_value AsyncProcess(napi_env env,
|
|||||||
|
|
||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
delete info;
|
delete info;
|
||||||
napi_delete_reference(env, callbackRef);
|
if (callbackRef != nullptr) {
|
||||||
|
static_cast<void>(napi_delete_reference(env, callbackRef));
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NAPICall(env, napi_create_async_work(env, nullptr, resourceName, AsyncFunc<ParamT>,
|
if (!NAPICall(env, napi_create_async_work(env, nullptr, resourceName, AsyncFunc<ParamT>,
|
||||||
CompleteFunc<ParamT>, reinterpret_cast<void *>(info), &info->asyncWork))) {
|
CompleteFunc<ParamT>, reinterpret_cast<void *>(info), &info->asyncWork))) {
|
||||||
delete info;
|
delete info;
|
||||||
napi_delete_reference(env, callbackRef);
|
if (callbackRef != nullptr) {
|
||||||
|
static_cast<void>(napi_delete_reference(env, callbackRef));
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!NAPICall(env, napi_queue_async_work(env, info->asyncWork))) {
|
if (!NAPICall(env, napi_queue_async_work(env, info->asyncWork))) {
|
||||||
delete info;
|
delete info;
|
||||||
napi_delete_reference(env, callbackRef);
|
if (callbackRef != nullptr) {
|
||||||
|
static_cast<void>(napi_delete_reference(env, callbackRef));
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ napi_value OnGetDefaultDisplaySync(napi_env env, napi_callback_info info)
|
|||||||
{
|
{
|
||||||
WLOGD("GetDefaultDisplaySync called");
|
WLOGD("GetDefaultDisplaySync called");
|
||||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Sync:GetDefaultDisplay");
|
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Sync:GetDefaultDisplay");
|
||||||
sptr<Display> display = SingletonContainer::Get<DisplayManager>().GetDefaultDisplaySync();
|
sptr<Display> display = SingletonContainer::Get<DisplayManager>().GetDefaultDisplaySync(true);
|
||||||
if (display == nullptr) {
|
if (display == nullptr) {
|
||||||
WLOGFE("[NAPI]Display info is nullptr, js error will be happen");
|
WLOGFE("[NAPI]Display info is nullptr, js error will be happen");
|
||||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN)));
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN)));
|
||||||
|
@ -27,6 +27,13 @@ namespace {
|
|||||||
constexpr int32_t NUMBER_TWO = 2;
|
constexpr int32_t NUMBER_TWO = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_valuetype GetType(napi_env env, napi_value value)
|
||||||
|
{
|
||||||
|
napi_valuetype res = napi_undefined;
|
||||||
|
napi_typeof(env, value, &res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
napi_value NapiGetUndefined(napi_env env)
|
napi_value NapiGetUndefined(napi_env env)
|
||||||
{
|
{
|
||||||
napi_value result = nullptr;
|
napi_value result = nullptr;
|
||||||
@ -179,6 +186,37 @@ napi_value JsPipManager::OnSetTypeNodeEnabled(napi_env env, napi_callback_info i
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsPipManager::SetPipNodeType(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsPipManager* me = CheckParamsAndGetThis<JsPipManager>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnSetPipNodeType(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsPipManager::OnSetPipNodeType(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_PIP, "[NAPI]");
|
||||||
|
size_t argc = 4; // 4: arg number
|
||||||
|
napi_value argv[4] = { nullptr };
|
||||||
|
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||||
|
if (argc != NUMBER_TWO) {
|
||||||
|
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
napi_value typeNode = argv[0];
|
||||||
|
bool markPip = false;
|
||||||
|
if (!ConvertFromJsValue(env, argv[1], markPip)) {
|
||||||
|
TLOGW(WmsLogTag::WMS_PIP, "Failed to convert param to bool");
|
||||||
|
}
|
||||||
|
if (typeNode != nullptr && GetType(env, typeNode) != napi_undefined) {
|
||||||
|
XComponentControllerErrorCode ret =
|
||||||
|
XComponentController::SetSurfaceCallbackMode(env, typeNode, markPip ?
|
||||||
|
SurfaceCallbackMode::PIP : SurfaceCallbackMode::DEFAULT);
|
||||||
|
TLOGI(WmsLogTag::WMS_PIP, "set surface mode, ret: %{public}u, isPip: %{public}d",
|
||||||
|
static_cast<uint32_t>(ret), static_cast<uint32_t>(markPip));
|
||||||
|
}
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsPipManager::RegisterCallback(napi_env env, napi_callback_info info)
|
napi_value JsPipManager::RegisterCallback(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
JsPipManager* me = CheckParamsAndGetThis<JsPipManager>(env, info);
|
JsPipManager* me = CheckParamsAndGetThis<JsPipManager>(env, info);
|
||||||
@ -250,6 +288,7 @@ napi_value JsPipManagerInit(napi_env env, napi_value exportObj)
|
|||||||
BindNativeFunction(env, exportObj, "on", moduleName, JsPipManager::RegisterCallback);
|
BindNativeFunction(env, exportObj, "on", moduleName, JsPipManager::RegisterCallback);
|
||||||
BindNativeFunction(env, exportObj, "off", moduleName, JsPipManager::UnregisterCallback);
|
BindNativeFunction(env, exportObj, "off", moduleName, JsPipManager::UnregisterCallback);
|
||||||
BindNativeFunction(env, exportObj, "setTypeNodeEnabled", moduleName, JsPipManager::SetTypeNodeEnabled);
|
BindNativeFunction(env, exportObj, "setTypeNodeEnabled", moduleName, JsPipManager::SetTypeNodeEnabled);
|
||||||
|
BindNativeFunction(env, exportObj, "setPipNodeType", moduleName, JsPipManager::SetPipNodeType);
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
||||||
static napi_value UnregisterCallback(napi_env env, napi_callback_info info);
|
static napi_value UnregisterCallback(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetTypeNodeEnabled(napi_env env, napi_callback_info info);
|
static napi_value SetTypeNodeEnabled(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value SetPipNodeType(napi_env env, napi_callback_info info);
|
||||||
private:
|
private:
|
||||||
napi_value OnInitXComponentController(napi_env env, napi_callback_info info);
|
napi_value OnInitXComponentController(napi_env env, napi_callback_info info);
|
||||||
napi_value OnGetCustomUIController(napi_env env, napi_callback_info info);
|
napi_value OnGetCustomUIController(napi_env env, napi_callback_info info);
|
||||||
@ -39,6 +40,7 @@ private:
|
|||||||
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
||||||
napi_value OnUnregisterCallback(napi_env env, napi_callback_info info);
|
napi_value OnUnregisterCallback(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetTypeNodeEnabled(napi_env env, napi_callback_info info);
|
napi_value OnSetTypeNodeEnabled(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnSetPipNodeType(napi_env env, napi_callback_info info);
|
||||||
};
|
};
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -38,6 +38,11 @@ using namespace AbilityRuntime;
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindowManager"};
|
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindowManager"};
|
||||||
const std::string PIP_WINDOW = "pip_window";
|
const std::string PIP_WINDOW = "pip_window";
|
||||||
|
constexpr size_t ARGC_ONE = 1;
|
||||||
|
constexpr size_t ARGC_TWO = 2;
|
||||||
|
constexpr size_t ARGC_THREE = 3;
|
||||||
|
constexpr size_t ARGC_FOUR = 4;
|
||||||
|
constexpr int32_t INVALID_COORDINATE = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsWindowManager::JsWindowManager() : registerManager_(std::make_unique<JsWindowRegisterManager>())
|
JsWindowManager::JsWindowManager() : registerManager_(std::make_unique<JsWindowRegisterManager>())
|
||||||
@ -121,6 +126,7 @@ napi_value JsWindowManager::GetSnapshot(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnGetSnapshot(env, info) : nullptr;
|
return (me != nullptr) ? me->OnGetSnapshot(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindowManager::SetWindowLayoutMode(napi_env env, napi_callback_info info)
|
napi_value JsWindowManager::SetWindowLayoutMode(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
|
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
|
||||||
@ -151,6 +157,12 @@ napi_value JsWindowManager::GetVisibleWindowInfo(napi_env env, napi_callback_inf
|
|||||||
return (me != nullptr) ? me->OnGetVisibleWindowInfo(env, info) : nullptr;
|
return (me != nullptr) ? me->OnGetVisibleWindowInfo(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindowManager::GetWindowsByCoordinate(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnGetWindowsByCoordinate(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
static void GetNativeContext(napi_env env, napi_value nativeContext, void*& contextPtr, WMError& errCode)
|
static void GetNativeContext(napi_env env, napi_value nativeContext, void*& contextPtr, WMError& errCode)
|
||||||
{
|
{
|
||||||
AppExecFwk::Ability* ability = nullptr;
|
AppExecFwk::Ability* ability = nullptr;
|
||||||
@ -893,7 +905,7 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca
|
|||||||
WLOGFE("%{public}s", lists->errMsg.c_str());
|
WLOGFE("%{public}s", lists->errMsg.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lists->window == nullptr) {
|
if (lists->window == nullptr || lists->window->GetWindowState() == WindowState::STATE_DESTROYED) {
|
||||||
if (newApi) {
|
if (newApi) {
|
||||||
task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,
|
task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,
|
||||||
"Get top window failed"));
|
"Get top window failed"));
|
||||||
@ -968,6 +980,7 @@ napi_value JsWindowManager::OnGetLastWindow(napi_env env, napi_callback_info inf
|
|||||||
return GetTopWindowTask(contextPtr, env, nativeCallback, true);
|
return GetTopWindowTask(contextPtr, env, nativeCallback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindowManager::OnSetWindowLayoutMode(napi_env env, napi_callback_info info)
|
napi_value JsWindowManager::OnSetWindowLayoutMode(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFD("OnSetWindowLayoutMode");
|
WLOGFD("OnSetWindowLayoutMode");
|
||||||
@ -1191,6 +1204,58 @@ napi_value JsWindowManager::OnGetVisibleWindowInfo(napi_env env, napi_callback_i
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindowManager::OnGetWindowsByCoordinate(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 || argc > ARGC_FOUR) { // min param num 1, max param num 4
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
int64_t displayId = static_cast<int64_t>(DISPLAY_ID_INVALID);
|
||||||
|
if (!ConvertFromJsValue(env, argv[0], displayId)) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "Failed to convert parameter to displayId");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
if (displayId < 0 ||
|
||||||
|
SingletonContainer::Get<DisplayManager>().GetDisplayById(static_cast<uint64_t>(displayId)) == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "invalid displayId");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
int32_t windowNumber = 0;
|
||||||
|
if (argc > ARGC_ONE && !ConvertFromJsValue(env, argv[ARGC_ONE], windowNumber)) {
|
||||||
|
windowNumber = 0;
|
||||||
|
}
|
||||||
|
int32_t x = INVALID_COORDINATE;
|
||||||
|
if (argc > ARGC_TWO && !ConvertFromJsValue(env, argv[ARGC_TWO], x)) {
|
||||||
|
x = INVALID_COORDINATE;
|
||||||
|
}
|
||||||
|
int32_t y = INVALID_COORDINATE;
|
||||||
|
if (argc > ARGC_THREE && !ConvertFromJsValue(env, argv[ARGC_THREE], y)) {
|
||||||
|
y = INVALID_COORDINATE;
|
||||||
|
}
|
||||||
|
napi_value result = nullptr;
|
||||||
|
NapiAsyncTask::CompleteCallback complete =
|
||||||
|
[displayId, windowNumber, x, y](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||||
|
std::vector<int32_t> windowIds;
|
||||||
|
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(SingletonContainer::Get<WindowManager>().
|
||||||
|
GetWindowIdsByCoordinate(static_cast<uint64_t>(displayId), windowNumber, x, y, windowIds));
|
||||||
|
if (ret == WmErrorCode::WM_OK) {
|
||||||
|
std::vector<sptr<Window>> windows(windowIds.size());
|
||||||
|
for (size_t i = 0; i < windowIds.size(); i++) {
|
||||||
|
sptr<Window> window = Window::GetWindowWithId(windowIds[i]);
|
||||||
|
windows[i] = window;
|
||||||
|
}
|
||||||
|
task.Resolve(env, CreateJsWindowArrayObject(env, windows));
|
||||||
|
} else {
|
||||||
|
task.Reject(env, JsErrUtils::CreateJsError(env, ret, "OnGetWindowsByCoordinate failed"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NapiAsyncTask::Schedule("JsWindowManager::OnGetWindowsByCoordinate",
|
||||||
|
env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
|
napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
|
||||||
{
|
{
|
||||||
@ -1238,6 +1303,7 @@ napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
|
|||||||
BindNativeFunction(env, exportObj, "setWaterMarkImage", moduleName, JsWindowManager::SetWaterMarkImage);
|
BindNativeFunction(env, exportObj, "setWaterMarkImage", moduleName, JsWindowManager::SetWaterMarkImage);
|
||||||
BindNativeFunction(env, exportObj, "shiftAppWindowFocus", moduleName, JsWindowManager::ShiftAppWindowFocus);
|
BindNativeFunction(env, exportObj, "shiftAppWindowFocus", moduleName, JsWindowManager::ShiftAppWindowFocus);
|
||||||
BindNativeFunction(env, exportObj, "getVisibleWindowInfo", moduleName, JsWindowManager::GetVisibleWindowInfo);
|
BindNativeFunction(env, exportObj, "getVisibleWindowInfo", moduleName, JsWindowManager::GetVisibleWindowInfo);
|
||||||
|
BindNativeFunction(env, exportObj, "getWindowsByCoordinate", moduleName, JsWindowManager::GetWindowsByCoordinate);
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
static napi_value SetWaterMarkImage(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 ShiftAppWindowFocus(napi_env env, napi_callback_info info);
|
||||||
static napi_value GetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
static napi_value GetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value GetWindowsByCoordinate(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static napi_value OnCreate(napi_env env, napi_callback_info info);
|
static napi_value OnCreate(napi_env env, napi_callback_info info);
|
||||||
@ -65,6 +66,7 @@ private:
|
|||||||
static napi_value OnSetWaterMarkImage(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 OnShiftAppWindowFocus(napi_env env, napi_callback_info info);
|
||||||
static napi_value OnGetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
static napi_value OnGetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value OnGetWindowsByCoordinate(napi_env env, napi_callback_info info);
|
||||||
static bool ParseRequiredConfigOption(
|
static bool ParseRequiredConfigOption(
|
||||||
napi_env env, napi_value jsObject, WindowOption& option);
|
napi_env env, napi_value jsObject, WindowOption& option);
|
||||||
static bool ParseConfigOption(
|
static bool ParseConfigOption(
|
||||||
|
@ -165,6 +165,7 @@ napi_value JsWindow::Recover(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnRecover(env, info) : nullptr;
|
return (me != nullptr) ? me->OnRecover(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::MoveTo(napi_env env, napi_callback_info info)
|
napi_value JsWindow::MoveTo(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGD("MoveTo");
|
WLOGD("MoveTo");
|
||||||
@ -172,6 +173,7 @@ napi_value JsWindow::MoveTo(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnMoveTo(env, info) : nullptr;
|
return (me != nullptr) ? me->OnMoveTo(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::MoveWindowTo(napi_env env, napi_callback_info info)
|
napi_value JsWindow::MoveWindowTo(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGD("MoveTo");
|
WLOGD("MoveTo");
|
||||||
@ -179,6 +181,7 @@ napi_value JsWindow::MoveWindowTo(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnMoveWindowTo(env, info) : nullptr;
|
return (me != nullptr) ? me->OnMoveWindowTo(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::MoveWindowToAsync(napi_env env, napi_callback_info info)
|
napi_value JsWindow::MoveWindowToAsync(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::WMS_LAYOUT, "MoveToAsync");
|
TLOGI(WmsLogTag::WMS_LAYOUT, "MoveToAsync");
|
||||||
@ -186,6 +189,7 @@ napi_value JsWindow::MoveWindowToAsync(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnMoveWindowToAsync(env, info) : nullptr;
|
return (me != nullptr) ? me->OnMoveWindowToAsync(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::Resize(napi_env env, napi_callback_info info)
|
napi_value JsWindow::Resize(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGD("Resize");
|
WLOGD("Resize");
|
||||||
@ -193,6 +197,7 @@ napi_value JsWindow::Resize(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnResize(env, info) : nullptr;
|
return (me != nullptr) ? me->OnResize(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::ResizeWindow(napi_env env, napi_callback_info info)
|
napi_value JsWindow::ResizeWindow(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGI("Resize");
|
WLOGI("Resize");
|
||||||
@ -200,6 +205,7 @@ napi_value JsWindow::ResizeWindow(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnResizeWindow(env, info) : nullptr;
|
return (me != nullptr) ? me->OnResizeWindow(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::ResizeWindowAsync(napi_env env, napi_callback_info info)
|
napi_value JsWindow::ResizeWindowAsync(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::WMS_LAYOUT, "ResizeAsync");
|
TLOGI(WmsLogTag::WMS_LAYOUT, "ResizeAsync");
|
||||||
@ -214,6 +220,7 @@ napi_value JsWindow::SetWindowType(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnSetWindowType(env, info) : nullptr;
|
return (me != nullptr) ? me->OnSetWindowType(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::SetWindowMode(napi_env env, napi_callback_info info)
|
napi_value JsWindow::SetWindowMode(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGI("SetWindowMode");
|
WLOGI("SetWindowMode");
|
||||||
@ -784,6 +791,7 @@ napi_value JsWindow::EnableDrag(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnEnableDrag(env, info) : nullptr;
|
return (me != nullptr) ? me->OnEnableDrag(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::GetWindowLimits(napi_env env, napi_callback_info info)
|
napi_value JsWindow::GetWindowLimits(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGI("[NAPI]GetWindowLimits");
|
WLOGI("[NAPI]GetWindowLimits");
|
||||||
@ -791,6 +799,7 @@ napi_value JsWindow::GetWindowLimits(napi_env env, napi_callback_info info)
|
|||||||
return (me != nullptr) ? me->OnGetWindowLimits(env, info) : nullptr;
|
return (me != nullptr) ? me->OnGetWindowLimits(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::SetWindowLimits(napi_env env, napi_callback_info info)
|
napi_value JsWindow::SetWindowLimits(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGI("[NAPI]SetWindowLimits");
|
WLOGI("[NAPI]SetWindowLimits");
|
||||||
@ -854,6 +863,13 @@ napi_value JsWindow::SetTitleButtonVisible(napi_env env, napi_callback_info info
|
|||||||
return (me != nullptr) ? me->OnSetTitleButtonVisible(env, info) : nullptr;
|
return (me != nullptr) ? me->OnSetTitleButtonVisible(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::SetWindowTitleButtonVisible(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
|
||||||
|
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnSetWindowTitleButtonVisible(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsWindow::SetWindowGrayScale(napi_env env, napi_callback_info info)
|
napi_value JsWindow::SetWindowGrayScale(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGI("[NAPI]SetWindowGrayScale");
|
WLOGI("[NAPI]SetWindowGrayScale");
|
||||||
@ -910,6 +926,20 @@ napi_value JsWindow::CreateSubWindowWithOptions(napi_env env, napi_callback_info
|
|||||||
return (me != nullptr) ? me->OnCreateSubWindowWithOptions(env, info) : nullptr;
|
return (me != nullptr) ? me->OnCreateSubWindowWithOptions(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::SetGestureBackEnabled(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]");
|
||||||
|
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnSetGestureBackEnabled(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::GetGestureBackEnabled(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]");
|
||||||
|
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnGetGestureBackEnabled(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdateSystemBarProperties(std::map<WindowType, SystemBarProperty>& systemBarProperties,
|
static void UpdateSystemBarProperties(std::map<WindowType, SystemBarProperty>& systemBarProperties,
|
||||||
const std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, sptr<Window> windowToken)
|
const std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, sptr<Window> windowToken)
|
||||||
{
|
{
|
||||||
@ -1325,6 +1355,7 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnMoveTo(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnMoveTo(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WMError errCode = WMError::WM_OK;
|
WMError errCode = WMError::WM_OK;
|
||||||
@ -1378,6 +1409,7 @@ napi_value JsWindow::OnMoveTo(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||||
@ -1464,6 +1496,7 @@ static void SetMoveWindowToAsyncTask(NapiAsyncTask::ExecuteCallback& execute, Na
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||||
@ -1502,6 +1535,7 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnResize(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnResize(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WMError errCode = WMError::WM_OK;
|
WMError errCode = WMError::WM_OK;
|
||||||
@ -1557,6 +1591,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnResizeWindow(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnResizeWindow(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||||
@ -1649,6 +1684,7 @@ static void SetResizeWindowAsyncTask(NapiAsyncTask::ExecuteCallback& execute, Na
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||||
@ -1749,6 +1785,7 @@ napi_value JsWindow::OnSetWindowType(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||||
@ -5706,6 +5743,26 @@ __attribute__((no_sanitize("cfi")))
|
|||||||
return objValue;
|
return objValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value CreateJsWindowArrayObject(napi_env env, const std::vector<sptr<Window>>& windows)
|
||||||
|
{
|
||||||
|
napi_value arrayValue = nullptr;
|
||||||
|
napi_create_array_with_length(env, windows.size(), &arrayValue);
|
||||||
|
if (arrayValue == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "Failed to create napi array");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
uint32_t index = 0;
|
||||||
|
for (size_t i = 0; i < windows.size(); i++) {
|
||||||
|
auto window = windows[i];
|
||||||
|
if (window == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::DEFAULT, "window is null");
|
||||||
|
} else {
|
||||||
|
napi_set_element(env, arrayValue, index++, CreateJsWindowObject(env, window));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arrayValue;
|
||||||
|
}
|
||||||
|
|
||||||
bool JsWindow::ParseWindowLimits(napi_env env, napi_value jsObject, WindowLimits& windowLimits)
|
bool JsWindow::ParseWindowLimits(napi_env env, napi_value jsObject, WindowLimits& windowLimits)
|
||||||
{
|
{
|
||||||
uint32_t data = 0;
|
uint32_t data = 0;
|
||||||
@ -5816,6 +5873,7 @@ NapiAsyncTask::CompleteCallback JsWindow::GetEnableDragCompleteCallback(
|
|||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
@ -5868,6 +5926,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @note @window.layout */
|
||||||
napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
@ -6168,6 +6227,42 @@ napi_value JsWindow::OnSetTitleButtonVisible(napi_env env, napi_callback_info in
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::OnSetWindowTitleButtonVisible(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 < 2) { // 2: params num
|
||||||
|
WLOGFE("Argc is invalid: %{public}zu", argc);
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
bool isMaximizeVisible = true;
|
||||||
|
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isMaximizeVisible)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMaximizeVisible");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
bool isMinimizeVisible = true;
|
||||||
|
if (!ConvertFromJsValue(env, argv[INDEX_ONE], isMinimizeVisible)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMinimizeVisible");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
if (windowToken_ == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
|
||||||
|
}
|
||||||
|
WMError errCode = windowToken_->SetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isMaximizeVisible,
|
||||||
|
true);
|
||||||
|
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode);
|
||||||
|
if (ret != WmErrorCode::WM_OK) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LAYOUT, "set title button visible failed!");
|
||||||
|
return NapiThrowError(env, ret);
|
||||||
|
}
|
||||||
|
TLOGI(WmsLogTag::WMS_LAYOUT,
|
||||||
|
"Window [%{public}u, %{public}s] [%{public}d, %{public}d]",
|
||||||
|
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isMaximizeVisible, isMinimizeVisible);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
@ -6522,6 +6617,52 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::OnSetGestureBackEnabled(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
size_t argc = FOUR_PARAMS_SIZE;
|
||||||
|
napi_value argv[FOUR_PARAMS_SIZE] = {nullptr};
|
||||||
|
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||||
|
if (argc != INDEX_ONE) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc);
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||||
|
}
|
||||||
|
if (windowToken_ == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
|
||||||
|
}
|
||||||
|
if (!WindowHelper::IsMainWindow(windowToken_->GetType()) &&
|
||||||
|
!WindowHelper::IsSubWindow(windowToken_->GetType())) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]set failed since invalid window type");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING);
|
||||||
|
}
|
||||||
|
bool enable = true;
|
||||||
|
napi_get_value_bool(env, argv[INDEX_ZERO], &enable);
|
||||||
|
TLOGI(WmsLogTag::WMS_IMMS, "[NAPI]enable: %{public}d", enable);
|
||||||
|
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetGestureBackEnabled(enable));
|
||||||
|
if (ret != WmErrorCode::WM_OK) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "set failed, ret = %{public}d", ret);
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY);
|
||||||
|
}
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsWindow::OnGetGestureBackEnabled(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
if (windowToken_ == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
|
||||||
|
}
|
||||||
|
if (!WindowHelper::IsMainWindow(windowToken_->GetType()) &&
|
||||||
|
!WindowHelper::IsSubWindow(windowToken_->GetType())) {
|
||||||
|
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI] get failed since invalid window type");
|
||||||
|
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING);
|
||||||
|
}
|
||||||
|
bool isEnabled = windowToken_->GetGestureBackEnabled();
|
||||||
|
TLOGI(WmsLogTag::WMS_IMMS, "window [%{public}u, %{public}s], enable = %{public}u",
|
||||||
|
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isEnabled);
|
||||||
|
return CreateJsValue(env, isEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
static void CreateNewSubWindowTask(const sptr<Window>& windowToken, const std::string& windowName,
|
static void CreateNewSubWindowTask(const sptr<Window>& windowToken, const std::string& windowName,
|
||||||
sptr<WindowOption>& windowOption, napi_env env, NapiAsyncTask& task)
|
sptr<WindowOption>& windowOption, napi_env env, NapiAsyncTask& task)
|
||||||
{
|
{
|
||||||
@ -6556,6 +6697,16 @@ static void CreateNewSubWindowTask(const sptr<Window>& windowToken, const std::s
|
|||||||
|
|
||||||
napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info)
|
napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
|
if (windowToken_ == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_SUB, "window is null");
|
||||||
|
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
if (!windowToken_->IsPcOrPadCapabilityEnabled()) {
|
||||||
|
TLOGE(WmsLogTag::WMS_SUB, "device not support");
|
||||||
|
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
napi_value argv[4] = {nullptr};
|
napi_value argv[4] = {nullptr};
|
||||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||||
@ -6710,6 +6861,7 @@ void BindFunctions(napi_env env, napi_value object, const char* moduleName)
|
|||||||
BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight);
|
BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight);
|
||||||
BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect);
|
BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect);
|
||||||
BindNativeFunction(env, object, "setTitleButtonVisible", moduleName, JsWindow::SetTitleButtonVisible);
|
BindNativeFunction(env, object, "setTitleButtonVisible", moduleName, JsWindow::SetTitleButtonVisible);
|
||||||
|
BindNativeFunction(env, object, "setWindowTitleButtonVisible", moduleName, JsWindow::SetWindowTitleButtonVisible);
|
||||||
BindNativeFunction(env, object, "setWindowContainerColor", moduleName, JsWindow::SetWindowContainerColor);
|
BindNativeFunction(env, object, "setWindowContainerColor", moduleName, JsWindow::SetWindowContainerColor);
|
||||||
BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask);
|
BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask);
|
||||||
BindNativeFunction(env, object, "setWindowGrayScale", moduleName, JsWindow::SetWindowGrayScale);
|
BindNativeFunction(env, object, "setWindowGrayScale", moduleName, JsWindow::SetWindowGrayScale);
|
||||||
@ -6719,6 +6871,8 @@ void BindFunctions(napi_env env, napi_value object, const char* moduleName)
|
|||||||
BindNativeFunction(env, object, "isFocused", moduleName, JsWindow::IsFocused);
|
BindNativeFunction(env, object, "isFocused", moduleName, JsWindow::IsFocused);
|
||||||
BindNativeFunction(env, object, "requestFocus", moduleName, JsWindow::RequestFocus);
|
BindNativeFunction(env, object, "requestFocus", moduleName, JsWindow::RequestFocus);
|
||||||
BindNativeFunction(env, object, "createSubWindowWithOptions", moduleName, JsWindow::CreateSubWindowWithOptions);
|
BindNativeFunction(env, object, "createSubWindowWithOptions", moduleName, JsWindow::CreateSubWindowWithOptions);
|
||||||
|
BindNativeFunction(env, object, "setGestureBackEnabled", moduleName, JsWindow::SetGestureBackEnabled);
|
||||||
|
BindNativeFunction(env, object, "getGestureBackEnabled", moduleName, JsWindow::GetGestureBackEnabled);
|
||||||
}
|
}
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -33,6 +33,7 @@ namespace OHOS {
|
|||||||
namespace Rosen {
|
namespace Rosen {
|
||||||
using namespace AbilityRuntime;
|
using namespace AbilityRuntime;
|
||||||
napi_value CreateJsWindowObject(napi_env env, sptr<Window>& window);
|
napi_value CreateJsWindowObject(napi_env env, sptr<Window>& window);
|
||||||
|
napi_value CreateJsWindowArrayObject(napi_env env, const std::vector<sptr<Window>>& windows);
|
||||||
std::shared_ptr<NativeReference> FindJsWindowObject(const std::string& windowName);
|
std::shared_ptr<NativeReference> FindJsWindowObject(const std::string& windowName);
|
||||||
void BindFunctions(napi_env env, napi_value object, const char* moduleName);
|
void BindFunctions(napi_env env, napi_value object, const char* moduleName);
|
||||||
napi_value NapiGetUndefined(napi_env env);
|
napi_value NapiGetUndefined(napi_env env);
|
||||||
@ -159,6 +160,7 @@ public:
|
|||||||
static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info);
|
static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info);
|
||||||
static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info);
|
static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetTitleButtonVisible(napi_env env, napi_callback_info info);
|
static napi_value SetTitleButtonVisible(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value SetWindowTitleButtonVisible(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetWindowMask(napi_env env, napi_callback_info info);
|
static napi_value SetWindowMask(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetWindowGrayScale(napi_env env, napi_callback_info info);
|
static napi_value SetWindowGrayScale(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
static napi_value SetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
||||||
@ -170,6 +172,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
static napi_value CreateSubWindowWithOptions(napi_env env, napi_callback_info info);
|
static napi_value CreateSubWindowWithOptions(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gesture Back
|
||||||
|
*/
|
||||||
|
static napi_value SetGestureBackEnabled(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value GetGestureBackEnabled(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string GetWindowName();
|
std::string GetWindowName();
|
||||||
static bool ParseScaleOption(napi_env env, napi_value jsObject, Transform& trans);
|
static bool ParseScaleOption(napi_env env, napi_value jsObject, Transform& trans);
|
||||||
@ -235,6 +243,7 @@ private:
|
|||||||
napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info);
|
napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info);
|
||||||
napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info);
|
napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetTitleButtonVisible(napi_env env, napi_callback_info info);
|
napi_value OnSetTitleButtonVisible(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnSetWindowTitleButtonVisible(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetWindowContainerColor(napi_env env, napi_callback_info info);
|
napi_value OnSetWindowContainerColor(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
napi_value OnSetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
||||||
napi_value OnGetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
napi_value OnGetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
|
||||||
@ -306,6 +315,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
napi_value OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info);
|
napi_value OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gesture Back
|
||||||
|
*/
|
||||||
|
napi_value OnSetGestureBackEnabled(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnGetGestureBackEnabled(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
sptr<Window> windowToken_ = nullptr;
|
sptr<Window> windowToken_ = nullptr;
|
||||||
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
||||||
std::shared_ptr<NativeReference> jsTransControllerObj_ = nullptr;
|
std::shared_ptr<NativeReference> jsTransControllerObj_ = nullptr;
|
||||||
|
@ -149,20 +149,20 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst
|
|||||||
|
|
||||||
void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type)
|
void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type)
|
||||||
{
|
{
|
||||||
WLOGFD("[NAPI]OnAvoidAreaChanged");
|
WLOGFD("[NAPI]");
|
||||||
// js callback should run in js thread
|
// js callback should run in js thread
|
||||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback> (
|
auto jsCallback = [self = weakRef_, avoidArea, type, env = env_] () {
|
||||||
[self = weakRef_, avoidArea, type, eng = env_] (napi_env env,
|
|
||||||
NapiAsyncTask& task, int32_t status) {
|
|
||||||
auto thisListener = self.promote();
|
auto thisListener = self.promote();
|
||||||
if (thisListener == nullptr || eng == nullptr) {
|
if (thisListener == nullptr || env == nullptr) {
|
||||||
WLOGFE("[NAPI]this listener or eng is nullptr");
|
TLOGNE(WmsLogTag::WMS_IMMS, "[NAPI]this listener or env is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value avoidAreaValue = ConvertAvoidAreaToJsValue(env, avoidArea, type);
|
napi_value avoidAreaValue = ConvertAvoidAreaToJsValue(env, avoidArea, type);
|
||||||
if (avoidAreaValue == nullptr) {
|
if (avoidAreaValue == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
napi_handle_scope scope = nullptr;
|
||||||
|
napi_open_handle_scope(env, &scope);
|
||||||
if (thisListener->isDeprecatedInterface_) {
|
if (thisListener->isDeprecatedInterface_) {
|
||||||
napi_value argv[] = { avoidAreaValue };
|
napi_value argv[] = { avoidAreaValue };
|
||||||
thisListener->CallJsMethod(SYSTEM_AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv));
|
thisListener->CallJsMethod(SYSTEM_AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv));
|
||||||
@ -170,7 +170,7 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy
|
|||||||
napi_value objValue = nullptr;
|
napi_value objValue = nullptr;
|
||||||
napi_create_object(env, &objValue);
|
napi_create_object(env, &objValue);
|
||||||
if (objValue == nullptr) {
|
if (objValue == nullptr) {
|
||||||
WLOGFE("Failed to get object");
|
TLOGNE(WmsLogTag::WMS_IMMS, "Failed to get object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_set_named_property(env, objValue, "type", CreateJsValue(env, static_cast<uint32_t>(type)));
|
napi_set_named_property(env, objValue, "type", CreateJsValue(env, static_cast<uint32_t>(type)));
|
||||||
@ -178,13 +178,15 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy
|
|||||||
napi_value argv[] = { objValue };
|
napi_value argv[] = { objValue };
|
||||||
thisListener->CallJsMethod(AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv));
|
thisListener->CallJsMethod(AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv));
|
||||||
}
|
}
|
||||||
}
|
napi_close_handle_scope(env, scope);
|
||||||
);
|
};
|
||||||
|
|
||||||
napi_ref callback = nullptr;
|
if (eventHandler_) {
|
||||||
std::unique_ptr<NapiAsyncTask::ExecuteCallback> execute = nullptr;
|
eventHandler_->PostTask(jsCallback, "wms:JsWindowListener::OnAvoidAreaChanged", 0,
|
||||||
NapiAsyncTask::Schedule("JsWindowListener::OnAvoidAreaChanged",
|
AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||||
env_, std::make_unique<NapiAsyncTask>(callback, std::move(execute), std::move(complete)));
|
} else {
|
||||||
|
WLOGFE("get main event handler failed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType)
|
void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType)
|
||||||
@ -584,5 +586,32 @@ void JsWindowListener::OnSubWindowClose(bool& terminateCloseProcess)
|
|||||||
eventHandler_->PostSyncTask(jsCallback, "wms:JsWindowRectListener::OnSubWindowClose",
|
eventHandler_->PostSyncTask(jsCallback, "wms:JsWindowRectListener::OnSubWindowClose",
|
||||||
AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsWindowListener::OnMainWindowClose(bool& terminateCloseProcess)
|
||||||
|
{
|
||||||
|
auto jsCallback = [self = weakRef_, &terminateCloseProcess, env = env_]() mutable {
|
||||||
|
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnMainWindowClose");
|
||||||
|
auto thisListener = self.promote();
|
||||||
|
if (thisListener == nullptr || env == nullptr) {
|
||||||
|
TLOGNE(WmsLogTag::WMS_LIFE, "this listener or env is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
napi_handle_scope scope = nullptr;
|
||||||
|
napi_open_handle_scope(env, &scope);
|
||||||
|
bool value = terminateCloseProcess;
|
||||||
|
napi_value returnValue = thisListener->CallJsMethod(WINDOW_STAGE_CLOSE_CB.c_str(), nullptr, 0);
|
||||||
|
if (napi_get_value_bool(env, returnValue, &value) == napi_ok) {
|
||||||
|
terminateCloseProcess = value;
|
||||||
|
}
|
||||||
|
napi_close_handle_scope(env, scope);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!eventHandler_) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "get main event handler failed!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eventHandler_->PostSyncTask(jsCallback, "wms:JsWindowListener::OnMainWindowClose",
|
||||||
|
AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||||
|
}
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
@ -50,6 +50,7 @@ const std::string WINDOW_TITLE_BUTTON_RECT_CHANGE_CB = "windowTitleButtonRectCha
|
|||||||
const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetected";
|
const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetected";
|
||||||
const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange";
|
const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange";
|
||||||
const std::string SUB_WINDOW_CLOSE_CB = "subWindowClose";
|
const std::string SUB_WINDOW_CLOSE_CB = "subWindowClose";
|
||||||
|
const std::string WINDOW_STAGE_CLOSE_CB = "windowStageClose";
|
||||||
|
|
||||||
class JsWindowListener : public IWindowChangeListener,
|
class JsWindowListener : public IWindowChangeListener,
|
||||||
public ISystemBarChangedListener,
|
public ISystemBarChangedListener,
|
||||||
@ -67,6 +68,7 @@ class JsWindowListener : public IWindowChangeListener,
|
|||||||
public IWindowStatusChangeListener,
|
public IWindowStatusChangeListener,
|
||||||
public IWindowNoInteractionListener,
|
public IWindowNoInteractionListener,
|
||||||
public IWindowRectChangeListener,
|
public IWindowRectChangeListener,
|
||||||
|
public IMainWindowCloseListener,
|
||||||
public ISubWindowCloseListener {
|
public ISubWindowCloseListener {
|
||||||
public:
|
public:
|
||||||
JsWindowListener(napi_env env, std::shared_ptr<NativeReference> callback, CaseType caseType)
|
JsWindowListener(napi_env env, std::shared_ptr<NativeReference> callback, CaseType caseType)
|
||||||
@ -103,6 +105,7 @@ public:
|
|||||||
int64_t GetTimeout() const override;
|
int64_t GetTimeout() const override;
|
||||||
void OnRectChange(Rect rect, WindowSizeChangeReason reason) override;
|
void OnRectChange(Rect rect, WindowSizeChangeReason reason) override;
|
||||||
void OnSubWindowClose(bool& terminateCloseProcess) override;
|
void OnSubWindowClose(bool& terminateCloseProcess) override;
|
||||||
|
void OnMainWindowClose(bool& terminateCloseProcess) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rect currRect_ = {0, 0, 0, 0};
|
Rect currRect_ = {0, 0, 0, 0};
|
||||||
|
@ -52,6 +52,7 @@ const std::map<std::string, RegisterListenerType> WINDOW_LISTENER_MAP {
|
|||||||
const std::map<std::string, RegisterListenerType> WINDOW_STAGE_LISTENER_MAP {
|
const std::map<std::string, RegisterListenerType> WINDOW_STAGE_LISTENER_MAP {
|
||||||
// white register list for window stage
|
// white register list for window stage
|
||||||
{WINDOW_STAGE_EVENT_CB, RegisterListenerType::WINDOW_STAGE_EVENT_CB},
|
{WINDOW_STAGE_EVENT_CB, RegisterListenerType::WINDOW_STAGE_EVENT_CB},
|
||||||
|
{WINDOW_STAGE_CLOSE_CB, RegisterListenerType::WINDOW_STAGE_CLOSE_CB},
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::map<CaseType, std::map<std::string, RegisterListenerType>> LISTENER_CODE_MAP {
|
const std::map<CaseType, std::map<std::string, RegisterListenerType>> LISTENER_CODE_MAP {
|
||||||
@ -451,8 +452,15 @@ WmErrorCode JsWindowRegisterManager::ProcessListener(RegisterListenerType regist
|
|||||||
return WmErrorCode::WM_ERROR_INVALID_PARAM;
|
return WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
} else if (caseType == CaseType::CASE_STAGE) {
|
} else if (caseType == CaseType::CASE_STAGE) {
|
||||||
if (registerListenerType == RegisterListenerType::WINDOW_STAGE_EVENT_CB) {
|
switch (registerListenerType) {
|
||||||
|
case RegisterListenerType::WINDOW_STAGE_EVENT_CB:
|
||||||
return ProcessLifeCycleEventRegister(windowManagerListener, window, isRegister, env, parameter);
|
return ProcessLifeCycleEventRegister(windowManagerListener, window, isRegister, env, parameter);
|
||||||
|
case RegisterListenerType::WINDOW_STAGE_CLOSE_CB:
|
||||||
|
return ProcessMainWindowCloseRegister(windowManagerListener, window, isRegister, env, parameter);
|
||||||
|
default:
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "[NAPI]RegisterListenerType %{public}u is not supported",
|
||||||
|
static_cast<uint32_t>(registerListenerType));
|
||||||
|
return WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WmErrorCode::WM_OK;
|
return WmErrorCode::WM_OK;
|
||||||
@ -567,5 +575,20 @@ WmErrorCode JsWindowRegisterManager::ProcessSubWindowCloseRegister(sptr<JsWindow
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WmErrorCode JsWindowRegisterManager::ProcessMainWindowCloseRegister(const sptr<JsWindowListener>& listener,
|
||||||
|
const sptr<Window>& window, bool isRegister, napi_env env, napi_value parameter)
|
||||||
|
{
|
||||||
|
if (window == nullptr) {
|
||||||
|
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||||
|
}
|
||||||
|
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||||
|
if (isRegister) {
|
||||||
|
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterMainWindowCloseListeners(listener));
|
||||||
|
} else {
|
||||||
|
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterMainWindowCloseListeners(listener));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
@ -45,6 +45,7 @@ enum class RegisterListenerType : uint32_t {
|
|||||||
WINDOW_RECT_CHANGE_CB,
|
WINDOW_RECT_CHANGE_CB,
|
||||||
SUB_WINDOW_CLOSE_CB,
|
SUB_WINDOW_CLOSE_CB,
|
||||||
WINDOW_STAGE_EVENT_CB,
|
WINDOW_STAGE_EVENT_CB,
|
||||||
|
WINDOW_STAGE_CLOSE_CB,
|
||||||
};
|
};
|
||||||
|
|
||||||
class JsWindowRegisterManager {
|
class JsWindowRegisterManager {
|
||||||
@ -93,6 +94,8 @@ private:
|
|||||||
bool isRegister, napi_env env, napi_value parameter = nullptr);
|
bool isRegister, napi_env env, napi_value parameter = nullptr);
|
||||||
WmErrorCode ProcessSubWindowCloseRegister(sptr<JsWindowListener> listener, sptr<Window> window,
|
WmErrorCode ProcessSubWindowCloseRegister(sptr<JsWindowListener> listener, sptr<Window> window,
|
||||||
bool isRegister, napi_env env, napi_value parameter = nullptr);
|
bool isRegister, napi_env env, napi_value parameter = nullptr);
|
||||||
|
WmErrorCode ProcessMainWindowCloseRegister(const sptr<JsWindowListener>& listener, const sptr<Window>& window,
|
||||||
|
bool isRegister, napi_env env, napi_value parameter = nullptr);
|
||||||
WmErrorCode ProcessListener(RegisterListenerType registerListenerType, CaseType caseType,
|
WmErrorCode ProcessListener(RegisterListenerType registerListenerType, CaseType caseType,
|
||||||
const sptr<JsWindowListener>& windowManagerListener, const sptr<Window>& window, bool isRegister,
|
const sptr<JsWindowListener>& windowManagerListener, const sptr<Window>& window, bool isRegister,
|
||||||
napi_env env, napi_value parameter);
|
napi_env env, napi_value parameter);
|
||||||
|
@ -499,7 +499,7 @@ napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr<Window>& window)
|
|||||||
napi_set_named_property(env, objValue, "navigationBarContentColor",
|
napi_set_named_property(env, objValue, "navigationBarContentColor",
|
||||||
CreateJsValue(env, GetHexColor(navi.contentColor_)));
|
CreateJsValue(env, GetHexColor(navi.contentColor_)));
|
||||||
napi_set_named_property(env, objValue, "isNavigationBarLightIcon",
|
napi_set_named_property(env, objValue, "isNavigationBarLightIcon",
|
||||||
CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE));
|
CreateJsValue(env, navi.contentColor_ == SYSTEM_COLOR_WHITE));
|
||||||
napi_set_named_property(env, objValue, "enableStatusBarAnimation",
|
napi_set_named_property(env, objValue, "enableStatusBarAnimation",
|
||||||
CreateJsValue(env, status.enableAnimation_));
|
CreateJsValue(env, status.enableAnimation_));
|
||||||
napi_set_named_property(env, objValue, "enableNavigationBarAnimation",
|
napi_set_named_property(env, objValue, "enableNavigationBarAnimation",
|
||||||
@ -733,6 +733,8 @@ void GetSpecificBarStatus(sptr<Window>& window, const std::string& name,
|
|||||||
systemBarProperties[type] = property;
|
systemBarProperties[type] = property;
|
||||||
systemBarProperties[type].enable_ = newSystemBarProperties[type].enable_;
|
systemBarProperties[type].enable_ = newSystemBarProperties[type].enable_;
|
||||||
systemBarProperties[type].enableAnimation_ = newSystemBarProperties[type].enableAnimation_;
|
systemBarProperties[type].enableAnimation_ = newSystemBarProperties[type].enableAnimation_;
|
||||||
|
systemBarProperties[type].settingFlag_ = systemBarProperties[type].settingFlag_ |
|
||||||
|
SystemBarSettingFlag::ENABLE_SETTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetSpecificBarStatus(napi_env env, napi_callback_info info,
|
bool GetSpecificBarStatus(napi_env env, napi_callback_info info,
|
||||||
|
@ -265,7 +265,12 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info)
|
|||||||
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
|
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value);
|
auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value);
|
||||||
|
if (ret != WmErrorCode::WM_OK) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret = %{public}d", eventString.c_str(), ret);
|
||||||
|
napi_throw(env, JsErrUtils::CreateJsError(env, ret));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] register event %{public}s",
|
WLOGI("[NAPI]Window [%{public}u, %{public}s] register event %{public}s",
|
||||||
window->GetWindowId(), window->GetWindowName().c_str(), eventString.c_str());
|
window->GetWindowId(), window->GetWindowName().c_str(), eventString.c_str());
|
||||||
|
|
||||||
@ -290,11 +295,6 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info)
|
|||||||
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
|
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
if (eventString.compare("windowStageEvent") != 0) {
|
|
||||||
WLOGFE("[NAPI]Envent %{public}s is invalid", eventString.c_str());
|
|
||||||
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
|
|
||||||
return NapiGetUndefined(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto window = weakScene->GetMainWindow();
|
auto window = weakScene->GetMainWindow();
|
||||||
if (window == nullptr) {
|
if (window == nullptr) {
|
||||||
@ -303,16 +303,22 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info)
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
napi_value value = nullptr;
|
napi_value value = nullptr;
|
||||||
|
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, nullptr);
|
ret = g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, nullptr);
|
||||||
} else {
|
} else {
|
||||||
value = argv[1];
|
value = argv[1];
|
||||||
if (value != nullptr && GetType(env, value) == napi_function) {
|
if (value != nullptr && GetType(env, value) == napi_function) {
|
||||||
g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, value);
|
ret = g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, value);
|
||||||
} else {
|
} else {
|
||||||
g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, nullptr);
|
ret = g_listenerManager->UnregisterListener(window, eventString, CaseType::CASE_STAGE, env, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret != WmErrorCode::WM_OK) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret = %{public}d", eventString.c_str(), ret);
|
||||||
|
napi_throw(env, JsErrUtils::CreateJsError(env, ret));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] unregister event %{public}s",
|
WLOGI("[NAPI]Window [%{public}u, %{public}s] unregister event %{public}s",
|
||||||
window->GetWindowId(), window->GetWindowName().c_str(), eventString.c_str());
|
window->GetWindowId(), window->GetWindowName().c_str(), eventString.c_str());
|
||||||
|
|
||||||
|
@ -298,6 +298,7 @@ public:
|
|||||||
virtual bool IsTopmost() const { return false; }
|
virtual bool IsTopmost() const { return false; }
|
||||||
virtual WMError HideNonSystemFloatingWindows(bool shouldHide) = 0;
|
virtual WMError HideNonSystemFloatingWindows(bool shouldHide) = 0;
|
||||||
virtual bool IsFloatingWindowAppType() const { return false; }
|
virtual bool IsFloatingWindowAppType() const { return false; }
|
||||||
|
virtual bool IsPcOrPadCapabilityEnabled() const { return false; }
|
||||||
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) = 0;
|
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) = 0;
|
||||||
virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;
|
virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;
|
||||||
virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;
|
virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;
|
||||||
@ -378,6 +379,19 @@ public:
|
|||||||
|
|
||||||
virtual void NotifyExtensionTimeout(int32_t errorCode) {}
|
virtual void NotifyExtensionTimeout(int32_t errorCode) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set whether to enable gesture back.
|
||||||
|
* @param enable the value true means to enable gesture back, and false means the opposite.
|
||||||
|
* @return WM_OK means set success, others means set failed.
|
||||||
|
*/
|
||||||
|
virtual WMError SetGestureBackEnabled(bool enable) { return WMError::WM_OK; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get whether the gesture back is enabled or not.
|
||||||
|
*
|
||||||
|
* @return the value true means to enable gesture back, and false means the opposite.
|
||||||
|
*/
|
||||||
|
virtual bool GetGestureBackEnabled() const { return true; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,6 +392,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool GetWindowTopmost() const;
|
bool GetWindowTopmost() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set whether this window is a sub window of the UIExtension.
|
||||||
|
*
|
||||||
|
* @return isUIExtensionSubWindowFlag.
|
||||||
|
*/
|
||||||
|
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
|
||||||
|
/**
|
||||||
|
* @brief Get IsUIExtensionSubWindowFlag of window.
|
||||||
|
*
|
||||||
|
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
|
||||||
|
*/
|
||||||
|
bool GetIsUIExtensionSubWindowFlag() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rect windowRect_ { 0, 0, 0, 0 };
|
Rect windowRect_ { 0, 0, 0, 0 };
|
||||||
std::string windowName_ { "" };
|
std::string windowName_ { "" };
|
||||||
|
@ -230,6 +230,12 @@ enum class SystemBarSettingFlag : uint32_t {
|
|||||||
ALL_SETTING = 0b11
|
ALL_SETTING = 0b11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline SystemBarSettingFlag operator|(SystemBarSettingFlag lhs, SystemBarSettingFlag rhs)
|
||||||
|
{
|
||||||
|
using T = std::underlying_type_t<SystemBarSettingFlag>;
|
||||||
|
return static_cast<SystemBarSettingFlag>(static_cast<T>(lhs) | static_cast<T>(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumerates flag of window.
|
* @brief Enumerates flag of window.
|
||||||
*/
|
*/
|
||||||
|
@ -99,6 +99,13 @@ export class PiPContent extends ViewPU {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.useNode = true;
|
this.useNode = true;
|
||||||
|
let parent = this.xComponent.getParent();
|
||||||
|
if (parent === null || parent === undefined) {
|
||||||
|
pip.setPipNodeType(this.xComponent, false);
|
||||||
|
} else {
|
||||||
|
pip.setPipNodeType(this.xComponent, true);
|
||||||
|
parent.removeChild(this.xComponent);
|
||||||
|
}
|
||||||
pip.setTypeNodeEnabled();
|
pip.setTypeNodeEnabled();
|
||||||
this.mXCNodeController = new XCNodeController(this.xComponent);
|
this.mXCNodeController = new XCNodeController(this.xComponent);
|
||||||
console.info(TAG, 'use Node Controller');
|
console.info(TAG, 'use Node Controller');
|
||||||
|
@ -63,6 +63,13 @@ export struct PiPContent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.useNode = true;
|
this.useNode = true;
|
||||||
|
let parent: FrameNode | null = this.xComponent.getParent();
|
||||||
|
if (parent === null || parent === undefined) {
|
||||||
|
pip.setPipNodeType(this.xComponent, false);
|
||||||
|
} else {
|
||||||
|
pip.setPipNodeType(this.xComponent, true);
|
||||||
|
parent.removeChild(this.xComponent);
|
||||||
|
}
|
||||||
pip.setTypeNodeEnabled();
|
pip.setTypeNodeEnabled();
|
||||||
this.mXCNodeController = new XCNodeController(this.xComponent);
|
this.mXCNodeController = new XCNodeController(this.xComponent);
|
||||||
console.info(TAG, 'use Node Controller');
|
console.info(TAG, 'use Node Controller');
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
MOCK_METHOD2(GetAvailableArea, DMError(ScreenId screenId, DMRect& area));
|
MOCK_METHOD2(GetAvailableArea, DMError(ScreenId screenId, DMRect& area));
|
||||||
MOCK_METHOD2(GetSupportedHDRFormats, DMError(ScreenId screenId, std::vector<uint32_t>& hdrFormats));
|
MOCK_METHOD2(GetSupportedHDRFormats, DMError(ScreenId screenId, std::vector<uint32_t>& hdrFormats));
|
||||||
MOCK_METHOD2(GetSupportedColorSpaces, DMError(ScreenId screenId, std::vector<uint32_t>& colorSpaces));
|
MOCK_METHOD2(GetSupportedColorSpaces, DMError(ScreenId screenId, std::vector<uint32_t>& colorSpaces));
|
||||||
|
MOCK_METHOD1(HasImmersiveWindow, DMError(bool& immersive));
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockScreenManagerAdapter : public ScreenManagerAdapter {
|
class MockScreenManagerAdapter : public ScreenManagerAdapter {
|
||||||
|
@ -690,7 +690,10 @@ void CheckWindowImplFunctionsPart7(sptr<WindowImpl> window, const uint8_t* data,
|
|||||||
AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM;
|
AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM;
|
||||||
AvoidArea avoidArea;
|
AvoidArea avoidArea;
|
||||||
startPos += GetObject<AvoidAreaType>(avoidAreaType, data + startPos, size - startPos);
|
startPos += GetObject<AvoidAreaType>(avoidAreaType, data + startPos, size - startPos);
|
||||||
startPos += GetObject<AvoidArea>(avoidArea, data + startPos, size - startPos);
|
startPos += GetObject<OHOS::Rosen::Rect>(avoidArea.topRect_, data + startPos, size - startPos);
|
||||||
|
startPos += GetObject<OHOS::Rosen::Rect>(avoidArea.leftRect_, data + startPos, size - startPos);
|
||||||
|
startPos += GetObject<OHOS::Rosen::Rect>(avoidArea.rightRect_, data + startPos, size - startPos);
|
||||||
|
startPos += GetObject<OHOS::Rosen::Rect>(avoidArea.bottomRect_, data + startPos, size - startPos);
|
||||||
window->GetAvoidAreaByType(avoidAreaType, avoidArea);
|
window->GetAvoidAreaByType(avoidAreaType, avoidArea);
|
||||||
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
|
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
|
||||||
uint32_t invalidGravityPercent = 0;
|
uint32_t invalidGravityPercent = 0;
|
||||||
|
@ -323,7 +323,6 @@ namespace {
|
|||||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
||||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 5;
|
constexpr uint32_t WINDOW_FRAME_WIDTH = 5;
|
||||||
constexpr uint32_t WINDOW_FRAME_WIDTH_TOUCH = 16;
|
|
||||||
constexpr uint32_t WINDOW_FRAME_CORNER_WIDTH = 16; // the frame width of corner
|
constexpr uint32_t WINDOW_FRAME_CORNER_WIDTH = 16; // the frame width of corner
|
||||||
constexpr uint32_t HOTZONE_TOUCH = 24;
|
constexpr uint32_t HOTZONE_TOUCH = 24;
|
||||||
constexpr uint32_t HOTZONE_POINTER = 4;
|
constexpr uint32_t HOTZONE_POINTER = 4;
|
||||||
|
@ -116,18 +116,9 @@ public:
|
|||||||
|
|
||||||
static AreaType GetAreaType(int32_t pointWinX, int32_t pointWinY,
|
static AreaType GetAreaType(int32_t pointWinX, int32_t pointWinY,
|
||||||
int32_t sourceType, int outside, float vpr, const WSRect& rect)
|
int32_t sourceType, int outside, float vpr, const WSRect& rect)
|
||||||
{
|
|
||||||
return GetAreaType(pointWinX, pointWinY, sourceType, outside, vpr, rect, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static AreaType GetAreaType(int32_t pointWinX, int32_t pointWinY,
|
|
||||||
int32_t sourceType, int outside, float vpr, const WSRect& rect, bool isPcOrFreeWindow)
|
|
||||||
{
|
{
|
||||||
int32_t insideCorner = WINDOW_FRAME_CORNER_WIDTH * vpr;
|
int32_t insideCorner = WINDOW_FRAME_CORNER_WIDTH * vpr;
|
||||||
int32_t insideEdge = WINDOW_FRAME_WIDTH * vpr;
|
int32_t insideEdge = WINDOW_FRAME_WIDTH * vpr;
|
||||||
if (isPcOrFreeWindow && sourceType != MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
|
|
||||||
insideEdge = WINDOW_FRAME_WIDTH_TOUCH * vpr;
|
|
||||||
}
|
|
||||||
int32_t leftOut = -outside;
|
int32_t leftOut = -outside;
|
||||||
int32_t leftIn = insideEdge;
|
int32_t leftIn = insideEdge;
|
||||||
int32_t leftCorner = insideCorner;
|
int32_t leftCorner = insideCorner;
|
||||||
|
@ -97,6 +97,7 @@ public:
|
|||||||
void SetIsAppSupportPhoneInPc(bool isSupportPhone);
|
void SetIsAppSupportPhoneInPc(bool isSupportPhone);
|
||||||
void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode);
|
void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode);
|
||||||
void SetIsPcAppInPad(bool isPcAppInPad);
|
void SetIsPcAppInPad(bool isPcAppInPad);
|
||||||
|
void SetCompatibleModeEnableInPad(bool enable);
|
||||||
|
|
||||||
bool GetIsNeedUpdateWindowMode() const;
|
bool GetIsNeedUpdateWindowMode() const;
|
||||||
const std::string& GetWindowName() const;
|
const std::string& GetWindowName() const;
|
||||||
@ -155,6 +156,7 @@ public:
|
|||||||
bool GetIsAppSupportPhoneInPc() const;
|
bool GetIsAppSupportPhoneInPc() const;
|
||||||
bool GetIsPcAppInPad() const;
|
bool GetIsPcAppInPad() const;
|
||||||
bool GetIsSupportDragInPcCompatibleMode() const;
|
bool GetIsSupportDragInPcCompatibleMode() const;
|
||||||
|
bool GetCompatibleModeEnableInPad() const;
|
||||||
|
|
||||||
bool MarshallingWindowLimits(Parcel& parcel) const;
|
bool MarshallingWindowLimits(Parcel& parcel) const;
|
||||||
static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
|
static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
|
||||||
@ -207,6 +209,8 @@ public:
|
|||||||
bool GetIsUIExtensionAbilityProcess() const;
|
bool GetIsUIExtensionAbilityProcess() const;
|
||||||
void SetParentWindowType(WindowType parentWindowType);
|
void SetParentWindowType(WindowType parentWindowType);
|
||||||
WindowType GetParentWindowType() const;
|
WindowType GetParentWindowType() const;
|
||||||
|
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
|
||||||
|
bool GetIsUIExtensionSubWindowFlag() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool MarshallingTouchHotAreas(Parcel& parcel) const;
|
bool MarshallingTouchHotAreas(Parcel& parcel) const;
|
||||||
@ -332,6 +336,8 @@ private:
|
|||||||
bool isAppSupportPhoneInPc_ = false;
|
bool isAppSupportPhoneInPc_ = false;
|
||||||
bool isSupportDragInPcCompatibleMode_ = false;
|
bool isSupportDragInPcCompatibleMode_ = false;
|
||||||
bool isPcAppInPad_ = false;
|
bool isPcAppInPad_ = false;
|
||||||
|
mutable std::mutex compatibleModeMutex_;
|
||||||
|
bool compatibleModeEnableInPad_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub Window
|
* Sub Window
|
||||||
@ -345,6 +351,7 @@ private:
|
|||||||
UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
|
UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
|
||||||
bool isExtensionFlag_ = false;
|
bool isExtensionFlag_ = false;
|
||||||
bool isUIExtensionAbilityProcess_ = false;
|
bool isUIExtensionAbilityProcess_ = false;
|
||||||
|
bool isUIExtensionSubWindowFlag_ = false;
|
||||||
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
|
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -239,24 +239,21 @@ bool SessionPermission::IsSameAppAsCalling(const std::string& bundleName, const
|
|||||||
if (callingBundleName != bundleName) {
|
if (callingBundleName != bundleName) {
|
||||||
TLOGE(WmsLogTag::DEFAULT,
|
TLOGE(WmsLogTag::DEFAULT,
|
||||||
"verify app failed, callingBundleName %{public}s, bundleName %{public}s.",
|
"verify app failed, callingBundleName %{public}s, bundleName %{public}s.",
|
||||||
callingBundleName.c_str(),
|
callingBundleName.c_str(), bundleName.c_str());
|
||||||
bundleName.c_str());
|
|
||||||
IPCSkeleton::SetCallingIdentity(identity);
|
IPCSkeleton::SetCallingIdentity(identity);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AppExecFwk::BundleInfo bundleInfo;
|
AppExecFwk::BundleInfo bundleInfo;
|
||||||
int userId = uid / 200000; // 200000 use uid to caculate userId
|
int userId = uid / 200000; // 200000 use uid to caculate userId
|
||||||
bool ret = bundleManagerServiceProxy->GetBundleInfo(callingBundleName,
|
bool ret = bundleManagerServiceProxy->GetBundleInfoV9(callingBundleName,
|
||||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO),
|
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO),
|
||||||
bundleInfo,
|
bundleInfo, userId);
|
||||||
userId);
|
|
||||||
IPCSkeleton::SetCallingIdentity(identity);
|
IPCSkeleton::SetCallingIdentity(identity);
|
||||||
|
|
||||||
if (ret != ERR_OK) {
|
if (ret != ERR_OK) {
|
||||||
TLOGE(WmsLogTag::DEFAULT,
|
TLOGE(WmsLogTag::DEFAULT,
|
||||||
"failed to query app info, callingBundleName:%{public}s, userId:%{public}d",
|
"failed to query app info, callingBundleName:%{public}s, userId:%{public}d",
|
||||||
callingBundleName.c_str(),
|
callingBundleName.c_str(), userId);
|
||||||
userId);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +264,7 @@ bool SessionPermission::IsSameAppAsCalling(const std::string& bundleName, const
|
|||||||
|
|
||||||
TLOGE(WmsLogTag::DEFAULT,
|
TLOGE(WmsLogTag::DEFAULT,
|
||||||
"verify app failed, callingBundleName %{public}s, bundleName %{public}s.",
|
"verify app failed, callingBundleName %{public}s, bundleName %{public}s.",
|
||||||
callingBundleName.c_str(),
|
callingBundleName.c_str(), bundleName.c_str());
|
||||||
bundleName.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,6 +947,18 @@ bool WindowSessionProperty::GetIsPcAppInPad() const
|
|||||||
return isPcAppInPad_;
|
return isPcAppInPad_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowSessionProperty::SetCompatibleModeEnableInPad(bool enable)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(compatibleModeMutex_);
|
||||||
|
compatibleModeEnableInPad_ = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowSessionProperty::GetCompatibleModeEnableInPad() const
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(compatibleModeMutex_);
|
||||||
|
return compatibleModeEnableInPad_;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowSessionProperty::SetSubWindowLevel(uint32_t subWindowLevel)
|
void WindowSessionProperty::SetSubWindowLevel(uint32_t subWindowLevel)
|
||||||
{
|
{
|
||||||
subWindowLevel_ = subWindowLevel;
|
subWindowLevel_ = subWindowLevel;
|
||||||
@ -1010,7 +1022,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const
|
|||||||
parcel.WriteInt32(compatibleInPcLandscapeWidth_) && parcel.WriteInt32(compatibleInPcLandscapeHeight_) &&
|
parcel.WriteInt32(compatibleInPcLandscapeWidth_) && parcel.WriteInt32(compatibleInPcLandscapeHeight_) &&
|
||||||
parcel.WriteBool(isAppSupportPhoneInPc_) &&
|
parcel.WriteBool(isAppSupportPhoneInPc_) &&
|
||||||
parcel.WriteBool(isSupportDragInPcCompatibleMode_) &&
|
parcel.WriteBool(isSupportDragInPcCompatibleMode_) &&
|
||||||
parcel.WriteBool(isPcAppInPad_);
|
parcel.WriteBool(isPcAppInPad_) && parcel.WriteBool(compatibleModeEnableInPad_);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
||||||
@ -1084,6 +1096,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
|||||||
property->SetIsAppSupportPhoneInPc(parcel.ReadBool());
|
property->SetIsAppSupportPhoneInPc(parcel.ReadBool());
|
||||||
property->SetIsSupportDragInPcCompatibleMode(parcel.ReadBool());
|
property->SetIsSupportDragInPcCompatibleMode(parcel.ReadBool());
|
||||||
property->SetIsPcAppInPad(parcel.ReadBool());
|
property->SetIsPcAppInPad(parcel.ReadBool());
|
||||||
|
property->SetCompatibleModeEnableInPad(parcel.ReadBool());
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,6 +1482,16 @@ bool WindowSessionProperty::GetIsUIExtensionAbilityProcess() const
|
|||||||
return isUIExtensionAbilityProcess_;
|
return isUIExtensionAbilityProcess_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowSessionProperty::SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag)
|
||||||
|
{
|
||||||
|
isUIExtensionSubWindowFlag_ = isUIExtensionSubWindowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowSessionProperty::GetIsUIExtensionSubWindowFlag() const
|
||||||
|
{
|
||||||
|
return isUIExtensionSubWindowFlag_;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowSessionProperty::SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage)
|
void WindowSessionProperty::SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage)
|
||||||
{
|
{
|
||||||
uiExtensionUsage_ = uiExtensionUsage;
|
uiExtensionUsage_ = uiExtensionUsage;
|
||||||
|
@ -42,9 +42,6 @@ ohos_shared_library("intention_event_anr_manager") {
|
|||||||
"../dfx/src/dfx_hisysevent.cpp",
|
"../dfx/src/dfx_hisysevent.cpp",
|
||||||
"../framework/anr_handler/src/anr_handler.cpp",
|
"../framework/anr_handler/src/anr_handler.cpp",
|
||||||
"../utils/src/util.cpp",
|
"../utils/src/util.cpp",
|
||||||
"anr_manager/src/anr_manager.cpp",
|
|
||||||
"event_stage/src/event_stage.cpp",
|
|
||||||
"timer_manager/src/timer_manager.cpp",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
public_configs = [ ":intention_event_public_config" ]
|
public_configs = [ ":intention_event_public_config" ]
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 ANR_MANAGER_H
|
|
||||||
#define ANR_MANAGER_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <mutex>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "nocopyable.h"
|
|
||||||
#include "singleton.h"
|
|
||||||
|
|
||||||
#include "event_stage.h"
|
|
||||||
#include "ws_common.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
|
|
||||||
class ANRManager final {
|
|
||||||
DECLARE_DELAYED_SINGLETON(ANRManager);
|
|
||||||
public:
|
|
||||||
DISALLOW_COPY_AND_MOVE(ANRManager);
|
|
||||||
void Init();
|
|
||||||
void AddTimer(int32_t eventId, int32_t persistentId);
|
|
||||||
void MarkProcessed(int32_t eventId, int32_t persistentId);
|
|
||||||
bool IsANRTriggered(int32_t persistentId);
|
|
||||||
void SwitchAnr(bool status);
|
|
||||||
void OnSessionLost(int32_t persistentId);
|
|
||||||
void OnBackground(int32_t persistentId);
|
|
||||||
void SetApplicationInfo(int32_t persistentId, int32_t pid, const std::string& uid);
|
|
||||||
void SetAnrObserver(std::function<void(int32_t)> anrObserver);
|
|
||||||
void SetAppInfoGetter(std::function<void(int32_t, std::string&, int32_t)> callback);
|
|
||||||
std::string GetBundleName(int32_t pid, int32_t uid);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct AppInfo {
|
|
||||||
int32_t pid { -1 };
|
|
||||||
std::string bundleName { "unknown" };
|
|
||||||
};
|
|
||||||
void RemoveTimers(int32_t persistentId);
|
|
||||||
void RemovePersistentId(int32_t persistentId);
|
|
||||||
void ExecuteAnrObserver(int32_t pid);
|
|
||||||
ANRManager::AppInfo GetAppInfoByPersistentId(int32_t persistentId);
|
|
||||||
private:
|
|
||||||
std::atomic_bool switcher_ { true };
|
|
||||||
std::atomic_int32_t anrTimerCount_ { 0 };
|
|
||||||
std::mutex mtx_;
|
|
||||||
std::unordered_map<int32_t, AppInfo> applicationMap_;
|
|
||||||
std::function<void(int32_t)> anrObserver_;
|
|
||||||
std::function<void(int32_t, std::string&, int32_t)> appInfoGetter_;
|
|
||||||
};
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // ANR_MANAGER_H
|
|
@ -1,210 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 "anr_manager.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dfx_hisysevent.h"
|
|
||||||
#include "entrance_log.h"
|
|
||||||
#include "proto.h"
|
|
||||||
#include "timer_manager.h"
|
|
||||||
#include "window_manager_hilog.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
namespace {
|
|
||||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ANRManager" };
|
|
||||||
constexpr int32_t MAX_ANR_TIMER_COUNT { 64 };
|
|
||||||
constexpr int32_t NONEXISTENT_TIMER_ID { -1 };
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ANRManager::ANRManager() {}
|
|
||||||
ANRManager::~ANRManager() {}
|
|
||||||
|
|
||||||
void ANRManager::Init()
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
SwitchAnr(false);
|
|
||||||
DelayedSingleton<TimerManager>::GetInstance()->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::AddTimer(int32_t eventId, int32_t persistentId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
if (!switcher_) {
|
|
||||||
WLOGFD("Anr is off, dispatch event without timer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (anrTimerCount_ >= MAX_ANR_TIMER_COUNT) {
|
|
||||||
WLOGFD("AddAnrTimer failed, anrTimerCount exceeded %{public}d", MAX_ANR_TIMER_COUNT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t timerId = DelayedSingleton<TimerManager>::GetInstance()->AddTimer(ANRTimeOutTime::INPUT_UI_TIMEOUT_TIME,
|
|
||||||
[this, eventId, persistentId]() {
|
|
||||||
WLOGFE("Anr callback enter. persistentId:%{public}d, eventId:%{public}d", persistentId, eventId);
|
|
||||||
DelayedSingleton<EventStage>::GetInstance()->SetAnrStatus(persistentId, true);
|
|
||||||
AppInfo appInfo = GetAppInfoByPersistentId(persistentId);
|
|
||||||
DfxHisysevent::ApplicationBlockInput(eventId, appInfo.pid, appInfo.bundleName, persistentId);
|
|
||||||
WLOGFE("Application not responding. persistentId:%{public}d, eventId:%{public}d, pid:%{public}d, "
|
|
||||||
"bundleName:%{public}s", persistentId, eventId, appInfo.pid, appInfo.bundleName.c_str());
|
|
||||||
ExecuteAnrObserver(appInfo.pid);
|
|
||||||
std::vector<int32_t> timerIds = DelayedSingleton<EventStage>::GetInstance()->GetTimerIds(persistentId);
|
|
||||||
for (int32_t item : timerIds) {
|
|
||||||
DelayedSingleton<TimerManager>::GetInstance()->RemoveTimer(item);
|
|
||||||
anrTimerCount_--;
|
|
||||||
}
|
|
||||||
WLOGFE("Anr callback leave. persistentId:%{public}d, eventId:%{public}d", persistentId, eventId);
|
|
||||||
});
|
|
||||||
if (timerId == NONEXISTENT_TIMER_ID) {
|
|
||||||
WLOGFD("AddTimer for eventId:%{public}d, persistentId:%{public}d failed, result from timerManager",
|
|
||||||
eventId, persistentId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
anrTimerCount_++;
|
|
||||||
DelayedSingleton<EventStage>::GetInstance()->SaveANREvent(persistentId, eventId, timerId);
|
|
||||||
WLOGFD("AddTimer for persistentId:%{public}d, timerId:%{public}d, eventId:%{public}d",
|
|
||||||
persistentId, timerId, eventId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::MarkProcessed(int32_t eventId, int32_t persistentId)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFI("MarkProcessed eventId:%{public}d, persistentId:%{public}d", eventId, persistentId);
|
|
||||||
std::vector<int32_t> timerIds = DelayedSingleton<EventStage>::GetInstance()->DelEvents(persistentId, eventId);
|
|
||||||
for (int32_t item : timerIds) {
|
|
||||||
DelayedSingleton<TimerManager>::GetInstance()->RemoveTimer(item);
|
|
||||||
anrTimerCount_--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ANRManager::IsANRTriggered(int32_t persistentId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
if (DelayedSingleton<EventStage>::GetInstance()->CheckAnrStatus(persistentId)) {
|
|
||||||
WLOGFE("Application not respond, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
|
||||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::OnSessionLost(int32_t persistentId)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFD("Disconnect session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
|
||||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
|
||||||
RemoveTimers(persistentId);
|
|
||||||
RemovePersistentId(persistentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::OnBackground(int32_t persistentId)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFD("Background session, persistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
|
||||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
|
||||||
RemoveTimers(persistentId);
|
|
||||||
RemovePersistentId(persistentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::SetApplicationInfo(int32_t persistentId, int32_t pid, const std::string& bundleName)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFD("PersistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
|
||||||
persistentId, pid, bundleName.c_str());
|
|
||||||
applicationMap_[persistentId] = { pid, bundleName };
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::SetAnrObserver(std::function<void(int32_t)> anrObserver)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFD("SetAnrObserver, anrObserver is null:%{public}d", (anrObserver==nullptr));
|
|
||||||
anrObserver_ = anrObserver;
|
|
||||||
}
|
|
||||||
|
|
||||||
ANRManager::AppInfo ANRManager::GetAppInfoByPersistentId(int32_t persistentId)
|
|
||||||
{
|
|
||||||
if (applicationMap_.find(persistentId) != applicationMap_.end()) {
|
|
||||||
WLOGFD("PersistentId:%{public}d -> pid:%{public}d, bundleName:%{public}s",
|
|
||||||
persistentId, applicationMap_[persistentId].pid, applicationMap_[persistentId].bundleName.c_str());
|
|
||||||
return applicationMap_[persistentId];
|
|
||||||
}
|
|
||||||
WLOGFD("No application matches persistentId:%{public}d", persistentId);
|
|
||||||
return ANRManager::AppInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::RemoveTimers(int32_t persistentId)
|
|
||||||
{
|
|
||||||
WLOGFD("Remove timers for persistentId:%{public}d", persistentId);
|
|
||||||
std::vector<int32_t> timerIds = DelayedSingleton<EventStage>::GetInstance()->GetTimerIds(persistentId);
|
|
||||||
for (int32_t item : timerIds) {
|
|
||||||
DelayedSingleton<TimerManager>::GetInstance()->RemoveTimer(item);
|
|
||||||
anrTimerCount_--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::RemovePersistentId(int32_t persistentId)
|
|
||||||
{
|
|
||||||
WLOGFD("RemovePersistentId:%{public}d", persistentId);
|
|
||||||
applicationMap_.erase(persistentId);
|
|
||||||
DelayedSingleton<EventStage>::GetInstance()->OnSessionLost(persistentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::SwitchAnr(bool status)
|
|
||||||
{
|
|
||||||
switcher_ = status;
|
|
||||||
if (switcher_) {
|
|
||||||
WLOGFI("Anr is on");
|
|
||||||
} else {
|
|
||||||
WLOGFI("Anr is off");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::SetAppInfoGetter(std::function<void(int32_t, std::string&, int32_t)> callback)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
WLOGFD("SetAppInfoGetter, callback is null:%{public}d", (callback==nullptr));
|
|
||||||
appInfoGetter_ = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ANRManager::GetBundleName(int32_t pid, int32_t uid)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mtx_);
|
|
||||||
std::string bundleName { "unknown" };
|
|
||||||
if (appInfoGetter_ == nullptr) {
|
|
||||||
WLOGFW("AppInfoGetter is nullptr");
|
|
||||||
return bundleName;
|
|
||||||
}
|
|
||||||
appInfoGetter_(pid, bundleName, uid);
|
|
||||||
return bundleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ANRManager::ExecuteAnrObserver(int32_t pid)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
if (anrObserver_ != nullptr) {
|
|
||||||
anrObserver_(pid);
|
|
||||||
} else {
|
|
||||||
WLOGFE("AnrObserver is nullptr, do nothing, pid:%{public}d", pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 <map>
|
|
||||||
#include <mutex>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "noncopyable.h"
|
|
||||||
#include "singleton.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
class EventStage final {
|
|
||||||
DECLARE_DELAYED_SINGLETON(EventStage);
|
|
||||||
public:
|
|
||||||
DISALLOW_COPY_AND_MOVE(EventStage);
|
|
||||||
void SetAnrStatus(int32_t persistentId, bool status);
|
|
||||||
bool CheckAnrStatus(int32_t persistentId);
|
|
||||||
void SaveANREvent(int32_t persistentId, int32_t eventId, int32_t timerId);
|
|
||||||
std::vector<int32_t> GetTimerIds(int32_t persistentId);
|
|
||||||
std::vector<int32_t> DelEvents(int32_t persistentId, int32_t eventId);
|
|
||||||
void OnSessionLost(int32_t persistentId);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct EventTime {
|
|
||||||
int32_t eventId { 0 };
|
|
||||||
int32_t timerId { -1 };
|
|
||||||
};
|
|
||||||
std::mutex mutex_;
|
|
||||||
std::map<int32_t, std::vector<EventTime>> events_;
|
|
||||||
std::map<int32_t, bool> isAnrProcess_;
|
|
||||||
};
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 "event_stage.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "entrance_log.h"
|
|
||||||
#include "proto.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "window_manager_hilog.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "EventStage" };
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
EventStage::EventStage() {}
|
|
||||||
EventStage::~EventStage() {}
|
|
||||||
|
|
||||||
void EventStage::SetAnrStatus(int32_t persistentId, bool status)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
isAnrProcess_[persistentId] = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EventStage::CheckAnrStatus(int32_t persistentId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
if (isAnrProcess_.find(persistentId) != isAnrProcess_.end()) {
|
|
||||||
return isAnrProcess_[persistentId];
|
|
||||||
}
|
|
||||||
WLOGFD("Current persistentId:%{public}d is not in event stage", persistentId);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventStage::SaveANREvent(int32_t persistentId, int32_t eventId, int32_t timerId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
EventTime eventTime { eventId, timerId };
|
|
||||||
events_[persistentId].push_back(eventTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int32_t> EventStage::GetTimerIds(int32_t persistentId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
if (events_.find(persistentId) == events_.end()) {
|
|
||||||
WLOGFD("Current events have no event for persistentId:%{public}d", persistentId);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
std::vector<int32_t> timers;
|
|
||||||
for (const auto &item : events_[persistentId]) {
|
|
||||||
timers.push_back(item.timerId);
|
|
||||||
}
|
|
||||||
return timers;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int32_t> EventStage::DelEvents(int32_t persistentId, int32_t eventId)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
WLOGFD("Delete events, persistentId:%{public}d, eventId:%{public}d", persistentId, eventId);
|
|
||||||
if (events_.find(persistentId) == events_.end()) {
|
|
||||||
WLOGFD("Current events have no event persistentId:%{public}d", persistentId);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
auto &events = events_[persistentId];
|
|
||||||
auto fistMatchIter = find_if(events.begin(), events.end(), [eventId](const auto& item) {
|
|
||||||
return item.eventId > eventId;
|
|
||||||
});
|
|
||||||
std::vector<int32_t> timerIds;
|
|
||||||
for (auto iter = events.begin(); iter != fistMatchIter; iter++) {
|
|
||||||
timerIds.push_back(iter->timerId);
|
|
||||||
}
|
|
||||||
events.erase(events.begin(), fistMatchIter);
|
|
||||||
isAnrProcess_[persistentId] = false;
|
|
||||||
return timerIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventStage::OnSessionLost(int32_t persistentId)
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
std::lock_guard<std::mutex> guard(mutex_);
|
|
||||||
events_.erase(persistentId);
|
|
||||||
isAnrProcess_.erase(persistentId);
|
|
||||||
}
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 TIMER_MANAGER_H
|
|
||||||
#define TIMER_MANAGER_H
|
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <functional>
|
|
||||||
#include <list>
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include "singleton.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
|
|
||||||
enum class TimerMgrState {
|
|
||||||
STATE_NOT_START,
|
|
||||||
STATE_RUNNING,
|
|
||||||
STATE_EXIT
|
|
||||||
};
|
|
||||||
class TimerManager final {
|
|
||||||
DECLARE_DELAYED_SINGLETON(TimerManager);
|
|
||||||
|
|
||||||
public:
|
|
||||||
DISALLOW_COPY_AND_MOVE(TimerManager);
|
|
||||||
void Init();
|
|
||||||
int32_t AddTimer(int32_t intervalMs, std::function<void()> callback);
|
|
||||||
int32_t RemoveTimer(int32_t timerId);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct TimerItem {
|
|
||||||
int32_t id { 0 };
|
|
||||||
int32_t intervalMs { 0 };
|
|
||||||
int64_t nextCallTime { 0 };
|
|
||||||
std::function<void()> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
void OnThread();
|
|
||||||
void OnStop();
|
|
||||||
int32_t CalcNextDelay();
|
|
||||||
void ProcessTimers();
|
|
||||||
int32_t TakeNextTimerId();
|
|
||||||
int32_t AddTimerInternal(int32_t intervalMs, std::function<void()> callback);
|
|
||||||
int32_t RemoveTimerInternal(int32_t timerId);
|
|
||||||
void InsertTimerInternal(std::unique_ptr<TimerItem>& timer);
|
|
||||||
int32_t CalcNextDelayInternal();
|
|
||||||
void ProcessTimersInternal();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::recursive_mutex mutex_;
|
|
||||||
std::atomic<TimerMgrState> state_ { TimerMgrState::STATE_NOT_START };
|
|
||||||
std::thread timerWorker_;
|
|
||||||
std::list<std::unique_ptr<TimerItem>> timers_;
|
|
||||||
};
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // TIMER_MANAGER_H
|
|
@ -1,225 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 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 "timer_manager.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
#include "entrance_log.h"
|
|
||||||
#include "window_manager_hilog.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace Rosen {
|
|
||||||
namespace {
|
|
||||||
constexpr int32_t MIN_DELAY = 5000;
|
|
||||||
constexpr int32_t MIN_INTERVAL = 50;
|
|
||||||
constexpr int32_t MAX_INTERVAL_MS = 10000;
|
|
||||||
constexpr int32_t MAX_TIMER_COUNT = 64;
|
|
||||||
constexpr int32_t NONEXISTENT_ID = -1;
|
|
||||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "TimerManager" };
|
|
||||||
const std::string TIMER_MANAGER_THREAD_NAME { "ANR_TIMER_MANAGER_THREAD" };
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
TimerManager::TimerManager() {}
|
|
||||||
TimerManager::~TimerManager()
|
|
||||||
{
|
|
||||||
OnStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::Init()
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
if (state_ != TimerMgrState::STATE_RUNNING) {
|
|
||||||
{
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
|
||||||
timerWorker_ = std::thread([this]() {
|
|
||||||
pthread_setname_np(pthread_self(), TIMER_MANAGER_THREAD_NAME.c_str());
|
|
||||||
this->OnThread();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
state_ = TimerMgrState::STATE_RUNNING;
|
|
||||||
} else {
|
|
||||||
WLOGFD("TimerManager init already");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::AddTimer(int32_t intervalMs, std::function<void()> callback)
|
|
||||||
{
|
|
||||||
if (state_ != TimerMgrState::STATE_RUNNING) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
|
||||||
return AddTimerInternal(intervalMs, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::RemoveTimer(int32_t timerId)
|
|
||||||
{
|
|
||||||
if (state_ != TimerMgrState::STATE_RUNNING) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
|
||||||
return RemoveTimerInternal(timerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::CalcNextDelay()
|
|
||||||
{
|
|
||||||
if (state_ != TimerMgrState::STATE_RUNNING) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
|
||||||
return CalcNextDelayInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::ProcessTimers()
|
|
||||||
{
|
|
||||||
if (state_ != TimerMgrState::STATE_RUNNING) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
|
||||||
ProcessTimersInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::OnThread()
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
while (state_ == TimerMgrState::STATE_RUNNING) {
|
|
||||||
int32_t timeout = CalcNextDelay();
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
|
||||||
ProcessTimers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::OnStop()
|
|
||||||
{
|
|
||||||
CALL_DEBUG_ENTER;
|
|
||||||
state_ = TimerMgrState::STATE_EXIT;
|
|
||||||
if (timerWorker_.joinable()) {
|
|
||||||
timerWorker_.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::TakeNextTimerId()
|
|
||||||
{
|
|
||||||
WLOGFI("TimerManager::TakeNextTimerId enter");
|
|
||||||
uint64_t timerSlot = 0;
|
|
||||||
uint64_t one = 1;
|
|
||||||
|
|
||||||
for (const auto &timer : timers_) {
|
|
||||||
timerSlot |= (one << timer->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < MAX_TIMER_COUNT; i++) {
|
|
||||||
if ((timerSlot & (one << i)) == 0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WLOGFI("TimerManager::TakeNextTimerId finish");
|
|
||||||
return NONEXISTENT_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::AddTimerInternal(int32_t intervalMs, std::function<void()> callback)
|
|
||||||
{
|
|
||||||
WLOGFI("TimerManager::AddTimerInternal enter");
|
|
||||||
if (intervalMs < MIN_INTERVAL) {
|
|
||||||
intervalMs = MIN_INTERVAL;
|
|
||||||
} else if (intervalMs > MAX_INTERVAL_MS) {
|
|
||||||
intervalMs = MAX_INTERVAL_MS;
|
|
||||||
}
|
|
||||||
if (!callback) {
|
|
||||||
return NONEXISTENT_ID;
|
|
||||||
}
|
|
||||||
int32_t timerId = TakeNextTimerId();
|
|
||||||
if (timerId < 0) {
|
|
||||||
return NONEXISTENT_ID;
|
|
||||||
}
|
|
||||||
auto timer = std::make_unique<TimerItem>();
|
|
||||||
timer->id = timerId;
|
|
||||||
timer->intervalMs = intervalMs;
|
|
||||||
auto nowTime = GetMillisTime();
|
|
||||||
if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) {
|
|
||||||
WLOGFE("The addition of nextCallTime in TimerItem overflows, nowTime:%{public}" PRId64
|
|
||||||
", timerId:%{public}d, intervalMs:%{public}d, nextCallTime:%{public}" PRId64,
|
|
||||||
nowTime, timer->id, timer->intervalMs, timer->nextCallTime);
|
|
||||||
return NONEXISTENT_ID;
|
|
||||||
}
|
|
||||||
timer->callback = callback;
|
|
||||||
InsertTimerInternal(timer);
|
|
||||||
WLOGFI("TimerManager::AddTimerInternal finish");
|
|
||||||
return timerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::RemoveTimerInternal(int32_t timerId)
|
|
||||||
{
|
|
||||||
for (auto it = timers_.begin(); it != timers_.end(); ++it) {
|
|
||||||
if ((*it)->id == timerId) {
|
|
||||||
timers_.erase(it);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::InsertTimerInternal(std::unique_ptr<TimerItem>& timer)
|
|
||||||
{
|
|
||||||
WLOGFI("TimerManager::InsertTimerInternal enter");
|
|
||||||
for (auto it = timers_.begin(); it != timers_.end(); ++it) {
|
|
||||||
if ((*it)->nextCallTime > timer->nextCallTime) {
|
|
||||||
timers_.insert(it, std::move(timer));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timers_.push_back(std::move(timer));
|
|
||||||
WLOGFI("TimerManager::InsertTimerInternal finish");
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t TimerManager::CalcNextDelayInternal()
|
|
||||||
{
|
|
||||||
auto delay = MIN_DELAY;
|
|
||||||
if (!timers_.empty()) {
|
|
||||||
auto nowTime = GetMillisTime();
|
|
||||||
const auto& item = *timers_.begin();
|
|
||||||
if (nowTime >= item->nextCallTime) {
|
|
||||||
delay = 0;
|
|
||||||
} else {
|
|
||||||
delay = item->nextCallTime - nowTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerManager::ProcessTimersInternal()
|
|
||||||
{
|
|
||||||
if (timers_.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto nowTime = GetMillisTime();
|
|
||||||
for (;;) {
|
|
||||||
auto it = timers_.begin();
|
|
||||||
if (it == timers_.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((*it)->nextCallTime > nowTime) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
auto curTimer = std::move(*it);
|
|
||||||
timers_.erase(it);
|
|
||||||
if (curTimer->callback != nullptr) {
|
|
||||||
curTimer->callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace Rosen
|
|
||||||
} // namespace OHOS
|
|
@ -34,6 +34,8 @@ struct AbilityInfo;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace OHOS::Rosen {
|
namespace OHOS::Rosen {
|
||||||
|
class RSTransaction;
|
||||||
|
constexpr int32_t ROTATE_ANIMATION_DURATION = 400;
|
||||||
constexpr int32_t INVALID_SESSION_ID = 0;
|
constexpr int32_t INVALID_SESSION_ID = 0;
|
||||||
|
|
||||||
enum class WSError : int32_t {
|
enum class WSError : int32_t {
|
||||||
@ -261,6 +263,10 @@ enum class FocusChangeReason {
|
|||||||
* select last focused app when requestSessionUnFocus.
|
* select last focused app when requestSessionUnFocus.
|
||||||
*/
|
*/
|
||||||
LAST_FOCUSED_APP,
|
LAST_FOCUSED_APP,
|
||||||
|
/**
|
||||||
|
* focus for zOrder pass through VOICE_INTERACTION.
|
||||||
|
*/
|
||||||
|
VOICE_INTERACTION,
|
||||||
/**
|
/**
|
||||||
* focus change max.
|
* focus change max.
|
||||||
*/
|
*/
|
||||||
@ -334,6 +340,7 @@ struct SessionInfo {
|
|||||||
bool fullScreenStart_ = false;
|
bool fullScreenStart_ = false;
|
||||||
bool isAtomicService_ = false;
|
bool isAtomicService_ = false;
|
||||||
bool isBackTransition_ = false;
|
bool isBackTransition_ = false;
|
||||||
|
bool needClearInNotShowRecent_ = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UIExtension
|
* UIExtension
|
||||||
@ -343,6 +350,12 @@ struct SessionInfo {
|
|||||||
bool isAsyncModalBinding_ = false;
|
bool isAsyncModalBinding_ = false;
|
||||||
uint32_t parentWindowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW
|
uint32_t parentWindowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW
|
||||||
SessionViewportConfig config_;
|
SessionViewportConfig config_;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Multi instance
|
||||||
|
*/
|
||||||
|
bool isNewAppInstance_ = false;
|
||||||
|
std::string appInstanceKey_;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SessionFlag : uint32_t {
|
enum class SessionFlag : uint32_t {
|
||||||
@ -467,6 +480,17 @@ struct WSRectT {
|
|||||||
GreatOrEqual(pointY, posY_) && LessOrEqual(pointY, posY_ + height_);
|
GreatOrEqual(pointY, posY_) && LessOrEqual(pointY, posY_ + height_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsOverlap(const WSRectT<T>& a) const
|
||||||
|
{
|
||||||
|
int32_t xStart = std::max(posX_, a.posX_);
|
||||||
|
int32_t xEnd = std::min(posX_ + static_cast<int32_t>(width_),
|
||||||
|
a.posX_ + static_cast<int32_t>(a.width_));
|
||||||
|
int32_t yStart = std::max(posY_, a.posY_);
|
||||||
|
int32_t yEnd = std::min(posY_ + static_cast<int32_t>(height_),
|
||||||
|
a.posY_ + static_cast<int32_t>(a.height_));
|
||||||
|
return yStart < yEnd && xStart < xEnd;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool IsInvalid() const
|
inline bool IsInvalid() const
|
||||||
{
|
{
|
||||||
return IsEmpty() || LessOrEqual(width_, 0) || LessOrEqual(height_, 0);
|
return IsEmpty() || LessOrEqual(width_, 0) || LessOrEqual(height_, 0);
|
||||||
@ -573,6 +597,16 @@ struct DeviceScreenConfig {
|
|||||||
bool isRightPowerButton_ = true;
|
bool isRightPowerButton_ = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SceneAnimationConfig {
|
||||||
|
std::shared_ptr<RSTransaction> rsTransaction_ = nullptr;
|
||||||
|
int32_t animationDuration_ = ROTATE_ANIMATION_DURATION;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RotateAnimationConfig {
|
||||||
|
int32_t duration_ = ROTATE_ANIMATION_DURATION;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct SessionEventParam {
|
struct SessionEventParam {
|
||||||
int32_t pointerX_ = 0;
|
int32_t pointerX_ = 0;
|
||||||
int32_t pointerY_ = 0;
|
int32_t pointerY_ = 0;
|
||||||
@ -657,12 +691,14 @@ enum class SessionUIDirtyFlag {
|
|||||||
struct PostProcessFocusState {
|
struct PostProcessFocusState {
|
||||||
bool enabled_ { false };
|
bool enabled_ { false };
|
||||||
bool isFocused_ { false };
|
bool isFocused_ { false };
|
||||||
|
bool byForeground_ { true };
|
||||||
FocusChangeReason reason_ { FocusChangeReason::DEFAULT };
|
FocusChangeReason reason_ { FocusChangeReason::DEFAULT };
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
enabled_ = false;
|
enabled_ = false;
|
||||||
isFocused_ = false;
|
isFocused_ = false;
|
||||||
|
byForeground_ = true;
|
||||||
reason_ = FocusChangeReason::DEFAULT;
|
reason_ = FocusChangeReason::DEFAULT;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -323,8 +323,9 @@ void JsRootSceneSession::VerifyCallerToken(SessionInfo& info)
|
|||||||
{
|
{
|
||||||
auto callerSession = SceneSessionManager::GetInstance().GetSceneSession(info.callerPersistentId_);
|
auto callerSession = SceneSessionManager::GetInstance().GetSceneSession(info.callerPersistentId_);
|
||||||
if (callerSession != nullptr) {
|
if (callerSession != nullptr) {
|
||||||
|
bool isSceneBoardBundle = SessionPermission::IsSameAppAsCalling("", "");
|
||||||
bool isCalledRightlyByCallerId = ((info.callerToken_ == callerSession->GetAbilityToken()) &&
|
bool isCalledRightlyByCallerId = ((info.callerToken_ == callerSession->GetAbilityToken()) &&
|
||||||
info.bundleName_ == "");
|
isSceneBoardBundle);
|
||||||
TLOGI(WmsLogTag::WMS_SCB,
|
TLOGI(WmsLogTag::WMS_SCB,
|
||||||
"root isCalledRightlyByCallerId: %{public}d", isCalledRightlyByCallerId);
|
"root isCalledRightlyByCallerId: %{public}d", isCalledRightlyByCallerId);
|
||||||
info.isCalledRightlyByCallerId_ = isCalledRightlyByCallerId;
|
info.isCalledRightlyByCallerId_ = isCalledRightlyByCallerId;
|
||||||
@ -341,13 +342,14 @@ sptr<SceneSession> JsRootSceneSession::GenSceneSession(SessionInfo& info)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.reuse) {
|
if (info.reuse || info.isAtomicService_) {
|
||||||
if (SceneSessionManager::GetInstance().CheckCollaboratorType(info.collaboratorType_)) {
|
if (SceneSessionManager::GetInstance().CheckCollaboratorType(info.collaboratorType_)) {
|
||||||
sceneSession = SceneSessionManager::GetInstance().FindSessionByAffinity(
|
sceneSession = SceneSessionManager::GetInstance().FindSessionByAffinity(
|
||||||
info.sessionAffinity);
|
info.sessionAffinity);
|
||||||
} else {
|
} else {
|
||||||
sceneSession = SceneSessionManager::GetInstance().GetSceneSessionByName(
|
ComparedSessionInfo compareSessionInfo = { info.bundleName_, info.moduleName_, info.abilityName_,
|
||||||
info.bundleName_, info.moduleName_, info.abilityName_, info.appIndex_);
|
info.appIndex_, info.appInstanceKey_, info.windowType_, info.isAtomicService_ };
|
||||||
|
sceneSession = SceneSessionManager::GetInstance().GetSceneSessionByName(compareSessionInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sceneSession == nullptr) {
|
if (sceneSession == nullptr) {
|
||||||
@ -360,6 +362,7 @@ sptr<SceneSession> JsRootSceneSession::GenSceneSession(SessionInfo& info)
|
|||||||
}
|
}
|
||||||
info.persistentId_ = sceneSession->GetPersistentId();
|
info.persistentId_ = sceneSession->GetPersistentId();
|
||||||
sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId());
|
sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId());
|
||||||
|
sceneSession->SetDefaultDisplayIdIfNeed();
|
||||||
} else {
|
} else {
|
||||||
sceneSession = SceneSessionManager::GetInstance().GetSceneSession(info.persistentId_);
|
sceneSession = SceneSessionManager::GetInstance().GetSceneSession(info.persistentId_);
|
||||||
if (sceneSession == nullptr) {
|
if (sceneSession == nullptr) {
|
||||||
|
@ -38,7 +38,7 @@ struct CallBackContext {
|
|||||||
napi_env env = nullptr;
|
napi_env env = nullptr;
|
||||||
std::shared_ptr<NativeReference> callbackRef = nullptr;
|
std::shared_ptr<NativeReference> callbackRef = nullptr;
|
||||||
OnRssEventCb eventCb = nullptr;
|
OnRssEventCb eventCb = nullptr;
|
||||||
int32_t eventType = 0;
|
uint32_t eventType = 0;
|
||||||
std::unordered_map<std::string, std::string> extraInfo;
|
std::unordered_map<std::string, std::string> extraInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ void RssSession::ParseCallbackMutex(const std::string& mutexStr, std::string& bu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssSession::OnReceiveEvent(napi_env env, napi_value callbackObj, int32_t eventType,
|
void RssSession::OnReceiveEvent(napi_env env, napi_value callbackObj, uint32_t eventType,
|
||||||
const std::unordered_map<std::string, std::string>& extraInfo)
|
const std::unordered_map<std::string, std::string>& extraInfo)
|
||||||
{
|
{
|
||||||
WLOGFI("asyncCallback.");
|
WLOGFI("asyncCallback.");
|
||||||
@ -237,7 +237,7 @@ void RssSession::OnReceiveEvent(napi_env env, napi_value callbackObj, int32_t ev
|
|||||||
napi_value RssSession::RegisterRssDataCallback(napi_env env, napi_callback_info info)
|
napi_value RssSession::RegisterRssDataCallback(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFD("start");
|
WLOGFD("start");
|
||||||
int32_t eventType;
|
uint32_t eventType;
|
||||||
napi_value jsCallback = nullptr;
|
napi_value jsCallback = nullptr;
|
||||||
if (!CheckCallbackParam(env, info, eventType, &jsCallback)) {
|
if (!CheckCallbackParam(env, info, eventType, &jsCallback)) {
|
||||||
WLOGFE("Register RssData Callback parameter error.");
|
WLOGFE("Register RssData Callback parameter error.");
|
||||||
@ -259,7 +259,7 @@ napi_value RssSession::RegisterRssDataCallback(napi_env env, napi_callback_info
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto rssDataCb = [](napi_env env, napi_value callbackObj, int32_t eventType,
|
auto rssDataCb = [](napi_env env, napi_value callbackObj, uint32_t eventType,
|
||||||
std::unordered_map<std::string, std::string>&& extraInfo) {
|
std::unordered_map<std::string, std::string>&& extraInfo) {
|
||||||
RssSession::GetInstance().OnReceiveEvent(env, callbackObj, eventType, extraInfo);
|
RssSession::GetInstance().OnReceiveEvent(env, callbackObj, eventType, extraInfo);
|
||||||
};
|
};
|
||||||
@ -273,7 +273,7 @@ napi_value RssSession::RegisterRssDataCallback(napi_env env, napi_callback_info
|
|||||||
napi_value RssSession::UnRegisterRssDataCallback(napi_env env, napi_callback_info info)
|
napi_value RssSession::UnRegisterRssDataCallback(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFD("start");
|
WLOGFD("start");
|
||||||
int32_t eventType;
|
uint32_t eventType;
|
||||||
napi_value jsCallback = nullptr;
|
napi_value jsCallback = nullptr;
|
||||||
if (!CheckCallbackParam(env, info, eventType, &jsCallback)) {
|
if (!CheckCallbackParam(env, info, eventType, &jsCallback)) {
|
||||||
WLOGFE("UnRegister RssData Callback parameter error.");
|
WLOGFE("UnRegister RssData Callback parameter error.");
|
||||||
@ -330,7 +330,7 @@ void RssSession::CompleteCb(napi_env env, napi_status status, void* data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RssSession::CheckCallbackParam(napi_env env, napi_callback_info info,
|
bool RssSession::CheckCallbackParam(napi_env env, napi_callback_info info,
|
||||||
int32_t& eventType, napi_value* jsCallback)
|
uint32_t& eventType, napi_value* jsCallback)
|
||||||
{
|
{
|
||||||
if (jsCallback == nullptr) {
|
if (jsCallback == nullptr) {
|
||||||
WLOGFE("Input callback is nullptr.");
|
WLOGFE("Input callback is nullptr.");
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
static napi_value UnregisterRssData(napi_env env, napi_callback_info info);
|
static napi_value UnregisterRssData(napi_env env, napi_callback_info info);
|
||||||
static napi_value DealRssReply(napi_env env, const nlohmann::json& payload, const nlohmann::json& reply);
|
static napi_value DealRssReply(napi_env env, const nlohmann::json& payload, const nlohmann::json& reply);
|
||||||
|
|
||||||
void OnReceiveEvent(napi_env env, napi_value callbackObj, int32_t eventType,
|
void OnReceiveEvent(napi_env env, napi_value callbackObj, uint32_t eventType,
|
||||||
const std::unordered_map<std::string, std::string>& extraInfo);
|
const std::unordered_map<std::string, std::string>& extraInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -85,14 +85,14 @@ private:
|
|||||||
|
|
||||||
napi_value RegisterRssDataCallback(napi_env env, napi_callback_info info);
|
napi_value RegisterRssDataCallback(napi_env env, napi_callback_info info);
|
||||||
napi_value UnRegisterRssDataCallback(napi_env env, napi_callback_info info);
|
napi_value UnRegisterRssDataCallback(napi_env env, napi_callback_info info);
|
||||||
bool CheckCallbackParam(napi_env env, napi_callback_info info, int32_t& eventType, napi_value* jsCallback);
|
bool CheckCallbackParam(napi_env env, napi_callback_info info, uint32_t& eventType, napi_value* jsCallback);
|
||||||
|
|
||||||
static void ParseMutex(const std::string& mutexStr, const nlohmann::json& payload, std::string& detailStr);
|
static void ParseMutex(const std::string& mutexStr, const nlohmann::json& payload, std::string& detailStr);
|
||||||
static void ParseCallbackMutex(const std::string& mutexStr, std::string& bundleName);
|
static void ParseCallbackMutex(const std::string& mutexStr, std::string& bundleName);
|
||||||
static void CompleteCb(napi_env env, napi_status status, void* data);
|
static void CompleteCb(napi_env env, napi_status status, void* data);
|
||||||
|
|
||||||
// ONLY Accessed on main thread
|
// ONLY Accessed on main thread
|
||||||
std::unordered_map<int32_t, std::list<CallBackPair>> jsCallBackMap_;
|
std::unordered_map<uint32_t, std::list<CallBackPair>> jsCallBackMap_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -32,6 +32,7 @@ const std::string BUFFER_AVAILABLE_CHANGE_CB = "bufferAvailableChange";
|
|||||||
const std::string SESSION_EVENT_CB = "sessionEvent";
|
const std::string SESSION_EVENT_CB = "sessionEvent";
|
||||||
const std::string SESSION_RECT_CHANGE_CB = "sessionRectChange";
|
const std::string SESSION_RECT_CHANGE_CB = "sessionRectChange";
|
||||||
const std::string SESSION_PIP_CONTROL_STATUS_CHANGE_CB = "sessionPiPControlStatusChange";
|
const std::string SESSION_PIP_CONTROL_STATUS_CHANGE_CB = "sessionPiPControlStatusChange";
|
||||||
|
const std::string SESSION_AUTO_START_PIP_CB = "autoStartPiP";
|
||||||
const std::string CREATE_SUB_SESSION_CB = "createSpecificSession";
|
const std::string CREATE_SUB_SESSION_CB = "createSpecificSession";
|
||||||
const std::string BIND_DIALOG_TARGET_CB = "bindDialogTarget";
|
const std::string BIND_DIALOG_TARGET_CB = "bindDialogTarget";
|
||||||
const std::string RAISE_TO_TOP_CB = "raiseToTop";
|
const std::string RAISE_TO_TOP_CB = "raiseToTop";
|
||||||
@ -85,6 +86,7 @@ const std::map<std::string, ListenerFuncType> ListenerFuncMap {
|
|||||||
{SESSION_EVENT_CB, ListenerFuncType::SESSION_EVENT_CB},
|
{SESSION_EVENT_CB, ListenerFuncType::SESSION_EVENT_CB},
|
||||||
{SESSION_RECT_CHANGE_CB, ListenerFuncType::SESSION_RECT_CHANGE_CB},
|
{SESSION_RECT_CHANGE_CB, ListenerFuncType::SESSION_RECT_CHANGE_CB},
|
||||||
{SESSION_PIP_CONTROL_STATUS_CHANGE_CB, ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB},
|
{SESSION_PIP_CONTROL_STATUS_CHANGE_CB, ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB},
|
||||||
|
{SESSION_AUTO_START_PIP_CB, ListenerFuncType::SESSION_AUTO_START_PIP_CB},
|
||||||
{CREATE_SUB_SESSION_CB, ListenerFuncType::CREATE_SUB_SESSION_CB},
|
{CREATE_SUB_SESSION_CB, ListenerFuncType::CREATE_SUB_SESSION_CB},
|
||||||
{BIND_DIALOG_TARGET_CB, ListenerFuncType::BIND_DIALOG_TARGET_CB},
|
{BIND_DIALOG_TARGET_CB, ListenerFuncType::BIND_DIALOG_TARGET_CB},
|
||||||
{RAISE_TO_TOP_CB, ListenerFuncType::RAISE_TO_TOP_CB},
|
{RAISE_TO_TOP_CB, ListenerFuncType::RAISE_TO_TOP_CB},
|
||||||
@ -203,6 +205,29 @@ static napi_value CreatePipTemplateInfo(napi_env env, const sptr<SceneSession>&
|
|||||||
return pipTemplateInfoValue;
|
return pipTemplateInfoValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetWindowSize(napi_env env, napi_value objValue, const sptr<SceneSession>& session)
|
||||||
|
{
|
||||||
|
auto abilityInfo = session->GetSessionInfo().abilityInfo;
|
||||||
|
if (!abilityInfo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t value = 0;
|
||||||
|
auto metadata = abilityInfo->metadata;
|
||||||
|
for (auto item : metadata) {
|
||||||
|
if (item.name == "ohos.ability.window.width") {
|
||||||
|
if (GetIntValueFromString(item.value, value) == WSError::WS_OK) {
|
||||||
|
TLOGI(WmsLogTag::WMS_LAYOUT, "ohos.ability.window.width = %{public}d", value);
|
||||||
|
napi_set_named_property(env, objValue, "windowWidth", CreateJsValue(env, value));
|
||||||
|
}
|
||||||
|
} else if (item.name == "ohos.ability.window.height") {
|
||||||
|
if (GetIntValueFromString(item.value, value) == WSError::WS_OK) {
|
||||||
|
TLOGI(WmsLogTag::WMS_LAYOUT, "ohos.ability.window.height = %{public}d", value);
|
||||||
|
napi_set_named_property(env, objValue, "windowHeight", CreateJsValue(env, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& session)
|
napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& session)
|
||||||
{
|
{
|
||||||
napi_value objValue = nullptr;
|
napi_value objValue = nullptr;
|
||||||
@ -229,6 +254,9 @@ napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& sessio
|
|||||||
CreateJsValue(env, static_cast<int32_t>(session->IsTopmost())));
|
CreateJsValue(env, static_cast<int32_t>(session->IsTopmost())));
|
||||||
napi_set_named_property(env, objValue, "subWindowModalType",
|
napi_set_named_property(env, objValue, "subWindowModalType",
|
||||||
CreateJsValue(env, static_cast<int32_t>(session->GetSubWindowModalType())));
|
CreateJsValue(env, static_cast<int32_t>(session->GetSubWindowModalType())));
|
||||||
|
napi_set_named_property(env, objValue, "appInstanceKey",
|
||||||
|
CreateJsValue(env, session->GetSessionInfo().appInstanceKey_));
|
||||||
|
SetWindowSize(env, objValue, session);
|
||||||
|
|
||||||
const char* moduleName = "JsSceneSession";
|
const char* moduleName = "JsSceneSession";
|
||||||
BindNativeMethod(env, objValue, moduleName);
|
BindNativeMethod(env, objValue, moduleName);
|
||||||
@ -268,6 +296,7 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
|
|||||||
BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale);
|
BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale);
|
||||||
BindNativeFunction(env, objValue, "setWindowLastSafeRect", moduleName, JsSceneSession::SetWindowLastSafeRect);
|
BindNativeFunction(env, objValue, "setWindowLastSafeRect", moduleName, JsSceneSession::SetWindowLastSafeRect);
|
||||||
BindNativeFunction(env, objValue, "setMovable", moduleName, JsSceneSession::SetMovable);
|
BindNativeFunction(env, objValue, "setMovable", moduleName, JsSceneSession::SetMovable);
|
||||||
|
BindNativeFunction(env, objValue, "setSplitButtonVisible", moduleName, JsSceneSession::SetSplitButtonVisible);
|
||||||
BindNativeFunction(env, objValue, "setOffset", moduleName, JsSceneSession::SetOffset);
|
BindNativeFunction(env, objValue, "setOffset", moduleName, JsSceneSession::SetOffset);
|
||||||
BindNativeFunction(env, objValue, "setExitSplitOnBackground", moduleName,
|
BindNativeFunction(env, objValue, "setExitSplitOnBackground", moduleName,
|
||||||
JsSceneSession::SetExitSplitOnBackground);
|
JsSceneSession::SetExitSplitOnBackground);
|
||||||
@ -292,6 +321,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
|
|||||||
JsSceneSession::SyncDefaultRequestedOrientation);
|
JsSceneSession::SyncDefaultRequestedOrientation);
|
||||||
BindNativeFunction(env, objValue, "setIsPcAppInPad", moduleName,
|
BindNativeFunction(env, objValue, "setIsPcAppInPad", moduleName,
|
||||||
JsSceneSession::SetIsPcAppInPad);
|
JsSceneSession::SetIsPcAppInPad);
|
||||||
|
BindNativeFunction(env, objValue, "setCompatibleModeEnableInPad", moduleName,
|
||||||
|
JsSceneSession::SetCompatibleModeEnableInPad);
|
||||||
BindNativeFunction(env, objValue, "setStartingWindowExitAnimationFlag", moduleName,
|
BindNativeFunction(env, objValue, "setStartingWindowExitAnimationFlag", moduleName,
|
||||||
JsSceneSession::SetStartingWindowExitAnimationFlag);
|
JsSceneSession::SetStartingWindowExitAnimationFlag);
|
||||||
}
|
}
|
||||||
@ -387,13 +418,14 @@ void JsSceneSession::ProcessPendingSceneSessionActivationRegister()
|
|||||||
void JsSceneSession::ProcessWindowDragHotAreaRegister()
|
void JsSceneSession::ProcessWindowDragHotAreaRegister()
|
||||||
{
|
{
|
||||||
WLOGFI("[NAPI]");
|
WLOGFI("[NAPI]");
|
||||||
NotifyWindowDragHotAreaFunc func = [weakThis = wptr(this)](uint32_t type, const SizeChangeReason& reason) {
|
NotifyWindowDragHotAreaFunc func = [weakThis = wptr(this)](
|
||||||
|
uint64_t displayId, uint32_t type, const SizeChangeReason reason) {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession) {
|
if (!jsSceneSession) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "ProcessWindowDragHotAreaRegister jsSceneSession is null");
|
TLOGE(WmsLogTag::WMS_LIFE, "ProcessWindowDragHotAreaRegister jsSceneSession is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jsSceneSession->OnWindowDragHotArea(type, reason);
|
jsSceneSession->OnWindowDragHotArea(displayId, type, reason);
|
||||||
};
|
};
|
||||||
auto session = weakSession_.promote();
|
auto session = weakSession_.promote();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
@ -403,7 +435,7 @@ void JsSceneSession::ProcessWindowDragHotAreaRegister()
|
|||||||
session->SetWindowDragHotAreaListener(func);
|
session->SetWindowDragHotAreaListener(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsSceneSession::OnWindowDragHotArea(uint32_t type, const SizeChangeReason& reason)
|
void JsSceneSession::OnWindowDragHotArea(uint64_t displayId, uint32_t type, const SizeChangeReason reason)
|
||||||
{
|
{
|
||||||
WLOGFI("[NAPI]");
|
WLOGFI("[NAPI]");
|
||||||
|
|
||||||
@ -413,7 +445,7 @@ void JsSceneSession::OnWindowDragHotArea(uint32_t type, const SizeChangeReason&
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WSRect rect = session->GetSessionTargetRect();
|
WSRect rect = session->GetSessionTargetRect();
|
||||||
auto task = [weakThis = wptr(this), persistentId = persistentId_, env = env_, type, reason, rect] {
|
auto task = [weakThis = wptr(this), persistentId = persistentId_, env = env_, displayId, type, reason, rect] {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "OnWindowDragHotArea jsSceneSession id:%{public}d has been destroyed",
|
TLOGE(WmsLogTag::WMS_LIFE, "OnWindowDragHotArea jsSceneSession id:%{public}d has been destroyed",
|
||||||
@ -422,25 +454,30 @@ void JsSceneSession::OnWindowDragHotArea(uint32_t type, const SizeChangeReason&
|
|||||||
}
|
}
|
||||||
auto jsCallBack = jsSceneSession->GetJSCallback(WINDOW_DRAG_HOT_AREA_CB);
|
auto jsCallBack = jsSceneSession->GetJSCallback(WINDOW_DRAG_HOT_AREA_CB);
|
||||||
if (!jsCallBack) {
|
if (!jsCallBack) {
|
||||||
WLOGFE("[NAPI]jsCallBack is nullptr");
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
napi_value jsHotAreaDisplayId = CreateJsValue(env, static_cast<int64_t>(displayId));
|
||||||
|
if (jsHotAreaDisplayId == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsHotAreaDisplayId is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value jsHotAreaType = CreateJsValue(env, type);
|
napi_value jsHotAreaType = CreateJsValue(env, type);
|
||||||
if (jsHotAreaType == nullptr) {
|
if (jsHotAreaType == nullptr) {
|
||||||
WLOGFE("[NAPI]jsHotAreaType is nullptr");
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsHotAreaType is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value jsHotAreaReason = CreateJsValue(env, reason);
|
napi_value jsHotAreaReason = CreateJsValue(env, reason);
|
||||||
if (jsHotAreaReason == nullptr) {
|
if (jsHotAreaReason == nullptr) {
|
||||||
WLOGFE("[NAPI]jsHotAreaReason is nullptr");
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsHotAreaReason is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value jsHotAreaRect = CreateJsSessionRect(env, rect);
|
napi_value jsHotAreaRect = CreateJsSessionRect(env, rect);
|
||||||
if (jsHotAreaRect == nullptr) {
|
if (jsHotAreaRect == nullptr) {
|
||||||
WLOGFE("[NAPI]jsHotAreaRect is nullptr");
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsHotAreaRect is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value argv[] = {jsHotAreaType, jsHotAreaReason, jsHotAreaRect};
|
napi_value argv[] = {jsHotAreaDisplayId, jsHotAreaType, jsHotAreaReason, jsHotAreaRect};
|
||||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||||
};
|
};
|
||||||
taskScheduler_->PostMainThreadTask(task, "OnWindowDragHotArea");
|
taskScheduler_->PostMainThreadTask(task, "OnWindowDragHotArea");
|
||||||
@ -820,13 +857,14 @@ void JsSceneSession::ProcessBindDialogTargetRegister()
|
|||||||
|
|
||||||
void JsSceneSession::ProcessSessionRectChangeRegister()
|
void JsSceneSession::ProcessSessionRectChangeRegister()
|
||||||
{
|
{
|
||||||
NotifySessionRectChangeFunc func = [weakThis = wptr(this)](const WSRect& rect, const SizeChangeReason& reason) {
|
NotifySessionRectChangeFunc func = [weakThis = wptr(this)](const WSRect& rect,
|
||||||
|
const SizeChangeReason reason, const DisplayId displayId = DISPLAY_ID_INVALID) {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession) {
|
if (!jsSceneSession) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionRectChangeRegister jsSceneSession is null");
|
TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionRectChangeRegister jsSceneSession is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jsSceneSession->OnSessionRectChange(rect, reason);
|
jsSceneSession->OnSessionRectChange(rect, reason, displayId);
|
||||||
};
|
};
|
||||||
auto session = weakSession_.promote();
|
auto session = weakSession_.promote();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
@ -857,6 +895,25 @@ void JsSceneSession::ProcessSessionPiPControlStatusChangeRegister()
|
|||||||
TLOGI(WmsLogTag::WMS_PIP, "success");
|
TLOGI(WmsLogTag::WMS_PIP, "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsSceneSession::ProcessAutoStartPiPStatusChangeRegister()
|
||||||
|
{
|
||||||
|
auto session = weakSession_.promote();
|
||||||
|
if (session == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::WMS_PIP, "session is nullptr, id:%{public}d", persistentId_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NotifyAutoStartPiPStatusChangeFunc func = [weakThis = wptr(this)](bool isAutoStart) {
|
||||||
|
auto jsSceneSession = weakThis.promote();
|
||||||
|
if (!jsSceneSession) {
|
||||||
|
TLOGNE(WmsLogTag::WMS_PIP, "jsSceneSession is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
jsSceneSession->OnAutoStartPiPStatusChange(isAutoStart);
|
||||||
|
};
|
||||||
|
session->SetAutoStartPiPStatusChangeCallback(func);
|
||||||
|
TLOGI(WmsLogTag::WMS_PIP, "success");
|
||||||
|
}
|
||||||
|
|
||||||
/** @note @window.hierarchy */
|
/** @note @window.hierarchy */
|
||||||
void JsSceneSession::ProcessRaiseToTopRegister()
|
void JsSceneSession::ProcessRaiseToTopRegister()
|
||||||
{
|
{
|
||||||
@ -1037,13 +1094,14 @@ void JsSceneSession::ProcessPendingSessionToForegroundRegister()
|
|||||||
void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
|
void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
|
||||||
{
|
{
|
||||||
TLOGD(WmsLogTag::WMS_LIFE, "in");
|
TLOGD(WmsLogTag::WMS_LIFE, "in");
|
||||||
NotifyPendingSessionToBackgroundForDelegatorFunc func = [weakThis = wptr(this)](const SessionInfo& info) {
|
NotifyPendingSessionToBackgroundForDelegatorFunc func = [weakThis = wptr(this)](const SessionInfo& info,
|
||||||
|
bool shouldBackToCaller) {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession) {
|
if (!jsSceneSession) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSessionToBackgroundForDelegatorRegister jsSceneSession is null");
|
TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jsSceneSession->PendingSessionToBackgroundForDelegator(info);
|
jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller);
|
||||||
};
|
};
|
||||||
auto session = weakSession_.promote();
|
auto session = weakSession_.promote();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
@ -1743,6 +1801,13 @@ napi_value JsSceneSession::SetIsPcAppInPad(napi_env env, napi_callback_info info
|
|||||||
return (me != nullptr) ? me->OnSetIsPcAppInPad(env, info) : nullptr;
|
return (me != nullptr) ? me->OnSetIsPcAppInPad(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSession::SetCompatibleModeEnableInPad(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::WMS_SCB, "[NAPI]");
|
||||||
|
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnSetCompatibleModeEnableInPad(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSession::SetStartingWindowExitAnimationFlag(napi_env env, napi_callback_info info)
|
napi_value JsSceneSession::SetStartingWindowExitAnimationFlag(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]");
|
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]");
|
||||||
@ -1877,6 +1942,9 @@ void JsSceneSession::ProcessRegisterCallback(ListenerFuncType listenerFuncType)
|
|||||||
case static_cast<uint32_t>(ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB):
|
case static_cast<uint32_t>(ListenerFuncType::SESSION_PIP_CONTROL_STATUS_CHANGE_CB):
|
||||||
ProcessSessionPiPControlStatusChangeRegister();
|
ProcessSessionPiPControlStatusChangeRegister();
|
||||||
break;
|
break;
|
||||||
|
case static_cast<uint32_t>(ListenerFuncType::SESSION_AUTO_START_PIP_CB):
|
||||||
|
ProcessAutoStartPiPStatusChangeRegister();
|
||||||
|
break;
|
||||||
case static_cast<uint32_t>(ListenerFuncType::CREATE_SUB_SESSION_CB):
|
case static_cast<uint32_t>(ListenerFuncType::CREATE_SUB_SESSION_CB):
|
||||||
ProcessCreateSubSessionRegister();
|
ProcessCreateSubSessionRegister();
|
||||||
break;
|
break;
|
||||||
@ -2447,28 +2515,30 @@ void JsSceneSession::OnBufferAvailableChange(const bool isBufferAvailable)
|
|||||||
taskScheduler_->PostMainThreadTask(task, "OnBufferAvailableChange");
|
taskScheduler_->PostMainThreadTask(task, "OnBufferAvailableChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsSceneSession::OnSessionRectChange(const WSRect& rect, const SizeChangeReason& reason)
|
/** @note @window.layout */
|
||||||
|
void JsSceneSession::OnSessionRectChange(const WSRect& rect, const SizeChangeReason reason, const DisplayId displayId)
|
||||||
{
|
{
|
||||||
if (reason != SizeChangeReason::MOVE && reason != SizeChangeReason::PIP_RESTORE && rect.IsEmpty()) {
|
if (reason != SizeChangeReason::MOVE && reason != SizeChangeReason::PIP_RESTORE && rect.IsEmpty()) {
|
||||||
WLOGFD("Rect is empty, there is no need to notify");
|
WLOGFD("Rect is empty, there is no need to notify");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WLOGFD("[NAPI]");
|
WLOGFD("[NAPI]");
|
||||||
auto task = [weakThis = wptr(this), persistentId = persistentId_, rect, reason, env = env_] {
|
auto task = [weakThis = wptr(this), persistentId = persistentId_, rect, displayId, reason, env = env_] {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "OnSessionRectChange jsSceneSession id:%{public}d has been destroyed",
|
TLOGNE(WmsLogTag::WMS_LIFE, "OnSessionRectChange jsSceneSession id:%{public}d has been destroyed",
|
||||||
persistentId);
|
persistentId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto jsCallBack = jsSceneSession->GetJSCallback(SESSION_RECT_CHANGE_CB);
|
auto jsCallBack = jsSceneSession->GetJSCallback(SESSION_RECT_CHANGE_CB);
|
||||||
if (!jsCallBack) {
|
if (!jsCallBack) {
|
||||||
WLOGFE("[NAPI]jsCallBack is nullptr");
|
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]jsCallBack is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value jsSessionStateObj = CreateJsSessionRect(env, rect);
|
napi_value jsSessionRect = CreateJsSessionRect(env, rect);
|
||||||
napi_value sizeChangeReason = CreateJsValue(env, static_cast<int32_t>(reason));
|
napi_value jsSizeChangeReason = CreateJsValue(env, static_cast<int32_t>(reason));
|
||||||
napi_value argv[] = {jsSessionStateObj, sizeChangeReason};
|
napi_value jsDisplayId = CreateJsValue(env, static_cast<int32_t>(displayId));
|
||||||
|
napi_value argv[] = {jsSessionRect, jsSizeChangeReason, jsDisplayId};
|
||||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||||
};
|
};
|
||||||
std::string rectInfo = "OnSessionRectChange [" + std::to_string(rect.posX_) + "," + std::to_string(rect.posY_)
|
std::string rectInfo = "OnSessionRectChange [" + std::to_string(rect.posX_) + "," + std::to_string(rect.posY_)
|
||||||
@ -2499,6 +2569,27 @@ void JsSceneSession::OnSessionPiPControlStatusChange(WsPiPControlType controlTyp
|
|||||||
taskScheduler_->PostMainThreadTask(task, __func__);
|
taskScheduler_->PostMainThreadTask(task, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsSceneSession::OnAutoStartPiPStatusChange(bool isAutoStart)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::WMS_PIP, "isAutoStart:%{public}u", isAutoStart);
|
||||||
|
auto task = [weakThis = wptr(this), persistentId = persistentId_, isAutoStart, env = env_] {
|
||||||
|
auto jsSceneSession = weakThis.promote();
|
||||||
|
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
||||||
|
TLOGNE(WmsLogTag::WMS_PIP, "jsSceneSession id:%{public}d has been destroyed", persistentId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto jsCallBack = jsSceneSession->GetJSCallback(SESSION_AUTO_START_PIP_CB);
|
||||||
|
if (!jsCallBack) {
|
||||||
|
TLOGNE(WmsLogTag::WMS_PIP, "[NAPI]jsCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
napi_value isAutoStartValue = CreateJsValue(env, isAutoStart);
|
||||||
|
napi_value argv[] = {isAutoStartValue};
|
||||||
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||||
|
};
|
||||||
|
taskScheduler_->PostMainThreadTask(task, __func__);
|
||||||
|
}
|
||||||
|
|
||||||
/** @note @window.hierarchy */
|
/** @note @window.hierarchy */
|
||||||
void JsSceneSession::OnRaiseToTop()
|
void JsSceneSession::OnRaiseToTop()
|
||||||
{
|
{
|
||||||
@ -2755,13 +2846,14 @@ sptr<SceneSession> JsSceneSession::GenSceneSession(SessionInfo& info)
|
|||||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]BrokerStates not started");
|
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]BrokerStates not started");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (info.reuse) {
|
if (info.reuse || info.isAtomicService_) {
|
||||||
TLOGI(WmsLogTag::WMS_LIFE, "session need to be reusesd.");
|
TLOGI(WmsLogTag::WMS_LIFE, "session need to be reusesd.");
|
||||||
if (SceneSessionManager::GetInstance().CheckCollaboratorType(info.collaboratorType_)) {
|
if (SceneSessionManager::GetInstance().CheckCollaboratorType(info.collaboratorType_)) {
|
||||||
sceneSession = SceneSessionManager::GetInstance().FindSessionByAffinity(info.sessionAffinity);
|
sceneSession = SceneSessionManager::GetInstance().FindSessionByAffinity(info.sessionAffinity);
|
||||||
} else {
|
} else {
|
||||||
sceneSession = SceneSessionManager::GetInstance().GetSceneSessionByName(
|
ComparedSessionInfo compareSessionInfo = { info.bundleName_, info.moduleName_, info.abilityName_,
|
||||||
info.bundleName_, info.moduleName_, info.abilityName_, info.appIndex_);
|
info.appIndex_, info.appInstanceKey_, info.windowType_, info.isAtomicService_ };
|
||||||
|
sceneSession = SceneSessionManager::GetInstance().GetSceneSessionByName(compareSessionInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sceneSession == nullptr) {
|
if (sceneSession == nullptr) {
|
||||||
@ -2814,8 +2906,9 @@ void JsSceneSession::PendingSessionActivation(SessionInfo& info)
|
|||||||
|
|
||||||
auto callerSession = SceneSessionManager::GetInstance().GetSceneSession(info.callerPersistentId_);
|
auto callerSession = SceneSessionManager::GetInstance().GetSceneSession(info.callerPersistentId_);
|
||||||
if (callerSession != nullptr) {
|
if (callerSession != nullptr) {
|
||||||
|
bool isSceneBoardBundle = SessionPermission::IsSameAppAsCalling("", "");
|
||||||
bool isCalledRightlyByCallerId = ((info.callerToken_ == callerSession->GetAbilityToken()) &&
|
bool isCalledRightlyByCallerId = ((info.callerToken_ == callerSession->GetAbilityToken()) &&
|
||||||
info.bundleName_ == "");
|
isSceneBoardBundle);
|
||||||
TLOGI(WmsLogTag::WMS_SCB,
|
TLOGI(WmsLogTag::WMS_SCB,
|
||||||
"isCalledRightlyByCallerId result is: %{public}d", isCalledRightlyByCallerId);
|
"isCalledRightlyByCallerId result is: %{public}d", isCalledRightlyByCallerId);
|
||||||
info.isCalledRightlyByCallerId_ = isCalledRightlyByCallerId;
|
info.isCalledRightlyByCallerId_ = isCalledRightlyByCallerId;
|
||||||
@ -3145,34 +3238,31 @@ void JsSceneSession::PendingSessionToForeground(const SessionInfo& info)
|
|||||||
taskScheduler_->PostMainThreadTask(task, "PendingSessionToForeground:" + info.bundleName_);
|
taskScheduler_->PostMainThreadTask(task, "PendingSessionToForeground:" + info.bundleName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsSceneSession::PendingSessionToBackgroundForDelegator(const SessionInfo& info)
|
void JsSceneSession::PendingSessionToBackgroundForDelegator(const SessionInfo& info, bool shouldBackToCaller)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName = %{public}s, abilityName = %{public}s",
|
TLOGI(WmsLogTag::WMS_LIFE,
|
||||||
info.bundleName_.c_str(), info.abilityName_.c_str());
|
"[NAPI]bundleName = %{public}s, abilityName = %{public}s, shouldBackToCaller = %{public}d",
|
||||||
|
info.bundleName_.c_str(), info.abilityName_.c_str(), shouldBackToCaller);
|
||||||
|
|
||||||
std::shared_ptr<SessionInfo> sessionInfo = std::make_shared<SessionInfo>(info);
|
std::shared_ptr<SessionInfo> sessionInfo = std::make_shared<SessionInfo>(info);
|
||||||
auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, env = env_] {
|
auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, env = env_, shouldBackToCaller] {
|
||||||
auto jsSceneSession = weakThis.promote();
|
auto jsSceneSession = weakThis.promote();
|
||||||
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "PendingSessionToBackgroundForDelegator jsSceneSession id:%{public}d has"
|
TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession id:%{public}d has been destroyed", persistentId);
|
||||||
" been destroyed", persistentId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto jsCallBack = jsSceneSession->GetJSCallback(PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB);
|
auto jsCallBack = jsSceneSession->GetJSCallback(PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR_CB);
|
||||||
if (!jsCallBack) {
|
if (!jsCallBack) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]jsCallBack is nullptr");
|
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]jsCallBack is nullptr");
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sessionInfo == nullptr) {
|
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]sessionInfo is nullptr");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value jsSessionInfo = CreateJsSessionInfo(env, *sessionInfo);
|
napi_value jsSessionInfo = CreateJsSessionInfo(env, *sessionInfo);
|
||||||
|
napi_value jsShouldBackToCaller = CreateJsValue(env, shouldBackToCaller);
|
||||||
if (jsSessionInfo == nullptr) {
|
if (jsSessionInfo == nullptr) {
|
||||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
|
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value argv[] = {jsSessionInfo};
|
napi_value argv[] = {jsSessionInfo, jsShouldBackToCaller};
|
||||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||||
};
|
};
|
||||||
taskScheduler_->PostMainThreadTask(task, "PendingSessionToBackgroundForDelegator, name:" + info.bundleName_);
|
taskScheduler_->PostMainThreadTask(task, "PendingSessionToBackgroundForDelegator, name:" + info.bundleName_);
|
||||||
@ -3763,7 +3853,7 @@ napi_value JsSceneSession::OnSetWindowLastSafeRect(napi_env env, napi_callback_i
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
WSRect lastRect = { left, top, width, height };
|
WSRect lastRect = { left, top, width, height };
|
||||||
session->SetLastSafeRect(lastRect);
|
session->SetSessionRequestRect(lastRect);
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3802,6 +3892,41 @@ napi_value JsSceneSession::OnSetMovable(napi_env env, napi_callback_info info)
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSession::SetSplitButtonVisible(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
|
||||||
|
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnSetSplitButtonVisible(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSession::OnSetSplitButtonVisible(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_LAYOUT, "[NAPI]Argc count 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 isVisible = true;
|
||||||
|
if (!ConvertFromJsValue(env, argv[0], isVisible)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert parameter to bool");
|
||||||
|
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_LAYOUT, "[NAPI]session is nullptr, id:%{public}d", persistentId_);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
session->SetSplitButtonVisible(isVisible);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSession::RequestHideKeyboard(napi_env env, napi_callback_info info)
|
napi_value JsSceneSession::RequestHideKeyboard(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFD("[NAPI]");
|
WLOGFD("[NAPI]");
|
||||||
@ -4137,6 +4262,35 @@ napi_value JsSceneSession::OnSetCompatibleWindowSizeInPc(napi_env env, napi_call
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSession::OnSetCompatibleModeEnableInPad(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[ARG_INDEX_0], enable)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert parameter to portraitWidth");
|
||||||
|
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, id:%{public}d", persistentId_);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
session->SetCompatibleModeEnableInPad(enable);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSession::OnSetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info)
|
napi_value JsSceneSession::OnSetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
size_t argc = ARG_COUNT_4;
|
size_t argc = ARG_COUNT_4;
|
||||||
|
@ -37,6 +37,7 @@ enum class ListenerFuncType : uint32_t {
|
|||||||
SESSION_EVENT_CB,
|
SESSION_EVENT_CB,
|
||||||
SESSION_RECT_CHANGE_CB,
|
SESSION_RECT_CHANGE_CB,
|
||||||
SESSION_PIP_CONTROL_STATUS_CHANGE_CB,
|
SESSION_PIP_CONTROL_STATUS_CHANGE_CB,
|
||||||
|
SESSION_AUTO_START_PIP_CB,
|
||||||
CREATE_SUB_SESSION_CB,
|
CREATE_SUB_SESSION_CB,
|
||||||
BIND_DIALOG_TARGET_CB,
|
BIND_DIALOG_TARGET_CB,
|
||||||
RAISE_TO_TOP_CB,
|
RAISE_TO_TOP_CB,
|
||||||
@ -109,6 +110,7 @@ private:
|
|||||||
static napi_value SetScale(napi_env env, napi_callback_info info);
|
static napi_value SetScale(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetWindowLastSafeRect(napi_env env, napi_callback_info info);
|
static napi_value SetWindowLastSafeRect(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetMovable(napi_env env, napi_callback_info info);
|
static napi_value SetMovable(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value SetSplitButtonVisible(napi_env env, napi_callback_info info);
|
||||||
static napi_value RequestHideKeyboard(napi_env env, napi_callback_info info);
|
static napi_value RequestHideKeyboard(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
static napi_value SetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetOffset(napi_env env, napi_callback_info info);
|
static napi_value SetOffset(napi_env env, napi_callback_info info);
|
||||||
@ -129,6 +131,7 @@ private:
|
|||||||
static napi_value SetCompatibleModeInPc(napi_env env, napi_callback_info info);
|
static napi_value SetCompatibleModeInPc(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetAppSupportPhoneInPc(napi_env env, napi_callback_info info);
|
static napi_value SetAppSupportPhoneInPc(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetCompatibleWindowSizeInPc(napi_env env, napi_callback_info info);
|
static napi_value SetCompatibleWindowSizeInPc(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value SetCompatibleModeEnableInPad(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info);
|
static napi_value SetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info);
|
||||||
static napi_value SetBlankFlag(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);
|
static napi_value SetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info);
|
||||||
@ -161,6 +164,7 @@ private:
|
|||||||
napi_value OnSetScale(napi_env env, napi_callback_info info);
|
napi_value OnSetScale(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetWindowLastSafeRect(napi_env env, napi_callback_info info);
|
napi_value OnSetWindowLastSafeRect(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetMovable(napi_env env, napi_callback_info info);
|
napi_value OnSetMovable(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnSetSplitButtonVisible(napi_env env, napi_callback_info info);
|
||||||
napi_value OnRequestHideKeyboard(napi_env env, napi_callback_info info);
|
napi_value OnRequestHideKeyboard(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
napi_value OnSetSCBKeepKeyboard(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetOffset(napi_env env, napi_callback_info info);
|
napi_value OnSetOffset(napi_env env, napi_callback_info info);
|
||||||
@ -175,6 +179,7 @@ private:
|
|||||||
napi_value OnSetCompatibleModeInPc(napi_env env, napi_callback_info info);
|
napi_value OnSetCompatibleModeInPc(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetAppSupportPhoneInPc(napi_env env, napi_callback_info info);
|
napi_value OnSetAppSupportPhoneInPc(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetCompatibleWindowSizeInPc(napi_env env, napi_callback_info info);
|
napi_value OnSetCompatibleWindowSizeInPc(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnSetCompatibleModeEnableInPad(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info);
|
napi_value OnSetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info);
|
||||||
napi_value OnSetBlankFlag(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);
|
napi_value OnSetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info);
|
||||||
@ -197,6 +202,7 @@ private:
|
|||||||
void ProcessBindDialogTargetRegister();
|
void ProcessBindDialogTargetRegister();
|
||||||
void ProcessSessionRectChangeRegister();
|
void ProcessSessionRectChangeRegister();
|
||||||
void ProcessSessionPiPControlStatusChangeRegister();
|
void ProcessSessionPiPControlStatusChangeRegister();
|
||||||
|
void ProcessAutoStartPiPStatusChangeRegister();
|
||||||
void ProcessRaiseToTopRegister();
|
void ProcessRaiseToTopRegister();
|
||||||
void ProcessRaiseToTopForPointDownRegister();
|
void ProcessRaiseToTopForPointDownRegister();
|
||||||
void ProcessClickModalSpecificWindowOutsideRegister();
|
void ProcessClickModalSpecificWindowOutsideRegister();
|
||||||
@ -243,8 +249,10 @@ private:
|
|||||||
void OnSessionEvent(uint32_t eventId, const SessionEventParam& param);
|
void OnSessionEvent(uint32_t eventId, const SessionEventParam& param);
|
||||||
void OnCreateSubSession(const sptr<SceneSession>& sceneSession);
|
void OnCreateSubSession(const sptr<SceneSession>& sceneSession);
|
||||||
void OnBindDialogTarget(const sptr<SceneSession>& sceneSession);
|
void OnBindDialogTarget(const sptr<SceneSession>& sceneSession);
|
||||||
void OnSessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED);
|
void OnSessionRectChange(const WSRect& rect,
|
||||||
|
const SizeChangeReason reason = SizeChangeReason::UNDEFINED, const DisplayId DisplayId = DISPLAY_ID_INVALID);
|
||||||
void OnSessionPiPControlStatusChange(WsPiPControlType controlType, WsPiPControlStatus status);
|
void OnSessionPiPControlStatusChange(WsPiPControlType controlType, WsPiPControlStatus status);
|
||||||
|
void OnAutoStartPiPStatusChange(bool isAutoStart);
|
||||||
void OnRaiseToTop();
|
void OnRaiseToTop();
|
||||||
void OnRaiseToTopForPointDown();
|
void OnRaiseToTopForPointDown();
|
||||||
void OnClickModalSpecificWindowOutside();
|
void OnClickModalSpecificWindowOutside();
|
||||||
@ -263,13 +271,13 @@ private:
|
|||||||
void OnSystemBarPropertyChange(const std::unordered_map<WindowType, SystemBarProperty>& propertyMap);
|
void OnSystemBarPropertyChange(const std::unordered_map<WindowType, SystemBarProperty>& propertyMap);
|
||||||
void OnNeedAvoid(bool status);
|
void OnNeedAvoid(bool status);
|
||||||
void PendingSessionToForeground(const SessionInfo& info);
|
void PendingSessionToForeground(const SessionInfo& info);
|
||||||
void PendingSessionToBackgroundForDelegator(const SessionInfo& info);
|
void PendingSessionToBackgroundForDelegator(const SessionInfo& info, bool shouldBackToCaller);
|
||||||
void OnDefaultAnimationFlagChange(bool isNeedDefaultAnimationFlag);
|
void OnDefaultAnimationFlagChange(bool isNeedDefaultAnimationFlag);
|
||||||
void OnIsCustomAnimationPlaying(bool status);
|
void OnIsCustomAnimationPlaying(bool status);
|
||||||
void OnShowWhenLocked(bool showWhenLocked);
|
void OnShowWhenLocked(bool showWhenLocked);
|
||||||
void OnReuqestedOrientationChange(uint32_t orientation);
|
void OnReuqestedOrientationChange(uint32_t orientation);
|
||||||
void OnForceHideChange(bool hide);
|
void OnForceHideChange(bool hide);
|
||||||
void OnWindowDragHotArea(uint32_t type, const SizeChangeReason& reason);
|
void OnWindowDragHotArea(uint64_t displayId, uint32_t type, const SizeChangeReason reason);
|
||||||
void OnTouchOutside();
|
void OnTouchOutside();
|
||||||
void OnSessionInfoLockedStateChange(bool lockedState);
|
void OnSessionInfoLockedStateChange(bool lockedState);
|
||||||
void OnPrepareClosePiPSession();
|
void OnPrepareClosePiPSession();
|
||||||
|
@ -63,6 +63,7 @@ const std::string ARG_DUMP_HELP = "-h";
|
|||||||
const std::string SHIFT_FOCUS_CB = "shiftFocus";
|
const std::string SHIFT_FOCUS_CB = "shiftFocus";
|
||||||
const std::string CALLING_WINDOW_ID_CHANGE_CB = "callingWindowIdChange";
|
const std::string CALLING_WINDOW_ID_CHANGE_CB = "callingWindowIdChange";
|
||||||
const std::string CLOSE_TARGET_FLOAT_WINDOW_CB = "closeTargetFloatWindow";
|
const std::string CLOSE_TARGET_FLOAT_WINDOW_CB = "closeTargetFloatWindow";
|
||||||
|
const std::string ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB = "abilityManagerCollaboratorRegistered";
|
||||||
|
|
||||||
const std::map<std::string, ListenerFunctionType> ListenerFunctionTypeMap {
|
const std::map<std::string, ListenerFunctionType> ListenerFunctionTypeMap {
|
||||||
{CREATE_SYSTEM_SESSION_CB, ListenerFunctionType::CREATE_SYSTEM_SESSION_CB},
|
{CREATE_SYSTEM_SESSION_CB, ListenerFunctionType::CREATE_SYSTEM_SESSION_CB},
|
||||||
@ -76,6 +77,7 @@ const std::map<std::string, ListenerFunctionType> ListenerFunctionTypeMap {
|
|||||||
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
{GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
||||||
ListenerFunctionType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB},
|
ListenerFunctionType::GESTURE_NAVIGATION_ENABLED_CHANGE_CB},
|
||||||
{CLOSE_TARGET_FLOAT_WINDOW_CB, ListenerFunctionType::CLOSE_TARGET_FLOAT_WINDOW_CB},
|
{CLOSE_TARGET_FLOAT_WINDOW_CB, ListenerFunctionType::CLOSE_TARGET_FLOAT_WINDOW_CB},
|
||||||
|
{ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB, ListenerFunctionType::ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB},
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -120,6 +122,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
|||||||
BindNativeFunction(env, exportObj, "on", moduleName, JsSceneSessionManager::RegisterCallback);
|
BindNativeFunction(env, exportObj, "on", moduleName, JsSceneSessionManager::RegisterCallback);
|
||||||
BindNativeFunction(env, exportObj, "getWindowSceneConfig", moduleName,
|
BindNativeFunction(env, exportObj, "getWindowSceneConfig", moduleName,
|
||||||
JsSceneSessionManager::GetWindowSceneConfig);
|
JsSceneSessionManager::GetWindowSceneConfig);
|
||||||
|
BindNativeFunction(env, exportObj, "updateRotateAnimationConfig", moduleName,
|
||||||
|
JsSceneSessionManager::UpdateRotateAnimationConfig);
|
||||||
BindNativeFunction(env, exportObj, "processBackEvent", moduleName, JsSceneSessionManager::ProcessBackEvent);
|
BindNativeFunction(env, exportObj, "processBackEvent", moduleName, JsSceneSessionManager::ProcessBackEvent);
|
||||||
BindNativeFunction(env, exportObj, "checkSceneZOrder", moduleName, JsSceneSessionManager::CheckSceneZOrder);
|
BindNativeFunction(env, exportObj, "checkSceneZOrder", moduleName, JsSceneSessionManager::CheckSceneZOrder);
|
||||||
BindNativeFunction(env, exportObj, "updateFocus", moduleName, JsSceneSessionManager::UpdateFocus);
|
BindNativeFunction(env, exportObj, "updateFocus", moduleName, JsSceneSessionManager::UpdateFocus);
|
||||||
@ -195,6 +199,14 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
|||||||
JsSceneSessionManager::UpdateAppHookDisplayInfo);
|
JsSceneSessionManager::UpdateAppHookDisplayInfo);
|
||||||
BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName,
|
BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName,
|
||||||
JsSceneSessionManager::RefreshPcZOrder);
|
JsSceneSessionManager::RefreshPcZOrder);
|
||||||
|
BindNativeFunction(env, exportObj, "getMaxInstanceCount", moduleName,
|
||||||
|
JsSceneSessionManager::GetMaxInstanceCount);
|
||||||
|
BindNativeFunction(env, exportObj, "getInstanceCount", moduleName,
|
||||||
|
JsSceneSessionManager::GetInstanceCount);
|
||||||
|
BindNativeFunction(env, exportObj, "getLastInstanceKey", moduleName,
|
||||||
|
JsSceneSessionManager::GetLastInstanceKey);
|
||||||
|
BindNativeFunction(env, exportObj, "packageRemovedOrChanged", moduleName,
|
||||||
|
JsSceneSessionManager::PackageRemovedOrChanged);
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,15 +353,17 @@ void JsSceneSessionManager::OnStatusBarEnabledUpdate(bool enable, const std::str
|
|||||||
taskScheduler_->PostMainThreadTask(task, "OnStatusBarEnabledUpdate, Enable" + std::to_string(enable));
|
taskScheduler_->PostMainThreadTask(task, "OnStatusBarEnabledUpdate, Enable" + std::to_string(enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName)
|
void JsSceneSessionManager::OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName,
|
||||||
|
GestureBackType type)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::WMS_MAIN, "enable: %{public}d bundleName: %{public}s", enable, bundleName.c_str());
|
TLOGI(WmsLogTag::WMS_MAIN, "enable: %{public}d bundleName: %{public}s", enable, bundleName.c_str());
|
||||||
auto task = [enable, bundleName, jsCallBack = GetJSCallback(GESTURE_NAVIGATION_ENABLED_CHANGE_CB), env = env_] {
|
auto task =
|
||||||
|
[enable, bundleName, type, jsCallBack = GetJSCallback(GESTURE_NAVIGATION_ENABLED_CHANGE_CB), env = env_] {
|
||||||
if (jsCallBack == nullptr) {
|
if (jsCallBack == nullptr) {
|
||||||
WLOGFE("[NAPI]jsCallBack is nullptr");
|
TLOGNE(WmsLogTag::WMS_MAIN, "jsCallBack is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
napi_value argv[] = {CreateJsValue(env, enable), CreateJsValue(env, bundleName)};
|
napi_value argv[] = {CreateJsValue(env, enable), CreateJsValue(env, bundleName), CreateJsValue(env, type)};
|
||||||
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
|
||||||
};
|
};
|
||||||
taskScheduler_->PostMainThreadTask(task, "OnGestureNavigationEnabledUpdate" + std::to_string(enable));
|
taskScheduler_->PostMainThreadTask(task, "OnGestureNavigationEnabledUpdate" + std::to_string(enable));
|
||||||
@ -424,6 +438,20 @@ void JsSceneSessionManager::OnCallingSessionIdChange(uint32_t sessionId)
|
|||||||
taskScheduler_->PostMainThreadTask(task, "OnCallingSessionIdChange, sessionId:" + std::to_string(sessionId));
|
taskScheduler_->PostMainThreadTask(task, "OnCallingSessionIdChange, sessionId:" + std::to_string(sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsSceneSessionManager::OnAbilityManagerCollaboratorRegistered()
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]");
|
||||||
|
const char* const where = __func__;
|
||||||
|
auto task = [jsCallBack = GetJSCallback(ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB), env = env_, where] {
|
||||||
|
if (jsCallBack == nullptr) {
|
||||||
|
TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s: jsCallBack is nullptr", where);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), 0, {}, nullptr);
|
||||||
|
};
|
||||||
|
taskScheduler_->PostMainThreadTask(task, where);
|
||||||
|
}
|
||||||
|
|
||||||
void JsSceneSessionManager::ProcessCreateSystemSessionRegister()
|
void JsSceneSessionManager::ProcessCreateSystemSessionRegister()
|
||||||
{
|
{
|
||||||
NotifyCreateSystemSessionFunc func = [this](const sptr<SceneSession>& session) {
|
NotifyCreateSystemSessionFunc func = [this](const sptr<SceneSession>& session) {
|
||||||
@ -471,9 +499,8 @@ void JsSceneSessionManager::ProcessStatusBarEnabledChangeListener()
|
|||||||
|
|
||||||
void JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener()
|
void JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener()
|
||||||
{
|
{
|
||||||
ProcessGestureNavigationEnabledChangeFunc func = [this](bool enable, const std::string& bundleName) {
|
auto func = [this](bool enable, const std::string& bundleName, GestureBackType type) {
|
||||||
WLOGFD("GestureNavigationEnabledUpdate");
|
this->OnGestureNavigationEnabledUpdate(enable, bundleName, type);
|
||||||
this->OnGestureNavigationEnabledUpdate(enable, bundleName);
|
|
||||||
};
|
};
|
||||||
SceneSessionManager::GetInstance().SetGestureNavigationEnabledChangeListener(func);
|
SceneSessionManager::GetInstance().SetGestureNavigationEnabledChangeListener(func);
|
||||||
}
|
}
|
||||||
@ -525,6 +552,14 @@ void JsSceneSessionManager::ProcessCallingSessionIdChangeRegister()
|
|||||||
SceneSessionManager::GetInstance().SetCallingSessionIdSessionListenser(func);
|
SceneSessionManager::GetInstance().SetCallingSessionIdSessionListenser(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsSceneSessionManager::ProcessAbilityManagerCollaboratorRegistered()
|
||||||
|
{
|
||||||
|
auto func = [this] {
|
||||||
|
this->OnAbilityManagerCollaboratorRegistered();
|
||||||
|
};
|
||||||
|
SceneSessionManager::GetInstance().SetAbilityManagerCollaboratorRegisteredFunc(func);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSessionManager::RegisterCallback(napi_env env, napi_callback_info info)
|
napi_value JsSceneSessionManager::RegisterCallback(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFD("[NAPI]");
|
WLOGFD("[NAPI]");
|
||||||
@ -691,6 +726,13 @@ napi_value JsSceneSessionManager::GetWindowSceneConfig(napi_env env, napi_callba
|
|||||||
return (me != nullptr) ? me->OnGetWindowSceneConfig(env, info) : nullptr;
|
return (me != nullptr) ? me->OnGetWindowSceneConfig(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::UpdateRotateAnimationConfig(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::WMS_SCB, "[NAPI]");
|
||||||
|
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||||
|
return (me != nullptr) ? me->OnUpdateRotateAnimationConfig(env, info) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSessionManager::GetSessionSnapshotFilePath(napi_env env, napi_callback_info info)
|
napi_value JsSceneSessionManager::GetSessionSnapshotFilePath(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
WLOGFI("[NAPI]");
|
WLOGFI("[NAPI]");
|
||||||
@ -950,6 +992,46 @@ napi_value JsSceneSessionManager::IsScbCoreEnabled(napi_env env, napi_callback_i
|
|||||||
return (me != nullptr) ? me->OnIsScbCoreEnabled(env, info) : nullptr;
|
return (me != nullptr) ? me->OnIsScbCoreEnabled(env, info) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::GetMaxInstanceCount(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||||
|
if (me == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return me->OnGetMaxInstanceCount(env, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::GetInstanceCount(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||||
|
if (me == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return me->OnGetInstanceCount(env, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::GetLastInstanceKey(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||||
|
if (me == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return me->OnGetLastInstanceKey(env, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::PackageRemovedOrChanged(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||||
|
if (me == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::WMS_LIFE, "me is null");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return me->OnPackageRemovedOrChanged(env, info);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info)
|
napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
|
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
|
||||||
@ -1059,6 +1141,9 @@ void JsSceneSessionManager::ProcessRegisterCallback(ListenerFunctionType listene
|
|||||||
case ListenerFunctionType::CLOSE_TARGET_FLOAT_WINDOW_CB:
|
case ListenerFunctionType::CLOSE_TARGET_FLOAT_WINDOW_CB:
|
||||||
ProcessCloseTargetFloatWindow();
|
ProcessCloseTargetFloatWindow();
|
||||||
break;
|
break;
|
||||||
|
case ListenerFunctionType::ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB:
|
||||||
|
ProcessAbilityManagerCollaboratorRegistered();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1173,6 +1258,7 @@ static napi_value CreateSCBAbilityInfo(napi_env env, const SCBAbilityInfo& scbAb
|
|||||||
}
|
}
|
||||||
napi_set_named_property(env, objValue, "abilityItemInfo", CreateAbilityItemInfo(env, scbAbilityInfo.abilityInfo_));
|
napi_set_named_property(env, objValue, "abilityItemInfo", CreateAbilityItemInfo(env, scbAbilityInfo.abilityInfo_));
|
||||||
napi_set_named_property(env, objValue, "sdkVersion", CreateJsValue(env, scbAbilityInfo.sdkVersion_));
|
napi_set_named_property(env, objValue, "sdkVersion", CreateJsValue(env, scbAbilityInfo.sdkVersion_));
|
||||||
|
napi_set_named_property(env, objValue, "codePath", CreateJsValue(env, scbAbilityInfo.codePath_));
|
||||||
return objValue;
|
return objValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1961,6 +2047,28 @@ napi_value JsSceneSessionManager::OnGetWindowSceneConfig(napi_env env, napi_call
|
|||||||
return jsWindowSceneConfigObj;
|
return jsWindowSceneConfigObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::OnUpdateRotateAnimationConfig(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);
|
||||||
|
}
|
||||||
|
RotateAnimationConfig rotateAnimationConfig;
|
||||||
|
if (!ConvertRotateAnimationConfigFromJs(env, argv[0], rotateAnimationConfig)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert parameter to rotateAnimationConfig.");
|
||||||
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||||
|
"Input parameter is invalid."));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
SceneSessionManager::GetInstance().UpdateRotateAnimationConfig(rotateAnimationConfig);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
napi_value JsSceneSessionManager::OnGetSessionSnapshotFilePath(napi_env env, napi_callback_info info)
|
napi_value JsSceneSessionManager::OnGetSessionSnapshotFilePath(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
@ -2049,11 +2157,6 @@ static napi_value CreateJsWindowVisibilityInfoArray(napi_env env,
|
|||||||
napi_value JsSceneSessionManager::OnGetAllWindowVisibilityInfos(napi_env env, napi_callback_info info)
|
napi_value JsSceneSessionManager::OnGetAllWindowVisibilityInfos(napi_env env, napi_callback_info info)
|
||||||
{
|
{
|
||||||
auto windowVisibilityInfos = std::make_shared<std::vector<std::pair<int32_t, uint32_t>>>();
|
auto windowVisibilityInfos = std::make_shared<std::vector<std::pair<int32_t, uint32_t>>>();
|
||||||
if (windowVisibilityInfos == nullptr) {
|
|
||||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_STATE_ABNORMALLY),
|
|
||||||
"failed to create window visiblity infos"));
|
|
||||||
return NapiGetUndefined(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto execute = [infos = windowVisibilityInfos]() {
|
auto execute = [infos = windowVisibilityInfos]() {
|
||||||
SceneSessionManager::GetInstance().GetAllWindowVisibilityInfos(*infos);
|
SceneSessionManager::GetInstance().GetAllWindowVisibilityInfos(*infos);
|
||||||
@ -2200,29 +2303,35 @@ napi_value JsSceneSessionManager::OnAddWindowDragHotArea(napi_env env, napi_call
|
|||||||
size_t argc = 4;
|
size_t argc = 4;
|
||||||
napi_value argv[4] = {nullptr};
|
napi_value argv[4] = {nullptr};
|
||||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||||
if (argc < ARGC_TWO) {
|
if (argc < ARGC_THREE) {
|
||||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc);
|
||||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||||
"Input parameter is missing or invalid"));
|
"Input parameter is missing or invalid"));
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
int64_t displayId;
|
||||||
|
if (!ConvertFromJsValue(env, argv[0], displayId)) {
|
||||||
|
WLOGFE("[NAPI]Failed to convert parameter to displayId");
|
||||||
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||||
|
"Input parameter is missing or invalid"));
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
if (!ConvertFromJsValue(env, argv[0], type)) {
|
if (!ConvertFromJsValue(env, argv[ARG_INDEX_ONE], type)) {
|
||||||
WLOGFE("[NAPI]Failed to convert parameter to type");
|
WLOGFE("[NAPI]Failed to convert parameter to type");
|
||||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||||
"Input parameter is missing or invalid"));
|
"Input parameter is missing or invalid"));
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
WSRect area;
|
WSRect area;
|
||||||
napi_value nativeObj = argv[1];
|
if (argv[ARG_INDEX_TWO] == nullptr || !ConvertRectInfoFromJs(env, argv[ARG_INDEX_TWO], area)) {
|
||||||
if (nativeObj == nullptr || !ConvertRectInfoFromJs(env, nativeObj, area)) {
|
|
||||||
WLOGFE("[NAPI]Failed to convert parameter to area");
|
WLOGFE("[NAPI]Failed to convert parameter to area");
|
||||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||||
"Input parameter is missing or invalid"));
|
"Input parameter is missing or invalid"));
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneSessionManager::GetInstance().AddWindowDragHotArea(type, area);
|
SceneSessionManager::GetInstance().AddWindowDragHotArea(displayId, type, area);
|
||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2802,9 +2911,10 @@ napi_value JsSceneSessionManager::OnGetSessionSnapshotPixelMap(napi_env env, nap
|
|||||||
};
|
};
|
||||||
NapiAsyncTask::CompleteCallback complete =
|
NapiAsyncTask::CompleteCallback complete =
|
||||||
[persistentId, scaleParam, pixelPtr](napi_env env, NapiAsyncTask& task, int32_t status) {
|
[persistentId, scaleParam, pixelPtr](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||||
if (!pixelPtr) {
|
if (pixelPtr == nullptr) {
|
||||||
WLOGE("[NAPI] pixelMap ptr not exist");
|
WLOGE("[NAPI] pixelMap ptr not exist");
|
||||||
task.Reject(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
task.Reject(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
napi_value nativeData = nullptr;
|
napi_value nativeData = nullptr;
|
||||||
if (*pixelPtr) {
|
if (*pixelPtr) {
|
||||||
@ -3119,6 +3229,98 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_
|
|||||||
return NapiGetUndefined(env);
|
return NapiGetUndefined(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::OnGetMaxInstanceCount(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_ONE) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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);
|
||||||
|
}
|
||||||
|
napi_value result = nullptr;
|
||||||
|
napi_create_uint32(env, SceneSessionManager::GetInstance().GetMaxInstanceCount(bundleName), &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::OnGetInstanceCount(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_ONE) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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);
|
||||||
|
}
|
||||||
|
napi_value result = nullptr;
|
||||||
|
napi_create_uint32(env, SceneSessionManager::GetInstance().GetInstanceCount(bundleName), &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::OnGetLastInstanceKey(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_ONE) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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);
|
||||||
|
}
|
||||||
|
std::string instanceKey = SceneSessionManager::GetInstance().GetLastInstanceKey(bundleName);
|
||||||
|
napi_value result = nullptr;
|
||||||
|
napi_create_string_utf8(env, instanceKey.c_str(), instanceKey.length(), &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
napi_value JsSceneSessionManager::OnPackageRemovedOrChanged(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_ONE) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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)) {
|
||||||
|
TLOGE(WmsLogTag::WMS_LIFE, "[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);
|
||||||
|
}
|
||||||
|
SceneSessionManager::GetInstance().PackageRemovedOrChanged(bundleName);
|
||||||
|
return NapiGetUndefined(env);
|
||||||
|
}
|
||||||
|
|
||||||
void JsSceneSessionManager::OnCloseTargetFloatWindow(const std::string& bundleName)
|
void JsSceneSessionManager::OnCloseTargetFloatWindow(const std::string& bundleName)
|
||||||
{
|
{
|
||||||
TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]in");
|
TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]in");
|
||||||
|
@ -40,6 +40,7 @@ enum class ListenerFunctionType : uint32_t {
|
|||||||
START_UI_ABILITY_ERROR,
|
START_UI_ABILITY_ERROR,
|
||||||
GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
GESTURE_NAVIGATION_ENABLED_CHANGE_CB,
|
||||||
CLOSE_TARGET_FLOAT_WINDOW_CB,
|
CLOSE_TARGET_FLOAT_WINDOW_CB,
|
||||||
|
ABILITY_MANAGER_COLLABORATOR_REGISTERED_CB,
|
||||||
};
|
};
|
||||||
|
|
||||||
class JsSceneSessionManager final {
|
class JsSceneSessionManager final {
|
||||||
@ -64,6 +65,7 @@ public:
|
|||||||
static napi_value ChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info);
|
static napi_value ChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info);
|
||||||
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
||||||
static napi_value GetWindowSceneConfig(napi_env env, napi_callback_info info);
|
static napi_value GetWindowSceneConfig(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value UpdateRotateAnimationConfig(napi_env env, napi_callback_info info);
|
||||||
static napi_value ProcessBackEvent(napi_env env, napi_callback_info info);
|
static napi_value ProcessBackEvent(napi_env env, napi_callback_info info);
|
||||||
static napi_value CheckSceneZOrder(napi_env env, napi_callback_info info);
|
static napi_value CheckSceneZOrder(napi_env env, napi_callback_info info);
|
||||||
static napi_value UpdateFocus(napi_env env, napi_callback_info info);
|
static napi_value UpdateFocus(napi_env env, napi_callback_info info);
|
||||||
@ -110,6 +112,14 @@ public:
|
|||||||
static napi_value IsScbCoreEnabled(napi_env env, napi_callback_info info);
|
static napi_value IsScbCoreEnabled(napi_env env, napi_callback_info info);
|
||||||
static napi_value RefreshPcZOrder(napi_env env, napi_callback_info info);
|
static napi_value RefreshPcZOrder(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Multi instance
|
||||||
|
*/
|
||||||
|
static napi_value GetMaxInstanceCount(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value GetInstanceCount(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value GetLastInstanceKey(napi_env env, napi_callback_info info);
|
||||||
|
static napi_value PackageRemovedOrChanged(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
|
||||||
napi_value OnGetRootSceneSession(napi_env env, napi_callback_info info);
|
napi_value OnGetRootSceneSession(napi_env env, napi_callback_info info);
|
||||||
@ -125,6 +135,7 @@ private:
|
|||||||
napi_value OnStartUIAbilityBySCB(napi_env env, napi_callback_info info);
|
napi_value OnStartUIAbilityBySCB(napi_env env, napi_callback_info info);
|
||||||
napi_value OnChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info);
|
napi_value OnChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info);
|
||||||
napi_value OnGetWindowSceneConfig(napi_env env, napi_callback_info info);
|
napi_value OnGetWindowSceneConfig(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnUpdateRotateAnimationConfig(napi_env env, napi_callback_info info);
|
||||||
napi_value OnProcessBackEvent(napi_env env, napi_callback_info info);
|
napi_value OnProcessBackEvent(napi_env env, napi_callback_info info);
|
||||||
napi_value OnCheckSceneZOrder(napi_env env, napi_callback_info info);
|
napi_value OnCheckSceneZOrder(napi_env env, napi_callback_info info);
|
||||||
napi_value OnUpdateFocus(napi_env env, napi_callback_info info);
|
napi_value OnUpdateFocus(napi_env env, napi_callback_info info);
|
||||||
@ -171,9 +182,17 @@ private:
|
|||||||
napi_value OnIsScbCoreEnabled(napi_env env, napi_callback_info info);
|
napi_value OnIsScbCoreEnabled(napi_env env, napi_callback_info info);
|
||||||
napi_value OnRefreshPcZOrder(napi_env env, napi_callback_info info);
|
napi_value OnRefreshPcZOrder(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* multi instance
|
||||||
|
*/
|
||||||
|
napi_value OnGetMaxInstanceCount(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnGetInstanceCount(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnGetLastInstanceKey(napi_env env, napi_callback_info info);
|
||||||
|
napi_value OnPackageRemovedOrChanged(napi_env env, napi_callback_info info);
|
||||||
|
|
||||||
void OnRootSceneBackEvent();
|
void OnRootSceneBackEvent();
|
||||||
void OnStatusBarEnabledUpdate(bool enable, const std::string& bundleName);
|
void OnStatusBarEnabledUpdate(bool enable, const std::string& bundleName);
|
||||||
void OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName);
|
void OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName, GestureBackType type);
|
||||||
void OnCreateSystemSession(const sptr<SceneSession>& sceneSession);
|
void OnCreateSystemSession(const sptr<SceneSession>& sceneSession);
|
||||||
void OnCreateKeyboardSession(const sptr<SceneSession>& keyboardSession, const sptr<SceneSession>& panelSession);
|
void OnCreateKeyboardSession(const sptr<SceneSession>& keyboardSession, const sptr<SceneSession>& panelSession);
|
||||||
void OnRecoverSceneSession(const sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo);
|
void OnRecoverSceneSession(const sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo);
|
||||||
@ -198,6 +217,8 @@ private:
|
|||||||
void OnCloseTargetFloatWindow(const std::string& bundleName);
|
void OnCloseTargetFloatWindow(const std::string& bundleName);
|
||||||
void ProcessCloseTargetFloatWindow();
|
void ProcessCloseTargetFloatWindow();
|
||||||
std::shared_ptr<NativeReference> GetJSCallback(const std::string& functionName);
|
std::shared_ptr<NativeReference> GetJSCallback(const std::string& functionName);
|
||||||
|
void ProcessAbilityManagerCollaboratorRegistered();
|
||||||
|
void OnAbilityManagerCollaboratorRegistered();
|
||||||
|
|
||||||
napi_env env_;
|
napi_env env_;
|
||||||
std::shared_mutex jsCbMapMutex_;
|
std::shared_mutex jsCbMapMutex_;
|
||||||
|
@ -71,6 +71,17 @@ napi_valuetype GetType(napi_env env, napi_value value)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WSError GetIntValueFromString(const std::string& str, uint32_t& value)
|
||||||
|
{
|
||||||
|
char* end;
|
||||||
|
value = strtoul(str.c_str(), &end, 10); // 10 number convert base
|
||||||
|
if (*end == '\0' && value != 0) {
|
||||||
|
return WSError::WS_OK;
|
||||||
|
}
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "param %{public}s convert int failed", str.c_str());
|
||||||
|
return WSError::WS_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsJsBundleNameUndefind(napi_env env, napi_value jsBundleName, SessionInfo& sessionInfo)
|
bool IsJsBundleNameUndefind(napi_env env, napi_value jsBundleName, SessionInfo& sessionInfo)
|
||||||
{
|
{
|
||||||
if (GetType(env, jsBundleName) != napi_undefined) {
|
if (GetType(env, jsBundleName) != napi_undefined) {
|
||||||
@ -287,6 +298,32 @@ bool IsJsFullScreenStartUndefined(napi_env env, napi_value jsFullscreenStart, Se
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsJsIsNewAppInstanceUndefined(napi_env env, napi_value jsIsNewAppInstance, SessionInfo& sessionInfo)
|
||||||
|
{
|
||||||
|
if (GetType(env, jsIsNewAppInstance) != napi_undefined) {
|
||||||
|
bool isNewAppInstance = false;
|
||||||
|
if (!ConvertFromJsValue(env, jsIsNewAppInstance, isNewAppInstance)) {
|
||||||
|
TLOGI(WmsLogTag::WMS_LIFE, "Failed to convert parameter to isNewAppInstance");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sessionInfo.isNewAppInstance_ = isNewAppInstance;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsJsInstanceKeyUndefined(napi_env env, napi_value jsInstanceKey, SessionInfo& sessionInfo)
|
||||||
|
{
|
||||||
|
if (GetType(env, jsInstanceKey) != napi_undefined) {
|
||||||
|
std::string instanceKey;
|
||||||
|
if (!ConvertFromJsValue(env, jsInstanceKey, instanceKey)) {
|
||||||
|
TLOGI(WmsLogTag::WMS_LIFE, "Failed to convert parameter to instanceKey");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sessionInfo.appInstanceKey_ = instanceKey;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ConvertSessionInfoName(napi_env env, napi_value jsObject, SessionInfo& sessionInfo)
|
bool ConvertSessionInfoName(napi_env env, napi_value jsObject, SessionInfo& sessionInfo)
|
||||||
{
|
{
|
||||||
napi_value jsBundleName = nullptr;
|
napi_value jsBundleName = nullptr;
|
||||||
@ -305,6 +342,10 @@ bool ConvertSessionInfoName(napi_env env, napi_value jsObject, SessionInfo& sess
|
|||||||
napi_get_named_property(env, jsObject, "windowInputType", &jsWindowInputType);
|
napi_get_named_property(env, jsObject, "windowInputType", &jsWindowInputType);
|
||||||
napi_value jsFullScreenStart = nullptr;
|
napi_value jsFullScreenStart = nullptr;
|
||||||
napi_get_named_property(env, jsObject, "fullScreenStart", &jsFullScreenStart);
|
napi_get_named_property(env, jsObject, "fullScreenStart", &jsFullScreenStart);
|
||||||
|
napi_value jsIsNewAppInstance = nullptr;
|
||||||
|
napi_get_named_property(env, jsObject, "isNewAppInstance", &jsIsNewAppInstance);
|
||||||
|
napi_value jsInstanceKey = nullptr;
|
||||||
|
napi_get_named_property(env, jsObject, "instanceKey", &jsInstanceKey);
|
||||||
if (!IsJsBundleNameUndefind(env, jsBundleName, sessionInfo)) {
|
if (!IsJsBundleNameUndefind(env, jsBundleName, sessionInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -326,7 +367,9 @@ bool ConvertSessionInfoName(napi_env env, napi_value jsObject, SessionInfo& sess
|
|||||||
if (!IsJsWindowInputTypeUndefind(env, jsWindowInputType, sessionInfo)) {
|
if (!IsJsWindowInputTypeUndefind(env, jsWindowInputType, sessionInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!IsJsFullScreenStartUndefined(env, jsFullScreenStart, sessionInfo)) {
|
if (!IsJsFullScreenStartUndefined(env, jsFullScreenStart, sessionInfo) ||
|
||||||
|
!IsJsIsNewAppInstanceUndefined(env, jsIsNewAppInstance, sessionInfo) ||
|
||||||
|
!IsJsInstanceKeyUndefined(env, jsInstanceKey, sessionInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -793,6 +836,21 @@ bool ConvertJsonFromJs(napi_env env, napi_value value, nlohmann::json& payload)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConvertRotateAnimationConfigFromJs(napi_env env, napi_value value, RotateAnimationConfig& config)
|
||||||
|
{
|
||||||
|
napi_value jsDuration = nullptr;
|
||||||
|
napi_get_named_property(env, value, "duration", &jsDuration);
|
||||||
|
if (GetType(env, jsDuration) != napi_undefined) {
|
||||||
|
int32_t duration = ROTATE_ANIMATION_DURATION;
|
||||||
|
if (!ConvertFromJsValue(env, jsDuration, duration)) {
|
||||||
|
TLOGE(WmsLogTag::DEFAULT, "Failed to convert parameter to duration");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
config.duration_ = duration;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ParseArrayStringValue(napi_env env, napi_value array, std::vector<std::string>& vector)
|
bool ParseArrayStringValue(napi_env env, napi_value array, std::vector<std::string>& vector)
|
||||||
{
|
{
|
||||||
if (array == nullptr) {
|
if (array == nullptr) {
|
||||||
@ -873,6 +931,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo)
|
|||||||
CreateJsValue(env, sessionInfo.isAtomicService_));
|
CreateJsValue(env, sessionInfo.isAtomicService_));
|
||||||
napi_set_named_property(env, objValue, "isBackTransition",
|
napi_set_named_property(env, objValue, "isBackTransition",
|
||||||
CreateJsValue(env, sessionInfo.isBackTransition_));
|
CreateJsValue(env, sessionInfo.isBackTransition_));
|
||||||
|
napi_set_named_property(env, objValue, "needClearInNotShowRecent",
|
||||||
|
CreateJsValue(env, sessionInfo.needClearInNotShowRecent_));
|
||||||
if (sessionInfo.processOptions != nullptr) {
|
if (sessionInfo.processOptions != nullptr) {
|
||||||
napi_set_named_property(env, objValue, "processOptions",
|
napi_set_named_property(env, objValue, "processOptions",
|
||||||
CreateJsProcessOption(env, sessionInfo.processOptions));
|
CreateJsProcessOption(env, sessionInfo.processOptions));
|
||||||
|
@ -182,6 +182,8 @@ napi_valuetype GetType(napi_env env, napi_value value);
|
|||||||
bool NapiIsCallable(napi_env env, napi_value value);
|
bool NapiIsCallable(napi_env env, napi_value value);
|
||||||
bool ConvertRectInfoFromJs(napi_env env, napi_value jsObject, WSRect& rect);
|
bool ConvertRectInfoFromJs(napi_env env, napi_value jsObject, WSRect& rect);
|
||||||
bool ConvertHookInfoFromJs(napi_env env, napi_value jsObject, HookInfo& hookInfo);
|
bool ConvertHookInfoFromJs(napi_env env, napi_value jsObject, HookInfo& hookInfo);
|
||||||
|
bool ConvertRotateAnimationConfigFromJs(napi_env env, napi_value value, RotateAnimationConfig& config);
|
||||||
|
WSError GetIntValueFromString(const std::string& str, uint32_t& value);
|
||||||
constexpr size_t ARGC_ONE = 1;
|
constexpr size_t ARGC_ONE = 1;
|
||||||
constexpr size_t ARGC_TWO = 2;
|
constexpr size_t ARGC_TWO = 2;
|
||||||
constexpr size_t ARGC_THREE = 3;
|
constexpr size_t ARGC_THREE = 3;
|
||||||
|
@ -37,6 +37,7 @@ const std::string ON_SCREEN_ORIENTATION_CHANGE_CALLBACK = "screenOrientationChan
|
|||||||
const std::string ON_SCREEN_ROTATION_LOCKED_CHANGE = "screenRotationLockedChange";
|
const std::string ON_SCREEN_ROTATION_LOCKED_CHANGE = "screenRotationLockedChange";
|
||||||
const std::string ON_SCREEN_DENSITY_CHANGE = "screenDensityChange";
|
const std::string ON_SCREEN_DENSITY_CHANGE = "screenDensityChange";
|
||||||
const std::string ON_SCREEN_EXTEND_CHANGE = "screenExtendChange";
|
const std::string ON_SCREEN_EXTEND_CHANGE = "screenExtendChange";
|
||||||
|
const std::string ON_HOVER_STATUS_CHANGE_CALLBACK = "hoverStatusChange";
|
||||||
constexpr size_t ARGC_ONE = 1;
|
constexpr size_t ARGC_ONE = 1;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -647,4 +648,44 @@ void JsScreenSession::OnScreenExtendChange(ScreenId mainScreenId, ScreenId exten
|
|||||||
WLOGFE("OnScreenExtendChange: env is nullptr");
|
WLOGFE("OnScreenExtendChange: env is nullptr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsScreenSession::OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId)
|
||||||
|
{
|
||||||
|
const std::string callbackType = ON_HOVER_STATUS_CHANGE_CALLBACK;
|
||||||
|
WLOGI("Call js callback: %{public}s.", callbackType.c_str());
|
||||||
|
if (mCallback_.count(callbackType) == 0) {
|
||||||
|
WLOGFE("Callback %{public}s is unregistered!", callbackType.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto jsCallbackRef = mCallback_[callbackType];
|
||||||
|
wptr<ScreenSession> screenSessionWeak(screenSession_);
|
||||||
|
auto napiTask = [jsCallbackRef, callbackType, screenSessionWeak, hoverStatus, env = env_]() {
|
||||||
|
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnHoverStatusChange");
|
||||||
|
if (jsCallbackRef == nullptr) {
|
||||||
|
WLOGFE("Call js callback %{public}s failed, jsCallbackRef is null!", callbackType.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto method = jsCallbackRef->GetNapiValue();
|
||||||
|
if (method == nullptr) {
|
||||||
|
WLOGFE("Call js callback %{public}s failed, method is null!", callbackType.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto screenSession = screenSessionWeak.promote();
|
||||||
|
if (screenSession == nullptr) {
|
||||||
|
WLOGFE("Call js callback %{public}s failed, screenSession is null!", callbackType.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
napi_value argv[] = { CreateJsValue(env, hoverStatus) };
|
||||||
|
napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr);
|
||||||
|
};
|
||||||
|
if (env_ != nullptr) {
|
||||||
|
napi_status ret = napi_send_event(env_, napiTask, napi_eprio_immediate);
|
||||||
|
if (ret != napi_status::napi_ok) {
|
||||||
|
WLOGFE("OnHoverStatusChange: Failed to SendEvent.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WLOGFE("OnHoverStatusChange: env is nullptr");
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
|
@ -57,6 +57,7 @@ private:
|
|||||||
void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override;
|
void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override;
|
||||||
void OnScreenDensityChange();
|
void OnScreenDensityChange();
|
||||||
void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
||||||
|
void OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId) override;
|
||||||
|
|
||||||
napi_env env_;
|
napi_env env_;
|
||||||
sptr<ScreenSession> screenSession_;
|
sptr<ScreenSession> screenSession_;
|
||||||
|
@ -84,6 +84,7 @@ ohos_shared_library("screen_session_manager") {
|
|||||||
"src/screen_session_dumper.cpp",
|
"src/screen_session_dumper.cpp",
|
||||||
"src/screen_session_manager.cpp",
|
"src/screen_session_manager.cpp",
|
||||||
"src/screen_setting_helper.cpp",
|
"src/screen_setting_helper.cpp",
|
||||||
|
"src/screen_tent_property.cpp",
|
||||||
"src/session_display_power_controller.cpp",
|
"src/session_display_power_controller.cpp",
|
||||||
"src/setting_observer.cpp",
|
"src/setting_observer.cpp",
|
||||||
"src/setting_provider.cpp",
|
"src/setting_provider.cpp",
|
||||||
@ -170,6 +171,10 @@ ohos_shared_library("screen_session_manager") {
|
|||||||
defines += [ "DEVICE_STATUS_ENABLE" ]
|
defines += [ "DEVICE_STATUS_ENABLE" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (build_variant == "user") {
|
||||||
|
defines += [ "IS_RELEASE_VERSION" ]
|
||||||
|
}
|
||||||
|
|
||||||
innerapi_tags = [ "platformsdk" ]
|
innerapi_tags = [ "platformsdk" ]
|
||||||
part_name = "window_manager"
|
part_name = "window_manager"
|
||||||
subsystem_name = "window"
|
subsystem_name = "window"
|
||||||
|
@ -47,6 +47,8 @@ private:
|
|||||||
FoldDisplayMode GetModeMatchStatus();
|
FoldDisplayMode GetModeMatchStatus();
|
||||||
void ReportFoldDisplayModeChange(FoldDisplayMode displayMode);
|
void ReportFoldDisplayModeChange(FoldDisplayMode displayMode);
|
||||||
void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen);
|
void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen);
|
||||||
|
void SetdisplayModeChangeStatus(bool status) override;
|
||||||
|
ScreenId GetScreenIdByDisplayMode(FoldDisplayMode displayMode);
|
||||||
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
||||||
};
|
};
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
|
@ -37,11 +37,14 @@ public:
|
|||||||
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler);
|
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler);
|
||||||
virtual ~FoldScreenController();
|
virtual ~FoldScreenController();
|
||||||
|
|
||||||
|
void BootAnimationFinishPowerInit();
|
||||||
void SetDisplayMode(const FoldDisplayMode displayMode);
|
void SetDisplayMode(const FoldDisplayMode displayMode);
|
||||||
FoldDisplayMode GetDisplayMode();
|
FoldDisplayMode GetDisplayMode();
|
||||||
bool IsFoldable();
|
bool IsFoldable();
|
||||||
FoldStatus GetFoldStatus();
|
FoldStatus GetFoldStatus();
|
||||||
|
bool GetTentMode();
|
||||||
void SetFoldStatus(FoldStatus foldStatus);
|
void SetFoldStatus(FoldStatus foldStatus);
|
||||||
|
void OnTentModeChanged(bool isTentMode);
|
||||||
sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
|
sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
|
||||||
ScreenId GetCurrentScreenId();
|
ScreenId GetCurrentScreenId();
|
||||||
void LockDisplayStatus(bool locked);
|
void LockDisplayStatus(bool locked);
|
||||||
|
@ -38,6 +38,9 @@ public:
|
|||||||
virtual void UpdateForPhyScreenPropertyChange();
|
virtual void UpdateForPhyScreenPropertyChange();
|
||||||
virtual void ExitCoordination();
|
virtual void ExitCoordination();
|
||||||
virtual void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command);
|
virtual void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command);
|
||||||
|
virtual void BootAnimationFinishPowerInit() {};
|
||||||
|
virtual void ChangeOnTentMode(FoldStatus currentState);
|
||||||
|
virtual void ChangeOffTentMode();
|
||||||
void ClearState();
|
void ClearState();
|
||||||
FoldDisplayMode GetScreenDisplayMode();
|
FoldDisplayMode GetScreenDisplayMode();
|
||||||
FoldStatus GetFoldStatus();
|
FoldStatus GetFoldStatus();
|
||||||
|
@ -81,6 +81,8 @@ private:
|
|||||||
|
|
||||||
uint16_t globalHall = USHRT_MAX;
|
uint16_t globalHall = USHRT_MAX;
|
||||||
|
|
||||||
|
bool registerPosture_ = false;
|
||||||
|
|
||||||
typedef struct EXTHALLData {
|
typedef struct EXTHALLData {
|
||||||
float flag = 0.0;
|
float flag = 0.0;
|
||||||
float hall = 0.0;
|
float hall = 0.0;
|
||||||
|
@ -60,9 +60,6 @@ private:
|
|||||||
sptr<ApplicationStateObserver> applicationStateObserver_;
|
sptr<ApplicationStateObserver> applicationStateObserver_;
|
||||||
bool isHallSwitchApp_ = true;
|
bool isHallSwitchApp_ = true;
|
||||||
std::vector<std::string> packageNames_;
|
std::vector<std::string> packageNames_;
|
||||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds> mLastHallReportTime_ =
|
|
||||||
std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
|
|
||||||
std::mutex hallMutex_;
|
|
||||||
};
|
};
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -31,17 +31,21 @@ public:
|
|||||||
|
|
||||||
virtual void HandleAngleChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
|
virtual void HandleAngleChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
virtual void HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
|
virtual void HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
|
virtual void HandleTentChange(bool isTentMode, sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
virtual void RegisterApplicationStateObserver();
|
virtual void RegisterApplicationStateObserver();
|
||||||
void ClearState(sptr<FoldScreenPolicy> foldScreenPolicy);
|
void ClearState(sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
|
bool IsTentMode();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void HandleSensorChange(FoldStatus nextState, float angle, sptr<FoldScreenPolicy> foldScreenPolicy);
|
void HandleSensorChange(FoldStatus nextState, float angle, sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
FoldStatus GetCurrentState();
|
FoldStatus GetCurrentState();
|
||||||
|
void SetTentMode(bool status);
|
||||||
std::recursive_mutex mutex_;
|
std::recursive_mutex mutex_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReportNotifyFoldStatusChange(int32_t currentStatus, int32_t nextStatus, float postureAngle);
|
void ReportNotifyFoldStatusChange(int32_t currentStatus, int32_t nextStatus, float postureAngle);
|
||||||
FoldStatus mState_ = FoldStatus::UNKNOWN;
|
FoldStatus mState_ = FoldStatus::UNKNOWN;
|
||||||
|
bool isTentMode_ = false;
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> mLastStateClock_ = std::chrono::system_clock::now();
|
std::chrono::time_point<std::chrono::system_clock> mLastStateClock_ = std::chrono::system_clock::now();
|
||||||
void NotifyReportFoldStatusToScb(FoldStatus currentStatus, FoldStatus nextStatus, float postureAngle);
|
void NotifyReportFoldStatusToScb(FoldStatus currentStatus, FoldStatus nextStatus, float postureAngle);
|
||||||
|
@ -29,12 +29,15 @@ public:
|
|||||||
|
|
||||||
void HandleAngleChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override;
|
void HandleAngleChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override;
|
||||||
void HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override;
|
void HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override;
|
||||||
|
void HandleTentChange(bool isTent, sptr<FoldScreenPolicy> foldScreenPolicy) override;
|
||||||
void RegisterApplicationStateObserver() override;
|
void RegisterApplicationStateObserver() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FoldStatus GetNextFoldState(float angle, int hall);
|
FoldStatus GetNextFoldState(float angle, int hall);
|
||||||
void UpdateSwitchScreenBoundaryForLargeFoldDevice(float, int);
|
void UpdateSwitchScreenBoundaryForLargeFoldDevice(float, int);
|
||||||
int allowUserSensorForLargeFoldDevice = 0;
|
int allowUserSensorForLargeFoldDevice = 0;
|
||||||
|
bool TriggerTentExit(float angle, int hall);
|
||||||
|
void TentModeHandleSensorChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
|
||||||
};
|
};
|
||||||
} // namespace Rosen
|
} // namespace Rosen
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -34,11 +34,16 @@ public:
|
|||||||
void LockDisplayStatus(bool locked) override;
|
void LockDisplayStatus(bool locked) override;
|
||||||
void SetOnBootAnimation(bool onBootAnimation) override;
|
void SetOnBootAnimation(bool onBootAnimation) override;
|
||||||
void UpdateForPhyScreenPropertyChange() override;
|
void UpdateForPhyScreenPropertyChange() override;
|
||||||
void ExitCoordination() override {};
|
void ExitCoordination() override;
|
||||||
void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override {};
|
void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override;
|
||||||
|
void BootAnimationFinishPowerInit() override;
|
||||||
private:
|
private:
|
||||||
void ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession);
|
void ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession);
|
||||||
void ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession);
|
void ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession);
|
||||||
|
void ChangeScreenDisplayModeToCoordination();
|
||||||
|
void ChangeScreenDisplayModeProc(sptr<ScreenSession> screenSession, FoldDisplayMode displayMode);
|
||||||
|
void ChangeScreenDisplayModeToMainWhenFoldScreenOn(sptr<ScreenSession> screenSession);
|
||||||
|
void ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession);
|
||||||
void ChangeScreenDisplayModeToMainOnBootAnimation(sptr<ScreenSession> screenSession);
|
void ChangeScreenDisplayModeToMainOnBootAnimation(sptr<ScreenSession> screenSession);
|
||||||
void ChangeScreenDisplayModeToFullOnBootAnimation(sptr<ScreenSession> screenSession);
|
void ChangeScreenDisplayModeToFullOnBootAnimation(sptr<ScreenSession> screenSession);
|
||||||
void ChangeScreenDisplayModePower(ScreenId screenId, ScreenPowerStatus screenPowerStatus);
|
void ChangeScreenDisplayModePower(ScreenId screenId, ScreenPowerStatus screenPowerStatus);
|
||||||
@ -49,6 +54,9 @@ private:
|
|||||||
void SendPropertyChangeResult(sptr<ScreenSession> screenSession, ScreenId screenId,
|
void SendPropertyChangeResult(sptr<ScreenSession> screenSession, ScreenId screenId,
|
||||||
ScreenPropertyChangeReason reason);
|
ScreenPropertyChangeReason reason);
|
||||||
void SetdisplayModeChangeStatus(bool status) override;
|
void SetdisplayModeChangeStatus(bool status) override;
|
||||||
|
void ChangeOnTentMode(FoldStatus currentState) override;
|
||||||
|
void ChangeOffTentMode() override;
|
||||||
|
void CloseCoordinationScreen();
|
||||||
std::recursive_mutex& displayInfoMutex_;
|
std::recursive_mutex& displayInfoMutex_;
|
||||||
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
||||||
};
|
};
|
||||||
|
@ -36,11 +36,20 @@ enum class DeviceRotation: int32_t {
|
|||||||
ROTATION_LANDSCAPE_INVERTED,
|
ROTATION_LANDSCAPE_INVERTED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class DeviceHoverStatus: int32_t {
|
||||||
|
INVALID = -1,
|
||||||
|
TENT_STATUS = 0,
|
||||||
|
TENT_STATUS_CANCEL,
|
||||||
|
CAMERA_STATUS,
|
||||||
|
CAMERA_STATUS_CANCEL,
|
||||||
|
};
|
||||||
|
|
||||||
class ScreenRotationProperty : public RefBase {
|
class ScreenRotationProperty : public RefBase {
|
||||||
public:
|
public:
|
||||||
ScreenRotationProperty() = delete;
|
ScreenRotationProperty() = delete;
|
||||||
~ScreenRotationProperty() = default;
|
~ScreenRotationProperty() = default;
|
||||||
static void HandleSensorEventInput(DeviceRotation deviceRotation);
|
static void HandleSensorEventInput(DeviceRotation deviceRotation);
|
||||||
|
static void HandleHoverStatusEventInput(DeviceHoverStatus hoverStatus);
|
||||||
private:
|
private:
|
||||||
static float ConvertDeviceToFloat(DeviceRotation deviceRotation);
|
static float ConvertDeviceToFloat(DeviceRotation deviceRotation);
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "motion_callback_stub.h"
|
#include "motion_callback_stub.h"
|
||||||
#endif
|
#endif
|
||||||
#include "screen_rotation_property.h"
|
#include "screen_rotation_property.h"
|
||||||
|
#include "screen_tent_property.h"
|
||||||
#ifdef SENSOR_ENABLE
|
#ifdef SENSOR_ENABLE
|
||||||
#include "sensor_agent.h"
|
#include "sensor_agent.h"
|
||||||
#endif
|
#endif
|
||||||
@ -38,6 +39,8 @@ public:
|
|||||||
|
|
||||||
static void SubscribeRotationSensor();
|
static void SubscribeRotationSensor();
|
||||||
static void UnsubscribeRotationSensor();
|
static void UnsubscribeRotationSensor();
|
||||||
|
static void SubscribeTentSensor();
|
||||||
|
static void UnsubscribeTentSensor();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
||||||
@ -49,6 +52,11 @@ public:
|
|||||||
void OnMotionChanged(const MotionEvent& motionData) override;
|
void OnMotionChanged(const MotionEvent& motionData) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TentMotionEventCallback : public MotionCallbackStub {
|
||||||
|
public:
|
||||||
|
void OnMotionChanged(const MotionEvent& motionData) override;
|
||||||
|
};
|
||||||
|
|
||||||
class MotionSubscriber {
|
class MotionSubscriber {
|
||||||
friend ScreenSensorConnector;
|
friend ScreenSensorConnector;
|
||||||
public:
|
public:
|
||||||
@ -61,6 +69,19 @@ private:
|
|||||||
static sptr<RotationMotionEventCallback> motionEventCallback_;
|
static sptr<RotationMotionEventCallback> motionEventCallback_;
|
||||||
static bool isMotionSensorSubscribed_;
|
static bool isMotionSensorSubscribed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MotionTentSubscriber {
|
||||||
|
friend ScreenSensorConnector;
|
||||||
|
public:
|
||||||
|
MotionTentSubscriber() = delete;
|
||||||
|
~MotionTentSubscriber() = default;
|
||||||
|
private:
|
||||||
|
static void SubscribeMotionSensor();
|
||||||
|
static void UnsubscribeMotionSensor();
|
||||||
|
|
||||||
|
static sptr<TentMotionEventCallback> motionEventCallback_;
|
||||||
|
static bool isMotionSensorSubscribed_;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
} // Rosen
|
} // Rosen
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "dm_common.h"
|
#include "dm_common.h"
|
||||||
#include "window_manager_hilog.h"
|
#include "window_manager_hilog.h"
|
||||||
#include "screen_session_manager.h"
|
#include "screen_session_manager.h"
|
||||||
|
#include "screen_rotation_property.h"
|
||||||
|
|
||||||
namespace OHOS {
|
namespace OHOS {
|
||||||
namespace Rosen {
|
namespace Rosen {
|
||||||
@ -45,6 +46,7 @@ private:
|
|||||||
void ShowHelpInfo();
|
void ShowHelpInfo();
|
||||||
void ShowAllScreenInfo();
|
void ShowAllScreenInfo();
|
||||||
void DumpFoldStatus();
|
void DumpFoldStatus();
|
||||||
|
void DumpTentMode();
|
||||||
void OutputDumpInfo();
|
void OutputDumpInfo();
|
||||||
void DumpScreenSessionById(ScreenId id);
|
void DumpScreenSessionById(ScreenId id);
|
||||||
void DumpRsInfoById(ScreenId id);
|
void DumpRsInfoById(ScreenId id);
|
||||||
@ -54,11 +56,22 @@ private:
|
|||||||
void DumpCutoutInfoById(ScreenId id);
|
void DumpCutoutInfoById(ScreenId id);
|
||||||
void DumpScreenInfoById(ScreenId id);
|
void DumpScreenInfoById(ScreenId id);
|
||||||
void DumpScreenPropertyById(ScreenId id);
|
void DumpScreenPropertyById(ScreenId id);
|
||||||
|
void ExcuteInjectCmd();
|
||||||
|
/*
|
||||||
|
hidumper 命令注入隔离
|
||||||
|
*/
|
||||||
|
#ifndef IS_RELEASE_VERSION
|
||||||
void ShowNotifyFoldStatusChangedInfo();
|
void ShowNotifyFoldStatusChangedInfo();
|
||||||
void ShowIllegalArgsInfo();
|
void ShowIllegalArgsInfo();
|
||||||
void SetMotionSensorvalue(std::string input);
|
void SetMotionSensorvalue(std::string input);
|
||||||
void SetRotationLockedvalue(std::string input);
|
void SetRotationLockedvalue(std::string input);
|
||||||
|
void SetEnterOrExitTentMode(std::string input);
|
||||||
|
void SetHoverStatusChange(std::string input);
|
||||||
void MockSendCastPublishEvent(std::string input);
|
void MockSendCastPublishEvent(std::string input);
|
||||||
|
bool IsValidDisplayModeCommand(std::string command);
|
||||||
|
int SetFoldDisplayMode();
|
||||||
|
int SetFoldStatusLocked();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fd_;
|
int fd_;
|
||||||
|
@ -83,6 +83,8 @@ public:
|
|||||||
bool WakeUpEnd() override;
|
bool WakeUpEnd() override;
|
||||||
bool SuspendBegin(PowerStateChangeReason reason) override;
|
bool SuspendBegin(PowerStateChangeReason reason) override;
|
||||||
bool SuspendEnd() override;
|
bool SuspendEnd() override;
|
||||||
|
ScreenId GetInternalScreenId() override;
|
||||||
|
bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
|
||||||
bool SetDisplayState(DisplayState state) override;
|
bool SetDisplayState(DisplayState state) override;
|
||||||
DisplayState GetDisplayState(DisplayId displayId) override;
|
DisplayState GetDisplayState(DisplayId displayId) override;
|
||||||
bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
|
bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
|
||||||
@ -216,6 +218,7 @@ public:
|
|||||||
bool IsCaptured() override;
|
bool IsCaptured() override;
|
||||||
|
|
||||||
FoldStatus GetFoldStatus() override;
|
FoldStatus GetFoldStatus() override;
|
||||||
|
bool GetTentMode();
|
||||||
|
|
||||||
bool SetScreenPower(ScreenPowerStatus status, PowerStateChangeReason reason);
|
bool SetScreenPower(ScreenPowerStatus status, PowerStateChangeReason reason);
|
||||||
void SetScreenPowerForFold(ScreenPowerStatus status);
|
void SetScreenPowerForFold(ScreenPowerStatus status);
|
||||||
@ -230,7 +233,9 @@ public:
|
|||||||
int NotifyFoldStatusChanged(const std::string& statusParam);
|
int NotifyFoldStatusChanged(const std::string& statusParam);
|
||||||
void NotifyDisplayModeChanged(FoldDisplayMode displayMode);
|
void NotifyDisplayModeChanged(FoldDisplayMode displayMode);
|
||||||
void NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info) override;
|
void NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info) override;
|
||||||
|
void OnTentModeChanged(bool isTentMode);
|
||||||
void RegisterSettingDpiObserver();
|
void RegisterSettingDpiObserver();
|
||||||
|
void RegisterExtendSettingDpiObserver();
|
||||||
void RegisterSettingRotationObserver();
|
void RegisterSettingRotationObserver();
|
||||||
|
|
||||||
void OnConnect(ScreenId screenId) override {}
|
void OnConnect(ScreenId screenId) override {}
|
||||||
@ -240,12 +245,12 @@ public:
|
|||||||
void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
|
void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
|
||||||
PowerStateChangeReason reason) override;
|
PowerStateChangeReason reason) override;
|
||||||
void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override;
|
void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override;
|
||||||
|
void OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId) override;
|
||||||
void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override;
|
void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override;
|
||||||
void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override;
|
void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override;
|
||||||
|
|
||||||
void SetHdrFormats(ScreenId screenId, sptr<ScreenSession>& session);
|
void SetHdrFormats(ScreenId screenId, sptr<ScreenSession>& session);
|
||||||
void SetColorSpaces(ScreenId screenId, sptr<ScreenSession>& session);
|
void SetColorSpaces(ScreenId screenId, sptr<ScreenSession>& session);
|
||||||
void SwitchUser() override;
|
|
||||||
void SetClient(const sptr<IScreenSessionManagerClient>& client) override;
|
void SetClient(const sptr<IScreenSessionManagerClient>& client) override;
|
||||||
ScreenProperty GetScreenProperty(ScreenId screenId) override;
|
ScreenProperty GetScreenProperty(ScreenId screenId) override;
|
||||||
std::shared_ptr<RSDisplayNode> GetDisplayNode(ScreenId screenId) override;
|
std::shared_ptr<RSDisplayNode> GetDisplayNode(ScreenId screenId) override;
|
||||||
@ -286,6 +291,17 @@ public:
|
|||||||
void NotifyCastWhenScreenConnectChange(bool isConnected);
|
void NotifyCastWhenScreenConnectChange(bool isConnected);
|
||||||
void MultiScreenModeChange(const std::string& mainScreenId, const std::string& secondaryScreenId,
|
void MultiScreenModeChange(const std::string& mainScreenId, const std::string& secondaryScreenId,
|
||||||
const std::string& secondaryScreenMode);
|
const std::string& secondaryScreenMode);
|
||||||
|
void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent);
|
||||||
|
void SetCoordinationFlag(bool isCoordinationFlag);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* multi user
|
||||||
|
*/
|
||||||
|
void SwitchUser() override;
|
||||||
|
void SwitchScbNodeHandle(int32_t userId, int32_t newScbPid, bool coldBoot);
|
||||||
|
void AddScbClientDeathRecipient(const sptr<IScreenSessionManagerClient>& scbClient, int32_t scbPid);
|
||||||
|
void ScbClientDeathCallback(int32_t deathScbPid);
|
||||||
|
void ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t> oldScbPids, int32_t newScbPid);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ScreenSessionManager();
|
ScreenSessionManager();
|
||||||
@ -301,7 +317,6 @@ private:
|
|||||||
void ConfigureWaterfallDisplayCompressionParams();
|
void ConfigureWaterfallDisplayCompressionParams();
|
||||||
void ConfigureScreenSnapshotParams();
|
void ConfigureScreenSnapshotParams();
|
||||||
void RegisterScreenChangeListener();
|
void RegisterScreenChangeListener();
|
||||||
void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent);
|
|
||||||
void RegisterRefreshRateChangeListener();
|
void RegisterRefreshRateChangeListener();
|
||||||
void OnHgmRefreshRateChange(uint32_t refreshRate);
|
void OnHgmRefreshRateChange(uint32_t refreshRate);
|
||||||
sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId);
|
sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId);
|
||||||
@ -316,14 +331,10 @@ private:
|
|||||||
void SendCastEvent(const bool &isPlugIn);
|
void SendCastEvent(const bool &isPlugIn);
|
||||||
void PhyMirrorConnectWakeupScreen();
|
void PhyMirrorConnectWakeupScreen();
|
||||||
void HandleScreenEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
|
void HandleScreenEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
|
||||||
void ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t> oldScbPids, int32_t newScbPid);
|
void HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
|
||||||
void SwitchScbNodeHandle(int32_t userId, int32_t newScbPid, bool coldBoot);
|
|
||||||
void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType);
|
void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType);
|
||||||
|
|
||||||
void SetClientInner();
|
void SetClientInner();
|
||||||
void GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight, bool& isReset, const ScreenId& screenid);
|
void GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight, bool& isReset, const ScreenId& screenid);
|
||||||
void ScbClientDeathCallback(int32_t deathScbPid);
|
|
||||||
void AddScbClientDeathRecipient(const sptr<IScreenSessionManagerClient>& scbClient, int32_t scbPid);
|
|
||||||
|
|
||||||
void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||||
@ -337,14 +348,6 @@ private:
|
|||||||
DMError CheckDisplayMangerAgentTypeAndPermission(
|
DMError CheckDisplayMangerAgentTypeAndPermission(
|
||||||
const sptr<IDisplayManagerAgent>& displayManagerAgent, DisplayManagerAgentType type);
|
const sptr<IDisplayManagerAgent>& displayManagerAgent, DisplayManagerAgentType type);
|
||||||
int Dump(int fd, const std::vector<std::u16string>& args) override;
|
int Dump(int fd, const std::vector<std::u16string>& args) override;
|
||||||
void ShowHelpInfo(std::string& dumpInfo);
|
|
||||||
void ShowIllegalArgsInfo(std::string& dumpInfo);
|
|
||||||
int DumpScreenInfo(const std::vector<std::string>& args, std::string& dumpInfo);
|
|
||||||
int DumpAllScreenInfo(std::string& dumpInfo);
|
|
||||||
int DumpSpecifiedScreenInfo(ScreenId screenId, std::string& dumpInfo);
|
|
||||||
bool IsValidDigitString(const std::string& idStr) const;
|
|
||||||
int SetFoldDisplayMode(const std::string& modeParam);
|
|
||||||
int SetFoldStatusLocked(const std::string& lockParam);
|
|
||||||
sptr<DisplayInfo> HookDisplayInfoByUid(sptr<DisplayInfo> displayInfo);
|
sptr<DisplayInfo> HookDisplayInfoByUid(sptr<DisplayInfo> displayInfo);
|
||||||
DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
|
DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
|
||||||
std::vector<uint64_t>& windowIdList) override;
|
std::vector<uint64_t>& windowIdList) override;
|
||||||
@ -386,12 +389,16 @@ private:
|
|||||||
std::shared_ptr<TaskScheduler> taskScheduler_;
|
std::shared_ptr<TaskScheduler> taskScheduler_;
|
||||||
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* multi user
|
||||||
|
*/
|
||||||
std::mutex oldScbPidsMutex_;
|
std::mutex oldScbPidsMutex_;
|
||||||
std::condition_variable scbSwitchCV_;
|
std::condition_variable scbSwitchCV_;
|
||||||
int32_t currentUserId_ { 0 };
|
int32_t currentUserId_ { 0 };
|
||||||
int32_t currentScbPId_ { -1 };
|
int32_t currentScbPId_ { -1 };
|
||||||
std::vector<int32_t> oldScbPids_ {};
|
std::vector<int32_t> oldScbPids_ {};
|
||||||
std::map<int32_t, sptr<IScreenSessionManagerClient>> clientProxyMap_;
|
std::map<int32_t, sptr<IScreenSessionManagerClient>> clientProxyMap_;
|
||||||
|
FoldDisplayMode oldScbDisplayMode_ = FoldDisplayMode::UNKNOWN;
|
||||||
|
|
||||||
sptr<IScreenSessionManagerClient> clientProxy_;
|
sptr<IScreenSessionManagerClient> clientProxy_;
|
||||||
ClientAgentContainer<IDisplayManagerAgent, DisplayManagerAgentType> dmAgentContainer_;
|
ClientAgentContainer<IDisplayManagerAgent, DisplayManagerAgentType> dmAgentContainer_;
|
||||||
@ -420,6 +427,7 @@ private:
|
|||||||
bool isAutoRotationOpen_ = false;
|
bool isAutoRotationOpen_ = false;
|
||||||
bool isExpandCombination_ = false;
|
bool isExpandCombination_ = false;
|
||||||
bool isScreenShot_ = false;
|
bool isScreenShot_ = false;
|
||||||
|
bool isCoordinationFlag_ = false;
|
||||||
uint32_t hdmiScreenCount_ = 0;
|
uint32_t hdmiScreenCount_ = 0;
|
||||||
uint32_t virtualScreenCount_ = 0;
|
uint32_t virtualScreenCount_ = 0;
|
||||||
uint32_t currentExpandScreenCount_ = 0;
|
uint32_t currentExpandScreenCount_ = 0;
|
||||||
@ -471,6 +479,7 @@ private:
|
|||||||
void HandleFoldScreenPowerInit();
|
void HandleFoldScreenPowerInit();
|
||||||
void SetFoldScreenPowerInit(std::function<void()> foldScreenPowerInit);
|
void SetFoldScreenPowerInit(std::function<void()> foldScreenPowerInit);
|
||||||
void SetDpiFromSettingData();
|
void SetDpiFromSettingData();
|
||||||
|
void SetDpiFromSettingData(bool isInternal);
|
||||||
void SetRotateLockedFromSettingData();
|
void SetRotateLockedFromSettingData();
|
||||||
void NotifyClientProxyUpdateFoldDisplayMode(FoldDisplayMode displayMode);
|
void NotifyClientProxyUpdateFoldDisplayMode(FoldDisplayMode displayMode);
|
||||||
void UpdateDisplayScaleState(ScreenId screenId);
|
void UpdateDisplayScaleState(ScreenId screenId);
|
||||||
@ -484,7 +493,6 @@ private:
|
|||||||
float& translateY);
|
float& translateY);
|
||||||
void RegisterApplicationStateObserver();
|
void RegisterApplicationStateObserver();
|
||||||
void SetPostureAndHallSensorEnabled();
|
void SetPostureAndHallSensorEnabled();
|
||||||
bool IsValidDisplayModeCommand(std::string command);
|
|
||||||
bool IsDefaultMirrorMode(ScreenId screenId);
|
bool IsDefaultMirrorMode(ScreenId screenId);
|
||||||
void SetCastFromSettingData();
|
void SetCastFromSettingData();
|
||||||
void RegisterCastObserver(std::vector<ScreenId>& mirrorScreenIds);
|
void RegisterCastObserver(std::vector<ScreenId>& mirrorScreenIds);
|
||||||
|
@ -26,6 +26,8 @@ class ScreenSettingHelper {
|
|||||||
public:
|
public:
|
||||||
static void RegisterSettingDpiObserver(SettingObserver::UpdateFunc func);
|
static void RegisterSettingDpiObserver(SettingObserver::UpdateFunc func);
|
||||||
static void UnregisterSettingDpiObserver();
|
static void UnregisterSettingDpiObserver();
|
||||||
|
static void RegisterExtendSettingDpiObserver(SettingObserver::UpdateFunc func);
|
||||||
|
static void UnregisterExtendSettingDpiObserver();
|
||||||
static bool GetSettingDpi(uint32_t& dpi, const std::string& key = SETTING_DPI_KEY);
|
static bool GetSettingDpi(uint32_t& dpi, const std::string& key = SETTING_DPI_KEY);
|
||||||
static bool GetSettingValue(uint32_t& value, const std::string& key);
|
static bool GetSettingValue(uint32_t& value, const std::string& key);
|
||||||
static void RegisterSettingCastObserver(SettingObserver::UpdateFunc func);
|
static void RegisterSettingCastObserver(SettingObserver::UpdateFunc func);
|
||||||
@ -40,10 +42,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const constexpr char* SETTING_DPI_KEY {"user_set_dpi_value"};
|
static const constexpr char* SETTING_DPI_KEY {"user_set_dpi_value"};
|
||||||
|
static const constexpr char* SETTING_DPI_KEY_EXTEND {"user_set_dpi_value_extend"};
|
||||||
static const constexpr char* SETTING_CAST_KEY {"huaweicast.data.privacy_projection_state"};
|
static const constexpr char* SETTING_CAST_KEY {"huaweicast.data.privacy_projection_state"};
|
||||||
static const constexpr char* SETTING_ROTATION_KEY {"screen_rotation_value"};
|
static const constexpr char* SETTING_ROTATION_KEY {"screen_rotation_value"};
|
||||||
static const constexpr char* SETTING_ROTATION_SCREEN_ID_KEY {"screen_rotation_screen_id_value"};
|
static const constexpr char* SETTING_ROTATION_SCREEN_ID_KEY {"screen_rotation_screen_id_value"};
|
||||||
static sptr<SettingObserver> dpiObserver_;
|
static sptr<SettingObserver> dpiObserver_;
|
||||||
|
static sptr<SettingObserver> extendDpiObserver_;
|
||||||
static sptr<SettingObserver> castObserver_;
|
static sptr<SettingObserver> castObserver_;
|
||||||
static sptr<SettingObserver> rotationObserver_;
|
static sptr<SettingObserver> rotationObserver_;
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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_ROSEN_SCREEN_TENT_PROPERTY_H
|
||||||
|
#define OHOS_ROSEN_SCREEN_TENT_PROPERTY_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <refbase.h>
|
||||||
|
|
||||||
|
#ifdef SENSOR_ENABLE
|
||||||
|
#include "sensor_agent.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "window_manager_hilog.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace Rosen {
|
||||||
|
|
||||||
|
class ScreenTentProperty : public RefBase {
|
||||||
|
public:
|
||||||
|
ScreenTentProperty() = delete;
|
||||||
|
~ScreenTentProperty() = default;
|
||||||
|
static void HandleSensorEventInput(bool isTentMode);
|
||||||
|
};
|
||||||
|
} // Rosen
|
||||||
|
} // OHOS
|
||||||
|
#endif // OHOS_ROSEN_SCREEN_TENT_PROPERTY_H
|
@ -87,6 +87,11 @@ public:
|
|||||||
virtual bool WakeUpEnd() override { return false; }
|
virtual bool WakeUpEnd() override { return false; }
|
||||||
virtual bool SuspendBegin(PowerStateChangeReason reason) override { return false; }
|
virtual bool SuspendBegin(PowerStateChangeReason reason) override { return false; }
|
||||||
virtual bool SuspendEnd() override { return false; }
|
virtual bool SuspendEnd() override { return false; }
|
||||||
|
virtual ScreenId GetInternalScreenId() override { return SCREEN_ID_INVALID; }
|
||||||
|
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override { return false; }
|
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override { return false; }
|
||||||
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override { return false; }
|
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override { return false; }
|
||||||
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override { return ScreenPowerState::INVALID_STATE; }
|
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override { return ScreenPowerState::INVALID_STATE; }
|
||||||
|
@ -62,6 +62,8 @@ public:
|
|||||||
virtual bool WakeUpEnd() override;
|
virtual bool WakeUpEnd() override;
|
||||||
virtual bool SuspendBegin(PowerStateChangeReason reason) override;
|
virtual bool SuspendBegin(PowerStateChangeReason reason) override;
|
||||||
virtual bool SuspendEnd() override;
|
virtual bool SuspendEnd() override;
|
||||||
|
virtual ScreenId GetInternalScreenId() override;
|
||||||
|
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
|
||||||
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override;
|
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override;
|
||||||
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
|
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
|
||||||
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override;
|
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override;
|
||||||
|
@ -40,7 +40,8 @@ const int32_t TP_TYPE = 12;
|
|||||||
const std::string MAIN_TP = "0";
|
const std::string MAIN_TP = "0";
|
||||||
const std::string SUB_TP = "1";
|
const std::string SUB_TP = "1";
|
||||||
const int32_t REMOVE_DISPLAY_NODE = 0;
|
const int32_t REMOVE_DISPLAY_NODE = 0;
|
||||||
const int32_t ADD_DISPLAY_NODE = 0;
|
const int32_t ADD_DISPLAY_NODE = 1;
|
||||||
|
const uint32_t CHANGE_MODE_TASK_NUM = 3;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex,
|
DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex,
|
||||||
@ -63,6 +64,26 @@ DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMu
|
|||||||
currentFoldCreaseRegion_ = new FoldCreaseRegion(screenIdMain, rect);
|
currentFoldCreaseRegion_ = new FoldCreaseRegion(screenIdMain, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DualDisplayFoldPolicy::SetdisplayModeChangeStatus(bool status)
|
||||||
|
{
|
||||||
|
if (status) {
|
||||||
|
pengdingTask_ = CHANGE_MODE_TASK_NUM;
|
||||||
|
startTimePoint_ = std::chrono::steady_clock::now();
|
||||||
|
displayModeChangeRunning_ = status;
|
||||||
|
} else {
|
||||||
|
pengdingTask_ --;
|
||||||
|
if (pengdingTask_ != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
displayModeChangeRunning_ = false;
|
||||||
|
endTimePoint_ = std::chrono::steady_clock::now();
|
||||||
|
if (lastCachedisplayMode_.load() != GetScreenDisplayMode()) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "start change displaymode to lastest mode");
|
||||||
|
ChangeScreenDisplayMode(lastCachedisplayMode_.load());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DualDisplayFoldPolicy::CheckDisplayMode(FoldDisplayMode displayMode)
|
bool DualDisplayFoldPolicy::CheckDisplayMode(FoldDisplayMode displayMode)
|
||||||
{
|
{
|
||||||
if (displayMode == FoldDisplayMode::COORDINATION && !IS_COORDINATION_SUPPORT) {
|
if (displayMode == FoldDisplayMode::COORDINATION && !IS_COORDINATION_SUPPORT) {
|
||||||
@ -76,24 +97,38 @@ bool DualDisplayFoldPolicy::CheckDisplayMode(FoldDisplayMode displayMode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenId DualDisplayFoldPolicy::GetScreenIdByDisplayMode(FoldDisplayMode displayMode)
|
||||||
|
{
|
||||||
|
ScreenId screenId = SCREEN_ID_MAIN;
|
||||||
|
if (displayMode == FoldDisplayMode::SUB) {
|
||||||
|
screenId = SCREEN_ID_SUB;
|
||||||
|
}
|
||||||
|
return screenId;
|
||||||
|
}
|
||||||
|
|
||||||
void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode)
|
void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayMode displayMode = %{public}d", displayMode);
|
SetLastCacheDisplayMode(displayMode);
|
||||||
sptr<ScreenSession> screenSession = ScreenSessionManager::GetInstance().GetScreenSession(SCREEN_ID_MAIN);
|
if (GetModeChangeRunningStatus()) {
|
||||||
if (displayMode == FoldDisplayMode::SUB) {
|
TLOGW(WmsLogTag::DMS, "last process not complete, skip mode: %{public}d", displayMode);
|
||||||
screenSession = ScreenSessionManager::GetInstance().GetScreenSession(SCREEN_ID_SUB);
|
|
||||||
}
|
|
||||||
if (screenSession == nullptr) {
|
|
||||||
TLOGE(WmsLogTag::DMS, "ChangeScreenDisplayMode default screenSession is null");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TLOGI(WmsLogTag::DMS, "start change displaymode: %{public}d, lastElapsedMs: %{public}" PRId64 "ms",
|
||||||
|
displayMode, getFoldingElapsedMs());
|
||||||
|
ScreenId screenId = GetScreenIdByDisplayMode(displayMode);
|
||||||
|
sptr<ScreenSession> screenSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId);
|
||||||
|
if (screenSession == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "default screenSession is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:ChangeScreenDisplayMode(displayMode= %" PRIu64")", displayMode);
|
||||||
{
|
{
|
||||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
|
|
||||||
"ssm:ChangeScreenDisplayMode(displayMode = %" PRIu64")", displayMode);
|
|
||||||
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||||
if (!CheckDisplayMode(displayMode)) {
|
if (!CheckDisplayMode(displayMode)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
SetdisplayModeChangeStatus(true);
|
||||||
ReportFoldDisplayModeChange(displayMode);
|
ReportFoldDisplayModeChange(displayMode);
|
||||||
switch (displayMode) {
|
switch (displayMode) {
|
||||||
case FoldDisplayMode::SUB: {
|
case FoldDisplayMode::SUB: {
|
||||||
@ -108,23 +143,19 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode)
|
|||||||
ChangeScreenDisplayModeToCoordination();
|
ChangeScreenDisplayModeToCoordination();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FoldDisplayMode::UNKNOWN: {
|
|
||||||
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayMode displayMode is unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayMode displayMode is invalid");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentDisplayMode_ != displayMode) {
|
if (currentDisplayMode_ != displayMode) {
|
||||||
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayMode NotifyDisplayModeChanged displayMode = %{public}d",
|
|
||||||
displayMode);
|
|
||||||
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||||
currentDisplayMode_ = displayMode;
|
currentDisplayMode_ = displayMode;
|
||||||
lastDisplayMode_ = displayMode;
|
lastDisplayMode_ = displayMode;
|
||||||
}
|
}
|
||||||
|
SetdisplayModeChangeStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DualDisplayFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
void DualDisplayFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
||||||
@ -137,10 +168,8 @@ void DualDisplayFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
|||||||
TLOGI(WmsLogTag::DMS, "CurrentDisplayMode is coordination, HalfFold no need to change displaympde");
|
TLOGI(WmsLogTag::DMS, "CurrentDisplayMode is coordination, HalfFold no need to change displaympde");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (displayMode != currentDisplayMode_) {
|
|
||||||
ChangeScreenDisplayMode(displayMode);
|
ChangeScreenDisplayMode(displayMode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sptr<FoldCreaseRegion> DualDisplayFoldPolicy::GetCurrentFoldCreaseRegion()
|
sptr<FoldCreaseRegion> DualDisplayFoldPolicy::GetCurrentFoldCreaseRegion()
|
||||||
{
|
{
|
||||||
@ -291,6 +320,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr<ScreenSession> scr
|
|||||||
screenId_ = offScreenId;
|
screenId_ = offScreenId;
|
||||||
ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false);
|
ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false);
|
||||||
ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_OFF);
|
ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
if (screenPowerTaskScheduler_ == nullptr) {
|
if (screenPowerTaskScheduler_ == nullptr) {
|
||||||
TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter");
|
TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter");
|
||||||
@ -309,6 +339,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr<ScreenSession> scr
|
|||||||
} else {
|
} else {
|
||||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||||
}
|
}
|
||||||
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOn, "screenOnTask");
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOn, "screenOnTask");
|
||||||
AddOrRemoveDisplayNodeToTree(onScreenId, ADD_DISPLAY_NODE);
|
AddOrRemoveDisplayNodeToTree(onScreenId, ADD_DISPLAY_NODE);
|
||||||
@ -333,6 +364,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeToCoordination()
|
|||||||
} else {
|
} else {
|
||||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||||
}
|
}
|
||||||
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
if (screenPowerTaskScheduler_ == nullptr) {
|
if (screenPowerTaskScheduler_ == nullptr) {
|
||||||
TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter");
|
TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter");
|
||||||
@ -347,6 +379,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeToCoordination()
|
|||||||
ScreenSessionManager::GetInstance().SetScreenPowerForFold(SCREEN_ID_SUB,
|
ScreenSessionManager::GetInstance().SetScreenPowerForFold(SCREEN_ID_SUB,
|
||||||
ScreenPowerStatus::POWER_STATUS_ON);
|
ScreenPowerStatus::POWER_STATUS_ON);
|
||||||
}
|
}
|
||||||
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnSub, "taskScreenOnSub");
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnSub, "taskScreenOnSub");
|
||||||
AddOrRemoveDisplayNodeToTree(SCREEN_ID_SUB, ADD_DISPLAY_NODE);
|
AddOrRemoveDisplayNodeToTree(SCREEN_ID_SUB, ADD_DISPLAY_NODE);
|
||||||
|
@ -134,6 +134,24 @@ void FoldScreenController::SetFoldStatus(FoldStatus foldStatus)
|
|||||||
foldScreenPolicy_->SetFoldStatus(foldStatus);
|
foldScreenPolicy_->SetFoldStatus(foldStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FoldScreenController::GetTentMode()
|
||||||
|
{
|
||||||
|
if (sensorFoldStateManager_ == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "GetTentMode: sensorFoldStateManager_ is null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return sensorFoldStateManager_->IsTentMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FoldScreenController::OnTentModeChanged(bool isTentMode)
|
||||||
|
{
|
||||||
|
if (sensorFoldStateManager_ == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "OnTentModeChanged: sensorFoldStateManager_ is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return sensorFoldStateManager_->HandleTentChange(isTentMode, foldScreenPolicy_);
|
||||||
|
}
|
||||||
|
|
||||||
sptr<FoldCreaseRegion> FoldScreenController::GetCurrentFoldCreaseRegion()
|
sptr<FoldCreaseRegion> FoldScreenController::GetCurrentFoldCreaseRegion()
|
||||||
{
|
{
|
||||||
if (foldScreenPolicy_ == nullptr) {
|
if (foldScreenPolicy_ == nullptr) {
|
||||||
@ -152,6 +170,16 @@ ScreenId FoldScreenController::GetCurrentScreenId()
|
|||||||
return foldScreenPolicy_->GetCurrentScreenId();
|
return foldScreenPolicy_->GetCurrentScreenId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FoldScreenController::BootAnimationFinishPowerInit()
|
||||||
|
{
|
||||||
|
if (foldScreenPolicy_ == nullptr) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "foldScreenPolicy_ is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foldScreenPolicy_->BootAnimationFinishPowerInit();
|
||||||
|
foldScreenPolicy_->currentDisplayMode_ = FoldDisplayMode::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
void FoldScreenController::SetOnBootAnimation(bool onBootAnimation)
|
void FoldScreenController::SetOnBootAnimation(bool onBootAnimation)
|
||||||
{
|
{
|
||||||
if (foldScreenPolicy_ == nullptr) {
|
if (foldScreenPolicy_ == nullptr) {
|
||||||
|
@ -71,6 +71,10 @@ void FoldScreenPolicy::ClearState()
|
|||||||
|
|
||||||
void FoldScreenPolicy::ExitCoordination() {};
|
void FoldScreenPolicy::ExitCoordination() {};
|
||||||
|
|
||||||
|
void FoldScreenPolicy::ChangeOnTentMode(FoldStatus currentState) {}
|
||||||
|
|
||||||
|
void FoldScreenPolicy::ChangeOffTentMode() {}
|
||||||
|
|
||||||
bool FoldScreenPolicy::GetModeChangeRunningStatus()
|
bool FoldScreenPolicy::GetModeChangeRunningStatus()
|
||||||
{
|
{
|
||||||
auto currentTime = std::chrono::steady_clock::now();
|
auto currentTime = std::chrono::steady_clock::now();
|
||||||
|
@ -45,7 +45,6 @@ constexpr float ANGLE_MAX_VAL = 180.0F;
|
|||||||
constexpr int32_t SENSOR_SUCCESS = 0;
|
constexpr int32_t SENSOR_SUCCESS = 0;
|
||||||
constexpr int32_t POSTURE_INTERVAL = 100000000;
|
constexpr int32_t POSTURE_INTERVAL = 100000000;
|
||||||
constexpr uint16_t SENSOR_EVENT_FIRST_DATA = 0;
|
constexpr uint16_t SENSOR_EVENT_FIRST_DATA = 0;
|
||||||
constexpr int32_t HALL_FOLDED_THRESHOLD = 0;
|
|
||||||
constexpr float ACCURACY_ERROR_FOR_ALTA = 0.0001F;
|
constexpr float ACCURACY_ERROR_FOR_ALTA = 0.0001F;
|
||||||
static float INWARD_HALF_FOLDED_MIN_THRESHOLD = static_cast<float>(system::GetIntParameter<int32_t>
|
static float INWARD_HALF_FOLDED_MIN_THRESHOLD = static_cast<float>(system::GetIntParameter<int32_t>
|
||||||
("const.fold.half_folded_min_threshold", 85));
|
("const.fold.half_folded_min_threshold", 85));
|
||||||
@ -82,6 +81,7 @@ void FoldScreenSensorManager::RegisterPostureCallback()
|
|||||||
if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) {
|
if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) {
|
||||||
TLOGE(WmsLogTag::DMS, "RegisterPostureCallback failed.");
|
TLOGE(WmsLogTag::DMS, "RegisterPostureCallback failed.");
|
||||||
} else {
|
} else {
|
||||||
|
registerPosture_ = true;
|
||||||
TLOGI(WmsLogTag::DMS, "FoldScreenSensorManager.RegisterPostureCallback success.");
|
TLOGI(WmsLogTag::DMS, "FoldScreenSensorManager.RegisterPostureCallback success.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,6 +93,7 @@ void FoldScreenSensorManager::UnRegisterPostureCallback()
|
|||||||
TLOGI(WmsLogTag::DMS, "UnRegisterPostureCallback, deactivateRet: %{public}d, unsubscribeRet: %{public}d",
|
TLOGI(WmsLogTag::DMS, "UnRegisterPostureCallback, deactivateRet: %{public}d, unsubscribeRet: %{public}d",
|
||||||
deactivateRet, unsubscribeRet);
|
deactivateRet, unsubscribeRet);
|
||||||
if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) {
|
if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) {
|
||||||
|
registerPosture_ = false;
|
||||||
TLOGI(WmsLogTag::DMS, "FoldScreenSensorManager.UnRegisterPostureCallback success.");
|
TLOGI(WmsLogTag::DMS, "FoldScreenSensorManager.UnRegisterPostureCallback success.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +191,7 @@ void FoldScreenSensorManager::HandleHallData(const SensorEvent * const event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TLOGI(WmsLogTag::DMS, "hall value is: %{public}u, angle value is: %{public}f", globalHall, globalAngle);
|
TLOGI(WmsLogTag::DMS, "hall value is: %{public}u, angle value is: %{public}f", globalHall, globalAngle);
|
||||||
if (globalHall == HALL_FOLDED_THRESHOLD) {
|
if (!registerPosture_) {
|
||||||
globalAngle = ANGLE_MIN_VAL;
|
globalAngle = ANGLE_MIN_VAL;
|
||||||
}
|
}
|
||||||
sensorFoldStateManager_->HandleHallChange(globalAngle, globalHall, foldScreenPolicy_);
|
sensorFoldStateManager_->HandleHallChange(globalAngle, globalHall, foldScreenPolicy_);
|
||||||
@ -205,7 +206,7 @@ void FoldScreenSensorManager::TriggerDisplaySwitch()
|
|||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "TriggerDisplaySwitch hall value is: %{public}u, angle value is: %{public}f",
|
TLOGI(WmsLogTag::DMS, "TriggerDisplaySwitch hall value is: %{public}u, angle value is: %{public}f",
|
||||||
globalHall, globalAngle);
|
globalHall, globalAngle);
|
||||||
if (globalHall == HALL_FOLDED_THRESHOLD) {
|
if (!registerPosture_) {
|
||||||
globalAngle = ANGLE_MIN_VAL;
|
globalAngle = ANGLE_MIN_VAL;
|
||||||
} else {
|
} else {
|
||||||
if (FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
|
if (FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
|
||||||
|
@ -61,7 +61,6 @@ constexpr int32_t HALL_FOLDED_THRESHOLD = 0;
|
|||||||
constexpr float ANGLE_MIN_VAL = 0.0F;
|
constexpr float ANGLE_MIN_VAL = 0.0F;
|
||||||
constexpr float INWARD_FOLDED_LOWER_THRESHOLD = 10.0F;
|
constexpr float INWARD_FOLDED_LOWER_THRESHOLD = 10.0F;
|
||||||
constexpr float INWARD_FOLDED_UPPER_THRESHOLD = 20.0F;
|
constexpr float INWARD_FOLDED_UPPER_THRESHOLD = 20.0F;
|
||||||
constexpr int64_t MIN_HALL_REPORT_INTERVAL = 100;
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DualDisplaySensorFoldStateManager::DualDisplaySensorFoldStateManager()
|
DualDisplaySensorFoldStateManager::DualDisplaySensorFoldStateManager()
|
||||||
@ -94,15 +93,6 @@ void DualDisplaySensorFoldStateManager::HandleAngleChange(float angle, int hall,
|
|||||||
void DualDisplaySensorFoldStateManager::HandleHallChange(float angle, int hall,
|
void DualDisplaySensorFoldStateManager::HandleHallChange(float angle, int hall,
|
||||||
sptr<FoldScreenPolicy> foldScreenPolicy)
|
sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(hallMutex_);
|
|
||||||
auto currentTime = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
|
|
||||||
int64_t duration = static_cast<int64_t>(
|
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - mLastHallReportTime_).count());
|
|
||||||
TLOGI(WmsLogTag::DMS, "duration = %{public}" PRIu64" ", duration);
|
|
||||||
if (duration < MIN_HALL_REPORT_INTERVAL) {
|
|
||||||
TLOGW(WmsLogTag::DMS, "duration < 100ms");
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(MIN_HALL_REPORT_INTERVAL - duration));
|
|
||||||
}
|
|
||||||
if (applicationStateObserver_ != nullptr && hall == HALL_THRESHOLD &&
|
if (applicationStateObserver_ != nullptr && hall == HALL_THRESHOLD &&
|
||||||
PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) {
|
PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) {
|
||||||
if (std::count(packageNames_.begin(), packageNames_.end(), applicationStateObserver_->GetForegroundApp())) {
|
if (std::count(packageNames_.begin(), packageNames_.end(), applicationStateObserver_->GetForegroundApp())) {
|
||||||
|
@ -34,19 +34,17 @@ void SensorFoldStateManager::HandleAngleChange(float angle, int hall, sptr<FoldS
|
|||||||
|
|
||||||
void SensorFoldStateManager::HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) {}
|
void SensorFoldStateManager::HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) {}
|
||||||
|
|
||||||
|
void SensorFoldStateManager::HandleTentChange(bool isTent, sptr<FoldScreenPolicy> foldScreenPolicy) {}
|
||||||
|
|
||||||
void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, float angle,
|
void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, float angle,
|
||||||
sptr<FoldScreenPolicy> foldScreenPolicy)
|
sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||||
if (foldScreenPolicy == nullptr) {
|
|
||||||
TLOGE(WmsLogTag::DMS, "foldScreenPolicy is nullptr");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nextState == FoldStatus::UNKNOWN) {
|
if (nextState == FoldStatus::UNKNOWN) {
|
||||||
WLOGFW("fold state is UNKNOWN");
|
WLOGFW("fold state is UNKNOWN");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mState_ == nextState) {
|
if (mState_ == nextState && !IsTentMode()) {
|
||||||
WLOGFI("fold state doesn't change, foldState = %{public}d.", mState_);
|
WLOGFI("fold state doesn't change, foldState = %{public}d.", mState_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,4 +109,14 @@ void SensorFoldStateManager::NotifyReportFoldStatusToScb(FoldStatus currentStatu
|
|||||||
std::to_string(static_cast<int32_t>(nextStatus)), std::to_string(duration), std::to_string(postureAngle)};
|
std::to_string(static_cast<int32_t>(nextStatus)), std::to_string(duration), std::to_string(postureAngle)};
|
||||||
ScreenSessionManager::GetInstance().ReportFoldStatusToScb(screenFoldInfo);
|
ScreenSessionManager::GetInstance().ReportFoldStatusToScb(screenFoldInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SensorFoldStateManager::IsTentMode()
|
||||||
|
{
|
||||||
|
return isTentMode_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorFoldStateManager::SetTentMode(bool status)
|
||||||
|
{
|
||||||
|
isTentMode_ = status;
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
@ -77,8 +77,11 @@ FoldStatus SingleDisplaySensorFoldStateManager::GetNextFoldState(float angle, in
|
|||||||
FoldStatus state;
|
FoldStatus state;
|
||||||
|
|
||||||
if (allowUserSensorForLargeFoldDevice == SMALLER_BOUNDARY_FLAG) {
|
if (allowUserSensorForLargeFoldDevice == SMALLER_BOUNDARY_FLAG) {
|
||||||
if (hall == HALL_FOLDED_THRESHOLD) {
|
if (std::islessequal(angle, OPEN_ALTA_HALF_FOLDED_MIN_THRESHOLD) && hall == HALL_FOLDED_THRESHOLD) {
|
||||||
state = FoldStatus::FOLDED;
|
state = FoldStatus::FOLDED;
|
||||||
|
} else if (std::isgreaterequal(angle, OPEN_ALTA_HALF_FOLDED_MIN_THRESHOLD + ALTA_HALF_FOLDED_BUFFER) &&
|
||||||
|
hall == HALL_FOLDED_THRESHOLD) {
|
||||||
|
state = FoldStatus::HALF_FOLD;
|
||||||
} else if (std::islessequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD - ALTA_HALF_FOLDED_BUFFER) &&
|
} else if (std::islessequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD - ALTA_HALF_FOLDED_BUFFER) &&
|
||||||
hall == HALL_THRESHOLD) {
|
hall == HALL_THRESHOLD) {
|
||||||
state = FoldStatus::HALF_FOLD;
|
state = FoldStatus::HALF_FOLD;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
namespace OHOS::Rosen {
|
namespace OHOS::Rosen {
|
||||||
namespace {
|
namespace {
|
||||||
|
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SingleDisplaySensorPocketFoldStateManager"};
|
||||||
constexpr float ANGLE_MIN_VAL = 0.0F;
|
constexpr float ANGLE_MIN_VAL = 0.0F;
|
||||||
constexpr float ALTA_HALF_FOLDED_MAX_THRESHOLD = 140.0F;
|
constexpr float ALTA_HALF_FOLDED_MAX_THRESHOLD = 140.0F;
|
||||||
constexpr float CLOSE_ALTA_HALF_FOLDED_MIN_THRESHOLD = 70.0F;
|
constexpr float CLOSE_ALTA_HALF_FOLDED_MIN_THRESHOLD = 70.0F;
|
||||||
@ -38,6 +39,8 @@ constexpr int32_t LARGER_BOUNDARY_FLAG = 1;
|
|||||||
constexpr int32_t SMALLER_BOUNDARY_FLAG = 0;
|
constexpr int32_t SMALLER_BOUNDARY_FLAG = 0;
|
||||||
constexpr int32_t HALL_THRESHOLD = 1;
|
constexpr int32_t HALL_THRESHOLD = 1;
|
||||||
constexpr int32_t HALL_FOLDED_THRESHOLD = 0;
|
constexpr int32_t HALL_FOLDED_THRESHOLD = 0;
|
||||||
|
constexpr float TENT_MODE_EXIT_MIN_THRESHOLD = 5.0F;
|
||||||
|
constexpr float TENT_MODE_EXIT_MAX_THRESHOLD = 175.0F;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SingleDisplaySensorPocketFoldStateManager::SingleDisplaySensorPocketFoldStateManager() {}
|
SingleDisplaySensorPocketFoldStateManager::SingleDisplaySensorPocketFoldStateManager() {}
|
||||||
@ -46,6 +49,9 @@ SingleDisplaySensorPocketFoldStateManager::~SingleDisplaySensorPocketFoldStateMa
|
|||||||
void SingleDisplaySensorPocketFoldStateManager::HandleAngleChange(float angle, int hall,
|
void SingleDisplaySensorPocketFoldStateManager::HandleAngleChange(float angle, int hall,
|
||||||
sptr<FoldScreenPolicy> foldScreenPolicy)
|
sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
{
|
{
|
||||||
|
if (IsTentMode()) {
|
||||||
|
return TentModeHandleSensorChange(angle, hall, foldScreenPolicy);
|
||||||
|
}
|
||||||
FoldStatus nextState = GetNextFoldState(angle, hall);
|
FoldStatus nextState = GetNextFoldState(angle, hall);
|
||||||
HandleSensorChange(nextState, angle, foldScreenPolicy);
|
HandleSensorChange(nextState, angle, foldScreenPolicy);
|
||||||
}
|
}
|
||||||
@ -53,6 +59,9 @@ void SingleDisplaySensorPocketFoldStateManager::HandleAngleChange(float angle, i
|
|||||||
void SingleDisplaySensorPocketFoldStateManager::HandleHallChange(float angle, int hall,
|
void SingleDisplaySensorPocketFoldStateManager::HandleHallChange(float angle, int hall,
|
||||||
sptr<FoldScreenPolicy> foldScreenPolicy)
|
sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
{
|
{
|
||||||
|
if (IsTentMode()) {
|
||||||
|
return TentModeHandleSensorChange(angle, hall, foldScreenPolicy);
|
||||||
|
}
|
||||||
FoldStatus nextState = GetNextFoldState(angle, hall);
|
FoldStatus nextState = GetNextFoldState(angle, hall);
|
||||||
HandleSensorChange(nextState, angle, foldScreenPolicy);
|
HandleSensorChange(nextState, angle, foldScreenPolicy);
|
||||||
}
|
}
|
||||||
@ -112,4 +121,50 @@ FoldStatus SingleDisplaySensorPocketFoldStateManager::GetNextFoldState(float ang
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SingleDisplaySensorPocketFoldStateManager::RegisterApplicationStateObserver() {}
|
void SingleDisplaySensorPocketFoldStateManager::RegisterApplicationStateObserver() {}
|
||||||
|
|
||||||
|
void SingleDisplaySensorPocketFoldStateManager::HandleTentChange(bool isTent, sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
|
{
|
||||||
|
bool isNotRepeated = isTent ^ IsTentMode();
|
||||||
|
if (!isNotRepeated) {
|
||||||
|
WLOGI("Repeat reporting tent mode:%{public}s, no processing", (isTent == true) ? "on" : "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetTentMode(isTent);
|
||||||
|
if (foldScreenPolicy == nullptr) {
|
||||||
|
WLOGE("foldScreenPolicy is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTent) {
|
||||||
|
FoldStatus currentState = GetCurrentState();
|
||||||
|
foldScreenPolicy->ChangeOnTentMode(currentState);
|
||||||
|
} else {
|
||||||
|
foldScreenPolicy->ChangeOffTentMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SingleDisplaySensorPocketFoldStateManager::TriggerTentExit(float angle, int hall)
|
||||||
|
{
|
||||||
|
if (hall == HALL_FOLDED_THRESHOLD) {
|
||||||
|
WLOGI("Exit tent mode due to hall sensor report folded");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::isless(angle, TENT_MODE_EXIT_MIN_THRESHOLD) || std::isgreater(angle, TENT_MODE_EXIT_MAX_THRESHOLD)) {
|
||||||
|
WLOGI("Exit tent mode due to angle sensor report angle:%{public}f", angle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplaySensorPocketFoldStateManager::TentModeHandleSensorChange(float angle, int hall,
|
||||||
|
sptr<FoldScreenPolicy> foldScreenPolicy)
|
||||||
|
{
|
||||||
|
if (TriggerTentExit(angle, hall)) {
|
||||||
|
FoldStatus nextState = GetNextFoldState(angle, hall);
|
||||||
|
HandleSensorChange(nextState, angle, foldScreenPolicy);
|
||||||
|
SetTentMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
@ -96,14 +96,15 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod
|
|||||||
TLOGE(WmsLogTag::DMS, "default screenSession is null");
|
TLOGE(WmsLogTag::DMS, "default screenSession is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:ChangeScreenDisplayMode(displayMode = %" PRIu64")", displayMode);
|
||||||
{
|
{
|
||||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
|
|
||||||
"ssm:ChangeScreenDisplayMode(displayMode = %" PRIu64")", displayMode);
|
|
||||||
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||||
if (currentDisplayMode_ == displayMode) {
|
if (currentDisplayMode_ == displayMode) {
|
||||||
TLOGW(WmsLogTag::DMS, "ChangeScreenDisplayMode already in displayMode %{public}d", displayMode);
|
TLOGW(WmsLogTag::DMS, "ChangeScreenDisplayMode already in displayMode %{public}d", displayMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SetdisplayModeChangeStatus(true);
|
SetdisplayModeChangeStatus(true);
|
||||||
ReportFoldDisplayModeChange(displayMode);
|
ReportFoldDisplayModeChange(displayMode);
|
||||||
switch (displayMode) {
|
switch (displayMode) {
|
||||||
@ -124,9 +125,9 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentDisplayMode_ != displayMode) {
|
|
||||||
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||||
}
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||||
currentDisplayMode_ = displayMode;
|
currentDisplayMode_ = displayMode;
|
||||||
lastDisplayMode_ = displayMode;
|
lastDisplayMode_ = displayMode;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ namespace {
|
|||||||
const ScreenId SCREEN_ID_FULL = 0;
|
const ScreenId SCREEN_ID_FULL = 0;
|
||||||
const ScreenId SCREEN_ID_MAIN = 5;
|
const ScreenId SCREEN_ID_MAIN = 5;
|
||||||
|
|
||||||
|
const int32_t REMOVE_DISPLAY_NODE = 0;
|
||||||
|
const int32_t ADD_DISPLAY_NODE = 1;
|
||||||
|
|
||||||
#ifdef TP_FEATURE_ENABLE
|
#ifdef TP_FEATURE_ENABLE
|
||||||
const int32_t TP_TYPE = 12;
|
const int32_t TP_TYPE = 12;
|
||||||
const int32_t TP_TYPE_MAIN = 18;
|
const int32_t TP_TYPE_MAIN = 18;
|
||||||
@ -104,15 +107,39 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp
|
|||||||
TLOGW(WmsLogTag::DMS, "ChangeScreenDisplayMode already in displayMode %{public}d", displayMode);
|
TLOGW(WmsLogTag::DMS, "ChangeScreenDisplayMode already in displayMode %{public}d", displayMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetdisplayModeChangeStatus(true);
|
|
||||||
ReportFoldDisplayModeChange(displayMode);
|
ReportFoldDisplayModeChange(displayMode);
|
||||||
|
|
||||||
|
ChangeScreenDisplayModeProc(screenSession, displayMode);
|
||||||
|
|
||||||
|
if (currentDisplayMode_ != displayMode) {
|
||||||
|
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||||
|
}
|
||||||
|
currentDisplayMode_ = displayMode;
|
||||||
|
lastDisplayMode_ = displayMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeProc(sptr<ScreenSession> screenSession,
|
||||||
|
FoldDisplayMode displayMode)
|
||||||
|
{
|
||||||
switch (displayMode) {
|
switch (displayMode) {
|
||||||
case FoldDisplayMode::MAIN: {
|
case FoldDisplayMode::MAIN: {
|
||||||
|
if (currentDisplayMode_ == FoldDisplayMode::COORDINATION) {
|
||||||
|
CloseCoordinationScreen();
|
||||||
|
}
|
||||||
ChangeScreenDisplayModeToMain(screenSession);
|
ChangeScreenDisplayModeToMain(screenSession);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FoldDisplayMode::FULL: {
|
case FoldDisplayMode::FULL: {
|
||||||
|
if (currentDisplayMode_ == FoldDisplayMode::COORDINATION) {
|
||||||
|
CloseCoordinationScreen();
|
||||||
|
} else {
|
||||||
ChangeScreenDisplayModeToFull(screenSession);
|
ChangeScreenDisplayModeToFull(screenSession);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FoldDisplayMode::COORDINATION: {
|
||||||
|
ChangeScreenDisplayModeToCoordination();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FoldDisplayMode::UNKNOWN: {
|
case FoldDisplayMode::UNKNOWN: {
|
||||||
@ -124,12 +151,6 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentDisplayMode_ != displayMode) {
|
|
||||||
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
|
||||||
}
|
|
||||||
currentDisplayMode_ = displayMode;
|
|
||||||
lastDisplayMode_ = displayMode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleDisplayPocketFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
void SingleDisplayPocketFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
||||||
@ -233,16 +254,8 @@ void SingleDisplayPocketFoldPolicy::ReportFoldStatusChangeBegin(int32_t offScree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession)
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenOn(sptr<ScreenSession> screenSession)
|
||||||
{
|
{
|
||||||
if (onBootAnimation_) {
|
|
||||||
ChangeScreenDisplayModeToMainOnBootAnimation(screenSession);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef TP_FEATURE_ENABLE
|
|
||||||
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, MAIN_TP.c_str());
|
|
||||||
#endif
|
|
||||||
if (PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn()) {
|
|
||||||
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is true, begin.");
|
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is true, begin.");
|
||||||
ReportFoldStatusChangeBegin(static_cast<int32_t>(SCREEN_ID_FULL),
|
ReportFoldStatusChangeBegin(static_cast<int32_t>(SCREEN_ID_FULL),
|
||||||
static_cast<int32_t>(SCREEN_ID_MAIN));
|
static_cast<int32_t>(SCREEN_ID_MAIN));
|
||||||
@ -264,7 +277,10 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSes
|
|||||||
SetdisplayModeChangeStatus(false);
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOn, "screenOnMainOnTask");
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOn, "screenOnMainOnTask");
|
||||||
} else { // When the screen is off and folded, it is not powered on
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession)
|
||||||
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is false, begin.");
|
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is false, begin.");
|
||||||
// off full screen
|
// off full screen
|
||||||
auto taskScreenOffMainOff = [=] {
|
auto taskScreenOffMainOff = [=] {
|
||||||
@ -275,20 +291,42 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSes
|
|||||||
};
|
};
|
||||||
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOffMainOff, "screenOffMainOffTask");
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOffMainOff, "screenOffMainOffTask");
|
||||||
SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING);
|
SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING);
|
||||||
|
bool ifTentMode = ScreenSessionManager::GetInstance().GetTentMode();
|
||||||
auto taskScreenOnMainChangeScreenId = [=] {
|
auto taskScreenOnMainChangeScreenId = [=] {
|
||||||
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToMain: IsFoldScreenOn is false, Change ScreenId to Main.");
|
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToMain: IsFoldScreenOn is false, Change ScreenId to Main.");
|
||||||
screenId_ = SCREEN_ID_MAIN;
|
screenId_ = SCREEN_ID_MAIN;
|
||||||
#ifdef TP_FEATURE_ENABLE
|
#ifdef TP_FEATURE_ENABLE
|
||||||
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE_MAIN, MAIN_TP_OFF.c_str());
|
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE_MAIN, MAIN_TP_OFF.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
if (ifTentMode) {
|
||||||
|
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||||
|
}
|
||||||
SetdisplayModeChangeStatus(false);
|
SetdisplayModeChangeStatus(false);
|
||||||
};
|
};
|
||||||
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainChangeScreenId, "taskScreenOnMainChangeScreenId");
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainChangeScreenId, "taskScreenOnMainChangeScreenId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession)
|
||||||
|
{
|
||||||
|
SetdisplayModeChangeStatus(true);
|
||||||
|
if (onBootAnimation_) {
|
||||||
|
ChangeScreenDisplayModeToMainOnBootAnimation(screenSession);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef TP_FEATURE_ENABLE
|
||||||
|
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, MAIN_TP.c_str());
|
||||||
|
#endif
|
||||||
|
if (PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn()) {
|
||||||
|
ChangeScreenDisplayModeToMainWhenFoldScreenOn(screenSession);
|
||||||
|
} else { // When the screen is off and folded, it is not powered on
|
||||||
|
ChangeScreenDisplayModeToMainWhenFoldScreenOff(screenSession);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession)
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession)
|
||||||
{
|
{
|
||||||
|
SetdisplayModeChangeStatus(true);
|
||||||
if (onBootAnimation_) {
|
if (onBootAnimation_) {
|
||||||
ChangeScreenDisplayModeToFullOnBootAnimation(screenSession);
|
ChangeScreenDisplayModeToFullOnBootAnimation(screenSession);
|
||||||
return;
|
return;
|
||||||
@ -385,4 +423,114 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFullOnBootAnimation
|
|||||||
screenSession->GetScreenProperty().GetBounds().rect_.height_);
|
screenSession->GetScreenProperty().GetBounds().rect_.height_);
|
||||||
screenId_ = SCREEN_ID_FULL;
|
screenId_ = SCREEN_ID_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::BootAnimationFinishPowerInit()
|
||||||
|
{
|
||||||
|
int64_t timeStamp = 50;
|
||||||
|
if (RSInterfaces::GetInstance().GetActiveScreenId() == SCREEN_ID_FULL) {
|
||||||
|
// 同显切内屏:外屏下电
|
||||||
|
TLOGI(WmsLogTag::DMS, "Fold Screen Power main screen off.");
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
} else if (RSInterfaces::GetInstance().GetActiveScreenId() == SCREEN_ID_MAIN) {
|
||||||
|
// 同显切外屏:双屏都灭再外屏上电
|
||||||
|
TLOGI(WmsLogTag::DMS, "Fold Screen Power all screen off.");
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(timeStamp));
|
||||||
|
TLOGI(WmsLogTag::DMS, "Fold Screen Power main screen on.");
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
|
||||||
|
} else {
|
||||||
|
TLOGI(WmsLogTag::DMS, "Fold Screen Power Init, invalid active screen id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeOnTentMode(FoldStatus currentState)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "Enter tent mode, current state:%{public}d, change display mode to MAIN", currentState);
|
||||||
|
if (currentState == FoldStatus::EXPAND || currentState == FoldStatus::HALF_FOLD) {
|
||||||
|
ChangeScreenDisplayMode(FoldDisplayMode::MAIN);
|
||||||
|
} else if (currentState == FoldStatus::FOLDED) {
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
ChangeScreenDisplayMode(FoldDisplayMode::MAIN);
|
||||||
|
RSInterfaces::GetInstance().SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
|
||||||
|
} else {
|
||||||
|
TLOGE(WmsLogTag::DMS, "current state:%{public}d invalid", currentState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeOffTentMode()
|
||||||
|
{
|
||||||
|
FoldDisplayMode displayMode = GetModeMatchStatus();
|
||||||
|
ChangeScreenDisplayMode(displayMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "AddOrRemoveDisplayNodeToTree, screenId: %{public}" PRIu64 ", command: %{public}d",
|
||||||
|
screenId, command);
|
||||||
|
sptr<ScreenSession> screenSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId);
|
||||||
|
if (screenSession == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "AddOrRemoveDisplayNodeToTree, screenSession is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::shared_ptr<RSDisplayNode> displayNode = screenSession->GetDisplayNode();
|
||||||
|
if (displayNode == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "AddOrRemoveDisplayNodeToTree, displayNode is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (command == ADD_DISPLAY_NODE) {
|
||||||
|
displayNode->AddDisplayNodeToTree();
|
||||||
|
} else if (command == REMOVE_DISPLAY_NODE) {
|
||||||
|
displayNode->RemoveDisplayNodeFromTree();
|
||||||
|
}
|
||||||
|
displayNode = nullptr;
|
||||||
|
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||||
|
if (transactionProxy != nullptr) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "add or remove displayNode");
|
||||||
|
transactionProxy->FlushImplicitTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToCoordination()
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "change displaymode to coordination current mode=%{public}d", currentDisplayMode_);
|
||||||
|
|
||||||
|
ScreenSessionManager::GetInstance().SetCoordinationFlag(true);
|
||||||
|
ScreenSessionManager::GetInstance().OnScreenChange(SCREEN_ID_MAIN, ScreenEvent::CONNECTED);
|
||||||
|
|
||||||
|
// on main screen
|
||||||
|
auto taskScreenOnMainOn = [=] {
|
||||||
|
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToCoordination: screenIdMain ON.");
|
||||||
|
ChangeScreenDisplayModePower(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
|
||||||
|
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
|
||||||
|
};
|
||||||
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOn, "ScreenToCoordinationTask");
|
||||||
|
AddOrRemoveDisplayNodeToTree(SCREEN_ID_MAIN, ADD_DISPLAY_NODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::CloseCoordinationScreen()
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "Close Coordination Screen current mode=%{public}d", currentDisplayMode_);
|
||||||
|
|
||||||
|
// on main screen
|
||||||
|
auto taskScreenOnMainOFF = [=] {
|
||||||
|
TLOGI(WmsLogTag::DMS, "CloseCoordinationScreen: screenIdMain OFF.");
|
||||||
|
ChangeScreenDisplayModePower(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF);
|
||||||
|
};
|
||||||
|
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOFF, "CloseCoordinationScreenTask");
|
||||||
|
AddOrRemoveDisplayNodeToTree(SCREEN_ID_MAIN, REMOVE_DISPLAY_NODE);
|
||||||
|
|
||||||
|
ScreenSessionManager::GetInstance().OnScreenChange(SCREEN_ID_MAIN, ScreenEvent::DISCONNECTED);
|
||||||
|
ScreenSessionManager::GetInstance().SetCoordinationFlag(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleDisplayPocketFoldPolicy::ExitCoordination()
|
||||||
|
{
|
||||||
|
CloseCoordinationScreen();
|
||||||
|
FoldDisplayMode displayMode = GetModeMatchStatus();
|
||||||
|
currentDisplayMode_ = displayMode;
|
||||||
|
lastDisplayMode_ = displayMode;
|
||||||
|
TLOGI(WmsLogTag::DMS, "Exit coordination, current display mode:%{public}d", displayMode);
|
||||||
|
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
@ -59,5 +59,22 @@ float ScreenRotationProperty::ConvertDeviceToFloat(DeviceRotation deviceRotation
|
|||||||
}
|
}
|
||||||
return sensorRotation;
|
return sensorRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus hoverStatus)
|
||||||
|
{
|
||||||
|
static DeviceHoverStatus lastHoverStatusConverted_ = DeviceHoverStatus::INVALID;
|
||||||
|
TLOGI(WmsLogTag::DMS, "DeviceHoverStatus: %{public}d, "
|
||||||
|
"lastHoverStatusConverted: %{public}d", hoverStatus, lastHoverStatusConverted_);
|
||||||
|
|
||||||
|
if (hoverStatus != DeviceHoverStatus::INVALID) {
|
||||||
|
lastHoverStatusConverted_ = hoverStatus;
|
||||||
|
}
|
||||||
|
auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession();
|
||||||
|
if (!screenSession) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "screenSession is null, sensor rotation status handle failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
screenSession->HandleHoverStatusChange(static_cast<int32_t>(hoverStatus));
|
||||||
|
}
|
||||||
} // Rosen
|
} // Rosen
|
||||||
} // OHOS
|
} // OHOS
|
@ -26,12 +26,16 @@ namespace {
|
|||||||
constexpr int32_t MOTION_ACTION_LEFT_LANDSCAPE = 1;
|
constexpr int32_t MOTION_ACTION_LEFT_LANDSCAPE = 1;
|
||||||
constexpr int32_t MOTION_ACTION_PORTRAIT_INVERTED = 2;
|
constexpr int32_t MOTION_ACTION_PORTRAIT_INVERTED = 2;
|
||||||
constexpr int32_t MOTION_ACTION_RIGHT_LANDSCAPE = 3;
|
constexpr int32_t MOTION_ACTION_RIGHT_LANDSCAPE = 3;
|
||||||
|
constexpr int32_t MOTION_ACTION_TENT_MODE_OFF = 0;
|
||||||
|
constexpr int32_t MOTION_ACTION_TENT_MODE_ON = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
||||||
bool MotionSubscriber::isMotionSensorSubscribed_ = false;
|
bool MotionSubscriber::isMotionSensorSubscribed_ = false;
|
||||||
sptr<RotationMotionEventCallback> MotionSubscriber::motionEventCallback_ = nullptr;
|
sptr<RotationMotionEventCallback> MotionSubscriber::motionEventCallback_ = nullptr;
|
||||||
|
bool MotionTentSubscriber::isMotionSensorSubscribed_ = false;
|
||||||
|
sptr<TentMotionEventCallback> MotionTentSubscriber::motionEventCallback_ = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ScreenSensorConnector::SubscribeRotationSensor()
|
void ScreenSensorConnector::SubscribeRotationSensor()
|
||||||
@ -52,6 +56,21 @@ void ScreenSensorConnector::UnsubscribeRotationSensor()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSensorConnector::SubscribeTentSensor()
|
||||||
|
{
|
||||||
|
TLOGD(WmsLogTag::DMS, "dms: subscribe tent sensor");
|
||||||
|
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
||||||
|
MotionTentSubscriber::SubscribeMotionSensor();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSensorConnector::UnsubscribeTentSensor()
|
||||||
|
{
|
||||||
|
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
||||||
|
MotionTentSubscriber::UnsubscribeMotionSensor();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Motion
|
// Motion
|
||||||
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
|
||||||
void MotionSubscriber::SubscribeMotionSensor()
|
void MotionSubscriber::SubscribeMotionSensor()
|
||||||
@ -113,6 +132,52 @@ void RotationMotionEventCallback::OnMotionChanged(const MotionEvent& motionData)
|
|||||||
}
|
}
|
||||||
ScreenRotationProperty::HandleSensorEventInput(motionRotation);
|
ScreenRotationProperty::HandleSensorEventInput(motionRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MotionTentSubscriber::SubscribeMotionSensor()
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "dms: Subscribe tent motion Sensor");
|
||||||
|
if (isMotionSensorSubscribed_) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "dms: tent motion sensor's already subscribed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<TentMotionEventCallback> callback = new (std::nothrow) TentMotionEventCallback();
|
||||||
|
if (callback == nullptr) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "dms: malloc tent motion callback failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = OHOS::Msdp::SubscribeCallback(OHOS::Msdp::MOTION_TYPE_TENT, callback);
|
||||||
|
if (ret != 0) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "dms: SubscribeCallback type:%{public}d failed", OHOS::Msdp::MOTION_TYPE_TENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
motionEventCallback_ = callback;
|
||||||
|
isMotionSensorSubscribed_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MotionTentSubscriber::UnsubscribeMotionSensor()
|
||||||
|
{
|
||||||
|
if (!isMotionSensorSubscribed_) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "dms: Unsubscribe tent motion sensor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = OHOS::Msdp::UnsubscribeCallback(OHOS::Msdp::MOTION_TYPE_TENT, motionEventCallback_);
|
||||||
|
if (ret != static_cast<int32_t>(OHOS::Msdp::MotionErrorCode::MOTION_SUCCESS)
|
||||||
|
&& ret != static_cast<int32_t>(OHOS::Msdp::MotionErrorCode::MOTION_NO_SUBSCRIBE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isMotionSensorSubscribed_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TentMotionEventCallback::OnMotionChanged(const MotionEvent& motionData)
|
||||||
|
{
|
||||||
|
if (motionData.status == MOTION_ACTION_TENT_MODE_ON) {
|
||||||
|
ScreenTentProperty::HandleSensorEventInput(true);
|
||||||
|
} else if (motionData.status == MOTION_ACTION_TENT_MODE_OFF) {
|
||||||
|
ScreenTentProperty::HandleSensorEventInput(false);
|
||||||
|
} else {
|
||||||
|
TLOGI(WmsLogTag::DMS, "dms: tent motion:%{public}d invalid", motionData.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} // Rosen
|
} // Rosen
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -30,16 +30,28 @@ constexpr int LINE_WIDTH = 30;
|
|||||||
constexpr int DUMPER_PARAM_INDEX_ONE = 1;
|
constexpr int DUMPER_PARAM_INDEX_ONE = 1;
|
||||||
constexpr int DUMPER_PARAM_INDEX_TWO = 2;
|
constexpr int DUMPER_PARAM_INDEX_TWO = 2;
|
||||||
constexpr int DUMPER_PARAM_INDEX_THREE = 3;
|
constexpr int DUMPER_PARAM_INDEX_THREE = 3;
|
||||||
constexpr int MOTION_SENSOR_PARAM_SIZE = 2;
|
|
||||||
const std::string ARG_DUMP_HELP = "-h";
|
const std::string ARG_DUMP_HELP = "-h";
|
||||||
const std::string ARG_DUMP_ALL = "-a";
|
const std::string ARG_DUMP_ALL = "-a";
|
||||||
|
const std::string ARG_DUMP_FOLD_STATUS = "-f";
|
||||||
|
#ifndef IS_RELEASE_VERSION
|
||||||
|
constexpr int MOTION_SENSOR_PARAM_SIZE = 2;
|
||||||
const std::string STATUS_FOLD_HALF = "-z";
|
const std::string STATUS_FOLD_HALF = "-z";
|
||||||
const std::string STATUS_EXPAND = "-y";
|
const std::string STATUS_EXPAND = "-y";
|
||||||
const std::string STATUS_FOLD = "-p";
|
const std::string STATUS_FOLD = "-p";
|
||||||
const std::string ARG_DUMP_FOLD_STATUS = "-f";
|
|
||||||
const std::string ARG_SET_ROTATION_SENSOR = "-motion"; // rotation event inject
|
const std::string ARG_SET_ROTATION_SENSOR = "-motion"; // rotation event inject
|
||||||
const std::string ARG_SET_ROTATION_LOCK = "-rotationlock";
|
const std::string ARG_SET_ROTATION_LOCK = "-rotationlock";
|
||||||
const std::string ARG_PUBLISH_CAST_EVENT = "-publishcastevent";
|
const std::string ARG_PUBLISH_CAST_EVENT = "-publishcastevent";
|
||||||
|
const std::string ARG_FOLD_DISPLAY_FULL = "-f";
|
||||||
|
const std::string ARG_FOLD_DISPLAY_MAIN = "-m";
|
||||||
|
const std::string ARG_FOLD_DISPLAY_SUB = "-sub";
|
||||||
|
const std::string ARG_FOLD_DISPLAY_COOR = "-coor";
|
||||||
|
const std::vector<std::string> displayModeCommands = {"-f", "-m", "-sub", "-coor"};
|
||||||
|
const std::string ARG_LOCK_FOLD_DISPLAY_STATUS = "-l";
|
||||||
|
const std::string ARG_UNLOCK_FOLD_DISPLAY_STATUS = "-u";
|
||||||
|
const std::string ARG_SET_ON_TENT_MODE = "-ontent";
|
||||||
|
const std::string ARG_SET_OFF_TENT_MODE = "-offtent";
|
||||||
|
const std::string ARG_SET_HOVER_STATUS = "-hoverstatus";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetProcessNameByPid(int32_t pid)
|
static std::string GetProcessNameByPid(int32_t pid)
|
||||||
@ -112,7 +124,15 @@ void ScreenSessionDumper::ExcuteDumpCmd()
|
|||||||
ShowAllScreenInfo();
|
ShowAllScreenInfo();
|
||||||
} else if (params_[0] == ARG_DUMP_FOLD_STATUS) {
|
} else if (params_[0] == ARG_DUMP_FOLD_STATUS) {
|
||||||
DumpFoldStatus();
|
DumpFoldStatus();
|
||||||
} else if (params_[0] == STATUS_FOLD_HALF || params_[0] == STATUS_EXPAND || params_[0] == STATUS_FOLD) {
|
}
|
||||||
|
ExcuteInjectCmd();
|
||||||
|
OutputDumpInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::ExcuteInjectCmd()
|
||||||
|
{
|
||||||
|
#ifndef IS_RELEASE_VERSION
|
||||||
|
if (params_[0] == STATUS_FOLD_HALF || params_[0] == STATUS_EXPAND || params_[0] == STATUS_FOLD) {
|
||||||
ShowNotifyFoldStatusChangedInfo();
|
ShowNotifyFoldStatusChangedInfo();
|
||||||
} else if (params_[0].find(ARG_SET_ROTATION_SENSOR) != std::string::npos) {
|
} else if (params_[0].find(ARG_SET_ROTATION_SENSOR) != std::string::npos) {
|
||||||
SetMotionSensorvalue(params_[0]);
|
SetMotionSensorvalue(params_[0]);
|
||||||
@ -120,73 +140,24 @@ void ScreenSessionDumper::ExcuteDumpCmd()
|
|||||||
SetRotationLockedvalue(params_[0]);
|
SetRotationLockedvalue(params_[0]);
|
||||||
} else if (params_[0].find(ARG_PUBLISH_CAST_EVENT) != std::string::npos) {
|
} else if (params_[0].find(ARG_PUBLISH_CAST_EVENT) != std::string::npos) {
|
||||||
MockSendCastPublishEvent(params_[0]);
|
MockSendCastPublishEvent(params_[0]);
|
||||||
|
} else if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) {
|
||||||
|
int errCode = SetFoldDisplayMode();
|
||||||
|
if (errCode != 0) {
|
||||||
|
ShowIllegalArgsInfo();
|
||||||
}
|
}
|
||||||
OutputDumpInfo();
|
} else if (params_.size() == 1 && (params_[0] == ARG_LOCK_FOLD_DISPLAY_STATUS
|
||||||
|
|| params_[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) {
|
||||||
|
int errCode = SetFoldStatusLocked();
|
||||||
|
if (errCode != 0) {
|
||||||
|
ShowIllegalArgsInfo();
|
||||||
}
|
}
|
||||||
|
} else if (params_[0].find(ARG_SET_ON_TENT_MODE) != std::string::npos ||
|
||||||
void ScreenSessionDumper::SetMotionSensorvalue(std::string input)
|
params_[0].find(ARG_SET_OFF_TENT_MODE) != std::string::npos) {
|
||||||
{
|
SetEnterOrExitTentMode(params_[0]);
|
||||||
size_t commaPos = input.find_last_of(',');
|
} else if (params_[0].find(ARG_SET_HOVER_STATUS) != std::string::npos) {
|
||||||
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_ROTATION_SENSOR)) {
|
SetHoverStatusChange(params_[0]);
|
||||||
std::string valueStr = input.substr(commaPos + 1, MOTION_SENSOR_PARAM_SIZE);
|
|
||||||
if (valueStr.size() == 1 && !std::isdigit(valueStr[0])) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (valueStr.size() == MOTION_SENSOR_PARAM_SIZE && valueStr != "-1") {
|
#endif
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t value = std::stoi(valueStr);
|
|
||||||
if (value < static_cast<int32_t>(DeviceRotation::INVALID) ||
|
|
||||||
value > static_cast<int32_t>(DeviceRotation::ROTATION_LANDSCAPE_INVERTED)) {
|
|
||||||
TLOGE(WmsLogTag::DMS, "params is invalid: %{public}d", value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ScreenRotationProperty::HandleSensorEventInput(static_cast<DeviceRotation>(value));
|
|
||||||
TLOGI(WmsLogTag::DMS, "mock motion sensor: %{public}d", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSessionDumper::SetRotationLockedvalue(std::string input)
|
|
||||||
{
|
|
||||||
size_t commaPos = input.find_last_of(',');
|
|
||||||
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_ROTATION_LOCK)) {
|
|
||||||
std::string valueStr = input.substr(commaPos + 1);
|
|
||||||
if (valueStr.size() != 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!std::isdigit(valueStr[0])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t value = std::stoi(valueStr);
|
|
||||||
ScreenSessionManager::GetInstance().SetScreenRotationLocked(static_cast<bool>(value));
|
|
||||||
TLOGI(WmsLogTag::DMS, "mock rotation locked: %{public}d", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSessionDumper::MockSendCastPublishEvent(std::string input)
|
|
||||||
{
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "-------------- DMS SEND CAST PUBLISH EVENT --------------" << std::endl;
|
|
||||||
size_t commaPos = input.find_last_of(',');
|
|
||||||
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_PUBLISH_CAST_EVENT)) {
|
|
||||||
std::string valueStr = input.substr(commaPos + 1);
|
|
||||||
if (valueStr.size() != 1) {
|
|
||||||
oss << std::left << "[error]: " << "the value is too long" << std::endl;
|
|
||||||
dumpInfo_.append(oss.str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!std::isdigit(valueStr[0])) {
|
|
||||||
oss << std::left << "[error]: " << "value is not a number" << std::endl;
|
|
||||||
dumpInfo_.append(oss.str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t value = std::stoi(valueStr);
|
|
||||||
ScreenSessionManager::GetInstance().NotifyCastWhenScreenConnectChange(static_cast<bool>(value));
|
|
||||||
oss << std::left << "[success]: " << "send cast publish event success" << std::endl;
|
|
||||||
} else {
|
|
||||||
oss << std::left << "[error]: " << "the command is invalid" << std::endl;
|
|
||||||
}
|
|
||||||
dumpInfo_.append(oss.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionDumper::DumpEventTracker(EventTracker& tracker)
|
void ScreenSessionDumper::DumpEventTracker(EventTracker& tracker)
|
||||||
@ -251,6 +222,7 @@ void ScreenSessionDumper::ShowAllScreenInfo()
|
|||||||
oss << "---------------- Screen ID: " << screenId << " ----------------" << std::endl;
|
oss << "---------------- Screen ID: " << screenId << " ----------------" << std::endl;
|
||||||
dumpInfo_.append(oss.str());
|
dumpInfo_.append(oss.str());
|
||||||
DumpFoldStatus();
|
DumpFoldStatus();
|
||||||
|
DumpTentMode();
|
||||||
DumpScreenSessionById(screenId);
|
DumpScreenSessionById(screenId);
|
||||||
DumpRsInfoById(screenId);
|
DumpRsInfoById(screenId);
|
||||||
DumpCutoutInfoById(screenId);
|
DumpCutoutInfoById(screenId);
|
||||||
@ -287,6 +259,21 @@ void ScreenSessionDumper::DumpFoldStatus()
|
|||||||
dumpInfo_.append(oss.str());
|
dumpInfo_.append(oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::DumpTentMode()
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
bool isTentMode = ScreenSessionManager::GetInstance().GetTentMode();
|
||||||
|
std::string status = "";
|
||||||
|
if (isTentMode) {
|
||||||
|
status = "TRUE";
|
||||||
|
} else {
|
||||||
|
status = "FALSE";
|
||||||
|
}
|
||||||
|
oss << std::left << std::setw(LINE_WIDTH) << "TentMode: "
|
||||||
|
<< status << std::endl;
|
||||||
|
dumpInfo_.append(oss.str());
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSessionDumper::DumpScreenSessionById(ScreenId id)
|
void ScreenSessionDumper::DumpScreenSessionById(ScreenId id)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -330,8 +317,7 @@ void ScreenSessionDumper::DumpRsInfoById(ScreenId id)
|
|||||||
TLOGE(WmsLogTag::DMS, "screenSession nullptr. screen id: %{public}" PRIu64"", id);
|
TLOGE(WmsLogTag::DMS, "screenSession nullptr. screen id: %{public}" PRIu64"", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScreenPowerState state = ScreenPowerState::INVALID_STATE;
|
auto state = static_cast<ScreenPowerState>(RSInterfaces::GetInstance().GetScreenPowerStatus(id));
|
||||||
state = static_cast<ScreenPowerState>(RSInterfaces::GetInstance().GetScreenPowerStatus(id));
|
|
||||||
oss << std::left << std::setw(LINE_WIDTH) << "ScreenPowerState: "
|
oss << std::left << std::setw(LINE_WIDTH) << "ScreenPowerState: "
|
||||||
<< static_cast<int32_t>(state) << std::endl;
|
<< static_cast<int32_t>(state) << std::endl;
|
||||||
std::vector<ScreenColorGamut> colorGamuts;
|
std::vector<ScreenColorGamut> colorGamuts;
|
||||||
@ -517,6 +503,7 @@ void ScreenSessionDumper::DumpScreenPropertyById(ScreenId id)
|
|||||||
dumpInfo_.append(oss.str());
|
dumpInfo_.append(oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef IS_RELEASE_VERSION
|
||||||
void ScreenSessionDumper::ShowNotifyFoldStatusChangedInfo()
|
void ScreenSessionDumper::ShowNotifyFoldStatusChangedInfo()
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "params_: [%{public}s]", params_[0].c_str());
|
TLOGI(WmsLogTag::DMS, "params_: [%{public}s]", params_[0].c_str());
|
||||||
@ -536,5 +523,147 @@ void ScreenSessionDumper::ShowIllegalArgsInfo()
|
|||||||
{
|
{
|
||||||
dumpInfo_.append("The arguments are illegal and you can enter '-h' for help.");
|
dumpInfo_.append("The arguments are illegal and you can enter '-h' for help.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::SetMotionSensorvalue(std::string input)
|
||||||
|
{
|
||||||
|
size_t commaPos = input.find_last_of(',');
|
||||||
|
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_ROTATION_SENSOR)) {
|
||||||
|
std::string valueStr = input.substr(commaPos + 1, MOTION_SENSOR_PARAM_SIZE);
|
||||||
|
if (valueStr.size() == 1 && !std::isdigit(valueStr[0])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (valueStr.size() == MOTION_SENSOR_PARAM_SIZE && valueStr != "-1") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t value = std::stoi(valueStr);
|
||||||
|
if (value < static_cast<int32_t>(DeviceRotation::INVALID) ||
|
||||||
|
value > static_cast<int32_t>(DeviceRotation::ROTATION_LANDSCAPE_INVERTED)) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "params is invalid: %{public}d", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ScreenRotationProperty::HandleSensorEventInput(static_cast<DeviceRotation>(value));
|
||||||
|
TLOGI(WmsLogTag::DMS, "mock motion sensor: %{public}d", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::SetRotationLockedvalue(std::string input)
|
||||||
|
{
|
||||||
|
size_t commaPos = input.find_last_of(',');
|
||||||
|
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_ROTATION_LOCK)) {
|
||||||
|
std::string valueStr = input.substr(commaPos + 1);
|
||||||
|
if (valueStr.size() != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!std::isdigit(valueStr[0])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t value = std::stoi(valueStr);
|
||||||
|
ScreenSessionManager::GetInstance().SetScreenRotationLocked(static_cast<bool>(value));
|
||||||
|
TLOGI(WmsLogTag::DMS, "mock rotation locked: %{public}d", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::MockSendCastPublishEvent(std::string input)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "-------------- DMS SEND CAST PUBLISH EVENT --------------" << std::endl;
|
||||||
|
size_t commaPos = input.find_last_of(',');
|
||||||
|
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_PUBLISH_CAST_EVENT)) {
|
||||||
|
std::string valueStr = input.substr(commaPos + 1);
|
||||||
|
if (valueStr.size() != 1) {
|
||||||
|
oss << std::left << "[error]: " << "the value is too long" << std::endl;
|
||||||
|
dumpInfo_.append(oss.str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!std::isdigit(valueStr[0])) {
|
||||||
|
oss << std::left << "[error]: " << "value is not a number" << std::endl;
|
||||||
|
dumpInfo_.append(oss.str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t value = std::stoi(valueStr);
|
||||||
|
ScreenSessionManager::GetInstance().NotifyCastWhenScreenConnectChange(static_cast<bool>(value));
|
||||||
|
oss << std::left << "[success]: " << "send cast publish event success" << std::endl;
|
||||||
|
} else {
|
||||||
|
oss << std::left << "[error]: " << "the command is invalid" << std::endl;
|
||||||
|
}
|
||||||
|
dumpInfo_.append(oss.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenSessionDumper::IsValidDisplayModeCommand(std::string command)
|
||||||
|
{
|
||||||
|
if (std::find(displayModeCommands.begin(), displayModeCommands.end(), command) != displayModeCommands.end()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScreenSessionDumper::SetFoldDisplayMode()
|
||||||
|
{
|
||||||
|
std::string modeParam = params_[0];
|
||||||
|
if (modeParam.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
|
||||||
|
if (modeParam == ARG_FOLD_DISPLAY_FULL) {
|
||||||
|
displayMode = FoldDisplayMode::FULL;
|
||||||
|
} else if (modeParam == ARG_FOLD_DISPLAY_MAIN) {
|
||||||
|
displayMode = FoldDisplayMode::MAIN;
|
||||||
|
} else if (modeParam == ARG_FOLD_DISPLAY_SUB) {
|
||||||
|
displayMode = FoldDisplayMode::SUB;
|
||||||
|
} else if (modeParam == ARG_FOLD_DISPLAY_COOR) {
|
||||||
|
displayMode = FoldDisplayMode::COORDINATION;
|
||||||
|
} else {
|
||||||
|
TLOGW(WmsLogTag::DMS, "SetFoldDisplayMode mode not support");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ScreenSessionManager::GetInstance().SetFoldDisplayMode(displayMode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScreenSessionDumper::SetFoldStatusLocked()
|
||||||
|
{
|
||||||
|
std::string lockParam = params_[0];
|
||||||
|
if (lockParam.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
bool lockDisplayStatus = false;
|
||||||
|
if (lockParam == ARG_LOCK_FOLD_DISPLAY_STATUS) {
|
||||||
|
lockDisplayStatus = true;
|
||||||
|
} else if (lockParam == ARG_UNLOCK_FOLD_DISPLAY_STATUS) {
|
||||||
|
lockDisplayStatus = false;
|
||||||
|
} else {
|
||||||
|
TLOGW(WmsLogTag::DMS, "SetFoldStatusLocked status not support");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ScreenSessionManager::GetInstance().SetFoldStatusLocked(lockDisplayStatus);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::SetEnterOrExitTentMode(std::string input)
|
||||||
|
{
|
||||||
|
if (input == ARG_SET_ON_TENT_MODE) {
|
||||||
|
ScreenSessionManager::GetInstance().OnTentModeChanged(true);
|
||||||
|
} else if (input == ARG_SET_OFF_TENT_MODE) {
|
||||||
|
ScreenSessionManager::GetInstance().OnTentModeChanged(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionDumper::SetHoverStatusChange(std::string input)
|
||||||
|
{
|
||||||
|
size_t commaPos = input.find_last_of(',');
|
||||||
|
auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession();
|
||||||
|
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_HOVER_STATUS)) {
|
||||||
|
std::string valueStr = input.substr(commaPos + 1);
|
||||||
|
int32_t value = std::stoi(valueStr);
|
||||||
|
if ((value < static_cast<int32_t>(DeviceHoverStatus::INVALID)) ||
|
||||||
|
(value > static_cast<int32_t>(DeviceHoverStatus::CAMERA_STATUS_CANCEL))) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "params is invalid: %{public}d", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
screenSession->HoverStatusChange(value);
|
||||||
|
TLOGI(WmsLogTag::DMS, "SetHoverStatusChange: %{public}d", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} // Rosen
|
} // Rosen
|
||||||
} // OHOS
|
} // OHOS
|
@ -66,25 +66,14 @@ const int32_t CV_WAIT_SCREENON_MS = 300;
|
|||||||
const int32_t CV_WAIT_SCREENOFF_MS = 1500;
|
const int32_t CV_WAIT_SCREENOFF_MS = 1500;
|
||||||
const int32_t CV_WAIT_SCREENOFF_MS_MAX = 3000;
|
const int32_t CV_WAIT_SCREENOFF_MS_MAX = 3000;
|
||||||
const int32_t CV_WAIT_SCBSWITCH_MS = 3000;
|
const int32_t CV_WAIT_SCBSWITCH_MS = 3000;
|
||||||
const std::u16string DEFAULT_USTRING = u"error";
|
const int64_t SWITCH_USER_DISPLAYMODE_CHANGE_DELAY = 500;
|
||||||
const std::string DEFAULT_STRING = "error";
|
|
||||||
const std::string ARG_DUMP_HELP = "-h";
|
|
||||||
const std::string ARG_DUMP_ALL = "-a";
|
|
||||||
const std::string ARG_DUMP_SCREEN = "-s";
|
|
||||||
const std::string ARG_FOLD_DISPLAY_FULL = "-f";
|
|
||||||
const std::string ARG_FOLD_DISPLAY_MAIN = "-m";
|
|
||||||
const std::string ARG_FOLD_DISPLAY_SUB = "-sub";
|
|
||||||
const std::string ARG_FOLD_DISPLAY_COOR = "-coor";
|
|
||||||
const std::string STATUS_FOLD_HALF = "-z";
|
const std::string STATUS_FOLD_HALF = "-z";
|
||||||
const std::string STATUS_EXPAND = "-y";
|
const std::string STATUS_EXPAND = "-y";
|
||||||
const std::string STATUS_FOLD = "-p";
|
const std::string STATUS_FOLD = "-p";
|
||||||
const std::string ARG_LOCK_FOLD_DISPLAY_STATUS = "-l";
|
|
||||||
const std::string ARG_UNLOCK_FOLD_DISPLAY_STATUS = "-u";
|
|
||||||
const std::string SETTING_LOCKED_KEY = "settings.general.accelerometer_rotation_status";
|
const std::string SETTING_LOCKED_KEY = "settings.general.accelerometer_rotation_status";
|
||||||
const ScreenId SCREEN_ID_FULL = 0;
|
const ScreenId SCREEN_ID_FULL = 0;
|
||||||
const ScreenId SCREEN_ID_MAIN = 5;
|
const ScreenId SCREEN_ID_MAIN = 5;
|
||||||
const ScreenId SCREEN_ID_PC_MAIN = 9;
|
const ScreenId SCREEN_ID_PC_MAIN = 9;
|
||||||
const std::vector<std::string> displayModeCommands = {"-f", "-m", "-sub", "-coor"};
|
|
||||||
constexpr int32_t INVALID_UID = -1;
|
constexpr int32_t INVALID_UID = -1;
|
||||||
constexpr int32_t INVALID_USER_ID = -1;
|
constexpr int32_t INVALID_USER_ID = -1;
|
||||||
constexpr int32_t INVALID_SCB_PID = -1;
|
constexpr int32_t INVALID_SCB_PID = -1;
|
||||||
@ -103,11 +92,14 @@ constexpr int32_t CAST_WIRED_PROJECTION_START = 1005;
|
|||||||
constexpr int32_t CAST_WIRED_PROJECTION_STOP = 1007;
|
constexpr int32_t CAST_WIRED_PROJECTION_STOP = 1007;
|
||||||
constexpr int32_t RES_FAILURE_FOR_PRIVACY_WINDOW = -2;
|
constexpr int32_t RES_FAILURE_FOR_PRIVACY_WINDOW = -2;
|
||||||
constexpr int32_t REMOVE_DISPLAY_MODE = 0;
|
constexpr int32_t REMOVE_DISPLAY_MODE = 0;
|
||||||
|
constexpr int32_t INVALID_DPI = 0;
|
||||||
|
|
||||||
const int32_t ROTATE_POLICY = system::GetIntParameter("const.window.device.rotate_policy", 0);
|
const int32_t ROTATE_POLICY = system::GetIntParameter("const.window.device.rotate_policy", 0);
|
||||||
constexpr int32_t FOLDABLE_DEVICE { 2 };
|
constexpr int32_t FOLDABLE_DEVICE { 2 };
|
||||||
constexpr float DEFAULT_PIVOT = 0.5f;
|
constexpr float DEFAULT_PIVOT = 0.5f;
|
||||||
constexpr float DEFAULT_SCALE = 1.0f;
|
constexpr float DEFAULT_SCALE = 1.0f;
|
||||||
|
static const constexpr char* SETTING_DPI_KEY {"user_set_dpi_value"};
|
||||||
|
static const constexpr char* SETTING_DPI_KEY_EXTEND {"user_set_dpi_value_extend"};
|
||||||
|
|
||||||
// based on the bundle_util
|
// based on the bundle_util
|
||||||
inline int32_t GetUserIdByCallingUid()
|
inline int32_t GetUserIdByCallingUid()
|
||||||
@ -170,8 +162,18 @@ void ScreenSessionManager::HandleFoldScreenPowerInit()
|
|||||||
}
|
}
|
||||||
TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str());
|
TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str());
|
||||||
screenEventTracker_.RecordEvent(oss.str());
|
screenEventTracker_.RecordEvent(oss.str());
|
||||||
|
if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
|
||||||
|
SetFoldScreenPowerInit([&]() {
|
||||||
|
foldScreenController_->BootAnimationFinishPowerInit();
|
||||||
|
FixPowerStatus();
|
||||||
|
foldScreenController_->SetOnBootAnimation(false);
|
||||||
|
RegisterApplicationStateObserver();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 后续其他设备rs上电规格将陆续迁移到BootAnimationFinishPowerInit中
|
||||||
FoldScreenPowerInit();
|
FoldScreenPowerInit();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::FoldScreenPowerInit()
|
void ScreenSessionManager::FoldScreenPowerInit()
|
||||||
{
|
{
|
||||||
@ -235,6 +237,7 @@ void ScreenSessionManager::FixPowerStatus()
|
|||||||
|
|
||||||
void ScreenSessionManager::Init()
|
void ScreenSessionManager::Init()
|
||||||
{
|
{
|
||||||
|
if (system::GetParameter("soc.boot.mode", "") != "rescue") {
|
||||||
constexpr uint64_t interval = 5 * 1000; // 5 second
|
constexpr uint64_t interval = 5 * 1000; // 5 second
|
||||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(
|
if (HiviewDFX::Watchdog::GetInstance().AddThread(
|
||||||
SCREEN_SESSION_MANAGER_THREAD, taskScheduler_->GetEventHandler(), interval)) {
|
SCREEN_SESSION_MANAGER_THREAD, taskScheduler_->GetEventHandler(), interval)) {
|
||||||
@ -246,6 +249,11 @@ void ScreenSessionManager::Init()
|
|||||||
TLOGW(WmsLogTag::DMS, "Add thread %{public}s to watchdog failed.",
|
TLOGW(WmsLogTag::DMS, "Add thread %{public}s to watchdog failed.",
|
||||||
SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD.c_str());
|
SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD.c_str());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
TLOGI(WmsLogTag::DMS, "Dms in rescue mode, not need watchdog.");
|
||||||
|
screenEventTracker_.RecordEvent("Dms in rescue mode, not need watchdog.");
|
||||||
|
}
|
||||||
|
|
||||||
auto stringConfig = ScreenSceneConfig::GetStringConfig();
|
auto stringConfig = ScreenSceneConfig::GetStringConfig();
|
||||||
if (stringConfig.count("defaultDisplayCutoutPath") != 0) {
|
if (stringConfig.count("defaultDisplayCutoutPath") != 0) {
|
||||||
std::string defaultDisplayCutoutPath = static_cast<std::string>(stringConfig["defaultDisplayCutoutPath"]);
|
std::string defaultDisplayCutoutPath = static_cast<std::string>(stringConfig["defaultDisplayCutoutPath"]);
|
||||||
@ -288,8 +296,7 @@ DMError ScreenSessionManager::CheckDisplayMangerAgentTypeAndPermission(
|
|||||||
if ((type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER ||
|
if ((type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER ||
|
||||||
type == DisplayManagerAgentType::PRIVATE_WINDOW_LISTENER) &&
|
type == DisplayManagerAgentType::PRIVATE_WINDOW_LISTENER) &&
|
||||||
!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "register or unregister display manager agent permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -319,9 +326,6 @@ DMError ScreenSessionManager::RegisterDisplayManagerAgent(
|
|||||||
TLOGE(WmsLogTag::DMS, "DisplayManagerAgentType: %{public}u", static_cast<uint32_t>(type));
|
TLOGE(WmsLogTag::DMS, "DisplayManagerAgentType: %{public}u", static_cast<uint32_t>(type));
|
||||||
return DMError::DM_ERROR_INVALID_PARAM;
|
return DMError::DM_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
TLOGD(WmsLogTag::DMS, "Register display listener type: %{public}u, clientName: %{public}s",
|
|
||||||
type, SysCapUtil::GetClientName().c_str());
|
|
||||||
return dmAgentContainer_.RegisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
return dmAgentContainer_.RegisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,9 +340,6 @@ DMError ScreenSessionManager::UnregisterDisplayManagerAgent(
|
|||||||
TLOGE(WmsLogTag::DMS, "UnregisterDisplayManagerAgent call CheckDisplayMangerAgentTypeAndPermission fail!");
|
TLOGE(WmsLogTag::DMS, "UnregisterDisplayManagerAgent call CheckDisplayMangerAgentTypeAndPermission fail!");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TLOGD(WmsLogTag::DMS, "UnRegister display listener type: %{public}u, clientName: %{public}s",
|
|
||||||
type, SysCapUtil::GetClientName().c_str());
|
|
||||||
return dmAgentContainer_.UnregisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
return dmAgentContainer_.UnregisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +630,10 @@ void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
|
|||||||
NotifyCastWhenScreenConnectChange(true);
|
NotifyCastWhenScreenConnectChange(true);
|
||||||
}
|
}
|
||||||
if (foldScreenController_ != nullptr) {
|
if (foldScreenController_ != nullptr) {
|
||||||
if (screenId == 0 && clientProxy_) {
|
if ((screenId == 0 || (screenId == SCREEN_ID_MAIN && isCoordinationFlag_ == true)) &&
|
||||||
|
clientProxy_) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "event: connect %{public}" PRIu64 ", %{public}" PRIu64 ", "
|
||||||
|
"name=%{public}s", screenId, screenSession->GetRSScreenId(), screenSession->GetName().c_str());
|
||||||
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED,
|
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED,
|
||||||
screenSession->GetRSScreenId(), screenSession->GetName(), screenSession->GetIsExtend());
|
screenSession->GetRSScreenId(), screenSession->GetName(), screenSession->GetIsExtend());
|
||||||
}
|
}
|
||||||
@ -646,6 +650,14 @@ void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
|
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
|
||||||
|
HandleScreenDisconnectEvent(screenSession, screenId, screenEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession,
|
||||||
|
ScreenId screenId, ScreenEvent screenEvent)
|
||||||
|
{
|
||||||
|
bool phyMirrorEnable = IsDefaultMirrorMode(screenId);
|
||||||
if (phyMirrorEnable) {
|
if (phyMirrorEnable) {
|
||||||
NotifyScreenDisconnected(screenSession->GetScreenId());
|
NotifyScreenDisconnected(screenSession->GetScreenId());
|
||||||
NotifyCastWhenScreenConnectChange(false);
|
NotifyCastWhenScreenConnectChange(false);
|
||||||
@ -663,14 +675,12 @@ void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
|
|||||||
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
|
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
|
||||||
screenSessionMap_.erase(screenId);
|
screenSessionMap_.erase(screenId);
|
||||||
}
|
}
|
||||||
{
|
if (!(screenId == SCREEN_ID_MAIN && isCoordinationFlag_ == true)) {
|
||||||
std::lock_guard<std::recursive_mutex> lock_phy(phyScreenPropMapMutex_);
|
std::lock_guard<std::recursive_mutex> lock_phy(phyScreenPropMapMutex_);
|
||||||
phyScreenPropMap_.erase(screenId);
|
phyScreenPropMap_.erase(screenId);
|
||||||
}
|
}
|
||||||
TLOGI(WmsLogTag::DMS, "DisconnectScreenSession success. ScreenId: %{public}" PRIu64 "", screenId);
|
TLOGI(WmsLogTag::DMS, "DisconnectScreenSession success. ScreenId: %{public}" PRIu64 "", screenId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate)
|
void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate)
|
||||||
{
|
{
|
||||||
GetDefaultScreenId();
|
GetDefaultScreenId();
|
||||||
@ -855,8 +865,7 @@ DMError ScreenSessionManager::SetScreenActiveMode(ScreenId screenId, uint32_t mo
|
|||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "SetScreenActiveMode: ScreenId: %{public}" PRIu64", modeId: %{public}u", screenId, modeId);
|
TLOGI(WmsLogTag::DMS, "SetScreenActiveMode: ScreenId: %{public}" PRIu64", modeId: %{public}u", screenId, modeId);
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set screen active permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -955,8 +964,7 @@ void ScreenSessionManager::NotifyScreenChanged(sptr<ScreenInfo> screenInfo, Scre
|
|||||||
DMError ScreenSessionManager::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
DMError ScreenSessionManager::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set virtual pixel permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -992,8 +1000,7 @@ DMError ScreenSessionManager::SetVirtualPixelRatio(ScreenId screenId, float virt
|
|||||||
DMError ScreenSessionManager::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
|
DMError ScreenSessionManager::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set virtual pixel permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -1289,8 +1296,7 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScreenId rsId = screenId;
|
screenIdManager_.UpdateScreenId(screenId, screenId);
|
||||||
screenIdManager_.UpdateScreenId(rsId, screenId);
|
|
||||||
|
|
||||||
ScreenProperty property;
|
ScreenProperty property;
|
||||||
CreateScreenProperty(screenId, property);
|
CreateScreenProperty(screenId, property);
|
||||||
@ -1307,11 +1313,12 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
|
|||||||
/* folder screen outer screenId is 5 */
|
/* folder screen outer screenId is 5 */
|
||||||
if (screenId == SCREEN_ID_MAIN) {
|
if (screenId == SCREEN_ID_MAIN) {
|
||||||
SetPostureAndHallSensorEnabled();
|
SetPostureAndHallSensorEnabled();
|
||||||
}
|
ScreenSensorConnector::SubscribeTentSensor();
|
||||||
if (screenId == SCREEN_ID_MAIN && !FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
|
if (!FoldScreenStateInternel::IsDualDisplayFoldDevice() && isCoordinationFlag_ == false) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sptr<ScreenSession> session = GetScreenSessionInner(screenId, property);
|
sptr<ScreenSession> session = GetScreenSessionInner(screenId, property);
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
@ -1465,6 +1472,54 @@ bool ScreenSessionManager::SuspendEnd()
|
|||||||
PowerStateChangeReason::STATE_CHANGE_REASON_INIT);
|
PowerStateChangeReason::STATE_CHANGE_REASON_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenId ScreenSessionManager::GetInternalScreenId()
|
||||||
|
{
|
||||||
|
ScreenId screenId = SCREEN_ID_INVALID;
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
|
||||||
|
for (auto sessionIt : screenSessionMap_) {
|
||||||
|
auto screenSession = sessionIt.second;
|
||||||
|
if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL && screenSession->isInternal_) {
|
||||||
|
screenId = sessionIt.first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return screenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
|
||||||
|
PowerStateChangeReason reason)
|
||||||
|
{
|
||||||
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
|
TLOGE(WmsLogTag::DMS, "permission denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerById: screen id:%{public}" PRIu64
|
||||||
|
", state:%{public}u, reason:%{public}u", screenId, state, static_cast<uint32_t>(reason));
|
||||||
|
|
||||||
|
ScreenPowerStatus status;
|
||||||
|
switch (state) {
|
||||||
|
case ScreenPowerState::POWER_ON: {
|
||||||
|
status = ScreenPowerStatus::POWER_STATUS_ON;
|
||||||
|
TLOGI(WmsLogTag::DMS, "[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ScreenPowerState::POWER_OFF: {
|
||||||
|
status = ScreenPowerStatus::POWER_STATUS_OFF;
|
||||||
|
TLOGI(WmsLogTag::DMS, "[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
TLOGW(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerById state not support");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rsInterface_.SetScreenPowerStatus(screenId, status);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ScreenSessionManager::IsPreBrightAuthFail(void)
|
bool ScreenSessionManager::IsPreBrightAuthFail(void)
|
||||||
{
|
{
|
||||||
return lastWakeUpReason_ == PowerStateChangeReason::
|
return lastWakeUpReason_ == PowerStateChangeReason::
|
||||||
@ -1562,6 +1617,7 @@ bool ScreenSessionManager::TryToCancelScreenOff()
|
|||||||
|
|
||||||
int32_t ScreenSessionManager::SetScreenOffDelayTime(int32_t delay)
|
int32_t ScreenSessionManager::SetScreenOffDelayTime(int32_t delay)
|
||||||
{
|
{
|
||||||
|
DmsXcollie dmsXcollie("DMS:SetScreenOffDelayTime", XCOLLIE_TIMEOUT_10S);
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set screen off delay time permission denied!");
|
TLOGE(WmsLogTag::DMS, "set screen off delay time permission denied!");
|
||||||
return 0;
|
return 0;
|
||||||
@ -1603,8 +1659,7 @@ bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowe
|
|||||||
PowerStateChangeReason reason)
|
PowerStateChangeReason reason)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetSpecifiedScreenPower permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1813,6 +1868,7 @@ void ScreenSessionManager::BootFinishedCallback(const char *key, const char *val
|
|||||||
that.SetRotateLockedFromSettingData();
|
that.SetRotateLockedFromSettingData();
|
||||||
that.SetDpiFromSettingData();
|
that.SetDpiFromSettingData();
|
||||||
that.RegisterSettingDpiObserver();
|
that.RegisterSettingDpiObserver();
|
||||||
|
that.RegisterExtendSettingDpiObserver();
|
||||||
if (that.foldScreenPowerInit_ != nullptr) {
|
if (that.foldScreenPowerInit_ != nullptr) {
|
||||||
that.foldScreenPowerInit_();
|
that.foldScreenPowerInit_();
|
||||||
}
|
}
|
||||||
@ -1844,8 +1900,20 @@ void ScreenSessionManager::SetRotateLockedFromSettingData()
|
|||||||
void ScreenSessionManager::RegisterSettingDpiObserver()
|
void ScreenSessionManager::RegisterSettingDpiObserver()
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "Register Setting Dpi Observer");
|
TLOGI(WmsLogTag::DMS, "Register Setting Dpi Observer");
|
||||||
|
if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "mirror") {
|
||||||
SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(); };
|
SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(); };
|
||||||
ScreenSettingHelper::RegisterSettingDpiObserver(updateFunc);
|
ScreenSettingHelper::RegisterSettingDpiObserver(updateFunc);
|
||||||
|
} else {
|
||||||
|
SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(true); };
|
||||||
|
ScreenSettingHelper::RegisterSettingDpiObserver(updateFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::RegisterExtendSettingDpiObserver()
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "Register Extend Setting Dpi Observer");
|
||||||
|
SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(false); };
|
||||||
|
ScreenSettingHelper::RegisterExtendSettingDpiObserver(updateFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::SetDpiFromSettingData()
|
void ScreenSessionManager::SetDpiFromSettingData()
|
||||||
@ -1867,6 +1935,41 @@ void ScreenSessionManager::SetDpiFromSettingData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::SetDpiFromSettingData(bool isInternal)
|
||||||
|
{
|
||||||
|
uint32_t settingDpi = INVALID_DPI;
|
||||||
|
bool ret = false;
|
||||||
|
if (isInternal == true) {
|
||||||
|
ret = ScreenSettingHelper::GetSettingDpi(settingDpi, SETTING_DPI_KEY);
|
||||||
|
} else {
|
||||||
|
ret = ScreenSettingHelper::GetSettingDpi(settingDpi, SETTING_DPI_KEY_EXTEND);
|
||||||
|
}
|
||||||
|
if (!ret) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "get setting dpi failed,use default dpi");
|
||||||
|
settingDpi = defaultDpi;
|
||||||
|
} else {
|
||||||
|
TLOGI(WmsLogTag::DMS, "get setting dpi success,settingDpi: %{public}u", settingDpi);
|
||||||
|
}
|
||||||
|
if (settingDpi >= DOT_PER_INCH_MINIMUM_VALUE && settingDpi <= DOT_PER_INCH_MAXIMUM_VALUE
|
||||||
|
&& cachedSettingDpi_ != settingDpi) {
|
||||||
|
cachedSettingDpi_ = settingDpi;
|
||||||
|
float dpi = static_cast<float>(settingDpi) / BASELINE_DENSITY;
|
||||||
|
ScreenId screenId = SCREEN_ID_INVALID;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
|
||||||
|
for (const auto& sessionIt : screenSessionMap_) {
|
||||||
|
const auto& screenSession = sessionIt.second;
|
||||||
|
if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL &&
|
||||||
|
screenSession->isInternal_ == isInternal) {
|
||||||
|
screenId = sessionIt.first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetVirtualPixelRatio(screenId, dpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ScreenId> ScreenSessionManager::GetAllScreenIds()
|
std::vector<ScreenId> ScreenSessionManager::GetAllScreenIds()
|
||||||
{
|
{
|
||||||
std::vector<ScreenId> res;
|
std::vector<ScreenId> res;
|
||||||
@ -1962,8 +2065,7 @@ ScreenPowerState ScreenSessionManager::GetScreenPower(ScreenId screenId)
|
|||||||
DMError ScreenSessionManager::IsScreenRotationLocked(bool& isLocked)
|
DMError ScreenSessionManager::IsScreenRotationLocked(bool& isLocked)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "screen rotation locked permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -1980,8 +2082,7 @@ DMError ScreenSessionManager::IsScreenRotationLocked(bool& isLocked)
|
|||||||
DMError ScreenSessionManager::SetScreenRotationLocked(bool isLocked)
|
DMError ScreenSessionManager::SetScreenRotationLocked(bool isLocked)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set screen rotation locked permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -1998,8 +2099,7 @@ DMError ScreenSessionManager::SetScreenRotationLocked(bool isLocked)
|
|||||||
DMError ScreenSessionManager::SetScreenRotationLockedFromJs(bool isLocked)
|
DMError ScreenSessionManager::SetScreenRotationLockedFromJs(bool isLocked)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set screen rotation locked from js permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2110,8 +2210,7 @@ void ScreenSessionManager::NotifyDisplayChanged(sptr<DisplayInfo> displayInfo, D
|
|||||||
DMError ScreenSessionManager::SetOrientation(ScreenId screenId, Orientation orientation)
|
DMError ScreenSessionManager::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "set orientation permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2291,8 +2390,7 @@ bool ScreenSessionManager::NotifyDisplayStateChanged(DisplayId id, DisplayState
|
|||||||
DMError ScreenSessionManager::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
|
DMError ScreenSessionManager::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "GetAllScreenInfos get all screen infos permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2327,8 +2425,7 @@ DMError ScreenSessionManager::GetScreenSupportedColorGamuts(ScreenId screenId,
|
|||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "GetScreenSupportedColorGamuts ENTER");
|
TLOGI(WmsLogTag::DMS, "GetScreenSupportedColorGamuts ENTER");
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "GetScreenSupportedColorGamuts permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2498,8 +2595,7 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option,
|
|||||||
}
|
}
|
||||||
if (!(Permission::IsSystemCalling() && Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION)) &&
|
if (!(Permission::IsSystemCalling() && Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION)) &&
|
||||||
!SessionPermission::IsShellCall()) {
|
!SessionPermission::IsShellCall()) {
|
||||||
TLOGE(WmsLogTag::DMS, "create virtual screen permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return SCREEN_ID_INVALID;
|
return SCREEN_ID_INVALID;
|
||||||
}
|
}
|
||||||
@ -2557,8 +2653,7 @@ DMError ScreenSessionManager::SetVirtualScreenSurface(ScreenId screenId, sptr<IB
|
|||||||
{
|
{
|
||||||
if (!(Permission::IsSystemCalling() && Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION)) &&
|
if (!(Permission::IsSystemCalling() && Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION)) &&
|
||||||
!SessionPermission::IsShellCall()) {
|
!SessionPermission::IsShellCall()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2590,8 +2685,7 @@ DMError ScreenSessionManager::SetVirtualScreenSurface(ScreenId screenId, sptr<IB
|
|||||||
DMError ScreenSessionManager::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
|
DMError ScreenSessionManager::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2616,8 +2710,7 @@ DMError ScreenSessionManager::SetVirtualMirrorScreenScaleMode(ScreenId screenId,
|
|||||||
DMError ScreenSessionManager::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate)
|
DMError ScreenSessionManager::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2645,8 +2738,7 @@ DMError ScreenSessionManager::SetVirtualMirrorScreenCanvasRotation(ScreenId scre
|
|||||||
DMError ScreenSessionManager::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
|
DMError ScreenSessionManager::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2672,8 +2764,7 @@ DMError ScreenSessionManager::ResizeVirtualScreen(ScreenId screenId, uint32_t wi
|
|||||||
DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId)
|
DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "destroy virtual screen permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2728,8 +2819,7 @@ DMError ScreenSessionManager::DisableMirror(bool disableOrNot)
|
|||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "DisableMirror %{public}d", disableOrNot);
|
TLOGI(WmsLogTag::DMS, "DisableMirror %{public}d", disableOrNot);
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGI(WmsLogTag::DMS, "DisableMirror permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2762,8 +2852,7 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vector<Scre
|
|||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "enter!");
|
TLOGI(WmsLogTag::DMS, "enter!");
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2845,8 +2934,7 @@ void ScreenSessionManager::RegisterSettingRotationObserver()
|
|||||||
DMError ScreenSessionManager::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
|
DMError ScreenSessionManager::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "StopMirror permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2902,8 +2990,7 @@ DMError ScreenSessionManager::StopScreens(const std::vector<ScreenId>& screenIds
|
|||||||
VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId)
|
VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return VirtualScreenFlag::DEFAULT;
|
return VirtualScreenFlag::DEFAULT;
|
||||||
}
|
}
|
||||||
@ -2918,8 +3005,7 @@ VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId)
|
|||||||
DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
|
DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2939,8 +3025,7 @@ DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScr
|
|||||||
DMError ScreenSessionManager::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
|
DMError ScreenSessionManager::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -2997,8 +3082,7 @@ DMError ScreenSessionManager::VirtualScreenUniqueSwitch(const std::vector<Screen
|
|||||||
DMError ScreenSessionManager::MakeUniqueScreen(const std::vector<ScreenId>& screenIds)
|
DMError ScreenSessionManager::MakeUniqueScreen(const std::vector<ScreenId>& screenIds)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -3009,7 +3093,11 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector<ScreenId>& scre
|
|||||||
}
|
}
|
||||||
ScreenId uniqueScreenId = screenIds[0];
|
ScreenId uniqueScreenId = screenIds[0];
|
||||||
auto uniqueScreen = GetScreenSession(uniqueScreenId);
|
auto uniqueScreen = GetScreenSession(uniqueScreenId);
|
||||||
if (uniqueScreen != nullptr && uniqueScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) {
|
if (uniqueScreen != nullptr) {
|
||||||
|
if (uniqueScreen->GetSourceMode() == ScreenSourceMode::SCREEN_UNIQUE) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "make unique ignore");
|
||||||
|
return DMError::DM_OK;
|
||||||
|
}
|
||||||
return MultiScreenManager::GetInstance().UniqueSwitch(screenIds);
|
return MultiScreenManager::GetInstance().UniqueSwitch(screenIds);
|
||||||
}
|
}
|
||||||
for (auto screenId : screenIds) {
|
for (auto screenId : screenIds) {
|
||||||
@ -3120,8 +3208,7 @@ bool ScreenSessionManager::OnMakeExpand(std::vector<ScreenId> screenId, std::vec
|
|||||||
DMError ScreenSessionManager::StopExpand(const std::vector<ScreenId>& expandScreenIds)
|
DMError ScreenSessionManager::StopExpand(const std::vector<ScreenId>& expandScreenIds)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "StopExpand permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -3806,8 +3893,7 @@ std::vector<ScreenId> ScreenSessionManager::GetAllValidScreenIds(const std::vect
|
|||||||
sptr<ScreenGroupInfo> ScreenSessionManager::GetScreenGroupInfoById(ScreenId screenId)
|
sptr<ScreenGroupInfo> ScreenSessionManager::GetScreenGroupInfoById(ScreenId screenId)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "GetScreenGroupInfoById permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -3918,8 +4004,7 @@ void ScreenSessionManager::NotifyPrivateSessionStateChanged(bool hasPrivate)
|
|||||||
void ScreenSessionManager::SetScreenPrivacyState(bool hasPrivate)
|
void ScreenSessionManager::SetScreenPrivacyState(bool hasPrivate)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetScreenPrivacyState permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3937,8 +4022,7 @@ void ScreenSessionManager::SetScreenPrivacyState(bool hasPrivate)
|
|||||||
void ScreenSessionManager::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
|
void ScreenSessionManager::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetPrivacyStateByDisplayId permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3961,8 +4045,7 @@ void ScreenSessionManager::SetPrivacyStateByDisplayId(DisplayId id, bool hasPriv
|
|||||||
void ScreenSessionManager::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
|
void ScreenSessionManager::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetScreenPrivacyWindowList permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permmission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3996,8 +4079,7 @@ void ScreenSessionManager::NotifyPrivateWindowListChanged(DisplayId id, std::vec
|
|||||||
DMError ScreenSessionManager::HasPrivateWindow(DisplayId id, bool& hasPrivateWindow)
|
DMError ScreenSessionManager::HasPrivateWindow(DisplayId id, bool& hasPrivateWindow)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "HasPrivateWindow permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permmision Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -4146,8 +4228,7 @@ std::string ScreenSessionManager::TransferTypeToString(ScreenType type) const
|
|||||||
void ScreenSessionManager::DumpAllScreensInfo(std::string& dumpInfo)
|
void ScreenSessionManager::DumpAllScreensInfo(std::string& dumpInfo)
|
||||||
{
|
{
|
||||||
if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) {
|
if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) {
|
||||||
TLOGE(WmsLogTag::DMS, "DumpAllScreensInfo permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4192,8 +4273,7 @@ void ScreenSessionManager::DumpAllScreensInfo(std::string& dumpInfo)
|
|||||||
void ScreenSessionManager::DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo)
|
void ScreenSessionManager::DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo)
|
||||||
{
|
{
|
||||||
if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) {
|
if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) {
|
||||||
TLOGE(WmsLogTag::DMS, "DumpSpecialScreenInfo permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4242,8 +4322,7 @@ ScreenProperty ScreenSessionManager::GetPhyScreenProperty(ScreenId screenId)
|
|||||||
void ScreenSessionManager::SetFoldDisplayMode(const FoldDisplayMode displayMode)
|
void ScreenSessionManager::SetFoldDisplayMode(const FoldDisplayMode displayMode)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetFoldDisplayMode permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4265,8 +4344,7 @@ void ScreenSessionManager::SetFoldDisplayMode(const FoldDisplayMode displayMode)
|
|||||||
DMError ScreenSessionManager::SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode)
|
DMError ScreenSessionManager::SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -4441,8 +4519,7 @@ void ScreenSessionManager::SetFoldStatusLocked(bool locked)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "SetFoldStatusLocked permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4452,8 +4529,7 @@ void ScreenSessionManager::SetFoldStatusLocked(bool locked)
|
|||||||
DMError ScreenSessionManager::SetFoldStatusLockedFromJs(bool locked)
|
DMError ScreenSessionManager::SetFoldStatusLockedFromJs(bool locked)
|
||||||
{
|
{
|
||||||
if (!SessionPermission::IsSystemCalling()) {
|
if (!SessionPermission::IsSystemCalling()) {
|
||||||
TLOGE(WmsLogTag::DMS, "permission denied!");
|
TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d",
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
||||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
@ -4515,6 +4591,18 @@ FoldStatus ScreenSessionManager::GetFoldStatus()
|
|||||||
return foldScreenController_->GetFoldStatus();
|
return foldScreenController_->GetFoldStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScreenSessionManager::GetTentMode()
|
||||||
|
{
|
||||||
|
if (!g_foldScreenFlag) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (foldScreenController_ == nullptr) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "foldScreenController_ is null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return foldScreenController_->GetTentMode();
|
||||||
|
}
|
||||||
|
|
||||||
sptr<FoldCreaseRegion> ScreenSessionManager::GetCurrentFoldCreaseRegion()
|
sptr<FoldCreaseRegion> ScreenSessionManager::GetCurrentFoldCreaseRegion()
|
||||||
{
|
{
|
||||||
if (!g_foldScreenFlag) {
|
if (!g_foldScreenFlag) {
|
||||||
@ -4700,6 +4788,16 @@ void ScreenSessionManager::OnSensorRotationChange(float sensorRotation, ScreenId
|
|||||||
clientProxy_->OnSensorRotationChanged(screenId, sensorRotation);
|
clientProxy_->OnSensorRotationChanged(screenId, sensorRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " hoverStatus: %{public}d", screenId, hoverStatus);
|
||||||
|
if (!clientProxy_) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "OnHoverStatusChange clientProxy_ is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clientProxy_->OnHoverStatusChanged(screenId, hoverStatus);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::OnScreenOrientationChange(float screenOrientation, ScreenId screenId)
|
void ScreenSessionManager::OnScreenOrientationChange(float screenOrientation, ScreenId screenId)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenOrientation: %{public}f", screenId, screenOrientation);
|
TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenOrientation: %{public}f", screenId, screenOrientation);
|
||||||
@ -4778,16 +4876,17 @@ void ScreenSessionManager::SwitchUser()
|
|||||||
|
|
||||||
void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t> oldScbPids, int32_t newScbPid)
|
void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t> oldScbPids, int32_t newScbPid)
|
||||||
{
|
{
|
||||||
NotifyFoldStatusChanged(GetFoldStatus());
|
|
||||||
NotifyDisplayModeChanged(GetFoldDisplayMode());
|
|
||||||
sptr<ScreenSession> screenSession = GetDefaultScreenSession();
|
sptr<ScreenSession> screenSession = GetDefaultScreenSession();
|
||||||
if (screenSession == nullptr) {
|
if (screenSession == nullptr) {
|
||||||
TLOGE(WmsLogTag::DMS, "fail to get default screenSession");
|
TLOGE(WmsLogTag::DMS, "fail to get default screenSession");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_foldScreenFlag && !FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
|
int64_t delayTime = 0;
|
||||||
|
if (g_foldScreenFlag && oldScbDisplayMode_ != GetFoldDisplayMode() &&
|
||||||
|
!FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
|
||||||
|
delayTime = SWITCH_USER_DISPLAYMODE_CHANGE_DELAY;
|
||||||
auto foldStatus = GetFoldStatus();
|
auto foldStatus = GetFoldStatus();
|
||||||
// fold device will be callback NotifyFoldToExpandCompletion to UpdateRotationAfterBoot
|
TLOGE(WmsLogTag::DMS, "old mode: %{public}u, cur mode: %{public}u", oldScbDisplayMode_, GetFoldDisplayMode());
|
||||||
if (foldStatus == FoldStatus::EXPAND || foldStatus == FoldStatus::HALF_FOLD) {
|
if (foldStatus == FoldStatus::EXPAND || foldStatus == FoldStatus::HALF_FOLD) {
|
||||||
screenSession->UpdatePropertyByFoldControl(GetPhyScreenProperty(SCREEN_ID_FULL));
|
screenSession->UpdatePropertyByFoldControl(GetPhyScreenProperty(SCREEN_ID_FULL));
|
||||||
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
||||||
@ -4802,7 +4901,10 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t>
|
|||||||
} else {
|
} else {
|
||||||
screenSession->UpdateRotationAfterBoot(true);
|
screenSession->UpdateRotationAfterBoot(true);
|
||||||
}
|
}
|
||||||
|
auto task = [=] {
|
||||||
clientProxy_->SwitchUserCallback(oldScbPids, newScbPid);
|
clientProxy_->SwitchUserCallback(oldScbPids, newScbPid);
|
||||||
|
};
|
||||||
|
taskScheduler_->PostAsyncTask(task, "ProxyForUnFreeze NotifyDisplayChanged", delayTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& client)
|
void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& client)
|
||||||
@ -4880,6 +4982,7 @@ void ScreenSessionManager::SwitchScbNodeHandle(int32_t newUserId, int32_t newScb
|
|||||||
currentUserId_ = newUserId;
|
currentUserId_ = newUserId;
|
||||||
currentScbPId_ = newScbPid;
|
currentScbPId_ = newScbPid;
|
||||||
scbSwitchCV_.notify_all();
|
scbSwitchCV_.notify_all();
|
||||||
|
oldScbDisplayMode_ = GetFoldDisplayMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::SetClientInner()
|
void ScreenSessionManager::SetClientInner()
|
||||||
@ -4907,12 +5010,14 @@ void ScreenSessionManager::SetClientInner()
|
|||||||
TLOGE(WmsLogTag::DMS, "clientProxy is null");
|
TLOGE(WmsLogTag::DMS, "clientProxy is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (iter.second->GetScreenCombination() != ScreenCombination::SCREEN_MIRROR) {
|
if (iter.second->GetIsExtend() && iter.second->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "current screen is extend and mirror, return before OnScreenConnectionChanged");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
clientProxy_->OnScreenConnectionChanged(iter.first, ScreenEvent::CONNECTED,
|
clientProxy_->OnScreenConnectionChanged(iter.first, ScreenEvent::CONNECTED,
|
||||||
iter.second->GetRSScreenId(), iter.second->GetName(), iter.second->GetIsExtend());
|
iter.second->GetRSScreenId(), iter.second->GetName(), iter.second->GetIsExtend());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSessionManager::GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight,
|
void ScreenSessionManager::GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight,
|
||||||
bool& isReset, const ScreenId& screenid)
|
bool& isReset, const ScreenId& screenid)
|
||||||
@ -4946,6 +5051,7 @@ void ScreenSessionManager::GetCurrentScreenPhyBounds(float& phyWidth, float& phy
|
|||||||
|
|
||||||
ScreenProperty ScreenSessionManager::GetScreenProperty(ScreenId screenId)
|
ScreenProperty ScreenSessionManager::GetScreenProperty(ScreenId screenId)
|
||||||
{
|
{
|
||||||
|
DmsXcollie dmsXcollie("DMS:GetScreenProperty", XCOLLIE_TIMEOUT_10S);
|
||||||
auto screenSession = GetScreenSession(screenId);
|
auto screenSession = GetScreenSession(screenId);
|
||||||
if (!screenSession) {
|
if (!screenSession) {
|
||||||
TLOGI(WmsLogTag::DMS, "GetScreenProperty screenSession is null");
|
TLOGI(WmsLogTag::DMS, "GetScreenProperty screenSession is null");
|
||||||
@ -4956,6 +5062,7 @@ ScreenProperty ScreenSessionManager::GetScreenProperty(ScreenId screenId)
|
|||||||
|
|
||||||
std::shared_ptr<RSDisplayNode> ScreenSessionManager::GetDisplayNode(ScreenId screenId)
|
std::shared_ptr<RSDisplayNode> ScreenSessionManager::GetDisplayNode(ScreenId screenId)
|
||||||
{
|
{
|
||||||
|
DmsXcollie dmsXcollie("DMS:GetDisplayNode", XCOLLIE_TIMEOUT_10S);
|
||||||
auto screenSession = GetScreenSession(screenId);
|
auto screenSession = GetScreenSession(screenId);
|
||||||
if (!screenSession) {
|
if (!screenSession) {
|
||||||
TLOGE(WmsLogTag::DMS, "GetDisplayNode screenSession is null");
|
TLOGE(WmsLogTag::DMS, "GetDisplayNode screenSession is null");
|
||||||
@ -4964,88 +5071,6 @@ std::shared_ptr<RSDisplayNode> ScreenSessionManager::GetDisplayNode(ScreenId scr
|
|||||||
return screenSession->GetDisplayNode();
|
return screenSession->GetDisplayNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManager::ShowHelpInfo(std::string& dumpInfo)
|
|
||||||
{
|
|
||||||
dumpInfo.append("Usage:\n")
|
|
||||||
.append(" -h ")
|
|
||||||
.append("|help text for the tool\n")
|
|
||||||
.append(" -a ")
|
|
||||||
.append("|dump all screen information in the system\n")
|
|
||||||
.append(" -s {screen id} ")
|
|
||||||
.append("|dump specified screen information\n")
|
|
||||||
.append(" -f ")
|
|
||||||
.append("|switch the screen to full display mode\n")
|
|
||||||
.append(" -m ")
|
|
||||||
.append("|switch the screen to main display mode\n")
|
|
||||||
.append(" -l ")
|
|
||||||
.append("|lock the screen display status\n")
|
|
||||||
.append(" -u ")
|
|
||||||
.append("|unlock the screen display status\n")
|
|
||||||
.append(" -z ")
|
|
||||||
.append("|switch to fold half status\n")
|
|
||||||
.append(" -y ")
|
|
||||||
.append("|switch to expand status\n")
|
|
||||||
.append(" -p ")
|
|
||||||
.append("|switch to fold status\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSessionManager::ShowIllegalArgsInfo(std::string& dumpInfo)
|
|
||||||
{
|
|
||||||
dumpInfo.append("The arguments are illegal and you can enter '-h' for help.");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScreenSessionManager::IsValidDigitString(const std::string& idStr) const
|
|
||||||
{
|
|
||||||
if (idStr.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (char ch : idStr) {
|
|
||||||
if ((ch >= '0' && ch <= '9')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
TLOGE(WmsLogTag::DMS, "invalid id");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::DumpScreenInfo(const std::vector<std::string>& args, std::string& dumpInfo)
|
|
||||||
{
|
|
||||||
if (args.empty()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (args.size() == 1 && args[0] == ARG_DUMP_ALL) { // 1: params num
|
|
||||||
return DumpAllScreenInfo(dumpInfo);
|
|
||||||
} else if (args[0] == ARG_DUMP_SCREEN && IsValidDigitString(args[1])) {
|
|
||||||
ScreenId screenId = std::stoull(args[1]);
|
|
||||||
return DumpSpecifiedScreenInfo(screenId, dumpInfo);
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::DumpAllScreenInfo(std::string& dumpInfo)
|
|
||||||
{
|
|
||||||
DumpAllScreensInfo(dumpInfo);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::DumpSpecifiedScreenInfo(ScreenId screenId, std::string& dumpInfo)
|
|
||||||
{
|
|
||||||
DumpSpecialScreenInfo(screenId, dumpInfo);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string Str16ToStr8(const std::u16string& str)
|
|
||||||
{
|
|
||||||
if (str == DEFAULT_USTRING) {
|
|
||||||
return DEFAULT_STRING;
|
|
||||||
}
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert(DEFAULT_STRING);
|
|
||||||
std::string result = convert.to_bytes(str);
|
|
||||||
return result == DEFAULT_STRING ? "" : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::Dump(int fd, const std::vector<std::u16string>& args)
|
int ScreenSessionManager::Dump(int fd, const std::vector<std::u16string>& args)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "Dump begin");
|
TLOGI(WmsLogTag::DMS, "Dump begin");
|
||||||
@ -5058,91 +5083,10 @@ int ScreenSessionManager::Dump(int fd, const std::vector<std::u16string>& args)
|
|||||||
dumper->DumpEventTracker(screenEventTracker_);
|
dumper->DumpEventTracker(screenEventTracker_);
|
||||||
dumper->DumpMultiUserInfo(oldScbPids_, currentUserId_, currentScbPId_);
|
dumper->DumpMultiUserInfo(oldScbPids_, currentUserId_, currentScbPId_);
|
||||||
dumper->ExcuteDumpCmd();
|
dumper->ExcuteDumpCmd();
|
||||||
|
|
||||||
std::vector<std::string> params;
|
|
||||||
for (auto& arg : args) {
|
|
||||||
params.emplace_back(Str16ToStr8(arg));
|
|
||||||
}
|
|
||||||
std::string dumpInfo;
|
|
||||||
if (params.empty()) {
|
|
||||||
ShowHelpInfo(dumpInfo);
|
|
||||||
} else if (params.size() == 1 && params[0] == ARG_DUMP_HELP) { // 1: params num
|
|
||||||
ShowHelpInfo(dumpInfo);
|
|
||||||
} else if (params.size() == 1 && IsValidDisplayModeCommand(params[0])) {
|
|
||||||
int errCode = SetFoldDisplayMode(params[0]);
|
|
||||||
if (errCode != 0) {
|
|
||||||
ShowIllegalArgsInfo(dumpInfo);
|
|
||||||
}
|
|
||||||
} else if (params.size() == 1 && (params[0] == ARG_LOCK_FOLD_DISPLAY_STATUS
|
|
||||||
|| params[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) {
|
|
||||||
int errCode = SetFoldStatusLocked(params[0]);
|
|
||||||
if (errCode != 0) {
|
|
||||||
ShowIllegalArgsInfo(dumpInfo);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int errCode = DumpScreenInfo(params, dumpInfo);
|
|
||||||
if (errCode != 0) {
|
|
||||||
ShowIllegalArgsInfo(dumpInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TLOGI(WmsLogTag::DMS, "dump end");
|
TLOGI(WmsLogTag::DMS, "dump end");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenSessionManager::IsValidDisplayModeCommand(std::string command)
|
|
||||||
{
|
|
||||||
if (std::find(displayModeCommands.begin(), displayModeCommands.end(), command) != displayModeCommands.end()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::SetFoldDisplayMode(const std::string& modeParam)
|
|
||||||
{
|
|
||||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
|
||||||
TLOGE(WmsLogTag::DMS, "SetFoldDisplayMode permission denied!");
|
|
||||||
TLOGE(WmsLogTag::DMS, "calling clientName: %{public}s, calling pid: %{public}d",
|
|
||||||
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (modeParam.empty()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
|
|
||||||
if (modeParam == ARG_FOLD_DISPLAY_FULL) {
|
|
||||||
displayMode = FoldDisplayMode::FULL;
|
|
||||||
} else if (modeParam == ARG_FOLD_DISPLAY_MAIN) {
|
|
||||||
displayMode = FoldDisplayMode::MAIN;
|
|
||||||
} else if (modeParam == ARG_FOLD_DISPLAY_SUB) {
|
|
||||||
displayMode = FoldDisplayMode::SUB;
|
|
||||||
} else if (modeParam == ARG_FOLD_DISPLAY_COOR) {
|
|
||||||
displayMode = FoldDisplayMode::COORDINATION;
|
|
||||||
} else {
|
|
||||||
TLOGW(WmsLogTag::DMS, "SetFoldDisplayMode mode not support");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
SetFoldDisplayMode(displayMode);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::SetFoldStatusLocked(const std::string& lockParam)
|
|
||||||
{
|
|
||||||
if (lockParam.empty()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
bool lockDisplayStatus = false;
|
|
||||||
if (lockParam == ARG_LOCK_FOLD_DISPLAY_STATUS) {
|
|
||||||
lockDisplayStatus = true;
|
|
||||||
} else if (lockParam == ARG_UNLOCK_FOLD_DISPLAY_STATUS) {
|
|
||||||
lockDisplayStatus = false;
|
|
||||||
} else {
|
|
||||||
TLOGW(WmsLogTag::DMS, "SetFoldStatusLocked status not support");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
SetFoldStatusLocked(lockDisplayStatus);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenSessionManager::NotifyFoldStatusChanged(const std::string& statusParam)
|
int ScreenSessionManager::NotifyFoldStatusChanged(const std::string& statusParam)
|
||||||
{
|
{
|
||||||
TLOGI(WmsLogTag::DMS, "NotifyFoldStatusChanged is dump log");
|
TLOGI(WmsLogTag::DMS, "NotifyFoldStatusChanged is dump log");
|
||||||
@ -5625,4 +5569,24 @@ void ScreenSessionManager::OnScreenExtendChange(ScreenId mainScreenId, ScreenId
|
|||||||
}
|
}
|
||||||
clientProxy_->OnScreenExtendChanged(mainScreenId, extendScreenId);
|
clientProxy_->OnScreenExtendChanged(mainScreenId, extendScreenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::OnTentModeChanged(bool isTentMode)
|
||||||
|
{
|
||||||
|
if (!foldScreenController_) {
|
||||||
|
TLOGI(WmsLogTag::DMS, "foldScreenController_ is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foldScreenController_->OnTentModeChanged(isTentMode);
|
||||||
|
if (isTentMode) {
|
||||||
|
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::TENT_STATUS);
|
||||||
|
} else {
|
||||||
|
ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::TENT_STATUS_CANCEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManager::SetCoordinationFlag(bool isCoordinationFlag)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "set coordination flag %{public}d", isCoordinationFlag);
|
||||||
|
isCoordinationFlag_ = isCoordinationFlag;
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
@ -21,6 +21,7 @@
|
|||||||
namespace OHOS {
|
namespace OHOS {
|
||||||
namespace Rosen {
|
namespace Rosen {
|
||||||
sptr<SettingObserver> ScreenSettingHelper::dpiObserver_;
|
sptr<SettingObserver> ScreenSettingHelper::dpiObserver_;
|
||||||
|
sptr<SettingObserver> ScreenSettingHelper::extendDpiObserver_;
|
||||||
sptr<SettingObserver> ScreenSettingHelper::castObserver_;
|
sptr<SettingObserver> ScreenSettingHelper::castObserver_;
|
||||||
sptr<SettingObserver> ScreenSettingHelper::rotationObserver_;
|
sptr<SettingObserver> ScreenSettingHelper::rotationObserver_;
|
||||||
|
|
||||||
@ -39,6 +40,21 @@ void ScreenSettingHelper::RegisterSettingDpiObserver(SettingObserver::UpdateFunc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSettingHelper::RegisterExtendSettingDpiObserver(SettingObserver::UpdateFunc func)
|
||||||
|
{
|
||||||
|
if (extendDpiObserver_) {
|
||||||
|
TLOGD(WmsLogTag::DMS, "setting extend dpi observer is already registered");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID);
|
||||||
|
extendDpiObserver_ = provider.CreateObserver(SETTING_DPI_KEY_EXTEND, func);
|
||||||
|
ErrCode ret = provider.RegisterObserver(extendDpiObserver_);
|
||||||
|
if (ret != ERR_OK) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "register extend setting dpi observer failed, ret=%{public}d", ret);
|
||||||
|
extendDpiObserver_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSettingHelper::UnregisterSettingDpiObserver()
|
void ScreenSettingHelper::UnregisterSettingDpiObserver()
|
||||||
{
|
{
|
||||||
if (dpiObserver_ == nullptr) {
|
if (dpiObserver_ == nullptr) {
|
||||||
@ -53,6 +69,20 @@ void ScreenSettingHelper::UnregisterSettingDpiObserver()
|
|||||||
dpiObserver_ = nullptr;
|
dpiObserver_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSettingHelper::UnregisterExtendSettingDpiObserver()
|
||||||
|
{
|
||||||
|
if (extendDpiObserver_ == nullptr) {
|
||||||
|
TLOGD(WmsLogTag::DMS, "extendDpiObserver_ is nullptr, no need to unregister");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID);
|
||||||
|
ErrCode ret = provider.UnregisterObserver(extendDpiObserver_);
|
||||||
|
if (ret != ERR_OK) {
|
||||||
|
TLOGW(WmsLogTag::DMS, "unregister extend setting dpi observer failed, ret=%{public}d", ret);
|
||||||
|
}
|
||||||
|
extendDpiObserver_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool ScreenSettingHelper::GetSettingDpi(uint32_t& dpi, const std::string& key)
|
bool ScreenSettingHelper::GetSettingDpi(uint32_t& dpi, const std::string& key)
|
||||||
{
|
{
|
||||||
return GetSettingValue(dpi, key);
|
return GetSettingValue(dpi, key);
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 "screen_tent_property.h"
|
||||||
|
#include "screen_session_manager.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace Rosen {
|
||||||
|
void ScreenTentProperty::HandleSensorEventInput(bool isTentMode)
|
||||||
|
{
|
||||||
|
TLOGI(WmsLogTag::DMS, "Tent mode: %{public}s", isTentMode ? "ON" : "OFF");
|
||||||
|
ScreenSessionManager::GetInstance().OnTentModeChanged(isTentMode);
|
||||||
|
}
|
||||||
|
} // Rosen
|
||||||
|
} // OHOS
|
@ -772,6 +772,66 @@ bool OHOS::Rosen::ScreenSessionManagerProxy::SuspendEnd()
|
|||||||
return reply.ReadBool();
|
return reply.ReadBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenId OHOS::Rosen::ScreenSessionManagerProxy::GetInternalScreenId()
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
WLOGFE("[UL_POWER]GetInternalScreenId remote is nullptr");
|
||||||
|
return SCREEN_ID_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
|
||||||
|
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||||
|
WLOGFE("[UL_POWER]GetInternalScreenId: WriteInterfaceToken failed");
|
||||||
|
return SCREEN_ID_INVALID;
|
||||||
|
}
|
||||||
|
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID),
|
||||||
|
data, reply, option) != ERR_NONE) {
|
||||||
|
WLOGFW("[UL_POWER]GetInternalScreenId: SendRequest failed");
|
||||||
|
return SCREEN_ID_INVALID;
|
||||||
|
}
|
||||||
|
return reply.ReadUint64();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OHOS::Rosen::ScreenSessionManagerProxy::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
|
||||||
|
PowerStateChangeReason reason)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
WLOGFE("[UL_POWER]SetScreenPowerById remote is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||||
|
WLOGFE("[UL_POWER]WriteInterfaceToken failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.WriteUint64(screenId)) {
|
||||||
|
WLOGFE("[UL_POWER]Write ScreenId failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
|
||||||
|
WLOGFE("[UL_POWER]Write ScreenPowerState failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
|
||||||
|
WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_BY_ID),
|
||||||
|
data, reply, option) != ERR_NONE) {
|
||||||
|
WLOGFW("[UL_POWER]SendRequest failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return reply.ReadBool();
|
||||||
|
}
|
||||||
|
|
||||||
bool OHOS::Rosen::ScreenSessionManagerProxy::SetDisplayState(DisplayState state)
|
bool OHOS::Rosen::ScreenSessionManagerProxy::SetDisplayState(DisplayState state)
|
||||||
{
|
{
|
||||||
sptr<IRemoteObject> remote = Remote();
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
@ -52,7 +52,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
||||||
DMError ret = RegisterDisplayManagerAgent(agent, type);
|
DMError ret = RegisterDisplayManagerAgent(agent, type);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: {
|
case DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: {
|
||||||
@ -62,7 +62,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
||||||
DMError ret = UnregisterDisplayManagerAgent(agent, type);
|
DMError ret = UnregisterDisplayManagerAgent(agent, type);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN: {
|
case DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN: {
|
||||||
@ -83,6 +83,17 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
reply.WriteBool(SuspendEnd());
|
reply.WriteBool(SuspendEnd());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID: {
|
||||||
|
reply.WriteUint64(GetInternalScreenId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_BY_ID: {
|
||||||
|
ScreenId screenId = data.ReadUint64();
|
||||||
|
ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32());
|
||||||
|
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
|
||||||
|
reply.WriteBool(SetScreenPowerById(screenId, state, reason));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE: {
|
case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE: {
|
||||||
DisplayState state = static_cast<DisplayState>(data.ReadUint32());
|
DisplayState state = static_cast<DisplayState>(data.ReadUint32());
|
||||||
reply.WriteBool(SetDisplayState(state));
|
reply.WriteBool(SetDisplayState(state));
|
||||||
@ -103,7 +114,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE: {
|
case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE: {
|
||||||
DisplayState state = GetDisplayState(data.ReadUint64());
|
DisplayState state = GetDisplayState(data.ReadUint64());
|
||||||
reply.WriteUint32(static_cast<uint32_t>(state));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(state)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT: {
|
case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT: {
|
||||||
@ -117,7 +128,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
WLOGFE("fail to read dmsScreenId.");
|
WLOGFE("fail to read dmsScreenId.");
|
||||||
return ERR_INVALID_DATA;
|
return ERR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
reply.WriteUint32(static_cast<uint32_t>(GetScreenPower(dmsScreenId)));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(GetScreenPower(dmsScreenId))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF: {
|
case DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF: {
|
||||||
@ -138,7 +149,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS: {
|
case DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS: {
|
||||||
std::vector<DisplayId> allDisplayIds = GetAllDisplayIds();
|
std::vector<DisplayId> allDisplayIds = GetAllDisplayIds();
|
||||||
reply.WriteUInt64Vector(allDisplayIds);
|
static_cast<void>(reply.WriteUInt64Vector(allDisplayIds));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
||||||
@ -150,7 +161,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
case DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS: {
|
case DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS: {
|
||||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||||
DMError ret = GetAllScreenInfos(screenInfos);
|
DMError ret = GetAllScreenInfos(screenInfos);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (!MarshallingHelper::MarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos)) {
|
if (!MarshallingHelper::MarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos)) {
|
||||||
WLOGE("fail to marshalling screenInfos in stub.");
|
WLOGE("fail to marshalling screenInfos in stub.");
|
||||||
}
|
}
|
||||||
@ -160,7 +171,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
std::vector<ScreenColorGamut> colorGamuts;
|
std::vector<ScreenColorGamut> colorGamuts;
|
||||||
DMError ret = GetScreenSupportedColorGamuts(screenId, colorGamuts);
|
DMError ret = GetScreenSupportedColorGamuts(screenId, colorGamuts);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -199,7 +210,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
.missionIds_ = missionIds
|
.missionIds_ = missionIds
|
||||||
};
|
};
|
||||||
ScreenId screenId = CreateVirtualScreen(virScrOption, virtualScreenAgent);
|
ScreenId screenId = CreateVirtualScreen(virScrOption, virtualScreenAgent);
|
||||||
reply.WriteUint64(static_cast<uint64_t>(screenId));
|
static_cast<void>(reply.WriteUint64(static_cast<uint64_t>(screenId)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE: {
|
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE: {
|
||||||
@ -211,27 +222,27 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
bp = iface_cast<IBufferProducer>(surfaceObject);
|
bp = iface_cast<IBufferProducer>(surfaceObject);
|
||||||
}
|
}
|
||||||
DMError result = SetVirtualScreenSurface(screenId, bp);
|
DMError result = SetVirtualScreenSurface(screenId, bp);
|
||||||
reply.WriteInt32(static_cast<int32_t>(result));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(result)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION: {
|
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
bool autoRotate = data.ReadBool();
|
bool autoRotate = data.ReadBool();
|
||||||
DMError result = SetVirtualMirrorScreenCanvasRotation(screenId, autoRotate);
|
DMError result = SetVirtualMirrorScreenCanvasRotation(screenId, autoRotate);
|
||||||
reply.WriteInt32(static_cast<int32_t>(result));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(result)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE: {
|
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
ScreenScaleMode scaleMode = static_cast<ScreenScaleMode>(data.ReadUint32());
|
ScreenScaleMode scaleMode = static_cast<ScreenScaleMode>(data.ReadUint32());
|
||||||
DMError result = SetVirtualMirrorScreenScaleMode(screenId, scaleMode);
|
DMError result = SetVirtualMirrorScreenScaleMode(screenId, scaleMode);
|
||||||
reply.WriteInt32(static_cast<int32_t>(result));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(result)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN: {
|
case DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
DMError result = DestroyVirtualScreen(screenId);
|
DMError result = DestroyVirtualScreen(screenId);
|
||||||
reply.WriteInt32(static_cast<int32_t>(result));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(result)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR: {
|
||||||
@ -243,8 +254,8 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||||
DMError ret = MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
|
DMError ret = MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteUint64(static_cast<uint64_t>(screenGroupId));
|
static_cast<void>(reply.WriteUint64(static_cast<uint64_t>(screenGroupId)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_MULTI_SCREEN_MODE_SWITCH: {
|
case DisplayManagerMessage::TRANS_ID_MULTI_SCREEN_MODE_SWITCH: {
|
||||||
@ -252,7 +263,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId secondaryScreenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId secondaryScreenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
MultiScreenMode screenMode = static_cast<MultiScreenMode>(data.ReadUint32());
|
MultiScreenMode screenMode = static_cast<MultiScreenMode>(data.ReadUint32());
|
||||||
DMError ret = SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode);
|
DMError ret = SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_MULTI_SCREEN_POSITION: {
|
case DisplayManagerMessage::TRANS_ID_SET_MULTI_SCREEN_POSITION: {
|
||||||
@ -273,7 +284,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
.startY_ = secondaryScreenY,
|
.startY_ = secondaryScreenY,
|
||||||
};
|
};
|
||||||
DMError ret = SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption);
|
DMError ret = SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR: {
|
||||||
@ -283,12 +294,12 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DMError ret = StopMirror(mirrorScreenIds);
|
DMError ret = StopMirror(mirrorScreenIds);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_DISABLE_MIRROR: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_DISABLE_MIRROR: {
|
||||||
DMError ret = DisableMirror(data.ReadBool());
|
DMError ret = DisableMirror(data.ReadBool());
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND: {
|
||||||
@ -306,8 +317,8 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||||
DMError ret = MakeExpand(screenId, startPoint, screenGroupId);
|
DMError ret = MakeExpand(screenId, startPoint, screenGroupId);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteUint64(static_cast<uint64_t>(screenGroupId));
|
static_cast<void>(reply.WriteUint64(static_cast<uint64_t>(screenGroupId)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND: {
|
||||||
@ -317,7 +328,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DMError ret = StopExpand(expandScreenIds);
|
DMError ret = StopExpand(expandScreenIds);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID: {
|
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID: {
|
||||||
@ -340,7 +351,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
DmErrorCode errCode = DmErrorCode::DM_OK;
|
DmErrorCode errCode = DmErrorCode::DM_OK;
|
||||||
std::shared_ptr<Media::PixelMap> displaySnapshot = GetDisplaySnapshot(displayId, &errCode);
|
std::shared_ptr<Media::PixelMap> displaySnapshot = GetDisplaySnapshot(displayId, &errCode);
|
||||||
reply.WriteParcelable(displaySnapshot == nullptr ? nullptr : displaySnapshot.get());
|
reply.WriteParcelable(displaySnapshot == nullptr ? nullptr : displaySnapshot.get());
|
||||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(errCode)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_SNAPSHOT_BY_PICKER: {
|
case DisplayManagerMessage::TRANS_ID_GET_SNAPSHOT_BY_PICKER: {
|
||||||
@ -351,21 +362,21 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
uint32_t modeId = data.ReadUint32();
|
uint32_t modeId = data.ReadUint32();
|
||||||
DMError ret = SetScreenActiveMode(screenId, modeId);
|
DMError ret = SetScreenActiveMode(screenId, modeId);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO: {
|
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
float virtualPixelRatio = data.ReadFloat();
|
float virtualPixelRatio = data.ReadFloat();
|
||||||
DMError ret = SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
DMError ret = SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM: {
|
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
float virtualPixelRatio = data.ReadFloat();
|
float virtualPixelRatio = data.ReadFloat();
|
||||||
DMError ret = SetVirtualPixelRatioSystem(screenId, virtualPixelRatio);
|
DMError ret = SetVirtualPixelRatioSystem(screenId, virtualPixelRatio);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_RESOLUTION: {
|
case DisplayManagerMessage::TRANS_ID_SET_RESOLUTION: {
|
||||||
@ -374,7 +385,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
uint32_t height = data.ReadUint32();
|
uint32_t height = data.ReadUint32();
|
||||||
float virtualPixelRatio = data.ReadFloat();
|
float virtualPixelRatio = data.ReadFloat();
|
||||||
DMError ret = SetResolution(screenId, width, height, virtualPixelRatio);
|
DMError ret = SetResolution(screenId, width, height, virtualPixelRatio);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION: {
|
case DisplayManagerMessage::TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION: {
|
||||||
@ -382,74 +393,74 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
float virtualPixelRatio;
|
float virtualPixelRatio;
|
||||||
DMError ret = GetDensityInCurResolution(screenId, virtualPixelRatio);
|
DMError ret = GetDensityInCurResolution(screenId, virtualPixelRatio);
|
||||||
reply.WriteFloat(virtualPixelRatio);
|
reply.WriteFloat(virtualPixelRatio);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
ScreenColorGamut colorGamut;
|
ScreenColorGamut colorGamut;
|
||||||
DMError ret = GetScreenColorGamut(screenId, colorGamut);
|
DMError ret = GetScreenColorGamut(screenId, colorGamut);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reply.WriteUint32(static_cast<uint32_t>(colorGamut));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(colorGamut)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
int32_t colorGamutIdx = data.ReadInt32();
|
int32_t colorGamutIdx = data.ReadInt32();
|
||||||
DMError ret = SetScreenColorGamut(screenId, colorGamutIdx);
|
DMError ret = SetScreenColorGamut(screenId, colorGamutIdx);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
ScreenGamutMap gamutMap;
|
ScreenGamutMap gamutMap;
|
||||||
DMError ret = GetScreenGamutMap(screenId, gamutMap);
|
DMError ret = GetScreenGamutMap(screenId, gamutMap);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reply.WriteInt32(static_cast<uint32_t>(gamutMap));
|
static_cast<void>(reply.WriteInt32(static_cast<uint32_t>(gamutMap)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
ScreenGamutMap gamutMap = static_cast<ScreenGamutMap>(data.ReadUint32());
|
ScreenGamutMap gamutMap = static_cast<ScreenGamutMap>(data.ReadUint32());
|
||||||
DMError ret = SetScreenGamutMap(screenId, gamutMap);
|
DMError ret = SetScreenGamutMap(screenId, gamutMap);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
DMError ret = SetScreenColorTransform(screenId);
|
DMError ret = SetScreenColorTransform(screenId);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
GraphicPixelFormat pixelFormat;
|
GraphicPixelFormat pixelFormat;
|
||||||
DMError ret = GetPixelFormat(screenId, pixelFormat);
|
DMError ret = GetPixelFormat(screenId, pixelFormat);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reply.WriteInt32(static_cast<uint32_t>(pixelFormat));
|
static_cast<void>(reply.WriteInt32(static_cast<uint32_t>(pixelFormat)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
GraphicPixelFormat pixelFormat = static_cast<GraphicPixelFormat>(data.ReadUint32());
|
GraphicPixelFormat pixelFormat = static_cast<GraphicPixelFormat>(data.ReadUint32());
|
||||||
DMError ret = SetPixelFormat(screenId, pixelFormat);
|
DMError ret = SetPixelFormat(screenId, pixelFormat);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
std::vector<ScreenHDRFormat> hdrFormats;
|
std::vector<ScreenHDRFormat> hdrFormats;
|
||||||
DMError ret = GetSupportedHDRFormats(screenId, hdrFormats);
|
DMError ret = GetSupportedHDRFormats(screenId, hdrFormats);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -464,25 +475,25 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
ScreenHDRFormat hdrFormat;
|
ScreenHDRFormat hdrFormat;
|
||||||
DMError ret = GetScreenHDRFormat(screenId, hdrFormat);
|
DMError ret = GetScreenHDRFormat(screenId, hdrFormat);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reply.WriteInt32(static_cast<uint32_t>(hdrFormat));
|
static_cast<void>(reply.WriteInt32(static_cast<uint32_t>(hdrFormat)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
int32_t modeIdx = data.ReadInt32();
|
int32_t modeIdx = data.ReadInt32();
|
||||||
DMError ret = SetScreenHDRFormat(screenId, modeIdx);
|
DMError ret = SetScreenHDRFormat(screenId, modeIdx);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
std::vector<GraphicCM_ColorSpaceType> colorSpaces;
|
std::vector<GraphicCM_ColorSpaceType> colorSpaces;
|
||||||
DMError ret = GetSupportedColorSpaces(screenId, colorSpaces);
|
DMError ret = GetSupportedColorSpaces(screenId, colorSpaces);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -497,43 +508,43 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
GraphicCM_ColorSpaceType colorSpace;
|
GraphicCM_ColorSpaceType colorSpace;
|
||||||
DMError ret = GetScreenColorSpace(screenId, colorSpace);
|
DMError ret = GetScreenColorSpace(screenId, colorSpace);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
if (ret != DMError::DM_OK) {
|
if (ret != DMError::DM_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reply.WriteInt32(static_cast<uint32_t>(colorSpace));
|
static_cast<void>(reply.WriteInt32(static_cast<uint32_t>(colorSpace)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE: {
|
case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
GraphicCM_ColorSpaceType colorSpace = static_cast<GraphicCM_ColorSpaceType>(data.ReadUint32());
|
GraphicCM_ColorSpaceType colorSpace = static_cast<GraphicCM_ColorSpaceType>(data.ReadUint32());
|
||||||
DMError ret = SetScreenColorSpace(screenId, colorSpace);
|
DMError ret = SetScreenColorSpace(screenId, colorSpace);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_ORIENTATION: {
|
case DisplayManagerMessage::TRANS_ID_SET_ORIENTATION: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
Orientation orientation = static_cast<Orientation>(data.ReadUint32());
|
Orientation orientation = static_cast<Orientation>(data.ReadUint32());
|
||||||
DMError ret = SetOrientation(screenId, orientation);
|
DMError ret = SetOrientation(screenId, orientation);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED: {
|
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED: {
|
||||||
bool isLocked = static_cast<bool>(data.ReadBool());
|
bool isLocked = static_cast<bool>(data.ReadBool());
|
||||||
DMError ret = SetScreenRotationLocked(isLocked);
|
DMError ret = SetScreenRotationLocked(isLocked);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS: {
|
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS: {
|
||||||
bool isLocked = static_cast<bool>(data.ReadBool());
|
bool isLocked = static_cast<bool>(data.ReadBool());
|
||||||
DMError ret = SetScreenRotationLockedFromJs(isLocked);
|
DMError ret = SetScreenRotationLockedFromJs(isLocked);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: {
|
case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: {
|
||||||
bool isLocked = false;
|
bool isLocked = false;
|
||||||
DMError ret = IsScreenRotationLocked(isLocked);
|
DMError ret = IsScreenRotationLocked(isLocked);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteBool(isLocked);
|
reply.WriteBool(isLocked);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -547,7 +558,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
DisplayId id = static_cast<DisplayId>(data.ReadUint64());
|
DisplayId id = static_cast<DisplayId>(data.ReadUint64());
|
||||||
bool hasPrivateWindow = false;
|
bool hasPrivateWindow = false;
|
||||||
DMError ret = HasPrivateWindow(id, hasPrivateWindow);
|
DMError ret = HasPrivateWindow(id, hasPrivateWindow);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteBool(hasPrivateWindow);
|
reply.WriteBool(hasPrivateWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -556,27 +567,27 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId rsId = SCREEN_ID_INVALID;
|
ScreenId rsId = SCREEN_ID_INVALID;
|
||||||
bool ret = ConvertScreenIdToRsScreenId(screenId, rsId);
|
bool ret = ConvertScreenIdToRsScreenId(screenId, rsId);
|
||||||
reply.WriteBool(ret);
|
reply.WriteBool(ret);
|
||||||
reply.WriteUint64(rsId);
|
static_cast<void>(reply.WriteUint64(rsId));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW: {
|
case DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW: {
|
||||||
bool immersive = false;
|
bool immersive = false;
|
||||||
DMError ret = HasImmersiveWindow(immersive);
|
DMError ret = HasImmersiveWindow(immersive);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteBool(immersive);
|
reply.WriteBool(immersive);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN: {
|
||||||
std::string dumpInfo;
|
std::string dumpInfo;
|
||||||
DumpAllScreensInfo(dumpInfo);
|
DumpAllScreensInfo(dumpInfo);
|
||||||
reply.WriteString(dumpInfo);
|
static_cast<void>(reply.WriteString(dumpInfo));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN: {
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
std::string dumpInfo;
|
std::string dumpInfo;
|
||||||
DumpSpecialScreenInfo(screenId, dumpInfo);
|
DumpSpecialScreenInfo(screenId, dumpInfo);
|
||||||
reply.WriteString(dumpInfo);
|
static_cast<void>(reply.WriteString(dumpInfo));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_DEVICE_IS_CAPTURE: {
|
case DisplayManagerMessage::TRANS_ID_DEVICE_IS_CAPTURE: {
|
||||||
@ -592,7 +603,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
case DisplayManagerMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS: {
|
case DisplayManagerMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS: {
|
||||||
FoldDisplayMode displayMode = static_cast<FoldDisplayMode>(data.ReadUint32());
|
FoldDisplayMode displayMode = static_cast<FoldDisplayMode>(data.ReadUint32());
|
||||||
DMError ret = SetFoldDisplayModeFromJs(displayMode);
|
DMError ret = SetFoldDisplayModeFromJs(displayMode);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS: {
|
||||||
@ -603,7 +614,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
case DisplayManagerMessage::TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS: {
|
case DisplayManagerMessage::TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS: {
|
||||||
bool lockDisplayStatus = static_cast<bool>(data.ReadUint32());
|
bool lockDisplayStatus = static_cast<bool>(data.ReadUint32());
|
||||||
DMError ret = SetFoldStatusLockedFromJs(lockDisplayStatus);
|
DMError ret = SetFoldStatusLockedFromJs(lockDisplayStatus);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE: {
|
||||||
@ -617,7 +628,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: {
|
||||||
FoldDisplayMode displayMode = GetFoldDisplayMode();
|
FoldDisplayMode displayMode = GetFoldDisplayMode();
|
||||||
reply.WriteUint32(static_cast<uint32_t>(displayMode));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(displayMode)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE: {
|
||||||
@ -625,7 +636,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS: {
|
||||||
reply.WriteUint32(static_cast<uint32_t>(GetFoldStatus()));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(GetFoldStatus())));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION: {
|
case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION: {
|
||||||
@ -644,7 +655,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DMError ret = MakeUniqueScreen(uniqueScreenIds);
|
DMError ret = MakeUniqueScreen(uniqueScreenIds);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SET_CLIENT: {
|
case DisplayManagerMessage::TRANS_ID_SET_CLIENT: {
|
||||||
@ -686,7 +697,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA: {
|
case DisplayManagerMessage::TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA: {
|
||||||
auto area = GetCurvedCompressionArea();
|
auto area = GetCurvedCompressionArea();
|
||||||
reply.WriteUint32(area);
|
static_cast<void>(reply.WriteUint32(area));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_PHY_SCREEN_PROPERTY: {
|
case DisplayManagerMessage::TRANS_ID_GET_PHY_SCREEN_PROPERTY: {
|
||||||
@ -728,7 +739,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
uint32_t width = data.ReadUint32();
|
uint32_t width = data.ReadUint32();
|
||||||
uint32_t height = data.ReadUint32();
|
uint32_t height = data.ReadUint32();
|
||||||
DMError ret = ResizeVirtualScreen(screenId, width, height);
|
DMError ret = ResizeVirtualScreen(screenId, width, height);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_UPDATE_AVAILABLE_AREA: {
|
case DisplayManagerMessage::TRANS_ID_UPDATE_AVAILABLE_AREA: {
|
||||||
@ -744,7 +755,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_OFF_DELAY_TIME: {
|
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_OFF_DELAY_TIME: {
|
||||||
int32_t delay = data.ReadInt32();
|
int32_t delay = data.ReadInt32();
|
||||||
int32_t ret = SetScreenOffDelayTime(delay);
|
int32_t ret = SetScreenOffDelayTime(delay);
|
||||||
reply.WriteInt32(ret);
|
static_cast<void>(reply.WriteInt32(ret));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_GET_AVAILABLE_AREA: {
|
case DisplayManagerMessage::TRANS_ID_GET_AVAILABLE_AREA: {
|
||||||
@ -774,7 +785,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
uint32_t refreshInterval = data.ReadUint32();
|
uint32_t refreshInterval = data.ReadUint32();
|
||||||
DMError ret = SetVirtualScreenRefreshRate(screenId, refreshInterval);
|
DMError ret = SetVirtualScreenRefreshRate(screenId, refreshInterval);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_SWITCH_USER: {
|
case DisplayManagerMessage::TRANS_ID_SWITCH_USER: {
|
||||||
@ -802,7 +813,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
|||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_RESET_ALL_FREEZE_STATUS: {
|
case DisplayManagerMessage::TRANS_ID_RESET_ALL_FREEZE_STATUS: {
|
||||||
DMError ret = ResetAllFreezeStatus();
|
DMError ret = ResetAllFreezeStatus();
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO: {
|
case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO: {
|
||||||
@ -844,11 +855,11 @@ void ScreenSessionManagerStub::ProcGetAvailableArea(MessageParcel& data, Message
|
|||||||
DisplayId displayId = static_cast<DisplayId>(data.ReadUint64());
|
DisplayId displayId = static_cast<DisplayId>(data.ReadUint64());
|
||||||
DMRect area;
|
DMRect area;
|
||||||
DMError ret = GetAvailableArea(displayId, area);
|
DMError ret = GetAvailableArea(displayId, area);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
reply.WriteInt32(area.posX_);
|
static_cast<void>(reply.WriteInt32(area.posX_));
|
||||||
reply.WriteInt32(area.posY_);
|
static_cast<void>(reply.WriteInt32(area.posY_));
|
||||||
reply.WriteUint32(area.width_);
|
static_cast<void>(reply.WriteUint32(area.width_));
|
||||||
reply.WriteUint32(area.height_);
|
static_cast<void>(reply.WriteUint32(area.height_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerStub::ProcGetSnapshotByPicker(MessageParcel& reply)
|
void ScreenSessionManagerStub::ProcGetSnapshotByPicker(MessageParcel& reply)
|
||||||
@ -857,11 +868,11 @@ void ScreenSessionManagerStub::ProcGetSnapshotByPicker(MessageParcel& reply)
|
|||||||
Media::Rect imgRect { 0, 0, 0, 0 };
|
Media::Rect imgRect { 0, 0, 0, 0 };
|
||||||
std::shared_ptr<Media::PixelMap> snapshot = GetSnapshotByPicker(imgRect, &errCode);
|
std::shared_ptr<Media::PixelMap> snapshot = GetSnapshotByPicker(imgRect, &errCode);
|
||||||
reply.WriteParcelable(snapshot == nullptr ? nullptr : snapshot.get());
|
reply.WriteParcelable(snapshot == nullptr ? nullptr : snapshot.get());
|
||||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(errCode)));
|
||||||
reply.WriteInt32(imgRect.left);
|
static_cast<void>(reply.WriteInt32(imgRect.left));
|
||||||
reply.WriteInt32(imgRect.top);
|
static_cast<void>(reply.WriteInt32(imgRect.top));
|
||||||
reply.WriteInt32(imgRect.width);
|
static_cast<void>(reply.WriteInt32(imgRect.width));
|
||||||
reply.WriteInt32(imgRect.height);
|
static_cast<void>(reply.WriteInt32(imgRect.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerStub::ProcSetVirtualScreenFlag(MessageParcel& data, MessageParcel& reply)
|
void ScreenSessionManagerStub::ProcSetVirtualScreenFlag(MessageParcel& data, MessageParcel& reply)
|
||||||
@ -869,14 +880,14 @@ void ScreenSessionManagerStub::ProcSetVirtualScreenFlag(MessageParcel& data, Mes
|
|||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
VirtualScreenFlag screenFlag = static_cast<VirtualScreenFlag>(data.ReadUint32());
|
VirtualScreenFlag screenFlag = static_cast<VirtualScreenFlag>(data.ReadUint32());
|
||||||
DMError setRet = SetVirtualScreenFlag(screenId, screenFlag);
|
DMError setRet = SetVirtualScreenFlag(screenId, screenFlag);
|
||||||
reply.WriteInt32(static_cast<int32_t>(setRet));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(setRet)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerStub::ProcGetVirtualScreenFlag(MessageParcel& data, MessageParcel& reply)
|
void ScreenSessionManagerStub::ProcGetVirtualScreenFlag(MessageParcel& data, MessageParcel& reply)
|
||||||
{
|
{
|
||||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
VirtualScreenFlag screenFlag = GetVirtualScreenFlag(screenId);
|
VirtualScreenFlag screenFlag = GetVirtualScreenFlag(screenId);
|
||||||
reply.WriteUint32(static_cast<uint32_t>(screenFlag));
|
static_cast<void>(reply.WriteUint32(static_cast<uint32_t>(screenFlag)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerStub::ProcProxyForFreeze(MessageParcel& data, MessageParcel& reply)
|
void ScreenSessionManagerStub::ProcProxyForFreeze(MessageParcel& data, MessageParcel& reply)
|
||||||
@ -892,7 +903,7 @@ void ScreenSessionManagerStub::ProcProxyForFreeze(MessageParcel& data, MessagePa
|
|||||||
}
|
}
|
||||||
bool isProxy = data.ReadBool();
|
bool isProxy = data.ReadBool();
|
||||||
DMError ret = ProxyForFreeze(pidList, isProxy);
|
DMError ret = ProxyForFreeze(pidList, isProxy);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerStub::ProcGetAllDisplayPhysicalResolution(MessageParcel& data, MessageParcel& reply)
|
void ScreenSessionManagerStub::ProcGetAllDisplayPhysicalResolution(MessageParcel& data, MessageParcel& reply)
|
||||||
@ -930,6 +941,6 @@ void ScreenSessionManagerStub::ProcSetVirtualScreenSecurityExemption(MessageParc
|
|||||||
std::vector<uint64_t> windowIdList;
|
std::vector<uint64_t> windowIdList;
|
||||||
data.ReadUInt64Vector(&windowIdList);
|
data.ReadUInt64Vector(&windowIdList);
|
||||||
DMError ret = SetVirtualScreenSecurityExemption(screenId, pid, windowIdList);
|
DMError ret = SetVirtualScreenSecurityExemption(screenId, pid, windowIdList);
|
||||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
|
||||||
}
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
|
@ -99,6 +99,7 @@ private:
|
|||||||
void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
||||||
PowerStateChangeReason reason) override;
|
PowerStateChangeReason reason) override;
|
||||||
void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) override;
|
void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) override;
|
||||||
|
void OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus) override;
|
||||||
void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) override;
|
void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) override;
|
||||||
void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) override;
|
void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) override;
|
||||||
void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM,
|
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM,
|
||||||
TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE,
|
TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE,
|
||||||
TRANS_ID_ON_SCREEN_EXTEND_CHANGED,
|
TRANS_ID_ON_SCREEN_EXTEND_CHANGED,
|
||||||
|
TRANS_ID_ON_HOVER_STATUS_CHANGED,
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid) = 0;
|
virtual void SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid) = 0;
|
||||||
@ -54,6 +55,7 @@ public:
|
|||||||
virtual void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
virtual void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
||||||
PowerStateChangeReason reason) = 0;
|
PowerStateChangeReason reason) = 0;
|
||||||
virtual void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) = 0;
|
virtual void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) = 0;
|
||||||
|
virtual void OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus) = 0;
|
||||||
virtual void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) = 0;
|
virtual void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) = 0;
|
||||||
virtual void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) = 0;
|
virtual void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) = 0;
|
||||||
virtual void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) = 0;
|
virtual void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) = 0;
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
|
||||||
PowerStateChangeReason reason) override;
|
PowerStateChangeReason reason) override;
|
||||||
void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) override;
|
void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) override;
|
||||||
|
void OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus) override;
|
||||||
void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) override;
|
void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) override;
|
||||||
void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override;
|
||||||
void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) override;
|
void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) override;
|
||||||
|
@ -47,6 +47,7 @@ private:
|
|||||||
int HandleSwitchUserCallback(MessageParcel& data, MessageParcel& reply);
|
int HandleSwitchUserCallback(MessageParcel& data, MessageParcel& reply);
|
||||||
int HandleOnFoldStatusChangedReportUE(MessageParcel& data, MessageParcel& reply);
|
int HandleOnFoldStatusChangedReportUE(MessageParcel& data, MessageParcel& reply);
|
||||||
int HandleOnScreenExtendChanged(MessageParcel& data, MessageParcel& reply);
|
int HandleOnScreenExtendChanged(MessageParcel& data, MessageParcel& reply);
|
||||||
|
int HandleOnHoverStatusChanged(MessageParcel& data, MessageParcel& reply);
|
||||||
};
|
};
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
|
|
||||||
|
@ -207,6 +207,16 @@ void ScreenSessionManagerClient::OnSensorRotationChanged(ScreenId screenId, floa
|
|||||||
screenSession->SensorRotationChange(sensorRotation);
|
screenSession->SensorRotationChange(sensorRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManagerClient::OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus)
|
||||||
|
{
|
||||||
|
auto screenSession = GetScreenSession(screenId);
|
||||||
|
if (!screenSession) {
|
||||||
|
WLOGFE("screenSession is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
screenSession->HandleHoverStatusChange(hoverStatus);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerClient::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
|
void ScreenSessionManagerClient::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
|
||||||
{
|
{
|
||||||
auto screenSession = GetScreenSession(screenId);
|
auto screenSession = GetScreenSession(screenId);
|
||||||
|
@ -229,6 +229,37 @@ void ScreenSessionManagerClientProxy::OnSensorRotationChanged(ScreenId screenId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSessionManagerClientProxy::OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
WLOGFE("remote is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||||
|
WLOGFE("WriteInterfaceToken failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!data.WriteUint64(screenId)) {
|
||||||
|
WLOGFE("Write screenId failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!data.WriteInt32(hoverStatus)) {
|
||||||
|
WLOGFE("Write hoverStatus failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_HOVER_STATUS_CHANGED),
|
||||||
|
data, reply, option) != ERR_NONE) {
|
||||||
|
WLOGFE("SendRequest failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSessionManagerClientProxy::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
|
void ScreenSessionManagerClientProxy::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
|
||||||
{
|
{
|
||||||
sptr<IRemoteObject> remote = Remote();
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
@ -46,6 +46,9 @@ int ScreenSessionManagerClientStub::OnRemoteRequest(uint32_t code, MessageParcel
|
|||||||
case ScreenSessionManagerClientMessage::TRANS_ID_ON_SENSOR_ROTATION_CHANGED: {
|
case ScreenSessionManagerClientMessage::TRANS_ID_ON_SENSOR_ROTATION_CHANGED: {
|
||||||
return HandleOnSensorRotationChanged(data, reply);
|
return HandleOnSensorRotationChanged(data, reply);
|
||||||
}
|
}
|
||||||
|
case ScreenSessionManagerClientMessage::TRANS_ID_ON_HOVER_STATUS_CHANGED: {
|
||||||
|
return HandleOnHoverStatusChanged(data, reply);
|
||||||
|
}
|
||||||
case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ORIENTATION_CHANGED: {
|
case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ORIENTATION_CHANGED: {
|
||||||
return HandleOnScreenOrientationChanged(data, reply);
|
return HandleOnScreenOrientationChanged(data, reply);
|
||||||
}
|
}
|
||||||
@ -255,4 +258,13 @@ int ScreenSessionManagerClientStub::HandleOnFoldStatusChangedReportUE(MessagePar
|
|||||||
OnFoldStatusChangedReportUE(screenFoldInfo);
|
OnFoldStatusChangedReportUE(screenFoldInfo);
|
||||||
return ERR_NONE;
|
return ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScreenSessionManagerClientStub::HandleOnHoverStatusChanged(MessageParcel& data, MessageParcel& reply)
|
||||||
|
{
|
||||||
|
WLOGD("HandleOnHoverStatusChanged");
|
||||||
|
auto screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||||
|
auto hoverStatus = data.ReadInt32();
|
||||||
|
OnHoverStatusChanged(screenId, hoverStatus);
|
||||||
|
return ERR_NONE;
|
||||||
|
}
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
|
@ -50,6 +50,7 @@ ohos_shared_library("scene_session") {
|
|||||||
"host/src/keyboard_session.cpp",
|
"host/src/keyboard_session.cpp",
|
||||||
"host/src/main_session.cpp",
|
"host/src/main_session.cpp",
|
||||||
"host/src/move_drag_controller.cpp",
|
"host/src/move_drag_controller.cpp",
|
||||||
|
"host/src/multi_instance_manager.cpp",
|
||||||
"host/src/root_scene_session.cpp",
|
"host/src/root_scene_session.cpp",
|
||||||
"host/src/scb_system_session.cpp",
|
"host/src/scb_system_session.cpp",
|
||||||
"host/src/scene_persistence.cpp",
|
"host/src/scene_persistence.cpp",
|
||||||
@ -79,6 +80,8 @@ ohos_shared_library("scene_session") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"ability_runtime:ability_start_setting",
|
"ability_runtime:ability_start_setting",
|
||||||
"ability_runtime:process_options",
|
"ability_runtime:process_options",
|
||||||
|
"bundle_framework:appexecfwk_base",
|
||||||
|
"bundle_framework:appexecfwk_core",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"eventhandler:libeventhandler",
|
"eventhandler:libeventhandler",
|
||||||
"ffrt:libffrt",
|
"ffrt:libffrt",
|
||||||
@ -174,6 +177,7 @@ ohos_shared_library("screen_session") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"graphic_2d:librender_service_client",
|
"graphic_2d:librender_service_client",
|
||||||
|
"hicollie:libhicollie",
|
||||||
"hilog:libhilog",
|
"hilog:libhilog",
|
||||||
"hisysevent:libhisysevent",
|
"hisysevent:libhisysevent",
|
||||||
"hitrace:hitrace_meter",
|
"hitrace:hitrace_meter",
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
// IPC interface
|
// IPC interface
|
||||||
virtual WSError SetActive(bool active) = 0;
|
virtual WSError SetActive(bool active) = 0;
|
||||||
virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
||||||
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
|
const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }) = 0;
|
||||||
virtual void UpdateDensity() = 0;
|
virtual void UpdateDensity() = 0;
|
||||||
virtual WSError UpdateOrientation() = 0;
|
virtual WSError UpdateOrientation() = 0;
|
||||||
|
|
||||||
@ -128,6 +128,10 @@ public:
|
|||||||
{
|
{
|
||||||
return WSError::WS_OK;
|
return WSError::WS_OK;
|
||||||
}
|
}
|
||||||
|
virtual WSError NotifyCompatibleModeEnableInPad(bool enable)
|
||||||
|
{
|
||||||
|
return WSError::WS_OK;
|
||||||
|
}
|
||||||
virtual void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) = 0;
|
virtual void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) = 0;
|
||||||
virtual void NotifySessionFullScreen(bool fullScreen) {}
|
virtual void NotifySessionFullScreen(bool fullScreen) {}
|
||||||
|
|
||||||
@ -173,6 +177,7 @@ public:
|
|||||||
{
|
{
|
||||||
return WSError::WS_OK;
|
return WSError::WS_OK;
|
||||||
}
|
}
|
||||||
|
virtual WSError SetSplitButtonVisible(bool isVisible) = 0;
|
||||||
};
|
};
|
||||||
} // namespace OHOS::Rosen
|
} // namespace OHOS::Rosen
|
||||||
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
|
#endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user