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 FRAMEWORKS_OPENGL_WRAPPER_EGL_SYSTEM_LAYERS_MANAGER_H
17 #define FRAMEWORKS_OPENGL_WRAPPER_EGL_SYSTEM_LAYERS_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 #include <unistd.h>
22 
23 #include "json/json.h"
24 
25 /*
26 Example of json config:
27 
28 {
29     "enableAppMode" : true,
30 
31     "appMode" : {
32         "enableDefaultAppMode" : true,
33 
34         "default" : ["layer1", "layer2"],
35 
36         "com.hiawei.app" : ["layer1", "layer2"]
37     }
38 }
39 */
40 
41 namespace OHOS {
42 
43 class EglSystemLayersManager {
44 public:
45     EglSystemLayersManager() = default;
46     ~EglSystemLayersManager() = default;
47 
48     std::vector<std::string> GetSystemLayers();
49 
50 private:
51     bool GetProcessName(pid_t pid, char *pname, int len);
52     bool GetJsonConfig(Json::Value &configData);
53     bool GetDefaultJsonConfig(Json::Value &configData);
54     std::vector<std::string> GetSystemLayersFromConfig(Json::Value &appModeSection,
55         const std::string &processName);
56     std::vector<std::string> GetStringVectorFromJson(const Json::Value &jsonVector);
57 };
58 
59 } //namespace OHOS
60 
61 #endif // FRAMEWORKS_OPENGL_WRAPPER_EGL_SYSTEM_LAYERS_MANAGER_H