1 /* 2 * Copyright (c) 2023-2024 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 16 #ifndef OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_CONSTANTS_H 17 #define OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_CONSTANTS_H 18 19 #include <unordered_set> 20 #include <string> 21 #include <unistd.h> 22 23 #ifdef __LP64__ 24 constexpr const char* LIB_LOAD_PATH = "/system/lib64/"; 25 constexpr const char* DMS_LIB_LOAD_PATH = "/system/lib64/platformsdk/"; 26 #else 27 constexpr const char* LIB_LOAD_PATH = "/system/lib/"; 28 constexpr const char* DMS_LIB_LOAD_PATH = "/system/lib/platformsdk/"; 29 #endif 30 31 namespace OHOS { 32 namespace DistributedDeviceProfile { 33 /* DeviceProfile Attribute */ 34 extern const std::string DEVICE_ID; 35 extern const std::string DEVICE_TYPE_ID; 36 extern const std::string DEVICE_TYPE_NAME; 37 extern const std::string DEVICE_NAME; 38 extern const std::string MANUFACTURE_NAME; 39 extern const std::string DEVICE_MODEL; 40 extern const std::string STORAGE_CAPACITY; 41 extern const std::string OS_SYS_CAPACITY; 42 extern const std::string OS_API_LEVEL; 43 extern const std::string OS_VERSION; 44 extern const std::string OS_TYPE; 45 extern const std::string OH_PROFILE_SUFFIX; 46 /* ServiceProfile Attribute */ 47 extern const std::string SERVICE_NAME; 48 extern const std::string SERVICE_TYPE; 49 /* CharacteristicProfile Attribute */ 50 extern const std::string CHARACTERISTIC_KEY; 51 extern const std::string CHARACTERISTIC_VALUE; 52 /* TrustDeviceProfile Attribute */ 53 extern const std::string SUBSCRIBE_TRUST_DEVICE_PROFILE; 54 extern const std::string DEVICE_ID_TYPE; 55 extern const std::string DEVICE_ID_HASH; 56 /* AccessControlProfile Attribute */ 57 extern const std::string ACCESS_CONTROL_ID; 58 extern const std::string ACCESSER_ID; 59 extern const std::string ACCESSEE_ID; 60 extern const std::string TRUST_DEVICE_ID; 61 extern const std::string SESSION_KEY; 62 extern const std::string BIND_TYPE; 63 extern const std::string AUTHENTICATION_TYPE; 64 extern const std::string BIND_LEVEL; 65 extern const std::string STATUS; 66 extern const std::string VALID_PERIOD; 67 extern const std::string LAST_AUTH_TIME; 68 /* Accesser Attribute */ 69 extern const std::string ACCESSER_DEVICE_ID; 70 extern const std::string ACCESSER_USER_ID; 71 extern const std::string ACCESSER_ACCOUNT_ID; 72 extern const std::string ACCESSER_TOKEN_ID; 73 extern const std::string ACCESSER_BUNDLE_NAME; 74 extern const std::string ACCESSER_HAP_SIGNATURE; 75 extern const std::string ACCESSER_BIND_LEVEL; 76 /* Accessee Attribute */ 77 extern const std::string ACCESSEE_DEVICE_ID; 78 extern const std::string ACCESSEE_USER_ID; 79 extern const std::string ACCESSEE_ACCOUNT_ID; 80 extern const std::string ACCESSEE_TOKEN_ID; 81 extern const std::string ACCESSEE_BUNDLE_NAME; 82 extern const std::string ACCESSEE_HAP_SIGNATURE; 83 extern const std::string ACCESSEE_BIND_LEVEL; 84 /* subscribe info */ 85 extern const std::string SA_ID; 86 extern const std::string SUBSCRIBE_KEY; 87 extern const std::string SUBSCRIBE_CHANGE_TYPES; 88 /* syncOptions */ 89 extern const std::string SYNC_MODE; 90 extern const std::string SYNC_DEVICE_IDS; 91 /* Interface Name */ 92 extern const std::string PUT_ACCESS_CONTROL_PROFILE; 93 extern const std::string UPDATE_ACCESS_CONTROL_PROFILE; 94 extern const std::string GET_ACCESS_CONTROL_PROFILE; 95 extern const std::string DELETE_ACCESS_CONTROL_PROFILE; 96 extern const std::string GET_TRUST_DEVICE_PROFILE; 97 extern const std::string GET_ALL_TRUST_DEVICE_PROFILE; 98 extern const std::string GET_ALL_ACCESS_CONTROL_PROFILE; 99 extern const std::string PUT_SERVICE_PROFILE; 100 extern const std::string PUT_SERVICE_PROFILE_BATCH; 101 extern const std::string PUT_CHARACTERISTIC_PROFILE; 102 extern const std::string PUT_CHARACTERISTIC_PROFILE_BATCH; 103 extern const std::string GET_DEVICE_PROFILE; 104 extern const std::string GET_SERVICE_PROFILE; 105 extern const std::string GET_CHARACTERISTIC_PROFILE; 106 extern const std::string DELETE_SERVICE_PROFILE; 107 extern const std::string DELETE_CHARACTERISTIC_PROFILE; 108 extern const std::string SUBSCRIBE_DEVICE_PROFILE; 109 extern const std::string UNSUBSCRIBE_DEVICE_PROFILE; 110 extern const std::string SYNC_DEVICE_PROFILE; 111 /* Common constants */ 112 constexpr int32_t MIN_STRING_LEN = 0; 113 constexpr int32_t MAX_STRING_LEN = 4096; 114 constexpr int64_t MIN_STORAGE_KB = 0; 115 constexpr int64_t MAX_STORAGE_KB = 5368709120; 116 constexpr int32_t MIN_OS_API_LEVEL = 0; 117 constexpr int32_t MAX_OS_API_LEVEL = 10000; 118 constexpr int32_t MIN_OS_TYPE = 0; 119 constexpr int32_t MAX_OS_TYPE = 10000; 120 constexpr int32_t MAX_PARAM_SIZE = 20; 121 constexpr int32_t MAX_PROFILE_SIZE = 10000; 122 constexpr int32_t MAX_DEVICE_SIZE = 1000; 123 constexpr int32_t MAX_SERVICE_SIZE = 1000; 124 constexpr int32_t MAX_CHAR_SIZE = 1000; 125 constexpr int32_t MAX_DB_SIZE = 1000; 126 constexpr int32_t MAX_LISTENER_SIZE = 100; 127 constexpr int32_t MAX_EVENT_HANDLER_SIZE = 50; 128 constexpr int32_t MAX_DB_RECORD_SIZE = 10000; 129 constexpr int32_t MAX_SUBSCRIBE_CHANGE_SIZE = 3; 130 constexpr int32_t MAX_INTERFACE_SIZE = 20; 131 constexpr int32_t MAX_SUBSCRIBE_INFO_SIZE = 500; 132 constexpr int32_t MAX_SYNC_RESULTS_SIZE = 50; 133 constexpr int32_t MAX_STATIC_CAPABILITY_SIZE = 100; 134 extern const std::string SEPARATOR; 135 extern const std::string DEV_PREFIX; 136 extern const std::string SVR_PREFIX; 137 extern const std::string CHAR_PREFIX; 138 extern const std::string USER_ID; 139 extern const std::string TOKEN_ID; 140 extern const std::string ALL_PROC; 141 constexpr int32_t NUM_1 = 1; 142 constexpr int32_t NUM_2 = 2; 143 constexpr int32_t NUM_3 = 3; 144 constexpr uint32_t NUM_1U = 1; 145 constexpr uint32_t NUM_8U = 8; 146 constexpr uint16_t CUR_SWITCH_LEN = 3; 147 extern const std::string DP_PKG_NAME; 148 extern const std::string IS_NUMSTRING_RULES; 149 constexpr int32_t OHOS_TYPE = 10; 150 constexpr int32_t OHOS_TYPE_UNKNOWN = -1; 151 /* rdb constants */ 152 extern const std::string RDB_PATH; 153 extern const std::string DATABASE_NAME; 154 constexpr int32_t RDB_VERSION = 1; 155 constexpr int32_t RDB_INIT_MAX_TIMES = 30; 156 constexpr int32_t RDB_INIT_INTERVAL_TIME = 100000; 157 /* TrustProfile Manager */ 158 extern const std::string USERID; 159 extern const std::string BUNDLENAME; 160 extern const std::string TOKENID; 161 extern const std::string ACCOUNTID; 162 extern const std::string DEVICEID_EQUAL_CONDITION; 163 extern const std::string ACCESSCONTROLID_EQUAL_CONDITION; 164 extern const std::string ACCESSERID_EQUAL_CONDITION; 165 extern const std::string ACCESSEEID_EQUAL_CONDITION; 166 constexpr int32_t ROWCNT_INIT = -1; 167 constexpr int32_t RET_INIT = -1; 168 constexpr int32_t ROWCOUNT_INIT = -1; 169 constexpr int32_t CHANGEROWCNT_INIT = -1; 170 constexpr int32_t COLUMNINDEX_INIT = -1; 171 constexpr int32_t STATUS_INIT = 0; 172 constexpr int32_t BINDTYPE_INIT = -1; 173 constexpr int32_t BINDLEVEL_INIT = -1; 174 constexpr int32_t DELETEROWS_INIT = -1; 175 constexpr int32_t DELETE_ACCESSER_CONDITION = 1; 176 constexpr int32_t DELETE_ACCESSEE_CONDITION = 1; 177 constexpr int32_t DELETE_TRUST_CONDITION = 0; 178 constexpr int32_t MAX_SAID = 16777215; 179 constexpr int64_t ROWID_INIT = -1; 180 constexpr int64_t ACCESSERID_INIT = -1; 181 constexpr int64_t ACCESSEEID_INIT = -1; 182 constexpr int64_t ACCESSCONTROLID_INIT = -1; 183 extern const std::string CREATE_TURST_DEVICE_TABLE_SQL; 184 extern const std::string CREATE_ACCESS_CONTROL_TABLE_SQL; 185 extern const std::string CREATE_ACCESSER_TABLE_SQL; 186 extern const std::string CREATE_ACCESSEE_TABLE_SQL; 187 extern const std::string CREATE_TURST_DEVICE_TABLE_UNIQUE_INDEX_SQL; 188 extern const std::string CREATE_ACCESS_CONTROL_TABLE_UNIQUE_INDEX_SQL; 189 extern const std::string CREATE_ACCESSER_TABLE_UNIQUE_INDEX_SQL; 190 extern const std::string CREATE_ACCESSEE_TABLE_UNIQUE_INDEX_SQL; 191 extern const std::string TRUST_DEVICE_TABLE; 192 extern const std::string ACCESS_CONTROL_TABLE; 193 extern const std::string ACCESSER_TABLE; 194 extern const std::string ACCESSEE_TABLE; 195 extern const std::string SELECT_TRUST_DEVICE_TABLE; 196 extern const std::string SELECT_TRUST_DEVICE_TABLE_WHERE_DEVICEID; 197 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ACCESSCONTROLID; 198 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ACCESSEEID; 199 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ACCESSERID; 200 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_BINDTYPE_AND_STATUS; 201 extern const std::string SELECT_ACCESS_CONTROL_TABLE; 202 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_TRUSTDEVICEID; 203 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_TRUSTDEVICEID_AND_STATUS; 204 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_STATUS; 205 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID; 206 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID; 207 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERUSERID_ACCESSERTOKENID; 208 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEUSEEID_ACCESSEETOKENID; 209 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERUSERID_ACCESSERBUNDLENAME; 210 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEUSEEID_ACCESSEEBUNDLENAME; 211 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERUSERID_ACCESSERACCOUNTID; 212 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEUSEEID_ACCESSEEACCOUNTID; 213 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERUSERID; 214 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEUSERID; 215 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_DEVICEID_AND_ACCESSERTOKENID; 216 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_DEVICEID_AND_ACCESSEETOKENID; 217 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERDEVICEID; 218 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEDEVICEID; 219 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERBUNDLENAME; 220 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEBUNDLENAME; 221 extern const std::string SELECT_ACCESSEE_TABLE; 222 extern const std::string SELECT_ACCESSER_TABLE; 223 extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ALL; 224 extern const std::string SELECT_ACCESSER_TABLE_WHERE_ALL; 225 extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ALL; 226 /* SubscribeTrustInfoManager */ 227 extern const std::string SUBSCRIBE_TRUST_INFO_TABLE; 228 extern const std::string CREATE_SUBSCRIBE_TRUST_INFO_TABLE_SQL; 229 extern const std::string CREATE_SUBSCRIBE_TRUST_INFO_TABLE_UNIQUE_INDEX_SQL; 230 extern const std::string TRUST_DEVICE_DELETE; 231 extern const std::string TRUST_DEVICE_ADD; 232 extern const std::string TRUST_DEVICE_UPDATE; 233 /* event handler factory */ 234 extern const std::string DP_HANDLER; 235 extern const std::string EMPTY_STRING; 236 /* switch attribute */ 237 extern const std::string SWITCH_CAPABILITY_PATH; 238 extern const std::string SWITCH_CALLERS; 239 extern const std::string SWITCH_SERVICE_NAMES; 240 extern const std::string SWITCH_STATUS; 241 extern const std::string SWITCH_ON; 242 extern const std::string SWITCH_OFF; 243 extern const std::string SWITCH_OPERATE_PUT; 244 extern const std::string SWITCH_OPERATE_GET; 245 /* static attribute */ 246 extern const std::string STATIC_CAPABILITY_SVR_ID; 247 extern const std::string STATIC_CAPABILITY_CHAR_ID; 248 extern const std::string STATIC_CAPABILITY_PATH; 249 extern const std::string STATIC_INFO_PATH; 250 extern const std::string STATIC_CAPABILITY_ATTRIBUTE; 251 extern const std::string STATIC_INFO; 252 extern const std::string DEFAULT_STATIC_VAL; 253 extern const std::string STATIC_CHARACTERISTIC_KEY; 254 extern const std::string STATIC_CAPABILITY_VERSION; 255 extern const std::string STATIC_CAPABILITY_VALUE; 256 extern const std::string DP_VERSION; 257 extern const std::string ABILITIES; 258 extern const std::string ABILITY_KEY; 259 extern const std::string ABILITY_VALUE; 260 constexpr char NOT_SUPPORT_STATIC_VAL = '0'; 261 constexpr char SUPPORT_STATIC_VAL = '1'; 262 extern const std::string STATIC_CAP_HANDLER_NAME; 263 extern const std::string STATIC_CAP_HANDLER_LOC; 264 extern const std::string DMS_HANDLER_LOC; 265 extern const std::string STATIC_VERSION_RULES; 266 constexpr uint32_t SWITCH_LENGTH_MAX = 24; 267 } // namespace DistributedDeviceProfile 268 } // namespace OHOS 269 #endif // OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_CONSTANTS_H 270