diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 0c3a5a2a723b8739fec60e3b5b5a45dfc7f4167e..e9d156d4febc29d0212936de3a9aa5a33e913c79 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1500,18 +1500,18 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con TAG_LOGE(AAFwkTag::APPKIT, "null bundleMgrHelper"); return; } - - auto bundleName = appInfo.bundleName; - auto tmpWatchdog = watchdog_; - if (tmpWatchdog != nullptr) { - tmpWatchdog->SetBundleInfo(bundleName, appInfo.versionName); - tmpWatchdog = nullptr; - } BundleInfo bundleInfo; + auto bundleName = appInfo.bundleName; if (!GetBundleForLaunchApplication(bundleMgrHelper, bundleName, appLaunchData.GetAppIndex(), bundleInfo)) { TAG_LOGE(AAFwkTag::APPKIT, "get bundleInfo failed"); return; } + auto tmpWatchdog = watchdog_; + bool isSystemApp = bundleInfo.applicationInfo.isSystemApp; + if (tmpWatchdog != nullptr) { + tmpWatchdog->SetBundleInfo(bundleName, appInfo.versionName, isSystemApp); + tmpWatchdog = nullptr; + } bool moduelJson = false; bool isStageBased = false; @@ -1639,7 +1639,6 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con } GetNativeLibPath(bundleInfo, hspList, appLibPaths); - bool isSystemApp = bundleInfo.applicationInfo.isSystemApp; TAG_LOGD(AAFwkTag::APPKIT, "the application isSystemApp: %{public}d", isSystemApp); #ifdef CJ_FRONTEND AbilityRuntime::CJRuntime::SetAppVersion(bundleInfo.applicationInfo.compileSdkVersion); diff --git a/frameworks/native/appkit/dfr/watchdog.cpp b/frameworks/native/appkit/dfr/watchdog.cpp index 8026e3370c3f5860f13449d27fd9e357714a8023..06904b3e258ae731fd70ec18706f61ac10eea81b 100644 --- a/frameworks/native/appkit/dfr/watchdog.cpp +++ b/frameworks/native/appkit/dfr/watchdog.cpp @@ -163,9 +163,9 @@ void Watchdog::ChangeTimeOut(const std::string& bundleName) } #endif -void Watchdog::SetBundleInfo(const std::string& bundleName, const std::string& bundleVersion) +void Watchdog::SetBundleInfo(const std::string& bundleName, const std::string& bundleVersion, bool isSystemApp) { - OHOS::HiviewDFX::Watchdog::GetInstance().SetBundleInfo(bundleName, bundleVersion); + OHOS::HiviewDFX::Watchdog::GetInstance().SetBundleInfo(bundleName, bundleVersion, isSystemApp); #ifdef APP_NO_RESPONSE_DIALOG if (isDeviceType2in1()) { ChangeTimeOut(bundleName); diff --git a/interfaces/kits/native/appkit/dfr/watchdog.h b/interfaces/kits/native/appkit/dfr/watchdog.h index 438d2cd6d5bfcd8924616da3571e1189ad55fc0f..211e6a242e9bb2a366f572a47185c74777efb57e 100644 --- a/interfaces/kits/native/appkit/dfr/watchdog.h +++ b/interfaces/kits/native/appkit/dfr/watchdog.h @@ -98,7 +98,7 @@ public: * @brief Set bundle info. * */ - void SetBundleInfo(const std::string& bundleName, const std::string& bundleVersion); + void SetBundleInfo(const std::string& bundleName, const std::string& bundleVersion, bool isSystemApp); /** * @@ -130,6 +130,7 @@ private: static std::shared_ptr appMainHandler_; int64_t lastWatchTime_ = 0; std::string bundleName_; + bool isSystemApp_ = true; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp index 74b27923f73bb64e49cd486390e374a0fb9255f4..00729625e91308f68f7b754c18081453a3a3603e 100644 --- a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp +++ b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp @@ -493,7 +493,7 @@ HWTEST_F(WatchdogTest, WatchdogTest_ReportEvent_009, TestSize.Level1) system_clock::now().time_since_epoch()).count() - TEST_INTERVAL_TIME; watchdog_->isInBackground_ = true; watchdog_->ReportEvent(); - watchdog_->SetBundleInfo("test", "1.1.0"); + watchdog_->SetBundleInfo("test", "1.1.0", true); watchdog_->SetBgWorkingThreadStatus(false); }