mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-27 09:41:43 +00:00
Signed-off-by:mrsongliang<songliangliang5@huawei.com>
Signed-off-by: mrsongliang <songliangliang5@huawei.com> Change-Id: I71442e09924606720537dda75d6ca730129ecc37
This commit is contained in:
commit
195e2bd363
@ -81,8 +81,10 @@
|
||||
"include/stationary_manager.h",
|
||||
"interaction/include/coordination_message.h",
|
||||
"interaction/include/drag_data.h",
|
||||
"interaction/include/drag_data_util.h",
|
||||
"interaction/include/i_coordination_listener.h",
|
||||
"interaction/include/i_drag_listener.h",
|
||||
"interaction/include/i_start_drag_listener.h",
|
||||
"interaction/include/interaction_manager.h"
|
||||
],
|
||||
"header_base": "//base/msdp/device_status/interfaces/innerkits"
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "devicestatus_define.h"
|
||||
#include "drag_data.h"
|
||||
#include "i_drag_listener.h"
|
||||
#include "i_start_drag_listener.h"
|
||||
#include "i_subscript_listener.h"
|
||||
#include "include/util.h"
|
||||
|
||||
@ -37,9 +38,10 @@ public:
|
||||
DragManagerImpl() = default;
|
||||
~DragManagerImpl() = default;
|
||||
|
||||
int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
|
||||
int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener);
|
||||
int32_t StopDrag(const DragDropResult &dropResult);
|
||||
int32_t OnNotifyResult(const StreamClient &client, NetPacket &pkt);
|
||||
int32_t OnNotifyHideIcon(const StreamClient& client, NetPacket& pkt);
|
||||
int32_t OnStateChangedMessage(const StreamClient &client, NetPacket &pkt);
|
||||
int32_t OnDragStyleChangedMessage(const StreamClient &client, NetPacket &pkt);
|
||||
int32_t AddDraglistener(DragListenerPtr listener);
|
||||
@ -66,8 +68,8 @@ private:
|
||||
std::atomic_bool hasRegistered_ { false };
|
||||
std::atomic_bool hasSubscriptRegistered_ { false };
|
||||
std::list<DragListenerPtr> dragListener_;
|
||||
std::shared_ptr<IStartDragListener> startDragListener_ { nullptr };
|
||||
std::list<SubscriptListenerPtr> subscriptListener_;
|
||||
std::function<void(const DragNotifyMsg&)> stopCallback_ { nullptr };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
int32_t GetCoordinationState(const std::string &networkId, std::function<void(bool)> callback,
|
||||
bool isCheckPermission = false);
|
||||
int32_t UpdateDragStyle(DragCursorStyle style);
|
||||
int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
|
||||
int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener);
|
||||
int32_t StopDrag(const DragDropResult &dropResult);
|
||||
int32_t GetDragTargetPid();
|
||||
int32_t GetUdKey(std::string &udKey);
|
||||
|
36
frameworks/native/interaction/src/drag_data_util.cpp
Normal file
36
frameworks/native/interaction/src/drag_data_util.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "drag_data_util.h"
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
#include "drag_data_packer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
int32_t DragDataUtil::Marshalling(const DragData &dragData, Parcel &data)
|
||||
{
|
||||
return DragDataPacker::Marshalling(dragData, data);
|
||||
}
|
||||
|
||||
int32_t DragDataUtil::UnMarshalling(Parcel &data, DragData &dragData)
|
||||
{
|
||||
return DragDataPacker::UnMarshalling(data, dragData);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -37,17 +37,19 @@ int32_t DragManagerImpl::UpdateDragStyle(DragCursorStyle style)
|
||||
return DeviceStatusClient::GetInstance().UpdateDragStyle(style);
|
||||
}
|
||||
|
||||
int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback)
|
||||
int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPR(callback, RET_ERR);
|
||||
CHKPR(dragData.shadowInfo.pixelMap, RET_ERR);
|
||||
if ((dragData.shadowInfo.x > 0) || (dragData.shadowInfo.y > 0) ||
|
||||
(dragData.shadowInfo.x < -dragData.shadowInfo.pixelMap->GetWidth()) ||
|
||||
(dragData.shadowInfo.y < -dragData.shadowInfo.pixelMap->GetHeight())) {
|
||||
FI_HILOGE("Start drag, invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y);
|
||||
return RET_ERR;
|
||||
CHKPR(listener, RET_ERR);
|
||||
for (const auto& shadowInfo : dragData.shadowInfos) {
|
||||
CHKPR(shadowInfo.pixelMap, RET_ERR);
|
||||
if ((shadowInfo.x > 0) || (shadowInfo.y > 0) ||
|
||||
(shadowInfo.x < -shadowInfo.pixelMap->GetWidth()) ||
|
||||
(shadowInfo.y < -shadowInfo.pixelMap->GetHeight())) {
|
||||
FI_HILOGE("Invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
|
||||
shadowInfo.x, shadowInfo.y);
|
||||
return RET_ERR;
|
||||
}
|
||||
}
|
||||
if ((dragData.dragNum <= 0) || (dragData.buffer.size() > MAX_BUFFER_SIZE) ||
|
||||
(dragData.displayX < 0) || (dragData.displayY < 0)) {
|
||||
@ -58,7 +60,7 @@ int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::function<void(
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
stopCallback_ = callback;
|
||||
startDragListener_ = listener;
|
||||
}
|
||||
return DeviceStatusClient::GetInstance().StartDrag(dragData);
|
||||
}
|
||||
@ -98,8 +100,17 @@ int32_t DragManagerImpl::OnNotifyResult(const StreamClient &client, NetPacket &p
|
||||
}
|
||||
notifyMsg.result = static_cast<DragResult>(result);
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
CHKPR(stopCallback_, RET_ERR);
|
||||
stopCallback_(notifyMsg);
|
||||
CHKPR(startDragListener_, RET_ERR);
|
||||
startDragListener_->OnDragEndMessage(notifyMsg);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManagerImpl::OnNotifyHideIcon(const StreamClient& client, NetPacket& pkt)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
CHKPR(startDragListener_, RET_ERR);
|
||||
startDragListener_->OnHideIconMessage();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ int32_t InteractionManager::UpdateDragStyle(DragCursorStyle style)
|
||||
return INTER_MGR_IMPL.UpdateDragStyle(style);
|
||||
}
|
||||
|
||||
int32_t InteractionManager::StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback)
|
||||
int32_t InteractionManager::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
|
||||
{
|
||||
return INTER_MGR_IMPL.StartDrag(dragData, callback);
|
||||
return INTER_MGR_IMPL.StartDrag(dragData, listener);
|
||||
}
|
||||
|
||||
int32_t InteractionManager::StopDrag(const DragDropResult &dropResult)
|
||||
|
@ -68,6 +68,8 @@ void InteractionManagerImpl::InitMsgHandler()
|
||||
MsgCallbackBind2(&DragManagerImpl::OnNotifyResult, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_STATE_LISTENER,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnStateChangedMessage, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_NOTIFY_HIDE_ICON,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnNotifyHideIcon, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_STYLE_LISTENER,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnDragStyleChangedMessage, &dragManagerImpl_)}
|
||||
};
|
||||
@ -217,7 +219,7 @@ int32_t InteractionManagerImpl::UpdateDragStyle(DragCursorStyle style)
|
||||
return dragManagerImpl_.UpdateDragStyle(style);
|
||||
}
|
||||
|
||||
int32_t InteractionManagerImpl::StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback)
|
||||
int32_t InteractionManagerImpl::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
@ -225,7 +227,7 @@ int32_t InteractionManagerImpl::StartDrag(const DragData &dragData, std::functio
|
||||
FI_HILOGE("Get client is nullptr");
|
||||
return RET_ERR;
|
||||
}
|
||||
return dragManagerImpl_.StartDrag(dragData, callback);
|
||||
return dragManagerImpl_.StartDrag(dragData, listener);
|
||||
}
|
||||
|
||||
int32_t InteractionManagerImpl::StopDrag(const DragDropResult &dropResult)
|
||||
|
@ -46,6 +46,9 @@ constexpr int32_t DISPLAY_ID { 0 };
|
||||
constexpr int32_t DISPLAY_X { 50 };
|
||||
constexpr int32_t DISPLAY_Y { 50 };
|
||||
constexpr int32_t DRAG_NUM_ONE { 1 };
|
||||
constexpr int32_t SHADOW_NUM_ONE { 1 };
|
||||
constexpr int32_t SHADOW_NUM_MULTIPLE { 3 };
|
||||
constexpr int32_t SHADOW_NUM_TOO_MUCH { 5 };
|
||||
constexpr int32_t DRAG_NUM_MULTIPLE { 10 };
|
||||
constexpr int32_t INT32_BYTE { 4 };
|
||||
constexpr int32_t PROMISE_WAIT_SPAN_MS { 2000 };
|
||||
@ -67,7 +70,7 @@ public:
|
||||
static void SetUpTestCase();
|
||||
static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
|
||||
static std::optional<DragData> CreateDragData(int32_t sourceType, int32_t pointerId, int32_t dragNum,
|
||||
bool hasCoordinateCorrected);
|
||||
bool hasCoordinateCorrected, int32_t shadowNum);
|
||||
};
|
||||
|
||||
void InteractionDragDrawingTest::SetUpTestCase() {}
|
||||
@ -113,19 +116,40 @@ std::shared_ptr<Media::PixelMap> InteractionDragDrawingTest::CreatePixelMap(int3
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
class TestStartDragListener : public IStartDragListener {
|
||||
public:
|
||||
explicit TestStartDragListener(std::function<void(const DragNotifyMsg&)> function) : function_(function) { }
|
||||
void OnDragEndMessage(const DragNotifyMsg &msg) override
|
||||
{
|
||||
FI_HILOGD("DisplayX:%{public}d, displayY:%{public}d, targetPid:%{public}d, result:%{public}d",
|
||||
msg.displayX, msg.displayY, msg.targetPid, static_cast<int32_t>(msg.result));
|
||||
if (function_ != nullptr) {
|
||||
function_(msg);
|
||||
}
|
||||
FI_HILOGD("Test OnDragEndMessage");
|
||||
}
|
||||
|
||||
void OnHideIconMessage() override
|
||||
{
|
||||
FI_HILOGI("Test OnHideIconMessage");
|
||||
}
|
||||
private:
|
||||
std::function<void(const DragNotifyMsg&)> function_;
|
||||
};
|
||||
|
||||
std::optional<DragData> InteractionDragDrawingTest::CreateDragData(int32_t sourceType,
|
||||
int32_t pointerId, int32_t dragNum, bool hasCoordinateCorrected)
|
||||
int32_t pointerId, int32_t dragNum, bool hasCoordinateCorrected, int32_t shadowNum)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
|
||||
if (pixelMap == nullptr) {
|
||||
FI_HILOGE("CreatePixelMap failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.pixelMap = pixelMap;
|
||||
dragData.shadowInfo.x = 0;
|
||||
dragData.shadowInfo.y = 0;
|
||||
for (int32_t i = 0; i < shadowNum; i++) {
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
|
||||
if (pixelMap == nullptr) {
|
||||
FI_HILOGE("CreatePixelMap failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
dragData.shadowInfos.push_back({ pixelMap, 0, 0 });
|
||||
}
|
||||
dragData.buffer = std::vector<uint8_t>(MAX_BUFFER_SIZE, 0);
|
||||
dragData.udKey = UD_KEY;
|
||||
dragData.extraInfo = FILTER_INFO;
|
||||
@ -151,7 +175,7 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Mouse_DragNum_On
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
@ -160,7 +184,8 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Mouse_DragNum_On
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -202,9 +227,10 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Mouse_DragNum_Mu
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_MULTIPLE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_MULTIPLE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -246,9 +272,10 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Drag
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -280,7 +307,7 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Drag
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_MULTIPLE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_MULTIPLE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
@ -289,7 +316,8 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Drag
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -328,9 +356,10 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_UpdateShadowPic,
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
|
||||
ASSERT_NE(pixelMap, nullptr);
|
||||
@ -365,9 +394,10 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Mouse_Animation,
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -397,9 +427,106 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Anim
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->UpdateDragStyle(DragCursorStyle::COPY);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_FAIL, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionDragDrawingTest_Multiple_Shadow
|
||||
* @tc.desc: Drag Drawing
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_ONE_Shadow, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->UpdateDragStyle(DragCursorStyle::COPY);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_FAIL, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionDragDrawingTest_Multiple_Shadow
|
||||
* @tc.desc: Drag Drawing
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Multiple_Shadow, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_MULTIPLE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->UpdateDragStyle(DragCursorStyle::COPY);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_FAIL, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionDragDrawingTest_Multiple_Shadow
|
||||
* @tc.desc: Drag Drawing
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Too_Much_Shadow, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_TOO_MUCH);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(DRAG_WINDOW_VISIBLE);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -409,7 +536,6 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Anim
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_ANIMATION_END));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -429,9 +555,10 @@ HWTEST_F(InteractionDragDrawingTest, EnterTextEditorArea001, TestSize.Level1)
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -461,9 +588,10 @@ HWTEST_F(InteractionDragDrawingTest, EnterTextEditorArea002, TestSize.Level1)
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(false);
|
||||
EXPECT_EQ(ret, RET_ERR);
|
||||
@ -483,7 +611,7 @@ HWTEST_F(InteractionDragDrawingTest, EnterTextEditorArea003, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, true);
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, true, SHADOW_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->EnterTextEditorArea(true);
|
||||
EXPECT_EQ(ret, RET_ERR);
|
||||
|
@ -25,12 +25,14 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "input_device.h"
|
||||
#include "input_manager.h"
|
||||
#include "parcel.h"
|
||||
#include "pointer_event.h"
|
||||
#include "securec.h"
|
||||
|
||||
#include "coordination_message.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_errors.h"
|
||||
#include "drag_data_util.h"
|
||||
#include "interaction_manager.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "token_setproc.h"
|
||||
@ -242,6 +244,27 @@ private:
|
||||
std::string moduleName_;
|
||||
};
|
||||
|
||||
class TestStartDragListener : public IStartDragListener {
|
||||
public:
|
||||
explicit TestStartDragListener(std::function<void(const DragNotifyMsg&)> function) : function_(function) { }
|
||||
void OnDragEndMessage(const DragNotifyMsg &msg) override
|
||||
{
|
||||
FI_HILOGD("DisplayX:%{public}d, displayY:%{public}d, targetPid:%{public}d, result:%{public}d",
|
||||
msg.displayX, msg.displayY, msg.targetPid, static_cast<int32_t>(msg.result));
|
||||
if (function_ != nullptr) {
|
||||
function_(msg);
|
||||
}
|
||||
FI_HILOGD("Test OnDragEndMessage");
|
||||
}
|
||||
|
||||
void OnHideIconMessage() override
|
||||
{
|
||||
FI_HILOGI("Test OnHideIconMessage");
|
||||
}
|
||||
private:
|
||||
std::function<void(const DragNotifyMsg&)> function_;
|
||||
};
|
||||
|
||||
std::vector<int32_t> InteractionManagerTest::GetInputDeviceIds()
|
||||
{
|
||||
std::vector<int32_t> realDeviceIds;
|
||||
@ -339,10 +362,9 @@ std::optional<DragData> InteractionManagerTest::CreateDragData(const std::pair<i
|
||||
FI_HILOGE("Create pixelmap failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
ShadowInfo shadowInfo { pixelMap, 0, 0 };
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.pixelMap = pixelMap;
|
||||
dragData.shadowInfo.x = 0;
|
||||
dragData.shadowInfo.y = 0;
|
||||
dragData.shadowInfos.push_back(shadowInfo);
|
||||
dragData.buffer = std::vector<uint8_t>(MAX_BUFFER_SIZE, 0);
|
||||
dragData.udKey = UD_KEY;
|
||||
dragData.sourceType = sourceType;
|
||||
@ -464,17 +486,19 @@ void InteractionManagerTest::TestRemoveMonitor(int32_t monitorId)
|
||||
void InteractionManagerTest::PrintDragData(const DragData &dragData)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
FI_HILOGD("PixelAlphaType:%{public}d, PixelFormat:%{public}d, PixelAllocatorType:%{public}d,"
|
||||
" PixelWidth:%{public}d, PixelHeight:%{public}d, shadowX:%{public}d, shadowY:%{public}d,"
|
||||
" sourceType:%{public}d, pointerId:%{public}d, displayId:%{public}d, displayX:%{public}d,"
|
||||
for (const auto &shadowInfo : dragData.shadowInfos) {
|
||||
CHKPV(shadowInfo.pixelMap);
|
||||
FI_HILOGD("PixelFormat:%{public}d, PixelAlphaType:%{public}d, PixelAllocatorType:%{public}d,"
|
||||
" PixelWidth:%{public}d, PixelHeight:%{public}d, shadowX:%{public}d, shadowY:%{public}d",
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetPixelFormat()),
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetAlphaType()),
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetAllocatorType()),
|
||||
shadowInfo.pixelMap->GetWidth(), shadowInfo.pixelMap->GetHeight(), shadowInfo.x, shadowInfo.y);
|
||||
}
|
||||
FI_HILOGD("SourceType:%{public}d, pointerId:%{public}d, displayId:%{public}d, displayX:%{public}d,"
|
||||
" displayY:%{public}d, dragNum:%{public}d, hasCanceledAnimation:%{public}d, udKey:%{public}s",
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetAlphaType()),
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetPixelFormat()),
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetAllocatorType()),
|
||||
dragData.shadowInfo.pixelMap->GetWidth(), dragData.shadowInfo.pixelMap->GetHeight(),
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y, dragData.sourceType, dragData.pointerId,
|
||||
dragData.displayId, dragData.displayX, dragData.displayY, dragData.dragNum, dragData.hasCanceledAnimation,
|
||||
dragData.udKey.substr(0, SUBSTR_UDKEY_LEN).c_str());
|
||||
dragData.sourceType, dragData.pointerId, dragData.displayId, dragData.displayX, dragData.displayY,
|
||||
dragData.dragNum, dragData.hasCanceledAnimation, dragData.udKey.substr(0, SUBSTR_UDKEY_LEN).c_str());
|
||||
}
|
||||
|
||||
void InteractionManagerTest::SetupKeyEvent(
|
||||
@ -833,7 +857,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener_Mouse, Test
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -875,7 +900,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener_Touch, Test
|
||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||
@ -923,7 +949,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener, TestSize.L
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||
@ -971,7 +998,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_SubscriptListener_001, T
|
||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||
@ -1016,7 +1044,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_SubscriptListener_002, T
|
||||
ASSERT_TRUE(dragData);
|
||||
SimulateDownPointerEvent(
|
||||
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
@ -1065,7 +1094,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Mouse, TestSiz
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1105,9 +1135,9 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Failed_Mouse,
|
||||
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), nullptr);
|
||||
ASSERT_EQ(ret, RET_ERR);
|
||||
|
||||
dragData->shadowInfo.pixelMap = nullptr;
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
dragData->shadowInfos = {};
|
||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_ERR);
|
||||
}
|
||||
}
|
||||
@ -1136,7 +1166,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Mouse, TestSize
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
@ -1195,7 +1226,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Touch, TestSiz
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1233,7 +1265,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Touch, TestSize
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
@ -1266,7 +1299,8 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Mouse, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1307,7 +1341,8 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Touch, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1346,7 +1381,8 @@ HWTEST_F(InteractionManagerTest, TouchEventDispatch, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::promise<bool> promiseEventFlag;
|
||||
std::future<bool> futureEventFlag = promiseEventFlag.get_future();
|
||||
@ -1387,7 +1423,8 @@ HWTEST_F(InteractionManagerTest, MouseEventDispatch, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, 0, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::promise<bool> promiseEventFlag;
|
||||
std::future<bool> futureEventFlag = promiseEventFlag.get_future();
|
||||
@ -1449,7 +1486,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetShadowOffset, TestSiz
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->GetShadowOffset(offsetX, offsetY, width, height);
|
||||
FI_HILOGD("offsetX:%{public}d, offsetY:%{public}d, width:%{public}d, height:%{public}d",
|
||||
@ -1485,7 +1523,8 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Mouse, TestSize.Level1)
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::string udKey;
|
||||
ret = InteractionManager::GetInstance()->GetUdKey(udKey);
|
||||
@ -1524,7 +1563,8 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Touch, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::string udKey;
|
||||
ret = InteractionManager::GetInstance()->GetUdKey(udKey);
|
||||
@ -1562,25 +1602,14 @@ HWTEST_F(InteractionManagerTest, GetDragData_Success, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
|
||||
DragData replyDragData;
|
||||
ret = InteractionManager::GetInstance()->GetDragData(replyDragData);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_NE(replyDragData.shadowInfo.pixelMap, nullptr);
|
||||
ASSERT_EQ(replyDragData.shadowInfo.pixelMap->GetWidth(), TEST_PIXEL_MAP_WIDTH);
|
||||
ASSERT_EQ(replyDragData.shadowInfo.pixelMap->GetHeight(), TEST_PIXEL_MAP_HEIGHT);
|
||||
ASSERT_EQ(dragData->udKey, replyDragData.udKey);
|
||||
ASSERT_EQ(dragData->shadowInfo.x, replyDragData.shadowInfo.x);
|
||||
ASSERT_EQ(dragData->shadowInfo.y, replyDragData.shadowInfo.y);
|
||||
ASSERT_EQ(dragData->sourceType, replyDragData.sourceType);
|
||||
ASSERT_EQ(dragData->pointerId, replyDragData.pointerId);
|
||||
ASSERT_EQ(dragData->dragNum, replyDragData.dragNum);
|
||||
ASSERT_EQ(dragData->displayX, replyDragData.displayX);
|
||||
ASSERT_EQ(dragData->displayY, replyDragData.displayY);
|
||||
ASSERT_EQ(dragData->displayId, replyDragData.displayId);
|
||||
ASSERT_EQ(dragData->hasCanceledAnimation, replyDragData.hasCanceledAnimation);
|
||||
ASSERT_EQ(replyDragData, dragData.value());
|
||||
PrintDragData(replyDragData);
|
||||
SimulateUpPointerEvent(
|
||||
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||
@ -1635,7 +1664,8 @@ HWTEST_F(InteractionManagerTest, GetDragState, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
|
||||
DragState dragState;
|
||||
@ -1781,7 +1811,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetDragSummary, TestSize
|
||||
constexpr int64_t recordSize = 20;
|
||||
std::map<std::string, int64_t> summarys = { { udType, recordSize } };
|
||||
dragData.value().summarys = summarys;
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
summarys.clear();
|
||||
ret = InteractionManager::GetInstance()->GetDragSummary(summarys);
|
||||
@ -1814,7 +1845,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_UpdatePreviewStyle, Test
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1865,7 +1897,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_UpdatePreviewStyleWithAn
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
@ -1926,7 +1959,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetExtraInfo, TestSize.L
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
std::string extraInfo;
|
||||
ret = InteractionManager::GetInstance()->GetExtraInfo(extraInfo);
|
||||
@ -1940,6 +1974,27 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetExtraInfo, TestSize.L
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TestDragDataUtil_Packer
|
||||
* @tc.desc: Pack up dragData
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionManagerTest, TestDragDataUtil_Packer, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
Parcel parcel;
|
||||
int32_t ret = DragDataUtil::Marshalling(dragData.value(), parcel);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragData dragDataFromParcel;
|
||||
ret = DragDataUtil::UnMarshalling(parcel, dragDataFromParcel);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_EQ(dragData.value(), dragDataFromParcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragAction_001
|
||||
* @tc.desc: Get drag action with no keyboard events of keys in dragging
|
||||
@ -1961,7 +2016,8 @@ HWTEST_F(InteractionManagerTest, GetDragAction_001, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragAction dragAction { DragAction::INVALID };
|
||||
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||
@ -1990,7 +2046,7 @@ HWTEST_F(InteractionManagerTest, GetDragAction_002, TestSize.Level1)
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
FI_HILOGD("DisplayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
@ -2000,7 +2056,8 @@ HWTEST_F(InteractionManagerTest, GetDragAction_002, TestSize.Level1)
|
||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||
std::make_shared<TestStartDragListener>(callback));
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
SimulateDownKeyEvent(MMI::KeyEvent::KEYCODE_CTRL_LEFT);
|
||||
DragAction dragAction { DragAction::INVALID };
|
||||
|
49
intention/cooperate/state_machine/BUILD.gn
Normal file
49
intention/cooperate/state_machine/BUILD.gn
Normal file
@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("../../../device_status.gni")
|
||||
|
||||
config("cooperate_public_config") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("state_machine") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${device_status_root_path}/intention/cooperate/server/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/cooperate.cpp",
|
||||
"src/cooperate_free.cpp",
|
||||
"src/cooperate_in.cpp",
|
||||
"src/cooperate_out.cpp",
|
||||
"src/i_cooperate_state.cpp",
|
||||
"src/state_machine.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":cooperate_public_config" ]
|
||||
|
||||
deps = [
|
||||
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
|
||||
"${device_status_utils_path}:devicestatus_util",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
subsystem_name = "${device_status_subsystem_name}"
|
||||
part_name = "${device_status_part_name}"
|
||||
}
|
49
intention/cooperate/state_machine/include/cooperate.h
Normal file
49
intention/cooperate/state_machine/include/cooperate.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef COOPERATE_H
|
||||
#define COOPERATE_H
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "state_machine.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class Cooperate {
|
||||
public:
|
||||
int32_t Init();
|
||||
int32_t Enable();
|
||||
void Disable();
|
||||
int32_t StartCooperate(int32_t userData, const std::string &remoteNetworkId, int32_t startDeviceId);
|
||||
int32_t StopCooperate(int32_t userData, bool isUnchained);
|
||||
|
||||
private:
|
||||
void Loop();
|
||||
|
||||
StateMachine sm_;
|
||||
std::thread worker_;
|
||||
std::atomic_bool running_ { false };
|
||||
Channel<CooperateEvent>::Sender sender_;
|
||||
Channel<CooperateEvent>::Receiver receiver_;
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // COOPERATE_H
|
147
intention/cooperate/state_machine/include/cooperate_define.h
Normal file
147
intention/cooperate/state_machine/include/cooperate_define.h
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef COOPERATE_DEFINE_H
|
||||
#define COOPERATE_DEFINE_H
|
||||
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <variant>
|
||||
|
||||
#include "channel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
enum class CooperateEventType {
|
||||
NOOP,
|
||||
QUIT,
|
||||
UPDATE_STATE,
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
START,
|
||||
STOP,
|
||||
APP_CLOSED,
|
||||
UNPLUG_POINTER,
|
||||
PLUG_KEYBOARD,
|
||||
POINTER_MOVE,
|
||||
PREPARE_DINPUT_RESULT,
|
||||
START_DINPUT_RESULT,
|
||||
DINPUT_CLOSED,
|
||||
DSOFTBUS_CLOSED,
|
||||
INTERCEPTOR,
|
||||
SESSION_OPEND,
|
||||
};
|
||||
|
||||
struct UpdateStateEvent {
|
||||
size_t current;
|
||||
};
|
||||
|
||||
struct StartCooperateEvent {
|
||||
int32_t userData;
|
||||
std::string remoteNetworkId;
|
||||
int32_t startDeviceId;
|
||||
};
|
||||
|
||||
struct StartRemoteInputResult {
|
||||
std::string source;
|
||||
std::string sink;
|
||||
int32_t startDeviceId;
|
||||
bool success;
|
||||
};
|
||||
|
||||
struct PointerMoveEvent {
|
||||
int32_t deviceId;
|
||||
};
|
||||
|
||||
struct SessionOpened {
|
||||
int32_t sessionId;
|
||||
int32_t result;
|
||||
};
|
||||
|
||||
struct CooperateEvent {
|
||||
CooperateEvent() : type(CooperateEventType::QUIT) {}
|
||||
|
||||
explicit CooperateEvent(CooperateEventType ty) : type(ty) {}
|
||||
|
||||
template<typename Event>
|
||||
CooperateEvent(CooperateEventType ty, Event ev) : type(ty), event(ev) {}
|
||||
|
||||
CooperateEventType type;
|
||||
std::variant<
|
||||
UpdateStateEvent,
|
||||
StartCooperateEvent,
|
||||
StartRemoteInputResult,
|
||||
PointerMoveEvent
|
||||
> event;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream &oss, CooperateEvent &event)
|
||||
{
|
||||
oss << "CooperateEvent(id:";
|
||||
switch (event.type) {
|
||||
case CooperateEventType::POINTER_MOVE : {
|
||||
PointerMoveEvent e = std::get<PointerMoveEvent>(event.event);
|
||||
oss << "pointer move, pointer:" << e.deviceId;
|
||||
break;
|
||||
}
|
||||
case CooperateEventType::START: {
|
||||
StartCooperateEvent e = std::get<StartCooperateEvent>(event.event);
|
||||
oss << "start cooperate, remote:" << e.remoteNetworkId << ", startDeviceId:" << e.startDeviceId;
|
||||
break;
|
||||
}
|
||||
case CooperateEventType::PREPARE_DINPUT_RESULT : {
|
||||
StartRemoteInputResult e = std::get<StartRemoteInputResult>(event.event);
|
||||
oss << "prepare remote input result, source:" << e.source << ", sink:" << e.sink
|
||||
<< ", startDeviceId:" << e.startDeviceId << ", isSuccess:" << std::boolalpha << e.success;
|
||||
break;
|
||||
}
|
||||
case CooperateEventType::START_DINPUT_RESULT : {
|
||||
StartRemoteInputResult e = std::get<StartRemoteInputResult>(event.event);
|
||||
oss << "start remote input result, source:" << e.source << ", sink:" << e.sink
|
||||
<< ", startDeviceId:" << e.startDeviceId << ", isSuccess:" << std::boolalpha << e.success;
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
oss << static_cast<int32_t>(event.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
oss << ")";
|
||||
return oss;
|
||||
}
|
||||
|
||||
class DeviceManager {
|
||||
public:
|
||||
std::string GetDhid(int32_t deviceId);
|
||||
};
|
||||
|
||||
std::string DeviceManager::GetDhid(int32_t deviceId)
|
||||
{
|
||||
return std::to_string(deviceId);
|
||||
}
|
||||
|
||||
class Context {
|
||||
public:
|
||||
DeviceManager devMgr_;
|
||||
Channel<CooperateEvent>::Sender sender_;
|
||||
std::string cooperated_;
|
||||
std::string startDeviceId_;
|
||||
bool isUnchain_;
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // COOPERATE_DEFINE_H
|
64
intention/cooperate/state_machine/include/cooperate_in.h
Normal file
64
intention/cooperate/state_machine/include/cooperate_in.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef COOPERATE_IN_H
|
||||
#define COOPERATE_IN_H
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
#include "i_cooperate_state.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class CooperateIn : public ICooperateState {
|
||||
public:
|
||||
CooperateIn();
|
||||
~CooperateIn() = default;
|
||||
|
||||
void OnEvent(Context &context, const CooperateEvent &event) override;
|
||||
void OnEnterState(Context &event) override;
|
||||
void OnLeaveState(Context &event) override;
|
||||
|
||||
private:
|
||||
class Initial final : public ICooperateStep {
|
||||
public:
|
||||
void OnEvent(Context &context, const CooperateEvent &event) override;
|
||||
void OnProgress(Context &context, const CooperateEvent &event) override;
|
||||
void OnReset(Context &context, const CooperateEvent &event) override;
|
||||
};
|
||||
|
||||
class PrepareRemoteInput final : public ICooperateStep {
|
||||
public:
|
||||
void OnEvent(Context &context, const CooperateEvent &event) override;
|
||||
void OnProgress(Context &context, const CooperateEvent &event) override;
|
||||
void OnReset(Context &context, const CooperateEvent &event) override;
|
||||
|
||||
private:
|
||||
std::pair<std::string, std::string> prepared_;
|
||||
};
|
||||
|
||||
class StartRemoteInput final : public ICooperateStep {
|
||||
public:
|
||||
void OnEvent(Context &context, const CooperateEvent &event) override;
|
||||
void OnProgress(Context &context, const CooperateEvent &event) override;
|
||||
void OnReset(Context &context, const CooperateEvent &event) override;
|
||||
};
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // COOPERATE_IN_H
|
74
intention/cooperate/state_machine/src/i_cooperate_state.cpp
Normal file
74
intention/cooperate/state_machine/src/i_cooperate_state.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "i_cooperate_state.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
|
||||
ICooperateState::ICooperateStep::ICooperateStep(ICooperateState &parent, std::shared_ptr<ICooperateStep> prev)
|
||||
: parent_(parent), prev_(prev)
|
||||
{}
|
||||
|
||||
void ICooperateState::Switch(std::shared_ptr<ICooperateStep> step)
|
||||
{
|
||||
if (step == nullptr) {
|
||||
FI_HILOGE("In ICooperateState::Switch, step is null");
|
||||
return;
|
||||
}
|
||||
current_ = step;
|
||||
}
|
||||
|
||||
void ICooperateState::ICooperateStep::SetNext(std::shared_ptr<ICooperateStep> next)
|
||||
{
|
||||
if (next == nullptr) {
|
||||
FI_HILOGE("In ICooperateState::ICooperateStep::SetNext, next is nullptr");
|
||||
return;
|
||||
}
|
||||
next_ = next;
|
||||
}
|
||||
|
||||
void ICooperateState::ICooperateStep::Switch(std::shared_ptr<ICooperateStep> step)
|
||||
{
|
||||
if (step == nullptr) {
|
||||
FI_HILOGE("In ICooperateState::ICooperateStep::Switch, step is nullptr");
|
||||
return;
|
||||
}
|
||||
parent_.Switch(step);
|
||||
}
|
||||
|
||||
void ICooperateState::ICooperateStep::Proceed(Context &context, CooperateEvent &event)
|
||||
{
|
||||
if (next_ == nullptr) {
|
||||
FI_HILOGE("In ICooperateState::ICooperateStep::Proceed, next_ is nullptr");
|
||||
return;
|
||||
}
|
||||
Switch(next_);
|
||||
next_->OnProgress(context, event);
|
||||
}
|
||||
|
||||
void ICooperateState::ICooperateStep::Reset(Context &context, CooperateEvent &event)
|
||||
{
|
||||
if (prev_ == nullptr) {
|
||||
FI_HILOGE("In ICooperateState::ICooperateStep::Reset, prev_ is nullptr");
|
||||
return;
|
||||
}
|
||||
Switch(prev_);
|
||||
prev_->OnReset(context, event);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -29,7 +29,7 @@ struct ShadowInfo {
|
||||
};
|
||||
|
||||
struct DragData {
|
||||
ShadowInfo shadowInfo;
|
||||
std::vector<ShadowInfo> shadowInfos;
|
||||
std::vector<uint8_t> buffer;
|
||||
std::string udKey;
|
||||
std::string filterInfo;
|
||||
|
@ -51,7 +51,6 @@ DragData DragDataManager::GetDragData() const
|
||||
|
||||
void DragDataManager::ResetDragData()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
dragData_ = { };
|
||||
previewStyle_ = { };
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ ohos_shared_library("devicestatus_client") {
|
||||
|
||||
version_script = "libdevicestatus_client_map"
|
||||
sources = [
|
||||
"${device_status_frameworks_path}/native/interaction/src/drag_data_util.cpp",
|
||||
"${device_status_frameworks_path}/native/interaction/src/drag_manager_impl.cpp",
|
||||
"${device_status_frameworks_path}/native/interaction/src/interaction_manager.cpp",
|
||||
"${device_status_frameworks_path}/native/interaction/src/interaction_manager_impl.cpp",
|
||||
|
@ -30,14 +30,31 @@ namespace DeviceStatus {
|
||||
constexpr size_t MAX_BUFFER_SIZE { 512 };
|
||||
constexpr size_t MAX_UDKEY_SIZE { 100 };
|
||||
constexpr size_t MAX_SUMMARY_SIZE { 200 };
|
||||
constexpr int32_t SHADOW_NUM_LIMIT { 3 };
|
||||
struct ShadowInfo {
|
||||
std::shared_ptr<OHOS::Media::PixelMap> pixelMap { nullptr };
|
||||
int32_t x { -1 };
|
||||
int32_t y { -1 };
|
||||
|
||||
bool operator == (const ShadowInfo &other) const
|
||||
{
|
||||
if (pixelMap == nullptr && other.pixelMap == nullptr) {
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
if (pixelMap == nullptr || other.pixelMap == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return pixelMap->IsSameImage(*(other.pixelMap)) && x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
bool operator != (const ShadowInfo &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
struct DragData {
|
||||
ShadowInfo shadowInfo;
|
||||
std::vector<ShadowInfo> shadowInfos;
|
||||
std::vector<uint8_t> buffer;
|
||||
std::string udKey;
|
||||
std::string extraInfo;
|
||||
@ -51,6 +68,20 @@ struct DragData {
|
||||
bool hasCanceledAnimation { false };
|
||||
bool hasCoordinateCorrected { false };
|
||||
std::map<std::string, int64_t> summarys;
|
||||
|
||||
bool operator == (const DragData &other) const
|
||||
{
|
||||
return shadowInfos == other.shadowInfos && buffer == other.buffer && udKey == other.udKey &&
|
||||
filterInfo == other.filterInfo && extraInfo == other.extraInfo && sourceType == other.sourceType &&
|
||||
dragNum == other.dragNum && pointerId == other.pointerId && displayX == other.displayX &&
|
||||
displayY == other.displayY && displayId == other.displayId &&
|
||||
hasCanceledAnimation == other.hasCanceledAnimation && summarys == other.summarys;
|
||||
}
|
||||
|
||||
bool operator != (const DragData &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
enum class DragState {
|
||||
|
34
interfaces/innerkits/interaction/include/drag_data_util.h
Normal file
34
interfaces/innerkits/interaction/include/drag_data_util.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DRAG_DATA_UTIL_H
|
||||
#define DRAG_DATA_UTIL_H
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
#include "drag_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class DragDataUtil {
|
||||
public:
|
||||
static int32_t Marshalling(const DragData &dragData, Parcel &data);
|
||||
static int32_t UnMarshalling(Parcel &data, DragData &dragData);
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // DRAG_DATA_UTIL_H
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef I_START_DRAG_LISTENER_H
|
||||
#define I_START_DRAG_LISTENER_H
|
||||
|
||||
#include "drag_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class IStartDragListener {
|
||||
public:
|
||||
IStartDragListener() = default;
|
||||
virtual ~IStartDragListener() = default;
|
||||
virtual void OnDragEndMessage(const DragNotifyMsg &msg) = 0;
|
||||
virtual void OnHideIconMessage() = 0;
|
||||
};
|
||||
}
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // I_START_DRAG_LISTENER_H
|
@ -25,6 +25,7 @@
|
||||
#include "drag_data.h"
|
||||
#include "i_coordination_listener.h"
|
||||
#include "i_drag_listener.h"
|
||||
#include "i_start_drag_listener.h"
|
||||
#include "i_hotarea_listener.h"
|
||||
#include "i_subscript_listener.h"
|
||||
|
||||
@ -108,11 +109,11 @@ public:
|
||||
/**
|
||||
* @brief Starts dragging.
|
||||
* @param dragData Indicates additional data used for dragging.
|
||||
* @param callback Indicates the callback used to return the dragging result.
|
||||
* @param listener Indicates the listener used to notify dragging result etc.
|
||||
* @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
|
||||
* @since 10
|
||||
*/
|
||||
int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
|
||||
int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener);
|
||||
|
||||
/**
|
||||
* @brief Stops dragging.
|
||||
|
@ -42,7 +42,7 @@
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::ActivateCoordination(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, int, std::__h::function<void (std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, OHOS::Msdp::CoordinationMessage)>, bool)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::DeactivateCoordination(bool, std::__h::function<void (std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, OHOS::Msdp::CoordinationMessage)>, bool)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetCoordinationState(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::function<void (bool)>, bool)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::StartDrag(OHOS::Msdp::DeviceStatus::DragData const&, std::__h::function<void (OHOS::Msdp::DeviceStatus::DragNotifyMsg const&)>)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::StartDrag(OHOS::Msdp::DeviceStatus::DragData const&, std::__h::shared_ptr<OHOS::Msdp::DeviceStatus::IStartDragListener>)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::StopDrag(OHOS::Msdp::DeviceStatus::DragDropResult const&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::SetDragWindowVisible(bool)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetShadowOffset(int&, int&, int&, int&)";
|
||||
@ -56,6 +56,9 @@
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::UpdatePreviewStyleWithAnimation(OHOS::Msdp::DeviceStatus::PreviewStyle const&, OHOS::Msdp::DeviceStatus::PreviewAnimation const&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDragSummary(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDragSummary(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDropType(OHOS::Msdp::DeviceStatus::DropType&)";
|
||||
"OHOS::Msdp::DeviceStatus::DragDataUtil::Marshalling(OHOS::Msdp::DeviceStatus::DragData const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::DragDataUtil::UnMarshalling(OHOS::Parcel&, OHOS::Msdp::DeviceStatus::DragData&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::EnterTextEditorArea(bool)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDragAction(OHOS::Msdp::DeviceStatus::DragAction&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetExtraInfo(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>&)";
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "devicestatus_common.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "drag_data_packer.h"
|
||||
#include "preview_style_packer.h"
|
||||
#include "stationary_callback.h"
|
||||
#include "stationary_data.h"
|
||||
@ -352,24 +353,9 @@ int32_t DeviceStatusSrvProxy::GetDragData(DragData &dragData)
|
||||
FI_HILOGE("Get DragData failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto pixelMap = OHOS::Media::PixelMap::Unmarshalling(reply);
|
||||
CHKPR(pixelMap, RET_ERR);
|
||||
dragData.shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap> (pixelMap);
|
||||
READINT32(reply, dragData.shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READUINT8VECTOR(reply, dragData.buffer, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(reply, dragData.udKey, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.sourceType, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.dragNum, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.pointerId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.displayX, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.displayY, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(reply, dragData.displayId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READBOOL(reply, dragData.hasCanceledAnimation, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
if (!Utility::Unmarshalling(dragData.summarys, reply)) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
return E_DEVICESTATUS_READ_PARCEL_ERROR;
|
||||
if (DragDataPacker::UnMarshalling(reply, dragData) != RET_OK) {
|
||||
FI_HILOGE("UnMarshalling dragData failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -430,26 +416,8 @@ int32_t DeviceStatusSrvProxy::StartDrag(const DragData &dragData)
|
||||
FI_HILOGE("Failed to write descriptor");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
CHKPR(dragData.shadowInfo.pixelMap, RET_ERR);
|
||||
if (!dragData.shadowInfo.pixelMap->Marshalling(data)) {
|
||||
FI_HILOGE("Failed to marshalling pixelMap");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
WRITEINT32(data, dragData.shadowInfo.x, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.shadowInfo.y, ERR_INVALID_VALUE);
|
||||
WRITEUINT8VECTOR(data, dragData.buffer, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.udKey, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.extraInfo, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.filterInfo, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.sourceType, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.dragNum, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.pointerId, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayX, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayY, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayId, ERR_INVALID_VALUE);
|
||||
WRITEBOOL(data, dragData.hasCanceledAnimation, ERR_INVALID_VALUE);
|
||||
if (!Utility::Marshalling(dragData.summarys, data)) {
|
||||
FI_HILOGE("Failed to summarys marshalling");
|
||||
if (DragDataPacker::Marshalling(dragData, data) != RET_OK) {
|
||||
FI_HILOGE("Failed to marshalling dragData");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
MessageParcel reply;
|
||||
@ -789,7 +757,7 @@ int32_t DeviceStatusSrvProxy::GetDragSummary(std::map<std::string, int64_t> &sum
|
||||
FI_HILOGE("Send request failed, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
if (!Utility::Unmarshalling(summarys, reply)) {
|
||||
if (SummaryPacker::UnMarshalling(reply, summarys) != RET_OK) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_service.h"
|
||||
#include "devicestatus_srv_proxy.h"
|
||||
#include "drag_data_packer.h"
|
||||
#include "fi_log.h"
|
||||
#include "preview_style_packer.h"
|
||||
#include "stationary_callback.h"
|
||||
@ -377,7 +378,7 @@ int32_t DeviceStatusSrvStub::GetUdKeyStub(MessageParcel &data, MessageParcel &re
|
||||
FI_HILOGE("Get udKey failed, ret:%{public}d", ret);
|
||||
}
|
||||
WRITESTRING(reply, udKey, IPC_STUB_WRITE_PARCEL_ERR);
|
||||
FI_HILOGD("Target udKey:%{public}s", udKey.c_str());
|
||||
FI_HILOGD("Target udKey:%{public}s", GetAnonyString(udKey).c_str());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -425,33 +426,19 @@ int32_t DeviceStatusSrvStub::HandleAllocSocketFdStub(MessageParcel &data, Messag
|
||||
|
||||
int32_t DeviceStatusSrvStub::StartDragStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
auto pixelMap = OHOS::Media::PixelMap::Unmarshalling(data);
|
||||
CHKPR(pixelMap, RET_ERR);
|
||||
CALL_DEBUG_ENTER;
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap>(pixelMap);
|
||||
READINT32(data, dragData.shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READUINT8VECTOR(data, dragData.buffer, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.udKey, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.extraInfo, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.filterInfo, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.sourceType, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.dragNum, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.pointerId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayX, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayY, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READBOOL(data, dragData.hasCanceledAnimation, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
if (!Utility::Unmarshalling(dragData.summarys, data)) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
if (DragDataPacker::UnMarshalling(data, dragData) != RET_OK) {
|
||||
FI_HILOGE("UnMarshalling dragData failed");
|
||||
return E_DEVICESTATUS_READ_PARCEL_ERROR;
|
||||
}
|
||||
if ((dragData.shadowInfo.x > 0) || (dragData.shadowInfo.y > 0) ||
|
||||
(dragData.shadowInfo.x < -dragData.shadowInfo.pixelMap->GetWidth()) ||
|
||||
(dragData.shadowInfo.y < -dragData.shadowInfo.pixelMap->GetHeight())) {
|
||||
FI_HILOGE("Start drag invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y);
|
||||
return RET_ERR;
|
||||
for (const auto& shadowInfo : dragData.shadowInfos) {
|
||||
CHKPR(shadowInfo.pixelMap, RET_ERR);
|
||||
if ((shadowInfo.x > 0) || (shadowInfo.y > 0) ||
|
||||
(shadowInfo.x < -shadowInfo.pixelMap->GetWidth()) || (shadowInfo.y < -shadowInfo.pixelMap->GetHeight())) {
|
||||
FI_HILOGE("Invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d", shadowInfo.x, shadowInfo.y);
|
||||
return RET_ERR;
|
||||
}
|
||||
}
|
||||
if ((dragData.dragNum <= 0) || (dragData.buffer.size() > MAX_BUFFER_SIZE) ||
|
||||
(dragData.displayX < 0) || (dragData.displayY < 0)) {
|
||||
@ -565,6 +552,7 @@ int32_t DeviceStatusSrvStub::UpdateShadowPicStub(MessageParcel &data, MessagePar
|
||||
shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap>(pixelMap);
|
||||
READINT32(data, shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
CHKPR(shadowInfo.pixelMap, RET_ERR);
|
||||
if ((shadowInfo.x > 0) || (shadowInfo.y > 0) ||
|
||||
(shadowInfo.x < -shadowInfo.pixelMap->GetWidth()) ||
|
||||
(shadowInfo.y < -shadowInfo.pixelMap->GetHeight())) {
|
||||
@ -589,25 +577,9 @@ int32_t DeviceStatusSrvStub::GetDragDataStub(MessageParcel &data, MessageParcel
|
||||
FI_HILOGE("Get DragData failed, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
CHKPR(dragData.shadowInfo.pixelMap, RET_ERR);
|
||||
if (!dragData.shadowInfo.pixelMap->Marshalling(reply)) {
|
||||
FI_HILOGE("Failed to marshalling pixelMap");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
WRITEINT32(reply, dragData.shadowInfo.x, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.shadowInfo.y, ERR_INVALID_VALUE);
|
||||
WRITEUINT8VECTOR(reply, dragData.buffer, ERR_INVALID_VALUE);
|
||||
WRITESTRING(reply, dragData.udKey, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.sourceType, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.dragNum, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.pointerId, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.displayX, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.displayY, ERR_INVALID_VALUE);
|
||||
WRITEINT32(reply, dragData.displayId, ERR_INVALID_VALUE);
|
||||
WRITEBOOL(reply, dragData.hasCanceledAnimation, ERR_INVALID_VALUE);
|
||||
if (!Utility::Marshalling(dragData.summarys, reply)) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
return ERR_INVALID_VALUE;
|
||||
if (DragDataPacker::Marshalling(dragData, reply) != RET_OK) {
|
||||
FI_HILOGE("Marshalling dragData failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -695,7 +667,7 @@ int32_t DeviceStatusSrvStub::GetDragSummaryStub(MessageParcel &data, MessageParc
|
||||
FI_HILOGE("Get summarys failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
if (!Utility::Marshalling(summarys, reply)) {
|
||||
if (SummaryPacker::Marshalling(summarys, reply) != RET_OK) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
void Init(const DragData &dragData);
|
||||
void SetDragStyle(DragCursorStyle style);
|
||||
void SetShadowInfo(const ShadowInfo &shadowInfo);
|
||||
void SetShadowInfos(const std::vector<ShadowInfo> &shadowInfos);
|
||||
DragCursorStyle GetDragStyle() const;
|
||||
void SetDragWindowVisible(bool visible);
|
||||
bool GetDragWindowVisible() const;
|
||||
|
@ -115,6 +115,7 @@ private:
|
||||
int32_t RemoveKeyEventMointor();
|
||||
int32_t RemovePointerEventHandler();
|
||||
int32_t NotifyDragResult(DragResult result);
|
||||
int32_t NotifyHideIcon();
|
||||
int32_t InitDataManager(const DragData &dragData) const;
|
||||
int32_t OnStartDrag();
|
||||
int32_t OnStopDrag(DragResult result, bool hasCustomAnimation);
|
||||
|
@ -48,9 +48,9 @@ void DragDataManager::Init(const DragData &dragData)
|
||||
targetTid_ = -1;
|
||||
}
|
||||
|
||||
void DragDataManager::SetShadowInfo(const ShadowInfo &shadowInfo)
|
||||
void DragDataManager::SetShadowInfos(const std::vector<ShadowInfo> &shadowInfos)
|
||||
{
|
||||
dragData_.shadowInfo = shadowInfo;
|
||||
dragData_.shadowInfos = shadowInfos;
|
||||
}
|
||||
|
||||
DragCursorStyle DragDataManager::GetDragStyle() const
|
||||
@ -95,9 +95,13 @@ int32_t DragDataManager::GetTargetPid() const
|
||||
|
||||
int32_t DragDataManager::GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height) const
|
||||
{
|
||||
offsetX = dragData_.shadowInfo.x;
|
||||
offsetY = dragData_.shadowInfo.y;
|
||||
auto pixelMap = dragData_.shadowInfo.pixelMap;
|
||||
if (dragData_.shadowInfos.empty()) {
|
||||
FI_HILOGE("ShadowInfos is empty");
|
||||
return RET_ERR;
|
||||
}
|
||||
offsetX = dragData_.shadowInfos.front().x;
|
||||
offsetY = dragData_.shadowInfos.front().y;
|
||||
auto pixelMap = dragData_.shadowInfos.front().pixelMap;
|
||||
CHKPR(pixelMap, RET_ERR);
|
||||
width = pixelMap->GetWidth();
|
||||
height = pixelMap->GetHeight();
|
||||
|
@ -223,7 +223,11 @@ int32_t DragDrawing::CheckDragData(const DragData &dragData)
|
||||
FI_HILOGE("Drag drawing is running, can not init again");
|
||||
return INIT_CANCEL;
|
||||
}
|
||||
CHKPR(dragData.shadowInfo.pixelMap, INIT_FAIL);
|
||||
if (dragData.shadowInfos.empty()) {
|
||||
FI_HILOGE("ShadowInfos is empty");
|
||||
return INIT_FAIL;
|
||||
}
|
||||
CHKPR(dragData.shadowInfos.front().pixelMap, INIT_FAIL);
|
||||
if ((dragData.sourceType != MMI::PointerEvent::SOURCE_TYPE_MOUSE) &&
|
||||
(dragData.sourceType != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN)) {
|
||||
FI_HILOGE("Invalid sourceType:%{public}d", dragData.sourceType);
|
||||
@ -708,14 +712,18 @@ void DragDrawing::OnVsync()
|
||||
void DragDrawing::InitDrawingInfo(const DragData &dragData)
|
||||
{
|
||||
g_drawingInfo.isRunning = true;
|
||||
if (dragData.shadowInfos.empty()) {
|
||||
FI_HILOGE("ShadowInfos is empty");
|
||||
return;
|
||||
}
|
||||
g_drawingInfo.pixelMap = dragData.shadowInfos.front().pixelMap;
|
||||
g_drawingInfo.pixelMapX = dragData.shadowInfos.front().x;
|
||||
g_drawingInfo.pixelMapY = dragData.shadowInfos.front().y;
|
||||
g_drawingInfo.currentDragNum = dragData.dragNum;
|
||||
g_drawingInfo.sourceType = dragData.sourceType;
|
||||
g_drawingInfo.displayId = dragData.displayId;
|
||||
g_drawingInfo.displayX = dragData.displayX;
|
||||
g_drawingInfo.displayY = dragData.displayY;
|
||||
g_drawingInfo.pixelMap = dragData.shadowInfo.pixelMap;
|
||||
g_drawingInfo.pixelMapX = dragData.shadowInfo.x;
|
||||
g_drawingInfo.pixelMapY = dragData.shadowInfo.y;
|
||||
g_drawingInfo.extraInfo = dragData.extraInfo;
|
||||
g_drawingInfo.filterInfo = dragData.filterInfo;
|
||||
}
|
||||
|
@ -123,23 +123,26 @@ int32_t DragManager::RemoveSubscriptListener(SessionPtr session)
|
||||
|
||||
void DragManager::PrintDragData(const DragData &dragData)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
for (const auto& shadowInfo : dragData.shadowInfos) {
|
||||
CHKPV(shadowInfo.pixelMap);
|
||||
FI_HILOGI("PixelFormat:%{public}d, PixelAlphaType:%{public}d, PixelAllocatorType:%{public}d,"
|
||||
" PixelWidth:%{public}d, PixelHeight:%{public}d, shadowX:%{public}d, shadowY:%{public}d",
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetPixelFormat()),
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetAlphaType()),
|
||||
static_cast<int32_t>(shadowInfo.pixelMap->GetAllocatorType()),
|
||||
shadowInfo.pixelMap->GetWidth(), shadowInfo.pixelMap->GetHeight(), shadowInfo.x, shadowInfo.y);
|
||||
}
|
||||
std::string summarys;
|
||||
for (const auto &[udKey, recordSize] : dragData.summarys) {
|
||||
std::string str = udKey + "-" + std::to_string(recordSize) + ";";
|
||||
summarys += str;
|
||||
}
|
||||
FI_HILOGI("dragData value Contains PixelFormat:%{public}d, PixelAlphaType:%{public}d,"
|
||||
" PixelAllocatorType:%{public}d, PixelWidth:%{public}d, PixelHeight:%{public}d, shadowX:%{public}d,"
|
||||
" shadowY:%{public}d, sourceType:%{public}d, pointerId:%{public}d, displayId:%{public}d,"
|
||||
FI_HILOGI("SourceType:%{public}d, pointerId:%{public}d, displayId:%{public}d,"
|
||||
" displayX:%{public}d, displayY:%{public}d, dragNum:%{public}d,"
|
||||
" hasCanceledAnimation:%{public}d, udKey:%{public}s,"
|
||||
" hasCoordinateCorrected:%{public}d, summarys:%{public}s",
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetPixelFormat()),
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetAllocatorType()),
|
||||
static_cast<int32_t>(dragData.shadowInfo.pixelMap->GetAlphaType()),
|
||||
dragData.shadowInfo.pixelMap->GetWidth(), dragData.shadowInfo.pixelMap->GetHeight(),
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y, dragData.sourceType, dragData.pointerId,
|
||||
dragData.displayId, dragData.displayX, dragData.displayY, dragData.dragNum, dragData.hasCanceledAnimation,
|
||||
" hasCanceledAnimation:%{public}d, udKey:%{public}s, hasCoordinateCorrected:%{public}d, summarys:%{public}s",
|
||||
dragData.sourceType, dragData.pointerId, dragData.displayId, dragData.displayX,
|
||||
dragData.displayY, dragData.dragNum, dragData.hasCanceledAnimation,
|
||||
GetAnonyString(dragData.udKey).c_str(), dragData.hasCoordinateCorrected, summarys.c_str());
|
||||
}
|
||||
|
||||
@ -253,7 +256,7 @@ int32_t DragManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
|
||||
FI_HILOGE("No drag instance running, can not update shadow picture");
|
||||
return RET_ERR;
|
||||
}
|
||||
DRAG_DATA_MGR.SetShadowInfo(shadowInfo);
|
||||
DRAG_DATA_MGR.SetShadowInfos({ shadowInfo });
|
||||
return dragDrawing_.UpdateShadowPic(shadowInfo);
|
||||
}
|
||||
|
||||
@ -302,6 +305,22 @@ int32_t DragManager::NotifyDragResult(DragResult result)
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::NotifyHideIcon()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
NetPacket pkt(MessageId::DRAG_NOTIFY_HIDE_ICON);
|
||||
if (pkt.ChkRWError()) {
|
||||
FI_HILOGE("Packet write data failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
CHKPR(dragOutSession_, RET_ERR);
|
||||
if (!dragOutSession_->SendMsg(pkt)) {
|
||||
FI_HILOGE("Send message failed");
|
||||
return MSG_SEND_FAIL;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void DragManager::DragCallback(std::shared_ptr<MMI::PointerEvent> pointerEvent)
|
||||
{
|
||||
CHKPV(pointerEvent);
|
||||
@ -450,16 +469,21 @@ void DragManager::Dump(int32_t fd) const
|
||||
FI_HILOGE("Target udKey is empty");
|
||||
udKey = "";
|
||||
}
|
||||
for (const auto& shadowInfo : dragData.shadowInfos) {
|
||||
dprintf(fd, "dragData = {\n""\tshadowInfoX:%d\n\tshadowInfoY\n", shadowInfo.x, shadowInfo.y);
|
||||
}
|
||||
dprintf(fd, "dragData = {\n"
|
||||
"\tshadowInfoX:%d\n\tshadowInfoY:%d\n\tudKey:%s\n\tfilterInfo:%s\n\textraInfo:%s\n\tsourceType:%d"
|
||||
"\tudKey:%s\n\tfilterInfo:%s\n\textraInfo:%s\n\tsourceType:%d"
|
||||
"\tdragNum:%d\n\tpointerId:%d\n\tdisplayX:%d\n\tdisplayY:%d\n""\tdisplayId:%d\n\thasCanceledAnimation:%s\n",
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y, udKey.c_str(), dragData.filterInfo.c_str(),
|
||||
dragData.extraInfo.c_str(), dragData.sourceType, dragData.dragNum, dragData.pointerId, dragData.displayX,
|
||||
dragData.displayY, dragData.displayId, dragData.hasCanceledAnimation ? "true" : "false");
|
||||
GetAnonyString(dragData.udKey).c_str(), dragData.filterInfo.c_str(), dragData.extraInfo.c_str(), dragData.sourceType,
|
||||
dragData.dragNum, dragData.pointerId, dragData.displayX, dragData.displayY, dragData.displayId,
|
||||
dragData.hasCanceledAnimation ? "true" : "false");
|
||||
if (dragState_ != DragState::STOP) {
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = dragData.shadowInfo.pixelMap;
|
||||
CHKPV(pixelMap);
|
||||
dprintf(fd, "\tpixelMapWidth:%d\n\tpixelMapHeight:%d\n", pixelMap->GetWidth(), pixelMap->GetHeight());
|
||||
for (const auto& shadowInfo : dragData.shadowInfos) {
|
||||
CHKPV(shadowInfo.pixelMap);
|
||||
dprintf(fd, "\tpixelMapWidth:%d\n\tpixelMapHeight:%d\n", shadowInfo.pixelMap->GetWidth(),
|
||||
shadowInfo.pixelMap->GetHeight());
|
||||
}
|
||||
}
|
||||
dprintf(fd, "}\n");
|
||||
}
|
||||
|
@ -102,10 +102,9 @@ std::optional<DragData> DragDataManagerTest::CreateDragData(int32_t sourceType,
|
||||
FI_HILOGE("Create pixelmap failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.x = 0;
|
||||
dragData.shadowInfo.y = 0;
|
||||
dragData.shadowInfo.pixelMap = pixelMap;
|
||||
dragData.shadowInfos.push_back({ pixelMap, 0, 0 });
|
||||
dragData.buffer = std::vector<uint8_t>(MAX_BUFFER_SIZE, 0);
|
||||
dragData.udKey = UD_KEY;
|
||||
dragData.sourceType = sourceType;
|
||||
@ -206,9 +205,7 @@ HWTEST_F(DragDataManagerTest, DragDataManagerTest005, TestSize.Level0)
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
|
||||
EXPECT_FALSE(pixelMap == nullptr);
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.pixelMap = pixelMap;
|
||||
dragData.shadowInfo.x = SHADOWINFO_X;
|
||||
dragData.shadowInfo.y = SHADOWINFO_Y;
|
||||
dragData.shadowInfos.push_back({ pixelMap, SHADOWINFO_X, SHADOWINFO_Y });
|
||||
dragData.displayX = DISPLAY_X;
|
||||
dragData.displayY = DISPLAY_Y;
|
||||
DRAG_DATA_MGR.Init(dragData);
|
||||
@ -239,9 +236,7 @@ HWTEST_F(DragDataManagerTest, DragDataManagerTest006, TestSize.Level0)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
DragData dragData;
|
||||
dragData.shadowInfo.pixelMap = nullptr;
|
||||
dragData.shadowInfo.x = SHADOWINFO_X;
|
||||
dragData.shadowInfo.y = SHADOWINFO_Y;
|
||||
dragData.shadowInfos.push_back({ nullptr, SHADOWINFO_X, SHADOWINFO_Y });
|
||||
dragData.displayX = DISPLAY_X;
|
||||
dragData.displayY = DISPLAY_Y;
|
||||
DRAG_DATA_MGR.Init(dragData);
|
||||
|
@ -40,6 +40,7 @@ ohos_shared_library("devicestatus_util") {
|
||||
version_script = "libdevicestatus_util_map"
|
||||
sources = [
|
||||
"src/animation_curve.cpp",
|
||||
"src/drag_data_packer.cpp",
|
||||
"src/preview_style_packer.cpp",
|
||||
"src/util.cpp",
|
||||
"src/util_napi.cpp",
|
||||
|
52
utils/common/include/drag_data_packer.h
Normal file
52
utils/common/include/drag_data_packer.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DRAG_DATA_PACKER_H
|
||||
#define DRAG_DATA_PACKER_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
#include "drag_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
|
||||
using SummaryMap = std::map<std::string, int64_t>;
|
||||
class DragDataPacker {
|
||||
public:
|
||||
static int32_t Marshalling(const DragData &dragData, Parcel &data);
|
||||
static int32_t UnMarshalling(Parcel &data, DragData &dragData);
|
||||
};
|
||||
|
||||
class ShadowPacker {
|
||||
public:
|
||||
static int32_t Marshalling(const std::vector<ShadowInfo> &shadowInfos, Parcel &data);
|
||||
static int32_t UnMarshalling(Parcel &data, std::vector<ShadowInfo> &shadowInfos);
|
||||
};
|
||||
|
||||
class SummaryPacker {
|
||||
public:
|
||||
static int32_t Marshalling(const SummaryMap &val, Parcel &parcel);
|
||||
static int32_t UnMarshalling(Parcel &parcel, SummaryMap &val);
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // DRAG_DATA_PACKER_H
|
@ -51,6 +51,7 @@ enum class MessageId : int32_t {
|
||||
|
||||
DRAG_NOTIFY_RESULT,
|
||||
DRAG_STATE_LISTENER,
|
||||
DRAG_NOTIFY_HIDE_ICON,
|
||||
DRAG_STYLE_LISTENER
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,6 @@ namespace DeviceStatus {
|
||||
|
||||
template<typename, typename = std::void_t<>>
|
||||
struct IsStreamable : public std::false_type {};
|
||||
using summaryMap = std::map<std::string, int64_t>;
|
||||
|
||||
template<typename T>
|
||||
struct IsStreamable<T, std::void_t<decltype(operator<<(std::declval<std::ostream>(), std::declval<T>()))>>
|
||||
@ -63,8 +62,6 @@ public:
|
||||
|
||||
static void ShowFileAttributes(const char *path);
|
||||
static void ShowUserAndGroup();
|
||||
static bool Marshalling(const summaryMap &val, Parcel &parcel);
|
||||
static bool Unmarshalling(summaryMap &val, Parcel &parcel);
|
||||
};
|
||||
|
||||
inline bool Utility::IsEmpty(const char *str)
|
||||
|
@ -36,10 +36,12 @@
|
||||
"OHOS::Msdp::DeviceStatus::StringSplit(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::vector<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, std::__h::allocator<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::StringPrintf(char const*, ...)";
|
||||
"OHOS::Msdp::DeviceStatus::GetAnonyString(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&)";
|
||||
"OHOS::Msdp::DeviceStatus::Utility::Unmarshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>>&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::Utility::Marshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>> const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::Utility::Unmarshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>>&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::Utility::Marshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>> const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::DragDataPacker::Marshalling(OHOS::Msdp::DeviceStatus::DragData const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::DragDataPacker::UnMarshalling(OHOS::Parcel&, OHOS::Msdp::DeviceStatus::DragData&)";
|
||||
"OHOS::Msdp::DeviceStatus::SummaryPacker::UnMarshalling(OHOS::Parcel&, std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::SummaryPacker::Marshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>> const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::SummaryPacker::UnMarshalling(OHOS::Parcel&, std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::SummaryPacker::Marshalling(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>> const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::PreviewStylePacker::Marshalling(OHOS::Msdp::DeviceStatus::PreviewStyle const&, OHOS::Parcel&)";
|
||||
"OHOS::Msdp::DeviceStatus::PreviewStylePacker::UnMarshalling(OHOS::Parcel&, OHOS::Msdp::DeviceStatus::PreviewStyle&)";
|
||||
"OHOS::Msdp::DeviceStatus::PreviewAnimationPacker::Marshalling(OHOS::Msdp::DeviceStatus::PreviewAnimation const&, OHOS::Parcel&)";
|
||||
|
157
utils/common/src/drag_data_packer.cpp
Normal file
157
utils/common/src/drag_data_packer.cpp
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "drag_data_packer.h"
|
||||
|
||||
#include "devicestatus_common.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_errors.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragDataPacker" };
|
||||
} // namespace
|
||||
|
||||
namespace DeviceStatus {
|
||||
|
||||
int32_t DragDataPacker::Marshalling(const DragData &dragData, Parcel &data)
|
||||
{
|
||||
if (ShadowPacker::Marshalling(dragData.shadowInfos, data) != RET_OK) {
|
||||
FI_HILOGE("Failed to marshalling shadowInfos");
|
||||
return RET_ERR;
|
||||
}
|
||||
WRITEUINT8VECTOR(data, dragData.buffer, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.udKey, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.extraInfo, ERR_INVALID_VALUE);
|
||||
WRITESTRING(data, dragData.filterInfo, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.sourceType, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.dragNum, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.pointerId, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayX, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayY, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, dragData.displayId, ERR_INVALID_VALUE);
|
||||
WRITEBOOL(data, dragData.hasCanceledAnimation, ERR_INVALID_VALUE);
|
||||
if (SummaryPacker::Marshalling(dragData.summarys, data) != RET_OK) {
|
||||
FI_HILOGE("Failed to summarys marshalling");
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragDataPacker::UnMarshalling(Parcel &data, DragData &dragData)
|
||||
{
|
||||
if (ShadowPacker::UnMarshalling(data, dragData.shadowInfos) != RET_OK) {
|
||||
FI_HILOGE("UnMarshallingShadowInfos failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
READUINT8VECTOR(data, dragData.buffer, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.udKey, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.extraInfo, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READSTRING(data, dragData.filterInfo, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.sourceType, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.dragNum, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.pointerId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayX, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayY, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, dragData.displayId, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READBOOL(data, dragData.hasCanceledAnimation, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
if (SummaryPacker::UnMarshalling(data, dragData.summarys) != RET_OK) {
|
||||
FI_HILOGE("Failed to summarys unmarshalling");
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t ShadowPacker::Marshalling(const std::vector<ShadowInfo> &shadowInfos, Parcel &data)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (shadowInfos.empty()) {
|
||||
FI_HILOGE("Invalid parameter shadowInfos");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t shadowNum = static_cast<int32_t>(shadowInfos.size());
|
||||
if (shadowNum > SHADOW_NUM_LIMIT) {
|
||||
FI_HILOGW("Only %{public}d shadowInfos are allowed to be packaged at most, now %{public}d exceeding the limit",
|
||||
SHADOW_NUM_LIMIT, shadowNum);
|
||||
shadowNum = SHADOW_NUM_LIMIT;
|
||||
}
|
||||
WRITEINT32(data, shadowNum, ERR_INVALID_VALUE);
|
||||
for (int32_t i = 0; i < shadowNum; i++) {
|
||||
CHKPR(shadowInfos[i].pixelMap, RET_ERR);
|
||||
if (!shadowInfos[i].pixelMap->Marshalling(data)) {
|
||||
FI_HILOGE("Failed to marshalling pixelMap");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
WRITEINT32(data, shadowInfos[i].x, ERR_INVALID_VALUE);
|
||||
WRITEINT32(data, shadowInfos[i].y, ERR_INVALID_VALUE);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t ShadowPacker::UnMarshalling(Parcel &data, std::vector<ShadowInfo> &shadowInfos)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t shadowNum { 0 };
|
||||
READINT32(data, shadowNum, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
if (shadowNum <= 0 || shadowNum > SHADOW_NUM_LIMIT) {
|
||||
FI_HILOGE("Invalid shadowNum:%{public}d", shadowNum);
|
||||
return RET_ERR;
|
||||
}
|
||||
for (int32_t i = 0; i < shadowNum; i++) {
|
||||
ShadowInfo shadowInfo;
|
||||
auto pixelMap = OHOS::Media::PixelMap::Unmarshalling(data);
|
||||
CHKPR(pixelMap, RET_ERR);
|
||||
shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap>(pixelMap);
|
||||
READINT32(data, shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
shadowInfos.push_back(shadowInfo);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t SummaryPacker::Marshalling(const SummaryMap &val, Parcel &parcel)
|
||||
{
|
||||
WRITEINT32(parcel, static_cast<int32_t>(val.size()), ERR_INVALID_VALUE);
|
||||
for (auto const &[k, v] : val) {
|
||||
WRITESTRING(parcel, k, ERR_INVALID_VALUE);
|
||||
WRITEINT64(parcel, v, ERR_INVALID_VALUE);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t SummaryPacker::UnMarshalling(Parcel &parcel, SummaryMap &val)
|
||||
{
|
||||
int32_t size = 0;
|
||||
READINT32(parcel, size, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
if (size < 0) {
|
||||
FI_HILOGE("Invalid size:%{public}d", size);
|
||||
return RET_ERR;
|
||||
}
|
||||
size_t readAbleSize = parcel.GetReadableBytes();
|
||||
if ((static_cast<size_t>(size) > readAbleSize) || static_cast<size_t>(size) > val.max_size()) {
|
||||
FI_HILOGE("Invalid size:%{public}d", size);
|
||||
return RET_ERR;
|
||||
}
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
std::string key;
|
||||
READSTRING(parcel, key, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT64(parcel, val[key], E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -215,37 +215,6 @@ void Utility::ShowUserAndGroup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Utility::Marshalling(const summaryMap &val, Parcel &parcel)
|
||||
{
|
||||
WRITEINT32(parcel, static_cast<int32_t>(val.size()), false);
|
||||
for (auto const &[k, v] : val) {
|
||||
WRITESTRING(parcel, k, false);
|
||||
WRITEINT64(parcel, v, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Utility::Unmarshalling(summaryMap &val, Parcel &parcel)
|
||||
{
|
||||
int32_t size = 0;
|
||||
READINT32(parcel, size, false);
|
||||
if (size < 0) {
|
||||
FI_HILOGE("Invalid size:%{public}d", size);
|
||||
return false;
|
||||
}
|
||||
size_t readAbleSize = parcel.GetReadableBytes();
|
||||
if ((static_cast<size_t>(size) > readAbleSize) || static_cast<size_t>(size) > val.max_size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
std::string key;
|
||||
READSTRING(parcel, key, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT64(parcel, val[key], E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user