diff --git a/frameworks/native/appkit/dfr/watchdog.cpp b/frameworks/native/appkit/dfr/watchdog.cpp index f701d55f71bc3cdba9d6f43316d88bd500a77b51..1539aa153bc877c94828c0cf62a3deefad4eea20 100644 --- a/frameworks/native/appkit/dfr/watchdog.cpp +++ b/frameworks/native/appkit/dfr/watchdog.cpp @@ -171,7 +171,6 @@ void Watchdog::AllowReportEvent() std::unique_lock lock(cvMutex_); needReport_.store(true); isSixSecondEvent_.store(false); - backgroundReportCount_.store(0); watchdogReportCount_.store(0); } @@ -267,14 +266,12 @@ void Watchdog::ReportEvent() return; } - if (isInBackground_ && backgroundReportCount_.load() < BACKGROUND_REPORT_COUNT_MAX) { + if (isInBackground_) { TAG_LOGI(AAFwkTag::APPDFR, "In Background, thread may be blocked in, not report time" "currTime: %{public}" PRIu64 ", lastTime: %{public}" PRIu64 "", static_cast(now), static_cast(lastWatchTime_)); - backgroundReportCount_++; return; } - backgroundReportCount_++; if (!needReport_) { return; diff --git a/interfaces/kits/native/appkit/dfr/watchdog.h b/interfaces/kits/native/appkit/dfr/watchdog.h index 4e220bc03f71e2c74c9b35c429aa0ebea9c4a5d8..7b6b62095ad3ae74c5c388ecc6aeb876b134d0f1 100644 --- a/interfaces/kits/native/appkit/dfr/watchdog.h +++ b/interfaces/kits/native/appkit/dfr/watchdog.h @@ -122,7 +122,6 @@ private: std::atomic_bool isSixSecondEvent_ = false; std::atomic_bool isInBackground_ = true; std::atomic_bool isBgWorkingThread_ = false; - std::atomic_int backgroundReportCount_ = 0; std::atomic_int watchdogReportCount_ = 0; std::mutex cvMutex_; std::condition_variable cvWatchdog_; diff --git a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp index 6b1b7e8d0e24d609a037e5749c0559477cee1990..1d89f5a6256cd641b7ff82b8d775530c6cf0c6fe 100644 --- a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp +++ b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp @@ -492,9 +492,7 @@ HWTEST_F(WatchdogTest, WatchdogTest_ReportEvent_009, TestSize.Level1) watchdog_->lastWatchTime_ = std::chrono::duration_cast(std::chrono:: system_clock::now().time_since_epoch()).count() - TEST_INTERVAL_TIME; watchdog_->isInBackground_ = true; - watchdog_->backgroundReportCount_ = 0; watchdog_->ReportEvent(); - EXPECT_EQ(watchdog_->backgroundReportCount_, 1); watchdog_->SetBundleInfo("test", "1.1.0"); watchdog_->SetBgWorkingThreadStatus(false); } @@ -508,7 +506,6 @@ HWTEST_F(WatchdogTest, WatchdogTest_ReportEvent_010, TestSize.Level1) watchdog_->lastWatchTime_ = std::chrono::duration_cast(std::chrono:: system_clock::now().time_since_epoch()).count() - TEST_INTERVAL_TIME; watchdog_->isInBackground_ = false; - watchdog_->backgroundReportCount_ = 0; watchdog_->isBgWorkingThread_ = false; watchdog_->needReport_ = false; watchdog_->ReportEvent(); @@ -517,7 +514,7 @@ HWTEST_F(WatchdogTest, WatchdogTest_ReportEvent_010, TestSize.Level1) watchdog_->ReportEvent(); watchdog_->isSixSecondEvent_ = false; watchdog_->ReportEvent(); - EXPECT_TRUE(watchdog_->backgroundReportCount_ > 0 && watchdog_->backgroundReportCount_.load() < 5); + EXPECT_TRUE(watchdog_ != nullptr); } #ifdef ABILITY_RUNTIME_HITRACE_ENABLE