1f8af9c48Sopenharmony_ci/*
2f8af9c48Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3f8af9c48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f8af9c48Sopenharmony_ci * you may not use this file except in compliance with the License.
5f8af9c48Sopenharmony_ci * You may obtain a copy of the License at
6f8af9c48Sopenharmony_ci *
7f8af9c48Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8f8af9c48Sopenharmony_ci *
9f8af9c48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f8af9c48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f8af9c48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f8af9c48Sopenharmony_ci * See the License for the specific language governing permissions and
13f8af9c48Sopenharmony_ci * limitations under the License.
14f8af9c48Sopenharmony_ci */
15f8af9c48Sopenharmony_ci
16f8af9c48Sopenharmony_ci#ifndef OHOS_DP_RADAR_HELPER_H
17f8af9c48Sopenharmony_ci#define OHOS_DP_RADAR_HELPER_H
18f8af9c48Sopenharmony_ci
19f8af9c48Sopenharmony_ci#include <cstdint>
20f8af9c48Sopenharmony_ci#include <chrono>
21f8af9c48Sopenharmony_ci#include <string>
22f8af9c48Sopenharmony_ci#include <map>
23f8af9c48Sopenharmony_ci#include <list>
24f8af9c48Sopenharmony_ci
25f8af9c48Sopenharmony_ci#include "single_instance.h"
26f8af9c48Sopenharmony_ci#include "access_control_profile.h"
27f8af9c48Sopenharmony_ci#include "characteristic_profile.h"
28f8af9c48Sopenharmony_ci#include "device_profile.h"
29f8af9c48Sopenharmony_ci#include "dp_subscribe_info.h"
30f8af9c48Sopenharmony_ci#include "service_profile.h"
31f8af9c48Sopenharmony_ci#include "trust_device_profile.h"
32f8af9c48Sopenharmony_ci
33f8af9c48Sopenharmony_cinamespace OHOS {
34f8af9c48Sopenharmony_cinamespace DistributedDeviceProfile {
35f8af9c48Sopenharmony_ciconst std::string ORGPKG_NAME = "deviceprofile";
36f8af9c48Sopenharmony_ciconst std::string SA_MAGR_NAME = "distributed.sa.manager";
37f8af9c48Sopenharmony_ciconst std::string KV_NAME = "distrubitedKv";
38f8af9c48Sopenharmony_ciconst std::string RDB_NAME = "relational_store";
39f8af9c48Sopenharmony_ciconst std::string DP_DATA_OPERATE_BEHAVIOR = "DP_DATA_OPERATE_BEHAVIOR";
40f8af9c48Sopenharmony_ciconst int32_t SUBSYS_DISTRIBUTEDHARDWARE_DP = 205;
41f8af9c48Sopenharmony_ciconstexpr int32_t INVALID_UDID_LENGTH = 10;
42f8af9c48Sopenharmony_ciconstexpr int32_t SUBSTR_UDID_LENGTH = 5;
43f8af9c48Sopenharmony_cienum class BizScene : int32_t {
44f8af9c48Sopenharmony_ci    DP_GET_SA = 1,
45f8af9c48Sopenharmony_ci    DP_ADD_DATA = 2,
46f8af9c48Sopenharmony_ci    DP_DELET_DATA = 3,
47f8af9c48Sopenharmony_ci    DP_GET_DATA = 4,
48f8af9c48Sopenharmony_ci    DP_SUBSCRIBE_DATA = 5,
49f8af9c48Sopenharmony_ci    DP_UNSUBSCRIBE_DATA = 6,
50f8af9c48Sopenharmony_ci    DP_SYNC_DATA = 7,
51f8af9c48Sopenharmony_ci    DP_PUT_ACL_PROFILE = 8,
52f8af9c48Sopenharmony_ci    DP_UPDATE_ACL_PROFILE = 9,
53f8af9c48Sopenharmony_ci    DP_GET_TRUST_PROFILE = 10,
54f8af9c48Sopenharmony_ci    DP_GET_ALL_TRUST_PROFILE = 11,
55f8af9c48Sopenharmony_ci    DP_GET_ACL_PROFILE = 12,
56f8af9c48Sopenharmony_ci    DP_GET_ALL_ACL_PROFILE = 13,
57f8af9c48Sopenharmony_ci    DP_DELETE_ACL_PROFILE = 14,
58f8af9c48Sopenharmony_ci    DP_PUT_SERVICE_PROFILE = 15,
59f8af9c48Sopenharmony_ci    DP_PUT_CHAR_PROFILE = 16,
60f8af9c48Sopenharmony_ci    DP_GET_DEVICE_PROFILE = 17,
61f8af9c48Sopenharmony_ci    DP_GET_SERVICE_PROFILE = 18,
62f8af9c48Sopenharmony_ci    DP_GET_CHAR_PROFILE = 19,
63f8af9c48Sopenharmony_ci    DP_DELETE_SERVICE_PROFILE = 20,
64f8af9c48Sopenharmony_ci    DP_DELETE_CHAR_PROFILE = 21,
65f8af9c48Sopenharmony_ci    DP_SUBSCRIBE_DEVICE_PROFILE = 22,
66f8af9c48Sopenharmony_ci    DP_UNSUNBSCRIBE_DEVICE_PROFILE = 23,
67f8af9c48Sopenharmony_ci    DP_SYNC_DEVICE_PROFILE = 24,
68f8af9c48Sopenharmony_ci};
69f8af9c48Sopenharmony_ci
70f8af9c48Sopenharmony_cienum class StageRes : int32_t {
71f8af9c48Sopenharmony_ci    STAGE_IDLE = 0x0,
72f8af9c48Sopenharmony_ci    STAGE_SUCC = 0x1,
73f8af9c48Sopenharmony_ci    STAGE_FAIL = 0x2,
74f8af9c48Sopenharmony_ci    STAGE_CANCEL = 0x3,
75f8af9c48Sopenharmony_ci    STAGE_UNKNOW = 0x4,
76f8af9c48Sopenharmony_ci};
77f8af9c48Sopenharmony_ci
78f8af9c48Sopenharmony_cienum class GetSaStage : int32_t {
79f8af9c48Sopenharmony_ci    DP_CHECK_SA = 0x1,
80f8af9c48Sopenharmony_ci    DP_LOAD_SA = 0x2,
81f8af9c48Sopenharmony_ci    DP_SA_CHACK_AUTH = 0x3,
82f8af9c48Sopenharmony_ci};
83f8af9c48Sopenharmony_ci
84f8af9c48Sopenharmony_cienum class BizState : int32_t {
85f8af9c48Sopenharmony_ci    BIZ_STATE_START = 0x1,
86f8af9c48Sopenharmony_ci    BIZ_STATE_END = 0x2,
87f8af9c48Sopenharmony_ci    BIZ_STATE_CANCEL = 0x3,
88f8af9c48Sopenharmony_ci};
89f8af9c48Sopenharmony_ci
90f8af9c48Sopenharmony_cienum class ProfileOperateStage : int32_t {
91f8af9c48Sopenharmony_ci    DP_PROFILE_OPERATE = 0x1,
92f8af9c48Sopenharmony_ci    DP_NOTIFY_PROFILE_CHANGE = 0x2,
93f8af9c48Sopenharmony_ci};
94f8af9c48Sopenharmony_ci
95f8af9c48Sopenharmony_ciclass DpRadarHelper {
96f8af9c48Sopenharmony_ci    DECLARE_SINGLE_INSTANCE(DpRadarHelper);
97f8af9c48Sopenharmony_cipublic:
98f8af9c48Sopenharmony_ci    void ReportCheckDpSa(int32_t stageRes);
99f8af9c48Sopenharmony_ci    void ReportLoadDpSa(int32_t stageRes);
100f8af9c48Sopenharmony_ci    void ReportLoadDpSaCb(int32_t stageRes);
101f8af9c48Sopenharmony_ci    void ReportSaCheckAuth(int32_t stageRes);
102f8af9c48Sopenharmony_ci    void ReportPutAclProfile(int32_t errCode, const AccessControlProfile& accessControlProfile);
103f8af9c48Sopenharmony_ci    void ReportUpdateAclProfile(int32_t errCode, const AccessControlProfile& accessControlProfile);
104f8af9c48Sopenharmony_ci    void ReportGetTrustProfile(int32_t errCode, const std::string& deviceId,
105f8af9c48Sopenharmony_ci        const TrustDeviceProfile& trustDeviceProfile);
106f8af9c48Sopenharmony_ci    void ReportGetAllTrustProfile(int32_t errCode, std::vector<TrustDeviceProfile>& trustDeviceProfiles);
107f8af9c48Sopenharmony_ci    void ReportGetAclProfile(int32_t errCode, std::vector<AccessControlProfile>& accessControlProfiles);
108f8af9c48Sopenharmony_ci    void ReportGetAllAclProfile(int32_t errCode, std::vector<AccessControlProfile>& accessControlProfiles);
109f8af9c48Sopenharmony_ci    void ReportDeleteAclProfile(int32_t errCode);
110f8af9c48Sopenharmony_ci    void ReportPutServiceProfile(int32_t errCode, const ServiceProfile& serviceProfile);
111f8af9c48Sopenharmony_ci    void ReportPutServiceProfileBatch(int32_t errCode, const std::vector<ServiceProfile>& serviceProfiles);
112f8af9c48Sopenharmony_ci    void ReportPutCharProfile(int32_t errCode, const CharacteristicProfile& characteristicProfile);
113f8af9c48Sopenharmony_ci    void ReportPutCharProfileBatch(int32_t errCode,
114f8af9c48Sopenharmony_ci        const std::vector<CharacteristicProfile>& characteristicProfiles);
115f8af9c48Sopenharmony_ci    void ReportGetDeviceProfile(int32_t errCode, const std::string& deviceId, DeviceProfile& deviceProfile);
116f8af9c48Sopenharmony_ci    void ReportGetServiceProfile(int32_t errCode,
117f8af9c48Sopenharmony_ci        const std::string& deviceId, ServiceProfile& serviceProfile);
118f8af9c48Sopenharmony_ci    void ReportGetCharProfile(int32_t errCode,
119f8af9c48Sopenharmony_ci        const std::string& deviceId, CharacteristicProfile& characteristicProfile);
120f8af9c48Sopenharmony_ci    void ReportDeleteServiceProfile(int32_t errCode, const std::string& deviceId);
121f8af9c48Sopenharmony_ci    void ReportDeleteCharProfile(int32_t errCode, const std::string& deviceId);
122f8af9c48Sopenharmony_ci    void ReportSubscribeDeviceProfile(int32_t errCode, const SubscribeInfo& subscribeInfo);
123f8af9c48Sopenharmony_ci    void ReportUnSubscribeDeviceProfile(int32_t errCode, const SubscribeInfo& subscribeInfo);
124f8af9c48Sopenharmony_ci    void ReportSyncDeviceProfile(int32_t errCode);
125f8af9c48Sopenharmony_ci    void ReportNotifyProfileChange(int32_t code);
126f8af9c48Sopenharmony_ci    std::string GetPeerUdidList(const std::vector<TrustDeviceProfile>& trustDeviceProfiles);
127f8af9c48Sopenharmony_ci    std::string GetPeerUdidList(const std::vector<AccessControlProfile>& accessControlProfiles);
128f8af9c48Sopenharmony_ci    std::string GetPeerUdidList(const std::vector<ServiceProfile>& serviceProfiles);
129f8af9c48Sopenharmony_ci    std::string GetPeerUdidList(const std::vector<CharacteristicProfile>& characteristicProfiles);
130f8af9c48Sopenharmony_ci    bool IsDeviceProfileInit();
131f8af9c48Sopenharmony_ci    void SetDeviceProfileInit(bool isInit);
132f8af9c48Sopenharmony_ciprivate:
133f8af9c48Sopenharmony_ci    std::string GetAnonyUdid(std::string udid);
134f8af9c48Sopenharmony_ci    std::string GetLocalUdid();
135f8af9c48Sopenharmony_ci    std::string GetPeerUdid(std::string udid);
136f8af9c48Sopenharmony_ci    bool isInit_ = false;
137f8af9c48Sopenharmony_ci};
138f8af9c48Sopenharmony_ci} // namespace DistributedDeviceProfile
139f8af9c48Sopenharmony_ci} // namespace OHOS
140f8af9c48Sopenharmony_ci#endif // OHOS_DP_RADAR_HELPER_H