diff --git a/services/formmgr/BUILD.gn b/services/formmgr/BUILD.gn index 1ea0f1282196c4a211a6ac9684ecf7344db72ddb..5808dd089fe23e09bb329d4c0da63288ab57b30b 100644 --- a/services/formmgr/BUILD.gn +++ b/services/formmgr/BUILD.gn @@ -22,7 +22,6 @@ config("formmgr_config") { # "//base/miscservices/time/interfaces/innerkits/include", ] - cflags_cc = [ "-fexceptions" ] } group("fms_target") { diff --git a/services/formmgr/src/form_data_mgr.cpp b/services/formmgr/src/form_data_mgr.cpp index 1f5a45f8470d80a3e58f137bb5b795a73d17978a..94b4e638b69dee256edce65ec772551d606876ab 100644 --- a/services/formmgr/src/form_data_mgr.cpp +++ b/services/formmgr/src/form_data_mgr.cpp @@ -1089,7 +1089,7 @@ void FormDataMgr::ParseIntervalConfig(FormRecord &record, const int configDurati * @param record The form record. * @param info form item info. */ -void FormDataMgr::ParseAtTimerConfig(FormRecord &record, const FormItemInfo &info) const +void FormDataMgr::ParseAtTimerConfig(FormRecord &record, const FormItemInfo &info) const { record.isEnableUpdate = false; record.updateDuration = 0; @@ -1099,21 +1099,16 @@ void FormDataMgr::ParseAtTimerConfig(FormRecord &record, const FormItemInfo &inf return; } - std::vector temp = FormUtil::StringSplit(configAtTime, Constants::TIME_DELIMETER); + std::vector temp = FormUtil::StringSplit(configAtTime, Constants::TIME_DELIMETER); if (temp.size() != Constants::UPDATE_AT_CONFIG_COUNT) { APP_LOGE("%{public}s, invalid config", __func__); return; } int hour = -1; int min = -1; - try { - hour = std::stoi(temp[0]); - min = std::stoi(temp[1]); - } catch (const std::exception& e) { - APP_LOGE("%{public}s, failed to stoi.", __func__); - } - - if (hour < Constants::MIN_TIME || hour > Constants::MAX_HOUR || min < Constants::MIN_TIME || min > + hour = std::stoi(temp[0]); + min = std::stoi(temp[1]); + if (hour < Constants::MIN_TIME || hour > Constants::MAX_HOUR || min < Constants::MIN_TIME || min > Constants::MAX_MININUTE) { APP_LOGE("%{public}s, time is invalid", __func__); return; diff --git a/services/formmgr/src/form_sys_event_receiver.cpp b/services/formmgr/src/form_sys_event_receiver.cpp index 0fd6edcd7af5f3a947fd82dc5911b18e221b5c57..c6f35022361770870c4bb9a6be0d2433aec1979a 100644 --- a/services/formmgr/src/form_sys_event_receiver.cpp +++ b/services/formmgr/src/form_sys_event_receiver.cpp @@ -370,7 +370,7 @@ void FormSysEventReceiver::ReCreateForm(const int64_t formId) want.SetParam(Constants::RECREATE_FORM_KEY, true); FormProviderMgr::GetInstance().ConnectAmsForRefresh(formId, reCreateRecord, want, false); } -void FormSysEventReceiver::GetTimerCfg(const bool updateEnabled, +void FormSysEventReceiver::GetTimerCfg(const bool updateEnabled, const int updateDuration, const std::string &configUpdateAt, FormTimerCfg& cfg) { APP_LOGI("%{public}s start", __func__); @@ -399,22 +399,16 @@ void FormSysEventReceiver::GetTimerCfg(const bool updateEnabled, } APP_LOGI("%{public}s,update at timer updateAt:%{public}s", __func__, configUpdateAt.c_str()); - std::vector temp = FormUtil::StringSplit(configUpdateAt, Constants::TIME_DELIMETER); + std::vector temp = FormUtil::StringSplit(configUpdateAt, Constants::TIME_DELIMETER); if (temp.size() != Constants::UPDATE_AT_CONFIG_COUNT) { APP_LOGE("%{public}s, invalid config", __func__); return; } int hour = -1; int min = -1; - try { - hour = std::stoi(temp[0]); - min = std::stoi(temp[1]); - } catch (const std::exception& e) { - APP_LOGE("%{public}s, failed to stoi.", __func__); - return; - } - - if (hour < Constants::MIN_TIME || hour > Constants::MAX_HOUR || min < Constants::MIN_TIME || min > + hour = std::stoi(temp[0]); + min = std::stoi(temp[1]); + if (hour < Constants::MIN_TIME || hour > Constants::MAX_HOUR || min < Constants::MIN_TIME || min > Constants::MAX_MININUTE) { APP_LOGE("%{public}s, time is invalid", __func__); return; diff --git a/services/formmgr/src/form_util.cpp b/services/formmgr/src/form_util.cpp index d033818a1bf2addffede4129143fa14cfb905b98..d3f08c5f020012fedad3bcabbddd2c34cd586ca6 100644 --- a/services/formmgr/src/form_util.cpp +++ b/services/formmgr/src/form_util.cpp @@ -175,17 +175,11 @@ long FormUtil::GetMillisecondFromTm(struct tm &tmAtTime) */ std::vector FormUtil::StringSplit(const std::string &in, const std::string &delim) { - std::vector vEmpty; - try { - std::regex reg { delim }; - return std::vector { - std::sregex_token_iterator(in.begin(), in.end(), reg, -1), - std::sregex_token_iterator() - }; - } catch (const std::exception& e) { - APP_LOGE("%{public}s, failed to split string.", __func__); - } - return vEmpty; + std::regex reg { delim }; + return std::vector { + std::sregex_token_iterator(in.begin(), in.end(), reg, -1), + std::sregex_token_iterator() + }; } } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file