ipc code 标准化

Signed-off-by: hui1975 <zhaominghui10@huawei.com>
Change-Id: Iba9e26023333e4b417600a013aa58dd18a32c70a
This commit is contained in:
hui1975 2023-06-12 11:39:28 +00:00
parent 9f98c74f31
commit 442e11df21
5 changed files with 111 additions and 43 deletions

17
CODEOWNERS Normal file
View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2021-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 frameworks/native/sensor/include/sensors_ipc_interface_code.h needs to be reviewed by @leonchan5
frameworks/native/sensor/include/sensors_ipc_interface_code.h @leonchan5

View File

@ -23,6 +23,7 @@
#include "active_info.h"
#include "i_sensor_client.h"
#include "sensors_ipc_interface_code.h"
#include "sensor_basic_data_channel.h"
#include "sensor.h"
@ -48,23 +49,6 @@ public:
virtual ErrCode EnableActiveInfoCB() = 0;
virtual ErrCode DisableActiveInfoCB() = 0;
virtual ErrCode ResetSensors() = 0;
enum {
ENABLE_SENSOR = 0,
DISABLE_SENSOR,
GET_SENSOR_STATE,
RUN_COMMAND,
GET_SENSOR_LIST,
TRANSFER_DATA_CHANNEL,
DESTROY_SENSOR_CHANNEL,
SUSPEND_SENSORS,
RESUME_SENSORS,
GET_ACTIVE_INFO_LIST,
CREATE_SOCKET_CHANNEL,
DESTROY_SOCKET_CHANNEL,
ENABLE_ACTIVE_INFO_CB,
DISABLE_ACTIVE_INFO_CB,
RESET_SENSORS,
};
};
} // namespace Sensors
} // namespace OHOS

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.
*/
#ifndef SENSORS_IPC_INTERFACE_CODE_H
#define SENSORS_IPC_INTERFACE_CODE_H
/* SAID:3601 */
namespace OHOS {
namespace Sensors {
enum class SensorInterfaceCode{
ENABLE_SENSOR = 0,
DISABLE_SENSOR,
GET_SENSOR_STATE,
RUN_COMMAND,
GET_SENSOR_LIST,
TRANSFER_DATA_CHANNEL,
DESTROY_SENSOR_CHANNEL,
SUSPEND_SENSORS,
RESUME_SENSORS,
GET_ACTIVE_INFO_LIST,
CREATE_SOCKET_CHANNEL,
DESTROY_SOCKET_CHANNEL,
ENABLE_ACTIVE_INFO_CB,
DISABLE_ACTIVE_INFO_CB,
RESET_SENSORS,
};
} // namespace Sensors
} // namespace OHOS
#endif // SENSORS_IPC_INTERFACE_CODE_H

View File

@ -49,7 +49,8 @@ ErrCode SensorServiceProxy::EnableSensor(int32_t sensorId, int64_t samplingPerio
WRITEINT64(data, maxReportDelayNs, WRITE_PARCEL_ERR);
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, ERROR);
int32_t ret = remote->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::ENABLE_SENSOR),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "EnableSensor", "ERROR_CODE", ret);
@ -70,7 +71,8 @@ ErrCode SensorServiceProxy::DisableSensor(int32_t sensorId)
WRITEINT32(data, sensorId, WRITE_PARCEL_ERR);
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, ERROR);
int32_t ret = remote->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::DISABLE_SENSOR),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "DisableSensor", "ERROR_CODE", ret);
@ -94,7 +96,8 @@ std::vector<Sensor> SensorServiceProxy::GetSensorList()
SEN_HILOGE("remote is null");
return sensors;
}
int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::GET_SENSOR_LIST),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "GetSensorList", "ERROR_CODE", ret);
@ -135,7 +138,8 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptr<SensorBasicDataChanne
WRITEREMOTEOBJECT(data, sensorClient, WRITE_PARCEL_ERR);
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, ERROR);
int32_t ret = remote->SendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::TRANSFER_DATA_CHANNEL),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "TransferDataChannel", "ERROR_CODE", ret);
@ -158,7 +162,8 @@ ErrCode SensorServiceProxy::DestroySensorChannel(sptr<IRemoteObject> sensorClien
WRITEREMOTEOBJECT(data, sensorClient, WRITE_PARCEL_ERR);
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, ERROR);
int32_t ret = remote->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::DESTROY_SENSOR_CHANNEL),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroySensorChannel", "ERROR_CODE", ret);
@ -179,7 +184,8 @@ ErrCode SensorServiceProxy::SuspendSensors(int32_t pid)
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::SUSPEND_SENSORS, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::SUSPEND_SENSORS),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SENSOR_SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "SuspendSensors", "ERROR_CODE", ret);
@ -200,7 +206,8 @@ ErrCode SensorServiceProxy::ResumeSensors(int32_t pid)
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::RESUME_SENSORS, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::RESUME_SENSORS),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SENSOR_SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "ResumeSensors", "ERROR_CODE", ret);
@ -221,7 +228,8 @@ ErrCode SensorServiceProxy::GetActiveInfoList(int32_t pid, std::vector<ActiveInf
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::GET_ACTIVE_INFO_LIST, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::GET_ACTIVE_INFO_LIST),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SENSOR_SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "GetActiveInfoList", "ERROR_CODE", ret);
@ -256,7 +264,8 @@ ErrCode SensorServiceProxy::CreateSocketChannel(sptr<IRemoteObject> sensorClient
MessageOption option;
sptr<IRemoteObject> remote = Remote();
CHKPR(remote, ERROR);
int32_t ret = remote->SendRequest(ISensorService::CREATE_SOCKET_CHANNEL, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::CREATE_SOCKET_CHANNEL),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "CreateSocketChannel", "ERROR_CODE", ret);
@ -284,7 +293,8 @@ ErrCode SensorServiceProxy::DestroySocketChannel(sptr<IRemoteObject> sensorClien
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::DESTROY_SOCKET_CHANNEL, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::DESTROY_SOCKET_CHANNEL),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroySocketChannel", "ERROR_CODE", ret);
@ -304,7 +314,8 @@ ErrCode SensorServiceProxy::EnableActiveInfoCB()
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::ENABLE_ACTIVE_INFO_CB, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::ENABLE_ACTIVE_INFO_CB),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "EnableActiveInfoCB", "ERROR_CODE", ret);
@ -324,7 +335,8 @@ ErrCode SensorServiceProxy::DisableActiveInfoCB()
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::DISABLE_ACTIVE_INFO_CB, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::DISABLE_ACTIVE_INFO_CB),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "DisableActiveInfoCB", "ERROR_CODE", ret);
@ -344,7 +356,8 @@ ErrCode SensorServiceProxy::ResetSensors()
CHKPR(remote, ERROR);
MessageParcel reply;
MessageOption option;
int32_t ret = remote->SendRequest(ISensorService::RESET_SENSORS, data, reply, option);
int32_t ret = remote->SendRequest(static_cast<uint32_t>(SensorInterfaceCode::RESET_SENSORS),
data, reply, option);
if (ret != NO_ERROR) {
HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION",
HiSysEvent::EventType::FAULT, "PKG_NAME", "ResetSensors", "ERROR_CODE", ret);

