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

Signed-off-by: 匡梅 <kuangmei1@huawei.com>
This commit is contained in:
匡梅 2024-10-30 12:48:20 +00:00 committed by Gitee
commit fe534eae93
193 changed files with 4774 additions and 2397 deletions

View File

@ -182,7 +182,11 @@ ohos_shared_library("libdm_ndk") {
sources = [ "src/oh_display_manager.cpp" ]
deps = [ ":libdm" ]
deps = [
":libdm",
"${window_base_path}/utils:libwmutil_base",
]
innerapi_tags = [ "ndk" ]
external_deps = [

View File

@ -100,6 +100,7 @@ public:
std::vector<uint64_t>& windowIdList);
virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr);
virtual sptr<DisplayInfo> GetPrimaryDisplayInfo();
private:
static inline SingletonDelegator<DisplayManagerAdapter> delegator;

View File

@ -38,7 +38,21 @@ public:
}
~Impl() = default;
DEFINE_VAR_FUNC_GET_SET(std::string, Name, name);
DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<DisplayInfo>, DisplayInfo, displayInfo);
sptr<DisplayInfo> GetDisplayInfo()
{
std::lock_guard<std::mutex> lock(displayInfoMutex_);
return displayInfo_;
}
void SetDisplayInfo(sptr<DisplayInfo> value)
{
std::lock_guard<std::mutex> lock(displayInfoMutex_);
displayInfo_ = value;
}
private:
sptr<DisplayInfo> displayInfo_;
std::mutex displayInfoMutex_;
};
Display::Display(const std::string& name, sptr<DisplayInfo> info)

View File

@ -90,6 +90,7 @@ public:
DMError ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy);
DMError ResetAllFreezeStatus();
DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector<uint64_t>& windowIdList);
sptr<Display> GetPrimaryDisplaySync();
void OnRemoteDied();
private:
void ClearDisplayStateCallback();
@ -117,7 +118,9 @@ private:
std::string GetDisplayInfoSrting(sptr<DisplayInfo> displayInfo);
DisplayId defaultDisplayId_ = DISPLAY_ID_INVALID;
DisplayId primaryDisplayId_ = DISPLAY_ID_INVALID;
std::map<DisplayId, sptr<Display>> displayMap_;
std::map<DisplayId, std::chrono::steady_clock::time_point> displayUptateTimeMap_;
DisplayStateCallback displayStateCallback_;
std::recursive_mutex& mutex_;
std::set<sptr<IDisplayListener>> displayListeners_;
@ -613,38 +616,37 @@ sptr<Display> DisplayManager::Impl::GetDefaultDisplaySync()
sptr<Display> DisplayManager::Impl::GetDisplayById(DisplayId displayId)
{
WLOGFD("GetDisplayById start, displayId: %{public}" PRIu64" ", displayId);
static std::chrono::steady_clock::time_point lastRequestTime = std::chrono::steady_clock::now();
auto currentTime = std::chrono::steady_clock::now();
auto interval = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - lastRequestTime).count();
if (displayId != DISPLAY_ID_INVALID && interval < MAX_INTERVAL_US) {
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = displayMap_.find(displayId);
if (iter != displayMap_.end()) {
WLOGFI("Get display from displayMap_");
return displayMap_[displayId];
auto lastRequestIter = displayUptateTimeMap_.find(displayId);
if (displayId != DISPLAY_ID_INVALID && lastRequestIter != displayUptateTimeMap_.end()) {
auto interval = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - lastRequestIter->second)
.count();
if (interval < MAX_INTERVAL_US) {
auto iter = displayMap_.find(displayId);
if (iter != displayMap_.end()) {
return displayMap_[displayId];
}
}
}
}
uint32_t retryTimes = 0;
sptr<DisplayInfo> displayInfo = nullptr;
while (retryTimes < MAX_RETRY_NUM) {
displayInfo = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(displayId);
if (displayInfo != nullptr) {
break;
}
retryTimes++;
WLOGFW("Current get display info is null, retry %{public}u times", retryTimes);
std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_WAIT_MS));
}
if (retryTimes >= MAX_RETRY_NUM || displayInfo == nullptr) {
WLOGFE("Get display info failed, please check whether the onscreenchange event is triggered");
WLOGFI("update displayId: %{public}" PRIu64" ", displayId);
sptr<DisplayInfo> displayInfo = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(displayId);
if (displayInfo == nullptr) {
WLOGFW("display null id : %{public}" PRIu64" ", displayId);
return nullptr;
}
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!UpdateDisplayInfoLocked(displayInfo)) {
displayMap_.erase(displayId);
//map erase函数删除不存在key行为安全
displayUptateTimeMap_.erase(displayId);
return nullptr;
}
lastRequestTime = currentTime;
displayUptateTimeMap_[displayId] = currentTime;
return displayMap_[displayId];
}
@ -2086,9 +2088,49 @@ DMError DisplayManager::Impl::SetVirtualScreenSecurityExemption(ScreenId screenI
screenId, pid, windowIdList);
}
sptr<Display> DisplayManager::Impl::GetPrimaryDisplaySync()
{
static std::chrono::steady_clock::time_point lastRequestTime = std::chrono::steady_clock::now();
auto currentTime = std::chrono::steady_clock::now();
auto interval = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - lastRequestTime).count();
if (primaryDisplayId_ != DISPLAY_ID_INVALID && interval < MAX_INTERVAL_US) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = displayMap_.find(primaryDisplayId_);
if (iter != displayMap_.end()) {
return displayMap_[primaryDisplayId_];
}
}
uint32_t retryTimes = 0;
sptr<DisplayInfo> displayInfo = nullptr;
while (retryTimes < MAX_RETRY_NUM) {
displayInfo = SingletonContainer::Get<DisplayManagerAdapter>().GetPrimaryDisplayInfo();
if (displayInfo != nullptr) {
break;
}
retryTimes++;
WLOGFW("get display info null, retry %{public}u times", retryTimes);
std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_WAIT_MS));
}
if (retryTimes >= MAX_RETRY_NUM || displayInfo == nullptr) {
WLOGFE("get display info failed");
return nullptr;
}
auto displayId = displayInfo->GetDisplayId();
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!UpdateDisplayInfoLocked(displayInfo)) {
displayMap_.erase(displayId);
return nullptr;
}
lastRequestTime = currentTime;
primaryDisplayId_ = displayId;
return displayMap_[displayId];
}
sptr<Display> DisplayManager::GetPrimaryDisplaySync()
{
return pImpl_->GetDefaultDisplaySync();
return pImpl_->GetPrimaryDisplaySync();
}
std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenCapture(const CaptureOption& captureOption,

View File

@ -856,4 +856,10 @@ std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetScreenCapture(const C
INIT_PROXY_CHECK_RETURN(nullptr);
return displayManagerServiceProxy_->GetScreenCapture(captureOption, errorCode);
}
sptr<DisplayInfo> DisplayManagerAdapter::GetPrimaryDisplayInfo()
{
INIT_PROXY_CHECK_RETURN(nullptr);
return displayManagerServiceProxy_->GetPrimaryDisplayInfo();
}
} // namespace OHOS::Rosen

View File

@ -948,6 +948,15 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateScreenCapture(uint3
option.isNeedNotify_ = true;
DmErrorCode errCode = DmErrorCode::DM_OK;
std::shared_ptr<Media::PixelMap> captureImage = DisplayManager::GetInstance().GetScreenCapture(option, &errCode);
if (errCode == DmErrorCode::DM_ERROR_INVALID_PARAM) {
TLOGE(WmsLogTag::DMS, "[DMNDK] param error.");
return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM;
}
if (errCode == DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT) {
TLOGE(WmsLogTag::DMS, "[DMNDK] not support.");
return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED;
}
if (errCode == DmErrorCode::DM_ERROR_NO_PERMISSION) {
TLOGE(WmsLogTag::DMS, "[DMNDK] pixelMap no permission.");
return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_NO_PERMISSION;

View File

@ -833,6 +833,18 @@ HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Leve
ScreenId screenId = displayInfo->GetScreenId();
displayManagerAdapter.SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY);
}
/**
* @tc.name: GetPrimaryDisplayInfo
* @tc.desc: GetPrimaryDisplayInfo test
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterTest, GetPrimaryDisplayInfo, Function | SmallTest | Level2)
{
DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo();
ASSERT_NE(displayInfo, nullptr);
}
}
}
}

View File

@ -1672,7 +1672,6 @@ HWTEST_F(DisplayManagerTest, GetScreenCapture, Function | SmallTest | Level1)
DmErrorCode errCode;
std::shared_ptr<Media::PixelMap> pixelMap = DisplayManager::GetInstance().GetScreenCapture(captureOption,
&errCode);
ASSERT_NE(pixelMap, nullptr);
}
/**

View File

@ -205,10 +205,10 @@ HWTEST_F(DisplayPowerUnitTest, suspend_begin_001, Function | SmallTest | Level2)
}
/**
* @tc.name: suspend_end_001
* @tc.desc: call SuspendEnd and check return value
* @tc.type: FUNC
*/
* @tc.name: suspend_end_001
* @tc.desc: call SuspendEnd and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerUnitTest, suspend_end_001, Function | SmallTest | Level2)
{
Mocker m;
@ -222,10 +222,10 @@ HWTEST_F(DisplayPowerUnitTest, suspend_end_001, Function | SmallTest | Level2)
}
/**
* @tc.name: set_screen_brightness_001
* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value
* @tc.type: FUNC
*/
* @tc.name: set_screen_brightness_001
* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerUnitTest, set_screen_brightness_001, Function | MediumTest | Level2)
{
bool ret = DisplayManager::GetInstance().SetScreenBrightness(defaultId_, brightnessLevel_);
@ -233,10 +233,10 @@ HWTEST_F(DisplayPowerUnitTest, set_screen_brightness_001, Function | MediumTest
}
/**
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value
* @tc.type: FUNC
*/
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerUnitTest, set_screen_power_for_all_001, Function | MediumTest | Level2)
{
SingletonMocker<ScreenManagerAdapter, MockScreenManagerAdapter> m;
@ -253,10 +253,10 @@ HWTEST_F(DisplayPowerUnitTest, set_screen_power_for_all_001, Function | MediumTe
}
/**
* @tc.name: set_display_state_001
* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value
* @tc.type: FUNC
*/
* @tc.name: set_display_state_001
* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerUnitTest, set_display_state_001, Function | MediumTest | Level2)
{
DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
@ -274,10 +274,10 @@ HWTEST_F(DisplayPowerUnitTest, set_display_state_001, Function | MediumTest | Le
}
/**
* @tc.name: set_display_state_002
* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value
* @tc.type: FUNC
*/
* @tc.name: set_display_state_002
* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerUnitTest, set_display_state_002, Function | MediumTest | Level2)
{
Mocker m;

View File

@ -112,10 +112,10 @@ HWTEST_F(DisplayLitePowerUnitTest, suspend_begin_001, Function | SmallTest | Lev
}
/**
* @tc.name: suspend_end_001
* @tc.desc: call SuspendEnd and check return value
* @tc.type: FUNC
*/
* @tc.name: suspend_end_001
* @tc.desc: call SuspendEnd and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, suspend_end_001, Function | SmallTest | Level2)
{
Mocker m;
@ -129,10 +129,10 @@ HWTEST_F(DisplayLitePowerUnitTest, suspend_end_001, Function | SmallTest | Level
}
/**
* @tc.name: set_screen_brightness_001
* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value
* @tc.type: FUNC
*/
* @tc.name: set_screen_brightness_001
* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_screen_brightness_001, Function | MediumTest | Level2)
{
bool ret = DisplayManagerLite::GetInstance().SetScreenBrightness(defaultId_, brightnessLevel_);
@ -153,10 +153,10 @@ HWTEST_F(DisplayLitePowerUnitTest, set_specified_screen_power_001, Function | Sm
}
/**
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value
* @tc.type: FUNC
*/
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_screen_power_for_all_001, Function | MediumTest | Level2)
{
SingletonMocker<ScreenManagerAdapterLite, MockScreenManagerAdapterLite> m;
@ -173,10 +173,10 @@ HWTEST_F(DisplayLitePowerUnitTest, set_screen_power_for_all_001, Function | Medi
}
/**
* @tc.name: set_display_state_001
* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value
* @tc.type: FUNC
*/
* @tc.name: set_display_state_001
* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_display_state_001, Function | MediumTest | Level2)
{
DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
@ -194,10 +194,10 @@ HWTEST_F(DisplayLitePowerUnitTest, set_display_state_001, Function | MediumTest
}
/**
* @tc.name: set_display_state_002
* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value
* @tc.type: FUNC
*/
* @tc.name: set_display_state_002
* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_display_state_002, Function | MediumTest | Level2)
{
Mocker m;

View File

@ -50,6 +50,7 @@ ohos_shared_library("libdms") {
"src/display_power_controller.cpp",
"src/screen_rotation_controller.cpp",
"src/sensor_connector.cpp",
"src/sensor_plugin.cpp",
]
configs = [
@ -81,7 +82,6 @@ ohos_shared_library("libdms") {
defines = []
if (window_manager_feature_subscribe_motion) {
if (defined(global_parts_info) && defined(global_parts_info.msdp_motion)) {
external_deps += [ "motion:motion_interface_native" ]
defines += [ "WM_SUBSCRIBE_MOTION_ENABLE" ]
}
}

View File

@ -239,6 +239,11 @@ public:
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
return nullptr;
}
virtual sptr<DisplayInfo> GetPrimaryDisplayInfo()
{
return nullptr;
}
};
} // namespace OHOS::Rosen

View File

@ -134,6 +134,7 @@ enum class DisplayManagerMessage : unsigned int {
TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION,
TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE,
TRANS_ID_GET_DISPLAY_CAPTURE,
TRANS_ID_GET_PRIMARY_DISPLAY_INFO,
};
}
#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H

View File

@ -22,11 +22,7 @@
#include "dm_common.h"
#include "screen_rotation_controller.h"
#include "window_manager_hilog.h"
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
#include "motion_agent.h"
#include "motion_callback_stub.h"
#endif
#include "sensor_plugin.h"
#ifdef SENSOR_ENABLE
#include "sensor_agent.h"
@ -65,14 +61,6 @@ private:
#endif
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
using OHOS::Msdp::MotionCallbackStub;
using OHOS::Msdp::MotionEvent;
class RotationMotionEventCallback : public MotionCallbackStub {
public:
void OnMotionChanged(const MotionEvent& motionData) override;
};
class MotionSubscriber {
friend SensorConnector;
public:
@ -82,7 +70,6 @@ private:
static void SubscribeMotionSensor();
static void UnsubscribeMotionSensor();
static sptr<RotationMotionEventCallback> motionEventCallback_;
static bool isMotionSensorSubscribed_;
};
#endif

View File

@ -0,0 +1,52 @@
/*
* 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 SENSOR_PLUGIN_H
#define SENSOR_PLUGIN_H
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <unistd.h>
#include "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
#if (defined(__aarch64__) || defined(__x86_64__))
const std::string PLUGIN_SO_PATH = "/system/lib64/platformsdk/libmotion_agent.z.so";
#else
const std::string PLUGIN_SO_PATH = "/system/lib/platformsdk/libmotion_agent.z.so";
#endif
typedef struct MotionSensorEvent {
int32_t type = -1;
int32_t status = -1;
int32_t dataLen = -1;
int32_t *data = nullptr;
} MotionSensorEvent;
using OnMotionChangedPtr = void (*)(const MotionSensorEvent&);
using MotionSubscribeCallbackPtr = bool (*)(int32_t, OnMotionChangedPtr);
using MotionUnsubscribeCallbackPtr = bool (*)(int32_t, OnMotionChangedPtr);
bool LoadMotionSensor(void);
void UnloadMotionSensor(void);
bool SubscribeCallback(int32_t motionType, OnMotionChangedPtr callback);
bool UnsubscribeCallback(int32_t motionType, OnMotionChangedPtr callback);
}
}
#endif /* SENSOR_PLUGIN_H */

View File

