Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>

Changes to be committed:
This commit is contained in:
ma-shaoyin 2023-07-18 11:31:01 +08:00
parent 38b73b0310
commit 4c8d8e0bbc
2 changed files with 3 additions and 4 deletions

View File

@ -65,7 +65,7 @@ private:
static std::map<int32_t, int32_t> inputmethodBehaviour_;
std::mutex behaviourMutex_;
sptr<Utils::Timer> timer_ = nullptr;
std::shared_ptr<Utils::Timer> timer_ = nullptr;
int32_t userId_ = 0;
uint32_t timerId_ = 0;
std::mutex timerLock_;

View File

@ -153,11 +153,10 @@ bool InputMethodSysEvent::StartTimer(const TimerCallback &callback, uint32_t int
{
IMSA_HILOGD("run in");
if (timer_ == nullptr) {
timer_ = new Utils::Timer("imfTimer");
timer_ = std::make_shared<Utils::Timer>("imfTimer");
uint32_t ret = timer_->Setup();
if (ret != Utils::TIMER_ERR_OK) {
IMSA_HILOGE("Create Timer error");
isTimerStart_ = false;
return false;
}
timerId_ = timer_->Register(callback, interval, true);
@ -172,7 +171,7 @@ bool InputMethodSysEvent::StartTimer(const TimerCallback &callback, uint32_t int
bool InputMethodSysEvent::StartTimerForReport()
{
IMSA_HILOGD("run in");
auto reportCallback = []() { ImeUsageBehaviourReporter(); };
auto reportCallback = [this]() { ImeUsageBehaviourReporter(); };
std::lock_guard<std::mutex> lock(timerLock_);
StartTimer(reportCallback, ONE_DAY_IN_HOURS * ONE_HOUR_IN_SECONDS * SECONDS_TO_MILLISECONDS);
return false;