• 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 #include "external_deps_proxy.h"
16 
17 namespace OHOS {
18 namespace NFC {
HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data)19 bool ExternalDepsProxy::HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data)
20 {
21     return AppDataParser::GetInstance().HandleAppAddOrChangedEvent(data);
22 }
23 
HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data)24 bool ExternalDepsProxy::HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data)
25 {
26     return AppDataParser::GetInstance().HandleAppRemovedEvent(data);
27 }
28 
InitAppList()29 void ExternalDepsProxy::InitAppList()
30 {
31     AppDataParser::GetInstance().InitAppList();
32 }
33 
GetDispatchTagAppsByTech(std::vector<int> discTechList)34 std::vector<ElementName> ExternalDepsProxy::GetDispatchTagAppsByTech(std::vector<int> discTechList)
35 {
36     return AppDataParser::GetInstance().GetDispatchTagAppsByTech(discTechList);
37 }
38 
39 #ifdef VENDOR_APPLICATIONS_ENABLED
GetVendorDispatchTagAppsByTech(std::vector<int> discTechList)40 std::vector<ElementName> ExternalDepsProxy::GetVendorDispatchTagAppsByTech(std::vector<int> discTechList)
41 {
42     return AppDataParser::GetInstance().GetVendorDispatchTagAppsByTech(discTechList);
43 }
44 
RegQueryApplicationCb(sptr<IQueryAppInfoCallback> callback)45 void ExternalDepsProxy::RegQueryApplicationCb(sptr<IQueryAppInfoCallback> callback)
46 {
47     AppDataParser::GetInstance().RegQueryApplicationCb(callback);
48 }
49 
RegCardEmulationNotifyCb(sptr<IOnCardEmulationNotifyCb> callback)50 void ExternalDepsProxy::RegCardEmulationNotifyCb(sptr<IOnCardEmulationNotifyCb> callback)
51 {
52     AppDataParser::GetInstance().RegCardEmulationNotifyCb(callback);
53 }
54 
GetNotifyCardEmulationCallback()55 sptr<IOnCardEmulationNotifyCb> ExternalDepsProxy::GetNotifyCardEmulationCallback()
56 {
57     return AppDataParser::GetInstance().GetNotifyCardEmulationCallback();
58 }
59 #endif
60 
NfcDataGetValue(Uri & uri,const std::string & column,int32_t & value)61 KITS::ErrorCode ExternalDepsProxy::NfcDataGetValue(Uri &uri, const std::string &column, int32_t &value)
62 {
63     return NfcDataShareImpl::GetInstance()->GetValue(uri, column, value);
64 }
65 
NfcDataSetValue(Uri & uri,const std::string & column,int & value)66 KITS::ErrorCode ExternalDepsProxy::NfcDataSetValue(Uri &uri, const std::string &column, int &value)
67 {
68     return NfcDataShareImpl::GetInstance()->SetValue(uri, column, value);
69 }
70 
NfcDataSetString(const std::string & key,const std::string & value)71 void ExternalDepsProxy::NfcDataSetString(const std::string& key, const std::string& value)
72 {
73     NfcPreferences::GetInstance().SetString(key, value);
74 }
75 
NfcDataGetString(const std::string & key)76 std::string ExternalDepsProxy::NfcDataGetString(const std::string& key)
77 {
78     return NfcPreferences::GetInstance().GetString(key);
79 }
80 
NfcDataSetInt(const std::string & key,const int value)81 void ExternalDepsProxy::NfcDataSetInt(const std::string& key, const int value)
82 {
83     NfcPreferences::GetInstance().SetInt(key, value);
84 }
85 
NfcDataGetInt(const std::string & key)86 int ExternalDepsProxy::NfcDataGetInt(const std::string& key)
87 {
88     return NfcPreferences::GetInstance().GetInt(key);
89 }
90 
NfcDataClear()91 void ExternalDepsProxy::NfcDataClear()
92 {
93     NfcPreferences::GetInstance().Clear();
94 }
95 
NfcDataDelete(const std::string & key)96 void ExternalDepsProxy::NfcDataDelete(const std::string& key)
97 {
98     NfcPreferences::GetInstance().Delete(key);
99 }
100 
UpdateNfcState(int newState)101 void ExternalDepsProxy::UpdateNfcState(int newState)
102 {
103     NfcPreferences::GetInstance().UpdateNfcState(newState);
104 }
105 
PublishNfcStateChanged(int newState)106 void ExternalDepsProxy::PublishNfcStateChanged(int newState)
107 {
108     NfcEventPublisher::PublishNfcStateChanged(newState);
109 }
110 
PublishNfcFieldStateChanged(bool isFieldOn)111 void ExternalDepsProxy::PublishNfcFieldStateChanged(bool isFieldOn)
112 {
113     NfcEventPublisher::PublishNfcFieldStateChanged(isFieldOn);
114 }
115 
WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode,SubErrorCode subErrorCode)116 void ExternalDepsProxy::WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode, SubErrorCode subErrorCode)
117 {
118     NfcFailedParams nfcFailedParams;
119     ExternalDepsProxy::GetInstance().BuildFailedParams(nfcFailedParams, mainErrorCode, subErrorCode);
120     ExternalDepsProxy::GetInstance().WriteNfcFailedHiSysEvent(&nfcFailedParams);
121 }
122 
WriteNfcFailedHiSysEvent(const NfcFailedParams * failedParams)123 void ExternalDepsProxy::WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams)
124 {
125     NfcHisysEvent::WriteNfcFailedHiSysEvent(failedParams);
126 }
127 
WriteOpenAndCloseHiSysEvent(int openRequestCnt,int openFailCnt,int closeRequestCnt,int closeFailCnt)128 void ExternalDepsProxy::WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
129                                                     int closeRequestCnt, int closeFailCnt)
130 {
131     NfcHisysEvent::WriteOpenAndCloseHiSysEvent(openRequestCnt, openFailCnt,
132         closeRequestCnt, closeFailCnt);
133 }
134 
WriteHceSwipeResultHiSysEvent(const std::string & appPackageName,int hceSwipeCnt)135 void ExternalDepsProxy::WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt)
136 {
137     NfcHisysEvent::WriteHceSwipeResultHiSysEvent(appPackageName, hceSwipeCnt);
138 }
139 
WriteDefaultPaymentAppChangeHiSysEvent(const std::string & oldAppPackageName,const std::string & newAppPackageName)140 void ExternalDepsProxy::WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
141                                                                const std::string &newAppPackageName)
142 {
143     NfcHisysEvent::WriteDefaultPaymentAppChangeHiSysEvent(oldAppPackageName, newAppPackageName);
144 }
145 
WriteForegroundAppChangeHiSysEvent(const std::string & appPackageName)146 void ExternalDepsProxy::WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName)
147 {
148     NfcHisysEvent::WriteForegroundAppChangeHiSysEvent(appPackageName);
149 }
150 
WriteTagFoundHiSysEvent(const std::vector<int> & techList)151 void ExternalDepsProxy::WriteTagFoundHiSysEvent(const std::vector<int>& techList)
152 {
153     NfcHisysEvent::WriteTagFoundHiSysEvent(techList);
154 }
155 
WritePassiveListenHiSysEvent(int requestCnt,int failCnt)156 void ExternalDepsProxy::WritePassiveListenHiSysEvent(int requestCnt, int failCnt)
157 {
158     NfcHisysEvent::WritePassiveListenHiSysEvent(requestCnt, failCnt);
159 }
160 
WriteFirmwareUpdateHiSysEvent(int requestCnt,int failCnt)161 void ExternalDepsProxy::WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt)
162 {
163     NfcHisysEvent::WriteFirmwareUpdateHiSysEvent(requestCnt, failCnt);
164 }
165 
BuildFailedParams(NfcFailedParams & nfcFailedParams,MainErrorCode mainErrorCode,SubErrorCode subErrorCode)166 void ExternalDepsProxy::BuildFailedParams(NfcFailedParams &nfcFailedParams,
167                                           MainErrorCode mainErrorCode,
168                                           SubErrorCode subErrorCode)
169 {
170     NfcHisysEvent::BuildFailedParams(nfcFailedParams, mainErrorCode, subErrorCode);
171 }
172 
WriteDefaultRouteChangeHiSysEvent(int oldRoute,int newRoute)173 void ExternalDepsProxy::WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute)
174 {
175     NfcHisysEvent::WriteDefaultRouteChangeHiSysEvent(oldRoute, newRoute);
176 }
177 
IsGranted(std::string permission)178 bool ExternalDepsProxy::IsGranted(std::string permission)
179 {
180     return NfcPermissionChecker::IsGranted(permission);
181 }
182 
DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo,OHOS::sptr<IRemoteObject> tagServiceIface)183 void ExternalDepsProxy::DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo,
184                                            OHOS::sptr<IRemoteObject> tagServiceIface)
185 {
186     TAG::TagAbilityDispatcher::DispatchTagAbility(tagInfo, tagServiceIface);
187 }
188 
DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface,std::string appGalleryBundleName)189 void ExternalDepsProxy::DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface, std::string appGalleryBundleName)
190 {
191     TAG::TagAbilityDispatcher::DispatchAppGallery(tagServiceIface, appGalleryBundleName);
192 }
193 
StartVibratorOnce()194 void ExternalDepsProxy::StartVibratorOnce()
195 {
196     TAG::TagAbilityDispatcher::StartVibratorOnce();
197 }
198 
GetPaymentAbilityInfos(std::vector<AbilityInfo> & paymentAbilityInfos)199 void ExternalDepsProxy::GetPaymentAbilityInfos(std::vector<AbilityInfo>& paymentAbilityInfos)
200 {
201     AppDataParser::GetInstance().GetPaymentAbilityInfos(paymentAbilityInfos);
202 }
203 
GetHceAppsByAid(const std::string & aid,std::vector<AppDataParser::HceAppAidInfo> & hceApps)204 void ExternalDepsProxy::GetHceAppsByAid(const std::string& aid, std::vector<AppDataParser::HceAppAidInfo>& hceApps)
205 {
206     AppDataParser::GetInstance().GetHceAppsByAid(aid, hceApps);
207 }
208 
GetHceApps(std::vector<AppDataParser::HceAppAidInfo> & hceApps)209 void ExternalDepsProxy::GetHceApps(std::vector<AppDataParser::HceAppAidInfo>& hceApps)
210 {
211     AppDataParser::GetInstance().GetHceApps(hceApps);
212 }
IsSystemApp(uint32_t uid)213 bool ExternalDepsProxy::IsSystemApp(uint32_t uid)
214 {
215     return AppDataParser::GetInstance().IsSystemApp(uid);
216 }
217 
IsHceApp(const ElementName & elementName)218 bool ExternalDepsProxy::IsHceApp(const ElementName& elementName)
219 {
220     return AppDataParser::GetInstance().IsHceApp(elementName);
221 }
222 
IsBundleInstalled(const std::string & bundleName)223 bool ExternalDepsProxy::IsBundleInstalled(const std::string& bundleName)
224 {
225     return AppDataParser::GetInstance().IsBundleInstalled(bundleName);
226 }
227 
GetBundleInfo(AppExecFwk::BundleInfo & bundleInfo,const std::string & bundleName)228 bool ExternalDepsProxy::GetBundleInfo(AppExecFwk::BundleInfo& bundleInfo, const std::string& bundleName)
229 {
230     return AppDataParser::GetInstance().GetBundleInfo(bundleInfo, bundleName);
231 }
232 
SetWantExtraParam(std::shared_ptr<KITS::TagInfo> & tagInfo,AAFwk::Want & want)233 void ExternalDepsProxy::SetWantExtraParam(std::shared_ptr<KITS::TagInfo> &tagInfo, AAFwk::Want &want)
234 {
235     TAG::TagAbilityDispatcher::SetWantExtraParam(tagInfo, want);
236 }
237 
PublishNfcNotification(int notificationId,const std::string & name,int balance)238 void ExternalDepsProxy::PublishNfcNotification(int notificationId, const std::string &name, int balance)
239 {
240     TAG::NfcNotificationPublisher::GetInstance().PublishNfcNotification(notificationId, name, balance);
241 }
242 
RegNotificationCallback(std::weak_ptr<NfcService> nfcService)243 void ExternalDepsProxy::RegNotificationCallback(std::weak_ptr<NfcService> nfcService)
244 {
245     TAG::NfcNotificationPublisher::GetInstance().RegNotificationCallback(nfcService);
246 }
247 } // namespace NFC
248 } // OHOS