!16 CCM配置参数,使用三方接口增加异常处理

Merge pull request !16 from 李天刚/master
This commit is contained in:
openharmony_ci
2023-05-10 08:14:09 +00:00
committed by Gitee
3 changed files with 21 additions and 9 deletions
+1
View File
@@ -44,6 +44,7 @@ namespace DistributedInput {
// whilte list error code
constexpr int32_t ERR_DH_INPUT_WHILTELIST_INIT_FAIL = -61001;
constexpr int32_t ERR_DH_INPUT_WHILTELIST_GET_WHILTELIST_FAIL = -61002;
constexpr int32_t ERR_DH_INPUT_WHILTELIST_FILE_PATH_IS_NULL = -61003;
// handler error code
constexpr int32_t ERR_DH_INPUT_HANDLER_GET_DEVICE_ID_FAIL = -63000;
+18 -9
View File
@@ -65,6 +65,10 @@ int32_t WhiteListUtil::Init()
{
char buf[MAX_PATH_LEN] = {0};
char *whiteListFilePath = GetOneCfgFile(WHITELIST_FILE_PATH, buf, MAX_PATH_LEN);
if (whiteListFilePath == nullptr) {
DHLOGE("WhiteListFilePath is null!");
return ERR_DH_INPUT_WHILTELIST_FILE_PATH_IS_NULL;
}
std::ifstream inFile(whiteListFilePath, std::ios::in | std::ios::binary);
if (!inFile.is_open()) {
DHLOGE("WhiteListUtil Init error, file open fail path=%s", whiteListFilePath);
@@ -83,15 +87,7 @@ int32_t WhiteListUtil::Init()
}
vecKeyCode.clear();
vecCombinationKey.clear();
std::size_t pos1 = line.find(SPLIT_COMMA);
while (pos1 != std::string::npos) {
std::string column = line.substr(0, pos1);
line = line.substr(pos1 + 1, line.size());
pos1 = line.find(SPLIT_COMMA);
vecKeyCode.clear();
ReadLineDataStepOne(column, vecKeyCode, vecCombinationKey);
}
SplitCombinationKey(line, vecKeyCode, vecCombinationKey);
if (CheckIsNumber(line)) {
int32_t keyCode = std::stoi(line);
@@ -179,6 +175,19 @@ void WhiteListUtil::ReadLineDataStepOne(std::string &column, TYPE_KEY_CODE_VEC &
}
}
void WhiteListUtil::SplitCombinationKey(std::string &line, TYPE_KEY_CODE_VEC &vecKeyCode,
TYPE_COMBINATION_KEY_VEC &vecCombinationKey) const
{
std::size_t pos1 = line.find(SPLIT_COMMA);
while (pos1 != std::string::npos) {
std::string column = line.substr(0, pos1);
line = line.substr(pos1 + 1, line.size());
pos1 = line.find(SPLIT_COMMA);
vecKeyCode.clear();
ReadLineDataStepOne(column, vecKeyCode, vecCombinationKey);
}
}
int32_t WhiteListUtil::SyncWhiteList(const std::string &deviceId, const TYPE_WHITE_LIST_VEC &vecWhiteList)
{
DHLOGI("deviceId=%s", GetAnonyString(deviceId).c_str());
+2
View File
@@ -70,6 +70,8 @@ private:
std::string GetBusinessEventHash(const BusinessEvent &event);
bool IsValidLine(const std::string &line) const;
bool CheckIsNumber(const std::string &str) const;
void SplitCombinationKey(std::string &line, TYPE_KEY_CODE_VEC &vecKeyCode,
TYPE_COMBINATION_KEY_VEC &vecCombinationKey) const;
private:
TYPE_DEVICE_WHITE_LIST_MAP mapDeviceWhiteList_;
std::map<std::string, std::unordered_set<std::string>> combKeysHashMap_;