@ -37,6 +37,7 @@ constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "Sensor
constexpr int32_t MOTION_ACTION_LEFT_LANDSCAPE = 1;
constexpr int32_t MOTION_ACTION_PORTRAIT_INVERTED = 2;
constexpr int32_t MOTION_ACTION_RIGHT_LANDSCAPE = 3;
const int32_t MOTION_TYPE_ROTATION = 700;
#endif
}
@ -48,7 +49,7 @@ long GravitySensorSubscriber::lastCallbackTime_ = 0;
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
bool MotionSubscriber::isMotionSensorSubscribed_ = false;
sptr<RotationMotionEventCallback> MotionSubscriber::motionEventCallback_ = nullptr;
static void RotationMotionEventCallback(const MotionSensorEvent& motionData);
#endif
void SensorConnector::SubscribeRotationSensor()
@ -196,15 +197,10 @@ void MotionSubscriber::SubscribeMotionSensor()
WLOGFE("dms: motion sensor's already subscribed");
return;
}
sptr<RotationMotionEventCallback> callback = new (std::nothrow) RotationMotionEventCallback();
if (callback == nullptr) {
if (!SubscribeCallback(MOTION_TYPE_ROTATION, RotationMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor subscribe failed");
return;
}
int32_t ret = OHOS::Msdp::SubscribeCallback(OHOS::Msdp::MOTION_TYPE_ROTATION, callback);
if (ret != 0) {
return;
}
motionEventCallback_ = callback;
isMotionSensorSubscribed_ = true;
}
@ -214,14 +210,14 @@ void MotionSubscriber::UnsubscribeMotionSensor()
WLOGFI("dms: Unsubscribe motion sensor");
return;
}
int32_t ret = OHOS::Msdp::UnsubscribeCallback(OHOS::Msdp::MOTION_TYPE_ROTATION, motionEventCallback_);
if (ret != 0) {
if (!UnsubscribeCallback(MOTION_TYPE_ROTATION, RotationMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor unsubscribe failed");
return;
}
isMotionSensorSubscribed_ = false;
}
void RotationMotionEventCallback::OnMotionChanged(const MotionEvent& motionData)
void RotationMotionEventCallback(const MotionSensorEvent& motionData)
{
DeviceRotation motionRotation = DeviceRotation::INVALID;
switch (motionData.status) {

View File

@ -0,0 +1,90 @@
/*
* 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 "sensor_plugin.h"
namespace OHOS {
namespace Rosen {
namespace {
constexpr uint32_t SLEEP_TIME_US = 10000;
}
static void *g_handle = nullptr;
bool LoadMotionSensor(void)
{
if (g_handle != nullptr) {
TLOGW(WmsLogTag::DMS, "motion plugin has already exits.");
return true;
}
int32_t cnt = 0;
int32_t retryTimes = 3;
do {
cnt++;
g_handle = dlopen(PLUGIN_SO_PATH.c_str(), RTLD_LAZY);
TLOGI(WmsLogTag::DMS, "dlopen %{public}s, retry cnt: %{public}d", PLUGIN_SO_PATH.c_str(), cnt);
usleep(SLEEP_TIME_US);
} while (!g_handle && cnt < retryTimes);
return g_handle != nullptr;
}
void UnloadMotionSensor(void)
{
TLOGI(WmsLogTag::DMS, "unload motion plugin.");
if (g_handle != nullptr) {
dlclose(g_handle);
g_handle = nullptr;
}
}
__attribute__((no_sanitize("cfi"))) bool SubscribeCallback(int32_t motionType, OnMotionChangedPtr callback)
{
if (callback == nullptr) {
TLOGE(WmsLogTag::DMS, "callback is nullptr");
return false;
}
if (g_handle == nullptr) {
TLOGE(WmsLogTag::DMS, "g_handle is nullptr");
return false;
}
MotionSubscribeCallbackPtr func = (MotionSubscribeCallbackPtr)(dlsym(g_handle, "MotionSubscribeCallback"));
const char* dlsymError = dlerror();
if (dlsymError) {
TLOGE(WmsLogTag::DMS, "dlsym error: %{public}s", dlsymError);
return false;
}
return func(motionType, callback);
}
__attribute__((no_sanitize("cfi"))) bool UnsubscribeCallback(int32_t motionType, OnMotionChangedPtr callback)
{
if (callback == nullptr) {
TLOGE(WmsLogTag::DMS, "callback is nullptr");
return false;
}
if (g_handle == nullptr) {
TLOGE(WmsLogTag::DMS, "g_handle is nullptr");
return false;
}
MotionUnsubscribeCallbackPtr func =
(MotionUnsubscribeCallbackPtr)(dlsym(g_handle, "MotionUnsubscribeCallback"));
const char* dlsymError = dlerror();
if (dlsymError) {
TLOGE(WmsLogTag::DMS, "dlsym error: %{public}s", dlsymError);
return false;
}
return func(motionType, callback);
}
}
}

View File

@ -139,7 +139,6 @@ ohos_unittest("dmserver_screen_rotation_controller_test") {
if (window_manager_feature_subscribe_motion) {
if (defined(global_parts_info) && defined(global_parts_info.msdp_motion)) {
external_deps += [ "motion:motion_interface_native" ]
defines = [ "WM_SUBSCRIBE_MOTION_ENABLE" ]
}
}

View File

@ -647,53 +647,6 @@ HWTEST_F(ScreenRotationControllerTest, SubscribeMotionSensor, Function | SmallTe
MotionSubscriber::UnsubscribeMotionSensor();
ASSERT_EQ(false, MotionSubscriber::isMotionSensorSubscribed_);
}
/**
* @tc.name: OnMotionChanged
* @tc.desc: check function RotationMotionEventCallback->SubscribeMotionSensor
* @tc.type: FUNC
*/
HWTEST_F(ScreenRotationControllerTest, OnMotionChanged, Function | SmallTest | Level3)
{
bool needUnsubscribe = false;
if (MotionSubscriber::motionEventCallback_ == nullptr) {
needUnsubscribe = true;
MotionSubscriber::SubscribeMotionSensor();
}
ASSERT_NE(MotionSubscriber::motionEventCallback_, nullptr);
DeviceRotation currentRotation = ScreenRotationController::lastSensorRotationConverted_;
DeviceRotation motionRotation = DeviceRotation::INVALID;
MotionEvent motionData;
motionData.status = 0;
motionRotation = DeviceRotation::ROTATION_PORTRAIT;
MotionSubscriber::motionEventCallback_->OnMotionChanged(motionData);
ASSERT_EQ(motionRotation, ScreenRotationController::lastSensorRotationConverted_);
motionData.status = 1;
MotionSubscriber::motionEventCallback_->OnMotionChanged(motionData);
motionRotation = ScreenRotationController::IsDefaultDisplayRotationPortrait() ?
DeviceRotation::ROTATION_LANDSCAPE_INVERTED : DeviceRotation::ROTATION_LANDSCAPE;
ASSERT_EQ(motionRotation, ScreenRotationController::lastSensorRotationConverted_);
motionData.status = 2;
MotionSubscriber::motionEventCallback_->OnMotionChanged(motionData);
motionRotation = DeviceRotation::ROTATION_PORTRAIT_INVERTED;
ASSERT_EQ(motionRotation, ScreenRotationController::lastSensorRotationConverted_);
motionData.status = 3;
MotionSubscriber::motionEventCallback_->OnMotionChanged(motionData);
motionRotation = ScreenRotationController::IsDefaultDisplayRotationPortrait() ?
DeviceRotation::ROTATION_LANDSCAPE : DeviceRotation::ROTATION_LANDSCAPE_INVERTED;
ASSERT_EQ(motionRotation, ScreenRotationController::lastSensorRotationConverted_);
ScreenRotationController::HandleSensorEventInput(currentRotation);
if (needUnsubscribe) {
MotionSubscriber::UnsubscribeMotionSensor();
}
}
#endif
}
} // namespace Rosen

View File

@ -42,6 +42,7 @@ ohos_shared_library("libmodal_system_ui_extension_client") {
public_configs = [ ":libmodal_system_ui_extension_client_public_config" ]
deps = [
"../../utils:libwmutil_base",
"../../window_scene/session:scene_session",
"../../wm:libwm",
]

View File

@ -354,6 +354,33 @@ enum class FoldStatus: uint32_t {
HALF_FOLD = 3,
};
/**
* @brief Enumerates the super fold state change events.
*/
enum class SuperFoldStatusChangeEvents : uint32_t {
UNDEFINED = 0,
ANGLE_CHANGE_EXPANDED,
ANGLE_CHANGE_HALF_FOLDED,
ANGLE_CHANGE_FOLDED,
KEYBOARD_ON,
KEYBOARD_OFF,
SOFT_KEYBOARD_ON,
SOFT_KEYBOARD_OFF,
INVALID,
};
/**
* @brief Enumerates the super fold state.
*/
enum class SuperFoldStatus : uint32_t {
UNKNOWN,
FOLDED,
HALF_FOLDED,
EXPANDED,
KEYBOARD,
SOFT_KEYBOARD,
};
/**
* @brief Enumerates the fold display mode.
*/

View File

@ -381,7 +381,7 @@ public:
* @class IWindowVisibilityChangedListener
*
* @brief Listener to observe one window visibility changed.
*/
*/
class IWindowVisibilityChangedListener : virtual public RefBase {
public:
virtual void OnWindowVisibilityChangedCallback(const bool isVisible) {};
@ -392,7 +392,7 @@ using IWindowVisibilityListenerSptr = sptr<IWindowVisibilityChangedListener>;
* @class IWindowNoInteractionListenerSptr
*
* @brief Listener to observe no interaction event for a long time of window.
*/
*/
class IWindowNoInteractionListener : virtual public RefBase {
public:
/**
@ -2258,6 +2258,14 @@ public:
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
}
/**
* @brief Flush layout size.
*
* @param width The width after layout
* @param height The height after layout
*/
virtual void FlushLayoutSize(int32_t width, int32_t height) {}
/**
* @brief get callingWindow windowStatus.
* @param windowStatus

View File

@ -798,7 +798,7 @@ public:
* @param pid pid
* @param watermarkName watermark picture name
* @param isEnabled add or remove
* @return @return WM_OK means set process watermark success, others means failed.
* @return WM_OK means set process watermark success, others means failed.
*/
WMError SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled);
@ -822,6 +822,16 @@ public:
*/
WMError ReleaseForegroundSessionScreenLock();
/**
* @brief Get displayId by windowId.
*
* @param windowIds list of window ids that need to get screen ids
* @param windowDisplayIdMap map of windows and displayIds
* @return WM_OK means get success, others means failed.
*/
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap);
private:
WindowManager();
~WindowManager();

View File

@ -13,14 +13,11 @@
* limitations under the License.
*/
#ifndef OH_NATIVE_DISPLAY_CAPTURE_H
#define OH_NATIVE_DISPLAY_CAPTURE_H
/**
* @addtogroup OH_DisplayManager
* @addtogroup OH_DisplayCapture
* @{
*
* @brief Defines the data structures for the C APIs of the display capture.
* @brief Defines the data structures for the C APIs of the display module.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @since 14
@ -33,12 +30,15 @@
* @brief Defines the data structures for the C APIs of the display capture.
*
* @kit ArkUI
* @library libnative_display_manager.so.
* @library libnative_display_manager.so
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @since 14
* @version 1.0
*/
#ifndef OH_NATIVE_DISPLAY_CAPTURE_H
#define OH_NATIVE_DISPLAY_CAPTURE_H
#include "image/pixelmap_native.h"
#include "oh_display_info.h"
@ -47,13 +47,14 @@ extern "C" {
#endif
/**
* @brief Obtain screen capture.
* @brief Creates a screen capture of the specified display.
*
* @param { displayId } this display to be captured.
* @param { pixelMap } the pixelMap of the display by id.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* @param displayId The ID of the display to be captured.
* @param pixelMap The output pixel map of the captured display.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_NO_PERMISSION } If no permission.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } If device not support.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14

View File

@ -45,7 +45,10 @@
extern "C" {
#endif
/* display name length */
/**
* @brief display name length
* @since 14
*/
#define OH_DISPLAY_NAME_LENGTH 32
/**
@ -153,13 +156,13 @@ typedef enum {
* @version 1.0
*/
typedef struct {
/* rect left */
/** rect left */
int32_t left;
/* rect top */
/** rect top */
int32_t top;
/* rect width */
/** rect width */
uint32_t width;
/* rect height */
/** rect height */
uint32_t height;
} NativeDisplayManager_Rect;
@ -170,16 +173,16 @@ typedef struct {
* @version 1.0
*/
typedef struct {
/* waterfall left rect */
/** waterfall left rect */
NativeDisplayManager_Rect left;
/* waterfall top rect */
/** waterfall top rect */
NativeDisplayManager_Rect top;
/* waterfall right rect */
/** waterfall right rect */
NativeDisplayManager_Rect right;
/* waterfall bottom rect */
/** waterfall bottom rect */
NativeDisplayManager_Rect bottom;
} NativeDisplayManager_WaterfallDisplayAreaRects;
@ -190,13 +193,13 @@ typedef struct {
* @version 1.0
*/
typedef struct {
/* boundingRects length */
/** boundingRects length */
int32_t boundingRectsLength;
/* boundingRects info pointer */
/** boundingRects info pointer */
NativeDisplayManager_Rect *boundingRects;
/* waterfallDisplayAreaRects info */
/** waterfallDisplayAreaRects info */
NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects;
} NativeDisplayManager_CutoutInfo;
@ -236,10 +239,10 @@ typedef enum {
* @version 1.0
*/
typedef struct {
/* hdrFormat length */
/** hdrFormat length */
uint32_t hdrFormatLength;
/* hdrFormat pointer */
/** hdrFormat pointer */
uint32_t *hdrFormats;
} NativeDisplayManager_DisplayHdrFormat;
@ -250,10 +253,10 @@ typedef struct {
* @version 1.0
*/
typedef struct {
/* color space length */
/** color space length */
uint32_t colorSpaceLength;
/* color space pointer */
/** color space pointer */
uint32_t *colorSpaces;
} NativeDisplayManager_DisplayColorSpace;
@ -264,78 +267,78 @@ typedef struct {
* @version 1.0
*/
typedef struct {
/* display id */
/** display id */
uint32_t id;
/* display name */
/** display name */
char name[OH_DISPLAY_NAME_LENGTH + 1];
/* display is alive */
/** display is alive */
bool isAlive;
/* display width */
/** display width */
int32_t width;
/* display height */
/** display height */
int32_t height;
/* display physical width */
/** display physical width */
int32_t physicalWidth;
/* display physical height */
/** display physical height */
int32_t physicalHeight;
/* display refresh rate */
/** display refresh rate */
uint32_t refreshRate;
/* display available width */
/** display available width */
uint32_t availableWidth;
/* display available height */
/** display available height */
uint32_t availableHeight;
/* display density dpi */
/** display density dpi */
float densityDPI;
/* display density pixels */
/** display density pixels */
float densityPixels;
/* display scale density */
/** display scale density */
float scaledDensity;
/* display xdpi*/
/** display xdpi*/
float xDPI;
/* display ydpi */
/** display ydpi */
float yDPI;
/* display rotation */
/** display rotation */
NativeDisplayManager_Rotation rotation;
/* display state */
/** display state */
NativeDisplayManager_DisplayState state;
/* display orientation */
/** display orientation */
NativeDisplayManager_Orientation orientation;
/* display hdr format */
/** display hdr format */
NativeDisplayManager_DisplayHdrFormat *hdrFormat;
/* display color space */
/** display color space */
NativeDisplayManager_DisplayColorSpace *colorSpace;
} NativeDisplayManager_DisplayInfo;
/**
* @brief Defines the display structure.
* @brief Defines the displays structure.
*
* @since 14
* @version 1.0
*/
typedef struct {
/* displays length */
/** displays length */
uint32_t displaysLength;
/* displays pointer */
/** displays pointer */
NativeDisplayManager_DisplayInfo *displaysInfo;
} NativeDisplayManager_DisplaysInfo;

View File

@ -312,9 +312,9 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeCh
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex);
/**
* @brief Obtain all displays.
* @brief Create all displays.
*
* @param { allDisplays } the result of all displays.
* @param allDisplays Output parameter for all displays information.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
@ -325,19 +325,18 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays(
NativeDisplayManager_DisplaysInfo **allDisplays);
/**
* @brief Destroy all displays.
* @brief Destroys all displays.
*
* @param { allDisplays } all displays to be free.
* @param allDisplays all displays to be free.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays);
/**
* @brief Obtain the target display by display id.
*
* @param { displayId } the display id.
* @param { displayInfo } the result of all displays.
* @brief Create display information by display id.
* @param displayId The display id.
* @param displayInfo The pointer to the display information.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
@ -348,18 +347,18 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uin
NativeDisplayManager_DisplayInfo **displayInfo);
/**
* @brief Destroy the target display.
* @brief Destroy the display information.
*
* @param { displayInfo } the target display to be free.
* @param displayInfo the target display to be free.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo);
/**
* @brief Obtain the primary display.
* @brief Creates a primary display.
*
* @param { displayInfo } the result of primary display.
* @param displayInfo The information of the created display.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.

View File

@ -41,7 +41,6 @@ ohos_shared_library("pipwindow_napi") {
]
deps = [
"../../../../dm:libdm",
"../../../../utils:libwmutil",
"../../../../utils:libwmutil_base",
"../../../../wm:libwm",
@ -54,11 +53,7 @@ ohos_shared_library("pipwindow_napi") {
"ace_engine:ace_uicontent",
"ace_engine:ace_xcomponent_controller",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image",
"napi:ace_napi",
]

View File

@ -38,7 +38,6 @@ ohos_shared_library("pip_napi") {
]
deps = [
"../../../../../dm:libdm",
"../../../../../utils:libwmutil",
"../../../../../utils:libwmutil_base",
"../../../../../wm:libwm",
@ -51,11 +50,7 @@ ohos_shared_library("pip_napi") {
"ace_engine:ace_uicontent",
"ace_engine:ace_xcomponent_controller",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image",
"napi:ace_napi",
]
relative_install_dir = "module"

View File

@ -16,13 +16,8 @@
#include "js_pip_controller.h"
#include "js_pip_utils.h"
#include "js_pip_window_listener.h"
#include "js_runtime_utils.h"
#include "picture_in_picture_controller.h"
#include "picture_in_picture_interface.h"
#include "picture_in_picture_manager.h"
#include "window_manager_hilog.h"
#include "wm_common.h"
namespace OHOS {
namespace Rosen {

View File

@ -21,7 +21,6 @@
#include "window_manager_hilog.h"
#include "window.h"
#include "xcomponent_controller.h"
#include <algorithm>
namespace OHOS {
namespace Rosen {
@ -57,8 +56,6 @@ namespace {
};
}
std::mutex JsPipWindowManager::mutex_;
static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector<std::uint32_t> controlGroups)
{
auto iter = TEMPLATE_CONTROL_MAP.find(static_cast<PiPTemplateType>(pipTemplateType));
@ -253,7 +250,6 @@ napi_value JsPipWindowManager::NapiSendTask(napi_env env, PipOption& pipOption)
napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_PIP, "[NAPI]");
std::lock_guard<std::mutex> lock(mutex_);
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);

View File

@ -18,7 +18,6 @@
#include "js_runtime_utils.h"
#include "picture_in_picture_manager.h"
#include <mutex>
namespace OHOS {
namespace Rosen {
@ -34,7 +33,6 @@ private:
napi_value OnIsPipEnabled(napi_env env, napi_callback_info info);
napi_value OnCreatePipController(napi_env env, napi_callback_info info);
napi_value NapiSendTask(napi_env env, PipOption& pipOption);
static std::mutex mutex_;
};
}
}

View File

@ -272,13 +272,35 @@ napi_value Resolve(napi_env env, std::unique_ptr<Param> &param)
napi_value result;
napi_value error;
napi_value code;
if (param->wret == DmErrorCode::DM_ERROR_INVALID_PARAM) {
bool isThrowError = true;
if (param->wret != DmErrorCode::DM_OK) {
napi_create_error(env, nullptr, nullptr, &error);
napi_create_int32(env, (int32_t)DmErrorCode::DM_ERROR_INVALID_PARAM, &code);
napi_set_named_property(env, error, "DM_ERROR_INVALID_PARAM", code);
napi_create_int32(env, (int32_t)param->wret, &code);
}
switch (param->wret) {
case DmErrorCode::DM_ERROR_NO_PERMISSION:
napi_set_named_property(env, error, "DM_ERROR_NO_PERMISSION", code);
break;
case DmErrorCode::DM_ERROR_INVALID_PARAM:
napi_set_named_property(env, error, "DM_ERROR_INVALID_PARAM", code);
break;
case DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT:
napi_set_named_property(env, error, "DM_ERROR_DEVICE_NOT_SUPPORT", code);
break;
case DmErrorCode::DM_ERROR_SYSTEM_INNORMAL:
napi_set_named_property(env, error, "DM_ERROR_SYSTEM_INNORMAL", code);
break;
default:
isThrowError = false;
WLOGFI("screen shot default.");
break;
}
WLOGFI("screen shot ret=%{public}d.", param->wret);
if (isThrowError) {
napi_throw(env, error);
return error;
} else if (param->wret != DmErrorCode::DM_OK) {
}
if (param->wret != DmErrorCode::DM_OK) {
NAPI_CALL(env, napi_get_undefined(env, &result));
return result;
}

View File

@ -6485,8 +6485,7 @@ bool JsWindow::CheckWindowMaskParams(napi_env env, napi_value jsObject)
WindowLimits windowLimits;
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowLimits(windowLimits));
if (ret == WmErrorCode::WM_OK) {
if (size == 0 ||
static_cast<float>(size) * windowLimits.vpRatio_ > static_cast<float>(windowLimits.maxWidth_)) {
if (size == 0 || size > windowLimits.maxWidth_) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid windowMask size:%{public}u, vpRatio:%{public}f, maxWidth:%{public}u",
size, windowLimits.vpRatio_, windowLimits.maxWidth_);
return false;

View File

@ -59,6 +59,7 @@ if (!ispreview) {
"${ability_runtime_path}/frameworks/simulator/common:ability_simulator_common_config",
]
sources = [
"../utils/src/window_manager_hilog.cpp",
"../utils/src/window_transition_info.cpp",
"../utils/src/wm_math.cpp",
"src/vsync_station.cpp",
@ -113,6 +114,7 @@ if (!ispreview) {
"../interfaces/kits/napi/window_runtime/window_napi/js_window.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp",
"../interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp",
"../utils/src/window_manager_hilog.cpp",
# mock
"mock/js_transition_controller.cpp",

View File

@ -402,6 +402,14 @@ public:
* @return WM_OK means get success, others means get failed.
*/
virtual WMError GetGestureBackEnabled(bool& enable) { return WMError::WM_OK; }
/**
* @brief Flush layout size.
*
* @param width The width after layout
* @param height The height after layout
*/
virtual void FlushLayoutSize(int32_t width, int32_t height) {}
};
}
}

View File

@ -53,10 +53,9 @@ void SnapshotDisplayTest::SetUpTestCase()
WLOGFE("GetDefaultDisplay: failed!\n");
return;
}
WLOGI("GetDefaultDisplay: id %" PRIu64", w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetRefreshRate());
defaultId_ = display->GetId();
WLOGI("GetDefaultDisplay: id[%{public}" PRIu64"], w:[%{public}d], h[%{public}d], fps[%{public}u]",
defaultId_, display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
CommonTestUtils::InjectTokenInfoByHapName(0, "com.ohos.systemui", 0);
const char** perms = new const char *[1];
@ -120,7 +119,8 @@ HWTEST_F(SnapshotDisplayTest, ScreenShotCmdValid01, Function | MediumTest | Leve
}
}
(void)system(defaultCmd_.c_str());
const std::string cmd = defaultCmd_ + " -i " + std::to_string(defaultId_) + " -f " + imgPath[0];
(void)system(cmd.c_str());
for (i = 0; i < testTimeCount_; i++) {
if (CheckFileExist(imgPath[i])) { // ok
@ -149,7 +149,7 @@ HWTEST_F(SnapshotDisplayTest, ScreenShotCmdValid02, Function | MediumTest | Leve
}
}
const std::string cmd = defaultCmd_ + " -i " + std::to_string(defaultId_);
const std::string cmd = defaultCmd_ + " -i " + std::to_string(defaultId_) + " -f " + imgPath[0];
(void)system(cmd.c_str());
for (i = 0; i < testTimeCount_; i++) {
@ -251,7 +251,7 @@ HWTEST_F(SnapshotDisplayTest, ScreenShotCmdValid09, Function | MediumTest | Leve
}
}
const std::string cmd = defaultCmd_ + " -t png";
const std::string cmd = defaultCmd_ + " -f " + imgPath[0] + " -t png";
(void)system(cmd.c_str());
for (i = 0; i < testTimeCount_; i++) {

View File

@ -163,10 +163,10 @@ HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_001, Function
}
/**
* @tc.name: unregister_display_power_event_listener_002
* @tc.desc: call UnregisterDisplayPowerEventListener with nullptr and check return value
* @tc.type: FUNC
*/
* @tc.name: unregister_display_power_event_listener_002
* @tc.desc: call UnregisterDisplayPowerEventListener with nullptr and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_002, Function | SmallTest | Level2)
{
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
@ -174,10 +174,10 @@ HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_002, Function
}
/**
* @tc.name: unregister_display_power_event_listener_003
* @tc.desc: call UnregisterDisplayPowerEventListener with an invalid listener and check return value
* @tc.type: FUNC
*/
* @tc.name: unregister_display_power_event_listener_003
* @tc.desc: call UnregisterDisplayPowerEventListener with an invalid listener and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_003, Function | SmallTest | Level2)
{
sptr<IDisplayPowerEventListener> listener = new DisplayPowerEventListener();
@ -306,10 +306,10 @@ HWTEST_F(DisplayPowerTest, suspend_begin_callback_001, Function | MediumTest | L
}
/**
* @tc.name: suspend_end_callback_001
* @tc.desc: Call SuspendEnd and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
* @tc.name: suspend_end_callback_001
* @tc.desc: Call SuspendEnd and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, suspend_end_callback_001, Function | MediumTest | Level2)
{
bool ret = DisplayManager::GetInstance().SuspendEnd();
@ -321,10 +321,10 @@ HWTEST_F(DisplayPowerTest, suspend_end_callback_001, Function | MediumTest | Lev
}
/**
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll OFF and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll OFF and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_001, Function | MediumTest | Level2)
{
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_OFF,
@ -337,10 +337,10 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_001, Function | MediumTest |
}
/**
* @tc.name: set_screen_power_for_all_002
* @tc.desc: Call SetScreenPowerForAll ON and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
* @tc.name: set_screen_power_for_all_002
* @tc.desc: Call SetScreenPowerForAll ON and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_002, Function | MediumTest | Level2)
{
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_ON,
@ -353,10 +353,10 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_002, Function | MediumTest |
}
/**
* @tc.name: set_screen_power_for_all_003
* @tc.desc: Call SetScreenPowerForAll with an invalid value and check the return value
* @tc.type: FUNC
*/
* @tc.name: set_screen_power_for_all_003
* @tc.desc: Call SetScreenPowerForAll with an invalid value and check the return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_003, Function | MediumTest | Level2)
{
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::INVALID_STATE,
@ -366,10 +366,10 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_003, Function | MediumTest |
}
/**
* @tc.name: set_display_state_power_event_callback_001
* @tc.desc: Call SetDisplayState with a valid value and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
* @tc.name: set_display_state_power_event_callback_001
* @tc.desc: Call SetDisplayState with a valid value and check the OnDisplayPowerEvent callback is called
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, set_display_state_power_event_callback_001, Function | MediumTest | Level2)
{
DisplayState initialState = DisplayManager::GetInstance().GetDisplayState(defaultId_);
@ -396,10 +396,10 @@ HWTEST_F(DisplayPowerTest, set_display_state_power_event_callback_001, Function
}
/**
* @tc.name: get_display_power_002
* @tc.desc: Call SetScreenPowerForAll ON and check the GetScreenPower return value
* @tc.type: FUNC
*/
* @tc.name: get_display_power_002
* @tc.desc: Call SetScreenPowerForAll ON and check the GetScreenPower return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, get_display_power_002, Function | MediumTest | Level2)
{
ScreenPowerState stateToSet = ScreenPowerState::POWER_ON;
@ -412,10 +412,10 @@ HWTEST_F(DisplayPowerTest, get_display_power_002, Function | MediumTest | Level2
}
/**
* @tc.name: window_life_cycle_001
* @tc.desc: Add a window and then call SuspendEnd and check window state; Notify unlock and check window state
* @tc.type: FUNC
*/
* @tc.name: window_life_cycle_001
* @tc.desc: Add a window and then call SuspendEnd and check window state; Notify unlock and check window state
* @tc.type: FUNC
*/
HWTEST_F(DisplayPowerTest, window_life_cycle_001, Function | MediumTest | Level2)
{
sptr<WindowOption> option = new WindowOption();

View File

@ -374,10 +374,10 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3)
}
/**
* @tc.name: FocusChangedTest06
* @tc.desc: hide unfocused window to test focus
* @tc.type: FUNC
*/
* @tc.name: FocusChangedTest06
* @tc.desc: hide unfocused window to test focus
* @tc.type: FUNC
*/
HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
{
floatAppInfo_.name = "FocusChangedTest06_1";
@ -417,10 +417,10 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
}
/**
* @tc.name: FocusChangedTest07
* @tc.desc: destroy focused window to test focus
* @tc.type: FUNC
*/
* @tc.name: FocusChangedTest07
* @tc.desc: destroy focused window to test focus
* @tc.type: FUNC
*/
HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
{
floatAppInfo_.name = "FocusChangedTest07_1";
@ -506,10 +506,10 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
}
/**
* @tc.name: FocusChangedTest08
* @tc.desc: destroy unfocused window to test focus
* @tc.type: FUNC
*/
* @tc.name: FocusChangedTest08
* @tc.desc: destroy unfocused window to test focus
* @tc.type: FUNC
*/
HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3)
{
floatAppInfo_.name = "FocusChangedTest08_1";
@ -559,19 +559,25 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3)
HWTEST_F(WindowFocusTest, WindowShowWithoutFocusTest, Function | MediumTest | Level3)
{
fullScreenAppInfo_.name = "WindowShowWithoutFocusTest_1";
fullScreenAppInfo_.focusable_ = false;
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
if (window1 == nullptr) {
return;
}
ASSERT_NE(nullptr, window1);
floatAppInfo_.name = "WindowShowWithoutFocusTest_2";
floatAppInfo_.rect = { 10, 200, 300, 400 };
const sptr<Window>& window2 = Utils::CreateTestWindow(floatAppInfo_);
if (window2 == nullptr) {
return;
}
ASSERT_NE(nullptr, window2);
subAppInfo_.name = "WindowShowWithoutFocusTest_3";
subAppInfo_.rect = { 400, 200, 100, 100 };
subAppInfo_.parentId = window2->GetWindowId();
const sptr<Window>& subWindow = Utils::CreateTestWindow(subAppInfo_);
if (subWindow == nullptr) {
return;
}
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, window1->Show());

View File

@ -76,10 +76,10 @@ void GestureNavigationEnabledTest::TearDown()
namespace {
/**
* @tc.name: SetGestureNavigationEnabled
* @tc.desc: Check gesture navigation enabled
* @tc.type: FUNC
*/
* @tc.name: SetGestureNavigationEnabled
* @tc.desc: Check gesture navigation enabled
* @tc.type: FUNC
*/
HWTEST_F(GestureNavigationEnabledTest, SetGestureNavigationEnabled, Function | MediumTest | Level1)
{
ASSERT_NE(lisenter_, nullptr);

View File

@ -131,9 +131,9 @@ void WindowNoInteractionTest::WaitForCallback(sptr<NoInteractionTesterListener>&
namespace {
/**
* @tc.name: RegisterUnregisterNormal
* @tc.type: FUNC
*/
* @tc.name: RegisterUnregisterNormal
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, RegisterUnregisterNormal, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -178,9 +178,9 @@ HWTEST_F(WindowNoInteractionTest, UnregisterNotReg, Function | MediumTest | Leve
}
/**
* @tc.name: KeyEventDownWindowShow
* @tc.type: FUNC
*/
* @tc.name: KeyEventDownWindowShow
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowShow, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -215,9 +215,9 @@ HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowShow, Function | MediumTest
}
/**
* @tc.name: KeyEventDownWindowHide
* @tc.type: FUNC
*/
* @tc.name: KeyEventDownWindowHide
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowHide, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -250,9 +250,9 @@ HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowHide, Function | MediumTest
}
/**
* @tc.name: KeyEventUpWindowShow
* @tc.type: FUNC
*/
* @tc.name: KeyEventUpWindowShow
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowShow, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -285,9 +285,9 @@ HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowShow, Function | MediumTest |
}
/**
* @tc.name: KeyEventUpWindowHide
* @tc.type: FUNC
*/
* @tc.name: KeyEventUpWindowHide
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowHide, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -320,9 +320,9 @@ HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowHide, Function | MediumTest |
}
/**
* @tc.name: PointerEventDown
* @tc.type: FUNC
*/
* @tc.name: PointerEventDown
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, PointerEventDown, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
@ -356,9 +356,9 @@ HWTEST_F(WindowNoInteractionTest, PointerEventDown, Function | MediumTest | Leve
}
/**
* @tc.name: PointerEventUp
* @tc.type: FUNC
*/
* @tc.name: PointerEventUp
* @tc.type: FUNC
*/
HWTEST_F(WindowNoInteractionTest, PointerEventUp, Function | MediumTest | Level1)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();

View File

@ -68,10 +68,10 @@ void WindowRaiseToAppTopTest::TearDown()
namespace {
/**
* @tc.name: WindowRaiseToAppTopTest1
* @tc.desc: to raise to app top, normal
* @tc.type: FUNC
*/
* @tc.name: WindowRaiseToAppTopTest1
* @tc.desc: to raise to app top, normal
* @tc.type: FUNC
*/
HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, Function | MediumTest | Level3)
{
fullInfo_.name = "mainWindow.1";
@ -109,10 +109,10 @@ HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, Function | MediumTest | Level3)
}
/**
* @tc.name: WindowRaiseToAppTopTest2
* @tc.desc: to raise to app top, with dialog
* @tc.type: FUNC
*/
* @tc.name: WindowRaiseToAppTopTest2
* @tc.desc: to raise to app top, with dialog
* @tc.type: FUNC
*/
HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, Function | MediumTest | Level3)
{
fullInfo_.name = "mainWindow.1";
@ -157,10 +157,10 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, Function | MediumTest | Leve
}
/**
* @tc.name: WindowRaiseToAppTopTest3
* @tc.desc: to raise to app top, in hide
* @tc.type: FUNC
*/
* @tc.name: WindowRaiseToAppTopTest3
* @tc.desc: to raise to app top, in hide
* @tc.type: FUNC
*/
HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, Function | MediumTest | Level3)
{
fullInfo_.name = "mainWindow.1";
@ -208,10 +208,10 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, Function | MediumTest | Level3)
}
/**
* @tc.name: WindowRaiseToAppTopTest3
* @tc.desc: to raise to app top, not app subwindow
* @tc.type: FUNC
*/
* @tc.name: WindowRaiseToAppTopTest3
* @tc.desc: to raise to app top, not app subwindow
* @tc.type: FUNC
*/
HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, Function | MediumTest | Level3)
{
CommonTestUtils::GuaranteeFloatWindowPermission("window_raisetoapptop_test");

View File

@ -113,7 +113,7 @@ HWTEST_F(WindowRecoverTest, RecoverAndReconnectSceneSession, Function | SmallTes
* @tc.name: RecoverAndConnectSpecificSession
* @tc.desc: RecoverAndConnectSpecificSession
* @tc.type: FUNC
*/
*/
HWTEST_F(WindowRecoverTest, RecoverAndConnectSpecificSession, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();

View File

@ -131,10 +131,10 @@ void WindowRotationTest::TearDown()
namespace {
/**
* @tc.name: WindowRotationTest1
* @tc.desc: create window and SetRequestedOrientation.
* @tc.type: FUNC
*/
* @tc.name: WindowRotationTest1
* @tc.desc: create window and SetRequestedOrientation.
* @tc.type: FUNC
*/
HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3)
{
fullInfo_.name = "fullscreen.1";
@ -167,10 +167,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3
}
/**
* @tc.name: WindowRotationTest2
* @tc.desc: create window with orientation property.
* @tc.type: FUNC
*/
* @tc.name: WindowRotationTest2
* @tc.desc: create window with orientation property.
* @tc.type: FUNC
*/
HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3)
{
fullInfo_.name = "fullscreen.2";
@ -204,10 +204,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3
}
/**
* @tc.name: WindowRotationTest3
* @tc.desc: create floating window with orientation property
* @tc.type: FUNC
*/
* @tc.name: WindowRotationTest3
* @tc.desc: create floating window with orientation property
* @tc.type: FUNC
*/
HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3)
{
auto display = DisplayManager::GetInstance().GetDefaultDisplay();
@ -240,10 +240,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3
/**
* @tc.name: WindowRotationTest4
* @tc.desc: create window with orientation after setting screen default orientation.
* @tc.type: FUNC
*/
* @tc.name: WindowRotationTest4
* @tc.desc: create window with orientation after setting screen default orientation.
* @tc.type: FUNC
*/
HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3)
{
auto displayDefault = DisplayManager::GetInstance().GetDefaultDisplay();
@ -282,11 +282,11 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3
}
/**
* @tc.name: WindowRotationTest5
* @tc.desc: create window with orientation after setting screen default orientation, and toggle shown state for all app
* windows.
* @tc.type: FUNC
*/
* @tc.name: WindowRotationTest5
* @tc.desc: create window with orientation after setting screen default orientation, and toggle shown state for all app
* windows.
* @tc.type: FUNC
*/
HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3)
{
auto displayDefault = DisplayManager::GetInstance().GetDefaultDisplay();

View File

@ -184,11 +184,11 @@ void WindowVisibilityInfoTest::WaitForCallback()
namespace {
/**
* @tc.name: WindowVisibilityInfoTest01
* @tc.desc: window show or hide
* @tc.type: FUNC
* @tc.require: issueI5FSQW
*/
* @tc.name: WindowVisibilityInfoTest01
* @tc.desc: window show or hide
* @tc.type: FUNC
* @tc.require: issueI5FSQW
*/
HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, Function | MediumTest | Level1)
{
floatAppInfo_.name = "window1";

View File

@ -134,11 +134,11 @@ bool WaterMarkTest::FillColor(sptr<Window> window)
namespace {
/**
* @tc.name: WindowVisibilityInfoTest01
* @tc.desc: window show or hide
* @tc.type: FUNC
* @tc.require: issueI5FSQW
*/
* @tc.name: WindowVisibilityInfoTest01
* @tc.desc: window show or hide
* @tc.type: FUNC
* @tc.require: issueI5FSQW
*/
HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, Function | MediumTest | Level1)
{
appInfo_.name = "window1";

View File

@ -19,6 +19,7 @@ config("libwmutil_private_config") {
"../dmserver/include",
"../interfaces/innerkits/dm",
"../interfaces/innerkits/wm",
"${window_base_path}/wm/include",
]
}
@ -60,7 +61,9 @@ ohos_static_library("libwmutil_static") {
"src/surface_reader_handler_impl.cpp",
"src/sys_cap_util.cpp",
"src/unreliable_window_info.cpp",
"src/vsync_station.cpp",
"src/window_drawing_content_info.cpp",
"src/window_frame_trace_impl.cpp",
"src/window_property.cpp",
"src/window_transition_info.cpp",
"src/window_visibility_info.cpp",
@ -76,6 +79,8 @@ ohos_static_library("libwmutil_static") {
public_configs = [ ":libwmutil_public_config" ]
deps = [ ":libwmutil_base" ]
external_deps = [
"ability_base:want",
"ability_runtime:ability_manager",
@ -84,6 +89,7 @@ ohos_static_library("libwmutil_static") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_2d:2d_graphics",
"graphic_2d:librender_service_client",
"graphic_surface:surface",
@ -99,6 +105,10 @@ ohos_static_library("libwmutil_static") {
part_name = "window_manager"
subsystem_name = "window"
defines = []
defines += [ "FRAME_TRACE_ENABLE" ]
external_deps += [ "frame_aware_sched:frame_trace_intf" ]
}
## Build libwmutil_base.so
@ -124,6 +134,7 @@ ohos_shared_library("libwmutil_base") {
"src/string_util.cpp",
"src/unreliable_window_info.cpp",
"src/window_drawing_content_info.cpp",
"src/window_manager_hilog.cpp",
"src/window_pid_visibility_info.cpp",
"src/window_visibility_info.cpp",
"src/wm_common.cpp",
@ -163,6 +174,8 @@ ohos_shared_library("libwmutil") {
"src/surface_reader_handler_impl.cpp",
"src/sys_cap_util.cpp",
"src/typec_port_info.cpp",
"src/vsync_station.cpp",
"src/window_frame_trace_impl.cpp",
"src/window_property.cpp",
"src/window_transition_info.cpp",
]
@ -184,6 +197,7 @@ ohos_shared_library("libwmutil") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_2d:2d_graphics",
"graphic_2d:librender_service_client",
"graphic_surface:surface",
@ -208,6 +222,9 @@ ohos_shared_library("libwmutil") {
if (build_variant == "user") {
defines += [ "IS_RELEASE_VERSION" ]
}
defines += [ "FRAME_TRACE_ENABLE" ]
external_deps += [ "frame_aware_sched:frame_trace_intf" ]
}
group("test") {

View File

@ -16,7 +16,6 @@
#ifndef WINDOW_WINDOW_MANAGER_PIP_REPORT_H
#define WINDOW_WINDOW_MANAGER_PIP_REPORT_H
#include <map>
#include <mutex>
#include "wm_single_instance.h"
#include "wm_common.h"

View File

@ -16,18 +16,21 @@
#ifndef OHOS_VSYNC_STATION_H
#define OHOS_VSYNC_STATION_H
#include <atomic>
#include <memory>
#include <unordered_set>
#include <event_handler.h>
#include <ui/rs_display_node.h>
#include <vsync_receiver.h>
#include "wm_common.h"
namespace OHOS {
namespace Rosen {
class RSFrameRateLinker;
class VSyncReceiver;
using FrameRateLinkerId = uint64_t;
using NodeId = uint64_t;
class VsyncStation : public std::enable_shared_from_this<VsyncStation> {
public:
@ -47,6 +50,9 @@ public:
void SetDisplaySoloistFrameRateLinkerEnable(bool enabled);
void SetUiDvsyncSwitch(bool dvsyncSwitch);
void DecreaseRequestVsyncTimes() { requestVsyncTimes_--; }
int32_t GetRequestVsyncTimes() { return requestVsyncTimes_.load(); }
private:
std::shared_ptr<VSyncReceiver> GetOrCreateVsyncReceiver();
std::shared_ptr<VSyncReceiver> GetOrCreateVsyncReceiverLocked();
@ -68,6 +74,8 @@ private:
using Callbacks = std::unordered_set<std::shared_ptr<VsyncCallback>>;
Callbacks vsyncCallbacks_;
// Above guarded by mutex_
std::atomic<int32_t> requestVsyncTimes_ {0};
};
} // namespace Rosen
} // namespace OHOS

View File

@ -63,30 +63,7 @@ enum class WmsLogTag : uint8_t {
END = 256, // Last one, do not use
};
inline const std::unordered_map<WmsLogTag, const char *> DOMAIN_CONTENTS_MAP = {
{ WmsLogTag::DEFAULT, "WMS" },
{ WmsLogTag::DMS, "DMS" },
{ WmsLogTag::WMS_MAIN, "WMSMain" },
{ WmsLogTag::WMS_SUB, "WMSSub" },
{ WmsLogTag::WMS_SCB, "WMSScb" },
{ WmsLogTag::WMS_DIALOG, "WMSDialog" },
{ WmsLogTag::WMS_SYSTEM, "WMSSystem" },
{ WmsLogTag::WMS_FOCUS, "WMSFocus" },
{ WmsLogTag::WMS_LAYOUT, "WMSLayout" },
{ WmsLogTag::WMS_IMMS, "WMSImms" },
{ WmsLogTag::WMS_LIFE, "WMSLife" },
{ WmsLogTag::WMS_KEYBOARD, "WMSKeyboard" },
{ WmsLogTag::WMS_EVENT, "WMSEvent" },
{ WmsLogTag::WMS_UIEXT, "WMSUiext" },
{ WmsLogTag::WMS_PIP, "WMSPiP" },
{ WmsLogTag::WMS_RECOVER, "WMSRecover" },
{ WmsLogTag::WMS_MULTI_USER, "WMSMultiUser" },
{ WmsLogTag::WMS_TOAST, "WMSToast" },
{ WmsLogTag::WMS_MULTI_WINDOW, "WMSMultiWindow" },
{ WmsLogTag::WMS_INPUT_KEY_FLOW, "InputKeyFlow" },
{ WmsLogTag::WMS_PIPELINE, "WMSPipeLine" },
{ WmsLogTag::WMS_HIERARCHY, "WMSHierarchy" },
};
extern const std::unordered_map<WmsLogTag, const char *> DOMAIN_CONTENTS_MAP;
#ifdef IS_RELEASE_VERSION
#define WMS_FILE_NAME ""
#else

View File

@ -55,7 +55,7 @@ std::ostream& operator<<(std::ostream& os, const Rect& r);
Event: Used for record a rect edge in/out event
y_: rect edge Y value
type: OPEN/CLOSE: lhs rect in/out; VOID_OPEN/VOID_CLOSE: rhs rect in/out
*/
*/
class Event {
public:
// Use different value to differentiate lhs and rhs ranges.

View File

@ -19,10 +19,12 @@
#include <hitrace_meter.h>
#include <transaction/rs_interfaces.h>
#include <ui/rs_display_node.h>
#include <ui/rs_ui_display_soloist.h>
#include "window_frame_trace.h"
#include "window_manager_hilog.h"
#include <vsync_receiver.h>
using namespace FRAME_TRACE;
@ -139,6 +141,7 @@ __attribute__((no_sanitize("cfi"))) void VsyncStation::RequestVsync(
vsyncHandler_->PostTask(task, vsyncTimeoutTaskName_, VSYNC_TIME_OUT_MILLISECONDS);
}
requestVsyncTimes_++;
WindowFrameTraceImpl::GetInstance()->VsyncStartFrameTrace();
auto task = [weakThis = weak_from_this()]
(int64_t timestamp, int64_t frameCount, void* client) {
@ -260,6 +263,5 @@ void VsyncStation::SetUiDvsyncSwitch(bool dvsyncSwitch)
receiver->SetUiDvsyncSwitch(dvsyncSwitch);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,45 @@
/*
* 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 "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
const std::unordered_map<WmsLogTag, const char *> DOMAIN_CONTENTS_MAP = {
{ WmsLogTag::DEFAULT, "WMS" },
{ WmsLogTag::DMS, "DMS" },
{ WmsLogTag::WMS_MAIN, "WMSMain" },
{ WmsLogTag::WMS_SUB, "WMSSub" },
{ WmsLogTag::WMS_SCB, "WMSScb" },
{ WmsLogTag::WMS_DIALOG, "WMSDialog" },
{ WmsLogTag::WMS_SYSTEM, "WMSSystem" },
{ WmsLogTag::WMS_FOCUS, "WMSFocus" },
{ WmsLogTag::WMS_LAYOUT, "WMSLayout" },
{ WmsLogTag::WMS_IMMS, "WMSImms" },
{ WmsLogTag::WMS_LIFE, "WMSLife" },
{ WmsLogTag::WMS_KEYBOARD, "WMSKeyboard" },
{ WmsLogTag::WMS_EVENT, "WMSEvent" },
{ WmsLogTag::WMS_UIEXT, "WMSUiext" },
{ WmsLogTag::WMS_PIP, "WMSPiP" },
{ WmsLogTag::WMS_RECOVER, "WMSRecover" },
{ WmsLogTag::WMS_MULTI_USER, "WMSMultiUser" },
{ WmsLogTag::WMS_TOAST, "WMSToast" },
{ WmsLogTag::WMS_MULTI_WINDOW, "WMSMultiWindow" },
{ WmsLogTag::WMS_INPUT_KEY_FLOW, "InputKeyFlow" },
{ WmsLogTag::WMS_PIPELINE, "WMSPipeLine" },
{ WmsLogTag::WMS_HIERARCHY, "WMSHierarchy" },
};
} // namespace OHOS
}

View File

@ -35,6 +35,20 @@ group("unittest") {
":utils_window_transition_info_test",
":utils_wm_math_test",
":utils_wm_occlusion_region_test",
":wm_window_frame_trace_impl_test",
]
}
ohos_unittest("wm_window_frame_trace_impl_test") {
module_out_path = module_out_path
defines = [ "FRAME_TRACE_ENABLE" ]
sources = [ "window_frame_trace_impl_test.cpp" ]
deps = [ ":utils_unittest_common" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
}

View File

@ -43,6 +43,8 @@ ohos_shared_library("window_scene_common") {
public_configs = [ ":window_scene_common_public_config" ]
deps = [ "${window_base_path}/utils:libwmutil_base" ]
external_deps = [
"ability_runtime:app_manager",
"access_token:libaccesstoken_sdk",

View File

@ -74,7 +74,7 @@ private:
void ExecuteExportTask();
std::unordered_map<std::string, Task> exportFuncMap_; // will used in OS_SceneSession
std::shared_ptr<AppExecFwk::EventHandler> handler_;
std::weak_ptr<AppExecFwk::EventHandler> exportHandler_;
std::shared_ptr<AppExecFwk::EventHandler> exportHandler_;
pid_t ssmTid_ = 0;
};
} // namespace OHOS::Rosen

View File

@ -45,6 +45,7 @@ public:
void SetRequestRect(const struct Rect& rect);
void SetWindowRect(const struct Rect& rect);
void SetFocusable(bool isFocusable);
void SetFocusableOnShow(bool isFocusableOnShow);
void SetTouchable(bool isTouchable);
void SetDragEnabled(bool dragEnabled);
void SetHideNonSystemFloatingWindows(bool hide);
@ -109,6 +110,7 @@ public:
Rect GetRequestRect() const;
WindowType GetWindowType() const;
bool GetFocusable() const;
bool GetFocusableOnShow() const;
bool GetTouchable() const;
bool GetDragEnabled() const;
bool GetHideNonSystemFloatingWindows() const;
@ -279,6 +281,7 @@ private:
Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window
bool focusable_ { true };
bool focusableOnShow_ { true };
bool touchable_ { true };
bool dragEnabled_ = { true };
bool raiseEnabled_ = { true };

View File

@ -110,8 +110,7 @@ void TaskScheduler::ExecuteExportTask()
if (exportFuncMap_.empty()) {
return;
}
std::shared_ptr<AppExecFwk::EventHandler> exportHandler = exportHandler_.lock();
if (!exportHandler) {
if (!exportHandler_) {
return;
}
auto task = [funcMap = std::move(exportFuncMap_)]() {
@ -121,7 +120,7 @@ void TaskScheduler::ExecuteExportTask()
}
};
exportFuncMap_.clear();
exportHandler->PostTask(task, "wms:exportTask");
exportHandler_->PostTask(task, "wms:exportTask");
}
void StartTraceForSyncTask(std::string name)

View File

@ -179,6 +179,11 @@ void WindowSessionProperty::SetFocusable(bool isFocusable)
focusable_ = isFocusable;
}
void WindowSessionProperty::SetFocusableOnShow(bool isFocusableOnShow)
{
focusableOnShow_ = isFocusableOnShow;
}
void WindowSessionProperty::SetTouchable(bool isTouchable)
{
touchable_ = isTouchable;
@ -284,6 +289,11 @@ bool WindowSessionProperty::GetFocusable() const
return focusable_;
}
bool WindowSessionProperty::GetFocusableOnShow() const
{
return focusableOnShow_;
}
bool WindowSessionProperty::GetTouchable() const
{
return touchable_;
@ -1018,7 +1028,8 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const
parcel.WriteInt32(requestRect_.posY_) && parcel.WriteUint32(requestRect_.width_) &&
parcel.WriteUint32(requestRect_.height_) &&
parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
parcel.WriteBool(focusable_) && parcel.WriteBool(touchable_) && parcel.WriteBool(tokenState_) &&
parcel.WriteBool(focusable_) && parcel.WriteBool(focusableOnShow_) &&
parcel.WriteBool(touchable_) && parcel.WriteBool(tokenState_) &&
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
parcel.WriteBool(isPrivacyMode_) && parcel.WriteBool(isSystemPrivacyMode_) &&
parcel.WriteBool(isSnapshotSkip_) &&
@ -1071,6 +1082,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
property->SetRequestRect(reqRect);
property->SetWindowType(static_cast<WindowType>(parcel.ReadUint32()));
property->SetFocusable(parcel.ReadBool());
property->SetFocusableOnShow(parcel.ReadBool());
property->SetTouchable(parcel.ReadBool());
property->SetTokenState(parcel.ReadBool());
property->SetTurnScreenOn(parcel.ReadBool());
@ -1142,7 +1154,8 @@ void WindowSessionProperty::CopyFrom(const sptr<WindowSessionProperty>& property
requestRect_ = property->requestRect_;
windowRect_ = property->windowRect_;
type_ = property->type_;
focusable_= property->focusable_;
focusable_ = property->focusable_;
focusableOnShow_ = property->focusableOnShow_;
touchable_ = property->touchable_;
dragEnabled_ = property->dragEnabled_;
hideNonSystemFloatingWindows_ = property->hideNonSystemFloatingWindows_;

View File

@ -1,67 +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_HANDLER_H
#define ANR_HANDLER_H
#include <memory>
#include <mutex>
#include <list>
#include <unordered_map>
#include "event_handler.h"
#include "nocopyable.h"
#include "singleton.h"
#include "session_stage_interface.h"
namespace OHOS {
namespace Rosen {
class ANRHandler {
DECLARE_DELAYED_SINGLETON(ANRHandler);
public:
DISALLOW_COPY_AND_MOVE(ANRHandler);
void SetSessionStage(int32_t eventId, const wptr<ISessionStage>& sessionStage);
void HandleEventConsumed(int32_t eventId, int64_t actionTime);
void OnWindowDestroyed(int32_t persistentId);
private:
using Task = std::function<void()>;
bool PostTask(Task &&task, const std::string& name = "ANRHandlerTask", int64_t delayTime = 0);
void MarkProcessed();
void SendEvent(int32_t eventId, int64_t delayTime);
void SetAnrHandleState(int32_t eventId, bool status);
void ClearExpiredEvents(int32_t eventId);
int32_t GetPersistentIdOfEvent(int32_t eventId);
bool IsOnEventHandler(int32_t persistentId);
void UpdateLatestEventId(int32_t eventId);
private:
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ { nullptr };
struct ANRHandlerState {
std::unordered_map<int32_t, bool> sendStatus;
int32_t currentEventIdToReceipt { -1 };
std::list<int32_t> eventsToReceipt;
};
ANRHandlerState anrHandlerState_;
struct SessionInfo {
int32_t persistentId;
wptr<ISessionStage> sessionStage;
};
std::unordered_map<int32_t, SessionInfo> sessionStageMap_;
};
} // namespace Rosen
} // namespace OHOS
#endif // ANR_HANDLER_H

View File

@ -1,230 +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_handler.h"
#include <algorithm>
#include <cinttypes>
#include <functional>
#include <string>
#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, "ANRHandler" };
constexpr int64_t MAX_MARK_PROCESS_DELAY_TIME_US { 3000000 };
constexpr int64_t MARK_PROCESS_DELAY_TIME_BIAS_US { 1500000 };
constexpr int32_t INVALID_EVENT_ID { -1 };
constexpr int32_t INVALID_PERSISTENT_ID { -1 };
constexpr int32_t TIME_TRANSITION { 1000 };
const std::string ANR_HANDLER_RUNNER { "ANR_HANDLER" };
} // namespace
ANRHandler::ANRHandler()
{
auto runner = AppExecFwk::EventRunner::Create(ANR_HANDLER_RUNNER);
if (runner == nullptr) {
WLOGFE("Create eventRunner failed");
return;
}
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
}
ANRHandler::~ANRHandler() {}
void ANRHandler::SetSessionStage(int32_t eventId, const wptr<ISessionStage>& sessionStage)
{
auto task = [this, eventId, sessionStage]() {
sptr<ISessionStage> session = sessionStage.promote();
if (session == nullptr) {
WLOGFE("SessionStage for eventId:%{public}d is nullptr", eventId);
sessionStageMap_[eventId] = { INVALID_PERSISTENT_ID, nullptr };
return;
}
int32_t persistentId = session->GetPersistentId();
sessionStageMap_[eventId] = { persistentId, sessionStage };
WLOGFD("SetSessionStage for eventId:%{public}d, persistentId:%{public}d", eventId, persistentId);
};
PostTask(task, "SetSessionStage:EID:" + std::to_string(eventId));
}
void ANRHandler::HandleEventConsumed(int32_t eventId, int64_t actionTime)
{
auto task = [this, eventId, actionTime]() {
int32_t currentPersistentId = GetPersistentIdOfEvent(eventId);
WLOGFD("Processed eventId:%{public}d, persistentId:%{public}d", eventId, currentPersistentId);
if (IsOnEventHandler(currentPersistentId)) {
UpdateLatestEventId(eventId);
return;
}
int64_t currentTime = GetSysClockTime();
int64_t timeoutTime = ANRTimeOutTime::INPUT_UI_TIMEOUT_TIME * TIME_TRANSITION - (currentTime - actionTime);
WLOGFD("Processed eventId:%{public}d, persistentId:%{public}d, actionTime:%{public}" PRId64 ", "
"currentTime:%{public}" PRId64 ", timeoutTime:%{public}" PRId64,
eventId, currentPersistentId, actionTime, currentTime, timeoutTime);
if (timeoutTime >= MAX_MARK_PROCESS_DELAY_TIME_US) {
int64_t delayTime = std::min(timeoutTime - MARK_PROCESS_DELAY_TIME_BIAS_US, MAX_MARK_PROCESS_DELAY_TIME_US);
SendEvent(eventId, delayTime / TIME_TRANSITION);
} else {
SendEvent(eventId, 0);
}
};
PostTask(task, "HandleEventConsumed:EID:" + std::to_string(eventId));
}
void ANRHandler::OnWindowDestroyed(int32_t persistentId)
{
auto task = [this, persistentId]() {
anrHandlerState_.sendStatus.erase(persistentId);
for (auto iter = sessionStageMap_.begin(); iter != sessionStageMap_.end();) {
if (iter->second.persistentId == persistentId) {
iter = sessionStageMap_.erase(iter);
} else {
++iter;
}
}
WLOGFD("PersistentId:%{public}d and its events erased in ANRHandler", persistentId);
};
PostTask(task, "OnWindowDestroyed:PID:" + std::to_string(persistentId));
}
bool ANRHandler::PostTask(Task &&task, const std::string& name, int64_t delayTime)
{
if (eventHandler_ == nullptr) {
WLOGFE("EventHandler is nullptr");
return false;
}
if (eventHandler_->GetEventRunner()->IsCurrentRunnerThread()) {
WLOGFE("Already running on eventHandler");
task();
return true;
}
if (!eventHandler_->PostTask(std::move(task), "wms:" + name, delayTime,
AppExecFwk::EventQueue::Priority::IMMEDIATE)) {
WLOGFE("PostTask failed");
return false;
}
return true;
}
void ANRHandler::SetAnrHandleState(int32_t eventId, bool status)
{
CALL_DEBUG_ENTER;
int32_t persistentId = GetPersistentIdOfEvent(eventId);
anrHandlerState_.sendStatus[persistentId] = status;
if (status) {
anrHandlerState_.eventsToReceipt.push_back(eventId);
} else {
if(anrHandlerState_.eventsToReceipt.empty()){
WLOGFE("EventsToReceipt is empty");
return;
}
anrHandlerState_.eventsToReceipt.pop_front();
ClearExpiredEvents(eventId);
}
}
void ANRHandler::MarkProcessed()
{
CALL_DEBUG_ENTER;
if (anrHandlerState_.eventsToReceipt.empty()) {
WLOGFE("Events to receipt is empty");
SetAnrHandleState(INVALID_EVENT_ID, false);
return;
}
int32_t eventId = anrHandlerState_.eventsToReceipt.front();
WLOGFI("InputTracking MarkProcessed eventId:%{public}d, persistentId:%{public}d",
eventId, GetPersistentIdOfEvent(eventId));
if (sessionStageMap_.find(eventId) == sessionStageMap_.end()) {
WLOGFW("SessionStage for eventId:%{public}d is not in sessionStageMap", eventId);
} else {
sptr<ISessionStage> session = sessionStageMap_[eventId].sessionStage.promote();
if (session == nullptr) {
WLOGFE("SessionStage for eventId:%{public}d is nullptr", eventId);
} else if (WSError ret = session->MarkProcessed(eventId); ret != WSError::WS_OK) {
WLOGFE("Send to sceneBoard failed, ret:%{public}d", ret);
}
}
SetAnrHandleState(eventId, false);
}
void ANRHandler::SendEvent(int32_t eventId, int64_t delayTime)
{
CALL_DEBUG_ENTER;
SetAnrHandleState(eventId, true);
auto task = [this]() {
MarkProcessed();
};
if (eventHandler_ != nullptr &&
eventHandler_->PostHighPriorityTask(task, "MarkProcessed", delayTime)) {
WLOGFD("Post eventId:%{public}d, delayTime:%{public}" PRId64 " successfully", eventId, delayTime);
} else {
WLOGFE("Post eventId:%{public}d, delayTime:%{public}" PRId64 " failed", eventId, delayTime);
SetAnrHandleState(eventId, false);
}
}
void ANRHandler::ClearExpiredEvents(int32_t eventId)
{
CALL_DEBUG_ENTER;
int32_t persistentId = GetPersistentIdOfEvent(eventId);
for (auto iter = sessionStageMap_.begin(); iter != sessionStageMap_.end();) {
auto currentPersistentId = GetPersistentIdOfEvent(iter->first);
if (iter->first < eventId &&
(currentPersistentId == persistentId || currentPersistentId == INVALID_PERSISTENT_ID)) {
iter = sessionStageMap_.erase(iter);
} else {
++iter;
}
}
}
int32_t ANRHandler::GetPersistentIdOfEvent(int32_t eventId)
{
if (sessionStageMap_.find(eventId) != sessionStageMap_.end()) {
return sessionStageMap_[eventId].persistentId;
}
WLOGFW("No sessionStage for eventId:%{public}d", eventId);
return INVALID_PERSISTENT_ID;
}
bool ANRHandler::IsOnEventHandler(int32_t persistentId)
{
if (anrHandlerState_.sendStatus.find(persistentId) != anrHandlerState_.sendStatus.end() &&
anrHandlerState_.sendStatus[persistentId]) {
return true;
}
return false;
}
void ANRHandler::UpdateLatestEventId(int32_t eventId)
{
auto currentPersistentId = GetPersistentIdOfEvent(eventId);
for (auto &event : anrHandlerState_.eventsToReceipt) {
if ((GetPersistentIdOfEvent(event) == currentPersistentId) && (eventId > event)) {
WLOGFD("Replace eventId:%{public}d by newer eventId:%{public}d", event, eventId);
event = eventId;
break;
}
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -48,12 +48,10 @@ public:
private:
void DispatchKeyEventCallback(
int32_t focusedSessionId, std::shared_ptr<MMI::KeyEvent> keyEvent, bool consumed) const;
void UpdateLastMouseEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
bool CheckPointerEvent(const std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
Ace::UIContent* uiContent_ = nullptr;
std::weak_ptr<AppExecFwk::EventHandler> weakEventConsumer_;
mutable std::mutex mouseEventMutex_;
};
};
} // namespace OHOS::Rosen

View File

@ -40,7 +40,6 @@ ohos_shared_library("intention_event_anr_manager") {
}
sources = [
"../dfx/src/dfx_hisysevent.cpp",
"../framework/anr_handler/src/anr_handler.cpp",
"../utils/src/util.cpp",
]

View File

@ -30,8 +30,6 @@ namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "IntentionEventManager" };
constexpr int32_t TRANSPARENT_FINGER_ID = 10000;
std::shared_ptr<MMI::PointerEvent> g_lastMouseEvent = nullptr;
int32_t g_lastLeaveWindowId = -1;
constexpr int32_t DELAY_TIME = 15;
constexpr unsigned int FREQUENT_CLICK_TIME_LIMIT = 3;
constexpr int FREQUENT_CLICK_COUNT_LIMIT = 8;
@ -78,8 +76,6 @@ IntentionEventManager::~IntentionEventManager() {}
IntentionEventManager::InputEventListener::~InputEventListener()
{
std::lock_guard<std::mutex> guard(mouseEventMutex_);
g_lastMouseEvent = nullptr;
}
bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent,
@ -105,26 +101,6 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent,
return true;
}
void IntentionEventManager::InputEventListener::UpdateLastMouseEvent(
std::shared_ptr<MMI::PointerEvent> pointerEvent) const
{
if (pointerEvent == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is null");
return;
}
g_lastLeaveWindowId = -1;
if ((pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_MOUSE) &&
(pointerEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW)) {
std::lock_guard<std::mutex> guard(mouseEventMutex_);
g_lastMouseEvent = std::make_shared<MMI::PointerEvent>(*pointerEvent);
} else if (g_lastMouseEvent != nullptr) {
TLOGD(WmsLogTag::WMS_EVENT, "Clear last mouse event");
std::lock_guard<std::mutex> guard(mouseEventMutex_);
g_lastMouseEvent = nullptr;
SceneSession::ClearEnterWindow();
}
}
bool IntentionEventManager::InputEventListener::CheckPointerEvent(
const std::shared_ptr<MMI::PointerEvent> pointerEvent) const
{
@ -212,7 +188,6 @@ void IntentionEventManager::InputEventListener::OnInputEvent(
pointerEvent->MarkProcessed();
}
}
UpdateLastMouseEvent(pointerEvent);
}
void IntentionEventManager::InputEventListener::DispatchKeyEventCallback(

View File

@ -344,6 +344,9 @@ struct SessionInfo {
bool isAtomicService_ = false;
bool isBackTransition_ = false;
bool needClearInNotShowRecent_ = false;
bool isPcOrPadEnableActivation_ = false;
bool canStartAbilityFromBackground_ = false;
bool isFoundationCall_ = false;
/*
* UIExtension
@ -685,6 +688,8 @@ enum class SessionUIDirtyFlag {
TOUCH_HOT_AREA = 1 << 4,
Z_ORDER = 1 << 5,
AVOID_AREA = 1 << 6,
DRAG_RECT = 1 << 7,
GLOBAL_RECT = 1 << 8,
};
/**

View File

@ -284,7 +284,7 @@ napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& sessio
CreateJsValue(env, static_cast<int32_t>(sessionProperty->GetDisplayId())));
} else {
napi_set_named_property(env, objValue, "screenId",
CreateJsValue(env, static_cast<int32_t>(0)));
CreateJsValue(env, static_cast<int32_t>(SCREEN_ID_INVALID)));
TLOGE(WmsLogTag::WMS_LIFE, "sessionProperty is nullptr!");
}
const char* moduleName = "JsSceneSession";
@ -354,6 +354,10 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
JsSceneSession::SetStartingWindowExitAnimationFlag);
BindNativeFunction(env, objValue, "setWindowEnableDragBySystem", moduleName,
JsSceneSession::SetWindowEnableDragBySystem);
BindNativeFunction(env, objValue, "setNeedSyncSessionRect", moduleName,
JsSceneSession::SetNeedSyncSessionRect);
BindNativeFunction(env, objValue, "setIsPendingToBackgroundState", moduleName,
JsSceneSession::SetIsPendingToBackgroundState);
}
void JsSceneSession::BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName)
@ -1516,20 +1520,19 @@ void JsSceneSession::ProcessShowWhenLockedRegister()
void JsSceneSession::ProcessRequestedOrientationChange()
{
auto sessionchangeCallback = sessionchangeCallback_.promote();
if (sessionchangeCallback == nullptr) {
WLOGFE("sessionchangeCallback is nullptr");
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr");
return;
}
sessionchangeCallback->OnRequestedOrientationChange_ = [weakThis = wptr(this)](uint32_t orientation) {
session->RegisterRequestedOrientationChangeCallback([weakThis = wptr(this)](uint32_t orientation) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessRequestedOrientationChange jsSceneSession is null");
TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null");
return;
}
jsSceneSession->OnReuqestedOrientationChange(orientation);
};
WLOGFD("success");
});
}
void JsSceneSession::ProcessForceHideChangeRegister()
@ -1893,7 +1896,7 @@ napi_value JsSceneSession::SetPiPControlEvent(napi_env env, napi_callback_info i
napi_value JsSceneSession::NotifyPipOcclusionChange(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_PIP, "[NAPI]");
TLOGD(WmsLogTag::WMS_PIP, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnNotifyPipOcclusionChange(env, info) : nullptr;
}
@ -2030,6 +2033,20 @@ napi_value JsSceneSession::SetWindowEnableDragBySystem(napi_env env, napi_callba
return (me != nullptr) ? me->OnSetWindowEnableDragBySystem(env, info) : nullptr;
}
napi_value JsSceneSession::SetNeedSyncSessionRect(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_PIPELINE, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnSetNeedSyncSessionRect(env, info) : nullptr;
}
napi_value JsSceneSession::SetIsPendingToBackgroundState(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnSetIsPendingToBackgroundState(env, info) : nullptr;
}
bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSession::IsCallbackRegistered[%s]", type.c_str());
@ -3194,31 +3211,41 @@ void JsSceneSession::PendingSessionActivation(SessionInfo& info)
void JsSceneSession::PendingSessionActivationInner(std::shared_ptr<SessionInfo> sessionInfo)
{
auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, env_ref = env_] {
auto task = [weakThis = wptr(this), persistentId = persistentId_, weakSession = weakSession_,
sessionInfo, env = env_] {
auto session = weakSession.promote();
if (session == nullptr) {
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]session is nullptr");
return;
}
if (session->DisallowActivationFromPendingBackground(sessionInfo->isPcOrPadEnableActivation_,
sessionInfo->isFoundationCall_, sessionInfo->canStartAbilityFromBackground_)) {
return;
}
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
TLOGE(WmsLogTag::WMS_LIFE, "PendingSessionActivationInner jsSceneSession id:%{public}d has been destroyed",
persistentId);
TLOGNE(WmsLogTag::WMS_LIFE, "PendingSessionActivationInner jsSceneSession "
"id:%{public}d has been destroyed", persistentId);
return;
}
auto jsCallBack = jsSceneSession->GetJSCallback(PENDING_SCENE_CB);
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");
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]sessionInfo is nullptr");
return;
}
napi_value jsSessionInfo = CreateJsSessionInfo(env_ref, *sessionInfo);
napi_value jsSessionInfo = CreateJsSessionInfo(env, *sessionInfo);
if (jsSessionInfo == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
TLOGNE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
return;
}
napi_value argv[] = {jsSessionInfo};
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]PendingSessionActivationInner task success, id:%{public}d",
TLOGNI(WmsLogTag::WMS_LIFE, "[NAPI]PendingSessionActivationInner task success, id:%{public}d",
sessionInfo->persistentId_);
napi_call_function(env_ref, NapiGetUndefined(env_ref),
napi_call_function(env, NapiGetUndefined(env),
jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
};
taskScheduler_->PostMainThreadTask(task, "PendingSessionActivationInner");
@ -3881,19 +3908,19 @@ napi_value JsSceneSession::OnSetWaterMarkFlag(napi_env env, napi_callback_info i
void JsSceneSession::ProcessPrepareClosePiPSessionRegister()
{
auto sessionchangeCallback = sessionchangeCallback_.promote();
if (sessionchangeCallback == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "sessionchangeCallback is nullptr");
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "session is nullptr, id:%{public}d", persistentId_);
return;
}
sessionchangeCallback->onPrepareClosePiPSession_ = [weakThis = wptr(this)] {
session->RegisterProcessPrepareClosePiPCallback([weakThis = wptr(this)] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "OnPrepareClosePiPSession jsSceneSession is null");
TLOGNE(WmsLogTag::WMS_LIFE, "OnPrepareClosePiPSession jsSceneSession is null");
return;
}
jsSceneSession->OnPrepareClosePiPSession();
};
});
TLOGD(WmsLogTag::WMS_PIP, "success");
}
@ -4905,4 +4932,62 @@ napi_value JsSceneSession::OnUnSyncScenePanelGlobalPosition(napi_env env, napi_c
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSetIsPendingToBackgroundState(napi_env env, napi_callback_info info)
{
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]session is null, id: %{public}d", persistentId_);
return NapiGetUndefined(env);
}
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_LIFE, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid"));
return NapiGetUndefined(env);
}
bool isPendingToBackgroundState = false;
if (GetType(env, argv[0]) == napi_boolean) {
if (!ConvertFromJsValue(env, argv[0], isPendingToBackgroundState)) {
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to convert parameter to isPendingToBackgroundState");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]isPendingToBackgroundState: %{public}u", isPendingToBackgroundState);
}
session->SetIsPendingToBackgroundState(isPendingToBackgroundState);
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSetNeedSyncSessionRect(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_PIPELINE, "[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 needSync = true;
if (!ConvertFromJsValue(env, argv[0], needSync)) {
TLOGE(WmsLogTag::WMS_PIPELINE, "[NAPI]Failed to convert parameter to needSync");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
TLOGI(WmsLogTag::WMS_PIPELINE, "[NAPI]needSync:%{public}u, id:%{public}d", needSync, persistentId_);
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_PIPELINE, "[NAPI]session is nullptr, id:%{public}d", persistentId_);
return NapiGetUndefined(env);
}
session->SetNeedSyncSessionRect(needSync);
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen

View File

@ -129,6 +129,7 @@ private:
static napi_value SetSkipDraw(napi_env env, napi_callback_info info);
static napi_value SyncScenePanelGlobalPosition(napi_env env, napi_callback_info info);
static napi_value UnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info);
static napi_value SetNeedSyncSessionRect(napi_env env, napi_callback_info info);
static void BindNativeMethod(napi_env env, napi_value objValue, const char* moduleName);
static void BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName);
static void BindNativeMethodForCompatiblePcMode(napi_env env, napi_value objValue, const char* moduleName);
@ -149,6 +150,7 @@ private:
static napi_value CompatibleFullScreenMinimize(napi_env env, napi_callback_info info);
static napi_value CompatibleFullScreenClose(napi_env env, napi_callback_info info);
static napi_value SetWindowEnableDragBySystem(napi_env env, napi_callback_info info);
static napi_value SetIsPendingToBackgroundState(napi_env env, napi_callback_info info);
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
napi_value OnUpdateNativeVisibility(napi_env env, napi_callback_info info);
@ -201,7 +203,9 @@ private:
napi_value OnCompatibleFullScreenClose(napi_env env, napi_callback_info info);
napi_value OnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info);
napi_value OnUnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info);
napi_value OnSetNeedSyncSessionRect(napi_env env, napi_callback_info info);
napi_value OnSetWindowEnableDragBySystem(napi_env env, napi_callback_info info);
napi_value OnSetIsPendingToBackgroundState(napi_env env, napi_callback_info info);
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
void ProcessChangeSessionVisibilityWithStatusBarRegister();

View File

@ -562,6 +562,38 @@ void JsSceneSessionManager::ProcessAbilityManagerCollaboratorRegistered()
SceneSessionManager::GetInstance().SetAbilityManagerCollaboratorRegisteredFunc(func);
}
void JsSceneSessionManager::RegisterRootSceneCallbacksOnSSManager()
{
RegisterDumpRootSceneElementInfoListener();
RegisterVirtualPixelRatioChangeListener();
SceneSessionManager::GetInstance().SetRootSceneProcessBackEventFunc([this] {
TLOGND(WmsLogTag::WMS_EVENT, "rootScene BackEvent");
this->OnRootSceneBackEvent();
});
SceneSessionManager::GetInstance().SetOnFlushUIParamsFunc([] {
RootScene::staticRootScene_->OnFlushUIParams();
});
SceneSessionManager::GetInstance().SetIsRootSceneLastFrameLayoutFinishedFunc([] {
return RootScene::staticRootScene_->IsLastFrameLayoutFinished();
});
}
void JsSceneSessionManager::RegisterSSManagerCallbacksOnRootScene()
{
rootScene_->SetGetSessionRectCallback([](AvoidAreaType type) {
return SceneSessionManager::GetInstance().GetRootSessionAvoidSessionRect(type);
});
if (!Session::IsScbCoreEnabled()) {
rootScene_->SetFrameLayoutFinishCallback([] {
SceneSessionManager::GetInstance().NotifyUpdateRectAfterLayout();
SceneSessionManager::GetInstance().FlushWindowInfoToMMI();
});
}
RootScene::SetOnConfigurationUpdatedCallback([](const std::shared_ptr<AppExecFwk::Configuration>& configuration) {
SceneSessionManager::GetInstance().OnConfigurationUpdated(configuration);
});
}
napi_value JsSceneSessionManager::RegisterCallback(napi_env env, napi_callback_info info)
{
WLOGFD("[NAPI]");
@ -1463,31 +1495,14 @@ napi_value JsSceneSessionManager::OnGetRootSceneSession(napi_env env, napi_callb
rootScene_ = sptr<RootScene>::MakeSptr();
}
RootScene::staticRootScene_ = rootScene_;
RegisterDumpRootSceneElementInfoListener();
RegisterVirtualPixelRatioChangeListener();
rootSceneSession->SetLoadContentFunc([rootScene = rootScene_]
(const std::string& contentUrl, napi_env env, napi_value storage, AbilityRuntime::Context* context) {
rootScene->LoadContent(contentUrl, env, storage, context);
ScenePersistentStorage::InitDir(context->GetPreferencesDir());
SceneSessionManager::GetInstance().InitPersistentStorage();
});
rootScene_->SetGetSessionRectCallback([](AvoidAreaType type) {
return SceneSessionManager::GetInstance().GetRootSessionAvoidSessionRect(type);
});
if (!Session::IsScbCoreEnabled()) {
rootScene_->SetFrameLayoutFinishCallback([]() {
SceneSessionManager::GetInstance().NotifyUpdateRectAfterLayout();
SceneSessionManager::GetInstance().FlushWindowInfoToMMI();
});
}
RootSceneProcessBackEventFunc processBackEventFunc = [this]() {
TLOGD(WmsLogTag::WMS_EVENT, "rootScene BackEvent");
this->OnRootSceneBackEvent();
};
SceneSessionManager::GetInstance().SetRootSceneProcessBackEventFunc(processBackEventFunc);
RootScene::SetOnConfigurationUpdatedCallback([](const std::shared_ptr<AppExecFwk::Configuration>& configuration) {
SceneSessionManager::GetInstance().OnConfigurationUpdated(configuration);
});
RegisterRootSceneCallbacksOnSSManager();
RegisterSSManagerCallbacksOnRootScene();
napi_value jsRootSceneSessionObj = JsRootSceneSession::Create(env, rootSceneSession);
if (jsRootSceneSessionObj == nullptr) {
WLOGFE("[NAPI]jsRootSceneSessionObj is nullptr");

View File

@ -221,6 +221,8 @@ private:
std::shared_ptr<NativeReference> GetJSCallback(const std::string& functionName);
void ProcessAbilityManagerCollaboratorRegistered();
void OnAbilityManagerCollaboratorRegistered();
void RegisterRootSceneCallbacksOnSSManager();
void RegisterSSManagerCallbacksOnRootScene();
napi_env env_;
std::shared_mutex jsCbMapMutex_;

View File

@ -92,6 +92,7 @@ JsScreenSession::JsScreenSession(napi_env env, const sptr<ScreenSession>& screen
Rect rect = { screenBounds.rect_.left_, screenBounds.rect_.top_,
screenBounds.rect_.width_, screenBounds.rect_.height_ };
screenScene_->SetDisplayDensity(density);
screenScene_->SetDisplayId(screenSession_->GetScreenId());
screenScene_->UpdateViewportConfig(rect, WindowSizeChangeReason::UPDATE_DPI_SYNC);
OnScreenDensityChange();
};

View File

@ -75,12 +75,15 @@ ohos_shared_library("screen_session_manager") {
"src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.cpp",
"src/fold_screen_controller/single_display_fold_policy.cpp",
"src/fold_screen_controller/single_display_pocket_fold_policy.cpp",
"src/fold_screen_controller/super_fold_sensor_manager.cpp",
"src/fold_screen_controller/super_fold_state_manager.cpp",
"src/multi_screen_manager.cpp",
"src/publish/screen_session_publish.cpp",
"src/screen_cutout_controller.cpp",
"src/screen_rotation_property.cpp",
"src/screen_scene_config.cpp",
"src/screen_sensor_connector.cpp",
"src/screen_sensor_plugin.cpp",
"src/screen_session_dumper.cpp",
"src/screen_session_manager.cpp",
"src/screen_setting_helper.cpp",
@ -141,7 +144,6 @@ ohos_shared_library("screen_session_manager") {
defines = []
if (window_manager_feature_subscribe_motion) {
if (defined(global_parts_info) && defined(global_parts_info.msdp_motion)) {
external_deps += [ "motion:motion_interface_native" ]
defines += [ "WM_SUBSCRIBE_MOTION_ENABLE" ]
}
}

View File

@ -0,0 +1,95 @@
/*
* 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_SUPER_FOLD_SENSOR_MANAGER_H
#define OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H
#ifdef SENSOR_ENABLE
#include <deque>
#include <memory>
#include <mutex>
#include <sstream>
#include <functional>
#include <climits>
#include "refbase.h"
#include "wm_single_instance.h"
#include "ws_common.h"
#include "sensor_agent.h"
#include "sensor_agent_type.h"
#include "session/screen/include/screen_property.h"
#include "dm_common.h"
namespace OHOS {
namespace Rosen {
class SuperFoldSensorManager : public RefBase {
WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldSensorManager);
public:
void RegisterPostureCallback(); //折叠角度注册回调
void RegisterHallCallback(); // 磁吸键盘
void RegisterSoftKeyboardCallback();
void UnregisterPostureCallback();
void UnregisterHallCallback();
void HandlePostureData(const SensorEvent * const event);
void HandleSoftKeyboardData();
void HandleHallData(const SensorEvent * const event);
void HandleSuperSensorChange();
void SetHasKeyboard(bool flag);
private:
std::recursive_mutex mutex_;
bool hasKeyboard_ = false;
SuperFoldStatusChangeEvents events_ = SuperFoldStatusChangeEvents::UNDEFINED;
SensorUser postureUser {};
SensorUser hallUser {};
float globalAngle = 170.0F;
uint16_t globalHall = USHRT_MAX;
void NotifyFoldAngleChanged(float foldAngle);
void NotifyHallChanged(uint16_t hall);
void NotifySoftKeyboardChanged();
SuperFoldSensorManager();
~SuperFoldSensorManager();
};
}
}
#endif // SENSOR_ENABLE
#endif // OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H

View File

@ -0,0 +1,84 @@
/*
* 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_SUPER_FOLD_STATE_MANAGER_H
#define OHOS_ROSEN_SUPER_FOLD_STATE_MANAGER_H
#include <mutex>
#include <refbase.h>
#include <functional>
#include <map>
#include <vector>
#include <memory>
#include <utility>
#include "dm_common.h"
#include "wm_single_instance.h"
namespace OHOS {
namespace Rosen {
class SuperFoldStateManager final {
WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldStateManager)
public:
SuperFoldStateManager();
~SuperFoldStateManager();
void initStateManagerMap(SuperFoldStatus curState,
SuperFoldStatusChangeEvents event,
SuperFoldStatus nextState,
std::function<void ()> action);
void transferState(SuperFoldStatus nextState);
void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events);
SuperFoldStatus GetCurrentStatus();
void SetCurrentStatus(SuperFoldStatus curState);
private:
SuperFoldStatus curState_ = SuperFoldStatus::HALF_FOLDED;
struct Transition {
SuperFoldStatus nextState;
std::function<void ()> action;
};
using transEvent = std::pair<SuperFoldStatus, SuperFoldStatusChangeEvents>;
std::map<transEvent, Transition> stateManagerMap_;
static void DoAngleChangeFolded();
static void DoAngleChangeHalfFolded();
static void DoAngleChangeExpanded();
static void DoKeyboardOn();
static void DoKeyboardOff();
static void DoSoftKeyboardOn();
static void DoSoftKeyboardOff();
static void DoKeyboardToExpanded();
static void DoExpandedToKeyboard();
};
} // Rosen
} // OHOS
#endif // OHOS_ROSEN_SUPER_FOLD_STATE_MANAGER_H

View File

@ -47,6 +47,7 @@ public:
static std::string GetExternalScreenDefaultMode();
static std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalConfig();
static std::map<FoldDisplayMode, ScrollableParam> GetAllScrollableParam();
static bool IsSupportCapture();
private:
static std::map<int32_t, std::string> xmlNodeMap_;
@ -61,6 +62,7 @@ private:
static uint32_t curvedAreaInLandscape_;
static std::vector<DisplayPhysicalResolution> displayPhysicalResolution_;
static std::map<FoldDisplayMode, ScrollableParam> scrollableParams_;
static bool isSupportCapture_;
static bool IsValidNode(const xmlNode& currNode);
static void ReadEnableConfigInfo(const xmlNodePtr& currNode);

View File

@ -19,16 +19,13 @@
#include <map>
#include <refbase.h>
#include "dm_common.h"
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
#include "motion_agent.h"
#include "motion_callback_stub.h"
#endif
#include "screen_rotation_property.h"
#include "screen_tent_property.h"
#ifdef SENSOR_ENABLE
#include "sensor_agent.h"
#endif
#include "window_manager_hilog.h"
#include "screen_sensor_plugin.h"
namespace OHOS {
namespace Rosen {
@ -44,19 +41,6 @@ public:
};
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
using OHOS::Msdp::MotionCallbackStub;
using OHOS::Msdp::MotionEvent;
class RotationMotionEventCallback : public MotionCallbackStub {
public:
void OnMotionChanged(const MotionEvent& motionData) override;
};
class TentMotionEventCallback : public MotionCallbackStub {
public:
void OnMotionChanged(const MotionEvent& motionData) override;
};
class MotionSubscriber {
friend ScreenSensorConnector;
public:
@ -66,7 +50,6 @@ private:
static void SubscribeMotionSensor();
static void UnsubscribeMotionSensor();
static sptr<RotationMotionEventCallback> motionEventCallback_;
static bool isMotionSensorSubscribed_;
};
@ -79,7 +62,6 @@ private:
static void SubscribeMotionSensor();
static void UnsubscribeMotionSensor();
static sptr<TentMotionEventCallback> motionEventCallback_;
static bool isMotionSensorSubscribed_;
};
#endif

View File

@ -0,0 +1,52 @@
/*
* 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 SCREEN_SENSOR_PLUGIN_H
#define SCREEN_SENSOR_PLUGIN_H
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <unistd.h>
#include "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
#if (defined(__aarch64__) || defined(__x86_64__))
const std::string PLUGIN_SO_PATH = "/system/lib64/platformsdk/libmotion_agent.z.so";
#else
const std::string PLUGIN_SO_PATH = "/system/lib/platformsdk/libmotion_agent.z.so";
#endif
typedef struct MotionSensorEvent {
int32_t type = -1;
int32_t status = -1;
int32_t dataLen = -1;
int32_t *data = nullptr;
} MotionSensorEvent;
using OnMotionChangedPtr = void (*)(const MotionSensorEvent&);
using MotionSubscribeCallbackPtr = bool (*)(int32_t, OnMotionChangedPtr);
using MotionUnsubscribeCallbackPtr = bool (*)(int32_t, OnMotionChangedPtr);
bool LoadMotionSensor(void);
void UnloadMotionSensor(void);
bool SubscribeCallback(int32_t motionType, OnMotionChangedPtr callback);
bool UnsubscribeCallback(int32_t motionType, OnMotionChangedPtr callback);
}
}
#endif /* SCREEN_SENSOR_PLUGIN_H */

View File

@ -59,13 +59,14 @@ private:
void ExcuteInjectCmd();
/*
hidumper
*/
*/
void ShowNotifyFoldStatusChangedInfo();
void ShowIllegalArgsInfo();
void SetMotionSensorvalue(std::string input);
void SetRotationLockedvalue(std::string input);
void SetEnterOrExitTentMode(std::string input);
void SetHoverStatusChange(std::string input);
void SetSuperFoldStatusChange(std::string input);
void MockSendCastPublishEvent(std::string input);
bool IsValidDisplayModeCommand(std::string command);
int SetFoldDisplayMode();

View File

@ -158,6 +158,10 @@ public:
sptr<ScreenSessionGroup> RemoveFromGroupLocked(sptr<ScreenSession> screen);
sptr<ScreenSessionGroup> GetAbstractScreenGroup(ScreenId smsScreenId);
void SetMultiScreenFrameControl(void);
bool IsPhysicalScreenAndInUse(sptr<ScreenSession> screenSession) const;
bool HandleFoldScreenSessionCreate(ScreenId screenId);
void ChangeScreenGroup(sptr<ScreenSessionGroup> group, const std::vector<ScreenId>& screens,
const std::vector<Point>& startPoints, bool filterScreen, ScreenCombination combination);
@ -314,6 +318,7 @@ public:
std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr) override;
void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override;
sptr<DisplayInfo> GetPrimaryDisplayInfo() override;
protected:
ScreenSessionManager();
@ -333,7 +338,7 @@ private:
void OnHgmRefreshRateChange(uint32_t refreshRate);
sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId);
void CreateScreenProperty(ScreenId screenId, ScreenProperty& property);
void InitScreenDensity(sptr<ScreenSession> session, const ScreenProperty& property);
void InitExtendScreenDensity(sptr<ScreenSession> session, ScreenProperty property);
float CalcDefaultExtendScreenDensity(const ScreenProperty& property);
sptr<ScreenSession> GetScreenSessionInner(ScreenId screenId, ScreenProperty property);
sptr<ScreenSession> CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId,

View File

@ -182,6 +182,8 @@ public:
uint32_t& actualRefreshRate) override;
std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr) override;
sptr<DisplayInfo> GetPrimaryDisplayInfo() override;
private:
static inline BrokerDelegator<ScreenSessionManagerProxy> delegator_;
};

View File

@ -343,7 +343,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr<ScreenSession> scr
ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false);
ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_ON);
} else {
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync();
}
SetdisplayModeChangeStatus(false);
};
@ -367,7 +367,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeToCoordination()
ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_ON,
PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH);
} else {
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync();
}
SetdisplayModeChangeStatus(false);
};

