mirror of
https://github.com/openharmony/frame_aware_sched.git
synced 2026-06-30 22:08:38 -04:00
frameaware code 20220214
Signed-off-by: rongkunshi <shirongkun@huawei.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/resourceschedule/frame_aware_sched/frameaware.gni")
|
||||
|
||||
|
||||
group("libintellisensesched_intf") {
|
||||
public_deps = [
|
||||
"${innerkits_path}/frameintf:frame_msg_intf",
|
||||
"${innerkits_path}/frameintf:frame_ui_intf",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
All configurations in this file will be merged to OAT-Default.xml, if you have any questions or concerns, please create issue in OpenHarmony/tools_oat and @jalenchen or chenyaxun.
|
||||
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
policylist:
|
||||
1. policy: If the OAT-Default.xml policies do not meet your requirements, please add policies here.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(projectroot means the root dir of the project), supported file names: LICENSE, README, README.OpenSource
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
7. policyitem desc: Used to describe the reason of this policy item, committers will check this while merging the code.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == "
|
||||
& == &
|
||||
' == '
|
||||
< == <
|
||||
> == >
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<!--policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/-->
|
||||
<!--policyitem type="license" name="LGPL" path=".*" desc="Dynamically linked by module X"/-->
|
||||
<!--policyitem type="copyright" name="xxx" path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
|
||||
</policy>
|
||||
</policylist>
|
||||
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="*.iml|*.json|*.txt" desc="desc files"/>
|
||||
<filteritem type="filepath" name="target/.*" desc="Compile output files"/>
|
||||
<filteritem type="filepath" name="out/.*" desc="Compile output files"/>
|
||||
<filteritem type="filepath" name="log/.*" desc="log files"/>
|
||||
<filteritem type="filepath" name=".idea/.*" desc="IDE temp files"/>
|
||||
<filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/>
|
||||
<filteritem type="filepath" name="src/test/.*" desc="Test files"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filteritem type="filepath" name="src/main/java/ohos/oat/analysis/headermatcher/.*" desc="License matcher rules, not license header"/>
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# frame_aware_sched
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -1,39 +0,0 @@
|
||||
# frame_aware_sched
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
# 智能感知调度
|
||||
|
||||
- [简介](#section_introduction)
|
||||
|
||||
- [目录](#section_catalogue)
|
||||
|
||||
- [框架](#section_framework)
|
||||
|
||||
- [绘帧信息收集](#section_strategy)
|
||||
|
||||
- [帧感知调度机制](#section_mechanism)
|
||||
|
||||
- [相关仓](#related_repositories)
|
||||
|
||||
|
||||
|
||||
## 简介<a name="section_introduction"></a>
|
||||
|
||||
智能感知调度部件位于全局资源调度管控子系统中,基于应用的生命周期状态、绘帧信息等,更新进程调度分组,通过设置进程组、线程优先级及其他内核调度参数等手段管理系统调度,保障系统进程调度供给。
|
||||
|
||||
|
||||
|
||||
## 目录<a name="section_catalogue"></a>
|
||||
|
||||
```
|
||||
//foundation/resourceschedule/plugins/frame_aware_sched
|
||||
├── common # 部件通用工具类
|
||||
│ └── include
|
||||
│ ├── frame_info_const.h # UI及render绘帧过程信息
|
||||
│ ├── frame_aware_constants.h # 通用参数配置
|
||||
│ ├── frame_aware_log_domain.h # 封装hilog,用于日志打印
|
||||
│ └── single_instance.h # 封装单例类,方便实现单例
|
||||
│
|
||||
├── interfaces
|
||||
│ └── innerkits # 对内接口目录
|
||||
│ └── frameintf # 感知调度专用接口
|
||||
│
|
||||
├── frameworks
|
||||
│ └── core
|
||||
│ ├── frame_aware_collector # 应用绘帧信息收集组件
|
||||
│ └── frame_aware_policy # 帧感知调度机制组件
|
||||
│
|
||||
├── profiles # 组件配置文件
|
||||
└── test # 自测试用例目录
|
||||
```
|
||||
|
||||
|
||||
## 框架<a name="section_framework"></a>
|
||||
|
||||
智能感知调度部件根据执行时所属线程进行划分,可包含两大组件,即运行在App进程的绘帧信息收集器组件和运行在系统服务进程的帧感知调度机制组件,每个组件分为若干模块。
|
||||
|
||||
- **绘帧信息收集组件**:主要分为绘帧事件处理模块、滑动场景策略模块以及模型处理模块,三者构成绘帧核心策略。其中:
|
||||
|
||||
消息处理模块负责统筹JS-UI子系统及Graphic子系统的绘帧子过程的消息信息并分发;
|
||||
|
||||
帧事件处理模块主要负责提供各个子过程的调节调度算法;
|
||||
|
||||
滑动场景策略模块主要负责针对滑动场景,使用帧事件处理模块的算法接口提供应用主线程绘帧策略,进行场景化精细调度。
|
||||
|
||||
- **帧感知调度机制组件**:主要分为场景处理模块、应用管控模块、调度参数管控模块和RTG(Related-Thread-Group)分组管理模块,四者构成应用线程调度机制。其中:
|
||||
|
||||
场景处理模块主要负责注册接收来自全局资源管控子系统的消息,诸如应用前后台切换、窗口焦点变化等,并分发消息给应用管控模块和RTG分组模块;
|
||||
|
||||
应用管控模块,主要负责把维护接收到的消息,形成应用消息管理;
|
||||
|
||||
RTG分组管理模块即调用内核接口设置,根据应用状态设置RTG分组实现线程调度管理;
|
||||
|
||||
调度参数管控模块主要负责读取默认调度参数配置。
|
||||
|
||||
两个组件中的事件处理模块,均统筹了智能感知调度部件所要对外相应的事件,而调度特性内核接口模块则负责将管控调度命令以帧的频率下发,两个组件相互合作,共同保障系统线程的性能供给。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
### 绘帧信息收集<a name="section_strategy"></a>
|
||||
|
||||
应用绘帧感知主要负责调节内核调度的参数,进行线程负载的缩放。当用户在APP界面滑动时,识别出应用的关键线程(诸如绘帧主线程、渲染线程),感知应用绘帧子过程的执行情况,根据是否超时来判断是否调整内核调度参数,进行实时的资源供给,进行优先调度。
|
||||
|
||||
- 根据屏幕刷新率,判断当前帧率信息。根据越接近绘帧结束时刻,越加大关键线程的资源供给
|
||||
|
||||
|
||||
- 根据界面绘帧图形渲染过程中的各个子阶段的时长,调节资源供给。
|
||||
|
||||
|
||||
- 对可能发生丢帧卡顿的高概率事件,增加资源供给
|
||||
|
||||
|
||||
|
||||
|
||||
### 帧感知调度机制<a name="section_mechanism"></a>
|
||||
|
||||
应用线程调度机制,作为应用绘帧感知实现的基础,主要负责管控线程组及线程优先级,实现应用线程的统一管理,保证整个系统性能。
|
||||
|
||||
**核心思想**:分组,即根据不同线程组提供不同的供给能力。把用户敏感度线程添加进同一个线程组,在应用启动、前后台切换等多个应用变化场景,提供资源优先供给。
|
||||
|
||||
|
||||
|
||||
### 使用说明<a name="instructions"></a>
|
||||
|
||||
系统开发者可以通过配置productdefine/common/products下的产品定义json文件,增加或移除本部件,来启用或停用本部件
|
||||
|
||||
"resourceschedule:frame_aware_sched":{}
|
||||
|
||||
|
||||
|
||||
### 相关仓<a name="related_repositories"></a>
|
||||
|
||||
- resource_schedule_service
|
||||
|
||||
- ace_ace_engine
|
||||
|
||||
- graphic_standard
|
||||
|
||||
- aafwk_standard
|
||||
|
||||
- **frame_aware_sched**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "@ohos/resource_schedule_service",
|
||||
"description": "resource_schedule_service",
|
||||
"version": "3.1",
|
||||
"license": "Apache License 2.0",
|
||||
"publishAs": "code-segment",
|
||||
"segment": {
|
||||
"destPath": "foundation/resourceschedule/plugins/frame_aware_sched"
|
||||
},
|
||||
"dirs": {},
|
||||
"scripts": {},
|
||||
"component": {
|
||||
"name": "frame_aware_sched",
|
||||
"subsystem": "resourceschedule",
|
||||
"syscap": [],
|
||||
"features": [],
|
||||
"adapted_system_type": [
|
||||
"mini",
|
||||
"small",
|
||||
"standard"
|
||||
],
|
||||
"rom": "2048KB",
|
||||
"ram": "10240KB",
|
||||
"deps": {
|
||||
"components": [
|
||||
"libeventhandler",
|
||||
"ipc_core",
|
||||
"samgr_proxy",
|
||||
"system_ability_fwk"
|
||||
],
|
||||
"third_party": [
|
||||
"xml2"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
"//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf:frame_ui_intf",
|
||||
"//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf:frame_msg_intf",
|
||||
"//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf:rtg_interface",
|
||||
"//foundation/resourceschedule/plugins/frame_aware_sched/profiles:frame_aware_sched_config"
|
||||
],
|
||||
"inner_kits": [
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf",
|
||||
"header_files": [
|
||||
"frame_ui_intf.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf:frame_ui_intf"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf",
|
||||
"header_files": [
|
||||
"frame_msg_intf.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/resourceschedule/plugins/frame_aware_sched/interfaces/innerkits/frameintf:frame_msg_intf"
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
"//foundation/resourceschedule/plugins/frame_aware_sched/test:frame_unittest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_INFO_CONST_H
|
||||
#define FRAME_INFO_CONST_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
enum class FrameEvent {
|
||||
FLUSH_ANIMATION,
|
||||
FLUSH_BUILD,
|
||||
FLUSH_LAYOUT,
|
||||
FLUSH_RENDER,
|
||||
FLUSH_RENDER_FINISH, // to add, do not realize
|
||||
PROCESS_POST_FLUSH,
|
||||
PROCESS_COMMANDS,
|
||||
ANIMATE,
|
||||
RENDER,
|
||||
SEND_COMMANDS,
|
||||
EVENT_SET_PARAM,
|
||||
EVENT_RTG_ENABLE,
|
||||
EVENT_BUFFER_COUNT,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
enum class EventState {
|
||||
EVENT_ENTER,
|
||||
EVENT_CONSUMED,
|
||||
EVENT_EXIT,
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
};
|
||||
|
||||
enum class SceneEvent {
|
||||
SCENE_INVALID = 0,
|
||||
VIDEO,
|
||||
SLIDE,
|
||||
GAME,
|
||||
CLICK,
|
||||
SCENE_MAX,
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RME_CONSTANTS_H
|
||||
#define RME_CONSTANTS_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
enum class AppStateUpdateReason {
|
||||
APP_FOREGROUND,
|
||||
APP_BACKGROUND,
|
||||
APP_TERMINATED,
|
||||
PROCESS_CREATE,
|
||||
PROCESS_READY,
|
||||
PROCESS_SUSPEND,
|
||||
PROCESS_DIED,
|
||||
REASON_UNKNOWN,
|
||||
};
|
||||
|
||||
enum class ThreadType {
|
||||
UI,
|
||||
RENDER,
|
||||
};
|
||||
|
||||
enum class ThreadState {
|
||||
CREATE = 0,
|
||||
DIED,
|
||||
};
|
||||
|
||||
enum class WindowState {
|
||||
FOCUS_YES = 0,
|
||||
FOCUS_NO,
|
||||
};
|
||||
|
||||
enum class ErrorCode {
|
||||
FAIL,
|
||||
SUCC,
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RME_LOG_DOMAIN_H
|
||||
#define RME_LOG_DOMAIN_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "hilog/log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RmeLogDomain {
|
||||
|
||||
constexpr uint32_t COMMON = 0xD006600;
|
||||
constexpr uint32_t RME_SERVICE = 0xD006601;
|
||||
constexpr uint32_t RME_TEST = 0xD006602;
|
||||
constexpr uint32_t RME_INTELLISENSE = 0xD006604;
|
||||
|
||||
/*
|
||||
#ifdef RME_LOGF
|
||||
#undef RME_LOGF
|
||||
#endif
|
||||
|
||||
#ifdef RME_LOGE
|
||||
#undef RME_LOGE
|
||||
#endif
|
||||
|
||||
#ifdef RME_LOGW
|
||||
#undef RME_LOGW
|
||||
#endif
|
||||
|
||||
#ifdef RME_LOGI
|
||||
#undef RME_LOGI
|
||||
#endif
|
||||
|
||||
#ifdef RME_LOGD
|
||||
#undef RME_LOGD
|
||||
#endif
|
||||
*/
|
||||
|
||||
#define DEFINE_RMELOG_LABEL(name) \
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::COMMON, name};
|
||||
#define DEFINE_RMELOG_INTELLISENSE(name) \
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_INTELLISENSE, name};
|
||||
#define DEFINE_RMELOG_SERVICE(name) \
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_SERVICE, name};
|
||||
#define DEFINE_RMELOG_TEST(name) \
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_TEST, name};
|
||||
|
||||
|
||||
#define RME_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(RME_LOG_LABEL, ##__VA_ARGS__)
|
||||
#define RME_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(RME_LOG_LABEL, ##__VA_ARGS__)
|
||||
#define RME_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(RME_LOG_LABEL, ##__VA_ARGS__)
|
||||
#define RME_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(RME_LOG_LABEL, ##__VA_ARGS__)
|
||||
#define RME_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(RME_LOG_LABEL, ##__VA_ARGS__)
|
||||
|
||||
|
||||
} // namespace RmeLogDomain
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RME_LOG_DOMAIN_H
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H
|
||||
#define OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MAX_TID_NUM 5
|
||||
#define MAX_SUBPROCESS_NUM 8
|
||||
#define MULTI_FRAME_NUM 5
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
struct rtg_enable_data {
|
||||
int enable;
|
||||
int len;
|
||||
char *data;
|
||||
};
|
||||
|
||||
struct rtg_str_data {
|
||||
int type;
|
||||
int len;
|
||||
char *data;
|
||||
};
|
||||
|
||||
struct proc_state_data {
|
||||
int grp_id;
|
||||
int state_param;
|
||||
};
|
||||
|
||||
enum grp_ctrl_cmd {
|
||||
CMD_CREATE_RTG_GRP,
|
||||
CMD_ADD_RTG_THREAD,
|
||||
CMD_REMOVE_RTG_THREAD,
|
||||
CMD_CLEAR_RTG_GRP,
|
||||
CMD_DESTROY_RTG_GRP
|
||||
};
|
||||
|
||||
struct rtg_grp_data {
|
||||
int rtg_cmd;
|
||||
int grp_id;
|
||||
int prio_type;
|
||||
int rt_cnt;
|
||||
int tid_num;
|
||||
int tids[MAX_TID_NUM];
|
||||
};
|
||||
|
||||
struct rtg_info {
|
||||
int rtg_num;
|
||||
int rtgs[MULTI_FRAME_NUM];
|
||||
};
|
||||
|
||||
enum rtg_sched_cmdid {
|
||||
SET_ENABLE = 1,
|
||||
SET_RTG,
|
||||
SET_CONFIG,
|
||||
SET_RTG_ATTR,
|
||||
BEGIN_FRAME_FREQ = 5,
|
||||
END_FRAME_FREQ,
|
||||
END_SCENE,
|
||||
SET_MIN_UTIL,
|
||||
SET_MARGIN,
|
||||
LIST_RTG,
|
||||
LIST_RTG_THREAD,
|
||||
SEARCH_RTG,
|
||||
RTG_CTRL_MAX_NR,
|
||||
};
|
||||
|
||||
extern "C"{
|
||||
int EnableRtg(bool flag);
|
||||
//-----for frame rtg-----//
|
||||
int CreateNewRtgGrp(int prioType = 0, int rtNum = 0); // Return GrpId if success
|
||||
int AddThreadToRtg(int tid, int grpId);
|
||||
int AddThreadsToRtg(vector<int> tids, int grpId);
|
||||
int RemoveRtgThread(int tid);
|
||||
int ClearRtgGrp(int grpId);
|
||||
int DestroyRtgGrp(int grpId);
|
||||
int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType);
|
||||
int SetMaxVipRtgs(int rtframe);
|
||||
int BeginFrameFreq(int grpId, int stateParam);
|
||||
int EndFrameFreq(int grpId, int stateParam);
|
||||
int EndScene(int rtgId);
|
||||
int SetMinUtil(int grpId, int stateParam);
|
||||
int SetMargin(int grpId, int stateParam);
|
||||
int ListRtgThread(int grpId, vector<int> *rs); // list all tasks of grpId;
|
||||
int ListRtgGroup(vector<int> *rs);
|
||||
int SearchRtgForTid(int stateParam);
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SINGLE_INSTANCE_H
|
||||
#define SINGLE_INSTANCE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
#define DECLARE_SINGLE_INSTANCE_BASE(className) \
|
||||
public: \
|
||||
static className& GetInstance(); \
|
||||
private: \
|
||||
className(const className&) = delete; \
|
||||
className& operator=(const className &) = delete; \
|
||||
className(className&&) = delete; \
|
||||
className& operator=(className&&) = delete; \
|
||||
|
||||
|
||||
#define DECLARE_SINGLE_INSTANCE(className) \
|
||||
DECLARE_SINGLE_INSTANCE_BASE(className) \
|
||||
private: \
|
||||
className() = default; \
|
||||
~className() = default; \
|
||||
|
||||
|
||||
#define IMPLEMENT_SINGLE_INSTANCE(className) \
|
||||
className& className::GetInstance() \
|
||||
{ \
|
||||
static auto instance = new className(); \
|
||||
return *instance; \
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SINGLE_INSTANCE_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
frame_aware_path = "//foundation/resourceschedule/plugins/frame_aware_sched"
|
||||
service_path = "${frame_aware_path}/services"
|
||||
innerkits_path = "${frame_aware_path}/interfaces/innerkits"
|
||||
|
||||
framework_path = "${frame_aware_path}/frameworks/core"
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_MSG_MGR_H
|
||||
#define FRAME_MSG_MGR_H
|
||||
|
||||
#include <hilog/log.h>
|
||||
|
||||
#include "rme_log_domain.h"
|
||||
#include "frame_info_const.h"
|
||||
#include "rme_scene_sched.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class RmeSceneSched;
|
||||
|
||||
class FrameMsgMgr {
|
||||
DECLARE_SINGLE_INSTANCE_BASE(FrameMsgMgr);
|
||||
public:
|
||||
FrameMsgMgr();
|
||||
~FrameMsgMgr();
|
||||
bool Init();
|
||||
void EventUpdate(FrameEvent eventType, EventState state);
|
||||
|
||||
private:
|
||||
void UpdateScene(SceneEvent scene);
|
||||
|
||||
void HandleDefaultEvent(FrameEvent event, EventState state);
|
||||
void SetSchedParam();
|
||||
FrameSceneSched *GetSceneHandler() const;
|
||||
|
||||
SceneEvent sceneType;
|
||||
RmeSceneSched *rmeScene;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_SCENE_SCHED_H
|
||||
#define FRAME_SCENE_SCHED_H
|
||||
|
||||
#include "rme_log_domain.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class FrameSceneSched {
|
||||
public:
|
||||
FrameSceneSched() {};
|
||||
virtual ~FrameSceneSched() = default;
|
||||
|
||||
// virtual void UpdateBufferCount(int count);
|
||||
virtual void BeginFlushAnimation() = 0;
|
||||
virtual void EndFlushAnimation() = 0;
|
||||
virtual void BeginFlushBuild() = 0;
|
||||
virtual void EndFlushBuild() = 0;
|
||||
virtual void BeginFlushLayout() = 0;
|
||||
virtual void EndFlushLayout() = 0;
|
||||
virtual void BeginFlushRender() = 0;
|
||||
virtual void EndFlushRender() = 0;
|
||||
virtual void BeginProcessPostFlush() = 0;
|
||||
virtual void ProcessCommandsStart() = 0;
|
||||
virtual void AnimateStart() = 0;
|
||||
virtual void RenderStart() = 0;
|
||||
virtual void SendCommandsStart() = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_WINDOW_MGR_H
|
||||
#define FRAME_WINDOW_MGR_H
|
||||
|
||||
#include <string>
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class FrameWindowMgr {
|
||||
DECLARE_SINGLE_INSTANCE(FrameWindowMgr);
|
||||
public:
|
||||
int GetEnable();
|
||||
void SetStartFlag(bool flag);
|
||||
bool GetStartFlag();
|
||||
private:
|
||||
int m_enable = -1;
|
||||
bool m_startFlag;
|
||||
// static int m_propName;
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef INTELLI_SENSE_SCHED_H
|
||||
#define INTELLI_SENSE_SCHED_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
namespace RME {
|
||||
|
||||
class IntelliSenseSched {
|
||||
public:
|
||||
IntelliSenseSched();
|
||||
~IntelliSenseSched();
|
||||
|
||||
static IntelliSenseSched &GetInstance();
|
||||
static bool IsSoLoaded();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RME_CORE_SCHED_H
|
||||
#define RME_CORE_SCHED_H
|
||||
|
||||
#include "rme_log_domain.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class RmeCoreSched {
|
||||
public:
|
||||
RmeCoreSched();
|
||||
~RmeCoreSched();
|
||||
|
||||
void Init();
|
||||
|
||||
void BeginFlushAnimation();
|
||||
void EndFlushAnimation();
|
||||
|
||||
void BeginFlushBuild();
|
||||
void EndFlushBuild();
|
||||
|
||||
void BeginFlushLayout();
|
||||
void EndFlushLayout();
|
||||
|
||||
void BeginFlushRender();
|
||||
void EndFlushRender();
|
||||
|
||||
void BeginProcessPostFlush();
|
||||
void ProcessCommandsStart();
|
||||
void AnimateStart();
|
||||
void RenderStart();
|
||||
void SendCommandsStart();
|
||||
|
||||
RmeCoreSched(const RmeCoreSched &) = delete;
|
||||
RmeCoreSched &operator=(const RmeCoreSched &) = delete;
|
||||
|
||||
private:
|
||||
int m_flushAnimationPeriod = 3;
|
||||
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RME_SCENE_SCHED_H
|
||||
#define RME_SCENE_SCHED_H
|
||||
|
||||
#include "frame_scene_sched.h"
|
||||
#include "frame_window_mgr.h"
|
||||
#include "rme_core_sched.h"
|
||||
#include "rme_log_domain.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class RmeSceneSched : public FrameSceneSched {
|
||||
public:
|
||||
RmeSceneSched();
|
||||
~RmeSceneSched() override;
|
||||
|
||||
void BeginFlushAnimation() override;
|
||||
void EndFlushAnimation() override;
|
||||
|
||||
void BeginFlushBuild() override;
|
||||
void EndFlushBuild() override;
|
||||
|
||||
void BeginFlushLayout() override;
|
||||
void EndFlushLayout() override;
|
||||
|
||||
void BeginFlushRender() override;
|
||||
void EndFlushRender() override;
|
||||
|
||||
void BeginProcessPostFlush() override;
|
||||
void ProcessCommandsStart() override;
|
||||
void AnimateStart() override;
|
||||
void RenderStart() override;
|
||||
void SendCommandsStart() override;
|
||||
|
||||
bool Init();
|
||||
|
||||
private:
|
||||
int curWorkingStatus;
|
||||
RmeCoreSched *rmeCoreSched;
|
||||
};
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frame_msg_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaClient-FrameMsgMgr");
|
||||
IMPLEMENT_SINGLE_INSTANCE(FrameMsgMgr);
|
||||
|
||||
FrameMsgMgr::FrameMsgMgr()
|
||||
: sceneType(SceneEvent::SLIDE), rmeScene(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
FrameMsgMgr::~FrameMsgMgr()
|
||||
{
|
||||
if (rmeScene != nullptr) {
|
||||
delete rmeScene;
|
||||
}
|
||||
}
|
||||
|
||||
bool FrameMsgMgr::Init()
|
||||
{
|
||||
if (rmeScene == nullptr) {
|
||||
rmeScene = new RmeSceneSched();
|
||||
}
|
||||
|
||||
if (!rmeScene->Init()) {
|
||||
RME_LOGE("[Init]:inited success!");
|
||||
return false;
|
||||
}
|
||||
RME_LOGI("[Init]:inited success!");
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrameMsgMgr::EventUpdate(FrameEvent event, EventState value)
|
||||
{
|
||||
switch (event) {
|
||||
case FrameEvent::EVENT_SET_PARAM:
|
||||
SetSchedParam();
|
||||
break;
|
||||
case FrameEvent::EVENT_RTG_ENABLE:
|
||||
RME_LOGI("[EventUpdate]:rtg enable!");
|
||||
break;
|
||||
default:
|
||||
HandleDefaultEvent(event, value);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FrameMsgMgr::UpdateScene(SceneEvent scene)
|
||||
{
|
||||
if (scene < SceneEvent::SCENE_INVALID || scene >= SceneEvent::SCENE_MAX) {
|
||||
scene = SceneEvent::SCENE_INVALID;
|
||||
}
|
||||
|
||||
sceneType = scene;
|
||||
}
|
||||
|
||||
void FrameMsgMgr::HandleDefaultEvent(FrameEvent event, EventState value)
|
||||
{
|
||||
FrameSceneSched *scene = GetSceneHandler();
|
||||
if (scene == nullptr) {
|
||||
RME_LOGE("[HandleDefaultEvent]:scene nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case FrameEvent::FLUSH_ANIMATION:
|
||||
if (value == EventState::EVENT_ENTER) {
|
||||
scene->BeginFlushAnimation();
|
||||
} else {
|
||||
scene->EndFlushAnimation();
|
||||
}
|
||||
break;
|
||||
case FrameEvent::FLUSH_BUILD:
|
||||
if (value == EventState::EVENT_ENTER) {
|
||||
scene->BeginFlushBuild();
|
||||
} else {
|
||||
scene->EndFlushBuild();
|
||||
}
|
||||
break;
|
||||
case FrameEvent::FLUSH_LAYOUT:
|
||||
if (value == EventState::EVENT_ENTER) {
|
||||
scene->BeginFlushLayout();
|
||||
} else {
|
||||
scene->EndFlushLayout();
|
||||
}
|
||||
break;
|
||||
case FrameEvent::FLUSH_RENDER:
|
||||
if (value == EventState::EVENT_ENTER) {
|
||||
scene->BeginFlushRender();
|
||||
} else {
|
||||
scene->EndFlushRender();
|
||||
}
|
||||
break;
|
||||
case FrameEvent::PROCESS_POST_FLUSH:
|
||||
scene->BeginProcessPostFlush();
|
||||
break;
|
||||
case FrameEvent::PROCESS_COMMANDS:
|
||||
scene->ProcessCommandsStart();
|
||||
break;
|
||||
case FrameEvent::ANIMATE:
|
||||
scene->AnimateStart();
|
||||
break;
|
||||
case FrameEvent::RENDER:
|
||||
scene->RenderStart();
|
||||
break;
|
||||
case FrameEvent::SEND_COMMANDS:
|
||||
scene->SendCommandsStart();
|
||||
break;
|
||||
default:
|
||||
RME_LOGE("[HandleDefaultEvent]: unknown event id: %{public}d, event state:%{public}d\n", static_cast<int>(event), static_cast<int>(value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMsgMgr::SetSchedParam()
|
||||
{
|
||||
RME_LOGI("[SetSchedParam]: set default sched param!");
|
||||
}
|
||||
|
||||
FrameSceneSched *FrameMsgMgr::GetSceneHandler() const
|
||||
{
|
||||
|
||||
if (sceneType == SceneEvent::SCENE_INVALID) {
|
||||
RME_LOGE("[GetSceneHandler]:get nullptr sceneType %{public}d,", static_cast<int>(sceneType));
|
||||
return nullptr;
|
||||
}
|
||||
return rmeScene;
|
||||
}
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frame_window_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
namespace {
|
||||
|
||||
const std::string SCHEME_SWITCH_PROP = ""; // to add prop
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(FrameWindowMgr);
|
||||
|
||||
int FrameWindowMgr::GetEnable()
|
||||
{
|
||||
if (m_enable == -1) {
|
||||
bool prop = true;
|
||||
if (prop) {
|
||||
m_enable = 1;
|
||||
} else {
|
||||
m_enable = 0;
|
||||
}
|
||||
}
|
||||
return m_enable;
|
||||
}
|
||||
|
||||
void FrameWindowMgr::SetStartFlag(bool flag)
|
||||
{
|
||||
m_startFlag = flag;
|
||||
}
|
||||
|
||||
bool FrameWindowMgr::GetStartFlag()
|
||||
{
|
||||
return m_startFlag;
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "rme_core_sched.h"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaClient-RmeCoreSched");
|
||||
|
||||
RmeCoreSched::RmeCoreSched()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RmeCoreSched::~RmeCoreSched()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void RmeCoreSched::Init()
|
||||
{
|
||||
int ret = EnableRtg(true);
|
||||
if (ret < 0) {
|
||||
RME_LOGE("[Init]: enableRtg failed!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void RmeCoreSched::BeginFlushAnimation()
|
||||
{
|
||||
int ret = BeginFrameFreq(2 ,0);
|
||||
RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq(2, 0), ret: %{public}d!", ret);
|
||||
int flushAnimationTime = 1; // TO DO
|
||||
if (flushAnimationTime >= m_flushAnimationPeriod) {
|
||||
flushAnimationTime = 2;
|
||||
} else {
|
||||
flushAnimationTime = 3;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void RmeCoreSched::EndFlushAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::BeginFlushBuild()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::EndFlushBuild()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::BeginFlushLayout()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::EndFlushLayout()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::BeginFlushRender()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::EndFlushRender()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::BeginProcessPostFlush()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::ProcessCommandsStart()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::AnimateStart()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::RenderStart()
|
||||
{
|
||||
}
|
||||
|
||||
void RmeCoreSched::SendCommandsStart()
|
||||
{
|
||||
int ret = EndFrameFreq(2, 16);
|
||||
RME_LOGI("[SendCommandsStart]: set EndFrameFreq(2, 16), ret: %{public}d!", ret);
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // OHOS
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "rme_scene_sched.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaClient-RmeSceneSched");
|
||||
|
||||
RmeSceneSched::RmeSceneSched()
|
||||
:curWorkingStatus(0), rmeCoreSched(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
RmeSceneSched::~RmeSceneSched()
|
||||
{
|
||||
if (rmeCoreSched != nullptr) {
|
||||
delete rmeCoreSched;
|
||||
}
|
||||
}
|
||||
|
||||
bool RmeSceneSched::Init()
|
||||
{
|
||||
if (rmeCoreSched == nullptr) {
|
||||
rmeCoreSched = new RmeCoreSched();
|
||||
}
|
||||
|
||||
curWorkingStatus = 1;
|
||||
if (rmeCoreSched == nullptr) {
|
||||
return false;
|
||||
}
|
||||
RME_LOGI("[Init]:RmeSceneSched init success!");
|
||||
return true;
|
||||
}
|
||||
|
||||
void RmeSceneSched::BeginFlushAnimation()
|
||||
{
|
||||
if (!FrameWindowMgr::GetInstance().GetEnable()) {
|
||||
return;
|
||||
}
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->BeginFlushAnimation();
|
||||
RME_LOGI("[BeginFlushAnimation]:RmeSceneSched send msg success!");
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::EndFlushAnimation()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->EndFlushAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::BeginFlushBuild()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->BeginFlushBuild();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::EndFlushBuild()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->EndFlushBuild();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::BeginFlushLayout()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->BeginFlushLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::EndFlushLayout()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->EndFlushLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::BeginFlushRender()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->BeginFlushRender();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::EndFlushRender()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->EndFlushRender();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::BeginProcessPostFlush()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->BeginProcessPostFlush();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::ProcessCommandsStart()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->ProcessCommandsStart();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::AnimateStart()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->AnimateStart();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::RenderStart()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->RenderStart();
|
||||
}
|
||||
}
|
||||
|
||||
void RmeSceneSched::SendCommandsStart()
|
||||
{
|
||||
if (curWorkingStatus == 1) {
|
||||
rmeCoreSched->SendCommandsStart();
|
||||
RME_LOGI("[SendCommandsStart]:RmeSceneSched send msg success!");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef APP_INFO_H
|
||||
#define APP_INFO_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
enum class AppState {
|
||||
APP_FOREGROUND,
|
||||
APP_BACKGROUND,
|
||||
APP_TERMINATED,
|
||||
APP_UNKNOWN,
|
||||
};
|
||||
|
||||
|
||||
class AppInfo {
|
||||
public:
|
||||
AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state);
|
||||
~AppInfo() = default;
|
||||
|
||||
void SetRenderTid(const int tid);
|
||||
int GetRenderTid();
|
||||
void SetUiTid(const int tid);
|
||||
int GetUiTid();
|
||||
void SetAppName(const std::string appName);
|
||||
void SetAppState(AppState appState);
|
||||
AppState GetAppState();
|
||||
void SetFocusState(const int isFocus);
|
||||
int GetFocusState();
|
||||
void SetAppPid(const int pid);
|
||||
int GetAppPid();
|
||||
void SetRtgrp(const int grpNum);
|
||||
int GetRtgrp();
|
||||
|
||||
private:
|
||||
std::string m_appName;
|
||||
int m_pid;
|
||||
int m_uiTid;
|
||||
int m_renderTid;
|
||||
int m_isFocus;
|
||||
int m_rtgrp;
|
||||
AppState m_appState;
|
||||
};
|
||||
|
||||
|
||||
} // RME
|
||||
} // OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef APP_INFO_MGR_H
|
||||
#define APP_INFO_MGR_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "app_info.h"
|
||||
#include "rme_log_domain.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class AppInfoMgr {
|
||||
DECLARE_SINGLE_INSTANCE(AppInfoMgr);
|
||||
|
||||
public:
|
||||
std::map<int, std::shared_ptr<AppInfo>> GetForegroundApp() const;
|
||||
void OnForegroundChanged(const int pid, const std::string appName, const int rtGrp);
|
||||
void OnBackgroundChanged(const int pid, const std::string appName);
|
||||
void OnAppTerminateChanged(const int pid, const std::string appName);
|
||||
void OnWindowFocus(const int pid, bool isFocus);
|
||||
void OnUiProcessStart(const int pid, const int tid);
|
||||
void OnRenderProcessStart(const int pid, const int tid);
|
||||
bool OnProcessDied(const int pid, const int tid);
|
||||
std::shared_ptr<AppInfo> GetFocusApp() const;
|
||||
void SetFocusApp(const int pid);
|
||||
int GetAppRtgrp(const int pid);
|
||||
|
||||
private:
|
||||
std::map<int, std::shared_ptr<AppInfo>> mForegroundAppList;
|
||||
std::map<int, std::shared_ptr<AppInfo>> mBackgroundAppList;
|
||||
std::shared_ptr<AppInfo> mFocusApp;
|
||||
};
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef INTELLI_SENSE_SERVER_H
|
||||
#define INTELLI_SENSE_SERVER_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "rme_constants.h"
|
||||
#include "single_instance.h"
|
||||
#include "event_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IntelliSenseServer {
|
||||
DECLARE_SINGLE_INSTANCE(IntelliSenseServer);
|
||||
public:
|
||||
void Init();
|
||||
void ReportMessage(std::string appName, std::string processName, int pid,
|
||||
AppStateUpdateReason reason);
|
||||
void ReportWindowFocus(const int pid, int isFocus);
|
||||
void ReportProcessInfo(const int pid, const int tid, ThreadState state);
|
||||
bool ReadXml();
|
||||
void SetPara(const int32_t currentFps, const int32_t currentRenderType);
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> m_generalPara {};
|
||||
std::map<std::string, std::map<std::string, int>> m_subEventPara {};
|
||||
std::vector<int> m_fpsList {};
|
||||
std::vector<int> m_renderTypeList {};
|
||||
|
||||
bool m_readXmlSuc = false;
|
||||
bool m_needReadXml = true;
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namesapce OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef PARA_CONFIG_H
|
||||
#define PARA_CONFIG_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "third_party/libxml2/include/libxml/parser.h"
|
||||
#include "third_party/libxml2/include/libxml/tree.h"
|
||||
#include "third_party/libxml2/include/libxml/xpath.h"
|
||||
#include "rme_log_domain.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class ParaConfig {
|
||||
public:
|
||||
ParaConfig();
|
||||
~ParaConfig();
|
||||
|
||||
ParaConfig(const ParaConfig&) = delete;
|
||||
ParaConfig& operator=(const ParaConfig&) = delete;
|
||||
ParaConfig(ParaConfig&&) = delete;
|
||||
ParaConfig& operator=(const ParaConfig&&) = delete;
|
||||
|
||||
static bool IsXmlPrepared(const std::string& filePath); // input parameters need gaurantee
|
||||
static std::map<std::string, std::string> GetGeneralConfig();
|
||||
static std::map<std::string, std::map<std::string, int>> GetSubEventConfig();
|
||||
static std::vector<int> GetFpsList();
|
||||
static std::vector<int> GetRenderTypeList();
|
||||
// static bool GetSwitchEnable();
|
||||
|
||||
private:
|
||||
static std::map<std::string, std::string> m_generalConfig;
|
||||
static std::map<std::string, std::map<std::string, int>> m_subEventConfig;
|
||||
static std::vector<int> m_fpsList;
|
||||
static std::vector<int> m_renderTypeList;
|
||||
// static bool m_switchEnable;
|
||||
|
||||
static void ReadAttr(xmlNodePtr& root, const std::string& attrName, std::string& res);
|
||||
static void ReadFrameConfig(const xmlNodePtr& root);
|
||||
static void ReadConfigInfo(const xmlNodePtr& root);
|
||||
static void ReadFpsConfig(const xmlNodePtr& root);
|
||||
static void ReadRenderType(const xmlNodePtr& root);
|
||||
static void SplitString(const std::string& context, const std::string& character,
|
||||
std::vector<int> &mList, const int maxVal, const std::string& attrName);
|
||||
static bool IsValidNode(const xmlNode& currNode);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace RME
|
||||
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RTG_MSG_MGR_H
|
||||
#define RTG_MSG_MGR_H
|
||||
|
||||
#include <hilog/log.h>
|
||||
#include <string>
|
||||
|
||||
#include "rme_log_domain.h"
|
||||
#include "rtg_interface.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class RtgMsgMgr {
|
||||
DECLARE_SINGLE_INSTANCE(RtgMsgMgr);
|
||||
public:
|
||||
void Init();
|
||||
int OnForeground(const std::string appName, const int pid);
|
||||
void OnBackground(const std::string appName, const int pid, const int grpId);
|
||||
void ProcessStart(const int tid, const int grpId);
|
||||
void ProcessDied(const int pid, const int tid);
|
||||
void FpsChanged();
|
||||
void FocusChanged(const int pid, bool isFocus); // for multiwindow
|
||||
};
|
||||
|
||||
} // RME
|
||||
} // OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
AppInfo::AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state)
|
||||
: m_appName(appName),
|
||||
m_pid(pid),
|
||||
m_uiTid(uiTid),
|
||||
m_renderTid(renderTid),
|
||||
m_isFocus(isFocus),
|
||||
m_appState(state)
|
||||
{}
|
||||
|
||||
void AppInfo::SetRenderTid(const int tid)
|
||||
{
|
||||
this->m_renderTid = tid;
|
||||
}
|
||||
|
||||
int AppInfo::GetRenderTid()
|
||||
{
|
||||
return m_renderTid;
|
||||
}
|
||||
|
||||
void AppInfo::SetUiTid(const int tid)
|
||||
{
|
||||
this->m_uiTid = tid;
|
||||
}
|
||||
|
||||
int AppInfo::GetUiTid()
|
||||
{
|
||||
return m_uiTid;
|
||||
}
|
||||
|
||||
void AppInfo::SetAppName(const std::string appName)
|
||||
{
|
||||
this->m_appName = appName;
|
||||
}
|
||||
|
||||
void AppInfo::SetFocusState(const int isFocus)
|
||||
{
|
||||
this->m_isFocus = isFocus;
|
||||
}
|
||||
|
||||
int AppInfo::GetFocusState()
|
||||
{
|
||||
return m_isFocus;
|
||||
}
|
||||
|
||||
void AppInfo::SetAppState(AppState appState)
|
||||
{
|
||||
this->m_appState = appState;
|
||||
}
|
||||
|
||||
void AppInfo::SetAppPid(const int pid)
|
||||
{
|
||||
this->m_pid = pid;
|
||||
}
|
||||
|
||||
int AppInfo::GetAppPid()
|
||||
{
|
||||
return m_pid;
|
||||
}
|
||||
|
||||
AppState AppInfo::GetAppState()
|
||||
{
|
||||
return m_appState;
|
||||
}
|
||||
|
||||
void AppInfo::SetRtgrp(const int grpNum)
|
||||
{
|
||||
this->m_rtgrp = grpNum;
|
||||
}
|
||||
|
||||
int AppInfo::GetRtgrp()
|
||||
{
|
||||
return m_rtgrp;
|
||||
}
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app_info_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_SERVICE("ueaServer-AppInfoMgr");
|
||||
|
||||
namespace {
|
||||
constexpr int INIT_VAL = -1;
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(AppInfoMgr);
|
||||
|
||||
void AppInfoMgr::OnForegroundChanged(const int pid, const std::string appName, const int rtGrp)
|
||||
{
|
||||
RME_LOGI("[OnForegroundChanged]:pid %{public}d, appname:%{public}s", pid, appName.c_str());
|
||||
std::map<int, std::shared_ptr<AppInfo>>::iterator it = mForegroundAppList.find(pid);
|
||||
if (it != mForegroundAppList.end()) {
|
||||
mForegroundAppList[pid]->SetAppName(appName);
|
||||
mForegroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND);
|
||||
} else {
|
||||
std::map<int, std::shared_ptr<AppInfo>>::iterator itB = mBackgroundAppList.find(pid);
|
||||
if (itB != mBackgroundAppList.end()) {
|
||||
mBackgroundAppList[pid]->SetAppName(appName);
|
||||
mBackgroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND);
|
||||
mForegroundAppList[pid] = mBackgroundAppList[pid];
|
||||
mBackgroundAppList.erase(pid);
|
||||
} else {
|
||||
auto appInfo = std::make_shared<AppInfo>(appName, pid, INIT_VAL, INIT_VAL, INIT_VAL, AppState::APP_FOREGROUND);
|
||||
mForegroundAppList[pid] = appInfo;
|
||||
}
|
||||
}
|
||||
mForegroundAppList[pid]->SetRtgrp(rtGrp);
|
||||
RME_LOGI("[OnForegroundChanged]rtgrp:%{public}d:", rtGrp);
|
||||
}
|
||||
|
||||
void AppInfoMgr::OnBackgroundChanged(const int pid, const std::string appName)
|
||||
{
|
||||
RME_LOGI("[OnBackgroundChanged]:pid:%{public}d, appName:%{public}s", pid, appName.c_str());
|
||||
std::map<int, std::shared_ptr<AppInfo>>::iterator it = mForegroundAppList.find(pid);
|
||||
if (it != mForegroundAppList.end()) {
|
||||
mForegroundAppList[pid]->SetAppState(AppState::APP_BACKGROUND);
|
||||
mBackgroundAppList[pid] = mForegroundAppList[pid];
|
||||
mForegroundAppList.erase(pid);
|
||||
} else {
|
||||
RME_LOGE("[OnBackgroundChanged]:unfind appName in foreground app when go to background!");
|
||||
}
|
||||
}
|
||||
|
||||
void AppInfoMgr::OnAppTerminateChanged(const int pid, const std::string appName)
|
||||
{
|
||||
RME_LOGI("[OnAppTerminatedChanged]: pid: %{public}d, appName: %{public}s:", pid, appName.c_str());
|
||||
mForegroundAppList.erase(pid);
|
||||
mBackgroundAppList.erase(pid);
|
||||
}
|
||||
|
||||
void AppInfoMgr::OnWindowFocus(const int pid, bool isFocus)
|
||||
{
|
||||
RME_LOGI("[OnAppFocus]: pid:%{public}d, isFocus:%{public}d", pid, isFocus);
|
||||
std::shared_ptr<AppInfo> appInfo = nullptr;
|
||||
if (mForegroundAppList.find(pid) != mForegroundAppList.end()) {
|
||||
appInfo = mForegroundAppList[pid];
|
||||
mForegroundAppList.erase(pid);
|
||||
} else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) {
|
||||
appInfo = mBackgroundAppList[pid];
|
||||
mBackgroundAppList.erase(pid);
|
||||
} else {
|
||||
appInfo = std::make_shared<AppInfo>("", pid, INIT_VAL, INIT_VAL, isFocus, AppState::APP_FOREGROUND);
|
||||
}
|
||||
appInfo->SetFocusState(isFocus);
|
||||
if (isFocus) {
|
||||
mForegroundAppList[pid] = appInfo;
|
||||
SetFocusApp(pid);
|
||||
} else {
|
||||
mBackgroundAppList[pid] = appInfo;
|
||||
}
|
||||
}
|
||||
|
||||
void AppInfoMgr::OnUiProcessStart(const int pid, const int tid)
|
||||
{
|
||||
RME_LOGI("[OnUiProcessStart]:pid:%{public}d, uitid:%{public}d.\n", pid, tid);
|
||||
std::shared_ptr<AppInfo> appInfo = nullptr;
|
||||
if (mForegroundAppList.find(pid) != mForegroundAppList.end()) {
|
||||
appInfo = mForegroundAppList[pid];
|
||||
mForegroundAppList.erase(pid);
|
||||
} else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) {
|
||||
appInfo = mBackgroundAppList[pid];
|
||||
mBackgroundAppList.erase(pid);
|
||||
} else {
|
||||
appInfo = std::make_shared<AppInfo>("", pid, tid, INIT_VAL, INIT_VAL, AppState::APP_UNKNOWN);
|
||||
}
|
||||
appInfo->SetUiTid(tid);
|
||||
}
|
||||
|
||||
bool AppInfoMgr::OnProcessDied(const int pid, const int tid)
|
||||
{
|
||||
bool deleted = false;
|
||||
if (mForegroundAppList.find(pid) != mForegroundAppList.end()) {
|
||||
mForegroundAppList.erase(pid);
|
||||
deleted = true;
|
||||
} else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) {
|
||||
mBackgroundAppList.erase(pid);
|
||||
}
|
||||
RME_LOGI("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d.\n", pid, tid, deleted);
|
||||
return deleted;
|
||||
}
|
||||
|
||||
void AppInfoMgr::OnRenderProcessStart(const int pid, const int tid)
|
||||
{
|
||||
RME_LOGI("[OnRenderProcessStart]:pid:%{public}d, tid:%{public}d.\n", pid, tid);
|
||||
std::shared_ptr<AppInfo> appInfo = nullptr;
|
||||
if (mForegroundAppList.find(pid) != mForegroundAppList.end()) {
|
||||
appInfo = mForegroundAppList[pid];
|
||||
mForegroundAppList.erase(pid);
|
||||
} else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) {
|
||||
appInfo = mBackgroundAppList[pid];
|
||||
mBackgroundAppList.erase(pid);
|
||||
} else {
|
||||
appInfo = std::make_shared<AppInfo>("", pid, INIT_VAL, tid, INIT_VAL, AppState::APP_UNKNOWN);
|
||||
}
|
||||
appInfo->SetUiTid(tid);
|
||||
}
|
||||
|
||||
void AppInfoMgr::SetFocusApp(const int pid)
|
||||
{
|
||||
mFocusApp = mForegroundAppList[pid];
|
||||
}
|
||||
|
||||
std::shared_ptr<AppInfo> AppInfoMgr::GetFocusApp() const
|
||||
{
|
||||
return mFocusApp;
|
||||
}
|
||||
|
||||
int AppInfoMgr::GetAppRtgrp(const int pid)
|
||||
{
|
||||
int rtGrp = -1;
|
||||
if (mForegroundAppList.count(pid) != 0) {
|
||||
rtGrp = mForegroundAppList[pid]->GetRtgrp();
|
||||
} else if (mBackgroundAppList.count(pid) != 0) {
|
||||
rtGrp = mBackgroundAppList[pid]->GetRtgrp();
|
||||
} else {
|
||||
RME_LOGI("[GetAppRtgrp]: do not have this pid, please add!");
|
||||
}
|
||||
return rtGrp;
|
||||
}
|
||||
|
||||
std::map<int, std::shared_ptr<AppInfo>> AppInfoMgr::GetForegroundApp() const
|
||||
{
|
||||
return mForegroundAppList;
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "intellisense_server.h"
|
||||
|
||||
#include <hilog/log.h>
|
||||
|
||||
#include "para_config.h"
|
||||
#include "rtg_msg_mgr.h"
|
||||
#include "rme_log_domain.h"
|
||||
#include "app_info_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
using namespace std;
|
||||
|
||||
static std::string configFilePath = "/system/etc/frame_aware_sched/hwrme.xml"; // need To check the exact file path.
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaServer-IntelliSenseServer");
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(IntelliSenseServer);
|
||||
|
||||
void IntelliSenseServer::Init()
|
||||
{
|
||||
RtgMsgMgr::GetInstance().Init();
|
||||
RME_LOGI("[Init]:Init rtg and readXml finish!");
|
||||
}
|
||||
|
||||
bool IntelliSenseServer::ReadXml()
|
||||
{
|
||||
if (!m_needReadXml) { // do this value really need?
|
||||
return false;
|
||||
}
|
||||
m_needReadXml = false;
|
||||
if (ParaConfig::IsXmlPrepared(configFilePath)) {
|
||||
m_generalPara = ParaConfig::GetGeneralConfig();
|
||||
m_subEventPara = ParaConfig::GetSubEventConfig();
|
||||
m_fpsList = ParaConfig::GetFpsList();
|
||||
m_renderTypeList = ParaConfig::GetRenderTypeList();
|
||||
if (!m_generalPara.empty() && !m_subEventPara.empty() && !m_fpsList.empty() && !m_renderTypeList.empty()) {
|
||||
m_readXmlSuc = true;
|
||||
RME_LOGI("[ReadXml]: read slide scene xml success!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
RME_LOGE("[ReadXml]: read slide scene xml not success!");
|
||||
return false;
|
||||
}
|
||||
|
||||
void IntelliSenseServer::ReportMessage(std::string appName, std::string processName, int pid, AppStateUpdateReason reason)
|
||||
{
|
||||
|
||||
int rtGrp = AppInfoMgr::GetInstance().GetAppRtgrp(pid);
|
||||
switch (reason) {
|
||||
case AppStateUpdateReason::APP_FOREGROUND:
|
||||
rtGrp = RtgMsgMgr::GetInstance().OnForeground(appName, pid);
|
||||
AppInfoMgr::GetInstance().OnForegroundChanged(pid, appName, rtGrp);
|
||||
RME_LOGI("[ReportMessage]: App_foreground!");
|
||||
break;
|
||||
case AppStateUpdateReason::APP_BACKGROUND:
|
||||
RtgMsgMgr::GetInstance().OnBackground(appName, pid, rtGrp);
|
||||
AppInfoMgr::GetInstance().OnBackgroundChanged(pid, appName);
|
||||
RME_LOGI("[ReportMessage]: App_background!");
|
||||
break;
|
||||
case AppStateUpdateReason::APP_TERMINATED:
|
||||
RtgMsgMgr::GetInstance().ProcessDied(pid, -1);
|
||||
AppInfoMgr::GetInstance().OnAppTerminateChanged(pid, appName);
|
||||
RME_LOGI("[ReportMessage]: App terminated!");
|
||||
break;
|
||||
default:
|
||||
RME_LOGI("[ReportMessage]: get unuse app state msg!");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void IntelliSenseServer::ReportWindowFocus(const int pid, int isFocus)
|
||||
{
|
||||
int rtGrp = AppInfoMgr::GetInstance().GetAppRtgrp(pid);
|
||||
switch (isFocus) {
|
||||
case static_cast<int>(WindowState::FOCUS_YES):
|
||||
{
|
||||
rtGrp = RtgMsgMgr::GetInstance().OnForeground("", pid);
|
||||
AppInfoMgr::GetInstance().OnForegroundChanged(pid, "", rtGrp);
|
||||
RME_LOGI("[ReportWindowFocus]: Focus yes!");
|
||||
}
|
||||
break;
|
||||
case static_cast<int>(WindowState::FOCUS_NO):
|
||||
{
|
||||
RtgMsgMgr::GetInstance().OnBackground("", pid, rtGrp);
|
||||
AppInfoMgr::GetInstance().OnBackgroundChanged(pid, "");
|
||||
RME_LOGI("[ReportWindowFocus]: Focus No!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
RME_LOGI("[ReportWindowFocus]:unknown msg!");
|
||||
|
||||
}
|
||||
AppInfoMgr::GetInstance().OnWindowFocus(pid, isFocus);
|
||||
RtgMsgMgr::GetInstance().FocusChanged(pid, isFocus);
|
||||
}
|
||||
|
||||
void IntelliSenseServer::ReportProcessInfo(const int pid, const int tid, ThreadState state)
|
||||
{
|
||||
switch (state) {
|
||||
case ThreadState::DIED:
|
||||
{
|
||||
int ret = AppInfoMgr::GetInstance().OnProcessDied(pid, tid);
|
||||
if (ret) {
|
||||
RtgMsgMgr::GetInstance().ProcessDied(pid, tid);
|
||||
RME_LOGI("process died, need to delete the rtgrp.");
|
||||
}
|
||||
RME_LOGI("process died, do not need to delete the rtgrp:pid:%{public}d, tid: %{public}d, threadstate: %{public}d", pid, tid, static_cast<int>(state));
|
||||
}
|
||||
break;
|
||||
case ThreadState::CREATE:
|
||||
RME_LOGI("process create, pid: %{public}d, tid: %{public}d, threadstate: %{public}d", pid, tid, static_cast<int>(state));
|
||||
break;
|
||||
default:
|
||||
RME_LOGI("unknown state : %{public}d", static_cast<int>(state));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void IntelliSenseServer::SetPara(const int32_t currentFps, const int32_t currentRenderType)
|
||||
{
|
||||
RME_LOGI("[SetPara]:ioctl SetPara!\n");
|
||||
std::string key = std::to_string(currentRenderType) + " " + std::to_string(currentFps);
|
||||
map<std::string, int> tempMap = m_subEventPara[key];
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace RME
|
||||
} // namesapce OHOS
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "para_config.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
namespace {
|
||||
constexpr int FPS_MAX_VALUE = 120;
|
||||
constexpr int RENDER_TYPE_MAX_VALUE = 2;
|
||||
}
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaServer-ParaConfig");
|
||||
|
||||
std::map<std::string, std::string> ParaConfig::m_generalConfig;
|
||||
std::map<std::string, std::map<std::string, int>> ParaConfig::m_subEventConfig;
|
||||
std::vector<int> ParaConfig::m_fpsList;
|
||||
std::vector<int> ParaConfig::m_renderTypeList;
|
||||
|
||||
bool ParaConfig::IsXmlPrepared(const std::string& filePath)
|
||||
{
|
||||
RME_LOGI("[IsXmlPrepared]:begin!");
|
||||
xmlDocPtr docPtr;
|
||||
docPtr = xmlReadFile(filePath.c_str(), nullptr, XML_PARSE_NOBLANKS);
|
||||
RME_LOGI("[IsXmlPrepared]:filePath:%{public}s", filePath.c_str());
|
||||
if (docPtr == nullptr) {
|
||||
RME_LOGE("[IsXmlPrepared]:load xml error!");
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlNodePtr rootPtr;
|
||||
rootPtr = xmlDocGetRootElement(docPtr);
|
||||
if (rootPtr == nullptr || rootPtr->name == nullptr) {
|
||||
RME_LOGE("[IsXmlPrepared]: get root element failed!");
|
||||
xmlFreeDoc(docPtr);
|
||||
return false;
|
||||
}
|
||||
for (xmlNodePtr curNodePtr = rootPtr->xmlChildrenNode; curNodePtr != nullptr; curNodePtr = curNodePtr->next) {
|
||||
if (IsValidNode(*curNodePtr)) {
|
||||
RME_LOGE("[IsXmlPrepared]: invalid node!");
|
||||
continue;
|
||||
}
|
||||
auto nodeName = curNodePtr->name; // char* to string
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("log_open")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("enable")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("SOC")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("frame_sched_reset_count"))) {
|
||||
ReadConfigInfo(curNodePtr); // is this transform ok?
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("fps_list"))) {
|
||||
ReadFpsConfig(curNodePtr);
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("render_type"))) {
|
||||
ReadFpsConfig(curNodePtr);
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("framedetect"))) {
|
||||
ReadFrameConfig(curNodePtr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
xmlFreeDoc(docPtr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParaConfig::IsValidNode(const xmlNode& currNode)
|
||||
{
|
||||
if (currNode.name == nullptr || currNode.type == XML_COMMENT_NODE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ParaConfig::ReadConfigInfo(const xmlNodePtr& root)
|
||||
{
|
||||
xmlChar* context = nullptr;
|
||||
context = xmlNodeGetContent(root);
|
||||
if (context == nullptr) {
|
||||
RME_LOGE("[GetConfigInfo]:read xml node error: nodeName:(%{public}s)", root->name);
|
||||
return;
|
||||
}
|
||||
std::string nodeName = reinterpret_cast<const char *>(root->name);
|
||||
m_generalConfig[nodeName] = std::string(reinterpret_cast<const char*>(context));
|
||||
xmlFree(context);
|
||||
}
|
||||
|
||||
void ParaConfig::ReadFpsConfig(const xmlNodePtr& root)
|
||||
{
|
||||
xmlChar* context = xmlNodeGetContent(root);
|
||||
if (context == nullptr) {
|
||||
RME_LOGE("[GetFpsConfig]: fps read failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
SplitString(std::string(reinterpret_cast<const char*>(context)), " ", m_fpsList, FPS_MAX_VALUE, "fpsList");
|
||||
xmlFree(context);
|
||||
}
|
||||
|
||||
void ParaConfig::ReadRenderType(const xmlNodePtr& root)
|
||||
{
|
||||
xmlChar* context = xmlNodeGetContent(root);
|
||||
if (context == nullptr) {
|
||||
RME_LOGE("[GetRenderType]: renderType read failed!");
|
||||
return;
|
||||
}
|
||||
SplitString(std::string(reinterpret_cast<const char*>(context)), " ", m_renderTypeList, RENDER_TYPE_MAX_VALUE, "renderType");
|
||||
xmlFree(context);
|
||||
}
|
||||
|
||||
void ParaConfig::SplitString(const std::string& context, const std::string& character,std::vector<int> &mList,
|
||||
const int maxVal, const std::string& attrName)
|
||||
{
|
||||
if (context == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string toSplitStr = context + character;
|
||||
size_t pos = toSplitStr.find(character);
|
||||
|
||||
while (pos != toSplitStr.npos) {
|
||||
int curVal = atoi(toSplitStr.substr(0, pos).c_str());
|
||||
if (curVal <= 0 && curVal > maxVal) {
|
||||
RME_LOGI("[SplitString]:get data error! attr name:%{public}s", attrName.c_str());
|
||||
return;
|
||||
}
|
||||
mList.push_back(curVal);
|
||||
|
||||
toSplitStr = toSplitStr.substr(pos + 1,toSplitStr.size());
|
||||
pos = toSplitStr.find(character);
|
||||
}
|
||||
RME_LOGI("[SplitString]:get data success!attr name:%{public}s", attrName.c_str());
|
||||
}
|
||||
|
||||
void ParaConfig::ReadFrameConfig(const xmlNodePtr& root)
|
||||
{
|
||||
// TODO: need abnormal process! what if the xml has problem when traversal?
|
||||
for (xmlNodePtr curNode = root->xmlChildrenNode; curNode != nullptr; curNode = curNode->next) {
|
||||
if (IsValidNode(*curNode)) {
|
||||
RME_LOGE("[IsXmlPrepared]: invalid node!");
|
||||
continue;
|
||||
}
|
||||
std::string key1 = "";
|
||||
std::string key2 = "";
|
||||
ReadAttr(curNode, "renderType", key1);
|
||||
ReadAttr(curNode, "fps_list", key2);
|
||||
std::string key = key1 + " " + key2;
|
||||
|
||||
std::map<std::string, int> frameConfigTmp;
|
||||
xmlNodePtr curSubNode = curNode->xmlChildrenNode;
|
||||
for (; curSubNode != nullptr; curSubNode = curSubNode->next) {
|
||||
std::string nodeName = reinterpret_cast<const char*>(curSubNode->name); // char* to string
|
||||
xmlChar* context = xmlNodeGetContent(curSubNode);
|
||||
if (context == nullptr) { // if one config wrong then this config dilscard.
|
||||
RME_LOGE("[GetFrameConfig]: frame config get error! nodeName:%{public}s, key:%{public}s", nodeName.c_str(), key.c_str());
|
||||
xmlFree(context);
|
||||
break;
|
||||
}
|
||||
frameConfigTmp[nodeName] = atoi(reinterpret_cast<const char*>(context));
|
||||
RME_LOGI("[GetFrameConfig]: nodeName:%{public}s, val:%{public}s", nodeName.c_str(), reinterpret_cast<const char*>(context));
|
||||
xmlFree(context);
|
||||
}
|
||||
m_subEventConfig[key] = frameConfigTmp;
|
||||
}
|
||||
RME_LOGI("[GetFrameConfig]:read frameconfig success!");
|
||||
}
|
||||
|
||||
void ParaConfig::ReadAttr(xmlNodePtr& root, const std::string& attrName, std::string& res)
|
||||
{
|
||||
xmlChar* attr = nullptr;
|
||||
attr = xmlGetProp(root, reinterpret_cast<const xmlChar*>(attrName.c_str()));
|
||||
if (attr == nullptr) {
|
||||
RME_LOGE("[ReadAttr]: attr <%{public}s> read error!", attrName.c_str());
|
||||
}
|
||||
const char* tmp = reinterpret_cast<const char*>(attr); // char* to string
|
||||
res = tmp;
|
||||
xmlFree(attr);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> ParaConfig::GetGeneralConfig()
|
||||
{
|
||||
return m_generalConfig;
|
||||
}
|
||||
|
||||
std::map<std::string,std::map<std::string, int>> ParaConfig::GetSubEventConfig()
|
||||
{
|
||||
return m_subEventConfig;
|
||||
}
|
||||
|
||||
std::vector<int> ParaConfig::GetFpsList()
|
||||
{
|
||||
return m_fpsList;
|
||||
}
|
||||
|
||||
std::vector<int> ParaConfig::GetRenderTypeList()
|
||||
{
|
||||
return m_renderTypeList;
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "rtg_msg_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
namespace {
|
||||
const int PRIO_TYPE = 0;
|
||||
const int RT_NUM = 0;
|
||||
}
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaServer-RtgMsgMgr");
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(RtgMsgMgr);
|
||||
|
||||
void RtgMsgMgr::Init()
|
||||
{
|
||||
int ret = EnableRtg(true);
|
||||
if (ret < 0) {
|
||||
RME_LOGE("[Init]: enable rtg failed!");
|
||||
}
|
||||
}
|
||||
|
||||
int RtgMsgMgr::OnForeground(const std::string appName, const int pid)
|
||||
{ // for multiwindow
|
||||
RME_LOGI("[OnForeground]:pid:%{public}d:", pid);
|
||||
int rtGrp = CreateNewRtgGrp(PRIO_TYPE, RT_NUM);
|
||||
RME_LOGI("[OnForeground]: createNewRtgGroup begin! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid);
|
||||
if (rtGrp < 0) {
|
||||
RME_LOGI("[OnForeground]: createNewRtgGroup failed! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid);
|
||||
rtGrp = -1;
|
||||
return rtGrp;
|
||||
}
|
||||
AddThreadToRtg(pid, rtGrp); // add ui thread
|
||||
return rtGrp;
|
||||
}
|
||||
|
||||
void RtgMsgMgr::OnBackground(const std::string appName, const int pid, const int grpId)
|
||||
{
|
||||
RME_LOGI("[OnBackground]:pid:%{public}d", pid);
|
||||
if (grpId <= 0) {
|
||||
RME_LOGI("[OnBackground]:do not find grpid, pid:%{public}d, grpId:%{public}d", pid, grpId);
|
||||
return;
|
||||
}
|
||||
DestroyRtgGrp(grpId);
|
||||
}
|
||||
|
||||
void RtgMsgMgr::ProcessStart(const int tid, const int grpId)
|
||||
{
|
||||
if (grpId <= 0) {
|
||||
RME_LOGI("[ProcessStart]:do not find grpid, tid:%{public}d, grpId:%{public}d", tid, grpId);
|
||||
return;
|
||||
}
|
||||
AddThreadToRtg(tid, grpId);
|
||||
}
|
||||
|
||||
void RtgMsgMgr::ProcessDied(const int pid, const int tid)
|
||||
{
|
||||
int removeTid = -1;
|
||||
if (tid == -1) {
|
||||
removeTid = pid;
|
||||
} else {
|
||||
removeTid = tid;
|
||||
}
|
||||
int ret = RemoveRtgThread(removeTid);
|
||||
if (ret < 0) {
|
||||
RME_LOGI("[ProcessDied]: removeRtgGroup failed!pid:%{public}d, tid:%{public}d", pid, tid);
|
||||
}
|
||||
RME_LOGI("[ProcessDied]: removeRtgGroup success! pid:%{public}d, tid:%{public}d:tid", pid, tid);
|
||||
}
|
||||
|
||||
void RtgMsgMgr::FpsChanged()
|
||||
{
|
||||
RME_LOGI("[FpsChanged]: need to change fps for rtggrp!");
|
||||
}
|
||||
|
||||
void RtgMsgMgr::FocusChanged(const int pid, bool isFocus)
|
||||
{
|
||||
RME_LOGI("[FocusChanged]: need to change prio for rtggrp");
|
||||
}
|
||||
|
||||
} // RME
|
||||
} // OHOS
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/resourceschedule/frame_aware_sched/frame_aware_sched.gni")
|
||||
|
||||
group("innerkits_target") {
|
||||
deps = [
|
||||
"frameintf:frame_ui_intf",
|
||||
"frameintf:frame_msg_intf",
|
||||
"frameintf:rtg_interface",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/resourceschedule/plugins/frame_aware_sched/frameaware.gni")
|
||||
|
||||
|
||||
config("frame_ui_intf_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"${innerkits_path}/frameintf",
|
||||
"${frame_aware_path}/common/include",
|
||||
"${framework_path}/frame_aware_collector/include",
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhitrace/include",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("frame_ui_intf") {
|
||||
sources = [
|
||||
"frame_ui_intf.cpp",
|
||||
"${framework_path}/frame_aware_collector/src/frame_msg_mgr.cpp",
|
||||
"${framework_path}/frame_aware_collector/src/frame_window_mgr.cpp",
|
||||
"${framework_path}/frame_aware_collector/src/rme_core_sched.cpp",
|
||||
"${framework_path}/frame_aware_collector/src/rme_scene_sched.cpp",
|
||||
"${frame_aware_path}/interfaces/innerkits/frameintf/rtg_interface.cpp",
|
||||
]
|
||||
|
||||
configs = [ ":frame_ui_intf_config" ]
|
||||
|
||||
deps = [
|
||||
"//utils/native/base:utils",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"bytrace_standard:bytrace_core",
|
||||
"dsoftbus_standard:softbus_client",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
subsystem_name = "resourceschedule"
|
||||
part_name = "frame_aware_sched"
|
||||
}
|
||||
|
||||
config("frame_msg_intf_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"${innerkits_path}/frameintf",
|
||||
"//third_party/libxml2/include",
|
||||
"${framework_path}/frame_aware_policy/include",
|
||||
"${frame_aware_path}/common/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhitrace/include",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("frame_msg_intf") {
|
||||
sources = [
|
||||
"frame_msg_intf.cpp",
|
||||
"${framework_path}/frame_aware_policy/src/intellisense_server.cpp",
|
||||
"${framework_path}/frame_aware_policy/src/app_info.cpp",
|
||||
"${framework_path}/frame_aware_policy/src/app_info_mgr.cpp",
|
||||
"${framework_path}/frame_aware_policy/src/para_config.cpp",
|
||||
"${framework_path}/frame_aware_policy/src/rtg_msg_mgr.cpp",
|
||||
"${frame_aware_path}/interfaces/innerkits/frameintf/rtg_interface.cpp",
|
||||
]
|
||||
|
||||
configs = [ ":frame_msg_intf_config" ]
|
||||
|
||||
deps = [
|
||||
"//third_party/libxml2:xml2",
|
||||
"//utils/native/base:utils",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bytrace_standard:bytrace_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"dsoftbus_standard:softbus_client",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
subsystem_name = "resourceschedule"
|
||||
part_name = "frame_aware_sched"
|
||||
}
|
||||
|
||||
|
||||
ohos_shared_library("rtg_interface") {
|
||||
sources = [
|
||||
"rtg_interface.cpp"
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"${frame_aware_path}/common/include",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
install_enable = true
|
||||
part_name = "frame_aware_sched"
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frame_msg_intf.h"
|
||||
#include "intellisense_server.h"
|
||||
#include "event_handler.h"
|
||||
#include "rme_log_domain.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaServer-FrameMsgIntf");
|
||||
|
||||
FrameMsgIntf& FrameMsgIntf::GetInstance()
|
||||
{
|
||||
static FrameMsgIntf instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool FrameMsgIntf::Init()
|
||||
{
|
||||
RME_LOGI("init begin!");
|
||||
if (!GetThreadHandler()) {
|
||||
return false;
|
||||
}
|
||||
threadHandler_->PostTask([] {
|
||||
IntelliSenseServer::GetInstance().Init();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FrameMsgIntf::GetThreadHandler()
|
||||
{
|
||||
if (threadHandler_ == nullptr) {
|
||||
threadHandler_ = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::Create());
|
||||
if (threadHandler_ == nullptr) {
|
||||
RME_LOGI("failed to create thread handler!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
RME_LOGI("Init process success!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FrameMsgIntf::ReportAppInfo(std::string appName, std::string processName, int pid, AppStateUpdateReason reason)
|
||||
{
|
||||
if (threadHandler_ == nullptr) {
|
||||
RME_LOGI("[ReportAppInfo]:threandHandler none!");
|
||||
return;
|
||||
}
|
||||
threadHandler_->PostTask([appName, processName, pid, reason] {
|
||||
IntelliSenseServer::GetInstance().ReportMessage(appName, processName, pid, reason);
|
||||
});
|
||||
}
|
||||
|
||||
void FrameMsgIntf::ReportWindowFocus(const int pid, const int isFocus)
|
||||
{
|
||||
if (threadHandler_ == nullptr) {
|
||||
RME_LOGI("[ReportWindowFocus]:threandHandler none!");
|
||||
return;
|
||||
}
|
||||
threadHandler_->PostTask([pid, isFocus] {
|
||||
IntelliSenseServer::GetInstance().ReportWindowFocus(pid, isFocus);
|
||||
});
|
||||
}
|
||||
|
||||
void FrameMsgIntf::ReportProcessInfo(const int pid, const int tid, ThreadState state)
|
||||
{
|
||||
|
||||
if (threadHandler_ == nullptr) {
|
||||
RME_LOGI("[ReportWindowFocus]:threandHandler none!");
|
||||
return;
|
||||
}
|
||||
threadHandler_->PostTask([pid, tid, state] {
|
||||
IntelliSenseServer::GetInstance().ReportProcessInfo(pid, tid, state);
|
||||
});
|
||||
}
|
||||
|
||||
void FrameMsgIntf::Stop()
|
||||
{
|
||||
if (threadHandler_ != nullptr) {
|
||||
threadHandler_->RemoveAllEvents();
|
||||
threadHandler_ = nullptr;
|
||||
}
|
||||
RME_LOGI("stop eventRunner success!");
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_MSG_INTF_H
|
||||
#define FRAME_MSG_INTF_H
|
||||
|
||||
#include "rme_constants.h"
|
||||
#include "single_instance.h"
|
||||
#include "event_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class FrameMsgIntf {
|
||||
public:
|
||||
static FrameMsgIntf& GetInstance();
|
||||
bool Init();
|
||||
bool GetThreadHandler();
|
||||
void ReportAppInfo(std::string appName, std::string processName, int pid, AppStateUpdateReason reason);
|
||||
void ReportWindowFocus(const int pid, const int isFocus);
|
||||
void ReportProcessInfo(const int pid, const int tid, ThreadState state);
|
||||
void Stop();
|
||||
|
||||
protected:
|
||||
FrameMsgIntf() = default;
|
||||
virtual ~FrameMsgIntf() = default;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> threadHandler_;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(FrameMsgIntf);
|
||||
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frame_ui_intf.h"
|
||||
|
||||
#include "frame_info_const.h"
|
||||
#include "rme_constants.h"
|
||||
#include "frame_msg_mgr.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("ueaCleint-FrameUiIntf");
|
||||
|
||||
//TO DO: need to check the init logic.
|
||||
|
||||
FrameUiIntf& FrameUiIntf::GetInstance()
|
||||
{
|
||||
static FrameUiIntf instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void FrameUiIntf::Init()
|
||||
{
|
||||
if (inited) {
|
||||
return;
|
||||
}
|
||||
int ret = FrameMsgMgr::GetInstance().Init();
|
||||
if (!ret) {
|
||||
inited = false;
|
||||
} else {
|
||||
inited = true;
|
||||
}
|
||||
RME_LOGI("[Init]:ret:%{public}d, inited:%{public}d", ret, inited);
|
||||
}
|
||||
|
||||
int FrameUiIntf::GetSenseSchedEnable()
|
||||
{
|
||||
if (!inited) {
|
||||
return static_cast<int>(ErrorCode::FAIL);
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::EVENT_RTG_ENABLE, EventState::ENABLE);
|
||||
return static_cast<int>(ErrorCode::SUCC);
|
||||
}
|
||||
|
||||
void FrameUiIntf::BeginFlushAnimation()
|
||||
{
|
||||
|
||||
RME_LOGI("[BeginFlushAnimation]:start");
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_ANIMATION, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::EndFlushAnimation()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_EXIT);
|
||||
}
|
||||
|
||||
void FrameUiIntf::BeginFlushBuild()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_ENTER);
|
||||
RME_LOGI("[BeginFlushBuild]:success");
|
||||
}
|
||||
|
||||
void FrameUiIntf::EndFlushBuild()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_EXIT);
|
||||
}
|
||||
|
||||
void FrameUiIntf::BeginFlushLayout()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_LAYOUT, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::EndFlushLayout()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_LAYOUT, EventState::EVENT_EXIT);
|
||||
}
|
||||
|
||||
void FrameUiIntf::BeginFlushRender()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::EndFlushRender()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER, EventState::EVENT_EXIT);
|
||||
}
|
||||
|
||||
void FrameUiIntf::BeginProcessPostFlush()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::PROCESS_POST_FLUSH, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::ProcessCommandsStart()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::PROCESS_COMMANDS, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::AnimateStart()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::ANIMATE, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::RenderStart()
|
||||
{
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::RENDER, EventState::EVENT_ENTER);
|
||||
}
|
||||
|
||||
void FrameUiIntf::SendCommandsStart()
|
||||
{
|
||||
RME_LOGI("[SendCommandsStart]:start");
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::SEND_COMMANDS, EventState::EVENT_ENTER);
|
||||
RME_LOGI("[SendCommandsStart]:success");
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_UI_INTF_H
|
||||
#define FRAME_UI_INTF_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
class FrameUiIntf {
|
||||
public:
|
||||
static FrameUiIntf& GetInstance();
|
||||
void Init();
|
||||
int GetSenseSchedEnable();
|
||||
void BeginFlushAnimation();
|
||||
void EndFlushAnimation();
|
||||
|
||||
void BeginFlushBuild();
|
||||
void EndFlushBuild();
|
||||
void BeginFlushLayout();
|
||||
void EndFlushLayout();
|
||||
|
||||
void BeginFlushRender();
|
||||
void EndFlushRender();
|
||||
|
||||
void BeginProcessPostFlush();
|
||||
void ProcessCommandsStart();
|
||||
void AnimateStart();
|
||||
void RenderStart();
|
||||
void SendCommandsStart();
|
||||
|
||||
bool inited = false;
|
||||
};
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -0,0 +1,491 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "rtg_interface.h"
|
||||
#include <linux/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "rme_log_domain.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
|
||||
DEFINE_RMELOG_INTELLISENSE("rtg_interface");
|
||||
|
||||
#define MAX_LENGTH 100
|
||||
#define MAX_STR_LEN 100
|
||||
#define MAX_PATH_LEN 100
|
||||
|
||||
#define RTG_SCHED_IPC_MAGIC 0xAB
|
||||
|
||||
#define CMD_ID_SET_ENABLE \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_ENABLE, struct rtg_enable_data)
|
||||
#define CMD_ID_SET_RTG \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG, struct rtg_str_data)
|
||||
#define CMD_ID_SET_CONFIG \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_CONFIG, struct rtg_str_data)
|
||||
#define CMD_ID_SET_RTG_ATTR \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG_ATTR, struct rtg_str_data)
|
||||
#define CMD_ID_BEGIN_FRAME_FREQ \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, BEGIN_FRAME_FREQ, struct proc_state_data)
|
||||
#define CMD_ID_END_FRAME_FREQ \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, END_FRAME_FREQ, struct proc_state_data)
|
||||
#define CMD_ID_END_SCENE \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, END_SCENE, struct proc_state_data)
|
||||
#define CMD_ID_SET_MIN_UTIL \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_MIN_UTIL, struct proc_state_data)
|
||||
#define CMD_ID_SET_MARGIN \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SET_MARGIN, struct proc_state_data)
|
||||
#define CMD_ID_LIST_RTG \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG, struct rtg_info)
|
||||
#define CMD_ID_LIST_RTG_THREAD \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG_THREAD, struct rtg_grp_data)
|
||||
#define CMD_ID_SEARCH_RTG \
|
||||
_IOWR(RTG_SCHED_IPC_MAGIC, SEARCH_RTG, struct proc_state_data)
|
||||
|
||||
int BasicOpenRtgNode(int pid)
|
||||
{
|
||||
char fileName[MAX_PATH_LEN] = {0};
|
||||
snprintf(fileName, MAX_PATH_LEN, "/proc/%d/rtg", pid);
|
||||
int fd = open(fileName, O_RDWR);
|
||||
if (fd < 0) {
|
||||
RME_LOGE("Open fail, errno = %{public}d(%{public}s), dev = %{public}s", errno, strerror(errno), fileName);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
enum rtg_type {
|
||||
VIP = 0,
|
||||
TOP_TASK_KEY,
|
||||
TOP_TASK,
|
||||
NORMAL_TASK,
|
||||
RTG_TYPE_MAX,
|
||||
};
|
||||
|
||||
int EnableRtg(bool flag)
|
||||
{
|
||||
struct rtg_enable_data enableData;
|
||||
char configStr[] = "load_freq_switch:1;sched_cycle:1";
|
||||
int pid = getpid();
|
||||
|
||||
enableData.enable = flag;
|
||||
enableData.len = sizeof(configStr);
|
||||
enableData.data = configStr;
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
if (ioctl(fd, CMD_ID_SET_ENABLE, &enableData)) {
|
||||
RME_LOGE("set rtg config enable failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set rtg config enable success.");
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
};
|
||||
|
||||
int CreateNewRtgGrp(int prioType, int rtNum)
|
||||
{
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
if ((prioType > 0) && (prioType < RTG_TYPE_MAX)) {
|
||||
grp_data.prio_type = prioType;
|
||||
}
|
||||
if (rtNum > 0) {
|
||||
grp_data.rt_cnt = rtNum;
|
||||
}
|
||||
grp_data.rtg_cmd = CMD_CREATE_RTG_GRP;
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("create rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("create rtg grp success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AddThreadToRtg(int tid, int grpId)
|
||||
{
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int fd = BasicOpenRtgNode(tid);
|
||||
if (fd < 0) {
|
||||
RME_LOGE("open node failed.");
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
grp_data.tid_num = 1;
|
||||
grp_data.tids[0] = tid;
|
||||
grp_data.grp_id = grpId;
|
||||
grp_data.rtg_cmd = CMD_ADD_RTG_THREAD;
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("add rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("add rtg grp success");
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AddThreadsToRtg(vector<int> tids, int grpId)
|
||||
{
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
int num = tids.size();
|
||||
if (num > MAX_TID_NUM) {
|
||||
return -1;
|
||||
}
|
||||
grp_data.tid_num = num;
|
||||
grp_data.grp_id = grpId;
|
||||
grp_data.rtg_cmd = CMD_ADD_RTG_THREAD;
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (tids[i] < 0) {
|
||||
return -1;
|
||||
}
|
||||
grp_data.tids[i] = tids[i];
|
||||
}
|
||||
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("add rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("add rtg grp success");
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
};
|
||||
|
||||
int RemoveRtgThread(int tid){
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int fd = BasicOpenRtgNode(tid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
grp_data.tid_num = 1;
|
||||
grp_data.tids[0] = tid;
|
||||
grp_data.rtg_cmd = CMD_REMOVE_RTG_THREAD;
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("remove grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("remove grp success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
};
|
||||
|
||||
int ClearRtgGrp(int GrpId){
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
grp_data.rtg_cmd = CMD_CLEAR_RTG_GRP;
|
||||
grp_data.grp_id = GrpId;
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("clear rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("clear rtg grp success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
};
|
||||
|
||||
int DestroyRtgGrp(int GrpId){
|
||||
struct rtg_grp_data grp_data;
|
||||
int ret;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
grp_data.rtg_cmd = CMD_DESTROY_RTG_GRP;
|
||||
grp_data.grp_id = GrpId;
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("create rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("create rtg grp success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
int SetMaxVipRtgs(int rtframe){
|
||||
int ret = 0;
|
||||
char str_data[MAX_STR_LEN] = {};
|
||||
snprintf(str_data, MAX_STR_LEN, "rtframe:%d", rtframe);
|
||||
struct rtg_str_data strData;
|
||||
strData.len = strlen(str_data);
|
||||
strData.data = str_data;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_SET_CONFIG, &strData);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set single config failed, ret = %{public}d", ret);
|
||||
} else {
|
||||
RME_LOGI("set single config success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType){
|
||||
int ret = 0;
|
||||
char str_data[MAX_LENGTH] = {};
|
||||
snprintf(str_data, MAX_LENGTH, "rtgId:%d;rate:%d;type:%d", rtgId, rate, rtgType);
|
||||
struct rtg_str_data strData;
|
||||
strData.len = strlen(str_data);
|
||||
strData.data = str_data;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_SET_RTG_ATTR, &strData);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set rtg attr failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set rtg attr success, get rtg id %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int BeginFrameFreq(int grpId, int stateParam){
|
||||
int ret = 0;
|
||||
struct proc_state_data state_data;
|
||||
state_data.grp_id = grpId;
|
||||
state_data.state_param = stateParam;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_BEGIN_FRAME_FREQ, &state_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set BeginFrameFreq failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set BeginFrameFreq success, get ret %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EndFrameFreq(int grpId, int stateParam){
|
||||
int ret = 0;
|
||||
struct proc_state_data state_data;
|
||||
state_data.grp_id = grpId;
|
||||
state_data.state_param = stateParam;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_END_FRAME_FREQ, &state_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set EndFrameFreq failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set EndFrameFreq success, get ret %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EndScene(int rtgId){
|
||||
int ret = 0;
|
||||
struct proc_state_data state_data;
|
||||
state_data.grp_id = rtgId;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_END_SCENE, &state_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set EndScene failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set EndScene success, get ret %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SetMinUtil(int grpId, int stateParam){
|
||||
int ret = 0;
|
||||
struct proc_state_data state_data;
|
||||
state_data.grp_id = grpId;
|
||||
state_data.state_param = stateParam;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_SET_MIN_UTIL, &state_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set min util failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set min util success, get ret %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SetMargin(int grpId, int stateParam) {
|
||||
int ret = 0;
|
||||
struct proc_state_data state_data;
|
||||
state_data.grp_id = grpId;
|
||||
state_data.state_param = stateParam;
|
||||
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
ret = ioctl(fd, CMD_ID_SET_MARGIN, &state_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("set margin failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("set margin success, get ret %{public}d.", ret);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ListRtgGroup(vector<int> *rs)
|
||||
{
|
||||
int ret = 0;
|
||||
struct rtg_info rtg_info;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
if (!rs) {
|
||||
return -1;
|
||||
}
|
||||
memset(&rtg_info, 0, sizeof(struct rtg_info));
|
||||
ret = ioctl(fd, CMD_ID_LIST_RTG, &rtg_info);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("list rtg group failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("list rtg group success with num %{public}d", rtg_info.rtg_num);
|
||||
rs->clear();
|
||||
for (int i = 0; i < rtg_info.rtg_num; i++) {
|
||||
rs->push_back(rtg_info.rtgs[i]);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ListRtgThread(int grpId, vector<int> *rs)
|
||||
{
|
||||
int ret = 0;
|
||||
struct rtg_grp_data grp_data;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
if (!rs) {
|
||||
return -1;
|
||||
}
|
||||
memset(&grp_data, 0, sizeof(struct rtg_grp_data));
|
||||
grp_data.grp_id = grpId;
|
||||
ret = ioctl(fd, CMD_ID_LIST_RTG_THREAD, &grp_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("list rtg thread failed, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("list rtg thread success with tid num %{public}d", grp_data.tid_num);
|
||||
rs->clear();
|
||||
for (int i = 0; i < grp_data.tid_num; i++) {
|
||||
rs->push_back(grp_data.tids[i]);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SearchRtgForTid(int stateParam)
|
||||
{
|
||||
int ret = 0;
|
||||
struct proc_state_data search_data;
|
||||
int pid = getpid();
|
||||
int fd = BasicOpenRtgNode(pid);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
if (stateParam <= 0) {
|
||||
RME_LOGI("Search tid err: invalid tid.");
|
||||
return -1;
|
||||
}
|
||||
memset(&search_data, 0, sizeof(struct proc_state_data));
|
||||
search_data.state_param = stateParam;
|
||||
ret = ioctl(fd, CMD_ID_SEARCH_RTG, &search_data);
|
||||
if ( ret < 0) {
|
||||
RME_LOGE("Search tid fail, errno = %{public}d (%{public}s)", errno, strerror(errno));
|
||||
} else {
|
||||
RME_LOGI("Search tid %{public}d success with rtg_grp %{public}d", stateParam, ret);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
ohos_prebuilt_etc("frame_aware_sched_config") {
|
||||
source = "hwrme.xml"
|
||||
subsystem_name = "resourceschedule"
|
||||
part_name = "frame_aware_sched"
|
||||
module_install_dir = "etc/frame_aware_sched"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<rme_intellisense version="3.0">
|
||||
<version>1.0</version>
|
||||
<log_open>-1</log_open>
|
||||
<enable>1</enable>
|
||||
<SOC>990</SOC>
|
||||
<frame_sched_reset_count>1</frame_sched_reset_count>
|
||||
<fps_list>60 90</fps_list>
|
||||
<render_type>0 1 2</render_type>
|
||||
<framedetect>
|
||||
<frameconfig render_type ="0" fps_list="60" size="24">
|
||||
<default_util>600</default_util>
|
||||
</frameconfig>
|
||||
</framedetect>
|
||||
</rme_intellisense>
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos_var.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/resourceschedule/plugins/frame_aware_sched/frameaware.gni")
|
||||
|
||||
module_output_path = "frameawareschedtest/"
|
||||
|
||||
frame_aware_sched_configs = [ "${innerkits_path}/frameintf:frame_msg_intf_config" ]
|
||||
|
||||
frame_aware_sched_deps = [
|
||||
"//utils/native/base:utils",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"${innerkits_path}/frameintf:frame_ui_intf",
|
||||
"${innerkits_path}/frameintf:frame_msg_intf",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
]
|
||||
|
||||
frame_aware_sched_external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
frame_aware_sched_public_deps = [ "//third_party/googletest:gtest_main" ]
|
||||
|
||||
|
||||
ohos_unittest("frame_ui_intf_test") {
|
||||
module_out_path = module_output_path
|
||||
configs = frame_aware_sched_configs
|
||||
|
||||
sources = [ "unittest/phone/frame_ui_intf_test.cpp" ]
|
||||
|
||||
deps = frame_aware_sched_deps
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps = frame_aware_sched_external_deps
|
||||
public_deps = frame_aware_sched_public_deps
|
||||
}
|
||||
part_name = "frame_aware_sched"
|
||||
subsystem_name = "resourceschedule"
|
||||
|
||||
}
|
||||
|
||||
ohos_unittest("frame_msg_intf_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [ "unittest/phone/frame_msg_intf_test.cpp" ]
|
||||
|
||||
configs = frame_aware_sched_configs
|
||||
|
||||
deps = frame_aware_sched_deps
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps = frame_aware_sched_external_deps
|
||||
public_deps = frame_aware_sched_public_deps
|
||||
}
|
||||
|
||||
part_name = "frame_aware_sched"
|
||||
subsystem_name = "resourceschedule"
|
||||
}
|
||||
|
||||
ohos_unittest("rtg_interface_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [ "unittest/phone/rtg_interface_test.cpp" ]
|
||||
|
||||
include_dirs = [
|
||||
"${frame_aware_path}/common/include",
|
||||
]
|
||||
|
||||
deps = frame_aware_sched_deps
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps = frame_aware_sched_external_deps
|
||||
public_deps = frame_aware_sched_public_deps
|
||||
}
|
||||
|
||||
part_name = "frame_aware_sched"
|
||||
subsystem_name = "resourceschedule"
|
||||
|
||||
}
|
||||
|
||||
group("frame_unittest") {
|
||||
testonly = true
|
||||
deps = [
|
||||
":frame_msg_intf_test",
|
||||
":rtg_interface_test",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "frame_msg_intf.h"
|
||||
#include "app_info_mgr.h"
|
||||
#include "app_info.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
class FrameMsgIntfTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void FrameMsgIntfTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameMsgIntfTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameMsgIntfTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameMsgIntfTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(FrameMsgIntfTest, FrameMsgIntfInit, TestSize.Level1)
|
||||
{
|
||||
bool ret = FrameMsgIntf::GetInstance().Init();
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfo, TestSize.Level1)
|
||||
{
|
||||
int pid_1 = 12315;
|
||||
std::string appName_1 = "com.ohos.frameaware.test1";
|
||||
int pid_2 = 12366;
|
||||
std::string appName_2 = "com.ohos.frameaware.test2";
|
||||
|
||||
// app foreground
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND);
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_FOREGROUND);
|
||||
|
||||
// app background
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_BACKGROUND);
|
||||
|
||||
|
||||
bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1);
|
||||
bool isAppPidExist2 = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_2);
|
||||
|
||||
EXPECT_EQ(isAppPidExist, true);
|
||||
EXPECT_EQ(isAppPidExist2, false);
|
||||
|
||||
// app terminated
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_TERMINATED);
|
||||
isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1);
|
||||
EXPECT_EQ(isAppPidExist, false);
|
||||
}
|
||||
|
||||
HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportWindowFocus, TestSize.Level1)
|
||||
{
|
||||
|
||||
int pid_1 = 12234;
|
||||
int pid_2 = 23134;
|
||||
int pid_3 = 8912;
|
||||
|
||||
std::string appName_1 = "com.ohos.frameaware.test1";
|
||||
std::string appName_2 = "com.ohos.frameaware.test2";
|
||||
std::string appName_3 = "com.ohos.frameaware.test3";
|
||||
|
||||
// app focus
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND);
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_FOREGROUND);
|
||||
FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1);
|
||||
|
||||
// app Unfocus
|
||||
FrameMsgIntf::GetInstance().ReportAppInfo(appName_3, appName_3, pid_3, AppStateUpdateReason::APP_FOREGROUND);
|
||||
FrameMsgIntf::GetInstance().ReportWindowFocus(pid_3, 0);
|
||||
|
||||
std::shared_ptr<AppInfo> app_1 = AppInfoMgr::GetInstance().GetFocusApp();
|
||||
bool focusSta_1 = app_1->GetFocusState();
|
||||
std::shared_ptr<AppInfo> app_2 = AppInfoMgr::GetInstance().GetFocusApp();
|
||||
bool focusSta_2 = app_2->GetFocusState();
|
||||
|
||||
EXPECT_EQ(focusSta_1, true);
|
||||
EXPECT_EQ(focusSta_2, false);
|
||||
}
|
||||
|
||||
HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfo, TestSize.Level1)
|
||||
{
|
||||
//process died
|
||||
int pid_1 = 12435;
|
||||
int pid_2 = 12436;
|
||||
int ui_tid = 12435;
|
||||
int render_tid = 13332;
|
||||
|
||||
FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1);
|
||||
FrameMsgIntf::GetInstance().ReportWindowFocus(pid_2, 1);
|
||||
|
||||
FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, ui_tid, ThreadState::DIED);
|
||||
FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, render_tid, ThreadState::DIED);
|
||||
|
||||
std::shared_ptr<AppInfo> app_1 = AppInfoMgr::GetInstance().mForegroundAppList[pid_1];
|
||||
EXPECT_EQ(app_1->GetUiTid(), ui_tid);
|
||||
EXPECT_EQ(app_1->GetRenderTid(), render_tid);
|
||||
}
|
||||
|
||||
HWTEST_F(FrameMsgIntfTest, FrameMsgIntfStop, TestSize.Level1)
|
||||
{
|
||||
FrameMsgIntf::GetInstance().Stop();
|
||||
std::shared_ptr<AppExecFwk::EventHandler> thread = FrameMsgIntf::GetInstance().threadHandler_;
|
||||
EXPECT_TRUE(thread == nullptr);
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "frame_ui_intf.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
class FrameUIIntfTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void FrameUIIntfTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameUIIntfTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameUIIntfTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void FrameUIIntfTest::TearDown()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "rtg_interface.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
namespace OHOS {
|
||||
namespace RME {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
#define RTG_INTERFACE_SO_PATH "/system/lib/librtg_interface.z.so"
|
||||
|
||||
enum rtg_type {
|
||||
VIP = 0,
|
||||
TOP_TASK_KEY,
|
||||
TOP_TASK,
|
||||
NORMAL_TASK,
|
||||
RTG_TYPE_MAX,
|
||||
};
|
||||
|
||||
class RtgInterfaceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void RtgInterfaceTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void RtgInterfaceTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void RtgInterfaceTest::SetUp()
|
||||
{
|
||||
// must enable rtg before use the interface
|
||||
bool ret = EnableRtg(true);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
void RtgInterfaceTest::TearDown()
|
||||
{
|
||||
// disable rtg after use the interface
|
||||
bool ret = EnableRtg(false);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceCreateAndDestroy
|
||||
* @tc.desc: Verify the CreateAndDestroy function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceCreateAndDestroy, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceDestroyErrorGroup
|
||||
* @tc.desc: Verify Destroy function with error param.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceDestroyErrorGroup, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = DestroyRtgGrp(-1);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceAddRtg
|
||||
* @tc.desc: Verify Rtg add function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceAddRtg, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
int pid = getpid();
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = AddThreadToRtg(pid, grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceAddErrorThread
|
||||
* @tc.desc: Verify Rtg add function with error pid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceAddErrorThread, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = AddThreadToRtg(-1, grpId);
|
||||
EXPECT_NE(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceAddErrorGroup
|
||||
* @tc.desc: Verify Rtg add function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceAddErrorGroup, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int pid = getpid();
|
||||
ret = AddThreadToRtg(pid, -1);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceAddRtgs
|
||||
* @tc.desc: Verify Rtg add multiple thread function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceAddRtgs, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
int pid = getpid();
|
||||
vector<int> pids = {};
|
||||
pids.push_back(pid);
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = AddThreadsToRtg(pids, grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceClearRtg
|
||||
* @tc.desc: Verify Rtg clear function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceClearRtg, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
int pid = getpid();
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = AddThreadToRtg(pid, grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = ClearRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceClearErrorGroup
|
||||
* @tc.desc: Verify Rtg clear function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceClearErrorGroup, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = ClearRtgGrp(-1);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceBeginFrameFreq
|
||||
* @tc.desc: Verify rtg frame start function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceBeginFrameFreq, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = BeginFrameFreq(grpId, 0);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceBeginFrameFreqWithErrorGrp
|
||||
* @tc.desc: Verify rtg frame start function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceBeginFrameFreqWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = BeginFrameFreq(-1, 0);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceEndFrameFreq
|
||||
* @tc.desc: Verify rtg frame end function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceEndFrameFreq, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = EndFrameFreq(grpId, 0);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceEndFrameFreqWithErrorGrp
|
||||
* @tc.desc: Verify rtg frame end function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceEndFrameFreqWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = EndFrameFreq(-1, 0);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceEndScene
|
||||
* @tc.desc: Verify rtg frame scene end function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceEndScene, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = EndScene(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceEndSceneWithErrorGrp
|
||||
* @tc.desc: Verify rtg frame scene end function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceEndSceneWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = EndScene(-1);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetMinUtil
|
||||
* @tc.desc: Verify rtg minUtil set function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetMinUtil, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = SetMinUtil(grpId, 0);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetMinUtilWithErrorGrp
|
||||
* @tc.desc: Verify rtg minUtil set function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetMinUtilWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = SetMinUtil(-1, 0);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetMargin
|
||||
* @tc.desc: Verify rtg margin set function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetMargin, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = SetMargin(grpId, 0);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetMarginWithErrorGrp
|
||||
* @tc.desc: Verify rtg margin set function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetMarginWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = SetMargin(-1, 0);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceListRtgThread
|
||||
* @tc.desc: Verify rtg list function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceListRtgThread, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
vector<int> rs;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = ListRtgThread(grpId, &rs);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceListRtgThreadWithNullRes
|
||||
* @tc.desc: Verify rtg thread list function with null vector input.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceListRtgThreadWithNullRes, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = ListRtgThread(grpId, nullptr);
|
||||
EXPECT_NE(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceListRtgThreadWithErrorGrp
|
||||
* @tc.desc: Verify rtg thread list function with error groupid.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceListRtgThreadWithErrorGrp, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
vector<int> rs;
|
||||
ret = ListRtgThread(-1, &rs);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceListRtgGroup
|
||||
* @tc.desc: Verify rtg list function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceListRtgGroup, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
vector<int> rs;
|
||||
ret = ListRtgGroup(&rs);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceListRtgGroupWithNullRes
|
||||
* @tc.desc: Verify rtg list function with null vector input.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceListRtgGroupWithNullRes, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = ListRtgGroup(nullptr);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetAttr
|
||||
* @tc.desc: Verify rtg attr set funtion.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetAttr, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = SetFrameRateAndPrioType(grpId, 60, VIP);
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetErrorAttr
|
||||
* @tc.desc: Verify rtg attr set funtion with error attr param.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetErrorAttr, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
int grpId = 0;
|
||||
grpId = CreateNewRtgGrp(VIP, 0);
|
||||
EXPECT_GT(grpId, 0);
|
||||
ret = SetFrameRateAndPrioType(grpId, 90, -1);
|
||||
EXPECT_NE(ret, 0);
|
||||
ret = DestroyRtgGrp(grpId);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetMaxVips
|
||||
* @tc.desc: Verify rtg max vip num set funtion.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetMaxVips, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = SetMaxVipRtgs(2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetErrorMaxVips
|
||||
* @tc.desc: Verify rtg max vip num set funtion with 0 vip nums.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetErrorMaxVips, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = SetMaxVipRtgs(0);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RtgInterfaceSetLargeMaxVips
|
||||
* @tc.desc: Verify rtg max vip num set funtion with too large vip nums.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RtgInterfaceTest, RtgInterfaceSetLargeMaxVips, TestSize.Level1)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = SetMaxVipRtgs(50000);
|
||||
EXPECT_NE(ret, 0);
|
||||
}
|
||||
|
||||
} // namespace RME
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user