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..3279d6019effd8ebb6a9f877fb781b521c27a547 100644 --- a/services/formmgr/src/form_sys_event_receiver.cpp +++ b/services/formmgr/src/form_sys_event_receiver.cpp @@ -40,7 +40,7 @@ const std::string KEY_BUNDLE_NAME = "bundleName"; * @brief Receiver Constructor. * @param subscriberInfo Subscriber info. */ -FormSysEventReceiver::FormSysEventReceiver(const EventFwk::CommonEventSubscribeInfo &subscriberInfo) +FormSysEventReceiver::FormSysEventReceiver(const EventFwk::CommonEventSubscribeInfo &subscriberInfo) : EventFwk::CommonEventSubscriber(subscriberInfo) {} /** @@ -53,7 +53,7 @@ void FormSysEventReceiver::OnReceiveEvent(const EventFwk::CommonEventData &event std::string action = want.GetAction(); std::string bundleName = want.GetStringParam(KEY_BUNDLE_NAME); if (action.empty() || bundleName.empty()) { - APP_LOGE("%{public}s failed, invalid param, action: %{public}s, bundleName: %{public}s", + APP_LOGE("%{public}s failed, invalid param, action: %{public}s, bundleName: %{public}s", __func__, action.c_str(), bundleName.c_str()); return; } @@ -104,7 +104,6 @@ void FormSysEventReceiver::HandleProviderUpdated(const std::string &bundleName) std::vector removedForms; std::vector updatedForms; - for (FormRecord& formRecord : formInfos) { APP_LOGI("%{public}s, provider update, formName:%{public}s", __func__, formRecord.formName.c_str()); int64_t formId = formRecord.formId; @@ -171,7 +170,7 @@ void FormSysEventReceiver::HandleProviderRemoved(const std::string &bundleName) } } -bool FormSysEventReceiver::ProviderFormUpdated(const int64_t formId, +bool FormSysEventReceiver::ProviderFormUpdated(const int64_t formId, const FormRecord &formRecord, const std::vector &targetForms) { APP_LOGI("%{public}s start", __func__); @@ -190,7 +189,7 @@ bool FormSysEventReceiver::ProviderFormUpdated(const int64_t formId, FormBmsHelper::GetInstance().NotifyModuleNotRemovable(formRecord.bundleName, formRecord.moduleName); FormTimerCfg timerCfg; - GetTimerCfg(updatedForm.updateEnabled, updatedForm.updateDuration, + GetTimerCfg(updatedForm.updateEnabled, updatedForm.updateDuration, updatedForm.scheduledUpateTime, timerCfg); HandleTimerUpdate(formId, formRecord, timerCfg); FormDataMgr::GetInstance().SetVersionUpgrade(formId, true); @@ -211,14 +210,13 @@ void FormSysEventReceiver::HandleBundleDataCleared(const std::string &bundleName for (int64_t formId : reCreateForms) { ReCreateForm(formId); } - // as form host data is cleared HandleFormHostDataCleared(uid); } void FormSysEventReceiver::HandleFormHostDataCleared(const int uid) { APP_LOGD("%{public}s, uid:%{public}d", __func__, uid); - std::map removedFormsMap; + std::map removedFormsMap; // clear formDBRecord ClearFormDBRecordData(uid, removedFormsMap); @@ -268,7 +266,7 @@ void FormSysEventReceiver::ClearTempFormRecordData(const int uid, std::map> &noHostFormDbMap, std::map &removedFormsMap) { std::set removableModuleSet; @@ -280,7 +278,7 @@ void FormSysEventReceiver::BatchDeleteNoHostDBForms(const int uid, std::map
> &noHostTempFormsMap, std::map &foundFormsMap) { for (const auto &element : noHostTempFormsMap) { @@ -331,7 +329,7 @@ void FormSysEventReceiver::BatchDeleteNoHostTempForms(const int uid, std::map 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; @@ -427,7 +419,7 @@ void FormSysEventReceiver::GetTimerCfg(const bool updateEnabled, } } -void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, +void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, const FormRecord &record, const FormTimerCfg &timerCfg) { // both disable @@ -444,13 +436,13 @@ void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, // disable to enable if (!record.isEnableUpdate && timerCfg.enableUpdate) { - FormDataMgr::GetInstance().SetUpdateInfo(formId, true, + FormDataMgr::GetInstance().SetUpdateInfo(formId, true, timerCfg.updateDuration, timerCfg.updateAtHour, timerCfg.updateAtMin); if (timerCfg.updateDuration > 0) { APP_LOGI("%{public}s, add interval timer:%{public}" PRId64 "", __func__, timerCfg.updateDuration); FormTimerMgr::GetInstance().AddFormTimer(formId, timerCfg.updateDuration); } else { - APP_LOGI("%{public}s, add at timer:%{public}d, %{public}d", __func__, + APP_LOGI("%{public}s, add at timer:%{public}d, %{public}d", __func__, timerCfg.updateAtHour, timerCfg.updateAtMin); FormTimerMgr::GetInstance().AddFormTimer(formId, timerCfg.updateAtHour, timerCfg.updateAtMin); } @@ -486,7 +478,7 @@ void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, } } - FormDataMgr::GetInstance().SetUpdateInfo(formId, true, + FormDataMgr::GetInstance().SetUpdateInfo(formId, true, timerCfg.updateDuration, timerCfg.updateAtHour, timerCfg.updateAtMin); FormTimerMgr::GetInstance().UpdateFormTimer(formId, type, timerCfg); } 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