View File

@ -294,9 +294,9 @@ void SingleDisplaySensorPocketFoldStateManager::ReportTentStatusChange(ReportTen
TLOGI(WmsLogTag::DMS, "report tentStatus: %{public}d", status);
int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
"TENT_MODE",
"FOLD_TENT_MODE",
OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
"TENT_STATUS", status);
"FOLD_TENT_STATUS", status);
if (ret != 0) {
TLOGE(WmsLogTag::DMS, "Write HiSysEvent error, ret: %{public}d", ret);
}

View File

@ -0,0 +1,229 @@
/*
* 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.
*/
#ifdef SENSOR_ENABLE
#include <cmath>
#include <hisysevent.h>
#include <parameters.h>
#include <vector>
#include "dm_common.h"
#include "fold_screen_controller/super_fold_sensor_manager.h"
#include "fold_screen_controller/super_fold_state_manager.h"
#include "window_manager_hilog.h"
#include "screen_session_manager.h"
namespace OHOS {
namespace Rosen {
namespace {
constexpr float ANGLE_MIN_VAL = 30.0F;
constexpr float ANGLE_MAX_VAL = 180.0F;
constexpr float ANGLE_FLAT_THRESHOLD = 150.0F;
constexpr float ANGLE_HALF_FOLD_THRESHOLD = 135.0F;
constexpr int32_t HALL_HAVE_KEYBOARD_THRESHOLD = 0x0100;
constexpr int32_t HALL_REMOVE_KEYBOARD_THRESHOLD = 0;
constexpr int32_t HALL_ACTIVE = 1 << 2;
constexpr int32_t SENSOR_SUCCESS = 0;
constexpr int32_t POSTURE_INTERVAL = 100000000;
constexpr uint16_t SENSOR_EVENT_FIRST_DATA = 0;
constexpr float ACCURACY_ERROR_FOR_PC = 0.0001F;
} // namespace
SuperFoldSensorManager &SuperFoldSensorManager::GetInstance()
{
static SuperFoldSensorManager SuperFoldSensorManager;
return SuperFoldSensorManager;
}
static void SensorPostureDataCallback(SensorEvent *event)
{
OHOS::Rosen::SuperFoldSensorManager::GetInstance().HandlePostureData(event);
}
static void SensorHallDataCallback(SensorEvent *event)
{
OHOS::Rosen::SuperFoldSensorManager::GetInstance().HandleHallData(event);
}
void SuperFoldSensorManager::RegisterPostureCallback()
{
postureUser.callback = SensorPostureDataCallback;
int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser);
int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_POSTURE, &postureUser, POSTURE_INTERVAL, POSTURE_INTERVAL);
int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser);
TLOGI(WmsLogTag::DMS,
"RegisterPostureCallback, subscribeRet: %{public}d, setBatchRet: %{public}d, activateRet: %{public}d",
subscribeRet, setBatchRet, activateRet);
if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) {
TLOGI(WmsLogTag::DMS, "RegisterPostureCallback failed.");
} else {
TLOGI(WmsLogTag::DMS, "RegisterPostureCallback success.");
}
}
void SuperFoldSensorManager::UnregisterPostureCallback()
{
int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser);
int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser);
TLOGI(WmsLogTag::DMS, "UnRegisterPostureCallback, deactivateRet: %{public}d, unsubscribeRet: %{public}d",
deactivateRet, unsubscribeRet);
if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) {
TLOGI(WmsLogTag::DMS, "FoldScreenSensorManager.UnRegisterPostureCallback success.");
}
}
void SuperFoldSensorManager::RegisterHallCallback()
{
hallUser.callback = SensorHallDataCallback;
int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_HALL, &hallUser);
TLOGI(WmsLogTag::DMS, "RegisterHallCallback, subscribeRet: %{public}d", subscribeRet);
int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_HALL, &hallUser, POSTURE_INTERVAL, POSTURE_INTERVAL);
TLOGI(WmsLogTag::DMS, "RegisterHallCallback, setBatchRet: %{public}d", setBatchRet);
int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_HALL, &hallUser);
TLOGI(WmsLogTag::DMS, "RegisterHallCallback, activateRet: %{public}d", activateRet);
if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) {
TLOGI(WmsLogTag::DMS, "RegisterHallCallback failed.");
}
}
void SuperFoldSensorManager::UnregisterHallCallback()
{
int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_HALL_EXT, &hallUser);
int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_HALL_EXT, &hallUser);
if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) {
TLOGI(WmsLogTag::DMS, "UnRegisterHallCallback success.");
}
}
void SuperFoldSensorManager::RegisterSoftKeyboardCallback() {}
void SuperFoldSensorManager::HandlePostureData(const SensorEvent * const event)
{
if (event == nullptr) {
TLOGI(WmsLogTag::DMS, "SensorEvent is nullptr.");
return;
}
if (event[SENSOR_EVENT_FIRST_DATA].data == nullptr) {
TLOGI(WmsLogTag::DMS, "SensorEvent[0].data is nullptr.");
return;
}
if (event[SENSOR_EVENT_FIRST_DATA].dataLen < sizeof(PostureData)) {
TLOGI(WmsLogTag::DMS, "SensorEvent dataLen less than posture data size.");
return;
}
PostureData *postureData = reinterpret_cast<PostureData *>(event[SENSOR_EVENT_FIRST_DATA].data);
globalAngle = (*postureData).angle;
if (std::isless(globalAngle, ANGLE_MIN_VAL) ||
std::isgreater(globalAngle, ANGLE_MAX_VAL + ACCURACY_ERROR_FOR_PC)) {
TLOGI(WmsLogTag::DMS, "Invalid value, angle value is: %{public}f.", globalAngle);
return;
}
TLOGI(WmsLogTag::DMS, "angle value is: %{public}f.", globalAngle);
NotifyFoldAngleChanged(globalAngle);
}
void SuperFoldSensorManager::NotifyFoldAngleChanged(float foldAngle)
{
if (std::isgreater(foldAngle, ANGLE_FLAT_THRESHOLD)) {
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is not Folded");
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED;
} else if (std::isless(foldAngle, ANGLE_HALF_FOLD_THRESHOLD)) {
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is folded");
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED;
} else {
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged");
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED;
return;
}
// notify
std::vector<float> foldAngles;
foldAngles.push_back(foldAngle);
ScreenSessionManager::GetInstance().NotifyFoldAngleChanged(foldAngles);
HandleSuperSensorChange();
}
void SuperFoldSensorManager::HandleHallData(const SensorEvent * const event)
{
if (event == nullptr) {
TLOGI(WmsLogTag::DMS, "SensorEvent is nullptr.");
return;
}
if (event[SENSOR_EVENT_FIRST_DATA].data == nullptr) {
TLOGI(WmsLogTag::DMS, "SensorEvent[0].data is nullptr.");
return;
}
if (event[SENSOR_EVENT_FIRST_DATA].dataLen < sizeof(HallData)) {
TLOGI(WmsLogTag::DMS, "SensorEvent[0].dataLen is nullptr.");
return;
}
auto data = reinterpret_cast<HallData*>(event->data);
auto status = static_cast<uint32_t>(data->status);
TLOGI(WmsLogTag::DMS, "HallData status is: %{public}u.", status);
if (globalHall == (status & HALL_ACTIVE)) {
TLOGI(WmsLogTag::DMS, "Hall don't change, hall = %{public}u", globalHall);
return;
}
globalHall = (status & HALL_ACTIVE);
TLOGI(WmsLogTag::DMS, "Hall change, hall = %{public}u", globalHall);
NotifyHallChanged(globalHall);
}
void SuperFoldSensorManager::NotifyHallChanged(uint16_t Hall)
{
if (Hall == HALL_REMOVE_KEYBOARD_THRESHOLD) {
TLOGI(WmsLogTag::DMS, "NotifyHallChanged is not hasPhysicalKeyboard");
hasKeyboard_ = false;
events_ = SuperFoldStatusChangeEvents::KEYBOARD_OFF;
} else if (Hall == HALL_HAVE_KEYBOARD_THRESHOLD) {
TLOGI(WmsLogTag::DMS, "NotifyHallChanged is hasPhysicalKeyboard");
hasKeyboard_ = true;
events_ = SuperFoldStatusChangeEvents::KEYBOARD_ON;
} else {
TLOGI(WmsLogTag::DMS, "NotifyHallChanged invalide hall value");
return;
}
// notify
HandleSuperSensorChange();
}
void SuperFoldSensorManager::HandleSoftKeyboardData() {}
void SuperFoldSensorManager::NotifySoftKeyboardChanged() {}
void SuperFoldSensorManager::HandleSuperSensorChange()
{
// trigger events
if (hasKeyboard_ && events_ != SuperFoldStatusChangeEvents::KEYBOARD_OFF) {
TLOGI(WmsLogTag::DMS, "Don't Change!");
return;
}
SuperFoldStateManager::GetInstance().HandleSuperFoldStatusChange(events_);
}
void SuperFoldSensorManager::SetHasKeyboard(bool flag)
{
hasKeyboard_ = flag;
}
SuperFoldSensorManager::SuperFoldSensorManager() {}
SuperFoldSensorManager::~SuperFoldSensorManager() {}
} // Rosen
} // OHOS
#endif

