!1720 Update drag manager for new device

Merge pull request !1720 from 邢江盼/xing_drag_drawing_003
This commit is contained in:
openharmony_ci 2024-07-01 13:04:18 +00:00 committed by Gitee
commit c6441a15f9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 83 additions and 4 deletions

View File

@ -189,6 +189,11 @@ int32_t InteractionManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RS
return INTER_MGR_IMPL.RotateDragWindowSync(rsTransaction);
}
int32_t InteractionManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
{
return INTER_MGR_IMPL.SetDragWindowScreenId(displayId, screenId);
}
int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summarys)
{
return INTER_MGR_IMPL.GetDragSummary(summarys);

View File

@ -54,6 +54,7 @@ public:
const PreviewStyle &previewStyle, const PreviewAnimation &animation);
int32_t RotateDragWindowSync(ITunnelClient &tunnel,
const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr);
int32_t SetDragWindowScreenId(ITunnelClient &tunnel, uint64_t displayId, uint64_t screenId);
int32_t GetDragSummary(ITunnelClient &tunnel, std::map<std::string, int64_t> &summary);
int32_t GetDragState(ITunnelClient &tunnel, DragState &dragState);
int32_t EnterTextEditorArea(ITunnelClient &tunnel, bool enable);

View File

@ -317,6 +317,18 @@ int32_t DragClient::RotateDragWindowSync(ITunnelClient &tunnel,
return ret;
}
int32_t DragClient::SetDragWindowScreenId(ITunnelClient &tunnel, uint64_t displayId, uint64_t screenId)
{
SetDragWindowScreenIdParam param { displayId, screenId };
DefaultReply reply {};
int32_t ret = tunnel.SetParam(Intention::DRAG, DragRequestID::SET_DRAG_WINDOW_SCREEN_ID, param, reply);
if (ret != RET_OK) {
FI_HILOGE("ITunnelClient::SetParam fail");
}
return ret;
}
int32_t DragClient::GetDragSummary(ITunnelClient &tunnel, std::map<std::string, int64_t> &summary)
{
DefaultParam param {};

View File

@ -50,6 +50,7 @@ enum DragRequestID : uint32_t {
GET_DRAG_ACTION,
GET_EXTRA_INFO,
ERASE_MOUSE_ICON,
SET_DRAG_WINDOW_SCREEN_ID,
};
struct StartDragParam final : public ParamBase {
@ -172,6 +173,17 @@ struct RotateDragWindowSyncParam final : public ParamBase {
std::shared_ptr<Rosen::RSTransaction> rsTransaction_ { nullptr };
};
struct SetDragWindowScreenIdParam final : public ParamBase {
SetDragWindowScreenIdParam() = default;
SetDragWindowScreenIdParam(uint64_t displayId, uint64_t screenId);
bool Marshalling(MessageParcel &parcel) const override;
bool Unmarshalling(MessageParcel &parcel) override;
uint64_t displayId_ { 0 };
uint64_t screenId_ { 0 };
};
struct GetDragSummaryReply final : public ParamBase {
GetDragSummaryReply() = default;
explicit GetDragSummaryReply(std::map<std::string, int64_t> &&summary);

View File

@ -264,6 +264,20 @@ bool RotateDragWindowSyncParam::Unmarshalling(MessageParcel &parcel)
return true;
}
SetDragWindowScreenIdParam::SetDragWindowScreenIdParam(uint64_t displayId, uint64_t screenId)
: displayId_(displayId), screenId_(screenId)
{}
bool SetDragWindowScreenIdParam::Marshalling(MessageParcel &parcel) const
{
return (parcel.WriteUint64(displayId_) && parcel.WriteUint64(screenId_));
}
bool SetDragWindowScreenIdParam::Unmarshalling(MessageParcel &parcel)
{
return (parcel.ReadUint64(displayId_) && parcel.ReadUint64(screenId_));
}
GetDragSummaryReply::GetDragSummaryReply(std::map<std::string, int64_t> &&summary)
: summary_(std::move(summary))
{}

View File

@ -57,6 +57,7 @@ private:
int32_t GetDragAction(CallingContext &context, MessageParcel &data, MessageParcel &reply);
int32_t GetExtraInfo(CallingContext &context, MessageParcel &data, MessageParcel &reply);
int32_t EnterTextEditorArea(CallingContext &context, MessageParcel &data, MessageParcel &reply);
int32_t SetDragWindowScreenId(CallingContext &context, MessageParcel &data, MessageParcel &reply);
std::string GetPackageName(Security::AccessToken::AccessTokenID tokenId);
IContext *env_ { nullptr };

View File

@ -128,6 +128,9 @@ int32_t DragServer::SetParam(CallingContext &context, uint32_t id, MessageParcel
case DragRequestID::UPDATE_PREVIEW_STYLE_WITH_ANIMATION: {
return UpdatePreviewAnimation(context, data, reply);
}
case DragRequestID::SET_DRAG_WINDOW_SCREEN_ID: {
return SetDragWindowScreenId(context, data, reply);
}
default: {
FI_HILOGE("Unexpected request ID (%{public}u)", id);
return RET_ERR;
@ -274,6 +277,18 @@ int32_t DragServer::RotateDragWindowSync(CallingContext &context, MessageParcel
return env_->GetDragManager().RotateDragWindowSync(param.rsTransaction_);
}
int32_t DragServer::SetDragWindowScreenId(CallingContext &context, MessageParcel &data, MessageParcel &reply)
{
SetDragWindowScreenIdParam param {};
if (!param.Unmarshalling(data)) {
FI_HILOGE("SetDragWindowScreenId::Unmarshalling fail");
return RET_ERR;
}
env_->GetDragManager().SetDragWindowScreenId(param.displayId_, param.screenId_);
return RET_OK;
}
int32_t DragServer::GetDragTargetPid(CallingContext &context, MessageParcel &data, MessageParcel &reply)
{
int32_t targetPid = env_->GetDragManager().GetDragTargetPid();

View File

@ -81,6 +81,7 @@ public:
int32_t GetExtraInfo(std::string &extraInfo);
int32_t AddPrivilege();
int32_t EraseMouseIcon();
int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId);
private:
void InitClient();

View File

@ -441,6 +441,12 @@ int32_t IntentionManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RSTr
return drag_.RotateDragWindowSync(*tunnel_, rsTransaction);
}
int32_t IntentionManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
{
CALL_DEBUG_ENTER;
return drag_.SetDragWindowScreenId(*tunnel_, displayId, screenId);
}
int32_t IntentionManager::GetDragSummary(std::map<std::string, int64_t> &summarys)
{
CALL_DEBUG_ENTER;

View File

@ -69,6 +69,7 @@ public:
virtual int32_t EnterTextEditorArea(bool enable) = 0;
virtual int32_t AddPrivilege(int32_t tokenId) = 0;
virtual int32_t EraseMouseIcon() = 0;
virtual void SetDragWindowScreenId(uint64_t displayId, uint64_t screenId) = 0;
};
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -341,6 +341,8 @@ public:
int32_t EraseMouseIcon();
int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId);
private:
InteractionManager() = default;
DISALLOW_COPY_AND_MOVE(InteractionManager);

View File

@ -68,6 +68,7 @@
"OHOS::Msdp::DeviceStatus::InteractionManager::GetExtraInfo(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>&)";
"OHOS::Msdp::DeviceStatus::InteractionManager::AddPrivilege()";
"OHOS::Msdp::DeviceStatus::InteractionManager::EraseMouseIcon()";
"OHOS::Msdp::DeviceStatus::InteractionManager::SetDragWindowScreenId(unsigned long long, unsigned long long)";
};
local:
*;

View File

@ -83,6 +83,7 @@ public:
int32_t AddPrivilege(int32_t tokenId) override;
int32_t EraseMouseIcon() override;
int32_t RotateDragWindow(Rosen::Rotation rotation) override;
void SetDragWindowScreenId(uint64_t displayId, uint64_t screenId) override;
#ifdef OHOS_DRAG_ENABLE_INTERCEPTOR
class InterceptorConsumer : public MMI::IInputEventConsumer {
public:
@ -157,6 +158,8 @@ private:
bool isControlMultiScreenVisible_ = false;
sptr<ISystemAbilityStatusChange> displayAbilityStatusChange_ { nullptr };
sptr<ISystemAbilityStatusChange> appStateObserverStatusChange_ { nullptr };
uint64_t displayId_ { 0 };
uint64_t screenId_ { 0 };
};
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -40,7 +40,6 @@ namespace DeviceStatus {
namespace {
constexpr int32_t TIMEOUT_MS { 3000 };
constexpr int32_t INTERVAL_MS { 500 };
constexpr uint64_t FOLD_SCREEN_ID { 5 };
std::atomic<int64_t> g_startFilterTime { -1 };
const std::string DRAG_STYLE_DEFAULT {"DEFAULT"};
const std::string DRAG_STYLE_FORBIDDEN {"FORBIDDEN"};
@ -774,9 +773,8 @@ int32_t DragManager::OnStartDrag()
}
dragDrawing_.SetScreenId(dragData.displayId);
if (Rosen::DisplayManager::GetInstance().IsFoldable() && !isHicarOrSuperLauncher) {
Rosen::FoldDisplayMode foldMode = Rosen::DisplayManager::GetInstance().GetFoldDisplayMode();
if (foldMode == Rosen::FoldDisplayMode::MAIN) {
dragDrawing_.SetScreenId(FOLD_SCREEN_ID);
if (static_cast<uint64_t>(dragData.displayId) == displayId_) {
dragDrawing_.SetScreenId(screenId_);
}
}
int32_t ret = dragDrawing_.Init(dragData, context_);
@ -1030,6 +1028,13 @@ int32_t DragManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransac
return dragDrawing_.RotateDragWindowSync(rsTransaction);
}
void DragManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
{
FI_HILOGI("displayId:%{public}" PRId64 ", screenId:%{public}" PRId64 "", displayId, screenId);
displayId_ = displayId;
screenId_ = screenId;
}
void DragManager::DragKeyEventCallback(std::shared_ptr<MMI::KeyEvent> keyEvent)
{
CHKPV(keyEvent);