diff --git a/interfaces/inner_api/include/time_service_client.h b/interfaces/inner_api/include/time_service_client.h index 5ebe7e3097f603a5e0f827cc368780e8f052334a..5ae7adf7a9fe596d67ecb4e4e28836e725369b23 100644 --- a/interfaces/inner_api/include/time_service_client.h +++ b/interfaces/inner_api/include/time_service_client.h @@ -464,6 +464,7 @@ private: ~TimeServiceClient(); bool SubscribeSA(sptr systemAbilityManager); bool ConnectService(); + bool GetTimeByClockId(clockid_t clockId, struct timespec &tv); void ClearProxy(); sptr GetProxy(); void SetProxy(sptr proxy); diff --git a/interfaces/inner_api/include/time_service_interface.h b/interfaces/inner_api/include/time_service_interface.h index 502529bdc464edbcd018f2f23371f1aabb400bdd..f1a3c5a39b81952fe8ef1eda8a808d676072d232 100644 --- a/interfaces/inner_api/include/time_service_interface.h +++ b/interfaces/inner_api/include/time_service_interface.h @@ -53,54 +53,6 @@ public: */ virtual int32_t GetTimeZone(std::string &timezoneId) = 0; - /** - * GetWallTimeMs - * - * @param times result of times ,unit: millisecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetWallTimeMs(int64_t ×) = 0; - - /** - * GetWallTimeNs - * - * @param times result of times ,unit: Nanosecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetWallTimeNs(int64_t ×) = 0; - - /** - * GetBootTimeMs - * - * @param times result of times ,unit: millisecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetBootTimeMs(int64_t ×) = 0; - - /** - * GetBootTimeNs - * - * @param times result of times ,unit: millisecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetBootTimeNs(int64_t ×) = 0; - - /** - * GetMonotonicTimeMs - * - * @param times result of times ,unit: millisecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetMonotonicTimeMs(int64_t ×) = 0; - - /** - * GetMonotonicTimeNs - * - * @param times result of times ,unit: Nanosecond - * @return int32_t ERR_OK on success, other on failure. - */ - virtual int32_t GetMonotonicTimeNs(int64_t ×) = 0; - /** * GetThreadTimeMs * diff --git a/interfaces/inner_api/src/time_service_client.cpp b/interfaces/inner_api/src/time_service_client.cpp index c8452bfbc054801c80297e8d8b02c46816a94341..62351c102d297a791475eb53aeafada1336a42e6 100644 --- a/interfaces/inner_api/src/time_service_client.cpp +++ b/interfaces/inner_api/src/time_service_client.cpp @@ -27,6 +27,12 @@ namespace OHOS { namespace MiscServices { +namespace { +static const int MILLI_TO_SEC = 1000LL; +static const int NANO_TO_SEC = 1000000000LL; +constexpr int32_t NANO_TO_MILLI = NANO_TO_SEC / MILLI_TO_SEC; +} + std::mutex TimeServiceClient::instanceLock_; sptr TimeServiceClient::instance_; @@ -154,6 +160,15 @@ bool TimeServiceClient::ConnectService() return true; } +bool TimeServiceClient::GetTimeByClockId(clockid_t clockId, struct timespec &tv) +{ + if (clock_gettime(clockId, &tv) < 0) { + TIME_HILOGE(TIME_MODULE_CLIENT, "Failed clock_gettime, errno: %{public}s.", strerror(errno)); + return false; + } + return true; +} + bool TimeServiceClient::SetTime(int64_t time) { if (!ConnectService()) { @@ -459,34 +474,24 @@ int32_t TimeServiceClient::GetTimeZone(std::string &timezoneId) int64_t TimeServiceClient::GetWallTimeMs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetWallTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_REALTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetWallTimeMs(int64_t &time) { - if (!ConnectService()) { - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetWallTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_REALTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } @@ -494,36 +499,24 @@ int32_t TimeServiceClient::GetWallTimeMs(int64_t &time) int64_t TimeServiceClient::GetWallTimeNs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetWallTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_REALTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetWallTimeNs(int64_t &time) { - if (!ConnectService()) { - TIME_HILOGE(TIME_MODULE_CLIENT, "connect service failed."); - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - TIME_HILOGE(TIME_MODULE_CLIENT, "get proxy failed."); - return E_TIME_NULLPTR; - } - if (proxy->GetWallTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_REALTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } @@ -531,34 +524,24 @@ int32_t TimeServiceClient::GetWallTimeNs(int64_t &time) int64_t TimeServiceClient::GetBootTimeMs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetBootTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_BOOTTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetBootTimeMs(int64_t &time) { - if (!ConnectService()) { - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetBootTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_BOOTTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } @@ -566,34 +549,24 @@ int32_t TimeServiceClient::GetBootTimeMs(int64_t &time) int64_t TimeServiceClient::GetBootTimeNs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetBootTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_BOOTTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetBootTimeNs(int64_t &time) { - if (!ConnectService()) { - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetBootTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_BOOTTIME, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } @@ -601,34 +574,24 @@ int32_t TimeServiceClient::GetBootTimeNs(int64_t &time) int64_t TimeServiceClient::GetMonotonicTimeMs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetMonotonicTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_MONOTONIC, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetMonotonicTimeMs(int64_t &time) { - if (!ConnectService()) { - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetMonotonicTimeMs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_MONOTONIC, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * MILLI_TO_SEC + tv.tv_nsec / NANO_TO_MILLI; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } @@ -636,34 +599,24 @@ int32_t TimeServiceClient::GetMonotonicTimeMs(int64_t &time) int64_t TimeServiceClient::GetMonotonicTimeNs() { int64_t time; - if (!ConnectService()) { - return -1; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetMonotonicTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_MONOTONIC, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return -1; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return time; } int32_t TimeServiceClient::GetMonotonicTimeNs(int64_t &time) { - if (!ConnectService()) { - return E_TIME_SA_DIED; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - return E_TIME_NULLPTR; - } - if (proxy->GetMonotonicTimeNs(time) != ERR_OK) { + struct timespec tv {}; + if (!GetTimeByClockId(CLOCK_MONOTONIC, tv)) { TIME_HILOGE(TIME_MODULE_CLIENT, "get failed."); return E_TIME_SA_DIED; } + time = tv.tv_sec * NANO_TO_SEC + tv.tv_nsec; TIME_HILOGD(TIME_MODULE_SERVICE, "Result: %{public}" PRId64 "", time); return E_TIME_OK; } diff --git a/services/ipc/base/time_service_ipc_interface_code.h b/services/ipc/base/time_service_ipc_interface_code.h index c30f6b04dc55571981d6b4b6bee2e9ba8739d15a..a8b58b00ad959cd2acb817780820bbac825d5ded 100644 --- a/services/ipc/base/time_service_ipc_interface_code.h +++ b/services/ipc/base/time_service_ipc_interface_code.h @@ -23,12 +23,6 @@ enum class TimeServiceIpcInterfaceCode { SET_TIME = 0, SET_TIME_ZONE, GET_TIME_ZONE, - GET_WALL_TIME_MILLI, - GET_WALL_TIME_NANO, - GET_BOOT_TIME_MILLI, - GET_BOOT_TIME_NANO, - GET_MONO_TIME_MILLI, - GET_MONO_TIME_NANO, GET_THREAD_TIME_MILLI, GET_THREAD_TIME_NANO, CREATE_TIMER, diff --git a/services/ipc/proxy/inner_api_include/time_service_proxy.h b/services/ipc/proxy/inner_api_include/time_service_proxy.h index 83e42d29185bf5581ac965a9d7f71619aeef5a28..fb4630738fb3dde280b869d0fca09a09368bf131 100644 --- a/services/ipc/proxy/inner_api_include/time_service_proxy.h +++ b/services/ipc/proxy/inner_api_include/time_service_proxy.h @@ -31,12 +31,6 @@ public: int32_t SetTime(int64_t time, APIVersion apiVersion = APIVersion::API_VERSION_7) override; int32_t SetTimeZone(const std::string &timeZoneId, APIVersion apiVersion = APIVersion::API_VERSION_7) override; int32_t GetTimeZone(std::string &timeZoneId) override; - int32_t GetWallTimeMs(int64_t ×) override; - int32_t GetWallTimeNs(int64_t ×) override; - int32_t GetBootTimeMs(int64_t ×) override; - int32_t GetBootTimeNs(int64_t ×) override; - int32_t GetMonotonicTimeMs(int64_t ×) override; - int32_t GetMonotonicTimeNs(int64_t ×) override; int32_t GetThreadTimeMs(int64_t ×) override; int32_t GetThreadTimeNs(int64_t ×) override; int32_t CreateTimer(const std::shared_ptr &timerOptions, sptr &timerCallback, diff --git a/services/ipc/proxy/time_service_proxy.cpp b/services/ipc/proxy/time_service_proxy.cpp index 3a1b4110610ac5c37845eacf842f0d52d7cfb30e..6c6e23302eacb188d059c6483830c4c4d0d3103c 100644 --- a/services/ipc/proxy/time_service_proxy.cpp +++ b/services/ipc/proxy/time_service_proxy.cpp @@ -202,114 +202,6 @@ int32_t TimeServiceProxy::GetTimeZone(std::string &timeZoneId) return result; } -int32_t TimeServiceProxy::GetWallTimeMs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_WALL_TIME_MILLI), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetWallTimeMs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - -int32_t TimeServiceProxy::GetWallTimeNs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_WALL_TIME_NANO), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetWallTimeNs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - -int32_t TimeServiceProxy::GetBootTimeMs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_MILLI), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetBootTimeMs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - -int32_t TimeServiceProxy::GetBootTimeNs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write parcelable"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_NANO), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetBootTimeNs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - -int32_t TimeServiceProxy::GetMonotonicTimeMs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_MONO_TIME_MILLI), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetMonotonicTimeMs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - -int32_t TimeServiceProxy::GetMonotonicTimeNs(int64_t ×) -{ - MessageParcel data, reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor"); - return E_TIME_WRITE_PARCEL_ERROR; - } - int32_t result = Remote()->SendRequest( - static_cast(TimeServiceIpcInterfaceCode::GET_MONO_TIME_NANO), data, reply, option); - if (result != ERR_NONE) { - TIME_HILOGE(TIME_MODULE_CLIENT, "GetMonotonicTimeNs failed, error code is: %{public}d", result); - return result; - } - times = reply.ReadInt64(); - return result; -} - int32_t TimeServiceProxy::GetThreadTimeMs(int64_t ×) { MessageParcel data, reply; diff --git a/services/ipc/stub/time_service_stub.cpp b/services/ipc/stub/time_service_stub.cpp index baa6c4577a73250a7ee47aeb581e337a631dd7c8..13895a0a74f82f4b6aea3e80d99e1633e46e748e 100644 --- a/services/ipc/stub/time_service_stub.cpp +++ b/services/ipc/stub/time_service_stub.cpp @@ -38,20 +38,6 @@ TimeServiceStub::TimeServiceStub() [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnSetTimeZone(data, reply); } }, { TimeServiceIpcInterfaceCode::GET_TIME_ZONE, [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetTimeZone(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_WALL_TIME_MILLI, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetWallTimeMs(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_WALL_TIME_NANO, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetWallTimeNs(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_BOOT_TIME_MILLI, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetBootTimeMs(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_BOOT_TIME_NANO, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetBootTimeNs(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_MONO_TIME_MILLI, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { - return OnGetMonotonicTimeMs(data, reply); } }, - { TimeServiceIpcInterfaceCode::GET_MONO_TIME_NANO, - [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { - return OnGetMonotonicTimeNs(data, reply); } }, { TimeServiceIpcInterfaceCode::GET_THREAD_TIME_MILLI, [this] (MessageParcel &data, MessageParcel &reply) -> int32_t { return OnGetThreadTimeMs(data, reply); } }, { TimeServiceIpcInterfaceCode::GET_THREAD_TIME_NANO, @@ -171,90 +157,6 @@ int32_t TimeServiceStub::OnGetTimeZone(MessageParcel &data, MessageParcel &reply return ret; } -int32_t TimeServiceStub::OnGetWallTimeMs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetWallTimeMs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - -int32_t TimeServiceStub::OnGetWallTimeNs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetWallTimeNs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - -int32_t TimeServiceStub::OnGetBootTimeMs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetBootTimeMs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - -int32_t TimeServiceStub::OnGetBootTimeNs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetBootTimeNs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - -int32_t TimeServiceStub::OnGetMonotonicTimeMs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetMonotonicTimeMs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - -int32_t TimeServiceStub::OnGetMonotonicTimeNs(MessageParcel &data, MessageParcel &reply) -{ - TIME_HILOGD(TIME_MODULE_SERVICE, " start."); - int64_t time; - int32_t ret = GetMonotonicTimeNs(time); - if (ret != ERR_OK) { - TIME_HILOGE(TIME_MODULE_SERVICE, " end##ret = %{public}d", ret); - return ret; - } - reply.WriteInt64(time); - TIME_HILOGD(TIME_MODULE_SERVICE, " end."); - return ret; -} - int32_t TimeServiceStub::OnGetThreadTimeMs(MessageParcel &data, MessageParcel &reply) { TIME_HILOGD(TIME_MODULE_SERVICE, " start."); diff --git a/services/ipc/stub/time_service_stub.h b/services/ipc/stub/time_service_stub.h index a98992cf4e54000f938711069e6ab5574fb11f40..e9c3cffaec05faee03ed25a706c11791cd185519 100644 --- a/services/ipc/stub/time_service_stub.h +++ b/services/ipc/stub/time_service_stub.h @@ -38,12 +38,6 @@ private: int32_t OnSetTime(MessageParcel &data, MessageParcel &reply); int32_t OnSetTimeZone(MessageParcel &data, MessageParcel &reply); int32_t OnGetTimeZone(MessageParcel &data, MessageParcel &reply); - int32_t OnGetWallTimeMs(MessageParcel &data, MessageParcel &reply); - int32_t OnGetWallTimeNs(MessageParcel &data, MessageParcel &reply); - int32_t OnGetBootTimeMs(MessageParcel &data, MessageParcel &reply); - int32_t OnGetBootTimeNs(MessageParcel &data, MessageParcel &reply); - int32_t OnGetMonotonicTimeMs(MessageParcel &data, MessageParcel &reply); - int32_t OnGetMonotonicTimeNs(MessageParcel &data, MessageParcel &reply); int32_t OnGetThreadTimeMs(MessageParcel &data, MessageParcel &reply); int32_t OnGetThreadTimeNs(MessageParcel &data, MessageParcel &reply); diff --git a/services/time_system_ability.cpp b/services/time_system_ability.cpp index bb63ea79a6c0970aaccf9014a07641023f79e7fe..9e522cd96202103d4a0963b44a2aff13f1ff6146 100644 --- a/services/time_system_ability.cpp +++ b/services/time_system_ability.cpp @@ -750,16 +750,6 @@ int32_t TimeSystemAbility::GetWallTimeMs(int64_t &time) return E_TIME_DEAL_FAILED; } -int32_t TimeSystemAbility::GetWallTimeNs(int64_t &time) -{ - struct timespec tv {}; - if (GetTimeByClockId(CLOCK_REALTIME, tv)) { - time = tv.tv_sec * NANO_TO_BASE + tv.tv_nsec; - return ERR_OK; - } - return E_TIME_DEAL_FAILED; -} - int32_t TimeSystemAbility::GetBootTimeMs(int64_t &time) { struct timespec tv {}; @@ -780,26 +770,6 @@ int32_t TimeSystemAbility::GetBootTimeNs(int64_t &time) return E_TIME_DEAL_FAILED; } -int32_t TimeSystemAbility::GetMonotonicTimeMs(int64_t &time) -{ - struct timespec tv {}; - if (GetTimeByClockId(CLOCK_MONOTONIC, tv)) { - time = tv.tv_sec * MILLI_TO_BASE + tv.tv_nsec / NANO_TO_MILLI; - return ERR_OK; - } - return E_TIME_DEAL_FAILED; -} - -int32_t TimeSystemAbility::GetMonotonicTimeNs(int64_t &time) -{ - struct timespec tv {}; - if (GetTimeByClockId(CLOCK_MONOTONIC, tv)) { - time = tv.tv_sec * NANO_TO_BASE + tv.tv_nsec; - return ERR_OK; - } - return E_TIME_DEAL_FAILED; -} - int32_t TimeSystemAbility::GetThreadTimeMs(int64_t &time) { struct timespec tv {}; diff --git a/services/time_system_ability.h b/services/time_system_ability.h index 42d7d5759b282024682694e9982277f87610976b..6ecb0663f94fef72ea145047746049424ba83674 100644 --- a/services/time_system_ability.h +++ b/services/time_system_ability.h @@ -54,12 +54,9 @@ public: bool SetRealTime(int64_t time); int32_t SetTimeZone(const std::string &timeZoneId, APIVersion apiVersion = APIVersion::API_VERSION_7) override; int32_t GetTimeZone(std::string &timeZoneId) override; - int32_t GetWallTimeMs(int64_t &time) override; - int32_t GetWallTimeNs(int64_t &time) override; - int32_t GetBootTimeMs(int64_t &time) override; - int32_t GetBootTimeNs(int64_t &time) override; - int32_t GetMonotonicTimeMs(int64_t &time) override; - int32_t GetMonotonicTimeNs(int64_t &time) override; + int32_t GetWallTimeMs(int64_t &time); + int32_t GetBootTimeMs(int64_t &time); + int32_t GetBootTimeNs(int64_t &time); int32_t GetThreadTimeMs(int64_t &time) override; int32_t GetThreadTimeNs(int64_t &time) override; int32_t CreateTimer(const std::shared_ptr &timerOptions, sptr &obj, diff --git a/test/fuzztest/timeservice_fuzzer/BUILD.gn b/test/fuzztest/timeservice_fuzzer/BUILD.gn index 1d6544e0d19d793cbbcb1326e6c61908d43cee69..e736d8c979a61236d66f805e31cbd2911e1e938e 100644 --- a/test/fuzztest/timeservice_fuzzer/BUILD.gn +++ b/test/fuzztest/timeservice_fuzzer/BUILD.gn @@ -33,26 +33,6 @@ timedestroytimer_test = { configFuzzer = "timedestroytimer_fuzzer" source = "timedestroytimer_fuzzer/timedestroytimer_fuzzer.cpp" } -timegetboottimemilli_test = { - targetName = "TimeGetBootTimeMilliFuzzTest" - configFuzzer = "timegetboottimemilli_fuzzer" - source = "timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.cpp" -} -timegetboottimenano_test = { - targetName = "TimeGetBootTimeNanoFuzzTest" - configFuzzer = "timegetboottimenano_fuzzer" - source = "timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.cpp" -} -timegetmonotimemilli_test = { - targetName = "TimeGetMonoTimeMilliFuzzTest" - configFuzzer = "timegetmonotimemilli_fuzzer" - source = "timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.cpp" -} -timegetmonotimenano_test = { - targetName = "TimeGetMonoTimeNanoFuzzTest" - configFuzzer = "timegetmonotimenano_fuzzer" - source = "timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.cpp" -} timegetthreadtimemilli_test = { targetName = "TimeGetThreadTimeMilliFuzzTest" configFuzzer = "timegetthreadtimemilli_fuzzer" @@ -68,16 +48,6 @@ timegettimezone_test = { configFuzzer = "timegettimezone_fuzzer" source = "timegettimezone_fuzzer/timegettimezone_fuzzer.cpp" } -timegetwalltimemilli_test = { - targetName = "TimeGetWallTimeMilliFuzzTest" - configFuzzer = "timegetwalltimemilli_fuzzer" - source = "timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.cpp" -} -timegetwalltimenano_test = { - targetName = "TimeGetWallTimeNanoFuzzTest" - configFuzzer = "timegetwalltimenano_fuzzer" - source = "timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.cpp" -} timereceivedmessage_test = { targetName = "TimeReceivedMessageFuzzTest" configFuzzer = "timereceivedmessage_fuzzer" @@ -113,15 +83,9 @@ time_fuzztests = [ timeboundarycode_test, timecreatetimer_test, timedestroytimer_test, - timegetboottimemilli_test, - timegetboottimenano_test, - timegetmonotimemilli_test, - timegetmonotimenano_test, timegetthreadtimemilli_test, timegetthreadtimenano_test, timegettimezone_test, - timegetwalltimemilli_test, - timegetwalltimenano_test, timereceivedmessage_test, timeservicesettimezone_test, timestarttimer_test, @@ -192,15 +156,9 @@ group("fuzztest") { ":TimeBoundaryCodeFuzzTest", ":TimeCreateTimerFuzzTest", ":TimeDestroyTimerFuzzTest", - ":TimeGetBootTimeMilliFuzzTest", - ":TimeGetBootTimeNanoFuzzTest", - ":TimeGetMonoTimeMilliFuzzTest", - ":TimeGetMonoTimeNanoFuzzTest", ":TimeGetThreadTimeMilliFuzzTest", ":TimeGetThreadTimeNanoFuzzTest", ":TimeGetTimeZoneFuzzTest", - ":TimeGetWallTimeMilliFuzzTest", - ":TimeGetWallTimeNanoFuzzTest", ":TimeReceivedMessageFuzzTest", ":TimeServiceSetTimeZoneFuzzTest", ":TimeSntpFuzzTest", diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.cpp deleted file mode 100644 index 9b367252fefecb7deb1dce2e29b3060672cfcbc1..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetboottimemilli_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_MILLI), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.h deleted file mode 100644 index c177b453308150cc813d296109cd0c8f10735847..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimemilli_fuzzer/timegetboottimemilli_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETBOOTTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETBOOTTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetboottimemilli_fuzzer" - -#endif // TEST_FUZZTEST_GETBOOTTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.cpp deleted file mode 100644 index 26b094c53127a637d2d1cf2efa87e759ce2a1dc6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetboottimenano_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_NANO), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.h deleted file mode 100644 index 2779a9eb5f114b955aa42a22aee40e2820626560..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetboottimenano_fuzzer/timegetboottimenano_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETBOOTTIMENANO_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETBOOTTIMENANO_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetboottimenano_fuzzer" - -#endif // TEST_FUZZTEST_GETBOOTTIMENANO_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.cpp deleted file mode 100644 index 8a205b3a03839515767dea8051aaf10e3747b797..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetmonotimemilli_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_MONO_TIME_MILLI), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.h deleted file mode 100644 index 5f40420efee3489f58f01dbb50c1a05956f8ebf3..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimemilli_fuzzer/timegetmonotimemilli_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETMONOTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETMONOTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetmonotimemilli_fuzzer" - -#endif // TEST_FUZZTEST_GETMONOTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.cpp deleted file mode 100644 index eb68b6f8956834d34f548036ad92602f1fa8170f..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetmonotimenano_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_MONO_TIME_NANO), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.h deleted file mode 100644 index 27158458cf04a6884583dcab57b1812ef6e35b1f..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetmonotimenano_fuzzer/timegetmonotimenano_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETMONOTIMENANO_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETMONOTIMENANO_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetmonotimenano_fuzzer" - -#endif // TEST_FUZZTEST_GETMONOTIMENANO_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.cpp deleted file mode 100644 index 3d402c3b072acb48bdd2c23258e9e1ed87443f0b..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetwalltimemilli_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_WALL_TIME_MILLI), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.h deleted file mode 100644 index 98e329e8f0a1daea744b5c5c5fffccb543ba3cd2..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimemilli_fuzzer/timegetwalltimemilli_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETWALLTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETWALLTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetwalltimemilli_fuzzer" - -#endif // TEST_FUZZTEST_GETWALLTIMEMILLI_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.cpp deleted file mode 100644 index e575d8b59d9e279837013dc726b266f5217e1f75..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 "timegetwalltimenano_fuzzer.h" - -#include -#include -#include - -#include "time_service_fuzz_utils.h" -#include "time_service_ipc_interface_code.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 4; -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return 0; - } - - /* Run your code on data */ - OHOS::TimeServiceFuzzUtils::OnRemoteRequestTest( - static_cast(TimeServiceIpcInterfaceCode::GET_WALL_TIME_NANO), data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.h deleted file mode 100644 index f32db45c1fa12b0e84db3059faa4eaa89d9f7473..0000000000000000000000000000000000000000 --- a/test/fuzztest/timeservice_fuzzer/timegetwalltimenano_fuzzer/timegetwalltimenano_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 TEST_FUZZTEST_GETWALLTIMENANO_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_GETWALLTIMENANO_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timegetwalltimenano_fuzzer" - -#endif // TEST_FUZZTEST_GETWALLTIMENANO_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file