diff --git a/frameworks/native/sensor/BUILD.gn b/frameworks/native/sensor/BUILD.gn index 4c584798f0bd0128ba11455e2ba62357f9290461..9fd42d9f7ea5897b321ed0fb1e28d72fadfb87fa 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/my_event_handler.cpp", - "src/my_file_descriptor_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", ] 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 2902f91427115080abcc84a9f0c92de9cbc46595..b2b0c21d04e897f2ed47d224e599d725f7258a71 --- 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 3b89c93bd67ecff4c538200a48e6626567e81d2b..3975e2bb5f271b59949e5f82462fcad6aa12ec17 --- 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 a2a5ff7a608e3a864b71e4042570fdc5fac27f1a..89274fdd0309d0dd98e0b66244ba7df02cb084af --- 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 2ff8d8b21601a37d4842cfd22353fe3790fa57c7..39eedd3296067e0d9f5636474b17729e20b6580d --- 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 802c128633623283dbfa441252b09789ac046f49..87befdba10823cd1165f104c6ecb932e3fc54399 --- 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 a16f79d0bbf59e1510c183c76b19915ebdc00195..eafcd641e5d0b54fdd382ed16ac6d7de7786b11c --- 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);