View File

@ -0,0 +1,168 @@
/*
* 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_session_manager/include/screen_session_manager.h"
#include "fold_screen_controller/super_fold_state_manager.h"
#include "fold_screen_controller/super_fold_sensor_manager.h"
#include "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
WM_IMPLEMENT_SINGLE_INSTANCE(SuperFoldStateManager)
void SuperFoldStateManager::DoAngleChangeFolded()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeFolded()");
}
void SuperFoldStateManager::DoAngleChangeHalfFolded()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeHalfFolded())");
}
void SuperFoldStateManager::DoAngleChangeExpanded()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeExpanded()");
}
void SuperFoldStateManager::DoKeyboardOn()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()");
}
void SuperFoldStateManager::DoKeyboardOff()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()");
}
void SuperFoldStateManager::DoSoftKeyboardOn()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOn()");
}
void SuperFoldStateManager::DoSoftKeyboardOff()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOff()");
}
void SuperFoldStateManager::DoKeyboardToExpanded()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardToExpanded()");
}
void SuperFoldStateManager::DoExpandedToKeyboard()
{
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoExpandedToKeyboard()");
}
SuperFoldStateManager::SuperFoldStateManager()
{
initStateManagerMap(SuperFoldStatus::HALF_FOLDED,
SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED,
SuperFoldStatus::EXPANDED,
&SuperFoldStateManager::DoAngleChangeExpanded);
initStateManagerMap(SuperFoldStatus::EXPANDED,
SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED,
SuperFoldStatus::HALF_FOLDED,
&SuperFoldStateManager::DoAngleChangeHalfFolded);
initStateManagerMap(SuperFoldStatus::HALF_FOLDED,
SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED,
SuperFoldStatus::FOLDED,
&SuperFoldStateManager::DoAngleChangeFolded);
initStateManagerMap(SuperFoldStatus::HALF_FOLDED,
SuperFoldStatusChangeEvents::KEYBOARD_ON,
SuperFoldStatus::KEYBOARD,
&SuperFoldStateManager::DoKeyboardOn);
initStateManagerMap(SuperFoldStatus::EXPANDED,
SuperFoldStatusChangeEvents::KEYBOARD_ON,
SuperFoldStatus::KEYBOARD,
&SuperFoldStateManager::DoExpandedToKeyboard);
initStateManagerMap(SuperFoldStatus::KEYBOARD,
SuperFoldStatusChangeEvents::KEYBOARD_OFF,
SuperFoldStatus::HALF_FOLDED,
&SuperFoldStateManager::DoKeyboardOff);
initStateManagerMap(SuperFoldStatus::KEYBOARD,
SuperFoldStatusChangeEvents::KEYBOARD_OFF,
SuperFoldStatus::EXPANDED,
&SuperFoldStateManager::DoKeyboardToExpanded);
initStateManagerMap(SuperFoldStatus::HALF_FOLDED,
SuperFoldStatusChangeEvents::SOFT_KEYBOARD_ON,
SuperFoldStatus::SOFT_KEYBOARD,
&SuperFoldStateManager::DoSoftKeyboardOn);
initStateManagerMap(SuperFoldStatus::SOFT_KEYBOARD,
SuperFoldStatusChangeEvents::SOFT_KEYBOARD_OFF,
SuperFoldStatus::HALF_FOLDED,
&SuperFoldStateManager::DoSoftKeyboardOff);
}
SuperFoldStateManager::~SuperFoldStateManager() = default;
void SuperFoldStateManager::initStateManagerMap(SuperFoldStatus curState,
SuperFoldStatusChangeEvents event,
SuperFoldStatus nextState,
std::function<void ()> action)
{
stateManagerMap_[{curState, event}] = {nextState, action};
}
void SuperFoldStateManager::transferState(SuperFoldStatus nextState)
{
TLOGI(WmsLogTag::DMS, "transferState from %{public}d to %{public}d", curState_, nextState);
curState_ = nextState;
}
void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents event)
{
SuperFoldStatus curState = curState_;
SuperFoldStatus nextState = SuperFoldStatus::UNKNOWN;
bool isTransfer = false;
std::function<void ()> action;
auto item = stateManagerMap_.find({curState, event});
if (item != stateManagerMap_.end()) {
nextState = item->second.nextState;
action = item->second.action;
isTransfer = true;
}
if (isTransfer && action) {
action();
transferState(nextState);
// notify
}
}
SuperFoldStatus SuperFoldStateManager::GetCurrentStatus()
{
return curState_;
}
void SuperFoldStateManager::SetCurrentStatus(SuperFoldStatus curState)
{
curState_ = curState;
}
} // Rosen
} // OHOS

View File

@ -520,7 +520,7 @@ void MultiScreenManager::InternalScreenOnChange(sptr<ScreenSession> internalSess
DoFirstMainChange(externalSession, internalSession, SCREEN_EXTEND);
TLOGI(WmsLogTag::DMS, "6: external mirror to external extend");
} else {
TLOGE(WmsLogTag::DMS, "paramater error!");
TLOGE(WmsLogTag::DMS, "no need to change or paramater error!");
return;
}
}

View File

@ -58,7 +58,8 @@ enum XmlNodeElement {
CAST_BUNDLE_NAME,
CAST_ABILITY_NAME,
PHYSICAL_DISPLAY_RESOLUTION,
SCROLLABLE_PARAM
SCROLLABLE_PARAM,
IS_SUPPORT_CAPTURE
};
}
@ -71,6 +72,7 @@ std::vector<DisplayPhysicalResolution> ScreenSceneConfig::displayPhysicalResolut
std::map<FoldDisplayMode, ScrollableParam> ScreenSceneConfig::scrollableParams_;
std::vector<DMRect> ScreenSceneConfig::subCutoutBoundaryRect_;
bool ScreenSceneConfig::isWaterfallDisplay_ = false;
bool ScreenSceneConfig::isSupportCapture_ = false;
bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0;
std::map<int32_t, std::string> ScreenSceneConfig::xmlNodeMap_ = {
@ -95,7 +97,8 @@ std::map<int32_t, std::string> ScreenSceneConfig::xmlNodeMap_ = {
{CAST_BUNDLE_NAME, "castBundleName"},
{CAST_ABILITY_NAME, "castAbilityName"},
{PHYSICAL_DISPLAY_RESOLUTION, "physicalDisplayResolution"},
{SCROLLABLE_PARAM, "scrollableParam"}
{SCROLLABLE_PARAM, "scrollableParam"},
{IS_SUPPORT_CAPTURE, "isSupportCapture"}
};
@ -177,6 +180,7 @@ void ScreenSceneConfig::ParseNodeConfig(const xmlNodePtr& currNode)
bool enableConfigCheck = (xmlNodeMap_[IS_WATERFALL_DISPLAY] == nodeName) ||
(xmlNodeMap_[IS_CURVED_COMPRESS_ENABLED] == nodeName) ||
(xmlNodeMap_[IS_RIGHT_POWER_BUTTON] == nodeName) ||
(xmlNodeMap_[IS_SUPPORT_CAPTURE] == nodeName) ||
(xmlNodeMap_[SUPPORT_ROTATE_WITH_SCREEN] == nodeName);
bool numberConfigCheck = (xmlNodeMap_[DPI] == nodeName) ||
(xmlNodeMap_[SUB_DPI] == nodeName) ||
@ -360,6 +364,8 @@ void ScreenSceneConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode)
isWaterfallDisplay_ = true;
} else if (xmlNodeMap_[IS_CURVED_COMPRESS_ENABLED] == nodeName) {
isScreenCompressionEnableInLandscape_ = true;
} else if (xmlNodeMap_[IS_SUPPORT_CAPTURE] == nodeName) {
isSupportCapture_ = true;
}
} else {
enableConfig_[nodeName] = false;
@ -508,6 +514,11 @@ bool ScreenSceneConfig::IsWaterfallDisplay()
return isWaterfallDisplay_;
}
bool ScreenSceneConfig::IsSupportCapture()
{
return isSupportCapture_;
}
void ScreenSceneConfig::SetCurvedCompressionAreaInLandscape()
{
if (intNumbersConfig_[xmlNodeMap_[CURVED_AREA_IN_LANDSCAPE]].size() > 0) {

View File

@ -28,14 +28,16 @@ namespace {
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;
const int32_t MOTION_TYPE_ROTATION = 700;
const int32_t MOTION_TYPE_TENT = 2800;
#endif
}
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
bool MotionSubscriber::isMotionSensorSubscribed_ = false;
sptr<RotationMotionEventCallback> MotionSubscriber::motionEventCallback_ = nullptr;
bool MotionTentSubscriber::isMotionSensorSubscribed_ = false;
sptr<TentMotionEventCallback> MotionTentSubscriber::motionEventCallback_ = nullptr;
static void RotationMotionEventCallback(const MotionSensorEvent& motionData);
static void TentMotionEventCallback(const MotionSensorEvent& motionData);
#endif
void ScreenSensorConnector::SubscribeRotationSensor()
@ -43,9 +45,6 @@ void ScreenSensorConnector::SubscribeRotationSensor()
TLOGD(WmsLogTag::DMS, "subscribe rotation-related sensor");
#ifdef WM_SUBSCRIBE_MOTION_ENABLE
MotionSubscriber::SubscribeMotionSensor();
if (MotionSubscriber::isMotionSensorSubscribed_) {
return;
}
#endif
}
@ -80,15 +79,11 @@ void MotionSubscriber::SubscribeMotionSensor()
TLOGE(WmsLogTag::DMS, "motion sensor's already subscribed");
return;
}
sptr<RotationMotionEventCallback> callback = new (std::nothrow) RotationMotionEventCallback();
if (callback == nullptr) {
if (!SubscribeCallback(MOTION_TYPE_ROTATION, RotationMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor subscribe failed");
return;
}
int32_t ret = OHOS::Msdp::SubscribeCallback(OHOS::Msdp::MOTION_TYPE_ROTATION, callback);
if (ret != 0) {
return;
}
motionEventCallback_ = callback;
isMotionSensorSubscribed_ = true;
}
@ -98,15 +93,15 @@ void MotionSubscriber::UnsubscribeMotionSensor()
TLOGI(WmsLogTag::DMS, "start");
return;
}
int32_t ret = OHOS::Msdp::UnsubscribeCallback(OHOS::Msdp::MOTION_TYPE_ROTATION, motionEventCallback_);
if (ret != static_cast<int32_t>(OHOS::Msdp::MotionErrorCode::MOTION_SUCCESS)
&& ret != static_cast<int32_t>(OHOS::Msdp::MotionErrorCode::MOTION_NO_SUBSCRIBE)) {
if (!UnsubscribeCallback(MOTION_TYPE_ROTATION, RotationMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor unsubscribe failed");
return;
}
isMotionSensorSubscribed_ = false;
}
void RotationMotionEventCallback::OnMotionChanged(const MotionEvent& motionData)
void RotationMotionEventCallback(const MotionSensorEvent& motionData)
{
DeviceRotation motionRotation = DeviceRotation::INVALID;
switch (motionData.status) {
@ -140,17 +135,11 @@ void MotionTentSubscriber::SubscribeMotionSensor()
TLOGE(WmsLogTag::DMS, "tent motion sensor's already subscribed");
return;
}
sptr<TentMotionEventCallback> callback = new (std::nothrow) TentMotionEventCallback();
if (callback == nullptr) {
TLOGE(WmsLogTag::DMS, "malloc tent motion callback failed");
if (!SubscribeCallback(MOTION_TYPE_TENT, TentMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor subscribe failed");
return;
}
int32_t ret = OHOS::Msdp::SubscribeCallback(OHOS::Msdp::MOTION_TYPE_TENT, callback);
if (ret != 0) {
TLOGE(WmsLogTag::DMS, "SubscribeCallback type:%{public}d failed", OHOS::Msdp::MOTION_TYPE_TENT);
return;
}
motionEventCallback_ = callback;
isMotionSensorSubscribed_ = true;
}
@ -160,15 +149,15 @@ void MotionTentSubscriber::UnsubscribeMotionSensor()
TLOGI(WmsLogTag::DMS, "start");
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)) {
if (!UnsubscribeCallback(MOTION_TYPE_TENT, TentMotionEventCallback)) {
TLOGE(WmsLogTag::DMS, "dms: motion sensor unsubscribe failed");
return;
}
isMotionSensorSubscribed_ = false;
}
void TentMotionEventCallback::OnMotionChanged(const MotionEvent& motionData)
void TentMotionEventCallback(const MotionSensorEvent& motionData)
{
if (motionData.status == MOTION_ACTION_TENT_MODE_ON) {
ScreenTentProperty::HandleSensorEventInput(true);

View File

@ -0,0 +1,90 @@
/*
* 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_sensor_plugin.h"
namespace OHOS {
namespace Rosen {
namespace {
constexpr uint32_t SLEEP_TIME_US = 10000;
}
static void *g_handle = nullptr;
bool LoadMotionSensor(void)
{
if (g_handle != nullptr) {
TLOGW(WmsLogTag::DMS, "motion plugin has already exits.");
return true;
}
int32_t cnt = 0;
int32_t retryTimes = 3;
do {
cnt++;
g_handle = dlopen(PLUGIN_SO_PATH.c_str(), RTLD_LAZY);
TLOGI(WmsLogTag::DMS, "dlopen %{public}s, retry cnt: %{public}d", PLUGIN_SO_PATH.c_str(), cnt);
usleep(SLEEP_TIME_US);
} while (!g_handle && cnt < retryTimes);
return g_handle != nullptr;
}
void UnloadMotionSensor(void)
{
TLOGI(WmsLogTag::DMS, "unload motion plugin.");
if (g_handle != nullptr) {
dlclose(g_handle);
g_handle = nullptr;
}
}
__attribute__((no_sanitize("cfi"))) bool SubscribeCallback(int32_t motionType, OnMotionChangedPtr callback)
{
if (callback == nullptr) {
TLOGE(WmsLogTag::DMS, "callback is nullptr");
return false;
}
if (g_handle == nullptr) {
TLOGE(WmsLogTag::DMS, "g_handle is nullptr");
return false;
}
MotionSubscribeCallbackPtr func = (MotionSubscribeCallbackPtr)(dlsym(g_handle, "MotionSubscribeCallback"));
const char* dlsymError = dlerror();
if (dlsymError) {
TLOGE(WmsLogTag::DMS, "dlsym error: %{public}s", dlsymError);
return false;
}
return func(motionType, callback);
}
__attribute__((no_sanitize("cfi"))) bool UnsubscribeCallback(int32_t motionType, OnMotionChangedPtr callback)
{
if (callback == nullptr) {
TLOGE(WmsLogTag::DMS, "callback is nullptr");
return false;
}
if (g_handle == nullptr) {
TLOGE(WmsLogTag::DMS, "g_handle is nullptr");
return false;
}
MotionUnsubscribeCallbackPtr func =
(MotionUnsubscribeCallbackPtr)(dlsym(g_handle, "MotionUnsubscribeCallback"));
const char* dlsymError = dlerror();
if (dlsymError) {
TLOGE(WmsLogTag::DMS, "dlsym error: %{public}s", dlsymError);
return false;
}
return func(motionType, callback);
}
}
}

View File

@ -23,6 +23,7 @@
#include "session_permission.h"
#include "screen_rotation_property.h"
#include "parameters.h"
#include "fold_screen_controller/super_fold_state_manager.h"
namespace OHOS {
namespace Rosen {
@ -36,6 +37,7 @@ const std::string ARG_DUMP_ALL = "-a";
const std::string ARG_DUMP_FOLD_STATUS = "-f";
constexpr int MOTION_SENSOR_PARAM_SIZE = 2;
constexpr int SUPER_FOLD_STATUS_MAX = 2;
const std::string STATUS_FOLD_HALF = "-z";
const std::string STATUS_EXPAND = "-y";
const std::string STATUS_FOLD = "-p";
@ -52,6 +54,7 @@ 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";
const std::string ARG_SET_SUPER_FOLD_STATUS = "-supertrans";
}
static std::string GetProcessNameByPid(int32_t pid)
@ -670,5 +673,34 @@ void ScreenSessionDumper::SetHoverStatusChange(std::string input)
TLOGI(WmsLogTag::DMS, "SetHoverStatusChange: %{public}d", value);
}
}
void ScreenSessionDumper::SetSuperFoldStatusChange(std::string input)
{
size_t commaPos = input.find_last_of(',');
if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_SUPER_FOLD_STATUS)) {
std::string valueStr = input.substr(commaPos + 1, SUPER_FOLD_STATUS_MAX);
if (valueStr.empty()) {
return;
}
if (valueStr.size() == 1 && !std::isdigit(valueStr[0])) {
return;
}
if (valueStr.size() == SUPER_FOLD_STATUS_MAX && !std::isdigit(valueStr[0])
&& !std::isdigit(valueStr[1])) {
return;
}
int32_t value = std::stoi(valueStr);
if (value <= static_cast<int32_t>(SuperFoldStatusChangeEvents::UNDEFINED) ||
value >= static_cast<int32_t>(SuperFoldStatusChangeEvents::INVALID)) {
TLOGE(WmsLogTag::DMS, "params is invalid: %{public}d", value);
return;
}
SuperFoldStateManager::GetInstance().
HandleSuperFoldStatusChange(static_cast<SuperFoldStatusChangeEvents>(value));
TLOGI(WmsLogTag::DMS, "state: %{public}d, event: %{public}d",
SuperFoldStateManager::GetInstance().GetCurrentStatus(), value);
}
}
} // Rosen
} // OHOS

View File

@ -55,6 +55,7 @@
#include "connection/screen_cast_connection.h"
#include "publish/screen_session_publish.h"
#include "dms_xcollie.h"
#include "screen_sensor_plugin.h"
namespace OHOS::Rosen {
namespace {
@ -88,6 +89,7 @@ static const int32_t AUTO_ROTATE_OFF = 0;
static const int NOTIFY_EVENT_FOR_DUAL_FAILED = 0;
static const int NOTIFY_EVENT_FOR_DUAL_SUCESS = 1;
static const int NO_NEED_NOTIFY_EVENT_FOR_DUAL = 2;
static bool g_isPcDevice = false;
const unsigned int XCOLLIE_TIMEOUT_10S = 10;
const unsigned int XCOLLIE_TIMEOUT_5S = 5;
constexpr int32_t CAST_WIRED_PROJECTION_START = 1005;
@ -99,6 +101,10 @@ constexpr int32_t IRREGULAR_REFRESH_RATE_SKIP_THRETHOLD = 10;
constexpr uint32_t SCREEN_MAIN_IN_DATA = 0;
constexpr uint32_t SCREEN_MIRROR_IN_DATA = 1;
constexpr uint32_t SCREEN_EXTEND_IN_DATA = 2;
constexpr uint32_t NUMBER_OF_PHYSICAL_SCREEN = 2;
constexpr bool ADD_VOTE = true;
constexpr bool REMOVE_VOTE = false;
constexpr uint32_t OLED_60_HZ = 60;
const int32_t ROTATE_POLICY = system::GetIntParameter("const.window.device.rotate_policy", 0);
constexpr int32_t FOLDABLE_DEVICE { 2 };
@ -223,11 +229,13 @@ void ScreenSessionManager::FoldScreenPowerInit()
std::string fullTpChange = "0";
std::string mainTpChange = "1";
#endif
if (rsInterface_.GetActiveScreenId() == SCREEN_ID_FULL) {
if (!foldScreenController_) {
TLOGE(WmsLogTag::DMS, "foldScreenController_ is nullptr");
return;
}
ScreenId currentScreenId = foldScreenController_->GetCurrentScreenId();
if (currentScreenId == SCREEN_ID_FULL) {
TLOGI(WmsLogTag::DMS, "ScreenSessionManager Fold Screen Power Full animation Init 1.");
#ifdef TP_FEATURE_ENABLE
rsInterface_.SetTpFeatureConfig(tpType, mainTpChange.c_str());
#endif
rsInterface_.SetScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
rsInterface_.SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
std::this_thread::sleep_for(std::chrono::milliseconds(timeStamp));
@ -240,11 +248,8 @@ void ScreenSessionManager::FoldScreenPowerInit()
foldScreenController_->AddOrRemoveDisplayNodeToTree(SCREEN_ID_MAIN, REMOVE_DISPLAY_MODE);
}
rsInterface_.SetScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON);
} else if (rsInterface_.GetActiveScreenId() == SCREEN_ID_MAIN) {
} else if (currentScreenId == SCREEN_ID_MAIN) {
TLOGI(WmsLogTag::DMS, "ScreenSessionManager Fold Screen Power Main animation Init 3.");
#ifdef TP_FEATURE_ENABLE
rsInterface_.SetTpFeatureConfig(tpType, fullTpChange.c_str());
#endif
rsInterface_.SetScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
rsInterface_.SetScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON);
std::this_thread::sleep_for(std::chrono::milliseconds(timeStamp));
@ -300,6 +305,15 @@ void ScreenSessionManager::Init()
ScreenSceneConfig::SetCutoutSvgPath(GetDefaultScreenId(), defaultDisplayCutoutPath);
}
if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "none") {
g_isPcDevice = true;
}
if (!LoadMotionSensor()) {
screenEventTracker_.RecordEvent("Dms load motion plugin failed.");
TLOGW(WmsLogTag::DMS, "load motion plugin failed.");
}
RegisterScreenChangeListener();
if (!ScreenSceneConfig::IsSupportRotateWithSensor()) {
TLOGI(WmsLogTag::DMS, "Current type not support SetSensorSubscriptionEnabled.");
@ -839,6 +853,9 @@ void ScreenSessionManager::HandleScreenDisconnectEvent(sptr<ScreenSession> scree
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
screenSessionMap_.erase(screenId);
}
if (g_isPcDevice) {
SetMultiScreenFrameControl();
}
if (!(screenId == SCREEN_ID_MAIN && isCoordinationFlag_ == true)) {
std::lock_guard<std::recursive_mutex> lock_phy(phyScreenPropMapMutex_);
phyScreenPropMap_.erase(screenId);
@ -861,6 +878,40 @@ void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate)
return;
}
bool ScreenSessionManager::IsPhysicalScreenAndInUse(sptr<ScreenSession> screenSession) const
{
if (!screenSession) {
return false;
}
if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL &&
screenSession->GetIsCurrentInUse()) {
return true;
}
return false;
}
void ScreenSessionManager::SetMultiScreenFrameControl(void)
{
uint32_t count = 0;
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
for (auto sessionIt : screenSessionMap_) {
if (IsPhysicalScreenAndInUse(sessionIt.second)) {
count++;
}
}
}
if (count >= NUMBER_OF_PHYSICAL_SCREEN) {
TLOGI(WmsLogTag::DMS, "MultiScreen control frame rate to 60");
EventInfo event = { "VOTER_MUTIPHSICALSCREEN", ADD_VOTE, OLED_60_HZ, OLED_60_HZ };
rsInterface_.NotifyRefreshRateEvent(event);
} else {
TLOGI(WmsLogTag::DMS, "Disabling frame rate control");
EventInfo event = { "VOTER_MUTIPHSICALSCREEN", REMOVE_VOTE };
rsInterface_.NotifyRefreshRateEvent(event);
}
}
sptr<ScreenSession> ScreenSessionManager::GetScreenSession(ScreenId screenId) const
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
@ -1422,6 +1473,21 @@ void ScreenSessionManager::CreateScreenProperty(ScreenId screenId, ScreenPropert
property.SetPhyBounds(screenBounds);
property.SetBounds(screenBounds);
property.SetAvailableArea({0, 0, screenMode.GetScreenWidth(), screenMode.GetScreenHeight()});
if (isDensityDpiLoad_) {
if (screenId == SCREEN_ID_MAIN) {
TLOGI(WmsLogTag::DMS, "subDensityDpi_ = %{public}f", subDensityDpi_);
property.SetVirtualPixelRatio(subDensityDpi_);
property.SetDefaultDensity(subDensityDpi_);
property.SetDensityInCurResolution(subDensityDpi_);
} else {
TLOGI(WmsLogTag::DMS, "densityDpi_ = %{public}f", densityDpi_);
property.SetVirtualPixelRatio(densityDpi_);
property.SetDefaultDensity(densityDpi_);
property.SetDensityInCurResolution(densityDpi_);
}
} else {
property.UpdateVirtualPixelRatio(screenBounds);
}
property.SetRefreshRate(screenRefreshRate);
property.SetDefaultDeviceRotationOffset(defaultDeviceRotationOffset_);
@ -1433,32 +1499,27 @@ void ScreenSessionManager::CreateScreenProperty(ScreenId screenId, ScreenPropert
property.CalcDefaultDisplayOrientation();
}
void ScreenSessionManager::InitScreenDensity(sptr<ScreenSession> session, const ScreenProperty& property)
void ScreenSessionManager::InitExtendScreenDensity(sptr<ScreenSession> session, ScreenProperty property)
{
if (session->GetScreenProperty().GetScreenType() == ScreenType::REAL && !session->isInternal_) {
// 表示拓展屏
float extendDensity = CalcDefaultExtendScreenDensity(property);
TLOGI(WmsLogTag::DMS, "extendDensity = %{public}f", extendDensity);
session->SetVirtualPixelRatio(extendDensity);
session->SetDefaultDensity(extendDensity);
session->SetDensityInCurResolution(extendDensity);
if (session->GetScreenProperty().GetScreenType() != ScreenType::REAL || session->isInternal_) {
// 表示非拓展屏
TLOGI(WmsLogTag::DMS, "Not expandable screen, no need to set dpi");
return;
}
if (isDensityDpiLoad_) {
if (session->GetScreenId() == SCREEN_ID_MAIN) {
TLOGI(WmsLogTag::DMS, "subDensityDpi_ = %{public}f", subDensityDpi_);
session->SetVirtualPixelRatio(subDensityDpi_);
session->SetDefaultDensity(subDensityDpi_);
session->SetDensityInCurResolution(subDensityDpi_);
} else {
TLOGI(WmsLogTag::DMS, "densityDpi_ = %{public}f", densityDpi_);
session->SetVirtualPixelRatio(densityDpi_);
session->SetDefaultDensity(densityDpi_);
session->SetDensityInCurResolution(densityDpi_);
}
} else {
session->UpdateVirtualPixelRatio(property.GetBounds());
float extendDensity = CalcDefaultExtendScreenDensity(property);
TLOGI(WmsLogTag::DMS, "extendDensity = %{public}f", extendDensity);
session->SetVirtualPixelRatio(extendDensity);
session->SetDefaultDensity(extendDensity);
session->SetDensityInCurResolution(extendDensity);
ScreenId screenId = session->GetScreenId();
property.SetVirtualPixelRatio(extendDensity);
property.SetDefaultDensity(extendDensity);
property.SetDensityInCurResolution(extendDensity);
{
std::lock_guard<std::recursive_mutex> lock_phy(phyScreenPropMapMutex_);
phyScreenPropMap_[screenId] = property;
}
return;
}
float ScreenSessionManager::CalcDefaultExtendScreenDensity(const ScreenProperty& property)
@ -1506,17 +1567,8 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
phyScreenPropMap_[screenId] = property;
}
if (foldScreenController_ != nullptr) {
// sensor may earlier than screen connect, when physical screen property changed, update
foldScreenController_->UpdateForPhyScreenPropertyChange();
/* folder screen outer screenId is 5 */
if (screenId == SCREEN_ID_MAIN) {
SetPostureAndHallSensorEnabled();
ScreenSensorConnector::SubscribeTentSensor();
if (!FoldScreenStateInternel::IsDualDisplayFoldDevice() && isCoordinationFlag_ == false) {
return nullptr;
}
}
if (HandleFoldScreenSessionCreate(screenId) == false) {
return nullptr;
}
sptr<ScreenSession> session = GetScreenSessionInner(screenId, property);
@ -1525,21 +1577,42 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
return session;
}
session->RegisterScreenChangeListener(this);
InitExtendScreenDensity(session, property);
InitAbstractScreenModesInfo(session);
session->groupSmsId_ = 1;
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
screenSessionMap_[screenId] = session;
}
if (g_isPcDevice) {
SetMultiScreenFrameControl();
}
screenEventTracker_.RecordEvent("create screen session success.");
SetHdrFormats(screenId, session);
SetColorSpaces(screenId, session);
InitScreenDensity(session, property);
RegisterRefreshRateChangeListener();
TLOGI(WmsLogTag::DMS, "CreateScreenSession success. ScreenId: %{public}" PRIu64 "", screenId);
return session;
}
bool ScreenSessionManager::HandleFoldScreenSessionCreate(ScreenId screenId)
{
if (foldScreenController_ != nullptr) {
// sensor may earlier than screen connect, when physical screen property changed, update
foldScreenController_->UpdateForPhyScreenPropertyChange();
/* folder screen outer screenId is 5 */
if (screenId == SCREEN_ID_MAIN) {
SetPostureAndHallSensorEnabled();
ScreenSensorConnector::SubscribeTentSensor();
if (!FoldScreenStateInternel::IsDualDisplayFoldDevice() && isCoordinationFlag_ == false) {
return false;
}
}
}
return true;
}
void ScreenSessionManager::SetHdrFormats(ScreenId screenId, sptr<ScreenSession>& session)
{
TLOGI(WmsLogTag::DMS, "SetHdrFormats %{public}" PRIu64, screenId);
@ -6013,6 +6086,11 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenCapture(const Ca
*errorCode = DmErrorCode::DM_ERROR_NO_PERMISSION;
return nullptr;
}
if (!ScreenSceneConfig::IsSupportCapture()) {
TLOGW(WmsLogTag::DMS, "device not support capture.");
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
return nullptr;
}
if (!Permission::CheckCallingPermission(CUSTOM_SCREEN_CAPTURE_PERMISSION) && !SessionPermission::IsShellCall()) {
TLOGE(WmsLogTag::DMS, "Permission Denied! clientName: %{public}s, pid: %{public}d.",
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingRealPid());
@ -6043,4 +6121,41 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenCapture(const Ca
NotifyCaptureStatusChanged();
return res;
}
} // namespace OHOS::Rosen
sptr<DisplayInfo> ScreenSessionManager::GetPrimaryDisplayInfo()
{
DmsXcollie dmsXcollie("DMS:GetPrimaryDisplayInfo", XCOLLIE_TIMEOUT_10S);
sptr<ScreenSession> screenSession = nullptr;
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
for (auto sessionIt : screenSessionMap_) {
screenSession = sessionIt.second;
if (screenSession == nullptr) {
TLOGE(WmsLogTag::DMS, "screenSession is nullptr!");
continue;
}
if (!screenSession->GetIsExtend()) {
TLOGE(WmsLogTag::DMS, "find primary %{public}" PRIu64, screenSession->screenId_);
break;
}
}
}
if (screenSession == nullptr) {
TLOGW(WmsLogTag::DMS, "get extend screen faild use default!");
screenSession = GetScreenSession(GetDefaultScreenId());
}
if (screenSession) {
std::lock_guard<std::recursive_mutex> lock_info(displayInfoMutex_);
sptr<DisplayInfo> displayInfo = screenSession->ConvertToDisplayInfo();
if (displayInfo == nullptr) {
TLOGI(WmsLogTag::DMS, "convert display error.");
return nullptr;
}
displayInfo = HookDisplayInfoByUid(displayInfo, screenSession);
return displayInfo;
} else {
TLOGE(WmsLogTag::DMS, "failed");
return nullptr;
}
}
} // namespace OHOS::Rosen

