aafwk->ability_runtime

Signed-off-by: zhoushicheng <zhoushicheng2@huawei.com>
Change-Id: I5c2a4daf596f2e5af375640d40499690e3bca0cb
This commit is contained in:
zhoushicheng
2022-06-27 11:01:36 +08:00
94 changed files with 1087 additions and 339 deletions
+2
View File
@@ -89,6 +89,8 @@ public:
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
virtual sptr<ScreenInfo> GetScreenInfo(ScreenId screenId);
virtual bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio);
virtual void SetScreenRotationLocked(bool isLocked);
virtual bool IsScreenRotationLocked();
// colorspace, gamut
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
+14
View File
@@ -125,6 +125,20 @@ DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Su
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
}
void ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
{
INIT_PROXY_CHECK_RETURN();
WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked");
displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
}
bool ScreenManagerAdapter::IsScreenRotationLocked()
{
INIT_PROXY_CHECK_RETURN(false);
WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked");
return displayManagerServiceProxy_->IsScreenRotationLocked();
}
bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
+10
View File
@@ -435,6 +435,16 @@ ScreenPowerState ScreenManager::GetScreenPower(ScreenId dmsScreenId)
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenPower(dmsScreenId);
}
void ScreenManager::SetScreenRotationLocked(bool isLocked)
{
SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
}
bool ScreenManager::IsScreenRotationLocked()
{
return SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked();
}
void ScreenManager::Impl::NotifyScreenConnect(sptr<ScreenInfo> info)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
@@ -743,6 +743,20 @@ HWTEST_F(ScreenManagerTest, ScreenManager17, Function | MediumTest | Level2)
ASSERT_NE(SCREEN_ID_INVALID, virtualScreenId);
}
}
/**
* @tc.name: ScreenManager18
* @tc.desc: Set screen rotation lock, and check whether screen rotation lock is Locked.
* @tc.type: FUNC
*/
HWTEST_F(ScreenManagerTest, ScreenManager18, Function | SmallTest | Level1)
{
bool originalLockStatus = ScreenManager::GetInstance().IsScreenRotationLocked();
ScreenManager::GetInstance().SetScreenRotationLocked(!originalLockStatus);
bool modifiedLockedStatus = ScreenManager::GetInstance().IsScreenRotationLocked();
ScreenManager::GetInstance().SetScreenRotationLocked(originalLockStatus);
ASSERT_EQ(!originalLockStatus, modifiedLockedStatus);
}
}
} // namespace Rosen
} // namespace OHOS
+4 -4
View File
@@ -51,11 +51,11 @@ void ScreenManagerTest::TearDown()
namespace {
/**
* @tc.name: CreateAndDestory01
* @tc.name: CreateAndDestroy01
* @tc.desc: CreateVirtualScreen with invalid option and return invalid screen id
* @tc.type: FUNC
*/
HWTEST_F(ScreenManagerTest, CreateAndDestory01, Function | SmallTest | Level1)
HWTEST_F(ScreenManagerTest, CreateAndDestroy01, Function | SmallTest | Level1)
{
VirtualScreenOption wrongOption = {defaultName_, defaultWidth_, defaultHeight_,
defaultDensity_, nullptr, defaultFlags_};
@@ -69,11 +69,11 @@ HWTEST_F(ScreenManagerTest, CreateAndDestory01, Function | SmallTest | Level1)
}
/**
* @tc.name: CreateAndDestory02
* @tc.name: CreateAndDestroy02
* @tc.desc: CreateVirtualScreen with valid option and return valid screen id
* @tc.type: FUNC
*/
HWTEST_F(ScreenManagerTest, CreateAndDestory02, Function | SmallTest | Level1)
HWTEST_F(ScreenManagerTest, CreateAndDestroy02, Function | SmallTest | Level1)
{
ScreenManagerUtils utils;
ASSERT_TRUE(utils.CreateSurface());
@@ -71,6 +71,8 @@ public:
TRANS_ID_SCREEN_GET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_COLOR_TRANSFORM,
TRANS_ID_IS_SCREEN_ROTATION_LOCKED,
TRANS_ID_SET_SCREEN_ROTATION_LOCKED,
};
virtual sptr<DisplayInfo> GetDefaultDisplayInfo() = 0;
@@ -83,6 +85,8 @@ public:
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) = 0;
virtual bool SetOrientation(ScreenId screenId, Orientation orientation) = 0;
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) = 0;
virtual void SetScreenRotationLocked(bool isLocked) = 0;
virtual bool IsScreenRotationLocked() = 0;
// colorspace, gamut
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) = 0;
+2
View File
@@ -41,6 +41,8 @@ public:
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
bool SetOrientation(ScreenId screenId, Orientation orientation) override;
std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) override;
bool IsScreenRotationLocked() override;
void SetScreenRotationLocked(bool isLocked) override;
// colorspace, gamut
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) override;
@@ -50,6 +50,8 @@ public:
const sptr<IRemoteObject>& displayManagerAgent) override;
DMError DestroyVirtualScreen(ScreenId screenId) override;
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
bool IsScreenRotationLocked() override;
void SetScreenRotationLocked(bool isLocked) override;
sptr<DisplayInfo> GetDefaultDisplayInfo() override;
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
@@ -57,6 +59,7 @@ public:
bool SetOrientation(ScreenId screenId, Orientation orientation) override;
bool SetOrientationFromWindow(ScreenId screenId, Orientation orientation);
bool SetRotationFromWindow(ScreenId screenId, Rotation targetRotation);
void SetGravitySensorSubscriptionEnabled();
std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) override;
ScreenId GetRSScreenId(DisplayId displayId) const;
@@ -118,6 +121,7 @@ private:
sptr<DisplayDumper> displayDumper_;
static float customVirtualPixelRatio_;
std::map<ScreenId, uint32_t> accessTokenIdMaps_;
bool isAutoRotationOpen_;
};
} // namespace OHOS::Rosen
@@ -45,6 +45,7 @@ public:
void RegisterDisplayChangeListener(sptr<IDisplayChangeListener> listener);
bool SetOrientationFromWindow(DisplayId displayId, Orientation orientation);
bool SetRotationFromWindow(DisplayId displayId, Rotation targetRotation);
void SetGravitySensorSubscriptionEnabled();
void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation);
};
} // namespace OHOS::Rosen
+1 -1
View File
@@ -108,7 +108,7 @@ std::shared_ptr<Media::PixelMap> AbstractDisplayController::GetScreenSnapshot(Di
{
sptr<AbstractDisplay> abstractDisplay = GetAbstractDisplay(displayId);
if (abstractDisplay == nullptr) {
WLOGFE("GetScreenSnapshot: GetAbstarctDisplay failed");
WLOGFE("GetScreenSnapshot: GetAbstractDisplay failed");
return nullptr;
}
ScreenId dmsScreenId = abstractDisplay->GetAbstractScreenId();
+1 -1
View File
@@ -243,7 +243,7 @@ Rotation AbstractScreen::CalcRotation(Orientation orientation) const
if (info == nullptr) {
return Rotation::ROTATION_0;
}
// virtical: phone(Plugin screen); horizontal: pad & external screen
// vertical: phone(Plugin screen); horizontal: pad & external screen
bool isVerticalScreen = info->width_ < info->height_;
switch (orientation) {
case Orientation::UNSPECIFIED: {
+2 -2
View File
@@ -60,7 +60,7 @@ void AbstractScreenController::RegisterRsScreenConnectionChangeListener()
auto task = [this] {
RegisterRsScreenConnectionChangeListener();
};
// posk task after 50 ms.
// post task after 50 ms.
controllerHandler_->PostTask(task, 50, AppExecFwk::EventQueue::Priority::HIGH);
}
bool callbackRegister = DisplayManagerAgentController::GetInstance().SetRemoveAgentCallback(
@@ -642,7 +642,7 @@ bool AbstractScreenController::SetRotation(ScreenId screenId, Rotation rotationA
{
auto screen = GetAbstractScreen(screenId);
if (rotationAfter != screen->rotation_) {
WLOGI("set orientation. roatiton %{public}u", rotationAfter);
WLOGI("set orientation. rotation %{public}u", rotationAfter);
ScreenId rsScreenId;
if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) {
WLOGE("Convert to RsScreenId fail. screenId: %{public}" PRIu64"", screenId);
+49
View File
@@ -1005,4 +1005,53 @@ bool DisplayManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualP
}
return reply.ReadBool();
}
bool DisplayManagerProxy::IsScreenRotationLocked()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("IsScreenRotationLocked: remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("IsScreenRotationLocked: WriteInterfaceToken failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED),
data, reply, option) != ERR_NONE) {
WLOGFW("IsScreenRotationLocked: SendRequest failed");
return false;
}
bool isLocked = reply.ReadBool();
return isLocked;
}
void DisplayManagerProxy::SetScreenRotationLocked(bool isLocked)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("SetScreenRotationLocked: remote is null");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("SetScreenRotationLocked: WriteInterfaceToken failed");
return;
}
if (!data.WriteBool(isLocked)) {
WLOGFE("SetScreenRotationLocked: write isLocked failed");
return;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED),
data, reply, option) != ERR_NONE) {
WLOGFE("SetScreenRotationLocked: SendRequest failed");
return;
}
}
} // namespace OHOS::Rosen
+24 -2
View File
@@ -24,6 +24,7 @@
#include "display_manager_config.h"
#include "dm_common.h"
#include "permission.h"
#include "parameters.h"
#include "screen_rotation_controller.h"
#include "transaction/rs_interfaces.h"
#include "window_manager_hilog.h"
@@ -52,7 +53,9 @@ DisplayManagerService::DisplayManagerService() : SystemAbility(DISPLAY_MANAGER_S
abstractScreenController_(new AbstractScreenController(mutex_)),
displayPowerController_(new DisplayPowerController(mutex_,
std::bind(&DisplayManagerService::NotifyDisplayStateChange, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)))
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4))),
isAutoRotationOpen_(OHOS::system::GetParameter(
"persist.display.ar.enabled", "1") == "1") // autoRotation default enabled
{
}
@@ -373,7 +376,7 @@ ScreenId DisplayManagerService::GetScreenIdByDisplayId(DisplayId displayId) cons
{
sptr<AbstractDisplay> abstractDisplay = abstractDisplayController_->GetAbstractDisplay(displayId);
if (abstractDisplay == nullptr) {
WLOGFE("GetScreenIdByDisplayId: GetAbstarctDisplay failed");
WLOGFE("GetScreenIdByDisplayId: GetAbstractDisplay failed");
return SCREEN_ID_INVALID;
}
return abstractDisplay->GetAbstractScreenId();
@@ -566,4 +569,23 @@ float DisplayManagerService::GetCustomVirtualPixelRatio()
{
return DisplayManagerService::customVirtualPixelRatio_;
}
bool DisplayManagerService::IsScreenRotationLocked()
{
return ScreenRotationController::IsScreenRotationLocked();
}
void DisplayManagerService::SetScreenRotationLocked(bool isLocked)
{
ScreenRotationController::SetScreenRotationLocked(isLocked);
}
void DisplayManagerService::SetGravitySensorSubscriptionEnabled()
{
if (!isAutoRotationOpen_) {
WLOGFE("autoRotation is not open");
return;
}
ScreenRotationController::SubscribeGravitySensor();
}
} // namespace OHOS::Rosen
@@ -152,4 +152,9 @@ void DisplayManagerServiceInner::GetFullScreenWindowRequestedOrientation(Display
{
DisplayManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation);
}
void DisplayManagerServiceInner::SetGravitySensorSubscriptionEnabled()
{
DisplayManagerService::GetInstance().SetGravitySensorSubscriptionEnabled();
}
} // namespace OHOS::Rosen
+10
View File
@@ -313,6 +313,16 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
reply.WriteInt32(static_cast<int32_t>(ret));
break;
}
case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: {
bool isLocked = IsScreenRotationLocked();
reply.WriteBool(isLocked);
break;
}
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED: {
bool isLocked = static_cast<bool>(data.ReadBool());
SetScreenRotationLocked(isLocked);
break;
}
default:
WLOGFW("unknown transaction code");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+3 -3
View File
@@ -24,8 +24,8 @@ namespace OHOS {
namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplaySensorController"};
constexpr int64_t ORIENTATION_SENSOR_SAMPING_RATE = 200000000; // 200ms
constexpr int64_t ORIENTATION_SENSOR_REPORTING_RATE = 200000000; // 200ms
constexpr int64_t ORIENTATION_SENSOR_SAMPLING_RATE = 200000000; // 200ms
constexpr int64_t ORIENTATION_SENSOR_REPORTING_RATE = 0;
constexpr long ORIENTATION_SENSOR_CALLBACK_TIME_INTERVAL = 200; // 200ms
constexpr int VALID_INCLINATION_ANGLE_THRESHOLD_COEFFICIENT = 3;
}
@@ -54,7 +54,7 @@ void ScreenRotationController::SubscribeGravitySensor()
user_.userData = nullptr;
user_.callback = &HandleGravitySensorEventCallback;
SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_);
SetBatch(SENSOR_TYPE_ID_GRAVITY, &user_, ORIENTATION_SENSOR_SAMPING_RATE, ORIENTATION_SENSOR_REPORTING_RATE);
SetBatch(SENSOR_TYPE_ID_GRAVITY, &user_, ORIENTATION_SENSOR_SAMPLING_RATE, ORIENTATION_SENSOR_REPORTING_RATE);
SetMode(SENSOR_TYPE_ID_GRAVITY, &user_, SENSOR_ON_CHANGE);
ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_);
isGravitySensorSubscribed_ = true;
+3 -3
View File
@@ -42,8 +42,8 @@ ohos_shared_library("libwindow_extension") {
configs = [ ":libwindow_extension_private_config" ]
deps = [
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
"${ability_runtime_kits_path}/appkit:app_context",
"${ability_runtime_path}/frameworks/js/napi/aafwk/inner/napi_common:napi_common",
"${ability_runtime_path}/frameworks/native/appkit:app_context",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/windowmanager/interfaces/kits/napi/window_runtime:window_native_kit",
"//foundation/windowmanager/utils:libwmutil",
@@ -71,7 +71,7 @@ config("window_extension_module_private_config") {
include_dirs = [
"include",
"${ability_runtime_kits_path}/ability/ability_runtime/include",
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
]
}
+1 -1
View File
@@ -25,7 +25,7 @@
# // __BASE is used for defining the basic info of the event.
# // "type" optional values are: FAULT, STATISTICS, SECURITY, BEHAVIOR.
# // "level" optional values are: CRITICAL, MINOR.
# // "tag" set tags with may used by subscriber of this event, multiple tags devided by space.
# // "tag" set tags with may used by subscriber of this event, multiple tags divided by space.
# // "desc" full description of this event.
# @PARAMETER: {type: parameter type, arrsize: array length(optional), desc: parameter description}.
# // follow the __BASE block, each line defines a parameter of this event.
+2 -1
View File
@@ -55,7 +55,8 @@ public:
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
ScreenPowerState GetScreenPower(ScreenId screenId);
void SetScreenRotationLocked(bool isLocked);
bool IsScreenRotationLocked();
private:
ScreenManager();
~ScreenManager();
+14
View File
@@ -127,8 +127,22 @@ public:
class Window : public RefBase {
public:
/**
* @brief create window, include main_window/sub_window/system_window
*
* @param windowName window name, identify window instance
* @param option window propertion
* @param context ability context
* @return sptr<Window> If create window success,return window instance;Otherwise, return nullptr
*/
static sptr<Window> Create(const std::string& windowName,
sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
/**
* @brief find window by windowName
*
* @param windowName
* @return sptr<Window> Return the window instance founded
*/
static sptr<Window> Find(const std::string& windowName);
static sptr<Window> GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
static sptr<Window> GetTopWindowWithId(uint32_t mainWinId);
+8
View File
@@ -125,6 +125,11 @@ public:
virtual void OnWindowUpdate(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) = 0;
};
class ICameraFloatWindowChangedListener : virtual public RefBase {
public:
virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0;
};
class WindowManager {
WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager);
friend class WindowManagerAgent;
@@ -137,6 +142,8 @@ public:
void UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
void RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
void UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
void RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
void UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
void MinimizeAllAppWindows(DisplayId displayId);
WMError ToggleShownStateForAllAppWindows();
WMError SetWindowLayoutMode(WindowLayoutMode mode);
@@ -155,6 +162,7 @@ private:
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) const;
void UpdateWindowVisibilityInfo(
const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos) const;
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const;
};
} // namespace Rosen
} // namespace OHOS
@@ -35,9 +35,9 @@ ohos_shared_library("display_napi") {
configs = [ ":display_config" ]
deps = [
"${ability_runtime_kits_path}/ability/native:abilitykit_native",
"${ability_runtime_kits_path}/appkit:app_context",
"${ability_runtime_kits_path}/appkit:appkit_native",
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
"${ability_runtime_path}/frameworks/native/appkit:app_context",
"${ability_runtime_path}/frameworks/native/appkit:appkit_native",
"../common:wm_napi_common",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/windowmanager/dm:libdm",
@@ -33,6 +33,15 @@ public:
private:
sptr<Display> display_ = nullptr;
};
enum class DisplayStateMode : uint32_t {
STATE_UNKNOWN = 0,
STATE_OFF,
STATE_ON,
STATE_DOZE,
STATE_DOZE_SUSPEND,
STATE_VR,
STATE_ON_SUSPEND
};
} // namespace Rosen
} // namespace OHOS
#endif
@@ -328,6 +328,36 @@ NativeValue* CreateJsDisplayArrayObject(NativeEngine& engine, std::vector<sptr<D
}
};
NativeValue* InitDisplayState(NativeEngine* engine)
{
WLOGFI("JsDisplayManager::InitDisplayState called");
if (engine == nullptr) {
WLOGFE("engine is nullptr");
return nullptr;
}
NativeValue *objValue = engine->CreateObject();
NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
if (object == nullptr) {
WLOGFE("Failed to get object");
return nullptr;
}
object->SetProperty("STATE_UNKNOWN", CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_UNKNOWN)));
object->SetProperty("STATE_OFF", CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_OFF)));
object->SetProperty("STATE_ON", CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_ON)));
object->SetProperty("STATE_DOZE",
CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_DOZE)));
object->SetProperty("STATE_DOZE_SUSPEND",
CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_DOZE_SUSPEND)));
object->SetProperty("STATE_VR",
CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_VR)));
object->SetProperty("STATE_ON_SUSPEND",
CreateJsValue(*engine, static_cast<int32_t>(DisplayStateMode::STATE_ON_SUSPEND)));
return objValue;
}
NativeValue* JsDisplayManagerInit(NativeEngine* engine, NativeValue* exportObj)
{
WLOGFI("JsDisplayManagerInit is called");
@@ -346,6 +376,8 @@ NativeValue* JsDisplayManagerInit(NativeEngine* engine, NativeValue* exportObj)
std::unique_ptr<JsDisplayManager> jsDisplayManager = std::make_unique<JsDisplayManager>(engine);
object->SetNativePointer(jsDisplayManager.release(), JsDisplayManager::Finalizer, nullptr);
object->SetProperty("DisplayState", InitDisplayState(engine));
BindNativeFunction(*engine, *object, "getDefaultDisplay", JsDisplayManager::GetDefaultDisplay);
BindNativeFunction(*engine, *object, "getDefaultDisplaySync", JsDisplayManager::GetDefaultDisplaySync);
BindNativeFunction(*engine, *object, "getAllDisplay", JsDisplayManager::GetAllDisplay);
@@ -38,9 +38,9 @@ ohos_shared_library("screenrecorder_napi") {
configs = [ ":screen_runtime_config" ]
deps = [
"${ability_runtime_kits_path}/ability/native:abilitykit_native",
"${ability_runtime_kits_path}/appkit:app_context",
"${ability_runtime_kits_path}/appkit:appkit_native",
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
"${ability_runtime_path}/frameworks/native/appkit:app_context",
"${ability_runtime_path}/frameworks/native/appkit:appkit_native",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/windowmanager/dm:libdm",
"//foundation/windowmanager/dmserver:libdms",
+3 -3
View File
@@ -37,9 +37,9 @@ ohos_shared_library("screen_napi") {
configs = [ ":screen_runtime_config" ]
deps = [
"${ability_runtime_kits_path}/ability/native:abilitykit_native",
"${ability_runtime_kits_path}/appkit:app_context",
"${ability_runtime_kits_path}/appkit:appkit_native",
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
"${ability_runtime_path}/frameworks/native/appkit:app_context",
"${ability_runtime_path}/frameworks/native/appkit:appkit_native",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/windowmanager/dm:libdm",
"//foundation/windowmanager/dmserver:libdms",
@@ -82,6 +82,21 @@ declare namespace screen {
function setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void;
function setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>;
/**
* Get screen rotation lock status.
* @since 9
*/
function isScreenRotationLocked(callback: AsyncCallback<boolean>): void;
function isScreenRotationLocked(): Promise<boolean>;
/**
* Set screen rotation lock status.
* @param isLocked Indicates whether the screen rotation switch is locked.
* @since 9
*/
function setScreenRotationLocked(isLocked:boolean, callback: AsyncCallback<void>): void;
function setScreenRotationLocked(isLocked:boolean): Promise<void>;
/**
* the parameter of making expand screen
* @syscap SystemCapability.WindowManager.WindowManager.Core
@@ -98,6 +98,18 @@ static NativeValue* SetVirtualScreenSurface(NativeEngine* engine, NativeCallback
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
return (me != nullptr) ? me->OnSetVirtualScreenSurface(*engine, *info) : nullptr;
}
static NativeValue* IsScreenRotationLocked(NativeEngine* engine, NativeCallbackInfo* info)
{
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
return (me != nullptr) ? me->OnIsScreenRotationLocked(*engine, *info) : nullptr;
}
static NativeValue* SetScreenRotationLocked(NativeEngine* engine, NativeCallbackInfo* info)
{
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
return (me != nullptr) ? me->OnSetScreenRotationLocked(*engine, *info) : nullptr;
}
private:
std::map<std::string, std::map<std::unique_ptr<NativeReference>, sptr<JsScreenListener>>> jsCbMap_;
std::mutex mtx_;
@@ -607,8 +619,102 @@ NativeValue* OnSetVirtualScreenSurface(NativeEngine& engine, NativeCallbackInfo&
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
return result;
}
NativeValue* OnIsScreenRotationLocked(NativeEngine& engine, NativeCallbackInfo& info)
{
WLOGFI("OnIsScreenRotationLocked is called");
DMError errCode = DMError::DM_OK;
if (info.argc > 1) {
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
errCode = DMError::DM_ERROR_INVALID_PARAM;
}
AsyncTask::CompleteCallback complete =
[errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
if (errCode != DMError::DM_OK) {
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
return;
}
bool isLocked = SingletonContainer::Get<ScreenManager>().IsScreenRotationLocked();
task.Resolve(engine, CreateJsValue(engine, isLocked));
};
NativeValue* lastParam = nullptr;
if (info.argc == ARGC_ONE && info.argv[ARGC_ONE - 1]->TypeOf() == NATIVE_FUNCTION) {
lastParam = info.argv[ARGC_ONE - 1];
}
NativeValue* result = nullptr;
AsyncTask::Schedule("JsScreenManager::OnIsScreenRotationLocked",
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
return result;
}
NativeValue* OnSetScreenRotationLocked(NativeEngine& engine, NativeCallbackInfo& info)
{
WLOGFI("JsScreenManager::OnSetScreenRotationLocked is called");
DMError errCode = DMError::DM_OK;
if (info.argc < 1 || info.argc > 2) { // 2: maximum params num
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
errCode = DMError::DM_ERROR_INVALID_PARAM;
}
bool isLocked = false;
if (errCode == DMError::DM_OK) {
NativeBoolean* nativeVal = ConvertNativeValueTo<NativeBoolean>(info.argv[0]);
if (nativeVal == nullptr) {
WLOGFE("[NAPI]Failed to convert parameter to isLocked");
errCode = DMError::DM_ERROR_INVALID_PARAM;
} else {
isLocked = static_cast<bool>(*nativeVal);
}
}
AsyncTask::CompleteCallback complete =
[isLocked, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
if (errCode != DMError::DM_OK) {
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
return;
}
SingletonContainer::Get<ScreenManager>().SetScreenRotationLocked(isLocked);
task.Resolve(engine, engine.CreateUndefined());
};
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
NativeValue* result = nullptr;
AsyncTask::Schedule("JsScreenManager::OnSetScreenRotationLocked",
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
return result;
}
};
NativeValue* InitScreenOrientation(NativeEngine* engine)
{
WLOGFI("JsScreenManager::InitScreenOrientation called");
if (engine == nullptr) {
WLOGFE("engine is nullptr");
return nullptr;
}
NativeValue *objValue = engine->CreateObject();
NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
if (object == nullptr) {
WLOGFE("Failed to get object");
return nullptr;
}
object->SetProperty("UNSPECIFIED", CreateJsValue(*engine, static_cast<int32_t>(Orientation::UNSPECIFIED)));
object->SetProperty("VERTICAL", CreateJsValue(*engine, static_cast<int32_t>(Orientation::VERTICAL)));
object->SetProperty("HORIZONTAL", CreateJsValue(*engine, static_cast<int32_t>(Orientation::HORIZONTAL)));
object->SetProperty("REVERSE_VERTICAL",
CreateJsValue(*engine, static_cast<int32_t>(Orientation::REVERSE_VERTICAL)));
object->SetProperty("REVERSE_HORIZONTAL",
CreateJsValue(*engine, static_cast<int32_t>(Orientation::REVERSE_HORIZONTAL)));
object->SetProperty("SENSOR", CreateJsValue(*engine, static_cast<int32_t>(Orientation::SENSOR)));
object->SetProperty("SENSOR_VERTICAL",
CreateJsValue(*engine, static_cast<int32_t>(Orientation::SENSOR_VERTICAL)));
object->SetProperty("SENSOR_HORIZONTAL",
CreateJsValue(*engine, static_cast<int32_t>(Orientation::SENSOR_HORIZONTAL)));
return objValue;
}
NativeValue* JsScreenManagerInit(NativeEngine* engine, NativeValue* exportObj)
{
WLOGFI("JsScreenManagerInit is called");
@@ -627,6 +733,8 @@ NativeValue* JsScreenManagerInit(NativeEngine* engine, NativeValue* exportObj)
std::unique_ptr<JsScreenManager> jsScreenManager = std::make_unique<JsScreenManager>(engine);
object->SetNativePointer(jsScreenManager.release(), JsScreenManager::Finalizer, nullptr);
object->SetProperty("Orientation", InitScreenOrientation(engine));
BindNativeFunction(*engine, *object, "getAllScreens", JsScreenManager::GetAllScreens);
BindNativeFunction(*engine, *object, "on", JsScreenManager::RegisterScreenManagerCallback);
BindNativeFunction(*engine, *object, "off", JsScreenManager::UnregisterScreenMangerCallback);
@@ -635,6 +743,8 @@ NativeValue* JsScreenManagerInit(NativeEngine* engine, NativeValue* exportObj)
BindNativeFunction(*engine, *object, "createVirtualScreen", JsScreenManager::CreateVirtualScreen);
BindNativeFunction(*engine, *object, "destroyVirtualScreen", JsScreenManager::DestroyVirtualScreen);
BindNativeFunction(*engine, *object, "setVirtualScreenSurface", JsScreenManager::SetVirtualScreenSurface);
BindNativeFunction(*engine, *object, "setScreenRotationLocked", JsScreenManager::SetScreenRotationLocked);
BindNativeFunction(*engine, *object, "isScreenRotationLocked", JsScreenManager::IsScreenRotationLocked);
return engine->CreateUndefined();
}
} // namespace Rosen
+4 -3
View File
@@ -77,12 +77,13 @@ ohos_shared_library("window_napi") {
configs = [ ":window_manager_napi_config" ]
deps = [
":window_native_kit",
"${ability_runtime_kits_path}/ability/native:abilitykit_native",
"${ability_runtime_kits_path}/appkit:app_context",
"${ability_runtime_kits_path}/appkit:appkit_native",
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
"${ability_runtime_path}/frameworks/native/appkit:app_context",
"${ability_runtime_path}/frameworks/native/appkit:appkit_native",
"//foundation/windowmanager/utils:libwmutil",
"//foundation/windowmanager/wm:libwm",
"//foundation/windowmanager/wmserver:libwms",
"//utils/native/base:utils",
]
external_deps = [
@@ -918,6 +918,20 @@ declare namespace window {
*/
setTransparent(isTransparent: boolean, callback: AsyncCallback<void>): void;
/**
* Set the requested orientation config of a window
* @param orientation the orientation config of a window
* @since 9
*/
setRequestedOrientation(orientation: Orientation): Promise<void>;
/**
* Set the requested orientation config of a window
* @param orientation the orientation config of a window
* @since 9
*/
setRequestedOrientation(orientation: Orientation, callback: AsyncCallback<void>): void;
/**
* disable window decoration. It must be called before loadContent.
* @systemapi
@@ -1043,6 +1057,26 @@ declare namespace window {
*/
off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType>): void;
}
/**
* screen orientation
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @since 9
*/
enum Orientation {
UNSPECIFIED = 0,
PORTRAIT = 1,
LANDSCAPE = 2,
PORTRAIT_INVERTED = 3,
LANDSCAPE_INVERTED = 4,
AUTO_ROTATION = 5,
AUTO_ROTATION_PORTRAIT = 6,
AUTO_ROTATION_LANDSCAPE = 7,
AUTO_ROTATION_RESTRICTED = 8,
AUTO_ROTATION_PORTRAIT_RESTRICTED = 9,
AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10,
LOCKED = 11,
}
}
export default window;
@@ -271,6 +271,13 @@ NativeValue* JsWindow::SetCallingWindow(NativeEngine* engine, NativeCallbackInfo
return (me != nullptr) ? me->OnSetCallingWindow(*engine, *info) : nullptr;
}
NativeValue* JsWindow::SetRequestedOrientation(NativeEngine* engine, NativeCallbackInfo* info)
{
WLOGFI("[NAPI]SetRequestedOrientation");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
return (me != nullptr) ? me->OnSetRequestedOrientation(*engine, *info) : nullptr;
}
NativeValue* JsWindow::DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info)
{
WLOGFI("[NAPI]DisableWindowDecor");
@@ -1023,6 +1030,53 @@ NativeValue* JsWindow::OnIsShowing(NativeEngine& engine, NativeCallbackInfo& inf
return result;
}
NativeValue* JsWindow::OnSetRequestedOrientation(NativeEngine& engine, NativeCallbackInfo& info)
{
WMError errCode = WMError::WM_OK;
Orientation requestedOrientation = Orientation::UNSPECIFIED;
if (info.argc < 1 || info.argc > 2) { // 2: maximum params num
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
errCode = WMError::WM_ERROR_INVALID_PARAM;
} else {
NativeNumber* nativeType = ConvertNativeValueTo<NativeNumber>(info.argv[0]);
if (nativeType == nullptr) {
errCode = WMError::WM_ERROR_INVALID_PARAM;
WLOGFE("[NAPI]Failed to convert parameter to Orientation");
} else {
requestedOrientation = JS_TO_NATIVE_ORIENTATION_MAP.at(
static_cast<ApiOrientation>(static_cast<uint32_t>(*nativeType)));
if (requestedOrientation < Orientation::BEGIN || requestedOrientation > Orientation::END) {
WLOGFE("[NAPI]Orientation %{public}u invalid!", static_cast<uint32_t>(requestedOrientation));
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
}
}
wptr<Window> weakToken(windowToken_);
AsyncTask::CompleteCallback complete =
[weakToken, requestedOrientation, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
auto weakWindow = weakToken.promote();
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode),
"OnSetRequestedOrientation failed"));
WLOGFE("[NAPI]Window is nullptr or get invalid param");
return;
}
weakWindow->SetRequestedOrientation(requestedOrientation);
task.Resolve(engine, engine.CreateUndefined());
WLOGFI("[NAPI]Window [%{public}u, %{public}s] OnSetRequestedOrientation end, orientation = %{public}u",
weakWindow->GetWindowId(),
weakWindow->GetWindowName().c_str(),
static_cast<uint32_t>(requestedOrientation));
};
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
NativeValue* result = nullptr;
AsyncTask::Schedule("JsWindow::OnSetRequestedOrientation",
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
return result;
}
NativeValue* JsWindow::OnIsSupportWideGamut(NativeEngine& engine, NativeCallbackInfo& info)
{
WMError errCode = WMError::WM_OK;
@@ -1614,6 +1668,17 @@ NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr<Window>& window)
std::unique_ptr<JsWindow> jsWindow = std::make_unique<JsWindow>(window);
object->SetNativePointer(jsWindow.release(), JsWindow::Finalizer, nullptr);
BindFunctions(engine, object);
std::shared_ptr<NativeReference> jsWindowRef;
jsWindowRef.reset(engine.CreateReference(objValue, 1));
std::lock_guard<std::recursive_mutex> lock(g_mutex);
g_jsWindowMap[windowName] = jsWindowRef;
return objValue;
}
void BindFunctions(NativeEngine& engine, NativeObject* object)
{
BindNativeFunction(engine, *object, "show", JsWindow::Show);
BindNativeFunction(engine, *object, "destroy", JsWindow::Destroy);
BindNativeFunction(engine, *object, "hide", JsWindow::Hide);
@@ -1647,12 +1712,7 @@ NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr<Window>& window)
BindNativeFunction(engine, *object, "disableWindowDecor", JsWindow::DisableWindowDecor);
BindNativeFunction(engine, *object, "dump", JsWindow::Dump);
BindNativeFunction(engine, *object, "setForbidSplitMove", JsWindow::SetForbidSplitMove);
std::shared_ptr<NativeReference> jsWindowRef;
jsWindowRef.reset(engine.CreateReference(objValue, 1));
std::lock_guard<std::recursive_mutex> lock(g_mutex);
g_jsWindowMap[windowName] = jsWindowRef;
return objValue;
BindNativeFunction(engine, *object, "setRequestedOrientation", JsWindow::SetRequestedOrientation);
}
} // namespace Rosen
} // namespace OHOS
@@ -27,6 +27,7 @@ namespace OHOS {
namespace Rosen {
NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr<Window>& window);
std::shared_ptr<NativeReference> FindJsWindowObject(std::string windowName);
void BindFunctions(NativeEngine& engine, NativeObject* object);
class JsWindow final {
public:
explicit JsWindow(const sptr<Window>& window);
@@ -59,7 +60,7 @@ public:
static NativeValue* SetTouchable(NativeEngine* engine, NativeCallbackInfo* info);
static NativeValue* SetTransparent(NativeEngine* engine, NativeCallbackInfo* info);
static NativeValue* SetCallingWindow(NativeEngine* engine, NativeCallbackInfo* info);
static NativeValue* SetRequestedOrientation(NativeEngine* engine, NativeCallbackInfo* info);
static NativeValue* DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info);
// colorspace, gamut
static NativeValue* IsSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info);
@@ -87,6 +88,7 @@ private:
NativeValue* OnLoadContent(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnGetAvoidArea(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnIsShowing(NativeEngine& engine, NativeCallbackInfo& info);
NativeValue* OnSetRequestedOrientation(NativeEngine& engine, NativeCallbackInfo& info);
// colorspace, gamut
NativeValue* OnIsSupportWideGamut(NativeEngine& engine, NativeCallbackInfo& info);
@@ -118,6 +118,36 @@ const std::map<ApiWindowMode, WindowMode> JS_TO_NATIVE_WINDOW_MODE_MAP {
{ApiWindowMode::FLOATING, WindowMode::WINDOW_MODE_FLOATING },
};
enum class ApiOrientation : uint32_t {
UNSPECIFIED = 0,
PORTRAIT = 1,
LANDSCAPE = 2,
PORTRAIT_INVERTED = 3,
LANDSCAPE_INVERTED = 4,
AUTO_ROTATION = 5,
AUTO_ROTATION_PORTRAIT = 6,
AUTO_ROTATION_LANDSCAPE = 7,
AUTO_ROTATION_RESTRICTED = 8,
AUTO_ROTATION_PORTRAIT_RESTRICTED = 9,
AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10,
LOCKED = 11,
};
const std::map<ApiOrientation, Orientation> JS_TO_NATIVE_ORIENTATION_MAP {
{ApiOrientation::UNSPECIFIED, Orientation::UNSPECIFIED },
{ApiOrientation::PORTRAIT, Orientation::VERTICAL },
{ApiOrientation::LANDSCAPE, Orientation::HORIZONTAL },
{ApiOrientation::PORTRAIT_INVERTED, Orientation::REVERSE_VERTICAL },
{ApiOrientation::LANDSCAPE_INVERTED, Orientation::REVERSE_HORIZONTAL },
{ApiOrientation::AUTO_ROTATION, Orientation::SENSOR },
{ApiOrientation::AUTO_ROTATION_PORTRAIT, Orientation::SENSOR_VERTICAL },
{ApiOrientation::AUTO_ROTATION_LANDSCAPE, Orientation::SENSOR_HORIZONTAL },
{ApiOrientation::AUTO_ROTATION_RESTRICTED, Orientation::AUTO_ROTATION_RESTRICTED },
{ApiOrientation::AUTO_ROTATION_PORTRAIT_RESTRICTED, Orientation::AUTO_ROTATION_PORTRAIT_RESTRICTED },
{ApiOrientation::AUTO_ROTATION_LANDSCAPE_RESTRICTED, Orientation::AUTO_ROTATION_LANDSCAPE_RESTRICTED },
{ApiOrientation::LOCKED, Orientation::LOCKED },
};
NativeValue* GetRectAndConvertToJsValue(NativeEngine& engine, const Rect rect);
NativeValue* CreateJsWindowPropertiesObject(NativeEngine& engine, sptr<Window>& window);
bool SetSystemBarPropertiesFromJs(NativeEngine& engine, NativeObject* jsObject,
+1 -1
View File
@@ -26,7 +26,7 @@ public:
virtual ~SurfaceReaderHandler() noexcept
{
}
virtual bool OnImageAvalible(sptr<Media::PixelMap> pixleMap) = 0;
virtual bool OnImageAvailable(sptr<Media::PixelMap> pixelMap) = 0;
};
}
}
+2 -2
View File
@@ -23,14 +23,14 @@ namespace OHOS {
namespace Rosen {
class SurfaceReaderHandlerImpl : public SurfaceReaderHandler {
public:
bool OnImageAvalible(sptr<Media::PixelMap> pixleMap) override;
bool OnImageAvailable(sptr<Media::PixelMap> pixelMap) override;
bool IsImageOk();
void ResetFlag();
sptr<Media::PixelMap> GetPixelMap();
private:
bool flag_ = false;
sptr<Media::PixelMap> pixleMap_ = nullptr;
sptr<Media::PixelMap> pixelMap_ = nullptr;
std::recursive_mutex mutex_;
};
}
+4 -2
View File
@@ -74,7 +74,7 @@ public:
return ((IsMainWindow(type)) && (mode != WindowMode::WINDOW_MODE_FLOATING));
}
static inline bool IsFloatintWindow(WindowMode mode)
static inline bool IsFloatingWindow(WindowMode mode)
{
return mode == WindowMode::WINDOW_MODE_FLOATING;
}
@@ -303,6 +303,7 @@ public:
static bool CalculateTouchHotAreas(const Rect& windowRect, const std::vector<Rect>& requestRects,
std::vector<Rect>& outRects)
{
bool isOk = true;
for (const auto& rect : requestRects) {
if (rect.posX_ < 0 || rect.posY_ < 0 || rect.width_ == 0 || rect.height_ == 0) {
return false;
@@ -310,6 +311,7 @@ public:
Rect hotArea;
if (rect.posX_ >= static_cast<int32_t>(windowRect.width_) ||
rect.posY_ >= static_cast<int32_t>(windowRect.height_)) {
isOk = false;
continue;
}
hotArea.posX_ = windowRect.posX_ + rect.posX_;
@@ -320,7 +322,7 @@ public:
std::min(hotArea.posY_ + rect.height_, windowRect.posY_ + windowRect.height_) - hotArea.posY_;
outRects.emplace_back(hotArea);
}
return true;
return isOk;
}
private:
+3
View File
@@ -72,6 +72,7 @@ public:
void SetStretchable(bool stretchable);
void SetOriginRect(const Rect& rect);
void SetTouchHotAreas(const std::vector<Rect>& rects);
void SetAccessTokenId(uint32_t accessTokenId);
WindowSizeChangeReason GetWindowSizeChangeReason() const;
const std::string& GetWindowName() const;
@@ -107,6 +108,7 @@ public:
bool GetStretchable() const;
const Rect& GetOriginRect() const;
void GetTouchHotAreas(std::vector<Rect>& rects) const;
uint32_t GetAccessTokenId() const;
virtual bool Marshalling(Parcel& parcel) const override;
static WindowProperty* Unmarshalling(Parcel& parcel);
@@ -155,6 +157,7 @@ private:
bool isStretchable_ {false};
DragType dragType_ = DragType::DRAG_UNDEFINED;
std::vector<Rect> touchHotAreas_; // coordinates relative to window.
uint32_t accessTokenId_ { 0 };
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
};
}
+1 -1
View File
@@ -146,7 +146,7 @@ namespace {
constexpr uint32_t MIN_HORIZONTAL_SPLIT_WIDTH = 320;
constexpr uint32_t MAX_FLOATING_SIZE = 2560;
const std::string WINDOW_MANAGER_CONFIG_XML = "/system/etc/window/resources/window_manager_config.xml";
const Rect IVALID_EMPTY_RECT = {0, 0, 0, 0};
const Rect INVALID_EMPTY_RECT = {0, 0, 0, 0};
}
}
}
+1 -1
View File
@@ -152,7 +152,7 @@ bool SurfaceReader::ProcessBuffer(const sptr<SurfaceBuffer> &buf)
pixelMap->SetPixelsAddr(data, nullptr, width * height, AllocatorType::HEAP_ALLOC, nullptr);
handler_->OnImageAvalible(pixelMap);
handler_->OnImageAvailable(pixelMap);
return true;
}
}
+3 -3
View File
@@ -21,12 +21,12 @@ namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SurfaceReaderHandlerImpl"};
} // namespace
bool SurfaceReaderHandlerImpl::OnImageAvalible(sptr<Media::PixelMap> pixleMap)
bool SurfaceReaderHandlerImpl::OnImageAvailable(sptr<Media::PixelMap> pixelMap)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!flag_) {
flag_ = true;
pixleMap_ = pixleMap;
pixelMap_ = pixelMap;
WLOGFI("Get an Image!");
}
return true;
@@ -49,7 +49,7 @@ void SurfaceReaderHandlerImpl::ResetFlag()
sptr<Media::PixelMap> SurfaceReaderHandlerImpl::GetPixelMap()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
return pixleMap_;
return pixelMap_;
}
}
}
+13 -1
View File
@@ -180,6 +180,11 @@ void WindowProperty::SetOriginRect(const Rect& rect)
originRect_ = rect;
}
void WindowProperty::SetAccessTokenId(uint32_t accessTokenId)
{
accessTokenId_ = accessTokenId;
}
WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
{
return windowSizeChangeReason_;
@@ -375,6 +380,11 @@ void WindowProperty::GetTouchHotAreas(std::vector<Rect>& rects) const
rects = touchHotAreas_;
}
uint32_t WindowProperty::GetAccessTokenId() const
{
return accessTokenId_;
}
bool WindowProperty::MapMarshalling(Parcel& parcel) const
{
auto size = sysBarPropMap_.size();
@@ -450,7 +460,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) &&
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel);
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_);
}
WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
@@ -498,6 +508,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
property->SetOriginRect(Rect { 0, 0, w, h });
property->SetStretchable(parcel.ReadBool());
UnmarshallingTouchHotAreas(parcel, property);
property->SetAccessTokenId(parcel.ReadUint32());
return property;
}
@@ -643,6 +654,7 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
originRect_ = property->originRect_;
isStretchable_ = property->isStretchable_;
touchHotAreas_ = property->touchHotAreas_;
accessTokenId_ = property->accessTokenId_;
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ config("libwm_private_config") {
include_dirs = [
"include",
"../wmserver/include",
"${ability_runtime_kits_path}/ability/ability_runtime/include",
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
"${ability_runtime_inner_api_path}/ability_manager/include",
"${ability_runtime_inner_api_path}/app_manager/include/appmgr",
"//third_party/jsoncpp/include",
-1
View File
@@ -49,7 +49,6 @@ public:
virtual void ProcessPointUp(uint32_t windowId);
virtual void MinimizeAllAppWindows(DisplayId displayId);
virtual WMError ToggleShownStateForAllAppWindows();
virtual WMError MaxmizeWindow(uint32_t windowId);
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode);
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
virtual WMError GetSystemConfig(SystemConfig& systemConfig);
+8 -4
View File
@@ -189,7 +189,7 @@ public:
void NotifySizeChange(Rect rect, WindowSizeChangeReason reason);
void NotifyKeyEvent(std::shared_ptr<MMI::KeyEvent> &keyEvent);
void NotifyPointEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
void NotifyAviodAreaChange(const std::vector<Rect>& avoidArea);
void NotifyAvoidAreaChange(const std::vector<Rect>& avoidArea);
void NotifyDisplayMoveChange(DisplayId from, DisplayId to);
void NotifyOccupiedAreaChange(const sptr<OccupiedAreaChangeInfo>& info);
void NotifyModeChange(WindowMode mode);
@@ -253,7 +253,11 @@ private:
}
inline void NotifyBeforeDestroy(std::string windowName)
{
CALL_UI_CONTENT(Destroy);
if (uiContent_ != nullptr) {
auto uiContent = std::move(uiContent_);
uiContent_ = nullptr;
uiContent->Destroy();
}
if (notifyNativefunc_) {
notifyNativefunc_(windowName);
}
@@ -318,7 +322,7 @@ private:
// colorspace, gamut
using ColorSpaceConvertMap = struct {
ColorSpace colorSpace;
ColorGamut sufaceColorGamut;
ColorGamut surfaceColorGamut;
};
static const ColorSpaceConvertMap colorSpaceConvertMap[];
static ColorSpace GetColorSpaceFromSurfaceGamut(ColorGamut ColorGamut);
@@ -361,7 +365,7 @@ private:
Rect startRectExceptFrame_ = { 0, 0, 0, 0 };
Rect startRectExceptCorner_ = { 0, 0, 0, 0 };
DragType dragType_ = DragType::DRAG_UNDEFINED;
bool isAppDecorEnbale_ = true;
bool isAppDecorEnable_ = true;
SystemConfig windowSystemConfig_ ;
bool isOriginRectSet_ = false;
bool isWaitingFrame_ = false;
+1
View File
@@ -30,6 +30,7 @@ public:
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& props) override;
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) override;
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) override;
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override;
};
} // namespace Rosen
} // namespace OHOS
@@ -27,6 +27,7 @@ enum class WindowManagerAgentType : uint32_t {
WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR,
WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE,
WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY,
WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
};
class IWindowManagerAgent : public IRemoteBroker {
@@ -38,6 +39,7 @@ public:
TRANS_ID_UPDATE_SYSTEM_BAR_PROPS,
TRANS_ID_UPDATE_WINDOW_STATUS,
TRANS_ID_UPDATE_WINDOW_VISIBILITY,
TRANS_ID_UPDATE_CAMERA_FLOAT,
};
virtual void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) = 0;
@@ -45,6 +47,7 @@ public:
virtual void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo,
WindowUpdateType type) = 0;
virtual void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) = 0;
virtual void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) = 0;
};
} // namespace Rosen
} // namespace OHOS
@@ -31,6 +31,7 @@ public:
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) override;
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type) override;
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos) override;
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override;
private:
static inline BrokerDelegator<WindowManagerAgentProxy> delegator_;
-7
View File
@@ -149,13 +149,6 @@ WMError WindowAdapter::ToggleShownStateForAllAppWindows()
return windowManagerServiceProxy_->ToggleShownStateForAllAppWindows();
}
WMError WindowAdapter::MaxmizeWindow(uint32_t windowId)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->MaxmizeWindow(windowId);
}
WMError WindowAdapter::GetSystemConfig(SystemConfig& systemConfig)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
+16 -10
View File
@@ -16,10 +16,11 @@
#include "window_impl.h"
#include <cmath>
#include <sstream>
#include <ability_manager_client.h>
#include <hisysevent.h>
#include <sstream>
#include "ipc_skeleton.h"
#include "color_parser.h"
#include "display_manager.h"
@@ -314,7 +315,7 @@ WMError WindowImpl::SetWindowType(WindowType type)
return WMError::WM_ERROR_INVALID_PARAM;
}
property_->SetWindowType(type);
if (isAppDecorEnbale_ && windowSystemConfig_.isSystemDecorEnable_) {
if (isAppDecorEnable_ && windowSystemConfig_.isSystemDecorEnable_) {
property_->SetDecorEnable(WindowHelper::IsMainWindow(property_->GetWindowType()));
}
AdjustWindowAnimationFlag();
@@ -442,7 +443,7 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
WLOGFE("fail to SetUIContent id: %{public}u", property_->GetWindowId());
return WMError::WM_ERROR_NULLPTR;
}
if (!isAppDecorEnbale_ || !windowSystemConfig_.isSystemDecorEnable_) {
if (!isAppDecorEnable_ || !windowSystemConfig_.isSystemDecorEnable_) {
WLOGFI("app set decor enable false");
property_->SetDecorEnable(false);
}
@@ -490,7 +491,7 @@ std::string WindowImpl::GetContentInfo()
ColorSpace WindowImpl::GetColorSpaceFromSurfaceGamut(ColorGamut ColorGamut)
{
for (auto item: colorSpaceConvertMap) {
if (item.sufaceColorGamut == ColorGamut) {
if (item.surfaceColorGamut == ColorGamut) {
return item.colorSpace;
}
}
@@ -501,7 +502,7 @@ ColorGamut WindowImpl::GetSurfaceGamutFromColorSpace(ColorSpace colorSpace)
{
for (auto item: colorSpaceConvertMap) {
if (item.colorSpace == colorSpace) {
return item.sufaceColorGamut;
return item.surfaceColorGamut;
}
}
return ColorGamut::COLOR_GAMUT_SRGB;
@@ -1015,6 +1016,8 @@ WMError WindowImpl::SetBackgroundColor(const std::string& color)
}
uint32_t colorValue;
if (ColorParser::Parse(color, colorValue)) {
WLOGFI("SetBackgroundColor: window: %{public}s, value: [%{public}s, %{public}u]",
name_.c_str(), color.c_str(), colorValue);
return SetBackgroundColor(colorValue);
}
WLOGFE("invalid color string: %{public}s", color.c_str());
@@ -1147,7 +1150,7 @@ void WindowImpl::DisableAppWindowDecor()
return;
}
WLOGFI("disable app window decoration.");
isAppDecorEnbale_ = false;
isAppDecorEnable_ = false;
}
bool WindowImpl::IsDecorEnable() const
@@ -1494,7 +1497,7 @@ void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo)
property_->SetModeSupportInfo(modeSupportInfo);
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) {
WLOGFI("currunt window mode is not supported, force to transform to appropriate mode. window id:%{public}u",
WLOGFI("current window mode is not supported, force to transform to appropriate mode. window id:%{public}u",
GetWindowId());
WindowMode mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo);
if (mode != WindowMode::WINDOW_MODE_UNDEFINED) {
@@ -1948,7 +1951,7 @@ void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configura
void WindowImpl::UpdateAvoidArea(const std::vector<Rect>& avoidArea)
{
WLOGFI("Window Update AvoidArea, id: %{public}u", property_->GetWindowId());
NotifyAviodAreaChange(avoidArea);
NotifyAvoidAreaChange(avoidArea);
}
void WindowImpl::UpdateWindowState(WindowState state)
@@ -2127,7 +2130,7 @@ void WindowImpl::NotifyPointEvent(std::shared_ptr<MMI::PointerEvent>& pointerEve
});
}
void WindowImpl::NotifyAviodAreaChange(const std::vector<Rect>& avoidArea)
void WindowImpl::NotifyAvoidAreaChange(const std::vector<Rect>& avoidArea)
{
std::vector<sptr<IAvoidAreaChangedListener>> avoidAreaChangeListeners;
{
@@ -2215,7 +2218,7 @@ Rect WindowImpl::GetSystemAlarmWindowDefaultSize(Rect defaultRect)
SYSTEM_ALARM_WINDOW_HEIGHT_RATIO));
rect = { static_cast<int32_t>((width - alarmWidth) / 2), static_cast<int32_t>((height - alarmHeight) / 2),
alarmWidth, alarmHeight }; // devided by 2 to middle the window
alarmWidth, alarmHeight }; // divided by 2 to middle the window
return rect;
}
@@ -2341,6 +2344,9 @@ bool WindowImpl::CheckCameraFloatingWindowMultiCreated(WindowType type)
return true;
}
}
uint32_t accessTokenId = static_cast<uint32_t>(IPCSkeleton::GetCallingTokenID());
property_->SetAccessTokenId(accessTokenId);
WLOGFI("Create camera float window, accessTokenId = %{public}u", accessTokenId);
return false;
}
} // namespace Rosen
+66
View File
@@ -146,6 +146,7 @@ public:
void NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints);
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type);
void NotifyWindowVisibilityInfoChanged(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos);
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing);
static inline SingletonDelegator<WindowManager> delegator_;
bool isHandlerRunning_ = false;
@@ -159,6 +160,8 @@ public:
sptr<WindowManagerAgent> windowUpdateListenerAgent_;
std::vector<sptr<IVisibilityChangedListener>> windowVisibilityListeners_;
sptr<WindowManagerAgent> windowVisibilityListenerAgent_;
std::vector<sptr<ICameraFloatWindowChangedListener>> cameraFloatWindowChangedListeners_;
sptr<WindowManagerAgent> cameraFloatWindowChangedListenerAgent_;
};
void WindowManager::Impl::PostTask(ListenerTaskCallback &&callback, EventPriority priority = EventPriority::LOW,
@@ -270,6 +273,16 @@ void WindowManager::Impl::NotifyWindowVisibilityInfoChanged(
}, EventPriority::LOW, "AccessibilityWindowInfo");
}
void WindowManager::Impl::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
{
WLOGFI("Camera float window, accessTokenId = %{public}u, isShowing = %{public}u", accessTokenId, isShowing);
PostTask([this, accessTokenId, isShowing]() mutable {
for (auto& listener : cameraFloatWindowChangedListeners_) {
listener->OnCameraFloatWindowChange(accessTokenId, isShowing);
}
}, EventPriority::LOW, "CameraFloatWindowStatus");
}
WindowManager::WindowManager() : pImpl_(std::make_unique<Impl>())
{
}
@@ -467,6 +480,53 @@ void WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityCh
}
}
void WindowManager::RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
{
if (listener == nullptr) {
WLOGFE("listener could not be null");
return;
}
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(),
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
if (iter != pImpl_->cameraFloatWindowChangedListeners_.end()) {
WLOGFI("Listener is already registered.");
return;
}
pImpl_->cameraFloatWindowChangedListeners_.push_back(listener);
if (pImpl_->cameraFloatWindowChangedListenerAgent_ == nullptr) {
pImpl_->cameraFloatWindowChangedListenerAgent_ = new WindowManagerAgent();
SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
pImpl_->cameraFloatWindowChangedListenerAgent_);
}
}
void WindowManager::UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
{
if (listener == nullptr) {
WLOGFE("listener could not be null");
return;
}
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(),
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
if (iter == pImpl_->cameraFloatWindowChangedListeners_.end()) {
WLOGFE("could not find this listener");
return;
}
pImpl_->cameraFloatWindowChangedListeners_.erase(iter);
if (pImpl_->cameraFloatWindowChangedListeners_.empty() &&
pImpl_->cameraFloatWindowChangedListenerAgent_ != nullptr) {
SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
pImpl_->cameraFloatWindowChangedListenerAgent_);
pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr;
}
}
void WindowManager::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) const
{
if (focusChangeInfo == nullptr) {
@@ -511,5 +571,11 @@ WMError WindowManager::GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>&
}
return ret;
}
void WindowManager::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const
{
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
pImpl_->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
}
} // namespace Rosen
} // namespace OHOS
+5
View File
@@ -40,5 +40,10 @@ void WindowManagerAgent::UpdateWindowVisibilityInfo(const std::vector<sptr<Windo
{
SingletonContainer::Get<WindowManager>().UpdateWindowVisibilityInfo(visibilityInfos);
}
void WindowManagerAgent::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
{
SingletonContainer::Get<WindowManager>().UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
}
} // namespace Rosen
} // namespace OHOS
@@ -144,6 +144,32 @@ void WindowManagerAgentProxy::UpdateWindowVisibilityInfo(
WLOGFE("SendRequest failed");
}
}
void WindowManagerAgentProxy::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return;
}
if (!data.WriteUint32(accessTokenId)) {
WLOGFE("Write accessTokenId failed");
return;
}
if (!data.WriteBool(isShowing)) {
WLOGFE("Write is showing status failed");
return;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
}
}
} // namespace Rosen
} // namespace OHOS
@@ -84,6 +84,12 @@ int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
UpdateWindowVisibilityInfo(infos);
break;
}
case WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT: {
uint32_t accessTokenId = data.ReadUint32();
bool isShowing = data.ReadBool();
UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
break;
}
default:
break;
}
@@ -126,17 +126,14 @@ void IPCSpecificInterfaceFuzzTest2(sptr<IRemoteObject> proxy, MessageParcel& sen
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_SET_BACKGROUND_BLUR),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_SET_APLPHA),
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_SET_ALPHA),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_UPDATE_LAYOUT_MODE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_MAXMIZE_WINDOW),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_UPDATE_PROPERTY),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_GET_ACCCESSIBILITY_WIDDOW_INFO_ID),
static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IWindowManager::WindowManagerMessage::TRANS_ID_ANIMATION_SET_CONTROLLER),
+2 -2
View File
@@ -268,8 +268,8 @@ config("wm_systemtest_common_public_config") {
"//third_party/googletest/googlemock/include",
# for abilityContext
"${ability_runtime_kits_path}/ability/ability_runtime/include",
"${ability_runtime_kits_path}/appkit/native/ability_runtime/context",
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
"//base/global/resource_management/interfaces/inner_api/include",
"//third_party/node/deps/icu-small/source/common",
"${ability_runtime_inner_api_path}/ability_manager/include",
@@ -16,7 +16,9 @@
// gtest
#include <gtest/gtest.h>
#include "ability_context_impl.h"
#include "ipc_skeleton.h"
#include "window.h"
#include "window_manager.h"
#include "window_option.h"
#include "window_scene.h"
#include "window_test_utils.h"
@@ -27,6 +29,17 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest"};
}
class TestCameraFloatWindowChangedListener : public ICameraFloatWindowChangedListener {
public:
uint32_t accessTokenId_ = 0;
bool isShowing_ = false;
void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) override;
};
class WindowAppFloatingWindowTest : public testing::Test {
public:
static void SetUpTestCase();
@@ -36,8 +49,19 @@ public:
static inline float virtualPixelRatio_ = 1.0;
static inline std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_ = nullptr;
static sptr<TestCameraFloatWindowChangedListener> testCameraFloatWindowChangedListener_;
};
sptr<TestCameraFloatWindowChangedListener> WindowAppFloatingWindowTest::testCameraFloatWindowChangedListener_ =
new TestCameraFloatWindowChangedListener();
void TestCameraFloatWindowChangedListener::OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing)
{
WLOGFI("TestCameraFloatWindowChangedListener [%{public}u, %{public}u]", accessTokenId, isShowing);
accessTokenId_ = accessTokenId;
isShowing_ = isShowing;
}
void WindowAppFloatingWindowTest::SetUpTestCase()
{
auto display = DisplayManager::GetInstance().GetDisplayById(0);
@@ -308,5 +332,65 @@ HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, Function | MediumTest
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
}
/**
* @tc.name: AppFloatingWindow10
* @tc.desc: Camera AppFloatingWindow multi create
* @tc.type: FUNC
*/
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow10, Function | MediumTest | Level3)
{
sptr<WindowScene> scene = CreateWindowScene();
ASSERT_NE(nullptr, scene);
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
ASSERT_NE(nullptr, fltWin);
sptr<Window> fltWin2 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
ASSERT_EQ(nullptr, fltWin2);
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
sptr<Window> fltWin3 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
ASSERT_NE(nullptr, fltWin3);
ASSERT_EQ(WMError::WM_OK, fltWin3->Destroy());
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
}
/**
* @tc.name: AppFloatingWindow11
* @tc.desc: Camera AppFloatingWindow listener
* @tc.type: FUNC
*/
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow11, Function | MediumTest | Level2)
{
uint32_t tokenId = static_cast<uint32_t>(IPCSkeleton::GetCallingTokenID());
WindowManager::GetInstance().RegisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_);
sptr<WindowScene> scene = CreateWindowScene();
ASSERT_NE(nullptr, scene);
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
ASSERT_NE(nullptr, fltWin);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
usleep(500000); // 500000us = 0.5s
ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_);
ASSERT_EQ(true, testCameraFloatWindowChangedListener_->isShowing_);
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
usleep(500000); // 500000us = 0.5s
ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_);
ASSERT_EQ(false, testCameraFloatWindowChangedListener_->isShowing_);
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
WindowManager::GetInstance().UnregisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_);
}
} // namespace Rosen
} // namespace OHOS
+8
View File
@@ -153,6 +153,14 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas02, Function | MediumTest | Level3)
rects.emplace_back(Rect{ 0, 0, windowRect.width_ / 2, 0 });
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetTouchHotAreas(rects));
rects.clear();
rects.emplace_back(Rect{ windowRect.width_, 0, windowRect.width_ / 2, windowRect.height_ / 2 });
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetTouchHotAreas(rects));
rects.clear();
rects.emplace_back(Rect{ 0, windowRect.height_, windowRect.width_ / 2, windowRect.height_ / 2 });
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetTouchHotAreas(rects));
std::vector<Rect> requestedTouchHotAreas;
window->GetRequestedTouchHotAreas(requestedTouchHotAreas);
ASSERT_TRUE(requestedTouchHotAreas.empty());
@@ -36,7 +36,7 @@ namespace {
}
using utils = WindowTestUtils;
constexpr int WAIT_ASYNC_MS_TIME_OUT = 1500; // 1500ms
constexpr int WAIT_ASYNC_MS_TIME_OUT = 2000; // 2000ms
#define CHECK_DISPLAY_POWER_STATE_RETURN() \
do { \
@@ -327,6 +327,49 @@ end:
window2->Destroy();
subWindow2->Destroy();
}
/**
* @tc.name: WindowVisibilityInfoTest04
* @tc.desc: add two main window and sub windows and test callback
* @tc.type: FUNC
*/
HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest04, Function | MediumTest | Level1)
{
floatAppInfo_.name = "window1";
floatAppInfo_.rect = {0, 0, 300, 600};
sptr<Window> window1 = utils::CreateTestWindow(floatAppInfo_);
floatAppInfo_.name = "window2";
floatAppInfo_.rect = {0, 0, 300, 300};
sptr<Window> window2 = utils::CreateTestWindow(floatAppInfo_);
floatAppInfo_.name = "window3";
floatAppInfo_.rect = {0, 300, 300, 300};
sptr<Window> window3 = utils::CreateTestWindow(floatAppInfo_);
ASSERT_EQ(WMError::WM_OK, window1->Show());
WaitForCallback();
CHECK_DISPLAY_POWER_STATE_RETURN();
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
ResetCallbackCalledFLag();
ASSERT_EQ(WMError::WM_OK, window2->Show());
WaitForCallback();
CHECK_DISPLAY_POWER_STATE_RETURN();
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
ResetCallbackCalledFLag();
ASSERT_EQ(WMError::WM_OK, window3->Show());
WaitForCallback();
CHECK_DISPLAY_POWER_STATE_RETURN();
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
ResetCallbackCalledFLag();
end:
window1->Destroy();
window2->Destroy();
window3->Destroy();
}
}
} // namespace Rosen
} // namespace OHOS
+2 -2
View File
@@ -144,8 +144,8 @@ config("wm_unittest_common_public_config") {
"//third_party/googletest/googlemock/include",
# for abilityContext
"${ability_runtime_kits_path}/ability/ability_runtime/include",
"${ability_runtime_kits_path}/appkit/native/ability_runtime/context",
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
"//base/global/resource_management/interfaces/inner_api/include",
"//third_party/node/deps/icu-small/source/common",
"${ability_runtime_inner_api_path}/ability_manager/include",
+1 -1
View File
@@ -18,7 +18,7 @@
#include <gmock/gmock.h>
#include "ability_context_impl.h"
#include "foundation/ability/ability_runtime/frameworks/kits/appkit/native/ability_runtime/context/context.h"
#include "foundation/ability/ability_runtime/interfaces/kits/native/appkit/ability_runtime/context/context.h"
#include "static_call.h"
namespace OHOS {
-1
View File
@@ -32,7 +32,6 @@ public:
MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level));
MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha));
MOCK_METHOD2(UpdateProperty, WMError(sptr<WindowProperty>& windowProperty, PropertyChangeAction action));
MOCK_METHOD1(MaxmizeWindow, WMError(uint32_t windowId));
};
}
} // namespace OHOS
+2 -2
View File
@@ -1309,7 +1309,7 @@ HWTEST_F(WindowImplTest, SetTouchable02, Function | SmallTest | Level3)
/**
* @tc.name: DisableAppWindowDecor01
* @tc.desc: disbale app window decor
* @tc.desc: disable app window decor
* @tc.type: FUNC
*/
HWTEST_F(WindowImplTest, DisableAppWindowDecor01, Function | SmallTest | Level3)
@@ -1323,7 +1323,7 @@ HWTEST_F(WindowImplTest, DisableAppWindowDecor01, Function | SmallTest | Level3)
window->DisableAppWindowDecor();
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_FALSE(window->isAppDecorEnbale_);
ASSERT_FALSE(window->isAppDecorEnable_);
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
+2 -2
View File
@@ -62,7 +62,7 @@ public:
private:
std::vector<sptr<WindowNode>>* GetWindowNodesByDisplayIdAndRootType(DisplayId displayId, WindowRootNodeType type);
void AddWindowNodeOnWindowTree(sptr<WindowNode>& node, WindowRootNodeType rootType);
void ProcessNotCrossNodesOnDestroiedDisplay(DisplayId displayId, std::vector<uint32_t>& windowIds);
void ProcessNotCrossNodesOnDestroyedDisplay(DisplayId displayId, std::vector<uint32_t>& windowIds);
void ProcessDisplaySizeChangeOrRotation(DisplayId defaultDisplayId, DisplayId displayId,
const std::map<DisplayId, Rect>& displayRectMap, DisplayStateChangeType type);
void ProcessCrossNodes(DisplayId defaultDisplayId, DisplayStateChangeType type);
@@ -72,7 +72,7 @@ private:
void UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode>& node,
const std::vector<DisplayId>& curShowingDisplays);
void UpdateWindowDisplayId(const sptr<WindowNode>& node, DisplayId newDisplayId);
void ClearMapOfDestroiedDisplay(DisplayId displayId);
void ClearMapOfDestroyedDisplay(DisplayId displayId);
void ChangeToRectInDisplayGroup(const sptr<WindowNode>& node);
sptr<WindowNodeContainer> windowNodeContainer_;
+2 -2
View File
@@ -26,7 +26,7 @@
namespace OHOS {
namespace Rosen {
enum class MinimizeReason : uint32_t {
MINIMIZE_BUTTOM,
MINIMIZE_BUTTON,
MINIMIZE_ALL,
LAYOUT_TILE,
MAX_APP_COUNT,
@@ -51,7 +51,7 @@ public:
private:
static inline bool IsFromUser(MinimizeReason reason)
{
return (reason == MinimizeReason::MINIMIZE_ALL || reason == MinimizeReason::MINIMIZE_BUTTOM ||
return (reason == MinimizeReason::MINIMIZE_ALL || reason == MinimizeReason::MINIMIZE_BUTTON ||
reason == MinimizeReason::MAX_APP_COUNT || reason == MinimizeReason::LAYOUT_TILE ||
reason == MinimizeReason::SPLIT_REPLACE || reason == MinimizeReason::SPLIT_QUIT);
}
-1
View File
@@ -51,7 +51,6 @@ public:
WMError ProcessPointUp(uint32_t windowId);
void MinimizeAllAppWindows(DisplayId displayId);
WMError ToggleShownStateForAllAppWindows();
WMError MaxmizeWindow(uint32_t windowId);
WMError SetWindowLayoutMode(WindowLayoutMode mode);
WMError UpdateProperty(sptr<WindowProperty>& property, PropertyChangeAction action);
void NotifySystemBarTints();
+2 -2
View File
@@ -89,7 +89,7 @@ protected:
void LimitFloatingWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect) const;
void LimitMainFloatingWindowPosition(const sptr<WindowNode>& node, Rect& winRect) const;
void UpdateFloatongWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
void UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
const Rect& displayRect, Rect& winRect) const;
void UpdateFloatingWindowSizeByCustomizedLimits(const sptr<WindowNode>& node,
const Rect& displayRect, Rect& winRect) const;
@@ -113,7 +113,7 @@ protected:
Rect secondaryLimitRect_;
Rect dividerRect_;
Rect firstCascadeRect_;
std::vector<int32_t> exitSplitPoints_; // 2 element, first elment < second element
std::vector<int32_t> exitSplitPoints_; // 2 element, first element < second element
std::vector<int32_t> splitRatioPoints_;
};
sptr<DisplayGroupInfo> displayGroupInfo_;
@@ -35,6 +35,7 @@ public:
void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints);
void NotifyAccessibilityWindowInfo(const sptr<AccessibilityWindowInfo>& windowInfo, WindowUpdateType type);
void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos);
void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing);
private:
WindowManagerAgentController() {}
+4 -1
View File
@@ -23,6 +23,7 @@
#include <nocopyable.h>
#include <system_ability.h>
#include <window_manager_service_handler_stub.h>
#include <transaction/rs_interfaces.h>
#include "display_change_listener.h"
#include "drag_controller.h"
#include "freeze_controller.h"
@@ -83,7 +84,6 @@ public:
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
void MinimizeAllAppWindows(DisplayId displayId) override;
WMError ToggleShownStateForAllAppWindows() override;
WMError MaxmizeWindow(uint32_t windowId) override;
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
WMError GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>& windowInfo) override;
@@ -111,6 +111,8 @@ private:
bool Init();
void RegisterSnapshotHandler();
void RegisterWindowManagerServiceHandler();
void RegisterWindowVisibilityChangeCallback();
void WindowVisibilityChangeCallback(std::shared_ptr<RSOcclusionData> occlusionData);
void OnWindowEvent(Event event, const sptr<IRemoteObject>& remoteObject);
void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
@@ -131,6 +133,7 @@ private:
SystemConfig systemConfig_;
ModeChangeHotZonesConfig hotZonesConfig_ { false, 0, 0, 0 };
std::unique_ptr<WindowTaskLooper> wmsTaskLooper_;
RSInterfaces& rsInterface_;
bool startingOpen_ = true;
};
}
+2 -1
View File
@@ -104,6 +104,7 @@ public:
const Rect& GetOriginRect() const;
void ResetWindowSizeChangeReason();
void GetTouchHotAreas(std::vector<Rect>& rects) const;
uint32_t GetAccessTokenId() const;
sptr<WindowNode> parent_;
std::vector<sptr<WindowNode>> children_;
@@ -115,7 +116,7 @@ public:
int32_t priority_ { 0 };
bool requestedVisibility_ { false };
bool currentVisibility_ { false };
bool isCovered_ { true }; // initial value true to ensure notification when this window is shown
bool isVisible_ { false };
bool isAppCrash_ { false };
bool isPlayAnimationShow_ { false };
bool isPlayAnimationHide_ { false };
+4 -6
View File
@@ -81,7 +81,6 @@ public:
bool IsAppWindowsEmpty() const;
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
void NotifySystemBarTints(std::vector<DisplayId> displayIdVec);
void NotifySystemBarDismiss(sptr<WindowNode>& node);
WMError MinimizeAppNodeExceptOptions(MinimizeReason reason, const std::vector<uint32_t> &exceptionalIds = {},
const std::vector<WindowMode> &exceptionalModes = {});
WMError SetWindowMode(sptr<WindowNode>& node, WindowMode dstMode);
@@ -103,9 +102,10 @@ public:
sptr<WindowLayoutPolicy> GetLayoutPolicy() const;
sptr<AvoidAreaController> GetAvoidController() const;
sptr<DisplayGroupController> GetMutiDisplayController() const;
sptr<DisplayGroupController> GetMultiDisplayController() const;
sptr<WindowNode> GetRootNode(WindowRootNodeType type) const;
void NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable);
void UpdateCameraFloatWindowStatus(const sptr<WindowNode>& node, bool isShowing);
private:
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
@@ -130,9 +130,7 @@ private:
bool IsSplitImmersiveNode(sptr<WindowNode> node) const;
bool TraverseFromTopToBottom(sptr<WindowNode> node, const WindowNodeOperationFunc& func) const;
bool TraverseFromBottomToTop(sptr<WindowNode> node, const WindowNodeOperationFunc& func) const;
void RcoveryScreenDefaultOrientationIfNeed(DisplayId displayId);
// cannot determine in case of a window covered by union of several windows or with transparent value
void UpdateWindowVisibilityInfos(std::vector<sptr<WindowVisibilityInfo>>& infos);
void RecoverScreenDefaultOrientationIfNeed(DisplayId displayId);
void RaiseOrderedWindowToTop(std::vector<sptr<WindowNode>>& orderedNodes,
std::vector<sptr<WindowNode>>& windowNodes);
static bool ReadIsWindowAnimationEnabledProperty();
@@ -160,7 +158,7 @@ private:
std::map<uint32_t, WindowMode> backupWindowMode_;
std::map<DisplayId, Rect> backupDividerWindowRect_;
sptr<WindowZorderPolicy> zorderPolicy_ = new WindowZorderPolicy();
std::unordered_map<WindowLayoutMode, sptr<WindowLayoutPolicy>> layoutPolicys_;
std::unordered_map<WindowLayoutMode, sptr<WindowLayoutPolicy>> layoutPolicies_;
WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE;
std::vector<Rect> currentCoveredArea_;
std::vector<uint32_t> removedIds_;
+4 -4
View File
@@ -51,7 +51,7 @@ public:
/**
* Constructor used to create an empty WindowPair instance.
*
* @param displayId the disply of window pair
* @param displayId the display of window pair
* @param appNode the window root of app window
*/
WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree);
@@ -221,7 +221,7 @@ private:
void DumpPairInfo();
/**
* Find pairable window frome window trees.
* Find pairable window from window trees.
*
* @param node the node waiting to be paired
* @return window node
@@ -237,7 +237,7 @@ private:
sptr<WindowNode> GetPairableWindow(sptr<WindowNode>& node);
/**
* Send brodcast message of split event.
* Send broadcast message of split event.
*
* @param node trigger node
*/
@@ -253,7 +253,7 @@ private:
WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY};
DisplayGroupWindowTree& displayGroupWindowTree_;
bool isAllAppWindowsRestoring_ { false };
Rect initalDivderRect_ {0, 0, 0, 0};
Rect initalDividerRect_ {0, 0, 0, 0};
};
} // namespace Rosen
} // namespace OHOS
+7 -1
View File
@@ -17,6 +17,7 @@
#include <refbase.h>
#include <iremote_object.h>
#include <transaction/rs_interfaces.h>
#include "agent_death_recipient.h"
#include "display_manager_service_inner.h"
@@ -51,6 +52,8 @@ public:
bool IsForbidDockSliceMove(DisplayId displayId) const;
bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const;
void ExitSplitMode(DisplayId displayId);
void NotifyWindowVisibilityChange(std::shared_ptr<RSOcclusionData> occlusionData);
void AddSurfaceNodeIdWindowNodePair(uint64_t surfaceNodeId, sptr<WindowNode> node);
WMError RequestFocus(uint32_t windowId);
WMError RequestActiveWindow(uint32_t windowId);
@@ -61,7 +64,6 @@ public:
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId);
void MinimizeAllAppWindows(DisplayId displayId);
WMError ToggleShownStateForAllAppWindows();
WMError MaxmizeWindow(uint32_t windowId);
WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode);
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
@@ -114,8 +116,12 @@ private:
void MoveNotShowingWindowToDefaultDisplay(DisplayId defaultDisplayId, DisplayId displayId);
WMError PostProcessAddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode,
sptr<WindowNodeContainer>& container);
std::vector<std::pair<uint64_t, bool>> GetWindowVisibilityChangeInfo(
std::shared_ptr<RSOcclusionData> occlusionData);
std::map<uint32_t, sptr<WindowNode>> windowNodeMap_;
std::map<sptr<IRemoteObject>, uint32_t> windowIdMap_;
std::map<uint64_t, sptr<WindowNode>> surfaceIdWindowNodeMap_;
std::shared_ptr<RSOcclusionData> lastOcclusionData_ = std::make_shared<RSOcclusionData>();
std::map<ScreenId, sptr<WindowNodeContainer>> windowNodeContainerMap_;
std::map<ScreenId, std::vector<DisplayId>> displayIdMap_;
@@ -50,11 +50,10 @@ public:
TRANS_ID_MINIMIZE_ALL_APP_WINDOWS,
TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS,
TRANS_ID_SET_BACKGROUND_BLUR,
TRANS_ID_SET_APLPHA,
TRANS_ID_SET_ALPHA,
TRANS_ID_UPDATE_LAYOUT_MODE,
TRANS_ID_MAXMIZE_WINDOW,
TRANS_ID_UPDATE_PROPERTY,
TRANS_ID_GET_ACCCESSIBILITY_WIDDOW_INFO_ID,
TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID,
TRANS_ID_ANIMATION_SET_CONTROLLER,
TRANS_ID_GET_SYSTEM_CONFIG,
TRANS_ID_NOTIFY_WINDOW_TRANSITION,
@@ -76,7 +75,6 @@ public:
virtual void ProcessPointUp(uint32_t windowId) = 0;
virtual void MinimizeAllAppWindows(DisplayId displayId) = 0;
virtual WMError ToggleShownStateForAllAppWindows() = 0;
virtual WMError MaxmizeWindow(uint32_t windowId) = 0;
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) = 0;
virtual void RegisterWindowManagerAgent(WindowManagerAgentType type,
@@ -44,7 +44,6 @@ public:
void ProcessPointUp(uint32_t windowId) override;
void MinimizeAllAppWindows(DisplayId displayId) override;
WMError ToggleShownStateForAllAppWindows() override;
WMError MaxmizeWindow(uint32_t windowId) override;
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
+3 -3
View File
@@ -46,7 +46,7 @@ void AvoidAreaController::UpdateAvoidNodesMap(DisplayId displayId, bool isAdd)
bool AvoidAreaController::IsAvoidAreaNode(const sptr<WindowNode>& node) const
{
if (node == nullptr) {
WLOGFE("IsAvoidAreaNode Failed, node is nullprt");
WLOGFE("IsAvoidAreaNode Failed, node is nullptr");
return false;
}
@@ -96,7 +96,7 @@ WMError AvoidAreaController::AvoidControl(const sptr<WindowNode>& node, AvoidCon
WLOGFE("WinId:%{public}d is added. AvoidControl Add Failed. Type: %{public}u", windowId, type);
return WMError::WM_ERROR_INVALID_PARAM;
}
// do not update or removew a unexist node
// do not update or remove a non-exist node
if (type != AvoidControlType::AVOID_NODE_ADD && iter == avoidNodes->end()) {
WLOGFE("WinId:%{public}d not exist. AvoidControl Update or Remove Failed. Type: %{public}u", windowId, type);
return WMError::WM_ERROR_INVALID_PARAM;
@@ -120,7 +120,7 @@ WMError AvoidAreaController::AvoidControl(const sptr<WindowNode>& node, AvoidCon
return WMError::WM_ERROR_INVALID_PARAM;
}
// get all Area info and notify windowcontainer
// get all Area info and notify window container
std::vector<Rect> avoidAreas = GetAvoidArea(node->GetDisplayId());
DumpAvoidArea(avoidAreas);
UseCallbackNotifyAvoidAreaChanged(avoidAreas, node->GetDisplayId());
+8 -8
View File
@@ -174,7 +174,7 @@ void DisplayGroupController::UpdateWindowShowingDisplays(const sptr<WindowNode>&
void DisplayGroupController::UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode>& node,
const std::vector<DisplayId>& curShowingDisplays)
{
// current mutiDisplay is only support left-right combination, maxNum is two
// current multi-display is only support left-right combination, maxNum is two
DisplayId newDisplayId = node->GetDisplayId();
if (curShowingDisplays.size() == 1) {
newDisplayId = *(curShowingDisplays.begin());
@@ -232,7 +232,7 @@ void DisplayGroupController::PreProcessWindowNode(const sptr<WindowNode>& node,
PreProcessWindowNode(childNode, type);
}
}
WLOGFI("Current mode is not muti-display");
WLOGFI("Current mode is not multi-display");
return;
}
@@ -314,7 +314,7 @@ void DisplayGroupController::MoveNotCrossNodeToDefaultDisplay(const sptr<WindowN
}
}
void DisplayGroupController::ProcessNotCrossNodesOnDestroiedDisplay(DisplayId displayId,
void DisplayGroupController::ProcessNotCrossNodesOnDestroyedDisplay(DisplayId displayId,
std::vector<uint32_t>& windowIds)
{
if (displayId == defaultDisplayId_) {
@@ -333,11 +333,11 @@ void DisplayGroupController::ProcessNotCrossNodesOnDestroiedDisplay(DisplayId di
if (node->GetDisplayId() != displayId || node->isShowingOnMultiDisplays_) {
continue;
}
// destroy status and navigati
// destroy status and navigation bar
if (node->GetWindowType() == WindowType::WINDOW_TYPE_STATUS_BAR ||
node->GetWindowType() == WindowType::WINDOW_TYPE_NAVIGATION_BAR) {
windowNodeContainer_->DestroyWindowNode(node, windowIds);
WLOGFI("destroy status or navigationbar on destroied display, windowId: %{public}d",
WLOGFI("destroy status or navigation bar on destroyed display, windowId: %{public}d",
node->GetWindowId());
continue;
}
@@ -380,11 +380,11 @@ void DisplayGroupController::ProcessDisplayDestroy(DisplayId defaultDisplayId, s
windowNodeContainer_->GetAvoidController()->UpdateAvoidNodesMap(displayId, false);
// delete nodes and map element of deleted display
ProcessNotCrossNodesOnDestroiedDisplay(displayId, windowIds);
ProcessNotCrossNodesOnDestroyedDisplay(displayId, windowIds);
// modify RSTree and window tree of displayGroup for cross-display nodes
ProcessCrossNodes(defaultDisplayId, DisplayStateChangeType::DESTROY);
UpdateDisplayGroupWindowTree();
ClearMapOfDestroiedDisplay(displayId);
ClearMapOfDestroyedDisplay(displayId);
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplayDestroy(displayId, displayRectMap);
}
@@ -423,7 +423,7 @@ void DisplayGroupController::ProcessDisplaySizeChangeOrRotation(DisplayId defaul
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplaySizeChangeOrRotation(displayId, displayRectMap);
}
void DisplayGroupController::ClearMapOfDestroiedDisplay(DisplayId displayId)
void DisplayGroupController::ClearMapOfDestroyedDisplay(DisplayId displayId)
{
sysBarTintMaps_.erase(displayId);
sysBarNodeMaps_.erase(displayId);
+5 -5
View File
@@ -96,7 +96,7 @@ void InputWindowMonitor::UpdateDisplayInfo(const sptr<DisplayInfo>& displayInfo,
if (displayInfo->GetRotation() == Rotation::ROTATION_90 || displayInfo->GetRotation() == Rotation::ROTATION_270) {
std::swap(displayWidth, displayHeight);
}
MMI::DisplayInfo diplay = {
MMI::DisplayInfo display = {
.id = static_cast<int32_t>(displayInfo->GetDisplayId()),
.x = displayInfo->GetOffsetX(),
.y = displayInfo->GetOffsetY(),
@@ -107,13 +107,13 @@ void InputWindowMonitor::UpdateDisplayInfo(const sptr<DisplayInfo>& displayInfo,
.direction = GetDisplayDirectionForMmi(displayInfo->GetRotation()),
};
auto displayIter = std::find_if(displayInfoVector.begin(), displayInfoVector.end(),
[&diplay](MMI::DisplayInfo& displayInfoTmp) {
return displayInfoTmp.id == diplay.id;
[&display](MMI::DisplayInfo& displayInfoTmp) {
return displayInfoTmp.id == display.id;
});
if (displayIter != displayInfoVector.end()) {
*displayIter = diplay;
*displayIter = display;
} else {
displayInfoVector.emplace_back(diplay);
displayInfoVector.emplace_back(display);
}
}
+5 -5
View File
@@ -115,7 +115,7 @@ WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> sr
WLOGFE("RSWindowAnimation: no startingWindow for dst window id:%{public}u!", dstNode->GetWindowId());
return WMError::WM_ERROR_NO_REMOTE_ANIMATION;
}
WLOGFI("RSWindowAnimation: nofity animation transition with dst currId:%{public}u!", dstNode->GetWindowId());
WLOGFI("RSWindowAnimation: notify animation transition with dst currId:%{public}u!", dstNode->GetWindowId());
sptr<RSWindowAnimationFinishedCallback> finishedCallback = new(std::nothrow) RSWindowAnimationFinishedCallback(
[]() {
WLOGFI("RSWindowAnimation: on finish transition with minimizeAll!");
@@ -173,7 +173,7 @@ WMError RemoteAnimation::NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcI
if (srcTarget == nullptr) {
return WMError::WM_ERROR_NO_MEM;
}
WLOGFI("RSWindowAnimation: nofity animation minimize Id:%{public}u!", srcNode->GetWindowId());
WLOGFI("RSWindowAnimation: notify animation minimize Id:%{public}u!", srcNode->GetWindowId());
srcNode->isPlayAnimationHide_ = true;
wptr<WindowNode> weak = srcNode;
auto minimizeFunc = [weak]() {
@@ -203,7 +203,7 @@ WMError RemoteAnimation::NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo
if (srcTarget == nullptr) {
return WMError::WM_ERROR_NO_MEM;
}
WLOGFI("RSWindowAnimation: nofity animation close id:%{public}u!", srcNode->GetWindowId());
WLOGFI("RSWindowAnimation: notify animation close id:%{public}u!", srcNode->GetWindowId());
srcNode->isPlayAnimationHide_ = true;
wptr<WindowNode> weak = srcNode;
auto closeFunc = [weak, event]() {
@@ -309,9 +309,9 @@ sptr<RSWindowAnimationTarget> RemoteAnimation::CreateWindowAnimationTarget(sptr<
}
auto& stagingProperties = windowAnimationTarget->surfaceNode_->GetStagingProperties();
auto bounds = stagingProperties.GetBounds();
auto rect = windowNode->GetWindowRect();
// 0, 1, 2, 3: convert bounds to RectF
auto boundsRect = RectF(bounds[0], bounds[1], bounds[2], bounds[3]);
auto boundsRect = RectF(rect.posX_, rect.posY_, rect.width_, rect.height_);
windowAnimationTarget->windowBounds_ = RRect(boundsRect, stagingProperties.GetCornerRadius());
return windowAnimationTarget;
}
+9
View File
@@ -42,6 +42,7 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> inf
property->SetWindowMode(info->GetWindowMode());
property->SetDisplayId(info->GetDisplayId());
property->SetWindowType(info->GetWindowType());
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
if (info->GetShowFlagWhenLocked()) {
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
}
@@ -97,6 +98,9 @@ void StartingWindow::DrawStartingWindow(sptr<WindowNode>& node,
return;
}
Rect rect = node->GetWindowRect();
if (RemoteAnimation::CheckAnimationController() && node->leashWinSurfaceNode_) {
node->leashWinSurfaceNode_->SetBounds(rect.posX_, rect.posY_, -1, -1);
}
if (pixelMap == nullptr) {
surfaceDraw_.DrawBackgroundColor(node->startingWinSurfaceNode_, rect, bkgColor);
return;
@@ -176,6 +180,11 @@ void StartingWindow::UpdateRSTree(sptr<WindowNode>& node)
} else { // to launcher
dms.UpdateRSTree(shownDisplayId, node->surfaceNode_, true);
}
for (auto& child : node->children_) {
if (child->currentVisibility_) {
dms.UpdateRSTree(shownDisplayId, child->surfaceNode_, true);
}
}
}
}
};
+14 -17
View File
@@ -35,7 +35,7 @@ namespace OHOS {
namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowController"};
constexpr uint32_t TOIUCH_HOT_AREA_MAX_NUM = 10;
constexpr uint32_t TOUCH_HOT_AREA_MAX_NUM = 10;
}
uint32_t WindowController::GenWindowId()
@@ -170,6 +170,7 @@ WMError WindowController::CreateWindow(sptr<IWindow>& window, sptr<WindowPropert
if (node != nullptr && WindowHelper::IsMainWindow(property->GetWindowType()) && node->startingWindowShown_) {
StartingWindow::HandleClientWindowCreate(node, window, windowId, surfaceNode, property, pid, uid);
windowRoot_->AddDeathRecipient(node);
windowRoot_->AddSurfaceNodeIdWindowNodePair(surfaceNode->GetId(), node);
return WMError::WM_OK;
}
windowId = GenWindowId();
@@ -622,7 +623,7 @@ WMError WindowController::ProcessPointDown(uint32_t windowId, bool isStartDrag)
return WMError::WM_ERROR_NULLPTR;
}
if (!node->currentVisibility_) {
WLOGFE("this window is not visibile and not in window tree, windowId: %{public}u", windowId);
WLOGFE("this window is not visible and not in window tree, windowId: %{public}u", windowId);
return WMError::WM_ERROR_INVALID_OPERATION;
}
@@ -690,17 +691,6 @@ WMError WindowController::ToggleShownStateForAllAppWindows()
return windowRoot_->ToggleShownStateForAllAppWindows();
}
WMError WindowController::MaxmizeWindow(uint32_t windowId)
{
WMError ret = SetWindowMode(windowId, WindowMode::WINDOW_MODE_FULLSCREEN);
if (ret != WMError::WM_OK) {
return ret;
}
ret = windowRoot_->MaxmizeWindow(windowId);
FlushWindowInfo(windowId);
return ret;
}
WMError WindowController::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
{
return windowRoot_->GetTopWindowId(mainWinId, topWinId);
@@ -871,15 +861,22 @@ WMError WindowController::UpdateTouchHotAreas(const sptr<WindowNode>& node, cons
}
WLOGFI("windowId: %{public}u, size: %{public}d, rects: %{public}s",
node->GetWindowId(), static_cast<int32_t>(rects.size()), oss.str().c_str());
Rect windowRect = node->GetWindowRect();
std::vector<Rect> hotAreas;
if (rects.size() > TOIUCH_HOT_AREA_MAX_NUM || !WindowHelper::CalculateTouchHotAreas(windowRect, rects, hotAreas)) {
if (rects.size() > TOUCH_HOT_AREA_MAX_NUM) {
WLOGFE("the number of touch hot areas exceeds the maximum");
return WMError::WM_ERROR_INVALID_PARAM;
}
node->GetWindowProperty()->SetTouchHotAreas(rects);
std::vector<Rect> hotAreas;
if (rects.empty()) {
hotAreas.emplace_back(node->GetFullWindowHotArea());
} else {
Rect windowRect = node->GetWindowRect();
if (!WindowHelper::CalculateTouchHotAreas(windowRect, rects, hotAreas)) {
WLOGFE("the requested touch hot areas are incorrect");
return WMError::WM_ERROR_INVALID_PARAM;
}
}
node->GetWindowProperty()->SetTouchHotAreas(rects);
node->SetTouchHotAreas(hotAreas);
FlushWindowInfo(node->GetWindowId());
return WMError::WM_OK;
+2
View File
@@ -166,6 +166,7 @@ WMError WindowDumper::DumpSpecifiedWindowInfo(uint32_t windowId, const std::vect
}
Rect rect = node->GetWindowRect();
std::string isShown_ = node->startingWindowShown_ ? "true" : "false";
std::string isVisible = node->isVisible_ ? "true" : "false";
std::ostringstream oss;
oss << "WindowName: " << node->GetWindowName() << std::endl;
oss << "DisplayId: " << node->GetDisplayId() << std::endl;
@@ -176,6 +177,7 @@ WMError WindowDumper::DumpSpecifiedWindowInfo(uint32_t windowId, const std::vect
oss << "Flag: " << node->GetWindowFlags() << std::endl;
oss << "Orientation: " << static_cast<uint32_t>(node->GetRequestedOrientation()) << std::endl;
oss << "IsStartingWindow: " << isShown_ << std::endl;
oss << "IsVisible: " << isVisible << std::endl;
oss << "WindowRect: " << "[ "
<< rect.posX_ << ", " << rect.posY_ << ", " << rect.width_ << ", " << rect.height_
<< " ]" << std::endl;
+2 -2
View File
@@ -80,13 +80,13 @@ void WindowInnerManager::Stop()
void WindowInnerManager::HandleCreateWindow(std::string name, WindowType type, Rect rect)
{
auto dialogCallback = [this](int32_t id, const std::string& event, const std::string& params) {
if (params == "EVENT_CANCLE_CODE") {
if (params == "EVENT_CANCEL_CODE") {
Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
}
};
Ace::UIServiceMgrClient::GetInstance()->ShowDialog(name, dividerParams_, type,
rect.posX_, rect.posY_, rect.width_, rect.height_, dialogCallback, &dialogId_);
WLOGFI("create inner window id: %{public}d succes", dialogId_);
WLOGFI("create inner window id: %{public}d success", dialogId_);
return;
}
+16 -14
View File
@@ -85,7 +85,7 @@ void WindowLayoutPolicy::LimitWindowToBottomRightCorner(const sptr<WindowNode>&
void WindowLayoutPolicy::UpdateDisplayGroupRect()
{
Rect newDisplayGroupRect = { 0, 0, 0, 0 };
// current mutiDisplay is only support left-right combination, maxNum is two
// current multi-display is only support left-right combination, maxNum is two
for (auto& elem : displayGroupInfo_->GetAllDisplayRects()) {
newDisplayGroupRect.posX_ = std::min(displayGroupRect_.posX_, elem.second.posX_);
newDisplayGroupRect.posY_ = std::min(displayGroupRect_.posY_, elem.second.posY_);
@@ -151,10 +151,10 @@ void WindowLayoutPolicy::UpdateMultiDisplayFlag()
{
if (displayGroupInfo_->GetAllDisplayRects().size() > 1) {
isMultiDisplay_ = true;
WLOGFI("current mode is muti-display");
WLOGFI("current mode is multi-display");
} else {
isMultiDisplay_ = false;
WLOGFI("current mode is not muti-display");
WLOGFI("current mode is not multi-display");
}
}
@@ -448,7 +448,9 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(const Rect& winRect, const sptr<W
if (requestedHotAreas.empty()) {
hotAreas.emplace_back(rect);
} else {
(void)WindowHelper::CalculateTouchHotAreas(winRect, requestedHotAreas, hotAreas);
if (!WindowHelper::CalculateTouchHotAreas(winRect, requestedHotAreas, hotAreas)) {
WLOGFW("some parameters in requestedHotAreas are abnormal");
}
}
node->SetTouchHotAreas(hotAreas);
}
@@ -534,8 +536,8 @@ FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const R
uint32_t configuredMaxHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.maxHeight_ * virtualPixelRatio);
uint32_t configuredMinWidth = static_cast<uint32_t>(floatingWindowLimitsConfig_.minWidth_ * virtualPixelRatio);
uint32_t configuredMinHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.minHeight_ * virtualPixelRatio);
float configuerdMaxRatio = floatingWindowLimitsConfig_.maxRatio_;
float configuerdMinRatio = floatingWindowLimitsConfig_.minRatio_;
float configuredMaxRatio = floatingWindowLimitsConfig_.maxRatio_;
float configuredMinRatio = floatingWindowLimitsConfig_.minRatio_;
// calculate new limit size
if (systemLimits.minWidth_ <= configuredMaxWidth && configuredMaxWidth <= systemLimits.maxWidth_) {
@@ -556,11 +558,11 @@ FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const R
static_cast<float>(newLimitConfig.minHeight_);
newLimitConfig.minRatio_ = static_cast<float>(newLimitConfig.minWidth_) /
static_cast<float>(newLimitConfig.maxHeight_);
if (newLimitConfig.minRatio_ <= configuerdMaxRatio && configuerdMaxRatio <= newLimitConfig.maxRatio_) {
newLimitConfig.maxRatio_ = configuerdMaxRatio;
if (newLimitConfig.minRatio_ <= configuredMaxRatio && configuredMaxRatio <= newLimitConfig.maxRatio_) {
newLimitConfig.maxRatio_ = configuredMaxRatio;
}
if (newLimitConfig.minRatio_ <= configuerdMinRatio && configuerdMinRatio <= newLimitConfig.maxRatio_) {
newLimitConfig.minRatio_ = configuerdMinRatio;
if (newLimitConfig.minRatio_ <= configuredMinRatio && configuredMinRatio <= newLimitConfig.maxRatio_) {
newLimitConfig.minRatio_ = configuredMinRatio;
}
// recalculate limit size by new ratio
@@ -583,7 +585,7 @@ FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const R
return newLimitConfig;
}
void WindowLayoutPolicy::UpdateFloatongWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
const Rect& displayRect, Rect& winRect) const
{
if (node->GetWindowSizeChangeReason() == WindowSizeChangeReason::DRAG) {
@@ -707,7 +709,7 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
if (node->GetStretchable() &&
WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
UpdateFloatongWindowSizeForStretchableWindow(node, displayRect, winRect);
UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
}
// fix size in case of moving window when dragging
@@ -811,7 +813,7 @@ void WindowLayoutPolicy::LimitWindowPositionWhenInitRectOrMove(const sptr<Window
uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
Rect limitRect;
// if is corss-display window, the limit rect should be full limitRect
// if is cross-display window, the limit rect should be full limitRect
if (node->isShowingOnMultiDisplays_) {
limitRect = displayGroupLimitRect_;
} else {
@@ -994,7 +996,7 @@ void WindowLayoutPolicy::SetFloatingWindowLimitsConfig(const FloatingWindowLimit
Rect WindowLayoutPolicy::GetInitalDividerRect(DisplayId displayId) const
{
return IVALID_EMPTY_RECT;
return INVALID_EMPTY_RECT;
}
}
}
@@ -301,7 +301,7 @@ void WindowLayoutPolicyCascade::UpdateLayoutRect(const sptr<WindowNode>& node)
if (!floatingWindow) { // fullscreen window
winRect = limitRect;
} else { // floating window
if (subWindow && parentLimit) { // subwidow and limited by parent
if (subWindow && parentLimit) { // subwindow and limited by parent
limitRect = node->parent_->GetWindowRect();
UpdateFloatingLayoutRect(limitRect, winRect);
}
+3 -3
View File
@@ -271,7 +271,7 @@ void WindowLayoutPolicyTile::UpdateLayoutRect(const sptr<WindowNode>& node)
WLOGFE("window property is nullptr.");
return;
}
auto decorEnbale = property->GetDecorEnable();
auto decorEnable = property->GetDecorEnable();
bool needAvoid = (flags & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
bool parentLimit = (flags & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT));
bool subWindow = WindowHelper::IsSubWindow(type);
@@ -283,7 +283,7 @@ void WindowLayoutPolicyTile::UpdateLayoutRect(const sptr<WindowNode>& node)
WLOGFI("Id:%{public}u, avoid:%{public}d parLimit:%{public}d floating:%{public}d, sub:%{public}d, " \
"deco:%{public}d, type:%{public}u, requestRect:[%{public}d, %{public}d, %{public}u, %{public}u]",
node->GetWindowId(), needAvoid, parentLimit, floatingWindow, subWindow, decorEnbale,
node->GetWindowId(), needAvoid, parentLimit, floatingWindow, subWindow, decorEnable,
static_cast<uint32_t>(type), winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
if (needAvoid) {
limitRect = limitRectMap_[node->GetDisplayId()];
@@ -292,7 +292,7 @@ void WindowLayoutPolicyTile::UpdateLayoutRect(const sptr<WindowNode>& node)
if (!floatingWindow) { // fullscreen window
winRect = limitRect;
} else { // floating window
if (subWindow && parentLimit) { // subwidow and limited by parent
if (subWindow && parentLimit) { // subwindow and limited by parent
limitRect = node->parent_->GetWindowRect();
UpdateFloatingLayoutRect(limitRect, winRect);
}
@@ -74,5 +74,13 @@ void WindowManagerAgentController::UpdateWindowVisibilityInfo(
agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
}
}
void WindowManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
{
for (auto& agent : wmAgentContainer_.GetAgentsByType(
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) {
agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
}
}
} // namespace Rosen
} // namespace OHOS
+46 -10
View File
@@ -46,7 +46,8 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerService)
const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(&SingletonContainer::Get<WindowManagerService>());
WindowManagerService::WindowManagerService() : SystemAbility(WINDOW_MANAGER_SERVICE_ID, true)
WindowManagerService::WindowManagerService() : SystemAbility(WINDOW_MANAGER_SERVICE_ID, true),
rsInterface_(RSInterfaces::GetInstance())
{
windowRoot_ = new WindowRoot(
std::bind(&WindowManagerService::OnWindowEvent, this, std::placeholders::_1, std::placeholders::_2));
@@ -71,9 +72,53 @@ void WindowManagerService::OnStart()
DisplayManagerServiceInner::GetInstance().RegisterDisplayChangeListener(listener);
RegisterSnapshotHandler();
RegisterWindowManagerServiceHandler();
RegisterWindowVisibilityChangeCallback();
wmsTaskLooper_->Start();
}
void WindowManagerService::WindowVisibilityChangeCallback(std::shared_ptr<RSOcclusionData> occlusionData)
{
WLOGFD("NotifyWindowVisibilityChange: enter");
std::weak_ptr<RSOcclusionData> weak(occlusionData);
return wmsTaskLooper_->ScheduleTask([this, weak]() {
auto weakOcclusionData = weak.lock();
if (weakOcclusionData == nullptr) {
WLOGFE("weak occlusionData is nullptr");
return;
}
windowRoot_->NotifyWindowVisibilityChange(weakOcclusionData);
}).wait();
}
void WindowManagerService::RegisterWindowVisibilityChangeCallback()
{
auto windowVisibilityChangeCb = std::bind(&WindowManagerService::WindowVisibilityChangeCallback, this,
std::placeholders::_1);
if (rsInterface_.RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) {
WLOGFW("WindowManagerService::RegisterWindowVisibilityChangeCallback failed, create async thread!");
auto fun = [this, windowVisibilityChangeCb]() {
WLOGFI("WindowManagerService::RegisterWindowVisibilityChangeCallback async thread enter!");
int counter = 0;
while (rsInterface_.RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) {
usleep(10000); // 10000us equals to 10ms
counter++;
if (counter >= 2000) { // wait for 2000 * 10ms = 20s
WLOGFE("WindowManagerService::RegisterWindowVisibilityChangeCallback timeout!");
return;
}
}
WLOGFI("WindowManagerService::RegisterWindowVisibilityChangeCallback async thread register handler"
" successfully!");
};
std::thread thread(fun);
thread.detach();
WLOGFI("WindowManagerService::RegisterWindowVisibilityChangeCallback async thread has been detached!");
} else {
WLOGFI("WindowManagerService::RegisterWindowVisibilityChangeCallback OnStart succeed!");
}
}
void WindowManagerService::RegisterSnapshotHandler()
{
if (snapshotController_ == nullptr) {
@@ -546,14 +591,6 @@ WMError WindowManagerService::ToggleShownStateForAllAppWindows()
return WMError::WM_OK;
}
WMError WindowManagerService::MaxmizeWindow(uint32_t windowId)
{
return wmsTaskLooper_->ScheduleTask([this, windowId]() {
WM_SCOPED_TRACE("wms:MaxmizeWindow");
return windowController_->MaxmizeWindow(windowId);
}).get();
}
WMError WindowManagerService::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
{
return wmsTaskLooper_->ScheduleTask([this, &topWinId, mainWinId]() {
@@ -594,7 +631,6 @@ WMError WindowManagerService::GetAccessibilityWindowInfo(sptr<AccessibilityWindo
return WMError::WM_ERROR_NULLPTR;
}
return wmsTaskLooper_->ScheduleTask([this, &windowInfo]() {
WM_SCOPED_TRACE("wms:GetAccessibilityWindowInfo");
return windowRoot_->GetAccessibilityWindowInfo(windowInfo);
}).get();
}
+5
View File
@@ -348,5 +348,10 @@ void WindowNode::GetTouchHotAreas(std::vector<Rect>& rects) const
{
rects = touchHotAreas_;
}
uint32_t WindowNode::GetAccessTokenId() const
{
return property_->GetAccessTokenId();
}
} // namespace Rosen
} // namespace OHOS
+28 -99
View File
@@ -55,14 +55,14 @@ WindowNodeContainer::WindowNodeContainer(const sptr<DisplayInfo>& displayInfo, S
displayGroupController_->InitNewDisplay(displayId);
// init layout policy
layoutPolicys_[WindowLayoutMode::CASCADE] = new WindowLayoutPolicyCascade(displayGroupInfo_,
layoutPolicies_[WindowLayoutMode::CASCADE] = new WindowLayoutPolicyCascade(displayGroupInfo_,
displayGroupController_->displayGroupWindowTree_);
layoutPolicys_[WindowLayoutMode::TILE] = new WindowLayoutPolicyTile(displayGroupInfo_,
layoutPolicies_[WindowLayoutMode::TILE] = new WindowLayoutPolicyTile(displayGroupInfo_,
displayGroupController_->displayGroupWindowTree_);
layoutPolicy_ = layoutPolicys_[WindowLayoutMode::CASCADE];
layoutPolicy_ = layoutPolicies_[WindowLayoutMode::CASCADE];
layoutPolicy_->Launch();
Rect initalDividerRect = layoutPolicys_[WindowLayoutMode::CASCADE]->GetInitalDividerRect(displayId);
Rect initalDividerRect = layoutPolicies_[WindowLayoutMode::CASCADE]->GetInitalDividerRect(displayId);
displayGroupController_->SetInitalDividerRect(displayId, initalDividerRect);
// init avoidAreaController
UpdateAvoidAreaFunc func = std::bind(&WindowNodeContainer::OnAvoidAreaChange, this,
@@ -179,11 +179,9 @@ WMError WindowNodeContainer::AddWindowNode(sptr<WindowNode>& node, sptr<WindowNo
AssignZOrder();
layoutPolicy_->AddWindowNode(node);
NotifyIfAvoidAreaChanged(node, AvoidControlType::AVOID_NODE_ADD);
std::vector<sptr<WindowVisibilityInfo>> infos;
UpdateWindowVisibilityInfos(infos);
DumpScreenWindowTree();
NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_ADDED);
WLOGFI("AddWindowNode windowId: %{public}u end", node->GetWindowId());
UpdateCameraFloatWindowStatus(node, true);
if (WindowHelper::IsAppWindow(node->GetWindowType())) {
backupWindowIds_.clear();
}
@@ -191,6 +189,7 @@ WMError WindowNodeContainer::AddWindowNode(sptr<WindowNode>& node, sptr<WindowNo
if (node->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) {
isScreenLocked_ = true;
}
WLOGFI("AddWindowNode windowId: %{public}u end", node->GetWindowId());
return WMError::WM_OK;
}
@@ -268,17 +267,6 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
node->requestedVisibility_ = false;
node->currentVisibility_ = false;
node->isCovered_ = true;
std::vector<sptr<WindowVisibilityInfo>> infos = {new WindowVisibilityInfo(node->GetWindowId(),
node->GetCallingPid(), node->GetCallingUid(), false, node->GetWindowType())};
for (auto& child : node->children_) {
if (child->currentVisibility_) {
child->currentVisibility_ = false;
child->isCovered_ = true;
infos.emplace_back(new WindowVisibilityInfo(child->GetWindowId(), child->GetCallingPid(),
child->GetCallingUid(), false, child->GetWindowType()));
}
}
// Remove node from RSTree
for (auto& displayId : node->GetShowingDisplays()) {
UpdateRSTree(node, displayId, false, node->isPlayAnimationHide_);
@@ -297,13 +285,16 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
NotifyDockWindowStateChanged(node, true);
}
NotifyIfAvoidAreaChanged(node, AvoidControlType::AVOID_NODE_REMOVE);
UpdateWindowVisibilityInfos(infos);
DumpScreenWindowTree();
NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_REMOVED);
RcoveryScreenDefaultOrientationIfNeed(node->GetDisplayId());
RecoverScreenDefaultOrientationIfNeed(node->GetDisplayId());
UpdateCameraFloatWindowStatus(node, false);
if (node->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) {
isScreenLocked_ = false;
}
if (node->GetWindowType() == WindowType::WINDOW_TYPE_BOOT_ANIMATION) {
DisplayManagerServiceInner::GetInstance().SetGravitySensorSubscriptionEnabled();
}
WLOGFI("RemoveWindowNode windowId: %{public}u end", node->GetWindowId());
return WMError::WM_OK;
}
@@ -447,7 +438,7 @@ bool WindowNodeContainer::UpdateRSTree(sptr<WindowNode>& node, DisplayId display
return true;
}
void WindowNodeContainer::RcoveryScreenDefaultOrientationIfNeed(DisplayId displayId)
void WindowNodeContainer::RecoverScreenDefaultOrientationIfNeed(DisplayId displayId)
{
if (displayGroupController_->displayGroupWindowTree_[displayId][WindowRootNodeType::APP_WINDOW_NODE]->empty()) {
WLOGFI("appWindowNode_ child is empty in display %{public}" PRIu64"", displayId);
@@ -667,7 +658,7 @@ sptr<AvoidAreaController> WindowNodeContainer::GetAvoidController() const
return avoidController_;
}
sptr<DisplayGroupController> WindowNodeContainer::GetMutiDisplayController() const
sptr<DisplayGroupController> WindowNodeContainer::GetMultiDisplayController() const
{
return displayGroupController_;
}
@@ -865,44 +856,19 @@ void WindowNodeContainer::NotifyIfKeyboardRegionChanged(const sptr<WindowNode>&
WLOGFE("does not have correct callingWindowMode for input method window");
}
void WindowNodeContainer::NotifySystemBarDismiss(sptr<WindowNode>& node)
{
WM_FUNCTION_TRACE();
if (node == nullptr) {
WLOGE("could not find window");
return;
}
SystemBarRegionTints tints;
auto& sysBarPropMapNode = node->GetSystemBarProperty();
SysBarTintMap& sysBarTintMap = displayGroupController_->sysBarTintMaps_[node->GetDisplayId()];
for (auto it : sysBarPropMapNode) {
it.second.enable_ = false;
node->SetSystemBarProperty(it.first, it.second);
WLOGFI("set system bar enable to false, id: %{public}u, type: %{public}d",
node->GetWindowId(), static_cast<int32_t>(it.first));
if (sysBarTintMap[it.first].prop_.enable_) {
sysBarTintMap[it.first].prop_.enable_ = false;
tints.emplace_back(sysBarTintMap[it.first]);
WLOGFI("notify system bar dismiss, type: %{public}d", static_cast<int32_t>(it.first));
}
}
WindowManagerAgentController::GetInstance().UpdateSystemBarRegionTints(node->GetDisplayId(), tints);
}
void WindowNodeContainer::NotifySystemBarTints(std::vector<DisplayId> displayIdVec)
{
WM_FUNCTION_TRACE();
if (displayIdVec.size() != displayGroupController_->sysBarTintMaps_.size()) {
WLOGE("the number of display is error");
WLOGE("[Immersive] the number of display is error");
}
for (auto displayId : displayIdVec) {
SystemBarRegionTints tints;
SysBarTintMap& sysBarTintMap = displayGroupController_->sysBarTintMaps_[displayId];
for (auto it : sysBarTintMap) {
WLOGFI("system bar cur notify, type: %{public}d, " \
"visible: %{public}d, color: %{public}x | %{public}x, " \
"region: [%{public}d, %{public}d, %{public}d, %{public}d]",
WLOGFI("[Immersive] system bar cur notify, T: %{public}d, " \
"V: %{public}d, C: %{public}x | %{public}x, " \
"R: [%{public}d, %{public}d, %{public}d, %{public}d]",
static_cast<int32_t>(it.first),
sysBarTintMap[it.first].prop_.enable_,
sysBarTintMap[it.first].prop_.backgroundColor_, sysBarTintMap[it.first].prop_.contentColor_,
@@ -917,13 +883,13 @@ void WindowNodeContainer::NotifySystemBarTints(std::vector<DisplayId> displayIdV
void WindowNodeContainer::NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable)
{
WM_FUNCTION_TRACE();
WLOGFI("begin isEnable: %{public}d", isEnable);
WLOGFI("[Immersive] begin isEnable: %{public}d", isEnable);
if (isEnable) {
for (auto& windowNode : appWindowNode_->children_) {
if (windowNode->GetWindowId() == node->GetWindowId()) {
continue;
}
if (!WindowHelper::IsFloatintWindow(windowNode->GetWindowMode())) {
if (!WindowHelper::IsFloatingWindow(windowNode->GetWindowMode())) {
return;
}
}
@@ -1526,7 +1492,7 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa
}
layoutMode_ = dstMode;
layoutPolicy_->Clean();
layoutPolicy_ = layoutPolicys_[dstMode];
layoutPolicy_ = layoutPolicies_[dstMode];
layoutPolicy_->Launch();
DumpScreenWindowTree();
} else {
@@ -1720,50 +1686,6 @@ bool WindowNodeContainer::TraverseFromBottomToTop(sptr<WindowNode> node, const W
return false;
}
void WindowNodeContainer::UpdateWindowVisibilityInfos(std::vector<sptr<WindowVisibilityInfo>>& infos)
{
// clear vector cache completely, swap with empty vector
auto emptyVector = std::vector<Rect>();
currentCoveredArea_.swap(emptyVector);
WindowNodeOperationFunc func = [this, &infos](sptr<WindowNode> node) {
if (node == nullptr) {
return false;
}
Rect layoutRect = node->GetWindowRect();
const Rect& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId());
int32_t nodeX = std::max(0, layoutRect.posX_);
int32_t nodeY = std::max(0, layoutRect.posY_);
int32_t nodeXEnd = std::min(displayRect.posX_ + static_cast<int32_t>(displayRect.width_),
layoutRect.posX_ + static_cast<int32_t>(layoutRect.width_));
int32_t nodeYEnd = std::min(displayRect.posY_ + static_cast<int32_t>(displayRect.height_),
layoutRect.posY_ + static_cast<int32_t>(layoutRect.height_));
Rect rectInDisplay = {nodeX, nodeY,
static_cast<uint32_t>(nodeXEnd - nodeX), static_cast<uint32_t>(nodeYEnd - nodeY)};
bool isCovered = false;
for (auto& rect : currentCoveredArea_) {
if (rectInDisplay.IsInsideOf(rect)) {
isCovered = true;
WLOGD("UpdateWindowVisibilityInfos: find covered window:%{public}u", node->GetWindowId());
break;
}
}
if (!isCovered) {
currentCoveredArea_.emplace_back(rectInDisplay);
}
if (isCovered != node->isCovered_) {
node->isCovered_ = isCovered;
infos.emplace_back(new WindowVisibilityInfo(node->GetWindowId(), node->GetCallingPid(),
node->GetCallingUid(), !isCovered, node->GetWindowType()));
WLOGD("UpdateWindowVisibilityInfos: covered status changed window:%{public}u, covered:%{public}d",
node->GetWindowId(), isCovered);
}
return false;
};
TraverseWindowTree(func, true);
WindowManagerAgentController::GetInstance().UpdateWindowVisibilityInfo(infos);
}
float WindowNodeContainer::GetVirtualPixelRatio(DisplayId displayId) const
{
return layoutPolicy_->GetVirtualPixelRatio(displayId);
@@ -1817,7 +1739,7 @@ WMError WindowNodeContainer::SetWindowMode(sptr<WindowNode>& node, WindowMode ds
}
windowPair->UpdateIfSplitRelated(node);
if (WindowHelper::IsMainWindow(node->GetWindowType())) {
if (WindowHelper::IsFloatintWindow(node->GetWindowMode())) {
if (WindowHelper::IsFloatingWindow(node->GetWindowMode())) {
NotifyDockWindowStateChanged(node, true);
} else {
NotifyDockWindowStateChanged(node, false);
@@ -1880,5 +1802,12 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation()
}
return Orientation::UNSPECIFIED;
}
void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr<WindowNode>& node, bool isShowing)
{
if (node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing);
}
}
} // namespace Rosen
} // namespace OHOS
+3 -3
View File
@@ -226,7 +226,7 @@ bool WindowPair::IsSplitRelated(sptr<WindowNode>& node) const
std::vector<sptr<WindowNode>> WindowPair::GetOrderedPair(sptr<WindowNode>& node)
{
WLOGI("Get piared node in Z order");
WLOGI("Get paired node in Z order");
std::vector<sptr<WindowNode>> orderedPair;
if (node == nullptr || Find(node) == nullptr) {
return orderedPair;
@@ -368,7 +368,7 @@ void WindowPair::UpdateWindowPairStatus()
status_ == WindowPairStatus::STATUS_PAIRING) {
// create divider
WindowInnerManager::GetInstance().CreateWindow("dialog_divider_ui", WindowType::WINDOW_TYPE_DOCK_SLICE,
initalDivderRect_);
initalDividerRect_);
} else if ((prevStatus == WindowPairStatus::STATUS_PAIRED_DONE || prevStatus == WindowPairStatus::STATUS_PAIRING) &&
(status_ != WindowPairStatus::STATUS_PAIRED_DONE && status_ != WindowPairStatus::STATUS_PAIRING)) {
// clear pair
@@ -494,7 +494,7 @@ void WindowPair::SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring)
void WindowPair::SetInitalDividerRect(const Rect& rect)
{
initalDivderRect_ = rect;
initalDividerRect_ = rect;
}
} // namespace Rosen
} // namespace OHOS
+99 -29
View File
@@ -24,6 +24,7 @@
#include "window_manager_hilog.h"
#include "window_manager_service.h"
#include "wm_trace.h"
#include "window_manager_agent_controller.h"
namespace OHOS {
namespace Rosen {
@@ -89,7 +90,7 @@ sptr<WindowNodeContainer> WindowRoot::GetOrCreateWindowNodeContainer(DisplayId d
sptr<WindowNodeContainer> WindowRoot::CreateWindowNodeContainer(sptr<DisplayInfo> displayInfo)
{
if (displayInfo == nullptr || !CheckDisplayInfo(displayInfo)) {
WLOGFE("get display failed or get invailed display info");
WLOGFE("get display failed or get invalid display info");
return nullptr;
}
@@ -181,6 +182,9 @@ WMError WindowRoot::SaveWindow(const sptr<WindowNode>& node)
WLOGFI("save windowId %{public}u", node->GetWindowId());
windowNodeMap_.insert(std::make_pair(node->GetWindowId(), node));
if (node->surfaceNode_ != nullptr) {
surfaceIdWindowNodeMap_.insert(std::make_pair(node->surfaceNode_->GetId(), node));
}
if (node->GetWindowToken()) {
AddDeathRecipient(node);
}
@@ -256,6 +260,69 @@ void WindowRoot::ExitSplitMode(DisplayId displayId)
container->ExitSplitMode(displayId);
}
void WindowRoot::AddSurfaceNodeIdWindowNodePair(uint64_t surfaceNodeId, sptr<WindowNode> node)
{
surfaceIdWindowNodeMap_.insert(std::make_pair(surfaceNodeId, node));
}
std::vector<std::pair<uint64_t, bool>> WindowRoot::GetWindowVisibilityChangeInfo(
std::shared_ptr<RSOcclusionData> occlusionData)
{
std::vector<std::pair<uint64_t, bool>> visibityChangeInfo;
VisibleData& currentVisibleWindow = occlusionData->GetVisibleData();
std::sort(currentVisibleWindow.begin(), currentVisibleWindow.end());
VisibleData& lastVisibleWindow = lastOcclusionData_->GetVisibleData();
uint32_t i, j;
i = j = 0;
for (; i < lastVisibleWindow.size() && j < currentVisibleWindow.size();) {
if (lastVisibleWindow[i] < currentVisibleWindow[j]) {
visibityChangeInfo.push_back(std::make_pair(lastVisibleWindow[i], false));
i++;
} else if (lastVisibleWindow[i] > currentVisibleWindow[j]) {
visibityChangeInfo.push_back(std::make_pair(currentVisibleWindow[j], true));
j++;
} else {
i++;
j++;
}
}
for (; i < lastVisibleWindow.size(); ++i) {
visibityChangeInfo.push_back(std::make_pair(lastVisibleWindow[i], false));
}
for (; j < currentVisibleWindow.size(); ++j) {
visibityChangeInfo.push_back(std::make_pair(currentVisibleWindow[j], true));
}
lastOcclusionData_ = occlusionData;
return visibityChangeInfo;
}
void WindowRoot::NotifyWindowVisibilityChange(std::shared_ptr<RSOcclusionData> occlusionData)
{
std::vector<std::pair<uint64_t, bool>> visibityChangeInfo = GetWindowVisibilityChangeInfo(occlusionData);
std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
for (const auto& elem : visibityChangeInfo) {
uint64_t surfaceId = elem.first;
bool isVisible = elem.second;
auto iter = surfaceIdWindowNodeMap_.find(surfaceId);
if (iter == surfaceIdWindowNodeMap_.end()) {
continue;
}
sptr<WindowNode> node = iter->second;
if (node == nullptr) {
continue;
}
node->isVisible_ = isVisible;
windowVisibilityInfos.emplace_back(new WindowVisibilityInfo(node->GetWindowId(), node->GetCallingPid(),
node->GetCallingUid(), isVisible, node->GetWindowType()));
WLOGFD("NotifyWindowVisibilityChange: covered status changed window:%{public}u, isVisible:%{public}d",
node->GetWindowId(), isVisible);
}
if (windowVisibilityInfos.size() != 0) {
WindowManagerAgentController::GetInstance().UpdateWindowVisibilityInfo(windowVisibilityInfos);
}
}
std::vector<Rect> WindowRoot::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType)
{
std::vector<Rect> avoidArea;
@@ -331,25 +398,6 @@ WMError WindowRoot::ToggleShownStateForAllAppWindows()
return res;
}
WMError WindowRoot::MaxmizeWindow(uint32_t windowId)
{
auto node = GetWindowNode(windowId);
if (node == nullptr) {
WLOGFE("could not find window");
return WMError::WM_ERROR_NULLPTR;
}
auto container = GetOrCreateWindowNodeContainer(node->GetDisplayId());
if (container == nullptr) {
WLOGFE("add window failed, window container could not be found");
return WMError::WM_ERROR_NULLPTR;
}
auto property = node->GetWindowProperty();
uint32_t flags = property->GetWindowFlags() & (~(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
property->SetWindowFlags(flags);
container->NotifySystemBarDismiss(node);
return WMError::WM_OK;
}
void WindowRoot::DestroyLeakStartingWindow()
{
WLOGFI("DestroyLeakStartingWindow is called");
@@ -631,6 +679,28 @@ WMError WindowRoot::DestroyWindowInner(sptr<WindowNode>& node)
return WMError::WM_ERROR_DESTROYED_OBJECT;
}
std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
node->isVisible_ = false;
windowVisibilityInfos.emplace_back(new WindowVisibilityInfo(node->GetWindowId(), node->GetCallingPid(),
node->GetCallingUid(), false, node->GetWindowType()));
WLOGFD("NotifyWindowVisibilityChange: covered status changed window:%{public}u, isVisible:%{public}d",
node->GetWindowId(), node->isVisible_);
WindowManagerAgentController::GetInstance().UpdateWindowVisibilityInfo(windowVisibilityInfos);
auto cmpFunc = [node](const std::map<uint64_t, sptr<WindowNode>>::value_type& pair) {
if (pair.second == nullptr) {
return false;
}
if (pair.second->GetWindowId() == node->GetWindowId()) {
return true;
}
return false;
};
auto iter = std::find_if(surfaceIdWindowNodeMap_.begin(), surfaceIdWindowNodeMap_.end(), cmpFunc);
if (iter != surfaceIdWindowNodeMap_.end()) {
surfaceIdWindowNodeMap_.erase(iter);
}
sptr<IWindow> window = node->GetWindowToken();
if ((window != nullptr) && (window->AsObject() != nullptr)) {
if (windowIdMap_.count(window->AsObject()) == 0) {
@@ -988,7 +1058,7 @@ void WindowRoot::ProcessExpandDisplayCreate(DisplayId defaultDisplayId, sptr<Dis
std::map<DisplayId, Rect>& displayRectMap)
{
if (displayInfo == nullptr || !CheckDisplayInfo(displayInfo)) {
WLOGFE("get display failed or get invailed display info");
WLOGFE("get display failed or get invalid display info");
return;
}
DisplayId displayId = displayInfo->GetDisplayId();
@@ -999,7 +1069,7 @@ void WindowRoot::ProcessExpandDisplayCreate(DisplayId defaultDisplayId, sptr<Dis
}
WLOGFI("[Display Create] before add new display, displayId: %{public}" PRIu64"", displayId);
container->GetMutiDisplayController()->ProcessDisplayCreate(defaultDisplayId, displayInfo, displayRectMap);
container->GetMultiDisplayController()->ProcessDisplayCreate(defaultDisplayId, displayInfo, displayRectMap);
WLOGFI("[Display Create] Container exist, add new display, displayId: %{public}" PRIu64"", displayId);
}
@@ -1111,20 +1181,20 @@ void WindowRoot::ProcessDisplayDestroy(DisplayId defaultDisplayId, sptr<DisplayI
}
WLOGFI("[Display Destroy] displayId: %{public}" PRIu64"", displayId);
std::vector<uint32_t> needDestoryWindows;
std::vector<uint32_t> needDestroyWindows;
auto displayRectMap = GetAllDisplayRectsByDisplayInfo(displayInfoMap);
// erase displayId in displayRectMap
auto displayRectIter = displayRectMap.find(displayId);
displayRectMap.erase(displayRectIter);
container->GetMutiDisplayController()->ProcessDisplayDestroy(
defaultDisplayId, displayInfo, displayRectMap, needDestoryWindows);
for (auto id : needDestoryWindows) {
container->GetMultiDisplayController()->ProcessDisplayDestroy(
defaultDisplayId, displayInfo, displayRectMap, needDestroyWindows);
for (auto id : needDestroyWindows) {
auto node = GetWindowNode(id);
if (node != nullptr) {
DestroyWindowInner(node);
}
}
// move window which is not showing on destroied display to default display
// move window which is not showing on destroyed display to default display
MoveNotShowingWindowToDefaultDisplay(defaultDisplayId, displayId);
WLOGFI("[Display Destroy] displayId: %{public}" PRIu64" ", displayId);
}
@@ -1153,7 +1223,7 @@ void WindowRoot::ProcessDisplayChange(DisplayId defaultDisplayId, sptr<DisplayIn
}
auto displayRectMap = GetAllDisplayRectsByDisplayInfo(displayInfoMap);
container->GetMutiDisplayController()->ProcessDisplayChange(defaultDisplayId, displayInfo, displayRectMap, type);
container->GetMultiDisplayController()->ProcessDisplayChange(defaultDisplayId, displayInfo, displayRectMap, type);
}
float WindowRoot::GetVirtualPixelRatio(DisplayId displayId) const
@@ -1209,7 +1279,7 @@ void WindowRoot::SetSplitRatios(const std::vector<float>& splitRatioNumbers)
}
std::sort(splitRatios.begin(), splitRatios.end());
auto iter = std::unique(splitRatios.begin(), splitRatios.end());
splitRatios.erase(iter, splitRatios.end()); // remove duplitcate ratios
splitRatios.erase(iter, splitRatios.end()); // remove duplicate ratios
}
void WindowRoot::SetExitSplitRatios(const std::vector<float>& exitSplitRatios)
+2 -24
View File
@@ -204,7 +204,7 @@ WMError WindowManagerProxy::SetAlpha(uint32_t windowId, float alpha)
WLOGFE("Write alpha failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_SET_APLPHA),
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_SET_ALPHA),
data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
@@ -432,28 +432,6 @@ WMError WindowManagerProxy::ToggleShownStateForAllAppWindows()
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::MaxmizeWindow(uint32_t windowId)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(windowId)) {
WLOGFE("Write windowId failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_MAXMIZE_WINDOW),
data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetWindowLayoutMode(WindowLayoutMode mode)
{
MessageParcel data;
@@ -542,7 +520,7 @@ WMError WindowManagerProxy::GetAccessibilityWindowInfo(sptr<AccessibilityWindowI
WLOGFE("Write windowInfo failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_GET_ACCCESSIBILITY_WIDDOW_INFO_ID),
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID),
data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
+2 -6
View File
@@ -81,7 +81,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case WindowManagerMessage::TRANS_ID_SET_APLPHA: {
case WindowManagerMessage::TRANS_ID_SET_ALPHA: {
uint32_t windowId = data.ReadUint32();
float alpha = data.ReadFloat();
WMError errCode = SetAlpha(windowId, alpha);
@@ -148,10 +148,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case WindowManagerMessage::TRANS_ID_MAXMIZE_WINDOW: {
MaxmizeWindow(data.ReadUint32());
break;
}
case WindowManagerMessage::TRANS_ID_UPDATE_LAYOUT_MODE: {
WindowLayoutMode mode = static_cast<WindowLayoutMode>(data.ReadUint32());
WMError errCode = SetWindowLayoutMode(mode);
@@ -166,7 +162,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case WindowManagerMessage::TRANS_ID_GET_ACCCESSIBILITY_WIDDOW_INFO_ID: {
case WindowManagerMessage::TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID: {
sptr<AccessibilityWindowInfo> windowInfo = data.ReadParcelable<AccessibilityWindowInfo>();
WMError errCode = GetAccessibilityWindowInfo(windowInfo);
reply.WriteParcelable(windowInfo);