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