View File

@ -3229,4 +3229,31 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetScreenCapture(con
}
return pixelMap;
}
sptr<DisplayInfo> ScreenSessionManagerProxy::GetPrimaryDisplayInfo()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("GetPrimaryDisplayInfo: remote is nullptr");
return nullptr;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return nullptr;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_INFO),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return nullptr;
}
sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
if (info == nullptr) {
WLOGFE("get display info.");
}
return info;
}
} // namespace OHOS::Rosen

View File

@ -868,6 +868,11 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
ProcGetScreenCapture(data, reply);
break;
}
case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_INFO: {
auto info = GetPrimaryDisplayInfo();
reply.WriteParcelable(info);
break;
}
default:
WLOGFW("unknown transaction code");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);

View File

@ -23,7 +23,6 @@
#include <key_event.h>
#include <pointer_event.h>
#include "anr_handler.h"
#include "window_manager_hilog.h"
#include "session_permission.h"

View File

@ -63,7 +63,7 @@ private:
void NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>& callingSession, const WSRect& rect,
const WSRect& occupiedArea, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void RaiseCallingSession(const WSRect& keyboardPanelRect,
void RaiseCallingSession(const WSRect& keyboardPanelRect, bool needCheckVisible,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void RestoreCallingSession(const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void UpdateKeyboardAvoidArea();

View File

@ -18,6 +18,7 @@
#include "session/host/include/session.h"
#include "session/host/include/move_drag_controller.h"
#include "vsync_station.h"
#include "wm_common.h"
namespace OHOS::PowerMgr {
@ -89,6 +90,7 @@ using NotifyMainWindowTopmostChangeFunc = std::function<void(bool isTopmost)>;
using NotifyPrivacyModeChangeFunc = std::function<void(uint32_t isPrivacyMode)>;
using UpdateGestureBackEnabledCallback = std::function<void(int32_t persistentId)>;
using NotifyVisibleChangeFunc = std::function<void(int32_t persistentId)>;
using IsLastFrameLayoutFinishedFunc = std::function<WSError(bool& isLayoutFinished)>;
class SceneSession : public Session {
public:
@ -126,12 +128,10 @@ public:
NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_;
NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
NotifyShowWhenLockedFunc OnShowWhenLocked_;
NotifyReqOrientationChangeFunc OnRequestedOrientationChange_;
NotifyRaiseAboveTargetFunc onRaiseAboveTarget_;
NotifyForceHideChangeFunc OnForceHideChange_;
NotifyTouchOutsideFunc OnTouchOutside_;
ClearCallbackMapFunc clearCallbackFunc_;
NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_;
NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_;
NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_;
};
@ -160,6 +160,7 @@ public:
const std::string& identityToken = "") override;
WSError Background(bool isFromClient = false, const std::string& identityToken = "") override;
virtual void SyncScenePanelGlobalPosition(bool needSync) {}
void SetNeedSyncSessionRect(bool needSync);
WSError BackgroundTask(const bool isSaveSnapshot = true);
WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override;
WSError DisconnectTask(bool isFromClient = false, bool isSaveSnapshot = true);
@ -194,6 +195,8 @@ public:
WSError UpdateClientRect(const WSRect& rect) override;
WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> info, bool visible) override;
WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> info) override;
bool DisallowActivationFromPendingBackground(bool isPcOrPadEnableActivation, bool isFoundationCall,
bool canStartAbilityFromBackground);
WSError TerminateSession(const sptr<AAFwk::SessionInfo> info) override;
WSError NotifySessionException(
const sptr<AAFwk::SessionInfo> info, bool needRemoveSession = false) override;
@ -230,6 +233,7 @@ public:
void SetAutoStartPiPStatusChangeCallback(const NotifyAutoStartPiPStatusChangeFunc& func);
WSError SetPipActionEvent(const std::string& action, int32_t status);
WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status);
void RegisterProcessPrepareClosePiPCallback(NotifyPrepareClosePiPSessionFunc&& callback);
void RequestHideKeyboard(bool isAppColdStart = false);
WSError ProcessPointDownSession(int32_t posX, int32_t posY) override;
@ -278,12 +282,14 @@ public:
WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) override;
WSError SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty);
void SetIsStatusBarVisible(bool isVisible);
WSError SetIsStatusBarVisibleInner(bool isVisible);
WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
void UpdateRotationAvoidArea();
bool CheckGetAvoidAreaAvailable(AvoidAreaType type) override;
bool GetIsDisplayStatusBarTemporarily() const;
void SetIsDisplayStatusBarTemporarily(bool isTemporary);
NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_;
void SetIsLastFrameLayoutFinishedFunc(IsLastFrameLayoutFinishedFunc&& func);
void SetAbilitySessionInfo(std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo);
void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func);
@ -341,6 +347,7 @@ public:
bool IsFloatingWindowAppType() const;
bool IsNeedDefaultAnimation() const;
bool IsDirtyWindow();
bool IsDirtyDragWindow();
void SetSystemTouchable(bool touchable) override;
bool IsVisibleForAccessibility() const;
void SetStartingWindowExitAnimationFlag(bool enable);
@ -368,6 +375,11 @@ public:
void RegisterForceSplitListener(const NotifyForceSplitFunc& func);
void SetUpdatePrivateStateAndNotifyFunc(const UpdatePrivateStateAndNotifyFunc& func);
/*
* Window Rotation
*/
void RegisterRequestedOrientationChangeCallback(NotifyReqOrientationChangeFunc&& callback);
/*
* Window Visibility
*/
@ -406,8 +418,6 @@ public:
std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_;
static const wptr<SceneSession> GetEnterWindow();
static void ClearEnterWindow();
static MaximizeMode maximizeMode_;
static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY);
static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area);
@ -463,7 +473,7 @@ public:
* Window ZOrder: PC
*/
void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }
void PcUpdateZOrderAndDirty(const uint32_t zOrder);
void UpdatePCZOrderAndMarkDirty(const uint32_t zOrder);
void SetPrivacyModeChangeNotifyFunc(const NotifyPrivacyModeChangeFunc& func);
@ -472,6 +482,14 @@ public:
*/
WSError SetSplitButtonVisible(bool isVisible);
void SetRequestNextVsyncFunc(const RequestVsyncFunc& func);
void OnNextVsyncDragReceived();
/*
* Window Layout
*/
void ResetSizeChangeReasonIfDirty();
/*
* Gesture Back
*/
@ -502,6 +520,10 @@ protected:
bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason);
bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY);
bool UpdateZOrderInner(uint32_t zOrder);
/**
* Window Immersive
*/
virtual void NotifyClientToUpdateAvoidArea();
bool PipelineNeedNotifyClientToUpdateAvoidArea(uint32_t dirty) const;
@ -516,6 +538,10 @@ protected:
sptr<SceneSession> keyboardSession_ = nullptr;
NotifyKeyboardGravityChangeFunc keyboardGravityChangeFunc_;
NotifyKeyboardLayoutAdjustFunc adjustKeyboardLayoutFunc_;
/**
* Window Immersive
*/
NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_;
/*
@ -523,16 +549,25 @@ protected:
*/
NotifyMainWindowTopmostChangeFunc mainWindowTopmostChangeFunc_;
/*
* PiP Window
*/
NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_;
private:
void NotifyAccessibilityVisibilityChange();
void CalculateCombinedExtWindowFlags();
void HandleStyleEvent(MMI::WindowArea area) override;
WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY);
/**
* Window Immersive
*/
void CalculateAvoidAreaRect(WSRect& rect, WSRect& avoidRect, AvoidArea& avoidArea) const;
void GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea);
void GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea);
void GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea);
void CalculateCombinedExtWindowFlags();
void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) const;
void HandleStyleEvent(MMI::WindowArea area) override;
WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY);
/*
* Window Lifecycle
@ -578,6 +613,7 @@ private:
bool IsMovable();
void HandleCastScreenConnection(SessionInfo& info, sptr<SceneSession> session);
void UpdateSessionRectInner(const WSRect& rect, const SizeChangeReason reason);
void UpdateRectForDrag(WSRect& rect);
WMError HandleUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
WSPropertyChangeAction action);
WMError HandleActionUpdateTurnScreenOn(const sptr<WindowSessionProperty>& property,
@ -652,8 +688,6 @@ private:
NotifyForceSplitFunc forceSplitFunc_;
UpdatePrivateStateAndNotifyFunc updatePrivateStateAndNotifyFunc_;
NotifyPrivacyModeChangeFunc privacyModeChangeNotifyFunc_;
static wptr<SceneSession> enterSession_;
static std::mutex enterSessionMutex_;
int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
mutable std::mutex sessionChangeCbMutex_;
WSRect lastSafeRect = { 0, 0, 0, 0 };
@ -664,7 +698,6 @@ private:
SessionEventParam sessionEventParam_ = { 0, 0, 0, 0 };
std::atomic_bool isStartMoving_ { false };
std::atomic_bool isVisibleForAccessibility_ { true };
std::atomic_bool isDisplayStatusBarTemporarily_ { false };
bool isSystemSpecificSession_ { false };
std::atomic_bool shouldHideNonSecureWindows_ { false };
std::shared_mutex combinedExtWindowFlagsMutex_;
@ -692,7 +725,6 @@ private:
bool isScreenAngleMismatch_ = false;
uint32_t targetScreenWidth_ = 0;
uint32_t targetScreenHeight_ = 0;
bool isStatusBarVisible_ = true;
// WMSPipeline-related: only accessed on SSM thread
PostProcessFocusState postProcessFocusState_;
@ -728,6 +760,18 @@ private:
* Window Visibility
*/
NotifyVisibleChangeFunc notifyVisibleChangeFunc_;
/*
* Window Rotation
*/
NotifyReqOrientationChangeFunc onRequestedOrientationChange_;
/**
* Window Immersive
*/
std::atomic_bool isDisplayStatusBarTemporarily_ { false };
bool isStatusBarVisible_ = true;
IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_;
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H

