• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 ON_SCREEN_SERVER_H
17 #define ON_SCREEN_SERVER_H
18 
19 #include <mutex>
20 
21 #include "i_on_screen_algorithm.h"
22 #include "i_plugin.h"
23 #include "on_screen_data.h"
24 
25 namespace OHOS {
26 namespace Msdp {
27 namespace DeviceStatus {
28 namespace OnScreen {
29 struct OnScreenAlgorithmHandle {
OnScreenAlgorithmHandleOnScreenAlgorithmHandle30     OnScreenAlgorithmHandle() : handle(nullptr), pAlgorithm(nullptr), create(nullptr), destroy(nullptr) {}
31     ~OnScreenAlgorithmHandle();
32     void Clear();
33     void* handle = nullptr;
34     IOnScreenAlgorithm* pAlgorithm = nullptr;
35     IOnScreenAlgorithm* (*create)();
36     void (*destroy)(const IOnScreenAlgorithm*);
37 };
38 
39 class OnScreenServer {
40 public:
41     OnScreenServer() = default;
42     virtual ~OnScreenServer();
43     int32_t GetPageContent(const CallingContext &context, const ContentOption &option, PageContent &pageContent);
44     int32_t SendControlEvent(const CallingContext &context, const ControlEvent &event);
45 private:
46     int32_t LoadAlgoLib();
47     int32_t UnloadAlgoLib();
48     int32_t ConnectAlgoLib();
49     bool CheckPermission(const CallingContext &context, const std::string &permission);
50     bool IsSystemCalling(const CallingContext &context);
51     bool IsSystemServiceCalling(const CallingContext &context);
52 
53     OnScreenAlgorithmHandle handle_;
54     std::mutex mtx_;
55 };
56 } // namespace OnScreen
57 } // namespace DeviceStatus
58 } // namespace Msdp
59 } // namespace OHOS
60 #endif // ON_SCREEN_SERVER_H