diff --git a/services/sensor/BUILD.gn b/services/sensor/BUILD.gn index d18cd13b460ec32e414272ef3dc03e98c0e3102b..da1031c44a5e3782f817efc8306a5de35cfb0953 100644 --- a/services/sensor/BUILD.gn +++ b/services/sensor/BUILD.gn @@ -30,6 +30,7 @@ ohos_shared_library("libsensor_service") { "src/sensor_power_policy.cpp", "src/sensor_service.cpp", "src/sensor_service_stub.cpp", + "src/stream_server.cpp", ] include_dirs = [ diff --git a/services/sensor/include/client_info.h b/services/sensor/include/client_info.h index bf89eaaf6c3029eb01701bfb5579a4e957fde069..c6c020e318c0189c0224935c85feb049eba9f291 100644 --- a/services/sensor/include/client_info.h +++ b/services/sensor/include/client_info.h @@ -79,7 +79,7 @@ public: int32_t AddActiveInfoCBPid(int32_t pid); int32_t DelActiveInfoCBPid(int32_t pid); std::vector GetActiveInfoCBPid(); - bool IsUnregisterClientDeathRecipient(int32_t pid); + bool CallingService(int32_t pid); int32_t GetPidByTokenId(AccessTokenID tokenId); void UpdatePermState(int32_t pid, int32_t sensorId, bool state); void ChangeSensorPerm(AccessTokenID tokenId, const std::string &permName, bool state); diff --git a/services/sensor/include/sensor_service.h b/services/sensor/include/sensor_service.h index a0cdc9d042999e3263225f75fc3fae9f7bc5876c..2c949b55fc268cd1d94aaf5d4e5dccfbe4260e14 100644 --- a/services/sensor/include/sensor_service.h +++ b/services/sensor/include/sensor_service.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -28,7 +28,9 @@ #include "sensor_data_event.h" #include "sensor_hdi_connection.h" #include "sensor_manager.h" +#include "sensor_power_policy.h" #include "sensor_service_stub.h" +#include "stream_server.h" namespace OHOS { namespace Sensors { @@ -37,7 +39,7 @@ enum class SensorServiceState { STATE_RUNNING, }; -class SensorService : public SystemAbility, public SensorServiceStub { +class SensorService : public SystemAbility, public StreamServer, public SensorServiceStub { DECLARE_SYSTEM_ABILITY(SensorService) public: @@ -54,6 +56,13 @@ public: const sptr &sensorClient) override; ErrCode DestroySensorChannel(sptr sensorClient) override; void ProcessDeathObserver(const wptr &object); + ErrCode SuspendSensors(int32_t pid); + ErrCode ResumeSensors(int32_t pid); + ErrCode GetActiveInfoList(int32_t pid, std::vector &activeInfoList); + ErrCode CreateSocketChannel(sptr sensorClient, int32_t &clientFd); + ErrCode DestroySocketChannel(sptr sensorClient); + ErrCode EnableActiveInfoCB(); + ErrCode DisableActiveInfoCB(); private: DISALLOW_COPY_AND_MOVE(SensorService); @@ -79,6 +88,7 @@ private: ErrCode DisableSensor(int32_t sensorId, int32_t pid); bool RegisterPermCallback(int32_t sensorId); void UnregisterPermCallback(); + void ReportActiveInfo(int32_t sensorId, int32_t pid); SensorServiceState state_; std::mutex serviceLock_; std::mutex sensorsMutex_; @@ -93,9 +103,12 @@ private: std::mutex uidLock_; // death recipient of sensor client sptr clientDeathObserver_ = nullptr; - std::shared_ptr permStateChangeCb_; + std::shared_ptr permStateChangeCb_ = nullptr; ErrCode SaveSubscriber(int32_t sensorId, int64_t samplingPeriodNs, int64_t maxReportDelayNs); + std::atomic_bool isReportActiveInfo_ = false; }; + +#define POWER_POLICY SensorPowerPolicy::GetInstance() } // namespace Sensors } // namespace OHOS #endif // SENSOR_SERVICE_H diff --git a/services/sensor/include/stream_server.h b/services/sensor/include/stream_server.h index ee32c2da26bacdeea586e935573d8b4fcc63a881..f0cf53026a106a82cd9d8b75f219e841df893028 100644 --- a/services/sensor/include/stream_server.h +++ b/services/sensor/include/stream_server.h @@ -37,11 +37,10 @@ public: int32_t AddSocketPairInfo(int32_t uid, int32_t pid, int32_t tokenType, int32_t &serverFd, int32_t &clientFd); protected: - bool AddSession(SessionPtr ses); + bool AddSession(SessionPtr sess); void DelSession(int32_t pid); - std::mutex idxPidMutex_; - std::map idxPidMap_; std::mutex sessionMutex_; + std::map idxPidMap_; std::map sessionsMap_; }; } // namespace Sensors diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index 495848bc1ccd28d86ddb52e337899dbaabc51c9c..d02a3a2687a5e811db973e32746519ee916de63f 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -725,7 +725,7 @@ std::vector ClientInfo::GetActiveInfoCBPid() return activeInfoCBPids; } -bool ClientInfo::IsUnregisterClientDeathRecipient(int32_t pid) +bool ClientInfo::CallingService(int32_t pid) { std::lock_guard channelLock(channelMutex_); auto channelIt = channelMap_.find(pid); diff --git a/services/sensor/src/flush_info_record.cpp b/services/sensor/src/flush_info_record.cpp index ec19f8f998e40d1dc3f96711c70129a0e32ef7e3..4953bb125ec0e71adbefe6187d86c37682110f20 100644 --- a/services/sensor/src/flush_info_record.cpp +++ b/services/sensor/src/flush_info_record.cpp @@ -24,11 +24,6 @@ using namespace OHOS::HiviewDFX; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "FlushInfoRecord" }; constexpr int32_t CHANNEL_NO_FLUSH = -1; -enum { - FLUSH = 0, - SET_MODE, - RESERVED, -}; } // namespace std::unordered_map> FlushInfoRecord::GetFlushInfo() diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index acdd63d9404346257929fc72dc6232863c2353fe..7df0bb9352309b52c9434b93db5e2d7d8c512e01 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * 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 @@ -32,18 +32,12 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; - namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorService" }; constexpr int32_t INVALID_SENSOR_ID = -1; constexpr int32_t INVALID_PID = -1; constexpr int64_t MAX_EVENT_COUNT = 1000; std::atomic_bool g_isRegister = false; -enum { - FLUSH = 0, - SET_MODE, - RESERVED, -}; } // namespace REGISTER_SYSTEM_ABILITY_BY_ID(SensorService, SENSOR_SERVICE_ABILITY_ID, true); @@ -232,6 +226,9 @@ ErrCode SensorService::EnableSensor(int32_t sensorId, int64_t samplingPeriodNs, SEN_HILOGE("ret : %{public}d", ret); } ReportOnChangeData(sensorId); + if (isReportActiveInfo_) { + ReportActiveInfo(sensorId, pid); + } return ERR_OK; } auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs); @@ -250,6 +247,9 @@ ErrCode SensorService::EnableSensor(int32_t sensorId, int64_t samplingPeriodNs, g_isRegister = true; } ReportSensorSysEvent(sensorId, true, pid); + if (isReportActiveInfo_) { + ReportActiveInfo(sensorId, pid); + } return ret; } @@ -359,6 +359,8 @@ void SensorService::ProcessDeathObserver(const wptr &object) SEN_HILOGE("disablesensor failed, ret:%{public}d", ret); } } + DelSession(pid); + clientInfo_.DelActiveInfoCBPid(pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); clientInfo_.DestroyCmd(clientInfo_.GetUidByPid(pid)); @@ -377,6 +379,15 @@ void SensorService::RegisterClientDeathRecipient(sptr sensorClien void SensorService::UnregisterClientDeathRecipient(sptr sensorClient) { CALL_LOG_ENTER; + int32_t pid = clientInfo_.FindClientPid(sensorClient); + if (pid == INVALID_PID) { + SEN_HILOGE("Pid is invalid"); + return; + } + if (!clientInfo_.CallingService(pid)) { + SEN_HILOGD("Cannot unregister client death recipient"); + return; + } sptr client = iface_cast(sensorClient); clientDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); CHKPV(clientDeathObserver_); @@ -407,6 +418,93 @@ int32_t SensorService::Dump(int32_t fd, const std::vector &args) return ERR_OK; } +ErrCode SensorService::SuspendSensors(int32_t pid) +{ + CALL_LOG_ENTER; + if (pid < 0) { + SEN_HILOGE("Pid is invalid"); + return CLIENT_PID_INVALID_ERR; + } + return POWER_POLICY.SuspendSensors(pid); +} + +ErrCode SensorService::ResumeSensors(int32_t pid) +{ + CALL_LOG_ENTER; + if (pid < 0) { + SEN_HILOGE("Pid is invalid"); + return CLIENT_PID_INVALID_ERR; + } + return POWER_POLICY.ResumeSensors(pid); +} + +ErrCode SensorService::GetActiveInfoList(int32_t pid, std::vector &activeInfoList) +{ + CALL_LOG_ENTER; + if (pid < 0) { + SEN_HILOGE("Pid is invalid"); + return CLIENT_PID_INVALID_ERR; + } + activeInfoList = POWER_POLICY.GetActiveInfoList(pid); + return ERR_OK; +} + +ErrCode SensorService::CreateSocketChannel(sptr sensorClient, int32_t &clientFd) +{ + CALL_LOG_ENTER; + CHKPR(sensorClient, INVALID_POINTER); + int32_t serverFd = -1; + int32_t ret = AddSocketPairInfo(GetCallingUid(), GetCallingPid(), + AccessTokenKit::GetTokenTypeFlag(GetCallingTokenID()), + serverFd, std::ref(clientFd)); + if (ret != ERR_OK) { + SEN_HILOGE("Add socket pair info failed, ret:%{public}d", ret); + return ret; + } + RegisterClientDeathRecipient(sensorClient, GetCallingPid()); + return ERR_OK; +} + +ErrCode SensorService::DestroySocketChannel(sptr sensorClient) +{ + CALL_LOG_ENTER; + CHKPR(sensorClient, INVALID_POINTER); + DelSession(GetCallingPid()); + UnregisterClientDeathRecipient(sensorClient); + return ERR_OK; +} + +ErrCode SensorService::EnableActiveInfoCB() +{ + CALL_LOG_ENTER; + isReportActiveInfo_ = true; + return clientInfo_.AddActiveInfoCBPid(GetCallingPid()); +} + +ErrCode SensorService::DisableActiveInfoCB() +{ + CALL_LOG_ENTER; + isReportActiveInfo_ = false; + return clientInfo_.DelActiveInfoCBPid(GetCallingPid()); +} + +void SensorService::ReportActiveInfo(int32_t sensorId, int32_t pid) +{ + CALL_LOG_ENTER; + std::vector sessionList; + auto pidList = clientInfo_.GetActiveInfoCBPid(); + for (const auto &pid : pidList) { + auto sess = GetSessionByPid(pid); + if (sess != nullptr) { + sessionList.push_back(sess); + } + } + SensorBasicInfo sensorInfo = clientInfo_.GetCurPidSensorInfo(sensorId, pid); + ActiveInfo activeInfo(pid, sensorId, sensorInfo.GetSamplingPeriodNs(), + sensorInfo.GetMaxReportDelayNs()); + POWER_POLICY.ReportActiveInfo(activeInfo, sessionList); +} + bool SensorService::RegisterPermCallback(int32_t sensorId) { CALL_LOG_ENTER; diff --git a/services/sensor/src/stream_server.cpp b/services/sensor/src/stream_server.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a749cbdd55600ac96190ac45a1e858a9570a53bf --- /dev/null +++ b/services/sensor/src/stream_server.cpp @@ -0,0 +1,196 @@ +/* + * 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. + */ + +#include "stream_server.h" + +#include + +#include + +#include "sensors_errors.h" + +namespace OHOS { +namespace Sensors { +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "StreamServer" }; +constexpr int32_t INVALID_PID = -1; +constexpr int32_t INVALID_FD = -1; +} // namespace + +StreamServer::~StreamServer() +{ + CALL_LOG_ENTER; + std::lock_guard sessionLock(sessionMutex_); + idxPidMap_.clear(); + for (const auto &item : sessionsMap_) { + item.second->Close(); + } + sessionsMap_.clear(); +} + +bool StreamServer::SendMsg(int32_t fd, const NetPacket& pkt) +{ + CALL_LOG_ENTER; + if (fd < 0) { + SEN_HILOGE("Fd is invalid"); + return false; + } + auto sess = GetSession(fd); + if (sess == nullptr) { + SEN_HILOGE("sess is nullptr"); + return false; + } + return sess->SendMsg(pkt); +} + +void StreamServer::Multicast(const std::vector& fdList, const NetPacket& pkt) +{ + CALL_LOG_ENTER; + for (const auto &item : fdList) { + SendMsg(item, pkt); + } +} + +int32_t StreamServer::GetClientFd(int32_t pid) +{ + std::lock_guard sessionLock(sessionMutex_); + auto it = idxPidMap_.find(pid); + return it == idxPidMap_.end() ? INVALID_FD : it->second; +} + +int32_t StreamServer::GetClientPid(int32_t fd) +{ + std::lock_guard sessionLock(sessionMutex_); + auto it = sessionsMap_.find(fd); + return it == sessionsMap_.end() ? INVALID_PID : it->second->GetPid(); +} + +SessionPtr StreamServer::GetSession(int32_t fd) +{ + std::lock_guard sessionLock(sessionMutex_); + auto it = sessionsMap_.find(fd); + if (it == sessionsMap_.end()) { + SEN_HILOGE("Session not found"); + return nullptr; + } + CHKPP(it->second); + return it->second->GetSharedPtr(); +} + +SessionPtr StreamServer::GetSessionByPid(int32_t pid) +{ + int32_t fd = GetClientFd(pid); + if (fd <= 0) { + SEN_HILOGE("Session not found"); + return nullptr; + } + return GetSession(fd); +} + +int32_t StreamServer::AddSocketPairInfo(int32_t uid, int32_t pid, int32_t tokenType, + int32_t &serverFd, int32_t &clientFd) +{ + CALL_LOG_ENTER; + int32_t sockFds[2] = { -1 }; + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockFds) != 0) { + SEN_HILOGE("Socketpair failed, errno:%{public}d", errno); + return ERROR; + } + serverFd = sockFds[0]; + clientFd = sockFds[1]; + if (serverFd < 0 || clientFd < 0) { + SEN_HILOGE("ServerFd or clientFd is invalid"); + return ERROR; + } + static constexpr size_t bufferSize = 32 * 1024; + SessionPtr sess = nullptr; + if (setsockopt(serverFd, SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize)) != 0) { + SEN_HILOGE("Setsockopt serverFd send buffer size failed, errno: %{public}d", errno); + goto CLOSE_SOCK; + } + if (setsockopt(serverFd, SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)) != 0) { + SEN_HILOGE("Setsockopt serverFd recv buffer size failed, errno: %{public}d", errno); + goto CLOSE_SOCK; + } + if (setsockopt(clientFd, SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize)) != 0) { + SEN_HILOGE("Setsockopt clientFd send buffer size failed, errno: %{public}d", errno); + goto CLOSE_SOCK; + } + if (setsockopt(clientFd, SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)) != 0) { + SEN_HILOGE("Setsockopt clientFd recv buffer size failed, errno: %{public}d", errno); + goto CLOSE_SOCK; + } + sess = std::make_shared("", serverFd, uid, pid); + sess->SetTokenType(tokenType); + if (!AddSession(sess)) { + SEN_HILOGE("AddSession fail"); + goto CLOSE_SOCK; + } + return ERR_OK; + +CLOSE_SOCK: + close(serverFd); + close(clientFd); + return ERROR; +} + +bool StreamServer::AddSession(SessionPtr sess) +{ + CALL_LOG_ENTER; + CHKPF(sess); + auto fd = sess->GetFd(); + if (fd < 0) { + SEN_HILOGE("Fd is Invalid"); + return false; + } + auto pid = sess->GetPid(); + if (pid <= 0) { + SEN_HILOGE("Pid is invalid"); + return false; + } + std::lock_guard sessionLock(sessionMutex_); + if (sessionsMap_.size() > MAX_SESSON_ALARM) { + SEN_HILOGE("Too many clients, size:%{public}zu", sessionsMap_.size()); + return false; + } + idxPidMap_[pid] = fd; + sessionsMap_[fd] = sess; + return true; +} + +void StreamServer::DelSession(int32_t pid) +{ + CALL_LOG_ENTER; + std::lock_guard sessionLock(sessionMutex_); + auto pidIt = idxPidMap_.find(pid); + if (pidIt == idxPidMap_.end()) { + SEN_HILOGW("Pid session not exist"); + return; + } + int32_t fd = pidIt->second; + idxPidMap_.erase(pidIt); + auto fdIt = sessionsMap_.find(fd); + if (fdIt != sessionsMap_.end()) { + sessionsMap_.erase(fdIt); + } + if (fd >= 0) { + int32_t ret = close(fd); + if (ret != 0) { + SEN_HILOGE("Socket fd close failed, ret:%{public}d, errno:%{public}d", ret, errno); + } + } +} +} // namespace Sensors +} // namespace OHOS \ No newline at end of file diff --git a/utils/common/include/sensor_parcel.h b/utils/common/include/sensor_parcel.h new file mode 100644 index 0000000000000000000000000000000000000000..f2aaa0657ca21523abdd7676c26766385d34021c --- /dev/null +++ b/utils/common/include/sensor_parcel.h @@ -0,0 +1,160 @@ +/* + * 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 SENSOR_PARCEL_H +#define SENSOR_PARCEL_H + +#include "sensors_errors.h" + +namespace OHOS { +namespace Sensors { + +#define WRITEBOOL(parcel, data, ...) \ + do { \ + if (!(parcel).WriteBool(data)) { \ + SEN_HILOGE("Parcel writeBool "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEINT32(parcel, data, ...) \ + do { \ + if (!(parcel).WriteInt32(data)) { \ + SEN_HILOGE("Parcel writeInt32 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEINT64(parcel, data, ...) \ + do { \ + if (!(parcel).WriteInt64(data)) { \ + SEN_HILOGE("Parcel writeInt64 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEUINT32(parcel, data, ...) \ + do { \ + if (!(parcel).WriteUint32(data)) { \ + SEN_HILOGE("Parcel writeUint32 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEDOUBLE(parcel, data, ...) \ + do { \ + if (!(parcel).WriteDouble(data)) { \ + SEN_HILOGE("Parcel writeDouble "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITESTRING(parcel, data, ...) \ + do { \ + if (!(parcel).WriteString(data)) { \ + SEN_HILOGE("Parcel writeString "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITESTRING16(parcel, data, ...) \ + do { \ + if (!(parcel).WriteString16(data)) { \ + SEN_HILOGE("Parcel writeString16 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEREMOTEOBJECT(parcel, data, ...) \ + do { \ + if (!(parcel).WriteRemoteObject(data)) { \ + SEN_HILOGE("Parcel writeRemoteObject "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define WRITEUINT8VECTOR(parcel, data, ...) \ + do { \ + if (!(parcel).WriteUInt8Vector(data)) { \ + SEN_HILOGE("Parcel writeUInt8Vector "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READBOOL(parcel, data, ...) \ + do { \ + if (!(parcel).ReadBool(data)) { \ + SEN_HILOGE("Parcel readBool "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READINT32(parcel, data, ...) \ + do { \ + if (!(parcel).ReadInt32(data)) { \ + SEN_HILOGE("Parcel readInt32 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READINT64(parcel, data, ...) \ + do { \ + if (!(parcel).ReadInt64(data)) { \ + SEN_HILOGE("Parcel readInt64 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READUINT32(parcel, data, ...) \ + do { \ + if (!(parcel).ReadUint32(data)) { \ + SEN_HILOGE("Parcel readUint32 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READDOUBLE(parcel, data, ...) \ + do { \ + if (!(parcel).ReadDouble(data)) { \ + SEN_HILOGE("Parcel readDouble "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READSTRING(parcel, data, ...) \ + do { \ + if (!(parcel).ReadString(data)) { \ + SEN_HILOGE("Parcel readString "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READUINT8VECTOR(parcel, data, ...) \ + do { \ + if (!(parcel).ReadUInt8Vector(&data)) { \ + SEN_HILOGE("Parcel readUInt8Vector "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define READSTRING16(parcel, data, ...) \ + do { \ + if (!(parcel).ReadString16(data)) { \ + SEN_HILOGE("Parcel readString16 "#data" failed"); \ + return __VA_ARGS__; \ + } \ + } while (0) +} // namespace Sensors +} // namespace OHOS +#endif // SENSOR_PARCEL_H \ No newline at end of file diff --git a/utils/ipc/src/stream_buffer.cpp b/utils/ipc/src/stream_buffer.cpp index 6b9fe1de5c96962b9efda84ea4efb3e5a8028d65..e666585c20d118f34899617c002006c9a00f2729 100644 --- a/utils/ipc/src/stream_buffer.cpp +++ b/utils/ipc/src/stream_buffer.cpp @@ -15,9 +15,6 @@ #include "stream_buffer.h" -#include -#include - namespace OHOS { namespace Sensors { StreamBuffer::StreamBuffer(const StreamBuffer &buf)