diff --git a/interfaces/kits/js/napi/system_time/src/js_systemtime.cpp b/interfaces/kits/js/napi/system_time/src/js_systemtime.cpp index e45c2c8..5827d07 100644 --- a/interfaces/kits/js/napi/system_time/src/js_systemtime.cpp +++ b/interfaces/kits/js/napi/system_time/src/js_systemtime.cpp @@ -154,15 +154,15 @@ napi_value JSSystemTimeSetTime(napi_env env, napi_callback_info info) TimePaddingAsyncCallbackInfo(env, asyncContext, callback, promise); napi_value resource = nullptr; napi_create_string_utf8(env, "JSSystemTimeSetTime", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work(env, - nullptr, + napi_create_async_work(env, + nullptr, resource, - [](napi_env env, void* data) { - AsyncContext* asyncContext = (AsyncContext*)data; + [](napi_env env, void *data) { + AsyncContext *asyncContext = (AsyncContext*)data; asyncContext->isOK = TimeServiceClient::GetInstance()->SetTime(asyncContext->time); }, - [](napi_env env, napi_status status, void* data) { - AsyncContext* asyncContext = (AsyncContext*)data; + [](napi_env env, napi_status status, void *data) { + AsyncContext *asyncContext = (AsyncContext*)data; if (!asyncContext->isOK) { asyncContext->errorCode = ERROR; } @@ -214,7 +214,7 @@ napi_value ParseParametersBySetTimezone(const napi_env &env, const napi_value (& return TimeNapiGetNull(env); } -napi_value JSSystemTimeSetTimeZone(napi_env env, napi_callback_info info) +napi_value JSSystemTimeSetTimeZone(napi_env env, napi_callback_info info) { size_t argc = SET_TIMEZONE_MAX_PARA; napi_value argv[SET_TIMEZONE_MAX_PARA] = {0}; @@ -225,7 +225,7 @@ napi_value JSSystemTimeSetTimeZone(napi_env env, napi_callback_info info) if (ParseParametersBySetTimezone(env, argv, argc, timezoneId, callback) == nullptr) { return TimeJSParaError(env, callback); } - AsyncContext* asyncContext = new (std::nothrow)AsyncContext{.env = env, .timeZone = timezoneId}; + AsyncContext *asyncContext = new (std::nothrow)AsyncContext{.env = env, .timeZone = timezoneId}; if (!asyncContext) { return TimeJSParaError(env, callback); } @@ -236,12 +236,12 @@ napi_value JSSystemTimeSetTimeZone(napi_env env, napi_callback_info info) napi_create_async_work(env, nullptr, resource, - [](napi_env env, void* data) { - AsyncContext* asyncContext = (AsyncContext*)data; + [](napi_env env, void *data) { + AsyncContext *asyncContext = (AsyncContext*)data; asyncContext->isOK = TimeServiceClient::GetInstance()->SetTimeZone(asyncContext->timeZone); }, - [](napi_env env, napi_status status, void* data) { - AsyncContext* asyncContext = (AsyncContext*)data; + [](napi_env env, napi_status status, void *data) { + AsyncContext *asyncContext = (AsyncContext*)data; if (!asyncContext->isOK) { asyncContext->errorCode = ERROR; } diff --git a/interfaces/kits/js/napi/system_timer/src/system_timer.cpp b/interfaces/kits/js/napi/system_timer/src/system_timer.cpp index 4babbf1..e79f001 100644 --- a/interfaces/kits/js/napi/system_timer/src/system_timer.cpp +++ b/interfaces/kits/js/napi/system_timer/src/system_timer.cpp @@ -198,9 +198,9 @@ void ITimerInfoInstance::OnTrigger() return; } - SetCallback(dataWorkerData->env, - dataWorkerData->ref, - NO_ERROR, + SetCallback(dataWorkerData->env, + dataWorkerData->ref, + NO_ERROR, NapiGetNull(dataWorkerData->env)); delete dataWorkerData; dataWorkerData = nullptr; diff --git a/services/time_manager/src/time_service_stub.cpp b/services/time_manager/src/time_service_stub.cpp index 852b1aa..3d744a3 100644 --- a/services/time_manager/src/time_service_stub.cpp +++ b/services/time_manager/src/time_service_stub.cpp @@ -59,7 +59,7 @@ int32_t TimeServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Mes } pid_t p = IPCSkeleton::GetCallingPid(); pid_t p1 = IPCSkeleton::GetCallingUid(); - TIME_HILOGI(TIME_MODULE_SERVICE, + TIME_HILOGI(TIME_MODULE_SERVICE, "CallingPid = %{public}d, CallingUid = %{public}d, code = %{public}u", p, p1, code); auto itFunc = memberFuncMap_.find(code); if (itFunc != memberFuncMap_.end()) { diff --git a/services/time_manager/src/timer_call_back.cpp b/services/time_manager/src/timer_call_back.cpp index b84d89a..f3ea1db 100644 --- a/services/time_manager/src/timer_call_back.cpp +++ b/services/time_manager/src/timer_call_back.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace MiscServices { namespace { - const int WANTAGENT_CODE_ELEVEN = 11; + const int WANTAGENT_CODE_ELEVEN = 11; } std::mutex TimerCallback::instanceLock_; sptr TimerCallback::instance_; @@ -102,5 +102,5 @@ void TimerCallback::NotifyTimer(const uint64_t timerId) } TIME_HILOGD(TIME_MODULE_SERVICE, "end."); } -} // namespace MiscServices -} // namespace OHOS \ No newline at end of file +} // namespace MiscServices +} // namespace OHOS \ No newline at end of file diff --git a/services/timer/src/batch.cpp b/services/timer/src/batch.cpp index ea7238a..049b4c9 100644 --- a/services/timer/src/batch.cpp +++ b/services/timer/src/batch.cpp @@ -46,7 +46,7 @@ std::shared_ptr Batch::Get(size_t index) const } bool Batch::CanHold(std::chrono::steady_clock::time_point whenElapsed, - std::chrono::steady_clock::time_point maxWhen) const + std::chrono::steady_clock::time_point maxWhen) const { return (end_ > whenElapsed) && (start_ <= maxWhen); } @@ -54,8 +54,8 @@ bool Batch::CanHold(std::chrono::steady_clock::time_point whenElapsed, bool Batch::Add(const std::shared_ptr &alarm) { bool new_start = false; - auto it = std::upper_bound(alarms_.begin(), - alarms_.end(), + auto it = std::upper_bound(alarms_.begin(), + alarms_.end(), alarm, [](const std::shared_ptr &first, const std::shared_ptr &second) { return first->whenElapsed < second->whenElapsed; @@ -116,10 +116,10 @@ bool Batch::Remove(std::function predicate) bool Batch::HasPackage(const std::string &package_name) { - return std::find_if(alarms_.begin(), + return std::find_if(alarms_.begin(), alarms_.end(), - [package_name] (const std::shared_ptr &alarm) { - return alarm->Matches(package_name); + [package_name] (const std::shared_ptr &alarm) { + return alarm->Matches(package_name); }) != alarms_.end(); } diff --git a/services/timer/src/timer_info.cpp b/services/timer/src/timer_info.cpp index 0f55edf..ab4f42b 100644 --- a/services/timer/src/timer_info.cpp +++ b/services/timer/src/timer_info.cpp @@ -28,14 +28,14 @@ bool TimerInfo::Matches(const std::string &packageName) const } TimerInfo::TimerInfo(uint64_t _id, int _type, - std::chrono::milliseconds _when, - std::chrono::steady_clock::time_point _whenElapsed, - std::chrono::milliseconds _windowLength, - std::chrono::steady_clock::time_point _maxWhen, - std::chrono::milliseconds _interval, - std::function _callback, - uint32_t _flags, - uint64_t _uid) + std::chrono::milliseconds _when, + std::chrono::steady_clock::time_point _whenElapsed, + std::chrono::milliseconds _windowLength, + std::chrono::steady_clock::time_point _maxWhen, + std::chrono::milliseconds _interval, + std::function _callback, + uint32_t _flags, + uint64_t _uid) : id {_id}, type {_type}, origWhen {_when}, diff --git a/services/timer/src/timer_manager.cpp b/services/timer/src/timer_manager.cpp index 909dcbb..1964681 100644 --- a/services/timer/src/timer_manager.cpp +++ b/services/timer/src/timer_manager.cpp @@ -63,14 +63,14 @@ TimerManager::TimerManager(std::shared_ptr impl) alarmThread_.reset(new std::thread(&TimerManager::TimerLooper, this)); } -uint64_t TimerManager::CreateTimer(int type, - uint64_t windowLength, - uint64_t interval, +uint64_t TimerManager::CreateTimer(int type, + uint64_t windowLength, + uint64_t interval, int flag, - std::function callback, + std::function callback, uint64_t uid) { - TIME_HILOGI(TIME_MODULE_SERVICE, + TIME_HILOGI(TIME_MODULE_SERVICE, "Create timer: %{public}d windowLength:%{public}" PRId64 "interval:%{public}" PRId64 "flag:%{public}d", type, windowLength, @@ -81,12 +81,12 @@ uint64_t TimerManager::CreateTimer(int type, timerNumber = random_(); } auto timerInfo = std::make_shared(TimerEntry { - timerNumber, + timerNumber, type, - windowLength, - interval, - flag, - std::move(callback), + windowLength, + interval, + flag, + std::move(callback), uid }); std::lock_guard lock(entryMapMutex_); @@ -151,7 +151,7 @@ void TimerManager::SetHandler(uint64_t id, uint64_t windowLength, uint64_t interval, int flag, - std::function callback, + std::function callback, uint64_t uid) { TIME_HILOGI(TIME_MODULE_SERVICE, "start id: %{public}" PRId64 "", id); @@ -236,7 +236,7 @@ void TimerManager::RemoveLocked(uint64_t id) }; bool didRemove = false; - for (auto it = alarmBatches_.begin(); it != alarmBatches_.end(); ) { + for (auto it = alarmBatches_.begin(); it != alarmBatches_.end();) { auto batch = *it; didRemove = batch->Remove(whichAlarms); if (batch->Size() == 0) { @@ -343,8 +343,8 @@ void TimerManager::TimerLooper() lastTimeChangeClockTime = lastTimeChangeClockTime_; expectedClockTime = lastTimeChangeClockTime + (duration_cast(nowElapsed.time_since_epoch()) - duration_cast(lastTimeChangeRealtime_.time_since_epoch())); - if (lastTimeChangeClockTime == system_clock::time_point::min() - || nowRtc < (expectedClockTime - milliseconds(ONE_THOUSAND)) + if (lastTimeChangeClockTime == system_clock::time_point::min() + || nowRtc < (expectedClockTime - milliseconds(ONE_THOUSAND)) || nowRtc > (expectedClockTime + milliseconds(ONE_THOUSAND))) { TIME_HILOGI(TIME_MODULE_SERVICE, "Time changed notification from kernel; rebatching"); ReBatchAllTimers(); @@ -399,7 +399,7 @@ bool TimerManager::TriggerTimersLocked(std::vector> & alarm->count = 1; triggerList.push_back(alarm); if (alarm->repeatInterval > milliseconds::zero()) { - alarm->count += duration_cast(nowElapsed - + alarm->count += duration_cast(nowElapsed - alarm->expectedWhenElapsed) / alarm->repeatInterval; auto delta = alarm->count * alarm->repeatInterval; auto nextElapsed = alarm->whenElapsed + delta; @@ -412,7 +412,7 @@ bool TimerManager::TriggerTimersLocked(std::vector> & } } } - std::sort(triggerList.begin(), + std::sort(triggerList.begin(), triggerList.end(), [] (const std::shared_ptr &l, const std::shared_ptr &r) { return l->whenElapsed < r->whenElapsed; @@ -508,19 +508,19 @@ void TimerManager::DeliverTimersLocked(const std::vector> &list, const std::shared_ptr &newBatch) { TIME_HILOGI(TIME_MODULE_SERVICE, "start"); - auto it = std::upper_bound(list.begin(), - list.end(), + auto it = std::upper_bound(list.begin(), + list.end(), newBatch, [](const std::shared_ptr &first, const std::shared_ptr &second) { - return first->GetStart() < second->GetStart(); - }); + return first->GetStart() < second->GetStart(); + }); list.insert(it, newBatch); TIME_HILOGI(TIME_MODULE_SERVICE, "end"); return it == list.begin(); } -steady_clock::time_point MaxTriggerTime(steady_clock::time_point now, - steady_clock::time_point triggerAtTime, +steady_clock::time_point MaxTriggerTime(steady_clock::time_point now, + steady_clock::time_point triggerAtTime, milliseconds interval) { milliseconds futurity = (interval == milliseconds::zero()) ?