!1021 intention build

Merge pull request !1021 from lifenghui/intention_build
This commit is contained in:
openharmony_ci 2023-10-20 03:40:27 +00:00 committed by Gitee
commit eef7772aa5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
42 changed files with 1062 additions and 327 deletions

View File

@ -28,6 +28,21 @@ group("devicestatus_service_group") {
}
}
group("intention_group") {
deps = [
"${device_status_root_path}/intention/data:cooperate_params",
"${device_status_root_path}/intention/data:drag_params",
"${device_status_root_path}/intention/frameworks/client:intention_client",
"${device_status_root_path}/intention/ipc:intention_ipc",
"${device_status_root_path}/intention/plugins/cooperate:intention_cooperate",
"${device_status_root_path}/intention/plugins/drag:intention_drag",
"${device_status_root_path}/intention/scheduler/plugin_manager:plugin_manager",
"${device_status_root_path}/intention/scheduler/task_scheduler:task_scheduler",
"${device_status_root_path}/intention/scheduler/timer_manager:timer_manager",
"${device_status_root_path}/intention/services:intention_service",
]
}
group("device_status_tests") {
testonly = true
deps = [

View File

@ -35,6 +35,7 @@ device_status_frameworks_path = "${device_status_root_path}/frameworks"
device_status_service_path = "${device_status_root_path}/services"
device_status_utils_path = "${device_status_root_path}/utils/common"
device_status_fuzz_output_path = "${device_status_part_name}/device_status"
intention_root_path = "//base/msdp/device_status/intention"
device_status_default_defines = []

View File

@ -14,27 +14,64 @@
import("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("params_public_config") {
include_dirs = [ "include" ]
}
config("cooperate_params_config") {
include_dirs = [
"include",
"cooperate/include",
"${device_status_root_path}/utils/ipc/include",
]
}
config("cooperate_params_public_config") {
include_dirs = [ "include" ]
}
ohos_source_set("cooperate_params") {
sources = [ "src/cooperate_params.cpp" ]
sources = [ "cooperate/src/cooperate_params.cpp" ]
configs = [ ":cooperate_params_config" ]
public_configs = [ ":cooperate_params_public_config" ]
public_configs = [ ":params_public_config" ]
deps = [ "${device_status_utils_path}:devicestatus_util" ]
external_deps = [
"c_utils:utils",
"hiviewdfx_hilog_native:libhilog",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_core",
]
subsystem_name = "msdp"
part_name = "${device_status_part_name}"
}
config("drag_params_config") {
include_dirs = [
"include",
"drag/include",
"${device_status_root_path}/utils/ipc/include",
]
}
ohos_source_set("drag_params") {
sources = [
"drag/src/drag_data_manager.cpp",
"drag/src/drag_params.cpp",
]
configs = [ ":drag_params_config" ]
public_configs = [ ":params_public_config" ]
deps = [ "${device_status_utils_path}:devicestatus_util" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image_native",
"input:libmmi-client",
"ipc:ipc_core",
]

View File

@ -22,7 +22,7 @@ namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
enum CooperateParam : uint32_t {
PREPARE
PREPARE,
STATE,
REGISTER
};
@ -42,6 +42,7 @@ struct DefaultCooperateReply final : public ParamBase {
};
struct StartCooperateParam final : public ParamBase {
StartCooperateParam() = default;
StartCooperateParam(int32_t userData, const std::string &remoteNetworkId, int32_t startDeviceId);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data) override;
@ -52,6 +53,7 @@ struct StartCooperateParam final : public ParamBase {
};
struct StopCooperateParam final : public ParamBase {
StopCooperateParam() = default;
StopCooperateParam(int32_t userData, bool isUnchained);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data) override;
@ -61,6 +63,7 @@ struct StopCooperateParam final : public ParamBase {
};
struct GetCooperateStateParam final : public ParamBase {
GetCooperateStateParam() = default;
GetCooperateStateParam(std::string deviceId, int32_t userData);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data) override;

View File

@ -25,12 +25,12 @@ DefaultCooperateParam::DefaultCooperateParam(int32_t userData)
bool DefaultCooperateParam::Marshalling(Parcel &data) const
{
return WRITEINT32(data, userData);
return data.WriteInt32(userData);
}
bool DefaultCooperateParam::Unmarshalling(Parcel &data)
{
return READINT32(data, userData);
return data.ReadInt32(userData);
}
bool DefaultCooperateReply::Marshalling(Parcel &data) const
@ -44,26 +44,26 @@ bool DefaultCooperateReply::Unmarshalling(Parcel &data)
}
StartCooperateParam::StartCooperateParam(int32_t userData, const std::string &remoteNetworkId, int32_t startDeviceId)
: userData(userData),
remoteNetworkId(remoteNetworkId),
startDeviceId(startDeviceId)
: remoteNetworkId(remoteNetworkId),
startDeviceId(startDeviceId),
userData(userData)
{}
bool StartCooperateParam::Marshalling(Parcel &data) const
{
return (
WRITEINT32(data, userData) &&
WRITESTRING(data, remoteNetworkId) &&
WRITEINT32(data, startDeviceId)
data.WriteInt32(userData) &&
data.WriteString(remoteNetworkId) &&
data.WriteInt32(startDeviceId)
);
}
bool StartCooperateParam::Unmarshalling(Parcel &data)
{
return (
READINT32(data, userData) &&
READSTRING(data, remoteNetworkId) &&
READINT32(data, startDeviceId)
data.ReadInt32(userData) &&
data.ReadString(remoteNetworkId) &&
data.ReadInt32(startDeviceId)
);
}
@ -74,18 +74,18 @@ GetCooperateStateParam::GetCooperateStateParam(std::string deviceId, int32_t use
bool GetCooperateStateParam::Marshalling(Parcel &data) const
{
return {
WRITEINT32(data, userData) &&
WRITESTRING(data, deviceId)
};
return (
data.WriteInt32(userData) &&
data.WriteString(deviceId)
);
}
bool GetCooperateStateParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, userData) &&
READSTRING(data, deviceId)
}
return (
data.ReadInt32(userData) &&
data.ReadString(deviceId)
);
}
StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained)
@ -94,18 +94,18 @@ StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained)
bool StopCooperateParam::Marshalling(Parcel &data) const
{
return {
WRITEINT32(data, userData) &&
WRITEBOOL(data, isUnchained)
};
return (
data.WriteInt32(userData) &&
data.WriteBool(isUnchained)
);
}
bool StopCooperateParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, userData) &&
READBOOL(data, isUnchained)
};
return (
data.ReadInt32(userData) &&
data.ReadBool(isUnchained)
);
}
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -0,0 +1,86 @@
/*
* 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_H
#define DRAG_DATA_H
#include "pixel_map.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
constexpr size_t MAX_BUFFER_SIZE { 512 };
struct ShadowInfo {
std::shared_ptr<OHOS::Media::PixelMap> pixelMap { nullptr };
int32_t x { -1 };
int32_t y { -1 };
};
struct DragData {
ShadowInfo shadowInfo;
std::vector<uint8_t> buffer;
std::string udKey;
std::string filterInfo;
std::string extraInfo;
int32_t sourceType { -1 };
int32_t dragNum { -1 };
int32_t pointerId { -1 };
int32_t displayX { -1 };
int32_t displayY { -1 };
int32_t displayId { -1 };
bool hasCanceledAnimation { false };
};
enum class DragState {
ERROR = 0,
START = 1,
STOP = 2,
CANCEL = 3,
MOTION_DRAGGING = 4
};
enum class DragResult {
DRAG_SUCCESS = 0,
DRAG_FAIL = 1,
DRAG_CANCEL = 2,
DRAG_EXCEPTION = 3
};
struct DragNotifyMsg {
int32_t displayX { -1 };
int32_t displayY { -1 };
int32_t targetPid { -1 };
DragResult result { DragResult::DRAG_FAIL };
};
struct DragAnimationData {
int32_t displayX { -1 };
int32_t displayY { -1 };
int32_t offsetX { -1 };
int32_t offsetY { -1 };
std::shared_ptr<OHOS::Media::PixelMap> pixelMap { nullptr };
};
enum class DragCursorStyle {
DEFAULT = 0,
FORBIDDEN,
COPY,
MOVE
};
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // DRAG_DATA_H

View File

@ -0,0 +1,55 @@
/*
* 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_MANAGER_H
#define DRAG_DATA_MANAGER_H
#include <string>
#include "pixel_map.h"
#include "singleton.h"
#include "drag_data.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
class DragDataManager final {
DECLARE_SINGLETON(DragDataManager);
public:
DISALLOW_MOVE(DragDataManager);
void Init(const DragData &dragData);
void ResetDragData();
DragData GetDragData() const;
bool IsMotionDrag() const;
private:
DragData dragData_;
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
std::u16string dragMessage_;
bool visible_ { false };
int32_t targetTid_ { -1 };
int32_t targetPid_ { -1 };
bool isMotionDrag_ { false };
};
#define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance()
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // DRAG_DATA_MANAGER_H

View File

@ -17,6 +17,7 @@
#define DRAG_PARAMS_H
#include <memory>
#include "drag_data.h"
#include "i_plugin.h"
namespace OHOS {
@ -39,17 +40,19 @@ struct DefaultDragReply final : public ParamBase {
};
struct StartDragParam final : public ParamBase {
StartDragParam() = default;
StartDragParam(const DragData &dragData);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
DragData dragData;
};
struct StopDragParam final : public ParamBase {
StopDragParam() = default;
StopDragParam(int32_t result, bool hasCustomAnimation);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
int32_t result;
bool hasCustomAnimation { false };
@ -58,39 +61,41 @@ struct StopDragParam final : public ParamBase {
struct DragStyleParam final : public ParamBase {
DragStyleParam(int32_t style);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
int32_t mouseStyle {};
};
struct DragTargetPidParam : public ParamBase {
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
int32_t pid;
};
struct GetUdKeyParam final : public ParamBase {
GetUdKeyParam(std::string &udKey);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
std::string udKey;
};
struct AddDragListenerParam : public ParamBase {
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
};
struct RemoveDragListenerParam : public ParamBase {
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
};
struct SetDragWindowVisibleParam final : public ParamBase {
SetDragWindowVisibleParam() = default;
SetDragWindowVisibleParam(bool visible);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
bool visible;
};
@ -98,7 +103,7 @@ struct SetDragWindowVisibleParam final : public ParamBase {
struct GetShadowOffsetParam final : public ParamBase {
GetShadowOffsetParam(int32_t offsetX, int32_t offsetY, int32_t width, int32_t height);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
int32_t offsetX { -1 };
int32_t offsetY { -1 };
@ -107,9 +112,10 @@ struct GetShadowOffsetParam final : public ParamBase {
};
struct UpdateShadowPicParam final : public ParamBase {
UpdateShadowPicParam() = default;
UpdateShadowPicParam(ShadowInfo shadowInfo);
bool Marshalling(Parcel &data) const override;
bool Unmarshalling(Parcel &data);
bool Unmarshalling(Parcel &data) override;
ShadowInfo shadowInfo;
};

View File

@ -0,0 +1,67 @@
/*
* 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_manager.h"
#include "hitrace_meter.h"
#include "pointer_style.h"
#include "devicestatus_define.h"
#include "drag_data.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragDataManager" };
constexpr int32_t DEFAULT_DISPLAY_ID { 0 };
} // namespace
DragDataManager::DragDataManager() = default;
DragDataManager::~DragDataManager() = default;
void DragDataManager::Init(const DragData &dragData)
{
CALL_DEBUG_ENTER;
dragData_ = dragData;
if (dragData.displayId < DEFAULT_DISPLAY_ID) {
dragData_.displayId = DEFAULT_DISPLAY_ID;
FI_HILOGW("The value of displayId(%{public}d) is correcting to 0", dragData.displayId);
}
targetTid_ = -1;
targetPid_ = -1;
}
DragData DragDataManager::GetDragData() const
{
return dragData_;
}
void DragDataManager::ResetDragData()
{
CALL_DEBUG_ENTER;
ShadowInfo shadowInfo;
std::vector<uint8_t> buffer;
dragData_ = { shadowInfo, buffer, "", "", "", -1, -1, -1, -1, -1, -1, false };
}
bool DragDataManager::IsMotionDrag() const
{
FI_HILOGD("isMotionDrag_:%{public}d", isMotionDrag_);
return isMotionDrag_;
}
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -18,45 +18,49 @@
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragParams" };
} // namespace
StartDragParam::StartDragParam(const DragData &dragData) : dragData(dragData)
{}
bool StartDragParam::Marshalling(Parcel &data) const
{
return {
WRITEINT32(data, dragData.shadowInfo.x) &&
WRITEINT32(data, dragData.shadowInfo.y) &&
WRITEUINT8VECTOR(data, dragData.buffer) &&
WRITESTRING(data, dragData.udKey) &&
WRITESTRING(data, dragData.filterInfo) &&
WRITESTRING(data, dragData.extraInfo) &&
WRITEINT32(data, dragData.sourceType) &&
WRITEINT32(data, dragData.dragNum) &&
WRITEINT32(data, dragData.pointerId) &&
WRITEINT32(data, dragData.displayX) &&
WRITEINT32(data, dragData.displayY) &&
WRITEINT32(data, dragData.displayId) &&
WRITEBOOL(data, dragData.hasCanceledAnimation)
};
return (
data.WriteInt32(dragData.shadowInfo.x) &&
data.WriteInt32(dragData.shadowInfo.y) &&
data.WriteUInt8Vector(dragData.buffer) &&
data.WriteString(dragData.udKey) &&
data.WriteString(dragData.filterInfo) &&
data.WriteString(dragData.extraInfo) &&
data.WriteInt32(dragData.sourceType) &&
data.WriteInt32(dragData.dragNum) &&
data.WriteInt32(dragData.pointerId) &&
data.WriteInt32(dragData.displayX) &&
data.WriteInt32(dragData.displayY) &&
data.WriteInt32(dragData.displayId) &&
data.WriteBool(dragData.hasCanceledAnimation)
);
}
bool StartDragParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, dragData.shadowInfo.x) &&
READINT32(data, dragData.shadowInfo.y) &&
READUINT8VECTOR(data, dragData.buffer) &&
READSTRING(data, dragData.udKey) &&
READSTRING(data, dragData.filterInfo) &&
READSTRING(data, dragData.extraInfo) &&
READINT32(data, dragData.sourceType) &&
READINT32(data, dragData.dragNum) &&
READINT32(data, dragData.pointerId) &&
READINT32(data, dragData.displayX) &&
READINT32(data, dragData.displayY) &&
READINT32(data, dragData.displayId) &&
READBOOL(data, dragData.hasCanceledAnimation)
};
return (
data.ReadInt32(dragData.shadowInfo.x) &&
data.ReadInt32(dragData.shadowInfo.y) &&
data.ReadUInt8Vector(&dragData.buffer) &&
data.ReadString(dragData.udKey) &&
data.ReadString(dragData.filterInfo) &&
data.ReadString(dragData.extraInfo) &&
data.ReadInt32(dragData.sourceType) &&
data.ReadInt32(dragData.dragNum) &&
data.ReadInt32(dragData.pointerId) &&
data.ReadInt32(dragData.displayX) &&
data.ReadInt32(dragData.displayY) &&
data.ReadInt32(dragData.displayId) &&
data.ReadBool(dragData.hasCanceledAnimation)
);
}
StopDragParam::StopDragParam(int32_t result, bool hasCustomAnimation)
@ -65,22 +69,23 @@ StopDragParam::StopDragParam(int32_t result, bool hasCustomAnimation)
bool StopDragParam::Marshalling(Parcel &data) const
{
if (result < DragResult::DRAG_SUCCESS || result > DragResult::DRAG_EXCEPTION) {
if (static_cast<DragResult>(result) < DragResult::DRAG_SUCCESS ||
static_cast<DragResult>(result) > DragResult::DRAG_EXCEPTION) {
FI_HILOGE("Invalid result:%{public}d", static_cast<int32_t>(result));
return false;
}
return {
WRITEINT32(data, static_cast<int32_t>(result));
WRITEBOOL(data, hasCustomAnimation);
};
return (
data.WriteInt32(static_cast<int32_t>(result)) &&
data.WriteBool(hasCustomAnimation)
);
}
bool StopDragParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, result) &&
READBOOL(data, hasCustomAnimation)
};
return (
data.ReadInt32(result) &&
data.ReadBool(hasCustomAnimation)
);
}
DragStyleParam::DragStyleParam(int32_t style) : mouseStyle(style)
@ -89,12 +94,12 @@ DragStyleParam::DragStyleParam(int32_t style) : mouseStyle(style)
bool DragStyleParam::Marshalling(Parcel &data) const
{
return WRITEINT32(data, static_cast<int32_t>(mouseStyle));
return data.WriteInt32(static_cast<int32_t>(mouseStyle));
}
bool DragStyleParam::Unmarshalling(Parcel &data)
{
return READINT32(data, mouseStyle);
return data.ReadInt32(mouseStyle);
}
bool DragTargetPidParam::Marshalling(Parcel &data) const
@ -104,7 +109,11 @@ bool DragTargetPidParam::Marshalling(Parcel &data) const
bool DragTargetPidParam::Unmarshalling(Parcel &data)
{
return READINT32(data, pid);
return data.ReadInt32(pid);
}
GetUdKeyParam::GetUdKeyParam(std::string &udKey) : udKey(udKey)
{
}
bool GetUdKeyParam::Marshalling(Parcel &data) const
@ -114,7 +123,7 @@ bool GetUdKeyParam::Marshalling(Parcel &data) const
bool GetUdKeyParam::Unmarshalling(Parcel &data)
{
return READSTRING(data, udKey);
return data.ReadString(udKey);
}
bool AddDragListenerParam::Marshalling(Parcel &data) const
@ -142,12 +151,12 @@ SetDragWindowVisibleParam::SetDragWindowVisibleParam(bool visible) : visible(vis
bool SetDragWindowVisibleParam::Marshalling(Parcel &data) const
{
return WRITEBOOL(data, visible);
return data.WriteBool(visible);
}
bool SetDragWindowVisibleParam::Unmarshalling(Parcel &data)
{
return READBOOL(data, visible);
return data.ReadBool(visible);
}
GetShadowOffsetParam::GetShadowOffsetParam(int32_t offsetX, int32_t offsetY, int32_t width, int32_t height)
@ -164,12 +173,12 @@ bool GetShadowOffsetParam::Marshalling(Parcel &data) const
bool GetShadowOffsetParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, offsetX) &&
READINT32(data, offsetY) &&
READINT32(data, width) &&
READINT32(data, height)
};
return (
data.ReadInt32(offsetX) &&
data.ReadInt32(offsetY) &&
data.ReadInt32(width) &&
data.ReadInt32(height)
);
}
UpdateShadowPicParam::UpdateShadowPicParam(ShadowInfo shadowInfo) : shadowInfo(shadowInfo)
@ -181,18 +190,18 @@ bool UpdateShadowPicParam::Marshalling(Parcel &data) const
FI_HILOGE("Failed to marshalling pixelMap");
return false;
}
return {
WRITEINT32(data, shadowInfo.x);
WRITEINT32(data, shadowInfo.y);
};
return (
data.WriteInt32(shadowInfo.x) &&
data.WriteInt32(shadowInfo.y)
);
}
bool UpdateShadowPicParam::Unmarshalling(Parcel &data)
{
return {
READINT32(data, shadowInfo.x) &&
READINT32(data, shadowInfo.y)
};
return (
data.ReadInt32(shadowInfo.x) &&
data.ReadInt32(shadowInfo.y)
);
}
bool DefaultDragReply::Marshalling(Parcel &data) const

View File

@ -18,12 +18,12 @@
#include "parcel.h"
#include "i_context.h"
#include "stream_session.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
class IContext;
enum CommonAction : uint32_t {
ENABLE,
DISABLE,
@ -88,6 +88,8 @@ struct CallingContext {
class IPlugin {
public:
virtual ~IPlugin() = default;
virtual int32_t Enable(CallingContext &context, Parcel &data, Parcel &reply) = 0;
virtual int32_t Disable(CallingContext &context, Parcel &data, Parcel &reply) = 0;
virtual int32_t Start(CallingContext &context, Parcel &data, Parcel &reply) = 0;
@ -99,8 +101,8 @@ public:
virtual int32_t Control(CallingContext &context, uint32_t id, Parcel &data, Parcel &reply) = 0;
};
using CreateInstance = IPlugin* (*)(IContext *context);
using DestroyInstance = void (*)(IPlugin *);
using IntentionCreateInstance = IPlugin* (*)(IContext *context);
using IntentionDestroyInstance = void (*)(IPlugin *);
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -0,0 +1,57 @@
# 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("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("intention_public_config") {
include_dirs = [
"include",
"${intention_root_path}/data/drag/include",
"${intention_root_path}/data/include",
"${intention_root_path}/interfaces/include",
"${device_status_root_path}/utils/ipc/include",
"${intention_root_path}/data/cooperate/include",
"${intention_root_path}/data/cooperate",
"${intention_root_path}/ipc/include",
]
}
ohos_shared_library("intention_client") {
sources = [
"${intention_root_path}/frameworks/client/src/cooperate_manager_impl.cpp",
"${intention_root_path}/frameworks/client/src/drag_manager_impl.cpp",
"${intention_root_path}/frameworks/client/src/intention_client.cpp",
]
deps = [
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
"${intention_root_path}/data:cooperate_params",
"${intention_root_path}/data:drag_params",
"${intention_root_path}/ipc:intention_ipc",
]
public_configs = [ ":intention_public_config" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
"samgr:samgr_proxy",
]
subsystem_name = "${device_status_subsystem_name}"
part_name = "${device_status_part_name}"
}

View File

@ -22,8 +22,8 @@
#include <mutex>
#include <optional>
#include "client.h"
#include "cooperate_message.h"
#include "cooperate_params.h"
#include "i_cooperate_listener.h"
namespace OHOS {
@ -59,7 +59,6 @@ private:
mutable std::mutex mtx_;
int32_t userData_ { 0 };
std::atomic_bool isListeningProcess_ { false };
IClientPtr client_ { nullptr };
};
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -21,11 +21,11 @@
#include <mutex>
#include <string>
#include "client.h"
#include "devicestatus_define.h"
#include "drag_data.h"
#include "drag_params.h"
#include "i_drag_listener.h"
#include "intention_client.h"
#include "intention_define.h"
#include "include/util.h"
namespace OHOS {
@ -41,8 +41,6 @@ public:
int32_t GetUdKey(std::string &udKey);
int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
int32_t StopDrag(DragResult result, bool hasCustomAnimation);
int32_t OnNotifyResult(const StreamClient& client, NetPacket& pkt);
int32_t OnStateChangedMessage(const StreamClient& client, NetPacket& pkt);
int32_t AddDraglistener(DragListenerPtr listener);
int32_t RemoveDraglistener(DragListenerPtr listener);
int32_t SetDragWindowVisible(bool visible);

View File

@ -20,6 +20,10 @@
#include <singleton.h>
#include "i_intention.h"
#include "i_plugin.h"
#include "intention_proxy.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
@ -56,12 +60,23 @@ public:
int32_t Control(uint32_t intention, uint32_t id, ParamBase &data, ParamBase &reply);
private:
class IntentionDeathRecipient : public IRemoteObject::DeathRecipient {
public:
IntentionDeathRecipient() = default;
~IntentionDeathRecipient() = default;
void OnRemoteDied(const wptr<IRemoteObject>& remote);
private:
DISALLOW_COPY_AND_MOVE(IntentionDeathRecipient);
};
ErrCode Connect();
void ResetProxy(const wptr<IRemoteObject>& remote);
private:
std::mutex mutex_;
sptr<IIntention> devicestatusProxy_ { nullptr };
sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr };
std::function<void()> deathListener_ { nullptr };
};
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -15,8 +15,8 @@
#include "cooperate_manager_impl.h"
#include "devicestatus_define.h"
#include "intention_client.h"
#include "intention_define.h"
#include "include/util.h"
namespace OHOS {
@ -41,7 +41,7 @@ int32_t CooperateManagerImpl::RegisterCooperateListener(CooperateListenerPtr lis
DefaultCooperateParam param;
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().AddWatch(Intention::COOPERATE,
int32_t ret = IntentionClient::GetInstance().AddWatch(static_cast<uint32_t>(Intention::COOPERATE),
CooperateParam::REGISTER, param, reply);
if (ret != RET_OK) {
FI_HILOGE("Failed to register, ret:%{public}d", ret);
@ -73,7 +73,8 @@ listenerLabel:
isListeningProcess_ = false;
DefaultCooperateParam param;
DefaultCooperateReply reply;
return IntentionClient::GetInstance().RemoveWatch(Intention::COOPERATE, CooperateParam::REGISTER, param, reply);
return IntentionClient::GetInstance().RemoveWatch(static_cast<uint32_t>(Intention::COOPERATE),
CooperateParam::REGISTER, param, reply);
}
return RET_OK;
}
@ -90,7 +91,8 @@ int32_t CooperateManagerImpl::PrepareCooperate(FuncCooperateMessage callback)
}
DefaultCooperateParam param { userData_ };
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().AddWatch(Intention::COOPERATE, CooperateParam::PREPARE, param, reply);
int32_t ret = IntentionClient::GetInstance().AddWatch(static_cast<uint32_t>(Intention::COOPERATE),
CooperateParam::PREPARE, param, reply);
if (ret != RET_OK) {
FI_HILOGE("Prepare cooperate failed");
return ret;
@ -112,7 +114,7 @@ int32_t CooperateManagerImpl::UnprepareCooperate(FuncCooperateMessage callback)
}
DefaultCooperateParam param { userData_ };
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().RemoveWatch(Intention::COOPERATE,
int32_t ret = IntentionClient::GetInstance().RemoveWatch(static_cast<uint32_t>(Intention::COOPERATE),
CooperateParam::PREPARE, param, reply);
if (ret != RET_OK) {
FI_HILOGE("Unprepare cooperate failed");
@ -136,7 +138,7 @@ int32_t CooperateManagerImpl::ActivateCooperate(const std::string &remoteNetwork
}
StartCooperateParam param { userData_, remoteNetworkId, startDeviceId };
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().Start(Intention::COOPERATE, param, reply);
int32_t ret = IntentionClient::GetInstance().Start(static_cast<uint32_t>(Intention::COOPERATE), param, reply);
if (ret != RET_OK) {
FI_HILOGE("Activate cooperate failed");
return ret;
@ -156,9 +158,9 @@ int32_t CooperateManagerImpl::DeactivateCooperate(bool isUnchained, FuncCooperat
FI_HILOGE("userData exceeds the maximum");
userData_ = 0;
}
StartCooperateParam param { userData_, isUnchained };
StopCooperateParam param { userData_, isUnchained };
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().Start(Intention::COOPERATE, param, reply);
int32_t ret = IntentionClient::GetInstance().Start(static_cast<uint32_t>(Intention::COOPERATE), param, reply);
if (ret != RET_OK) {
FI_HILOGE("Deactivate cooperate failed");
return ret;
@ -180,7 +182,8 @@ int32_t CooperateManagerImpl::GetCooperateState(const std::string &deviceId, Fun
}
GetCooperateStateParam param { deviceId, userData_ };
DefaultCooperateReply reply;
int32_t ret = IntentionClient::GetInstance().GetParam(Intention::COOPERATE, CooperateParam::STATE, param, reply);
int32_t ret = IntentionClient::GetInstance().GetParam(static_cast<uint32_t>(Intention::COOPERATE),
CooperateParam::STATE, param, reply);
if (ret != RET_OK) {
FI_HILOGE("Get cooperate state failed");
return ret;

View File

@ -16,8 +16,6 @@
#include "drag_manager_impl.h"
#include "drag_data.h"
#include "intention_client.h"
#include "intention_define.h"
namespace OHOS {
namespace Msdp {
@ -29,12 +27,14 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragMan
int32_t DragManagerImpl::UpdateDragStyle(DragCursorStyle style)
{
if ((style < DragCursorStyle::DEFAULT) || (style > DragCursorStyle::MOVE)) {
FI_HILOGE("Style is invalid");
return RET_ERR;
}
DragStyleParam param { static_cast<int32_t>(style) };
DefaultDragReply reply;
return IntentionClient::GetInstance().SetParam(Intention::DRAG, DragParam::DRAG_STYLE, param, reply);
return IntentionClient::GetInstance().SetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::DRAG_STYLE, param, reply);
}
int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback)
@ -62,28 +62,30 @@ int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::function<void(
StartDragParam param { dragData };
DefaultDragReply reply;
return IntentionClient::GetInstance().Start(Intention::DRAG, param, reply);
return IntentionClient::GetInstance().Start(static_cast<uint32_t>(Intention::DRAG), param, reply);
}
int32_t DragManagerImpl::StopDrag(DragResult result, bool hasCustomAnimation)
{
StopDragParam param { static_cast<int32_t>(result), hasCustomAnimation };
DefaultDragReply reply;
return IntentionClient::GetInstance().Stop(Intention::DRAG, param, reply);
return IntentionClient::GetInstance().Stop(static_cast<uint32_t>(Intention::DRAG), param, reply);
}
int32_t DragManagerImpl::GetDragTargetPid()
{
DragTargetPidParam param;
DefaultDragReply reply;
return IntentionClient::GetInstance().GetParam(Intention::DRAG, DragParam::PID, data, reply);
return IntentionClient::GetInstance().GetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::PID, param, reply);
}
int32_t DragManagerImpl::GetUdKey(std::string &udKey)
{
GetUdKeyParam param { udKey };
DefaultDragReply reply;
return IntentionClient::GetInstance().GetParam(Intention::DRAG, DragParam::UDKEY, param, reply);
return IntentionClient::GetInstance().GetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::UDKEY, param, reply);
}
int32_t DragManagerImpl::AddDraglistener(DragListenerPtr listener)
@ -93,7 +95,8 @@ int32_t DragManagerImpl::AddDraglistener(DragListenerPtr listener)
if (!hasRegistered_) {
AddDragListenerParam param;
DefaultDragReply reply;
int32_t ret = IntentionClient::GetInstance().AddWatch(Intention::DRAG, DragParam::LISTENER, param, reply);
int32_t ret = IntentionClient::GetInstance().AddWatch(static_cast<uint32_t>(Intention::DRAG),
DragParam::LISTENER, param, reply);
if (ret != RET_OK) {
FI_HILOGE("Failed to register");
return ret;
@ -128,7 +131,8 @@ int32_t DragManagerImpl::RemoveDraglistener(DragListenerPtr listener)
hasRegistered_ = false;
RemoveDragListenerParam param;
DefaultDragReply reply;
return IntentionClient::GetInstance().RemoveWatch(Intention::DRAG, DragParam::LISTENER, param, reply);
return IntentionClient::GetInstance().RemoveWatch(static_cast<uint32_t>(Intention::DRAG),
DragParam::LISTENER, param, reply);
}
return RET_OK;
}
@ -137,14 +141,16 @@ int32_t DragManagerImpl::SetDragWindowVisible(bool visible)
{
SetDragWindowVisibleParam param { visible };
DefaultDragReply reply;
return IntentionClient::GetInstance().SetParam(Intention::DRAG, DragParam::WINDOW_VISIBLE, param, reply);
return IntentionClient::GetInstance().SetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::WINDOW_VISIBLE, param, reply);
}
int32_t DragManagerImpl::GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height)
{
GetShadowOffsetParam param { offsetX, offsetY, width, height };
DefaultDragReply reply;
return IntentionClient::GetInstance().GetParam(Intention::DRAG, DragParam::SHADOW_OFFSET, param, reply);
return IntentionClient::GetInstance().GetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::SHADOW_OFFSET, param, reply);
}
int32_t DragManagerImpl::UpdateShadowPic(const ShadowInfo &shadowInfo)
@ -160,7 +166,8 @@ int32_t DragManagerImpl::UpdateShadowPic(const ShadowInfo &shadowInfo)
UpdateShadowPicParam param { shadowInfo };
DefaultDragReply reply;
return IntentionClient::GetInstance().SetParam(Intention::DRAG, DragParam::SHADOW_PIC, param, reply);
return IntentionClient::GetInstance().SetParam(static_cast<uint32_t>(Intention::DRAG),
DragParam::SHADOW_PIC, param, reply);
}
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -13,8 +13,6 @@
* limitations under the License.
*/
#include "ipc_client.h"
#include <if_system_ability_manager.h>
#include <iservice_registry.h>
#include <system_ability_definition.h>
@ -23,13 +21,10 @@
#include "iremote_object.h"
#include "cooperate_manager_impl.h"
#include "devicestatus_define.h"
#include "drag_manager_impl.h"
#include "intention_common.h"
#include "intention_define.h"
#include "include/util.h"
// Implementation of client side of IPC.
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
@ -59,7 +54,10 @@ int32_t IntentionClient::Enable(uint32_t intention, ParamBase &data, ParamBase &
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->Enable(intention, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -78,7 +76,10 @@ int32_t IntentionClient::Disable(uint32_t intention, ParamBase &data, ParamBase
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->Disable(intention, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -91,13 +92,16 @@ int32_t IntentionClient::Start(uint32_t intention, ParamBase &data, ParamBase &r
{
CALL_DEBUG_ENTER;
MessageParcel dataParcel;
if (!dataParcel.WriteInterfaceToken(InentionProxy::GetDescriptor())) {
if (!dataParcel.WriteInterfaceToken(IntentionProxy::GetDescriptor())) {
FI_HILOGE("Write descriptor failed");
return RET_ERR;
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->Start(intention, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -116,7 +120,10 @@ int32_t IntentionClient::Stop(uint32_t intention, ParamBase &data, ParamBase &re
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->Stop(intention, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -135,7 +142,10 @@ int32_t IntentionClient::AddWatch(uint32_t intention, uint32_t id, ParamBase &da
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->AddWatch(intention, id, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -154,7 +164,10 @@ int32_t IntentionClient::RemoveWatch(uint32_t intention, uint32_t id, ParamBase
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->RemoveWatch(intention, id, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -173,7 +186,10 @@ int32_t IntentionClient::SetParam(uint32_t intention, uint32_t id, ParamBase &da
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->SetParam(intention, id, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -192,7 +208,10 @@ int32_t IntentionClient::GetParam(uint32_t intention, uint32_t id, ParamBase &da
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->GetParam(intention, id, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -211,7 +230,10 @@ int32_t IntentionClient::Control(uint32_t intention, uint32_t id, ParamBase &dat
}
data.Marshalling(dataParcel);
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
if (Connect() != RET_OK) {
FI_HILOGE("Failed to connect IntentionService");
return RET_ERR;
}
MessageParcel replyParcel;
int32_t ret = devicestatusProxy_->Control(intention, id, dataParcel, replyParcel);
if (ret == RET_OK) {
@ -234,7 +256,7 @@ ErrCode IntentionClient::Connect()
sptr<IRemoteObject> remoteObject = sa->CheckSystemAbility(MSDP_DEVICESTATUS_SERVICE_ID);
CHKPR(remoteObject, E_DEVICESTATUS_GET_SERVICE_FAILED);
deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new (std::nothrow) DeviceStatusDeathRecipient());
deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new (std::nothrow) IntentionDeathRecipient());
CHKPR(deathRecipient_, ERR_NO_MEMORY);
if (remoteObject->IsProxyObject()) {
@ -245,7 +267,7 @@ ErrCode IntentionClient::Connect()
}
devicestatusProxy_ = iface_cast<IIntention>(remoteObject);
FI_HILOGD("Connecting DeviceStatusService success");
FI_HILOGD("Connecting IntentionService success");
return RET_OK;
}
@ -265,7 +287,7 @@ void IntentionClient::ResetProxy(const wptr<IRemoteObject>& remote)
}
}
void IntentionClient::DeviceStatusDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
void IntentionClient::IntentionDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
{
CALL_DEBUG_ENTER;
CHKPV(remote);

View 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.
*/
#ifndef I_DRAG_LISTENER_H
#define I_DRAG_LISTENER_H
#include <memory>
#include "drag_data.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
class IDragListener {
public:
IDragListener() = default;
virtual ~IDragListener() = default;
virtual void OnDragMessage(DragState state) = 0;
};
using DragListenerPtr = std::shared_ptr<IDragListener>;
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // I_DRAG_LISTENER_H

51
intention/ipc/BUILD.gn Normal file
View File

@ -0,0 +1,51 @@
# 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("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("ipc_public_config") {
include_dirs = [ "include" ]
}
config("ipc_config") {
include_dirs = [
"include",
"${intention_root_path}/data/include",
"${device_status_root_path}/utils/ipc/include",
]
}
ohos_source_set("intention_ipc") {
sources = [
"src/intention_proxy.cpp",
"src/intention_stub.cpp",
]
configs = [ ":ipc_config" ]
public_configs = [ ":ipc_public_config" ]
deps = [ "${device_status_utils_path}:devicestatus_util" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image_native",
"ipc:ipc_core",
]
subsystem_name = "msdp"
part_name = "${device_status_part_name}"
}

View File

@ -32,28 +32,28 @@ namespace DeviceStatus {
class IIntention : public IRemoteBroker {
public:
// Enable the service identified by [`intention`].
int32_t Enable(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t Enable(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
// Disable the service identified by [`intention`].
int32_t Disable(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t Disable(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
// Start the service identified by [`intention`].
int32_t Start(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t Start(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
// Stop the service identified by [`intention`].
int32_t Stop(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t Stop(uint32_t intention, MessageParcel &data, MessageParcel &reply) = 0;
// Add a watch of state of service, with the service identified by [`intention`],
// the state to watch identified by [`id`], parameters packed in [`data`] parcel.
int32_t AddWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t AddWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
// Remove a watch of state of service.
int32_t RemoveWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t RemoveWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
// Set a parameter of service, with the service identified by [`intention`],
// the parameter identified by [`id`], and values packed in [`data`] parcel.
int32_t SetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t SetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
// Get a parameter of service, with the service identified by [`intention`],
// the parameter identified by [`id`].
int32_t GetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t GetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
// Interact with service identified by [`intention`] for general purpose. This interface
// supplements functions of previous intefaces. Functionalities of this interface is
// service spicific.
int32_t Control(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
virtual int32_t Control(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply) = 0;
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.msdp.Idevicestatus");
};

View File

@ -34,11 +34,11 @@ int32_t IntentionProxy::Enable(uint32_t intention, MessageParcel &data, MessageP
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::ENABLE, intention, 0u),
PARAMID(CommonAction::ENABLE, intention, 0u)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -50,11 +50,11 @@ int32_t IntentionProxy::Disable(uint32_t intention, MessageParcel &data, Message
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::DISABLE, intention, 0u),
PARAMID(CommonAction::DISABLE, intention, 0u)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -66,11 +66,11 @@ int32_t IntentionProxy::Start(uint32_t intention, MessageParcel &data, MessagePa
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::START, intention, 0u),
PARAMID(CommonAction::START, intention, 0u)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -82,11 +82,11 @@ int32_t IntentionProxy::Stop(uint32_t intention, MessageParcel &data, MessagePar
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::STOP, intention, 0u),
PARAMID(CommonAction::STOP, intention, 0u)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -98,11 +98,11 @@ int32_t IntentionProxy::AddWatch(uint32_t intention, uint32_t id, MessageParcel
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::ADD_WATCH, intention, id),
PARAMID(CommonAction::ADD_WATCH, intention, id)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -114,11 +114,11 @@ int32_t IntentionProxy::RemoveWatch(uint32_t intention, uint32_t id, MessageParc
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::REMOVE_WATCH, intention, id),
PARAMID(CommonAction::REMOVE_WATCH, intention, id)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -130,11 +130,11 @@ int32_t IntentionProxy::SetParam(uint32_t intention, uint32_t id, MessageParcel
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::SET_PARAM, intention, id),
PARAMID(CommonAction::SET_PARAM, intention, id)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -146,11 +146,11 @@ int32_t IntentionProxy::GetParam(uint32_t intention, uint32_t id, MessageParcel
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::GET_PARAM, intention, id),
PARAMID(CommonAction::GET_PARAM, intention, id)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);
@ -162,11 +162,11 @@ int32_t IntentionProxy::Control(uint32_t intention, uint32_t id, MessageParcel &
{
CALL_DEBUG_ENTER;
sptr<IRemoteObject> remote = Remote();
DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
CHKPR(remote, RET_ERR);
MessageOption option;
int32_t ret = remote->SendRequest(static_cast<uint32_t>(
PARAMID(CommonAction::CONTROL, intention, id),
PARAMID(CommonAction::CONTROL, intention, id)),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, ret:%{public}d", ret);

View File

@ -18,11 +18,9 @@
#include "message_parcel.h"
#include "pixel_map.h"
#include "fi_log.h"
#include "intention_common.h"
#include "intention_define.h"
#include "intention_proxy.h"
#include "intention_service.h"
#include "devicestatus_common.h"
#include "devicestatus_define.h"
#include "i_plugin.h"
#include "include/util.h"
namespace OHOS {
@ -43,16 +41,16 @@ int32_t IntentionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
}
switch (GACTION(code)) {
case CommonAction::enable: {
case CommonAction::ENABLE: {
return Enable(GINTENTION(code), data, reply);
}
case CommonAction::Disable: {
case CommonAction::DISABLE: {
return Disable(GINTENTION(code), data, reply);
}
case CommonAction::start: {
case CommonAction::START: {
return Start(GINTENTION(code), data, reply);
}
case CommonAction::stop: {
case CommonAction::STOP: {
return Stop(GINTENTION(code), data, reply);
}
case CommonAction::ADD_WATCH: {

View File

@ -17,27 +17,16 @@ config("cooperate_public_config") {
include_dirs = [ "include" ]
}
ohos_shared_library("cooperate") {
ohos_shared_library("intention_cooperate") {
include_dirs = [
"include",
"${device_status_interfaces_path}/innerkits/interaction/include",
"${device_status_service_path}/context/include",
"//third_party/cJSON",
"${intention_root_path}/data/cooperate/include",
"${device_status_root_path}/utils/ipc/include",
"${intention_root_path}/data/include",
]
sources = [
"src/cooperate.cpp",
"src/cooperate_device_manager.cpp",
"src/cooperate_event_handler.cpp",
"src/cooperate_event_manager.cpp",
"src/cooperate_state_free.cpp",
"src/cooperate_state_in.cpp",
"src/cooperate_state_out.cpp",
"src/cooperate_util.cpp",
"src/device_profile_adapter.cpp",
"src/dinput_adapter.cpp",
"src/dsoftbus_adapter.cpp",
"src/i_cooperate_state.cpp",
"src/state_machine.cpp",
]
@ -48,23 +37,14 @@ ohos_shared_library("cooperate") {
deps = [
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
"//third_party/cJSON:cjson",
"//third_party/openssl:libcrypto_shared",
"${intention_root_path}/data:cooperate_params",
]
external_deps = [
"c_utils:utils",
"device_info_manager:distributed_device_profile_client",
"device_manager:devicemanagersdk",
"distributed_input:libdinput_sdk",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image_native",
"input:libmmi-client",
"ipc:ipc_single",
"window_manager:libdm",
]
subsystem_name = "${device_status_subsystem_name}"

View File

@ -16,7 +16,7 @@
#include "cooperate.h"
#include "cooperate_params.h"
#include "intention_define.h"
#include "devicestatus_define.h"
namespace OHOS {
namespace Msdp {
@ -43,8 +43,10 @@ int32_t Cooperate::Disable(CallingContext &context, Parcel &data, Parcel &reply)
int32_t Cooperate::Start(CallingContext &context, Parcel &data, Parcel &reply)
{
CHKPR(context_, RET_ERR);
StartCooperateParam param;
if (!param.Unmarshalling(data)) {
FI_HILOGE("Failed to unmarshalling param");
return RET_ERR;
}
@ -59,6 +61,7 @@ int32_t Cooperate::Stop(CallingContext &context, Parcel &data, Parcel &reply)
{
StopCooperateParam param;
if (!param.Unmarshalling(data)) {
FI_HILOGE("Failed to unmarshalling param");
return RET_ERR;
}
@ -88,6 +91,7 @@ int32_t Cooperate::GetParam(CallingContext &context, uint32_t id, Parcel &data,
{
GetCooperateStateParam param;
if (!param.Unmarshalling(data)) {
FI_HILOGE("Failed to unmarshalling param");
return RET_ERR;
}

View File

@ -15,7 +15,7 @@
#include "state_machine.h"
#include "intention_define.h"
#include "devicestatus_define.h"
namespace OHOS {
namespace Msdp {
@ -27,16 +27,14 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "StateMa
void StateMachine::EnableCooperate()
{
CALL_INFO_TRACE;
return RET_ERR;
}
void StateMachine::DisableCooperate()
{
CALL_INFO_TRACE;
return RET_ERR;
}
int32_t StartCooperate(const std::string &remoteNetworkId, int32_t startDeviceId)
int32_t StateMachine::StartCooperate(const std::string &remoteNetworkId, int32_t startDeviceId)
{
CALL_INFO_TRACE;
return RET_ERR;

View File

@ -14,61 +14,40 @@
import("//build/ohos.gni")
import("../../../device_status.gni")
config("interaction_drag_public_config") {
config("intention_drag_public_config") {
include_dirs = [
"include",
"${intention_service_path}/context/include",
"${intention_root_path}/data/drag/include",
"${device_status_root_path}/utils/ipc/include",
]
}
ohos_shared_library("interaction_drag") {
include_dirs = [
"include",
"${intention_interfaces_path}/innerkits/interaction/include",
"${intention_utils_path}/include",
"${intention_service_path}/context/include",
"${intention_service_path}/native/include",
"//third_party/cJSON",
]
ohos_shared_library("intention_drag") {
include_dirs = [ "include" ]
public_configs = [ ":intention_drag_public_config" ]
sources = [
"src/drag_data_manager.cpp",
"src/drag_drawing.cpp",
"src/drag_manager.cpp",
"src/intention_drag.cpp",
"src/state_change_notify.cpp",
]
defines = device_status_default_defines
public_configs = [ ":interaction_drag_public_config" ]
if (defined(use_rosen_drawing) && use_rosen_drawing) {
defines += [ "USE_ROSEN_DRAWING" ]
}
deps = [
"${intention_root_path}/etc/drag_icon:device_status_drag_icon",
"${intention_root_path}/utils/ipc:devicestatus_ipc",
"${intention_utils_path}:devicestatus_util",
"//third_party/cJSON:cjson",
"//third_party/libxml2:xml2",
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
"${intention_root_path}/data:drag_params",
]
external_deps = [
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_2d:libcomposer",
"graphic_2d:librender_service_base",
"graphic_2d:window_animation",
"hilog:libhilog",
"hitrace:hitrace_meter",
"image_framework:image_native",
"init:libbegetutil",
"input:libmmi-client",
"ipc:ipc_single",
"udmf:udmf_client",
"window_manager:libdm",
"window_manager:libwm",
]
subsystem_name = "${device_status_subsystem_name}"

View File

@ -18,10 +18,10 @@
#include "pixel_map.h"
#include "drag_data.h"
#include "drag_drawing.h"
#include "intention_define.h"
#include "stream_session.h"
#include "devicestatus_define.h"
#include "drag_data_manager.h"
#include "i_context.h"
#include "state_change_notify.h"
namespace OHOS {
namespace Msdp {
@ -45,14 +45,21 @@ public:
private:
int32_t InitDataManager(const DragData &dragData) const;
int32_t NotifyDragResult(DragResult result);
int32_t OnStartDrag();
int32_t OnStopDrag(DragResult result, bool hasCustomAnimation);
void StateChangedNotify(DragState state);
private:
int32_t timerId_ { -1 };
DragResult dragResult_ { DragResult::DRAG_FAIL };
StateChangeNotify stateNotify_;
IContext* context_ { nullptr };
SessionPtr dragOutSession_ { nullptr };
DragState dragState_ { DragState::STOP };
std::function<void(DragState)> stateChangedCallback_;
};
#define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance()
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -0,0 +1,60 @@
/*
* 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 STATE_CHANGE_NOTIFY_H
#define STATE_CHANGE_NOTIFY_H
#include <list>
#include <memory>
#include <mutex>
#include "drag_data.h"
#include "stream_session.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
class StateChangeNotify final {
public:
StateChangeNotify() = default;
~StateChangeNotify() = default;
struct MessageInfo {
MessageId msgId { MessageId::INVALID };
SessionPtr session { nullptr };
DragState state { DragState::ERROR };
bool operator==(std::shared_ptr<MessageInfo> info)
{
if (info == nullptr || info->session == nullptr) {
return false;
}
return session->GetPid() == info->session->GetPid();
}
};
void AddNotifyMsg(std::shared_ptr<MessageInfo> info);
void RemoveNotifyMsg(std::shared_ptr<MessageInfo> info);
int32_t StateChangedNotify(DragState state);
private:
void OnStateChangedNotify(SessionPtr session, MessageId msId, DragState state);
private:
std::list<std::shared_ptr<MessageInfo>> msgInfos_;
};
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // STATE_CHANGE_NOTIFY_H

View File

@ -17,13 +17,13 @@
#include "drag_params.h"
#include "fi_log.h"
#include "intention_define.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragManager" };
constexpr int32_t SUBSTR_UDKEY_LEN { 6 };
} // namespace
int32_t DragManager::AddListener(SessionPtr session)
@ -95,7 +95,7 @@ int32_t DragManager::StopDrag(DragResult result, bool hasCustomAnimation)
DRAG_DATA_MGR.ResetDragData();
dragResult_ = static_cast<DragResult>(result);
StateChangedNotify(DragState::STOP);
return ret;
return RET_OK;
}
int32_t DragManager::GetDragTargetPid() const
@ -153,6 +153,29 @@ int32_t DragManager::OnStopDrag(DragResult result, bool hasCustomAnimation)
CALL_DEBUG_ENTER;
return RET_ERR;
}
int32_t DragManager::NotifyDragResult(DragResult result)
{
CALL_DEBUG_ENTER;
DragData dragData = DRAG_DATA_MGR.GetDragData();
int32_t targetPid = GetDragTargetPid();
NetPacket pkt(MessageId::DRAG_NOTIFY_RESULT);
if ((result < DragResult::DRAG_SUCCESS) || (result > DragResult::DRAG_EXCEPTION)) {
FI_HILOGE("Invalid result:%{public}d", static_cast<int32_t>(result));
return RET_ERR;
}
pkt << dragData.displayX << dragData.displayY << static_cast<int32_t>(result) << targetPid;
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;
}
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -41,20 +41,23 @@ int32_t IntentionDrag::Disable(CallingContext &context, Parcel &data, Parcel &re
int32_t IntentionDrag::Start(CallingContext &context, Parcel &data, Parcel &reply)
{
CHKPR(context_, RET_ERR);
StartDragParam param;
if (!param.Unmarshalling(data)) {
FI_HILOGE("Failed to unmarshalling param");
return RET_ERR;
}
return dragMgr_.StartDrag(param, context.session);
return dragMgr_.StartDrag(param.dragData, context.session);
}
int32_t IntentionDrag::Stop(CallingContext &context, Parcel &data, Parcel &reply)
{
StopDragParam param;
if (!param.Unmarshalling(data)) {
FI_HILOGE("Failed to unmarshalling param");
return RET_ERR;
}
return dragMgr_.StopDrag(param.result, param.hasCustomAnimation);
return dragMgr_.StopDrag(static_cast<DragResult>(param.result), param.hasCustomAnimation);
}
int32_t IntentionDrag::AddWatch(CallingContext &context, uint32_t id, Parcel &data, Parcel &reply)

View File

@ -0,0 +1,88 @@
/*
* 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 "state_change_notify.h"
#include "devicestatus_define.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "StateChangeNotify" };
} // namespace
void StateChangeNotify::AddNotifyMsg(std::shared_ptr<MessageInfo> info)
{
CALL_DEBUG_ENTER;
CHKPV(info);
auto it = std::find_if(msgInfos_.begin(), msgInfos_.end(),
[info] (std::shared_ptr<MessageInfo> msgInfo) {
return *msgInfo == info;
});
if (it != msgInfos_.end()) {
return;
}
msgInfos_.emplace_back(info);
}
void StateChangeNotify::RemoveNotifyMsg(std::shared_ptr<MessageInfo> info)
{
CALL_DEBUG_ENTER;
if (msgInfos_.empty() || info == nullptr) {
FI_HILOGE("Remove listener failed");
return;
}
auto it = std::find_if(msgInfos_.begin(), msgInfos_.end(),
[info] (std::shared_ptr<MessageInfo> msgInfo) {
return *msgInfo == info;
});
if (it != msgInfos_.end()) {
msgInfos_.erase(it);
}
}
int32_t StateChangeNotify::StateChangedNotify(DragState state)
{
CALL_DEBUG_ENTER;
if (msgInfos_.empty()) {
FI_HILOGW("No listener, send message failed");
return RET_ERR;
}
for (auto it = msgInfos_.begin(); it != msgInfos_.end(); ++it) {
auto info = *it;
CHKPC(info);
OnStateChangedNotify(info->session, info->msgId, state);
}
return RET_OK;
}
void StateChangeNotify::OnStateChangedNotify(SessionPtr session, MessageId msgId, DragState state)
{
CALL_DEBUG_ENTER;
CHKPV(session);
NetPacket pkt(msgId);
pkt << static_cast<int32_t>(state);
if (pkt.ChkRWError()) {
FI_HILOGE("Packet write data failed");
return;
}
if (!session->SendMsg(pkt)) {
FI_HILOGE("Sending failed");
}
}
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -11,31 +11,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../../device_status.gni")
import("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("plugin_manager_public_config") {
config("plugin_manager_config") {
include_dirs = [
"include",
"${device_status_root_path}/intention/data/ipc",
"${intention_root_path}/data/include",
]
}
ohos_source_set("plugin_manager") {
include_dirs = [
"include",
"${device_status_root_path}/intention/data/ipc",
]
sources = [ "src/plugin_manager.cpp" ]
public_configs = [ ":plugin_manager_public_config" ]
configs = [ ":plugin_manager_config" ]
defines = device_status_default_defines
deps = [
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
]
deps = [ "${device_status_utils_path}:devicestatus_util" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
external_deps = [ "c_utils:utils" ]
subsystem_name = "${device_status_subsystem_name}"
subsystem_name = "msdp"
part_name = "${device_status_part_name}"
}

View File

@ -27,7 +27,7 @@ namespace Msdp {
namespace DeviceStatus {
// Loading、unloading and bookkeeping of modules.
class PluginManager {
class PluginManager : public IPluginManager {
public:
class Plugin {
public:
@ -62,6 +62,8 @@ private:
IContext *context_ { nullptr };
std::map<Intention, Plugin> libs_;
};
using DestroyInstance = void (*)(IPlugin *);
using CreateInstance = IPlugin* (*)(IContext *);
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS

View File

@ -15,6 +15,8 @@
#include "plugin_manager.h"
#include <dlfcn.h>
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
@ -29,7 +31,7 @@ PluginManager::Plugin::Plugin(IContext *context, void *handle)
PluginManager::Plugin::~Plugin()
{
if (instance_ != nullptr) {
auto destroy = static_cast<DestroyInstance>(dlsym(handle_, "DestroyInstance"));
auto destroy = reinterpret_cast<DestroyInstance>(dlsym(handle_, "DestroyInstance"));
if (destroy != nullptr) {
destroy(instance_);
}
@ -42,10 +44,10 @@ IPlugin* PluginManager::Plugin::GetInstance()
if (instance_ != nullptr) {
return instance_;
}
auto func = static_cast<CreateInstance*>(dlsym(iter.second, "CreateInstance"));
auto func = reinterpret_cast<CreateInstance>(dlsym(handle_, "CreateInstance"));
if (func == nullptr) {
FI_HILOGE("dlsym msg:%{public}s", dlerror());
return RET_ERR;
return nullptr;
}
instance_ = func(context_);
return instance_;
@ -75,11 +77,11 @@ int32_t PluginManager::LoadLibrary(Intention intention)
{
std::string libPath;
switch intention {
case Intention::Drag: {
switch (intention) {
case Intention::DRAG: {
libPath = "/system/lib/libintention_drag.z.so";
}
case Intention::Cooperate: {
case Intention::COOPERATE: {
libPath = "/system/lib/libintention_cooperate.z.so";
}
default: {

View File

@ -0,0 +1,41 @@
# 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("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("task_scheduler_config") {
include_dirs = [
"include",
"${intention_root_path}/data/include",
]
}
ohos_source_set("task_scheduler") {
sources = [ "src/task_scheduler.cpp" ]
configs = [ ":task_scheduler_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 = "msdp"
part_name = "${device_status_part_name}"
}

View File

@ -19,7 +19,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include "intention_define.h"
#include "devicestatus_define.h"
namespace OHOS {
namespace Msdp {

View File

@ -0,0 +1,41 @@
# 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("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
config("timer_manager_config") {
include_dirs = [
"include",
"${intention_root_path}/data/include",
]
}
ohos_source_set("timer_manager") {
sources = [ "src/timer_manager.cpp" ]
configs = [ ":timer_manager_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 = "msdp"
part_name = "${device_status_part_name}"
}

View File

@ -19,8 +19,7 @@
#include <sys/timerfd.h>
#include "fi_log.h"
#include "intention_define.h"
#include "devicestatus_define.h"
#include "include/util.h"
namespace OHOS {
@ -167,9 +166,7 @@ int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount,
} else if (intervalMs > MAX_INTERVAL_MS) {
intervalMs = MAX_INTERVAL_MS;
}
if (callback == nullptr) {
return NONEXISTENT_ID;
}
CHKPR(callback, NONEXISTENT_ID);
int32_t timerId = TakeNextTimerId();
if (timerId < 0) {
return NONEXISTENT_ID;

View File

@ -0,0 +1,48 @@
# 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
#
# 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("//base/msdp/device_status/device_status.gni")
import("//build/ohos.gni")
ohos_shared_library("intention_service") {
shlib_type = "sa"
include_dirs = [
"include",
"${intention_root_path}/data/include",
"${intention_root_path}/ipc/include",
"${intention_root_path}/scheduler/plugin_manager/include",
"${intention_root_path}/scheduler/task_scheduler/include",
"${intention_root_path}/scheduler/timer_manager/include",
"${intention_root_path}/utils/common/include",
]
sources = [ "src/intention_service.cpp" ]
deps = [
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
"${intention_root_path}/ipc:intention_ipc",
"${intention_root_path}/scheduler/plugin_manager:plugin_manager",
"${intention_root_path}/scheduler/task_scheduler:task_scheduler",
"${intention_root_path}/scheduler/timer_manager:timer_manager",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"safwk:system_ability_fwk",
]
subsystem_name = "${device_status_subsystem_name}"
part_name = "${device_status_part_name}"
}

View File

@ -19,6 +19,7 @@
#include <iremote_object.h>
#include <system_ability.h>
#include "devicestatus_delayed_sp_singleton.h"
#include "i_context.h"
#include "intention_stub.h"
#include "plugin_manager.h"
@ -32,15 +33,16 @@ class IntentionService final : public IContext,
public SystemAbility,
public IntentionStub {
DECLARE_SYSTEM_ABILITY(IntentionService);
DECLARE_DELAYED_SP_SINGLETON(IntentionService);
public:
virtual void OnDump() override;
virtual void OnStart() override;
virtual void OnStop() override;
ITaskScheduler& GetTaskScheduler() const override;
ITimerManager& GetTimerManager() const override;
IPluginManager& GetPluginManager() const override;
ITaskScheduler& GetTaskScheduler() override;
ITimerManager& GetTimerManager() override;
IPluginManager& GetPluginManager() override;
private:
int32_t Enable(uint32_t intention, MessageParcel &data, MessageParcel &reply) override;
@ -59,17 +61,17 @@ private:
PluginManager pluginMgr_;
};
ITaskScheduler& IntentionService::GetTaskScheduler() const
ITaskScheduler& IntentionService::GetTaskScheduler()
{
return taskScheduler_;
}
ITimerManager& IntentionService::GetTimerManager() const
ITimerManager& IntentionService::GetTimerManager()
{
return timerMgr_;
}
IPluginManager& IntentionService::GetPluginManager() const
IPluginManager& IntentionService::GetPluginManager()
{
return pluginMgr_;
}

View File

@ -18,25 +18,18 @@
#include <unistd.h>
#include <vector>
#include "hitrace_meter.h"
#include "hisysevent.h"
#include "if_system_ability_manager.h"
#include <ipc_skeleton.h>
#include "iservice_registry.h"
#include "string_ex.h"
#include "system_ability_definition.h"
#include "devicestatus_common.h"
#include "i_plugin.h"
#include "intention_common.h"
#include "intention_hisysevent.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "IntentionService" };
const bool REGISTER_RESULT =
SystemAbility::MakeAndRegisterAbility(DelayedSpSingleton<IntentionService>::GetInstance().GetRefPtr());
} // namespace
IntentionService::IntentionService() : SystemAbility(MSDP_DEVICESTATUS_SERVICE_ID, true)
@ -63,12 +56,12 @@ void IntentionService::OnStop()
int32_t IntentionService::Enable(uint32_t intention, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::Enable, m, context, 0u, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::Enable, plugin, context, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("Enable failed, ret:%{public}d", ret);
}
@ -77,12 +70,12 @@ int32_t IntentionService::Enable(uint32_t intention, MessageParcel &data, Messag
int32_t IntentionService::Disable(uint32_t intention, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::Disable, m, context, 0u, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::Disable, plugin, context, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("Disable failed, ret:%{public}d", ret);
}
@ -91,12 +84,12 @@ int32_t IntentionService::Disable(uint32_t intention, MessageParcel &data, Messa
int32_t IntentionService::Start(uint32_t intention, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::Start, m, context, 0u, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::Start, plugin, context, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("Start failed, ret:%{public}d", ret);
}
@ -105,12 +98,12 @@ int32_t IntentionService::Start(uint32_t intention, MessageParcel &data, Message
int32_t IntentionService::Stop(uint32_t intention, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::Stop, m, context, 0u, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::Stop, plugin, context, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("Stop failed, ret:%{public}d", ret);
}
@ -119,12 +112,12 @@ int32_t IntentionService::Stop(uint32_t intention, MessageParcel &data, MessageP
int32_t IntentionService::AddWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::AddWatch, m, context, id, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::AddWatch, plugin, context, id, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("AddWatch failed, ret:%{public}d", ret);
}
@ -133,12 +126,12 @@ int32_t IntentionService::AddWatch(uint32_t intention, uint32_t id, MessageParce
int32_t IntentionService::RemoveWatch(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::RemoveWatch, m, context, id, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::RemoveWatch, plugin, context, id, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("RemoveWatch failed, ret:%{public}d", ret);
}
@ -147,12 +140,12 @@ int32_t IntentionService::RemoveWatch(uint32_t intention, uint32_t id, MessagePa
int32_t IntentionService::SetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::SetParam, m, context, id, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::SetParam, plugin, context, id, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("SetParam failed, ret:%{public}d", ret);
}
@ -161,12 +154,12 @@ int32_t IntentionService::SetParam(uint32_t intention, uint32_t id, MessageParce
int32_t IntentionService::GetParam(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::GetParam, m, context, id, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::GetParam, plugin, context, id, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("GetParam failed, ret:%{public}d", ret);
}
@ -175,12 +168,12 @@ int32_t IntentionService::GetParam(uint32_t intention, uint32_t id, MessageParce
int32_t IntentionService::Control(uint32_t intention, uint32_t id, MessageParcel &data, MessageParcel &reply)
{
IPlugin *m = pluginMgr_.LoadModule(intention);
CHKPR(m, RET_ERR);
IPlugin *plugin = pluginMgr_.LoadPlugin(static_cast<Intention>(intention));
CHKPR(plugin, RET_ERR);
CallingContext context;
int32_t ret = taskScheduler_.PostSyncTask(
std::bind(&IPlugin::Control, m, context, id, std::ref(data), std::ref(reply)));
std::bind(&IPlugin::Control, plugin, context, id, std::ref(data), std::ref(reply)));
if (ret != RET_OK) {
FI_HILOGE("Control failed, ret:%{public}d", ret);
}