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 class IResourceManager { 33 public: 34 virtual int32_t CloseRawFd(const std::string &name) = 0; 35 virtual int32_t GetRawFd(const std::string &rawFileName, 36 Global::Resource::ResourceManager::RawFileDescriptor &descriptor) = 0; 37 virtual int32_t GetRawFileContent(const std::string &name, size_t &len, std::unique_ptr<uint8_t[]> &outValue) = 0; 38 virtual int32_t GetRawFileList(const std::string &rawDirPath, std::vector<std::string>& rawfileList) = 0; 39 virtual int32_t GetColorByName(const char *name, uint32_t &outValue) = 0; 40 virtual int32_t GetColorById(uint32_t id, uint32_t &outValue) = 0; 41 virtual int32_t GetBooleanById(uint32_t id, bool &outValue) = 0; 42 virtual int32_t GetBooleanByName(const char *name, bool &outValue) = 0; 43 virtual int32_t GetIntegerById(uint32_t id, int &outValue) = 0; 44 virtual int32_t GetIntegerByName(const char *name, int &outValue) = 0; 45 virtual int32_t GetFloatById(uint32_t id, float &outValue) = 0; 46 virtual int32_t GetFloatByName(const char *name, float &outValue) = 0; 47 virtual void GetConfiguration(Configuration &cfg) = 0; 48 virtual void GetDeviceCapability(DeviceCapability &deviceCapability) = 0; 49 virtual int32_t GetMediaDataByName(const char *name, size_t &len, std::unique_ptr<uint8_t[]> &outValue, 50 uint32_t density) = 0; 51 virtual int32_t GetMediaDataById(uint32_t id, size_t &len, std::unique_ptr<uint8_t[]> &outValue, 52 uint32_t density) = 0; 53 virtual int32_t GetPluralStringValue(uint32_t resId, int64_t num, std::string &outValue) = 0; 54 virtual int32_t GetPluralStringValue(const char *name, int64_t num, std::string &outValue) = 0; 55 virtual int32_t GetStringArrayValue(uint32_t resId, std::vector<std::string> &outValue) = 0; 56 virtual int32_t GetStringArrayByName(const char *name, std::vector<std::string> &outValue) = 0; 57 virtual int32_t GetString(uint32_t resId, std::string &outValue) = 0; 58 virtual int32_t GetStringByName(const char *name, std::string &outValue) = 0; 59 virtual int32_t AddResource(const char *path) = 0; 60 virtual int32_t RemoveResource(const char *path) = 0; 61 virtual int32_t GetMediaContentBase64ById(uint32_t id, std::string &outValue, uint32_t density) = 0; 62 virtual int32_t GetMediaContentBase64ByName(const char *name, std::string &outValue, uint32_t density) = 0; 63 virtual int32_t GetDrawableDescriptor(uint32_t id, int64_t &outValue, uint32_t density) = 0; 64 virtual int32_t GetDrawableDescriptorByName(const char *name, int64_t &outValue, uint32_t density) = 0; 65 virtual void GetLocales(bool includeSystem, std::vector<std::string> &outValue) = 0; 66 }; 67 } // namespace Resource 68 } // namespace OHOS 69 70 #endif