1 /* 2 * Copyright (c) 2023-2024 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 16 #ifndef OHOS_ABILITY_RUNTIME_EXTENSION_CONFIG_H 17 #define OHOS_ABILITY_RUNTIME_EXTENSION_CONFIG_H 18 19 #include <map> 20 #include <nlohmann/json.hpp> 21 #include <unordered_map> 22 #include <unordered_set> 23 24 #include "extension_ability_info.h" 25 #include "singleton.h" 26 27 namespace OHOS { 28 namespace AAFwk { 29 class ExtensionConfig : public DelayedSingleton<ExtensionConfig> { 30 public: 31 explicit ExtensionConfig() = default; 32 virtual ~ExtensionConfig() = default; 33 void LoadExtensionConfiguration(); 34 int32_t GetExtensionAutoDisconnectTime(std::string extensionTypeName); 35 bool IsExtensionStartThirdPartyAppEnable(std::string extensionTypeName); 36 bool IsExtensionStartServiceEnable(std::string extensionTypeName, std::string targetUri); 37 private: 38 void LoadExtensionConfig(const nlohmann::json &object); 39 bool ReadFileInfoJson(const std::string &filePath, nlohmann::json &jsonBuf); 40 41 std::string GetExtensionConfigPath() const; 42 void LoadExtensionAutoDisconnectTime(const nlohmann::json &object, std::string extensionTypeName); 43 void LoadExtensionThirdPartyAppBlockedList(const nlohmann::json &object, std::string extensionTypeName); 44 void LoadExtensionServiceBlockedList(const nlohmann::json &, std::string extensionTypeNameobject); 45 46 bool CheckServiceExtensionUriValid(const std::string &uri); 47 48 std::map<std::string, int32_t> extensionAutoDisconnectTimeMap_; 49 std::unordered_map<std::string, bool> thirdPartyAppEnableFlags_; 50 std::unordered_map<std::string, bool> serviceEnableFlags_; 51 std::unordered_map<std::string, std::unordered_set<std::string>> serviceBlockedLists_; 52 }; 53 } // OHOS 54 } // AAFwk 55 56 #endif // OHOS_ABILITY_RUNTIME_EXTENSION_CONFIG_H