From 6f426ba3894f4a82e44f78a81c86de2cb423259e Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Mon, 28 Jun 2021 10:04:31 +0800 Subject: [PATCH 1/6] fix forcestopbundle life cycle --- services/abilitymgr_lite/src/ability_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index 4cd2f32..fdd7885 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -233,7 +233,7 @@ int32_t AbilityService::ForceStopBundle(uint16_t token) return PARAM_NULL_ERROR; } if (launcherRecord->GetState() != SCHEDULE_ACTIVE) { - return SchedulerLifecycleInner(LAUNCHER_TOKEN, STATE_ACTIVE); + return SchedulerLifecycle(LAUNCHER_TOKEN, STATE_ACTIVE); } return ERR_OK; } -- Gitee From 0736988b1065f12580d71b4125ac7f9b6bc76c4b Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Sat, 10 Jul 2021 21:02:06 +0800 Subject: [PATCH 2/6] add forcestop and callbackfunc and jstojs --- .../src/slite/ability_manager_inner.cpp | 13 ++++++++ .../src/slite/abilityms_slite_client.cpp | 16 +++++++++ .../ability_service_interface.h | 1 + .../slite/ability_manager_inner.h | 15 +++++++++ .../abilitymgr_lite/include/ability_service.h | 1 + .../src/ability_mgr_service.cpp | 3 ++ .../abilitymgr_lite/src/ability_service.cpp | 33 +++++++++++++++++-- 7 files changed, 80 insertions(+), 2 deletions(-) diff --git a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp index b5759c2..3c1103c 100755 --- a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp +++ b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp @@ -17,9 +17,12 @@ #include "abilityms_slite_client.h" +StartCheckFunc CALLBACKFUNC; + extern "C" { int RegAbilityCallback(StartCheckFunc startChecktCallback) { + CALLBACKFUNC = startChecktCallback; return 0; } @@ -32,4 +35,14 @@ int ForceStopBundle(uint64_t token) { return OHOS::AbilityMsClient::GetInstance().ForceStopBundle(token); } + +int ForceStop(char *bundlename) +{ + return OHOS::AbilityMsClient::GetInstance().ForceStop(bundlename); +} + +StartCheckFunc getAbilityCallback() +{ + return CALLBACKFUNC +} } diff --git a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp index 5852ee8..6c5006c 100755 --- a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp +++ b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp @@ -135,4 +135,20 @@ ElementName *AbilityMsClient::GetTopAbility() const } return amsProxy_->GetTopAbility(); } + +int AbilityMsClient::ForceStop(char *bundlename) const +{ + AbilityMgrService *service = AbilityMgrService::GetInstance(); + if (service == nullptr) { + return PARAM_CHECK_ERROR; + } + char* name = Utils::Strdup(bundlename); + Request request = { + .msgId = TERMINATE_APP_BY_BUNDLENAME, + .data = reinterpret_cast(name), + .len = strlen(name), + } + + return SAMGR_SendRequest(service->GetIdentity(), &request, nullptr); +} } // namespace OHOS diff --git a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h index 353da6d..de91cb6 100755 --- a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h +++ b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h @@ -45,6 +45,7 @@ enum AmsCommand { TERMINATE_APP = INNER_BEGIN, DUMP_ABILITY, COMMAND_END, + TERMINATE_APP_BY_BUNDLENAME, }; /** diff --git a/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h b/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h index 37d9e88..f5fb634 100755 --- a/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h +++ b/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h @@ -59,6 +59,21 @@ int ForceStopBundle(uint64_t token); * @return Returns the element name of the top ability. */ ElementName *GetTopAbility(); + +/** + * @brief Forcestop an ability based on the specified bundlename information. + * + * @param bundlename Indicates the bundlename of the ability. + * @return Returns 0 if this function is successfully called; returns another value otherwise. + */ +int ForceStop(char *bundlename); + +/** + * @brief get ability callback function + * + * @return Returns the ability callback function + */ +StartCheckFunc getAbilityCallback(); #ifdef __cplusplus #if __cplusplus } diff --git a/services/abilitymgr_lite/include/ability_service.h b/services/abilitymgr_lite/include/ability_service.h index 3ffbabf..787a723 100755 --- a/services/abilitymgr_lite/include/ability_service.h +++ b/services/abilitymgr_lite/include/ability_service.h @@ -45,6 +45,7 @@ public: ~AbilityService() override; int32_t StartAbility(const Want *want); int32_t TerminateAbility(uint16_t token); + int32_t ForceStop(char *bundlename); int32_t ForceStopBundle(uint16_t token); int32_t SchedulerLifecycleDone(uint64_t token, int32_t state); ElementName *GetTopAbility(); diff --git a/services/abilitymgr_lite/src/ability_mgr_service.cpp b/services/abilitymgr_lite/src/ability_mgr_service.cpp index 385e190..07af420 100755 --- a/services/abilitymgr_lite/src/ability_mgr_service.cpp +++ b/services/abilitymgr_lite/src/ability_mgr_service.cpp @@ -90,6 +90,9 @@ BOOL AbilityMgrService::ServiceMessageHandle(Service *service, Request *request) ret = AbilityService::GetInstance().TerminateAbility(request->msgValue); } else if (request->msgId == TERMINATE_APP) { ret = AbilityService::GetInstance().ForceStopBundle(request->msgValue); + } else if (request->msgId == TERMINATE_APP_BY_BUNDLENAME) { + char* bundleName = reinterpret_cast(request->data) + ret = AbilityService::GetInstance().ForceStop(bundleName); } return ret == ERR_OK; #else diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index fdd7885..846c843 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -24,6 +24,7 @@ #include "ability_stack.h" #include "ability_state.h" #include "abilityms_log.h" +#include "ability_manager_inner.h" #include "bundle_manager.h" #include "cmsis_os.h" #include "js_app_host.h" @@ -175,7 +176,9 @@ int32_t AbilityService::StartAbility(AbilitySvcInfo *info) HILOG_INFO(HILOG_MODULE_AAFWK, "Js app already started or starting."); } else { // TODO ��֮ǰ��jsӦ�ò���һ��Ӧ�� JS2JS��������Ҫ�Ȱ�֮ǰ��JS�˳� - return ERR_OK; + HILOG_INFO(HILOG_MODULE_AAFWK, "Terminate pre js app when js to js") + TerminateAbility(topRecord->GetToken()); + pendingToken_ = GenerateToken() } } @@ -238,6 +241,23 @@ int32_t AbilityService::ForceStopBundle(uint16_t token) return ERR_OK; } +int32_t AbilityService::ForceStop(char* bundlename) +{ + //stop Launcher + if (strcmp(bundlename, LAUNCHER_BUNDLE_NAME) == 0) { + return TerminateAbility(0); + } + + //stop js app + if (strcmp(GetTopAbility()->bundlename, bundlename) == 0) { + HILOG_INFO(HILOG_MODULE_AAFWK, "ForceStop [%s]", bundlename); + AbilityRecord *topRecord = const_cast(abilityStack_.GetTopAbility()); + return TerminateAbility(topRecord->GetToken()); + } + + return PARAM_CHECK_ERROR; +} + int32_t AbilityService::ForceStopBundleInner(uint16_t token) { // free js mem and delete the record @@ -271,13 +291,17 @@ int32_t AbilityService::PreCheckStartAbility( return ERR_OK; } auto record = new AbilityRecord(); + if (pendingToken_ != 0) { + record->SetToken(pendingToken_); + } else { record->SetToken(GenerateToken()); + } record->SetAppName(bundleName); record->SetAppPath(path); record->SetAppData(data, dataLength); record->SetState(SCHEDULE_STOP); abilityList_.Add(record); - if (CreateAppTask(record) != ERR_OK) { + if (pendingToken_ == 0 && CreateAppTask(record) != ERR_OK) { HILOG_ERROR(HILOG_MODULE_AAFWK, "CheckResponse CreateAppTask fail"); abilityList_.Erase(record->GetToken()); delete record; @@ -288,6 +312,11 @@ int32_t AbilityService::PreCheckStartAbility( bool AbilityService::CheckResponse(const char *bundleName) { + StartCheckFunc callBackFunc = getAbilityCallback(); + if (callBackFunc != nullptr) { + int ret = (*callBackFunc)(bundleName); + return (ret == 0) ? true : false; + } return true; } -- Gitee From ad78caac5b88faaf466332502b8cd6c43440d7f7 Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Sat, 10 Jul 2021 21:02:06 +0800 Subject: [PATCH 3/6] add forcestop and callbackfunc and jstojs --- .../src/slite/ability_manager_inner.cpp | 13 +++++++ .../src/slite/abilityms_slite_client.cpp | 16 +++++++++ .../ability_service_interface.h | 1 + .../slite/ability_manager_inner.h | 15 ++++++++ .../abilitymgr_lite/include/ability_service.h | 1 + .../src/ability_mgr_service.cpp | 3 ++ .../abilitymgr_lite/src/ability_service.cpp | 34 +++++++++++++++++-- 7 files changed, 80 insertions(+), 3 deletions(-) diff --git a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp index b5759c2..3c1103c 100755 --- a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp +++ b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp @@ -17,9 +17,12 @@ #include "abilityms_slite_client.h" +StartCheckFunc CALLBACKFUNC; + extern "C" { int RegAbilityCallback(StartCheckFunc startChecktCallback) { + CALLBACKFUNC = startChecktCallback; return 0; } @@ -32,4 +35,14 @@ int ForceStopBundle(uint64_t token) { return OHOS::AbilityMsClient::GetInstance().ForceStopBundle(token); } + +int ForceStop(char *bundlename) +{ + return OHOS::AbilityMsClient::GetInstance().ForceStop(bundlename); +} + +StartCheckFunc getAbilityCallback() +{ + return CALLBACKFUNC +} } diff --git a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp index 5852ee8..6c5006c 100755 --- a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp +++ b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp @@ -135,4 +135,20 @@ ElementName *AbilityMsClient::GetTopAbility() const } return amsProxy_->GetTopAbility(); } + +int AbilityMsClient::ForceStop(char *bundlename) const +{ + AbilityMgrService *service = AbilityMgrService::GetInstance(); + if (service == nullptr) { + return PARAM_CHECK_ERROR; + } + char* name = Utils::Strdup(bundlename); + Request request = { + .msgId = TERMINATE_APP_BY_BUNDLENAME, + .data = reinterpret_cast(name), + .len = strlen(name), + } + + return SAMGR_SendRequest(service->GetIdentity(), &request, nullptr); +} } // namespace OHOS diff --git a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h index 353da6d..de91cb6 100755 --- a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h +++ b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h @@ -45,6 +45,7 @@ enum AmsCommand { TERMINATE_APP = INNER_BEGIN, DUMP_ABILITY, COMMAND_END, + TERMINATE_APP_BY_BUNDLENAME, }; /** diff --git a/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h b/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h index 37d9e88..f5fb634 100755 --- a/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h +++ b/interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h @@ -59,6 +59,21 @@ int ForceStopBundle(uint64_t token); * @return Returns the element name of the top ability. */ ElementName *GetTopAbility(); + +/** + * @brief Forcestop an ability based on the specified bundlename information. + * + * @param bundlename Indicates the bundlename of the ability. + * @return Returns 0 if this function is successfully called; returns another value otherwise. + */ +int ForceStop(char *bundlename); + +/** + * @brief get ability callback function + * + * @return Returns the ability callback function + */ +StartCheckFunc getAbilityCallback(); #ifdef __cplusplus #if __cplusplus } diff --git a/services/abilitymgr_lite/include/ability_service.h b/services/abilitymgr_lite/include/ability_service.h index 3ffbabf..787a723 100755 --- a/services/abilitymgr_lite/include/ability_service.h +++ b/services/abilitymgr_lite/include/ability_service.h @@ -45,6 +45,7 @@ public: ~AbilityService() override; int32_t StartAbility(const Want *want); int32_t TerminateAbility(uint16_t token); + int32_t ForceStop(char *bundlename); int32_t ForceStopBundle(uint16_t token); int32_t SchedulerLifecycleDone(uint64_t token, int32_t state); ElementName *GetTopAbility(); diff --git a/services/abilitymgr_lite/src/ability_mgr_service.cpp b/services/abilitymgr_lite/src/ability_mgr_service.cpp index 385e190..07af420 100755 --- a/services/abilitymgr_lite/src/ability_mgr_service.cpp +++ b/services/abilitymgr_lite/src/ability_mgr_service.cpp @@ -90,6 +90,9 @@ BOOL AbilityMgrService::ServiceMessageHandle(Service *service, Request *request) ret = AbilityService::GetInstance().TerminateAbility(request->msgValue); } else if (request->msgId == TERMINATE_APP) { ret = AbilityService::GetInstance().ForceStopBundle(request->msgValue); + } else if (request->msgId == TERMINATE_APP_BY_BUNDLENAME) { + char* bundleName = reinterpret_cast(request->data) + ret = AbilityService::GetInstance().ForceStop(bundleName); } return ret == ERR_OK; #else diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index fdd7885..42d0038 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -24,6 +24,7 @@ #include "ability_stack.h" #include "ability_state.h" #include "abilityms_log.h" +#include "ability_manager_inner.h" #include "bundle_manager.h" #include "cmsis_os.h" #include "js_app_host.h" @@ -175,7 +176,9 @@ int32_t AbilityService::StartAbility(AbilitySvcInfo *info) HILOG_INFO(HILOG_MODULE_AAFWK, "Js app already started or starting."); } else { // TODO ��֮ǰ��jsӦ�ò���һ��Ӧ�� JS2JS��������Ҫ�Ȱ�֮ǰ��JS�˳� - return ERR_OK; + HILOG_INFO(HILOG_MODULE_AAFWK, "Terminate pre js app when js to js") + TerminateAbility(topRecord->GetToken()); + pendingToken_ = GenerateToken() } } @@ -238,6 +241,23 @@ int32_t AbilityService::ForceStopBundle(uint16_t token) return ERR_OK; } +int32_t AbilityService::ForceStop(char* bundlename) +{ + //stop Launcher + if (strcmp(bundlename, LAUNCHER_BUNDLE_NAME) == 0) { + return TerminateAbility(0); + } + + //stop js app + if (strcmp(GetTopAbility()->bundlename, bundlename) == 0) { + HILOG_INFO(HILOG_MODULE_AAFWK, "ForceStop [%s]", bundlename); + AbilityRecord *topRecord = const_cast(abilityStack_.GetTopAbility()); + return TerminateAbility(topRecord->GetToken()); + } + + return PARAM_CHECK_ERROR; +} + int32_t AbilityService::ForceStopBundleInner(uint16_t token) { // free js mem and delete the record @@ -271,13 +291,17 @@ int32_t AbilityService::PreCheckStartAbility( return ERR_OK; } auto record = new AbilityRecord(); + if (pendingToken_ != 0) { + record->SetToken(pendingToken_); + } else { record->SetToken(GenerateToken()); + } record->SetAppName(bundleName); record->SetAppPath(path); record->SetAppData(data, dataLength); record->SetState(SCHEDULE_STOP); abilityList_.Add(record); - if (CreateAppTask(record) != ERR_OK) { + if (pendingToken_ == 0 && CreateAppTask(record) != ERR_OK) { HILOG_ERROR(HILOG_MODULE_AAFWK, "CheckResponse CreateAppTask fail"); abilityList_.Erase(record->GetToken()); delete record; @@ -288,6 +312,11 @@ int32_t AbilityService::PreCheckStartAbility( bool AbilityService::CheckResponse(const char *bundleName) { + StartCheckFunc callBackFunc = getAbilityCallback(); + if (callBackFunc != nullptr) { + int ret = (*callBackFunc)(bundleName); + return (ret == 0) ? true : false; + } return true; } @@ -411,7 +440,6 @@ void AbilityService::OnBackgroundDone(uint16_t token) if (token != LAUNCHER_TOKEN) { if (topRecord->GetToken() == token) { APP_EVENT(MT_ACE_APP_BACKGROUND); - topRecord->SetTerminated(true); (void) SchedulerLifecycle(LAUNCHER_TOKEN, STATE_ACTIVE); } return; -- Gitee From 3cd295c31ffefe89ba7638961ebddeaed1f2bd89 Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Wed, 14 Jul 2021 21:08:53 +0800 Subject: [PATCH 4/6] fix commiters --- .../ability_service_interface.h | 2 +- .../abilitymgr_lite/src/ability_service.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h index de91cb6..ee1f644 100755 --- a/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h +++ b/interfaces/innerkits/abilitymgr_lite/ability_service_interface.h @@ -44,8 +44,8 @@ enum AmsCommand { INNER_BEGIN, TERMINATE_APP = INNER_BEGIN, DUMP_ABILITY, - COMMAND_END, TERMINATE_APP_BY_BUNDLENAME, + COMMAND_END, }; /** diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index 01d912a..7755ebf 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -175,7 +175,7 @@ int32_t AbilityService::StartAbility(AbilitySvcInfo *info) } HILOG_INFO(HILOG_MODULE_AAFWK, "Js app already started or starting."); } else { - // TODO ��֮ǰ��jsӦ�ò���һ��Ӧ�� JS2JS��������Ҫ�Ȱ�֮ǰ��JS�˳� + // js to js HILOG_INFO(HILOG_MODULE_AAFWK, "Terminate pre js app when js to js") TerminateAbility(topRecord->GetToken()); pendingToken_ = GenerateToken() @@ -195,9 +195,9 @@ int32_t AbilityService::TerminateAbility(uint16_t token) return PARAM_NULL_ERROR; } uint16_t topToken = topRecord->GetToken(); - // TODO CHECK terminate ����,�Ƿ��иó����� + // TODO CHECK terminate token if (token == LAUNCHER_TOKEN) { - // �����ǰjs�ں�̨, �������˺�̨��js�ߵ�ǰ̨ + // if js is in background, the launcher goes back to background and js goes to active if (topToken != token && topRecord->GetState() == SCHEDULE_BACKGROUND) { HILOG_INFO(HILOG_MODULE_AAFWK, "Resume Js app [%u]", topToken); return SchedulerLifecycle(LAUNCHER_TOKEN, STATE_BACKGROUND); @@ -205,14 +205,13 @@ int32_t AbilityService::TerminateAbility(uint16_t token) return ERR_OK; } - // TODO CHECK�Ƿ��иó��� if (token != topToken) { APP_ERRCODE_EXTRA(EXCE_ACE_APP_START, EXCE_ACE_APP_STOP_UNKNOWN_ABILITY_TOKEN); DeleteRecordInfo(token); return -1; } topRecord->SetTerminated(true); - // TerminateAbility TOP��js + // TerminateAbility top js return SchedulerLifecycleInner(topRecord, STATE_BACKGROUND); } @@ -315,7 +314,10 @@ bool AbilityService::CheckResponse(const char *bundleName) StartCheckFunc callBackFunc = getAbilityCallback(); if (callBackFunc != nullptr) { int ret = (*callBackFunc)(bundleName); - return (ret == 0) ? true : false; + if (ret != ERR_OK) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "calling ability callback failed bundlename is: [%s]", bundleName); + return false; + } } return true; } @@ -511,7 +513,7 @@ int32_t AbilityService::SchedulerLifecycleInner(const AbilityRecord *record, int return PARAM_NULL_ERROR; } // dispatch js life cycle - if (record->GetToken() != LAUNCHER_TOKEN) { // jsӦ�� + if (record->GetToken() != LAUNCHER_TOKEN) { (void) SendMsgToJsAbility(state, record); return ERR_OK; } @@ -519,7 +521,7 @@ int32_t AbilityService::SchedulerLifecycleInner(const AbilityRecord *record, int if (g_NativeAbility == nullptr) { return PARAM_NULL_ERROR; } - // ����want�ڴ棬�ڷ���������ͷ� + // malloc want memory and release after use Want *info = static_cast(AdapterMalloc(sizeof(Want))); if (info == nullptr) { return MEMORY_MALLOC_ERROR; -- Gitee From 2ef2e0ce934ac6831cf7522a65fc16def1609658 Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Fri, 16 Jul 2021 10:45:12 +0800 Subject: [PATCH 5/6] move kernel include and fix bugs --- frameworks/ability_lite/BUILD.gn | 2 -- frameworks/ability_lite/example/BUILD.gn | 2 -- frameworks/abilitymgr_lite/BUILD.gn | 2 -- frameworks/abilitymgr_lite/include/abilityms_slite_client.h | 2 ++ .../abilitymgr_lite/src/slite/ability_manager_inner.cpp | 4 ++-- frameworks/want_lite/BUILD.gn | 2 -- services/abilitymgr_lite/BUILD.gn | 2 -- services/abilitymgr_lite/src/ability_mgr_service.cpp | 2 +- services/abilitymgr_lite/src/ability_service.cpp | 4 ++-- services/abilitymgr_lite/tools/BUILD.gn | 2 -- .../unittest/test_lv0/page_ability_test/BUILD.gn | 2 -- 11 files changed, 7 insertions(+), 19 deletions(-) diff --git a/frameworks/ability_lite/BUILD.gn b/frameworks/ability_lite/BUILD.gn index 85b1a61..c57d378 100755 --- a/frameworks/ability_lite/BUILD.gn +++ b/frameworks/ability_lite/BUILD.gn @@ -79,8 +79,6 @@ lite_library("ability") { "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//foundation/communication/ipc_lite/frameworks/liteipc/include", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//third_party/freetype/include", "//utils/native/lite/kv_store/innerkits", diff --git a/frameworks/ability_lite/example/BUILD.gn b/frameworks/ability_lite/example/BUILD.gn index 5005a7e..d568217 100644 --- a/frameworks/ability_lite/example/BUILD.gn +++ b/frameworks/ability_lite/example/BUILD.gn @@ -47,8 +47,6 @@ lite_library("hiability") { "//foundation/graphic/utils/interfaces/innerkits", "//foundation/graphic/ui/interfaces/kits", "//foundation/graphic/utils/interfaces/kits/gfx_utils", - "//kernel/liteos_a/kernel/common", - "//kernel/liteos_a/kernel/include", ] deps = [ diff --git a/frameworks/abilitymgr_lite/BUILD.gn b/frameworks/abilitymgr_lite/BUILD.gn index e6f6180..e66514c 100755 --- a/frameworks/abilitymgr_lite/BUILD.gn +++ b/frameworks/abilitymgr_lite/BUILD.gn @@ -41,8 +41,6 @@ lite_library("abilitymanager") { "${appexecfwk_lite_path}/frameworks/bundle_lite/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//utils/native/lite/kv_store/innerkits", "//utils/native/lite/include", diff --git a/frameworks/abilitymgr_lite/include/abilityms_slite_client.h b/frameworks/abilitymgr_lite/include/abilityms_slite_client.h index 21e71ed..a87d3d3 100755 --- a/frameworks/abilitymgr_lite/include/abilityms_slite_client.h +++ b/frameworks/abilitymgr_lite/include/abilityms_slite_client.h @@ -42,6 +42,8 @@ public: int ForceStopBundle(uint64_t token) const; + int ForceStop(char *bundlename) const; + ElementName *GetTopAbility() const; private: diff --git a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp index 3c1103c..e79972f 100755 --- a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp +++ b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp @@ -17,7 +17,7 @@ #include "abilityms_slite_client.h" -StartCheckFunc CALLBACKFUNC; +StartCheckFunc CALLBACKFUNC = nullptr; extern "C" { int RegAbilityCallback(StartCheckFunc startChecktCallback) @@ -43,6 +43,6 @@ int ForceStop(char *bundlename) StartCheckFunc getAbilityCallback() { - return CALLBACKFUNC + return CALLBACKFUNC; } } diff --git a/frameworks/want_lite/BUILD.gn b/frameworks/want_lite/BUILD.gn index 2d74e5a..016cad7 100755 --- a/frameworks/want_lite/BUILD.gn +++ b/frameworks/want_lite/BUILD.gn @@ -34,8 +34,6 @@ source_set("want") { "${appexecfwk_lite_path}/frameworks/bundle_lite/include", "${appexecfwk_lite_path}/utils/bundle_lite", "//foundation/communication/ipc_lite/interfaces/kits", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", ] defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] diff --git a/services/abilitymgr_lite/BUILD.gn b/services/abilitymgr_lite/BUILD.gn index ba3479b..072dbd0 100644 --- a/services/abilitymgr_lite/BUILD.gn +++ b/services/abilitymgr_lite/BUILD.gn @@ -83,8 +83,6 @@ lite_library("abilityms") { "//base/startup/appspawn_lite/services/include", "//base/security/permission/interfaces/kits/permission_lite", "//base/security/permission/services/permission_lite/pms/include", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//utils/native/lite/include", "include", diff --git a/services/abilitymgr_lite/src/ability_mgr_service.cpp b/services/abilitymgr_lite/src/ability_mgr_service.cpp index 07af420..ccac550 100755 --- a/services/abilitymgr_lite/src/ability_mgr_service.cpp +++ b/services/abilitymgr_lite/src/ability_mgr_service.cpp @@ -91,7 +91,7 @@ BOOL AbilityMgrService::ServiceMessageHandle(Service *service, Request *request) } else if (request->msgId == TERMINATE_APP) { ret = AbilityService::GetInstance().ForceStopBundle(request->msgValue); } else if (request->msgId == TERMINATE_APP_BY_BUNDLENAME) { - char* bundleName = reinterpret_cast(request->data) + char* bundleName = reinterpret_cast(request->data); ret = AbilityService::GetInstance().ForceStop(bundleName); } return ret == ERR_OK; diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index 7755ebf..b5e5cd6 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -178,7 +178,7 @@ int32_t AbilityService::StartAbility(AbilitySvcInfo *info) // js to js HILOG_INFO(HILOG_MODULE_AAFWK, "Terminate pre js app when js to js") TerminateAbility(topRecord->GetToken()); - pendingToken_ = GenerateToken() + pendingToken_ = GenerateToken(); } } @@ -248,7 +248,7 @@ int32_t AbilityService::ForceStop(char* bundlename) } //stop js app - if (strcmp(GetTopAbility()->bundlename, bundlename) == 0) { + if (strcmp(abilityStack_.GetTopAbility()->GetAppName(), bundlename) == 0) { HILOG_INFO(HILOG_MODULE_AAFWK, "ForceStop [%s]", bundlename); AbilityRecord *topRecord = const_cast(abilityStack_.GetTopAbility()); return TerminateAbility(topRecord->GetToken()); diff --git a/services/abilitymgr_lite/tools/BUILD.gn b/services/abilitymgr_lite/tools/BUILD.gn index 6280e90..7f5b6cd 100755 --- a/services/abilitymgr_lite/tools/BUILD.gn +++ b/services/abilitymgr_lite/tools/BUILD.gn @@ -69,8 +69,6 @@ executable("aa") { "//foundation/communication/ipc_lite/interfaces/kits", "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//third_party/cJSON", "//utils/native/lite/include", diff --git a/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn b/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn index b259a0a..db1a2a5 100644 --- a/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn +++ b/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn @@ -39,8 +39,6 @@ unittest("ability_test_pageAbilityTest_lv0") { "${appexecfwk_lite_path}/kits/appkit_lite/appkit_utils/include", "//foundation/distributedschedule/samgr_lite/interfaces/innerkits/samgr", "//foundation/distributedschedule/samgr_lite/interfaces/innerkits/registry", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/cJSON", "//utils/native/lite/include", ] -- Gitee From 36d6eba8d358d10f44c094866e5e4811ffc8fbdb Mon Sep 17 00:00:00 2001 From: Zhaoyuan Date: Fri, 16 Jul 2021 10:45:12 +0800 Subject: [PATCH 6/6] move kernel include and fix bugs Signed-off-by: Zhaoyuan --- frameworks/ability_lite/BUILD.gn | 2 -- frameworks/ability_lite/example/BUILD.gn | 2 -- frameworks/abilitymgr_lite/BUILD.gn | 2 -- frameworks/abilitymgr_lite/include/abilityms_slite_client.h | 2 ++ .../abilitymgr_lite/src/slite/ability_manager_inner.cpp | 4 ++-- frameworks/want_lite/BUILD.gn | 2 -- services/abilitymgr_lite/BUILD.gn | 2 -- services/abilitymgr_lite/src/ability_mgr_service.cpp | 2 +- services/abilitymgr_lite/src/ability_service.cpp | 4 ++-- services/abilitymgr_lite/tools/BUILD.gn | 2 -- .../unittest/test_lv0/page_ability_test/BUILD.gn | 2 -- 11 files changed, 7 insertions(+), 19 deletions(-) diff --git a/frameworks/ability_lite/BUILD.gn b/frameworks/ability_lite/BUILD.gn index 85b1a61..c57d378 100755 --- a/frameworks/ability_lite/BUILD.gn +++ b/frameworks/ability_lite/BUILD.gn @@ -79,8 +79,6 @@ lite_library("ability") { "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//foundation/communication/ipc_lite/frameworks/liteipc/include", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//third_party/freetype/include", "//utils/native/lite/kv_store/innerkits", diff --git a/frameworks/ability_lite/example/BUILD.gn b/frameworks/ability_lite/example/BUILD.gn index 5005a7e..d568217 100644 --- a/frameworks/ability_lite/example/BUILD.gn +++ b/frameworks/ability_lite/example/BUILD.gn @@ -47,8 +47,6 @@ lite_library("hiability") { "//foundation/graphic/utils/interfaces/innerkits", "//foundation/graphic/ui/interfaces/kits", "//foundation/graphic/utils/interfaces/kits/gfx_utils", - "//kernel/liteos_a/kernel/common", - "//kernel/liteos_a/kernel/include", ] deps = [ diff --git a/frameworks/abilitymgr_lite/BUILD.gn b/frameworks/abilitymgr_lite/BUILD.gn index e6f6180..e66514c 100755 --- a/frameworks/abilitymgr_lite/BUILD.gn +++ b/frameworks/abilitymgr_lite/BUILD.gn @@ -41,8 +41,6 @@ lite_library("abilitymanager") { "${appexecfwk_lite_path}/frameworks/bundle_lite/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//utils/native/lite/kv_store/innerkits", "//utils/native/lite/include", diff --git a/frameworks/abilitymgr_lite/include/abilityms_slite_client.h b/frameworks/abilitymgr_lite/include/abilityms_slite_client.h index 21e71ed..a87d3d3 100755 --- a/frameworks/abilitymgr_lite/include/abilityms_slite_client.h +++ b/frameworks/abilitymgr_lite/include/abilityms_slite_client.h @@ -42,6 +42,8 @@ public: int ForceStopBundle(uint64_t token) const; + int ForceStop(char *bundlename) const; + ElementName *GetTopAbility() const; private: diff --git a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp index 3c1103c..e79972f 100755 --- a/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp +++ b/frameworks/abilitymgr_lite/src/slite/ability_manager_inner.cpp @@ -17,7 +17,7 @@ #include "abilityms_slite_client.h" -StartCheckFunc CALLBACKFUNC; +StartCheckFunc CALLBACKFUNC = nullptr; extern "C" { int RegAbilityCallback(StartCheckFunc startChecktCallback) @@ -43,6 +43,6 @@ int ForceStop(char *bundlename) StartCheckFunc getAbilityCallback() { - return CALLBACKFUNC + return CALLBACKFUNC; } } diff --git a/frameworks/want_lite/BUILD.gn b/frameworks/want_lite/BUILD.gn index 2d74e5a..016cad7 100755 --- a/frameworks/want_lite/BUILD.gn +++ b/frameworks/want_lite/BUILD.gn @@ -34,8 +34,6 @@ source_set("want") { "${appexecfwk_lite_path}/frameworks/bundle_lite/include", "${appexecfwk_lite_path}/utils/bundle_lite", "//foundation/communication/ipc_lite/interfaces/kits", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", ] defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] diff --git a/services/abilitymgr_lite/BUILD.gn b/services/abilitymgr_lite/BUILD.gn index ba3479b..072dbd0 100644 --- a/services/abilitymgr_lite/BUILD.gn +++ b/services/abilitymgr_lite/BUILD.gn @@ -83,8 +83,6 @@ lite_library("abilityms") { "//base/startup/appspawn_lite/services/include", "//base/security/permission/interfaces/kits/permission_lite", "//base/security/permission/services/permission_lite/pms/include", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//utils/native/lite/include", "include", diff --git a/services/abilitymgr_lite/src/ability_mgr_service.cpp b/services/abilitymgr_lite/src/ability_mgr_service.cpp index 07af420..ccac550 100755 --- a/services/abilitymgr_lite/src/ability_mgr_service.cpp +++ b/services/abilitymgr_lite/src/ability_mgr_service.cpp @@ -91,7 +91,7 @@ BOOL AbilityMgrService::ServiceMessageHandle(Service *service, Request *request) } else if (request->msgId == TERMINATE_APP) { ret = AbilityService::GetInstance().ForceStopBundle(request->msgValue); } else if (request->msgId == TERMINATE_APP_BY_BUNDLENAME) { - char* bundleName = reinterpret_cast(request->data) + char* bundleName = reinterpret_cast(request->data); ret = AbilityService::GetInstance().ForceStop(bundleName); } return ret == ERR_OK; diff --git a/services/abilitymgr_lite/src/ability_service.cpp b/services/abilitymgr_lite/src/ability_service.cpp index 7755ebf..b5e5cd6 100755 --- a/services/abilitymgr_lite/src/ability_service.cpp +++ b/services/abilitymgr_lite/src/ability_service.cpp @@ -178,7 +178,7 @@ int32_t AbilityService::StartAbility(AbilitySvcInfo *info) // js to js HILOG_INFO(HILOG_MODULE_AAFWK, "Terminate pre js app when js to js") TerminateAbility(topRecord->GetToken()); - pendingToken_ = GenerateToken() + pendingToken_ = GenerateToken(); } } @@ -248,7 +248,7 @@ int32_t AbilityService::ForceStop(char* bundlename) } //stop js app - if (strcmp(GetTopAbility()->bundlename, bundlename) == 0) { + if (strcmp(abilityStack_.GetTopAbility()->GetAppName(), bundlename) == 0) { HILOG_INFO(HILOG_MODULE_AAFWK, "ForceStop [%s]", bundlename); AbilityRecord *topRecord = const_cast(abilityStack_.GetTopAbility()); return TerminateAbility(topRecord->GetToken()); diff --git a/services/abilitymgr_lite/tools/BUILD.gn b/services/abilitymgr_lite/tools/BUILD.gn index 6280e90..7f5b6cd 100755 --- a/services/abilitymgr_lite/tools/BUILD.gn +++ b/services/abilitymgr_lite/tools/BUILD.gn @@ -69,8 +69,6 @@ executable("aa") { "//foundation/communication/ipc_lite/interfaces/kits", "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/bounds_checking_function/include", "//third_party/cJSON", "//utils/native/lite/include", diff --git a/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn b/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn index b259a0a..db1a2a5 100644 --- a/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn +++ b/services/abilitymgr_lite/unittest/test_lv0/page_ability_test/BUILD.gn @@ -39,8 +39,6 @@ unittest("ability_test_pageAbilityTest_lv0") { "${appexecfwk_lite_path}/kits/appkit_lite/appkit_utils/include", "//foundation/distributedschedule/samgr_lite/interfaces/innerkits/samgr", "//foundation/distributedschedule/samgr_lite/interfaces/innerkits/registry", - "//kernel/liteos_a/kernel/include", - "//kernel/liteos_a/kernel/common", "//third_party/cJSON", "//utils/native/lite/include", ] -- Gitee