From 72306db72d970794058a7b98fd6734061c43084b Mon Sep 17 00:00:00 2001 From: h00514358 Date: Wed, 8 Jun 2022 16:17:05 +0800 Subject: [PATCH 1/3] Modify sensor worning Signed-off-by: h00514358 --- .../sensor/src/sensor_service_proxy.cpp | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_service_proxy.cpp b/frameworks/native/sensor/src/sensor_service_proxy.cpp index 459cca58..db72b5c2 100755 --- a/frameworks/native/sensor/src/sensor_service_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_service_proxy.cpp @@ -61,7 +61,9 @@ ErrCode SensorServiceProxy::EnableSensor(uint32_t sensorId, int64_t samplingPeri SEN_HILOGE("write maxReportDelayNs failed"); return WRITE_MSG_ERR; } - int32_t ret = Remote()->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "EnableSensor", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -82,7 +84,9 @@ ErrCode SensorServiceProxy::DisableSensor(uint32_t sensorId) SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } - int32_t ret = Remote()->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DisableSensor", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -103,7 +107,9 @@ int32_t SensorServiceProxy::GetSensorState(uint32_t sensorId) SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } - int32_t ret = Remote()->SendRequest(ISensorService::GET_SENSOR_STATE, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_STATE, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorState", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -136,7 +142,9 @@ ErrCode SensorServiceProxy::RunCommand(uint32_t sensorId, uint32_t cmdType, uint SEN_HILOGE("write params failed"); return WRITE_MSG_ERR; } - int32_t ret = Remote()->SendRequest(ISensorService::RUN_COMMAND, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::RUN_COMMAND, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "RunCommand", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -154,7 +162,9 @@ std::vector SensorServiceProxy::GetSensorList() SEN_HILOGE("write descriptor failed"); return sensors; } - int32_t ret = Remote()->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorList", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -194,7 +204,9 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptrSendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "TransferDataChannel", ret); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -217,7 +229,9 @@ ErrCode SensorServiceProxy::DestroySensorChannel(sptr sensorClien SEN_HILOGE("write sensorClient failed"); return WRITE_MSG_ERR; } - int32_t ret = Remote()->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option); + auto remote = Remote(); + CHKPR(remote, INVALID_POINTER); + int32_t ret = remote->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DestroySensorChannel", ret); SEN_HILOGE("failed, ret : %{public}d", ret); -- Gitee From 17d0e66d8c54426af86abf29810e30d471c75b83 Mon Sep 17 00:00:00 2001 From: h00514358 Date: Wed, 8 Jun 2022 17:19:13 +0800 Subject: [PATCH 2/3] Modify sensor woring Signed-off-by: h00514358 --- .../native/sensor/src/sensor_service_proxy.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_service_proxy.cpp b/frameworks/native/sensor/src/sensor_service_proxy.cpp index db72b5c2..2ecc6219 100755 --- a/frameworks/native/sensor/src/sensor_service_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_service_proxy.cpp @@ -62,7 +62,7 @@ ErrCode SensorServiceProxy::EnableSensor(uint32_t sensorId, int64_t samplingPeri return WRITE_MSG_ERR; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "EnableSensor", ret); @@ -85,7 +85,7 @@ ErrCode SensorServiceProxy::DisableSensor(uint32_t sensorId) return WRITE_MSG_ERR; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DisableSensor", ret); @@ -108,7 +108,7 @@ int32_t SensorServiceProxy::GetSensorState(uint32_t sensorId) return WRITE_MSG_ERR; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_STATE, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorState", ret); @@ -143,7 +143,7 @@ ErrCode SensorServiceProxy::RunCommand(uint32_t sensorId, uint32_t cmdType, uint return WRITE_MSG_ERR; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::RUN_COMMAND, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "RunCommand", ret); @@ -163,7 +163,10 @@ std::vector SensorServiceProxy::GetSensorList() return sensors; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + if (remote == nullptr) { + SEN_HILOGE("remote is null"); + return sensors; + } int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorList", ret); @@ -205,7 +208,7 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptrSendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "TransferDataChannel", ret); @@ -230,7 +233,7 @@ ErrCode SensorServiceProxy::DestroySensorChannel(sptr sensorClien return WRITE_MSG_ERR; } auto remote = Remote(); - CHKPR(remote, INVALID_POINTER); + CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DestroySensorChannel", ret); -- Gitee From cacc6f2f39fce4937d27d62a07bcbd5b77b0f2f8 Mon Sep 17 00:00:00 2001 From: h00514358 Date: Thu, 9 Jun 2022 09:30:10 +0800 Subject: [PATCH 3/3] Modify sensor woring Signed-off-by: h00514358 --- .../native/sensor/src/sensor_service_proxy.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_service_proxy.cpp b/frameworks/native/sensor/src/sensor_service_proxy.cpp index 2ecc6219..55c58306 100755 --- a/frameworks/native/sensor/src/sensor_service_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_service_proxy.cpp @@ -61,7 +61,7 @@ ErrCode SensorServiceProxy::EnableSensor(uint32_t sensorId, int64_t samplingPeri SEN_HILOGE("write maxReportDelayNs failed"); return WRITE_MSG_ERR; } - auto remote = Remote(); + sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { @@ -84,7 +84,7 @@ ErrCode SensorServiceProxy::DisableSensor(uint32_t sensorId) SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } - auto remote = Remote(); + sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { @@ -107,7 +107,7 @@ int32_t SensorServiceProxy::GetSensorState(uint32_t sensorId) SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } - auto remote = Remote(); + sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::GET_SENSOR_STATE, data, reply, option); if (ret != NO_ERROR) { @@ -142,7 +142,7 @@ ErrCode SensorServiceProxy::RunCommand(uint32_t sensorId, uint32_t cmdType, uint SEN_HILOGE("write params failed"); return WRITE_MSG_ERR; } - auto remote = Remote(); + sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::RUN_COMMAND, data, reply, option); if (ret != NO_ERROR) { @@ -162,7 +162,7 @@ std::vector SensorServiceProxy::GetSensorList() SEN_HILOGE("write descriptor failed"); return sensors; } - auto remote = Remote(); + sptr remote = Remote(); if (remote == nullptr) { SEN_HILOGE("remote is null"); return sensors; @@ -207,7 +207,7 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); if (ret != NO_ERROR) { @@ -232,7 +232,7 @@ ErrCode SensorServiceProxy::DestroySensorChannel(sptr sensorClien SEN_HILOGE("write sensorClient failed"); return WRITE_MSG_ERR; } - auto remote = Remote(); + sptr remote = Remote(); CHKPR(remote, ERROR); int32_t ret = remote->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option); if (ret != NO_ERROR) { -- Gitee