Signed-off-by:lcaidm<lichen139@huawei.com>

Signed-off-by: lcaidm <lichen139@huawei.com>
This commit is contained in:
lcaidm 2023-06-27 14:25:33 +08:00
parent ab15e547a8
commit 075b43a2ed
5 changed files with 149 additions and 67 deletions

17
CODEOWNERS Normal file
View File

@ -0,0 +1,17 @@
/*
* 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.
*/
# any change to services/communication/base/msdp_ipc_interface_code.h needs to be reviewed by @leonchan5
services/communication/base/msdp_ipc_interface_code.h @leonchan5

View File

@ -19,6 +19,7 @@
#include <iremote_broker.h>
#include "drag_data.h"
#include "msdp_ipc_interface_code.h"
#include "stationary_callback.h"
#include "stationary_data.h"
@ -27,30 +28,6 @@ namespace Msdp {
namespace DeviceStatus {
class Idevicestatus : public IRemoteBroker {
public:
enum {
DEVICESTATUS_SUBSCRIBE = 0,
DEVICESTATUS_UNSUBSCRIBE,
DEVICESTATUS_GETCACHE,
REGISTER_COORDINATION_MONITOR = 10,
UNREGISTER_COORDINATION_MONITOR,
PREPARE_COORDINATION,
UNPREPARE_COORDINATION,
START_COORDINATION,
STOP_COORDINATION,
GET_COORDINATION_STATE,
UPDATED_DRAG_STYLE = 20,
START_DRAG,
STOP_DRAG,
GET_DRAG_TARGET_PID,
GET_DRAG_TARGET_UDKEY,
REGISTER_DRAG_MONITOR,
UNREGISTER_DRAG_MONITOR,
SET_DRAG_WINDOW_VISIBLE,
GET_SHADOW_OFFSET,
UPDATE_SHADOW_PIC,
ALLOC_SOCKET_FD = 40
};
virtual void Subscribe(Type type,
ActivityEvent event,
ReportLatencyNs latency,

View File

@ -0,0 +1,47 @@
/*
* 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.
*/
#ifndef MSDP_IPC_INTERFACE_CODE_H
#define MSDP_IPC_INTERFACE_CODE_H
/* SAID:2902 */
namespace OHOS {
namespace Msdp {
enum class DeviceInterfaceCode {
DEVICESTATUS_SUBSCRIBE = 0,
DEVICESTATUS_UNSUBSCRIBE,
DEVICESTATUS_GETCACHE,
REGISTER_COORDINATION_MONITOR = 10,
UNREGISTER_COORDINATION_MONITOR,
PREPARE_COORDINATION,
UNPREPARE_COORDINATION,
START_COORDINATION,
STOP_COORDINATION,
GET_COORDINATION_STATE,
UPDATED_DRAG_STYLE = 20,
START_DRAG,
STOP_DRAG,
GET_DRAG_TARGET_PID,
GET_DRAG_TARGET_UDKEY,
REGISTER_DRAG_MONITOR,
UNREGISTER_DRAG_MONITOR,
SET_DRAG_WINDOW_VISIBLE,
GET_SHADOW_OFFSET,
UPDATE_SHADOW_PIC,
ALLOC_SOCKET_FD = 40
};
} // namespace Msdp
} // namespace OHOS
#endif // MSDP_IPC_INTERFACE_CODE_H

View File

@ -54,7 +54,8 @@ void DeviceStatusSrvProxy::Subscribe(Type type, ActivityEvent event, ReportLaten
WRITEINT32(data, latency);
WRITEREMOTEOBJECT(data, callback->AsObject());
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_SUBSCRIBE), data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_SUBSCRIBE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
return;
@ -82,7 +83,7 @@ void DeviceStatusSrvProxy::Unsubscribe(Type type, ActivityEvent event, sptr<IRem
WRITEINT32(data, event);
WRITEREMOTEOBJECT(data, callback->AsObject());
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_UNSUBSCRIBE),
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_UNSUBSCRIBE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
@ -111,7 +112,8 @@ Data DeviceStatusSrvProxy::GetCache(const Type& type)
WRITEINT32(data, type, devicestatusData);
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_GETCACHE), data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_GETCACHE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
return devicestatusData;
@ -139,7 +141,8 @@ int32_t DeviceStatusSrvProxy::RegisterCoordinationListener()
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(REGISTER_COORDINATION_MONITOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -158,7 +161,8 @@ int32_t DeviceStatusSrvProxy::UnregisterCoordinationListener()
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(UNREGISTER_COORDINATION_MONITOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COORDINATION_MONITOR),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -178,7 +182,8 @@ int32_t DeviceStatusSrvProxy::PrepareCoordination(int32_t userData)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(PREPARE_COORDINATION, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COORDINATION),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -198,7 +203,8 @@ int32_t DeviceStatusSrvProxy::UnprepareCoordination(int32_t userData)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(UNPREPARE_COORDINATION, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COORDINATION),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -221,7 +227,8 @@ int32_t DeviceStatusSrvProxy::ActivateCoordination(int32_t userData, const std::
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(START_COORDINATION, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::START_COORDINATION),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -242,7 +249,8 @@ int32_t DeviceStatusSrvProxy::DeactivateCoordination(int32_t userData, bool isUn
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(STOP_COORDINATION, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::STOP_COORDINATION),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -262,7 +270,8 @@ int32_t DeviceStatusSrvProxy::UpdateDragStyle(DragCursorStyle style)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(UPDATED_DRAG_STYLE, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UPDATED_DRAG_STYLE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -281,7 +290,8 @@ int32_t DeviceStatusSrvProxy::GetDragTargetPid()
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(GET_DRAG_TARGET_PID, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_PID),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
return RET_ERR;
@ -303,7 +313,8 @@ int32_t DeviceStatusSrvProxy::GetUdKey(std::string &udKey)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(GET_DRAG_TARGET_UDKEY, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_UDKEY),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
return RET_ERR;
@ -326,7 +337,8 @@ int32_t DeviceStatusSrvProxy::GetCoordinationState(int32_t userData, const std::
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(GET_COORDINATION_STATE, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -361,7 +373,8 @@ int32_t DeviceStatusSrvProxy::StartDrag(const DragData &dragData)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(START_DRAG, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -387,7 +400,8 @@ int32_t DeviceStatusSrvProxy::StopDrag(DragResult result, bool hasCustomAnimatio
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(STOP_DRAG, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::STOP_DRAG),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}
@ -410,7 +424,8 @@ int32_t DeviceStatusSrvProxy::AllocSocketFd(const std::string &programName, int3
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(ALLOC_SOCKET_FD, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request failed, ret:%{public}d", ret);
return RET_ERR;
@ -437,7 +452,8 @@ int32_t DeviceStatusSrvProxy::AddDraglistener()
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(REGISTER_DRAG_MONITOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_DRAG_MONITOR),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request failed, ret:%{public}d", ret);
}
@ -456,7 +472,8 @@ int32_t DeviceStatusSrvProxy::RemoveDraglistener()
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(UNREGISTER_DRAG_MONITOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_DRAG_MONITOR),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request failed, ret:%{public}d", ret);
}
@ -476,7 +493,8 @@ int32_t DeviceStatusSrvProxy::SetDragWindowVisible(bool visible)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(SET_DRAG_WINDOW_VISIBLE, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::SET_DRAG_WINDOW_VISIBLE),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request failed, ret:%{public}d", ret);
}
@ -495,7 +513,8 @@ int32_t DeviceStatusSrvProxy::GetShadowOffset(int32_t& offsetX, int32_t& offsetY
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(GET_SHADOW_OFFSET, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_SHADOW_OFFSET),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request failed, ret:%{public}d", ret);
}
@ -527,7 +546,8 @@ int32_t DeviceStatusSrvProxy::UpdateShadowPic(const ShadowInfo &shadowInfo)
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, RET_ERR);
int32_t ret = remote->SendRequest(UPDATE_SHADOW_PIC, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_SHADOW_PIC),
data, reply, option);
if (ret != RET_OK) {
FI_HILOGE("Send request fail, ret:%{public}d", ret);
}

View File

@ -46,28 +46,49 @@ int32_t DeviceStatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
FI_HILOGE("DeviceStatusSrvStub::OnRemoteRequest failed, descriptor is not matched");
return E_DEVICESTATUS_GET_SERVICE_FAILED;
}
const std::map<int32_t, ConnFunc> mapConnFunc = {
{Idevicestatus::DEVICESTATUS_SUBSCRIBE, &DeviceStatusSrvStub::SubscribeStub},
{Idevicestatus::DEVICESTATUS_UNSUBSCRIBE, &DeviceStatusSrvStub::UnsubscribeStub},
{Idevicestatus::DEVICESTATUS_GETCACHE, &DeviceStatusSrvStub::GetLatestDeviceStatusDataStub},
{Idevicestatus::REGISTER_COORDINATION_MONITOR, &DeviceStatusSrvStub::RegisterCoordinationMonitorStub},
{Idevicestatus::UNREGISTER_COORDINATION_MONITOR, &DeviceStatusSrvStub::UnregisterCoordinationMonitorStub},
{Idevicestatus::PREPARE_COORDINATION, &DeviceStatusSrvStub::PrepareCoordinationStub},
{Idevicestatus::UNPREPARE_COORDINATION, &DeviceStatusSrvStub::UnPrepareCoordinationStub},
{Idevicestatus::START_COORDINATION, &DeviceStatusSrvStub::ActivateCoordinationStub},
{Idevicestatus::STOP_COORDINATION, &DeviceStatusSrvStub::DeactivateCoordinationStub},
{Idevicestatus::GET_COORDINATION_STATE, &DeviceStatusSrvStub::GetCoordinationStateStub},
{Idevicestatus::ALLOC_SOCKET_FD, &DeviceStatusSrvStub::HandleAllocSocketFdStub},
{Idevicestatus::START_DRAG, &DeviceStatusSrvStub::StartDragStub},
{Idevicestatus::STOP_DRAG, &DeviceStatusSrvStub::StopDragStub},
{Idevicestatus::UPDATED_DRAG_STYLE, &DeviceStatusSrvStub::UpdateDragStyleStub},
{Idevicestatus::GET_DRAG_TARGET_PID, &DeviceStatusSrvStub::GetDragTargetPidStub},
{Idevicestatus::GET_DRAG_TARGET_UDKEY, &DeviceStatusSrvStub::GetUdKeyStub},
{Idevicestatus::REGISTER_DRAG_MONITOR, &DeviceStatusSrvStub::AddDraglistenerStub},
{Idevicestatus::UNREGISTER_DRAG_MONITOR, &DeviceStatusSrvStub::RemoveDraglistenerStub},
{Idevicestatus::SET_DRAG_WINDOW_VISIBLE, &DeviceStatusSrvStub::SetDragWindowVisibleStub},
{Idevicestatus::GET_SHADOW_OFFSET, &DeviceStatusSrvStub::GetShadowOffsetStub},
{Idevicestatus::UPDATE_SHADOW_PIC, &DeviceStatusSrvStub::UpdateShadowPicStub}
const std::map<uint32_t, ConnFunc> mapConnFunc = {
{static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_SUBSCRIBE),
&DeviceStatusSrvStub::SubscribeStub},
{static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_UNSUBSCRIBE),
&DeviceStatusSrvStub::UnsubscribeStub},
{static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_GETCACHE),
&DeviceStatusSrvStub::GetLatestDeviceStatusDataStub},
{static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
&DeviceStatusSrvStub::RegisterCoordinationMonitorStub},
{static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COORDINATION_MONITOR),
&DeviceStatusSrvStub::UnregisterCoordinationMonitorStub},
{static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COORDINATION),
&DeviceStatusSrvStub::PrepareCoordinationStub},
{static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COORDINATION),
&DeviceStatusSrvStub::UnPrepareCoordinationStub},
{static_cast<uint32_t>(DeviceInterfaceCode::START_COORDINATION),
&DeviceStatusSrvStub::ActivateCoordinationStub},
{static_cast<uint32_t>(DeviceInterfaceCode::STOP_COORDINATION),
&DeviceStatusSrvStub::DeactivateCoordinationStub},
{static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE),
&DeviceStatusSrvStub::GetCoordinationStateStub},
{static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
&DeviceStatusSrvStub::HandleAllocSocketFdStub},
{static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
&DeviceStatusSrvStub::StartDragStub},
{static_cast<uint32_t>(DeviceInterfaceCode::STOP_DRAG),
&DeviceStatusSrvStub::StopDragStub},
{static_cast<uint32_t>(DeviceInterfaceCode::UPDATED_DRAG_STYLE),
&DeviceStatusSrvStub::UpdateDragStyleStub},
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_PID),
&DeviceStatusSrvStub::GetDragTargetPidStub},
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_UDKEY),
&DeviceStatusSrvStub::GetUdKeyStub},
{static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_DRAG_MONITOR),
&DeviceStatusSrvStub::AddDraglistenerStub},
{static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_DRAG_MONITOR),
&DeviceStatusSrvStub::RemoveDraglistenerStub},
{static_cast<uint32_t>(DeviceInterfaceCode::SET_DRAG_WINDOW_VISIBLE),
&DeviceStatusSrvStub::SetDragWindowVisibleStub},
{static_cast<uint32_t>(DeviceInterfaceCode::GET_SHADOW_OFFSET),
&DeviceStatusSrvStub::GetShadowOffsetStub},
{static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_SHADOW_PIC),
&DeviceStatusSrvStub::UpdateShadowPicStub}
};
auto it = mapConnFunc.find(code);
if (it != mapConnFunc.end()) {