From 50342974eea48fa3ab279b5feb5b148bab113daa Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 29 Jan 2022 15:08:07 +0800 Subject: [PATCH 1/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- frameworks/native/sensor/BUILD.gn | 4 ++-- .../sensor/include/sensor_data_channel.h | 4 ++-- ..._event_handler.h => sensor_event_handler.h} | 12 ++++++------ ...ptor_listener.h => sensor_event_listener.h} | 12 ++++++------ .../native/sensor/src/sensor_data_channel.cpp | 8 ++++---- ...nt_handler.cpp => sensor_event_handler.cpp} | 6 +++--- ..._listener.cpp => sensor_event_listener.cpp} | 18 +++++++++--------- 7 files changed, 32 insertions(+), 32 deletions(-) mode change 100755 => 100644 frameworks/native/sensor/include/sensor_data_channel.h rename frameworks/native/sensor/include/{my_event_handler.h => sensor_event_handler.h} (75%) mode change 100755 => 100644 rename frameworks/native/sensor/include/{my_file_descriptor_listener.h => sensor_event_listener.h} (80%) mode change 100755 => 100644 mode change 100755 => 100644 frameworks/native/sensor/src/sensor_data_channel.cpp rename frameworks/native/sensor/src/{my_event_handler.cpp => sensor_event_handler.cpp} (79%) mode change 100755 => 100644 rename frameworks/native/sensor/src/{my_file_descriptor_listener.cpp => sensor_event_listener.cpp} (83%) mode change 100755 => 100644 diff --git a/frameworks/native/sensor/BUILD.gn b/frameworks/native/sensor/BUILD.gn index 4c584798..b5105c27 100644 --- a/frameworks/native/sensor/BUILD.gn +++ b/frameworks/native/sensor/BUILD.gn @@ -21,8 +21,8 @@ SUBSYSTEM_DIR = "//base/sensors" ############################################## ohos_shared_library("libsensor_native") { sources = [ - "src/my_event_handler.cpp", - "src/my_file_descriptor_listener.cpp", + "src/sensor_event_handler.cpp", + "src/sensor_event_listener.cpp", "src/sensor_agent_proxy.cpp", "src/sensor_data_channel.cpp", "src/sensor_service_client.cpp", diff --git a/frameworks/native/sensor/include/sensor_data_channel.h b/frameworks/native/sensor/include/sensor_data_channel.h old mode 100755 new mode 100644 index 2902f914..b2b0c21d --- a/frameworks/native/sensor/include/sensor_data_channel.h +++ b/frameworks/native/sensor/include/sensor_data_channel.h @@ -20,7 +20,7 @@ #include #include "sensor_basic_data_channel.h" #include "sensor_agent_type.h" -#include "my_event_handler.h" +#include "sensor_event_handler.h" namespace OHOS { namespace Sensors { @@ -43,7 +43,7 @@ private: static void threadProcessTask(SensorDataChannel *sensorChannel); int32_t InnerSensorDataChannel(); std::mutex eventRunnerMutex_; - static std::shared_ptr eventHandler_; + static std::shared_ptr eventHandler_; static std::shared_ptr eventRunner_; static int32_t receiveFd_; }; diff --git a/frameworks/native/sensor/include/my_event_handler.h b/frameworks/native/sensor/include/sensor_event_handler.h old mode 100755 new mode 100644 similarity index 75% rename from frameworks/native/sensor/include/my_event_handler.h rename to frameworks/native/sensor/include/sensor_event_handler.h index 3b89c93b..3975e2bb --- a/frameworks/native/sensor/include/my_event_handler.h +++ b/frameworks/native/sensor/include/sensor_event_handler.h @@ -13,18 +13,18 @@ * limitations under the License. */ -#ifndef MY_EVENT_HANDLER_H -#define MY_EVENT_HANDLER_H +#ifndef SENSOR_EVENT_HANDLER_H +#define SENSOR_EVENT_HANDLER_H #include "event_handler.h" #include "event_runner.h" namespace OHOS { namespace Sensors { -class MyEventHandler : public AppExecFwk::EventHandler { +class SensorEventHandler : public AppExecFwk::EventHandler { public: - explicit MyEventHandler(const std::shared_ptr &runner); - ~MyEventHandler() = default; + explicit SensorEventHandler(const std::shared_ptr &runner); + ~SensorEventHandler() = default; /** * Function: Process the event. Override the method of base class. @@ -34,4 +34,4 @@ public: }; } // namespace Sensors } // namespace OHOS -#endif // MY_EVENT_HANDLER_H \ No newline at end of file +#endif // SENSOR_EVENT_HANDLER_H \ No newline at end of file diff --git a/frameworks/native/sensor/include/my_file_descriptor_listener.h b/frameworks/native/sensor/include/sensor_event_listener.h old mode 100755 new mode 100644 similarity index 80% rename from frameworks/native/sensor/include/my_file_descriptor_listener.h rename to frameworks/native/sensor/include/sensor_event_listener.h index a2a5ff7a..89274fdd --- a/frameworks/native/sensor/include/my_file_descriptor_listener.h +++ b/frameworks/native/sensor/include/sensor_event_listener.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef MY_FILE_DESCRIPTOR_LISTENER_H -#define MY_FILE_DESCRIPTOR_LISTENER_H +#ifndef SENSOR_EVENT_LISTENER_H +#define SENSOR_EVENT_LISTENER_H #include #include @@ -28,11 +28,11 @@ namespace OHOS { namespace Sensors { -class MyFileDescriptorListener : public AppExecFwk::FileDescriptorListener { +class SensorEventListener : public AppExecFwk::FileDescriptorListener { public: - explicit MyFileDescriptorListener(); + explicit SensorEventListener(); - ~MyFileDescriptorListener(); + ~SensorEventListener(); void OnReadable(int32_t fileDescriptor) override; @@ -50,4 +50,4 @@ private: }; } // namespace Sensors } // namespace OHOS -#endif // MY_FILE_DESCRIPTOR_LISTENER_H +#endif // SENSOR_EVENT_LISTENER_H diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp old mode 100755 new mode 100644 index 2ff8d8b2..39eedd32 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -21,7 +21,7 @@ #include #include -#include "my_file_descriptor_listener.h" +#include "sensor_event_listener.h" #include "sensors_errors.h" #include "sensors_log_domain.h" #include "string_ex.h" @@ -34,7 +34,7 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; using namespace OHOS::AppExecFwk; -std::shared_ptr SensorDataChannel::eventHandler_; +std::shared_ptr SensorDataChannel::eventHandler_; std::shared_ptr SensorDataChannel::eventRunner_; namespace { @@ -82,14 +82,14 @@ int32_t SensorDataChannel::InnerSensorDataChannel() HiLog::Error(LABEL, "%{public}s create basic channel failed, ret : %{public}d", __func__, ret); return ret; } - auto listener = std::make_shared(); + auto listener = std::make_shared(); listener->SetChannel(this); auto myRunner = AppExecFwk::EventRunner::Create(true); if (myRunner == nullptr) { HiLog::Error(LABEL, "%{public}s myRunner is null", __func__); return -1; } - auto handler = std::make_shared(myRunner); + auto handler = std::make_shared(myRunner); if (handler == nullptr) { HiLog::Error(LABEL, "%{public}s handler is null", __func__); return -1; diff --git a/frameworks/native/sensor/src/my_event_handler.cpp b/frameworks/native/sensor/src/sensor_event_handler.cpp old mode 100755 new mode 100644 similarity index 79% rename from frameworks/native/sensor/src/my_event_handler.cpp rename to frameworks/native/sensor/src/sensor_event_handler.cpp index 802c1286..3a974b93 --- a/frameworks/native/sensor/src/my_event_handler.cpp +++ b/frameworks/native/sensor/src/sensor_event_handler.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "my_event_handler.h" +#include "sensor_event_handler.h" #include "sensors_log_domain.h" namespace OHOS { @@ -24,12 +24,12 @@ using namespace OHOS::AppExecFwk; namespace { } // namespace -MyEventHandler::MyEventHandler(const std::shared_ptr &runner):EventHandler(runner){} +SensorEventHandler::SensorEventHandler(const std::shared_ptr &runner):EventHandler(runner){} /** * Function: Process the event. Override the method of base class. * @param event The event need to be processed. */ -void MyEventHandler::ProcessEvent(const InnerEvent::Pointer &event){} +void SensorEventHandler::ProcessEvent(const InnerEvent::Pointer &event){} } // namespace Sensors } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/sensor_event_listener.cpp old mode 100755 new mode 100644 similarity index 83% rename from frameworks/native/sensor/src/my_file_descriptor_listener.cpp rename to frameworks/native/sensor/src/sensor_event_listener.cpp index a16f79d0..7b596169 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/sensor_event_listener.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "my_file_descriptor_listener.h" +#include "sensor_event_listener.h" #include "sensors_log_domain.h" namespace OHOS { @@ -22,17 +22,17 @@ using namespace OHOS::HiviewDFX; using namespace OHOS::AppExecFwk; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "MyFileDescriptorListener" }; +constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "SensorEventListener" }; constexpr int32_t RECEIVE_DATA_SIZE = 100; } // namespace -MyFileDescriptorListener::MyFileDescriptorListener() +SensorEventListener::SensorEventListener() :channel_(nullptr), receiveDataBuff_( new (std::nothrow) TransferSensorEvents[sizeof(struct TransferSensorEvents) * RECEIVE_DATA_SIZE]) {} -MyFileDescriptorListener::~MyFileDescriptorListener() +SensorEventListener::~SensorEventListener() { HiLog::Debug(LABEL, "%{public}s begin", __func__); if (receiveDataBuff_ != nullptr) { @@ -41,7 +41,7 @@ MyFileDescriptorListener::~MyFileDescriptorListener() } } -void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) +void SensorEventListener::OnReadable(int32_t fileDescriptor) { HiLog::Debug(LABEL, "%{public}s begin", __func__); if (fileDescriptor < 0) { @@ -75,14 +75,14 @@ void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) } } -void MyFileDescriptorListener::OnWritable(int32_t fileDescriptor){} +void SensorEventListener::OnWritable(int32_t fileDescriptor){} -void MyFileDescriptorListener::SetChannel(SensorDataChannel* channel) +void SensorEventListener::SetChannel(SensorDataChannel* channel) { channel_ = channel; } -void MyFileDescriptorListener::OnShutdown(int32_t fileDescriptor) +void SensorEventListener::OnShutdown(int32_t fileDescriptor) { if (fileDescriptor < 0) { HiLog::Error(LABEL, "%{public}s param is error: %{public}d", __func__, fileDescriptor); @@ -96,7 +96,7 @@ void MyFileDescriptorListener::OnShutdown(int32_t fileDescriptor) } } -void MyFileDescriptorListener::OnException(int32_t fileDescriptor) +void SensorEventListener::OnException(int32_t fileDescriptor) { if (fileDescriptor < 0) { HiLog::Error(LABEL, "%{public}s param is error: %{public}d", __func__, fileDescriptor); -- Gitee From 08c5b906c976c633fbf04502616c3abb494ac2da Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 29 Jan 2022 15:32:02 +0800 Subject: [PATCH 2/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- frameworks/native/sensor/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/sensor/BUILD.gn b/frameworks/native/sensor/BUILD.gn index b5105c27..9fd42d9f 100644 --- a/frameworks/native/sensor/BUILD.gn +++ b/frameworks/native/sensor/BUILD.gn @@ -21,10 +21,10 @@ SUBSYSTEM_DIR = "//base/sensors" ############################################## ohos_shared_library("libsensor_native") { sources = [ - "src/sensor_event_handler.cpp", - "src/sensor_event_listener.cpp", "src/sensor_agent_proxy.cpp", "src/sensor_data_channel.cpp", + "src/sensor_event_handler.cpp", + "src/sensor_event_listener.cpp", "src/sensor_service_client.cpp", "src/sensor_service_proxy.cpp", ] -- Gitee From 7f6ea840ae40fcee002c27a9454d6a963e41eaaa Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 29 Jan 2022 15:37:43 +0800 Subject: [PATCH 3/3] Signed-off-by:hellohyh001 Signed-off-by: hellohyh001 --- frameworks/native/sensor/src/sensor_event_handler.cpp | 4 ++-- frameworks/native/sensor/src/sensor_event_listener.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_event_handler.cpp b/frameworks/native/sensor/src/sensor_event_handler.cpp index 3a974b93..87befdba 100644 --- a/frameworks/native/sensor/src/sensor_event_handler.cpp +++ b/frameworks/native/sensor/src/sensor_event_handler.cpp @@ -24,12 +24,12 @@ using namespace OHOS::AppExecFwk; namespace { } // namespace -SensorEventHandler::SensorEventHandler(const std::shared_ptr &runner):EventHandler(runner){} +SensorEventHandler::SensorEventHandler(const std::shared_ptr &runner):EventHandler(runner) {} /** * Function: Process the event. Override the method of base class. * @param event The event need to be processed. */ -void SensorEventHandler::ProcessEvent(const InnerEvent::Pointer &event){} +void SensorEventHandler::ProcessEvent(const InnerEvent::Pointer &event) {} } // namespace Sensors } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/sensor/src/sensor_event_listener.cpp b/frameworks/native/sensor/src/sensor_event_listener.cpp index 7b596169..eafcd641 100644 --- a/frameworks/native/sensor/src/sensor_event_listener.cpp +++ b/frameworks/native/sensor/src/sensor_event_listener.cpp @@ -75,7 +75,7 @@ void SensorEventListener::OnReadable(int32_t fileDescriptor) } } -void SensorEventListener::OnWritable(int32_t fileDescriptor){} +void SensorEventListener::OnWritable(int32_t fileDescriptor) {} void SensorEventListener::SetChannel(SensorDataChannel* channel) { -- Gitee