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