1 /*
2  * Copyright (c) 2021-2024 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 #include "account_log_wrapper.h"
17 #include "os_account_event_listener.h"
18 
19 namespace OHOS {
20 namespace AccountSA {
OsAccountEventListener(const std::shared_ptr<OsAccountSubscriber> & subscriber)21 OsAccountEventListener::OsAccountEventListener(const std::shared_ptr<OsAccountSubscriber> &subscriber)
22     : osAccountSubscriber_(subscriber)
23 {}
24 
~OsAccountEventListener()25 OsAccountEventListener::~OsAccountEventListener()
26 {}
27 
OnAccountsChanged(const int & id)28 void OsAccountEventListener::OnAccountsChanged(const int &id)
29 {
30     if (osAccountSubscriber_ == nullptr) {
31         ACCOUNT_LOGI("osAccountSubscriber_ is nullptr");
32         return;
33     }
34 
35     osAccountSubscriber_->OnAccountsChanged(id);
36 }
37 
OnAccountsSwitch(const int & newId,const int & oldId)38 void OsAccountEventListener::OnAccountsSwitch(const int &newId, const int &oldId)
39 {
40     if (osAccountSubscriber_ == nullptr) {
41         ACCOUNT_LOGI("OsAccountSubscriber_ is nullptr.");
42         return;
43     }
44 
45     osAccountSubscriber_->OnAccountsSwitch(newId, oldId);
46 }
47 
Stop()48 void OsAccountEventListener::Stop()
49 {}
50 }  // namespace AccountSA
51 }  // namespace OHOS
52