OAT modify
Signed-off-by: zhaojunxia <zhaojunxia@kaihong.com>
38
OAT.xml
@ -254,6 +254,8 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkNativeWindow/screenshots/device/ProduceBuffer.jpg" desc="Provided by code/BasicFeature/Native/NdkNativeWindow"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkNativeWindow/screenshots/device/AttachBuffer.jpg" desc="Provided by code/BasicFeature/Native/NdkNativeWindow"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkNativeWindow/screenshots/device/DetachBuffer.jpg" desc="Provided by code/BasicFeature/Native/NdkNativeWindow"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkNativeWindow/screenshots/device/scaledown.jpg" desc="Provided by code/BasicFeature/Native/NdkNativeWindow"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkNativeWindow/screenshots/device/scalefit.jpg" desc="Provided by code/BasicFeature/Native/NdkNativeWindow"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/screenshots/device/QoSLog.png" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
@ -262,6 +264,20 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/screenshots/device/main.jpeg" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/screenshots/device/showhighQoScomputingTime.jpeg" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/Native/NdkNativeQoS"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/media/background.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/media/foreground.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/media/icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/resources/base/media/app_icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/screenshots/MindSporeLiteArkTSDemo.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/media/background.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/media/foreground.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/media/icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/resources/base/media/app_icon.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/MindSporeLiteCDemo/screenshots/MindSporeLiteCDemoPic.png" desc="Provided by code/DocsSample/ApplicationModels/MindSporeLiteCDemo"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/resources/base/media/icon.png" desc="Provided by code/DocsSample/ApplicationModels/ImplicitStartByTypeRely"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/screenshots/newability.png" desc="Provided by code/DocsSample/ApplicationModels/ImplicitStartByTypeRely"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ApplicationModels/StageModelAbilityInteraction/screenshot/coldstartuppage.png" desc="Provided by code/DocsSample/ApplicationModels/StageModelAbilityInteraction"/>
|
||||
@ -665,6 +681,17 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/Audio/screenshots/device/AudioVivid.jpg" desc="Provided by code/BasicFeature/Native/Audio"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/Audio/screenshots/device/index.jpg" desc="Provided by code/BasicFeature/Native/Audio"/>
|
||||
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmonyProfileDebug.pem" desc="Provided by code/Project/HapBuild"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmonyApplication.pem" desc="Provided by code/Project/HapBuild"/>
|
||||
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmonyProfileRelease.pem" desc="Provided by code/Project/HapBuild"/>
|
||||
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/hap-sign-tool.jar" desc="Provided by code/Project/HapBuild"/>
|
||||
@ -747,6 +774,17 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/screenshots/select.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/screenshots/drag.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/entry/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091651506.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_next.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_back.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/file.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/add.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/zip.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_delete.png" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="License文件头校验策略的过滤条件" >
|
||||
<filteritem type="filename" name="oh-package.json5" desc="OpenHarmony工程编译入口脚本,无需添加License头"/>
|
||||
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.samples.bundlemanagement",
|
||||
"vendor": "samples",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "bundleManagement"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 6.6 KiB |
109
code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md
Executable file
@ -0,0 +1,109 @@
|
||||
# 支持5.0特性能力sample
|
||||
|
||||
### 介绍
|
||||
|
||||
本示例使用[@ohos.bundle.bundleManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.bundleManager.d.ts),[@ohos.bundle.defaultAppManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.defaultAppManager.d.ts),[@ohos.bundle.overlay](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.overlay.d.ts)
|
||||
等接口,展示了向开发者如何调用包管理提供的public接口,验证其功能。
|
||||
|
||||
### 效果预览
|
||||
|
||||
|主页|
|
||||
|---|
|
||||
|![main](/sceenshots/device/Scene-directory.png)|
|
||||
|
||||
### 使用说明
|
||||
|
||||
此界面为主页面,其中展示了包管理各类接口的调用以及特性Overlay场景功能其作用有:
|
||||
|
||||
1、点击每个示例按钮,可调用包管理接口并把数据通过弹窗形式显现。
|
||||
|
||||
例如下图所示,点击获取BundleInfo按钮对应的接口返回结果会通过弹窗形式显现,其他示例按钮对应的返回结果形式与其相同。
|
||||
|
||||
|资源API测试|
|
||||
|---|
|
||||
|![main](/sceenshots/device/snapshot_directory.png)|
|
||||
|
||||
### 工程目录
|
||||
|
||||
```
|
||||
entry/src/main/ets/
|
||||
|---entryability
|
||||
|---newuiextability // ExtensionAbilitiy实现类
|
||||
|---pages
|
||||
| |---Index.ets // 场景首页
|
||||
| |---NewPage.ets // 静态快捷方式场景
|
||||
|---libraryOverlay // 动态共享包
|
||||
|---libraryRuntimeOverlay
|
||||
```
|
||||
|
||||
动态共享包可参考:[HSP (openharmony.cn)](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/quick-start/in-app-hsp.md)
|
||||
|
||||
### 具体实现
|
||||
|
||||
#### 包管理API调用示例具体实现:
|
||||
|
||||
1、引入d.ts头文件import bundleManager from '@ohos.bundle.bundleManager';import defaultAppMgr from '@ohos.bundle.defaultAppManager';import overlay from '@ohos.bundle.overlay';然后调用内部的相关接口,例如:
|
||||
|
||||
* 获取当前应用的BundleInfo:bundleManager.getBundleInfoForSelf()
|
||||
* 获取BundleInfo(sync):bundleManager.getBundleInfoForSelfSync()
|
||||
* 获取配置json:bundleManager.getProfileByAbility()
|
||||
* 获取配置json(sync):bundleManager.getProfileByExtensionAbility()
|
||||
* 获取配置数组:bundleManager.getProfileByExtensionAbilitySync()
|
||||
* 校验.abc文件:bundleManager.verifyAbc()
|
||||
* 删除.abc文件:bundleManager.deleteAbc()
|
||||
* 校验链接是否可打开:bundleManager.canOpenLink()
|
||||
* 判断默认应用:defaultAppMgr.isDefaultApplication()
|
||||
* 判断默认应用(sync):defaultAppMgr.isDefaultApplicationSync()
|
||||
* 设置overlay状态:overlay.setOverlayEnabled()
|
||||
* 获取overlayModuleInfo信息:overlay.getOverlayModuleInfo()
|
||||
* 获取多条overlayModuleInfo信息:overlay.getTargetOverlayModuleInfos()
|
||||
|
||||
源码参考:[资源API调用示例](entry/src/main/ets/pages/Index.ets)
|
||||
|
||||
#### 安装命令:
|
||||
|
||||
modules.abc(任意hap中的\ets\modules.abc文件)。
|
||||
|
||||
1.由于测试verifyAbc()接口,deleteAbc()接口(分别是校验.abc文件,删除.abc文件)时依赖.abc文件,因此需要推送到指定目录:
|
||||
|
||||
```
|
||||
hdc_std file send 本地路径\modules.abc /data/app/el1/bundle/public/com.samples.bundlemanagement/
|
||||
```
|
||||
|
||||
2.由于测试setOverlayEnabled(),getOverlayModuleInfo(),getTargetOverlayModuleInfos()(分别是设置overlay状态,获取overlayModuleInfo信息,获取多条overlayModuleInfo信息)时依赖动态共享包,因此需要共同安装:
|
||||
|
||||
```
|
||||
hdc_std install 本地路径\entry-default-signed.hap 本地路径\libraryRuntimeOverlay-default-signed.hsp 本地路径\libraryOverlay-default-signed.hsp
|
||||
```
|
||||
|
||||
|
||||
### 相关权限
|
||||
|
||||
不涉及。
|
||||
|
||||
### 依赖
|
||||
|
||||
不涉及。
|
||||
|
||||
### 约束与限制
|
||||
|
||||
1.本示例仅支持标准系统上运行,支持设备:RK3568;
|
||||
|
||||
2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.22;
|
||||
|
||||
3.本示例需要使用DevEco Studio 4.1.3 Release(Build Version: 4.1.3.500, built on January 20, 2024)才可编译运行;
|
||||
|
||||
4.本示例涉及权限至少为system_basic级别。
|
||||
|
||||
### 下载
|
||||
|
||||
如需单独下载本工程,执行如下命令:
|
||||
|
||||
```
|
||||
git init
|
||||
git config core.sparsecheckout true
|
||||
echo code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
||||
```
|
||||
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"compileSdkVersion": 12,
|
||||
"compatibleSdkVersion": 12,
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "libraryOverlay",
|
||||
"srcPath": "./libraryOverlay",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "libraryRuntimeOverlay",
|
||||
"srcPath": "./libraryRuntimeOverlay",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "ohosTest",
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {},
|
||||
"author": "",
|
||||
"name": "entry",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"libraryOverlay": "file:../libraryOverlay",
|
||||
"libraryRuntimeOverlay": "file:../libraryRuntimeOverlay"
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = 'entryAbility';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
|
||||
windowStage.getMainWindow((err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
let windowClass = data;
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
|
||||
|
||||
let SystemBarProperties = {
|
||||
statusBarColor: "#f1f3f5",
|
||||
navigationBarColor: "#f1f3f5"
|
||||
};
|
||||
windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
|
||||
if (err) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in setting the system bar properties.');
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = 'newAbility';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
export default class NewAbility extends UIAbility {
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/NewPage', (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit';
|
||||
|
||||
export default class NewUIExtAbility extends UIExtensionAbility {
|
||||
onCreate() {
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
}
|
||||
|
||||
onSessionCreate(want: Want, session: UIExtensionContentSession) {
|
||||
let param: Record<string, Object> = {
|
||||
'session': session,
|
||||
'want': want
|
||||
};
|
||||
|
||||
let storage: LocalStorage = new LocalStorage(param);
|
||||
session.loadContent('pages/NewPage', storage);
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
}
|
||||
}
|
@ -0,0 +1,429 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { bundleManager, overlay, defaultAppManager } from '@kit.AbilityKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = 'testTag';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
export interface GroupMsg {
|
||||
title: Resource | string,
|
||||
list: ButtonMsg[]
|
||||
}
|
||||
|
||||
export interface ButtonMsg {
|
||||
text: Resource | string,
|
||||
callback?: () => void
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State buttons: GroupMsg[] = [
|
||||
{
|
||||
title: $r('app.string.GetBundleInfoCurrentApplication'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.GetBundleInfo'),
|
||||
callback: () => {
|
||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION;
|
||||
try {
|
||||
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf success. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetBundleInfoSync'),
|
||||
callback: () => {
|
||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
||||
try {
|
||||
let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelfSync success: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelfSync failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.GetConfiguration'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.GetConfigurationJson'),
|
||||
callback: () => {
|
||||
let moduleName = 'entry';
|
||||
let abilityName = 'EntryAbility';
|
||||
let metadataName = 'ohos.ability.shortcuts';
|
||||
try {
|
||||
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
|
||||
if (err) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByAbility failed. Cause: %{public}s', err.message);
|
||||
} else {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByAbility success: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByAbility failed. Cause: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetConfigurationArray'),
|
||||
callback: () => {
|
||||
let moduleName = 'entry';
|
||||
let extensionAbilityName = 'NewUIExtAbility';
|
||||
let metadataName = 'ohos.ability.NewUIExtAbility';
|
||||
try {
|
||||
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName,
|
||||
(err, data) => {
|
||||
if (err) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbility failed: %{public}s', err.message);
|
||||
} else {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbility success: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbility failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetConfigurationJsonSync'),
|
||||
callback: () => {
|
||||
let moduleName = 'entry';
|
||||
let extensionAbilityName = 'NewUIExtAbility';
|
||||
let metadataName = 'ohos.ability.NewUIExtAbility';
|
||||
try {
|
||||
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync successfully. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
|
||||
}
|
||||
|
||||
try {
|
||||
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync successfully. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.VerifyFile'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.VerifyFile'),
|
||||
callback: () => {
|
||||
let abcPaths: Array<string> = ['/data/storage/el1/bundle/modules.abc'];
|
||||
try {
|
||||
bundleManager.verifyAbc(abcPaths, true).then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'verifyAbc successfully' + JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: 'success', duration: 3000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'verifyAbc err: %{public}s', err.message);
|
||||
})
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'verifyAbc failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.DeleteFile'),
|
||||
callback: () => {
|
||||
let abcPath: string = '/data/storage/el1/bundle/modules.abc';
|
||||
try {
|
||||
bundleManager.deleteAbc(abcPath).then(() => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'deleteAbc successfully');
|
||||
promptAction.showToast({
|
||||
message: 'success', duration: 3000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'deleteAbc failed. err: %{public}s', err.message);
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'deleteAbc failed. Cause: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.VerifyLink'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.VerifyLinkOpened'),
|
||||
callback: () => {
|
||||
try {
|
||||
let link = 'http://';
|
||||
let data = bundleManager.canOpenLink(link);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'canOpenLink successfully: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'canOpenLink failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.DetermineDefaultApplications'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.DetermineDefaultApplication'),
|
||||
callback: () => {
|
||||
defaultAppManager.isDefaultApplication(defaultAppManager.ApplicationType.BROWSER)
|
||||
.then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Operation successful. IsDefaultApplication ? ' + JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
}).catch((error: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Operation failed. Cause: ' + JSON.stringify(error));
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.DetermineDefaultApplicationSync'),
|
||||
callback: () => {
|
||||
try {
|
||||
let data = defaultAppManager.isDefaultApplicationSync(defaultAppManager.ApplicationType.AUDIO)
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Operation successful. IsDefaultApplicationSync ? ' +
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
} catch (error) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Operation failed. Cause: ' + JSON.stringify(error));
|
||||
}
|
||||
;
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.SetOverlayStatus'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.SetDisableEnableStatus'),
|
||||
callback: () => {
|
||||
let moduleName = 'libraryOverlay';
|
||||
let isEnabled = true;
|
||||
try {
|
||||
overlay.setOverlayEnabled(moduleName, isEnabled)
|
||||
.then(() => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'setOverlayEnabled success');
|
||||
promptAction.showToast({
|
||||
message: 'setOverlayEnabled success'
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'setOverlayEnabled failed due to err code: ' + err.code + ' ' +
|
||||
'message:' + err.message);
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'setOverlayEnabled failed due to err code: ' + code + ' ' +
|
||||
'message:' + message);
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: $r('app.string.ObtainOverlayModuleInfo'),
|
||||
list: [
|
||||
{
|
||||
text: $r('app.string.ObtainOverlayModuleInfoInformation'),
|
||||
callback: () => {
|
||||
let moduleName = 'libraryRuntimeOverlay';
|
||||
(async () => {
|
||||
try {
|
||||
let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(overlayModuleInfo), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getOverlayModuleInfo err code : ' + code + ' ' + 'message :' +
|
||||
message);
|
||||
}
|
||||
})();
|
||||
},
|
||||
},
|
||||
{
|
||||
text: $r('app.string.ObtainMultipleOverlayModuleInfoInformation'),
|
||||
callback: () => {
|
||||
let targetModuleName = 'entry';
|
||||
(async () => {
|
||||
try {
|
||||
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(overlayModuleInfos), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getTargetOverlayModuleInfos err code : ' + code + ' ' + 'message :' +
|
||||
message);
|
||||
}
|
||||
})();
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.interface'))
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}.height(56)
|
||||
.padding({ left: 26, right: 26 })
|
||||
.width('100%')
|
||||
|
||||
Column() {
|
||||
List({ space: 0, initialIndex: 0 }) {
|
||||
ForEach(this.buttons, (groupItem: GroupMsg, groupIndex: Number) => {
|
||||
ListItem() {
|
||||
Text(groupItem.title) {
|
||||
}
|
||||
.borderRadius(0)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
.padding({ left: 12, right: 12, top: 8 })
|
||||
.width('100%')
|
||||
.height(25)
|
||||
}
|
||||
|
||||
ListItemGroup() {
|
||||
ForEach(groupItem.list, (item: ButtonMsg, index: Number) => {
|
||||
ListItem() {
|
||||
Flex({ direction: FlexDirection.Column }) {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text(item.text) {
|
||||
}.fontSize(16)
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('99%')
|
||||
.id('key' + index)
|
||||
|
||||
if (groupItem.list.length == 3) {
|
||||
if (index < 2) {
|
||||
Row() {
|
||||
}
|
||||
.width('100%')
|
||||
.height('1%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
}
|
||||
if (groupItem.list.length == 2) {
|
||||
if (index < 1) {
|
||||
Row() {
|
||||
}
|
||||
.width('100%')
|
||||
.height('1%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.height(48)
|
||||
.onClick(item.callback)
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.borderRadius(24)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.padding({ left: 12, right: 12, top: 4, bottom: 4 })
|
||||
.margin({ top: 10, bottom: 10 })
|
||||
})
|
||||
}
|
||||
.listDirection(Axis.Vertical) // 排列方向
|
||||
.scrollBar(BarState.Off)
|
||||
.friction(0.6)
|
||||
.edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
|
||||
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'first' + firstIndex);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'last' + lastIndex);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'center' + centerIndex);
|
||||
})
|
||||
.onScrollIndex((scrollOffset: number, scrollState: ScrollState) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` +
|
||||
scrollOffset);
|
||||
})
|
||||
.padding({ left: 12, right: 12 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(700)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
.margin({ top: '16vp' })
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = '[Sample_ShortCut]';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct NewPage {
|
||||
private context = getContext(this) as common.UIAbilityContext;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_back'))
|
||||
.size({ width: 20, height: 18 })
|
||||
.margin({ right: 18 })
|
||||
.onClick(() => {
|
||||
this.context.terminateSelf(() => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'terminateSelf');
|
||||
})
|
||||
})
|
||||
Text($r('app.string.NewAbility_label'))
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}.height(56)
|
||||
.padding({ left: 26, right: 26 })
|
||||
.width('100%')
|
||||
|
||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) {
|
||||
Column() {
|
||||
Image($r('app.media.pic_empty')).width('33%')
|
||||
Text($r('app.string.empty'))
|
||||
.fontSize(14)
|
||||
}
|
||||
}.width('100%')
|
||||
.height('90%')
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.padding({ top: 36, bottom: 0 })
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:module_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntry": "./ets/entryability/EntryAbility.ts",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"exported": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
],
|
||||
"uris": [
|
||||
{
|
||||
"scheme": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ohos.ability.shortcuts",
|
||||
"resource": "$profile:shortcuts_config"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NewAbility",
|
||||
"srcEntry": "./ets/newability/NewAbility.ts",
|
||||
"description": "$string:NewAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:NewAbility_label",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ohos.ability.NewAbility",
|
||||
"resource": "$profile:shortcuts_config"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"extensionAbilities": [
|
||||
{
|
||||
"name": "NewUIExtAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "NewUIExtAbility",
|
||||
"exported": true,
|
||||
"type": "sysPicker/share",
|
||||
"srcEntry": "./ets/newuiextability/NewUIExtAbility.ets",
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ohos.ability.NewUIExtAbility",
|
||||
"resource": "$profile:shortcuts_config"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.RUN_DYN_CODE",
|
||||
}
|
||||
],
|
||||
"querySchemes": [
|
||||
"http"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "button_color",
|
||||
"value": "#027DFF"
|
||||
},
|
||||
{
|
||||
"name": "backGrounding",
|
||||
"value": "#f1f3f5"
|
||||
},
|
||||
{
|
||||
"name": "text_color",
|
||||
"value": "#000"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "BundleManagement"
|
||||
},
|
||||
{
|
||||
"name": "shortcut",
|
||||
"value": "shortcut"
|
||||
},
|
||||
{
|
||||
"name": "empty",
|
||||
"value": "empty"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_label",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_desc",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "bundleManagement",
|
||||
"value": "bundleManagement"
|
||||
},
|
||||
{
|
||||
"name": "interface",
|
||||
"value": "interface"
|
||||
},
|
||||
{
|
||||
"name": "adler_crc_interface",
|
||||
"value": "adler_crc_interface"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCurrentApplication",
|
||||
"value": "获取当前应用的BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfo",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfiguration",
|
||||
"value": "获取module.json配置"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJson",
|
||||
"value": "获取配置json"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFile",
|
||||
"value": "校验.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFile",
|
||||
"value": "删除.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLink",
|
||||
"value": "校验链接"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpened",
|
||||
"value": "校验链接是否可打开"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplications",
|
||||
"value": "判断是否为默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplication",
|
||||
"value": "判断默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSync",
|
||||
"value": "判断默认应用(sync)"
|
||||
},
|
||||
{
|
||||
"name": "SetOverlayStatus",
|
||||
"value": "设置overlay状态"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatus",
|
||||
"value": "设置禁用使能状态"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfo",
|
||||
"value": "获取overlayModuleInfo"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformation",
|
||||
"value": "获取overlayModuleInfo信息"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformation",
|
||||
"value": "获取多条overlayModuleInfo信息"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_back</title>
|
||||
<defs>
|
||||
<path
|
||||
d="M5.56079777,13.7499686 L11.5303301,19.7196699 L11.5640714,19.7556673 C11.8227547,20.0502619 11.8115076,20.4991526 11.5303301,20.7803301 C11.2491526,21.0615076 10.8002619,21.0727547 10.5056673,20.8140714 L10.4696699,20.7803301 L3.43929777,13.7499686 L5.56079777,13.7499686 Z M10.4696699,3.21966991 C10.7625631,2.9267767 11.2374369,2.9267767 11.5303301,3.21966991 C11.8115076,3.5008474 11.8227547,3.94973814 11.5640714,4.24433269 L11.5303301,4.28033009 L4.5605,11.25 L21.25,11.25 C21.6494202,11.25 21.9759152,11.56223 21.9987268,11.9559318 L22,12 C22,12.3994202 21.68777,12.7259152 21.2940682,12.7487268 L21.25,12.75 L2.75,12.75 C2.09603793,12.75 1.76158663,11.9761547 2.19060357,11.5002723 L2.21966991,11.4696699 L10.4696699,3.21966991 Z"
|
||||
id="path-1"></path>
|
||||
</defs>
|
||||
<g
|
||||
id="ic_back"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<mask
|
||||
id="mask-2"
|
||||
fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use
|
||||
id="形状结合"
|
||||
fill="#182431"
|
||||
fill-rule="nonzero"
|
||||
xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="120px"
|
||||
height="120px"
|
||||
viewBox="0 0 120 120"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>pic_empty</title>
|
||||
<g
|
||||
id="pic_empty"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<path
|
||||
d="M72.3173684,96.5151117 C73.8679813,96.5315497 78.2712138,97.1257855 80.2099313,90.7893826 C86.6692105,92.1757402 90.75,94.2175519 90.75,96.4940318 C90.75,100.675369 76.9827561,104.065013 60,104.065013 C43.0172439,104.065013 29.25,100.675369 29.25,96.4940318 L29.251,96.5143826 Z"
|
||||
id="shadow"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.15"></path>
|
||||
<path
|
||||
d="M89.6271412,15.4449044 C94.6179581,15.4449044 98.1316055,19.7487672 98.1316055,24.5403259 C98.1316055,24.6405635 98.1299392,24.7404041 98.1266332,24.8398203 L98.1316055,33.8145473 L81.1226769,33.8145473 L81.1226769,24.8394944 C81.1243432,24.7404041 81.1226769,24.6405635 81.1226769,24.5403259 C81.1226769,19.7487672 84.6363243,15.4449044 89.6271412,15.4449044 Z"
|
||||
id="形状结合"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.600000024"></path>
|
||||
<path
|
||||
d="M89.7539954,15.5965666 C86.3875404,15.5965666 84.1818218,17.3578378 83.0669397,18.9023864 C81.6573733,20.8551881 81.1690409,22.657016 81.1458589,24.3124383 C81.1304042,25.4160531 81.1304042,26.5065743 81.1458589,27.5840021 L81.1457914,51.4435917 C72.8733201,53.2314678 66.675,60.5912079 66.675,69.3986432 C66.675,78.1241555 72.7585481,85.4287791 80.9154921,87.3023616 C79.7096443,97.324571 74.1091093,96.5341058 72.3173684,96.5151117 L25.3333912,96.51478 L25.333034,96.4935666 L13.2834473,96.4940318 C12.2927246,96.4940318 9.13545494,94.2417589 7.33515704,90.6729662 C6.13495845,88.293771 5.55847855,84.7631315 5.60571734,80.0810477 L25.333034,80.0805666 L25.3333912,25.4940528 C25.3333912,20.4595761 27.7355585,17.1921939 32.5398933,15.6919061 L32.8566252,15.5965666 L89.7539954,15.5965666 Z"
|
||||
id="形状结合"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.300000012"></path>
|
||||
<path
|
||||
d="M5.60571734,80.0810477 L62.729506,80.0810477 C62.3525731,85.7863224 63.0813003,89.8341336 64.9156877,92.2244812 C66.750075,94.6148288 69.4661267,96.0380124 73.0638428,96.4940318 C33.8707275,96.4940318 13.943929,96.4940318 13.2834473,96.4940318 C12.2927246,96.4940318 9.13545494,94.2417589 7.33515704,90.6729662 C6.13495845,88.293771 5.55847855,84.7631315 5.60571734,80.0810477 Z"
|
||||
id="矩形"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.400000006"></path>
|
||||
<path
|
||||
d="M98.5302859,81.8697759 L102.097608,85.4372528 C103.043246,85.0544679 104.167164,85.2464706 104.933954,86.0132607 L114.175162,95.2544691 C115.198092,96.2773987 115.198092,97.9358952 114.175162,98.9588248 L113.922423,99.2115639 C112.899493,100.234493 111.240997,100.234493 110.218067,99.2115639 L100.976859,89.9703555 C100.210208,89.2037048 100.018136,88.0800567 100.400642,87.1345259 L96.7894064,83.5216377 C97.4050227,83.0092055 97.9866118,82.457289 98.5302859,81.8697759 Z"
|
||||
id="形状结合"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.600000024"></path>
|
||||
<path
|
||||
d="M85.0446429,51.0267857 C95.1899165,51.0267857 103.414286,59.251155 103.414286,69.3964286 C103.414286,79.5417022 95.1899165,87.7660714 85.0446429,87.7660714 C74.8993692,87.7660714 66.675,79.5417022 66.675,69.3964286 C66.675,59.251155 74.8993692,51.0267857 85.0446429,51.0267857 Z M85.0446429,55.1089286 C77.1538745,55.1089286 70.7571429,61.5056602 70.7571429,69.3964286 C70.7571429,77.2871969 77.1538745,83.6839286 85.0446429,83.6839286 C92.9354112,83.6839286 99.3321429,77.2871969 99.3321429,69.3964286 C99.3321429,61.5056602 92.9354112,55.1089286 85.0446429,55.1089286 Z"
|
||||
id="形状结合"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.5"></path>
|
||||
<circle
|
||||
id="椭圆形"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.200000003"
|
||||
cx="85.0446429"
|
||||
cy="69.3964286"
|
||||
r="14.2875"></circle>
|
||||
<rect
|
||||
id="矩形"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.200000003"
|
||||
transform="translate(93.714014, 70.183327) rotate(-255.000000) translate(-93.714014, -70.183327) "
|
||||
x="89.6318713"
|
||||
y="69.5029701"
|
||||
width="8.16428571"
|
||||
height="1.36071429"
|
||||
rx="0.680357143"></rect>
|
||||
<rect
|
||||
id="矩形备份"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.200000003"
|
||||
transform="translate(91.672943, 65.420827) rotate(-255.000000) translate(-91.672943, -65.420827) "
|
||||
x="89.6318713"
|
||||
y="64.7404701"
|
||||
width="4.08214286"
|
||||
height="1.36071429"
|
||||
rx="0.680357143"></rect>
|
||||
<path
|
||||
d="M52.7160161,47.187668 C53.441911,46.9931651 54.188041,47.4239434 54.3825439,48.1498383 L56.2216997,55.0136613 C56.4162027,55.7395562 55.9854244,56.4856861 55.2595294,56.6801891 C54.5336345,56.8746921 53.7875046,56.4439138 53.5930016,55.7180188 L51.7538458,48.8541959 C51.5593428,48.1283009 51.9901211,47.382171 52.7160161,47.187668 Z M63.0592013,46.2642857 C63.8107031,46.2642857 64.4199156,46.8734983 64.4199156,47.625 L64.4199156,54.7309524 C64.4199156,55.4824541 63.8107031,56.0916667 63.0592013,56.0916667 C62.3076996,56.0916667 61.6984871,55.4824541 61.6984871,54.7309524 L61.6984871,47.625 C61.6984871,46.8734983 62.3076996,46.2642857 63.0592013,46.2642857 Z M72.6464342,47.187668 C73.3723292,47.382171 73.8031075,48.1283009 73.6086045,48.8541959 L71.7694487,55.7180188 C71.5749457,56.4439138 70.8288158,56.8746921 70.1029209,56.6801891 C69.3770259,56.4856861 68.9462476,55.7395562 69.1407506,55.0136613 L70.9799064,48.1498383 C71.1744093,47.4239434 71.9205393,46.9931651 72.6464342,47.187668 Z"
|
||||
id="形状结合"
|
||||
fill="#A1A7B3"
|
||||
opacity="0.300000012"
|
||||
transform="translate(62.681225, 51.495589) rotate(-53.000000) translate(-62.681225, -51.495589) "></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.0 KiB |
@ -0,0 +1,6 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/NewPage",
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"shortcuts": [{
|
||||
"shortcutId": "id_test1",
|
||||
"label": "$string:shortcut",
|
||||
"icon": "$media:icon",
|
||||
"wants": [{
|
||||
"bundleName": "com.samples.bundlemanagement",
|
||||
"moduleName": "entry",
|
||||
"abilityName": "NewAbility"
|
||||
}]
|
||||
}]
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "BundleManagement"
|
||||
},
|
||||
{
|
||||
"name": "shortcut",
|
||||
"value": "shortcut"
|
||||
},
|
||||
{
|
||||
"name": "empty",
|
||||
"value": "empty"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_label",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_desc",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "bundleManagement",
|
||||
"value": "bundleManagement"
|
||||
},
|
||||
{
|
||||
"name": "interface",
|
||||
"value": "interface"
|
||||
},
|
||||
{
|
||||
"name": "adler_crc_interface",
|
||||
"value": "adler_crc_interface"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCurrentApplication",
|
||||
"value": "GetBundleInfoCurrentApplication"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfo",
|
||||
"value": "GetBundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "GetBundleInfoSync"
|
||||
},
|
||||
{
|
||||
"name": "GetConfiguration",
|
||||
"value": "GetConfiguration"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJson",
|
||||
"value": "GetConfigurationJson"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "GetConfigurationArray"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "GetConfigurationJsonSync"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFile",
|
||||
"value": "VerifyFile"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFile",
|
||||
"value": "DeleteFile"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLink",
|
||||
"value": "VerifyLink"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpened",
|
||||
"value": "VerifyLinkOpened"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplications",
|
||||
"value": "DetermineDefaultApplications"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplication",
|
||||
"value": "DetermineDefaultApplication"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSync",
|
||||
"value": "DetermineDefaultApplicationSync"
|
||||
},
|
||||
{
|
||||
"name": "SetOverlayStatus",
|
||||
"value": "SetOverlayStatus"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatus",
|
||||
"value": "SetDisableEnableStatus"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfo",
|
||||
"value": "ObtainOverlayModuleInfo"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformation",
|
||||
"value": "ObtainOverlayModuleInfoInformation"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformation",
|
||||
"value": "ObtainMultipleOverlayModuleInfoInformation"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "BundleManagement"
|
||||
},
|
||||
{
|
||||
"name": "shortcut",
|
||||
"value": "快捷方式"
|
||||
},
|
||||
{
|
||||
"name": "empty",
|
||||
"value": "暂无内容"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_label",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "NewAbility_desc",
|
||||
"value": "NewAbility"
|
||||
},
|
||||
{
|
||||
"name": "bundleManagement",
|
||||
"value": "包管理"
|
||||
},
|
||||
{
|
||||
"name": "interface",
|
||||
"value": "包管理接口"
|
||||
},
|
||||
{
|
||||
"name": "adler_crc_interface",
|
||||
"value": "接口1"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility1_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCurrentApplication",
|
||||
"value": "获取当前应用的BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfo",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfiguration",
|
||||
"value": "获取module.json配置"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJson",
|
||||
"value": "获取配置json"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFile",
|
||||
"value": "校验.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFile",
|
||||
"value": "删除.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLink",
|
||||
"value": "校验链接"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpened",
|
||||
"value": "校验链接是否可打开"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplications",
|
||||
"value": "判断是否为默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplication",
|
||||
"value": "判断默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSync",
|
||||
"value": "判断默认应用(sync)"
|
||||
},
|
||||
{
|
||||
"name": "SetOverlayStatus",
|
||||
"value": "设置overlay状态"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatus",
|
||||
"value": "设置禁用使能状态"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfo",
|
||||
"value": "获取overlayModuleInfo"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformation",
|
||||
"value": "获取overlayModuleInfo信息"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformation",
|
||||
"value": "获取多条overlayModuleInfo信息"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { describe, it, expect } from '@ohos/hypium';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { Want } from '@kit.AbilityKit';
|
||||
import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = '[Sample_BundleManager]';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
const abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
let resourceManager = abilityDelegator.getAppContext().resourceManager;
|
||||
|
||||
async function sleep(time: number) {
|
||||
return new Promise<void>((resolve: Function) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
function startAbility() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'StartAbility start');
|
||||
let want: Want = {
|
||||
bundleName: 'com.samples.bundlemanagement',
|
||||
abilityName: 'EntryAbility'
|
||||
};
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getAbilityDelegator end');
|
||||
abilityDelegator.startAbility(want, (err: BusinessError) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'StartAbility get err ' + JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('AutoFillSampleTest', () => {
|
||||
/*
|
||||
* @tc.number: BundleManager_GetBundleInfoForSelf_001
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbility API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetBundleInfoForSelf_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetBundleInfoForSelfSync_001 start');
|
||||
await sleep(1000);
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'driver err ' + JSON.stringify(driver));
|
||||
startAbility();
|
||||
await sleep(2000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetBundleInfoTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetBundleInfoForSelfSync_002
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetBundleInfoForSelfSync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetBundleInfoForSelfSync_002', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetBundleInfoForSelfSync_002 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetBundleInfoSyncTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByAbility_004
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByAbility API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByAbility_004', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByAbility_004 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationJsonTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbility_005
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbility API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByExtensionAbility_005', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbility_005 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationArrayTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(2000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbilitySync_006
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbilitySync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByExtensionAbilitySync_006', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbilitySync_006 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(2000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationJsonSyncTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_CanOpenLink_007
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the CanOpenLink API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_CanOpenLink_007', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_CanOpenLink_007 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.VerifyLinkOpenedTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplication_008
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the IsDefaultApplication API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('DefaultAppMgr_IsDefaultApplication_008', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplication_008 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
await driver.swipe(360, 1070, 360, 600);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.DetermineDefaultApplicationTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplicationSync_009
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the IsDefaultApplicationSync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('DefaultAppMgr_IsDefaultApplicationSync_009', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplicationSync_009 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.DetermineDefaultApplicationSyncTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_SetOverlayEnabled_010
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the SetOverlayEnabled API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_SetOverlayEnabled_010', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_SetOverlayEnabled_010 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.SetDisableEnableStatusTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_GetOverlayModuleInfo_011
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetOverlayModuleInfo API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_GetOverlayModuleInfo_011', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetOverlayModuleInfo_011 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.ObtainOverlayModuleInfoInformationTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_GetTargetOverlayModuleInfos_012
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetTargetOverlayModuleInfos API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_GetTargetOverlayModuleInfos_012', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetTargetOverlayModuleInfos_012 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.ObtainMultipleOverlayModuleInfoInformationTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 abilityTest from './Ability.test'
|
||||
|
||||
export default function testsuite() {
|
||||
abilityTest()
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { Hypium } from '@ohos/hypium';
|
||||
import testsuite from '../test/List.test';
|
||||
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { abilityDelegatorRegistry } from '@kit.TestKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = 'testAbility';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
export default class TestAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onCreate');
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
AppStorage.set('context', this.context);
|
||||
let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator;
|
||||
abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs;
|
||||
abilityDelegatorArguments = abilityDelegatorRegistry.getArguments();
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'start run testcase!!!');
|
||||
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onWindowStageCreate');
|
||||
windowStage.loadContent('testability/pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'TestAbility onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
aboutToAppear() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
|
||||
}
|
||||
|
||||
@State message: string = 'Hello World';
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Button() {
|
||||
Text('next page')
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.type(ButtonType.Capsule)
|
||||
.margin({
|
||||
top: 20
|
||||
})
|
||||
.backgroundColor('#0D9FFB')
|
||||
.width('35%')
|
||||
.height('5%')
|
||||
.onClick(() => {
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { abilityDelegatorRegistry, TestRunner } from '@kit.TestKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
var abilityDelegator = undefined;
|
||||
var abilityDelegatorArguments = undefined;
|
||||
|
||||
const TAG: string = 'testRunner';
|
||||
const DOMAIN_NUMBER: number = 0xFF00;
|
||||
|
||||
async function onAbilityCreateCallback() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', '%{public}s', 'onAbilityCreateCallback');
|
||||
}
|
||||
|
||||
async function addAbilityMonitorCallback(err: any) {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
|
||||
}
|
||||
|
||||
export default class OpenHarmonyTestRunner implements TestRunner {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
onPrepare() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
|
||||
}
|
||||
|
||||
async onRun() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
|
||||
abilityDelegatorArguments = abilityDelegatorRegistry.getArguments();
|
||||
abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
|
||||
let lMonitor = {
|
||||
abilityName: testAbilityName,
|
||||
onAbilityCreate: onAbilityCreateCallback,
|
||||
};
|
||||
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
|
||||
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
|
||||
var debug = abilityDelegatorArguments.parameters['-D'];
|
||||
if (debug == 'true') {
|
||||
cmd += ' -D';
|
||||
}
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', 'cmd : %{public}s', cmd);
|
||||
abilityDelegator.executeShellCommand(cmd,
|
||||
(err: any, d: any) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
|
||||
})
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry_test",
|
||||
"type": "feature",
|
||||
"description": "$string:module_test_desc",
|
||||
"mainElement": "TestAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:test_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "TestAbility",
|
||||
"srcEntry": "./ets/testability/TestAbility.ets",
|
||||
"description": "$string:TestAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:TestAbility_label",
|
||||
"exported": true,
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"skills": [
|
||||
{
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
],
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonTest",
|
||||
"value": "获取配置json"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArrayTest",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFileTest",
|
||||
"value": "校验.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFileTest",
|
||||
"value": "删除.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpenedTest",
|
||||
"value": "校验链接是否可打开"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationTest",
|
||||
"value": "判断默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSyncTest",
|
||||
"value": "判断默认应用(sync)"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatusTest",
|
||||
"value": "设置禁用使能状态"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformationTest",
|
||||
"value": "获取overlayModuleInfo信息"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformationTest",
|
||||
"value": "获取多条overlayModuleInfo信息"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"testability/pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "GetBundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "GetBundleInfoSync"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonTest",
|
||||
"value": "GetConfigurationJson"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArrayTest",
|
||||
"value": "GetConfigurationArray"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"value": "GetConfigurationJsonSync"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFileTest",
|
||||
"value": "VerifyFile"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFileTest",
|
||||
"value": "DeleteFile"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpenedTest",
|
||||
"value": "VerifyLinkOpened"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationTest",
|
||||
"value": "DetermineDefaultApplication"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSyncTest",
|
||||
"value": "DetermineDefaultApplicationSync"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatusTest",
|
||||
"value": "SetDisableEnableStatus"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformationTest",
|
||||
"value": "ObtainOverlayModuleInfoInformation"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformationTest",
|
||||
"value": "ObtainMultipleOverlayModuleInfoInformation"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonTest",
|
||||
"value": "获取配置json"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArrayTest",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFileTest",
|
||||
"value": "校验.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "DeleteFileTest",
|
||||
"value": "删除.abc文件"
|
||||
},
|
||||
{
|
||||
"name": "VerifyLinkOpenedTest",
|
||||
"value": "校验链接是否可打开"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationTest",
|
||||
"value": "判断默认应用"
|
||||
},
|
||||
{
|
||||
"name": "DetermineDefaultApplicationSyncTest",
|
||||
"value": "判断默认应用(sync)"
|
||||
},
|
||||
{
|
||||
"name": "SetDisableEnableStatusTest",
|
||||
"value": "设置禁用使能状态"
|
||||
},
|
||||
{
|
||||
"name": "ObtainOverlayModuleInfoInformationTest",
|
||||
"value": "获取overlayModuleInfo信息"
|
||||
},
|
||||
{
|
||||
"name": "ObtainMultipleOverlayModuleInfoInformationTest",
|
||||
"value": "获取多条overlayModuleInfo信息"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"hvigorVersion": "4.0.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "4.0.2"
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { appTasks } from '@ohos/hvigor-ohos-plugin';
|
48
code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Hvigor startup script, version 1.0.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# NODE_HOME - location of a Node home dir
|
||||
# or
|
||||
# Add /usr/local/nodejs/bin to the PATH environment variable
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
|
||||
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
|
||||
warn() {
|
||||
echo ""
|
||||
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo ""
|
||||
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
|
||||
}
|
||||
|
||||
fail() {
|
||||
error "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Determine node to start hvigor wrapper script
|
||||
if [ -n "${NODE_HOME}" ];then
|
||||
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
|
||||
if [ ! -x "$EXECUTABLE_NODE" ];then
|
||||
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
|
||||
fi
|
||||
else
|
||||
EXECUTABLE_NODE="node"
|
||||
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
|
||||
fi
|
||||
|
||||
# Check hvigor wrapper script
|
||||
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
|
||||
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
|
||||
fi
|
||||
|
||||
# start hvigor-wrapper script
|
||||
exec "${EXECUTABLE_NODE}" \
|
||||
"${HVIGOR_WRAPPER_SCRIPT}" "$@"
|
@ -0,0 +1,64 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Hvigor startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
|
||||
set NODE_EXE=node.exe
|
||||
|
||||
goto start
|
||||
|
||||
:start
|
||||
@rem Find node.exe
|
||||
if defined NODE_HOME goto findNodeFromNodeHome
|
||||
|
||||
%NODE_EXE% --version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the NODE_HOME variable in your environment to match the
|
||||
echo location of your NodeJs installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findNodeFromNodeHome
|
||||
set NODE_HOME=%NODE_HOME:"=%
|
||||
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
|
||||
|
||||
if exist "%NODE_EXE_PATH%" goto execute
|
||||
echo.
|
||||
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the NODE_HOME variable in your environment to match the
|
||||
echo location of your NodeJs installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Execute hvigor
|
||||
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
|
||||
|
||||
if "%ERRORLEVEL%" == "0" goto hvigorwEnd
|
||||
|
||||
:fail
|
||||
exit /b 1
|
||||
|
||||
:hvigorwEnd
|
||||
if "%OS%" == "Windows_NT" endlocal
|
||||
|
||||
:end
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {},
|
||||
"author": "",
|
||||
"name": "libraryOverlay",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "./src/main/ets/Index.ets",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
export { add } from './utils/Calc'
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
export function add(a:number, b:number): number {
|
||||
return a + b;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "libraryOverlay",
|
||||
"type": "shared",
|
||||
"description": "$string:shared_desc",
|
||||
"targetModuleName":"entry",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"pages": "$profile:main_pages"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "base_overlay_test"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "overlay description"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "overlay en_US_test"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "overlay description"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "overlay测试"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {},
|
||||
"author": "",
|
||||
"name": "libraryRuntimeOverlay",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "./src/main/ets/Index.ets",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
export { add } from './utils/Calc'
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
export function add(a:number, b:number): number {
|
||||
return a + b;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "libraryRuntimeOverlay",
|
||||
"type": "shared",
|
||||
"description": "$string:shared_desc",
|
||||
"targetModuleName":"entry",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"pages": "$profile:main_pages"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "en_US_overlay_RUNTIME"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "overlay description"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "overlay en_US_test runtime"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "描述"
|
||||
},
|
||||
{
|
||||
"name": "test_string",
|
||||
"value": "overlay运行时测试"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {
|
||||
"@ohos/hypium": "1.0.6"
|
||||
},
|
||||
"author": "",
|
||||
"name": "shortcut",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
|测试功能|预置条件|输入|预期输出|测试结果|
|
||||
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetBundleInfoForSelfSync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbilitySync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下 2.拉起资源API示例页面 |不涉及|调用verifyAbc接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下 2.拉起资源API示例页面 |不涉及|调用deleteAbc接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用CanOpenLink接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplication接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplicationSync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起Overlay示例页面,根据静态overlay脚本安装共享hsp包 |不涉及|调用SetOverlayEnabled接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetOverlayModuleInfo接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetTargetOverlayModuleInfos接口成功,页面正常展示字符串文本|Pass|
|
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 84 KiB |
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
{
|
||||
"hvigorVersion": "4.2.0",
|
||||
"hvigorVersion": "4.1.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "4.2.0"
|
||||
"@ohos/hvigor-ohos-plugin": "4.1.2"
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
### 具体实现
|
||||
|
||||
* XComponent:通过在IDE中的Native c++ 工程,在c++代码中定义对外接口为register、unregister以及destroy,并调用NativeDisplaySoloist分级管控接口,可在页面上使用drawing根据设定的期望帧率来绘制。
|
||||
* 涉及到的相关接口([CAPI接口链接](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/_native_display_soloist.md)):
|
||||
|
||||
| 接口名 | 描述 |
|
||||
| -------- | -------- |
|
||||
@ -75,7 +76,7 @@
|
||||
```
|
||||
git init
|
||||
git config core.sparsecheckout true
|
||||
echo code/SystemFeature/Graphics/DisplaySoloist/ > .git/info/sparse-checkout
|
||||
echo code/BasicFeature/Graphics/DisplaySoloist/ > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
||||
|
||||
|
@ -88,8 +88,8 @@ struct Index {
|
||||
.onLoad((xComponentContext) => {
|
||||
this.xComponentContext1 = xComponentContext as XComponentContext;
|
||||
}).width('640px')
|
||||
.backgroundColor(Color.White);
|
||||
}.height('30%')
|
||||
.backgroundColor(Color.White);
|
||||
|
||||
Row() {
|
||||
Text('60hz')
|
||||
@ -114,8 +114,8 @@ struct Index {
|
||||
.onLoad((xComponentContext) => {
|
||||
this.xComponentContext2 = xComponentContext as XComponentContext;
|
||||
}).width('640px')
|
||||
.backgroundColor(Color.White);
|
||||
}.height('30%')
|
||||
.backgroundColor(Color.White);
|
||||
|
||||
Row() {
|
||||
Text('120hz')
|
||||
@ -140,8 +140,8 @@ struct Index {
|
||||
.onLoad((xComponentContext) => {
|
||||
this.xComponentContext3 = xComponentContext as XComponentContext;
|
||||
}).width('640px')
|
||||
.backgroundColor(Color.White);
|
||||
}.height('30%')
|
||||
.backgroundColor(Color.White);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"runtimeOS": "HarmonyOS"
|
||||
"runtimeOS": "OpenHarmony"
|
||||
},
|
||||
{
|
||||
"name": "ohosTest",
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 hilog from '@ohos.hilog';
|
||||
import Ability from '@ohos.app.ability.UIAbility'
|
||||
import Window from '@ohos.window'
|
||||
|
||||
import deviceInfo from '@ohos.deviceInfo'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: Window.WindowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
windowStage.getMainWindow().then((win) => {
|
||||
win.setLayoutFullScreen(true).then(() => {
|
||||
win.setSystemBarEnable(['navigation']).then(() => {
|
||||
})
|
||||
})
|
||||
win.setSystemBarProperties({
|
||||
navigationBarColor: '#00000000',
|
||||
navigationBarContentColor: '#B3B3B3'
|
||||
}).then(() => {
|
||||
})
|
||||
})
|
||||
this.onLoadContent(windowStage, 'pages/Index');
|
||||
}
|
||||
|
||||
onLoadContent(windowStage, page) {
|
||||
windowStage.loadContent(page, (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -30,6 +30,10 @@ export class Constants {
|
||||
// video frame
|
||||
static readonly VIDEO_FRAME_30 = 30; // 30: VIDEO_FRAME_30
|
||||
static readonly VIDEO_FRAME_15 = 15; // 15: VIDEO_FRAME_15
|
||||
|
||||
// video type
|
||||
static readonly IMAGE = 1;
|
||||
static readonly VIDEO = 2;
|
||||
};
|
||||
|
||||
export class SettingDataObj {
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import prompt from '@system.prompt'
|
||||
import window from '@ohos.window';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
@ -28,6 +27,12 @@ export default class EntryAbility extends UIAbility {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
const PERMISSIONS: Array<Permissions> = [
|
||||
'ohos.permission.MEDIA_LOCATION',
|
||||
'ohos.permission.MICROPHONE'
|
||||
];
|
||||
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
|
||||
atManager.requestPermissionsFromUser(this.context, PERMISSIONS);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
@ -12,20 +12,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// @ts-nocheck
|
||||
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
import DateTimeUtil from '../model/DateTimeUtil';
|
||||
import Logger from '../model/Logger';
|
||||
import { SettingDataObj } from '../common/Constants';
|
||||
import { Constants, SettingDataObj } from '../common/Constants';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
let context = getContext(this) as common.Context;
|
||||
|
||||
export default class MediaUtils {
|
||||
private tag: string = 'MediaUtils';
|
||||
private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(context);
|
||||
private mediaTest: photoAccessHelper.PhotoAsset = photoAccessHelper.getPhotoAccessHelper(context);
|
||||
private static instance: MediaUtils = new MediaUtils();
|
||||
private num: number = 0;
|
||||
private settingDataObj: SettingDataObj = {
|
||||
@ -56,19 +55,17 @@ export default class MediaUtils {
|
||||
let name = `${dateTimeUtil.getDate()}_${dateTimeUtil.getTime()}`;
|
||||
let displayName = `${info.prefix}${name}${info.suffix}`;
|
||||
Logger.info(this.tag, `createAndGetUri displayName = ${displayName},mediaType = ${mediaType}`);
|
||||
let publicPath = await this.mediaTest.getPublicDirectory(info.directory);
|
||||
Logger.info(this.tag, `createAndGetUri publicPath = ${publicPath}`);
|
||||
try {
|
||||
return await this.mediaTest.createAsset(mediaType, displayName, publicPath);
|
||||
return await this.mediaTest.createAsset(displayName);
|
||||
} catch {
|
||||
this.num++;
|
||||
displayName = `${info.prefix}${name}_${this.num}${info.suffix}`;
|
||||
return await this.mediaTest.createAsset(mediaType, displayName, publicPath);
|
||||
return await this.mediaTest.createAsset(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
async getFdPath(fileAsset: mediaLibrary.FileAsset) {
|
||||
let fd = await fileAsset.open('Rw');
|
||||
async getFdPath(fileAsset: photoAccessHelper.PhotoAsset) {
|
||||
let fd = await fileAsset.open('rw');
|
||||
Logger.info(this.tag, `fd = ${fd}`);
|
||||
return fd;
|
||||
}
|
||||
@ -94,28 +91,18 @@ export default class MediaUtils {
|
||||
|
||||
getInfoFromType(mediaType: number) {
|
||||
let result = {
|
||||
prefix: '', suffix: '', directory: 0
|
||||
prefix: '', suffix: ''
|
||||
};
|
||||
switch (mediaType) {
|
||||
case mediaLibrary.MediaType.FILE:
|
||||
result.prefix = 'FILE_';
|
||||
result.suffix = '.txt';
|
||||
result.directory = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
|
||||
break;
|
||||
case mediaLibrary.MediaType.IMAGE:
|
||||
case Constants.IMAGE:
|
||||
result.prefix = 'IMG_';
|
||||
result.suffix = `.${this.onChangePhotoFormat()}`;
|
||||
result.directory = mediaLibrary.DirectoryType.DIR_CAMERA;
|
||||
break;
|
||||
case mediaLibrary.MediaType.VIDEO:
|
||||
case Constants.VIDEO:
|
||||
result.prefix = 'VID_';
|
||||
result.suffix = '.mp4';
|
||||
result.directory = mediaLibrary.DirectoryType.DIR_CAMERA;
|
||||
break;
|
||||
case mediaLibrary.MediaType.AUDIO:
|
||||
result.prefix = 'AUD_';
|
||||
result.suffix = '.wav';
|
||||
result.directory = mediaLibrary.DirectoryType.DIR_AUDIO;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
@ -18,13 +18,13 @@
|
||||
import DateTimeUtil from '../model/DateTimeUtil';
|
||||
import Logger from '../model/Logger';
|
||||
import cameraDemo from 'libentry.so';
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
import image from '@ohos.multimedia.image';
|
||||
import media from '@ohos.multimedia.media';
|
||||
import MediaUtils from '../model/MediaUtils';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import fileio from '@ohos.fileio';
|
||||
import { SettingDataObj } from '../common/Constants'
|
||||
import { Constants, SettingDataObj } from '../common/Constants'
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
@ -54,7 +54,7 @@ interface PhotoRotationMap {
|
||||
export struct modeSwitchPage {
|
||||
private tag: string = 'sample modeSwitchPage:';
|
||||
private mediaUtil = MediaUtils.getInstance();
|
||||
private fileAsset?: mediaLibrary.FileAsset;
|
||||
private fileAsset?: photoAccessHelper.PhotoAsset;
|
||||
private fd: number = -1;
|
||||
@State videoId: string = '';
|
||||
@State mSurfaceId: string = '';
|
||||
@ -171,7 +171,7 @@ export struct modeSwitchPage {
|
||||
this.videoRecorder = await media.createAVRecorder();
|
||||
Logger.info(this.tag, `getVideoSurfaceID videoRecorder: ${this.videoRecorder}`);
|
||||
|
||||
this.fileAsset = await this.mediaUtil.createAndGetUri(mediaLibrary.MediaType.VIDEO);
|
||||
this.fileAsset = await this.mediaUtil.createAndGetUri(Constants.VIDEO);
|
||||
Logger.info(this.tag, `getVideoSurfaceID fileAsset: ${this.fileAsset}`);
|
||||
|
||||
this.fd = await this.mediaUtil.getFdPath(this.fileAsset);
|
||||
@ -247,7 +247,7 @@ export struct modeSwitchPage {
|
||||
async savePicture(buffer: ArrayBuffer, img: image.Image) {
|
||||
try {
|
||||
Logger.info(this.tag, 'savePicture start');
|
||||
let imgFileAsset = await this.mediaUtil.createAndGetUri(mediaLibrary.MediaType.IMAGE);
|
||||
let imgFileAsset: photoAccessHelper.PhotoAsset = await this.mediaUtil.createAndGetUri(Constants.IMAGE);
|
||||
let imgPhotoUri = imgFileAsset.uri;
|
||||
Logger.info(this.tag, `photoUri = ${imgPhotoUri}`);
|
||||
let imgFd = await this.mediaUtil.getFdPath(imgFileAsset);
|
||||
@ -453,7 +453,7 @@ export struct modeSwitchPage {
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
// Stop video
|
||||
this.stopVideo().then(async (fileAsset: mediaLibrary.FileAsset | undefined) => {
|
||||
this.stopVideo().then(async (fileAsset: photoAccessHelper.PhotoAsset | undefined) => {
|
||||
this.videoRecodeTime = 0;
|
||||
this.isModeBol = true;
|
||||
try {
|
||||
|
@ -70,15 +70,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_MEDIA",
|
||||
"name": "ohos.permission.WRITE_IMAGEVIDEO",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA",
|
||||
"name": "ohos.permission.READ_IMAGEVIDEO",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.MEDIA_LOCATION",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
|
@ -9,8 +9,7 @@
|
||||
使用[@ohos.effectKit](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-effectKit.md)
|
||||
生成effectKit,使用effectKit.getHighestSaturationColor()
|
||||
接口实现对图片的高亮调节。添加文字/贴纸,利用组件的组合编辑素材大小和位置,再使用OffscreenCanvasRenderingContext2D进行离屏绘制保存。
|
||||
新增图片编解码示例代码,使用[libentry.so]实现uri创建ImageSource,fd创建ImageSource,data创建ImageSource,rawFile创建ImageSource,
|
||||
imageSource转换为pixelMap,PixelMap转为file,ImageSource转为file,PixelMap转为data,ImageSource转为数据。
|
||||
接口实现对图片编解码功能。可以通过uri\fd\data\rawFile将图片资源解码为ImageSource或pixelMap。可通过ImageSource/pixelMap编码为file/data。
|
||||
|
||||
### 效果预览
|
||||
|
||||
@ -35,7 +34,7 @@ imageSource转换为pixelMap,PixelMap转为file,ImageSource转为file,Pixe
|
||||
4. 调整菜单有裁剪、缩放、旋转、调色、修改hdr设置功能(因为有些机型设备不支持,所以HDR解码后显示效果看不出来);
|
||||
5. 标记菜单有添加文字、添加贴纸功能;
|
||||
6. 编辑完成后,点击撤回按钮图片会还原到上一个编辑状态;
|
||||
7. 图片编辑完成后,点击保存,会调新增的图片编解码示例代码,用页面会跳转到发表评价页面,显示相关照片;
|
||||
7. 图片编辑完成后,点击保存,页面会跳转到发表评价页面,显示相关照片;
|
||||
8. 点击返回按钮,退出应用。
|
||||
|
||||
### 工程目录
|
||||
@ -70,7 +69,7 @@ photomodify/src/main/ets/components
|
||||
| |---Logger.ets // 日志工具
|
||||
| |---MediaUtil.ts // 媒体帮助类
|
||||
| |---SvgUtil.ts // svg操作帮助类
|
||||
| |---FileUtil.ets // 数据操作帮助类
|
||||
| |---FileUtil.ets // 图片编解码操作帮助类
|
||||
```
|
||||
|
||||
### 具体实现
|
||||
@ -82,6 +81,12 @@ photomodify/src/main/ets/components
|
||||
申请,源码参考[MainAbility.ts](entry/src/main/ets/MainAbility/MainAbility.ts)
|
||||
,首先根据选择图片获取到的uri打开图片文件,fileAsset.open选择‘rw'读写模式,然后使用image.createImageSource创建图片源实例,接下来使用createPixelMap创建PixelMap对象,便于处理图片,最后使用crop对图像进行裁剪处理,使用scale对图像进行缩放处理,rotate进行旋转处理。亮度调节使用effectKit.getHighestSaturationColor()
|
||||
接口实现对图片的高亮调节。图片解码通过createPixelMap(DecodingOptions),并根据DecodingOptions构造参数里面的设定值(0: auto;1: SDR;2 HDR),对应创建不同的PixelMap对象。其中设置值为AUTO时,会根据图片本身结构来判断是否解码为HDR内容。添加文字/贴纸,编辑模式下,使用组件组合(Image、Shape、Text)进行交互完成素材大小和位置选择;编辑确认后,再使用OffscreenCanvasRenderingContext2D进行离屏绘制,保存为新的pixelMap。
|
||||
+ 图片编解码功能在Image中实现,源码参考[Image.cpp](photomodify/src/main/cpp/Image.cpp):
|
||||
+ 图片解码:调用OH_ImageSourceNative_CreateFromUri,OH_ImageSourceNative_CreateFromFd,
|
||||
OH_ImageSourceNative_CreateFromData,OH_ImageSourceNative_CreateFromRawFile等接口,根据接收不同的参数调用不同的接口来创建ImageSource对象。
|
||||
再通过OH_ImageSourceNative_CreatePixelmap接口将ImageSource转换为新的pixelMap。
|
||||
+ 图片编码:通过调用OH_ImagePackerNative_PackToFileFromPixelmap,OH_ImagePackerNative_PackToFileFromImageSource,
|
||||
OH_ImagePackerNative_PackToDataFromPixelmap,OH_ImagePackerNative_PackToDataFromImageSource等接口,可以将ImageSource或pixelMap编码为file/data。
|
||||
|
||||
### 相关权限
|
||||
|
||||
|
@ -7,7 +7,7 @@ set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${NATIVERENDER_ROOT_PATH}
|
||||
${NATIVERENDER_ROOT_PATH}/include)
|
||||
|
||||
add_library(entry SHARED hello.cpp)
|
||||
add_library(entry SHARED Image.cpp)
|
||||
target_link_libraries(entry PUBLIC libace_napi.z.so)
|
||||
target_link_libraries(entry PUBLIC libimage_source.so)
|
||||
target_link_libraries(entry PUBLIC libimage_packer.so)
|
||||
|
@ -242,13 +242,8 @@ static napi_value packToFileImageSource(napi_env env, napi_callback_info info)
|
||||
}
|
||||
std::shared_ptr<OH_ImageSourceNative> ptrImgSource(imgSource, OH_ImageSourceNative_Release);
|
||||
|
||||
auto ptrPixelMap = CreatePixelMap(ptrImgSource.get());
|
||||
if (!ptrPixelMap) {
|
||||
return retFailed;
|
||||
}
|
||||
|
||||
errCode = OH_ImagePackerNative_PackToFileFromPixelmap(
|
||||
ptrPacker.get(), ptrOpts.get(), ptrPixelMap.get(), outFD);
|
||||
errCode = OH_ImagePackerNative_PackToFileFromImageSource(
|
||||
ptrPacker.get(), ptrOpts.get(), imgSource, outFD);
|
||||
if (errCode != IMAGE_SUCCESS) {
|
||||
return retFailed;
|
||||
}
|
||||
@ -288,14 +283,11 @@ static napi_value packToDataImageSource(napi_env env, napi_callback_info info)
|
||||
return retFailed;
|
||||
}
|
||||
std::shared_ptr<OH_ImageSourceNative> ptrImgSource(imgSource, OH_ImageSourceNative_Release);
|
||||
auto ptrPixelMap = CreatePixelMap(ptrImgSource.get());
|
||||
if (!ptrPixelMap) {
|
||||
return retFailed;
|
||||
}
|
||||
|
||||
uint8_t* outBuffer = new uint8_t[DEFAULT_BUFFER_SIZE];
|
||||
size_t outBufferSize = 0;
|
||||
errCode = OH_ImagePackerNative_PackToDataFromPixelmap(
|
||||
ptrPacker.get(), ptrOpts.get(), ptrPixelMap.get(), outBuffer, &outBufferSize);
|
||||
errCode = OH_ImagePackerNative_PackToDataFromImageSource(
|
||||
ptrPacker.get(), ptrOpts.get(), imgSource, outBuffer, &outBufferSize);
|
||||
if (errCode != IMAGE_SUCCESS) {
|
||||
delete [] outBuffer;
|
||||
return retFailed;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 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
|
||||
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
{
|
||||
"hvigorVersion": "2.4.2",
|
||||
"hvigorVersion": "4.1.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "2.4.2"
|
||||
"@ohos/hvigor-ohos-plugin": "4.1.2"
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@
|
||||
|
||||
### 效果预览
|
||||
|
||||
| 主页 | 改变矩形框颜色 | 生产buffer | 获取可用帧回调次数 |
|
||||
|----------------------------------------------|---------------------------------------------------| --------------------------------------------------------- | --------------------------------------------------------- |
|
||||
| ![main](screenshots/device/Main.jpg) | ![Draw Path](screenshots/device/ChangeColor.jpg) | ![change color](screenshots/device/ProduceBuffer.jpg) |![change color](screenshots/device/GetAvailableCount.jpg)|
|
||||
| attachbuffer | detachbuffer |
|
||||
| ![main](screenshots/device/AttachBuffer.jpg) | ![Draw Path](screenshots/device/DetachBuffer.jpg) |
|
||||
| 主页 | 改变矩形框颜色 | 生产buffer | 获取可用帧回调次数 |
|
||||
|----------------------------------------------|---------------------------------------------------|---------------------------------------------------|-----------------------------------------------------------|
|
||||
| ![main](screenshots/device/Main.jpg) | ![Draw Path](screenshots/device/ChangeColor.jpg) | ![change color](screenshots/device/ProduceBuffer.jpg) | ![change color](screenshots/device/GetAvailableCount.jpg) |
|
||||
| attachbuffer | detachbuffer | fit模式(手机) | 拉伸模式(手机) |
|
||||
| ![main](screenshots/device/AttachBuffer.jpg) | ![Draw Path](screenshots/device/DetachBuffer.jpg) | ![Draw Path](screenshots/device/scalefit.jpg) | ![Draw Path](screenshots/device/scaledown.jpg) |
|
||||
|
||||
|
||||
使用说明
|
||||
@ -19,10 +19,10 @@
|
||||
2. 点击页面底部“Chaneg Color”按钮,矩形框填充区域将改变颜色,黄蓝切换;
|
||||
3. 点击页面底部“produce buffer”按钮,NativeWindow将生产数据并发送给NativeImage,页面展示了生产buffer的次数;
|
||||
4. 点击页面底部“update available buffer count”按钮,将展示NativeImage收到的可用帧回调次数。
|
||||
5. 点击页面底部“update bufferqueuesize, attachedbuffer, cachebuffer"按钮,将更新三项数值,分别是NativeWindow的buffer队列容量,attach到NativeWindow的buffer数量,缓存区buffer数量。
|
||||
5. 点击页面底部“update bufferqueuesize, attachedbuffer, cachebuffer"按钮,将更新三项数值,分别是NativeWindow的buffer队列容量,attach到NativeWindow的buffer数量,缓存区buffer数量。
|
||||
6. 点击页面底部”attachbuffer“, 在cachebuffer大于0时将buffer添加到nativewindow中,attachedbuffer数值加1,cachebuffer数值减1;cachebuffer为0时不做处理。(需要点第五步按钮更新数值)
|
||||
7. 点击页面底部”detachbuffer", 在attachedbuffer大于0时将buffer添加到缓存区cachebuffer中,attachedbuffer数值减1,cachebuffer数值加1; attachedbuffer为0时不做处理。(需要点第五步按钮更新数值)
|
||||
8. 点击页面顶部"Change ScalingMode"按钮,在支持fit模式的设备可以切换色块居中显示或平铺显示。
|
||||
8. 点击页面顶部"Change ScalingMode"按钮,在支持fit模式的设备可以切换色块居中显示或平铺显示,开发板不支持fit模式。
|
||||
|
||||
### 工程目录
|
||||
|
||||
@ -81,6 +81,7 @@
|
||||
| OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer) | 将OHNativeWindow中的buffer移除,放置到缓存区中 |
|
||||
| OH_NativeWindow_WriteToParcel(OHNativeWindow* window, OHIPCParcel* parcel)| 向OHIPCParcel对象中写入一个OHNativeWindow对象|
|
||||
| OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window)| 从OHIPCParcel对象中读取一个OHNativeWindow对象|
|
||||
| OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode)| 为OHNativeWindow设置显示模式|
|
||||
|
||||
详细的接口说明请参考[NativeWindow](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkgraphics2d/_o_h___native_image.md),[NativeImage](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkgraphics2d/_o_h___native_image.md),[NativeBuffer](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/native-apis/_o_h___native_buffer.md)。
|
||||
|
||||
|
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 153 KiB |
@ -128,7 +128,7 @@ RenderNode。
|
||||
### 约束与限制
|
||||
|
||||
1. 本示例仅支持标准系统上运行。
|
||||
2. 本示例为Stage模型,已适配API version 12版本SDK,SDK版本号(5.0.0.19及以上),镜像版本号(5.0.0.19及以上);
|
||||
2. 本示例为Stage模型,已适配API version 12版本SDK,SDK版本号(5.0.0.26及以上),镜像版本号(5.0.0.26及以上);
|
||||
3. 本示例需要使用DevEco Studio 4.0 Beta2 版本号(4.1.3.400)及以上版本才可编译运行。
|
||||
### 下载
|
||||
|
||||
|
@ -19,6 +19,5 @@ find_library(
|
||||
)
|
||||
target_link_libraries(entry PUBLIC ${hilog-lib})
|
||||
target_link_libraries(entry PUBLIC libace_napi.z.so)
|
||||
target_link_libraries(entry PUBLIC libnative_window.so)
|
||||
target_link_libraries(entry PUBLIC libnative_drawing.so)
|
||||
target_link_libraries(entry PUBLIC libpixelmap_ndk.z.so libimage_source_ndk.z.so librawfile.z.so)
|
@ -48,7 +48,9 @@ enum DrawType {
|
||||
};
|
||||
|
||||
const int FONT_COUNT = 2;
|
||||
const char *g_paths[FONT_COUNT] = {"system/fonts/NotoSans_KR_Bold.otf", "/system/fonts/HarmonyOS_Sans_Thin_Italic.ttf"};
|
||||
const char *TEXT_DEMO = "Hello, OpenHarmony! 你好,鸿蒙!";
|
||||
const char *g_paths[FONT_COUNT] = {"system/fonts/NotoSansBengaliUI-Bold.ttf",
|
||||
"system/fonts/NotoSansDevanagariUI-Regular.ttf"};
|
||||
|
||||
static void NativeOnDrawPath(OH_Drawing_Canvas *canvas, int32_t width, int32_t height)
|
||||
{
|
||||
@ -136,8 +138,7 @@ static void NativeOnDrawText(OH_Drawing_Canvas *canvas, int32_t width, int32_t h
|
||||
OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
|
||||
OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
|
||||
// 设置文字内容
|
||||
const char *text = "你好,This is the text for demonstration";
|
||||
OH_Drawing_TypographyHandlerAddText(handler, text);
|
||||
OH_Drawing_TypographyHandlerAddText(handler, TEXT_DEMO);
|
||||
OH_Drawing_TypographyHandlerPopTextStyle(handler);
|
||||
OH_Drawing_Typography *typography = OH_Drawing_CreateTypography(handler);
|
||||
// 设置页面最大宽度
|
||||
@ -161,14 +162,6 @@ static void NativeOnDrawTextBlob(OH_Drawing_Canvas *canvas, int32_t width, int32
|
||||
OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
|
||||
OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(0xff, 0xff, 0x00, 0x00));
|
||||
OH_Drawing_CanvasAttachBrush(canvas, brush);
|
||||
// 第一种textBlob创建方式,自主指定pos和glyphsID,要求用户有自排版能力,不支持字体退化
|
||||
const int textCount = 37;
|
||||
const uint16_t glyphs[FONT_COUNT][textCount] = {
|
||||
{ 0, 3723, 21672, 53, 73, 74, 84, 1, 74, 84, 1, 85, 73, 70, 1, 85, 70, 89,
|
||||
85, 1, 71, 80, 83, 1, 69, 70, 78, 80, 79, 84, 85, 83, 66, 85, 74, 80, 79 },
|
||||
{ 0, 0, 0, 139, 256, 260, 331, 1, 260, 331, 1, 339, 256, 226, 1, 339, 226,
|
||||
374, 339, 1, 247, 298, 327, 1, 222, 226, 288, 298, 290, 331, 339, 327, 187, 339, 260, 298, 290 },
|
||||
};
|
||||
float textSize = width / 16;
|
||||
for (int i = 0; i < FONT_COUNT; ++i) {
|
||||
OH_Drawing_TextBlobBuilder *builder = OH_Drawing_TextBlobBuilderCreate();
|
||||
@ -176,27 +169,37 @@ static void NativeOnDrawTextBlob(OH_Drawing_Canvas *canvas, int32_t width, int32
|
||||
OH_Drawing_Typeface *typeface = OH_Drawing_TypefaceCreateFromFile(g_paths[i], 0);
|
||||
OH_Drawing_FontSetTypeface(font, typeface);
|
||||
OH_Drawing_FontSetTextSize(font, textSize);
|
||||
const OH_Drawing_RunBuffer *runBuffer = OH_Drawing_TextBlobBuilderAllocRunPos(builder, font, 37, nullptr);
|
||||
int textCount = OH_Drawing_FontCountText(font, TEXT_DEMO, strlen(TEXT_DEMO), TEXT_ENCODING_UTF8);
|
||||
uint16_t glyphs[textCount];
|
||||
// 获取文本对应的glyphsID
|
||||
uint32_t glyphsCount =
|
||||
OH_Drawing_FontTextToGlyphs(font, TEXT_DEMO, strlen(TEXT_DEMO), TEXT_ENCODING_UTF8, glyphs, textCount);
|
||||
float textWidth[glyphsCount];
|
||||
// 获取文本中每个字符的宽度,以此来确定排版横坐标
|
||||
OH_Drawing_FontGetWidths(font, glyphs, glyphsCount, textWidth);
|
||||
OH_Drawing_Font_Metrics metrics;
|
||||
OH_Drawing_FontGetMetrics(font, &metrics);
|
||||
// 计算字体高度用于换行
|
||||
const float textHeight = metrics.descent - metrics.ascent;
|
||||
const OH_Drawing_RunBuffer *runBuffer =
|
||||
OH_Drawing_TextBlobBuilderAllocRunPos(builder, font, glyphsCount, nullptr);
|
||||
// 以下为计算每个字的坐标设置的数据,无具体含义
|
||||
const float posX = width / 10.0;
|
||||
const float posY = height / 2.0;
|
||||
const float shortX = 1.6;
|
||||
const float enlargeY = 1.2;
|
||||
const int numberTwo = 2;
|
||||
const int wrap = 23;
|
||||
for (int j = 0; j < textCount; ++j) {
|
||||
runBuffer->glyphs[j] = glyphs[i][j];
|
||||
// 此处在第wrap个字符处换行
|
||||
if (j < wrap) {
|
||||
// 自定义字体排版中的横坐标,数据可自由指定
|
||||
runBuffer->pos[j * numberTwo] = posX + textSize * j / shortX;
|
||||
// 自定义字体排版中的纵坐标,数据可自由指定
|
||||
runBuffer->pos[j * numberTwo + 1] = posY + enlargeY * textSize * i * numberTwo;
|
||||
} else {
|
||||
// 自定义字体排版中的横坐标,数据可自由指定
|
||||
runBuffer->pos[j * numberTwo] = posX + textSize * (j - wrap) / shortX;
|
||||
// 自定义字体排版中的纵坐标,数据可自由指定
|
||||
runBuffer->pos[j * numberTwo + 1] = posY + enlargeY * textSize * (i * numberTwo + 1);
|
||||
float bufferPosX = posX;
|
||||
float bufferPosY = posY + enlargeY * textSize * i * numberTwo;
|
||||
for (int j = 0; j < glyphsCount; ++j) {
|
||||
runBuffer->glyphs[j] = glyphs[j];
|
||||
// 自定义字体排版中的横坐标
|
||||
runBuffer->pos[j * numberTwo] = bufferPosX;
|
||||
// 自定义字体排版中的纵坐标
|
||||
runBuffer->pos[j * numberTwo + 1] = bufferPosY;
|
||||
bufferPosX += textWidth[j];
|
||||
if (bufferPosX >= width) {
|
||||
bufferPosX = posX;
|
||||
bufferPosY += textHeight;
|
||||
}
|
||||
}
|
||||
OH_Drawing_TextBlob *textBlob = OH_Drawing_TextBlobBuilderMake(builder);
|
||||
@ -205,7 +208,7 @@ static void NativeOnDrawTextBlob(OH_Drawing_Canvas *canvas, int32_t width, int32
|
||||
// 第二种textBlob创建方式,通过字符串创建,带有基础的排版,且不支持字体退化
|
||||
const float tempY = 1.3;
|
||||
OH_Drawing_TextBlob *stringTextBlob =
|
||||
OH_Drawing_TextBlobCreateFromString("你好,This is the text for demonstration", font, TEXT_ENCODING_UTF8);
|
||||
OH_Drawing_TextBlobCreateFromString(TEXT_DEMO, font, TEXT_ENCODING_UTF8);
|
||||
OH_Drawing_CanvasDrawTextBlob(canvas, stringTextBlob, posX, height / tempY + textSize * i);
|
||||
|
||||
OH_Drawing_TextBlobDestroy(textBlob);
|
||||
@ -242,7 +245,8 @@ static void NativeOnDrawPixelMap(OH_Drawing_Canvas *canvas, NativePixelMap *nati
|
||||
OH_Drawing_CanvasTranslate(canvas, 300.f, 0.f);
|
||||
OH_Drawing_CanvasDrawPixelMapRect(canvas, pixelMap, src, dst, sampling);
|
||||
OH_Drawing_CanvasDetachBrush(canvas);
|
||||
|
||||
|
||||
OH_Drawing_PixelMapDissolve(pixelMap);
|
||||
OH_Drawing_BrushDestroy(brush);
|
||||
OH_Drawing_CanvasRestore(canvas);
|
||||
OH_Drawing_FilterDestroy(filter);
|
||||
|
@ -13,11 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NodeController, FrameNode, RenderNode, DrawContext } from "@ohos.arkui.node";
|
||||
import { UIContext } from '@ohos.arkui.UIContext';
|
||||
import bridge from "libentry.so";
|
||||
import image from '@ohos.multimedia.image';
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { FrameNode, NodeController, RenderNode } from '@kit.ArkUI';
|
||||
import { image } from '@kit.ImageKit';
|
||||
import { resourceManager } from '@kit.LocalizationKit';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
enum drawType {
|
||||
|
Before Width: | Height: | Size: 519 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 69 KiB |