mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2025-02-19 23:32:28 +00:00
!243 modify define name
Merge pull request !243 from hhh2/lifenghui_1112
This commit is contained in:
commit
8f99ab5946
@ -48,8 +48,8 @@ int32_t DevicestatusCallbackStub::OnDevicestatusChangedStub(MessageParcel& data)
|
||||
DEV_HILOGD(SERVICE, "Enter");
|
||||
int32_t type;
|
||||
int32_t value;
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(data, Int32, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(data, Int32, value, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, value, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
DevicestatusDataUtils::DevicestatusData devicestatusData = {
|
||||
static_cast<DevicestatusDataUtils::DevicestatusType>(type),
|
||||
static_cast<DevicestatusDataUtils::DevicestatusValue>(value)
|
||||
|
@ -39,8 +39,8 @@ void DevicestatusCallbackProxy::OnDevicestatusChanged(const DevicestatusDataUtil
|
||||
return;
|
||||
}
|
||||
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, Int32, static_cast<int32_t>(devicestatusData.type));
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, Int32, static_cast<int32_t>(devicestatusData.value));
|
||||
WRITEINT32(data, static_cast<int32_t>(devicestatusData.type));
|
||||
WRITEINT32(data, static_cast<int32_t>(devicestatusData.value));
|
||||
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IdevicestatusCallback::DEVICESTATUS_CHANGE),
|
||||
data, reply, option);
|
||||
|
@ -44,8 +44,8 @@ void DevicestatusSrvProxy::Subscribe(const DevicestatusDataUtils::DevicestatusTy
|
||||
return;
|
||||
}
|
||||
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, Int32, type);
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, RemoteObject, callback->AsObject());
|
||||
WRITEINT32(data, type);
|
||||
WRITEREMOTEOBJECT(data, callback->AsObject());
|
||||
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_SUBSCRIBE), data, reply, option);
|
||||
if (ret != ERR_OK) {
|
||||
@ -73,8 +73,8 @@ void DevicestatusSrvProxy::UnSubscribe(const DevicestatusDataUtils::Devicestatus
|
||||
return;
|
||||
}
|
||||
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, Int32, type);
|
||||
DEVICESTATUS_WRITE_PARCEL_NO_RET(data, RemoteObject, callback->AsObject());
|
||||
WRITEINT32(data, type);
|
||||
WRITEREMOTEOBJECT(data, callback->AsObject());
|
||||
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_UNSUBSCRIBE),
|
||||
data, reply, option);
|
||||
@ -106,7 +106,7 @@ DevicestatusDataUtils::DevicestatusData DevicestatusSrvProxy::GetCache(const \
|
||||
return devicestatusData;
|
||||
}
|
||||
|
||||
DEVICESTATUS_WRITE_PARCEL_WITH_RET(data, Int32, type, devicestatusData);
|
||||
WRITEINT32(data, type, devicestatusData);
|
||||
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(Idevicestatus::DEVICESTATUS_GETCACHE), data, reply, option);
|
||||
if (ret != ERR_OK) {
|
||||
@ -116,8 +116,8 @@ DevicestatusDataUtils::DevicestatusData DevicestatusSrvProxy::GetCache(const \
|
||||
|
||||
int32_t devicestatusType = -1;
|
||||
int32_t devicestatusValue = -1;
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(reply, Int32, devicestatusType, devicestatusData);
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(reply, Int32, devicestatusValue, devicestatusData);
|
||||
READINT32(reply, devicestatusType, devicestatusData);
|
||||
READINT32(reply, devicestatusValue, devicestatusData);
|
||||
devicestatusData.type = DevicestatusDataUtils::DevicestatusType(devicestatusType);
|
||||
devicestatusData.value = DevicestatusDataUtils::DevicestatusValue(devicestatusValue);
|
||||
DEV_HILOGD(INNERKIT, "type: %{public}d, value: %{public}d", devicestatusData.type, devicestatusData.value);
|
||||
|
@ -57,7 +57,7 @@ int32_t DevicestatusSrvStub::SubscribeStub(MessageParcel& data)
|
||||
{
|
||||
DEV_HILOGD(SERVICE, "Enter");
|
||||
int32_t type = -1;
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(data, Int32, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
DEV_HILOGD(SERVICE, "Read type successfully");
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
DEVICESTATUS_RETURN_IF_WITH_RET((obj == nullptr), E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
@ -73,7 +73,7 @@ int32_t DevicestatusSrvStub::UnSubscribeStub(MessageParcel& data)
|
||||
{
|
||||
DEV_HILOGD(SERVICE, "Enter");
|
||||
int32_t type = -1;
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(data, Int32, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
DEVICESTATUS_RETURN_IF_WITH_RET((obj == nullptr), E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
sptr<IdevicestatusCallback> callback = iface_cast<IdevicestatusCallback>(obj);
|
||||
@ -86,12 +86,12 @@ int32_t DevicestatusSrvStub::GetLatestDevicestatusDataStub(MessageParcel& data,
|
||||
{
|
||||
DEV_HILOGD(SERVICE, "Enter");
|
||||
int32_t type = -1;
|
||||
DEVICESTATUS_READ_PARCEL_WITH_RET(data, Int32, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
|
||||
DevicestatusDataUtils::DevicestatusData devicestatusData = GetCache(DevicestatusDataUtils::DevicestatusType(type));
|
||||
DEV_HILOGD(SERVICE, "devicestatusData.type: %{public}d", devicestatusData.type);
|
||||
DEV_HILOGD(SERVICE, "devicestatusData.value: %{public}d", devicestatusData.value);
|
||||
DEVICESTATUS_WRITE_PARCEL_WITH_RET(reply, Int32, devicestatusData.type, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
|
||||
DEVICESTATUS_WRITE_PARCEL_WITH_RET(reply, Int32, devicestatusData.value, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
|
||||
WRITEINT32(reply, devicestatusData.type, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
|
||||
WRITEINT32(reply, devicestatusData.value, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
|
||||
DEV_HILOGD(SERVICE, "Exit");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -35,36 +35,108 @@ namespace DeviceStatus {
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
#define DEVICESTATUS_READ_PARCEL_NO_RET(parcel, type, out) \
|
||||
do { \
|
||||
if (!(parcel).Read##type(out)) { \
|
||||
DEV_HILOGE(COMMON, "%{public}s read "#out" failed", __func__); \
|
||||
return; \
|
||||
} \
|
||||
} while (0) \
|
||||
#define WRITEBOOL(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteBool(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteBool "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEVICESTATUS_WRITE_PARCEL_NO_RET(parcel, type, data) \
|
||||
do { \
|
||||
if (!(parcel).Write##type(data)) { \
|
||||
DEV_HILOGE(COMMON, "%{public}s write "#data" failed", __func__); \
|
||||
return; \
|
||||
} \
|
||||
} while (0) \
|
||||
#define WRITEINT32(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteInt32(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteInt32 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEVICESTATUS_READ_PARCEL_WITH_RET(parcel, type, out, retval) \
|
||||
do { \
|
||||
if (!(parcel).Read##type(out)) { \
|
||||
DEV_HILOGE(COMMON, "%{public}s read "#out" failed", __func__); \
|
||||
return (retval); \
|
||||
} \
|
||||
} while (0) \
|
||||
#define WRITEINT64(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteInt64(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteInt64 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEVICESTATUS_WRITE_PARCEL_WITH_RET(parcel, type, data, retval) \
|
||||
do { \
|
||||
if (!(parcel).Write##type(data)) { \
|
||||
DEV_HILOGE(COMMON, "%{public}s write "#data" failed", __func__); \
|
||||
return (retval); \
|
||||
} \
|
||||
#define WRITEUINT32(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteUint32(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteUint32 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITEDOUBLE(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteDouble(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteDouble "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITESTRING(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteString(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteString "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITEREMOTEOBJECT(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).WriteRemoteObject(data)) { \
|
||||
DEV_HILOGE(COMMON, "WriteRemoteObject "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READBOOL(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadBool(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadBool "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READINT32(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadInt32(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadInt32 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READINT64(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadInt64(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadInt64 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READUINT32(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadUint32(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadUint32 "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READDOUBLE(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadDouble(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadDouble "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READSTRING(parcel, data, ...) \
|
||||
do { \
|
||||
if (!(parcel).ReadString(data)) { \
|
||||
DEV_HILOGE(COMMON, "ReadString "#data" failed"); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
template<typename E>
|
||||
|
Loading…
x
Reference in New Issue
Block a user