diff --git a/frameworks/include/context/js_ability.h b/frameworks/include/context/js_ability.h index 1da3bc1fb6461c0a7e641d54a3b7d9ab8675508c..eef0183847b927e9eb71e57e016175a0df221822 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 59ce1f6f2653ee8759b506ec365b44a7a9230314..7e96eded65f176715253d0bc91c914b0f9013931 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) {