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