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 #ifndef NFC_DEFAULT_PAYMENT_APP_CHANGE_H
16 #define NFC_DEFAULT_PAYMENT_APP_CHANGE_H
17 
18 #include "data_ability_observer_stub.h"
19 #include "idefault_payment_service_change_callback.h"
20 #include "element_name.h"
21 #include "setting_data_share_impl.h"
22 #include "loghelper.h"
23 
24 namespace OHOS {
25 namespace NFC {
26 using OHOS::AppExecFwk::ElementName;
27 class DefaultPaymentServiceChangeCallback : public AAFwk::DataAbilityObserverStub {
28 public:
DefaultPaymentServiceChangeCallback(std::weak_ptr<IDefaultPaymentServiceChangeCallback> callback)29     explicit DefaultPaymentServiceChangeCallback(std::weak_ptr<IDefaultPaymentServiceChangeCallback> callback)
30         : callback_(callback)
31     {
32     }
~DefaultPaymentServiceChangeCallback()33     virtual ~DefaultPaymentServiceChangeCallback()
34     {
35     }
OnChange()36     void OnChange() override
37     {
38         if (callback_.expired()) {
39             ErrorLog("OnDefaultPaymentServiceChange: callback is expired");
40             return;
41         }
42         callback_.lock()->OnDefaultPaymentServiceChange();
43     }
44 
45 private:
46     std::weak_ptr<IDefaultPaymentServiceChangeCallback> callback_;
47 };
48 
49 } // namespace NFC
50 } // namespace OHOS
51 #endif