diff --git a/frameworks/abilitymgr_lite/BUILD.gn b/frameworks/abilitymgr_lite/BUILD.gn index 97cce51ad72491ff00f92cce03a1e4c0868ee2ab..cd0aa46072b5fafa3ecd0c314254530c0c741844 100644 --- a/frameworks/abilitymgr_lite/BUILD.gn +++ b/frameworks/abilitymgr_lite/BUILD.gn @@ -21,7 +21,9 @@ lite_library("abilitymanager") { sources = [ "src/slite/ability_manager.cpp", + "src/slite/ability_manager_client.cpp", "src/slite/ability_manager_inner.cpp", + "src/slite/ability_record_state_data.cpp", "src/slite/abilityms_slite_client.cpp", ] diff --git a/frameworks/abilitymgr_lite/include/slite/abilityms_slite_client.h b/frameworks/abilitymgr_lite/include/slite/abilityms_slite_client.h index 4c959e877c33c9579b0a315478385e2a0a37bc3d..9b94f330a4c0cc7372491e70180cd9c80173dbc6 100755 --- a/frameworks/abilitymgr_lite/include/slite/abilityms_slite_client.h +++ b/frameworks/abilitymgr_lite/include/slite/abilityms_slite_client.h @@ -17,6 +17,7 @@ #define OHOS_ABILITY_SLITE_ABILITYMS_SLITE_CLIENT_H #include "ability_service_interface.h" +#include "ability_record_observer.h" #include "nocopyable.h" #include "want.h" @@ -51,6 +52,9 @@ public: void SetServiceIdentity(const Identity *identity); + int32_t AddAbilityRecordObserver(AbilityRecordObserver *observer); + int32_t RemoveAbilityRecordObserver(AbilityRecordObserver *observer); + private: AbilityMsClient() = default; diff --git a/frameworks/abilitymgr_lite/src/slite/ability_manager_client.cpp b/frameworks/abilitymgr_lite/src/slite/ability_manager_client.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd20587988ce4b4002c9bff7b168eec3f239e1f4 --- /dev/null +++ b/frameworks/abilitymgr_lite/src/slite/ability_manager_client.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ability_manager_client.h" +#include "abilityms_slite_client.h" + +namespace OHOS { +namespace AbilitySlite { +AbilityManagerClient &AbilityManagerClient::GetInstance() { + static AbilityManagerClient instance; + return instance; +} + +void AbilityManagerClient::AddAbilityRecordObserver(AbilityRecordObserver *observer) +{ + AbilityMsClient::GetInstance().AddAbilityRecordObserver(observer); +} + +void AbilityManagerClient::RemoveAbilityRecordObserver(AbilityRecordObserver *observer) +{ + AbilityMsClient::GetInstance().RemoveAbilityRecordObserver(observer); +} + +} +} \ No newline at end of file diff --git a/frameworks/abilitymgr_lite/src/slite/ability_record_state_data.cpp b/frameworks/abilitymgr_lite/src/slite/ability_record_state_data.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f6aa7eccc683d877fb8b367068e89d7b48d6f0c --- /dev/null +++ b/frameworks/abilitymgr_lite/src/slite/ability_record_state_data.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ability_record_state_data.h" + +#include "adapter.h" +#include "utils.h" + +namespace OHOS { +namespace AbilitySlite { +AbilityRecordStateData::AbilityRecordStateData(const char *appName, AbilityRecordState state) +{ + SetAppName(appName); + state_ = state; +} + +AbilityRecordStateData::AbilityRecordStateData(const AbilityRecordStateData &stateData) + : AbilityRecordStateData(stateData.GetAppName(), stateData.GetState()) +{ +} + +AbilityRecordStateData &AbilityRecordStateData::operator=(const AbilityRecordStateData &stateData) +{ + if (this != &stateData) { + SetAppName(stateData.GetAppName()); + state_ = stateData.GetState(); + } + return *this; +} + +AbilityRecordStateData::~AbilityRecordStateData() +{ + AdapterFree(appName_); +} + +void AbilityRecordStateData::SetAppName(const char *name) +{ + AdapterFree(appName_); + appName_ = Utils::Strdup(name); +} +} // namespace AbilitySlite +} // namespace OHOS diff --git a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp index 91cf50fbf7fa7756bea37eafaead27ff64428923..3298c0df5fc7857d70c6de36fcd3f75324acb3aa 100644 --- a/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp +++ b/frameworks/abilitymgr_lite/src/slite/abilityms_slite_client.cpp @@ -161,6 +161,32 @@ int32_t AbilityMsClient::ForceStop(char *bundleName) const return SAMGR_SendRequest(identity_, &request, nullptr); } +int32_t AbilityMsClient::AddAbilityRecordObserver(AbilityRecordObserver *observer) +{ + if (identity_ == nullptr) { + return PARAM_CHECK_ERROR; + } + Request request = { + .msgId = ADD_ABILITY_RECORD_OBSERVER, + .msgValue = reinterpret_cast(observer), + }; + + return SAMGR_SendRequest(identity_, &request, nullptr); +} + +int32_t AbilityMsClient::RemoveAbilityRecordObserver(AbilityRecordObserver *observer) +{ + if (identity_ == nullptr) { + return PARAM_CHECK_ERROR; + } + Request request = { + .msgId = REMOVE_ABILITY_RECORD_OBSERVER, + .msgValue = reinterpret_cast(observer), + }; + + return SAMGR_SendRequest(identity_, &request, nullptr); +} + void AbilityMsClient::SetServiceIdentity(const Identity *identity) { identity_ = identity; diff --git a/interfaces/inner_api/abilitymgr_lite/ability_service_interface.h b/interfaces/inner_api/abilitymgr_lite/ability_service_interface.h index 6c3b38ac96f54f78622de2a6891b7ca3ea5cd839..00e01f1cbb6f427768b88e3fbd21079e801eaedf 100755 --- a/interfaces/inner_api/abilitymgr_lite/ability_service_interface.h +++ b/interfaces/inner_api/abilitymgr_lite/ability_service_interface.h @@ -56,6 +56,8 @@ enum AmsCommand { TERMINATE_APP = INNER_BEGIN, DUMP_ABILITY, TERMINATE_APP_BY_BUNDLENAME, + ADD_ABILITY_RECORD_OBSERVER, + REMOVE_ABILITY_RECORD_OBSERVER, COMMAND_END, }; diff --git a/interfaces/inner_api/abilitymgr_lite/slite/ability_manager_client.h b/interfaces/inner_api/abilitymgr_lite/slite/ability_manager_client.h new file mode 100644 index 0000000000000000000000000000000000000000..9e2f7a1f922f9baa5063d0f25231e39fdbd21b78 --- /dev/null +++ b/interfaces/inner_api/abilitymgr_lite/slite/ability_manager_client.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_SLITE_ABILITY_MANAGER_CLIENT_H +#define OHOS_ABILITY_SLITE_ABILITY_MANAGER_CLIENT_H + +#include "ability_record_observer.h" + +namespace OHOS { +namespace AbilitySlite { +class AbilityManagerClient { +public: + static AbilityManagerClient &GetInstance(); + + void AddAbilityRecordObserver(AbilityRecordObserver *observer); + void RemoveAbilityRecordObserver(AbilityRecordObserver *observer); + +private: + AbilityManagerClient() = default; + ~AbilityManagerClient() = default; +}; +} // AbilitySlite +} // namespace OHOS +#endif // OHOS_ABILITY_SLITE_ABILITY_MANAGER_CLIENT_H diff --git a/interfaces/inner_api/abilitymgr_lite/slite/ability_record_observer.h b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_observer.h new file mode 100644 index 0000000000000000000000000000000000000000..fd7b720cf8feda44576ba23c0d3828b8a9ba99c9 --- /dev/null +++ b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_observer.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_H +#define OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_H + +#include "ability_record_state_data.h" + +namespace OHOS { +namespace AbilitySlite { +class AbilityRecordObserver { +public: + AbilityRecordObserver() = default; + + virtual ~AbilityRecordObserver() = default; + + virtual void OnAbilityRecordStateChanged(const AbilityRecordStateData &data) {} + + virtual void OnAbilityRecordCleanup(char *appName) {} +}; +} // AbilitySlite +} // namespace OHOS +#endif // OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_H diff --git a/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state.h b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state.h new file mode 100644 index 0000000000000000000000000000000000000000..12d31dcb2c01c75f76d5bcf9da230eba9dc37624 --- /dev/null +++ b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_H +#define OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_H + +namespace OHOS { +namespace AbilitySlite { +enum AbilityRecordState { + SCHEDULE_INITED, + SCHEDULE_FOREGROUND, + SCHEDULE_BACKGROUND, + SCHEDULE_STOP +}; +} // AbilitySlite +} // namespace OHOS +#endif // OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_H diff --git a/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state_data.h b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state_data.h new file mode 100644 index 0000000000000000000000000000000000000000..8618327e77a927cddddfa834e2e086823129f604 --- /dev/null +++ b/interfaces/inner_api/abilitymgr_lite/slite/ability_record_state_data.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_DATA_H +#define OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_DATA_H + +#include "ability_record_state.h" + +namespace OHOS { +namespace AbilitySlite { +class AbilityRecordStateData { +public: + AbilityRecordStateData() = default; + AbilityRecordStateData(const char *appName, AbilityRecordState state); + AbilityRecordStateData(const AbilityRecordStateData &stateData); + AbilityRecordStateData &operator=(const AbilityRecordStateData &stateData); + ~AbilityRecordStateData(); + + void SetAppName(const char *name); + + const char *GetAppName() const + { + return appName_; + } + + void SetState(AbilityRecordState state) + { + state_ = state; + } + + AbilityRecordState GetState() const + { + return state_; + } + +private: + char *appName_ = nullptr; + AbilityRecordState state_ = SCHEDULE_STOP; +}; +} // AbilitySlite +} // namespace OHOS +#endif // OHOS_ABILITY_SLITE_ABILITY_RECORD_STATE_DATA_H diff --git a/services/abilitymgr_lite/BUILD.gn b/services/abilitymgr_lite/BUILD.gn index f9e860290e8541a7e7ad28387ca8678a21feadb4..882fd565cbcb159c2fccb2348480c8b2aa0d6229 100644 --- a/services/abilitymgr_lite/BUILD.gn +++ b/services/abilitymgr_lite/BUILD.gn @@ -29,6 +29,7 @@ lite_library("abilityms") { "src/slite/ability_mgr_service_slite.cpp", "src/slite/ability_record.cpp", "src/slite/ability_record_manager.cpp", + "src/slite/ability_record_observer_manager.cpp", "src/slite/ability_thread.cpp", "src/slite/ability_thread_loader.cpp", "src/slite/bms_helper.cpp", diff --git a/services/abilitymgr_lite/include/slite/ability_record.h b/services/abilitymgr_lite/include/slite/ability_record.h index d2f236c3a42460bcf554008ade75efa699608249..1bafa2dda71d73a7224e023a92ebcedf9a43f526 100755 --- a/services/abilitymgr_lite/include/slite/ability_record.h +++ b/services/abilitymgr_lite/include/slite/ability_record.h @@ -19,6 +19,7 @@ #include "ability_info.h" #include "cmsis_os.h" #include "ability_thread.h" +#include "ability_record_state.h" namespace OHOS { namespace AbilitySlite { @@ -26,14 +27,6 @@ class JsAppHost; constexpr int FAIL_CALLBACK_ERRORCODE = 200; -/* States-feedback from launcher to AMS */ -typedef enum { - SCHEDULE_INITED, - SCHEDULE_FOREGROUND, - SCHEDULE_BACKGROUND, - SCHEDULE_STOP -} AbilityState; - typedef enum { STATE_JS_RUNNING, STATE_NATIVE_RUNNING, diff --git a/services/abilitymgr_lite/include/slite/ability_record_manager.h b/services/abilitymgr_lite/include/slite/ability_record_manager.h index bbc575b31cfdd0a494ccef42b8e18d478952a539..c3fca860dfb1c5d68187dbaf56b0bd5213a8a8cd 100644 --- a/services/abilitymgr_lite/include/slite/ability_record_manager.h +++ b/services/abilitymgr_lite/include/slite/ability_record_manager.h @@ -20,6 +20,7 @@ #include "ability_list.h" #include "ability_record.h" +#include "ability_record_observer.h" #include "adapter.h" #include "bms_helper.h" #include "js_ability_thread.h" @@ -63,6 +64,9 @@ public: void StartLauncher(); + int32_t AddAbilityRecordObserver(AbilityRecordObserver *observer); + int32_t RemoveAbilityRecordObserver(AbilityRecordObserver *observer); + uint32_t curTask_ = 0; private: diff --git a/services/abilitymgr_lite/include/slite/ability_record_observer_manager.h b/services/abilitymgr_lite/include/slite/ability_record_observer_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..7e45e047cb5bd322319a097831a92e9a010f4ba4 --- /dev/null +++ b/services/abilitymgr_lite/include/slite/ability_record_observer_manager.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_MANAGER_H +#define OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_MANAGER_H + +#include "ability_record_observer.h" +#include "nocopyable.h" +#include "stdint.h" +#include "utils_list.h" + +namespace OHOS { +namespace AbilitySlite { +class AbilityRecordObserverManager : public NoCopyable { +public: + static AbilityRecordObserverManager &GetInstance(); + + void AddObserver(AbilityRecordObserver *observer); + + void RemoveObserver(AbilityRecordObserver *observer); + + void NotifyAbilityRecordStateChanged(const AbilityRecordStateData &data); + + void NotifyAbilityRecordCleanup(char *appName); + +private: + AbilityRecordObserverManager() = default; + ~AbilityRecordObserverManager() = default; + + List observers_; +}; + +} // namespace AbilitySlite +} // namespace OHOS +#endif // OHOS_ABILITY_SLITE_ABILITY_RECORD_OBSERVER_MANAGER_H diff --git a/services/abilitymgr_lite/src/slite/ability_mgr_service_slite.cpp b/services/abilitymgr_lite/src/slite/ability_mgr_service_slite.cpp index 94054c54d80d17ccec75b3e0b252388c80da06c8..10a0ab25edb7cc38289fd8ab5aa51b38fe6982c2 100755 --- a/services/abilitymgr_lite/src/slite/ability_mgr_service_slite.cpp +++ b/services/abilitymgr_lite/src/slite/ability_mgr_service_slite.cpp @@ -16,6 +16,7 @@ #include "ability_mgr_service_slite.h" #include "ability_errors.h" +#include "ability_record_observer.h" #include "ability_service_interface.h" #include "ability_thread_loader.h" #include "abilityms_slite_client.h" @@ -171,6 +172,12 @@ BOOL AbilityMgrServiceSlite::ServiceMessageHandle(Service *service, Request *req } else if (request->msgId == TERMINATE_APP_BY_BUNDLENAME) { char *bundleName = reinterpret_cast(request->data); ret = AbilityRecordManager::GetInstance().ForceStop(bundleName); + } else if (request->msgId == ADD_ABILITY_RECORD_OBSERVER) { + AbilityRecordObserver *observer = reinterpret_cast(request->msgValue); + ret = AbilityRecordManager::GetInstance().AddAbilityRecordObserver(observer); + } else if (request->msgId == REMOVE_ABILITY_RECORD_OBSERVER) { + AbilityRecordObserver *observer = reinterpret_cast(request->msgValue); + ret = AbilityRecordManager::GetInstance().RemoveAbilityRecordObserver(observer); } return ret == ERR_OK; } diff --git a/services/abilitymgr_lite/src/slite/ability_record_manager.cpp b/services/abilitymgr_lite/src/slite/ability_record_manager.cpp index 5d3e0e846215f3e43d9477c23fbc1311a1e897a5..b9c74f41d4ea7e0db50030d637929f4c716e9843 100644 --- a/services/abilitymgr_lite/src/slite/ability_record_manager.cpp +++ b/services/abilitymgr_lite/src/slite/ability_record_manager.cpp @@ -19,6 +19,7 @@ #include "ability_errors.h" #include "ability_inner_message.h" #include "ability_record.h" +#include "ability_record_observer_manager.h" #include "ability_thread_loader.h" #include "abilityms_log.h" #include "ability_manager_inner.h" @@ -592,6 +593,7 @@ void AbilityRecordManager::DeleteRecordInfo(uint16_t token) RecordAbiityInfoEvt(record->GetAppName()); } abilityList_.Erase(token); + AbilityRecordObserverManager::GetInstance().NotifyAbilityRecordCleanup(record->appName); delete record; } @@ -815,6 +817,8 @@ void AbilityRecordManager::SetAbilityState(uint64_t token, int32_t state) return; } record->state = state; + AbilityRecordObserverManager::GetInstance().NotifyAbilityRecordStateChanged( + AbilityRecordStateData(record->appName, static_cast(state))); } #ifndef _MINI_MULTI_TASKS_ @@ -979,6 +983,18 @@ void AbilityRecordManager::setNativeAbility(const SliteAbility *ability) { nativeAbility_ = const_cast(ability); } + +int32_t AbilityRecordManager::AddAbilityRecordObserver(AbilityRecordObserver *observer) +{ + AbilityRecordObserverManager::GetInstance().AddObserver(observer); + return ERR_OK; +} + +int32_t AbilityRecordManager::RemoveAbilityRecordObserver(AbilityRecordObserver *observer) +{ + AbilityRecordObserverManager::GetInstance().RemoveObserver(observer); + return ERR_OK; +} } // namespace AbilitySlite } // namespace OHOS diff --git a/services/abilitymgr_lite/src/slite/ability_record_observer_manager.cpp b/services/abilitymgr_lite/src/slite/ability_record_observer_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..245df1f90aefbc1c0591bd9dd58fb0a9463fb61c --- /dev/null +++ b/services/abilitymgr_lite/src/slite/ability_record_observer_manager.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ability_record_observer_manager.h" + +namespace OHOS { +namespace AbilitySlite { +AbilityRecordObserverManager &AbilityRecordObserverManager::GetInstance() +{ + static AbilityRecordObserverManager instance; + return instance; +} + +void AbilityRecordObserverManager::AddObserver(AbilityRecordObserver *observer) +{ + for (auto it = observers_.Begin(); it != observers_.End(); it = it->next_) { + if (it->value_ == observer) { + return; + } + } + observers_.PushBack(observer); +} + +void AbilityRecordObserverManager::RemoveObserver(AbilityRecordObserver *observer) +{ + for (auto it = observers_.Begin(); it != observers_.End(); it = it->next_) { + if (it->value_ == observer) { + observers_.Remove(it); + return; + } + } +} + +void AbilityRecordObserverManager::NotifyAbilityRecordStateChanged(const AbilityRecordStateData &data) +{ + for (auto it = observers_.Begin(); it != observers_.End(); it = it->next_) { + it->value_->OnAbilityRecordStateChanged(data); + } +} + +void AbilityRecordObserverManager::NotifyAbilityRecordCleanup(char *appName) +{ + for (auto it = observers_.Begin(); it != observers_.End(); it = it->next_) { + it->value_->OnAbilityRecordCleanup(appName); + } +} +} // namespace AbilitySlite +} // namespace OHOS \ No newline at end of file