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 WINDOW_MANAGER_LOADER_H
17 #define WINDOW_MANAGER_LOADER_H
18 #include <string>
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
22 const std::string WINDOW_MANAGER_PATH = "libaccesstoken_window_manager.z.so";
23 
24 using WindowChangeCallback = void (*)(uint32_t, bool);
25 class WindowManagerLoaderInterface {
26 public:
WindowManagerLoaderInterface()27     WindowManagerLoaderInterface() {}
~WindowManagerLoaderInterface()28     virtual ~WindowManagerLoaderInterface() {}
29     virtual int32_t RegisterFloatWindowListener(const WindowChangeCallback& callback);
30     virtual int32_t UnregisterFloatWindowListener(const WindowChangeCallback& callback);
31 
32     virtual int32_t RegisterPipWindowListener(const WindowChangeCallback& callback);
33     virtual int32_t UnregisterPipWindowListener(const WindowChangeCallback& callback);
34 
35     virtual void AddDeathCallback(void (*callback)());
36 };
37 
38 class WindowManagerLoader final: public WindowManagerLoaderInterface {
39     int32_t RegisterFloatWindowListener(const WindowChangeCallback& callback);
40     int32_t UnregisterFloatWindowListener(const WindowChangeCallback& callback);
41 
42     int32_t RegisterPipWindowListener(const WindowChangeCallback& callback);
43     int32_t UnregisterPipWindowListener(const WindowChangeCallback& callback);
44 
45     void AddDeathCallback(void (*callback)());
46 };
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51     void* Create();
52     void Destroy(void* loaderPtr);
53 #ifdef __cplusplus
54 }
55 #endif
56 } // namespace AccessToken
57 } // namespace Security
58 } // namespace OHOS
59 #endif // WINDOW_MANAGER_LOADER_H