• 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     NfcParamUtil::UpdateNfcStateToParam(newState);
104 }
105 
GetNfcStateFromParam()106 int ExternalDepsProxy::GetNfcStateFromParam()
107 {
108     return NfcParamUtil::GetNfcStateFromParam();
109 }
110 
PublishNfcStateChanged(int newState)111 void ExternalDepsProxy::PublishNfcStateChanged(int newState)
112 {
113     NfcEventPublisher::PublishNfcStateChanged(newState);
114 }
115 
PublishNfcFieldStateChanged(bool isFieldOn)116 void ExternalDepsProxy::PublishNfcFieldStateChanged(bool isFieldOn)
117 {
118     NfcEventPublisher::PublishNfcFieldStateChanged(isFieldOn);
119 }
120 
WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode,SubErrorCode subErrorCode)121 void ExternalDepsProxy::WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode, SubErrorCode subErrorCode)
122 {
123     NfcFailedParams nfcFailedParams;
124     ExternalDepsProxy::GetInstance().BuildFailedParams(nfcFailedParams, mainErrorCode, subErrorCode);
125     ExternalDepsProxy::GetInstance().WriteNfcFailedHiSysEvent(&nfcFailedParams);
126 }
127 
WriteNfcFailedHiSysEvent(const NfcFailedParams * failedParams)128 void ExternalDepsProxy::WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams)
129 {
130     NfcHisysEvent::WriteNfcFailedHiSysEvent(failedParams);
131 }
132 
WriteOpenAndCloseHiSysEvent(int openRequestCnt,int openFailCnt,int closeRequestCnt,int closeFailCnt)133 void ExternalDepsProxy::WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
134                                                     int closeRequestCnt, int closeFailCnt)
135 {
136     NfcHisysEvent::WriteOpenAndCloseHiSysEvent(openRequestCnt, openFailCnt,
137         closeRequestCnt, closeFailCnt);
138 }
139 
WriteHceSwipeResultHiSysEvent(const std::string & appPackageName,int hceSwipeCnt)140 void ExternalDepsProxy::WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt)
141 {
142     NfcHisysEvent::WriteHceSwipeResultHiSysEvent(appPackageName, hceSwipeCnt);
143 }
144 
WriteDefaultPaymentAppChangeHiSysEvent(const std::string & oldAppPackageName,const std::string & newAppPackageName)145 void ExternalDepsProxy::WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
146                                                                const std::string &newAppPackageName)
147 {
148     NfcHisysEvent::WriteDefaultPaymentAppChangeHiSysEvent(oldAppPackageName, newAppPackageName);
149 }
150 
WriteForegroundAppChangeHiSysEvent(const std::string & appPackageName)151 void ExternalDepsProxy::WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName)
152 {
153     NfcHisysEvent::WriteForegroundAppChangeHiSysEvent(appPackageName);
154 }
155 
WriteDispatchToAppHiSysEvent(const std::string & appPackageName,SubErrorCode subErrorCode)156 void ExternalDepsProxy::WriteDispatchToAppHiSysEvent(const std::string &appPackageName, SubErrorCode subErrorCode)
157 {
158     NfcHisysEvent::WriteDispatchToAppHiSysEvent(appPackageName, subErrorCode);
159 }
160 
WriteTagFoundHiSysEvent(const std::vector<int> & techList)161 void ExternalDepsProxy::WriteTagFoundHiSysEvent(const std::vector<int>& techList)
162 {
163     NfcHisysEvent::WriteTagFoundHiSysEvent(techList);
164 }
165 
WritePassiveListenHiSysEvent(int requestCnt,int failCnt)166 void ExternalDepsProxy::WritePassiveListenHiSysEvent(int requestCnt, int failCnt)
167 {
168     NfcHisysEvent::WritePassiveListenHiSysEvent(requestCnt, failCnt);
169 }
170 
WriteFirmwareUpdateHiSysEvent(int requestCnt,int failCnt)171 void ExternalDepsProxy::WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt)
172 {
173     NfcHisysEvent::WriteFirmwareUpdateHiSysEvent(requestCnt, failCnt);
174 }
175 
BuildFailedParams(NfcFailedParams & nfcFailedParams,MainErrorCode mainErrorCode,SubErrorCode subErrorCode)176 void ExternalDepsProxy::BuildFailedParams(NfcFailedParams &nfcFailedParams,
177                                           MainErrorCode mainErrorCode,
178                                           SubErrorCode subErrorCode)
179 {
180     NfcHisysEvent::BuildFailedParams(nfcFailedParams, mainErrorCode, subErrorCode);
181 }
182 
WriteDefaultRouteChangeHiSysEvent(int oldRoute,int newRoute)183 void ExternalDepsProxy::WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute)
184 {
185     NfcHisysEvent::WriteDefaultRouteChangeHiSysEvent(oldRoute, newRoute);
186 }
187 
WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode,const std::string & appName)188 void ExternalDepsProxy::WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode, const std::string &appName)
189 {
190     NfcHisysEvent::WriteAppBehaviorHiSysEvent(behaviorCode, appName);
191 }
192 
WriteNfcHceCmdCbHiSysEvent(const std::string & appName,SubErrorCode subErrorCode)193 void ExternalDepsProxy::WriteNfcHceCmdCbHiSysEvent(const std::string &appName, SubErrorCode subErrorCode)
194 {
195     NfcHisysEvent::WriteNfcHceCmdCbHiSysEvent(appName, subErrorCode);
196 }
197 
IsGranted(std::string permission)198 bool ExternalDepsProxy::IsGranted(std::string permission)
199 {
200     return NfcPermissionChecker::IsGranted(permission);
201 }
202 
DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo,OHOS::sptr<IRemoteObject> tagServiceIface)203 void ExternalDepsProxy::DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo,
204                                            OHOS::sptr<IRemoteObject> tagServiceIface)
205 {
206     TAG::TagAbilityDispatcher::DispatchTagAbility(tagInfo, tagServiceIface);
207 }
208 
DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface,std::string appGalleryBundleName)209 void ExternalDepsProxy::DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface, std::string appGalleryBundleName)
210 {
211     TAG::TagAbilityDispatcher::DispatchAppGallery(tagServiceIface, appGalleryBundleName);
212 }
213 
StartVibratorOnce()214 void ExternalDepsProxy::StartVibratorOnce()
215 {
216     TAG::TagAbilityDispatcher::StartVibratorOnce();
217 }
218 
GetPaymentAbilityInfos(std::vector<AbilityInfo> & paymentAbilityInfos)219 void ExternalDepsProxy::GetPaymentAbilityInfos(std::vector<AbilityInfo>& paymentAbilityInfos)
220 {
221     AppDataParser::GetInstance().GetPaymentAbilityInfos(paymentAbilityInfos);
222 }
223 
GetHceAppsByAid(const std::string & aid,std::vector<AppDataParser::HceAppAidInfo> & hceApps)224 void ExternalDepsProxy::GetHceAppsByAid(const std::string& aid, std::vector<AppDataParser::HceAppAidInfo>& hceApps)
225 {
226     AppDataParser::GetInstance().GetHceAppsByAid(aid, hceApps);
227 }
228 
GetHceApps(std::vector<AppDataParser::HceAppAidInfo> & hceApps)229 void ExternalDepsProxy::GetHceApps(std::vector<AppDataParser::HceAppAidInfo>& hceApps)
230 {
231     AppDataParser::GetInstance().GetHceApps(hceApps);
232 }
IsSystemApp(uint32_t uid)233 bool ExternalDepsProxy::IsSystemApp(uint32_t uid)
234 {
235     return AppDataParser::GetInstance().IsSystemApp(uid);
236 }
237 
IsHceApp(const ElementName & elementName)238 bool ExternalDepsProxy::IsHceApp(const ElementName& elementName)
239 {
240     return AppDataParser::GetInstance().IsHceApp(elementName);
241 }
242 
IsBundleInstalled(const std::string & bundleName)243 bool ExternalDepsProxy::IsBundleInstalled(const std::string& bundleName)
244 {
245     return AppDataParser::GetInstance().IsBundleInstalled(bundleName);
246 }
247 
GetBundleInfo(AppExecFwk::BundleInfo & bundleInfo,const std::string & bundleName)248 bool ExternalDepsProxy::GetBundleInfo(AppExecFwk::BundleInfo& bundleInfo, const std::string& bundleName)
249 {
250     return AppDataParser::GetInstance().GetBundleInfo(bundleInfo, bundleName);
251 }
252 
SetWantExtraParam(const std::shared_ptr<KITS::TagInfo> & tagInfo,AAFwk::Want & want)253 void ExternalDepsProxy::SetWantExtraParam(const std::shared_ptr<KITS::TagInfo> &tagInfo, AAFwk::Want &want)
254 {
255     TAG::TagAbilityDispatcher::SetWantExtraParam(tagInfo, want);
256 }
257 
GetBundleNameByUid(uint32_t uid)258 std::string ExternalDepsProxy::GetBundleNameByUid(uint32_t uid)
259 {
260     std::string bundleName = AppDataParser::GetInstance().GetBundleNameByUid(uid);
261     if (bundleName == "") {
262         // system abilities have no bundle name, should return UID.
263         bundleName = std::to_string(uid);
264     }
265     return bundleName;
266 }
267 
PublishNfcNotification(int notificationId,const std::string & name,int balance)268 void ExternalDepsProxy::PublishNfcNotification(int notificationId, const std::string &name, int balance)
269 {
270     TAG::NfcNotificationPublisher::GetInstance().PublishNfcNotification(notificationId, name, balance);
271 }
272 
RegNotificationCallback(std::weak_ptr<NfcService> nfcService)273 void ExternalDepsProxy::RegNotificationCallback(std::weak_ptr<NfcService> nfcService)
274 {
275     TAG::NfcNotificationPublisher::GetInstance().RegNotificationCallback(nfcService);
276 }
277 } // namespace NFC
278 } // OHOS