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