1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_FORM_FWK_FORM_EVENT_UTIL_H 16 #define OHOS_FORM_FWK_FORM_EVENT_UTIL_H 17 18 #include <set> 19 #include <string> 20 21 #include "form_record.h" 22 #include "form_info.h" 23 #include "form_id_key.h" 24 #include "form_timer.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 const std::string KEY_UID = "uid"; 29 const std::string KEY_USER_ID = "userId"; 30 class FormEventUtil { 31 public: 32 33 FormEventUtil() = default; 34 35 void HandleBundleFormInfoChanged(const std::string &bundleName, int32_t userId); 36 void HandleProviderUpdated(const std::string &bundleName, const int userId); 37 void HandleBundleFormInfoRemoved(const std::string &bundleName, int32_t userId); 38 void HandleProviderRemoved(const std::string &bundleName, const int32_t userId); 39 void HandleBundleDataCleared(const std::string &bundleName, const int uid); 40 void HandleFormHostDataCleared(const int uid); 41 bool ProviderFormUpdated(const int64_t formId, const FormRecord &formRecord, 42 const std::vector<FormInfo> &targetForms); 43 void ClearFormDBRecordData(const int uid, std::map<int64_t, bool> &removedFormsMap); 44 void ClearTempFormRecordData(const int uid, std::map<int64_t, bool> &removedFormsMap); 45 void BatchDeleteNoHostTempForms(const int uid, std::map<FormIdKey, std::set<int64_t>> &noHostTempFormsMap, 46 std::map<int64_t, bool> &foundFormsMap); 47 void GetTimerCfg(const bool updateEnabled, const int updateDuration, const std::string &configUpdateAt, 48 FormTimerCfg &cfg); 49 void HandleTimerUpdate(const int64_t formId, const FormRecord &record, const FormTimerCfg &timerCfg); 50 void ReCreateForm(const int64_t formId); 51 void BatchDeleteNoHostDBForms(const int uid, std::map<FormIdKey, std::set<int64_t>> &noHostFormDbMap, 52 std::map<int64_t, bool> &removedFormsMap); 53 }; 54 } // namespace AppExecFwk 55 } // namespace OHOS 56 #endif // OHOS_FORM_FWK_FORM_EVENT_UTIL_H