1bc2ed2b3Sopenharmony_ci/*
2bc2ed2b3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3bc2ed2b3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bc2ed2b3Sopenharmony_ci * you may not use this file except in compliance with the License.
5bc2ed2b3Sopenharmony_ci * You may obtain a copy of the License at
6bc2ed2b3Sopenharmony_ci *
7bc2ed2b3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc2ed2b3Sopenharmony_ci *
9bc2ed2b3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc2ed2b3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bc2ed2b3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc2ed2b3Sopenharmony_ci * See the License for the specific language governing permissions and
13bc2ed2b3Sopenharmony_ci * limitations under the License.
14bc2ed2b3Sopenharmony_ci */
15bc2ed2b3Sopenharmony_ci#ifndef EXTERNAL_DEPS_PROXY_H
16bc2ed2b3Sopenharmony_ci#define EXTERNAL_DEPS_PROXY_H
17bc2ed2b3Sopenharmony_ci#include <vector>
18bc2ed2b3Sopenharmony_ci
19bc2ed2b3Sopenharmony_ci#include "app_data_parser.h"
20bc2ed2b3Sopenharmony_ci#include "common_event_manager.h"
21bc2ed2b3Sopenharmony_ci#include "nfc_sdk_common.h"
22bc2ed2b3Sopenharmony_ci#include "nfc_data_share_impl.h"
23bc2ed2b3Sopenharmony_ci#include "nfc_preferences.h"
24bc2ed2b3Sopenharmony_ci#include "nfc_event_publisher.h"
25bc2ed2b3Sopenharmony_ci#include "nfc_hisysevent.h"
26bc2ed2b3Sopenharmony_ci#include "nfc_param_util.h"
27bc2ed2b3Sopenharmony_ci#include "nfc_permission_checker.h"
28bc2ed2b3Sopenharmony_ci#include "nfc_notification_publisher.h"
29bc2ed2b3Sopenharmony_ci#include "tag_ability_dispatcher.h"
30bc2ed2b3Sopenharmony_ci#include "taginfo.h"
31bc2ed2b3Sopenharmony_ci#include "ability_info.h"
32bc2ed2b3Sopenharmony_ci#include "want.h"
33bc2ed2b3Sopenharmony_ci
34bc2ed2b3Sopenharmony_cinamespace OHOS {
35bc2ed2b3Sopenharmony_cinamespace NFC {
36bc2ed2b3Sopenharmony_ciusing OHOS::AppExecFwk::ElementName;
37bc2ed2b3Sopenharmony_ciusing AppExecFwk::AbilityInfo;
38bc2ed2b3Sopenharmony_ciclass ExternalDepsProxy {
39bc2ed2b3Sopenharmony_cipublic:
40bc2ed2b3Sopenharmony_ci    static ExternalDepsProxy &GetInstance()
41bc2ed2b3Sopenharmony_ci    {
42bc2ed2b3Sopenharmony_ci        static ExternalDepsProxy instance;
43bc2ed2b3Sopenharmony_ci        return instance;
44bc2ed2b3Sopenharmony_ci    }
45bc2ed2b3Sopenharmony_ci
46bc2ed2b3Sopenharmony_ci    bool HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
47bc2ed2b3Sopenharmony_ci    bool HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
48bc2ed2b3Sopenharmony_ci    void InitAppList();
49bc2ed2b3Sopenharmony_ci    std::vector<ElementName> GetDispatchTagAppsByTech(std::vector<int> discTechList);
50bc2ed2b3Sopenharmony_ci#ifdef VENDOR_APPLICATIONS_ENABLED
51bc2ed2b3Sopenharmony_ci    std::vector<ElementName> GetVendorDispatchTagAppsByTech(std::vector<int> discTechList);
52bc2ed2b3Sopenharmony_ci    void RegQueryApplicationCb(sptr<IQueryAppInfoCallback> callback);
53bc2ed2b3Sopenharmony_ci    void RegCardEmulationNotifyCb(sptr<IOnCardEmulationNotifyCb> callback);
54bc2ed2b3Sopenharmony_ci    sptr<IOnCardEmulationNotifyCb> GetNotifyCardEmulationCallback();
55bc2ed2b3Sopenharmony_ci#endif
56bc2ed2b3Sopenharmony_ci
57bc2ed2b3Sopenharmony_ci    KITS::ErrorCode NfcDataGetValue(Uri &uri, const std::string &column, int32_t &value);
58bc2ed2b3Sopenharmony_ci    KITS::ErrorCode NfcDataSetValue(Uri &uri, const std::string &column, int &value);
59bc2ed2b3Sopenharmony_ci
60bc2ed2b3Sopenharmony_ci    void NfcDataSetString(const std::string& key, const std::string& value);
61bc2ed2b3Sopenharmony_ci    std::string NfcDataGetString(const std::string& key);
62bc2ed2b3Sopenharmony_ci    void NfcDataSetInt(const std::string& key, const int value);
63bc2ed2b3Sopenharmony_ci    int NfcDataGetInt(const std::string& key);
64bc2ed2b3Sopenharmony_ci    void NfcDataClear();
65bc2ed2b3Sopenharmony_ci    void NfcDataDelete(const std::string& key);
66bc2ed2b3Sopenharmony_ci    void UpdateNfcState(int newState);
67bc2ed2b3Sopenharmony_ci    int GetNfcStateFromParam();
68bc2ed2b3Sopenharmony_ci
69bc2ed2b3Sopenharmony_ci    void PublishNfcStateChanged(int newState);
70bc2ed2b3Sopenharmony_ci    void PublishNfcFieldStateChanged(bool isFieldOn);
71bc2ed2b3Sopenharmony_ci
72bc2ed2b3Sopenharmony_ci    void WriteNfcFailedHiSysEvent(MainErrorCode mainErrorCode, SubErrorCode subErrorCode);
73bc2ed2b3Sopenharmony_ci    void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams);
74bc2ed2b3Sopenharmony_ci    void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
75bc2ed2b3Sopenharmony_ci                                     int closeRequestCnt, int closeFailCnt);
76bc2ed2b3Sopenharmony_ci    void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt);
77bc2ed2b3Sopenharmony_ci    void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
78bc2ed2b3Sopenharmony_ci                                                const std::string &newAppPackageName);
79bc2ed2b3Sopenharmony_ci    void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName);
80bc2ed2b3Sopenharmony_ci    void WriteTagFoundHiSysEvent(const std::vector<int> &techList);
81bc2ed2b3Sopenharmony_ci    void WritePassiveListenHiSysEvent(int requestCnt, int failCnt);
82bc2ed2b3Sopenharmony_ci    void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt);
83bc2ed2b3Sopenharmony_ci    void BuildFailedParams(NfcFailedParams &nfcFailedParams, MainErrorCode mainErrorCode, SubErrorCode subErrorCode);
84bc2ed2b3Sopenharmony_ci    void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute);
85bc2ed2b3Sopenharmony_ci    void WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode, const std::string &appName);
86bc2ed2b3Sopenharmony_ci
87bc2ed2b3Sopenharmony_ci    bool IsGranted(std::string permission);
88bc2ed2b3Sopenharmony_ci
89bc2ed2b3Sopenharmony_ci    void DispatchTagAbility(std::shared_ptr<KITS::TagInfo> tagInfo, OHOS::sptr<IRemoteObject> tagServiceIface);
90bc2ed2b3Sopenharmony_ci    void DispatchAppGallery(OHOS::sptr<IRemoteObject> tagServiceIface, std::string appGalleryBundleName);
91bc2ed2b3Sopenharmony_ci    void StartVibratorOnce();
92bc2ed2b3Sopenharmony_ci    void GetPaymentAbilityInfos(std::vector<AbilityInfo> &paymentAbilityInfos);
93bc2ed2b3Sopenharmony_ci    void GetHceAppsByAid(const std::string &aid, std::vector<AppDataParser::HceAppAidInfo>& hceApps);
94bc2ed2b3Sopenharmony_ci    void GetHceApps(std::vector<AppDataParser::HceAppAidInfo> &hceApps);
95bc2ed2b3Sopenharmony_ci    bool IsSystemApp(uint32_t uid);
96bc2ed2b3Sopenharmony_ci    bool IsHceApp(const ElementName &elementName);
97bc2ed2b3Sopenharmony_ci    bool IsBundleInstalled(const std::string &bundleName);
98bc2ed2b3Sopenharmony_ci    bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo, const std::string &bundleName);
99bc2ed2b3Sopenharmony_ci    void SetWantExtraParam(std::shared_ptr<KITS::TagInfo> &tagInfo, AAFwk::Want &want);
100bc2ed2b3Sopenharmony_ci    std::string GetBundleNameByUid(uint32_t uid);
101bc2ed2b3Sopenharmony_ci
102bc2ed2b3Sopenharmony_ci    void PublishNfcNotification(int notificationId, const std::string &name, int balance);
103bc2ed2b3Sopenharmony_ci    void RegNotificationCallback(std::weak_ptr<NfcService> nfcService);
104bc2ed2b3Sopenharmony_ci};
105bc2ed2b3Sopenharmony_ci} // NFC
106bc2ed2b3Sopenharmony_ci} // OHOS
107bc2ed2b3Sopenharmony_ci#endif // EXTERNAL_DEPS_PROXY_H