mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-27 01:11:15 +00:00
update OpenHarmony 2.0 Canary
This commit is contained in:
parent
b9e037c0cb
commit
cd77f12946
15
.gitattributes
vendored
Normal file
15
.gitattributes
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.trp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.apk filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.asm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.8svn filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.9svn filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.dylib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.exe filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.a filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.so filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.dll filter=lfs diff=lfs merge=lfs -text
|
47
BUILD.gn
Normal file
47
BUILD.gn
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
|
||||||
|
import("interfaces/innerkits/appexecfwk_base/appexecfwk_base_header.gni")
|
||||||
|
import("interfaces/innerkits/appexecfwk_core/appexecfwk_headers.gni")
|
||||||
|
import("interfaces/innerkits/libeventhandler/lib_event_handler_headers.gni")
|
||||||
|
|
||||||
|
# install to /system/framework
|
||||||
|
ohos_combine_jars("appexecfwk_install_java") {
|
||||||
|
deps = [
|
||||||
|
"common:appexecfwk_utils_java",
|
||||||
|
"interfaces/innerkits/abilityshell_java:abilityshell_inner_java",
|
||||||
|
"interfaces/innerkits/abilityshell_java:abilityshell_java",
|
||||||
|
"interfaces/innerkits/appexecfwk_base_java:appexecfwk_base_java",
|
||||||
|
"interfaces/innerkits/appexecfwk_java:appexecfwk_java",
|
||||||
|
"interfaces/innerkits/appexecfwk_launcher_java:appexecfwk_launcher_java",
|
||||||
|
"interfaces/innerkits/bundlemgr_adapter_java:bundlemgr_adapter_java",
|
||||||
|
"interfaces/innerkits/bundlemgr_adapter_java:package_manager_adapter_java",
|
||||||
|
"interfaces/innerkits/eventhandler_java:eventhandler_java",
|
||||||
|
"interfaces/innerkits/handler_adapter_java:handler_adapter_java",
|
||||||
|
"interfaces/innerkits/interwork_java:interwork_java",
|
||||||
|
"interfaces/innerkits/pluginproxy_adapter_java:pluginproxy_adapter_java",
|
||||||
|
"kits/appkit:appkit_java",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (!is_ivi_product) {
|
||||||
|
deps += [ "interfaces/innerkits/appexecfwk_plugin:appexecfwk_plugin_java" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_double_framework && !mrt) {
|
||||||
|
subsystem_name = "appexecfwk"
|
||||||
|
part_name = "appexecfwk_standard"
|
||||||
|
dex_path = "${target_out_dir}/appexecfwk.z.jar"
|
||||||
|
}
|
||||||
|
}
|
177
LICENSE
Normal file
177
LICENSE
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
|
||||||
|
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
|
70
OAT.xml
Normal file
70
OAT.xml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?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.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun@huawei.com.
|
||||||
|
-->
|
||||||
|
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||||
|
basedir: Root dir, the basedir + project path is the real source file location.
|
||||||
|
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.
|
||||||
|
|
||||||
|
tasklist(only for batch mode):
|
||||||
|
1. task: Define oat check thread, each task will start a new thread.
|
||||||
|
2. task name: Only an name, no practical effect.
|
||||||
|
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
|
||||||
|
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
|
||||||
|
5. task project: Projects to be checked, the path field define the source root dir of the project.
|
||||||
|
|
||||||
|
|
||||||
|
policyList:
|
||||||
|
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
|
||||||
|
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(support projectroot in default OAT.xml), 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.
|
||||||
|
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="">
|
||||||
|
</policy>
|
||||||
|
</policylist>
|
||||||
|
<filefilterlist>
|
||||||
|
<filefilter name="defaultFilter" desc="Files not to check">
|
||||||
|
<filteritem type="filename" name="*.hap|*.rpk" desc="valid and invalid bundle files for tests"/>
|
||||||
|
</filefilter>
|
||||||
|
</filefilterlist>
|
||||||
|
</oatconfig>
|
||||||
|
</configuration>
|
36
README.en.md
36
README.en.md
@ -1,36 +0,0 @@
|
|||||||
# appexecfwk_standard
|
|
||||||
|
|
||||||
#### Description
|
|
||||||
Application execution and management framework | 用户程序运行管理框架
|
|
||||||
|
|
||||||
#### 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/)
|
|
37
README.md
37
README.md
@ -1,37 +0,0 @@
|
|||||||
# appexecfwk_standard
|
|
||||||
|
|
||||||
#### 介绍
|
|
||||||
Application execution and management framework | 用户程序运行管理框架
|
|
||||||
|
|
||||||
#### 软件架构
|
|
||||||
软件架构说明
|
|
||||||
|
|
||||||
|
|
||||||
#### 安装教程
|
|
||||||
|
|
||||||
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/)
|
|
96
README_zh.md
Executable file
96
README_zh.md
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
# **用户程序框架子系统**
|
||||||
|
|
||||||
|
## 简介
|
||||||
|
|
||||||
|
用户程序框架子系统是OpenHarmony为开发者提供的一套开发OpenHarmony应用程序的框架。
|
||||||
|
|
||||||
|
**包含以下模块:**
|
||||||
|
|
||||||
|
- **AppKit:**是用户程序框架提供给开发者的开发包,开发者基于该开发包可以开发出基于Ability组件的应用。
|
||||||
|
|
||||||
|
- **AppManagerService:**应用管理服务,用于管理应用运行关系、调度应用进程生命周期及状态的系统服务。
|
||||||
|
|
||||||
|
- **BundleManagerService:**是负责管理安装包的系统服务,常见的比如包安装、更新,卸载和包信息查询等,运行在Foundation进程。
|
||||||
|
|
||||||
|
应用程序框架子系统架构如下图所示:
|
||||||
|
|
||||||
|
![](figures/appexecfwk.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 目录
|
||||||
|
|
||||||
|
```
|
||||||
|
foundation/appexecfwk/standard
|
||||||
|
├── kits
|
||||||
|
│ └── appkit # Appkit实现的核心代码
|
||||||
|
├── common
|
||||||
|
│ └── log # 日志组件目录
|
||||||
|
├── interfaces
|
||||||
|
│ └── innerkits # 内部接口存放目录
|
||||||
|
├── services
|
||||||
|
│ ├── appmgr # 用户程序管理服务框架代码
|
||||||
|
│ └── bundlemgr # 包管理服务框架代码
|
||||||
|
├── test # 测试目录
|
||||||
|
└── tools # bm命令存放目录
|
||||||
|
```
|
||||||
|
|
||||||
|
### 使用说明
|
||||||
|
|
||||||
|
当前版本用户程序框架不具备权限管理的能力。
|
||||||
|
|
||||||
|
以下模块的JS接口为非正式API,仅供Launcher、Settings、SystemUI等系统应用使用,不排除对这些接口进行变更的可能性,后续版本将提供正式API。
|
||||||
|
|
||||||
|
- @ohos.bundle_mgr.d.ts
|
||||||
|
- bundleinfo.d.ts
|
||||||
|
- common.d.ts
|
||||||
|
- installresult.d.ts
|
||||||
|
- moduleinfo.d.ts
|
||||||
|
|
||||||
|
|
||||||
|
### bm命令如下
|
||||||
|
|
||||||
|
**bm命令帮助**
|
||||||
|
|
||||||
|
| 命令 | 描述 |
|
||||||
|
| ------- | ---------- |
|
||||||
|
| bm help | bm帮助命令 |
|
||||||
|
|
||||||
|
**安装应用**
|
||||||
|
|
||||||
|
| 命令 | 描述 |
|
||||||
|
| ----------------------------------- | -------------------------- |
|
||||||
|
| bm install -p <bundle-file-path> | 通过指定路径安装一个应用包 |
|
||||||
|
| bm install -r -p <bundle-file-path> | 覆盖安装一个应用包 |
|
||||||
|
|
||||||
|
```
|
||||||
|
示例如下:
|
||||||
|
bm install -p /data/app/ohosapp.hap
|
||||||
|
```
|
||||||
|
|
||||||
|
**卸载应用**
|
||||||
|
|
||||||
|
| 命令 | 描述 |
|
||||||
|
| ----------------------------- | ------------------------ |
|
||||||
|
| bm uninstall -n <bundle-name> | 通过指定包名卸载一个应用 |
|
||||||
|
|
||||||
|
```
|
||||||
|
示例如下:
|
||||||
|
bm uninstall -n com.ohos.app
|
||||||
|
```
|
||||||
|
|
||||||
|
**查看应用安装信息**
|
||||||
|
|
||||||
|
| 命令 | 描述 |
|
||||||
|
| ---------- | -------------------------- |
|
||||||
|
| bm dump -a | 列出系统已经安装的所有应用 |
|
||||||
|
|
||||||
|
## 相关仓
|
||||||
|
|
||||||
|
用户程序框架子系统
|
||||||
|
|
||||||
|
**appexecfwk_standard**
|
||||||
|
|
||||||
|
aafwk_standard
|
||||||
|
|
||||||
|
startup_appspawn
|
27
appexecfwk.gni
Normal file
27
appexecfwk.gni
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
aafwk_path = "//foundation/aafwk/standard"
|
||||||
|
appexecfwk_path = "//foundation/appexecfwk/standard"
|
||||||
|
appspawn_path = "//base/startup/appspawn_standard"
|
||||||
|
even_path = "//base/notification/ces_standard"
|
||||||
|
|
||||||
|
libs_path = "${appexecfwk_path}/libs"
|
||||||
|
common_path = "${appexecfwk_path}/common"
|
||||||
|
services_path = "${appexecfwk_path}/services"
|
||||||
|
kits_path = "${appexecfwk_path}/kits"
|
||||||
|
innerkits_path = "${appexecfwk_path}/interfaces/innerkits"
|
||||||
|
tools_path = "${appexecfwk_path}/tools"
|
||||||
|
test_hap_common_path = "${appexecfwk_path}/test/common"
|
||||||
|
system_test_app_path =
|
||||||
|
"${appexecfwk_path}/test/resource/amssystemtestability/abilitySrc"
|
50
common/BUILD.gn
Normal file
50
common/BUILD.gn
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
group("common_target") {
|
||||||
|
deps = [ ":libappexecfwk_common" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("appexecfwk_common_config") {
|
||||||
|
include_dirs = [
|
||||||
|
"log/include",
|
||||||
|
"perf/include",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
ohos_shared_library("libappexecfwk_common") {
|
||||||
|
sources = [
|
||||||
|
"log/src/app_log_wrapper.cpp",
|
||||||
|
"perf/src/perf_profile.cpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = [
|
||||||
|
"APP_LOG_TAG = \"AppExecFwk\"",
|
||||||
|
"LOG_DOMAIN = 0xD001140",
|
||||||
|
]
|
||||||
|
|
||||||
|
public_configs = [
|
||||||
|
":appexecfwk_common_config",
|
||||||
|
"//utils/native/base:utils_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [ "//utils/native/base:utils" ]
|
||||||
|
|
||||||
|
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||||
|
|
||||||
|
subsystem_name = "appexecfwk"
|
||||||
|
part_name = "appexecfwk_standard"
|
||||||
|
}
|
54
common/log/README.md
Normal file
54
common/log/README.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
## How To Use Log
|
||||||
|
|
||||||
|
# C++
|
||||||
|
1. Add a statement to your gn file
|
||||||
|
|
||||||
|
```
|
||||||
|
deps = [
|
||||||
|
"${common_path}/log:appexecfwk_log_source_set",
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = [
|
||||||
|
"APP_LOG_TAG = \"Appexecfwk_Core\"",
|
||||||
|
"LOG_DOMAIN = 0xD001110",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
2. Include header file `#include "app_log_wrapper.h"`
|
||||||
|
3. Control log print level `AppLogWrapper::SetLogLevel(AppLogLevel::DEBUG);` default is DEBUG
|
||||||
|
4. Example output format `[fileName(functionName)] string`
|
||||||
|
```
|
||||||
|
// dynamic control log level
|
||||||
|
AppLogWrapper::SetLogLevel(AppLogLevel::FATAL);
|
||||||
|
|
||||||
|
// The following log statement will not print
|
||||||
|
APP_LOGD("one %{public}d", 1234);
|
||||||
|
APP_LOGI("two %{public}s", "1234");
|
||||||
|
APP_LOGW("three %{private}s", "1234");
|
||||||
|
APP_LOGE("four %{private}s", "1234");
|
||||||
|
|
||||||
|
// The following log statement will print
|
||||||
|
AppLogWrapper::SetLogLevel(AppLogLevel::DEBUG);
|
||||||
|
APP_LOGD("five %{public}d", 1234);
|
||||||
|
APP_LOGI("six %{public}s", "1234");
|
||||||
|
APP_LOGW("seven %{private}s", "1234");
|
||||||
|
APP_LOGE("eight %{private}s", "1234");
|
||||||
|
```
|
||||||
|
|
||||||
|
# Java
|
||||||
|
|
||||||
|
1. import dependent in your class
|
||||||
|
```
|
||||||
|
import ohosos.appexecfwk.utils.AppLog;
|
||||||
|
import ohosos.hiviewdfx.HiLogLabel;
|
||||||
|
```
|
||||||
|
|
||||||
|
2. custom HiLogLabel (if you don't custom label, the default will be used)
|
||||||
|
```
|
||||||
|
private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_CORE, 0xD001110, "AppKit");
|
||||||
|
```
|
||||||
|
|
||||||
|
3. use AppLog interface
|
||||||
|
```
|
||||||
|
App_Log.d(LABEL, "log %{public}s", "123");
|
||||||
|
App_Log.i("log %{public}d", 123);
|
||||||
|
```
|
74
common/log/include/app_log_wrapper.h
Normal file
74
common/log/include/app_log_wrapper.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_LIBS_LOG_INCLUDE_APP_LOG_WRAPPER_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_LIBS_LOG_INCLUDE_APP_LOG_WRAPPER_H
|
||||||
|
|
||||||
|
#include "hilog/log.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
#ifndef LOG_DOMAIN
|
||||||
|
#define LOG_DOMAIN 0xD001100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef APP_LOG_TAG
|
||||||
|
#define APP_LOG_TAG NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum class AppLogLevel { DEBUG = 0, INFO, WARN, ERROR, FATAL };
|
||||||
|
|
||||||
|
static constexpr OHOS::HiviewDFX::HiLogLabel APP_LABEL = {LOG_CORE, LOG_DOMAIN, APP_LOG_TAG};
|
||||||
|
|
||||||
|
class AppLogWrapper {
|
||||||
|
public:
|
||||||
|
static bool JudgeLevel(const AppLogLevel &level);
|
||||||
|
|
||||||
|
static void SetLogLevel(const AppLogLevel &level)
|
||||||
|
{
|
||||||
|
level_ = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const AppLogLevel &GetLogLevel()
|
||||||
|
{
|
||||||
|
return level_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetBriefFileName(const char *str);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static AppLogLevel level_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PRINT_LOG(LEVEL, Level, fmt, ...) \
|
||||||
|
if (AppLogWrapper::JudgeLevel(AppLogLevel::LEVEL)) \
|
||||||
|
OHOS::HiviewDFX::HiLog::Level(APP_LABEL, \
|
||||||
|
"[%{public}s(%{public}s):%{public}d] " fmt, \
|
||||||
|
AppLogWrapper::GetBriefFileName(__FILE__).c_str(), \
|
||||||
|
__FUNCTION__, \
|
||||||
|
__LINE__, \
|
||||||
|
##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define APP_LOGD(fmt, ...) PRINT_LOG(DEBUG, Debug, fmt, ##__VA_ARGS__)
|
||||||
|
#define APP_LOGI(fmt, ...) PRINT_LOG(INFO, Info, fmt, ##__VA_ARGS__)
|
||||||
|
#define APP_LOGW(fmt, ...) PRINT_LOG(WARN, Warn, fmt, ##__VA_ARGS__)
|
||||||
|
#define APP_LOGE(fmt, ...) PRINT_LOG(ERROR, Error, fmt, ##__VA_ARGS__)
|
||||||
|
#define APP_LOGF(fmt, ...) PRINT_LOG(FATAL, Fatal, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_LIBS_LOG_INCLUDE_APP_LOG_WRAPPER_H
|
44
common/log/src/app_log_wrapper.cpp
Normal file
44
common/log/src/app_log_wrapper.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
// initial static member object
|
||||||
|
AppLogLevel AppLogWrapper::level_ = AppLogLevel::DEBUG;
|
||||||
|
|
||||||
|
bool AppLogWrapper::JudgeLevel(const AppLogLevel &level)
|
||||||
|
{
|
||||||
|
return (AppLogWrapper::GetLogLevel() <= level);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AppLogWrapper::GetBriefFileName(const char *str)
|
||||||
|
{
|
||||||
|
if (!str) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
std::string fullPath(str);
|
||||||
|
size_t pos = fullPath.find_last_of("/");
|
||||||
|
if (pos == std::string::npos) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
return fullPath.substr(pos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
125
common/perf/include/perf_profile.h
Normal file
125
common/perf/include/perf_profile.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_SERVICES_COMMON_INCLUDE_PERF_PROFILE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_SERVICES_COMMON_INCLUDE_PERF_PROFILE_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class PerfProfile : public Singleton<PerfProfile> {
|
||||||
|
DECLARE_SINGLETON(PerfProfile);
|
||||||
|
|
||||||
|
public:
|
||||||
|
int64_t GetBmsLoadStartTime() const;
|
||||||
|
void SetBmsLoadStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBmsLoadEndTime() const;
|
||||||
|
void SetBmsLoadEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleScanStartTime() const;
|
||||||
|
void SetBundleScanStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleScanEndTime() const;
|
||||||
|
void SetBundleScanEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleDownloadStartTime() const;
|
||||||
|
void SetBundleDownloadStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleDownloadEndTime() const;
|
||||||
|
void SetBundleDownloadEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleInstallStartTime() const;
|
||||||
|
void SetBundleInstallStartTime(int64_t time);
|
||||||
|
int64_t GetBundleTotalInstallTime() const;
|
||||||
|
|
||||||
|
int64_t GetBundleInstallEndTime() const;
|
||||||
|
void SetBundleInstallEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleUninstallStartTime() const;
|
||||||
|
void SetBundleUninstallStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleUninstallEndTime() const;
|
||||||
|
void SetBundleUninstallEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleParseStartTime() const;
|
||||||
|
void SetBundleParseStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetBundleParseEndTime() const;
|
||||||
|
void SetBundleParseEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAmsLoadStartTime() const;
|
||||||
|
void SetAmsLoadStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAmsLoadEndTime() const;
|
||||||
|
void SetAmsLoadEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAbilityLoadStartTime() const;
|
||||||
|
void SetAbilityLoadStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAbilityLoadEndTime() const;
|
||||||
|
void SetAbilityLoadEndTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAppForkStartTime() const;
|
||||||
|
void SetAppForkStartTime(int64_t time);
|
||||||
|
|
||||||
|
int64_t GetAppForkEndTime() const;
|
||||||
|
void SetAppForkEndTime(int64_t time);
|
||||||
|
|
||||||
|
bool GetPerfProfileEnabled() const;
|
||||||
|
void SetPerfProfileEnabled(bool enable);
|
||||||
|
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
void Dump() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int64_t bmsLoadStart_ = 0;
|
||||||
|
int64_t bmsLoadEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t bundleScanStart_ = 0;
|
||||||
|
int64_t bundleScanEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t bundleDownloadStart_ = 0;
|
||||||
|
int64_t bundleDownloadEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t bundleInstallStart_ = 0;
|
||||||
|
int64_t bundleInstallEnd_ = 0;
|
||||||
|
int64_t bundleInstallTime_ = 0;
|
||||||
|
|
||||||
|
int64_t bundleUninstallStart_ = 0;
|
||||||
|
int64_t bundleUninstallEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t bundleParseStart_ = 0;
|
||||||
|
int64_t bundleParseEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t amsLoadStart_ = 0;
|
||||||
|
int64_t amsLoadEnd_ = 0;
|
||||||
|
|
||||||
|
int64_t abilityLoadStart_ = 0;
|
||||||
|
int64_t abilityLoadEnd_ = 0;
|
||||||
|
int64_t appForkStart_ = 0;
|
||||||
|
int64_t appForkEnd_ = 0;
|
||||||
|
|
||||||
|
bool enableProfile_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_SERVICES_COMMON_INCLUDE_PERF_PROFILE_H
|
311
common/perf/src/perf_profile.cpp
Executable file
311
common/perf/src/perf_profile.cpp
Executable file
@ -0,0 +1,311 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "perf_profile.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
PerfProfile::PerfProfile()
|
||||||
|
{
|
||||||
|
APP_LOGD("create");
|
||||||
|
}
|
||||||
|
|
||||||
|
PerfProfile::~PerfProfile()
|
||||||
|
{
|
||||||
|
APP_LOGD("destroy");
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBmsLoadStartTime() const
|
||||||
|
{
|
||||||
|
return bmsLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBmsLoadStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bmsLoadStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBmsLoadEndTime() const
|
||||||
|
{
|
||||||
|
return bmsLoadEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBmsLoadEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
bmsLoadEnd_ = (time > 0 && time > bmsLoadStart_) ? time : bmsLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleScanStartTime() const
|
||||||
|
{
|
||||||
|
return bundleScanStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleScanStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleScanStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleScanEndTime() const
|
||||||
|
{
|
||||||
|
return bundleScanEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleScanEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleScanEnd_ = (time > 0 && time > bundleScanStart_) ? time : bundleScanStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleDownloadStartTime() const
|
||||||
|
{
|
||||||
|
return bundleDownloadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleDownloadStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleDownloadStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleDownloadEndTime() const
|
||||||
|
{
|
||||||
|
return bundleDownloadEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleDownloadEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleDownloadEnd_ = (time > 0 && time > bundleDownloadStart_) ? time : bundleDownloadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleInstallStartTime() const
|
||||||
|
{
|
||||||
|
return bundleInstallStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleInstallStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleInstallStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleInstallEndTime() const
|
||||||
|
{
|
||||||
|
return bundleInstallEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleInstallEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
if (time >= 0 && time > bundleInstallStart_) {
|
||||||
|
bundleInstallEnd_ = time;
|
||||||
|
bundleInstallTime_ += (bundleInstallEnd_ - bundleInstallStart_);
|
||||||
|
} else {
|
||||||
|
bundleInstallEnd_ = bundleInstallStart_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleTotalInstallTime() const
|
||||||
|
{
|
||||||
|
return bundleInstallTime_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleUninstallStartTime() const
|
||||||
|
{
|
||||||
|
return bundleUninstallStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleUninstallStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleUninstallStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleUninstallEndTime() const
|
||||||
|
{
|
||||||
|
return bundleUninstallEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleUninstallEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleUninstallEnd_ = (time > 0 && time > bundleUninstallStart_) ? time : bundleUninstallStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleParseStartTime() const
|
||||||
|
{
|
||||||
|
return bundleParseStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleParseStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleParseStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetBundleParseEndTime() const
|
||||||
|
{
|
||||||
|
return bundleParseEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetBundleParseEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
bundleParseEnd_ = (time > 0 && time > bundleParseStart_) ? time : bundleParseStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAmsLoadStartTime() const
|
||||||
|
{
|
||||||
|
return amsLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAmsLoadStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
amsLoadStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAmsLoadEndTime() const
|
||||||
|
{
|
||||||
|
return amsLoadEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAmsLoadEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
amsLoadEnd_ = (time > 0 && time > amsLoadStart_) ? time : amsLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAbilityLoadStartTime() const
|
||||||
|
{
|
||||||
|
return abilityLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAbilityLoadStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
abilityLoadStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAbilityLoadEndTime() const
|
||||||
|
{
|
||||||
|
return abilityLoadEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAbilityLoadEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
abilityLoadEnd_ = (time > 0 && time > abilityLoadStart_) ? time : abilityLoadStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAppForkStartTime() const
|
||||||
|
{
|
||||||
|
return appForkStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAppForkStartTime(int64_t time)
|
||||||
|
{
|
||||||
|
appForkStart_ = (time > 0) ? time : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t PerfProfile::GetAppForkEndTime() const
|
||||||
|
{
|
||||||
|
return appForkEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetAppForkEndTime(int64_t time)
|
||||||
|
{
|
||||||
|
appForkEnd_ = (time > 0 && time > appForkStart_) ? time : appForkStart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PerfProfile::GetPerfProfileEnabled() const
|
||||||
|
{
|
||||||
|
return enableProfile_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::SetPerfProfileEnabled(bool enable)
|
||||||
|
{
|
||||||
|
enableProfile_ = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::Reset()
|
||||||
|
{
|
||||||
|
bmsLoadStart_ = 0;
|
||||||
|
bmsLoadEnd_ = 0;
|
||||||
|
|
||||||
|
bundleScanStart_ = 0;
|
||||||
|
bundleScanEnd_ = 0;
|
||||||
|
|
||||||
|
bundleDownloadStart_ = 0;
|
||||||
|
bundleDownloadEnd_ = 0;
|
||||||
|
|
||||||
|
bundleInstallStart_ = 0;
|
||||||
|
bundleInstallEnd_ = 0;
|
||||||
|
bundleInstallTime_ = 0;
|
||||||
|
|
||||||
|
bundleUninstallStart_ = 0;
|
||||||
|
bundleUninstallEnd_ = 0;
|
||||||
|
|
||||||
|
bundleParseStart_ = 0;
|
||||||
|
bundleParseEnd_ = 0;
|
||||||
|
|
||||||
|
amsLoadStart_ = 0;
|
||||||
|
amsLoadEnd_ = 0;
|
||||||
|
|
||||||
|
abilityLoadStart_ = 0;
|
||||||
|
abilityLoadEnd_ = 0;
|
||||||
|
appForkStart_ = 0;
|
||||||
|
appForkEnd_ = 0;
|
||||||
|
|
||||||
|
enableProfile_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfProfile::Dump() const
|
||||||
|
{
|
||||||
|
if (!enableProfile_) {
|
||||||
|
APP_LOGI("profile disabled!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only dump the valid perf time
|
||||||
|
if ((bundleScanEnd_ > bundleScanStart_) || (bundleInstallTime_ > 0) ||
|
||||||
|
(bundleUninstallEnd_ > bundleUninstallStart_) || (bundleParseEnd_ > bundleParseStart_) ||
|
||||||
|
(abilityLoadEnd_ > abilityLoadStart_) || (bmsLoadEnd_ > bmsLoadStart_) || (amsLoadEnd_ > amsLoadStart_)) {
|
||||||
|
APP_LOGI("start\n");
|
||||||
|
|
||||||
|
APP_LOGI("*************************\n");
|
||||||
|
|
||||||
|
if (bmsLoadEnd_ > bmsLoadStart_) {
|
||||||
|
APP_LOGI("BmsLoadTime: %{public}" PRId64 "(ms) \n", (bmsLoadEnd_ - bmsLoadStart_));
|
||||||
|
}
|
||||||
|
if (bundleScanEnd_ > bundleScanStart_) {
|
||||||
|
APP_LOGI("BundleScanTime: %{public}" PRId64 "(ms) \n", (bundleScanEnd_ - bundleScanStart_));
|
||||||
|
}
|
||||||
|
if (bundleInstallTime_ > 0) {
|
||||||
|
APP_LOGI("BundleInstallTime: %{public}" PRId64 "(ms) \n", bundleInstallTime_);
|
||||||
|
}
|
||||||
|
if (bundleUninstallEnd_ > bundleUninstallStart_) {
|
||||||
|
APP_LOGI("BundleUninstallTime: %{public}" PRId64 "(ms) \n", (bundleUninstallEnd_ - bundleUninstallStart_));
|
||||||
|
}
|
||||||
|
if (bundleParseEnd_ > bundleParseStart_) {
|
||||||
|
APP_LOGI("BundleParseTime: %{public}" PRId64 "(ms) \n", (bundleParseEnd_ - bundleParseStart_));
|
||||||
|
}
|
||||||
|
if (amsLoadEnd_ > amsLoadStart_) {
|
||||||
|
APP_LOGI("AmsLoadTime: %{public}" PRId64 "(ms) \n", (amsLoadEnd_ - amsLoadStart_));
|
||||||
|
}
|
||||||
|
if (abilityLoadEnd_ > abilityLoadStart_) {
|
||||||
|
APP_LOGI("AbilityLoadTime: %{public}" PRId64 "(ms) \n", (abilityLoadEnd_ - abilityLoadStart_));
|
||||||
|
APP_LOGI(" AppForkTime: %{public}" PRId64 "(ms) \n", (appForkEnd_ - appForkStart_));
|
||||||
|
}
|
||||||
|
|
||||||
|
APP_LOGI("*************************\n");
|
||||||
|
|
||||||
|
APP_LOGI("end\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
30
common/test/BUILD.gn
Normal file
30
common/test/BUILD.gn
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
config("common_test_config") {
|
||||||
|
defines = [
|
||||||
|
"APP_LOG_TAG = \"AppExecFwk\"",
|
||||||
|
"LOG_DOMAIN = 0xD00114E",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
group("unittest") {
|
||||||
|
testonly = true
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"unittest/common_appexecfwk_log_test:unittest",
|
||||||
|
"unittest/common_perf_profile_test:unittest",
|
||||||
|
]
|
||||||
|
}
|
40
common/test/unittest/common_appexecfwk_log_test/BUILD.gn
Normal file
40
common/test/unittest/common_appexecfwk_log_test/BUILD.gn
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/test.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
module_output_path = "appexecfwk/common"
|
||||||
|
|
||||||
|
ohos_unittest("AppExecFwkLogTest") {
|
||||||
|
module_out_path = module_output_path
|
||||||
|
|
||||||
|
sources = [ "${common_path}/log/src/app_log_wrapper.cpp" ]
|
||||||
|
|
||||||
|
sources += [ "appexecfwk_log_test.cpp" ]
|
||||||
|
|
||||||
|
configs = [
|
||||||
|
"${common_path}:appexecfwk_common_config",
|
||||||
|
"${common_path}/test:common_test_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [ "//third_party/googletest:gtest_main" ]
|
||||||
|
|
||||||
|
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
group("unittest") {
|
||||||
|
testonly = true
|
||||||
|
|
||||||
|
deps = [ ":AppExecFwkLogTest" ]
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
using namespace testing::ext;
|
||||||
|
using namespace OHOS::AppExecFwk;
|
||||||
|
|
||||||
|
class AppExecFwkLogTest : public testing::Test {
|
||||||
|
public:
|
||||||
|
static void SetUpTestCase() const;
|
||||||
|
static void TearDownTestCase() const;
|
||||||
|
void SetUp() const;
|
||||||
|
void TearDown() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
void AppExecFwkLogTest::SetUpTestCase() const
|
||||||
|
{}
|
||||||
|
|
||||||
|
void AppExecFwkLogTest::TearDownTestCase() const
|
||||||
|
{}
|
||||||
|
|
||||||
|
void AppExecFwkLogTest::SetUp() const
|
||||||
|
{}
|
||||||
|
|
||||||
|
void AppExecFwkLogTest::TearDown() const
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: AppLogWrapper
|
||||||
|
* Function: AppLogWrapper
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: Dynamically control the log print level
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: set log print level
|
||||||
|
*/
|
||||||
|
HWTEST_F(AppExecFwkLogTest, AppLogWrapper_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(AppLogLevel::DEBUG, AppLogWrapper::GetLogLevel());
|
||||||
|
AppLogWrapper::SetLogLevel(AppLogLevel::INFO);
|
||||||
|
EXPECT_EQ(AppLogLevel::INFO, AppLogWrapper::GetLogLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: AppLogWrapper
|
||||||
|
* Function: AppLogWrapper
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: splice filename
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: normal valid filename
|
||||||
|
*/
|
||||||
|
HWTEST_F(AppExecFwkLogTest, AppLogWrapper_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
std::string fileName = "../foundation/appexecfwk/test.cpp";
|
||||||
|
std::string exceptStr = "test.cpp";
|
||||||
|
|
||||||
|
std::string result = AppLogWrapper::GetBriefFileName(fileName.c_str());
|
||||||
|
EXPECT_EQ(exceptStr, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: AppLogWrapper
|
||||||
|
* Function: AppLogWrapper
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: splice filename
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: invalid filename
|
||||||
|
*/
|
||||||
|
HWTEST_F(AppExecFwkLogTest, AppLogWrapper_003, TestSize.Level0)
|
||||||
|
{
|
||||||
|
std::string fileName = "test.cpp";
|
||||||
|
std::string exceptStr = "";
|
||||||
|
|
||||||
|
std::string result = AppLogWrapper::GetBriefFileName(fileName.c_str());
|
||||||
|
EXPECT_EQ(exceptStr, result);
|
||||||
|
|
||||||
|
fileName = "";
|
||||||
|
result = AppLogWrapper::GetBriefFileName(fileName.c_str());
|
||||||
|
EXPECT_EQ(exceptStr, result);
|
||||||
|
|
||||||
|
result = AppLogWrapper::GetBriefFileName(nullptr);
|
||||||
|
EXPECT_EQ(exceptStr, result);
|
||||||
|
}
|
47
common/test/unittest/common_perf_profile_test/BUILD.gn
Normal file
47
common/test/unittest/common_perf_profile_test/BUILD.gn
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/test.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
module_output_path = "appexecfwk/common"
|
||||||
|
|
||||||
|
ohos_unittest("CommonPerfProfileTest") {
|
||||||
|
module_out_path = module_output_path
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"${common_path}/log/src/app_log_wrapper.cpp",
|
||||||
|
"${common_path}/perf/src/perf_profile.cpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources += [ "common_perf_profile_test.cpp" ]
|
||||||
|
|
||||||
|
configs = [
|
||||||
|
"${common_path}:appexecfwk_common_config",
|
||||||
|
"${common_path}/test:common_test_config",
|
||||||
|
"//utils/native/base:utils_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"//third_party/googletest:gtest_main",
|
||||||
|
"//utils/native/base:utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
group("unittest") {
|
||||||
|
testonly = true
|
||||||
|
|
||||||
|
deps = [ ":CommonPerfProfileTest" ]
|
||||||
|
}
|
@ -0,0 +1,751 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "perf_profile.h"
|
||||||
|
|
||||||
|
using namespace testing::ext;
|
||||||
|
using namespace OHOS::AppExecFwk;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const int64_t INVALID_TIME = -1;
|
||||||
|
|
||||||
|
const int64_t BMS_LOAD_INIT_START_TIME = 0;
|
||||||
|
const int64_t BMS_LOAD_SET_START_TIME = 10;
|
||||||
|
const int64_t BMS_LOAD_INIT_END_TIME = 0;
|
||||||
|
const int64_t BMS_LOAD_SET_END_TIME = 120;
|
||||||
|
|
||||||
|
const int64_t BUNDLE_SCAN_INIT_START_TIME = 0;
|
||||||
|
const int64_t BUNDLE_SCAN_SET_START_TIME = 100;
|
||||||
|
const int64_t BUNDLE_SCAN_INIT_END_TIME = 0;
|
||||||
|
const int64_t BUNDLE_SCAN_SET_END_TIME = 150;
|
||||||
|
|
||||||
|
const int64_t BUNDLE_DOWNLOAD_INIT_START_TIME = 0;
|
||||||
|
const int64_t BUNDLE_DOWNLOAD_SET_START_TIME = 50;
|
||||||
|
const int64_t BUNDLE_DOWNLOAD_INIT_END_TIME = 0;
|
||||||
|
const int64_t BUNDLE_DOWNLOAD_SET_END_TIME = 500;
|
||||||
|
|
||||||
|
const int64_t BUNDLE_INSTALL_INIT_START_TIME = 0;
|
||||||
|
const int64_t BUNDLE_INSTALL_SET_START_TIME = 50;
|
||||||
|
const int64_t BUNDLE_INSTALL_SET_START_TIME_SECOND = 400;
|
||||||
|
const int64_t BUNDLE_INSTALL_INIT_END_TIME = 0;
|
||||||
|
const int64_t BUNDLE_INSTALL_SET_END_TIME = 300;
|
||||||
|
const int64_t BUNDLE_INSTALL_SET_END_TIME_SECOND = 500;
|
||||||
|
const int64_t BUNDLE_INSTALL_INIT_TOTAL_TIME = 0;
|
||||||
|
|
||||||
|
const int64_t BUNDLE_UNINSTALL_INIT_START_TIME = 0;
|
||||||
|
const int64_t BUNDLE_UNINSTALL_SET_START_TIME = 30;
|
||||||
|
const int64_t BUNDLE_UNINSTALL_INIT_END_TIME = 0;
|
||||||
|
const int64_t BUNDLE_UNINSTALL_SET_END_TIME = 130;
|
||||||
|
|
||||||
|
const int64_t BUNDLE_PARSE_INIT_START_TIME = 0;
|
||||||
|
const int64_t BUNDLE_PARSE_SET_START_TIME = 50;
|
||||||
|
const int64_t BUNDLE_PARSE_INIT_END_TIME = 0;
|
||||||
|
const int64_t BUNDLE_PARSE_SET_END_TIME = 250;
|
||||||
|
|
||||||
|
const int64_t AMS_LOAD_INIT_START_TIME = 0;
|
||||||
|
const int64_t AMS_LOAD_SET_START_TIME = 10;
|
||||||
|
const int64_t AMS_LOAD_INIT_END_TIME = 0;
|
||||||
|
const int64_t AMS_LOAD_SET_END_TIME = 90;
|
||||||
|
|
||||||
|
const int64_t ABILITY_LOAD_INIT_START_TIME = 0;
|
||||||
|
const int64_t ABILITY_LOAD_SET_START_TIME = 50;
|
||||||
|
const int64_t ABILITY_LOAD_INIT_END_TIME = 0;
|
||||||
|
const int64_t ABILITY_LOAD_SET_END_TIME = 1000;
|
||||||
|
|
||||||
|
const int64_t APP_FORK_INIT_START_TIME = 0;
|
||||||
|
const int64_t APP_FORK_SET_START_TIME = 50;
|
||||||
|
const int64_t APP_FORK_INIT_END_TIME = 0;
|
||||||
|
const int64_t APP_FORK_SET_END_TIME = 100;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class CommonPerfProfileTest : public testing::Test {
|
||||||
|
public:
|
||||||
|
CommonPerfProfileTest();
|
||||||
|
~CommonPerfProfileTest();
|
||||||
|
static void SetUpTestCase();
|
||||||
|
static void TearDownTestCase();
|
||||||
|
void SetUp();
|
||||||
|
void TearDown();
|
||||||
|
};
|
||||||
|
|
||||||
|
CommonPerfProfileTest::CommonPerfProfileTest()
|
||||||
|
{}
|
||||||
|
|
||||||
|
CommonPerfProfileTest::~CommonPerfProfileTest()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void CommonPerfProfileTest::SetUpTestCase()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void CommonPerfProfileTest::TearDownTestCase()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void CommonPerfProfileTest::SetUp()
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommonPerfProfileTest::TearDown()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBmsLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBmsLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bms load time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBmsLoadTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadStartTime(BMS_LOAD_SET_START_TIME);
|
||||||
|
int64_t bmsLoadStartTime = PerfProfile::GetInstance().GetBmsLoadStartTime();
|
||||||
|
EXPECT_EQ(bmsLoadStartTime, BMS_LOAD_SET_START_TIME) << "bms load start time " << bmsLoadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadEndTime(BMS_LOAD_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t bmsLoadEndTime = PerfProfile::GetInstance().GetBmsLoadEndTime();
|
||||||
|
EXPECT_EQ(bmsLoadEndTime, BMS_LOAD_SET_END_TIME) << "bms load end time " << bmsLoadEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the bms load start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initBmsLoadStartTime = PerfProfile::GetInstance().GetBmsLoadStartTime();
|
||||||
|
int64_t initBmsLoadEndTime = PerfProfile::GetInstance().GetBmsLoadEndTime();
|
||||||
|
EXPECT_EQ(initBmsLoadStartTime, BMS_LOAD_INIT_START_TIME) << "bms init load start time " << initBmsLoadStartTime;
|
||||||
|
EXPECT_EQ(initBmsLoadEndTime, BMS_LOAD_INIT_END_TIME) << "bms init load end time " << initBmsLoadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBmsLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBmsLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bms load time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBmsLoadTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t bmsLoadStartTime = 0;
|
||||||
|
int64_t bmsLoadEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadStartTime(INVALID_TIME);
|
||||||
|
bmsLoadStartTime = PerfProfile::GetInstance().GetBmsLoadStartTime();
|
||||||
|
EXPECT_EQ(bmsLoadStartTime, BMS_LOAD_INIT_START_TIME) << "bms load start time " << bmsLoadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadStartTime(BMS_LOAD_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadEndTime(INVALID_TIME);
|
||||||
|
bmsLoadEndTime = PerfProfile::GetInstance().GetBmsLoadEndTime();
|
||||||
|
EXPECT_EQ(bmsLoadEndTime, BMS_LOAD_SET_START_TIME) << "bms load end time " << bmsLoadEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetBmsLoadEndTime(BMS_LOAD_SET_START_TIME - 1);
|
||||||
|
bmsLoadEndTime = PerfProfile::GetInstance().GetBmsLoadEndTime();
|
||||||
|
EXPECT_EQ(bmsLoadEndTime, BMS_LOAD_SET_START_TIME) << "bms load end time " << bmsLoadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleScanTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleScanTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle scan time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleScanTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetBundleScanStartTime(BUNDLE_SCAN_SET_START_TIME);
|
||||||
|
int64_t scanStartTime = PerfProfile::GetInstance().GetBundleScanStartTime();
|
||||||
|
EXPECT_EQ(scanStartTime, BUNDLE_SCAN_SET_START_TIME) << "bundle scan start time " << scanStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleScanEndTime(BUNDLE_SCAN_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t scanEndTime = PerfProfile::GetInstance().GetBundleScanEndTime();
|
||||||
|
EXPECT_EQ(scanEndTime, BUNDLE_SCAN_SET_END_TIME) << "bundle scan end time " << scanEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the scan start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initScanStartTime = PerfProfile::GetInstance().GetBundleScanStartTime();
|
||||||
|
int64_t initScanEndTime = PerfProfile::GetInstance().GetBundleScanEndTime();
|
||||||
|
EXPECT_EQ(initScanStartTime, BUNDLE_SCAN_INIT_START_TIME) << "bundle init scan start time " << initScanStartTime;
|
||||||
|
EXPECT_EQ(initScanEndTime, BUNDLE_SCAN_INIT_END_TIME) << "bundle init scan end time " << initScanEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleScanTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleScanTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle scan time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleScanTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t scanStartTime = 0;
|
||||||
|
int64_t scanEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleScanStartTime(INVALID_TIME);
|
||||||
|
scanStartTime = PerfProfile::GetInstance().GetBundleScanStartTime();
|
||||||
|
EXPECT_EQ(scanStartTime, BUNDLE_SCAN_INIT_START_TIME) << "bundle scan start time " << scanStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleScanStartTime(BUNDLE_SCAN_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetBundleScanEndTime(INVALID_TIME);
|
||||||
|
scanEndTime = PerfProfile::GetInstance().GetBundleScanEndTime();
|
||||||
|
EXPECT_EQ(scanEndTime, BUNDLE_SCAN_SET_START_TIME) << "bundle scan end time " << scanEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetBundleScanEndTime(BUNDLE_SCAN_SET_START_TIME - 1);
|
||||||
|
scanEndTime = PerfProfile::GetInstance().GetBundleScanEndTime();
|
||||||
|
EXPECT_EQ(scanEndTime, BUNDLE_SCAN_SET_START_TIME) << "bundle scan end time " << scanEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleDownloadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleDownloadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle download time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleDownloadTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadStartTime(BUNDLE_DOWNLOAD_SET_START_TIME);
|
||||||
|
int64_t downloadStartTime = PerfProfile::GetInstance().GetBundleDownloadStartTime();
|
||||||
|
EXPECT_EQ(downloadStartTime, BUNDLE_DOWNLOAD_SET_START_TIME) << "bundle download start time " << downloadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadEndTime(BUNDLE_DOWNLOAD_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t downloadEndTime = PerfProfile::GetInstance().GetBundleDownloadEndTime();
|
||||||
|
EXPECT_EQ(downloadEndTime, BUNDLE_DOWNLOAD_SET_END_TIME) << "bundle download end time " << downloadEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the download start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initDownloadStartTime = PerfProfile::GetInstance().GetBundleDownloadStartTime();
|
||||||
|
int64_t initDownloadEndTime = PerfProfile::GetInstance().GetBundleDownloadEndTime();
|
||||||
|
EXPECT_EQ(initDownloadStartTime, BUNDLE_DOWNLOAD_INIT_START_TIME)
|
||||||
|
<< "bundle init download start time " << initDownloadStartTime;
|
||||||
|
EXPECT_EQ(initDownloadEndTime, BUNDLE_DOWNLOAD_INIT_END_TIME)
|
||||||
|
<< "bundle init download end time " << initDownloadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleDownloadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleDownloadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle download time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleDownloadTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t downloadStartTime = 0;
|
||||||
|
int64_t downloadEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadStartTime(INVALID_TIME);
|
||||||
|
downloadStartTime = PerfProfile::GetInstance().GetBundleDownloadStartTime();
|
||||||
|
EXPECT_EQ(downloadStartTime, BUNDLE_DOWNLOAD_INIT_START_TIME) << "bundle download start time " << downloadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadStartTime(BUNDLE_DOWNLOAD_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadEndTime(INVALID_TIME);
|
||||||
|
downloadEndTime = PerfProfile::GetInstance().GetBundleDownloadEndTime();
|
||||||
|
EXPECT_EQ(downloadEndTime, BUNDLE_DOWNLOAD_SET_START_TIME) << "bundle download end time " << downloadEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetBundleDownloadEndTime(BUNDLE_DOWNLOAD_SET_START_TIME - 1);
|
||||||
|
downloadEndTime = PerfProfile::GetInstance().GetBundleDownloadEndTime();
|
||||||
|
EXPECT_EQ(downloadEndTime, BUNDLE_DOWNLOAD_SET_START_TIME) << "bundle download end time " << downloadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleInstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleInstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle install time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleInstallTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t expectTotalInstallTime = 0;
|
||||||
|
int64_t realTotalInstallTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
int64_t installStartTime = PerfProfile::GetInstance().GetBundleInstallStartTime();
|
||||||
|
EXPECT_EQ(installStartTime, BUNDLE_INSTALL_SET_START_TIME) << "bundle install start time " << installStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t installEndTime = PerfProfile::GetInstance().GetBundleInstallEndTime();
|
||||||
|
EXPECT_EQ(installEndTime, BUNDLE_INSTALL_SET_END_TIME) << "bundle install end time " << installEndTime;
|
||||||
|
|
||||||
|
expectTotalInstallTime = (BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME_SECOND);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME_SECOND);
|
||||||
|
expectTotalInstallTime = (BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME) +
|
||||||
|
(BUNDLE_INSTALL_SET_END_TIME_SECOND - BUNDLE_INSTALL_SET_START_TIME_SECOND);
|
||||||
|
realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the install start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initInstallStartTime = PerfProfile::GetInstance().GetBundleInstallStartTime();
|
||||||
|
int64_t initInstallEndTime = PerfProfile::GetInstance().GetBundleInstallEndTime();
|
||||||
|
int64_t initInstallTotalTime = PerfProfile::GetInstance().GetBundleInstallEndTime();
|
||||||
|
EXPECT_EQ(initInstallStartTime, BUNDLE_INSTALL_INIT_START_TIME)
|
||||||
|
<< "bundle init install start time " << initInstallStartTime;
|
||||||
|
EXPECT_EQ(initInstallEndTime, BUNDLE_INSTALL_INIT_END_TIME)
|
||||||
|
<< "bundle init install end time " << initInstallEndTime;
|
||||||
|
EXPECT_EQ(initInstallTotalTime, BUNDLE_INSTALL_INIT_TOTAL_TIME)
|
||||||
|
<< "bundle init total time " << initInstallTotalTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleInstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleInstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle install time can set correct when set first invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleInstallTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t installStartTime = 0;
|
||||||
|
int64_t installEndTime = 0;
|
||||||
|
int64_t realTotalInstallTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(INVALID_TIME);
|
||||||
|
installStartTime = PerfProfile::GetInstance().GetBundleInstallStartTime();
|
||||||
|
EXPECT_EQ(installStartTime, BUNDLE_INSTALL_INIT_START_TIME) << "bundle install start time " << installStartTime;
|
||||||
|
|
||||||
|
// set first install right start time and wrong end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(INVALID_TIME);
|
||||||
|
installEndTime = PerfProfile::GetInstance().GetBundleInstallEndTime();
|
||||||
|
EXPECT_EQ(installEndTime, BUNDLE_INSTALL_SET_START_TIME) << "bundle install end time " << installEndTime;
|
||||||
|
EXPECT_EQ(realTotalInstallTime, BUNDLE_INSTALL_INIT_TOTAL_TIME)
|
||||||
|
<< "bundle total install time " << realTotalInstallTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_START_TIME - 1);
|
||||||
|
installEndTime = PerfProfile::GetInstance().GetBundleInstallEndTime();
|
||||||
|
realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(installEndTime, BUNDLE_INSTALL_SET_START_TIME) << "bundle install end time " << installEndTime;
|
||||||
|
EXPECT_EQ(realTotalInstallTime, BUNDLE_INSTALL_INIT_TOTAL_TIME)
|
||||||
|
<< "bundle total install time " << realTotalInstallTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleInstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleInstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle install time can set correct when set second invalid end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleInstallTime_003, TestSize.Level0)
|
||||||
|
{
|
||||||
|
// set first install right start and end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME);
|
||||||
|
|
||||||
|
// set second install right start time and wrong end time
|
||||||
|
int64_t expectTotalInstallTime = 0;
|
||||||
|
int64_t realTotalInstallTime = 0;
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME_SECOND);
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(INVALID_TIME);
|
||||||
|
expectTotalInstallTime = BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME;
|
||||||
|
realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_START_TIME_SECOND - 1);
|
||||||
|
expectTotalInstallTime = BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME;
|
||||||
|
realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleInstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleInstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle install time can set correct when set second invalid start time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleInstallTime_004, TestSize.Level0)
|
||||||
|
{
|
||||||
|
// set first install right start and end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME);
|
||||||
|
|
||||||
|
// set second install wrong start time and right end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(INVALID_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME_SECOND);
|
||||||
|
int64_t expectTotalInstallTime =
|
||||||
|
BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME + BUNDLE_INSTALL_SET_END_TIME_SECOND;
|
||||||
|
int64_t realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleInstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleInstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle install time can set correct when set second invalid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleInstallTime_005, TestSize.Level0)
|
||||||
|
{
|
||||||
|
// set first install right start and end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(BUNDLE_INSTALL_SET_START_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(BUNDLE_INSTALL_SET_END_TIME);
|
||||||
|
|
||||||
|
// set second install wrong start time and end time
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallStartTime(INVALID_TIME);
|
||||||
|
PerfProfile::GetInstance().SetBundleInstallEndTime(INVALID_TIME);
|
||||||
|
int64_t expectTotalInstallTime = BUNDLE_INSTALL_SET_END_TIME - BUNDLE_INSTALL_SET_START_TIME;
|
||||||
|
int64_t realTotalInstallTime = PerfProfile::GetInstance().GetBundleTotalInstallTime();
|
||||||
|
EXPECT_EQ(realTotalInstallTime, expectTotalInstallTime) << "bundle total install time " << realTotalInstallTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleUninstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleUninstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle uninstall time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleUninstallTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetBundleUninstallStartTime(BUNDLE_UNINSTALL_SET_START_TIME);
|
||||||
|
int64_t uninstallStartTime = PerfProfile::GetInstance().GetBundleUninstallStartTime();
|
||||||
|
EXPECT_EQ(uninstallStartTime, BUNDLE_UNINSTALL_SET_START_TIME)
|
||||||
|
<< "bundle uninstall start time " << uninstallStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleUninstallEndTime(BUNDLE_UNINSTALL_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t uninstallEndTime = PerfProfile::GetInstance().GetBundleUninstallEndTime();
|
||||||
|
EXPECT_EQ(uninstallEndTime, BUNDLE_UNINSTALL_SET_END_TIME) << "bundle uninstall end time " << uninstallEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the parse start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initUninstallStartTime = PerfProfile::GetInstance().GetBundleUninstallStartTime();
|
||||||
|
int64_t initUninstallEndTime = PerfProfile::GetInstance().GetBundleUninstallEndTime();
|
||||||
|
EXPECT_EQ(initUninstallStartTime, BUNDLE_UNINSTALL_INIT_START_TIME)
|
||||||
|
<< "bundle init uninstall start time " << initUninstallStartTime;
|
||||||
|
EXPECT_EQ(initUninstallEndTime, BUNDLE_UNINSTALL_INIT_END_TIME)
|
||||||
|
<< "bundle init uninstall end time " << initUninstallEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleUninstallTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleUninstallTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle uninstall time can set correct when set the invalid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleUninstallTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t uninstallStartTime = 0;
|
||||||
|
int64_t uninstallEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleUninstallStartTime(INVALID_TIME);
|
||||||
|
uninstallStartTime = PerfProfile::GetInstance().GetBundleParseStartTime();
|
||||||
|
EXPECT_EQ(uninstallStartTime, BUNDLE_UNINSTALL_INIT_START_TIME)
|
||||||
|
<< "bundle uninstall start time " << uninstallStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleUninstallStartTime(BUNDLE_UNINSTALL_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetBundleUninstallEndTime(INVALID_TIME);
|
||||||
|
uninstallEndTime = PerfProfile::GetInstance().GetBundleUninstallEndTime();
|
||||||
|
EXPECT_EQ(uninstallEndTime, BUNDLE_UNINSTALL_SET_START_TIME) << "bundle uninstall end time " << uninstallEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetBundleParseEndTime(BUNDLE_UNINSTALL_SET_START_TIME - 1);
|
||||||
|
uninstallEndTime = PerfProfile::GetInstance().GetBundleUninstallEndTime();
|
||||||
|
EXPECT_EQ(uninstallEndTime, BUNDLE_UNINSTALL_SET_START_TIME) << "bundle uninstall end time " << uninstallEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleParseTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleParseTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle parse time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleParseTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetBundleParseStartTime(BUNDLE_PARSE_SET_START_TIME);
|
||||||
|
int64_t parseStartTime = PerfProfile::GetInstance().GetBundleParseStartTime();
|
||||||
|
EXPECT_EQ(parseStartTime, BUNDLE_PARSE_SET_START_TIME) << "bundle parse start time " << parseStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleParseEndTime(BUNDLE_PARSE_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t parseEndTime = PerfProfile::GetInstance().GetBundleParseEndTime();
|
||||||
|
EXPECT_EQ(parseEndTime, BUNDLE_PARSE_SET_END_TIME) << "bundle parse end time " << parseEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the parse start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initParseStartTime = PerfProfile::GetInstance().GetBundleParseStartTime();
|
||||||
|
int64_t initParseEndTime = PerfProfile::GetInstance().GetBundleParseEndTime();
|
||||||
|
EXPECT_EQ(initParseStartTime, BUNDLE_PARSE_INIT_START_TIME)
|
||||||
|
<< "bundle init parse start time " << initParseStartTime;
|
||||||
|
EXPECT_EQ(initParseEndTime, BUNDLE_PARSE_INIT_END_TIME) << "bundle init parse end time " << initParseEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetBundleParseTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetBundleParseTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify bundle parse time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetBundleParseTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t parseStartTime = 0;
|
||||||
|
int64_t parseEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleParseStartTime(INVALID_TIME);
|
||||||
|
parseStartTime = PerfProfile::GetInstance().GetBundleParseStartTime();
|
||||||
|
EXPECT_EQ(parseStartTime, BUNDLE_PARSE_INIT_START_TIME) << "bundle parse start time " << parseStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetBundleParseStartTime(BUNDLE_PARSE_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetBundleParseEndTime(INVALID_TIME);
|
||||||
|
parseEndTime = PerfProfile::GetInstance().GetBundleParseEndTime();
|
||||||
|
EXPECT_EQ(parseEndTime, BUNDLE_PARSE_SET_START_TIME) << "bundle parse end time " << parseEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetBundleParseEndTime(BUNDLE_PARSE_SET_START_TIME - 1);
|
||||||
|
parseEndTime = PerfProfile::GetInstance().GetBundleParseEndTime();
|
||||||
|
EXPECT_EQ(parseEndTime, BUNDLE_PARSE_SET_START_TIME) << "bundle parse end time " << parseEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAmsLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAmsLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify ams load time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAmsLoadTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadStartTime(AMS_LOAD_SET_START_TIME);
|
||||||
|
int64_t amsLoadStartTime = PerfProfile::GetInstance().GetAmsLoadStartTime();
|
||||||
|
EXPECT_EQ(amsLoadStartTime, AMS_LOAD_SET_START_TIME) << "ams load start time " << amsLoadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadEndTime(AMS_LOAD_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t amsLoadEndTime = PerfProfile::GetInstance().GetAmsLoadEndTime();
|
||||||
|
EXPECT_EQ(amsLoadEndTime, AMS_LOAD_SET_END_TIME) << "ams load end time " << amsLoadEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the ams load start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initAmsLoadStartTime = PerfProfile::GetInstance().GetAmsLoadStartTime();
|
||||||
|
int64_t initAmsLoadEndTime = PerfProfile::GetInstance().GetAmsLoadEndTime();
|
||||||
|
EXPECT_EQ(initAmsLoadStartTime, AMS_LOAD_INIT_START_TIME) << "ams init load start time " << initAmsLoadStartTime;
|
||||||
|
EXPECT_EQ(initAmsLoadEndTime, AMS_LOAD_INIT_END_TIME) << "ams init load end time " << initAmsLoadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAmsLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAmsLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify ams load time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAmsLoadTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t amsLoadStartTime = 0;
|
||||||
|
int64_t amsLoadEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadStartTime(INVALID_TIME);
|
||||||
|
amsLoadStartTime = PerfProfile::GetInstance().GetAmsLoadStartTime();
|
||||||
|
EXPECT_EQ(amsLoadStartTime, AMS_LOAD_INIT_START_TIME) << "ams load start time " << amsLoadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadStartTime(AMS_LOAD_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadEndTime(INVALID_TIME);
|
||||||
|
amsLoadEndTime = PerfProfile::GetInstance().GetAmsLoadEndTime();
|
||||||
|
EXPECT_EQ(amsLoadEndTime, AMS_LOAD_SET_START_TIME) << "ams load end time " << amsLoadEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadEndTime(AMS_LOAD_SET_START_TIME - 1);
|
||||||
|
amsLoadEndTime = PerfProfile::GetInstance().GetAmsLoadEndTime();
|
||||||
|
EXPECT_EQ(amsLoadEndTime, AMS_LOAD_SET_START_TIME) << "ams load end time " << amsLoadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAbilityLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAbilityLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify ability load time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAbilityLoadTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetAbilityLoadStartTime(ABILITY_LOAD_SET_START_TIME);
|
||||||
|
int64_t loadStartTime = PerfProfile::GetInstance().GetAbilityLoadStartTime();
|
||||||
|
EXPECT_EQ(loadStartTime, ABILITY_LOAD_SET_START_TIME) << "ability load start time " << loadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAbilityLoadEndTime(ABILITY_LOAD_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t loadEndTime = PerfProfile::GetInstance().GetAbilityLoadEndTime();
|
||||||
|
EXPECT_EQ(loadEndTime, ABILITY_LOAD_SET_END_TIME) << "ability load end time " << loadEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the ability load start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initLoadStartTime = PerfProfile::GetInstance().GetAbilityLoadStartTime();
|
||||||
|
int64_t initLoadEndTime = PerfProfile::GetInstance().GetAbilityLoadEndTime();
|
||||||
|
EXPECT_EQ(initLoadStartTime, ABILITY_LOAD_INIT_START_TIME) << "ability init load start time " << initLoadStartTime;
|
||||||
|
EXPECT_EQ(initLoadEndTime, ABILITY_LOAD_INIT_END_TIME) << "ability init load end time " << initLoadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAbilityLoadTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAbilityLoadTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify ability load time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAbilityLoadTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t loadStartTime = 0;
|
||||||
|
int64_t loadEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAbilityLoadStartTime(INVALID_TIME);
|
||||||
|
loadStartTime = PerfProfile::GetInstance().GetAbilityLoadStartTime();
|
||||||
|
EXPECT_EQ(loadStartTime, ABILITY_LOAD_INIT_START_TIME) << "ability load start time " << loadStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAbilityLoadStartTime(ABILITY_LOAD_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetAbilityLoadEndTime(INVALID_TIME);
|
||||||
|
loadEndTime = PerfProfile::GetInstance().GetAbilityLoadEndTime();
|
||||||
|
EXPECT_EQ(loadEndTime, ABILITY_LOAD_SET_START_TIME) << "ability load end time " << loadEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetAmsLoadEndTime(ABILITY_LOAD_SET_START_TIME - 1);
|
||||||
|
loadEndTime = PerfProfile::GetInstance().GetAbilityLoadEndTime();
|
||||||
|
EXPECT_EQ(loadEndTime, ABILITY_LOAD_SET_START_TIME) << "ability load end time " << loadEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAppForkTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAppForkTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify app fork time can set correct when set the valid start and end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAppForkTime_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
PerfProfile::GetInstance().SetAppForkStartTime(APP_FORK_SET_START_TIME);
|
||||||
|
int64_t forkStartTime = PerfProfile::GetInstance().GetAppForkStartTime();
|
||||||
|
EXPECT_EQ(forkStartTime, APP_FORK_SET_START_TIME) << "app fork start time " << forkStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAppForkEndTime(APP_FORK_SET_END_TIME);
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
int64_t forkEndTime = PerfProfile::GetInstance().GetAppForkEndTime();
|
||||||
|
EXPECT_EQ(forkEndTime, APP_FORK_SET_END_TIME) << "app fork end time " << forkEndTime;
|
||||||
|
|
||||||
|
// after reset the perf profile, the ability load start and end time should be zero
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
int64_t initForkStartTime = PerfProfile::GetInstance().GetAppForkStartTime();
|
||||||
|
int64_t initForkEndTime = PerfProfile::GetInstance().GetAppForkEndTime();
|
||||||
|
EXPECT_EQ(initForkStartTime, APP_FORK_INIT_START_TIME) << "app init fork start time " << initForkStartTime;
|
||||||
|
EXPECT_EQ(initForkEndTime, APP_FORK_INIT_END_TIME) << "app init fork end time " << initForkEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: SetAppForkTime
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: SetAppForkTime
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify app fork time can set correct when set invalid start or end time
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, SetAppForkTime_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
int64_t forkStartTime = 0;
|
||||||
|
int64_t forkEndTime = 0;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAppForkStartTime(INVALID_TIME);
|
||||||
|
forkStartTime = PerfProfile::GetInstance().GetAppForkStartTime();
|
||||||
|
EXPECT_EQ(forkStartTime, APP_FORK_INIT_START_TIME) << "app fork start time " << forkStartTime;
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetAppForkStartTime(APP_FORK_SET_START_TIME);
|
||||||
|
|
||||||
|
// set the invalid end time less than zero
|
||||||
|
PerfProfile::GetInstance().SetAppForkEndTime(INVALID_TIME);
|
||||||
|
forkEndTime = PerfProfile::GetInstance().GetAppForkEndTime();
|
||||||
|
EXPECT_EQ(forkEndTime, APP_FORK_SET_START_TIME) << "app fork end time " << forkEndTime;
|
||||||
|
|
||||||
|
// set the invalid end time more than zero and less then start time
|
||||||
|
PerfProfile::GetInstance().SetAppForkEndTime(APP_FORK_SET_START_TIME - 1);
|
||||||
|
forkEndTime = PerfProfile::GetInstance().GetAppForkEndTime();
|
||||||
|
EXPECT_EQ(forkEndTime, ABILITY_LOAD_SET_START_TIME) << "app fork end time " << forkEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature: CommonPerfProfileTest
|
||||||
|
* Function: PerfProfileEnable
|
||||||
|
* SubFunction: NA
|
||||||
|
* FunctionPoints: PerfProfileEnable
|
||||||
|
* EnvConditions: NA
|
||||||
|
* CaseDescription: verify perf profile dump can set enable or disable
|
||||||
|
*/
|
||||||
|
HWTEST_F(CommonPerfProfileTest, PerfProfileEnable_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
bool profileFlag = false;
|
||||||
|
PerfProfile::GetInstance().SetPerfProfileEnabled(false);
|
||||||
|
profileFlag = PerfProfile::GetInstance().GetPerfProfileEnabled();
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
ASSERT_FALSE(profileFlag);
|
||||||
|
|
||||||
|
PerfProfile::GetInstance().SetPerfProfileEnabled(true);
|
||||||
|
profileFlag = PerfProfile::GetInstance().GetPerfProfileEnabled();
|
||||||
|
PerfProfile::GetInstance().Dump();
|
||||||
|
ASSERT_TRUE(profileFlag);
|
||||||
|
|
||||||
|
// after reset the perf profile, the perf profile flag should be true
|
||||||
|
PerfProfile::GetInstance().SetPerfProfileEnabled(false);
|
||||||
|
PerfProfile::GetInstance().Reset();
|
||||||
|
profileFlag = PerfProfile::GetInstance().GetPerfProfileEnabled();
|
||||||
|
ASSERT_TRUE(profileFlag);
|
||||||
|
}
|
BIN
figures/appexecfwk.png
Executable file
BIN
figures/appexecfwk.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
24
interfaces/innerkits/BUILD.gn
Normal file
24
interfaces/innerkits/BUILD.gn
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
group("innerkits_target") {
|
||||||
|
deps = [
|
||||||
|
"appexecfwk_base:appexecfwk_base",
|
||||||
|
"appexecfwk_core:appexecfwk_core",
|
||||||
|
"eventhandler_native:eventhandler_native",
|
||||||
|
"libeventhandler:libeventhandler",
|
||||||
|
]
|
||||||
|
}
|
63
interfaces/innerkits/appexecfwk_base/BUILD.gn
Normal file
63
interfaces/innerkits/appexecfwk_base/BUILD.gn
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
import("//build/test.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
config("appexecfwk_base_sdk_config") {
|
||||||
|
include_dirs = [ "include" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
ohos_shared_library("appexecfwk_base") {
|
||||||
|
include_dirs = [ "//third_party/json/include" ]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"src/ability_info.cpp",
|
||||||
|
"src/app_process_info.cpp",
|
||||||
|
"src/application_info.cpp",
|
||||||
|
"src/bundle_info.cpp",
|
||||||
|
"src/element_name.cpp",
|
||||||
|
"src/hap_module_info.cpp",
|
||||||
|
"src/install_param.cpp",
|
||||||
|
"src/module_info.cpp",
|
||||||
|
"src/permission_def.cpp",
|
||||||
|
"src/running_process_info.cpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
public_configs = [
|
||||||
|
":appexecfwk_base_sdk_config",
|
||||||
|
"//utils/native/base:utils_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = [
|
||||||
|
"APP_LOG_TAG = \"AppExecFwkBase\"",
|
||||||
|
"LOG_DOMAIN = 0xD001100",
|
||||||
|
]
|
||||||
|
cflags = []
|
||||||
|
if (target_cpu == "arm") {
|
||||||
|
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||||
|
}
|
||||||
|
deps = [
|
||||||
|
"${common_path}:libappexecfwk_common",
|
||||||
|
"//utils/native/base:utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
external_deps = [
|
||||||
|
"hiviewdfx_hilog_native:libhilog",
|
||||||
|
"ipc:ipc_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
subsystem_name = "appexecfwk"
|
||||||
|
part_name = "appexecfwk_standard"
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
appexecfwk_base_headers = {
|
||||||
|
header_files = [
|
||||||
|
"ability_info.h",
|
||||||
|
"appexecfwk_errors.h",
|
||||||
|
"application_info.h",
|
||||||
|
"element_name.h",
|
||||||
|
"bundle_info.h",
|
||||||
|
"hap_module_info.h",
|
||||||
|
"install_param.h",
|
||||||
|
"module_info.h",
|
||||||
|
"permission_def.h",
|
||||||
|
"app_process_info.h",
|
||||||
|
"running_process_info.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
header_base = "interfaces/innerkits/appexecfwk_base/include"
|
||||||
|
}
|
86
interfaces/innerkits/appexecfwk_base/include/ability_info.h
Normal file
86
interfaces/innerkits/appexecfwk_base/include/ability_info.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class AbilityType {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
PAGE,
|
||||||
|
SERVICE,
|
||||||
|
DATA,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class DisplayOrientation {
|
||||||
|
UNSPECIFIED = 0,
|
||||||
|
LANDSCAPE,
|
||||||
|
PORTRAIT,
|
||||||
|
FOLLOWRECENT,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class LaunchMode {
|
||||||
|
SINGLETON = 0,
|
||||||
|
SINGLETOP,
|
||||||
|
STANDARD, // support more than one instance
|
||||||
|
};
|
||||||
|
|
||||||
|
// configuration information about an ability
|
||||||
|
struct AbilityInfo : public Parcelable {
|
||||||
|
std::string name; // ability name, only the main class name
|
||||||
|
std::string label;
|
||||||
|
std::string description;
|
||||||
|
std::string iconPath;
|
||||||
|
bool visible = false;
|
||||||
|
std::string kind; // ability category
|
||||||
|
AbilityType type = AbilityType::UNKNOWN;
|
||||||
|
DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED;
|
||||||
|
LaunchMode launchMode = LaunchMode::STANDARD;
|
||||||
|
std::vector<std::string> permissions;
|
||||||
|
|
||||||
|
std::string process;
|
||||||
|
std::vector<std::string> deviceTypes;
|
||||||
|
std::vector<std::string> deviceCapabilities;
|
||||||
|
std::string uri;
|
||||||
|
ApplicationInfo applicationInfo;
|
||||||
|
bool isLauncherAbility = false;
|
||||||
|
bool isNativeAbility = false;
|
||||||
|
|
||||||
|
// set when install
|
||||||
|
std::string package; // the "module.package" in config.json
|
||||||
|
std::string bundleName;
|
||||||
|
std::string moduleName; // the "module.name" in config.json
|
||||||
|
std::string applicationName; // the "bundlename" in config.json
|
||||||
|
std::string deviceId; // should auto-get self device id
|
||||||
|
std::string codePath; // ability main code path with name
|
||||||
|
std::string resourcePath; // resource path for resource init
|
||||||
|
std::string libPath; // ability library path without name, libPath->libDir
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static AbilityInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
void Dump(std::string prefix, int fd);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APP_PROCESS_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APP_PROCESS_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class AppProcessState {
|
||||||
|
APP_STATE_BEGIN = 0,
|
||||||
|
APP_STATE_CREATE = APP_STATE_BEGIN,
|
||||||
|
APP_STATE_READY,
|
||||||
|
APP_STATE_FOREGROUND,
|
||||||
|
APP_STATE_BACKGROUND,
|
||||||
|
APP_STATE_SUSPENDED,
|
||||||
|
APP_STATE_TERMINATED,
|
||||||
|
APP_STATE_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class WeightReasonCode {
|
||||||
|
REASON_UNKNOWN = 0,
|
||||||
|
WEIGHT_FOREGROUND = 100,
|
||||||
|
WEIGHT_FOREGROUND_SERVICE = 125,
|
||||||
|
WEIGHT_VISIBLE = 200,
|
||||||
|
WEIGHT_PERCEPTIBLE = 230,
|
||||||
|
WEIGHT_SERVICE = 300,
|
||||||
|
WEIGHT_TOP_SLEEPING = 325,
|
||||||
|
WEIGHT_CANT_SAVE_STATE = 350,
|
||||||
|
WEIGHT_CACHED = 400,
|
||||||
|
WEIGHT_GONE = 1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AppProcessInfo : public Parcelable {
|
||||||
|
std::string processName_;
|
||||||
|
std::int32_t pid_;
|
||||||
|
std::int32_t uid_;
|
||||||
|
AppProcessState state_;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static AppProcessInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APP_PROCESS_INFO_H
|
106
interfaces/innerkits/appexecfwk_base/include/appexecfwk_errors.h
Normal file
106
interfaces/innerkits/appexecfwk_base/include/appexecfwk_errors.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPEXECFWK_ERRORS_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPEXECFWK_ERRORS_H
|
||||||
|
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
|
||||||
|
enum {
|
||||||
|
APPEXECFWK_MODULE_COMMON = 0x00,
|
||||||
|
APPEXECFWK_MODULE_APPMGR = 0x01,
|
||||||
|
APPEXECFWK_MODULE_BUNDLEMGR = 0x02,
|
||||||
|
// Reserved 0x03 ~ 0x0f for new modules, Event related modules start from 0x10
|
||||||
|
APPEXECFWK_MODULE_EVENTMGR = 0x10
|
||||||
|
};
|
||||||
|
|
||||||
|
// Error code for Common
|
||||||
|
constexpr ErrCode APPEXECFWK_COMMON_ERR_OFFSET = ErrCodeOffset(SUBSYS_APPEXECFWK, APPEXECFWK_MODULE_COMMON);
|
||||||
|
enum {
|
||||||
|
ERR_APPEXECFWK_SERVICE_NOT_READY = APPEXECFWK_COMMON_ERR_OFFSET + 1,
|
||||||
|
ERR_APPEXECFWK_SERVICE_NOT_CONNECTED,
|
||||||
|
ERR_APPEXECFWK_INVALID_UID,
|
||||||
|
ERR_APPEXECFWK_INVALID_PID,
|
||||||
|
ERR_APPEXECFWK_PARCEL_ERROR,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Error code for AppMgr
|
||||||
|
constexpr ErrCode APPEXECFWK_APPMGR_ERR_OFFSET = ErrCodeOffset(SUBSYS_APPEXECFWK, APPEXECFWK_MODULE_APPMGR);
|
||||||
|
enum {
|
||||||
|
ERR_APPEXECFWK_ASSEMBLE_START_MSG_FAILED = APPEXECFWK_APPMGR_ERR_OFFSET + 1,
|
||||||
|
ERR_APPEXECFWK_CONNECT_APPSPAWN_FAILED,
|
||||||
|
ERR_APPEXECFWK_BAD_APPSPAWN_CLIENT,
|
||||||
|
ERR_APPEXECFWK_BAD_APPSPAWN_SOCKET,
|
||||||
|
ERR_APPEXECFWK_SOCKET_READ_FAILED,
|
||||||
|
ERR_APPEXECFWK_SOCKET_WRITE_FAILED
|
||||||
|
};
|
||||||
|
|
||||||
|
// Error code for BundleMgr
|
||||||
|
constexpr ErrCode APPEXECFWK_BUNDLEMGR_ERR_OFFSET = ErrCodeOffset(SUBSYS_APPEXECFWK, APPEXECFWK_MODULE_BUNDLEMGR);
|
||||||
|
enum {
|
||||||
|
// the install error code from 0x0001 ~ 0x0020.
|
||||||
|
ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0001,
|
||||||
|
ERR_APPEXECFWK_INSTALL_HOST_INSTALLER_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALL_PARSE_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALL_VERSION_DOWNGRADE,
|
||||||
|
ERR_APPEXECFWK_INSTALL_VERIFICATION_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALL_NO_SIGNATURE_INFO,
|
||||||
|
ERR_APPEXECFWK_INSTALL_UPDATE_INCOMPATIBLE,
|
||||||
|
ERR_APPEXECFWK_INSTALL_PARAM_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALL_PERMISSION_DENIED,
|
||||||
|
ERR_APPEXECFWK_INSTALL_ENTRY_ALREADY_EXIST,
|
||||||
|
ERR_APPEXECFWK_INSTALL_STATE_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID,
|
||||||
|
ERR_APPEXECFWK_INSTALL_INVALID_HAP_NAME,
|
||||||
|
ERR_APPEXECFWK_INSTALL_INVALID_BUNDLE_FILE,
|
||||||
|
ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALL_BUNDLE_MGR_SERVICE_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALL_ALREADY_EXIST,
|
||||||
|
|
||||||
|
ERR_APPEXECFWK_PARSE_UNEXPECTED = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0021,
|
||||||
|
ERR_APPEXECFWK_PARSE_MISSING_BUNDLE,
|
||||||
|
ERR_APPEXECFWK_PARSE_MISSING_ABILITY,
|
||||||
|
ERR_APPEXECFWK_PARSE_NO_PROFILE,
|
||||||
|
ERR_APPEXECFWK_PARSE_BAD_PROFILE,
|
||||||
|
ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR,
|
||||||
|
ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP,
|
||||||
|
ERR_APPEXECFWK_PARSE_PERMISSION_ERROR,
|
||||||
|
|
||||||
|
ERR_APPEXECFWK_INSTALLD_PARAM_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_CREATE_DIR_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_CREATE_DIR_EXIST,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_CHOWN_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_REMOVE_DIR_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_EXTRACT_FILES_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_RNAME_DIR_FAILED,
|
||||||
|
ERR_APPEXECFWK_INSTALLD_CLEAN_DIR_FAILED,
|
||||||
|
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_SYSTEM_APP_ERROR,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_KILLING_APP_ERROR,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_INVALID_NAME,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_PARAM_ERROR,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_PERMISSION_DENIED,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE,
|
||||||
|
ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_MODULE
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPEXECFWK_ERRORS_H
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
#include "module_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class ApplicationFlag {
|
||||||
|
// get the basic ApplicationInfo
|
||||||
|
GET_BASIC_APPLICATION_INFO = 0x00000000,
|
||||||
|
// get the ApplicationInfo with permission specified
|
||||||
|
GET_APPLICATION_INFO_WITH_PERMS = 0x00000008,
|
||||||
|
};
|
||||||
|
|
||||||
|
// configuration information about an application
|
||||||
|
struct ApplicationInfo : public Parcelable {
|
||||||
|
std::string name; // application name is same to bundleName
|
||||||
|
std::string bundleName;
|
||||||
|
std::string description;
|
||||||
|
std::string iconPath;
|
||||||
|
std::string label; // entity.system.home ability label
|
||||||
|
int32_t labelId = 0;
|
||||||
|
int32_t iconId = 0;
|
||||||
|
int32_t descriptionId = 0;
|
||||||
|
std::string deviceId; // should auto-get self device id.
|
||||||
|
std::string signatureKey; // the public key info of this application.
|
||||||
|
bool isSystemApp = false;
|
||||||
|
bool isLauncherApp = false;
|
||||||
|
int supportedModes = 0; // returns 0 if the application does not support the driving mode
|
||||||
|
std::string process;
|
||||||
|
std::vector<std::string> permissions;
|
||||||
|
std::vector<std::string> moduleSourceDirs;
|
||||||
|
std::vector<ModuleInfo> moduleInfos;
|
||||||
|
std::string entryDir;
|
||||||
|
std::string codePath;
|
||||||
|
std::string dataDir;
|
||||||
|
std::string dataBaseDir;
|
||||||
|
std::string cacheDir;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static ApplicationInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
void Dump(std::string prefix, int fd);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H
|
116
interfaces/innerkits/appexecfwk_base/include/bundle_constants.h
Executable file
116
interfaces/innerkits/appexecfwk_base/include/bundle_constants.h
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
namespace Constants {
|
||||||
|
|
||||||
|
const std::string EMPTY_STRING = "";
|
||||||
|
const std::string BUNDLE_PROFILE_NAME = "config.json";
|
||||||
|
const std::string INSTALL_FILE_SUFFIX = ".hap";
|
||||||
|
const std::string PATH_SEPARATOR = "/";
|
||||||
|
const std::string FILE_UNDERLINE = "_";
|
||||||
|
const std::string ILLEGAL_PATH_FIELD = "../";
|
||||||
|
const char DOT_SUFFIX = '.';
|
||||||
|
const std::string CURRENT_DEVICE_ID = "PHONE-001";
|
||||||
|
const std::string BUNDLE_DATA_BASE_DIR = "/data/bundlemgr";
|
||||||
|
const std::string BUNDLE_DATA_BASE_FILE = BUNDLE_DATA_BASE_DIR + "/bmsdb.json";
|
||||||
|
const std::string SYSTEM_APP_SCAN_PATH = "/system/app";
|
||||||
|
const std::string SYSTEM_APP_INSTALL_PATH = "/data/accounts";
|
||||||
|
const std::string THIRD_SYSTEM_APP_SCAN_PATH = "/system/vendor";
|
||||||
|
const std::string THIRD_SYSTEM_APP_INSTALL_PATH = "/data/accounts";
|
||||||
|
const std::string THIRD_PARTY_APP_INSTALL_PATH = "/data/accounts";
|
||||||
|
const std::string EXTRACT_TMP_PATH = "/data/sadata/install_tmp/bundle_haps";
|
||||||
|
const std::string HAP_COPY_PATH = "/data/sadata/install_tmp/Tmp_";
|
||||||
|
const std::string USER_ACCOUNT_DIR = "account";
|
||||||
|
const std::string APP_CODE_DIR = "applications";
|
||||||
|
const std::string APP_DATA_DIR = "appdata";
|
||||||
|
const std::string DATA_BASE_DIR = "database";
|
||||||
|
const std::string DATA_DIR = "files";
|
||||||
|
const std::string CACHE_DIR = "cache";
|
||||||
|
const std::string SHARED_DIR = "shared";
|
||||||
|
const std::string SHARED_PREFERENCE_DIR = "sharedPreference";
|
||||||
|
const std::string TMP_SUFFIX = "_tmp";
|
||||||
|
const std::string ASSETS_DIR = "assets";
|
||||||
|
const std::string RESOURCES_INDEX = "resources.index";
|
||||||
|
|
||||||
|
const std::string BMS_SERVICE_NAME = "BundleMgrService";
|
||||||
|
const std::string INSTALLD_SERVICE_NAME = "installd";
|
||||||
|
const std::string SYSTEM_APP = "system";
|
||||||
|
const std::string THIRD_PARTY_APP = "third-party";
|
||||||
|
constexpr int DEFAULT_USERID = 0;
|
||||||
|
constexpr int INVALID_USERID = -1;
|
||||||
|
constexpr int PATH_MAX_SIZE = 256;
|
||||||
|
constexpr int SIGNATURE_MATCHED = 0;
|
||||||
|
constexpr int SIGNATURE_NOT_MATCHED = 1;
|
||||||
|
constexpr int SIGNATURE_UNKNOWN_BUNDLE = 2;
|
||||||
|
constexpr int PERMISSION_GRANTED = 0;
|
||||||
|
constexpr int PERMISSION_NOT_GRANTED = -1;
|
||||||
|
constexpr int DUMP_INDENT = 4;
|
||||||
|
constexpr unsigned int INSTALLD_UMASK = 0000;
|
||||||
|
|
||||||
|
// uid and gid
|
||||||
|
constexpr int32_t INVALID_UID = -1;
|
||||||
|
constexpr int32_t INVALID_GID = -1;
|
||||||
|
constexpr int32_t ROOT_UID = 0;
|
||||||
|
constexpr int32_t BMS_UID = 1000;
|
||||||
|
constexpr int32_t BMS_GID = 1000;
|
||||||
|
constexpr int32_t BASE_SYS_UID = 2100;
|
||||||
|
constexpr int32_t MAX_SYS_UID = 2899;
|
||||||
|
constexpr int32_t BASE_SYS_VEN_UID = 5000;
|
||||||
|
constexpr int32_t MAX_SYS_VEN_UID = 5999;
|
||||||
|
constexpr int32_t BASE_APP_UID = 10000;
|
||||||
|
constexpr int32_t MAX_APP_UID = 65535;
|
||||||
|
const std::string PROFILE_KEY_UID_SIZE = "size";
|
||||||
|
const std::string PROFILE_KEY_UID_AND_GID = "uid_and_gid";
|
||||||
|
|
||||||
|
// permissions
|
||||||
|
const std::string PERMISSION_INSTALL_BUNDLE = "ohos.permission.INSTALL_BUNDLE";
|
||||||
|
|
||||||
|
enum class AppType {
|
||||||
|
SYSTEM_APP = 0,
|
||||||
|
THIRD_SYSTEM_APP,
|
||||||
|
THIRD_PARTY_APP,
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string INTENT_ACTION_HOME = "action.system.home";
|
||||||
|
const std::string INTENT_ENTITY_HOME = "entity.system.home";
|
||||||
|
const std::string FLAG_HW_HOME_INTENT_FROM_SYSTEM = "flag.home.intent.from.system";
|
||||||
|
|
||||||
|
// the ability file folder name.
|
||||||
|
const std::string LIB_FOLDER_NAME = "libs";
|
||||||
|
const std::string RES_FOLDER_NAME = "resources";
|
||||||
|
|
||||||
|
constexpr uint8_t MAX_LABLE_LEN = 30;
|
||||||
|
constexpr uint8_t MAX_BUNDLE_NAME = 255;
|
||||||
|
constexpr uint8_t MIN_BUNDLE_NAME = 7;
|
||||||
|
constexpr uint8_t MAX_VENDOR = 255;
|
||||||
|
constexpr uint8_t EQUAL_ZERO = 0;
|
||||||
|
constexpr uint8_t MAX_MODULE_PACKAGE = 127;
|
||||||
|
constexpr uint8_t MAX_MODULE_NAME = 255;
|
||||||
|
constexpr uint8_t MAX_MODULE_ABILITIES_READPERMISSION = 255;
|
||||||
|
constexpr uint8_t MAX_MODULE_ABILITIES_WRITEPERMISSION = 255;
|
||||||
|
constexpr uint8_t MAX_MODULE_SHORTCUTID = 63;
|
||||||
|
constexpr uint8_t MAX_MODULE_LABEL = 63;
|
||||||
|
|
||||||
|
} // namespace Constants
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H
|
83
interfaces/innerkits/appexecfwk_base/include/bundle_info.h
Normal file
83
interfaces/innerkits/appexecfwk_base/include/bundle_info.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class BundleFlag {
|
||||||
|
// get bundle info except abilityInfos
|
||||||
|
GET_BUNDLE_DEFAULT = 0x00000000,
|
||||||
|
// get bundle info include abilityInfos
|
||||||
|
GET_BUNDLE_WITH_ABILITIES = 0x00000001,
|
||||||
|
};
|
||||||
|
|
||||||
|
// configuration information about a bundle
|
||||||
|
struct BundleInfo : public Parcelable {
|
||||||
|
std::string name; // bundle name
|
||||||
|
std::string label; // name display on screen
|
||||||
|
std::string description; // detail description. When ResourceKit ready replace with descriptionId
|
||||||
|
std::string vendor;
|
||||||
|
uint32_t versionCode = 0;
|
||||||
|
std::string versionName;
|
||||||
|
std::string jointUserId;
|
||||||
|
int32_t minSdkVersion = -1; // The min SDK version this app can run on
|
||||||
|
int32_t maxSdkVersion = -1; // The max SDK version this app can run on
|
||||||
|
std::string mainEntry; // entry is path of ability main executable file
|
||||||
|
std::string cpuAbi;
|
||||||
|
std::string appId;
|
||||||
|
int compatibleVersion = 0;
|
||||||
|
int targetVersion = 0;
|
||||||
|
std::string releaseType;
|
||||||
|
int uid = -1;
|
||||||
|
int gid = -1;
|
||||||
|
std::string seInfo;
|
||||||
|
std::string entryModuleName;
|
||||||
|
bool isKeepAlive = false;
|
||||||
|
bool isNativeApp = false;
|
||||||
|
int64_t installTime = 0; // the installation time is the number of seconds elapsed since January 1,
|
||||||
|
// 1970 00:00:00 UTC. The time will be recalculated if the application is reinstalled
|
||||||
|
// after being uninstalled.
|
||||||
|
int64_t updateTime = 0; // the update time is the number of seconds elapsed since January 1,
|
||||||
|
// 1970 00:00:00 UTC. If the application is installed for the first time, the application
|
||||||
|
// update time is the same as the installation time.
|
||||||
|
ApplicationInfo applicationInfo;
|
||||||
|
std::vector<AbilityInfo> abilityInfos;
|
||||||
|
std::vector<std::string> reqPermissions;
|
||||||
|
std::vector<std::string> defPermissions; // the permissions required for accessing the application.
|
||||||
|
std::vector<std::string> hapModuleNames; // the "module.package" in each config.json
|
||||||
|
std::vector<std::string> moduleNames; // the "module.name" in each config.json
|
||||||
|
std::vector<std::string> modulePublicDirs; // the public paths of all modules of the application.
|
||||||
|
std::vector<std::string> moduleDirs; // the paths of all modules of the application.
|
||||||
|
std::vector<std::string> moduleResPaths; // the paths of all resources paths.
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static BundleInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H
|
85
interfaces/innerkits/appexecfwk_base/include/element_name.h
Normal file
85
interfaces/innerkits/appexecfwk_base/include/element_name.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class ElementName : public Parcelable {
|
||||||
|
/*
|
||||||
|
* How to locate unique Ability: deviceId/bundleName/abilityName
|
||||||
|
*/
|
||||||
|
public:
|
||||||
|
ElementName(const std::string &deviceId, const std::string &bundleName, const std::string &abilityName);
|
||||||
|
ElementName();
|
||||||
|
~ElementName();
|
||||||
|
|
||||||
|
std::string GetURI() const;
|
||||||
|
bool operator==(const ElementName &element) const;
|
||||||
|
|
||||||
|
inline void SetDeviceID(const std::string &id)
|
||||||
|
{
|
||||||
|
deviceId_ = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string GetDeviceID() const
|
||||||
|
{
|
||||||
|
return deviceId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetBundleName(const std::string &name)
|
||||||
|
{
|
||||||
|
bundleName_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string GetBundleName() const
|
||||||
|
{
|
||||||
|
return bundleName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetAbilityName(const std::string &name)
|
||||||
|
{
|
||||||
|
abilityName_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string GetAbilityName() const
|
||||||
|
{
|
||||||
|
return abilityName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static ElementName *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
void SetElementDeviceID(ElementName *element, const char *deviceId);
|
||||||
|
void SetElementBundleName(ElementName *element, const char *bundleName);
|
||||||
|
void SetElementAbilityName(ElementName *element, const char *abilityName);
|
||||||
|
void ClearElement(ElementName *element);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string deviceId_;
|
||||||
|
std::string bundleName_;
|
||||||
|
std::string abilityName_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_HAP_MODULE_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_HAP_MODULE_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
#include "ability_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
// configuration information about an module
|
||||||
|
struct HapModuleInfo : public Parcelable {
|
||||||
|
std::string name; // module.package in config.json
|
||||||
|
std::string moduleName; // module.name in config.json
|
||||||
|
std::string description;
|
||||||
|
std::string iconPath;
|
||||||
|
std::string label;
|
||||||
|
std::string backgroundImg;
|
||||||
|
int supportedModes = 0;
|
||||||
|
|
||||||
|
std::vector<std::string> reqCapabilities;
|
||||||
|
std::vector<std::string> deviceTypes;
|
||||||
|
std::vector<AbilityInfo> abilityInfos;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static HapModuleInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_HAP_MODULE_INFO_H
|
54
interfaces/innerkits/appexecfwk_base/include/install_param.h
Normal file
54
interfaces/innerkits/appexecfwk_base/include/install_param.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALL_PARAM_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALL_PARAM_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class InstallFlag {
|
||||||
|
NORMAL = 0,
|
||||||
|
// Allow to replace the existing bundle when the new version isn't lower than the old one.
|
||||||
|
// If the bundle does not exist, just like normal flag.
|
||||||
|
REPLACE_EXISTING = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class InstallLocation {
|
||||||
|
INTERNAL_ONLY = 1,
|
||||||
|
PREFER_EXTERNAL = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// provides parameters required for installing or uninstalling an application
|
||||||
|
struct InstallParam : public Parcelable {
|
||||||
|
InstallFlag installFlag = InstallFlag::NORMAL;
|
||||||
|
InstallLocation installLocation = InstallLocation::INTERNAL_ONLY;
|
||||||
|
int userId = 0;
|
||||||
|
// is keep user data while uninstall.
|
||||||
|
bool isKeepData = false;
|
||||||
|
|
||||||
|
// the parcel object function is not const.
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static InstallParam *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALL_PARAM_H
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_JSON_SERIALIZER_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_JSON_SERIALIZER_H
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "bundle_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* form_json and to_json is global static overload method, which need callback by json library,
|
||||||
|
* and can not rename this function, so don't named according UpperCamelCase style
|
||||||
|
*/
|
||||||
|
void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo);
|
||||||
|
void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo);
|
||||||
|
void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo);
|
||||||
|
void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInfo);
|
||||||
|
void to_json(nlohmann::json &jsonObject, const BundleInfo &bundleInfo);
|
||||||
|
void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo);
|
||||||
|
void to_json(nlohmann::json &jsonObject, const ModuleInfo &moduleInfo);
|
||||||
|
void from_json(const nlohmann::json &jsonObject, ModuleInfo &moduleInfo);
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_JSON_SERIALIZER_H
|
38
interfaces/innerkits/appexecfwk_base/include/module_info.h
Normal file
38
interfaces/innerkits/appexecfwk_base/include/module_info.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_MODULE_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_MODULE_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
// stores module information about an application
|
||||||
|
struct ModuleInfo : public Parcelable {
|
||||||
|
std::string moduleName; // the "name" in module part in config.json
|
||||||
|
std::string moduleSourceDir;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static ModuleInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_MODULE_INFO_H
|
45
interfaces/innerkits/appexecfwk_base/include/parcel_macro.h
Normal file
45
interfaces/innerkits/appexecfwk_base/include/parcel_macro.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PARCEL_MACRO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PARCEL_MACRO_H
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
#define READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(type, parcel, data) \
|
||||||
|
do { \
|
||||||
|
if (!(parcel).Read##type(data)) { \
|
||||||
|
APP_LOGE("fail to read %{public}s type from parcel", #type); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(type, parcel, data) \
|
||||||
|
do { \
|
||||||
|
if (!(parcel).Write##type(data)) { \
|
||||||
|
APP_LOGE("fail to write %{public}s type into parcel", #type); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PARCEL_MACRO_H
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PERMISSION_DEF_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PERMISSION_DEF_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
// provides known system security permissions.
|
||||||
|
struct PermissionDef : public Parcelable {
|
||||||
|
std::string permissionName;
|
||||||
|
std::string bundleName;
|
||||||
|
int grantMode = 0;
|
||||||
|
int availableScope = 0;
|
||||||
|
std::string label;
|
||||||
|
int labelId = 0;
|
||||||
|
std::string description;
|
||||||
|
int descriptionId = 0;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static PermissionDef *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_PERMISSION_DEF_H
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_RUNNING_PROCESS_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_RUNNING_PROCESS_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
#include "app_process_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
struct RunningProcessInfo : public Parcelable {
|
||||||
|
std::vector<AppProcessInfo> appProcessInfos;
|
||||||
|
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
static RunningProcessInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_RUNNING_PROCESS_INFO_H
|
261
interfaces/innerkits/appexecfwk_base/src/ability_info.cpp
Normal file
261
interfaces/innerkits/appexecfwk_base/src/ability_info.cpp
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
#include "json_serializer.h"
|
||||||
|
#include "bundle_constants.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const std::string JSON_KEY_PACKAGE = "package";
|
||||||
|
const std::string JSON_KEY_NAME = "name";
|
||||||
|
const std::string JSON_KEY_BUNDLE_NAME = "bundleName";
|
||||||
|
const std::string JSON_KEY_APPLICATION_NAME = "applicationName";
|
||||||
|
const std::string JSON_KEY_LABEL = "label";
|
||||||
|
const std::string JSON_KEY_DESCRIPTION = "description";
|
||||||
|
const std::string JSON_KEY_ICON_PATH = "iconPath";
|
||||||
|
const std::string JSON_KEY_VISIBLE = "visible";
|
||||||
|
const std::string JSON_KEY_KIND = "kind";
|
||||||
|
const std::string JSON_KEY_TYPE = "type";
|
||||||
|
const std::string JSON_KEY_ORIENTATION = "orientation";
|
||||||
|
const std::string JSON_KEY_LAUNCH_MODE = "launchMode";
|
||||||
|
const std::string JSON_KEY_CODE_PATH = "codePath";
|
||||||
|
const std::string JSON_KEY_RESOURCE_PATH = "resourcePath";
|
||||||
|
const std::string JSON_KEY_LIB_PATH = "libPath";
|
||||||
|
const std::string JSON_KEY_PERMISSIONS = "permissions";
|
||||||
|
const std::string JSON_KEY_PROCESS = "process";
|
||||||
|
const std::string JSON_KEY_DEVICE_TYPES = "deviceTypes";
|
||||||
|
const std::string JSON_KEY_DEVICE_CAPABILITIES = "deviceCapabilities";
|
||||||
|
const std::string JSON_KEY_URI = "uri";
|
||||||
|
const std::string JSON_KEY_MODULE_NAME = "moduleName";
|
||||||
|
const std::string JSON_KEY_DEVICE_ID = "deviceId";
|
||||||
|
const std::string JSON_KEY_IS_LAUNCHER_ABILITY = "isLauncherAbility";
|
||||||
|
const std::string JSON_KEY_IS_NATIVE_ABILITY = "isNativeAbility";
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool AbilityInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
name = Str16ToStr8(parcel.ReadString16());
|
||||||
|
label = Str16ToStr8(parcel.ReadString16());
|
||||||
|
description = Str16ToStr8(parcel.ReadString16());
|
||||||
|
iconPath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
kind = Str16ToStr8(parcel.ReadString16());
|
||||||
|
uri = Str16ToStr8(parcel.ReadString16());
|
||||||
|
package = Str16ToStr8(parcel.ReadString16());
|
||||||
|
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
moduleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
applicationName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
process = Str16ToStr8(parcel.ReadString16());
|
||||||
|
deviceId = Str16ToStr8(parcel.ReadString16());
|
||||||
|
codePath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
resourcePath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
libPath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
visible = parcel.ReadBool();
|
||||||
|
isLauncherAbility = parcel.ReadBool();
|
||||||
|
isNativeAbility = parcel.ReadBool();
|
||||||
|
|
||||||
|
int32_t typeData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, typeData);
|
||||||
|
type = static_cast<AbilityType>(typeData);
|
||||||
|
|
||||||
|
int32_t orientationData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, orientationData);
|
||||||
|
orientation = static_cast<DisplayOrientation>(orientationData);
|
||||||
|
|
||||||
|
int32_t launchModeData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, launchModeData);
|
||||||
|
launchMode = static_cast<LaunchMode>(launchModeData);
|
||||||
|
|
||||||
|
int32_t permissionsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, permissionsSize);
|
||||||
|
for (int32_t i = 0; i < permissionsSize; i++) {
|
||||||
|
permissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t deviceTypesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceTypesSize);
|
||||||
|
for (int32_t i = 0; i < deviceTypesSize; i++) {
|
||||||
|
deviceTypes.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t deviceCapabilitiesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceCapabilitiesSize);
|
||||||
|
for (int32_t i = 0; i < deviceCapabilitiesSize; i++) {
|
||||||
|
deviceCapabilities.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ApplicationInfo> appInfo(parcel.ReadParcelable<ApplicationInfo>());
|
||||||
|
if (!appInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<ApplicationInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
applicationInfo = *appInfo;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbilityInfo *AbilityInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
AbilityInfo *info = new (std::nothrow) AbilityInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AbilityInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(iconPath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(kind));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(uri));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(package));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(applicationName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(process));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceId));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(codePath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(resourcePath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(libPath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, visible);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isLauncherAbility);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isNativeAbility);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(type));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(orientation));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(launchMode));
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, permissions.size());
|
||||||
|
for (auto &permission : permissions) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceTypes.size());
|
||||||
|
for (auto &deviceType : deviceTypes) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceType));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceCapabilities.size());
|
||||||
|
for (auto &deviceCapability : deviceCapabilities) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceCapability));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &applicationInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbilityInfo::Dump(std::string prefix, int fd)
|
||||||
|
{
|
||||||
|
APP_LOGI("called dump Abilityinfo");
|
||||||
|
if (fd < 0) {
|
||||||
|
APP_LOGE("dump Abilityinfo fd error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int flags = fcntl(fd, F_GETFL);
|
||||||
|
if (flags < 0) {
|
||||||
|
APP_LOGE("dump Abilityinfo fcntl error %{public}s", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
flags &= O_ACCMODE;
|
||||||
|
if ((flags == O_WRONLY) || (flags == O_RDWR)) {
|
||||||
|
nlohmann::json jsonObject = *this;
|
||||||
|
std::string result;
|
||||||
|
result.append(prefix);
|
||||||
|
result.append(jsonObject.dump(Constants::DUMP_INDENT));
|
||||||
|
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
|
||||||
|
if (ret < 0) {
|
||||||
|
APP_LOGE("dump Abilityinfo write error %{public}s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo)
|
||||||
|
{
|
||||||
|
jsonObject = nlohmann::json{
|
||||||
|
{"name", abilityInfo.name},
|
||||||
|
{"label", abilityInfo.label},
|
||||||
|
{"description", abilityInfo.description},
|
||||||
|
{"iconPath", abilityInfo.iconPath},
|
||||||
|
{"visible", abilityInfo.visible},
|
||||||
|
{"isLauncherAbility", abilityInfo.isLauncherAbility},
|
||||||
|
{"isNativeAbility", abilityInfo.isNativeAbility},
|
||||||
|
{"kind", abilityInfo.kind},
|
||||||
|
{"type", abilityInfo.type},
|
||||||
|
{"orientation", abilityInfo.orientation},
|
||||||
|
{"launchMode", abilityInfo.launchMode},
|
||||||
|
{"permissions", abilityInfo.permissions},
|
||||||
|
{"process", abilityInfo.process},
|
||||||
|
{"deviceTypes", abilityInfo.deviceTypes},
|
||||||
|
{"deviceCapabilities", abilityInfo.deviceCapabilities},
|
||||||
|
{"uri", abilityInfo.uri},
|
||||||
|
{"package", abilityInfo.package},
|
||||||
|
{"bundleName", abilityInfo.bundleName},
|
||||||
|
{"moduleName", abilityInfo.moduleName},
|
||||||
|
{"applicationName", abilityInfo.applicationName},
|
||||||
|
{"deviceId", abilityInfo.deviceId},
|
||||||
|
{"codePath", abilityInfo.codePath},
|
||||||
|
{"resourcePath", abilityInfo.resourcePath},
|
||||||
|
{"libPath", abilityInfo.libPath}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo)
|
||||||
|
{
|
||||||
|
abilityInfo.name = jsonObject.at(JSON_KEY_NAME).get<std::string>();
|
||||||
|
abilityInfo.label = jsonObject.at(JSON_KEY_LABEL).get<std::string>();
|
||||||
|
abilityInfo.description = jsonObject.at(JSON_KEY_DESCRIPTION).get<std::string>();
|
||||||
|
abilityInfo.iconPath = jsonObject.at(JSON_KEY_ICON_PATH).get<std::string>();
|
||||||
|
abilityInfo.visible = jsonObject.at(JSON_KEY_VISIBLE).get<bool>();
|
||||||
|
abilityInfo.isLauncherAbility = jsonObject.at(JSON_KEY_IS_LAUNCHER_ABILITY).get<bool>();
|
||||||
|
abilityInfo.isNativeAbility = jsonObject.at(JSON_KEY_IS_NATIVE_ABILITY).get<bool>();
|
||||||
|
abilityInfo.kind = jsonObject.at(JSON_KEY_KIND).get<std::string>();
|
||||||
|
abilityInfo.type = jsonObject.at(JSON_KEY_TYPE).get<AbilityType>();
|
||||||
|
abilityInfo.orientation = jsonObject.at(JSON_KEY_ORIENTATION).get<DisplayOrientation>();
|
||||||
|
abilityInfo.launchMode = jsonObject.at(JSON_KEY_LAUNCH_MODE).get<LaunchMode>();
|
||||||
|
abilityInfo.permissions = jsonObject.at(JSON_KEY_PERMISSIONS).get<std::vector<std::string>>();
|
||||||
|
abilityInfo.process = jsonObject.at(JSON_KEY_PROCESS).get<std::string>();
|
||||||
|
abilityInfo.deviceTypes = jsonObject.at(JSON_KEY_DEVICE_TYPES).get<std::vector<std::string>>();
|
||||||
|
abilityInfo.deviceCapabilities = jsonObject.at(JSON_KEY_DEVICE_CAPABILITIES).get<std::vector<std::string>>();
|
||||||
|
abilityInfo.uri = jsonObject.at(JSON_KEY_URI).get<std::string>();
|
||||||
|
abilityInfo.package = jsonObject.at(JSON_KEY_PACKAGE).get<std::string>();
|
||||||
|
abilityInfo.bundleName = jsonObject.at(JSON_KEY_BUNDLE_NAME).get<std::string>();
|
||||||
|
abilityInfo.moduleName = jsonObject.at(JSON_KEY_MODULE_NAME).get<std::string>();
|
||||||
|
abilityInfo.applicationName = jsonObject.at(JSON_KEY_APPLICATION_NAME).get<std::string>();
|
||||||
|
abilityInfo.deviceId = jsonObject.at(JSON_KEY_DEVICE_ID).get<std::string>();
|
||||||
|
abilityInfo.codePath = jsonObject.at(JSON_KEY_CODE_PATH).get<std::string>();
|
||||||
|
abilityInfo.resourcePath = jsonObject.at(JSON_KEY_RESOURCE_PATH).get<std::string>();
|
||||||
|
abilityInfo.libPath = jsonObject.at(JSON_KEY_LIB_PATH).get<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_process_info.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const std::string JSON_KEY_PROCESSNAME = "processName";
|
||||||
|
const std::string JSON_KEY_PID = "pid";
|
||||||
|
const std::string JSON_KEY_STATE = "state";
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool AppProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
processName_ = Str16ToStr8(parcel.ReadString16());
|
||||||
|
int32_t typeData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, typeData);
|
||||||
|
pid_ = static_cast<int32_t>(typeData);
|
||||||
|
int32_t uidData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uidData);
|
||||||
|
uid_ = static_cast<int32_t>(uidData);
|
||||||
|
int32_t stateData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, stateData);
|
||||||
|
state_ = static_cast<AppProcessState>(stateData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppProcessInfo *AppProcessInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
AppProcessInfo *info = new (std::nothrow) AppProcessInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppProcessInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(processName_));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(pid_));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(uid_));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(state_));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
210
interfaces/innerkits/appexecfwk_base/src/application_info.cpp
Normal file
210
interfaces/innerkits/appexecfwk_base/src/application_info.cpp
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "application_info.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "bundle_constants.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
#include "json_serializer.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool ApplicationInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
name = Str16ToStr8(parcel.ReadString16());
|
||||||
|
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
description = Str16ToStr8(parcel.ReadString16());
|
||||||
|
iconPath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
label = Str16ToStr8(parcel.ReadString16());
|
||||||
|
deviceId = Str16ToStr8(parcel.ReadString16());
|
||||||
|
signatureKey = Str16ToStr8(parcel.ReadString16());
|
||||||
|
process = Str16ToStr8(parcel.ReadString16());
|
||||||
|
entryDir = Str16ToStr8(parcel.ReadString16());
|
||||||
|
codePath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
dataDir = Str16ToStr8(parcel.ReadString16());
|
||||||
|
dataBaseDir = Str16ToStr8(parcel.ReadString16());
|
||||||
|
cacheDir = Str16ToStr8(parcel.ReadString16());
|
||||||
|
isSystemApp = parcel.ReadBool();
|
||||||
|
isLauncherApp = parcel.ReadBool();
|
||||||
|
supportedModes = parcel.ReadInt32();
|
||||||
|
labelId = parcel.ReadInt32();
|
||||||
|
iconId = parcel.ReadInt32();
|
||||||
|
descriptionId = parcel.ReadInt32();
|
||||||
|
|
||||||
|
int32_t permissionsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, permissionsSize);
|
||||||
|
for (int32_t i = 0; i < permissionsSize; i++) {
|
||||||
|
permissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t moduleSourceDirsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleSourceDirsSize);
|
||||||
|
for (int32_t i = 0; i < moduleSourceDirsSize; i++) {
|
||||||
|
moduleSourceDirs.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t moduleInfosSize = parcel.ReadInt32();
|
||||||
|
for (int32_t i = 0; i < moduleInfosSize; i++) {
|
||||||
|
std::unique_ptr<ModuleInfo> moduleInfo(parcel.ReadParcelable<ModuleInfo>());
|
||||||
|
if (!moduleInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<ModuleInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
moduleInfos.emplace_back(*moduleInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationInfo *ApplicationInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
ApplicationInfo *info = new (std::nothrow) ApplicationInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ApplicationInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(iconPath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceId));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(signatureKey));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(process));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(entryDir));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(codePath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataDir));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataBaseDir));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(cacheDir));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isSystemApp);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isLauncherApp);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportedModes);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labelId);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, iconId);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, descriptionId);
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, permissions.size());
|
||||||
|
for (auto &permission : permissions) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleSourceDirs.size());
|
||||||
|
for (auto &moduleSourceDir : moduleSourceDirs) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleSourceDir));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleInfos.size());
|
||||||
|
for (auto &moduleInfo : moduleInfos) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &moduleInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationInfo::Dump(std::string prefix, int fd)
|
||||||
|
{
|
||||||
|
APP_LOGI("called dump ApplicationInfo");
|
||||||
|
if (fd < 0) {
|
||||||
|
APP_LOGE("dump ApplicationInfo fd error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int flags = fcntl(fd, F_GETFL);
|
||||||
|
if (flags < 0) {
|
||||||
|
APP_LOGE("dump ApplicationInfo fcntl error %{public}s", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
flags &= O_ACCMODE;
|
||||||
|
if ((flags == O_WRONLY) || (flags == O_RDWR)) {
|
||||||
|
nlohmann::json jsonObject = *this;
|
||||||
|
std::string result;
|
||||||
|
result.append(prefix);
|
||||||
|
result.append(jsonObject.dump(Constants::DUMP_INDENT));
|
||||||
|
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
|
||||||
|
if (ret < 0) {
|
||||||
|
APP_LOGE("dump ApplicationInfo write error %{public}s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo)
|
||||||
|
{
|
||||||
|
jsonObject = nlohmann::json{
|
||||||
|
{"name", applicationInfo.name},
|
||||||
|
{"bundleName", applicationInfo.bundleName},
|
||||||
|
{"description", applicationInfo.description},
|
||||||
|
{"iconPath", applicationInfo.iconPath},
|
||||||
|
{"label", applicationInfo.label},
|
||||||
|
{"labelId", applicationInfo.labelId},
|
||||||
|
{"descriptionId", applicationInfo.descriptionId},
|
||||||
|
{"iconId", applicationInfo.iconId},
|
||||||
|
{"deviceId", applicationInfo.deviceId},
|
||||||
|
{"signatureKey", applicationInfo.signatureKey},
|
||||||
|
{"isSystemApp", applicationInfo.isSystemApp},
|
||||||
|
{"isLauncherApp", applicationInfo.isLauncherApp},
|
||||||
|
{"supportedModes", applicationInfo.supportedModes},
|
||||||
|
{"process", applicationInfo.process},
|
||||||
|
{"permissions", applicationInfo.permissions},
|
||||||
|
{"moduleSourceDirs", applicationInfo.moduleSourceDirs},
|
||||||
|
{"moduleInfos", applicationInfo.moduleInfos},
|
||||||
|
{"entryDir", applicationInfo.entryDir},
|
||||||
|
{"codePath", applicationInfo.codePath},
|
||||||
|
{"dataDir", applicationInfo.dataDir},
|
||||||
|
{"dataBaseDir", applicationInfo.dataBaseDir},
|
||||||
|
{"cacheDir", applicationInfo.cacheDir}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInfo)
|
||||||
|
{
|
||||||
|
applicationInfo.name = jsonObject.at("name").get<std::string>();
|
||||||
|
applicationInfo.bundleName = jsonObject.at("bundleName").get<std::string>();
|
||||||
|
applicationInfo.description = jsonObject.at("description").get<std::string>();
|
||||||
|
applicationInfo.iconPath = jsonObject.at("iconPath").get<std::string>();
|
||||||
|
applicationInfo.label = jsonObject.at("label").get<std::string>();
|
||||||
|
applicationInfo.labelId = jsonObject.at("labelId").get<int32_t>();
|
||||||
|
applicationInfo.descriptionId = jsonObject.at("descriptionId").get<int32_t>();
|
||||||
|
applicationInfo.iconId = jsonObject.at("iconId").get<int32_t>();
|
||||||
|
applicationInfo.deviceId = jsonObject.at("deviceId").get<std::string>();
|
||||||
|
applicationInfo.signatureKey = jsonObject.at("signatureKey").get<std::string>();
|
||||||
|
applicationInfo.isSystemApp = jsonObject.at("isSystemApp").get<bool>();
|
||||||
|
applicationInfo.isLauncherApp = jsonObject.at("isLauncherApp").get<bool>();
|
||||||
|
applicationInfo.supportedModes = jsonObject.at("supportedModes").get<int>();
|
||||||
|
applicationInfo.process = jsonObject.at("process").get<std::string>();
|
||||||
|
applicationInfo.permissions = jsonObject.at("permissions").get<std::vector<std::string>>();
|
||||||
|
applicationInfo.moduleSourceDirs = jsonObject.at("moduleSourceDirs").get<std::vector<std::string>>();
|
||||||
|
applicationInfo.moduleInfos = jsonObject.at("moduleInfos").get<std::vector<ModuleInfo>>();
|
||||||
|
applicationInfo.entryDir = jsonObject.at("entryDir").get<std::string>();
|
||||||
|
applicationInfo.codePath = jsonObject.at("codePath").get<std::string>();
|
||||||
|
applicationInfo.dataDir = jsonObject.at("dataDir").get<std::string>();
|
||||||
|
applicationInfo.dataBaseDir = jsonObject.at("dataBaseDir").get<std::string>();
|
||||||
|
applicationInfo.cacheDir = jsonObject.at("cacheDir").get<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
270
interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp
Normal file
270
interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "bundle_info.h"
|
||||||
|
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "json_serializer.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool BundleInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
name = Str16ToStr8(parcel.ReadString16());
|
||||||
|
label = Str16ToStr8(parcel.ReadString16());
|
||||||
|
description = Str16ToStr8(parcel.ReadString16());
|
||||||
|
vendor = Str16ToStr8(parcel.ReadString16());
|
||||||
|
versionName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
mainEntry = Str16ToStr8(parcel.ReadString16());
|
||||||
|
cpuAbi = Str16ToStr8(parcel.ReadString16());
|
||||||
|
appId = Str16ToStr8(parcel.ReadString16());
|
||||||
|
entryModuleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
releaseType = Str16ToStr8(parcel.ReadString16());
|
||||||
|
jointUserId = Str16ToStr8(parcel.ReadString16());
|
||||||
|
seInfo = Str16ToStr8(parcel.ReadString16());
|
||||||
|
versionCode = parcel.ReadUint32();
|
||||||
|
minSdkVersion = parcel.ReadInt32();
|
||||||
|
maxSdkVersion = parcel.ReadInt32();
|
||||||
|
compatibleVersion = parcel.ReadInt32();
|
||||||
|
targetVersion = parcel.ReadInt32();
|
||||||
|
uid = parcel.ReadInt32();
|
||||||
|
gid = parcel.ReadInt32();
|
||||||
|
isKeepAlive = parcel.ReadBool();
|
||||||
|
isNativeApp = parcel.ReadBool();
|
||||||
|
installTime = parcel.ReadInt64();
|
||||||
|
updateTime = parcel.ReadInt64();
|
||||||
|
|
||||||
|
int32_t reqPermissionsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionsSize);
|
||||||
|
for (int32_t i = 0; i < reqPermissionsSize; i++) {
|
||||||
|
reqPermissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t defPermissionsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, defPermissionsSize);
|
||||||
|
for (int32_t i = 0; i < defPermissionsSize; i++) {
|
||||||
|
defPermissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t hapModuleNamesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleNamesSize);
|
||||||
|
for (int32_t i = 0; i < hapModuleNamesSize; i++) {
|
||||||
|
hapModuleNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t moduleNamesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleNamesSize);
|
||||||
|
for (int32_t i = 0; i < moduleNamesSize; i++) {
|
||||||
|
moduleNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t modulePublicDirsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, modulePublicDirsSize);
|
||||||
|
for (int32_t i = 0; i < modulePublicDirsSize; i++) {
|
||||||
|
modulePublicDirs.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t moduleDirsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleDirsSize);
|
||||||
|
for (int32_t i = 0; i < moduleDirsSize; i++) {
|
||||||
|
moduleDirs.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t moduleResPathsSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleResPathsSize);
|
||||||
|
for (int32_t i = 0; i < moduleResPathsSize; i++) {
|
||||||
|
moduleResPaths.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ApplicationInfo> appInfo(parcel.ReadParcelable<ApplicationInfo>());
|
||||||
|
if (!appInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<ApplicationInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
applicationInfo = *appInfo;
|
||||||
|
|
||||||
|
int32_t abilityInfosSize = parcel.ReadInt32();
|
||||||
|
for (int32_t i = 0; i < abilityInfosSize; i++) {
|
||||||
|
std::unique_ptr<AbilityInfo> abilityInfo(parcel.ReadParcelable<AbilityInfo>());
|
||||||
|
if (!abilityInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<AbilityInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
abilityInfos.emplace_back(*abilityInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BundleInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(vendor));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(versionName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(mainEntry));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(cpuAbi));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(appId));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(entryModuleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(releaseType));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(jointUserId));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(seInfo));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, versionCode);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, minSdkVersion);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, maxSdkVersion);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, compatibleVersion);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, targetVersion);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, gid);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepAlive);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isNativeApp);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, installTime);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, updateTime);
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissions.size());
|
||||||
|
for (auto &reqPermission : reqPermissions) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(reqPermission));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, defPermissions.size());
|
||||||
|
for (auto &defPermission : defPermissions) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(defPermission));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleNames.size());
|
||||||
|
for (auto &hapModuleName : hapModuleNames) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(hapModuleName));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleNames.size());
|
||||||
|
for (auto &moduleName : moduleNames) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, modulePublicDirs.size());
|
||||||
|
for (auto &modulePublicDir : modulePublicDirs) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(modulePublicDir));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleDirs.size());
|
||||||
|
for (auto &moduleDir : moduleDirs) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleDir));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleResPaths.size());
|
||||||
|
for (auto &moduleResPath : moduleResPaths) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleResPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &applicationInfo);
|
||||||
|
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, abilityInfos.size());
|
||||||
|
for (auto &abilityInfo : abilityInfos) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &abilityInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BundleInfo *BundleInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
BundleInfo *info = new (std::nothrow) BundleInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &jsonObject, const BundleInfo &bundleInfo)
|
||||||
|
{
|
||||||
|
jsonObject = nlohmann::json{
|
||||||
|
{"name", bundleInfo.name},
|
||||||
|
{"label", bundleInfo.label},
|
||||||
|
{"description", bundleInfo.description},
|
||||||
|
{"vendor", bundleInfo.vendor},
|
||||||
|
{"isKeepAlive", bundleInfo.isKeepAlive},
|
||||||
|
{"isNativeApp", bundleInfo.isNativeApp},
|
||||||
|
{"applicationInfo", bundleInfo.applicationInfo},
|
||||||
|
{"abilityInfos", bundleInfo.abilityInfos},
|
||||||
|
{"jointUserId", bundleInfo.jointUserId},
|
||||||
|
{"versionCode", bundleInfo.versionCode},
|
||||||
|
{"versionName", bundleInfo.versionName},
|
||||||
|
{"minSdkVersion", bundleInfo.minSdkVersion},
|
||||||
|
{"maxSdkVersion", bundleInfo.maxSdkVersion},
|
||||||
|
{"mainEntry", bundleInfo.mainEntry},
|
||||||
|
{"cpuAbi", bundleInfo.cpuAbi},
|
||||||
|
{"appId", bundleInfo.appId},
|
||||||
|
{"compatibleVersion", bundleInfo.compatibleVersion},
|
||||||
|
{"targetVersion", bundleInfo.targetVersion},
|
||||||
|
{"releaseType", bundleInfo.releaseType},
|
||||||
|
{"uid", bundleInfo.uid},
|
||||||
|
{"gid", bundleInfo.gid},
|
||||||
|
{"seInfo", bundleInfo.seInfo},
|
||||||
|
{"installTime", bundleInfo.installTime},
|
||||||
|
{"updateTime", bundleInfo.updateTime},
|
||||||
|
{"entryModuleName", bundleInfo.entryModuleName},
|
||||||
|
{"reqPermissions", bundleInfo.reqPermissions},
|
||||||
|
{"defPermissions", bundleInfo.defPermissions},
|
||||||
|
{"hapModuleNames", bundleInfo.hapModuleNames},
|
||||||
|
{"moduleNames", bundleInfo.moduleNames},
|
||||||
|
{"modulePublicDirs", bundleInfo.modulePublicDirs},
|
||||||
|
{"moduleDirs", bundleInfo.moduleDirs},
|
||||||
|
{"moduleResPaths", bundleInfo.moduleResPaths}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo)
|
||||||
|
{
|
||||||
|
bundleInfo.name = jsonObject.at("name").get<std::string>();
|
||||||
|
bundleInfo.label = jsonObject.at("label").get<std::string>();
|
||||||
|
bundleInfo.description = jsonObject.at("description").get<std::string>();
|
||||||
|
bundleInfo.vendor = jsonObject.at("vendor").get<std::string>();
|
||||||
|
bundleInfo.isKeepAlive = jsonObject.at("isKeepAlive").get<bool>();
|
||||||
|
bundleInfo.isNativeApp = jsonObject.at("isNativeApp").get<bool>();
|
||||||
|
bundleInfo.applicationInfo = jsonObject.at("applicationInfo").get<ApplicationInfo>();
|
||||||
|
bundleInfo.abilityInfos = jsonObject.at("abilityInfos").get<std::vector<AbilityInfo>>();
|
||||||
|
bundleInfo.versionCode = jsonObject.at("versionCode").get<uint32_t>();
|
||||||
|
bundleInfo.versionName = jsonObject.at("versionName").get<std::string>();
|
||||||
|
bundleInfo.jointUserId = jsonObject.at("jointUserId").get<std::string>();
|
||||||
|
bundleInfo.minSdkVersion = jsonObject.at("minSdkVersion").get<int32_t>();
|
||||||
|
bundleInfo.maxSdkVersion = jsonObject.at("maxSdkVersion").get<int32_t>();
|
||||||
|
bundleInfo.mainEntry = jsonObject.at("mainEntry").get<std::string>();
|
||||||
|
bundleInfo.cpuAbi = jsonObject.at("cpuAbi").get<std::string>();
|
||||||
|
bundleInfo.appId = jsonObject.at("appId").get<std::string>();
|
||||||
|
bundleInfo.compatibleVersion = jsonObject.at("compatibleVersion").get<int>();
|
||||||
|
bundleInfo.targetVersion = jsonObject.at("targetVersion").get<int>();
|
||||||
|
bundleInfo.releaseType = jsonObject.at("releaseType").get<std::string>();
|
||||||
|
bundleInfo.uid = jsonObject.at("uid").get<int>();
|
||||||
|
bundleInfo.gid = jsonObject.at("gid").get<int>();
|
||||||
|
bundleInfo.seInfo = jsonObject.at("seInfo").get<std::string>();
|
||||||
|
bundleInfo.installTime = jsonObject.at("installTime").get<int64_t>();
|
||||||
|
bundleInfo.updateTime = jsonObject.at("updateTime").get<int64_t>();
|
||||||
|
bundleInfo.entryModuleName = jsonObject.at("entryModuleName").get<std::string>();
|
||||||
|
bundleInfo.reqPermissions = jsonObject.at("reqPermissions").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.defPermissions = jsonObject.at("defPermissions").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.hapModuleNames = jsonObject.at("hapModuleNames").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.moduleNames = jsonObject.at("moduleNames").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.modulePublicDirs = jsonObject.at("modulePublicDirs").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.moduleDirs = jsonObject.at("moduleDirs").get<std::vector<std::string>>();
|
||||||
|
bundleInfo.moduleResPaths = jsonObject.at("moduleResPaths").get<std::vector<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
115
interfaces/innerkits/appexecfwk_base/src/element_name.cpp
Normal file
115
interfaces/innerkits/appexecfwk_base/src/element_name.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "element_name.h"
|
||||||
|
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
void ElementName::SetElementDeviceID(ElementName *element, const char *deviceId)
|
||||||
|
{
|
||||||
|
if (element == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element->SetDeviceID(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElementName::SetElementBundleName(ElementName *element, const char *bundleName)
|
||||||
|
{
|
||||||
|
if (element == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element->SetBundleName(bundleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElementName::SetElementAbilityName(ElementName *element, const char *abilityName)
|
||||||
|
{
|
||||||
|
if (element == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element->SetAbilityName(abilityName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElementName::ClearElement(ElementName *element)
|
||||||
|
{
|
||||||
|
if (element == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element->SetDeviceID("");
|
||||||
|
element->SetBundleName("");
|
||||||
|
element->SetAbilityName("");
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementName::ElementName(const std::string &deviceId, const std::string &bundleName, const std::string &abilityName)
|
||||||
|
: deviceId_(deviceId), bundleName_(bundleName), abilityName_(abilityName)
|
||||||
|
{
|
||||||
|
APP_LOGD("instance is created with parameters");
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementName::ElementName()
|
||||||
|
{
|
||||||
|
APP_LOGD("instance is created without parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementName::~ElementName()
|
||||||
|
{
|
||||||
|
APP_LOGD("instance is destroyed");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ElementName::GetURI() const
|
||||||
|
{
|
||||||
|
return deviceId_ + "/" + bundleName_ + "/" + abilityName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ElementName::operator==(const ElementName &element) const
|
||||||
|
{
|
||||||
|
return (deviceId_ == element.GetDeviceID() && bundleName_ == element.GetBundleName() &&
|
||||||
|
abilityName_ == element.GetAbilityName());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ElementName::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
bundleName_ = Str16ToStr8(parcel.ReadString16());
|
||||||
|
abilityName_ = Str16ToStr8(parcel.ReadString16());
|
||||||
|
deviceId_ = Str16ToStr8(parcel.ReadString16());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementName *ElementName::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
ElementName *elementName = new (std::nothrow) ElementName();
|
||||||
|
if (elementName && !elementName->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete elementName;
|
||||||
|
elementName = nullptr;
|
||||||
|
}
|
||||||
|
return elementName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ElementName::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName_));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(abilityName_));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceId_));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
97
interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp
Normal file
97
interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hap_module_info.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool HapModuleInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
name = Str16ToStr8(parcel.ReadString16());
|
||||||
|
moduleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
description = Str16ToStr8(parcel.ReadString16());
|
||||||
|
iconPath = Str16ToStr8(parcel.ReadString16());
|
||||||
|
label = Str16ToStr8(parcel.ReadString16());
|
||||||
|
backgroundImg = Str16ToStr8(parcel.ReadString16());
|
||||||
|
supportedModes = parcel.ReadInt32();
|
||||||
|
|
||||||
|
int32_t reqCapabilitiesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqCapabilitiesSize);
|
||||||
|
for (int32_t i = 0; i < reqCapabilitiesSize; i++) {
|
||||||
|
reqCapabilities.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t deviceTypesSize;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceTypesSize);
|
||||||
|
for (int32_t i = 0; i < deviceTypesSize; i++) {
|
||||||
|
deviceTypes.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t abilityInfosSize = parcel.ReadInt32();
|
||||||
|
for (int32_t i = 0; i < abilityInfosSize; i++) {
|
||||||
|
std::unique_ptr<AbilityInfo> abilityInfo(parcel.ReadParcelable<AbilityInfo>());
|
||||||
|
if (!abilityInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<AbilityInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
abilityInfos.emplace_back(*abilityInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
HapModuleInfo *HapModuleInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
HapModuleInfo *info = new (std::nothrow) HapModuleInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HapModuleInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(iconPath));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(backgroundImg));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportedModes);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqCapabilities.size());
|
||||||
|
for (auto &reqCapability : reqCapabilities) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(reqCapability));
|
||||||
|
}
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceTypes.size());
|
||||||
|
for (auto &deviceType : deviceTypes) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deviceType));
|
||||||
|
}
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, abilityInfos.size());
|
||||||
|
for (auto &abilityInfo : abilityInfos) {
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &abilityInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
63
interfaces/innerkits/appexecfwk_base/src/install_param.cpp
Normal file
63
interfaces/innerkits/appexecfwk_base/src/install_param.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "install_param.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool InstallParam::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
int32_t flagData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, flagData);
|
||||||
|
installFlag = static_cast<InstallFlag>(flagData);
|
||||||
|
|
||||||
|
int32_t locationData;
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, locationData);
|
||||||
|
installLocation = static_cast<InstallLocation>(locationData);
|
||||||
|
|
||||||
|
userId = parcel.ReadInt32();
|
||||||
|
isKeepData = parcel.ReadBool();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
InstallParam *InstallParam::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
InstallParam *info = new (std::nothrow) InstallParam();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InstallParam::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(installFlag));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(installLocation));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
67
interfaces/innerkits/appexecfwk_base/src/module_info.cpp
Normal file
67
interfaces/innerkits/appexecfwk_base/src/module_info.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module_info.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool ModuleInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
moduleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
moduleSourceDir = Str16ToStr8(parcel.ReadString16());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModuleInfo *ModuleInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
ModuleInfo *info = new (std::nothrow) ModuleInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModuleInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleSourceDir));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &jsonObject, const ModuleInfo &moduleInfo)
|
||||||
|
{
|
||||||
|
jsonObject = nlohmann::json{
|
||||||
|
{"moduleName", moduleInfo.moduleName},
|
||||||
|
{"moduleSourceDir", moduleInfo.moduleSourceDir}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &jsonObject, ModuleInfo &moduleInfo)
|
||||||
|
{
|
||||||
|
moduleInfo.moduleName = jsonObject.at("moduleName").get<std::string>();
|
||||||
|
moduleInfo.moduleSourceDir = jsonObject.at("moduleSourceDir").get<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
65
interfaces/innerkits/appexecfwk_base/src/permission_def.cpp
Normal file
65
interfaces/innerkits/appexecfwk_base/src/permission_def.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "permission_def.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool PermissionDef::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
permissionName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||||
|
label = Str16ToStr8(parcel.ReadString16());
|
||||||
|
description = Str16ToStr8(parcel.ReadString16());
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, availableScope);
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, grantMode);
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labelId);
|
||||||
|
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, descriptionId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionDef *PermissionDef::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
PermissionDef *info = new (std::nothrow) PermissionDef();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PermissionDef::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(permissionName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, availableScope);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, grantMode);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labelId);
|
||||||
|
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, descriptionId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "running_process_info.h"
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "parcel_macro.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool RunningProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
int32_t processInfoSize = parcel.ReadInt32();
|
||||||
|
for (int32_t i = 0; i < processInfoSize; i++) {
|
||||||
|
std::unique_ptr<AppProcessInfo> appProcessInfo(parcel.ReadParcelable<AppProcessInfo>());
|
||||||
|
if (!appProcessInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<appProcessInfo> failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
appProcessInfos.emplace_back(*appProcessInfo);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RunningProcessInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
size_t appProcessInfoSize = appProcessInfos.size();
|
||||||
|
if (!parcel.WriteInt32(appProcessInfoSize)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < appProcessInfoSize; i++) {
|
||||||
|
if (!parcel.WriteParcelable(&appProcessInfos[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RunningProcessInfo *RunningProcessInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
RunningProcessInfo *info = new (std::nothrow) RunningProcessInfo();
|
||||||
|
if (info && !info->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("read from parcel failed");
|
||||||
|
delete info;
|
||||||
|
info = nullptr;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
100
interfaces/innerkits/appexecfwk_core/BUILD.gn
Normal file
100
interfaces/innerkits/appexecfwk_core/BUILD.gn
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
import("//foundation/appexecfwk/standard/appexecfwk.gni")
|
||||||
|
|
||||||
|
config("appmgr_sdk_config") {
|
||||||
|
include_dirs = [
|
||||||
|
"include/appmgr",
|
||||||
|
"//foundation/aafwk/standard/frameworks/kits/ability/native/include",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("bundlemgr_sdk_config") {
|
||||||
|
include_dirs = [ "include/bundlemgr" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("appexecfwk_core_config") {
|
||||||
|
include_dirs = [ "include" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
ohos_shared_library("appexecfwk_core") {
|
||||||
|
include_dirs = [
|
||||||
|
"//third_party/json/include",
|
||||||
|
"${services_path}/appmgr/include",
|
||||||
|
"${services_path}/bundlemgr/include",
|
||||||
|
"//utils/system/safwk/native/include",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"src/appmgr/ams_mgr_proxy.cpp",
|
||||||
|
"src/appmgr/ams_mgr_stub.cpp",
|
||||||
|
"src/appmgr/app_launch_data.cpp",
|
||||||
|
"src/appmgr/app_mgr_client.cpp",
|
||||||
|
"src/appmgr/app_mgr_proxy.cpp",
|
||||||
|
"src/appmgr/app_mgr_stub.cpp",
|
||||||
|
"src/appmgr/app_process_data.cpp",
|
||||||
|
"src/appmgr/app_record_id.cpp",
|
||||||
|
"src/appmgr/app_scheduler_host.cpp",
|
||||||
|
"src/appmgr/app_scheduler_proxy.cpp",
|
||||||
|
"src/appmgr/app_service_manager.cpp",
|
||||||
|
"src/appmgr/app_state_callback_host.cpp",
|
||||||
|
"src/appmgr/app_state_callback_proxy.cpp",
|
||||||
|
"src/appmgr/app_task_info.cpp",
|
||||||
|
"src/appmgr/dummy_configuration.cpp",
|
||||||
|
"src/appmgr/priority_object.cpp",
|
||||||
|
"src/appmgr/process_info.cpp",
|
||||||
|
"src/appmgr/profile.cpp",
|
||||||
|
"src/bundlemgr/bundle_installer_proxy.cpp",
|
||||||
|
"src/bundlemgr/bundle_mgr_host.cpp",
|
||||||
|
"src/bundlemgr/bundle_mgr_proxy.cpp",
|
||||||
|
"src/bundlemgr/bundle_status_callback_host.cpp",
|
||||||
|
"src/bundlemgr/bundle_status_callback_proxy.cpp",
|
||||||
|
"src/bundlemgr/clean_cache_callback_host.cpp",
|
||||||
|
"src/bundlemgr/clean_cache_callback_proxy.cpp",
|
||||||
|
"src/bundlemgr/status_receiver_host.cpp",
|
||||||
|
"src/bundlemgr/status_receiver_proxy.cpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
public_configs = [
|
||||||
|
":appexecfwk_core_config",
|
||||||
|
":appmgr_sdk_config",
|
||||||
|
":bundlemgr_sdk_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = [
|
||||||
|
"APP_LOG_TAG = \"AppexecfwkCore\"",
|
||||||
|
"LOG_DOMAIN = 0xD001100",
|
||||||
|
]
|
||||||
|
cflags = []
|
||||||
|
if (target_cpu == "arm") {
|
||||||
|
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||||
|
}
|
||||||
|
deps = [
|
||||||
|
"${common_path}:libappexecfwk_common",
|
||||||
|
"//foundation/aafwk/standard/interfaces/innerkits/base:base",
|
||||||
|
"//foundation/aafwk/standard/interfaces/innerkits/want:want",
|
||||||
|
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||||
|
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||||
|
"//utils/native/base:utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
external_deps = [
|
||||||
|
"hiviewdfx_hilog_native:libhilog",
|
||||||
|
"ipc:ipc_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
subsystem_name = "appexecfwk"
|
||||||
|
part_name = "appexecfwk_standard"
|
||||||
|
}
|
29
interfaces/innerkits/appexecfwk_core/appexecfwk_headers.gni
Normal file
29
interfaces/innerkits/appexecfwk_core/appexecfwk_headers.gni
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
appexecfwk_headers = {
|
||||||
|
header_files = [
|
||||||
|
"appmgr/app_mgr_client.h",
|
||||||
|
"appmgr/iapp_state_callback.h",
|
||||||
|
"appmgr/app_state_callback_host.h",
|
||||||
|
"appmgr/app_mgr_constants.h",
|
||||||
|
"bundlemgr/bundle_installer_interface.h",
|
||||||
|
"bundlemgr/bundle_mgr_interface.h",
|
||||||
|
"bundlemgr/bundle_status_callback_interface.h",
|
||||||
|
"bundlemgr/clean_cache_callback_interface.h",
|
||||||
|
"bundlemgr/status_receiver_interface.h",
|
||||||
|
"appmgr/app_process_data.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
header_base = "interfaces/innerkits/appexecfwk_core/include"
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
#include "app_record_id.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class IAmsMgr : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IAmsMgr");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LoadAbility, call LoadAbility() through proxy project, load the ability that needed to be started.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to start the ability.
|
||||||
|
* @param preToken, the unique identification to call the ability.
|
||||||
|
* @param abilityInfo, the ability information.
|
||||||
|
* @param appInfo, the app information.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TerminateAbility, call TerminateAbility() through the proxy object, terminate the token ability.
|
||||||
|
*
|
||||||
|
* @param token, token, he unique identification to terminate the ability.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void TerminateAbility(const sptr<IRemoteObject> &token) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateAbilityState, call UpdateAbilityState() through the proxy object, update the ability status.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to update the ability.
|
||||||
|
* @param state, ability status that needs to be updated.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RegisterAppStateCallback, call RegisterAppStateCallback() through the proxy object, register the callback.
|
||||||
|
*
|
||||||
|
* @param callback, Ams register the callback.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void RegisterAppStateCallback(const sptr<IAppStateCallback> &callback) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset,call Reset() through the proxy object, reset DFX of AppMgr.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void Reset() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityBehaviorAnalysis,call AbilityBehaviorAnalysis() through the proxy object,
|
||||||
|
* ability behavior analysis assistant process optimization.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to start the ability.
|
||||||
|
* @param preToken, the unique identification to call the ability.
|
||||||
|
* @param visibility, the visibility information about windows info.
|
||||||
|
* @param perceptibility, the Perceptibility information about windows info.
|
||||||
|
* @param connectionState, the service ability connection state.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const int32_t visibility, const int32_t perceptibility, const int32_t connectionState) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object,
|
||||||
|
* kill the process by ability token.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to the ability.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void KillProcessByAbilityToken(const sptr<IRemoteObject> &token) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillApplication, call KillApplication() through proxy object, kill the application.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int KillApplication(const std::string &bundleName) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
AMS_LOAD_ABILITY = 0,
|
||||||
|
AMS_TERMINATE_ABILITY,
|
||||||
|
AMS_UPDATE_ABILITY_STATE,
|
||||||
|
AMS_REGISTER_APP_STATE_CALLBACK,
|
||||||
|
AMS_RESET,
|
||||||
|
AMS_ABILITY_BEHAVIOR_ANALYSIS,
|
||||||
|
AMS_KILL_PEOCESS_BY_ABILITY_TOKEN,
|
||||||
|
AMS_KILL_APPLICATION,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_INTERFACE_H
|
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_CLIENT_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_CLIENT_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "ams_mgr_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AmsMgrProxy : public IRemoteProxy<IAmsMgr> {
|
||||||
|
public:
|
||||||
|
explicit AmsMgrProxy(const sptr<IRemoteObject> &impl);
|
||||||
|
virtual ~AmsMgrProxy() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LoadAbility, call LoadAbility() through proxy project, load the ability that needed to be started.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to start the ability.
|
||||||
|
* @param preToken, the unique identification to call the ability.
|
||||||
|
* @param abilityInfo, the ability information.
|
||||||
|
* @param appInfo, the app information.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TerminateAbility, call TerminateAbility() through the proxy object, terminate the token ability.
|
||||||
|
*
|
||||||
|
* @param token, token, he unique identification to terminate the ability.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void TerminateAbility(const sptr<IRemoteObject> &token) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateAbilityState, call UpdateAbilityState() through the proxy object, update the ability status.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to update the ability.
|
||||||
|
* @param state, ability status that needs to be updated.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RegisterAppStateCallback, call RegisterAppStateCallback() through the proxy object, register the callback.
|
||||||
|
*
|
||||||
|
* @param callback, Ams register the callback.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void RegisterAppStateCallback(const sptr<IAppStateCallback> &callback) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset,call Reset() through the proxy object, reset DFX of AppMgr.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void Reset() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityBehaviorAnalysis,call AbilityBehaviorAnalysis() through the proxy object,
|
||||||
|
* ability behavior analysis assistant process optimization.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to start the ability.
|
||||||
|
* @param preToken, the unique identification to call the ability.
|
||||||
|
* @param visibility, the visibility information about windows info.
|
||||||
|
* @param perceptibility, the Perceptibility information about windows info.
|
||||||
|
* @param connectionState, the service ability connection state.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const int32_t visibility, const int32_t perceptibility, const int32_t connectionState) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object,
|
||||||
|
* kill the process by ability token.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to the ability.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void KillProcessByAbilityToken(const sptr<IRemoteObject> &token) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillApplication, call KillApplication() through proxy object, kill the application.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int32_t KillApplication(const std::string &bundleName) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool WriteInterfaceToken(MessageParcel &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline BrokerDelegator<AmsMgrProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_CLIENT_H
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_STUB_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_STUB_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "string_ex.h"
|
||||||
|
#include "ams_mgr_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AmsMgrStub : public IRemoteStub<IAmsMgr> {
|
||||||
|
public:
|
||||||
|
AmsMgrStub();
|
||||||
|
virtual ~AmsMgrStub();
|
||||||
|
|
||||||
|
virtual int OnRemoteRequest(
|
||||||
|
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t HandleLoadAbility(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleTerminateAbility(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleUpdateAbilityState(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleRegisterAppStateCallback(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleReset(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleAbilityBehaviorAnalysis(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleKillProcessByAbilityToken(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleKillApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
using AmsMgrFunc = int32_t (AmsMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||||
|
std::map<uint32_t, AmsMgrFunc> memberFuncMap_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_MOVE(AmsMgrStub);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_AMS_MGR_STUB_H
|
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
#include "application_info.h"
|
||||||
|
#include "process_info.h"
|
||||||
|
#include "profile.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppLaunchData : public Parcelable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief setting information for the application.
|
||||||
|
*
|
||||||
|
* @param ApplicationInfo&, the current application info.
|
||||||
|
*/
|
||||||
|
void SetApplicationInfo(const ApplicationInfo &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting information for the profile.
|
||||||
|
*
|
||||||
|
* @param Profile&, the current profile.
|
||||||
|
*/
|
||||||
|
void SetProfile(const Profile &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting information for the process.
|
||||||
|
*
|
||||||
|
* @param Profile&, the current process info.
|
||||||
|
*/
|
||||||
|
void SetProcessInfo(const ProcessInfo &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting id for app record.
|
||||||
|
*
|
||||||
|
* @param int32_t, the current app record id.
|
||||||
|
*/
|
||||||
|
void SetRecordId(const int32_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting id for User.
|
||||||
|
*
|
||||||
|
* @param int32_t, the current app User.
|
||||||
|
*/
|
||||||
|
void SetUId(const int32_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the info of the application.
|
||||||
|
*
|
||||||
|
* @return Returns the current application info.
|
||||||
|
*/
|
||||||
|
inline const ApplicationInfo &GetApplicationInfo() const
|
||||||
|
{
|
||||||
|
return applicationInfo_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the profile.
|
||||||
|
*
|
||||||
|
* @return Returns the current profile.
|
||||||
|
*/
|
||||||
|
inline const Profile &GetProfile() const
|
||||||
|
{
|
||||||
|
return profile_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the info of the process.
|
||||||
|
*
|
||||||
|
* @return Returns the current process info.
|
||||||
|
*/
|
||||||
|
inline const ProcessInfo &GetProcessInfo() const
|
||||||
|
{
|
||||||
|
return processInfo_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the id of the app record.
|
||||||
|
*
|
||||||
|
* @return Returns the current appRecord id.
|
||||||
|
*/
|
||||||
|
inline int32_t GetRecordId() const
|
||||||
|
{
|
||||||
|
return recordId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the id of the User.
|
||||||
|
*
|
||||||
|
* @return Returns the current User id.
|
||||||
|
*/
|
||||||
|
inline int32_t GetUId() const
|
||||||
|
{
|
||||||
|
return uId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static AppLaunchData *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ApplicationInfo applicationInfo_;
|
||||||
|
Profile profile_;
|
||||||
|
ProcessInfo processInfo_;
|
||||||
|
int32_t recordId_ = 0;
|
||||||
|
int32_t uId_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H
|
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_MGR_CLIENT_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_MGR_CLIENT_H
|
||||||
|
|
||||||
|
#include "iremote_object.h"
|
||||||
|
#include "refbase.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
#include "running_process_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppServiceManager;
|
||||||
|
|
||||||
|
class AppMgrClient {
|
||||||
|
public:
|
||||||
|
AppMgrClient();
|
||||||
|
virtual ~AppMgrClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load ability.
|
||||||
|
*
|
||||||
|
* @param token, Ability identify.
|
||||||
|
* @param abilityInfo, Ability information.
|
||||||
|
* @param appInfo, Application information.
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const AbilityInfo &abilityInfo, const ApplicationInfo &appInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminate ability.
|
||||||
|
*
|
||||||
|
* @param token Ability identify.
|
||||||
|
*
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode TerminateAbility(const sptr<IRemoteObject> &token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update ability state.
|
||||||
|
*
|
||||||
|
* @param token Ability identify.
|
||||||
|
* @param state Ability running state.
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Application state callback.
|
||||||
|
*
|
||||||
|
* @param callback IAppStateCallback
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode RegisterAppStateCallback(const sptr<IAppStateCallback> &callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect service.
|
||||||
|
*
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode ConnectAppMgrService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ability manager resst.
|
||||||
|
*
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode Reset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityBehaviorAnalysis, ability behavior analysis assistant process optimization.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to start the ability.
|
||||||
|
* @param preToken, the unique identification to call the ability.
|
||||||
|
* @param visibility, the visibility information about windows info.
|
||||||
|
* @param perceptibility, the Perceptibility information about windows info.
|
||||||
|
* @param connectionState, the service ability connection state.
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token,
|
||||||
|
const sptr<IRemoteObject> &preToken, const int32_t visibility, const int32_t perceptibility,
|
||||||
|
const int32_t connectionState);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object,
|
||||||
|
* kill the process by ability token.
|
||||||
|
*
|
||||||
|
* @param token, the unique identification to the ability.
|
||||||
|
* @return Returns RESULT_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode KillProcessByAbilityToken(const sptr<IRemoteObject> &token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KillApplication, call KillApplication() through proxy object, kill the application.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode KillApplication(const std::string &bundleName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||||
|
* clear the application data.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode ClearUpApplicationData(const std::string &bundleName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||||
|
* Obtains information about application processes that are running on the device.
|
||||||
|
*
|
||||||
|
* @param runningProcessInfo, app name in Application record.
|
||||||
|
* @return ERR_OK ,return back success,others fail.
|
||||||
|
*/
|
||||||
|
virtual AppMgrResultCode GetAllRunningProcesses(std::shared_ptr<RunningProcessInfo> &runningProcessInfo);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<AppServiceManager> serviceManager_;
|
||||||
|
sptr<IRemoteObject> remote_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_MGR_CLIENT_H
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CONSTANTS_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CONSTANTS_H
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
namespace Constants {
|
||||||
|
|
||||||
|
const std::string APP_MGR_SERVICE_NAME = "AppMgrService";
|
||||||
|
|
||||||
|
} // namespace Constants
|
||||||
|
|
||||||
|
enum class ApplicationState {
|
||||||
|
APP_STATE_BEGIN = 0,
|
||||||
|
APP_STATE_CREATE = APP_STATE_BEGIN,
|
||||||
|
APP_STATE_READY,
|
||||||
|
APP_STATE_FOREGROUND,
|
||||||
|
APP_STATE_BACKGROUND,
|
||||||
|
APP_STATE_SUSPENDED,
|
||||||
|
APP_STATE_TERMINATED,
|
||||||
|
APP_STATE_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class AbilityState {
|
||||||
|
ABILITY_STATE_BEGIN = 0,
|
||||||
|
ABILITY_STATE_CREATE = ABILITY_STATE_BEGIN,
|
||||||
|
ABILITY_STATE_READY,
|
||||||
|
ABILITY_STATE_FOREGROUND,
|
||||||
|
ABILITY_STATE_BACKGROUND,
|
||||||
|
ABILITY_STATE_TERMINATED,
|
||||||
|
ABILITY_STATE_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum AppMgrResultCode {
|
||||||
|
RESULT_OK = 0,
|
||||||
|
ERROR_SERVICE_NOT_READY,
|
||||||
|
ERROR_SERVICE_NOT_CONNECTED,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CONSTANTS_H
|
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
#include "app_record_id.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
#include "ams_mgr_interface.h"
|
||||||
|
#include "running_process_info.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class IAppMgr : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppMgr");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AttachApplication, call AttachApplication() through proxy object,
|
||||||
|
* get all the information needed to start the Application (data related to the Application ).
|
||||||
|
*
|
||||||
|
* @param app, information needed to start the Application.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AttachApplication(const sptr<IRemoteObject> &app) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationForegrounded, call ApplicationForegrounded() through proxy object,
|
||||||
|
* set the application to Foreground State.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationForegrounded(const int32_t recordId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationBackgrounded, call ApplicationBackgrounded() through proxy object,
|
||||||
|
* set the application to Backgrounded State.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationBackgrounded(const int32_t recordId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationTerminated, call ApplicationTerminated() through proxy object,
|
||||||
|
* terminate the application.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationTerminated(const int32_t recordId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CheckPermission, call CheckPermission() through proxy object, check the permission.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @param permission, check the permissions.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int CheckPermission(const int32_t recordId, const std::string &permission) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityCleaned,call through AbilityCleaned() proxy project, clean Ability record.
|
||||||
|
*
|
||||||
|
* @param token, a unique record that identifies AbilityCleaned from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AbilityCleaned(const sptr<IRemoteObject> &token) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetAmsMgr, call GetAmsMgr() through proxy object, get AMS interface instance.
|
||||||
|
*
|
||||||
|
* @return sptr<IAmsMgr>, return to AMS interface instance.
|
||||||
|
*/
|
||||||
|
virtual sptr<IAmsMgr> GetAmsMgr() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||||
|
* clear the application data.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ClearUpApplicationData(const std::string &bundleName) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IsBackgroundRunningRestricted, call IsBackgroundRunningRestricted() through proxy project,
|
||||||
|
* Checks whether the process of this application is forbidden to run in the background.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int IsBackgroundRunningRestricted(const std::string &bundleName) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||||
|
* Obtains information about application processes that are running on the device.
|
||||||
|
*
|
||||||
|
* @param runningProcessInfo, app name in Application record.
|
||||||
|
* @return ERR_OK ,return back success,others fail.
|
||||||
|
*/
|
||||||
|
virtual int GetAllRunningProcesses(std::shared_ptr<RunningProcessInfo> &runningProcessInfo) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
AMS_APP_ATTACH_APPLICATION = 0,
|
||||||
|
AMS_APP_APPLICATION_FOREGROUNDED,
|
||||||
|
AMS_APP_APPLICATION_BACKGROUNDED,
|
||||||
|
AMS_APP_APPLICATION_TERMINATED,
|
||||||
|
AMS_APP_CHECK_PERMISSION,
|
||||||
|
AMS_APP_ABILITY_CLEANED,
|
||||||
|
AMS_APP_GET_MGR_INSTANCE,
|
||||||
|
AMS_APP_CLEAR_UP_APPLICATION_DATA,
|
||||||
|
AMS_APP_IS_BACKGROUND_RUNNING_RESTRICTED,
|
||||||
|
AMS_APP_GET_ALL_RUNNING_PROCESSES,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_INTERFACE_H
|
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CLIENT_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CLIENT_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "app_mgr_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppMgrProxy : public IRemoteProxy<IAppMgr> {
|
||||||
|
public:
|
||||||
|
explicit AppMgrProxy(const sptr<IRemoteObject> &impl);
|
||||||
|
virtual ~AppMgrProxy() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AttachApplication, call AttachApplication() through proxy object,
|
||||||
|
* get all the information needed to start the Application (data related to the Application ).
|
||||||
|
*
|
||||||
|
* @param app, information needed to start the Application.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AttachApplication(const sptr<IRemoteObject> &obj) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationForegrounded, call ApplicationForegrounded() through proxy object,
|
||||||
|
* set the application to Foreground State.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationForegrounded(const int32_t recordId) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationBackgrounded, call ApplicationBackgrounded() through proxy object,
|
||||||
|
* set the application to Backgrounded State.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationBackgrounded(const int32_t recordId) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationTerminated, call ApplicationTerminated() through proxy object,
|
||||||
|
* terminate the application.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ApplicationTerminated(const int32_t recordId) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CheckPermission, call CheckPermission() through proxy object, check the permission.
|
||||||
|
*
|
||||||
|
* @param recordId, a unique record that identifies this Application from others.
|
||||||
|
* @param permission, check the permissions.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int32_t CheckPermission(const int32_t recordId, const std::string &permission) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityCleaned,call through AbilityCleaned() proxy project, clean Ability record.
|
||||||
|
*
|
||||||
|
* @param token, a unique record that identifies AbilityCleaned from others.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void AbilityCleaned(const sptr<IRemoteObject> &token) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetAmsMgr, call GetAmsMgr() through proxy object, get AMS interface instance.
|
||||||
|
*
|
||||||
|
* @return sptr<IAmsMgr>, return to AMS interface instance.
|
||||||
|
*/
|
||||||
|
virtual sptr<IAmsMgr> GetAmsMgr() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||||
|
* clear the application data.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ClearUpApplicationData(const std::string &bundleName) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IsBackgroundRunningRestricted, call IsBackgroundRunningRestricted() through proxy project,
|
||||||
|
* Checks whether the process of this application is forbidden to run in the background.
|
||||||
|
*
|
||||||
|
* @param bundleName, bundle name in Application record.
|
||||||
|
* @return ERR_OK, return back success, others fail.
|
||||||
|
*/
|
||||||
|
virtual int32_t IsBackgroundRunningRestricted(const std::string &bundleName) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||||
|
* Obtains information about application processes that are running on the device.
|
||||||
|
*
|
||||||
|
* @param runningProcessInfo, app name in Application record.
|
||||||
|
* @return ERR_OK ,return back success,others fail.
|
||||||
|
*/
|
||||||
|
virtual int32_t GetAllRunningProcesses(std::shared_ptr<RunningProcessInfo> &runningProcessInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool SendTransactCmd(IAppMgr::Message code, MessageParcel &data, MessageParcel &reply);
|
||||||
|
bool WriteInterfaceToken(MessageParcel &data);
|
||||||
|
static inline BrokerDelegator<AppMgrProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_CLIENT_H
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_STUB_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_STUB_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "string_ex.h"
|
||||||
|
#include "app_mgr_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppMgrStub : public IRemoteStub<IAppMgr> {
|
||||||
|
public:
|
||||||
|
AppMgrStub();
|
||||||
|
virtual ~AppMgrStub();
|
||||||
|
|
||||||
|
virtual int OnRemoteRequest(
|
||||||
|
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t HandleAttachApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleApplicationBackgrounded(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleApplicationTerminated(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleCheckPermission(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleAbilityCleaned(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleGetAmsMgr(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleClearUpApplicationData(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleIsBackgroundRunningRestricted(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||||
|
std::map<uint32_t, AppMgrFunc> memberFuncMap_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_MOVE(AppMgrStub);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_MGR_STUB_H
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_PROCESS_DATA_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_PROCESS_DATA_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
struct AppProcessData : public Parcelable {
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static AppProcessData *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
std::string appName;
|
||||||
|
std::string processName;
|
||||||
|
ApplicationState appState = ApplicationState::APP_STATE_CREATE;
|
||||||
|
pid_t pid = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_PROCESS_DATA_H
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_RECORD_ID_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_RECORD_ID_H
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppRecordId {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief create id for the application.
|
||||||
|
*
|
||||||
|
* @return the app record id.
|
||||||
|
*/
|
||||||
|
static int32_t Create();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_RECORD_ID_H
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_HOST_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "iremote_object.h"
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "app_scheduler_interface.h"
|
||||||
|
#include "string_ex.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
class AppSchedulerHost : public IRemoteStub<IAppScheduler> {
|
||||||
|
public:
|
||||||
|
AppSchedulerHost();
|
||||||
|
virtual ~AppSchedulerHost();
|
||||||
|
|
||||||
|
virtual int OnRemoteRequest(
|
||||||
|
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t HandleScheduleForegroundApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleBackgroundApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleTerminateApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleLowMemory(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleShrinkMemory(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleLaunchAbility(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleCleanAbility(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleLaunchApplication(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleProfileChanged(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleConfigurationUpdated(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleScheduleProcessSecurityExit(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
using AppSchedulerFunc = int32_t (AppSchedulerHost::*)(MessageParcel &data, MessageParcel &reply);
|
||||||
|
std::map<uint32_t, AppSchedulerFunc> memberFuncMap_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_MOVE(AppSchedulerHost);
|
||||||
|
};
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_HOST_H
|
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "app_launch_data.h"
|
||||||
|
#include "app_launch_data.h"
|
||||||
|
#include "dummy_configuration.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
class IAppScheduler : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppScheduler");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project,
|
||||||
|
* Notify application to switch to foreground.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleForegroundApplication() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project,
|
||||||
|
* Notify application to switch to background.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleBackgroundApplication() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project,
|
||||||
|
* Notify application to terminate.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleTerminateApplication() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project,
|
||||||
|
* Notifies the application of the memory seen.
|
||||||
|
*
|
||||||
|
* @param The memory value.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleShrinkMemory(const int) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLowMemory, call ScheduleLowMemory() through proxy project,
|
||||||
|
* Notify application to low memory.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLowMemory() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project,
|
||||||
|
* Notify application to launch application.
|
||||||
|
*
|
||||||
|
* @param The app data value.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLaunchApplication(const AppLaunchData &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project,
|
||||||
|
* Notify application to launch ability.
|
||||||
|
*
|
||||||
|
* @param The ability info.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project,
|
||||||
|
* Notify application to clean ability.
|
||||||
|
*
|
||||||
|
* @param The ability token.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project,
|
||||||
|
* Notify application to profile update.
|
||||||
|
*
|
||||||
|
* @param The profile data.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleProfileChanged(const Profile &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project,
|
||||||
|
* Notify application to configuration update.
|
||||||
|
*
|
||||||
|
* @param The configuration data.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleConfigurationUpdated(const Configuration &config) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project,
|
||||||
|
* Notify application process exit safely.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleProcessSecurityExit() = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
|
||||||
|
SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION,
|
||||||
|
SCHEDULE_TERMINATE_APPLICATION_TRANSACTION,
|
||||||
|
SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION,
|
||||||
|
SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION,
|
||||||
|
SCHEDULE_LAUNCH_ABILITY_TRANSACTION,
|
||||||
|
SCHEDULE_CLEAN_ABILITY_TRANSACTION,
|
||||||
|
SCHEDULE_LAUNCH_APPLICATION_TRANSACTION,
|
||||||
|
SCHEDULE_PROFILE_CHANGED_TRANSACTION,
|
||||||
|
SCHEDULE_CONFIGURATION_UPDATED,
|
||||||
|
SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_INTERFACE_H
|
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_CLIENT_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_CLIENT_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
#include "app_scheduler_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
class AppSchedulerProxy : public IRemoteProxy<IAppScheduler> {
|
||||||
|
public:
|
||||||
|
explicit AppSchedulerProxy(const sptr<IRemoteObject> &impl);
|
||||||
|
virtual ~AppSchedulerProxy() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project,
|
||||||
|
* Notify application to switch to foreground.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleForegroundApplication() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project,
|
||||||
|
* Notify application to switch to background.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleBackgroundApplication() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project,
|
||||||
|
* Notify application to terminate.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleTerminateApplication() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project,
|
||||||
|
* Notifies the application of the memory seen.
|
||||||
|
*
|
||||||
|
* @param The memory value.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleShrinkMemory(const int32_t) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLowMemory, call ScheduleLowMemory() through proxy project,
|
||||||
|
* Notify application to low memory.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLowMemory() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project,
|
||||||
|
* Notify application to launch application.
|
||||||
|
*
|
||||||
|
* @param The app data value.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLaunchApplication(const AppLaunchData &) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project,
|
||||||
|
* Notify application to launch ability.
|
||||||
|
*
|
||||||
|
* @param The ability info.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project,
|
||||||
|
* Notify application to clean ability.
|
||||||
|
*
|
||||||
|
* @param The ability token.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project,
|
||||||
|
* Notify application to profile update.
|
||||||
|
*
|
||||||
|
* @param The profile data.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleProfileChanged(const Profile &) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project,
|
||||||
|
* Notify application to configuration update.
|
||||||
|
*
|
||||||
|
* @param The configuration data.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleConfigurationUpdated(const Configuration &config) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project,
|
||||||
|
* Notify application process exit safely.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual void ScheduleProcessSecurityExit() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool WriteInterfaceToken(MessageParcel &data);
|
||||||
|
static inline BrokerDelegator<AppSchedulerProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_SCHEDULER_CLIENT_H
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_SERVICE_MANAGER_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_SERVICE_MANAGER_H
|
||||||
|
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppServiceManager {
|
||||||
|
public:
|
||||||
|
AppServiceManager() = default;
|
||||||
|
virtual ~AppServiceManager() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the AMS interface instance.
|
||||||
|
*
|
||||||
|
* @return Returns the AMS interface instance.
|
||||||
|
*/
|
||||||
|
virtual sptr<IRemoteObject> GetAppMgrService() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_SERVICE_MANAGER_H
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_HOST_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "string_ex.h"
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppStateCallbackHost : public IRemoteStub<IAppStateCallback> {
|
||||||
|
public:
|
||||||
|
AppStateCallbackHost();
|
||||||
|
virtual ~AppStateCallbackHost();
|
||||||
|
|
||||||
|
virtual int OnRemoteRequest(
|
||||||
|
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityMgr's request is done.
|
||||||
|
*
|
||||||
|
* @param token Ability token.
|
||||||
|
* @param state Application state.
|
||||||
|
*/
|
||||||
|
virtual void OnAbilityRequestDone(const sptr<IRemoteObject> &, const AbilityState) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application state changed callback.
|
||||||
|
*
|
||||||
|
* @param appProcessData Process data
|
||||||
|
*/
|
||||||
|
virtual void OnAppStateChanged(const AppProcessData &) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
using AppStateCallbackFunc = int32_t (AppStateCallbackHost::*)(MessageParcel &data, MessageParcel &reply);
|
||||||
|
std::map<uint32_t, AppStateCallbackFunc> memberFuncMap_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_MOVE(AppStateCallbackHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_HOST_H
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_PROXY_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppStateCallbackProxy : public IRemoteProxy<IAppStateCallback> {
|
||||||
|
public:
|
||||||
|
explicit AppStateCallbackProxy(const sptr<IRemoteObject> &impl);
|
||||||
|
virtual ~AppStateCallbackProxy() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityMgr's request is done.
|
||||||
|
*
|
||||||
|
* @param token Ability token.
|
||||||
|
* @param state Application state.
|
||||||
|
*/
|
||||||
|
virtual void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const AbilityState state) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application state changed callback.
|
||||||
|
*
|
||||||
|
* @param appProcessData Process data
|
||||||
|
*/
|
||||||
|
virtual void OnAppStateChanged(const AppProcessData &appProcessData) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool WriteInterfaceToken(MessageParcel &data);
|
||||||
|
static inline BrokerDelegator<AppStateCallbackProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_STATE_CALLBACK_PROXY_H
|
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_TASK_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_TASK_INFO_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class AppTaskInfo : public Parcelable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app name.
|
||||||
|
*
|
||||||
|
* @return Returns the app name.
|
||||||
|
*/
|
||||||
|
const std::string &GetName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the process name.
|
||||||
|
*
|
||||||
|
* @return Returns the process name.
|
||||||
|
*/
|
||||||
|
const std::string &GetProcessName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app pid.
|
||||||
|
*
|
||||||
|
* @return Returns the app pid.
|
||||||
|
*/
|
||||||
|
pid_t GetPid() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app record id.
|
||||||
|
*
|
||||||
|
* @return Returns app record id.
|
||||||
|
*/
|
||||||
|
int32_t GetRecordId() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting name for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app name.
|
||||||
|
*/
|
||||||
|
void SetName(const std::string &appName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting name for process.
|
||||||
|
*
|
||||||
|
* @param int32_t, the process name.
|
||||||
|
*/
|
||||||
|
void SetProcessName(const std::string &processName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting pid for app.
|
||||||
|
*
|
||||||
|
* @param int32_t, the app pid.
|
||||||
|
*/
|
||||||
|
void SetPid(const pid_t pid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting id for app record.
|
||||||
|
*
|
||||||
|
* @param int32_t, the app record id.
|
||||||
|
*/
|
||||||
|
void SetRecordId(const int32_t appRecordId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read succeeded; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static AppTaskInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string appName_;
|
||||||
|
std::string processName_;
|
||||||
|
pid_t pid_ = 0;
|
||||||
|
int32_t appRecordId_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_APP_TASK_INFO_H
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_OHOS_CONFIGURATION_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_OHOS_CONFIGURATION_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class Configuration : public Parcelable {
|
||||||
|
public:
|
||||||
|
Configuration() = default;
|
||||||
|
explicit Configuration(const std::string &name);
|
||||||
|
virtual ~Configuration() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the name of the Configuration.
|
||||||
|
*
|
||||||
|
* @return Returns the Configuration name.
|
||||||
|
*/
|
||||||
|
inline const std::string &GetName() const
|
||||||
|
{
|
||||||
|
return testInfostr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static Configuration *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string testInfostr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_OHOS_CONFIGURATION_H
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IAPP_STATE_CALLBACK_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IAPP_STATE_CALLBACK_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
#include "app_process_data.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class IAppStateCallback : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppStateCallback");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application state changed callback.
|
||||||
|
*
|
||||||
|
* @param appProcessData Process data
|
||||||
|
*/
|
||||||
|
virtual void OnAppStateChanged(const AppProcessData &appProcessData) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbilityMgr's request is done.
|
||||||
|
*
|
||||||
|
* @param token Ability token.
|
||||||
|
* @param state Application state.
|
||||||
|
*/
|
||||||
|
virtual void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const AbilityState state) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
TRANSACT_ON_APP_STATE_CHANGED = 0,
|
||||||
|
TRANSACT_ON_ABILITY_REQUEST_DONE,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IAPP_STATE_CALLBACK_H
|
@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_PRIORITY_OBJECT_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_PRIORITY_OBJECT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class PriorityObject : public Parcelable {
|
||||||
|
public:
|
||||||
|
PriorityObject() = default;
|
||||||
|
virtual ~PriorityObject() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app pid.
|
||||||
|
*
|
||||||
|
* @return Returns the app pid.
|
||||||
|
*/
|
||||||
|
pid_t GetPid() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app max adj.
|
||||||
|
*
|
||||||
|
* @return Returns the app max adj.
|
||||||
|
*/
|
||||||
|
int32_t GetMaxAdj() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app cur adj.
|
||||||
|
*
|
||||||
|
* @return Returns the app cur adj.
|
||||||
|
*/
|
||||||
|
int32_t GetCurAdj() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app cur cgroup.
|
||||||
|
*
|
||||||
|
* @return Returns the app cur cgroup.
|
||||||
|
*/
|
||||||
|
int32_t GetCurCgroup() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the app time level.
|
||||||
|
*
|
||||||
|
* @return Returns the app time level.
|
||||||
|
*/
|
||||||
|
int32_t GetTimeLevel() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the ability visible status.
|
||||||
|
*
|
||||||
|
* @return Returns the ability visible status.
|
||||||
|
*/
|
||||||
|
bool GetVisibleStatus() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the ability preceptible status.
|
||||||
|
*
|
||||||
|
* @return Returns the ability preceptible status.
|
||||||
|
*/
|
||||||
|
bool GetPerceptibleStatus() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting pid for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app pid.
|
||||||
|
*/
|
||||||
|
void SetPid(const pid_t pid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting max adj for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app max adj.
|
||||||
|
*/
|
||||||
|
void SetMaxAdj(const int32_t maxAdj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting cur adj for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app cur adj.
|
||||||
|
*/
|
||||||
|
void SetCurAdj(const int32_t curAdj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting cur cgroup for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app cur cgroup.
|
||||||
|
*/
|
||||||
|
void SetCurCgroup(const int32_t curCgroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting time level for app.
|
||||||
|
*
|
||||||
|
* @param appName, the app time level.
|
||||||
|
*/
|
||||||
|
void SetTimeLevel(const int32_t timeLevel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting visible status for ability.
|
||||||
|
*
|
||||||
|
* @param status, the visible status.
|
||||||
|
*/
|
||||||
|
void SetVisibleStatus(bool status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setting perceptible status for ability.
|
||||||
|
*
|
||||||
|
* @param status, the perceptible status.
|
||||||
|
*/
|
||||||
|
void SetPerceptibleStatus(bool status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static PriorityObject *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
pid_t pid_ = 0;
|
||||||
|
int32_t maxAdj_ = 0;
|
||||||
|
int32_t curAdj_ = 0;
|
||||||
|
int32_t curCgroup_ = 0;
|
||||||
|
int32_t timeLevel_ = 0;
|
||||||
|
bool visibleStatus_ = false;
|
||||||
|
bool perceptibleStatus_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_PRIORITY_OBJECT_H
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROCESS_INFO_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROCESS_INFO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class ProcessInfo : public Parcelable {
|
||||||
|
public:
|
||||||
|
ProcessInfo() = default;
|
||||||
|
explicit ProcessInfo(const std::string &name, const pid_t &pid);
|
||||||
|
virtual ~ProcessInfo() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the name of the current process.
|
||||||
|
*
|
||||||
|
* @return Returns the current process name.
|
||||||
|
*/
|
||||||
|
inline const std::string &GetProcessName() const
|
||||||
|
{
|
||||||
|
return processName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the id of the current process.
|
||||||
|
*
|
||||||
|
* @return Returns the current process id.
|
||||||
|
*/
|
||||||
|
inline pid_t GetPid() const
|
||||||
|
{
|
||||||
|
return pid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static ProcessInfo *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string processName_;
|
||||||
|
pid_t pid_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROCESS_INFO_H
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROFILE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROFILE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "nocopyable.h"
|
||||||
|
#include "parcel.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class Profile : public Parcelable {
|
||||||
|
public:
|
||||||
|
Profile() = default;
|
||||||
|
explicit Profile(const std::string &name);
|
||||||
|
virtual ~Profile() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtains the profile name.
|
||||||
|
*
|
||||||
|
* @return Returns profile name.
|
||||||
|
*/
|
||||||
|
inline const std::string &GetName() const
|
||||||
|
{
|
||||||
|
return profileName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief read this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
* @return Returns true if read successed; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool ReadFromParcel(Parcel &parcel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Marshals this Sequenceable object into a Parcel.
|
||||||
|
*
|
||||||
|
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||||
|
*/
|
||||||
|
virtual bool Marshalling(Parcel &parcel) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||||
|
*
|
||||||
|
* @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
|
||||||
|
*/
|
||||||
|
static Profile *Unmarshalling(Parcel &parcel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string profileName_; // the name of the ability
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_PROFILE_H
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_INTERFACE_H
|
||||||
|
|
||||||
|
#include "status_receiver_interface.h"
|
||||||
|
#include "install_param.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class IBundleInstaller : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleInstaller");
|
||||||
|
/**
|
||||||
|
* @brief Installs an application, the final result will be notified from the statusReceiver object.
|
||||||
|
* @attention Notice that the bundleFilePath should be an absolute path.
|
||||||
|
* @param bundleFilePath Indicates the path for storing the ohos Ability Package (HAP) of the application
|
||||||
|
* to install or update.
|
||||||
|
* @param installParam Indicates the install parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the install result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Install(const std::string &bundleFilePath, const InstallParam &installParam,
|
||||||
|
const sptr<IStatusReceiver> &statusReceiver) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uninstalls an application, the result will be notified from the statusReceiver object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application to uninstall.
|
||||||
|
* @param installParam Indicates the uninstall parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the uninstall result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Uninstall(const std::string &bundleName, const InstallParam &installParam,
|
||||||
|
const sptr<IStatusReceiver> &statusReceiver) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uninstalls a module in an application, the result will be notified from the statusReceiver object.
|
||||||
|
* @param bundleName Indicates the bundle name of the module to uninstall.
|
||||||
|
* @param modulePackage Indicates the module package of the module to uninstall.
|
||||||
|
* @param installParam Indicates the uninstall parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the uninstall result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Uninstall(const std::string &bundleName, const std::string &modulePackage,
|
||||||
|
const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
INSTALL,
|
||||||
|
UNINSTALL,
|
||||||
|
UNINSTALL_MODULE,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_INTERFACE_H
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_PROXY_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "bundle_installer_interface.h"
|
||||||
|
#include "status_receiver_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class BundleInstallerProxy : public IRemoteProxy<IBundleInstaller> {
|
||||||
|
public:
|
||||||
|
explicit BundleInstallerProxy(const sptr<IRemoteObject> &object);
|
||||||
|
virtual ~BundleInstallerProxy() override;
|
||||||
|
/**
|
||||||
|
* @brief Installs an application through the proxy object.
|
||||||
|
* @attention Notice that the bundleFilePath should be an absolute path.
|
||||||
|
* @param bundleFilePath Indicates the path for storing the ohos Ability Package (HAP) of the application
|
||||||
|
* to install or update.
|
||||||
|
* @param installParam Indicates the install parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the install result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Install(const std::string &bundleFilePath, const InstallParam &installParam,
|
||||||
|
const sptr<IStatusReceiver> &statusReceiver) override;
|
||||||
|
/**
|
||||||
|
* @brief Uninstalls an application through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application to uninstall.
|
||||||
|
* @param installParam Indicates the uninstall parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the uninstall result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Uninstall(const std::string &bundleName, const InstallParam &installParam,
|
||||||
|
const sptr<IStatusReceiver> &statusReceiver) override;
|
||||||
|
/**
|
||||||
|
* @brief Uninstalls a module in an application through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the module to uninstall.
|
||||||
|
* @param modulePackage Indicates the module package of the module to uninstall.
|
||||||
|
* @param installParam Indicates the uninstall parameters.
|
||||||
|
* @param statusReceiver Indicates the callback object that using for notifing the uninstall result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool Uninstall(const std::string &bundleName, const std::string &modulePackage,
|
||||||
|
const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline BrokerDelegator<BundleInstallerProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_INSTALLER_PROXY_H
|
@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_HOST_H
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "bundle_mgr_interface.h"
|
||||||
|
#include "bundle_mgr_proxy.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class BundleMgrHost : public IRemoteStub<IBundleMgr> {
|
||||||
|
public:
|
||||||
|
BundleMgrHost() = default;
|
||||||
|
virtual ~BundleMgrHost() = default;
|
||||||
|
|
||||||
|
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
/**
|
||||||
|
* @attention This function is implement in the proxy side.
|
||||||
|
*/
|
||||||
|
virtual int GetUidByBundleName([[maybe_unused]] const std::string &bundleName, const int userId) override;
|
||||||
|
/**
|
||||||
|
* @attention This function is implement in the proxy side.
|
||||||
|
*/
|
||||||
|
virtual std::string GetAppType([[maybe_unused]] const std::string &bundleName) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetApplicationInfo function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetApplicationInfo(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetApplicationInfos function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetApplicationInfos(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleInfo function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleInfo(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleInfos function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleInfos(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleNameForUid function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleNameForUid(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleGids function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleGids(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleInfosByMetaData function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleInfosByMetaData(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the QueryAbilityInfo function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleQueryAbilityInfo(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the QueryAbilityInfoByUri function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleQueryAbilityInfoByUri(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the QueryKeepAliveBundleInfos function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleQueryKeepAliveBundleInfos(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetAbilityLabel function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetAbilityLabel(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CheckIsSystemAppByUid function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCheckIsSystemAppByUid(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleArchiveInfo function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleArchiveInfo(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetHapModuleInfo function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetHapModuleInfo(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetLaunchWantForBundle function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetLaunchWantForBundle(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CheckPublicKeys function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCheckPublicKeys(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CheckPermission function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCheckPermission(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetPermissionDef function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetPermissionDef(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetAllPermissionGroupDefs function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetAllPermissionGroupDefs(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetAppsGrantedPermissions function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetAppsGrantedPermissions(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the HasSystemCapability function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleHasSystemCapability(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetSystemAvailableCapabilities function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetSystemAvailableCapabilities(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the IsSafeMode function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleIsSafeMode(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CleanBundleCacheFiles function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCleanBundleCacheFiles(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CleanBundleDataFiles function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCleanBundleDataFiles(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the RegisterBundleStatusCallback function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleRegisterBundleStatusCallback(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the ClearBundleStatusCallback function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleClearBundleStatusCallback(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the UnregisterBundleStatusCallback function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleUnregisterBundleStatusCallback(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the DumpInfos function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleDumpInfos(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the GetBundleInstaller function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleGetBundleInstaller(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the IsApplicationEnabled function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleIsApplicationEnabled(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the SetApplicationEnabled function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleSetApplicationEnabled(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the CanRequestPermission function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleCanRequestPermission(Parcel &data, Parcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Handles the RequestPermissionFromUser function called from a IBundleMgr proxy object.
|
||||||
|
* @param data Indicates the data to be read.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||||
|
*/
|
||||||
|
ErrCode HandleRequestPermissionFromUser(Parcel &data, Parcel &reply);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Write a parcelabe vector objects to the proxy node.
|
||||||
|
* @param parcelableVector Indicates the objects to be write.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns true if objects send successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
bool WriteParcelableVector(std::vector<T> &parcelableVector, Parcel &reply);
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_MOVE(BundleMgrHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_HOST_H
|
@ -0,0 +1,345 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "application_info.h"
|
||||||
|
#include "bundle_info.h"
|
||||||
|
#include "hap_module_info.h"
|
||||||
|
#include "permission_def.h"
|
||||||
|
#include "bundle_installer_interface.h"
|
||||||
|
#include "bundle_status_callback_interface.h"
|
||||||
|
#include "clean_cache_callback_interface.h"
|
||||||
|
#include "ohos/aafwk/content/want.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
enum class DumpFlag {
|
||||||
|
DUMP_BUNDLE_LIST = 1, // corresponse to option "-bundle-list"
|
||||||
|
DUMP_ALL_BUNDLE_INFO, // corresponse to option "-bundle"
|
||||||
|
DUMP_BUNDLE_INFO, // corresponse to option "-bundle [name]"
|
||||||
|
};
|
||||||
|
|
||||||
|
class IBundleMgr : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleMgr");
|
||||||
|
|
||||||
|
using Want = OHOS::AAFwk::Want;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the ApplicationInfo based on a given bundle name.
|
||||||
|
* @param appName Indicates the application bundle name to be queried.
|
||||||
|
* @param flag Indicates the flag used to specify information contained
|
||||||
|
* in the ApplicationInfo object that will be returned.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @param appInfo Indicates the obtained ApplicationInfo object.
|
||||||
|
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetApplicationInfo(
|
||||||
|
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains information about all installed applications of a specified user.
|
||||||
|
* @param flag Indicates the flag used to specify information contained
|
||||||
|
* in the ApplicationInfo objects that will be returned.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @param appInfos Indicates all of the obtained ApplicationInfo objects.
|
||||||
|
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetApplicationInfos(
|
||||||
|
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo based on a given bundle name.
|
||||||
|
* @param bundleName Indicates the application bundle name to be queried.
|
||||||
|
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||||
|
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||||
|
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains BundleInfo of all bundles available in the system.
|
||||||
|
* @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the application UID based on the given bundle name and user ID.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @return Returns the uid if successfully obtained; returns -1 otherwise.
|
||||||
|
*/
|
||||||
|
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the bundle name of a specified application based on the given UID.
|
||||||
|
* @param uid Indicates the uid.
|
||||||
|
* @param bundleName Indicates the obtained bundle name.
|
||||||
|
* @return Returns true if the bundle name is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains an array of all group IDs associated with a specified bundle.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param gids Indicates the group IDs associated with the specified bundle.
|
||||||
|
* @return Returns true if the gids is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the type of a specified application based on the given bundle name.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @return Returns "system" if the bundle is a system application; returns "third-party" otherwise.
|
||||||
|
*/
|
||||||
|
virtual std::string GetAppType(const std::string &bundleName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Check whether the app is system app by it's UID.
|
||||||
|
* @param uid Indicates the uid.
|
||||||
|
* @return Returns true if the bundle is a system application; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CheckIsSystemAppByUid(const int uid) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo of application bundles based on the specified metaData.
|
||||||
|
* @param metaData Indicates the metadata to get in the bundle.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Query the AbilityInfo by the given Want.
|
||||||
|
* @param want Indicates the information of the ability.
|
||||||
|
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||||
|
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Query the AbilityInfo by ability.uri in config.json.
|
||||||
|
* @param abilityUri Indicates the uri of the ability.
|
||||||
|
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||||
|
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo of all keep-alive applications in the system.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the label of a specified ability.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param className Indicates the ability class name.
|
||||||
|
* @return Returns the label of the ability if exist; returns empty string otherwise.
|
||||||
|
*/
|
||||||
|
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
|
||||||
|
* @param hapFilePath Indicates the absolute file path of the HAP.
|
||||||
|
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||||
|
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||||
|
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleArchiveInfo(
|
||||||
|
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtain the HAP module info of a specific ability.
|
||||||
|
* @param abilityInfo Indicates the ability.
|
||||||
|
* @param hapModuleInfo Indicates the obtained HapModuleInfo object.
|
||||||
|
* @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param want Indicates the obtained launch Want object.
|
||||||
|
* @return Returns true if the launch Want object is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the publickeys of two bundles are the same.
|
||||||
|
* @param firstBundleName Indicates the first bundle name.
|
||||||
|
* @param secondBundleName Indicates the second bundle name.
|
||||||
|
* @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found;
|
||||||
|
* returns SIGNATURE_NOT_MATCHED if their publickeys are different;
|
||||||
|
* returns SIGNATURE_MATCHED if their publickeys are the same.
|
||||||
|
*/
|
||||||
|
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a specified bundle has been granted a specific permission.
|
||||||
|
* @param bundleName Indicates the name of the bundle to check.
|
||||||
|
* @param permission Indicates the permission to check.
|
||||||
|
* @return Returns 0 if the bundle has the permission; returns -1 otherwise.
|
||||||
|
*/
|
||||||
|
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains detailed information about a specified permission.
|
||||||
|
* @param permissionName Indicates the name of the ohos permission.
|
||||||
|
* @param permissionDef Indicates the object containing detailed information about the given ohos permission.
|
||||||
|
* @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains all known permission groups in the system.
|
||||||
|
* @param permissionDefs Indicates the list of objects containing the permission group information.
|
||||||
|
* @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains all known permission groups in the system.
|
||||||
|
* @param permissions Indicates the permission array.
|
||||||
|
* @param appNames Indicates the list of application names that have the specified permissions.
|
||||||
|
* @return Returns true if the application names is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetAppsGrantedPermissions(
|
||||||
|
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the system has a specified capability.
|
||||||
|
* @param capName Indicates the name of the system feature to check.
|
||||||
|
* @return Returns true if the given feature specified by name is available in the system; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool HasSystemCapability(const std::string &capName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the capabilities that are available in the system.
|
||||||
|
* @param systemCaps Indicates the list of capabilities available in the system.
|
||||||
|
* @return Returns true if capabilities in the system are successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the current device has been started in safe mode.
|
||||||
|
* @return Returns true if the device is in safe mode; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool IsSafeMode() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Clears cache data of a specified application.
|
||||||
|
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
|
||||||
|
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CleanBundleCacheFiles(
|
||||||
|
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Clears application running data of a specified application.
|
||||||
|
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
|
||||||
|
* @return Returns true if the data cleared successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CleanBundleDataFiles(const std::string &bundleName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Register the specific bundle status callback.
|
||||||
|
* @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Clear the specific bundle status callback.
|
||||||
|
* @param bundleStatusCallback Indicates the callback to be cleared.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Unregister all the callbacks of status changed.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool UnregisterBundleStatusCallback() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Dump the bundle informations with specific flags.
|
||||||
|
* @param flag Indicates the information contained in the dump result.
|
||||||
|
* @param bundleName Indicates the bundle name if needed.
|
||||||
|
* @param result Indicates the dump information result.
|
||||||
|
* @return Returns true if the dump result is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a specified application is enabled.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @return Returns true if the application is enabled; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool IsApplicationEnabled(const std::string &bundleName) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Sets whether to enable a specified application.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @param isEnable Specifies whether to enable the application.
|
||||||
|
* The value true means to enable it, and the value false means to disable it.
|
||||||
|
* @return Returns true if the application is enabled; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Confirms with the permission management module to check whether a request prompt is required for granting
|
||||||
|
* a certain permission.
|
||||||
|
* @param bundleName Indicates the name of the bundle to check.
|
||||||
|
* @param permission Indicates the permission to check.
|
||||||
|
* @param userId Indicates the user id.
|
||||||
|
* @return Returns true if the current application does not have the permission and the user does not turn off
|
||||||
|
* further requests; returns false if the current application already has the permission, the permission is rejected
|
||||||
|
* by the system, or the permission is denied by the user and the user has turned off further requests.
|
||||||
|
*/
|
||||||
|
virtual bool CanRequestPermission(
|
||||||
|
const std::string &bundleName, const std::string &permissionName, const int userId) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Requests a certain permission from user.
|
||||||
|
* @param bundleName Indicates the name of the bundle to request permission.
|
||||||
|
* @param permission Indicates the permission to request permission.
|
||||||
|
* @param userId Indicates the user id.
|
||||||
|
* @return Returns true if the permission request successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool RequestPermissionFromUser(
|
||||||
|
const std::string &bundleName, const std::string &permission, const int userId) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the interface used to install and uninstall bundles.
|
||||||
|
* @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
|
||||||
|
*/
|
||||||
|
virtual sptr<IBundleInstaller> GetBundleInstaller() = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
GET_APPLICATION_INFO,
|
||||||
|
GET_APPLICATION_INFOS,
|
||||||
|
GET_BUNDLE_INFO,
|
||||||
|
GET_BUNDLE_INFOS,
|
||||||
|
GET_UID_BY_BUNDLE_NAME,
|
||||||
|
GET_BUNDLE_NAME_FOR_UID,
|
||||||
|
GET_BUNDLE_GIDS,
|
||||||
|
GET_APP_TYPE,
|
||||||
|
CHECK_IS_SYSTEM_APP_BY_UID,
|
||||||
|
GET_BUNDLE_INFOS_BY_METADATA,
|
||||||
|
QUERY_ABILITY_INFO,
|
||||||
|
QUERY_ABILITY_INFO_BY_URI,
|
||||||
|
QUERY_KEEPALIVE_BUNDLE_INFOS,
|
||||||
|
GET_ABILITY_LABEL,
|
||||||
|
GET_BUNDLE_ARCHIVE_INFO,
|
||||||
|
GET_HAP_MODULE_INFO,
|
||||||
|
GET_LAUNCH_WANT_FOR_BUNDLE,
|
||||||
|
CHECK_PUBLICKEYS,
|
||||||
|
CHECK_PERMISSION,
|
||||||
|
GET_PERMISSION_DEF,
|
||||||
|
GET_ALL_PERMISSION_GROUP_DEFS,
|
||||||
|
GET_APPS_GRANTED_PERMISSIONS,
|
||||||
|
HAS_SYSTEM_CAPABILITY,
|
||||||
|
GET_SYSTEM_AVAILABLE_CAPABILITIES,
|
||||||
|
IS_SAFE_MODE,
|
||||||
|
CLEAN_BUNDLE_CACHE_FILES,
|
||||||
|
CLEAN_BUNDLE_DATA_FILES,
|
||||||
|
REGISTER_BUNDLE_STATUS_CALLBACK,
|
||||||
|
CLEAR_BUNDLE_STATUS_CALLBACK,
|
||||||
|
UNREGISTER_BUNDLE_STATUS_CALLBACK,
|
||||||
|
DUMP_INFOS,
|
||||||
|
IS_APPLICATION_ENABLED,
|
||||||
|
SET_APPLICATION_ENABLED,
|
||||||
|
CAN_REQUEST_PERMISSION,
|
||||||
|
REQUEST_PERMISSION_FROM_USER,
|
||||||
|
GET_BUNDLE_INSTALLER,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
@ -0,0 +1,329 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_PROXY_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "bundle_mgr_interface.h"
|
||||||
|
#include "element_name.h"
|
||||||
|
#include "bundle_status_callback_interface.h"
|
||||||
|
#include "clean_cache_callback_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class BundleMgrProxy : public IRemoteProxy<IBundleMgr> {
|
||||||
|
public:
|
||||||
|
explicit BundleMgrProxy(const sptr<IRemoteObject> &impl);
|
||||||
|
virtual ~BundleMgrProxy() override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the ApplicationInfo based on a given bundle name through the proxy object.
|
||||||
|
* @param appName Indicates the application bundle name to be queried.
|
||||||
|
* @param flag Indicates the flag used to specify information contained
|
||||||
|
* in the ApplicationInfo object that will be returned.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @param appInfo Indicates the obtained ApplicationInfo object.
|
||||||
|
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetApplicationInfo(
|
||||||
|
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains information about all installed applications of a specified user through the proxy object.
|
||||||
|
* @param flag Indicates the flag used to specify information contained
|
||||||
|
* in the ApplicationInfo objects that will be returned.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @param appInfos Indicates all of the obtained ApplicationInfo objects.
|
||||||
|
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetApplicationInfos(
|
||||||
|
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo based on a given bundle name through the proxy object.
|
||||||
|
* @param bundleName Indicates the application bundle name to be queried.
|
||||||
|
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||||
|
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||||
|
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains BundleInfo of all bundles available in the system through the proxy object.
|
||||||
|
* @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the application UID based on the given bundle name and user ID through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @param userId Indicates the user ID.
|
||||||
|
* @return Returns the uid if successfully obtained; returns -1 otherwise.
|
||||||
|
*/
|
||||||
|
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the bundle name of a specified application based on the given UID through the proxy object.
|
||||||
|
* @param uid Indicates the uid.
|
||||||
|
* @param bundleName Indicates the obtained bundle name.
|
||||||
|
* @return Returns true if the bundle name is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains an array of all group IDs associated with a specified bundle through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param gids Indicates the group IDs associated with the specified bundle.
|
||||||
|
* @return Returns true if the gids is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the type of a specified application based on the given bundle name through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @return Returns "system" if the bundle is a system application; returns "third-party" otherwise.
|
||||||
|
*/
|
||||||
|
virtual std::string GetAppType(const std::string &bundleName) override;
|
||||||
|
/**
|
||||||
|
* @brief Check whether the app is system app by it's UID through the proxy object.
|
||||||
|
* @param uid Indicates the uid.
|
||||||
|
* @return Returns true if the bundle is a system application; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CheckIsSystemAppByUid(const int uid) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo of application bundles based on the specified metaData through the proxy object.
|
||||||
|
* @param metaData Indicates the metadata to get in the bundle.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
|
||||||
|
/**
|
||||||
|
* @brief Query the AbilityInfo by the given Want through the proxy object.
|
||||||
|
* @param want Indicates the information of the ability.
|
||||||
|
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||||
|
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Query the AbilityInfo by ability.uri in config.json through the proxy object.
|
||||||
|
* @param abilityUri Indicates the uri of the ability.
|
||||||
|
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||||
|
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the BundleInfo of all keep-alive applications in the system through the proxy object.
|
||||||
|
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||||
|
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the label of a specified ability through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param className Indicates the ability class name.
|
||||||
|
* @return Returns the label of the ability if exist; returns empty string otherwise.
|
||||||
|
*/
|
||||||
|
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains information about an application bundle contained
|
||||||
|
* in an ohos Ability Package (HAP) through the proxy object.
|
||||||
|
* @param hapFilePath Indicates the absolute file path of the HAP.
|
||||||
|
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||||
|
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||||
|
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetBundleArchiveInfo(
|
||||||
|
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtain the HAP module info of a specific ability through the proxy object.
|
||||||
|
* @param abilityInfo Indicates the ability.
|
||||||
|
* @param hapModuleInfo Indicates the obtained HapModuleInfo object.
|
||||||
|
* @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the Want for starting the main ability of an application
|
||||||
|
* based on the given bundle name through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name.
|
||||||
|
* @param want Indicates the obtained launch Want object.
|
||||||
|
* @return Returns true if the launch Want object is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the publickeys of two bundles are the same through the proxy object.
|
||||||
|
* @param firstBundleName Indicates the first bundle name.
|
||||||
|
* @param secondBundleName Indicates the second bundle name.
|
||||||
|
* @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found;
|
||||||
|
* returns SIGNATURE_NOT_MATCHED if their publickeys are different;
|
||||||
|
* returns SIGNATURE_MATCHED if their publickeys are the same.
|
||||||
|
*/
|
||||||
|
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a specified bundle has been granted a specific permission through the proxy object.
|
||||||
|
* @param bundleName Indicates the name of the bundle to check.
|
||||||
|
* @param permission Indicates the permission to check.
|
||||||
|
* @return Returns 0 if the bundle has the permission; returns -1 otherwise.
|
||||||
|
*/
|
||||||
|
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains detailed information about a specified permission through the proxy object.
|
||||||
|
* @param permissionName Indicates the name of the ohos permission.
|
||||||
|
* @param permissionDef Indicates the object containing detailed information about the given ohos permission.
|
||||||
|
* @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains all known permission groups in the system through the proxy object.
|
||||||
|
* @param permissionDefs Indicates the list of objects containing the permission group information.
|
||||||
|
* @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains all known permission groups in the system through the proxy object.
|
||||||
|
* @param permissions Indicates the permission array.
|
||||||
|
* @param appNames Indicates the list of application names that have the specified permissions.
|
||||||
|
* @return Returns true if the application names is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetAppsGrantedPermissions(
|
||||||
|
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the system has a specified capability through the proxy object.
|
||||||
|
* @param capName Indicates the name of the system feature to check.
|
||||||
|
* @return Returns true if the given feature specified by name is available in the system; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool HasSystemCapability(const std::string &capName) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the capabilities that are available in the system through the proxy object.
|
||||||
|
* @param systemCaps Indicates the list of capabilities available in the system.
|
||||||
|
* @return Returns true if capabilities in the system are successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether the current device has been started in safe mode through the proxy object.
|
||||||
|
* @return Returns true if the device is in safe mode; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool IsSafeMode() override;
|
||||||
|
/**
|
||||||
|
* @brief Clears cache data of a specified application through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
|
||||||
|
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CleanBundleCacheFiles(
|
||||||
|
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) override;
|
||||||
|
/**
|
||||||
|
* @brief Clears application running data of a specified application through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
|
||||||
|
* @return Returns true if the data cleared successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool CleanBundleDataFiles(const std::string &bundleName) override;
|
||||||
|
/**
|
||||||
|
* @brief Register the specific bundle status callback through the proxy object.
|
||||||
|
* @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||||
|
/**
|
||||||
|
* @brief Clear the specific bundle status callback through the proxy object.
|
||||||
|
* @param bundleStatusCallback Indicates the callback to be cleared.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||||
|
/**
|
||||||
|
* @brief Unregister all the callbacks of status changed through the proxy object.
|
||||||
|
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool UnregisterBundleStatusCallback() override;
|
||||||
|
/**
|
||||||
|
* @brief Dump the bundle informations with specific flags through the proxy object.
|
||||||
|
* @param flag Indicates the information contained in the dump result.
|
||||||
|
* @param bundleName Indicates the bundle name if needed.
|
||||||
|
* @param result Indicates the dump information result.
|
||||||
|
* @return Returns true if the dump result is successfully obtained; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) override;
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a specified application is enabled through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @return Returns true if the application is enabled; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool IsApplicationEnabled(const std::string &bundleName) override;
|
||||||
|
/**
|
||||||
|
* @brief Sets whether to enable a specified application through the proxy object.
|
||||||
|
* @param bundleName Indicates the bundle name of the application.
|
||||||
|
* @param isEnable Specifies whether to enable the application.
|
||||||
|
* The value true means to enable it, and the value false means to disable it.
|
||||||
|
* @return Returns true if the application is enabled; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override;
|
||||||
|
/**
|
||||||
|
* @brief Obtains the interface used to install and uninstall bundles through the proxy object.
|
||||||
|
* @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
|
||||||
|
*/
|
||||||
|
virtual sptr<IBundleInstaller> GetBundleInstaller() override;
|
||||||
|
/**
|
||||||
|
* @brief Confirms with the permission management module to check whether a request prompt is required for granting
|
||||||
|
* a certain permission.
|
||||||
|
* @param bundleName Indicates the name of the bundle to check through the proxy object.
|
||||||
|
* @param permission Indicates the permission to check.
|
||||||
|
* @param userId Indicates the user id.
|
||||||
|
* @return Returns true if the current application does not have the permission and the user does not turn off
|
||||||
|
* further requests; returns false if the current application already has the permission, the permission is rejected
|
||||||
|
* by the system, or the permission is denied by the user and the user has turned off further requests.
|
||||||
|
*/
|
||||||
|
virtual bool CanRequestPermission(
|
||||||
|
const std::string &bundleName, const std::string &permissionName, const int userId) override;
|
||||||
|
/**
|
||||||
|
* @brief Requests a certain permission from user through the proxy object.
|
||||||
|
* @param bundleName Indicates the name of the bundle to request permission.
|
||||||
|
* @param permission Indicates the permission to request permission.
|
||||||
|
* @param userId Indicates the user id.
|
||||||
|
* @return Returns true if the permission request successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool RequestPermissionFromUser(
|
||||||
|
const std::string &bundleName, const std::string &permission, const int userId) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Send a command message from the proxy object.
|
||||||
|
* @param code Indicates the message code to be sent.
|
||||||
|
* @param data Indicates the objects to be sent.
|
||||||
|
* @param reply Indicates the reply to be sent;
|
||||||
|
* @return Returns true if message send successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
bool SendTransactCmd(IBundleMgr::Message code, MessageParcel &data, MessageParcel &reply);
|
||||||
|
/**
|
||||||
|
* @brief Send a command message and then get a parcelable information object from the reply.
|
||||||
|
* @param code Indicates the message code to be sent.
|
||||||
|
* @param data Indicates the objects to be sent.
|
||||||
|
* @param parcelableInfo Indicates the object to be got;
|
||||||
|
* @return Returns true if objects get successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
bool GetParcelableInfo(IBundleMgr::Message code, MessageParcel &data, T &parcelableInfo);
|
||||||
|
/**
|
||||||
|
* @brief Send a command message and then get a vector of parcelable information objects from the reply.
|
||||||
|
* @param code Indicates the message code to be sent.
|
||||||
|
* @param data Indicates the objects to be sent.
|
||||||
|
* @param parcelableInfos Indicates the vector objects to be got;
|
||||||
|
* @return Returns true if the vector get successfully; returns false otherwise.
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
bool GetParcelableInfos(IBundleMgr::Message code, MessageParcel &data, std::vector<T> &parcelableInfos);
|
||||||
|
static inline BrokerDelegator<BundleMgrProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_PROXY_H
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_HOST_H
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
|
||||||
|
#include "bundle_status_callback_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class BundleStatusCallbackHost : public IRemoteStub<IBundleStatusCallback> {
|
||||||
|
public:
|
||||||
|
BundleStatusCallbackHost();
|
||||||
|
virtual ~BundleStatusCallbackHost() override;
|
||||||
|
|
||||||
|
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_MOVE(BundleStatusCallbackHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_HOST_H
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
const std::string INSTALL_SUCCESS = "install success !";
|
||||||
|
const std::string UNINSTALL_SUCCESS = "uninstall success !";
|
||||||
|
|
||||||
|
enum class InstallType { INSTALL_CALLBACK, UNINSTALL_CALLBACK };
|
||||||
|
|
||||||
|
class IBundleStatusCallback : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleStatusCallback");
|
||||||
|
/**
|
||||||
|
* @brief Called when the installation, update, or uninstallation state of an application changes.
|
||||||
|
* @param installType Indicates the installation, update, or uninstallation state.
|
||||||
|
* The value <b>0</b> indicates that the application is being installed or updated,
|
||||||
|
* and <b>1</b> indicates that the application is being uninstalled.
|
||||||
|
* @param resultCode Indicates the status code returned for the application installation, update, or uninstallation
|
||||||
|
* result.
|
||||||
|
* @param resultMessage Indicates the result message returned with the status code.
|
||||||
|
* @param bundleName Indicates the name of the bundle whose state has changed.
|
||||||
|
*/
|
||||||
|
virtual void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
|
||||||
|
const std::string &bundleName) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
ON_BUNDLE_STATE_CHANGED,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string GetBundleName()
|
||||||
|
{
|
||||||
|
return bundleName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBundleName(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
bundleName_ = bundleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string bundleName_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_PROXY_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "bundle_status_callback_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class BundleStatusCallbackProxy : public IRemoteProxy<IBundleStatusCallback> {
|
||||||
|
public:
|
||||||
|
explicit BundleStatusCallbackProxy(const sptr<IRemoteObject> &object);
|
||||||
|
virtual ~BundleStatusCallbackProxy() override;
|
||||||
|
/**
|
||||||
|
* @brief Called when the installation, update, or uninstallation state of an application changes from proxy side.
|
||||||
|
* @param installType Indicates the installation, update, or uninstallation state.
|
||||||
|
* The value <b>0</b> indicates that the application is being installed or updated,
|
||||||
|
* and <b>1</b> indicates that the application is being uninstalled.
|
||||||
|
* @param resultCode Indicates the status code returned for the application installation, update, or uninstallation
|
||||||
|
* result.
|
||||||
|
* @param resultMessage Indicates the result message returned with the status code.
|
||||||
|
* @param bundleName Indicates the name of the bundle whose state has changed.
|
||||||
|
*/
|
||||||
|
virtual void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
|
||||||
|
const std::string &bundleName) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline BrokerDelegator<BundleStatusCallbackProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_PROXY_H
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_HOST_H
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
|
||||||
|
#include "clean_cache_callback_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class CleanCacheCallbackHost : public IRemoteStub<ICleanCacheCallback> {
|
||||||
|
public:
|
||||||
|
CleanCacheCallbackHost();
|
||||||
|
virtual ~CleanCacheCallbackHost() override;
|
||||||
|
|
||||||
|
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_MOVE(CleanCacheCallbackHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_HOST_H
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class ICleanCacheCallback : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.CleanCacheCallback");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when clean cache files progress finished.
|
||||||
|
* @param succeeded Indicates the result of the clean cache files progress.
|
||||||
|
*/
|
||||||
|
virtual void OnCleanCacheFinished(bool succeeded) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
ON_CLEAN_CACHE_CALLBACK,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_PROXY_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "clean_cache_callback_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class CleanCacheCallbackProxy : public IRemoteProxy<ICleanCacheCallback> {
|
||||||
|
public:
|
||||||
|
explicit CleanCacheCallbackProxy(const sptr<IRemoteObject> &object);
|
||||||
|
virtual ~CleanCacheCallbackProxy() override;
|
||||||
|
/**
|
||||||
|
* @brief Called when clean cache files progress finished through the proxy object.
|
||||||
|
* @param succeeded Indicates the result of the clean cache files progress.
|
||||||
|
*/
|
||||||
|
virtual void OnCleanCacheFinished(bool succeeded) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline BrokerDelegator<CleanCacheCallbackProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_PROXY_H
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_HOST_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_HOST_H
|
||||||
|
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
|
||||||
|
#include "status_receiver_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class StatusReceiverHost : public IRemoteStub<IStatusReceiver> {
|
||||||
|
public:
|
||||||
|
StatusReceiverHost();
|
||||||
|
virtual ~StatusReceiverHost() override;
|
||||||
|
|
||||||
|
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_MOVE(StatusReceiverHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_HOST_H
|
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_INTERFACE_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_INTERFACE_H
|
||||||
|
|
||||||
|
#include "iremote_broker.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class IStatusReceiver : public IRemoteBroker {
|
||||||
|
public:
|
||||||
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.StatusReceiver");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when install status changed, with the percentage of installation progress
|
||||||
|
* @param progress Indicates the percentage of the installation progress.
|
||||||
|
*/
|
||||||
|
virtual void OnStatusNotify(const int progress) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Called when an application is installed, updated, or uninstalled.
|
||||||
|
* @param resultCode Indicates the status code returned for the application installation, update, or uninstallation
|
||||||
|
* result.
|
||||||
|
* @param resultMsg Indicates the result message returned with the status code.
|
||||||
|
*/
|
||||||
|
virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) = 0;
|
||||||
|
|
||||||
|
enum class Message {
|
||||||
|
ON_STATUS_NOTIFY,
|
||||||
|
ON_FINISHED,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SUCCESS = 0,
|
||||||
|
ERR_INSTALL_INTERNAL_ERROR,
|
||||||
|
ERR_INSTALL_HOST_INSTALLER_FAILED,
|
||||||
|
ERR_INSTALL_PARSE_FAILED,
|
||||||
|
ERR_INSTALL_VERSION_DOWNGRADE,
|
||||||
|
ERR_INSTALL_VERIFICATION_FAILED,
|
||||||
|
ERR_INSTALL_NO_SIGNATURE_INFO,
|
||||||
|
ERR_INSTALL_UPDATE_INCOMPATIBLE,
|
||||||
|
ERR_INSTALL_PARAM_ERROR,
|
||||||
|
ERR_INSTALL_PERMISSION_DENIED,
|
||||||
|
ERR_INSTALL_ENTRY_ALREADY_EXIST,
|
||||||
|
ERR_INSTALL_STATE_ERROR,
|
||||||
|
ERR_INSTALL_FILE_PATH_INVALID,
|
||||||
|
ERR_INSTALL_INVALID_HAP_NAME,
|
||||||
|
ERR_INSTALL_INVALID_BUNDLE_FILE,
|
||||||
|
ERR_INSTALL_GENERATE_UID_ERROR,
|
||||||
|
ERR_INSTALL_INSTALLD_SERVICE_ERROR,
|
||||||
|
ERR_INSTALL_BUNDLE_MGR_SERVICE_ERROR,
|
||||||
|
ERR_INSTALL_ALREADY_EXIST,
|
||||||
|
|
||||||
|
ERR_INSTALL_PARSE_UNEXPECTED,
|
||||||
|
ERR_INSTALL_PARSE_MISSING_BUNDLE,
|
||||||
|
ERR_INSTALL_PARSE_MISSING_ABILITY,
|
||||||
|
ERR_INSTALL_PARSE_NO_PROFILE,
|
||||||
|
ERR_INSTALL_PARSE_BAD_PROFILE,
|
||||||
|
ERR_INSTALL_PARSE_PROFILE_PROP_TYPE_ERROR,
|
||||||
|
ERR_INSTALL_PARSE_PROFILE_MISSING_PROP,
|
||||||
|
ERR_INSTALL_PARSE_PERMISSION_ERROR,
|
||||||
|
|
||||||
|
ERR_INSTALLD_PARAM_ERROR,
|
||||||
|
ERR_INSTALLD_GET_PROXY_ERROR,
|
||||||
|
ERR_INSTALLD_CREATE_DIR_FAILED,
|
||||||
|
ERR_INSTALLD_CREATE_DIR_EXIST,
|
||||||
|
ERR_INSTALLD_CHOWN_FAILED,
|
||||||
|
ERR_INSTALLD_REMOVE_DIR_FAILED,
|
||||||
|
ERR_INSTALLD_EXTRACT_FILES_FAILED,
|
||||||
|
ERR_INSTALLD_RNAME_DIR_FAILED,
|
||||||
|
ERR_INSTALLD_CLEAN_DIR_FAILED,
|
||||||
|
|
||||||
|
ERR_UNINSTALL_SYSTEM_APP_ERROR,
|
||||||
|
ERR_UNINSTALL_KILLING_APP_ERROR,
|
||||||
|
ERR_UNINSTALL_INVALID_NAME,
|
||||||
|
ERR_UNINSTALL_PARAM_ERROR,
|
||||||
|
ERR_UNINSTALL_PERMISSION_DENIED,
|
||||||
|
ERR_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR,
|
||||||
|
ERR_UNINSTALL_MISSING_INSTALLED_BUNDLE,
|
||||||
|
ERR_UNINSTALL_MISSING_INSTALLED_MODULE,
|
||||||
|
ERR_UNKNOWN,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_INTERFACE_H
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_PROXY_H
|
||||||
|
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_PROXY_H
|
||||||
|
|
||||||
|
#include "iremote_proxy.h"
|
||||||
|
|
||||||
|
#include "status_receiver_interface.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
class StatusReceiverProxy : public IRemoteProxy<IStatusReceiver> {
|
||||||
|
public:
|
||||||
|
explicit StatusReceiverProxy(const sptr<IRemoteObject> &object);
|
||||||
|
virtual ~StatusReceiverProxy() override;
|
||||||
|
/**
|
||||||
|
* @brief Called when install status changed, with the percentage of installation progress
|
||||||
|
* @param progress Indicates the percentage of the installation progress.
|
||||||
|
*/
|
||||||
|
virtual void OnStatusNotify(const int32_t progress) override;
|
||||||
|
/**
|
||||||
|
* @brief Called when an application is installed, updated, or uninstalled.
|
||||||
|
* @param resultCode Indicates the status code returned for the application installation, update, or uninstallation
|
||||||
|
* result.
|
||||||
|
* @param resultMsg Indicates the result message returned with the status code.
|
||||||
|
*/
|
||||||
|
virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void TransformResult(const int32_t resultCode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t resultCode_ = -1;
|
||||||
|
std::string resultMsg_;
|
||||||
|
static inline BrokerDelegator<StatusReceiverProxy> delegator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_STATUS_RECEIVER_PROXY_H
|
@ -0,0 +1,246 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ams_mgr_proxy.h"
|
||||||
|
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AmsMgrProxy::AmsMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAmsMgr>(impl)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool AmsMgrProxy::WriteInterfaceToken(MessageParcel &data)
|
||||||
|
{
|
||||||
|
if (!data.WriteInterfaceToken(AmsMgrProxy::GetDescriptor())) {
|
||||||
|
APP_LOGE("write interface token failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
if (!abilityInfo || !appInfo) {
|
||||||
|
APP_LOGE("param error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token);
|
||||||
|
data.WriteParcelable(preToken);
|
||||||
|
data.WriteParcelable(abilityInfo.get());
|
||||||
|
data.WriteParcelable(appInfo.get());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_LOAD_ABILITY), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::TerminateAbility(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_TERMINATE_ABILITY), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
data.WriteInt32(static_cast<int32_t>(state));
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_UPDATE_ABILITY_STATE), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::RegisterAppStateCallback(const sptr<IAppStateCallback> &callback)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
if (!callback) {
|
||||||
|
APP_LOGE("callback is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(callback->AsObject());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAmsMgr::Message::AMS_REGISTER_APP_STATE_CALLBACK), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::Reset()
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_RESET), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const int32_t visibility, const int32_t perceptibility, const int32_t connectionState)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
data.WriteParcelable(preToken.GetRefPtr());
|
||||||
|
data.WriteInt32(static_cast<int32_t>(visibility));
|
||||||
|
data.WriteInt32(static_cast<int32_t>(perceptibility));
|
||||||
|
data.WriteInt32(static_cast<int32_t>(connectionState));
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_TERMINATE_ABILITY), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AmsMgrProxy::KillProcessByAbilityToken(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_TERMINATE_ABILITY), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AmsMgrProxy::KillApplication(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return ERR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return ERR_NULL_OBJECT;
|
||||||
|
}
|
||||||
|
if (!data.WriteString(bundleName)) {
|
||||||
|
APP_LOGE("parcel WriteString failed");
|
||||||
|
return ERR_FLATTEN_OBJECT;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAmsMgr::Message::AMS_KILL_APPLICATION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return reply.ReadInt32();
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
152
interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp
Normal file
152
interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ams_mgr_stub.h"
|
||||||
|
|
||||||
|
#include "ipc_skeleton.h"
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "app_mgr_proxy.h"
|
||||||
|
#include "app_scheduler_interface.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AmsMgrStub::AmsMgrStub()
|
||||||
|
{
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_LOAD_ABILITY)] = &AmsMgrStub::HandleLoadAbility;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_TERMINATE_ABILITY)] =
|
||||||
|
&AmsMgrStub::HandleTerminateAbility;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_UPDATE_ABILITY_STATE)] =
|
||||||
|
&AmsMgrStub::HandleUpdateAbilityState;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_REGISTER_APP_STATE_CALLBACK)] =
|
||||||
|
&AmsMgrStub::HandleRegisterAppStateCallback;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_RESET)] = &AmsMgrStub::HandleReset;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_ABILITY_BEHAVIOR_ANALYSIS)] =
|
||||||
|
&AmsMgrStub::HandleAbilityBehaviorAnalysis;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_KILL_PEOCESS_BY_ABILITY_TOKEN)] =
|
||||||
|
&AmsMgrStub::HandleKillProcessByAbilityToken;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::AMS_KILL_APPLICATION)] = &AmsMgrStub::HandleKillApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
AmsMgrStub::~AmsMgrStub()
|
||||||
|
{
|
||||||
|
memberFuncMap_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||||
|
{
|
||||||
|
APP_LOGI("AmsMgrStub::OnReceived, code = %{public}d, flags= %{public}d.", code, option.GetFlags());
|
||||||
|
std::u16string descriptor = AmsMgrStub::GetDescriptor();
|
||||||
|
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||||
|
if (descriptor != remoteDescriptor) {
|
||||||
|
APP_LOGE("local descriptor is not equal to remote");
|
||||||
|
return ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itFunc = memberFuncMap_.find(code);
|
||||||
|
if (itFunc != memberFuncMap_.end()) {
|
||||||
|
auto memberFunc = itFunc->second;
|
||||||
|
if (memberFunc != nullptr) {
|
||||||
|
return (this->*memberFunc)(data, reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleLoadAbility(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
sptr<IRemoteObject> preToke = data.ReadParcelable<IRemoteObject>();
|
||||||
|
std::shared_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
|
||||||
|
if (!abilityInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<AbilityInfo> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ApplicationInfo> appInfo(data.ReadParcelable<ApplicationInfo>());
|
||||||
|
if (!appInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<ApplicationInfo> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadAbility(token, preToke, abilityInfo, appInfo);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleTerminateAbility(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
TerminateAbility(token);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleUpdateAbilityState(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
int32_t state = data.ReadInt32();
|
||||||
|
UpdateAbilityState(token, static_cast<AbilityState>(state));
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleRegisterAppStateCallback(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> obj = data.ReadParcelable<IRemoteObject>();
|
||||||
|
sptr<IAppStateCallback> callback = iface_cast<IAppStateCallback>(obj);
|
||||||
|
RegisterAppStateCallback(callback);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleReset(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleAbilityBehaviorAnalysis(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
sptr<IRemoteObject> preToke = data.ReadParcelable<IRemoteObject>();
|
||||||
|
int32_t visibility = data.ReadInt32();
|
||||||
|
int32_t Perceptibility = data.ReadInt32();
|
||||||
|
int32_t connectionState = data.ReadInt32();
|
||||||
|
|
||||||
|
AbilityBehaviorAnalysis(token, preToke, visibility, Perceptibility, connectionState);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleKillProcessByAbilityToken(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
|
||||||
|
KillProcessByAbilityToken(token);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrCode AmsMgrStub::HandleKillApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::string bundleName = data.ReadString();
|
||||||
|
int32_t result = KillApplication(bundleName);
|
||||||
|
reply.WriteInt32(result);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_launch_data.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
void AppLaunchData::SetApplicationInfo(const ApplicationInfo &info)
|
||||||
|
{
|
||||||
|
applicationInfo_ = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppLaunchData::SetProfile(const Profile &profile)
|
||||||
|
{
|
||||||
|
profile_ = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppLaunchData::SetProcessInfo(const ProcessInfo &info)
|
||||||
|
{
|
||||||
|
processInfo_ = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppLaunchData::SetRecordId(const int32_t recordId)
|
||||||
|
{
|
||||||
|
recordId_ = recordId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppLaunchData::SetUId(const int32_t uId)
|
||||||
|
{
|
||||||
|
uId_ = uId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppLaunchData::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
return (parcel.WriteParcelable(&applicationInfo_) && parcel.WriteParcelable(&profile_) &&
|
||||||
|
parcel.WriteParcelable(&processInfo_) && parcel.WriteInt32(recordId_) && parcel.WriteInt32(uId_));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppLaunchData::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
std::unique_ptr<ApplicationInfo> applicationInfoRead(parcel.ReadParcelable<ApplicationInfo>());
|
||||||
|
if (!applicationInfoRead) {
|
||||||
|
APP_LOGE("failed, applicationInfoRead is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
applicationInfo_ = *applicationInfoRead;
|
||||||
|
|
||||||
|
std::unique_ptr<Profile> profileRead(parcel.ReadParcelable<Profile>());
|
||||||
|
if (!profileRead) {
|
||||||
|
APP_LOGE("failed, profileRead is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
profile_ = *profileRead;
|
||||||
|
|
||||||
|
std::unique_ptr<ProcessInfo> processInfoRead(parcel.ReadParcelable<ProcessInfo>());
|
||||||
|
if (!processInfoRead) {
|
||||||
|
APP_LOGE("failed, processInfoRead is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
processInfo_ = *processInfoRead;
|
||||||
|
|
||||||
|
recordId_ = parcel.ReadInt32();
|
||||||
|
uId_ = parcel.ReadInt32();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppLaunchData *AppLaunchData::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
AppLaunchData *appLaunchData = new (std::nothrow) AppLaunchData();
|
||||||
|
if (appLaunchData && !appLaunchData->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("failed, because ReadFromParcel failed");
|
||||||
|
delete appLaunchData;
|
||||||
|
appLaunchData = nullptr;
|
||||||
|
}
|
||||||
|
return appLaunchData;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_mgr_client.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "if_system_ability_manager.h"
|
||||||
|
#include "ipc_skeleton.h"
|
||||||
|
|
||||||
|
#include "app_mgr_interface.h"
|
||||||
|
#include "app_service_manager.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppMgrClient::AppMgrClient()
|
||||||
|
{
|
||||||
|
SetServiceManager(std::make_unique<AppServiceManager>());
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrClient::~AppMgrClient()
|
||||||
|
{}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
|
||||||
|
const AbilityInfo &abilityInfo, const ApplicationInfo &appInfo)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
// From here, separate AbilityInfo and ApplicationInfo from AA.
|
||||||
|
std::shared_ptr<AbilityInfo> abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
|
||||||
|
std::shared_ptr<ApplicationInfo> appInfoPtr = std::make_shared<ApplicationInfo>(appInfo);
|
||||||
|
amsService->LoadAbility(token, preToken, abilityInfoPtr, appInfoPtr);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::TerminateAbility(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->TerminateAbility(token);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->UpdateAbilityState(token, state);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::RegisterAppStateCallback(const sptr<IAppStateCallback> &callback)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->RegisterAppStateCallback(callback);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::Reset()
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->Reset();
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token,
|
||||||
|
const sptr<IRemoteObject> &preToken, const int32_t visibility, const int32_t perceptibility,
|
||||||
|
const int32_t connectionState)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->AbilityBehaviorAnalysis(token, preToken, visibility, perceptibility, connectionState);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::KillProcessByAbilityToken(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
amsService->KillProcessByAbilityToken(token);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::KillApplication(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||||
|
if (amsService != nullptr) {
|
||||||
|
int32_t result = amsService->KillApplication(bundleName);
|
||||||
|
if (result == ERR_OK) {
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
service->ClearUpApplicationData(bundleName);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::GetAllRunningProcesses(std::shared_ptr<RunningProcessInfo> &runningProcessInfo)
|
||||||
|
{
|
||||||
|
sptr<IAppMgr> service = iface_cast<IAppMgr>(remote_);
|
||||||
|
if (service != nullptr) {
|
||||||
|
service->GetAllRunningProcesses(runningProcessInfo);
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrResultCode AppMgrClient::ConnectAppMgrService()
|
||||||
|
{
|
||||||
|
if (!serviceManager_) {
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||||
|
}
|
||||||
|
remote_ = serviceManager_->GetAppMgrService();
|
||||||
|
if (!remote_) {
|
||||||
|
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||||
|
}
|
||||||
|
return AppMgrResultCode::RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrClient::SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)
|
||||||
|
{
|
||||||
|
serviceManager_ = std::move(serviceMgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,306 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_mgr_proxy.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppMgrProxy::AppMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAppMgr>(impl)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool AppMgrProxy::WriteInterfaceToken(MessageParcel &data)
|
||||||
|
{
|
||||||
|
if (!data.WriteInterfaceToken(AppMgrProxy::GetDescriptor())) {
|
||||||
|
APP_LOGE("write interface token failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::AttachApplication(const sptr<IRemoteObject> &obj)
|
||||||
|
{
|
||||||
|
APP_LOGD("AppMgrProxy::AttachApplication start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(obj.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAppMgr::Message::AMS_APP_ATTACH_APPLICATION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::ApplicationForegrounded(const int32_t recordId)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteInt32(recordId);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_FOREGROUNDED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::ApplicationBackgrounded(const int32_t recordId)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteInt32(recordId);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_BACKGROUNDED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::ApplicationTerminated(const int32_t recordId)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteInt32(recordId);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_TERMINATED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrProxy::CheckPermission(const int32_t recordId, const std::string &permission)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return ERR_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
|
data.WriteInt32(recordId);
|
||||||
|
data.WriteString(permission);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return ERR_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAppMgr::Message::AMS_APP_CHECK_PERMISSION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGE("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
return ERR_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
return reply.ReadInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::AbilityCleaned(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAppMgr::Message::AMS_APP_ABILITY_CLEANED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr<IAmsMgr> AppMgrProxy::GetAmsMgr()
|
||||||
|
{
|
||||||
|
APP_LOGD("begin to get Ams instance");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (!SendTransactCmd(IAppMgr::Message::AMS_APP_GET_MGR_INSTANCE, data, reply)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> object = reply.ReadParcelable<IRemoteObject>();
|
||||||
|
sptr<IAmsMgr> amsMgr = iface_cast<IAmsMgr>(object);
|
||||||
|
if (!amsMgr) {
|
||||||
|
APP_LOGE("ams instance is nullptr");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
APP_LOGD("get ams instance success");
|
||||||
|
return amsMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppMgrProxy::ClearUpApplicationData(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!data.WriteString(bundleName)) {
|
||||||
|
APP_LOGE("parcel WriteString failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppMgr::Message::AMS_APP_CLEAR_UP_APPLICATION_DATA), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrProxy::IsBackgroundRunningRestricted(const std::string &bundleName)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return ERR_FLATTEN_OBJECT;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return ERR_NULL_OBJECT;
|
||||||
|
}
|
||||||
|
if (!data.WriteString(bundleName)) {
|
||||||
|
APP_LOGE("parcel WriteString failed");
|
||||||
|
return ERR_FLATTEN_OBJECT;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppMgr::Message::AMS_APP_IS_BACKGROUND_RUNNING_RESTRICTED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
return reply.ReadInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrProxy::GetAllRunningProcesses(std::shared_ptr<RunningProcessInfo> &runningProcessInfo)
|
||||||
|
{
|
||||||
|
APP_LOGD("start");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return ERR_FLATTEN_OBJECT;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return ERR_NULL_OBJECT;
|
||||||
|
}
|
||||||
|
if (!data.WriteParcelable(runningProcessInfo.get())) {
|
||||||
|
APP_LOGE("parcel WriteString failed");
|
||||||
|
return ERR_FLATTEN_OBJECT;
|
||||||
|
}
|
||||||
|
if (!SendTransactCmd(IAppMgr::Message::AMS_APP_GET_ALL_RUNNING_PROCESSES, data, reply)) {
|
||||||
|
return ERR_NULL_OBJECT;
|
||||||
|
}
|
||||||
|
int result = reply.ReadInt32();
|
||||||
|
std::unique_ptr<RunningProcessInfo> info(reply.ReadParcelable<RunningProcessInfo>());
|
||||||
|
if (!info) {
|
||||||
|
APP_LOGE("readParcelableInfo failed");
|
||||||
|
return ERR_NULL_OBJECT;
|
||||||
|
}
|
||||||
|
runningProcessInfo = std::move(info);
|
||||||
|
APP_LOGD("end");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppMgrProxy::SendTransactCmd(IAppMgr::Message code, MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (!remote) {
|
||||||
|
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||||
|
if (result != NO_ERROR) {
|
||||||
|
APP_LOGE("receive error transact code %{public}d in transact cmd %{public}d", result, code);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
163
interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_stub.cpp
Normal file
163
interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_stub.cpp
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_mgr_stub.h"
|
||||||
|
|
||||||
|
#include "ipc_skeleton.h"
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
#include "app_mgr_proxy.h"
|
||||||
|
#include "app_scheduler_interface.h"
|
||||||
|
#include "iapp_state_callback.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppMgrStub::AppMgrStub()
|
||||||
|
{
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_ATTACH_APPLICATION)] =
|
||||||
|
&AppMgrStub::HandleAttachApplication;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_FOREGROUNDED)] =
|
||||||
|
&AppMgrStub::HandleApplicationForegrounded;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_BACKGROUNDED)] =
|
||||||
|
&AppMgrStub::HandleApplicationBackgrounded;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_APPLICATION_TERMINATED)] =
|
||||||
|
&AppMgrStub::HandleApplicationTerminated;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_CHECK_PERMISSION)] =
|
||||||
|
&AppMgrStub::HandleCheckPermission;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_ABILITY_CLEANED)] =
|
||||||
|
&AppMgrStub::HandleAbilityCleaned;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_GET_MGR_INSTANCE)] = &AppMgrStub::HandleGetAmsMgr;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_CLEAR_UP_APPLICATION_DATA)] =
|
||||||
|
&AppMgrStub::HandleClearUpApplicationData;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_IS_BACKGROUND_RUNNING_RESTRICTED)] =
|
||||||
|
&AppMgrStub::HandleIsBackgroundRunningRestricted;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::AMS_APP_GET_ALL_RUNNING_PROCESSES)] =
|
||||||
|
&AppMgrStub::HandleGetAllRunningProcesses;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppMgrStub::~AppMgrStub()
|
||||||
|
{
|
||||||
|
memberFuncMap_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||||
|
{
|
||||||
|
APP_LOGI("AppMgrStub::OnReceived, code = %{public}d, flags= %{public}d.", code, option.GetFlags());
|
||||||
|
std::u16string descriptor = AppMgrStub::GetDescriptor();
|
||||||
|
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||||
|
if (descriptor != remoteDescriptor) {
|
||||||
|
APP_LOGE("local descriptor is not equal to remote");
|
||||||
|
return ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itFunc = memberFuncMap_.find(code);
|
||||||
|
if (itFunc != memberFuncMap_.end()) {
|
||||||
|
auto memberFunc = itFunc->second;
|
||||||
|
if (memberFunc != nullptr) {
|
||||||
|
return (this->*memberFunc)(data, reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleAttachApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
|
||||||
|
AttachApplication(client);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ApplicationForegrounded(data.ReadInt32());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleApplicationBackgrounded(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ApplicationBackgrounded(data.ReadInt32());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleApplicationTerminated(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ApplicationTerminated(data.ReadInt32());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleCheckPermission(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
int32_t recordId = data.ReadInt32();
|
||||||
|
std::string permission = data.ReadString();
|
||||||
|
int32_t result = CheckPermission(recordId, permission);
|
||||||
|
reply.WriteInt32(result);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleAbilityCleaned(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
AbilityCleaned(token);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleGetAmsMgr(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
int32_t result = NO_ERROR;
|
||||||
|
sptr<IAmsMgr> amsMgr = GetAmsMgr();
|
||||||
|
if (!amsMgr) {
|
||||||
|
APP_LOGE("ams instance is nullptr");
|
||||||
|
result = ERR_NO_INIT;
|
||||||
|
} else {
|
||||||
|
if (!reply.WriteParcelable(amsMgr->AsObject())) {
|
||||||
|
APP_LOGE("failed to reply ams instance to client, for write parcel error");
|
||||||
|
result = ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply.WriteInt32(result);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleClearUpApplicationData(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::string bundleName = data.ReadString();
|
||||||
|
ClearUpApplicationData(bundleName);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleIsBackgroundRunningRestricted(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::string bundleName = data.ReadString();
|
||||||
|
int32_t result = IsBackgroundRunningRestricted(bundleName);
|
||||||
|
reply.WriteInt32(result);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppMgrStub::HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::shared_ptr<RunningProcessInfo> runningProcessInfo(data.ReadParcelable<RunningProcessInfo>());
|
||||||
|
int32_t result = GetAllRunningProcesses(runningProcessInfo);
|
||||||
|
reply.WriteInt32(result);
|
||||||
|
reply.WriteParcelable(runningProcessInfo.get());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_process_data.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
bool AppProcessData::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
return (parcel.WriteString(appName) && parcel.WriteString(processName) &&
|
||||||
|
parcel.WriteInt32(static_cast<int32_t>(appState)) && parcel.WriteInt32(pid));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppProcessData::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
appName = parcel.ReadString();
|
||||||
|
|
||||||
|
processName = parcel.ReadString();
|
||||||
|
|
||||||
|
appState = static_cast<ApplicationState>(parcel.ReadInt32());
|
||||||
|
|
||||||
|
pid = parcel.ReadInt32();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppProcessData *AppProcessData::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
AppProcessData *appProcessData = new (std::nothrow) AppProcessData();
|
||||||
|
if (appProcessData && !appProcessData->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("failed, because ReadFromParcel failed");
|
||||||
|
delete appProcessData;
|
||||||
|
appProcessData = nullptr;
|
||||||
|
}
|
||||||
|
return appProcessData;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include "app_record_id.h"
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
int32_t AppRecordId::Create()
|
||||||
|
{
|
||||||
|
// Make it atomic to avoid multi app creating concurrently.
|
||||||
|
static std::atomic_int id(0);
|
||||||
|
return ++id;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,169 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_scheduler_host.h"
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "ability_info.h"
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppSchedulerHost::AppSchedulerHost()
|
||||||
|
{
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleForegroundApplication;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleBackgroundApplication;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_TERMINATE_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleTerminateApplication;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleLowMemory;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleShrinkMemory;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_ABILITY_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleLaunchAbility;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CLEAN_ABILITY_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleCleanAbility;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_APPLICATION_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleLaunchApplication;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_PROFILE_CHANGED_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleProfileChanged;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CONFIGURATION_UPDATED)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleConfigurationUpdated;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION)] =
|
||||||
|
&AppSchedulerHost::HandleScheduleProcessSecurityExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppSchedulerHost::~AppSchedulerHost()
|
||||||
|
{
|
||||||
|
memberFuncMap_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppSchedulerHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||||
|
{
|
||||||
|
APP_LOGI("AppSchedulerHost::OnReceived, code = %{public}d, flags= %{public}d.", code, option.GetFlags());
|
||||||
|
std::u16string descriptor = AppSchedulerHost::GetDescriptor();
|
||||||
|
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||||
|
if (descriptor != remoteDescriptor) {
|
||||||
|
APP_LOGE("local descriptor is not equal to remote");
|
||||||
|
return ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itFunc = memberFuncMap_.find(code);
|
||||||
|
if (itFunc != memberFuncMap_.end()) {
|
||||||
|
auto memberFunc = itFunc->second;
|
||||||
|
if (memberFunc != nullptr) {
|
||||||
|
return (this->*memberFunc)(data, reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleForegroundApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleForegroundApplication();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleBackgroundApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleBackgroundApplication();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleTerminateApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleTerminateApplication();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleLowMemory(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleLowMemory();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleShrinkMemory(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleShrinkMemory(data.ReadInt32());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleLaunchAbility(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
|
||||||
|
if (!abilityInfo) {
|
||||||
|
APP_LOGE("ReadParcelable<AbilityInfo> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
ScheduleLaunchAbility(*abilityInfo, token);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleCleanAbility(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||||
|
ScheduleCleanAbility(token);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleLaunchApplication(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::unique_ptr<AppLaunchData> launchData(data.ReadParcelable<AppLaunchData>());
|
||||||
|
if (!launchData) {
|
||||||
|
APP_LOGE("ReadParcelable<launchData> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScheduleLaunchApplication(*launchData);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleProfileChanged(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::unique_ptr<Profile> profile(data.ReadParcelable<Profile>());
|
||||||
|
if (!profile) {
|
||||||
|
APP_LOGE("ReadParcelable<Profile> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScheduleProfileChanged(*profile);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleConfigurationUpdated(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::unique_ptr<Configuration> configuration(data.ReadParcelable<Configuration>());
|
||||||
|
if (!configuration) {
|
||||||
|
APP_LOGE("ReadParcelable<Configuration> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScheduleConfigurationUpdated(*configuration);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppSchedulerHost::HandleScheduleProcessSecurityExit(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
ScheduleProcessSecurityExit();
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,274 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_scheduler_proxy.h"
|
||||||
|
|
||||||
|
#include "iremote_object.h"
|
||||||
|
#include "ipc_types.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
AppSchedulerProxy::AppSchedulerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAppScheduler>(impl)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool AppSchedulerProxy::WriteInterfaceToken(MessageParcel &data)
|
||||||
|
{
|
||||||
|
if (!data.WriteInterfaceToken(AppSchedulerProxy::GetDescriptor())) {
|
||||||
|
APP_LOGE("write interface token failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleForegroundApplication()
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION),
|
||||||
|
data,
|
||||||
|
reply,
|
||||||
|
option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleBackgroundApplication()
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret =
|
||||||
|
remote->SendRequest(static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION),
|
||||||
|
data,
|
||||||
|
reply,
|
||||||
|
option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleTerminateApplication()
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_TERMINATE_APPLICATION_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleLowMemory()
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleShrinkMemory(const int32_t level)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteInt32(level);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION),
|
||||||
|
data,
|
||||||
|
reply,
|
||||||
|
option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&info);
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_ABILITY_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleCleanAbility(const sptr<IRemoteObject> &token)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CLEAN_ABILITY_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleLaunchApplication(const AppLaunchData &launchData)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&launchData);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_APPLICATION_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleProfileChanged(const Profile &profile)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&profile);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_PROFILE_CHANGED_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleConfigurationUpdated(const Configuration &config)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&config);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CONFIGURATION_UPDATED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSchedulerProxy::ScheduleProcessSecurityExit()
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_service_manager.h"
|
||||||
|
|
||||||
|
#include "ipc_skeleton.h"
|
||||||
|
#include "system_ability_definition.h"
|
||||||
|
#include "if_system_ability_manager.h"
|
||||||
|
|
||||||
|
#include "iservice_registry.h"
|
||||||
|
#include "app_mgr_constants.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
sptr<IRemoteObject> AppServiceManager::GetAppMgrService() const
|
||||||
|
{
|
||||||
|
sptr<ISystemAbilityManager> systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||||
|
if (!systemAbilityMgr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return systemAbilityMgr->GetSystemAbility(APP_MGR_SERVICE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_state_callback_host.h"
|
||||||
|
|
||||||
|
#include "appexecfwk_errors.h"
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
#include "ipc_types.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
#include "app_state_callback_proxy.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppStateCallbackHost::AppStateCallbackHost()
|
||||||
|
{
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_APP_STATE_CHANGED)] =
|
||||||
|
&AppStateCallbackHost::HandleOnAppStateChanged;
|
||||||
|
memberFuncMap_[static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_ABILITY_REQUEST_DONE)] =
|
||||||
|
&AppStateCallbackHost::HandleOnAbilityRequestDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppStateCallbackHost::~AppStateCallbackHost()
|
||||||
|
{
|
||||||
|
memberFuncMap_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppStateCallbackHost::OnRemoteRequest(
|
||||||
|
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||||
|
{
|
||||||
|
APP_LOGI("AppStateCallbackHost::OnReceived, code = %{public}d, flags= %{public}d.", code, option.GetFlags());
|
||||||
|
std::u16string descriptor = AppStateCallbackHost::GetDescriptor();
|
||||||
|
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||||
|
if (descriptor != remoteDescriptor) {
|
||||||
|
APP_LOGE("local descriptor is not equal to remote");
|
||||||
|
return ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itFunc = memberFuncMap_.find(code);
|
||||||
|
if (itFunc != memberFuncMap_.end()) {
|
||||||
|
auto memberFunc = itFunc->second;
|
||||||
|
if (memberFunc != nullptr) {
|
||||||
|
return (this->*memberFunc)(data, reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppStateCallbackHost::OnAbilityRequestDone(const sptr<IRemoteObject> &, const AbilityState)
|
||||||
|
{
|
||||||
|
APP_LOGD("called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppStateCallbackHost::OnAppStateChanged(const AppProcessData &)
|
||||||
|
{
|
||||||
|
APP_LOGD("called");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppStateCallbackHost::HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
std::unique_ptr<AppProcessData> processData(data.ReadParcelable<AppProcessData>());
|
||||||
|
if (!processData) {
|
||||||
|
APP_LOGE("ReadParcelable<AppProcessData> failed");
|
||||||
|
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnAppStateChanged(*processData);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppStateCallbackHost::HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
sptr<IRemoteObject> obj = data.ReadParcelable<IRemoteObject>();
|
||||||
|
int32_t state = data.ReadInt32();
|
||||||
|
OnAbilityRequestDone(obj, static_cast<AbilityState>(state));
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_state_callback_proxy.h"
|
||||||
|
|
||||||
|
#include "ipc_types.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
AppStateCallbackProxy::AppStateCallbackProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAppStateCallback>(impl)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool AppStateCallbackProxy::WriteInterfaceToken(MessageParcel &data)
|
||||||
|
{
|
||||||
|
if (!data.WriteInterfaceToken(AppStateCallbackProxy::GetDescriptor())) {
|
||||||
|
APP_LOGE("write interface token failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppStateCallbackProxy::OnAbilityRequestDone(const sptr<IRemoteObject> &token, const AbilityState state)
|
||||||
|
{
|
||||||
|
APP_LOGD("begin");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(token.GetRefPtr());
|
||||||
|
int32_t abilityState = static_cast<int32_t>(state);
|
||||||
|
data.WriteInt32(abilityState);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_ABILITY_REQUEST_DONE), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppStateCallbackProxy::OnAppStateChanged(const AppProcessData &appProcessData)
|
||||||
|
{
|
||||||
|
APP_LOGD("begin");
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&appProcessData);
|
||||||
|
sptr<IRemoteObject> remote = Remote();
|
||||||
|
if (remote == nullptr) {
|
||||||
|
APP_LOGE("Remote() is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t ret = remote->SendRequest(
|
||||||
|
static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_APP_STATE_CHANGED), data, reply, option);
|
||||||
|
if (ret != NO_ERROR) {
|
||||||
|
APP_LOGW("SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
}
|
||||||
|
APP_LOGD("end");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "app_task_info.h"
|
||||||
|
|
||||||
|
#include "app_log_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AppExecFwk {
|
||||||
|
|
||||||
|
const std::string &AppTaskInfo::GetName() const
|
||||||
|
{
|
||||||
|
return appName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &AppTaskInfo::GetProcessName() const
|
||||||
|
{
|
||||||
|
return processName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t AppTaskInfo::GetPid() const
|
||||||
|
{
|
||||||
|
return pid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AppTaskInfo::GetRecordId() const
|
||||||
|
{
|
||||||
|
return appRecordId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppTaskInfo::SetName(const std::string &appName)
|
||||||
|
{
|
||||||
|
appName_ = appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppTaskInfo::SetProcessName(const std::string &processName)
|
||||||
|
{
|
||||||
|
processName_ = processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppTaskInfo::SetPid(const pid_t pid)
|
||||||
|
{
|
||||||
|
pid_ = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppTaskInfo::SetRecordId(const int32_t appRecordId)
|
||||||
|
{
|
||||||
|
appRecordId_ = appRecordId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppTaskInfo::Marshalling(Parcel &parcel) const
|
||||||
|
{
|
||||||
|
return (parcel.WriteString(appName_) && parcel.WriteString(processName_) && parcel.WriteInt32(pid_) &&
|
||||||
|
parcel.WriteInt32(appRecordId_));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppTaskInfo::ReadFromParcel(Parcel &parcel)
|
||||||
|
{
|
||||||
|
return (parcel.ReadString(appName_) && parcel.ReadString(processName_) && parcel.ReadInt32(pid_) &&
|
||||||
|
parcel.ReadInt32(appRecordId_));
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTaskInfo *AppTaskInfo::Unmarshalling(Parcel &parcel)
|
||||||
|
{
|
||||||
|
AppTaskInfo *appTaskInfo = new (std::nothrow) AppTaskInfo();
|
||||||
|
if (appTaskInfo && !appTaskInfo->ReadFromParcel(parcel)) {
|
||||||
|
APP_LOGW("failed, because ReadFromParcel failed");
|
||||||
|
delete appTaskInfo;
|
||||||
|
appTaskInfo = nullptr;
|
||||||
|
}
|
||||||
|
return appTaskInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user