From 29901dc8ada59aab2edfc34d5494df5a02d80055 Mon Sep 17 00:00:00 2001 From: jiadexiang Date: Tue, 28 Sep 2021 11:44:07 +0800 Subject: [PATCH] Description: add system crash dfx in js ability destructor IssueNo:I4C7QJ Feature or Bugfix: Feature Binary Source:No Signed-off-by: jiadexiang --- frameworks/include/context/js_ability.h | 4 ++-- frameworks/src/core/context/js_ability.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frameworks/include/context/js_ability.h b/frameworks/include/context/js_ability.h index 1da3bc1f..eef01838 100755 --- a/frameworks/include/context/js_ability.h +++ b/frameworks/include/context/js_ability.h @@ -42,7 +42,7 @@ public: * * @brief Destructor. */ - virtual ~JSAbility() {} + virtual ~JSAbility(); /** * @fn JSAbility::Launch() @@ -127,4 +127,4 @@ private: }; // class JSAbility } // namespace ACELite } // namespace OHOS -#endif // OHOS_ACELITE_JS_ABILITY_H \ No newline at end of file +#endif // OHOS_ACELITE_JS_ABILITY_H diff --git a/frameworks/src/core/context/js_ability.cpp b/frameworks/src/core/context/js_ability.cpp index 59ce1f6f..7e96eded 100644 --- a/frameworks/src/core/context/js_ability.cpp +++ b/frameworks/src/core/context/js_ability.cpp @@ -56,6 +56,20 @@ static void DumpNativeMemoryUsage() #endif // OHOS_ACELITE_PRODUCT_WATCH } +#ifdef OHOS_ACELITE_PRODUCT_WATCH +extern "C" void RestoreSystemWrapper(const char *crashMessage); +#endif +JSAbility::~JSAbility() +{ + // check the status + if (jsAbilityImpl_ != nullptr) { +#ifdef OHOS_ACELITE_PRODUCT_WATCH + // the JSAbility instance can only be destroied after transfering the app to DESTROY state + RestoreSystemWrapper("AMS is deleting app task but without normal lifecycle transition!"); +#endif + } +} + void JSAbility::Launch(const char * const abilityPath, const char * const bundleName, uint16_t token, const char *pageInfo) { -- Gitee