1 /* 2 * Copyright (c) 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 RESOURCE_MANAGER_INTERFACE_H 17 #define RESOURCE_MANAGER_INTERFACE_H 18 19 #include <cstdint> 20 #include <string> 21 22 namespace OHOS { 23 namespace Resource { 24 struct Configuration { 25 int32_t direction; 26 char* locale; 27 }; 28 struct DeviceCapability { 29 int32_t screenDensity; 30 int32_t deviceType; 31 }; 32 33 struct ConfigurationEx { 34 int32_t direction; 35 int32_t deviceType; 36 int32_t screenDensity; 37 int32_t colorMode; 38 uint32_t mcc; 39 uint32_t mnc; 40 char* locale; 41 }; 42 43 class IResourceManager { 44 public: 45 virtual int32_t CloseRawFd(const std::string &name) = 0; 46 virtual int32_t GetRawFd(const std::string &rawFileName, 47 Global::Resource::ResourceManager::RawFileDescriptor &descriptor) = 0; 48 virtual int32_t GetRawFileContent(const std::string &name, size_t &len, std::unique_ptr<uint8_t[]> &outValue) = 0; 49 virtual int32_t GetRawFileList(const std::string &rawDirPath, std::vector<std::string>& rawfileList) = 0; 50 virtual int32_t GetColorByName(const char *name, uint32_t &outValue) = 0; 51 virtual int32_t GetColorById(uint32_t id, uint32_t &outValue) = 0; 52 virtual int32_t GetBooleanById(uint32_t id, bool &outValue) = 0; 53 virtual int32_t GetBooleanByName(const char *name, bool &outValue) = 0; 54 virtual int32_t GetIntegerById(uint32_t id, int &outValue) = 0; 55 virtual int32_t GetIntegerByName(const char *name, int &outValue) = 0; 56 virtual int32_t GetFloatById(uint32_t id, float &outValue) = 0; 57 virtual int32_t GetFloatByName(const char *name, float &outValue) = 0; 58 virtual void GetConfiguration(Configuration &cfg) = 0; 59 virtual void GetConfiguration(ConfigurationEx *configuration) = 0; 60 virtual void GetOverrideConfiguration(ConfigurationEx *configuration) = 0; 61 virtual void GetDeviceCapability(DeviceCapability &deviceCapability) = 0; 62 virtual int32_t GetMediaDataByName(const char *name, size_t &len, std::unique_ptr<uint8_t[]> &outValue, 63 uint32_t density) = 0; 64 virtual int32_t GetMediaDataById(uint32_t id, size_t &len, std::unique_ptr<uint8_t[]> &outValue, 65 uint32_t density) = 0; 66 virtual int32_t GetPluralStringValue(uint32_t resId, int64_t num, std::string &outValue) = 0; 67 virtual int32_t GetPluralStringValue(const char *name, int64_t num, std::string &outValue) = 0; 68 virtual int32_t GetStringArrayValue(uint32_t resId, std::vector<std::string> &outValue) = 0; 69 virtual int32_t GetStringArrayByName(const char *name, std::vector<std::string> &outValue) = 0; 70 virtual int32_t GetString(uint32_t resId, std::string &outValue) = 0; 71 virtual int32_t GetStringByName(const char *name, std::string &outValue) = 0; 72 virtual int32_t AddResource(const char *path) = 0; 73 virtual int32_t RemoveResource(const char *path) = 0; 74 virtual int32_t GetMediaContentBase64ById(uint32_t id, std::string &outValue, uint32_t density) = 0; 75 virtual int32_t GetMediaContentBase64ByName(const char *name, std::string &outValue, uint32_t density) = 0; 76 virtual int32_t GetDrawableDescriptor(uint32_t id, int64_t &outValue, uint32_t density) = 0; 77 virtual int32_t GetDrawableDescriptorByName(const char *name, int64_t &outValue, uint32_t density) = 0; 78 virtual void GetLocales(bool includeSystem, std::vector<std::string> &outValue) = 0; 79 virtual int32_t GetSymbolById(uint32_t id, uint32_t &outValue) = 0; 80 virtual int32_t GetSymbolByName(const char *name, uint32_t &outValue) = 0; 81 virtual std::shared_ptr<Global::Resource::ResourceManager> GetOverrideResMgr(ConfigurationEx &configuration, 82 int32_t &errCode) = 0; 83 }; 84 } // namespace Resource 85 } // namespace OHOS 86 87 #endif