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/**
17 * @addtogroup resourcemanager
18 * @{
19 *
20 * @brief Provides the c interface to obtain resources, and relies on librawfile.z.so when used.
21 *
22 * @since 12
23 */
24
25/**
26 * @file resmgr_common.h
27 *
28 * @brief Provides the structure required by the interface.
29 * @syscap SystemCapability.Global.ResourceManager
30 * @library libohresmgr.so
31 * @since 12
32 */
33#ifndef GLOBAL_RESMGR_COMMON_H
34#define GLOBAL_RESMGR_COMMON_H
35
36#include <stdint.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/**
43 * @brief The error code of resource manager.
44 *
45 * @since 12
46 */
47typedef enum ResourceManager_ErrorCode {
48    /** @error Success */
49    SUCCESS = 0,
50    /** @error Invalid input parameter */
51    ERROR_CODE_INVALID_INPUT_PARAMETER = 401,
52    /** @error Invalid resource ID */
53    ERROR_CODE_RES_ID_NOT_FOUND = 9001001,
54    /** @error Invalid resource name */
55    ERROR_CODE_RES_NOT_FOUND_BY_ID = 9001002,
56    /** @error No matching resource is found based on the resource ID */
57    ERROR_CODE_RES_NAME_NOT_FOUND = 9001003,
58    /** @error No matching resource is found based on the resource name */
59    ERROR_CODE_RES_NOT_FOUND_BY_NAME = 9001004,
60    /** @error Invalid relative path */
61    ERROR_CODE_RES_PATH_INVALID = 9001005,
62    /** @error The resource is referenced cyclically */
63    ERROR_CODE_RES_REF_TOO_MUCH = 9001006,
64    /** @error Failed to format the resource obtained based on the resource ID */
65    ERROR_CODE_RES_ID_FORMAT_ERROR = 9001007,
66    /** @error Failed to format the resource obtained based on the resource Name */
67    ERROR_CODE_RES_NAME_FORMAT_ERROR = 9001008,
68    /** @error Failed to access the system resource */
69    ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED = 9001009,
70    /** @error Invalid overlay path */
71    ERROR_CODE_OVERLAY_RES_PATH_INVALID = 9001010,
72    /** @error Out of memory */
73    ERROR_CODE_OUT_OF_MEMORY = 9001100,
74} ResourceManager_ErrorCode;
75
76/**
77 * @brief Enumerates screen density types.
78 *
79 * @since 12
80 */
81typedef enum ScreenDensity {
82    /** Indicates small screen density. */
83    SCREEN_SDPI = 120,
84    /** Indicates medium screen density. */
85    SCREEN_MDPI = 160,
86    /** Indicates large screen density. */
87    SCREEN_LDPI = 240,
88    /** Indicates extra-large screen density. */
89    SCREEN_XLDPI = 320,
90    /** Indicates extra-extra-large screen density. */
91    SCREEN_XXLDPI = 480,
92    /** Indicates extra-extra-extra-large screen density. */
93    SCREEN_XXXLDPI = 640,
94} ScreenDensity;
95
96/**
97 * @brief Enumerates screen directions.
98 *
99 * @since 12
100 */
101typedef enum ResourceManager_Direction {
102    /** Indicates the vertical direction. */
103    DIRECTION_VERTICAL = 0,
104    /** Indicates the horizontal direction. */
105    DIRECTION_HORIZONTAL = 1,
106} ResourceManager_Direction;
107
108/**
109 * @brief Enumerates color mode types.
110 *
111 * @since 12
112 */
113typedef enum ResourceManager_ColorMode {
114    /** Indicates dark mode. */
115    DARK = 0,
116    /** Indicates light mode. */
117    LIGHT = 1,
118} ResourceManager_ColorMode;
119
120/**
121 * @brief Enumerates device types.
122 *
123 * @since 12
124 */
125typedef enum ResourceManager_DeviceType {
126    /** Indicates a phone. */
127    DEVICE_TYPE_PHONE = 0X00,
128    /** Indicates a tablet. */
129    DEVICE_TYPE_TABLET = 0x01,
130    /** Indicates a car. */
131    DEVICE_TYPE_CAR = 0x02,
132    /** Indicates a PC. */
133    DEVICE_TYPE_PC = 0x03,
134    /** Indicates a smart TV. */
135    DEVICE_TYPE_TV = 0x04,
136    /** Indicates a wearable device. */
137    DEVICE_TYPE_WEARABLE = 0x06,
138    /** Indicates a 2in1 device. */
139    DEVICE_TYPE_2IN1 = 0x07,
140} ResourceManager_DeviceType;
141
142/**
143 * @brief Enumerates device configuration.
144 *
145 * @since 12
146 */
147typedef struct ResourceManager_Configuration {
148    /** Indicates the screen direction of the current device. */
149    ResourceManager_Direction direction;
150    /** Indicates the current system language, for example, zh-Hans-CN. */
151    char* locale;
152    /** Indicates the device type. */
153    ResourceManager_DeviceType deviceType;
154    /** Indicates the screen density. */
155    ScreenDensity screenDensity;
156    /** Indicates the color mode. */
157    ResourceManager_ColorMode colorMode;
158    /** Indicates the mcc. */
159    uint32_t mcc;
160    /** Indicates the mnc. */
161    uint32_t mnc;
162    /** Reserved attributes. */
163    uint32_t reserved[20];
164} ResourceManager_Configuration;
165#ifdef __cplusplus
166};
167#endif
168
169/** @} */
170#endif // GLOBAL_RESMGR_COMMON_H
171