• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 EXTERNAL_DEPS_PROXY_H
16 #define EXTERNAL_DEPS_PROXY_H
17 #include <vector>
18 
19 #include "app_data_parser.h"
20 #include "common_event_manager.h"
21 #include "nfc_sdk_common.h"
22 #include "nfc_data_share_impl.h"
23 #include "nfc_preferences.h"
24 #include "nfc_event_publisher.h"
25 #include "nfc_hisysevent.h"
26 #include "nfc_permission_checker.h"
27 #include "tag_ability_dispatcher.h"
28 #include "taginfo.h"
29 #include "ability_info.h"
30 
31 namespace OHOS {
32 namespace NFC {
33 using OHOS::AppExecFwk::ElementName;
34 using AppExecFwk::AbilityInfo;
35 class ExternalDepsProxy {
36 public:
GetInstance()37     static ExternalDepsProxy &GetInstance()
38     {
39         static ExternalDepsProxy instance;
40         return instance;
41     }
42 
43     bool HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
44     bool HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
45     void InitAppList();
46     std::vector<ElementName> GetDispatchTagAppsByTech(std::vector<int> discTechList);
47 #ifdef VENDOR_APPLICATIONS_ENABLED
48     std::vector<ElementName> GetVendorDispatchTagAppsByTech(std::vector<int> discTechList);
49     void RegQueryApplicationCb(sptr<IQueryAppInfoCallback> callback);
50     void RegCardEmulationNotifyCb(sptr<IOnCardEmulationNotifyCb> callback);
51     sptr<IOnCardEmulationNotifyCb> GetNotifyCardEmulationCallback();
52 #endif
53 
54     KITS::ErrorCode NfcDataGetValue(Uri &uri, const std::string &column, int32_t &value);
55     KITS::ErrorCode NfcDataSetValue(Uri &uri, const std::string &column, int &value);
56 
57     void NfcDataSetString(const std::string& key, const std::string& value);
58     std::string NfcDataGetString(const std::string& key);
59     void NfcDataSetInt(const std::string& key, const int value);
60     int NfcDataGetInt(const std::string& key);
61     void NfcDataClear();
62     void NfcDataDelete(const std::string& key);
63     void UpdateNfcState(int newState);
64 
65     void PublishNfcStateChanged(int newState);
66     void PublishNfcFieldStateChanged(bool isFieldOn);
67 
68     void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams);
69     void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
70                                      int closeRequestCnt, int closeFailCnt);
71     void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt);
72     void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
73                                                 const std::string &newAppPackageName);
74     void WriteTagFoundHiSysEvent(const std::vector<int>& techList);
75     void WritePassiveListenHiSysEvent(int requestCnt, int failCnt);
76     void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt);
77     void BuildFailedParams(NfcFailedParams &nfcFailedParams, MainErrorCode mainErrorCode, SubErrorCode subErrorCode);
78 
79     bool IsGranted(std::string permission);
80 
81     void DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo, OHOS::sptr<IRemoteObject> tagServiceIface);
82     void StartVibratorOnce();
83     void GetPaymentAbilityInfos(std::vector<AbilityInfo> &paymentAbilityInfos);
84     void GetHceAppsByAid(const std::string &aid, std::vector<ElementName>& elementNames);
85     void GetHceApps(std::vector<AppDataParser::HceAppAidInfo> &hceApps);
86     bool IsSystemApp(uint32_t uid);
87 };
88 } // NFC
89 } // OHOS
90 #endif // EXTERNAL_DEPS_PROXY_H