mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-23 07:29:52 +00:00
Signed-off-by:mrsongliang<songliangliang5@huawei.com>
Signed-off-by: mrsongliang <songliangliang5@huawei.com> Change-Id: Icf28f60482e60590cad68c4f0788a6cf9faeef14
This commit is contained in:
parent
3807c0bbcb
commit
a94a8cf59b
@ -7,7 +7,7 @@
|
||||
|
||||
## 简介<a name="section_device_status_introduction"></a>
|
||||
|
||||
MSDP设备状态感知框架能够识别出目前设备的状态并传递给订阅者,整个框架是基于MSDP算法库和系统SensorHDI组件组成的,将其接收到的感知时间传递给订阅者。根据感知用途分为以下三大类:
|
||||
MSDP设备状态感知框架能够识别出目前设备的状态并传递给订阅者,整个框架是基于MSDP算法库和系统SensorHDI组件组成的,将其接收到的感知事件传递给订阅者。根据感知用途分为以下三大类:
|
||||
|
||||
- 绝对静止类:利用加速度、陀螺仪等传感器信息识别设备处于绝对静止状态。
|
||||
- 水平/垂直姿态类:利用加速度、陀螺仪等传感器信息识别设备处于绝对静止状态。
|
||||
|
@ -396,7 +396,7 @@ napi_value DeviceStatusNapi::UnsubscribeDeviceStatus(napi_env env, napi_callback
|
||||
UnsubscribeCallback(env, type, event);
|
||||
return nullptr;
|
||||
}
|
||||
FI_HILOGD("type: %{public}d, event: %{public}d", type, event);
|
||||
FI_HILOGD("type:%{public}d, event:%{public}d", type, event);
|
||||
if (IsMatchType(env, args[2], napi_function)) {
|
||||
if (!g_obj->Off(type, args[2])) {
|
||||
FI_HILOGE("Not ready to unsubscribe for type:%{public}d", type);
|
||||
|
@ -58,7 +58,7 @@ constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
|
||||
constexpr bool HAS_CANCELED_ANIMATION { true };
|
||||
constexpr bool HAS_CUSTOM_ANIMATION { true };
|
||||
constexpr int32_t MOVE_STEP { 10 };
|
||||
const std::string UD_KEY = "Unified data key";
|
||||
const std::string UD_KEY { "Unified data key" };
|
||||
int32_t g_deviceMouseId { -1 };
|
||||
int32_t g_deviceTouchId { -1 };
|
||||
} // namespace
|
||||
|
@ -49,7 +49,7 @@ void DeviceStatusCallbackProxy::OnDeviceStatusChanged(const Data& devicestatusDa
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IRemoteDevStaCallback::DEVICESTATUS_CHANGE),
|
||||
data, reply, option);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("SendRequest is failed, error code: %{public}d", ret);
|
||||
FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ int32_t DeviceStatusClient::SubscribeCallback(Type type, ActivityEvent event, Re
|
||||
int32_t DeviceStatusClient::UnsubscribeCallback(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
FI_HILOGI("UNevent: %{public}d", event);
|
||||
FI_HILOGI("UNevent:%{public}d", event);
|
||||
typeMap_.erase(type);
|
||||
FI_HILOGD("typeMap_ %{public}d", typeMap_[type]);
|
||||
CHKPR(callback, RET_ERR);
|
||||
@ -249,7 +249,7 @@ int32_t DeviceStatusClient::AllocSocketPair(int32_t moduleType)
|
||||
const std::string programName(GetProgramName());
|
||||
int32_t ret = fusion_alloc_socket_fd(programName.c_str(), moduleType, &socketFd_, &tokenType_);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Fail to connect to server via socket: %{public}d", ret);
|
||||
FI_HILOGE("Fail to connect to server via socket:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("Connected successfully to server via socket, "
|
||||
|
@ -149,7 +149,7 @@ static void SensorDataCallbackImpl(SensorEvent *event)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPV(event);
|
||||
FI_HILOGI("SensorDataCallbackImpl sensorTypeId: %{public}d", event->sensorTypeId);
|
||||
FI_HILOGI("SensorDataCallbackImpl sensorTypeId:%{public}d", event->sensorTypeId);
|
||||
SENSOR_DATA_CB.PushData(event->sensorTypeId, event->data);
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ std::shared_ptr<IDevice> DeviceManager::RemoveDevice(const std::string &devNode)
|
||||
void DeviceManager::OnDeviceAdded(std::shared_ptr<IDevice> dev)
|
||||
{
|
||||
CHKPV(dev);
|
||||
FI_HILOGI("add device %{public}d: %{public}s", dev->GetId(), dev->GetDevPath().c_str());
|
||||
FI_HILOGI("add device %{public}d:%{public}s", dev->GetId(), dev->GetDevPath().c_str());
|
||||
FI_HILOGI(" sysPath: \"%{public}s\"", dev->GetSysPath().c_str());
|
||||
FI_HILOGI(" bus: %{public}04x", dev->GetBus());
|
||||
FI_HILOGI(" vendor: %{public}04x", dev->GetVendor());
|
||||
|
@ -28,8 +28,8 @@ namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "CoordinationDeviceManager" };
|
||||
constexpr size_t NETWORK_ID_NUMS = 3;
|
||||
constexpr size_t DESCRIPTOR_INDEX = 2;
|
||||
constexpr size_t NETWORK_ID_NUMS { 3 };
|
||||
constexpr size_t DESCRIPTOR_INDEX { 2 };
|
||||
} // namespace
|
||||
|
||||
CoordinationDeviceManager::CoordinationDeviceManager() {}
|
||||
|
@ -302,7 +302,7 @@ void CoordinationSM::StartPointerEventFilter()
|
||||
int32_t POINTER_DEFAULT_PRIORITY = 220;
|
||||
auto filter = std::make_shared<PointerFilter>();
|
||||
uint32_t touchTags = CapabilityToTags(MMI::INPUT_DEV_CAP_POINTER);
|
||||
FI_HILOGE("Touchtags: %{public}d", static_cast<int32_t>(touchTags));
|
||||
FI_HILOGE("Touchtags:%{public}d", static_cast<int32_t>(touchTags));
|
||||
if (filterId_ >= 0) {
|
||||
MMI::InputManager::GetInstance()->RemoveInputEventFilter(filterId_);
|
||||
}
|
||||
@ -534,8 +534,8 @@ bool CoordinationSM::UpdateMouseLocation()
|
||||
}
|
||||
int32_t xPercent = displayX_ * MOUSE_ABS_LOCATION / width;
|
||||
int32_t yPercent = displayY_ * MOUSE_ABS_LOCATION / height;
|
||||
FI_HILOGI("displayWidth: %{public}d, displayHeight: %{public}d, "
|
||||
"physicalX: %{public}d, physicalY: %{public}d,",
|
||||
FI_HILOGI("displayWidth:%{public}d, displayHeight:%{public}d, "
|
||||
"physicalX:%{public}d, physicalY:%{public}d,",
|
||||
width, height, displayX_, displayY_);
|
||||
mouseLocation_ = std::make_pair(xPercent, yPercent);
|
||||
return true;
|
||||
|
@ -288,7 +288,7 @@ int32_t CoordinationSoftbusAdapter::StartRemoteCoordination(const std::string &l
|
||||
break;
|
||||
}
|
||||
}
|
||||
FI_HILOGD("isPointerButtonPressed: %{public}d", isPointerButtonPressed);
|
||||
FI_HILOGD("isPointerButtonPressed:%{public}d", isPointerButtonPressed);
|
||||
cJSON *jsonStr = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_CMD_TYPE, cJSON_CreateNumber(REMOTE_COORDINATION_START));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_LOCAL_DEVICE_ID, cJSON_CreateString(localNetworkId.c_str()));
|
||||
|
@ -86,9 +86,9 @@ const std::string FORBID_ONE_DRAG_PATH { "/system/etc/device_status/drag_icon/Fo
|
||||
const std::string MOUSE_DRAG_PATH { "/system/etc/device_status/drag_icon/Mouse_Drag.svg" };
|
||||
const std::string MOVE_DRAG_PATH { "/system/etc/device_status/drag_icon/Move_Drag.svg" };
|
||||
#ifdef __aarch64__
|
||||
const std::string DRAG_ANIMATION_EXTENSION_SO_PATH = "/system/lib64/drag_drop_ext/libdrag_drop_ext.z.so";
|
||||
const std::string DRAG_ANIMATION_EXTENSION_SO_PATH { "/system/lib64/drag_drop_ext/libdrag_drop_ext.z.so" };
|
||||
#else
|
||||
const std::string DRAG_ANIMATION_EXTENSION_SO_PATH = "/system/lib/drag_drop_ext/libdrag_drop_ext.z.so";
|
||||
const std::string DRAG_ANIMATION_EXTENSION_SO_PATH { "/system/lib/drag_drop_ext/libdrag_drop.z.so" };
|
||||
#endif
|
||||
struct DrawingInfo {
|
||||
std::atomic_bool isRunning { false };
|
||||
|
@ -258,7 +258,7 @@ void DragManager::OnDragUp(std::shared_ptr<MMI::PointerEvent> pointerEvent)
|
||||
MMI::InputManager::GetInstance()->SetPointerVisible(true);
|
||||
}
|
||||
int32_t targetTid = DRAG_DATA_MGR.GetTargetTid();
|
||||
FI_HILOGD("Target window drag tid: %{public}d", targetTid);
|
||||
FI_HILOGD("Target window drag tid:%{public}d", targetTid);
|
||||
SendDragData(targetTid, dragData.udKey);
|
||||
CHKPV(context_);
|
||||
timerId_ = context_->GetTimerManager().AddTimer(TIMEOUT_MS, 1, [this]() {
|
||||
|
@ -33,8 +33,8 @@ namespace DeviceStatus {
|
||||
using json = nlohmann::json;
|
||||
class VirtualDeviceBuilder {
|
||||
public:
|
||||
explicit VirtualDeviceBuilder(const std::string &name, uint16_t bustype, uint16_t vendor, uint16_t product);
|
||||
explicit VirtualDeviceBuilder(const std::string &name, std::shared_ptr<VirtualDevice> vDev);
|
||||
VirtualDeviceBuilder(const std::string &name, uint16_t bustype, uint16_t vendor, uint16_t product);
|
||||
VirtualDeviceBuilder(const std::string &name, std::shared_ptr<VirtualDevice> vDev);
|
||||
virtual ~VirtualDeviceBuilder();
|
||||
DISALLOW_COPY_AND_MOVE(VirtualDeviceBuilder);
|
||||
bool SetUp();
|
||||
|
@ -60,7 +60,7 @@ int32_t VInputDevice::Open()
|
||||
CALL_DEBUG_ENTER;
|
||||
char buf[PATH_MAX] {};
|
||||
if (realpath(devPath_.c_str(), buf) == nullptr) {
|
||||
FI_HILOGE("Not real path: %{public}s", devPath_.c_str());
|
||||
FI_HILOGE("Not real path:%{public}s", devPath_.c_str());
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ int32_t VInputDevice::Open()
|
||||
Utility::ShowFileAttributes(buf);
|
||||
fd_ = open(buf, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (fd_ < 0) {
|
||||
FI_HILOGE("Unable to open device \'%{public}s\': %{public}s", buf, strerror(errno));
|
||||
FI_HILOGE("Unable to open device \'%{public}s\':%{public}s", buf, strerror(errno));
|
||||
if (nRetries-- > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
FI_HILOGI("Retry opening device \'%{public}s\'", buf);
|
||||
@ -93,7 +93,7 @@ void VInputDevice::Close()
|
||||
CALL_DEBUG_ENTER;
|
||||
if (fd_ >= 0) {
|
||||
if (close(fd_) != 0) {
|
||||
FI_HILOGE("close error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("close error:%{public}s", strerror(errno));
|
||||
}
|
||||
fd_ = -1;
|
||||
}
|
||||
@ -131,7 +131,7 @@ int32_t VInputDevice::SendEvent(uint16_t type, uint16_t code, int32_t value)
|
||||
event.input_event_usec = tv.tv_usec;
|
||||
ssize_t ret = ::write(fd_, &event, sizeof(struct input_event));
|
||||
if (ret < 0) {
|
||||
FI_HILOGE("Failed to send event: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Failed to send event:%{public}s", strerror(errno));
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -144,14 +144,14 @@ void VInputDevice::QueryDeviceInfo()
|
||||
|
||||
int32_t rc = ioctl(fd_, EVIOCGNAME(sizeof(buffer) - 1), &buffer);
|
||||
if (rc < 0) {
|
||||
FI_HILOGE("Could not get device name: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Could not get device name:%{public}s", strerror(errno));
|
||||
} else {
|
||||
name_.assign(buffer);
|
||||
}
|
||||
|
||||
rc = ioctl(fd_, EVIOCGID, &inputId_);
|
||||
if (rc < 0) {
|
||||
FI_HILOGE("Could not get device input id: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Could not get device input id:%{public}s", strerror(errno));
|
||||
}
|
||||
errno_t ret = memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
|
||||
if (ret != EOK) {
|
||||
@ -160,7 +160,7 @@ void VInputDevice::QueryDeviceInfo()
|
||||
}
|
||||
rc = ioctl(fd_, EVIOCGPHYS(sizeof(buffer) - 1), &buffer);
|
||||
if (rc < 0) {
|
||||
FI_HILOGE("Could not get location: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Could not get location:%{public}s", strerror(errno));
|
||||
} else {
|
||||
phys_.assign(buffer);
|
||||
}
|
||||
@ -171,7 +171,7 @@ void VInputDevice::QueryDeviceInfo()
|
||||
}
|
||||
rc = ioctl(fd_, EVIOCGUNIQ(sizeof(buffer) - 1), &buffer);
|
||||
if (rc < 0) {
|
||||
FI_HILOGE("Could not get uniq: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Could not get uniq:%{public}s", strerror(errno));
|
||||
} else {
|
||||
uniq_.assign(buffer);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void VirtualDeviceBuilder::Unmount(const char *name, const char *id)
|
||||
std::cout << "Mo backing process for virtual " << name << " was found." << std::endl;
|
||||
EXIT:
|
||||
if (closedir(procDir) != 0) {
|
||||
FI_HILOGE("closedir error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("closedir error:%{public}s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ void VirtualDeviceBuilder::SetSupportedEvents()
|
||||
const auto &events = setEvents.second();
|
||||
for (const auto &e : events) {
|
||||
if (ioctl(fd_, setEvents.first, e) < 0) {
|
||||
FI_HILOGE("Failed while setting event type: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Failed while setting event type:%{public}s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ void VirtualDeviceBuilder::SetAbsResolution()
|
||||
{
|
||||
for (const auto &item : absInit_) {
|
||||
if (ioctl(fd_, UI_ABS_SETUP, &item) < 0) {
|
||||
FI_HILOGE("Failed while setting abs info: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Failed while setting abs info:%{public}s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,14 +238,14 @@ void VirtualDeviceBuilder::SetPhys()
|
||||
}
|
||||
|
||||
if (ioctl(fd_, UI_SET_PHYS, phys.c_str()) < 0) {
|
||||
FI_HILOGE("Failed while setting phys: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Failed while setting phys:%{public}s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
void VirtualDeviceBuilder::SetIdentity()
|
||||
{
|
||||
if (write(fd_, &uinputDev_, sizeof(uinputDev_)) < 0) {
|
||||
FI_HILOGE("Unable to set uinput device info: %{public}s", strerror(errno));
|
||||
FI_HILOGE("Unable to set uinput device info:%{public}s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ bool VirtualDeviceBuilder::SetUp()
|
||||
if (ioctl(fd_, UI_DEV_CREATE) < 0) {
|
||||
FI_HILOGE("Failed to setup uinput device");
|
||||
if (close(fd_) != 0) {
|
||||
FI_HILOGE("close error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("close error:%{public}s", strerror(errno));
|
||||
}
|
||||
fd_ = -1;
|
||||
return false;
|
||||
@ -278,10 +278,10 @@ void VirtualDeviceBuilder::Close()
|
||||
{
|
||||
if (fd_ >= 0) {
|
||||
if (ioctl(fd_, UI_DEV_DESTROY) < 0) {
|
||||
FI_HILOGE("ioctl error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("ioctl error:%{public}s", strerror(errno));
|
||||
}
|
||||
if (close(fd_) != 0) {
|
||||
FI_HILOGE("close error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("close error:%{public}s", strerror(errno));
|
||||
}
|
||||
fd_ = -1;
|
||||
}
|
||||
@ -403,7 +403,7 @@ int32_t VirtualDeviceBuilder::ScanFor(std::function<bool(std::shared_ptr<Virtual
|
||||
CALL_DEBUG_ENTER;
|
||||
DIR *dir = opendir(DEV_INPUT_PATH.c_str());
|
||||
if (dir == nullptr) {
|
||||
FI_HILOGE("Failed to open directory \'%{public}s\': %{public}s", DEV_INPUT_PATH.c_str(), strerror(errno));
|
||||
FI_HILOGE("Failed to open directory \'%{public}s\':%{public}s", DEV_INPUT_PATH.c_str(), strerror(errno));
|
||||
return RET_ERR;
|
||||
}
|
||||
struct dirent *dent;
|
||||
@ -428,7 +428,7 @@ int32_t VirtualDeviceBuilder::ScanFor(std::function<bool(std::shared_ptr<Virtual
|
||||
}
|
||||
}
|
||||
if (closedir(dir) != 0) {
|
||||
FI_HILOGE("closedir error: %{public}s", strerror(errno));
|
||||
FI_HILOGE("closedir error:%{public}s", strerror(errno));
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int32_t VirtualKeyboard::Down(int32_t key)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (!SupportKey(key)) {
|
||||
FI_HILOGE("Unsupported key code: %{public}d", key);
|
||||
FI_HILOGE("Unsupported key code:%{public}d", key);
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ int32_t VirtualKeyboard::Up(int32_t key)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (!SupportKey(key)) {
|
||||
FI_HILOGE("Unsupported key code: %{public}d", key);
|
||||
FI_HILOGE("Unsupported key code:%{public}d", key);
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ int32_t VirtualMouse::DownButton(int32_t button)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (button < BTN_MOUSE || button > BTN_TASK) {
|
||||
FI_HILOGE("Not mouse button: %{public}d", button);
|
||||
FI_HILOGE("Not mouse button:%{public}d", button);
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ int32_t VirtualMouse::UpButton(int32_t button)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (button < BTN_MOUSE || button > BTN_TASK) {
|
||||
FI_HILOGE("Not mouse button: %{public}d", button);
|
||||
FI_HILOGE("Not mouse button:%{public}d", button);
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user