• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 APP_DATA_PARSER_H
16 #define APP_DATA_PARSER_H
17 #include <vector>
18 #include "ability_info.h"
19 #include "bundle_mgr_interface.h"
20 #include "bundle_mgr_proxy.h"
21 #include "common_event_subscriber.h"
22 #include "common_event_support.h"
23 #include "element_name.h"
24 #include "loghelper.h"
25 #include "nfc_service.h"
26 #include "system_ability.h"
27 #include "want.h"
28 
29 namespace OHOS {
30 namespace NFC {
31 using AppExecFwk::AbilityInfo;
32 using OHOS::AppExecFwk::ElementName;
33 class AppDataParser {
34 public:
35     explicit AppDataParser();
36     ~AppDataParser();
37 
38     struct AidInfo {
39         std::string name; // the type, payment-aid, or other-aid
40         std::string value; // the aid value
41     };
42 
43     struct TagAppTechInfo {
44         ElementName element;
45         std::vector<std::string> tech; // technology, such as NfcA/NfcB/IsoDep.
46     };
47 
48     struct HceAppAidInfo {
49         ElementName element;
50         std::vector<AidInfo> customDataAid;
51     };
52 
53     std::vector<TagAppTechInfo> g_tagAppAndTechMap;
54     std::vector<HceAppAidInfo> g_hceAppAndAidMap;
55 
56     static AppDataParser& GetInstance();
57 
58     void HandleAppAddOrChangedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
59     void HandleAppRemovedEvent(std::shared_ptr<EventFwk::CommonEventData> data);
60     void InitAppList();
61     std::vector<ElementName> GetDispatchTagAppsByTech(std::vector<int> discTechList);
62 private:
63     static sptr<AppExecFwk::IBundleMgr> GetBundleMgrProxy();
64     ElementName GetMatchedTagKeyElement(ElementName &element);
65     ElementName GetMatchedHceKeyElement(ElementName &element);
66     bool IsMatchedByBundleName(ElementName &src, ElementName &target);
67     bool InitAppListByAction(const std::string action);
68     bool VerifyHapPermission(const std::string bundleName, const std::string action);
69     bool UpdateAppListInfo(ElementName &element, const std::string action);
70     void UpdateTagAppList(AbilityInfo &abilityInfo, ElementName &element);
71     void UpdateHceAppList(AbilityInfo &abilityInfo, ElementName &element);
72     void RemoveTagAppInfo(ElementName &element);
73     void RemoveHceAppInfo(ElementName &element);
74 };
75 }  // namespace NFC
76 }  // namespace OHOS
77 #endif  // COMMON_EVENT_HANDLER_H
78