From c02f0225ace9488fc9b7f43ba0ae083d2406eb2d Mon Sep 17 00:00:00 2001 From: mayunteng Date: Mon, 3 Apr 2023 08:54:37 +0000 Subject: [PATCH 1/5] Signed-off-by: mayunteng_1 Signed-off-by: mayunteng Change-Id: I69ce3939a48243ac13732b3a2a33849678b1f1a3 --- services/context/include/i_context.h | 2 + services/context/include/i_drag_manager.h | 34 ++++++ services/device_manager/include/device.h | 1 - services/device_manager/src/device.cpp | 9 +- .../interaction/drag/include/drag_manager.h | 9 +- .../interaction/drag/src/drag_manager.cpp | 107 ++++++++++++++++++ services/native/include/devicestatus_dumper.h | 11 +- .../native/include/devicestatus_service.h | 4 +- services/native/src/devicestatus_dumper.cpp | 43 ++++--- services/native/src/devicestatus_service.cpp | 14 ++- services/native/test/unittest/BUILD.gn | 7 +- utils/common/include/util.h | 1 + utils/common/include/utility.h | 1 + utils/common/src/util.cpp | 19 ++++ utils/common/src/utility.cpp | 5 + 15 files changed, 221 insertions(+), 46 deletions(-) create mode 100644 services/context/include/i_drag_manager.h diff --git a/services/context/include/i_context.h b/services/context/include/i_context.h index 21cabacf0..322c9c636 100644 --- a/services/context/include/i_context.h +++ b/services/context/include/i_context.h @@ -18,6 +18,7 @@ #include "i_delegate_tasks.h" #include "i_device_manager.h" +#include "i_drag_manager.h" #include "i_timer_manager.h" namespace OHOS { @@ -36,6 +37,7 @@ public: virtual IDelegateTasks& GetDelegateTasks() = 0; virtual IDeviceManager& GetDeviceManager() = 0; virtual ITimerManager& GetTimerManager() = 0; + virtual IDragManager& GetDragManager() = 0; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/context/include/i_drag_manager.h b/services/context/include/i_drag_manager.h new file mode 100644 index 000000000..caccb64b9 --- /dev/null +++ b/services/context/include/i_drag_manager.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_DRAG_MANAGER_H +#define I_DRAG_MANAGER_H + +#include + +namespace OHOS { +namespace Msdp { +namespace DeviceStatus { +class IDragManager { +public: + IDragManager() = default; + virtual ~IDragManager() = default; + + virtual void Dump(int32_t fd) = 0; +}; +} // namespace DeviceStatus +} // namespace Msdp +} // namespace OHOS +#endif // I_DRAG_MANAGER_H \ No newline at end of file diff --git a/services/device_manager/include/device.h b/services/device_manager/include/device.h index c45680e8a..60dbbcbb6 100644 --- a/services/device_manager/include/device.h +++ b/services/device_manager/include/device.h @@ -101,7 +101,6 @@ private: void UpdateCapability(); void CheckPointers(); void CheckKeys(); - void RemoveSpace(std::string &str) const; std::string MakeConfigFileName() const; int32_t ReadConfigFile(const std::string &filePath); int32_t ConfigItemSwitch(const std::string &configItem, const std::string &value); diff --git a/services/device_manager/src/device.cpp b/services/device_manager/src/device.cpp index 03c4063d1..7016e7ce6 100644 --- a/services/device_manager/src/device.cpp +++ b/services/device_manager/src/device.cpp @@ -244,17 +244,12 @@ void Device::CheckKeys() } } -void Device::RemoveSpace(std::string &str) const -{ - str.erase(remove_if(str.begin(), str.end(), [](unsigned char c) { return std::isspace(c);}), str.end()); -} - std::string Device::MakeConfigFileName() const { std::ostringstream ss; ss << GetVendor() << "_" << GetProduct() << "_" << GetVersion() << "_" << GetName(); std::string fname { ss.str() }; - RemoveSpace(fname); + Utility::RemoveSpace(fname); std::ostringstream sp; sp << "/vendor/etc/keymap/" << fname << ".TOML"; @@ -271,7 +266,7 @@ int32_t Device::ReadConfigFile(const std::string &filePath) } std::string tmp; while (std::getline(cfgFile, tmp)) { - RemoveSpace(tmp); + Utility::RemoveSpace(tmp); size_t pos = tmp.find('#'); if (pos != tmp.npos && pos != COMMENT_SUBSCRIPT) { FI_HILOGE("File format is error"); diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index 798d3ae73..02dcbeadf 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -19,7 +19,6 @@ #include #include "extra_data.h" -#include "i_context.h" #include "i_input_event_consumer.h" #include "input_manager.h" #include "pixel_map.h" @@ -27,13 +26,14 @@ #include "devicestatus_define.h" #include "drag_data.h" #include "drag_drawing.h" +#include "i_context.h" #include "state_change_notify.h" #include "stream_session.h" namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DragManager { +class DragManager : public IDragManager { public: DragManager() {} @@ -56,6 +56,7 @@ public: void OnDragMove(std::shared_ptr pointerEvent); int32_t OnSetDragWindowVisible(bool visible); int32_t OnGetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height); + void Dump(int32_t fd); class InterceptorConsumer final : public MMI::IInputEventConsumer { public: InterceptorConsumer(IContext *context, @@ -75,10 +76,14 @@ private: int32_t InitDataAdapter(const DragData &dragData) const; int32_t OnStartDrag(); int32_t OnStopDrag(DragResult result, bool hasCustomAnimation); + std::string GetDragState(DragMessage value) const; + std::string GetDragResult(DragResult value) const; + std::string GetDragCursorStyle(DragCursorStyle value) const; private: int32_t timerId_ { 0 }; StateChangeNotify stateNotify_; DragMessage dragState_ { DragMessage::MSG_DRAG_STATE_STOP }; + DragResult dragResult_ { DragResult::DRAG_FAIL }; int32_t interceptorId_ { -1 }; int32_t dragTargetPid_ { -1 }; SessionPtr dragOutSession_ { nullptr }; diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index db76c9185..4fb9d13f0 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -123,6 +123,7 @@ int32_t DragManager::StopDrag(DragResult result, bool hasCustomAnimation) FI_HILOGE("NotifyDragResult failed"); return RET_ERR; } + dragResult_ = static_cast(result); return RET_OK; } @@ -283,6 +284,112 @@ void DragManager::InterceptorConsumer::OnInputEvent(std::shared_ptr pixelMap = dragData.shadowInfo.pixelMap; + CHKPV(pixelMap); + dprintf(fd, "Drag information:\n"); + dprintf(fd, + "dragState:%s | dragResult:%s | interceptorId:%d | dragTargetPid:%d | cursorStyle:%s | isWindowVisble:%s\n" + "pixelMapWidth:%d | pixelMapHeight:%d | shadowInfoX:%d | shadowInfoY:%d | sourceType:%d | dragNum:%d\n" + "pointerId:%d | displayX:%d | displayY:%d | displayId:%d | hasCanceledAnimation:%s\n", + GetDragState(dragState_).c_str(), GetDragResult(dragResult_).c_str(), interceptorId_, GetDragTargetPid(), + GetDragCursorStyle(style).c_str(), DataAdapter.GetDragWindowVisible() ? "true" : "false", + pixelMap->GetWidth(), pixelMap->GetHeight(), dragData.shadowInfo.x, dragData.shadowInfo.y, + dragData.sourceType, dragData.dragNum, dragData.pointerId, dragData.displayX, dragData.displayY, + dragData.displayId, dragData.hasCanceledAnimation ? "true" : "false"); +} + +std::string DragManager::GetDragState(DragMessage value) const +{ + std::string state; + switch (value) { + case DragMessage::MSG_DRAG_STATE_START: { + state = "start"; + break; + } + case DragMessage::MSG_DRAG_STATE_STOP: { + state = "stop"; + break; + } + case DragMessage::MSG_DRAG_STATE_CANCEL: { + state = "cancel"; + break; + } + case DragMessage::MSG_DRAG_STATE_ERROR: { + state = "error"; + break; + } + default: { + state = "unknown"; + FI_HILOGW("Drag status unknown"); + break; + } + } + return state; +} + +std::string DragManager::GetDragResult(DragResult value) const +{ + std::string result; + switch (value) { + case DragResult::DRAG_SUCCESS: { + result = "success"; + break; + } + case DragResult::DRAG_FAIL: { + result = "fail"; + break; + } + case DragResult::DRAG_CANCEL: { + result = "cancel"; + break; + } + case DragResult::DRAG_EXCEPTION: { + result = "abnormal"; + break; + } + default: { + result = "unknown"; + FI_HILOGW("Drag result unknown"); + break; + } + } + return result; +} + +std::string DragManager::GetDragCursorStyle(DragCursorStyle value) const +{ + std::string style; + switch (value) { + case DragCursorStyle::COPY: { + style = "copy"; + break; + } + case DragCursorStyle::DEFAULT: { + style = "default"; + break; + } + case DragCursorStyle::FORBIDDEN: { + style = "forbidden"; + break; + } + case DragCursorStyle::MOVE: { + style = "move"; + break; + } + default: { + style = "unknown"; + FI_HILOGW("Drag cursor style unknown"); + break; + } + } + return style; +} + OHOS::MMI::ExtraData DragManager::CreateExtraData(bool appended) const { CALL_DEBUG_ENTER; diff --git a/services/native/include/devicestatus_dumper.h b/services/native/include/devicestatus_dumper.h index df47acac2..d9440119e 100644 --- a/services/native/include/devicestatus_dumper.h +++ b/services/native/include/devicestatus_dumper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -16,11 +16,10 @@ #ifndef DEVICESTATUS_DUMPER_H #define DEVICESTATUS_DUMPER_H -#include -#include #include #include #include +#include #include #include #include @@ -30,6 +29,7 @@ #include "accesstoken_kit.h" #include "devicestatus_data_utils.h" #include "idevicestatus_callback.h" +#include "i_context.h" namespace OHOS { namespace Msdp { @@ -40,8 +40,6 @@ const std::string ARG_DUMP_DEVICESTATUS_CHANGES = "-l"; const std::string ARG_DUMP_DEVICESTATUS_CURRENT_STATE = "-c"; constexpr int32_t RET_NG = -1; constexpr uint32_t MAX_DEVICE_STATUS_SIZE = 10; -constexpr uint32_t BASE_YEAR = 1900; -constexpr uint32_t BASE_MON = 1; struct AppInfo { std::string startTime; int32_t uid {}; @@ -60,6 +58,7 @@ class DeviceStatusDumper final : public RefBase, public: DeviceStatusDumper() = default; ~DeviceStatusDumper() = default; + int32_t Init(IContext *context); void ParseCommand(int32_t fd, const std::vector &args, const std::vector &datas); void ParseLong(int32_t fd, const std::vector &args, const std::vector &datas); void ExecutDump(int32_t fd, const std::vector &datas, int32_t info); @@ -73,13 +72,13 @@ public: std::string GetPackageName(Security::AccessToken::AccessTokenID tokenId); private: DISALLOW_COPY_AND_MOVE(DeviceStatusDumper); - void DumpCurrentTime(std::string &startTime) const; std::string GetStatusType(Type type) const; std::string GetDeviceState(OnChangedValue type) const; std::map>> appInfoMap_; std::queue> deviceStatusQueue_; std::mutex mutex_; + IContext *context_ { nullptr }; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/native/include/devicestatus_service.h b/services/native/include/devicestatus_service.h index c0b8a414a..a5a319bf8 100644 --- a/services/native/include/devicestatus_service.h +++ b/services/native/include/devicestatus_service.h @@ -21,6 +21,7 @@ #include #include +#include "across_device_drag.h" #include "delegate_tasks.h" #include "device_manager.h" #include "devicestatus_srv_stub.h" @@ -28,7 +29,6 @@ #include "devicestatus_dumper.h" #include "devicestatus_manager.h" #include "devicestatus_delayed_sp_singleton.h" -#include "across_device_drag.h" #include "drag_data.h" #include "drag_manager.h" #include "i_context.h" @@ -54,6 +54,7 @@ public: IDelegateTasks& GetDelegateTasks() override; IDeviceManager& GetDeviceManager() override; ITimerManager& GetTimerManager() override; + IDragManager& GetDragManager() override; void Subscribe(Type type, ActivityEvent event, ReportLatencyNs latency, sptr callback) override; @@ -127,6 +128,7 @@ private: std::shared_ptr msdpImpl_; DragManager dragMgr_; AcrossDeviceDrag acrossDeviceDrag_; + DeviceStatusDumper deviceStatusDumper_; }; } // namespace DeviceStatus diff --git a/services/native/src/devicestatus_dumper.cpp b/services/native/src/devicestatus_dumper.cpp index 237d9c9bc..db593db06 100644 --- a/services/native/src/devicestatus_dumper.cpp +++ b/services/native/src/devicestatus_dumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -32,13 +32,24 @@ #include "devicestatus_common.h" #include "devicestatus_define.h" #include "devicestatus_dumper.h" +#include "drag_manager.h" +#include "util.h" namespace OHOS { namespace Msdp { namespace DeviceStatus { namespace { - constexpr uint32_t MS_NS = 1000000; + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusDumper" }; } + +int32_t DeviceStatusDumper::Init(IContext *context) +{ + CALL_DEBUG_ENTER; + CHKPR(context, RET_ERR); + context_ = context; + return RET_OK; +} + void DeviceStatusDumper::ParseCommand(int32_t fd, const std::vector &args, const std::vector &datas) { ParseLong(fd, args, datas); @@ -123,6 +134,8 @@ void DeviceStatusDumper::ExecutDump(int32_t fd, const std::vector &datas, break; } case 'd': { + CHKPV(context_); + context_->GetDragManager().Dump(fd); break; } default: { @@ -141,7 +154,7 @@ void DeviceStatusDumper::DumpDeviceStatusSubscriber(int32_t fd) return; } std::string startTime; - DumpCurrentTime(startTime); + GetTimeStamp(startTime); dprintf(fd, "Current time: %s \n", startTime.c_str()); for (const auto &item : appInfoMap_) { for (auto appInfo : item.second) { @@ -160,7 +173,7 @@ void DeviceStatusDumper::DumpDeviceStatusChanges(int32_t fd) return; } std::string startTime; - DumpCurrentTime(startTime); + GetTimeStamp(startTime); dprintf(fd, "Current time:%s\n", startTime.c_str()); size_t length = deviceStatusQueue_.size() > MAX_DEVICE_STATUS_SIZE ? \ MAX_DEVICE_STATUS_SIZE : deviceStatusQueue_.size(); @@ -182,7 +195,7 @@ void DeviceStatusDumper::DumpDeviceStatusCurrentStatus(int32_t fd, const std::ve { DEV_HILOGI(SERVICE, "start"); std::string startTime; - DumpCurrentTime(startTime); + GetTimeStamp(startTime); dprintf(fd, "Current time:%s\n", startTime.c_str()); dprintf(fd, "Current device status:\n"); if (datas.empty()) { @@ -250,22 +263,6 @@ std::string DeviceStatusDumper::GetStatusType(Type type) const return stateType; } -void DeviceStatusDumper::DumpCurrentTime(std::string &startTime) const -{ - timespec curTime; - clock_gettime(CLOCK_REALTIME, &curTime); - struct tm *timeinfo = localtime(&(curTime.tv_sec)); - if (timeinfo == nullptr) { - DEV_HILOGE(SERVICE, "get localtime failed"); - return; - } - startTime.append(std::to_string(timeinfo->tm_year + BASE_YEAR)).append("-") - .append(std::to_string(timeinfo->tm_mon + BASE_MON)).append("-").append(std::to_string(timeinfo->tm_mday)) - .append(" ").append(std::to_string(timeinfo->tm_hour)).append(":").append(std::to_string(timeinfo->tm_min)) - .append(":").append(std::to_string(timeinfo->tm_sec)).append(".") - .append(std::to_string(curTime.tv_nsec / MS_NS)); -} - void DeviceStatusDumper::DumpHelpInfo(int32_t fd) const { dprintf(fd, "Usage:\n"); @@ -284,7 +281,7 @@ void DeviceStatusDumper::SaveAppInfo(std::shared_ptr appInfo) DEV_HILOGE(SERVICE, "appInfo is nullptr"); return; } - DumpCurrentTime(appInfo->startTime); + GetTimeStamp(appInfo->startTime); std::set> appInfos; auto iter = appInfoMap_.find(appInfo->type); if (iter == appInfoMap_.end()) { @@ -332,7 +329,7 @@ void DeviceStatusDumper::PushDeviceStatus(const Data& data) DEV_HILOGD(SERVICE, "Enter"); std::unique_lock lock(mutex_); auto record = std::make_shared(); - DumpCurrentTime(record->startTime); + GetTimeStamp(record->startTime); record->data = data; deviceStatusQueue_.push(record); if (deviceStatusQueue_.size() > MAX_DEVICE_STATUS_SIZE) { diff --git a/services/native/src/devicestatus_service.cpp b/services/native/src/devicestatus_service.cpp index 94274831e..4921bb9a0 100644 --- a/services/native/src/devicestatus_service.cpp +++ b/services/native/src/devicestatus_service.cpp @@ -125,6 +125,11 @@ ITimerManager& DeviceStatusService::GetTimerManager() return timerMgr_; } +IDragManager& DeviceStatusService::GetDragManager() +{ + return dragMgr_; +} + int32_t DeviceStatusService::Dump(int32_t fd, const std::vector& args) { DEV_HILOGI(SERVICE, "dump DeviceStatusServiceInfo"); @@ -132,11 +137,10 @@ int32_t DeviceStatusService::Dump(int32_t fd, const std::vector& DEV_HILOGE(SERVICE, "fd is invalid"); return RET_NG; } - DeviceStatusDumper &deviceStatusDumper = DeviceStatusDumper::GetInstance(); if (args.empty()) { DEV_HILOGE(SERVICE, "param cannot be empty"); dprintf(fd, "param cannot be empty\n"); - deviceStatusDumper.DumpHelpInfo(fd); + deviceStatusDumper_.DumpHelpInfo(fd); return RET_NG; } std::vector argList = { "" }; @@ -153,7 +157,7 @@ int32_t DeviceStatusService::Dump(int32_t fd, const std::vector& datas.emplace_back(data); } } - deviceStatusDumper.ParseCommand(fd, argList, datas); + deviceStatusDumper_.ParseCommand(fd, argList, datas); return RET_OK; } @@ -194,6 +198,10 @@ bool DeviceStatusService::Init() FI_HILOGE("Drag adapter init failed"); goto INIT_FAIL; } + if (deviceStatusDumper_.Init(this) != RET_OK) { + FI_HILOGE("Dump init failed"); + goto INIT_FAIL; + } InitSessionDeathMonitor(); #ifdef OHOS_BUILD_ENABLE_COORDINATION diff --git a/services/native/test/unittest/BUILD.gn b/services/native/test/unittest/BUILD.gn index 5283bfe30..f140812df 100644 --- a/services/native/test/unittest/BUILD.gn +++ b/services/native/test/unittest/BUILD.gn @@ -22,9 +22,10 @@ config("module_private_config") { include_dirs = [ "include", "//utils/system/safwk/native/include", - "//base/msdp/device_status/libs/interface", - "//base/msdp/device_status/services/delegate_task/include", - "../../../communication/service/include", + "${device_status_root_path}/libs/interface", + "${device_status_service_path}/delegate_task/include", + "${device_status_service_path}/context/include", + "${device_status_service_path}/communication/service/include", ] } diff --git a/utils/common/include/util.h b/utils/common/include/util.h index ee14c0430..0bad6dcd6 100644 --- a/utils/common/include/util.h +++ b/utils/common/include/util.h @@ -31,6 +31,7 @@ int64_t GetMillisTime(); uint64_t GetThisThreadId(); void SetThreadName(const std::string &name); +void GetTimeStamp(std::string &startTime); template bool AddInt(T op1, T op2, T minVal, T maxVal, T &res) diff --git a/utils/common/include/utility.h b/utils/common/include/utility.h index e585d9467..804d5bd7e 100644 --- a/utils/common/include/utility.h +++ b/utils/common/include/utility.h @@ -51,6 +51,7 @@ public: return ss.str(); } + static void RemoveSpace(std::string &str); static bool IsInteger(const std::string &target); static bool DoesFileExist(const char *path); static size_t GetFileSize(const char *path); diff --git a/utils/common/src/util.cpp b/utils/common/src/util.cpp index d850311c5..d21e4ea2c 100644 --- a/utils/common/src/util.cpp +++ b/utils/common/src/util.cpp @@ -35,6 +35,9 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "Util" constexpr size_t BUF_TID_SIZE = 10; constexpr size_t PROGRAM_NAME_SIZE = 256; constexpr size_t BUF_CMD_SIZE = 512; +constexpr uint32_t BASE_YEAR = 1900; +constexpr uint32_t BASE_MON = 1; +constexpr uint32_t MS_NS = 1000000; constexpr int32_t FILE_SIZE_MAX = 0x5000; const std::string SVG_PATH = "/system/etc/device_status/drag_icon/"; } // namespace @@ -76,6 +79,22 @@ int64_t GetMillisTime() return tmp.count(); } +void GetTimeStamp(std::string &startTime) +{ + timespec curTime; + clock_gettime(CLOCK_REALTIME, &curTime); + struct tm *timeinfo = localtime(&(curTime.tv_sec)); + if (timeinfo == nullptr) { + DEV_HILOGE(SERVICE, "get localtime failed"); + return; + } + startTime.append(std::to_string(timeinfo->tm_year + BASE_YEAR)).append("-") + .append(std::to_string(timeinfo->tm_mon + BASE_MON)).append("-").append(std::to_string(timeinfo->tm_mday)) + .append(" ").append(std::to_string(timeinfo->tm_hour)).append(":").append(std::to_string(timeinfo->tm_min)) + .append(":").append(std::to_string(timeinfo->tm_sec)).append(".") + .append(std::to_string(curTime.tv_nsec / MS_NS)); +} + void SetThreadName(const std::string &name) { prctl(PR_SET_NAME, name.c_str()); diff --git a/utils/common/src/utility.cpp b/utils/common/src/utility.cpp index 66e70118e..e9c05d98f 100644 --- a/utils/common/src/utility.cpp +++ b/utils/common/src/utility.cpp @@ -92,6 +92,11 @@ void Utility::RemoveTrailingChars(std::string &path, const std::string &toRemove } } +void Utility::RemoveSpace(std::string &str) +{ + str.erase(remove_if(str.begin(), str.end(), [](unsigned char c) { return std::isspace(c);}), str.end()); +} + bool Utility::IsInteger(const std::string &target) { std::regex pattern("^\\s*-?(0|([1-9]\\d*))\\s*$"); -- Gitee From 2368fcb123cdc410c165602c094cb8e60426de40 Mon Sep 17 00:00:00 2001 From: mayunteng Date: Thu, 6 Apr 2023 06:18:07 +0000 Subject: [PATCH 2/5] Signed-off-by: mayunteng_1 Signed-off-by: mayunteng Change-Id: I23f3128b967f04bb5ceb0356c6b87cb344dd73d5 --- .../interaction/drag/src/drag_manager.cpp | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index 4fb9d13f0..49a6adb01 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -287,20 +287,31 @@ void DragManager::InterceptorConsumer::OnInputEvent(std::shared_ptr pixelMap = dragData.shadowInfo.pixelMap; - CHKPV(pixelMap); dprintf(fd, "Drag information:\n"); dprintf(fd, - "dragState:%s | dragResult:%s | interceptorId:%d | dragTargetPid:%d | cursorStyle:%s | isWindowVisble:%s\n" - "pixelMapWidth:%d | pixelMapHeight:%d | shadowInfoX:%d | shadowInfoY:%d | sourceType:%d | dragNum:%d\n" - "pointerId:%d | displayX:%d | displayY:%d | displayId:%d | hasCanceledAnimation:%s\n", + "dragState:%s | dragResult:%s | interceptorId:%d | dragTargetPid:%d | " + "cursorStyle:%s | isWindowVisble:%s\n", GetDragState(dragState_).c_str(), GetDragResult(dragResult_).c_str(), interceptorId_, GetDragTargetPid(), - GetDragCursorStyle(style).c_str(), DataAdapter.GetDragWindowVisible() ? "true" : "false", - pixelMap->GetWidth(), pixelMap->GetHeight(), dragData.shadowInfo.x, dragData.shadowInfo.y, - dragData.sourceType, dragData.dragNum, dragData.pointerId, dragData.displayX, dragData.displayY, - dragData.displayId, dragData.hasCanceledAnimation ? "true" : "false"); + GetDragCursorStyle(style).c_str(), DataAdapter.GetDragWindowVisible() ? "true" : "false"); + DragData dragData = DataAdapter.GetDragData(); + std::string udKey; + if (RET_ERR == GetUdKey(udKey)) { + FI_HILOGE("Target udKey is empty"); + udKey = ""; + } + dprintf(fd, "dragData = {\n" + "\tshadowInfoX:%d\n\tshadowInfoY:%d\n\tudKey:%s\n\tsourceType:%d\n\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.sourceType, dragData.dragNum, + dragData.pointerId, dragData.displayX,dragData.displayY, dragData.displayId, + dragData.hasCanceledAnimation ? "true" : "false"); + if (dragState_ != DragMessage::MSG_DRAG_STATE_STOP) { + std::shared_ptr pixelMap = dragData.shadowInfo.pixelMap; + CHKPV(pixelMap); + dprintf(fd, "\tpixelMapWidth:%d\n\tpixelMapHeight:%d\n", pixelMap->GetWidth(), pixelMap->GetHeight()); + } + dprintf(fd, "}\n"); } std::string DragManager::GetDragState(DragMessage value) const -- Gitee From 0ee68a0633c0b150ce6727dc6d6f44f0e44199cc Mon Sep 17 00:00:00 2001 From: mayunteng Date: Thu, 6 Apr 2023 06:43:31 +0000 Subject: [PATCH 3/5] Signed-off-by: mayunteng_1 Signed-off-by: mayunteng Change-Id: Ia4f93f47d88f9d83dd8c61ebd886b38b323f9ee7 --- services/interaction/drag/src/drag_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index 49a6adb01..dbf14e10f 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -304,7 +304,7 @@ void DragManager::Dump(int32_t fd) "\tshadowInfoX:%d\n\tshadowInfoY:%d\n\tudKey:%s\n\tsourceType:%d\n\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.sourceType, dragData.dragNum, - dragData.pointerId, dragData.displayX,dragData.displayY, dragData.displayId, + dragData.pointerId, dragData.displayX, dragData.displayY, dragData.displayId, dragData.hasCanceledAnimation ? "true" : "false"); if (dragState_ != DragMessage::MSG_DRAG_STATE_STOP) { std::shared_ptr pixelMap = dragData.shadowInfo.pixelMap; -- Gitee From 592bc985d28a691fa6360da74c011c6e754afaac Mon Sep 17 00:00:00 2001 From: mayunteng Date: Fri, 7 Apr 2023 06:32:05 +0000 Subject: [PATCH 4/5] Signed-off-by: mayunteng_1 Signed-off-by: mayunteng Change-Id: Ia91ac29f02fc014855da8f4fc060ef314eec0b2a --- services/context/include/i_context.h | 2 +- services/context/include/i_drag_manager.h | 2 +- services/interaction/drag/include/drag_manager.h | 4 ++-- services/interaction/drag/src/drag_manager.cpp | 4 ++-- services/native/include/devicestatus_service.h | 2 +- services/native/src/devicestatus_service.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/context/include/i_context.h b/services/context/include/i_context.h index 322c9c636..38aade892 100644 --- a/services/context/include/i_context.h +++ b/services/context/include/i_context.h @@ -37,7 +37,7 @@ public: virtual IDelegateTasks& GetDelegateTasks() = 0; virtual IDeviceManager& GetDeviceManager() = 0; virtual ITimerManager& GetTimerManager() = 0; - virtual IDragManager& GetDragManager() = 0; + virtual const IDragManager& GetDragManager() const = 0; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/context/include/i_drag_manager.h b/services/context/include/i_drag_manager.h index caccb64b9..754a7a184 100644 --- a/services/context/include/i_drag_manager.h +++ b/services/context/include/i_drag_manager.h @@ -26,7 +26,7 @@ public: IDragManager() = default; virtual ~IDragManager() = default; - virtual void Dump(int32_t fd) = 0; + virtual void Dump(int32_t fd) const = 0; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index 02dcbeadf..d8bab55ba 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -47,7 +47,7 @@ public: int32_t StartDrag(const DragData &dragData, SessionPtr sess); int32_t StopDrag(DragResult result, bool hasCustomAnimation); int32_t GetDragTargetPid() const; - int32_t GetUdKey(std::string &udKey); + int32_t GetUdKey(std::string &udKey) const; void SetDragTargetPid(int32_t dragTargetPid); void SendDragData(int32_t targetPid, const std::string &udKey); int32_t UpdateDragStyle(DragCursorStyle style); @@ -56,7 +56,7 @@ public: void OnDragMove(std::shared_ptr pointerEvent); int32_t OnSetDragWindowVisible(bool visible); int32_t OnGetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height); - void Dump(int32_t fd); + void Dump(int32_t fd) const; class InterceptorConsumer final : public MMI::IInputEventConsumer { public: InterceptorConsumer(IContext *context, diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index dbf14e10f..66b52ea92 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -132,7 +132,7 @@ int32_t DragManager::GetDragTargetPid() const return dragTargetPid_; } -int32_t DragManager::GetUdKey(std::string &udKey) +int32_t DragManager::GetUdKey(std::string &udKey) const { CALL_DEBUG_ENTER; DragData dragData = DataAdapter.GetDragData(); @@ -284,7 +284,7 @@ void DragManager::InterceptorConsumer::OnInputEvent(std::shared_ptr callback) override; diff --git a/services/native/src/devicestatus_service.cpp b/services/native/src/devicestatus_service.cpp index 4921bb9a0..482b51129 100644 --- a/services/native/src/devicestatus_service.cpp +++ b/services/native/src/devicestatus_service.cpp @@ -125,7 +125,7 @@ ITimerManager& DeviceStatusService::GetTimerManager() return timerMgr_; } -IDragManager& DeviceStatusService::GetDragManager() +const IDragManager& DeviceStatusService::GetDragManager() const { return dragMgr_; } -- Gitee From 1e6d1b424194c1d9e7c32371fba1d5019b38903b Mon Sep 17 00:00:00 2001 From: mayunteng Date: Fri, 7 Apr 2023 06:59:59 +0000 Subject: [PATCH 5/5] Signed-off-by: mayunteng_1 Signed-off-by: mayunteng Change-Id: I92e05b4a7243aded75d6fb33b34feaa9c9dae897 --- services/interaction/drag/include/drag_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index d8bab55ba..01d6d3a8f 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -47,7 +47,7 @@ public: int32_t StartDrag(const DragData &dragData, SessionPtr sess); int32_t StopDrag(DragResult result, bool hasCustomAnimation); int32_t GetDragTargetPid() const; - int32_t GetUdKey(std::string &udKey) const; + int32_t GetUdKey(std::string &udKey) const; void SetDragTargetPid(int32_t dragTargetPid); void SendDragData(int32_t targetPid, const std::string &udKey); int32_t UpdateDragStyle(DragCursorStyle style); -- Gitee