1 /* 2 * Copyright (c) 2025-2025 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_EXEMPT_LOCK_MGR_H 16 #define OHOS_FORM_FWK_FORM_EXEMPT_LOCK_MGR_H 17 18 #include <map> 19 #include <shared_mutex> 20 #include <singleton.h> 21 #include <string> 22 23 #include "want.h" 24 #include "form_rdb_data_mgr.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 /** 29 * @class FormExemptLockMgr 30 * Form bundle exempt manager. 31 */ 32 class FormExemptLockMgr final : public DelayedRefSingleton<FormExemptLockMgr> { 33 DECLARE_DELAYED_REF_SINGLETON(FormExemptLockMgr) 34 public: 35 DISALLOW_COPY_AND_MOVE(FormExemptLockMgr); 36 37 /** 38 * @brief Init form bundle exempt mgr. 39 * @return True for sucessful init, false for failed init. 40 */ 41 bool Init(); 42 43 /** 44 * @brief Get whether bundle is exempt. 45 * @param formId The Id of the forms. 46 * @return True for exempt, false for not exempt. 47 */ 48 bool IsExemptLock(int64_t formId); 49 50 /** 51 * @brief Set whether form is exempt. 52 * @param formId The Id of the forms. 53 * @param isExempt True for exempt, false for not exempt. 54 */ 55 void SetExemptLockStatus(int64_t formId, bool isExempt); 56 private: 57 bool isInitialized_ = false; 58 std::set<std::string> formExemptLockSet_; 59 mutable std::shared_mutex exemptLockSetMutex_; 60 }; 61 } // namespace AppExecFwk 62 } // namespace OHOS 63 64 #endif // OHOS_FORM_FWK_FORM_EXEMPT_LOCK_MGR_H 65