• 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_DATA_H
17 #define ON_SCREEN_DATA_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace OHOS {
24 namespace Msdp {
25 namespace DeviceStatus {
26 namespace OnScreen {
27 namespace {
28 constexpr int32_t MIN_PARA_SIZE = 300;
29 constexpr int32_t MAX_PARA_SIZE = 500;
30 }
31 
32 enum class Scenario {
33     UNKNOWN = 0,
34     ARTICLE,
35     END,
36 };
37 
38 enum class EventType {
39     UNKNOWN = 0,
40     SCROLL_TO_HOOK,
41     END,
42 };
43 
44 struct ParagraphSizeRange {
45     int32_t minSize;
46     int32_t maxSize;
47 };
48 
49 struct ContentOption {
50     int32_t windowId = -1;
51     // 是否进行内容理解
52     bool contentUnderstand = false;
53     // 是否采集页面链接
54     bool pageLink = false;
55     // 是否只采集文本
56     bool textOnly = false;
57     // 设置最小分段长度和最大分段长度,默认为300 500
58     ParagraphSizeRange paragraphSizeRange = {
59         .minSize = MIN_PARA_SIZE,
60         .maxSize = MAX_PARA_SIZE
61     };
62 };
63 
64 struct Paragraph {
65     int64_t hookId = 0;
66     int32_t chapterId = 0;
67     std::string title;
68     std::string content;
69 };
70 
71 struct PageContent {
72     int32_t windowId = -1;
73     int64_t sessionId = 0;
74     std::string bundleName;
75     // content understand = true
76     Scenario scenario = Scenario::UNKNOWN;
77     std::string title;
78     std::string content;
79     // page_link = true
80     std::string pageLink;
81     // text only = true
82     std::vector<Paragraph> paragraphs;
83 };
84 
85 struct ControlEvent {
86     int32_t windowId = 0;
87     int64_t sessionId = 0;
88     EventType eventType = EventType::UNKNOWN;
89     int64_t hookId = 0;
90 };
91 
92 struct OnScreenCallingContext {
93     uint64_t fullTokenId = 0;
94     uint32_t tokenId = 0;
95     int32_t uid = -1;
96     int32_t pid = -1;
97 };
98 } // namespace OnScreen
99 } // namespace DeviceStatus
100 } // namespace Msdp
101 } // namespace OHOS
102 #endif // ON_SCREEN_DATA_H