View File

@ -31,6 +31,7 @@
#include "occupied_area_change_info.h"
#include "window_visibility_info.h"
#include "pattern_detach_callback_interface.h"
#include "vsync_station.h"
namespace OHOS::MMI {
class PointerEvent;
@ -47,6 +48,7 @@ namespace OHOS::Rosen {
class RSSurfaceNode;
class RSTransaction;
class RSSyncTransactionController;
class Session;
using NotifySessionRectChangeFunc = std::function<void(const WSRect& rect,
const SizeChangeReason reason, const DisplayId displayId)>;
using NotifyPendingSessionActivationFunc = std::function<void(SessionInfo& info)>;
@ -87,6 +89,7 @@ using NotifyFrameLayoutFinishFunc = std::function<void()>;
using VisibilityChangedDetectFunc = std::function<void(const int32_t pid, const bool isVisible,
const bool newIsVisible)>;
using AcquireRotateAnimationConfigFunc = std::function<void(RotateAnimationConfig& config)>;
using RequestVsyncFunc = std::function<void(std::shared_ptr<VsyncCallback>& callback)>;
class ILifecycleListener {
public:
@ -340,7 +343,7 @@ public:
void SetContextTransparentFunc(const NotifyContextTransparentFunc& func);
void NotifyContextTransparent();
bool NeedCheckContextTransparent() const;
/*
* Window Rotate Animation
*/
@ -355,7 +358,7 @@ public:
bool GetFocusable() const;
void SetFocusedOnShow(bool focusedOnShow); // Used when creating ability
bool IsFocusedOnShow() const;
WSError SetFocusableOnShow(bool isFocusableOnShow) override; // Used when showing window
WSError SetFocusableOnShow(bool isFocusableOnShow); // Used when showing window
bool IsFocusableOnShow() const;
virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB
bool GetSystemFocusable() const;
@ -469,6 +472,8 @@ public:
// ForegroundInteractiveStatus interface only for event use
bool GetForegroundInteractiveStatus() const;
virtual void SetForegroundInteractiveStatus(bool interactive);
bool GetIsPendingToBackgroundState() const;
void SetIsPendingToBackgroundState(bool isPendingToBackgroundState);
void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED);
bool GetAttachState() const;
void RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback);
@ -495,6 +500,7 @@ public:
void SetMainSessionUIStateDirty(bool dirty);
bool GetUIStateDirty() const;
void ResetDirtyFlags();
void ResetDragDirtyFlags();
static bool IsScbCoreEnabled();
static void SetScbCoreEnabled(bool enabled);
bool IsVisible() const;
@ -622,6 +628,8 @@ protected:
*/
AcquireRotateAnimationConfigFunc acquireRotateAnimationConfigFunc_;
RequestVsyncFunc requestNextVsyncFunc_;
SystemSessionConfig systemConfig_;
bool needSnapshot_ = false;
float snapshotScale_ = 0.5;
@ -658,7 +666,10 @@ protected:
mutable std::mutex pointerEventMutex_;
mutable std::shared_mutex keyEventMutex_;
bool rectChangeListenerRegistered_ = false;
uint32_t dirtyFlags_ = 0; // only accessed on SSM thread
// only accessed on SSM thread
uint32_t dirtyFlags_ = 0;
bool isNeedSyncSessionRect_ { true }; // where need sync to session rect, currently use in split drag
bool isStarting_ = false; // when start app, session is starting state until foreground
std::atomic_bool mainUIStateDirty_ = false;
static bool isScbCoreEnabled_;
@ -689,6 +700,8 @@ private:
void InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>& property);
void InitSystemSessionDragEnable(const sptr<WindowSessionProperty>& property);
void UpdateGravityWhenUpdateWindowMode(WindowMode mode);
template<typename T1, typename T2, typename Ret>
using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type;
template<typename T>
@ -745,7 +758,8 @@ private:
bool systemTouchable_ { true };
std::atomic<bool> rectChangeBySystem_ { false };
std::atomic_bool foregroundInteractiveStatus_ { true };
std::atomic<bool> isAttach_{ false };
std::atomic<bool> isAttach_ { false };
std::atomic<bool> isPendingToBackgroundState_ { false };
sptr<IPatternDetachCallback> detachCallback_ = nullptr;
std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_;