View File

@ -38,19 +38,32 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorServiceStub"
SensorServiceStub::SensorServiceStub()
{
CALL_LOG_ENTER;
baseFuncs_[ENABLE_SENSOR] = &SensorServiceStub::SensorEnableInner;
baseFuncs_[DISABLE_SENSOR] = &SensorServiceStub::SensorDisableInner;
baseFuncs_[GET_SENSOR_LIST] = &SensorServiceStub::GetAllSensorsInner;
baseFuncs_[TRANSFER_DATA_CHANNEL] = &SensorServiceStub::CreateDataChannelInner;
baseFuncs_[DESTROY_SENSOR_CHANNEL] = &SensorServiceStub::DestroyDataChannelInner;
baseFuncs_[SUSPEND_SENSORS] = &SensorServiceStub::SuspendSensorsInner;
baseFuncs_[RESUME_SENSORS] = &SensorServiceStub::ResumeSensorsInner;
baseFuncs_[GET_ACTIVE_INFO_LIST] = &SensorServiceStub::GetActiveInfoListInner;
baseFuncs_[CREATE_SOCKET_CHANNEL] = &SensorServiceStub::CreateSocketChannelInner;
baseFuncs_[DESTROY_SOCKET_CHANNEL] = &SensorServiceStub::DestroySocketChannelInner;
baseFuncs_[ENABLE_ACTIVE_INFO_CB] = &SensorServiceStub::EnableActiveInfoCBInner;
baseFuncs_[DISABLE_ACTIVE_INFO_CB] = &SensorServiceStub::DisableActiveInfoCBInner;
baseFuncs_[RESET_SENSORS] = &SensorServiceStub::ResetSensorsInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::ENABLE_SENSOR)] =
&SensorServiceStub::SensorEnableInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::DISABLE_SENSOR)] =
&SensorServiceStub::SensorDisableInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::GET_SENSOR_STATE)] =
&SensorServiceStub::GetAllSensorsInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::TRANSFER_DATA_CHANNEL)] =
&SensorServiceStub::CreateDataChannelInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::DESTROY_SENSOR_CHANNEL)] =
&SensorServiceStub::DestroyDataChannelInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::SUSPEND_SENSORS)] =
&SensorServiceStub::SuspendSensorsInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::RESUME_SENSORS)] =
&SensorServiceStub::ResumeSensorsInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::GET_ACTIVE_INFO_LIST)] =
&SensorServiceStub::GetActiveInfoListInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::CREATE_SOCKET_CHANNEL)] =
&SensorServiceStub::CreateSocketChannelInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::DESTROY_SOCKET_CHANNEL)] =
&SensorServiceStub::DestroySocketChannelInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::ENABLE_ACTIVE_INFO_CB)] =
&SensorServiceStub::EnableActiveInfoCBInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::DISABLE_ACTIVE_INFO_CB)] =
&SensorServiceStub::DisableActiveInfoCBInner;
baseFuncs_[static_cast<uint32_t>(SensorInterfaceCode::RESET_SENSORS)] =
&SensorServiceStub::ResetSensorsInner;
}
SensorServiceStub::~SensorServiceStub()