diff --git a/interfaces/innerkits/form_manager/include/form_constants.h b/interfaces/innerkits/form_manager/include/form_constants.h index c02f3516da0b29ec66ac514db8224826449a7a3d..796d214f81f2ffa58b6aaec3babb59ee898d9bcd 100644 --- a/interfaces/innerkits/form_manager/include/form_constants.h +++ b/interfaces/innerkits/form_manager/include/form_constants.h @@ -37,7 +37,7 @@ namespace Constants { const int32_t ORIENTATION_PORTRAIT = 1; const int32_t ORIENTATION_LANDSCAPE = 2; const std::string PARAM_FORM_ABILITY_NAME_KEY = "abilityName"; - + const std::string PARAM_FORM_USER_ID = "ohos.extra.param.key.form_user_id"; const std::string KEY_IS_TIMER = "isTimerRefresh"; const std::string SYSTEM_PARAM_FORM_UPDATE_TIME = "persist.sys.fms.form.update.time"; const std::string SYSTEM_PARAM_FORM_REFRESH_MIN_TIME = "persist.sys.fms.form.refresh.min.time"; diff --git a/services/formmgr/BUILD.gn b/services/formmgr/BUILD.gn index baa09e3e2a9277589ee857d9981195378c79cc41..19332c1f376e5e75606c1bf8b304f2c845cfbd33 100644 --- a/services/formmgr/BUILD.gn +++ b/services/formmgr/BUILD.gn @@ -109,7 +109,7 @@ ohos_shared_library("libfms") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "os_account_standard:libaccountkits", - "os_account_standard:libaccountkits", + "os_account_standard:os_account_innerkits", "permission_standard:libpermissionsdk_standard", "power_manager_native:powermgr_client", "safwk:system_ability_fwk", diff --git a/services/formmgr/include/form_data_mgr.h b/services/formmgr/include/form_data_mgr.h index f726ace290645d3a72af5f673db20fd1e1ed3efc..61ec4383af0df6d1792bd2cfc59a9fe015aa8a3a 100644 --- a/services/formmgr/include/form_data_mgr.h +++ b/services/formmgr/include/form_data_mgr.h @@ -23,6 +23,7 @@ #include #include +#include "form_constants.h" #include "form_host_record.h" #include "form_id_key.h" #include "form_info.h" @@ -46,9 +47,11 @@ public: * @param formId The Id of the form. * @param formInfo Form item info. * @param callingUid The UID of the proxy. + * @param userId User ID. * @return Returns form record. */ - FormRecord AllotFormRecord(const FormItemInfo &formInfo, const int callingUid); + FormRecord AllotFormRecord(const FormItemInfo &formInfo, const int callingUid, + const int32_t userId = Constants::DEFAULT_USER_ID); /** * @brief Create form js info by form record. * @param formId The Id of the form. @@ -85,10 +88,11 @@ public: int CheckTempEnoughForm() const; /** * @brief Check form count is max. + * @param currentUserId The current userId. * @param callingUid The UID of the proxy. * @return Returns true if this function is successfully called; returns false otherwise. */ - int CheckEnoughForm(const int callingUid) const; + int CheckEnoughForm(const int callingUid, const int32_t currentUserId = Constants::DEFAULT_USER_ID) const; /** * @brief Delete temp form. * @param formId The Id of the form. @@ -114,14 +118,14 @@ public: * @param formUserUid The form user uid. * @return Returns true if this function is successfully called; returns false otherwise. */ - bool AddFormUserUid(const int64_t formId, const int32_t formUserUid); + bool AddFormUserUid(const int64_t formId, const int formUserUid); /** * @brief Delete form user uid from form record. * @param formId The Id of the form. * @param uid calling user id. * @return Returns true if this function is successfully called; returns false otherwise. */ - bool DeleteFormUserUid(const int64_t formId, const int32_t uid); + bool DeleteFormUserUid(const int64_t formId, const int uid); /** * @brief Update form record. * @param formId The Id of the form. @@ -185,7 +189,7 @@ public: * @param formUserUids The form user uids. * @return Returns true if this user uid is valid; returns false otherwise. */ - bool IsCallingUidValid(const std::vector &formUserUids) const; + bool IsCallingUidValid(const std::vector &formUserUids) const; /** * @brief Generate udid. * @return Returns true if this function is successfully called; returns false otherwise. @@ -331,6 +335,13 @@ public: */ void UpdateFormProviderInfo(const int64_t formId, const FormProviderInfo &formProviderInfo); + /** + * @brief delete forms by userId. + * + * @param userId user ID. + * @param removedFormIds removed userId. + */ + void DeleteFormsByUserId(const int32_t userId, std::vector &removedFormIds); /** * @brief Clear form records for st limit value test. */ @@ -340,9 +351,11 @@ private: * @brief Create form record. * @param formInfo The form item info. * @param callingUid The UID of the proxy. + * @param userId User ID. * @return Form record. */ - FormRecord CreateFormRecord(const FormItemInfo &formInfo, const int callingUid) const; + FormRecord CreateFormRecord(const FormItemInfo &formInfo, const int callingUid, + const int32_t userId = Constants::DEFAULT_USER_ID) const; /** * @brief Create host record. * @param info The form item info. diff --git a/services/formmgr/include/form_db_cache.h b/services/formmgr/include/form_db_cache.h index 66c2d27918d64978a3f66361084fe805ff801425..a4652652cb6f47a9f6df77581ffdaa8dbcdfa4b6 100644 --- a/services/formmgr/include/form_db_cache.h +++ b/services/formmgr/include/form_db_cache.h @@ -122,6 +122,12 @@ public: * @return Returns data storage. */ std::shared_ptr GetDataStorage() const; + + /** + * @brief delete forms bu userId. + * @param userId user ID. + */ + void DeleteDBFormsByUserId(const int32_t userId); private: std::shared_ptr dataStorage_; mutable std::mutex formDBInfosMutex_; diff --git a/services/formmgr/include/form_db_info.h b/services/formmgr/include/form_db_info.h index 0f93b03d5b1f93ca0772123f1771a40c4fd845ca..6913e9ad65de71c53bc889c6c1f209e4ff278e0a 100644 --- a/services/formmgr/include/form_db_info.h +++ b/services/formmgr/include/form_db_info.h @@ -25,11 +25,12 @@ namespace OHOS { namespace AppExecFwk { struct FormDBInfo { int64_t formId; + int32_t userId; std::string formName; std::string bundleName; std::string moduleName; std::string abilityName; - std::vector formUserUids; + std::vector formUserUids; /** * @brief Constructors @@ -47,6 +48,7 @@ struct FormDBInfo { FormDBInfo(const int64_t formIdTmp, const FormRecord &formRecord) { formId = formIdTmp; + userId = formRecord.userId; formName = formRecord.formName; bundleName = formRecord.bundleName; moduleName = formRecord.moduleName; @@ -81,6 +83,9 @@ struct FormDBInfo { if (formId != formDBInfo.formId) { return false; } + if (userId != formDBInfo.userId) { + return false; + } if (formName != formDBInfo.formName) { return false; } @@ -117,6 +122,7 @@ public: InnerFormInfo(const FormDBInfo &formDBInfo) { formDBInfo_.formId = formDBInfo.formId; + formDBInfo_.userId = formDBInfo.userId; formDBInfo_.formName = formDBInfo.formName; formDBInfo_.bundleName = formDBInfo.bundleName; formDBInfo_.moduleName = formDBInfo.moduleName; @@ -130,6 +136,7 @@ public: InnerFormInfo(const InnerFormInfo &innerFormInfo) { formDBInfo_.formId = innerFormInfo.formDBInfo_.formId; + formDBInfo_.userId = innerFormInfo.formDBInfo_.userId; formDBInfo_.formName = innerFormInfo.formDBInfo_.formName; formDBInfo_.bundleName = innerFormInfo.formDBInfo_.bundleName; formDBInfo_.moduleName = innerFormInfo.formDBInfo_.moduleName; @@ -143,6 +150,7 @@ public: InnerFormInfo(const int64_t formId, const FormRecord &formRecord) { formDBInfo_.formId = formId; + formDBInfo_.userId = formRecord.userId; formDBInfo_.formName = formRecord.formName; formDBInfo_.bundleName = formRecord.bundleName; formDBInfo_.moduleName = formRecord.moduleName; @@ -153,6 +161,7 @@ public: { nlohmann::json j; j["formId"] = formDBInfo_.formId; + j["userId"] = formDBInfo_.userId; j["formName"] = formDBInfo_.formName; j["bundleName"] = formDBInfo_.bundleName; j["moduleName"] = formDBInfo_.moduleName; @@ -205,6 +214,24 @@ public: formDBInfo_.formId = formId; } + /** + * @brief Get application user id. + * @return Returns the user id. + */ + int64_t GetUserId() const + { + return formDBInfo_.userId; + } + + /** + * @brief Set application user id. + * @param userId Indicates the user id to be set. + */ + void SetUserId(const int64_t userId) + { + formDBInfo_.userId = userId; + } + /** * @brief Get application form name. * @return Returns the form name. @@ -281,7 +308,7 @@ public: * @brief Get application user uids. * @return Returns the user uids. */ - std::vector GetUserUids() const + std::vector GetUserUids() const { return formDBInfo_.formUserUids; } @@ -290,7 +317,7 @@ public: * @brief Set application user uids. * @param userId Indicates the user uids to be set. */ - void SetUserUids(const std::vector &formUserUids) + void SetUserUids(const std::vector &formUserUids) { formDBInfo_.formUserUids.insert(formDBInfo_.formUserUids.end(), formUserUids.begin(), formUserUids.end()); } diff --git a/services/formmgr/include/form_mgr_adapter.h b/services/formmgr/include/form_mgr_adapter.h index 7101c730515b46c5f7331ba84dfc1fcc9612aa48..e9e6160e3faa5d4549fa7a1bbb2c2abf5ba3de47 100644 --- a/services/formmgr/include/form_mgr_adapter.h +++ b/services/formmgr/include/form_mgr_adapter.h @@ -395,9 +395,10 @@ private: * @brief set next refresht time locked. * @param formId The form's id. * @param nextTime next refresh time. + * @param userId User ID. * @return Returns ERR_OK on success, others on failure. */ - int SetNextRefreshtTimeLocked(const int64_t formId, const int64_t nextTime); + int SetNextRefreshtTimeLocked(const int64_t formId, const int64_t nextTime, const int32_t userId = 0); /** * @brief set next refresht time locked. @@ -458,6 +459,12 @@ private: */ bool CreateHandleEventMap(const int64_t matchedFormId, const FormRecord &formRecord, std::map> &eventMaps); + /** + * @brief Get current user ID. + * @param callingUid calling Uid. + * @return Returns user ID. + */ + int32_t GetCurrentUserId(const int callingUid); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/formmgr/include/form_record.h b/services/formmgr/include/form_record.h index ffb7db76dc40e6d844ccbbb917cfca17f7c2050a..dcb0f453df373f709d527c9416d99d922f0c1de4 100644 --- a/services/formmgr/include/form_record.h +++ b/services/formmgr/include/form_record.h @@ -51,7 +51,7 @@ public: std::vector formUserUids; bool formVisibleNotify = false; int formVisibleNotifyState = 0; - int userId = 0; + int32_t userId = 0; std::string formSrc = ""; FormWindow formWindow; uint32_t versionCode = 0; diff --git a/services/formmgr/include/form_sys_event_receiver.h b/services/formmgr/include/form_sys_event_receiver.h index a8c54ec2d0513b37cbeb04f85a25080d641b2fa9..e6ccac514c273e54865b151d74131c000e841ee8 100644 --- a/services/formmgr/include/form_sys_event_receiver.h +++ b/services/formmgr/include/form_sys_event_receiver.h @@ -50,6 +50,7 @@ private: void ClearTempFormRecordData(const int uid, std::map &removedFormsMap); void BatchDeleteNoHostDBForms(const int uid, std::map> &noHostFormDbMap, std::map &removedFormsMap); + void HandleUserIdRemoved(const int32_t userId); // multiuser /** * @brief Delete no host temp forms. * @param uid The caller uid. diff --git a/services/formmgr/include/form_timer.h b/services/formmgr/include/form_timer.h index ad44ad69befa4e727a3321fb6e314f7946e314de..e52bac2530ccd5acfe5e7b8292e030d066869fac 100644 --- a/services/formmgr/include/form_timer.h +++ b/services/formmgr/include/form_timer.h @@ -35,6 +35,7 @@ enum UpdateType { class FormTimer { public: int64_t formId; + int32_t userId; int64_t period; int hour; int min; @@ -47,6 +48,7 @@ public: FormTimer() { formId = -1; + userId = -1; period = -1; hour = -1; min = -1; @@ -56,9 +58,10 @@ public: type = UpdateType::TYPE_INTERVAL_CHANGE; } - FormTimer(int64_t id, bool countTimer) + FormTimer(int64_t id, bool countTimer, int32_t uId = 0) { formId = id; + userId = uId; period = -1; hour = -1; min = -1; @@ -68,9 +71,10 @@ public: type = UpdateType::TYPE_INTERVAL_CHANGE; } - FormTimer(int64_t id, long repeatTime) + FormTimer(int64_t id, long repeatTime, int32_t uId = 0) { formId = id; + userId = uId; period = repeatTime; hour = -1; min = -1; @@ -80,9 +84,10 @@ public: type = UpdateType::TYPE_INTERVAL_CHANGE; } - FormTimer(int64_t id, int hourTime, int minTime) + FormTimer(int64_t id, int hourTime, int minTime, int32_t uId = 0) { formId = id; + userId = uId; hour = hourTime; min = minTime; period = -1; @@ -111,13 +116,14 @@ class DynamicRefreshItem { public: int64_t formId = 0L; int64_t settedTime = -1L; - + int32_t userId = -1; DynamicRefreshItem(){} - DynamicRefreshItem(int64_t id, int64_t time) + DynamicRefreshItem(int64_t id, int64_t time, int32_t uId = 0) { formId = id; settedTime = time; + userId = uId; } ~DynamicRefreshItem(void){ } diff --git a/services/formmgr/include/form_timer_mgr.h b/services/formmgr/include/form_timer_mgr.h index f0d2aa209405a3dba5a4811095f8794d0f5452d7..23e9cf5da7878c83c7c3c9ea05277f8eb1ba93a2 100644 --- a/services/formmgr/include/form_timer_mgr.h +++ b/services/formmgr/include/form_timer_mgr.h @@ -57,18 +57,20 @@ public: /** * @brief Add duration form timer. * @param formId The Id of the form. - * @param updateDuration Update duration + * @param updateDuration Update duration. + * @param userId User ID. * @return Returns true on success, false on failure. */ - bool AddFormTimer(const int64_t formId, const long updateDuration); + bool AddFormTimer(const int64_t formId, const long updateDuration, const int32_t userId = 0); /** * @brief Add scheduled form timer. * @param formId The Id of the form. * @param updateAtHour Hour * @param updateAtMin Min + * @param userId User ID. * @return Returns true on success, false on failure. */ - bool AddFormTimer(const int64_t formId, const long updateAtHour, const long updateAtMin); + bool AddFormTimer(const int64_t formId, const long updateAtHour, const long updateAtMin, const int32_t userId = 0); /** * @brief Remove form timer by form id. * @param formId The Id of the form. @@ -98,9 +100,10 @@ public: * @brief Set next refresh time. * @param formId The Id of the form. * @param nextGapTime Next gap time. + * @param userId User ID. * @return Returns true on success, false on failure. */ - bool SetNextRefreshTime(const int64_t formId, const long nextGapTime); + bool SetNextRefreshTime(const int64_t formId, const long nextGapTime, const int32_t userId = 0); /** * @brief Get refresh count. * @param formId The Id of the form. @@ -314,6 +317,13 @@ private: * @return Returns WantAgent. */ std::shared_ptr GetDynamicWantAgent(long nextTime); + + /** + * @brief check if user is active or not. + * @param userId User ID. + * @return true:active, false:inactive + */ + bool IsActiveUser(const int32_t userId); private: /** * @class TimerReceiver diff --git a/services/formmgr/src/form_data_mgr.cpp b/services/formmgr/src/form_data_mgr.cpp index d67ff19c574ba56b9fdeafffd7e5f6d9e4fa1321..bd5d07359573b12696027305425b281e7e9f0662 100644 --- a/services/formmgr/src/form_data_mgr.cpp +++ b/services/formmgr/src/form_data_mgr.cpp @@ -39,12 +39,12 @@ FormDataMgr::~FormDataMgr() /** * @brief Allot form info by item info. - * @param formId The Id of the form. * @param formInfo Form item info. * @param callingUid The UID of the proxy. + * @param userId User ID. * @return Returns form record. */ -FormRecord FormDataMgr::AllotFormRecord(const FormItemInfo &formInfo, const int callingUid) +FormRecord FormDataMgr::AllotFormRecord(const FormItemInfo &formInfo, const int callingUid, const int32_t userId) { APP_LOGI("%{public}s, allot form info", __func__); if (formInfo.IsTemporaryForm() && !ExistTempForm(formInfo.GetFormId())) { @@ -56,13 +56,13 @@ FormRecord FormDataMgr::AllotFormRecord(const FormItemInfo &formInfo, const int std::lock_guard lock(formRecordMutex_); if (formRecords_.empty()) { // formRecords_ is empty, create a new one APP_LOGD("%{public}s, form info not exist", __func__); - record = CreateFormRecord(formInfo, callingUid); + record = CreateFormRecord(formInfo, callingUid, userId); formRecords_.emplace(formInfo.GetFormId(), record); } else { auto info = formRecords_.find(formInfo.GetFormId()); if (info == formRecords_.end()) { APP_LOGD("%{public}s, form info not find", __func__); - record = CreateFormRecord(formInfo, callingUid); + record = CreateFormRecord(formInfo, callingUid, userId); formRecords_.emplace(formInfo.GetFormId(), record); } else { record = info->second; @@ -144,13 +144,15 @@ bool FormDataMgr::CreateHostRecord(const FormItemInfo &info, const sptr= Constants::MAX_FORMS) { - APP_LOGW("%{public}s, already exist %{public}d forms in system", __func__, Constants::MAX_FORMS); - return ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS; - } + APP_LOGI("%{public}s, callingUid: %{public}d, current userId: %{public}d", __func__, callingUid, currentUserId); + int formsInSystem = 0; int callingUidFormCounts = 0; for (auto &recordPair : formRecords_) { FormRecord record = recordPair.second; - if (IsCallingUidValid(record.formUserUids) && !record.formTempFlg) { + if ((record.userId == currentUserId) && !record.formTempFlg) { + if (++formsInSystem >= Constants::MAX_FORMS) { + APP_LOGW("%{public}s, already exist %{public}d forms in system", __func__, Constants::MAX_FORMS); + return ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS; + } for (auto &userUid : record.formUserUids) { if (userUid == callingUid) { if (++callingUidFormCounts >= Constants::MAX_RECORD_PER_APP) { APP_LOGW("%{public}s, already use %{public}d forms", __func__, Constants::MAX_RECORD_PER_APP); return ERR_APPEXECFWK_FORM_MAX_FORMS_PER_CLIENT; } + break; } } } @@ -274,7 +278,7 @@ bool FormDataMgr::ExistTempForm(const int64_t formId) const * @param formUserUids The form user uids. * @return Returns true if this user uid is valid; returns false otherwise. */ -bool FormDataMgr::IsCallingUidValid(const std::vector &formUserUids) const +bool FormDataMgr::IsCallingUidValid(const std::vector &formUserUids) const { if (formUserUids.size() != 0) { for (auto &userUid : formUserUids) { @@ -308,7 +312,7 @@ bool FormDataMgr::ModifyFormTempFlg(const int64_t formId, const bool formTempFlg * @param formRecord The form record. * @return Returns true if this function is successfully called; returns false otherwise. */ -bool FormDataMgr::AddFormUserUid(const int64_t formId, const int32_t formUserUid) +bool FormDataMgr::AddFormUserUid(const int64_t formId, const int formUserUid) { APP_LOGI("%{public}s, add form user uid by formId", __func__); std::lock_guard lock(formRecordMutex_); @@ -328,7 +332,7 @@ bool FormDataMgr::AddFormUserUid(const int64_t formId, const int32_t formUserUid * @param uid calling user id. * @return Returns true if this function is successfully called; returns false otherwise. */ -bool FormDataMgr::DeleteFormUserUid(const int64_t formId, const int32_t uid) +bool FormDataMgr::DeleteFormUserUid(const int64_t formId, const int uid) { APP_LOGI("%{public}s, delete form user uid from form record", __func__); std::lock_guard lock(formRecordMutex_); @@ -1146,7 +1150,47 @@ bool FormDataMgr::IsFormCached(const FormRecord record) } return FormCacheMgr::GetInstance().IsExist(record.formId); } +/** + * @brief delete forms by userId. + * + * @param userId user ID. + * @param removedFormIds removed userId. + */ +void FormDataMgr::DeleteFormsByUserId(const int32_t userId, std::vector &removedFormIds) +{ + APP_LOGI("%{public}s, delete forms by userId", __func__); + + // handle formRecords_ + std::vector removedTempForms; + { + std::lock_guard lock(formRecordMutex_); + std::map::iterator itFormRecord; + for (itFormRecord = formRecords_.begin(); itFormRecord != formRecords_.end(); itFormRecord++) { + if (userId == itFormRecord->second.userId) { + if (itFormRecord->second.formTempFlg) { + removedTempForms.emplace_back(itFormRecord->second.formId); + } + removedFormIds.emplace_back(itFormRecord->second.formId); + itFormRecord = formRecords_.erase(itFormRecord); + } else { + itFormRecord++; + } + } + } + // handle tempForms_ + if (removedTempForms.size() > 0) { + std::lock_guard lock(formTempMutex_); + std::vector::iterator itTemp; + for (itTemp = tempForms_.begin();itTemp != tempForms_.end();) { + if (std::find(removedTempForms.begin(), removedTempForms.end(), *itTemp) != removedTempForms.end()) { + itTemp = tempForms_.erase(itTemp); + } else { + itTemp++; + } + } + } +} /** * @brief Clear form records for st limit value test. */ diff --git a/services/formmgr/src/form_db_cache.cpp b/services/formmgr/src/form_db_cache.cpp index d0c2589fde72e0a301a335e67187f5973e7defba..0888c12ab6508cf6bbd67a1f72983fe3b1dec445 100644 --- a/services/formmgr/src/form_db_cache.cpp +++ b/services/formmgr/src/form_db_cache.cpp @@ -180,6 +180,7 @@ ErrCode FormDbCache::GetDBRecord(const int64_t formId, FormRecord &record) const std::lock_guard lock(formDBInfosMutex_); for (const FormDBInfo &dbInfo : formDBInfos_) { if (dbInfo.formId == formId) { + record.userId = dbInfo.userId; record.formName = dbInfo.formName; record.bundleName = dbInfo.bundleName; record.moduleName = dbInfo.moduleName; @@ -277,7 +278,29 @@ int FormDbCache::GetMatchCount(const std::string &bundleName, const std::string } return matchCount; } - +/** + * @brief delete forms bu userId. + * + * @param userId user ID. + */ +void FormDbCache::DeleteDBFormsByUserId(const int32_t userId) +{ + std::lock_guard lock(formDBInfosMutex_); + std::vector::iterator itRecord; + for (itRecord = formDBInfos_.begin(); itRecord != formDBInfos_.end();) { + if (userId == itRecord->userId) { + int64_t formId = itRecord->formId; + if (dataStorage_->DeleteStorageFormInfo(std::to_string(formId)) == ERR_OK) { + itRecord = formDBInfos_.erase(itRecord); + } else { + APP_LOGE("%{public}s, failed to delete form, formId[%{public}" PRId64 "]", __func__, formId); + itRecord++; + } + } else { + itRecord++; + } + } +} std::shared_ptr FormDbCache::GetDataStorage() const { return dataStorage_; diff --git a/services/formmgr/src/form_db_info.cpp b/services/formmgr/src/form_db_info.cpp index 6c0551b52b275f96e6a79716ae3a19691922f267..d6467d3eb2d0ca3efa7275e57b02b8ebb0315ec9 100644 --- a/services/formmgr/src/form_db_info.cpp +++ b/services/formmgr/src/form_db_info.cpp @@ -21,6 +21,7 @@ namespace OHOS { namespace AppExecFwk { namespace { const std::string INNER_FORM_INFO_FORM_ID = "formId"; +const std::string INNER_FORM_INFO_USER_ID = "userId"; const std::string INNER_FORM_INFO_FORM_NAME = "formName"; const std::string INNER_FORM_INFO_BUNDLE_NAME = "bundleName"; const std::string INNER_FORM_INFO_MODULE_NAME = "moduleName"; @@ -36,6 +37,7 @@ const std::string INNER_FORM_INFO_FORM_USER_UIDS = "formUserUids"; void InnerFormInfo::ToJson(nlohmann::json &jsonObject) const { jsonObject[INNER_FORM_INFO_FORM_ID] = formDBInfo_.formId; + jsonObject[INNER_FORM_INFO_USER_ID] = formDBInfo_.userId; jsonObject[INNER_FORM_INFO_FORM_NAME] = formDBInfo_.formName; jsonObject[INNER_FORM_INFO_BUNDLE_NAME] = formDBInfo_.bundleName; jsonObject[INNER_FORM_INFO_MODULE_NAME] = formDBInfo_.moduleName; @@ -60,6 +62,14 @@ bool InnerFormInfo::FromJson(const nlohmann::json &jsonObject) false, parseResult, ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + INNER_FORM_INFO_USER_ID, + formDBInfo_.userId, + JsonType::NUMBER, + false, + parseResult, + ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, INNER_FORM_INFO_FORM_NAME, @@ -92,7 +102,7 @@ bool InnerFormInfo::FromJson(const nlohmann::json &jsonObject) false, parseResult, ArrayType::NOT_ARRAY); - GetValueIfFindKey>(jsonObject, + GetValueIfFindKey>(jsonObject, jsonObjectEnd, INNER_FORM_INFO_FORM_USER_UIDS, formDBInfo_.formUserUids, diff --git a/services/formmgr/src/form_dump_mgr.cpp b/services/formmgr/src/form_dump_mgr.cpp index 68c7c0cbb807486e7a8b3a8989059979c3192505..51a2ae50ec4ae8c02b965968f878d57564d272b1 100644 --- a/services/formmgr/src/form_dump_mgr.cpp +++ b/services/formmgr/src/form_dump_mgr.cpp @@ -32,6 +32,7 @@ void FormDumpMgr::DumpStorageFormInfos(const std::vector &storageInf for (const auto &info : storageInfos) { formInfos += " FormId #" + std::to_string(info.formId); formInfos += " formName [" + info.formName + "]"; + formInfos += " userId [" + std::to_string(info.userId) + "]"; formInfos += " bundleName [" + info.bundleName + "]"; formInfos += " moduleName [" + info.moduleName + "]"; formInfos += " abilityName [" + info.abilityName + "]"; @@ -67,6 +68,7 @@ void FormDumpMgr::DumpFormInfos(const std::vector &formRecordInfos, formInfos += " formTempFlg [" + std::to_string(info.formTempFlg) + "]"; formInfos += " formVisibleNotify [" + std::to_string(info.formVisibleNotify) + "]"; formInfos += " formVisibleNotifyState [" + std::to_string(info.formVisibleNotifyState) + "]"; + formInfos += " userId [" + std::to_string(info.userId) + "]"; if (info.hapSourceDirs.size() > 0) { formInfos += " hapSourceDirs ["; @@ -141,6 +143,7 @@ void FormDumpMgr::DumpFormInfo(const FormRecord &formRecordInfo, std::string &fo formInfo += " versionName [" + formRecordInfo.versionName + "]"; formInfo += " compatibleVersion [" + std::to_string(formRecordInfo.compatibleVersion) + "]"; formInfo += " icon [" + formRecordInfo.icon + "]"; + formInfo += " userId [" + std::to_string(formRecordInfo.userId) + "]"; if (formRecordInfo.hapSourceDirs.size() > 0) { formInfo += " hapSourceDirs ["; diff --git a/services/formmgr/src/form_mgr_adapter.cpp b/services/formmgr/src/form_mgr_adapter.cpp index a3e95a0a2d47e78217892e253d3ad4a8e9ec4999..174d8fc3d249c8b227408d8f54446157ee8dcd83 100644 --- a/services/formmgr/src/form_mgr_adapter.cpp +++ b/services/formmgr/src/form_mgr_adapter.cpp @@ -46,6 +46,8 @@ namespace OHOS { namespace AppExecFwk { const int HUNDRED = 100; +constexpr int32_t UID_CALLINGUID_TRANSFORM_DIVISOR = 200000; + FormMgrAdapter::FormMgrAdapter() { }; @@ -80,7 +82,9 @@ int FormMgrAdapter::AddForm(const int64_t formId, const Want &want, checkCode = FormDataMgr::GetInstance().CheckTempEnoughForm(); } else { if (formId == 0) { - checkCode = FormDataMgr::GetInstance().CheckEnoughForm(callingUid); + // get current userId + int32_t currentUserId = GetCurrentUserId(callingUid); + checkCode = FormDataMgr::GetInstance().CheckEnoughForm(callingUid, currentUserId); } } if (checkCode != 0) { @@ -153,7 +157,19 @@ int FormMgrAdapter::ReleaseForm(const int64_t formId, const sptr // delete temp form if receive release form call return HandleDeleteTempForm(matchedFormId, callerToken); } - + FormRecord dbRecord; + if (FormDbCache::GetInstance().GetDBRecord(matchedFormId, dbRecord) != ERR_OK) { + APP_LOGE("%{public}s, not exist such db form:%{public}" PRId64 "", __func__, formId); + return ERR_APPEXECFWK_FORM_NOT_EXIST_ID; + } + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = GetCurrentUserId(callingUid); + bool isSelfDbFormId = (userId == dbRecord.userId) && ((std::find(dbRecord.formUserUids.begin(), + dbRecord.formUserUids.end(), callingUid) != dbRecord.formUserUids.end()) ? true : false); + if (!isSelfDbFormId) { + APP_LOGE("%{public}s, not self form:%{public}" PRId64 "", __func__, formId); + return ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF; + } if (delCache) { if (ErrCode result = HandleReleaseForm(matchedFormId, callerToken); result != ERR_OK) { APP_LOGE("%{public}s, release form error.", __func__); @@ -216,15 +232,16 @@ ErrCode FormMgrAdapter::HandleDeleteForm(const int64_t formId, const sptrGetUidByBundleName(bundleName, userId); if (bundleUid != callingUid) { APP_LOGE("%{public}s error, permission denied, the updated form is not your own.", __func__); @@ -394,11 +412,8 @@ int FormMgrAdapter::UpdateForm(const int64_t formId, return ERR_APPEXECFWK_FORM_NOT_EXIST_ID; } - // check then form under current user - if (formRecord.userId != DEFAULT_USER_ID && - !FormDataMgr::GetInstance().IsCallingUidValid(formRecord.formUserUids)) { - APP_LOGE("%{public}s error, not under current user, userId:%{public}d formId:%{public}d", - __func__, (int32_t)formRecord.userId, (int32_t)matchedFormId); + if (userId != formRecord.userId) { + APP_LOGE("%{public}s error, not under current user, formId:%{public}" PRId64 ".", __func__, matchedFormId); return ERR_APPEXECFWK_FORM_NOT_EXIST_ID; } @@ -447,7 +462,11 @@ int FormMgrAdapter::RequestForm(const int64_t formId, const sptr } APP_LOGI("%{public}s, find target client.", __func__); - return FormProviderMgr::GetInstance().RefreshForm(matchedFormId, want); + Want reqWant(want); + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = GetCurrentUserId(callingUid); + reqWant.SetParam(Constants::PARAM_FORM_USER_ID, userId); + return FormProviderMgr::GetInstance().RefreshForm(matchedFormId, reqWant); } /** @@ -534,7 +553,8 @@ int FormMgrAdapter::CastTempForm(const int64_t formId, const sptr } int callingUid = IPCSkeleton::GetCallingUid(); - int checkCode = FormDataMgr::GetInstance().CheckEnoughForm(callingUid); + int32_t userId = GetCurrentUserId(callingUid); + int checkCode = FormDataMgr::GetInstance().CheckEnoughForm(callingUid, userId); if (checkCode != 0) { APP_LOGE("%{public}s, %{public}" PRId64 " failed,because if too mush forms", __func__, matchedFormId); return checkCode; @@ -738,7 +758,10 @@ ErrCode FormMgrAdapter::AllotFormById(const FormItemInfo &info, return ERR_APPEXECFWK_FORM_COMMON_CODE; } - if (hasRecord && (record.userId == DEFAULT_USER_ID + // get current userId + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t currentUserId = GetCurrentUserId(callingUid); + if (hasRecord && (record.userId == currentUserId || FormDataMgr::GetInstance().IsCallingUidValid(record.formUserUids))) { if (!info.IsMatch(record)) { APP_LOGE("%{public}s, formId and item info not match:%{public}" PRId64 "", __func__, formId); @@ -750,7 +773,7 @@ ErrCode FormMgrAdapter::AllotFormById(const FormItemInfo &info, // find in db but not in cache FormRecord dbRecord; ErrCode getDbRet = FormDbCache::GetInstance().GetDBRecord(formId, dbRecord); - if (getDbRet == ERR_OK && (record.userId == DEFAULT_USER_ID + if (getDbRet == ERR_OK && (record.userId == currentUserId || FormDataMgr::GetInstance().IsCallingUidValid(dbRecord.formUserUids))) { return AddNewFormRecord(info, formId, callerToken, wantParams, formInfo); } @@ -872,8 +895,10 @@ ErrCode FormMgrAdapter::AddNewFormRecord(const FormItemInfo &info, const int64_t return ERR_APPEXECFWK_FORM_COMMON_CODE; } + // get current userId + int32_t currentUserId = GetCurrentUserId(callingUid); // allot form record - FormRecord formRecord = FormDataMgr::GetInstance().AllotFormRecord(newInfo, callingUid); + FormRecord formRecord = FormDataMgr::GetInstance().AllotFormRecord(newInfo, callingUid, currentUserId); // acquire formInfo from provider if (ErrCode errorCode = AcquireProviderFormInfoAsync(formId, newInfo, wantParams); errorCode != ERR_OK) { @@ -906,10 +931,11 @@ ErrCode FormMgrAdapter::AddFormTimer(const FormRecord &formRecord) if (formRecord.isEnableUpdate && !formRecord.formTempFlg) { bool timerRet = false; if (formRecord.updateDuration > 0) { - timerRet = FormTimerMgr::GetInstance().AddFormTimer(formRecord.formId, formRecord.updateDuration); + timerRet = FormTimerMgr::GetInstance().AddFormTimer(formRecord.formId, + formRecord.updateDuration, formRecord.userId); } else { timerRet = FormTimerMgr::GetInstance().AddFormTimer(formRecord.formId, formRecord.updateAtHour, - formRecord.updateAtMin); + formRecord.updateAtMin, formRecord.userId); } if (!timerRet) { APP_LOGE("%{public}s fail, add form timer failed", __func__); @@ -1221,13 +1247,22 @@ int FormMgrAdapter::SetNextRefreshTime(const int64_t formId, const int64_t nextT APP_LOGE("%{public}s, not found in formrecord.", __func__); return ERR_APPEXECFWK_FORM_NOT_EXIST_ID; } + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = GetCurrentUserId(callingUid); + bool isSelfFormId = (userId == formRecord.userId) && ((std::find(formRecord.formUserUids.begin(), + formRecord.formUserUids.end(), callingUid) != formRecord.formUserUids.end()) ? true : false); + if (!isSelfFormId) { + APP_LOGE("%{public}s, not self form:%{public}" PRId64 "", __func__, formId); + return ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF; + } + // check bundleName if (bundleName != formRecord.bundleName) { APP_LOGE("%{public}s, not match bundleName:%{public}s", __func__, bundleName.c_str()); return ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF; } - return SetNextRefreshtTimeLocked(matchedFormId, nextTime); + return SetNextRefreshtTimeLocked(matchedFormId, nextTime, userId); } /** @@ -1243,7 +1278,7 @@ bool FormMgrAdapter::GetBundleName(std::string &bundleName) return false; } - int32_t uid = IPCSkeleton::GetCallingUid(); + int uid = IPCSkeleton::GetCallingUid(); if (!iBundleMgr->CheckIsSystemAppByUid(uid)) { APP_LOGE("%{public}s fail, form is not system app. uid:%{public}d", __func__, uid); return false; @@ -1261,9 +1296,10 @@ bool FormMgrAdapter::GetBundleName(std::string &bundleName) * @brief set next refresht time locked. * @param formId The form's id. * @param nextTime next refresh time. + * @param userId User ID. * @return Returns ERR_OK on success, others on failure. */ -int FormMgrAdapter::SetNextRefreshtTimeLocked(const int64_t formId, const int64_t nextTime) +int FormMgrAdapter::SetNextRefreshtTimeLocked(const int64_t formId, const int64_t nextTime, const int32_t userId) { APP_LOGE("SetNextRefreshtTimeLocked."); int32_t timerRefreshedCount = FormTimerMgr::GetInstance().GetRefreshCount(formId); @@ -1273,7 +1309,7 @@ int FormMgrAdapter::SetNextRefreshtTimeLocked(const int64_t formId, const int64_ return ERR_APPEXECFWK_FORM_MAX_REFRESH; } - if (!FormTimerMgr::GetInstance().SetNextRefreshTime(formId, nextTime)) { + if (!FormTimerMgr::GetInstance().SetNextRefreshTime(formId, nextTime, userId)) { APP_LOGE("%{public}s failed", __func__); return ERR_APPEXECFWK_FORM_COMMON_CODE; } @@ -1382,6 +1418,9 @@ int FormMgrAdapter::HandleUpdateFormFlag(std::vector formIds, for (const int64_t id : refreshForms) { APP_LOGI("%{public}s, formRecord need refresh: %{public}" PRId64 "", __func__, id); Want want; + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = GetCurrentUserId(callingUid); + want.SetParam(Constants::PARAM_FORM_USER_ID, userId); FormProviderMgr::GetInstance().RefreshForm(id, want); } } @@ -1500,8 +1539,9 @@ int FormMgrAdapter::BatchAddFormRecords(const Want &want) formItemInfo.SetFormId(newFormId); // allot form host record int callingUid = IPCSkeleton::GetCallingUid(); + int32_t currentUserId = GetCurrentUserId(callingUid); // allot form record - FormRecord formRecord = FormDataMgr::GetInstance().AllotFormRecord(formItemInfo, callingUid); + FormRecord formRecord = FormDataMgr::GetInstance().AllotFormRecord(formItemInfo, callingUid, currentUserId); APP_LOGI("%{public}s, batch add form, formId:" "%{public}" PRId64 ".", __func__, formRecord.formId); APP_LOGI("%{public}s, count: %{public}d", __func__, count + 1); @@ -1643,5 +1683,16 @@ int FormMgrAdapter::DistributedDataDeleteForm(const std::string &formId) { return FormDbCache::GetInstance().DeleteFormInfo(std::stoll(formId)); } +/** + * @brief Get current user ID. + * @param callingUid calling Uid. + * @return Returns user ID. + */ +int32_t FormMgrAdapter::GetCurrentUserId(const int callingUid) +{ + // get current userId + int32_t userId = callingUid / UID_CALLINGUID_TRANSFORM_DIVISOR; + return userId; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/formmgr/src/form_mgr_service.cpp b/services/formmgr/src/form_mgr_service.cpp index 783a7f3c20ce312629b87afda9e56dbb75dbbea6..4ba2987c930468d20e6b3025133271bbba96ee1e 100644 --- a/services/formmgr/src/form_mgr_service.cpp +++ b/services/formmgr/src/form_mgr_service.cpp @@ -379,7 +379,8 @@ ErrCode FormMgrService::Init() matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_ABILITY_UPDATED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED); - + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_UID_REMOVED); + // init TimerReceiver EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills); formSysEventReceiver_ = std::make_shared(subscribeInfo); diff --git a/services/formmgr/src/form_provider_mgr.cpp b/services/formmgr/src/form_provider_mgr.cpp index 2c2bb608f18a5fd0218b3c5fc43bc8c0d17c663b..3354f6853899abf3d15867e57a011e6ae8f87560 100644 --- a/services/formmgr/src/form_provider_mgr.cpp +++ b/services/formmgr/src/form_provider_mgr.cpp @@ -111,6 +111,14 @@ ErrCode FormProviderMgr::RefreshForm(const int64_t formId, const Want &want) return ERR_APPEXECFWK_FORM_NOT_EXIST_ID; } + // get current userId + int32_t currentUserId = want.GetIntParam(Constants::PARAM_FORM_USER_ID, DEFAULT_USER_ID); + if (currentUserId != record.userId) { + FormDataMgr::GetInstance().SetNeedRefresh(formId, true); + APP_LOGE("%{public}s, not current user, just set refresh flag, userId:%{public}d", __func__, record.userId); + return ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF; + } + bool isTimerRefresh = want.GetBoolParam(Constants::KEY_IS_TIMER, false); Want newWant(want); newWant.RemoveParam(Constants::KEY_IS_TIMER); diff --git a/services/formmgr/src/form_refresh_connection.cpp b/services/formmgr/src/form_refresh_connection.cpp index bb3ee269ed43b39f3635362cdd5f8f4333708936..598857f3da2f86352ed631d351d865f57ce5fd6b 100644 --- a/services/formmgr/src/form_refresh_connection.cpp +++ b/services/formmgr/src/form_refresh_connection.cpp @@ -56,6 +56,9 @@ void FormRefreshConnection::OnAbilityConnectDone( if (want_.HasParameter(Constants::PARAM_MESSAGE_KEY)) { std::string message = want_.GetStringParam(Constants::PARAM_MESSAGE_KEY); + Want msgWant = Want(want_); + msgWant.SetParam(Constants::FORM_CONNECT_ID, this->GetConnectId()); + FormTaskMgr::GetInstance().PostFormEventTask(formId_, message, msgWant, remoteObject); } else if (want_.HasParameter(Constants::RECREATE_FORM_KEY)) { Want cloneWant = Want(want_); cloneWant.RemoveParam(Constants::RECREATE_FORM_KEY); diff --git a/services/formmgr/src/form_sys_event_receiver.cpp b/services/formmgr/src/form_sys_event_receiver.cpp index 849eae96ad53101a69439a99b6133286737db75b..7f366b30da82457166e714759d00b3f2d8b8e003 100644 --- a/services/formmgr/src/form_sys_event_receiver.cpp +++ b/services/formmgr/src/form_sys_event_receiver.cpp @@ -35,6 +35,7 @@ namespace OHOS { namespace AppExecFwk { const std::string KEY_UID = "uid"; +const std::string KEY_USER_ID = "userId"; /** * @brief Receiver Constructor. * @param subscriberInfo Subscriber info. @@ -66,6 +67,13 @@ void FormSysEventReceiver::OnReceiveEvent(const EventFwk::CommonEventData &event } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED) { int uid = want.GetIntParam(KEY_UID, 0); HandleBundleDataCleared(bundleName, uid); + } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_UID_REMOVED) { + int32_t userId = want.GetIntParam(KEY_USER_ID, -1); + if (userId == -1) { + APP_LOGE("%{public}s, failed to get userId, bundleName: %{public}s", __func__, bundleName.c_str()); + return; + } + HandleUserIdRemoved(userId); } else { APP_LOGW("%{public}s warnning, invalid action.", __func__); } @@ -439,11 +447,12 @@ void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, 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); + FormTimerMgr::GetInstance().AddFormTimer(formId, timerCfg.updateDuration, record.userId); } else { APP_LOGI("%{public}s, add at timer:%{public}d, %{public}d", __func__, timerCfg.updateAtHour, timerCfg.updateAtMin); - FormTimerMgr::GetInstance().AddFormTimer(formId, timerCfg.updateAtHour, timerCfg.updateAtMin); + FormTimerMgr::GetInstance().AddFormTimer(formId, timerCfg.updateAtHour, + timerCfg.updateAtMin, record.userId); } return; @@ -481,5 +490,19 @@ void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, timerCfg.updateDuration, timerCfg.updateAtHour, timerCfg.updateAtMin); FormTimerMgr::GetInstance().UpdateFormTimer(formId, type, timerCfg); } + +// multiuser +void FormSysEventReceiver::HandleUserIdRemoved(const int32_t userId) +{ + std::vector removedFormIds; + FormDataMgr::GetInstance().DeleteFormsByUserId(userId, removedFormIds); + FormDbCache::GetInstance().DeleteDBFormsByUserId(userId); + + // delete form timer + std::vector::iterator itRemoved; + for (itRemoved = removedFormIds.begin();itRemoved != removedFormIds.end(); itRemoved++) { + FormTimerMgr::GetInstance().RemoveFormTimer(*itRemoved); + } +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/formmgr/src/form_task_mgr.cpp b/services/formmgr/src/form_task_mgr.cpp index 59413d05cf0e6f17f6e2f2016ddb3f8ffb73c3a3..67ecbebc71e05fd6f5ffdbef7ca5decdd7a03688 100644 --- a/services/formmgr/src/form_task_mgr.cpp +++ b/services/formmgr/src/form_task_mgr.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace AppExecFwk { -const int FORM_TASK_DELAY_TIME = 6; // ms +const int FORM_TASK_DELAY_TIME = 20; // ms FormTaskMgr::FormTaskMgr() {} FormTaskMgr::~FormTaskMgr() {} /** diff --git a/services/formmgr/src/form_timer_mgr.cpp b/services/formmgr/src/form_timer_mgr.cpp index 9bd9022eaa68f17e905dd07a9e0f6c617b6f273e..938a092bc07430a314f991d4d39fbf4d718675b8 100644 --- a/services/formmgr/src/form_timer_mgr.cpp +++ b/services/formmgr/src/form_timer_mgr.cpp @@ -27,6 +27,7 @@ #include "form_refresh_limiter.h" #include "form_timer_option.h" #include "form_util.h" +#include "os_account_manager.h" #include "want.h" namespace OHOS { @@ -54,7 +55,7 @@ FormTimerMgr::~FormTimerMgr() */ bool FormTimerMgr::AddFormTimer(const FormTimer &task) { - APP_LOGI("%{public}s, formId: %{public}" PRId64 "", __func__, task.formId); + APP_LOGI("%{public}s, formId: %{public}" PRId64 ", userId:%{public}d", __func__, task.formId, task.userId); if (task.isUpdateAt) { if (task.hour >= Constants::MIN_TIME && task.hour <= Constants::MAX_HOUR && task.min >= Constants::MIN_TIME && task.min <= Constants::MAX_MININUTE) { @@ -77,23 +78,26 @@ bool FormTimerMgr::AddFormTimer(const FormTimer &task) * @brief Add duration form timer. * @param formId The Id of the form. * @param updateDuration Update duration + * @param userId User ID. * @return Returns true on success, false on failure. */ -bool FormTimerMgr::AddFormTimer(const int64_t formId, const long updateDuration) +bool FormTimerMgr::AddFormTimer(const int64_t formId, const long updateDuration, const int32_t userId) { - FormTimer timerTask(formId, updateDuration); + FormTimer timerTask(formId, updateDuration, userId); return AddFormTimer(timerTask); } /** * @brief Add scheduled form timer. * @param formId The Id of the form. - * @param updateAtHour Hour - * @param updateAtMin Min + * @param updateAtHour Hour. + * @param updateAtMin Min. + * @param userId User ID. * @return Returns true on success, false on failure. */ -bool FormTimerMgr::AddFormTimer(const int64_t formId, const long updateAtHour, const long updateAtMin) +bool FormTimerMgr::AddFormTimer(const int64_t formId, const long updateAtHour, + const long updateAtMin, const int32_t userId) { - FormTimer timerTask(formId, updateAtHour, updateAtMin); + FormTimer timerTask(formId, updateAtHour, updateAtMin, userId); return AddFormTimer(timerTask); } /** @@ -318,9 +322,10 @@ void FormTimerMgr::IncreaseRefreshCount(const int64_t formId) * @brief Set next refresh time. * @param formId The Id of the form. * @param nextGapTime Next gap time(ms). + * @param userId User ID. * @return Returns true on success, false on failure. */ -bool FormTimerMgr::SetNextRefreshTime(const int64_t formId, const long nextGapTime) +bool FormTimerMgr::SetNextRefreshTime(const int64_t formId, const long nextGapTime, const int32_t userId) { if (nextGapTime < Constants::MIN_NEXT_TIME) { APP_LOGE("%{public}s failed, nextGapTime is invalid, nextGapTime:%{public}ld", __func__, nextGapTime); @@ -332,7 +337,7 @@ bool FormTimerMgr::SetNextRefreshTime(const int64_t formId, const long nextGapTi std::lock_guard lock(refreshMutex_); bool isExist = false; for (auto &refreshItem: dynamicRefreshTasks_) { - if (refreshItem.formId == formId) { + if ((refreshItem.formId == formId) && (refreshItem.userId == userId)) { refreshItem.settedTime = refreshTime; isExist = true; break; @@ -342,6 +347,7 @@ bool FormTimerMgr::SetNextRefreshTime(const int64_t formId, const long nextGapTi DynamicRefreshItem theItem; theItem.formId = formId; theItem.settedTime = refreshTime; + theItem.userId = userId; dynamicRefreshTasks_.emplace_back(theItem); } std::sort(dynamicRefreshTasks_.begin(), dynamicRefreshTasks_.end(), CompareDynamicRefreshItem); @@ -555,7 +561,7 @@ bool FormTimerMgr::OnDynamicTimeTrigger(long updateTime) for (itItem = dynamicRefreshTasks_.begin(); itItem != dynamicRefreshTasks_.end();) { if (itItem->settedTime <= updateTime || itItem->settedTime <= markedTime) { if (refreshLimiter_.IsEnableRefresh(itItem->formId)) { - FormTimer timerTask(itItem->formId, true); + FormTimer timerTask(itItem->formId, true, itItem->userId); updateList.emplace_back(timerTask); } itItem = dynamicRefreshTasks_.erase(itItem); @@ -682,6 +688,7 @@ bool FormTimerMgr::GetDynamicItem(const int64_t formId, DynamicRefreshItem &dyna if (itItem->formId == formId) { dynamicItem.formId = itItem->formId; dynamicItem.settedTime = itItem->settedTime; + dynamicItem.userId = itItem->userId; APP_LOGI("%{public}s, get dynamic item successfully", __func__); return true; } @@ -873,7 +880,7 @@ bool FormTimerMgr::UpdateAtTimerAlarm() std::shared_ptr FormTimerMgr::GetUpdateAtWantAgent(long updateAtTime) { std::shared_ptr want = std::make_shared(); - ElementName element("device", "bundleName", "abilityName"); + ElementName element("", "", ""); want->SetElement(element); want->SetAction(Constants::ACTION_UPDATEATTIMER); want->SetParam(Constants::KEY_ACTION_TYPE, Constants::TYPE_STATIC_UPDATE); @@ -987,7 +994,7 @@ void FormTimerMgr::ClearLimiterTimerResource() std::shared_ptr FormTimerMgr::GetLimiterWantAgent() { std::shared_ptr want = std::make_shared(); - ElementName element("device", "bundleName", "abilityName"); + ElementName element("", "", ""); want->SetElement(element); want->SetAction(Constants::ACTION_UPDATEATTIMER); want->SetParam(Constants::KEY_ACTION_TYPE, Constants::TYPE_RESET_LIMIT); @@ -1059,7 +1066,7 @@ bool FormTimerMgr::UpdateDynamicAlarm() std::shared_ptr FormTimerMgr::GetDynamicWantAgent(long nextTime) { std::shared_ptr want = std::make_shared(); - ElementName element("device", "bundleName", "abilityName"); + ElementName element("", "", ""); want->SetElement(element); want->SetAction(Constants::ACTION_UPDATEATTIMER); want->SetParam(Constants::KEY_ACTION_TYPE, Constants::TYPE_DYNAMIC_UPDATE); @@ -1190,6 +1197,12 @@ void FormTimerMgr::ExecTimerTask(const FormTimer &timerTask) if (timerTask.isCountTimer) { want.SetParam(Constants::KEY_IS_TIMER, true); } + // multi user + if (IsActiveUser(timerTask.userId)) { + want.SetParam(Constants::PARAM_FORM_USER_ID, timerTask.userId); + } + APP_LOGI("%{public}s, userId:%{public}d", __func__, timerTask.userId); + auto task = std::bind(&FormProviderMgr::RefreshForm, &FormProviderMgr::GetInstance(), timerTask.formId, want); taskExecutor_->AddTask(task); } @@ -1267,5 +1280,17 @@ void FormTimerMgr::TimerReceiver::OnReceiveEvent(const EventFwk::CommonEventData APP_LOGE("%{public}s failed, invalid action.", __func__); } } +/** + * @brief check if user is active or not. + * + * @param userId User ID. + * @return true:active, false:inactive + */ +bool FormTimerMgr::IsActiveUser(const int32_t userId) +{ + bool isOsAccountActived = false; + AccountSA::OsAccountManager::IsOsAccountActived(userId, isOsAccountActived); + return isOsAccountActived; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/formmgr/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp index 2a6db4545da2d7e6404b7315f09357ad9ade6aed..1c1d2f67dda94e6d96fdfd83cd25891e414dfd32 100644 --- a/services/formmgr/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp @@ -45,7 +45,7 @@ public: void SetUp(); void TearDown(); - void InitFormItemInfo(int64_t formId, FormItemInfo &form_item_info); + void InitFormItemInfo(int64_t formId, FormItemInfo &form_item_info, bool istemp = true); protected: FormDataMgr formDataMgr_; @@ -72,7 +72,7 @@ void FmsFormDataMgrTest::TearDown(void) formDataMgr_.udidHash_ = 0; } -void FmsFormDataMgrTest::InitFormItemInfo(int64_t formId, FormItemInfo &form_item_info) +void FmsFormDataMgrTest::InitFormItemInfo(int64_t formId, FormItemInfo &form_item_info, bool istemp) { // create hapSourceDirs std::vector hapSourceDirs; @@ -81,7 +81,7 @@ void FmsFormDataMgrTest::InitFormItemInfo(int64_t formId, FormItemInfo &form_ite // create form_item_info form_item_info.SetFormId(formId); - form_item_info.SetTemporaryFlag(true); + form_item_info.SetTemporaryFlag(istemp); form_item_info.SetEnableUpdateFlag(true); form_item_info.SetUpdateDuration(Constants::MIN_CONFIG_DURATION); form_item_info.SetScheduledUpdateTime("10:30"); @@ -494,9 +494,9 @@ HWTEST_F(FmsFormDataMgrTest, FmsFormDataMgrTest_CheckEnoughForm_001, TestSize.Le // create formRecords for (int formId_index = 0; formId_index < Constants::MAX_FORMS; formId_index++) { FormItemInfo formItemInfo; - InitFormItemInfo(formId_index, formItemInfo); + InitFormItemInfo(formId_index, formItemInfo, false); - FormRecord record = formDataMgr_.CreateFormRecord(formItemInfo, callingUid); + FormRecord record = formDataMgr_.CreateFormRecord(formItemInfo, callingUid++); formDataMgr_.formRecords_.emplace(formId_index, record); } diff --git a/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp index fc139af20564d0f43b1ab146906bce210ba76efc..e6cad4e0edc7752ef33a9b13b06a592dae3d3e5f 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp @@ -520,7 +520,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_008, TestSize.Level0) record1[tempCount].SetFormName(PARAM_FORM_NAME); record1[tempCount].SetSpecificationId(PARAM_FORM_DIMENSION_VALUE); record1[tempCount].SetTemporaryFlag(false); - FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1[tempCount], callingUid); + FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1[tempCount], callingUid++); // Set database info. FormDBInfo formDBInfo(formId+tempCount, retFormRec); FormDbCache::GetInstance().SaveFormInfo(formDBInfo); diff --git a/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp index 67c58083c7a9ef43fd87b415bee093b7d3cfc803..d0ec63205f1c316a60b86966b7a773454f64bf51 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp @@ -124,8 +124,14 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_001, TestSize.Level0) { GTEST_LOG_(INFO) << "fms_form_mgr_delete_form_test_001 start"; + // clear old data + FormDataMgr::GetInstance().ClearFormRecords(); + std::vector oldFormDBInfos; + FormDbCache::GetInstance().GetAllFormInfo(oldFormDBInfos); + FormDbCache::GetInstance().DeleteFormInfoByBundleName(FORM_HOST_BUNDLE_NAME, oldFormDBInfos); + int64_t formId {12001}; - int callingUid {0}; + int callingUid = IPCSkeleton::GetCallingUid(); // Create cache FormItemInfo record1; record1.SetFormId(formId); @@ -183,7 +189,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_002, TestSize.Level0) GTEST_LOG_(INFO) << "fms_form_mgr_delete_form_test_002 start"; int64_t formId {12002}; - int callingUid {0}; + int callingUid = IPCSkeleton::GetCallingUid(); // Create cache FormItemInfo record1; record1.SetFormId(formId); @@ -251,7 +257,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_006, TestSize.Level0) GTEST_LOG_(INFO) << "fms_form_mgr_delete_form_test_006 start"; int64_t formId {12006}; - int callingUid {0}; + int callingUid = IPCSkeleton::GetCallingUid(); FormItemInfo record1; record1.SetFormId(formId); record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME); @@ -283,7 +289,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_007, TestSize.Level0) GTEST_LOG_(INFO) << "fms_form_mgr_delete_form_test_007 start"; int64_t formId {12007}; - int callingUid {0}; + int callingUid = IPCSkeleton::GetCallingUid(); // Create cache FormItemInfo record1; record1.SetFormId(formId); @@ -338,7 +344,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_008, TestSize.Level0) GTEST_LOG_(INFO) << "fms_form_mgr_delete_form_test_008 start"; int64_t formId {12008}; - int callingUid {0}; + int callingUid = IPCSkeleton::GetCallingUid(); FormItemInfo record1; record1.SetFormId(formId); record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME); diff --git a/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp index d5a45a19f9c39b8a8fde40b866a867fc4c713368..ca8bdd6c2a42ae9d79bf821fd2790dd5aaed9b13 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp @@ -50,6 +50,7 @@ const std::string FORM_HOST_BUNDLE_NAME = "com.form.host.app"; const std::string DEVICE_ID = "ohos-phone1"; const std::string DEF_LABEL1 = "PermissionFormRequireGrant"; +constexpr int32_t UID_CALLINGUID_TRANSFORM_DIVISOR = 200000; class FmsFormMgrReleaseFormTest : public testing::Test { public: @@ -112,22 +113,27 @@ HWTEST_F(FmsFormMgrReleaseFormTest, ReleaseForm_001, TestSize.Level0) GTEST_LOG_(INFO) << "fms_form_mgr_release_test_001 start"; int64_t formId = FormDataMgr::GetInstance().GenerateFormId(); - + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = callingUid/UID_CALLINGUID_TRANSFORM_DIVISOR; FormItemInfo record1; record1.SetFormId(formId); record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME); record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME); record1.SetTemporaryFlag(false); - FormDataMgr::GetInstance().AllotFormRecord(record1, 0); + FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid, userId); + // Set database info. + FormDBInfo formDBInfo(formId, retFormRec); + FormDbCache::GetInstance().SaveFormInfo(formDBInfo); + int64_t formId2 = FormDataMgr::GetInstance().GenerateFormId(); FormItemInfo record2; record2.SetFormId(formId2); record2.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME); record2.SetAbilityName(FORM_PROVIDER_ABILITY_NAME); record2.SetTemporaryFlag(false); - FormDataMgr::GetInstance().AllotFormRecord(record2, 1); + FormDataMgr::GetInstance().AllotFormRecord(record2, 1, userId); FormItemInfo itemInfo; - FormDataMgr::GetInstance().AllotFormHostRecord(itemInfo, token_, formId, 0); + FormDataMgr::GetInstance().AllotFormHostRecord(itemInfo, token_, formId, callingUid); EXPECT_EQ(ERR_OK, FormMgr::GetInstance().ReleaseForm(formId, token_, true)); @@ -168,7 +174,10 @@ HWTEST_F(FmsFormMgrReleaseFormTest, ReleaseForm_002, TestSize.Level0) record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME); record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME); record1.SetTemporaryFlag(false); - FormDataMgr::GetInstance().AllotFormRecord(record1, 0); + FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, 0); + // Set database info. + FormDBInfo formDBInfo(formId1, retFormRec); + FormDbCache::GetInstance().SaveFormInfo(formDBInfo); FormItemInfo record2; record2.SetFormId(formId2); @@ -227,7 +236,7 @@ HWTEST_F(FmsFormMgrReleaseFormTest, ReleaseForm_005, TestSize.Level0) record.SetAbilityName(FORM_PROVIDER_ABILITY_NAME); record.SetTemporaryFlag(false); FormDataMgr::GetInstance().AllotFormRecord(record, 0); - EXPECT_EQ(ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF, FormMgr::GetInstance().ReleaseForm(formId, token_, true)); + EXPECT_EQ(ERR_APPEXECFWK_FORM_NOT_EXIST_ID, FormMgr::GetInstance().ReleaseForm(formId, token_, true)); GTEST_LOG_(INFO) << "fms_form_mgr_release_test_005 end"; } } \ No newline at end of file diff --git a/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp index 338fc96d50aa7a1ccc960a9c267a90bee4f0f4eb..cec93e35f57136a431338a6ed079da5aa2f2359a 100644 --- a/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp @@ -21,7 +21,6 @@ #include "form_db_cache.h" #include "form_refresh_limiter.h" #include "form_host_interface.h" -#include "form_mgr.h" #undef private #include "form_mgr_service.h" #include "form_provider_mgr.h" diff --git a/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp b/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp index 311c7bde55246b75d452240c778b8a3da1ee5661..c363f16e3a2b47b72c509f68f05106fe8876a3d3 100644 --- a/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp +++ b/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp @@ -27,6 +27,9 @@ #include "form_mgr_service.h" #include "form_timer_mgr.h" #undef private +#include "if_system_ability_manager.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" #include "mock_bundle_manager.h" using namespace testing::ext; @@ -38,6 +41,7 @@ const std::string FORM_HOST_BUNDLE_NAME = "com.form.provider.service"; const std::string FORM_PROVIDER_ABILITY_NAME = "com.form.provider.app.test.abiliy"; const std::string PERMISSION_NAME_REQUIRE_FORM = "ohos.permission.REQUIRE_FORM"; const std::string DEF_LABEL1 = "PermissionFormRequireGrant"; +constexpr int32_t UID_CALLINGUID_TRANSFORM_DIVISOR = 200000; class FmsFormSetNextRefreshTest : public testing::Test { public: @@ -115,7 +119,9 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime GTEST_LOG_(INFO) << "FmsFormSetNextRefreshTest_SetNextRefreshTime_003 start"; int64_t formId = 3; int64_t nextTime = Constants::MIN_NEXT_TIME; - + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = callingUid/UID_CALLINGUID_TRANSFORM_DIVISOR; + GTEST_LOG_(INFO) << "callingUid:" << callingUid << " userId:" << userId; // check dynamicRefreshTasks_ EXPECT_EQ(true, FormTimerMgr::GetInstance().dynamicRefreshTasks_.empty()); @@ -125,8 +131,8 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime iteminfo.providerBundleName_ = FORM_HOST_BUNDLE_NAME; iteminfo.abilityName_ = FORM_PROVIDER_ABILITY_NAME; iteminfo.temporaryFlag_ = true; - FormDataMgr::GetInstance().AllotFormRecord(iteminfo, 0); + FormDataMgr::GetInstance().AllotFormRecord(iteminfo, callingUid, userId); EXPECT_EQ(ERR_OK, formSetNextRefresh_->SetNextRefreshTime(formId, nextTime)); // check dynamicRefreshTasks_ @@ -168,18 +174,21 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime GTEST_LOG_(INFO) << "FmsFormSetNextRefreshTest_SetNextRefreshTime_005 start"; int64_t formId = 5; int64_t nextTime = Constants::MIN_NEXT_TIME; - + int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = callingUid/UID_CALLINGUID_TRANSFORM_DIVISOR; // creat formRecords_ FormItemInfo iteminfo; iteminfo.formId_ = formId; iteminfo.providerBundleName_ = FORM_HOST_BUNDLE_NAME; iteminfo.abilityName_ = FORM_PROVIDER_ABILITY_NAME; iteminfo.temporaryFlag_ = true; - FormDataMgr::GetInstance().AllotFormRecord(iteminfo, 0); + + FormDataMgr::GetInstance().AllotFormRecord(iteminfo, callingUid, userId); // Creat dynamicRefreshTasks_ DynamicRefreshItem theItem; theItem.formId = formId; + theItem.userId = userId; theItem.settedTime = 1; FormTimerMgr::GetInstance().dynamicRefreshTasks_.clear(); FormTimerMgr::GetInstance().dynamicRefreshTasks_.emplace_back(theItem); @@ -187,7 +196,8 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime EXPECT_EQ(1, FormTimerMgr::GetInstance().dynamicRefreshTasks_.at(0).settedTime); // Create IntervalTimerTasks_ - FormTimer task(formId, 3 * Constants::MIN_PERIOD); + FormTimer task(formId, 3 * Constants::MIN_PERIOD, userId); + task.isEnable = true; FormTimerMgr::GetInstance().AddFormTimer(task); @@ -209,6 +219,8 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime int64_t formId = 6; int64_t nextTime = Constants::MIN_NEXT_TIME; + int32_t callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = callingUid/UID_CALLINGUID_TRANSFORM_DIVISOR; // creat formRecords_ FormItemInfo iteminfo; @@ -216,7 +228,7 @@ HWTEST_F(FmsFormSetNextRefreshTest, FmsFormSetNextRefreshTest_SetNextRefreshTime iteminfo.providerBundleName_ = FORM_HOST_BUNDLE_NAME; iteminfo.abilityName_ = FORM_PROVIDER_ABILITY_NAME; iteminfo.temporaryFlag_ = true; - FormDataMgr::GetInstance().AllotFormRecord(iteminfo, 0); + FormDataMgr::GetInstance().AllotFormRecord(iteminfo, callingUid, userId); // set timerRefreshedCount FormTimerMgr::GetInstance().refreshLimiter_.AddItem(formId); diff --git a/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp index 1a65ebf112cb8b3f912fc5994ee67a9f7f1e48cf..e41de5bc00a17ef34651ae5448d870d61e196bd8 100644 --- a/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp @@ -70,7 +70,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0001, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0002, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0002 start"; - bool isOk = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 2, 50); + bool isOk = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 2, 50, 0); EXPECT_EQ(isOk, true); GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0002 end"; } @@ -85,7 +85,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0003, Function | MediumTest | Lev GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0003 start"; bool isAddOk1 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_3, 336 * Constants::MIN_PERIOD); EXPECT_EQ(isAddOk1, true); - bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 3, 30); + bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 3, 30, 0); EXPECT_EQ(isAddOk2, true); bool isDelOk1 = FormTimerMgr::GetInstance().RemoveFormTimer(PARAM_FORM_ID_VALUE_3); EXPECT_EQ(isDelOk1, true); @@ -121,7 +121,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0004, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0005, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0005 start"; - bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 3, 30); + bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 3, 30, 0); EXPECT_EQ(isAddOk2, true); // TYPE_ATTIME_CHANGE @@ -164,7 +164,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0006, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0007, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0007 start"; - bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 10, 30); + bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 10, 30, 0); EXPECT_EQ(isAddOk4, true); // TYPE_ATTIME_TO_INTERVAL @@ -184,7 +184,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0007, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0008, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0008 start"; - bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_1, 11, 30); + bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_1, 11, 30, 0); EXPECT_EQ(isAddOk5, true); bool isAddOk6 = FormTimerMgr::GetInstance().HandleSystemTimeChanged(); EXPECT_EQ(isAddOk6, true); @@ -200,7 +200,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0008, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0009, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0009 start"; - bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 11, 30); + bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 11, 30, 0); EXPECT_EQ(isAddOk5, true); bool isAddOk6 = FormTimerMgr::GetInstance().HandleSystemTimeChanged(); EXPECT_EQ(isAddOk6, true); @@ -215,7 +215,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0009, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0010, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0010 start"; - bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_3, 16, 30); + bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_3, 16, 30, 0); EXPECT_EQ(isAddOk5, true); bool isAddOk6 = FormTimerMgr::GetInstance().HandleResetLimiter(); EXPECT_EQ(isAddOk6, true); @@ -231,7 +231,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0010, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0011, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0011 start"; - bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 11, 30); + bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 11, 30, 0); EXPECT_EQ(isAddOk5, true); bool isAddOk6 = FormTimerMgr::GetInstance().OnUpdateAtTrigger(90L); @@ -247,7 +247,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0011, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0012, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0012 start"; - bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_5, 11, 30); + bool isAddOk5 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_5, 11, 30, 0); EXPECT_EQ(isAddOk5, true); bool isAddOk6 = FormTimerMgr::GetInstance().OnDynamicTimeTrigger(90L); @@ -277,7 +277,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0013, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0014, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0014 start"; - bool isOk = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 0, 60); + bool isOk = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 0, 60, 0); EXPECT_EQ(isOk, false); GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0014 end"; } @@ -310,7 +310,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0015, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0016, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0016 start"; - bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 3, 30); + bool isAddOk2 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_2, 3, 30, 0); EXPECT_EQ(isAddOk2, true); // TYPE_ATTIME_CHANGE @@ -353,7 +353,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0017, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0018, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0018 start"; - bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 10, 30); + bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_4, 10, 30, 0); EXPECT_EQ(isAddOk4, true); // TYPE_ATTIME_TO_INTERVAL @@ -537,7 +537,7 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0026, Function | MediumTest | Lev HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0027, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0027 start"; - bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_6, 10, 30); + bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_6, 10, 30, 0); EXPECT_EQ(isAddOk4, true); std::this_thread::sleep_for(std::chrono::milliseconds(Constants::MIN_PERIOD));