View File

@ -273,14 +273,6 @@ public:
*/
virtual WSError RequestFocus(bool isFocused) { return WSError::WS_OK; }
/**
* @brief Set focusable of window when show.
*
* @param isFocusableOnShow True means window can get focus when it shows to foreground, false means the opposite.
* @return Returns WSError::WS_OK if called success, otherwise failed.
*/
virtual WSError SetFocusableOnShow(bool isFocusableOnShow) { return WSError::WS_OK; }
virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {};
/**
* @brief Callback for session modal type changes.

View File

@ -64,7 +64,6 @@ enum class SessionInterfaceCode {
TRANS_ID_FRAME_LAYOUT_FINISH,
TRANS_ID_SET_SYSTEM_DRAG_ENABLE,
TRANS_ID_REQUEST_FOCUS,
TRANS_ID_SET_FOCUSABLE_ON_SHOW,
TRANS_ID_GET_START_MOVE_FLAG,
TRANS_ID_GET_ALL_AVOID_AREAS,
TRANS_ID_UPDATE_CLIENT_RECT,

View File

@ -98,7 +98,6 @@ public:
WSError SetDialogSessionBackGestureEnabled(bool isEnabled) override;
WMError SetSystemWindowEnableDrag(bool enableDrag) override;
WSError RequestFocus(bool isFocused) override;
WSError SetFocusableOnShow(bool isFocusableOnShow) override;
void NotifyExtensionEventAsync(uint32_t notifyEvent) override;
WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) override;

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