diff --git a/frameworks/native/sensor/src/sensor_service_proxy.cpp b/frameworks/native/sensor/src/sensor_service_proxy.cpp index 459cca58633444004ec43608193fdb72e18fdb60..55c58306d2fdd483735e3604a276785c83863b5d 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); + sptr remote = Remote(); + 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); 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); + sptr remote = Remote(); + 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); 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); + sptr remote = Remote(); + 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); 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); + sptr remote = Remote(); + 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); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -154,7 +162,12 @@ std::vector SensorServiceProxy::GetSensorList() SEN_HILOGE("write descriptor failed"); return sensors; } - int32_t ret = Remote()->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option); + sptr remote = Remote(); + 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); SEN_HILOGE("failed, ret : %{public}d", ret); @@ -194,7 +207,9 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptrSendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); + sptr remote = Remote(); + CHKPR(remote, ERROR); + 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 +232,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); + sptr remote = Remote(); + 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); SEN_HILOGE("failed, ret : %{public}d", ret);