• 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 "nfc_notification_publisher.h"
28 #include "tag_ability_dispatcher.h"
29 #include "taginfo.h"
30 #include "ability_info.h"
31 #include "want.h"
32 
33 namespace OHOS {
34 namespace NFC {
35 using OHOS::AppExecFwk::ElementName;
36 using AppExecFwk::AbilityInfo;
37 class ExternalDepsProxy {
38 public:
GetInstance()39     static ExternalDepsProxy &GetInstance()
40     {
41         static ExternalDepsProxy instance;
42         return instance;
43     }
44 
45     bool HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
46     bool HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
47     void InitAppList();
48     std::vector<ElementName> GetDispatchTagAppsByTech(std::vector<int> discTechList);
49 #ifdef VENDOR_APPLICATIONS_ENABLED
50     std::vector<ElementName> GetVendorDispatchTagAppsByTech(std::vector<int> discTechList);
51     void RegQueryApplicationCb(sptr<IQueryAppInfoCallback> callback);
52     void RegCardEmulationNotifyCb(sptr<IOnCardEmulationNotifyCb> callback);
53     sptr<IOnCardEmulationNotifyCb> GetNotifyCardEmulationCallback();
54 #endif
55 
56     KITS::ErrorCode NfcDataGetValue(Uri &uri, const std::string &column, int32_t &value);
57     KITS::ErrorCode NfcDataSetValue(Uri &uri, const std::string &column, int &value);
58 
59     void NfcDataSetString(const std::string& key, const std::string& value);
60     std::string NfcDataGetString(const std::string& key);
61     void NfcDataSetInt(const std::string& key, const int value);
62     int NfcDataGetInt(const std::string& key);
63     void NfcDataClear();
64     void NfcDataDelete(const std::string& key);
65     void UpdateNfcState(int newState);
66 
67     void PublishNfcStateChanged(int newState);
68     void PublishNfcFieldStateChanged(bool isFieldOn);
69 
70     void WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode, SubErrorCode subErrorCode);
71     void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams);
72     void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
73                                      int closeRequestCnt, int closeFailCnt);
74     void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt);
75     void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
76                                                 const std::string &newAppPackageName);
77     void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName);
78     void WriteTagFoundHiSysEvent(const std::vector<int> &techList);
79     void WritePassiveListenHiSysEvent(int requestCnt, int failCnt);
80     void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt);
81     void BuildFailedParams(NfcFailedParams &nfcFailedParams, MainErrorCode mainErrorCode, SubErrorCode subErrorCode);
82     void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute);
83 
84     bool IsGranted(std::string permission);
85 
86     void DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo, OHOS::sptr<IRemoteObject> tagServiceIface);
87     void DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface, std::string appGalleryBundleName);
88     void StartVibratorOnce();
89     void GetPaymentAbilityInfos(std::vector<AbilityInfo> &paymentAbilityInfos);
90     void GetHceAppsByAid(const std::string &aid, std::vector<AppDataParser::HceAppAidInfo>& hceApps);
91     void GetHceApps(std::vector<AppDataParser::HceAppAidInfo> &hceApps);
92     bool IsSystemApp(uint32_t uid);
93     bool IsHceApp(const ElementName &elementName);
94     bool IsBundleInstalled(const std::string &bundleName);
95     bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo, const std::string &bundleName);
96     void SetWantExtraParam(std::shared_ptr<KITS::TagInfo> &tagInfo, AAFwk::Want &want);
97 
98     void PublishNfcNotification(int notificationId, const std::string &name, int balance);
99     void RegNotificationCallback(std::weak_ptr<NfcService> nfcService);
100 };
101 } // NFC
102 } // OHOS
103 #endif // EXTERNAL_DEPS_PROXY_H