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_ROUTING_MANAGER_H
16 #define NFC_ROUTING_MANAGER_H
17 #include "nfc_event_handler.h"
18 #include "inci_ce_interface.h"
19 #include "nfc_sdk_common.h"
20 
21 namespace OHOS {
22 namespace NFC {
23 class NfcService;
24 class NfcRoutingManager {
25 public:
26     NfcRoutingManager(std::shared_ptr<NfcEventHandler> eventHandler,
27                       std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy,
28                       std::weak_ptr<NCI::INciCeInterface> nciCeProxy,
29                       std::weak_ptr<NfcService> nfcService);
30     ~NfcRoutingManager();
31 
32     // commit routing
33     void HandleCommitRouting();
34     void HandleComputeRoutingParams(int defaultPaymentType);
35     void CommitRouting();
36     void ComputeRoutingParams(KITS::DefaultPaymentType defaultPaymentType);
37 
38 private:
39     std::shared_ptr<NfcEventHandler> eventHandler_ {};
40     std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy_ {};
41     std::weak_ptr<NCI::INciCeInterface> nciCeProxy_ {};
42     std::weak_ptr<NfcService> nfcService_ {};
43 
44     // lock
45     std::mutex mutex_ {};
46     static constexpr const int WAIT_ROUTING_INIT = 10 * 1000;
47 };
48 } // namespace NFC
49 } // namespace OHOS
50 #endif // NFC_ROUTING_MANAGER_H