add abilityRuntime sample
Signed-off-by: tantingting <tantingting5@huawei.com>
9
OAT.xml
@ -929,6 +929,15 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/media/icon.png" desc="Provided by code/SystemFeature/Media/Recorder"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/SystemFeature/Media/Recorder"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FullScreenStart/FullScreenStart_Service/screenshots/atomicServicePage.png" desc="Provided by code/SystemFeature/Media/Recorder"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/screenshots/appManager.jpeg" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/screenshots/index.jpeg" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/screenshots/errorManager.jpeg" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/screenshots/UIabilityContext.jpeg" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/media/background.png" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/media/foreground.png" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/media/ic_arrow.svg" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/media/app_icon.png" desc="Provided by code/BasicFeature/Ability/AbilityRuntime"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/media/background.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/media/app_icon.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
|
||||
|
12
code/BasicFeature/Ability/AbilityRuntime/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/node_modules
|
||||
/oh_modules
|
||||
/local.properties
|
||||
/.idea
|
||||
**/build
|
||||
/.hvigor
|
||||
.cxx
|
||||
/.clangd
|
||||
/.clang-format
|
||||
/.clang-tidy
|
||||
**/.test
|
||||
/.appanalyzer
|
28
code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5
Normal file
@ -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.
|
||||
*/
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.samples.abilityruntime",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"multiAppMode": {
|
||||
"multiAppModeType": "appClone",
|
||||
"maxCount": 5
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "AbilityRuntime"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 2.7 KiB |
204
code/BasicFeature/Ability/AbilityRuntime/README_zh.md
Normal file
@ -0,0 +1,204 @@
|
||||
# 基础能力增强
|
||||
|
||||
### 介绍
|
||||
|
||||
本示例使用 [AppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager.md) ,[dataUriUtils](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-dataUriUtils.md),[WantAgent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-wantAgent.md),[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md),[errorManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-errorManager.md),[UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-application-uiAbilityContext.md)中的接口进行实现。
|
||||
|
||||
### 效果预览-未更新
|
||||
|
||||
| 主页面 | appManager开发示例 | errorManager开发示例 | UIAbilityContext开发示例 |
|
||||
| :----------------------------------------------: | :---------------------------------------------------: | :-----------------------------------------------------: | :---------------------------------------------------------: |
|
||||
| <img src="screenshots/index.jpeg" width="270" /> | <img src="screenshots/appManager.jpeg" width="270" /> | <img src="screenshots/errorManager.jpeg" width="270" /> | <img src="screenshots/UIabilityContext.jpeg" width="270" /> |
|
||||
|
||||
### 使用说明
|
||||
|
||||
AppManager对应接口
|
||||
|
||||
1.点击主页面**appManager开发示例**按钮,跳转到'appManager开发示例'界面;
|
||||
|
||||
2.点击**isRunningInStabilityTest callback**按钮,弹出'isRunningInStabilityTest(callback) success...'信息;
|
||||
|
||||
3.点击**isRunningInStabilityTest promise**按钮,弹出提示'isRunningInStabilityTest(promise) success...'信息;
|
||||
|
||||
4.点击**isRamConstrainedDevice callback**按钮,弹出提示'isRamConstrainedDevice(callback) success...'信息;
|
||||
|
||||
5.点击**isRamConstrainedDevice promise**按钮,弹出提示'isRamConstrainedDevice(promise) success...'信息;
|
||||
|
||||
6.点击**getAppMemorySize callback**按钮,弹出提示'getAppMemorySize(callback) success...'信息;
|
||||
|
||||
7.点击**getAppMemorySize promise**按钮,弹出提示'getAppMemorySize(promise) success...'信息;
|
||||
|
||||
8.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation(callback) success...'信息;
|
||||
|
||||
9.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation(promise) success...'信息;
|
||||
|
||||
|
||||
|
||||
dataUriUtils对应接口
|
||||
|
||||
1.点击主页面**dataUriUtils开发示例**按钮,跳转到'dataUriUtils开发示例'界面;
|
||||
|
||||
2.点击**getId**按钮,弹出提示'dataUriUtils.getId() called ...'信息;
|
||||
|
||||
3.点击**attachId**按钮,弹出提示'dataUriUtils.attachd() called ...'信息;
|
||||
|
||||
4.点击**deleteId**按钮,弹出提示'dataUriUtils.deleteId() called ...'信息;
|
||||
|
||||
5.点击**getId**按钮,弹出提示'dataUriUtils.getId() called ...'信息;
|
||||
|
||||
|
||||
|
||||
WantAgent对应接口
|
||||
|
||||
1.点击主页面**WantAgent开发示例**按钮,跳转到'WantAgent开发示例'界面;
|
||||
|
||||
2.点击**getBundleName callback**按钮,弹出提示'getBundleName(callback) success...'信息;
|
||||
|
||||
3.点击**getBundleName promise**按钮,弹出提示'getBundleName(promise) success...'信息;
|
||||
|
||||
4.点击**getUid callback**按钮,弹出提示'getUid(callback) success...'信息;
|
||||
|
||||
5.点击**getUid promise**按钮,弹出提示'getUid(promise) success...'信息;
|
||||
|
||||
6.点击**cancel callback**按钮,弹出提示'cancel(callback) success...'信息;
|
||||
|
||||
7.点击**cancel promise**按钮,弹出提示'cancel(promise) success...'信息;
|
||||
|
||||
8.点击**equal callback**按钮,弹出提示'equal(callback) success...'信息;
|
||||
|
||||
9.点击**equal promise**按钮,弹出提示'equal(promise) success...'信息;
|
||||
|
||||
10.点击**getOperationType callback**按钮,弹出提示'getOperationType(callback) success...'信息;
|
||||
|
||||
11.点击**getOperationType promise**按钮,弹出提示'getOperationType(promise) success ...'信息;
|
||||
|
||||
12.点击**trigger**按钮,弹出提示'trigger success ...'信息;
|
||||
|
||||
|
||||
|
||||
ApplicationContext对应接口
|
||||
|
||||
1.点击主页面**ApplicationContext开发示例**按钮,跳转到'ApplicationContext开发示例'界面;
|
||||
|
||||
2.点击**setFont**按钮,弹出提示'setFont successfully ...'信息;
|
||||
|
||||
3.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation promise successfully...'信息;
|
||||
|
||||
4.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation callback successfully...'信息;
|
||||
|
||||
5.点击**getCurrentAppCloneIndex**按钮,弹出提示'getCurrentAppCloneIndex successfully ...'信息;
|
||||
|
||||
|
||||
|
||||
errorManager对应接口
|
||||
|
||||
1.点击主页面**errorManager开发示例**按钮,跳转到'errorManager开发示例'界面;
|
||||
|
||||
2.点击**注册LoopObserver**按钮,弹出提示'loopObserver registered successfully...'信息;
|
||||
|
||||
3.点击**注册UnhandledRejectionObserver**按钮,弹出提示'unhandledRejection registered successfully...'信息,列表中增加**模拟UnhandledRejection**按钮,并且原**注册UnhandledRejectionObserver**按钮变为**注销UnhandledRejectionObserver**按钮
|
||||
|
||||
4.点击**模拟UnhandledRejection**按钮,弹出提示'UnhandledRejectionObserver reason...'信息;
|
||||
|
||||
5.点击**注销UnhandledRejection**按钮,弹出提示'unhandledRejection unregistered successfully ...'信息,**注销UnhandledRejectionObserver**按钮变回**注册UnhandledRejectionObserver**按钮,列表中**模拟UnhandledRejection**按钮消失;
|
||||
|
||||
|
||||
|
||||
UIAbilityContext对应接口
|
||||
|
||||
1.点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面;
|
||||
|
||||
2.点击**moveAbilityToBackground**按钮,将启动的Ability移动到后台,页面显示为主页面,触发AbilityLifecycleCallback中的生命周期;
|
||||
|
||||
3.再次点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面,点击**terminateSelf**按钮,回到主页面;
|
||||
|
||||
### 工程目录-未更新
|
||||
|
||||
```
|
||||
entry/src/main/ets/
|
||||
|---abilitylifecyclecallback
|
||||
| |---AbilityLifecycleCallback.ets //AbilityLifecycleCallback生命周期
|
||||
|---abilitypages
|
||||
| |---ApplicationContext.ets //ApplicationContext中对应接口
|
||||
| |---AppManager.ets //AppManager中对应接口
|
||||
| |---DataUriUtils.ets //DataUriUtils中对应接口
|
||||
| |---ErrorManager.ets //ErrorManager中对应接口
|
||||
| |---UIAbilityContext.ets //UIAbilityContext中对应接口
|
||||
| |---WantAgent.ets //WantAgent中对应接口
|
||||
|---entryability
|
||||
| |---EntryAbility.ets // 首页的Ability
|
||||
|---pages
|
||||
| |---Index.ets // 首页
|
||||
```
|
||||
|
||||
### 具体实现
|
||||
|
||||
* AppManager对应接口实现,源码参考[AppManager.ets](entry/src/main/ets/abilitypages/appManager.ets)
|
||||
|
||||
* isRunningInStabilityTest(callback)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用callback异步回调,并将弹出Toast信息的功能;
|
||||
* isRunningInStabilityTest(promise)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用Promise异步回调,并将弹出Toast信息的功能;
|
||||
* isRamConstrainedDevice(callback)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用callback异步回调,并将弹出Toast信息的功能;
|
||||
* isRamConstrainedDevice(promise)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用Promise异步回调,并将弹出Toast信息的功能;
|
||||
* getAppMemorySize(callback)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用callback异步回调,并将弹出Toast信息的功能;
|
||||
* getAppMemorySize(promise)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用Promise异步回调,并将弹出Toast信息的功能;
|
||||
* getRunningProcessInformation(callback)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用callback异步回调,并将弹出Toast信息的功能;
|
||||
* getRunningProcessInformation(promise)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用Promise异步回调,并将弹出Toast信息的功能;
|
||||
* dataUriUtils对应接口实现,源码参考[DataUriUtils.ets](entry/src/main/ets/abilitypages/DataUriUtils.ets)
|
||||
|
||||
* getId接口实现:通过调用dataUriUtils.getId()接口,获取指定uri路径末尾的ID的功能;
|
||||
* attachId接口实现:通过调用dataUriUtils.attachId()接口,将ID附加到uri的路径末尾的功能;
|
||||
* deleteId接口实现:通过调用dataUriUtils.deleteId()接口,删除指定uri路径末尾的ID的功能;
|
||||
* updateId接口实现:通过调用dataUriUtils.updateId()接口,更新指定uri中的ID的功能;
|
||||
* WantAgent对应接口实现,源码参考[WantAgent.ets](entry/src/main/ets/abilitypages/WantAgent.ets)
|
||||
|
||||
* getBundleName(callback)接口实现:通过调用this.getBundleNameCallback()接口,获取WantAgent实例的包名;
|
||||
* getBundleName(promise)接口实现:通过调用this.getBundleNamePromise()接口,获取WantAgent实例的包名;
|
||||
* getUid(callback)接口实现:通过调用this.getUidCallback()接口,获取WantAgent实例的用户ID;
|
||||
* getUid(promise)接口实现:通过调用this.getUidPromise接口,获取WantAgent实例的用户ID;
|
||||
* cancel(callback)接口实现:通过调用this.cancelCallback()接口,取消WantAgent实例;
|
||||
* cancel(promise)接口实现:通过调用this.cancelPromise()接口,取消WantAgent实例;
|
||||
* equal(callback)接口实现:通过调用this.equalCallback()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的回调方法。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
|
||||
* equal(promise)接口实现:通过调用this.equalPromise()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的结果。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
|
||||
* getOperationType(callback)接口实现:通过调用this.getOperationTypeCallback()接口,获取一个WantAgent的OperationType信息;
|
||||
* getOperationType(promise)接口实现:通过调用this.getOperationTypePromise()接口,获取一个WantAgent的OperationType信息;
|
||||
* trigger接口实现:通过调用this.trigger()接口,主动激发WantAgent实例;
|
||||
* ApplicationContext对应接口实现,源码参考[ApplicationContext.ets](entry/src/main/ets/abilitypages/ApplicationContext.ets)
|
||||
|
||||
* setFont接口实现:通过调用applicationContext.setFont接口,设置应用的字体类型。仅支持主线程调用,设置字体类型,字体可以通过font.registerFont方法进行注册使用;
|
||||
* getRunningProcessInformation(callback)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
|
||||
* getRunningProcessInformation(promise)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
|
||||
* getCurrentAppCloneIndex接口实现:通过调用ApplicationContext.getCurrentAppCloneIndex接口,获取当前应用的分身索引;
|
||||
* errorManager对应接口实现,源码参考[ErrorManager.ets](entry/src/main/ets/abilitypages/ErrorManager.ets)
|
||||
* 注册on(loopObserver类型)接口实现:通过调用errorManager.on 接口,注册监听loopObserver,注册后可以捕获到应用主线程处理消息的具体执行时间,触发onLoopTimeOut,之后注销监听;
|
||||
* 注册on(unhandledRejection类型)接口实现:通过调用errorManager.on接口,注册监听unhandledRejection,注册后可以捕获到当前线程中未被捕获到的promise rejection,模拟unhandledRejection类型错误,触发监听,之后注销监听;
|
||||
* UIAbilityContext对应接口实现:源码参考[UIAbilityContext.ets](entry/src/main/ets/abilitypages/UIAbilityContext.ets)
|
||||
* moveAbilityToBackground接口实现:通过调用context.moveAbilityToBackground()接口,将处于前台的Ability移动到后台,调用context.terminateSelf(),停止Ability自身,触发AbilityLifecycleCallback中的生命周期;
|
||||
|
||||
### 相关权限
|
||||
|
||||
不涉及。
|
||||
|
||||
### 依赖
|
||||
|
||||
不涉及。
|
||||
|
||||
### 约束与限制
|
||||
|
||||
1.本示例仅支持标准系统上运行,支持设备:RK3568;
|
||||
|
||||
2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31;
|
||||
|
||||
3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.502, built on July 28, 2024)才可编译运行;
|
||||
|
||||
### 下载
|
||||
|
||||
```shell
|
||||
git init
|
||||
git config core.sparsecheckout true
|
||||
echo code/BasicFeature/Ability/AbilityRuntime > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
||||
```
|
||||
|
||||
|
||||
|
51
code/BasicFeature/Ability/AbilityRuntime/build-profile.json5
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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",
|
||||
"compatibleSdkVersion": 12,
|
||||
"compileSdkVersion": 12,
|
||||
"runtimeOS": "OpenHarmony",
|
||||
}
|
||||
],
|
||||
"buildModeSet": [
|
||||
{
|
||||
"name": "debug",
|
||||
},
|
||||
{
|
||||
"name": "release"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
6
code/BasicFeature/Ability/AbilityRuntime/entry/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/node_modules
|
||||
/oh_modules
|
||||
/.preview
|
||||
/build
|
||||
/.cxx
|
||||
/.test
|
@ -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.
|
||||
*/
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "ohosTest",
|
||||
}
|
||||
]
|
||||
}
|
21
code/BasicFeature/Ability/AbilityRuntime/entry/hvigorfile.ts
Normal file
@ -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.
|
||||
*/
|
||||
|
||||
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* 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 { AbilityConstant, AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = '[AbilityLifecycleCallback]';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
export class GlobalContext {
|
||||
private constructor() {
|
||||
}
|
||||
|
||||
private static instance: GlobalContext;
|
||||
private _objects = new Map<string, Object>();
|
||||
|
||||
public static getContext(): GlobalContext {
|
||||
if (!GlobalContext.instance) {
|
||||
GlobalContext.instance = new GlobalContext();
|
||||
}
|
||||
return GlobalContext.instance;
|
||||
}
|
||||
|
||||
getObject(value: string): Object | undefined {
|
||||
return this._objects.get(value);
|
||||
}
|
||||
|
||||
setObject(key: string, objectClass: Object): void {
|
||||
this._objects.set(key, objectClass);
|
||||
}
|
||||
}
|
||||
|
||||
// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册
|
||||
let abilityLifecycleCallback: AbilityLifecycleCallback = {
|
||||
onAbilityCreate(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityCreate.');
|
||||
},
|
||||
onWindowStageCreate(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageCreate.');
|
||||
},
|
||||
onWindowStageActive(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageActive.');
|
||||
},
|
||||
onWindowStageInactive(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageInactive.');
|
||||
},
|
||||
onWindowStageDestroy(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageDestroy.');
|
||||
},
|
||||
onAbilityDestroy(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityDestroy.');
|
||||
},
|
||||
onAbilityForeground(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityForeground.');
|
||||
},
|
||||
onAbilityBackground(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityBackground.');
|
||||
},
|
||||
onAbilityContinue(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityContinue.');
|
||||
},
|
||||
////注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发后回调。
|
||||
onNewWant(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onNewWant');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发前回调。
|
||||
onWillNewWant(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWillNewWant');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onCreate]触发前回调。
|
||||
onAbilityWillCreate(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillCreate');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageCreate]触发前回调。
|
||||
onWindowStageWillCreate(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillCreate');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageDestroy]触发前回调。
|
||||
onWindowStageWillDestroy(ability, windowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillDestroy');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onDestroy]触发前回调。
|
||||
onAbilityWillDestroy(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillDestroy');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onForeground]触发前回调。
|
||||
onAbilityWillForeground(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillForeground');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onBackground]触发前回调。
|
||||
onAbilityWillBackground(ability) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillBackground');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发前回调。
|
||||
onAbilityWillSaveState(ability: UIAbility) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillSaveState.');
|
||||
},
|
||||
//注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发后回调。
|
||||
onAbilitySaveState(ability: UIAbility) {
|
||||
hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilitySaveState.');
|
||||
}
|
||||
};
|
||||
|
||||
export default class AbilityLifecycle extends UIAbility {
|
||||
onCreate() {
|
||||
hilog.info(DOMAIN, TAG, 'MyAbilityStage onCreate');
|
||||
|
||||
// 1.通过context属性获取applicationContext
|
||||
let applicationContext = this.context.getApplicationContext();
|
||||
// 2.通过applicationContext注册监听应用内生命周期
|
||||
try {
|
||||
let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
|
||||
GlobalContext.getContext().setObject("lifecycleId", lifecycleId);
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`registerAbilityLifecycleCallback lifecycleId: ${GlobalContext.getContext().getObject('lifecycleId')}`);
|
||||
} catch (paramError) {
|
||||
hilog.error(DOMAIN, TAG, `error: ${paramError.code}, ${paramError.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'onWindowStageCreate');
|
||||
|
||||
let windowClass: window.Window | undefined = undefined;
|
||||
windowStage.getMainWindow((err: BusinessError, data) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
windowClass = data;
|
||||
let SystemBarProperties: window.SystemBarProperties = {
|
||||
statusBarColor: '#f1f3f5',
|
||||
navigationBarColor: '#f1f3f5',
|
||||
};
|
||||
try {
|
||||
windowClass.setWindowSystemBarProperties(SystemBarProperties, (err: BusinessError) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
console.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
console.info('Succeeded in setting the system bar properties.');
|
||||
});
|
||||
} catch (exception) {
|
||||
console.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
windowStage.loadContent('abilitypages/UIAbilityContext', (err, data) => {
|
||||
if (err.code) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
hilog.info(DOMAIN, TAG, 'onBackground');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
hilog.info(DOMAIN, TAG, 'onBackground');
|
||||
}
|
||||
|
||||
onPrepareToTerminate() {
|
||||
hilog.info(DOMAIN, TAG, 'onPrepareToTerminate');
|
||||
// 开发者定义预关闭动作
|
||||
// 例如拉起另一个ability,根据ability处理结果执行异步关闭
|
||||
let want: Want = {
|
||||
bundleName: "com.example.myapplication",
|
||||
moduleName: "entry",
|
||||
abilityName: "SecondAbility"
|
||||
}
|
||||
this.context.startAbilityForResult(want)
|
||||
.then((result)=>{
|
||||
// 获取ability处理结果,当返回结果的resultCode为0关闭当前UIAbility
|
||||
hilog.info(DOMAIN, TAG, 'startAbilityForResult success, resultCode is ' + result.resultCode);
|
||||
if (result.resultCode === 0) {
|
||||
this.context.terminateSelf();
|
||||
}
|
||||
}).catch((err: BusinessError)=>{
|
||||
// 异常处理
|
||||
hilog.error(DOMAIN, TAG, 'startAbilityForResult failed, err:' + JSON.stringify(err));
|
||||
this.context.terminateSelf();
|
||||
})
|
||||
|
||||
return true; // 已定义预关闭操作后,返回true表示UIAbility取消关闭
|
||||
}
|
||||
|
||||
onWindowStageWillDestroy(windowStage: window.WindowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'onWindowStageWillDestroy');
|
||||
}
|
||||
|
||||
onWindowStageRestore(windowStage: window.WindowStage) {
|
||||
hilog.info(DOMAIN, TAG, 'onWindowStageRestore');
|
||||
}
|
||||
|
||||
onSaveState(reason: AbilityConstant.StateType, wantParam: Record<string, Object>): AbilityConstant.OnSaveResult {
|
||||
// No need to save state
|
||||
hilog.info(DOMAIN, TAG, 'onSaveState');
|
||||
return AbilityConstant.OnSaveResult.ALL_REJECT;
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
hilog.info(DOMAIN, TAG, 'onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
let applicationContext = this.context.getApplicationContext();
|
||||
let lifecycleId = GlobalContext.getContext().getObject("lifecycleId") as number;
|
||||
try {
|
||||
// 3.通过applicationContext注销监听应用内生命周期
|
||||
applicationContext.off('abilityLifecycle', lifecycleId, (error) => {
|
||||
if (error && error.code !== 0) {
|
||||
hilog.error(DOMAIN, TAG, `unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}`);
|
||||
} else {
|
||||
hilog.info(DOMAIN, TAG, 'unregisterAbilityLifecycleCallback success.');
|
||||
}
|
||||
});
|
||||
} catch (paramError) {
|
||||
hilog.error(DOMAIN, TAG,
|
||||
`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,349 @@
|
||||
/*
|
||||
* 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 { appManager } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'AppManager';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct AppManager {
|
||||
private promptDuration: number = 2000;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.AppManager'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('7.18%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
.margin({
|
||||
top: '7.18%',
|
||||
bottom: '6.41%',
|
||||
left: '3.33%'
|
||||
})
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.isRunningInStabilityTestCallback'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('isRunningInStabilityTestCallback')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.isRunningInStabilityTest((err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of isRunningInStabilityTest(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `isRunningInStabilityTest(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(callback) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.isRunningInStabilityTestPromise'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('isRunningInStabilityTestPromise')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.isRunningInStabilityTest().then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of isRunningInStabilityTest(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `isRunningInStabilityTest(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(promise) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.isRamConstrainedDeviceCallback'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('isRamConstrainedDeviceCallback')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.isRamConstrainedDevice((err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of isRamConstrainedDevice(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `isRamConstrainedDevice(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(callback) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.isRamConstrainedDevicePromise'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('isRamConstrainedDevicePromise')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.isRamConstrainedDevice().then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of isRamConstrainedDevice(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `isRamConstrainedDevice(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(promise) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.getAppMemorySizeCallback'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('getAppMemorySizeCallback')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.getAppMemorySize((err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getAppMemorySize(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getAppMemorySize(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `getAppMemorySize(callback) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.getAppMemorySizePromise'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('getAppMemorySizePromise')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.getAppMemorySize().then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getAppMemorySize(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getAppMemorySize(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `getAppMemorySize(promise) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.getRunningProcessInformationCallback'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('getRunningProcessInformationCallback')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.getRunningProcessInformation((err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getRunningProcessInformation(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getRunningProcessInformation(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `getRunningProcessInformation(callback) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.getRunningProcessInformationPromise'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.id('getRunningProcessInformationPromise')
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
appManager.getRunningProcessInformation().then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getRunningProcessInformation(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getRunningProcessInformation(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `getRunningProcessInformation(promise) fail, err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
}
|
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* 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, Want } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { font, promptAction } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'ApplicationContext';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ApplicationContext {
|
||||
private promptDuration: number = 2000;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('14.36%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext_restartApp'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('restartApp')
|
||||
.onClick(() => {
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.restartApp begin.');
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let applicationContext = context.getApplicationContext();
|
||||
let want: Want = {
|
||||
bundleName: 'com.samples.abilityruntime',
|
||||
abilityName: 'EntryAbility'
|
||||
};
|
||||
try {
|
||||
applicationContext.restartApp(want);
|
||||
} catch (error) {
|
||||
hilog.info(DOMAIN, TAG, `ApplicationContext.restartApp fail, error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.restartApp succeed.');
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext_getCurrentAppCloneIndex'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getCurrentAppCloneIndex')
|
||||
.onClick(() => {
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex begin.');
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let applicationContext = context.getApplicationContext();
|
||||
try {
|
||||
let index = applicationContext.getCurrentAppCloneIndex();
|
||||
let msg = `getCurrentAppCloneIndex successfully, index: ${index}`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
} catch (error) {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`ApplicationContext.getCurrentAppCloneIndex fail, error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex succeed.');
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext_getRunningProcessInformation_callback'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getRunningProcessInformationCallback')
|
||||
.onClick(() => {
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback begin.');
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let applicationContext = context.getApplicationContext();
|
||||
|
||||
try {
|
||||
applicationContext.getRunningProcessInformation((err, data) => {
|
||||
let msg = `getRunningProcessInformation callback successfully, data: ${JSON.stringify(data)}`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`ApplicationContext.getRunningProcessInformation callback fail, error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback succeed.');
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext_getRunningProcessInformation_promise'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getRunningProcessInformationPromise')
|
||||
.onClick(() => {
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise begin.');
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let applicationContext = context.getApplicationContext();
|
||||
|
||||
try {
|
||||
applicationContext.getRunningProcessInformation().then((data) => {
|
||||
let msg = `getRunningProcessInformation promise successfully, data: ${JSON.stringify(data)}`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`ApplicationContext.getRunningProcessInformation promise fail, error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise succeed.');
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ApplicationContext_setFont'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('setFont')
|
||||
.onClick(() => {
|
||||
font.registerFont({
|
||||
familyName: 'fontName',
|
||||
familySrc: $rawfile('font/Roboto-Regular.ttf')
|
||||
})
|
||||
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont begin.');
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let applicationContext = context.getApplicationContext();
|
||||
|
||||
try {
|
||||
applicationContext.setFont("fontName");
|
||||
let msg = `setFont successfully`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`ApplicationContext.setFont fail, error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont succeed.');
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,198 @@
|
||||
/*
|
||||
* 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 { dataUriUtils } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'DataUriUtils';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct DataUriUtils {
|
||||
private promptDuration: number = 2000;
|
||||
@State loopObserverRegistered: boolean = false;
|
||||
@State unhandledRejectionRegistered: boolean = false;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.DataUriUtils'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('14.36%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.getId'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getId')
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
try {
|
||||
let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
|
||||
hilog.info(DOMAIN, TAG, `dataUriUtils.getId() called. id: ${id}`);
|
||||
promptAction.showToast({
|
||||
message: `dataUriUtils.getId() called. id: ${id}`,
|
||||
duration: this.promptDuration
|
||||
});
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, `dataUriUtils.getId() error: ${err}`);
|
||||
promptAction.showToast({
|
||||
message: `dataUriUtils.getId() error: ${err}`,
|
||||
duration: this.promptDuration
|
||||
});
|
||||
}
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.attachId'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('attachId')
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
let id = 1122;
|
||||
let uri = dataUriUtils.attachId(
|
||||
'com.example.dataUriUtils',
|
||||
id,
|
||||
);
|
||||
promptAction.showToast({
|
||||
message: `dataUriUtils.attachId() called. uri: ${JSON.stringify(uri)}`,
|
||||
duration: this.promptDuration
|
||||
});
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.deleteId'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('deleteId')
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
|
||||
promptAction.showToast({
|
||||
message: `dataUriUtils.deleteId() called. uri: ${JSON.stringify(uri)}`,
|
||||
duration: this.promptDuration
|
||||
});
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.updateId'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('updateId')
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
let id = 1122;
|
||||
let uri = dataUriUtils.updateId(
|
||||
'com.example.dataUriUtils/1221',
|
||||
id
|
||||
);
|
||||
promptAction.showToast({
|
||||
message: `dataUriUtils.updateId() called. uri: ${JSON.stringify(uri)}`,
|
||||
duration: this.promptDuration
|
||||
});
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* 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 { errorManager } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'ErrorManager';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
let observer: errorManager.LoopObserver = {
|
||||
onLoopTimeOut(timeout: number) {
|
||||
hilog.info(DOMAIN, TAG, `onLoopTimeOut, timeout: ${timeout}`)
|
||||
errorManager.off("loopObserver");
|
||||
}
|
||||
};
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ErrorManager {
|
||||
private promptDuration: number = 2000;
|
||||
private loopTimeOut: number = 20;
|
||||
@State unhandledRejectionRegistered: boolean = false;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.ErrorManager'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('14.36%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.registerLoopObserver'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('registerLoopObserver')
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
try {
|
||||
errorManager.on("loopObserver", this.loopTimeOut, observer);
|
||||
let msg = `loopObserver registered successfully, loopTimeOut: ${this.loopTimeOut}`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
} catch (error) {
|
||||
hilog.info(DOMAIN, TAG, `errorManager.on("loopObserver") failed, error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text(this.unhandledRejectionRegistered ?
|
||||
$r('app.string.unregisterUnhandledRejection') : $r('app.string.registerUnhandledRejection'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id(this.unhandledRejectionRegistered ? ('unregisterUnhandledRejection') : ('registerUnhandledRejection'))
|
||||
.onClick(() => {
|
||||
((): void => {
|
||||
if (this.unhandledRejectionRegistered == false) {
|
||||
let observer: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise<void>) => {
|
||||
let msg = `UnhandledRejectionObserver reason: ${JSON.stringify(reason)}`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
};
|
||||
|
||||
try {
|
||||
errorManager.on("unhandledRejection", observer);
|
||||
this.unhandledRejectionRegistered = true;
|
||||
let msg = `unhandledRejection registered successfully`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
} catch (error) {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`errorManager.on("unhandledRejection") failed, error: ${JSON.stringify(error)}`);
|
||||
this.unhandledRejectionRegistered = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
errorManager.off("unhandledRejection");
|
||||
this.unhandledRejectionRegistered = false;
|
||||
let msg: string = `unhandledRejection unregistered successfully`;
|
||||
hilog.info(DOMAIN, TAG, msg);
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
} catch (error) {
|
||||
this.unhandledRejectionRegistered = true;
|
||||
hilog.info(DOMAIN, TAG, `unhandledRejection unregistered failed, error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
}
|
||||
})()
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
if (this.unhandledRejectionRegistered) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.simulateUnhandledRejection'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('simulateUnhandledRejection')
|
||||
.onClick(() => {
|
||||
Promise.reject({ name: 'test', message: 'simulateUnhandledRejection' });
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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 { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
|
||||
const TAG: string = 'UIAbilityContext';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct UIAbilityContext {
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.UIAbilityContext'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('14.36%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.UIAbilityContext_moveAbilityToBackground'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('moveAbilityToBackground')
|
||||
.onClick(() => {
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
context.moveAbilityToBackground().then(() => {
|
||||
hilog.info(DOMAIN, TAG, 'moveAbilityToBackground success.');
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.info(DOMAIN, TAG, `moveAbilityToBackground error: ${JSON.stringify(err)}.`);
|
||||
});
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.UIAbilityContext_terminateSelf'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('terminateSelf')
|
||||
.onClick(() => {
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
context.terminateSelf().then(() => {
|
||||
hilog.info(DOMAIN, TAG, 'terminateSelf success.');
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.info(DOMAIN, TAG, `terminateSelf error: ${JSON.stringify(err)}.`);
|
||||
});
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,506 @@
|
||||
/*
|
||||
* 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 { wantAgent } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'WantAgent';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct WantAgentClass {
|
||||
private promptDuration: number = 2000;
|
||||
private wantAgentInfo: wantAgent.WantAgentInfo = {
|
||||
wants: [
|
||||
{
|
||||
bundleName: "com.samples.abilityruntime",
|
||||
abilityName: "EntryAbility",
|
||||
}
|
||||
],
|
||||
operationType: wantAgent.OperationType.START_ABILITY,
|
||||
requestCode: 0,
|
||||
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
|
||||
}
|
||||
|
||||
async getBundleNameCallback(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getBundleName(dataBase, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getBundleName(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getBundleName(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async getBundleNamePromise(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getBundleName(dataBase).then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getBundleName(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getBundleName(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async getUidCallback(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getUid(dataBase, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getUid(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getUid(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async getUidPromise(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getUid(dataBase).then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getUid(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getUid(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async cancelCallback(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.cancel(dataBase, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of cancel(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `cancel(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async cancelPromise(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.cancel(dataBase).then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of cancel(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `cancel(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async equalCallback(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.equal(dataBase, dataBase, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of equal(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `equal(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async equalPromise(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.equal(dataBase, dataBase).then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of equal(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `equal(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async getOperationTypeCallback(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getOperationType(dataBase, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getOperationType(callback) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getOperationType(callback) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async getOperationTypePromise(): Promise<void> {
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.getOperationType(dataBase).then((data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of getOperationType(promise) is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `getOperationType(promise) success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
async trigger(): Promise<void> {
|
||||
let triggerInfo: wantAgent.TriggerInfo = {
|
||||
code: 0,
|
||||
want: {
|
||||
bundleName: "com.samples.abilityruntime",
|
||||
abilityName: "EntryAbility",
|
||||
},
|
||||
permission: '',
|
||||
extraInfo: {
|
||||
test: 'this is a test value'
|
||||
}
|
||||
}
|
||||
|
||||
wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
|
||||
wantAgent.trigger(dataBase, triggerInfo, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG,
|
||||
`The result of trigger is: ${JSON.stringify(data)}`);
|
||||
promptAction.showToast({
|
||||
message: `trigger success, data: ${JSON.stringify(data)}`,
|
||||
duration: this.promptDuration
|
||||
})
|
||||
})
|
||||
console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.WantAgent'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('14.36%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getBundleNameCallback`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getBundleNameCallback')
|
||||
.onClick(() => {
|
||||
this.getBundleNameCallback();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getBundleNamePromise`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getBundleNamePromise')
|
||||
.onClick(() => {
|
||||
this.getBundleNamePromise();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getUidCallback`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getUidCallback')
|
||||
.onClick(() => {
|
||||
this.getUidCallback();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getUidPromise`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getUidPromise')
|
||||
.onClick(() => {
|
||||
this.getUidPromise();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.cancelCallback`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('cancelCallback')
|
||||
.onClick(() => {
|
||||
this.cancelCallback();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.cancelPromise`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('cancelPromise')
|
||||
.onClick(() => {
|
||||
this.cancelPromise();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.equalCallback`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('equalCallback')
|
||||
.onClick(() => {
|
||||
this.equalCallback();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.equalPromise`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('equalPromise')
|
||||
.onClick(() => {
|
||||
this.equalPromise();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getOperationTypeCallback`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getOperationTypeCallback')
|
||||
.onClick(() => {
|
||||
this.getOperationTypeCallback();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.getOperationTypePromise`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('getOperationTypePromise')
|
||||
.onClick(() => {
|
||||
this.getOperationTypePromise();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.trigger`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
}
|
||||
.id('trigger')
|
||||
.onClick(() => {
|
||||
this.trigger();
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('86%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
|
||||
const TAG: string = 'EntryAbility';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate');
|
||||
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
hilog.info(DOMAIN, TAG, 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.info(DOMAIN, TAG, 'Ability onWindowStageCreate');
|
||||
|
||||
let windowClass: window.Window | undefined = undefined;
|
||||
windowStage.getMainWindow((err: BusinessError, data) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
windowClass = data;
|
||||
let SystemBarProperties: window.SystemBarProperties = {
|
||||
statusBarColor: '#f1f3f5',
|
||||
navigationBarColor: '#f1f3f5',
|
||||
};
|
||||
try {
|
||||
windowClass.setWindowSystemBarProperties(SystemBarProperties, (err: BusinessError) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
console.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
console.info('Succeeded in setting the system bar properties.');
|
||||
});
|
||||
} catch (exception) {
|
||||
console.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
windowStage.loadContent('pages/Index', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(DOMAIN, TAG, 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(DOMAIN, TAG, 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
hilog.info(DOMAIN, TAG, 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
||||
|
||||
export default class EntryBackupAbility extends BackupExtensionAbility {
|
||||
async onBackup() {
|
||||
hilog.info(0x0000, 'testTag', 'onBackup ok');
|
||||
}
|
||||
|
||||
async onRestore(bundleVersion: BundleVersion) {
|
||||
hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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 '@ohos.base';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import router from '@ohos.router';
|
||||
|
||||
const TAG: string = 'Index';
|
||||
const DOMAIN: number = 0xFF00;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
private fileName: string[] = [
|
||||
'AppManager',
|
||||
'DataUriUtils',
|
||||
'WantAgent',
|
||||
'ApplicationContext',
|
||||
'ErrorManager'
|
||||
]
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
|
||||
Text($r('app.string.main_title'))
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
left: 12
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('7.18%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
.margin({
|
||||
top: '7.18%',
|
||||
bottom: '6.41%',
|
||||
left: '3.33%'
|
||||
})
|
||||
|
||||
List({ initialIndex: 0 }) {
|
||||
ForEach(this.fileName, (item: string, index: number) => {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.${item}`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_arrow'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.margin({ top: 16, bottom: 16, right: 6 })
|
||||
}
|
||||
}
|
||||
.id(`${item}`)
|
||||
.onClick(() => {
|
||||
router.pushUrl({
|
||||
url: `abilitypages/${item}`
|
||||
});
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}, (item: string, index: number) => item)
|
||||
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
|
||||
Text($r(`app.string.UIAbilityContext`))
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontWeight(500)
|
||||
.margin({
|
||||
top: 17,
|
||||
bottom: 17,
|
||||
left: 12
|
||||
})
|
||||
.fontSize(16)
|
||||
.width('77.87%')
|
||||
.height('39.29%')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_arrow'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.margin({ top: 16, bottom: 16, right: 6 })
|
||||
}
|
||||
}
|
||||
.id('UIAbilityContext')
|
||||
.onClick(() => {
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let want: Want = {
|
||||
bundleName: 'com.samples.abilityruntime',
|
||||
abilityName: 'AbilityLifecycleAbility',
|
||||
};
|
||||
// context为调用方UIAbility的UIAbilityContext
|
||||
context.startAbility(want).then(() => {
|
||||
hilog.info(DOMAIN, TAG, 'Succeeded in starting LifecycleAbility.');
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN, TAG,
|
||||
`Failed to start LifecycleAbility. Code is ${err.code}, message is ${err.message}`);
|
||||
});
|
||||
})
|
||||
}
|
||||
.height('8.45%')
|
||||
.backgroundColor($r('app.color.start_window_background'))
|
||||
.borderRadius(24)
|
||||
.margin({ top: 12, right: 12, left: 12 })
|
||||
}
|
||||
.height('85%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('app.color.backGrounding'))
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.ets",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:startIcon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:startIcon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"exported": true,
|
||||
"recoverable": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AbilityLifecycleAbility",
|
||||
"srcEntry": "./ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:startIcon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"recoverable": true,
|
||||
"startWindowIcon": "$media:startIcon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"exported": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
"extensionAbilities": [
|
||||
{
|
||||
"name": "EntryBackupAbility",
|
||||
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
|
||||
"type": "backup",
|
||||
"exported": false,
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ohos.extension.backup",
|
||||
"resource": "$profile:backup_config"
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "backGrounding",
|
||||
"value": "#f1f3f5"
|
||||
},
|
||||
{
|
||||
"name": "text_color",
|
||||
"value": "#182431"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,248 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "main_title",
|
||||
"value": "public api example"
|
||||
},
|
||||
{
|
||||
"name": "AppManager",
|
||||
"value": "appManager example"
|
||||
},
|
||||
{
|
||||
"name": "appRecovery",
|
||||
"value": "appRecovery example"
|
||||
},
|
||||
{
|
||||
"name": "DataUriUtils",
|
||||
"value": "dataUriUtils example"
|
||||
},
|
||||
{
|
||||
"name": "WantAgent",
|
||||
"value": "WantAgent example"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext",
|
||||
"value": "ApplicationContext example"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext",
|
||||
"value": "UIAbilityContext example"
|
||||
},
|
||||
{
|
||||
"name": "AbilityLifecycleCallback",
|
||||
"value": "AbilityLifecycleCallback example"
|
||||
},
|
||||
{
|
||||
"name": "ErrorManager",
|
||||
"value": "errorManager example"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestCallback",
|
||||
"value": "isRunningInStabilityTest(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestPromise",
|
||||
"value": "isRunningInStabilityTest(promise)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDeviceCallback",
|
||||
"value": "isRamConstrainedDevice(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDevicePromise",
|
||||
"value": "isRamConstrainedDevice(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizeCallback",
|
||||
"value": "getAppMemorySize(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizePromise",
|
||||
"value": "getAppMemorySize(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationCallback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationPromise",
|
||||
"value": "getRunningProcessInformation(promise)"
|
||||
},
|
||||
{
|
||||
"name": "registerErrorObserver",
|
||||
"value": "register ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterErrorObserver",
|
||||
"value": "unregister ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateError",
|
||||
"value": "simulate Error"
|
||||
},
|
||||
{
|
||||
"name": "registerLoopObserver",
|
||||
"value": "register LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterLoopObserver",
|
||||
"value": "unregister LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateLoopTimeout",
|
||||
"value": "simulate LoopTimeout"
|
||||
},
|
||||
{
|
||||
"name": "registerUnhandledRejection",
|
||||
"value": "register UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterUnhandledRejection",
|
||||
"value": "unregister UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateUnhandledRejection",
|
||||
"value": "simulate UnhandledRejection"
|
||||
},
|
||||
{
|
||||
"name": "getId",
|
||||
"value": "getId"
|
||||
},
|
||||
{
|
||||
"name": "attachId",
|
||||
"value": "attachId"
|
||||
},
|
||||
{
|
||||
"name": "deleteId",
|
||||
"value": "deleteId"
|
||||
},
|
||||
{
|
||||
"name": "updateId",
|
||||
"value": "updateId"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_startAbilityByType",
|
||||
"value": "startAbilityByType"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_requestModalUIExtension",
|
||||
"value": "requestModalUIExtension"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultCallback",
|
||||
"value": "terminateSelfWithResult(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultPromise",
|
||||
"value": "terminateSelfWithResult(promise)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModeCallback",
|
||||
"value": "setWindowPrivacyMode(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModePromise",
|
||||
"value": "setWindowPrivacyMode(promise)"
|
||||
},
|
||||
{
|
||||
"name": "privacy_window_permission",
|
||||
"value": "permit user to set privacy window"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_getUIExtensionWindowProxy",
|
||||
"value": "getUIExtensionWindowProxy"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNameCallback",
|
||||
"value": "getBundleName(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNamePromise",
|
||||
"value": "getBundleName(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getUidCallback",
|
||||
"value": "getUid(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getUidPromise",
|
||||
"value": "getUid(promise)"
|
||||
},
|
||||
{
|
||||
"name": "cancelCallback",
|
||||
"value": "cancel(callback)"
|
||||
},
|
||||
{
|
||||
"name": "cancelPromise",
|
||||
"value": "cancel(promise)"
|
||||
},
|
||||
{
|
||||
"name": "equalCallback",
|
||||
"value": "equal(callback)"
|
||||
},
|
||||
{
|
||||
"name": "equalPromise",
|
||||
"value": "equal(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypeCallback",
|
||||
"value": "getOperationType(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypePromise",
|
||||
"value": "getOperationType(promise)"
|
||||
},
|
||||
{
|
||||
"name": "trigger",
|
||||
"value": "trigger"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_restartApp",
|
||||
"value": "restartApp"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_setFont",
|
||||
"value": "setFont"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_promise",
|
||||
"value": "getRunningProcessInformationPromise"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_callback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getCurrentAppCloneIndex",
|
||||
"value": "getCurrentAppCloneIndex"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_moveAbilityToBackground",
|
||||
"value": "moveAbilityToBackground"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_terminateSelf",
|
||||
"value": "terminateSelf"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,13 @@
|
||||
<?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_arrow</title>
|
||||
<defs>
|
||||
<path d="M10.2482689,5.78255501 L10.2803301,5.81281566 L15.2300776,10.7625631 C15.8992572,11.4317428 15.9131984,12.5080354 15.2719013,13.1941781 L15.2300776,13.2374369 L10.2803301,18.1871843 C10.1514571,18.3160574 9.98735263,18.3882262 9.81902041,18.403691 L9.7730301,18.4065028 L9.7269699,18.4065028 C9.54277571,18.4008792 9.36025866,18.3277731 9.21966991,18.1871843 C8.93723717,17.9047516 8.92715028,17.4531048 9.18940926,17.1585854 L9.21966991,17.1265242 L13.815864,12.5303301 C14.0982967,12.2478973 14.1083836,11.7962506 13.8461246,11.5017311 L13.815864,11.4696699 L9.21966991,6.87347584 C8.9267767,6.58058262 8.9267767,6.10570888 9.21966991,5.81281566 C9.36088629,5.67159929 9.54440617,5.59846938 9.72943689,5.59342594 L9.77570243,5.59358355 C9.94528507,5.59936249 10.1132808,5.66235298 10.2482689,5.78255501 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="ic_arrow" 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-opacity="0.2" fill="#182431" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,7 @@
|
||||
{
|
||||
"layered-image":
|
||||
{
|
||||
"background" : "$media:background",
|
||||
"foreground" : "$media:foreground"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,3 @@
|
||||
{
|
||||
"allowToBackupRestore": true
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index",
|
||||
"abilitypages/AppManager",
|
||||
"abilitypages/ErrorManager",
|
||||
"abilitypages/DataUriUtils",
|
||||
"abilitypages/UIAbilityContext",
|
||||
"abilitypages/WantAgent",
|
||||
"abilitypages/ApplicationContext"
|
||||
]
|
||||
}
|
@ -0,0 +1,248 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "main_title",
|
||||
"value": "public api example"
|
||||
},
|
||||
{
|
||||
"name": "AppManager",
|
||||
"value": "appManager example"
|
||||
},
|
||||
{
|
||||
"name": "appRecovery",
|
||||
"value": "appRecovery example"
|
||||
},
|
||||
{
|
||||
"name": "DataUriUtils",
|
||||
"value": "dataUriUtils example"
|
||||
},
|
||||
{
|
||||
"name": "WantAgent",
|
||||
"value": "WantAgent example"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext",
|
||||
"value": "ApplicationContext example"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext",
|
||||
"value": "UIAbilityContext example"
|
||||
},
|
||||
{
|
||||
"name": "AbilityLifecycleCallback",
|
||||
"value": "AbilityLifecycleCallback example"
|
||||
},
|
||||
{
|
||||
"name": "ErrorManager",
|
||||
"value": "errorManager example"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestCallback",
|
||||
"value": "isRunningInStabilityTest(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestPromise",
|
||||
"value": "isRunningInStabilityTest(promise)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDeviceCallback",
|
||||
"value": "isRamConstrainedDevice(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDevicePromise",
|
||||
"value": "isRamConstrainedDevice(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizeCallback",
|
||||
"value": "getAppMemorySize(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizePromise",
|
||||
"value": "getAppMemorySize(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationCallback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationPromise",
|
||||
"value": "getRunningProcessInformation(promise)"
|
||||
},
|
||||
{
|
||||
"name": "registerErrorObserver",
|
||||
"value": "register ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterErrorObserver",
|
||||
"value": "unregister ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateError",
|
||||
"value": "simulate Error"
|
||||
},
|
||||
{
|
||||
"name": "registerLoopObserver",
|
||||
"value": "register LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterLoopObserver",
|
||||
"value": "unregister LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateLoopTimeout",
|
||||
"value": "simulate LoopTimeout"
|
||||
},
|
||||
{
|
||||
"name": "registerUnhandledRejection",
|
||||
"value": "register UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterUnhandledRejection",
|
||||
"value": "unregister UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateUnhandledRejection",
|
||||
"value": "simulate UnhandledRejection"
|
||||
},
|
||||
{
|
||||
"name": "getId",
|
||||
"value": "getId"
|
||||
},
|
||||
{
|
||||
"name": "attachId",
|
||||
"value": "attachId"
|
||||
},
|
||||
{
|
||||
"name": "deleteId",
|
||||
"value": "deleteId"
|
||||
},
|
||||
{
|
||||
"name": "updateId",
|
||||
"value": "updateId"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_startAbilityByType",
|
||||
"value": "startAbilityByType"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_requestModalUIExtension",
|
||||
"value": "requestModalUIExtension"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultCallback",
|
||||
"value": "terminateSelfWithResult(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultPromise",
|
||||
"value": "terminateSelfWithResult(promise)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModeCallback",
|
||||
"value": "setWindowPrivacyMode(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModePromise",
|
||||
"value": "setWindowPrivacyMode(promise)"
|
||||
},
|
||||
{
|
||||
"name": "privacy_window_permission",
|
||||
"value": "permit user to set privacy window"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_getUIExtensionWindowProxy",
|
||||
"value": "getUIExtensionWindowProxy"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNameCallback",
|
||||
"value": "getBundleName(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNamePromise",
|
||||
"value": "getBundleName(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getUidCallback",
|
||||
"value": "getUid(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getUidPromise",
|
||||
"value": "getUid(promise)"
|
||||
},
|
||||
{
|
||||
"name": "cancelCallback",
|
||||
"value": "cancel(callback)"
|
||||
},
|
||||
{
|
||||
"name": "cancelPromise",
|
||||
"value": "cancel(promise)"
|
||||
},
|
||||
{
|
||||
"name": "equalCallback",
|
||||
"value": "equal(callback)"
|
||||
},
|
||||
{
|
||||
"name": "equalPromise",
|
||||
"value": "equal(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypeCallback",
|
||||
"value": "getOperationType(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypePromise",
|
||||
"value": "getOperationType(promise)"
|
||||
},
|
||||
{
|
||||
"name": "trigger",
|
||||
"value": "trigger"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_restartApp",
|
||||
"value": "restartApp"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_setFont",
|
||||
"value": "setFont"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_promise",
|
||||
"value": "getRunningProcessInformationPromise"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_callback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getCurrentAppCloneIndex",
|
||||
"value": "getCurrentAppCloneIndex"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_moveAbilityToBackground",
|
||||
"value": "moveAbilityToBackground"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_terminateSelf",
|
||||
"value": "terminateSelf"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,248 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "main_title",
|
||||
"value": "元能力public接口开发示例"
|
||||
},
|
||||
{
|
||||
"name": "AppManager",
|
||||
"value": "appManager开发示例"
|
||||
},
|
||||
{
|
||||
"name": "appRecovery",
|
||||
"value": "appRecovery开发示例"
|
||||
},
|
||||
{
|
||||
"name": "DataUriUtils",
|
||||
"value": "dataUriUtils开发示例"
|
||||
},
|
||||
{
|
||||
"name": "WantAgent",
|
||||
"value": "WantAgent开发示例"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext",
|
||||
"value": "ApplicationContext开发示例"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext",
|
||||
"value": "UIAbilityContext开发示例"
|
||||
},
|
||||
{
|
||||
"name": "AbilityLifecycleCallback",
|
||||
"value": "AbilityLifecycleCallback开发示例"
|
||||
},
|
||||
{
|
||||
"name": "ErrorManager",
|
||||
"value": "errorManager开发示例"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestCallback",
|
||||
"value": "isRunningInStabilityTest(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRunningInStabilityTestPromise",
|
||||
"value": "isRunningInStabilityTest(promise)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDeviceCallback",
|
||||
"value": "isRamConstrainedDevice(callback)"
|
||||
},
|
||||
{
|
||||
"name": "isRamConstrainedDevicePromise",
|
||||
"value": "isRamConstrainedDevice(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizeCallback",
|
||||
"value": "getAppMemorySize(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getAppMemorySizePromise",
|
||||
"value": "getAppMemorySize(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationCallback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getRunningProcessInformationPromise",
|
||||
"value": "getRunningProcessInformation(promise)"
|
||||
},
|
||||
{
|
||||
"name": "registerErrorObserver",
|
||||
"value": "注册ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterErrorObserver",
|
||||
"value": "注销ErrorObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateError",
|
||||
"value": "模拟Error"
|
||||
},
|
||||
{
|
||||
"name": "registerLoopObserver",
|
||||
"value": "注册LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterLoopObserver",
|
||||
"value": "注销LoopObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateLoopTimeout",
|
||||
"value": "模拟LoopTimeout"
|
||||
},
|
||||
{
|
||||
"name": "registerUnhandledRejection",
|
||||
"value": "注册UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "unregisterUnhandledRejection",
|
||||
"value": "注销UnhandledRejectionObserver"
|
||||
},
|
||||
{
|
||||
"name": "simulateUnhandledRejection",
|
||||
"value": "模拟UnhandledRejection"
|
||||
},
|
||||
{
|
||||
"name": "getId",
|
||||
"value": "getId(获取指定uri路径末尾的ID)"
|
||||
},
|
||||
{
|
||||
"name": "attachId",
|
||||
"value": "attachId(将ID附加到uri的路径末尾)"
|
||||
},
|
||||
{
|
||||
"name": "deleteId",
|
||||
"value": "deleteId(删除指定uri路径末尾的ID)"
|
||||
},
|
||||
{
|
||||
"name": "updateId",
|
||||
"value": "updateId(更新指定uri中的ID)"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_startAbilityByType",
|
||||
"value": "startAbilityByType"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_requestModalUIExtension",
|
||||
"value": "requestModalUIExtension"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultCallback",
|
||||
"value": "terminateSelfWithResult(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_terminateSelfWithResultPromise",
|
||||
"value": "terminateSelfWithResult(promise)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModeCallback",
|
||||
"value": "setWindowPrivacyMode(callback)"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_setWindowPrivacyModePromise",
|
||||
"value": "setWindowPrivacyMode(promise)"
|
||||
},
|
||||
{
|
||||
"name": "privacy_window_permission",
|
||||
"value": "运行用户设置隐私窗口"
|
||||
},
|
||||
{
|
||||
"name": "UIExtensionContentSession_getUIExtensionWindowProxy",
|
||||
"value": "getUIExtensionWindowProxy"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNameCallback",
|
||||
"value": "getBundleName(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getBundleNamePromise",
|
||||
"value": "getBundleName(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getUidCallback",
|
||||
"value": "getUid(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getUidPromise",
|
||||
"value": "getUid(promise)"
|
||||
},
|
||||
{
|
||||
"name": "cancelCallback",
|
||||
"value": "cancel(callback)"
|
||||
},
|
||||
{
|
||||
"name": "cancelPromise",
|
||||
"value": "cancel(promise)"
|
||||
},
|
||||
{
|
||||
"name": "equalCallback",
|
||||
"value": "equal(callback)"
|
||||
},
|
||||
{
|
||||
"name": "equalPromise",
|
||||
"value": "equal(promise)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypeCallback",
|
||||
"value": "getOperationType(callback)"
|
||||
},
|
||||
{
|
||||
"name": "getOperationTypePromise",
|
||||
"value": "getOperationType(promise)"
|
||||
},
|
||||
{
|
||||
"name": "trigger",
|
||||
"value": "trigger"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "MapAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_restartApp",
|
||||
"value": "restartApp"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_setFont",
|
||||
"value": "setFont"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_promise",
|
||||
"value": "getRunningProcessInformation(promise)"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getRunningProcessInformation_callback",
|
||||
"value": "getRunningProcessInformation(callback)"
|
||||
},
|
||||
{
|
||||
"name": "ApplicationContext_getCurrentAppCloneIndex",
|
||||
"value": "getCurrentAppCloneIndex"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_moveAbilityToBackground",
|
||||
"value": "moveAbilityToBackground"
|
||||
},
|
||||
{
|
||||
"name": "UIAbilityContext_terminateSelf",
|
||||
"value": "terminateSelf"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,408 @@
|
||||
/*
|
||||
* 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';
|
||||
import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
|
||||
import { describe, beforeAll, it, expect } from '@ohos/hypium';
|
||||
|
||||
const TAG = '[Sample_AbilityRuntime]';
|
||||
const DOMAIN = 0xFF00;
|
||||
const BUNDLE = 'AbilityRuntime_';
|
||||
const TIME = 500;
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 begin');
|
||||
let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
try {
|
||||
await abilityDelegator.startAbility({
|
||||
bundleName: 'com.samples.abilityruntime',
|
||||
abilityName: 'EntryAbility'
|
||||
});
|
||||
} catch (err) {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'error: ' + err.message);
|
||||
expect(err.code).assertEqual(0);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 end');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_AppManager_001
|
||||
* @tc.name : PublicAbility_AppManager_001
|
||||
* @tc.desc : test onclick appManager
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_AppManager_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'AppManager_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
// //进入appManager开发示例页面
|
||||
let appManager = await driver.findComponent(ON.id('AppManager'));
|
||||
await appManager.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击isRunningInStabilityTestCallback
|
||||
await driver.assertComponentExist(ON.id('isRunningInStabilityTestCallback'));
|
||||
let isRunningInStabilityTestCallback = await driver.findComponent(ON.id('isRunningInStabilityTestCallback'));
|
||||
await isRunningInStabilityTestCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击isRunningInStabilityTestPromise
|
||||
await driver.assertComponentExist(ON.id('isRunningInStabilityTestPromise'));
|
||||
let isRunningInStabilityTestPromise = await driver.findComponent(ON.id('isRunningInStabilityTestPromise'));
|
||||
await isRunningInStabilityTestPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击isRamConstrainedDeviceCallback
|
||||
await driver.assertComponentExist(ON.id('isRamConstrainedDeviceCallback'));
|
||||
let isRamConstrainedDeviceCallback = await driver.findComponent(ON.id('isRamConstrainedDeviceCallback'));
|
||||
await isRamConstrainedDeviceCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击isRamConstrainedDevicePromise
|
||||
await driver.assertComponentExist(ON.id('isRamConstrainedDevicePromise'));
|
||||
let isRamConstrainedDevicePromise = await driver.findComponent(ON.id('isRamConstrainedDevicePromise'));
|
||||
await isRamConstrainedDevicePromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'AppManager_001 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_AppManager_002
|
||||
* @tc.name : PublicAbility_AppManager_002
|
||||
* @tc.desc : test onclick appManager
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_AppManager_002', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'AppManager_002 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
//点击getAppMemorySizeCallback
|
||||
await driver.assertComponentExist(ON.id('getAppMemorySizeCallback'));
|
||||
let getAppMemorySizeCallback = await driver.findComponent(ON.id('getAppMemorySizeCallback'));
|
||||
await getAppMemorySizeCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getAppMemorySizePromise
|
||||
await driver.assertComponentExist(ON.id('getAppMemorySizePromise'));
|
||||
let getAppMemorySizePromise = await driver.findComponent(ON.id('getAppMemorySizePromise'));
|
||||
await getAppMemorySizePromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getRunningProcessInformationCallback
|
||||
await driver.assertComponentExist(ON.id('getRunningProcessInformationCallback'));
|
||||
let getRunningProcessInformationCallback =
|
||||
await driver.findComponent(ON.id('getRunningProcessInformationCallback'));
|
||||
await getRunningProcessInformationCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getRunningProcessInformationPromise
|
||||
await driver.assertComponentExist(ON.id('getRunningProcessInformationPromise'));
|
||||
let getRunningProcessInformationPromise =
|
||||
await driver.findComponent(ON.id('getRunningProcessInformationPromise'));
|
||||
await getRunningProcessInformationPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'AppManager_002 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_DataUriUtils_001
|
||||
* @tc.name : PublicAbility_DataUriUtils_001
|
||||
* @tc.desc : test onclick DataUriUtils
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_DataUriUtils_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'DataUriUtils_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
|
||||
// //进入DataUriUtils开发示例页面
|
||||
let dataUriUtils = await driver.findComponent(ON.id('DataUriUtils'));
|
||||
await dataUriUtils.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击GetId
|
||||
await driver.assertComponentExist(ON.id('getId'));
|
||||
let getId = await driver.findComponent(ON.id('getId'));
|
||||
await getId.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击AttachId
|
||||
await driver.assertComponentExist(ON.id('attachId'));
|
||||
let attachId = await driver.findComponent(ON.id('attachId'));
|
||||
await attachId.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击DeleteId
|
||||
await driver.assertComponentExist(ON.id('deleteId'));
|
||||
let deleteId = await driver.findComponent(ON.id('deleteId'));
|
||||
await deleteId.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击UpdateId
|
||||
await driver.assertComponentExist(ON.id('updateId'));
|
||||
let updateId = await driver.findComponent(ON.id('updateId'));
|
||||
await updateId.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'DataUriUtils_001 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_WantAgent_001
|
||||
* @tc.name : PublicAbility_WantAgent_001
|
||||
* @tc.desc : test onclick WantAgent
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_WantAgent_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'WantAgent_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
// //进入WantAgent开发示例页面
|
||||
let wantAgent = await driver.findComponent(ON.id('WantAgent'));
|
||||
await wantAgent.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getBundleNameCallback
|
||||
await driver.assertComponentExist(ON.id('getBundleNameCallback'));
|
||||
let getBundleNameCallback = await driver.findComponent(ON.id('getBundleNameCallback'));
|
||||
await getBundleNameCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getBundleNamePromise
|
||||
await driver.assertComponentExist(ON.id('getBundleNamePromise'));
|
||||
let getBundleNamePromise = await driver.findComponent(ON.id('getBundleNamePromise'));
|
||||
await getBundleNamePromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getUidCallback
|
||||
await driver.assertComponentExist(ON.id('getUidCallback'));
|
||||
let getUidCallback = await driver.findComponent(ON.id('getUidCallback'));
|
||||
await getUidCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getUidPromise
|
||||
await driver.assertComponentExist(ON.id('getUidPromise'));
|
||||
let getUidPromise = await driver.findComponent(ON.id('getUidPromise'));
|
||||
await getUidPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击cancelCallback
|
||||
await driver.assertComponentExist(ON.id('cancelCallback'));
|
||||
let cancelCallback = await driver.findComponent(ON.id('cancelCallback'));
|
||||
await cancelCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'WantAgent_001 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_WantAgent_002
|
||||
* @tc.name : PublicAbility_WantAgent_002
|
||||
* @tc.desc : test onclick WantAgent
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_WantAgent_002', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'WantAgent_002 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
//点击cancelPromise
|
||||
await driver.assertComponentExist(ON.id('cancelPromise'));
|
||||
let cancelPromise = await driver.findComponent(ON.id('cancelPromise'));
|
||||
await cancelPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击equalCallback
|
||||
await driver.assertComponentExist(ON.id('equalCallback'));
|
||||
let equalCallback = await driver.findComponent(ON.id('equalCallback'));
|
||||
await equalCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击equalPromise
|
||||
await driver.assertComponentExist(ON.id('equalPromise'));
|
||||
let equalPromise = await driver.findComponent(ON.id('equalPromise'));
|
||||
await equalPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getOperationTypeCallback
|
||||
await driver.assertComponentExist(ON.id('getOperationTypeCallback'));
|
||||
let getOperationTypeCallback = await driver.findComponent(ON.id('getOperationTypeCallback'));
|
||||
await getOperationTypeCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getOperationTypePromise
|
||||
await driver.swipe(100, 400, 100, 100, 600);
|
||||
await driver.delayMs(TIME);
|
||||
await driver.assertComponentExist(ON.id('getOperationTypePromise'));
|
||||
let getOperationTypePromise = await driver.findComponent(ON.id('getOperationTypePromise'));
|
||||
await getOperationTypePromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击trigger
|
||||
await driver.assertComponentExist(ON.id('trigger'));
|
||||
let trigger = await driver.findComponent(ON.id('trigger'));
|
||||
await trigger.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'WantAgent_002 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_ApplicationContext_001
|
||||
* @tc.name : PublicAbility_ApplicationContext_001
|
||||
* @tc.desc : test onclick ApplicationContext
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_ApplicationContext_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'ApplicationContext_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
// //进入ApplicationContext开发示例页面
|
||||
let applicationContext = await driver.findComponent(ON.id('ApplicationContext'));
|
||||
await applicationContext.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getCurrentAppCloneIndex
|
||||
await driver.assertComponentExist(ON.id('getCurrentAppCloneIndex'));
|
||||
let getCurrentAppCloneIndex = await driver.findComponent(ON.id('getCurrentAppCloneIndex'));
|
||||
await getCurrentAppCloneIndex.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getRunningProcessInformationCallback
|
||||
await driver.assertComponentExist(ON.id('getRunningProcessInformationCallback'));
|
||||
let getRunningProcessInformationCallback =
|
||||
await driver.findComponent(ON.id('getRunningProcessInformationCallback'));
|
||||
await getRunningProcessInformationCallback.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击getRunningProcessInformationPromise
|
||||
await driver.assertComponentExist(ON.id('getRunningProcessInformationPromise'));
|
||||
let getRunningProcessInformationPromise =
|
||||
await driver.findComponent(ON.id('getRunningProcessInformationPromise'));
|
||||
await getRunningProcessInformationPromise.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击setFont
|
||||
await driver.assertComponentExist(ON.id('setFont'));
|
||||
let setFont = await driver.findComponent(ON.id('setFont'));
|
||||
await setFont.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击restartApp
|
||||
// await driver.assertComponentExist(ON.id('restartApp'));
|
||||
// let restartApp = await driver.findComponent(ON.id('restartApp'));
|
||||
// await restartApp.click();
|
||||
// await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'ApplicationContext_001 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_ErrorManager_001
|
||||
* @tc.name : PublicAbility_ErrorManager_001
|
||||
* @tc.desc : test onclick ErrorManager
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_ErrorManager_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'ErrorManager_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
// //进入ErrorManager开发示例页面
|
||||
let errorManager = await driver.findComponent(ON.id('ErrorManager'));
|
||||
await errorManager.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击registerLoopObserver
|
||||
await driver.assertComponentExist(ON.id('registerLoopObserver'));
|
||||
let registerLoopObserver = await driver.findComponent(ON.id('registerLoopObserver'));
|
||||
await registerLoopObserver.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击registerUnhandledRejection
|
||||
await driver.assertComponentExist(ON.id('registerUnhandledRejection'));
|
||||
let registerUnhandledRejection = await driver.findComponent(ON.id('registerUnhandledRejection'));
|
||||
await registerUnhandledRejection.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击simulateUnhandledRejection
|
||||
await driver.assertComponentExist(ON.id('simulateUnhandledRejection'));
|
||||
let simulateUnhandledRejection = await driver.findComponent(ON.id('simulateUnhandledRejection'));
|
||||
await simulateUnhandledRejection.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击unregisterUnhandledRejection
|
||||
await driver.assertComponentExist(ON.id('unregisterUnhandledRejection'));
|
||||
let unregisterUnhandledRejection = await driver.findComponent(ON.id('unregisterUnhandledRejection'));
|
||||
await unregisterUnhandledRejection.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'ErrorManager_001 end');
|
||||
done();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : PublicAbility_UIAbilityContext_001
|
||||
* @tc.name : PublicAbility_UIAbilityContext_001
|
||||
* @tc.desc : test onclick UIAbilityContext
|
||||
* @tc.size : MEDIUM
|
||||
* @tc.type : Function
|
||||
* @tc.level : Level 1
|
||||
*/
|
||||
it('PublicAbility_UIAbilityContext_001', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'UIAbilityContext_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
//进入UIAbilityContext开发示例页面
|
||||
let uiAbilityContext = await driver.findComponent(ON.id('UIAbilityContext'));
|
||||
await uiAbilityContext.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击moveAbilityToBackground
|
||||
await driver.assertComponentExist(ON.id('moveAbilityToBackground'));
|
||||
let moveAbilityToBackground = await driver.findComponent(ON.id('moveAbilityToBackground'));
|
||||
await moveAbilityToBackground.click();
|
||||
await driver.delayMs(TIME);
|
||||
//再次点击UIAbilityContext,进入UIAbilityContext开发示例页面
|
||||
await uiAbilityContext.click();
|
||||
await driver.delayMs(TIME);
|
||||
//点击terminateSelf
|
||||
await driver.assertComponentExist(ON.id('terminateSelf'));
|
||||
let terminateSelf = await driver.findComponent(ON.id('terminateSelf'));
|
||||
await terminateSelf.click();
|
||||
await driver.delayMs(TIME);
|
||||
|
||||
await driver.delayMs(TIME);
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(TIME);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'UIAbilityContext_001 end');
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import abilityTest from './Ability.test';
|
||||
|
||||
export default function testsuite() {
|
||||
abilityTest();
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"modelVersion": "5.0.0",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
21
code/BasicFeature/Ability/AbilityRuntime/hvigorfile.ts
Normal file
@ -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.
|
||||
*/
|
||||
|
||||
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
24
code/BasicFeature/Ability/AbilityRuntime/oh-package.json5
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"modelVersion": "5.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ohos/hypium": "1.0.18",
|
||||
"@ohos/hamock": "1.0.0"
|
||||
}
|
||||
}
|
12
code/BasicFeature/Ability/AbilityRuntime/ohosTest.md
Normal file
@ -0,0 +1,12 @@
|
||||
|测试功能|预置条件|输入|预期输出|测试结果|
|
||||
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|
||||
|拉起应用| 设备正常运行| |成功拉起应用|Pass|
|
||||
|测试appManager中接口| AppManager开发示例页面 | 1.点击isRunningInStabilityTest(callback)按钮<br/>2.点击isRunningInStabilityTest(promise)按钮<br/>3.点击isRamConstrainedDevice(callback)按钮<br/>4.点击isRamConstrainedDevice(promise)按钮 | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息<br/> |Pass|
|
||||
|测试appManager中接口| AppManager开发示例页面 | 1.点击getAppMemorySize(callback)按钮<br/>2.点击getAppMemorySize(promise)按钮<br/>3.点击getRunningProcessInformation(callback)按钮<br/>4.点击getRunningProcessInformation(promise)按钮 | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息<br/> |Pass|
|
||||
|测试dataUriUtils中接口| 位于DataUriUtils开发示例页面 | 1.点击getId按钮<br/>2.点击attachId按钮<br/>3.点击deleteId按钮<br/>4.点击updateId按钮 | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息 |Pass|
|
||||
|测试WantAgent中接口| 位于WantAgent开发示例页面 | 1.点击getBundleName(callback)按钮<br/>2.点击getBundleName(promise)按钮<br/>3.点击getUid(callback)按钮<br/>4.点击getUid(promise)按钮<br/>5.点击cancel(callback)按钮<br/> | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息<br/>5.弹出Toast信息 |Pass|
|
||||
|测试WantAgent中接口| 位于WantAgent开发示例页面 | 1.点击cancel(promise)按钮<br/>2.点击equal(callback)按钮<br/>3.点击equal(promise)按钮<br/>4.点击getOperationType(callback)按钮<br/>5.点击getOperationType(promise)按钮<br/>6.点击trigger按钮 | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息<br/>5.弹出Toast信息<br/>6.弹出Toast信息 |Pass|
|
||||
|测试ApplicationContext中接口| 位于ApplicationContext开发示例页面 | 1.点击setFont按钮<br/>2.点击getRunningProcessInformation(callback)按钮<br/>3.点击getRunningProcessInformation(promise)按钮<br/>4.点击getCurrentAppCloneIndex按钮 | 1.弹出Toast信息<br/>2.弹出Toast信息<br/>3.弹出Toast信息<br/>4.弹出Toast信息 |Pass|
|
||||
|测试errorManager中接口| 位于errorManager开发示例页面 | 1.点击注册LoopObserver按钮<br/>2.点击注册 UnhandledRejectionObserver按钮<br/>3.点击模拟UnhandledRejection按钮<br/>4.点击注销 UnhandledRejectionObserver按钮 | 1.弹出Toast信息<br/>2.列表中增加模拟UnhandledRejection按钮,并且原注册UnhandledRejectionObserver按钮变为注销UnhandledRejectionObserver按钮,并弹出Toast信息<br/>3.弹出Toast信息<br/>4.模拟UnhandledRejection按钮消失,注销UnhandledRejectionObserver按钮变回注册UnhandledRejectionObserver按钮,并弹出Toast信息 |Pass|
|
||||
|测试UIAbilityContext中接口| 位于UIAbilityContext开发示例页面 | 1.点击moveAbilityToBackground按钮<br/>2.点击主页面UIAbilityContext开发实例按钮,启动新的Ability,点击terminatrSelf按钮 | 1.Ability被移动到后台<br/>2.Ability被停止,显示主页面 |Pass|
|
||||
|
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 42 KiB |
BIN
code/BasicFeature/Ability/AbilityRuntime/screenshots/index.jpeg
Normal file
After Width: | Height: | Size: 47 KiB |