1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_STATUS_LISTENER_MANAGER_H 17 #define OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_STATUS_LISTENER_MANAGER_H 18 19 #include <map> 20 #include <mutex> 21 #include <set> 22 #include <vector> 23 24 #include "domain_account_common.h" 25 #include "idomain_account_callback.h" 26 27 namespace OHOS { 28 namespace AccountSA { 29 class StatusListenerManager { 30 private: 31 virtual ~StatusListenerManager(); 32 StatusListenerManager(); 33 DISALLOW_COPY_AND_MOVE(StatusListenerManager); 34 35 public: 36 static StatusListenerManager& GetInstance(); 37 ErrCode InsertListenerToRecords(const sptr<IRemoteObject> &listener); 38 ErrCode RemoveListenerByListener(const sptr<IRemoteObject> &listener); 39 void NotifyEventAsync(const DomainAccountEventData &report); 40 41 private: 42 void DomainAccountEventParcel(const DomainAccountEventData &report, Parcel &parcel); 43 44 std::mutex mutex_; 45 std::set<sptr<IRemoteObject>> listenerAll_; 46 sptr<IRemoteObject::DeathRecipient> listenerDeathRecipient_; 47 }; 48 } // namespace AccountSA 49 } // namespace OHOS 50 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_STATUS_LISTENER_MANAGER_H 51