!4671 【Sample】FAModelAbilityDevelop FA模型应用下线

Merge pull request !4671 from yuandongping/fa-model-ability
This commit is contained in:
openharmony_ci 2024-08-06 13:40:40 +00:00 committed by Gitee
commit 2d031a5024
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
61 changed files with 0 additions and 5204 deletions

View File

@ -1,11 +0,0 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test

View File

@ -1,199 +0,0 @@
# FA模型开发指导
### 介绍
本示例展示了在一个FA模型中PageAbility组件/ServiceAbility组件/DataAbility组件/服务卡片以及Context相关的示例。
本示例参考[应用模型](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/application-models)。
### 效果预览
|PageAbility组件开发指导|ServiceAbility&DataAbility组件开发指导|FA模型与Stage模型应用组件互通指导|FA模型服务卡片开发指导|
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|![PageAbility组件开发指导](screenshots/PageAbility组件开发指导.gif)|![ServiceAbility&DataAbility组件开发指导](screenshots/ServiceAbility&DataAbility组件开发指导.gif)| ![FA模型与Stage模型应用组件互通指导](screenshots/FA模型与Stage模型应用组件互通指导.gif) | ![FA模型服务卡片开发指导](screenshots/FA模型服务卡片开发指导.gif) |
#### 使用说明
##### 1.PgaeAbility组件开发指导
1进入主页点击[PageAbility组件开发指导-单设备]进入PageAbility组件开发指导-单设备‘界面;
2点击[获取分布式目录]弹出toast[/data/***]
3点击[启动单例PageAbility]跳转至Title为PageAbilitySingleton页面一的页面再点击Home键回到桌面再点击应用图标回到PageAbility组件开发指导-单设备‘界面,点击[再启动单例PageAbility]跳转至Title为PageAbilitySingleton页面二的页面
4回到PageAbility组件开发指导-单设备‘界面,点击[启动多例PageAbility页面一]跳转至Title为PageAbilityStandard页面一的页面再点击Home键回到桌面再点击应用图标回到PageAbility组件开发指导-单设备‘界面,点击[启动多例PageAbility页面二]跳转至Title为PageAbilityStandard页面二的页面
5点击[使用Worker进行线程间通信]弹出toast[{"data":"message from worker thread."}]
6点击[停止PageAbility],退出当前应用返回桌面;
7回到主页点击[PageAbility组件开发指导-多设备]进入PageAbility组件开发指导-多设备’界面;
8点击[获取分布式数据同步权限],并在弹出的申请权限对话框中点击’允许‘;
9点击[获取设备id]弹出对端设备的deviceId
10点击[启动远程设备PageAbility]弹出toast[启动远程Ability成功],同时打开对端设备音乐应用。
##### 2.ServiceAbility组件开发指导
1回到主页点击[ServiceAbility组件开发指导]进入ServiceAbility组件开发指导界面
2点击[启动ServiceAbility]弹出toast[启动serviceAbility成功]
3点击[连接ServiceAbility]弹出toast[连接serviceAbility成功]
4点击[连接错误的ServiceAbility] 弹出toast[连接serviceAbility失败]。
##### 3.DataAbility组件开发指导
1回到主页点击[DataAbility组件开发指导]进入DataAbility组件开发指导界面
2在弹出的对话框中点击允许
3点击[插入数据-callback方式],再点击[插入数据-promise方式]点击后均弹出toast[插入数据成功]
4点击[删除数据-callback方式],再点击[删除数据-promise方式]点击后均弹出toast[删除数据成功]
5点击[更新数据-callback方式],再点击[更新数据-promise方式]点击后均弹出toast[更新数据成功]
6点击[查找数据-callback方式],再点击[查找数据-promise方式]点击后均弹出toast[查找数据成功]
7点击[批量插入数据-callback方式],再点击[批量插入数据-promise方式点击后均弹出toast[批量插入数据成功]
8点击[批量处理数据-callback方式],再点击[批量处理数据-promise方式]点击后均弹出toast[批量处理数据成功]。
##### 4.FA模型与Stage模型应用组件互通指导
1回到主页点击[FA模型与Stage模型应用组件互通指导]进入FA模型与Stage模型应用组件互通指导界面
2点击[通过PageAbility与Stage模型互通-无需返回结果],成功启动时钟应用;
3回到FA模型与Stage模型应用组件互通指导界面点击[通过PageAbility与Stage模型互通-返回执行结果],成功启动时钟应用;
4回到FA模型与Stage模型应用组件互通指导界面点击[通过ServiceAbility与Stage模型互通],成功启动时钟应用(仅生效一次)。
##### 5. FA模型服务卡片开发指导
1回到桌面长按应用图标在弹出框中点击服务卡片进入服务卡片添加界面
2点击添加至桌面会跳转会桌面并桌面上新增FAModel服务卡片
3点击卡片内titleOnCreate',会跳转至应用界面;
4回到桌面点击卡片内detailOnCreate',卡片内容会更新。
### 工程目录
```
entry/src/main/ets/
├── DataAbility
│ └── data.ts //测试DataAbility基本功能
├── FormAbility
│ └── form.ts //测试FormAbility基本功能
├── MainAbility
│ ├── app.ets
│ └── pages
│ ├── index.ets //应用主界面
│ ├── pageDataAbility.ets //DataAbility组件开发指导界面
│ ├── pageInterflowFaAndStage.ets //FA模型与Stage模型应用组件互通指导界面
│ ├── pagePageAbilityFirst.ets //PageAbility组件开发指导-单设备界面
│ ├── pagePageAbilitySecond.ets //PageAbility组件开发指导-多设备界面
│ └── pageServiceAbility.ets //ServiceAbility组件开发指导界面
├── PageAbilitySingleton
│ ├── app.ets
│ └── pages
│ ├── first.ets //单例PageAbility页面一
│ └── second.ets //单例PageAbility页面二
├── PageAbilityStandard
│ ├── app.ets
│ └── pages
│ ├── default.ets //多例PageAbility默认页面
│ ├── first.ets //多例PageAbility页面一
│ └── second.ets //多例PageAbility页面二
├── ServiceAbility
│ └── service.ts //测试ServiceAbility基本功能
├── ServiceAbilityStartUIAbility
│ └── service.ts //FA模型与Stage模型应用组件互通用ServiceAbility
├── utils
│ └── GlobalContext.ts //object存储工具类
└── workers
└── worker.ts //使用worker进行线程间通信
```
### 具体实现
* 本示例分为PageAbility组件开发指导,ServiceAbility组件开发指导,DataAbility组件开发指导和FA模型与Stage模型应用组件互通指导四个模块。
* PageAbility组件开发指导
* 调用相关接口函数来实现FA模型中单例PageAbility/多例PageAbility的启动停止以及启动远程PageAbility等功能以及还实现了使用worker进行线程间通信的功能。
* 源码链接:[pagePageAbilityFirst.ets](entry\src\main\ets\MainAbility\pages\pagePageAbilityFirst.ets) [pagePageAbilitySecond.ets](entry\src\main\ets\MainAbility\pages\pagePageAbilitySecond.ets) [first.ets](entry\src\main\ets\PageAbilitySingleton\pages\first.ets) [second.ets](entry\src\main\ets\PageAbilitySingleton\pages\second.ets) [first.ets](entry\src\main\ets\PageAbilityStandard\pages\first.ets) [second.ets](entry\src\main\ets\PageAbilityStandard\pages\second.ets) [worker.ts](entry\src\main\ets\workers\worker.ts)
* 参考接口:[@ohos.ability.featureAbility](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md/) [@ohos.worker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-worker.md)
* ServiceAbility组件开发指导
* 调用相关接口函数来实现FA模型中ServiceAbility的启动和连接等功能。
* 源码链接:[pageServiceAbility.ets](entry\src\main\ets\MainAbility\pages\pageServiceAbility.ets) [service.ts](entry\src\main\ets\ServiceAbility\service.ts)
* 参考接口:[@ohos.ability.featureAbility](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md/)
* DataAbility组件开发指导
* 调用相关接口函数来实现FA模型中DataAbility的增删改查等功能。
* 源码链接:[pageDataAbility.ets](entry\src\main\ets\MainAbility\pages\pageDataAbility.ets) [data.ts](entry\src\main\ets\DataAbility\data.ts)
* 参考接口:[@ohos.data.dataAbility](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-data-ability.md/)
* FA模型与Stage模型应用组件互通指导
* 调用相关接口函数来实现FA模型中调用相关接口函数来启动Stage模型中UIAbility的功能。
* 源码链接:[pageInterflowFaAndStage.ets](entry\src\main\ets\MainAbility\pages\pageInterflowFaAndStage.ets) [service.ts](entry\src\main\ets\ServiceAbilityStartUIAbility\service.ts)
* 参考接口:[@ohos.ability.featureAbility](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md/)
* FA模型服务卡片开发指导
* 调用相关接口函数来实现FA模型中服务卡片的创建更新及事件等功能。
* 源码链接:[form.ts](entry\src\main\ets\FormAbility\form.ts) [index.css](entry\src\main\js\widget\pages\index\index.css) [index.hml](entry\src\main\js\widget\pages\index\index.hml) [index.json](entry\src\main\js\widget\pages\index\index.json)
* 参考接口:[@ohos.app.form.formBindingData](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md/) [@ohos.app.form.formInfo](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md/) [@ohos.app.form.formProvider](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md/)
### 相关权限
[ohos.permission.READ_CONTACTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionread_contacts)
[ohos.permission.WRITE_CONTACTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionwrite_contacts)
[ohos.permission.DISTRIBUTED_DATASYNC](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissiondistributed_datasync)
[ohos.permission.ACCESS_SERVICE_DM](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccess_service_dm)
### 依赖
本示例依赖系统默认自带的[时钟](https://gitee.com/openharmony/applications_app_samples/tree/master/code/Solutions/Tools/ArkTSClock)应用和[音乐](https://gitee.com/openharmony/applications_app_samples/tree/master/code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer)应用。
本示例依赖带有ServiceExtensionAbility的Stage模型应用:[StageModelAbilityInteraction](https://gitee.com/openharmony/applications_app_samples/tree/master/code/DocsSample/ApplicationModels/StageModelAbilityInteraction)。
在测试PgaeAbility组件开发指导相关功能前需要准备两台RK3568设备并将设备组网步骤如下
```
1.使两台设备处于同一网络下。
2.打开AB两设备的音乐。
3.点击A设备音乐应用左下角箭头选择B设备。
4.在B设备选择信任设备弹出PIN码。
5.在A设备输入PIN码。
6.已组网成功验证方法在A设备播放音乐B设备同步播放则证明组网成功。
```
### 约束与限制
1.本示例仅支持标准系统上运行,支持设备:RK3568。
2.本示例为Stage模型已适配API version 11版本SDK版本号4.1.3.1
3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)及以上版本才可编译运行。
4.本示例涉及相关权限为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/link?target=https%3A%2F%2Fdocs.openharmony.cn%2Fpages%2Fv3.2%2Fzh-cn%2Fapplication-dev%2Fsecurity%2Fhapsigntool-overview.md%2F))。
6.本示例类型为系统应用,需要手动配置对应级别的应用类型("app-feature": "hos_system_app")。具体可参考profile配置文件[bundle-info对象内部结构]( https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/application-dev/security/app-provision-structure.md#bundle-info%E5%AF%B9%E8%B1%A1%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84 )
### 下载
如需单独下载本工程,执行如下命令:
```
git init
git config core.sparsecheckout true
echo code/DocsSample/ApplicationModels/FAModelAbilityDevelop/ > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master
```

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"signingConfigs": [
],
"products": [
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 11,
"compatibleSdkVersion": 11,
"runtimeOS": "OpenHarmony"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -1,6 +0,0 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"apiType": 'faMode',
"buildOption": {
"sourceOption": {
"workers": [
"./src/main/ets/workers/worker.ts"
]
}
},
"targets": [
{
"name": "default",
"runtimeOS": "OpenHarmony"
},
{
"name": "ohosTest",
}
]
}

View File

@ -1,17 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { legacyHapTasks } from '@ohos/hvigor-ohos-plugin';

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"license": "",
"devDependencies": {},
"author": "",
"name": "entry",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,214 +0,0 @@
{
"app": {
"bundleName": "com.samples.famodelabilitydevelop",
"vendor": "samples",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.samples.famodelabilitydevelop",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "singleton"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".PageAbilitySingleton",
"srcLanguage": "ets",
"srcPath": "PageAbilitySingleton",
"icon": "$media:icon",
"description": "$string:PageAbilitySingleton_desc",
"label": "$string:PageAbilitySingleton_label",
"type": "page",
"launchType": "singleton"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".PageAbilityStandard",
"srcLanguage": "ets",
"srcPath": "PageAbilityStandard",
"icon": "$media:icon",
"description": "$string:PageAbilityStandard_desc",
"label": "$string:PageAbilityStandard_label",
"type": "page",
"launchType": "standard"
},
{
"name": ".ServiceAbility",
"srcLanguage": "ets",
"srcPath": "ServiceAbility",
"icon": "$media:icon",
"description": "$string:ServiceAbility_desc",
"type": "service",
"visible": true
},
{
"name": ".DataAbility",
"srcLanguage": "ets",
"srcPath": "DataAbility",
"icon": "$media:icon",
"description": "$string:DataAbility_desc",
"type": "data",
"visible": true,
"uri": "dataability://com.samples.famodelabilitydevelop.DataAbility",
"readPermission": "ohos.permission.READ_CONTACTS",
"writePermission": "ohos.permission.WRITE_CONTACTS"
},
{
"name": ".FormAbility",
"srcPath": "FormAbility",
"description": "$string:FormAbility_desc",
"icon": "$media:icon",
"label": "$string:FormAbility_label",
"type": "service",
"formsEnabled": true,
"srcLanguage": "ets",
"forms": [
{
"jsComponentName": "widget",
"isDefault": true,
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget",
"description": "This is a service widget.",
"colorMode": "auto",
"type": "JS",
"formVisibleNotify": true,
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
}
]
},
{
"name": ".ServiceAbilityStartUIAbility",
"srcLanguage": "ets",
"srcPath": "ServiceAbilityStartUIAbility",
"icon": "$media:icon",
"description": "$string:ServiceAbilityStartUIAbility_desc",
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/pageDataAbility",
"pages/pagePageAbilityFirst",
"pages/pagePageAbilitySecond",
"pages/pageServiceAbility",
"pages/pageInterflowFaAndStage"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/first",
"pages/second"
],
"name": ".PageAbilitySingleton",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/default",
"pages/first",
"pages/second"
],
"name": ".PageAbilityStandard",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"name": "widget",
"pages": [
"pages/index/index"
],
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"type": "form"
}
],
"reqPermissions": [
{
"name": "ohos.permission.READ_CONTACTS"
},
{
"name": "ohos.permission.WRITE_CONTACTS"
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.ACCESS_SERVICE_DM"
}
],
"defPermissions": [
{
"name": "com.samples.famodelabilitydevelop.DataAbilityShellProvider.PROVIDER"
}
]
}
}

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import type common from '@ohos.app.ability.common';
import type Want from '@ohos.app.ability.Want';
import type { AsyncCallback, BusinessError } from '@ohos.base';
import dataAbility from '@ohos.data.dataAbility';
import rdb from '@ohos.data.rdb';
import hilog from '@ohos.hilog';
let TABLE_NAME = 'book';
let STORE_CONFIG: rdb.StoreConfig = { name: 'book.db' };
let SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)';
let rdbStore: rdb.RdbStore | undefined = undefined;
const TAG: string = '[Sample_FAModelAbilityDevelop]';
const domain: number = 0xFF00;
class DataAbility {
onInitialized(want: Want): void {
hilog.info(domain, TAG, 'DataAbility onInitialized, abilityInfo:' + want.bundleName);
let context: common.BaseContext = { stageMode: featureAbility.getContext().stageMode };
rdb.getRdbStore(context, STORE_CONFIG, 1, (err, store) => {
hilog.info(domain, TAG, 'DataAbility getRdbStore callback');
store.executeSql(SQL_CREATE_TABLE, []);
rdbStore = store;
});
}
insert(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback<number>): void {
hilog.info(domain, TAG, 'DataAbility insert start');
if (rdbStore) {
rdbStore.insert(TABLE_NAME, valueBucket, callback);
}
}
batchInsert(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): void {
hilog.info(domain, TAG, 'DataAbility batch insert start');
if (rdbStore) {
for (let i = 0; i < valueBuckets.length; i++) {
hilog.info(domain, TAG, 'DataAbility batch insert i=' + i);
if (i < valueBuckets.length - 1) {
rdbStore.insert(TABLE_NAME, valueBuckets[i], (err: BusinessError, num: number) => {
hilog.info(domain, TAG, 'DataAbility batch insert ret=' + num);
});
} else {
rdbStore.insert(TABLE_NAME, valueBuckets[i], callback);
}
}
}
}
query(uri: string, columns: Array<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<rdb.ResultSet>): void {
hilog.info(domain, TAG, 'DataAbility query start');
let rdbPredicates = dataAbility.createRdbPredicates(TABLE_NAME, predicates);
if (rdbStore) {
rdbStore.query(rdbPredicates, columns, callback);
}
}
update(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void {
hilog.info(domain, TAG, 'DataAbility update start');
let rdbPredicates = dataAbility.createRdbPredicates(TABLE_NAME, predicates);
if (rdbStore) {
rdbStore.update(valueBucket, rdbPredicates, callback);
}
}
delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void {
hilog.info(domain, TAG, 'DataAbility delete start');
let rdbPredicates = dataAbility.createRdbPredicates(TABLE_NAME, predicates);
if (rdbStore) {
rdbStore.delete(rdbPredicates, callback);
}
}
}
export default new DataAbility();

View File

@ -1,150 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type featureAbility from '@ohos.ability.featureAbility';
import type Want from '@ohos.app.ability.Want';
import formBindingData from '@ohos.app.form.formBindingData';
import formInfo from '@ohos.app.form.formInfo';
import formProvider from '@ohos.app.form.formProvider';
import dataPreferences from '@ohos.data.preferences';
import hilog from '@ohos.hilog';
const TAG: string = '[Sample_FAModelAbilityDevelop]';
const domain: number = 0xFF00;
const DATA_STORAGE_PATH: string = 'form_store';
let storeFormInfo = async (formId: string, formName: string, tempFlag: boolean, context: featureAbility.Context): Promise<void> => {
// 此处仅对卡片IDformId卡片名formName和是否为临时卡片tempFlag进行了持久化
let formInfo: Record<string, string | number | boolean> = {
formName: 'formName',
tempFlag: 'tempFlag',
updateCount: 0
};
try {
const storage = await dataPreferences.getPreferences(context, DATA_STORAGE_PATH);
// put form info
await storage.put(formId, JSON.stringify(formInfo));
hilog.info(domain, TAG, `storeFormInfo, put form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
hilog.error(domain, TAG, `failed to storeFormInfo, err: ${JSON.stringify(err as Error)}`);
}
};
let deleteFormInfo = async (formId: string, context: featureAbility.Context): Promise<void> => {
try {
const storage = await dataPreferences.getPreferences(context, DATA_STORAGE_PATH);
// del form info
await storage.delete(formId);
hilog.info(domain, TAG, `deleteFormInfo, del form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
hilog.error(domain, TAG, `failed to deleteFormInfo, err: ${JSON.stringify(err)}`);
}
};
class LifeCycle {
onCreate: (want: Want) => formBindingData.FormBindingData = (want) => ({ data: '' });
onCastToNormal: (formId: string) => void = (formId) => {
};
onUpdate: (formId: string) => void = (formId) => {
};
onVisibilityChange: (newStatus: Record<string, number>) => void = (newStatus) => {
let obj: Record<string, number> = {
'test': 1
};
return obj;
};
onEvent: (formId: string, message: string) => void = (formId, message) => {
};
onDestroy: (formId: string) => void = (formId) => {
};
onAcquireFormState?: (want: Want) => formInfo.FormState = (want) => (0);
onShare?: (formId: string) => Record<string, number | string | boolean | object | undefined | null> = (formId) => {
let obj: Record<string, number> = {
test: 1
};
return obj;
};
}
let obj: LifeCycle = {
onCreate(want: Want) {
hilog.info(domain, TAG, 'FormAbility onCreate');
if (want.parameters) {
let formId = String(want.parameters['ohos.extra.param.key.form_identity']);
let formName = String(want.parameters['ohos.extra.param.key.form_name']);
let tempFlag = Boolean(want.parameters['ohos.extra.param.key.form_temporary']);
// 将创建的卡片信息持久化,以便在下次获取/更新该卡片实例时进行使用
// 此接口请根据实际情况实现具体请参考FormExtAbility Stage模型卡片实例
hilog.info(domain, TAG, 'FormAbility onCreate' + formId);
storeFormInfo(formId, formName, tempFlag, this.context);
}
// 使用方创建卡片时触发,提供方需要返回卡片数据绑定类
let obj: Record<string, string> = {
title: 'titleOnCreate',
detail: 'detailOnCreate'
};
let formData: formBindingData.FormBindingData = formBindingData.createFormBindingData(obj);
return formData;
},
onCastToNormal(formId: string) {
// 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理
hilog.info(domain, TAG, 'FormAbility onCastToNormal');
},
onUpdate(formId: string) {
// 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新
hilog.info(domain, TAG, 'FormAbility onUpdate');
let obj: Record<string, string> = {
title: 'titleOnUpdate',
detail: 'detailOnUpdate'
};
let formData: formBindingData.FormBindingData = formBindingData.createFormBindingData(obj);
// 调用updateForm接口去更新对应的卡片仅更新入参中携带的数据信息其他信息保持不变
formProvider.updateForm(formId, formData).catch((error: Error) => {
hilog.error(domain, TAG, 'FormAbility updateForm, error:' + JSON.stringify(error));
});
},
onVisibilityChange(newStatus: Record<string, number>) {
// 使用方发起可见或者不可见通知触发,提供方需要做相应的处理,仅系统应用生效
hilog.info(domain, TAG, 'FormAbility onVisibilityChange');
},
onEvent(formId: string, message: string) {
// 若卡片支持触发事件,则需要重写该方法并实现对事件的触发
let obj: Record<string, string> = {
title: 'titleOnEvent',
detail: 'detailOnEvent'
};
let formData: formBindingData.FormBindingData = formBindingData.createFormBindingData(obj);
// 调用updateForm接口去更新对应的卡片仅更新入参中携带的数据信息其他信息保持不变
formProvider.updateForm(formId, formData).catch((error: Error) => {
hilog.error(domain, TAG, 'FormAbility updateForm, error:' + JSON.stringify(error));
});
hilog.info(domain, TAG, 'FormAbility onEvent');
},
onDestroy(formId: string) {
// 删除卡片实例数据
hilog.info(domain, TAG, 'FormAbility onDestroy');
// 删除之前持久化的卡片实例数据
// 此接口请根据实际情况实现具体请参考FormExtAbility Stage模型卡片实例
deleteFormInfo(formId, this.context);
},
onAcquireFormState(want: Want) {
hilog.info(domain, TAG, 'FormAbility onAcquireFormState');
return formInfo.FormState.READY;
}
};
export default obj;

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import hilog from '@ohos.hilog';
const TAG: string = 'MainAbility';
const domain: number = 0xFF00;
class MainAbility {
onCreate() {
// 获取context并调用相关方法
let context = featureAbility.getContext();
context.getBundleName((data, bundleName) => {
hilog.info(domain, TAG, 'ability bundleName:' ,bundleName);
});
hilog.info(domain, TAG, 'Application onCreate');
}
onDestroy() {
hilog.info(domain, TAG, 'Application onDestroy');
}
onShow(): void {
hilog.info(domain, TAG, 'Application onShow');
}
onHide(): void {
hilog.info(domain, TAG, 'Application onHide');
}
onActive(): void {
hilog.info(domain, TAG, 'Application onActive');
}
onInactive(): void {
hilog.info(domain, TAG, 'Application onInactive');
}
onNewWant() {
hilog.info(domain, TAG, 'Application onNewWant');
}
}
export default new MainAbility();

View File

@ -1,209 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import router from '@ohos.router';
@Entry
@Component
struct Index {
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.main_title'))
.fontSize(24)
.fontWeight(700)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.PageAbility_Component_Develop'))
.textAlign(TextAlign.Start)
.fontWeight(500)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Row() {
Text($r('app.string.SingleDevice'))
.textAlign(TextAlign.End)
.fontWeight(500)
.margin({ top: 19, bottom: 18 })
.fontSize(14)
.width(64)
.height(19)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, bottom: 16, right: 6 })
}
}
.onClick(() => {
router.pushUrl({
url: 'pages/pagePageAbilityFirst'
});
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 8, right: 12, left: 12 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.PageAbility_Component_Develop'))
.textAlign(TextAlign.Start)
.fontWeight(500)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Row() {
Text($r('app.string.multi_device'))
.textAlign(TextAlign.End)
.fontWeight(500)
.margin({ top: 19, bottom: 18 })
.fontSize(14)
.width(64)
.height(19)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, bottom: 16, right: 6 })
}
}
.onClick(() => {
router.pushUrl({
url: 'pages/pagePageAbilitySecond'
});
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.serviceAbility_button'))
.textAlign(TextAlign.Start)
.fontWeight(500)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
router.pushUrl({
url: 'pages/pageServiceAbility'
});
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.dataAbility_button'))
.textAlign(TextAlign.Start)
.fontWeight(500)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
router.pushUrl({
url: 'pages/pageDataAbility'
});
let array: Array<string> = ['ohos.permission.READ_CONTACTS', 'ohos.permission.WRITE_CONTACTS'];
featureAbility.getContext().requestPermissionsFromUser(array, 1);
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.interflow_fa_and_stage_button'))
.textAlign(TextAlign.Start)
.fontWeight(500)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(304)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
router.pushUrl({
url: 'pages/pageInterflowFaAndStage'
});
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
}
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,654 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ability from '@ohos.ability.ability';
import featureAbility from '@ohos.ability.featureAbility';
import { BusinessError } from '@ohos.base';
import ohos_data_ability from '@ohos.data.dataAbility';
import rdb from '@ohos.data.rdb';
import promptAction from '@ohos.promptAction';
import hilog from '@ohos.hilog';
const TAG: string = 'PageDataAbility';
const domain: number = 0xFF00;
@Entry
@Component
struct PageDataAbility {
private valuesBucket_insert: rdb.ValuesBucket = { name: 'Rose', introduction: 'insert' };
private valuesBucket_update: rdb.ValuesBucket = { name: 'Rose', introduction: 'update' };
private crowd = new Array({ name: 'Rose', introduction: 'batchInsert_one' } as rdb.ValuesBucket,
{ name: 'Rose', introduction: 'batchInsert_two' } as rdb.ValuesBucket);
private columnArray = new Array('id', 'name', 'introduction');
private predicates = new ohos_data_ability.DataAbilityPredicates();
private uri = 'dataability:///com.samples.famodelabilitydevelop.DataAbility';
private DAHelper = featureAbility.acquireDataAbilityHelper(this.uri);
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.dataAbility_button'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Text($r('app.string.insertData'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
this.DAHelper.insert(this.uri, this.valuesBucket_insert, (error: BusinessError, data: number) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.insert_failed_toast')
});
} else {
promptAction.showToast({
message: $r('app.string.insert_success_toast')
});
}
hilog.info(domain, TAG, 'DAHelper insert result: ' + data + ', error: ' + JSON.stringify(error));
}
);
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
this.DAHelper.insert(this.uri, this.valuesBucket_insert).then((datainsert) => {
promptAction.showToast({
message: $r('app.string.insert_success_toast')
});
hilog.info(domain, TAG, 'DAHelper insert result: ' + datainsert);
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.insert_failed_toast')
});
hilog.error(domain, TAG, `DAHelper insert failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
ListItem() {
Text($r('app.string.delete_data'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
this.DAHelper.delete(this.uri, this.predicates, (error, data) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.delete_failed_toast')
});
} else {
promptAction.showToast({
message: $r('app.string.delete_success_toast')
});
}
hilog.info(domain, TAG, 'DAHelper delete result: ' + data + ', error: ' + JSON.stringify(error));
}
);
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
this.DAHelper.delete(this.uri, this.predicates).then((datadelete) => {
promptAction.showToast({
message: $r('app.string.delete_success_toast')
});
hilog.info(domain, TAG, 'DAHelper delete result: ' + datadelete);
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.delete_failed_toast')
});
hilog.error(domain, TAG, `DAHelper delete failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
ListItem() {
Text($r('app.string.update_data'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
this.predicates.equalTo('name', 'Rose');
this.DAHelper.update(this.uri, this.valuesBucket_update, this.predicates, (error, data) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.update_failed_toast')
});
} else {
promptAction.showToast({
message: $r('app.string.update_success_toast')
});
}
hilog.info(domain, TAG, 'DAHelper update result: ' + data + ', error: ' + JSON.stringify(error));
}
);
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
this.predicates.equalTo('name', 'Rose');
this.DAHelper.update(this.uri, this.valuesBucket_update, this.predicates).then((dataupdate) => {
promptAction.showToast({
message: $r('app.string.update_success_toast')
});
hilog.info(domain, TAG, 'DAHelper update result: ' + dataupdate);
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.update_failed_toast')
});
hilog.error(domain, TAG, `DAHelper update failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
ListItem() {
Text($r('app.string.query_data'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
this.predicates.equalTo('name', 'Rose');
this.DAHelper.query(this.uri, this.columnArray, this.predicates, (error, data) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.query_failed_toast')
});
hilog.error(domain, TAG, `DAHelper query failed. Cause: ${error.message}`);
} else {
promptAction.showToast({
message: $r('app.string.query_success_toast')
});
}
// ResultSet是一个数据集合的游标默认指向第-1个记录有效的数据从0开始。
while (data.goToNextRow()) {
const id = data.getLong(data.getColumnIndex('id'));
const name = data.getString(data.getColumnIndex('name'));
const introduction = data.getString(data.getColumnIndex('introduction'));
hilog.info(domain, TAG, `DAHelper query result:id = [${id}], name = [${name}], introduction = [${introduction}]`);
}
// 释放数据集的内存
data.close();
}
);
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
this.predicates.equalTo('name', 'Rose');
this.DAHelper.query(this.uri, this.columnArray, this.predicates).then((dataquery) => {
promptAction.showToast({
message: $r('app.string.query_success_toast')
});
// ResultSet是一个数据集合的游标默认指向第-1个记录有效的数据从0开始。
while (dataquery.goToNextRow()) {
const id = dataquery.getLong(dataquery.getColumnIndex('id'));
const name = dataquery.getString(dataquery.getColumnIndex('name'));
const introduction = dataquery.getString(dataquery.getColumnIndex('introduction'));
hilog.info(domain, TAG, `DAHelper query result:id = [${id}], name = [${name}], introduction = [${introduction}]`);
}
// 释放数据集的内存
dataquery.close();
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.query_failed_toast')
});
hilog.error(domain, TAG, `DAHelper query failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
ListItem() {
Text($r('app.string.batchInsert_data'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
this.DAHelper.batchInsert(this.uri, this.crowd, (error, data) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.batchInsert_failed_toast')
});
} else {
promptAction.showToast({
message: $r('app.string.batchInsert_success_toast')
});
}
hilog.info(domain, TAG, 'DAHelper batchInsert result: ' + data + ', error: ' + JSON.stringify(error));
}
);
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
this.DAHelper.batchInsert(this.uri, this.crowd).then((databatchInsert) => {
promptAction.showToast({
message: $r('app.string.batchInsert_success_toast')
});
hilog.info(domain, TAG, 'DAHelper batchInsert result: ' + databatchInsert);
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.batchInsert_failed_toast')
});
hilog.error(domain, TAG, `DAHelper batchInsert failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
ListItem() {
Text($r('app.string.executeBatch_data'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 19.5, bottom: 9.5 })
.fontSize(14)
.width(176)
.height(22)
.fontColor($r('app.color.text_color'))
.opacity(0.6)
}
.height(48)
.width(176)
.margin({ top: 8, left: 24 })
ListItemGroup() {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_callback'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 12.5, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// callback方式调用:
let operations: Array<ability.DataAbilityOperation> = [{
uri: this.uri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: { name: 'Rose', introduction: 'executeBatch' },
predicates: this.predicates,
expectedCount: 0,
predicatesBackReferences: undefined,
interrupted: true,
}];
this.DAHelper.executeBatch(this.uri, operations, (error, data) => {
if (error && error.code !== 0) {
promptAction.showToast({
message: $r('app.string.executeBatch_failed_toast')
});
} else {
promptAction.showToast({
message: $r('app.string.executeBatch_success_toast')
});
}
hilog.info(domain, TAG, `DAHelper executeBatch, result: ` + JSON.stringify(data) + ', error: ' + JSON.stringify(error));
});
})
}
.height(51)
.width('100%')
.margin({ top: 4 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.method_promise'))
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
Image($r('app.media.ic_arrow'))
.width(24)
.height(24)
.margin({ top: 16, right: 6 })
}
.onClick(() => {
// promise方式调用(await需要在async方法中使用):
let operations: Array<ability.DataAbilityOperation> = [{
uri: this.uri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: { name: 'Rose', introduction: 'executeBatch' },
predicates: this.predicates,
expectedCount: 0,
predicatesBackReferences: undefined,
interrupted: true,
}];
this.DAHelper.executeBatch(this.uri, operations).then((dataquery) => {
promptAction.showToast({
message: $r('app.string.executeBatch_success_toast')
});
hilog.info(domain, TAG, 'DAHelper executeBatch result: ' + JSON.stringify(dataquery));
}).catch((error: BusinessError) => {
promptAction.showToast({
message: $r('app.string.executeBatch_failed_toast')
});
hilog.error(domain, TAG, `DAHelper executeBatch failed. Cause: ${error.message}`);
});
})
}
.height(52)
.width('100%')
.margin({ bottom: 4 })
}
.borderRadius(24)
.divider({ strokeWidth: 0.5, color: ($r('app.color.backGrounding')), startMargin: 12, endMargin: 12 })
.height(104)
.backgroundColor($r('app.color.start_window_background'))
.margin({ right: 12, left: 12 })
}
.height('92%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,174 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
const TAG: string = 'PageInterflowFaAndStage';
const domain: number = 0xFF00;
@Entry
@Component
struct PageInterflowFaAndStage {
async startServiceAbility(): Promise<void> {
try {
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.ServiceAbilityStartUIAbility'
};
await featureAbility.startAbility({ want });
hilog.info(domain, TAG, `Start ServiceAbility succeed`);
} catch (error) {
hilog.error(domain, TAG, 'Start ServiceAbility failed with ' + error);
}
}
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.interflow_fa_and_stage_button'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Row() {
Row() {
Text($r('app.string.start_stage_noResult_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
let want: Want = {
bundleName: 'ohos.samples.etsclock',
abilityName: 'MainAbility'
};
featureAbility.startAbility({ want }).then((code) => {
hilog.info(domain, TAG, 'Ability verify code: ' + JSON.stringify(code));
}).catch((error: BusinessError) => {
hilog.error(domain, TAG, 'Ability failed: ' + JSON.stringify(error));
});
let serviceWant: Want = {
bundleName: 'com.samples.stagemodelabilityinteraction',
abilityName: 'ServiceExtAbility'
};
let faConnect: common.ConnectOptions = {
onConnect: (elementName, proxy) => {
hilog.info(domain, TAG, "FaConnection onConnect called.");
},
onDisconnect: (elementName) => {
hilog.info(domain, TAG, "FaConnection onDisconnect called.");
},
onFailed: (code) => {
hilog.info(domain, TAG, "FaConnection onFailed code is: " + code);
}
};
let connectionId = featureAbility.connectAbility(serviceWant, faConnect);
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 8, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.start_stage_withResult_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
let want: Want = {
bundleName: 'ohos.samples.etsclock',
abilityName: 'MainAbility'
};
featureAbility.startAbilityForResult({ want }).then((result) => {
hilog.info(domain, TAG, 'Ability verify result: ' + JSON.stringify(result));
}).catch((error: BusinessError) => {
hilog.error(domain, TAG, 'Ability failed: ' + JSON.stringify(error));
});
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.start_stage_service_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
this.startServiceAbility();
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
}
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,273 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';
import fs from '@ohos.file.fs';
import promptAction from '@ohos.promptAction';
import worker from '@ohos.worker';
import hilog from '@ohos.hilog';
const TAG: string = 'PagePageAbilityFirst';
const domain: number = 0xFF00;
@Entry
@Component
struct PagePageAbilityFirst {
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.pageAbility_first_button'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.getDirectory_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
(async (): Promise<void> => {
let dir: string;
try {
hilog.info(domain, TAG, 'Begin to getOrCreateDistributedDir');
dir = await featureAbility.getContext().getOrCreateDistributedDir();
promptAction.showToast({
message: dir
});
hilog.info(domain, TAG, 'distribute dir is ' + dir);
let fd: number;
let path = dir + '/a.txt';
fd = fs.openSync(path, fs.OpenMode.READ_WRITE).fd;
fs.close(fd);
} catch (error) {
hilog.error(domain, TAG, 'getOrCreateDistributedDir failed with : ' + error);
}
})()
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 8, right: 12, left: 12 })
ListItem() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
Text($r('app.string.start_singleton_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
(async (): Promise<void> => {
try {
hilog.info(domain, TAG, 'Begin to start ability');
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
moduleName: 'entry',
abilityName: 'com.samples.famodelabilitydevelop.PageAbilitySingleton'
};
await featureAbility.startAbility({ want: want });
hilog.info(domain, TAG, `Start ability succeed`);
}
catch (error) {
hilog.error(domain, TAG, 'Start ability failed with ' + error);
}
})()
})
}
.height(56)
.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.restart_singleton_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
(async (): Promise<void> => {
let wantInfo: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.PageAbilitySingleton',
parameters: { page: 'pages/second' }
};
featureAbility.startAbility({ want: wantInfo }).then((data) => {
hilog.debug(domain, TAG, `restartAbility success : ${data}`);
});
})()
})
}
.height(56)
.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.start_standard_first_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.PageAbilityStandard',
parameters: { page: 'pages/first' }
};
featureAbility.startAbility({ want: want }).then((data) => {
hilog.info(domain, TAG, `startAbility finish:${data}`);
}).catch((err: BusinessError) => {
hilog.info(domain, TAG, `startAbility failed errcode:${err.code}`);
})
})
}
.height(56)
.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.start_standard_second_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.PageAbilityStandard',
parameters: { page: 'pages/second' }
};
featureAbility.startAbility({ want: want }).then((data) => {
hilog.info(domain, TAG, `startAbility finish:${data}`);
}).catch((err: BusinessError) => {
hilog.info(domain, TAG, `startAbility failed errcode:${err.code}`);
})
})
}
.height(56)
.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.stop_pageAbility_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
(async (): Promise<void> => {
try {
hilog.info(domain, TAG, 'Begin to terminateSelf');
await featureAbility.terminateSelf();
hilog.info(domain, TAG, 'terminateSelf succeed');
} catch (error) {
hilog.error(domain, TAG, 'terminateSelf failed with ' + error);
}
})()
})
}
.height(56)
.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.worker_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 17, bottom: 17, left: 12, right: 92 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.onClick(() => {
let wk = new worker.ThreadWorker('../workers/worker.ts');
// 发送消息到worker线程
wk.postMessage('message from main thread.')
// 处理来自worker线程的消息
wk.onmessage = (message): void => {
promptAction.showToast({
message: JSON.stringify(message)
});
hilog.info(domain, TAG, 'message from worker: ' + JSON.stringify(message));
// 根据业务按需停止worker线程
wk.terminate();
}
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
}
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,215 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility'
import Want from '@ohos.app.ability.Want';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundle from '@ohos.bundle.bundleManager';
import deviceManager from '@ohos.distributedDeviceManager';
import promptAction from '@ohos.promptAction';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
const TAG: string = 'PagePageAbilitySecond'
const domain: number = 0xFF00;
@Entry
@Component
struct PagePageAbilitySecond {
@State deviceID: string = '';
async requestPermission(): Promise<void> {
hilog.info(domain, TAG, 'RequestPermission begin');
let array: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC'];
let bundleFlag = 0;
let tokenID: number | undefined = undefined;
let userID = 100;
let appInfo: bundle.ApplicationInfo = await bundle.getApplicationInfo('com.samples.famodelabilitydevelop', bundleFlag, userID);
tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let requestPermissions: Array<string> = [];
for (let i = 0;i < array.length; i++) {
let result = await atManager.verifyAccessToken(tokenID, array[i]);
hilog.info(domain, TAG, 'checkAccessToken result:' + JSON.stringify(result));
if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
requestPermissions.push(array[i]);
}
}
hilog.info(domain, TAG, 'requestPermissions:' + JSON.stringify(requestPermissions));
if (requestPermissions.length == 0) {
return;
}
let context = featureAbility.getContext();
context.requestPermissionsFromUser(requestPermissions, 1, (error, data) => {
hilog.info(domain, TAG, 'error:' + error.message + ',data:' + JSON.stringify(data));
hilog.info(domain, TAG, 'data requestCode:' + data.requestCode);
hilog.info(domain, TAG, 'data permissions:' + data.permissions);
hilog.info(domain, TAG, 'data authResults:' + data.authResults);
});
hilog.info(domain, TAG, 'RequestPermission end');
}
getRemoteDeviceId(): void {
let dmClass: deviceManager.DeviceManager;
dmClass = deviceManager.createDeviceManager('com.samples.famodelabilitydevelop');
try {
if (typeof dmClass === 'object' && dmClass !== null) {
let list = dmClass.getAvailableDeviceListSync();
if (typeof (list) == undefined || list.length == 0) {
hilog.info(domain, TAG, 'EntryAbility onButtonClick getRemoteDeviceId err: list is null');
return;
}
hilog.info(domain, TAG, `EntryAbility onButtonClick getRemoteDeviceId success[${list.length}]:` + JSON.stringify(list[0]));
if (list[0].networkId != undefined) {
this.deviceID = list[0].networkId;
}
promptAction.showToast({
message: this.deviceID
});
} else {
hilog.info(domain, TAG, 'EntryAbility onButtonClick getRemoteDeviceId err: dmClass is null');
}
} catch (error) {
hilog.info(domain, TAG, `getRemoteDeviceId error, error=${error}, message=${error.message}`);
}
}
onStartRemoteAbility(): void {
hilog.info(domain, TAG, 'onStartRemoteAbility begin');
let wantValue: Want = {
bundleName: 'ohos.samples.distributedmusicplayer',
abilityName: 'ohos.samples.distributedmusicplayer.MainAbility',
deviceId: this.deviceID, // this.deviceID的获取方式在前面的示例代码中
};
hilog.info(domain, TAG, 'onStartRemoteAbility want=' + JSON.stringify(wantValue));
featureAbility.startAbility({
want: wantValue
}).then((data) => {
promptAction.showToast({
message: $r('app.string.start_remote_success_toast')
});
hilog.info(domain, TAG, 'onStartRemoteAbility finished, ' + JSON.stringify(data));
}).catch((error: BusinessError) => {
promptAction.showToast({
message: JSON.stringify(error)
});
hilog.error(domain, TAG, 'onStartRemoteAbility failed: ' + JSON.stringify(error));
});
hilog.info(domain, TAG, 'onStartRemoteAbility end');
}
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.pageAbility_second_button'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Row() {
Row() {
Text($r('app.string.obtain_permissions_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
this.requestPermission();
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 8, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.obtain_device_id_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
this.getRemoteDeviceId();
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.start_remote_ability_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
this.onStartRemoteAbility();
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
}
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,223 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';
import promptAction from '@ohos.promptAction';
import rpc from '@ohos.rpc';
import hilog from '@ohos.hilog';
const TAG: string = 'PageServiceAbility';
const domain: number = 0xFF00;
@Entry
@Component
struct PageServiceAbility {
async startServiceAbility(): Promise<void> {
try {
hilog.info(domain, TAG, 'Begin to start ability');
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.ServiceAbility'
};
await featureAbility.startAbility({ want });
promptAction.showToast({
message: $r('app.string.start_service_success_toast')
});
hilog.info(domain, TAG, `Start ability succeed`);
} catch (error) {
hilog.error(domain, TAG, 'Start ability failed with ' + error);
}
}
build() {
Column() {
Row() {
Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
Text($r('app.string.serviceAbility_button'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.backGrounding'))
List({ initialIndex: 0 }) {
ListItem() {
Row() {
Row() {
Text($r('app.string.create_service_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
this.startServiceAbility();
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 8, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.connect_service_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
let option: common.ConnectOptions = {
onConnect: (element, proxy) => {
hilog.info(domain, TAG, `onConnectLocalService onConnectDone element:` + JSON.stringify(element));
if (proxy === null) {
promptAction.showToast({
message: $r('app.string.connect_service_failed_toast')
});
return;
}
let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create();
let option = new rpc.MessageOption();
data.writeInterfaceToken('connect.test.token');
proxy.sendRequest(0, data, reply, option);
promptAction.showToast({
message: $r('app.string.connect_service_success_toast')
});
},
onDisconnect: (element) => {
hilog.info(domain, TAG, `onConnectLocalService onDisconnectDone element:${element}`);
promptAction.showToast({
message: $r('app.string.disconnect_service_success_toast')
});
},
onFailed: (code) => {
hilog.info(domain, TAG, `onConnectLocalService onFailed errCode:${code}`);
promptAction.showToast({
message: $r('app.string.connect_service_failed_toast')
});
}
};
let request: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.ServiceAbility',
};
let connId = featureAbility.connectAbility(request, option);
hilog.info(domain, TAG, `onConnectLocalService onFailed errCode:${connId}`);
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
ListItem() {
Row() {
Row() {
Text($r('app.string.connect_wrong_service_button'))
.textAlign(TextAlign.Start)
.fontWeight(FontWeight.Medium)
.margin({ top: 13, bottom: 13, left: 0, right: 8 })
.fontSize(16)
.width(232)
.height(22)
.fontColor($r('app.color.text_color'))
}
.height(48)
.width('100%')
.borderRadius(24)
.margin({ top: 4, bottom: 4, left: 12, right: 84 })
}
.onClick(() => {
let option: common.ConnectOptions = {
onConnect: (element, proxy) => {
hilog.info(domain, TAG, `onConnectLocalService onConnectDone element:` + JSON.stringify(element));
if (proxy === null) {
promptAction.showToast({
message: $r('app.string.connect_service_failed_toast')
});
return;
}
let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create();
let option = new rpc.MessageOption();
data.writeInterfaceToken('connect.test.token');
proxy.sendRequest(0, data, reply, option);
promptAction.showToast({
message: $r('app.string.connect_service_success_toast')
});
},
onDisconnect: (element) => {
hilog.info(domain, TAG, `onConnectLocalService onDisconnectDone element:${element}`)
promptAction.showToast({
message: $r('app.string.disconnect_service_success_toast')
});
},
onFailed: (code) => {
hilog.info(domain, TAG, `onConnectLocalService onFailed errCode:${code}`);
promptAction.showToast({
message: $r('app.string.connect_service_failed_toast')
});
}
};
let request: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.UnKnownServiceAbility',
};
let connId = featureAbility.connectAbility(request, option);
hilog.info(domain, TAG, `onConnectLocalService onFailed errCode:${connId}`);
})
}
.height(56)
.backgroundColor($r('app.color.start_window_background'))
.borderRadius(24)
.margin({ top: 12, right: 12, left: 12 })
}
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
.width('100%')
.margin({ top: 8 })
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Want from '@ohos.app.ability.Want';
import featureAbility from '@ohos.ability.featureAbility';
import bundle from '@ohos.bundle';
import { GlobalContext } from '../utils/GlobalContext';
import hilog from '@ohos.hilog';
const TAG: string = 'PageAbilitySingleton';
const domain: number = 0xFF00;
class PageAbilitySingleton {
onCreate() {
// 获取context并调用相关方法
let context = featureAbility.getContext();
context.setDisplayOrientation(bundle.DisplayOrientation.PORTRAIT).then(() => {
hilog.info(domain, TAG, 'Set display orientation.')
})
hilog.info(domain, TAG, 'Application onCreate');
}
onDestroy() {
hilog.info(domain, TAG, 'Application onDestroy');
}
onNewWant(want: Want) {
featureAbility.getWant().then((want) => {
GlobalContext.getContext().setObject('newWant', want);
})
}
}
export default new PageAbilitySingleton();

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Want from '@ohos.app.ability.Want';
import router from '@ohos.router';
import { GlobalContext } from '../../utils/GlobalContext';
@Entry
@Component
struct First {
onPageShow() {
let newWant = GlobalContext.getContext().getObject('newWant') as Want;
if (newWant) {
if (newWant.parameters) {
if (newWant.parameters.page) {
router.push({ url: newWant.parameters.page as string});
GlobalContext.getContext().setObject("newWant", undefined);
}
}
}
}
build() {
Column() {
Row() {
Text($r('app.string.singleton_first_title'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.no_content'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Second {
build() {
Column() {
Row() {
Text($r('app.string.singleton_second_title'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.no_content'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import router from '@ohos.router';
class PageAbilityStandard {
onCreate() {
featureAbility.getWant().then((want) => {
if (want.parameters) {
if (want.parameters.page) {
router.push({ url: want.parameters.page as string });
}
}
})
}
}
export default new PageAbilityStandard();

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Default {
build() {
Column() {
Row() {
Text($r('app.string.standard_default_title'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.no_content'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct First {
build() {
Column() {
Row() {
Text($r('app.string.standard_first_title'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.no_content'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Second {
build() {
Column() {
Row() {
Text($r('app.string.standard_second_title'))
.fontSize(24)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.no_content'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type Want from '@ohos.app.ability.Want';
import rpc from '@ohos.rpc';
import hilog from '@ohos.hilog';
const TAG: string = '[Sample_FAModelAbilityDevelop]';
const domain: number = 0xFF00;
class FirstServiceAbilityStub extends rpc.RemoteObject {
constructor(des: Object) {
if (typeof des === 'string') {
super(des);
} else {
return;
}
}
onRemoteRequest(code: number, data: rpc.MessageParcel, reply: rpc.MessageParcel, option: rpc.MessageOption): boolean {
hilog.info(domain, TAG, 'ServiceAbility onRemoteRequest called');
if (code === 1) {
let string = data.readString();
hilog.info(domain, TAG, `ServiceAbility string=${string}`);
let result = Array.from(string).sort().join('');
hilog.info(domain, TAG, `ServiceAbility result=${result}`);
reply.writeString(result);
} else {
hilog.info(domain, TAG, 'ServiceAbility unknown request code');
}
return true;
}
}
class ServiceAbility {
onStart(): void {
hilog.info(domain, TAG, 'ServiceAbility onStart');
}
onStop(): void {
hilog.info(domain, TAG, 'ServiceAbility onStop');
}
onCommand(want: Want, startId: number): void {
hilog.info(domain, TAG, 'ServiceAbility onCommand');
}
onConnect(want: Want): rpc.RemoteObject {
hilog.info(domain, TAG, 'ServiceAbility onDisconnect' + want);
return new FirstServiceAbilityStub('test');
}
onDisconnect(want: Want): void {
hilog.info(domain, TAG, 'ServiceAbility onDisconnect' + want);
}
}
export default new ServiceAbility();

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type common from '@ohos.app.ability.common';
import particleAbility from '@ohos.ability.particleAbility';
import type Want from '@ohos.app.ability.Want';
import type { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
const TAG: string = '[Sample_FAModelAbilityDevelop]';
const domain: number = 0xFF00;
class ServiceAbilityStartUiAbility {
onStart(): void {
// 启动UIAbility
let want: Want = {
bundleName: 'ohos.samples.etsclock',
abilityName: 'MainAbility'
};
particleAbility.startAbility({ want }).then(() => {
hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility Start Ability successfully.');
}).catch((error: BusinessError) => {
hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility Ability failed: ' + JSON.stringify(error));
});
// 访问ServiceExtensionAbility
let serviceWant: Want = {
bundleName: 'com.samples.stagemodelabilityinteraction',
abilityName: 'ServiceExtAbility'
};
let faConnect: common.ConnectOptions = {
onConnect: (elementName, proxy) => {
hilog.info(domain, TAG, 'FaConnection onConnect called.');
},
onDisconnect: (elementName) => {
hilog.info(domain, TAG, 'FaConnection onDisconnect called.');
},
onFailed: (code) => {
hilog.info(domain, TAG, 'FaConnection onFailed code is: ' + code);
}
};
let connectionId = particleAbility.connectAbility(serviceWant, faConnect);
hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility ServiceAbility onStart');
}
};
export default new ServiceAbilityStartUiAbility();

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// GlobalContext.ts 构造单例对象
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);
}
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import worker from '@ohos.worker';
import hilog from '@ohos.hilog';
let parent = worker.workerPort;
// 处理来自主线程的消息
parent.onmessage = (message): void => {
hilog.info(0xFF00, 'Worker', 'onmessage: ' + JSON.stringify(message));
// 发送消息到主线程
parent.postMessage('message from worker thread.');
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.bg-img {
flex-shrink: 0;
height: 100%;
z-index: 1;
}
.bottom-img {
position: absolute;
width: 150px;
height: 56px;
top: 63%;
background-color: rgba(216, 216, 216, 0.15);
filter: blur(20px);
z-index: 2;
}
.container-inner {
flex-direction: column;
justify-content: flex-end;
align-items: flex-start;
height: 100%;
width: 100%;
padding: 12px;
}
.title {
font-family: HarmonyHeiTi-Medium;
font-size: 14px;
color: rgba(255,255,255,0.90);
letter-spacing: 0.6px;
}
.detail_text {
font-family: HarmonyHeiTi;
font-size: 12px;
color: rgba(255,255,255,0.60);
letter-spacing: 0.51px;
text-overflow: ellipsis;
max-lines: 1;
margin-top: 6px;
}

View File

@ -1,12 +0,0 @@
<div class="container">
<stack>
<div class="container-img">
<image src="/common/widget.png" class="bg-img"></image>
<image src="/common/rect.png" class="bottom-img"></image>
</div>
<div class="container-inner">
<text class="title" onclick="routerEvent">{{title}}</text>
<text class="detail_text" onclick="messageEvent">{{detail}}</text>
</div>
</stack>
</div>

View File

@ -1,21 +0,0 @@
{
"data": {
"title": "TitleDefault",
"detail": "TextDefault"
},
"actions": {
"routerEvent": {
"action": "router",
"abilityName": "com.samples.famodelabilitydevelop.MainAbility",
"params": {
"message": "add detail"
}
},
"messageEvent": {
"action": "message",
"params": {
"message": "add detail"
}
}
}
}

View File

@ -1,20 +0,0 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "background",
"value": "#f1f3f5"
},
{
"name": "backGrounding",
"value": "#f1f3f5"
},
{
"name": "text_color",
"value": "#182431"
}
]
}

View File

@ -1,340 +0,0 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "PageAbilitySingleton_desc",
"value": "description"
},
{
"name": "PageAbilitySingleton_label",
"value": "label"
},
{
"name": "PageAbilityStandard_desc",
"value": "description"
},
{
"name": "PageAbilityStandard_label",
"value": "label"
},
{
"name": "ServiceAbility_desc",
"value": "hap sample empty service"
},
{
"name": "DataAbility_desc",
"value": "hap sample empty provider"
},
{
"name": "FormAbility_desc",
"value": "form_description"
},
{
"name": "FormAbility_label",
"value": "form_label"
},
{
"name": "ServiceAbilityStartUIAbility_desc",
"value": "hap sample empty service"
},
{
"name": "main_title",
"value": "main_title"
},
{
"name": "getDirectory_button",
"value": "getDirectory_button"
},
{
"name": "start_singleton_button",
"value": "start_singleton_button"
},
{
"name": "start_standard_first_button",
"value": "start_standard_first_button"
},
{
"name": "start_standard_second_button",
"value": "start_standard_second_button"
},
{
"name": "restart_singleton_button",
"value": "restart_singleton_button"
},
{
"name": "stop_pageAbility_button",
"value": "stop_pageAbility_button"
},
{
"name": "singleton_first_title",
"value": "singleton_first_title"
},
{
"name": "singleton_second_title",
"value": "singleton_second_title"
},
{
"name": "standard_default_title",
"value": "standard_default_title"
},
{
"name": "standard_first_title",
"value": "standard_first_title"
},
{
"name": "standard_second_title",
"value": "standard_second_title"
},
{
"name": "pageAbility_first_button",
"value": "pageAbility_first_button"
},
{
"name": "pageAbility_second_button",
"value": "pageAbility_second_button"
},
{
"name": "serviceAbility_button",
"value": "serviceAbility_button"
},
{
"name": "dataAbility_button",
"value": "dataAbility_button"
},
{
"name": "interflow_fa_and_stage_button",
"value": "interflow_fa_and_stage_button"
},
{
"name": "insert_cb_button",
"value": "insert_cb_button"
},
{
"name": "insert_pm_button",
"value": "insert_pm_button"
},
{
"name": "delete_cb_button",
"value": "delete_cb_button"
},
{
"name": "delete_pm_button",
"value": "delete_pm_button"
},
{
"name": "update_cb_button",
"value": "update_cb_button"
},
{
"name": "update_pm_button",
"value": "update_pm_button"
},
{
"name": "query_cb_button",
"value": "query_cb_button"
},
{
"name": "query_pm_button",
"value": "query_pm_button"
},
{
"name": "batchInsert_cb_button",
"value": "batchInsert_cb_button"
},
{
"name": "batchInsert_pm_button",
"value": "batchInsert_pm_button"
},
{
"name": "executeBatch_cb_button",
"value": "executeBatch_cb_button"
},
{
"name": "executeBatch_pm_button",
"value": "executeBatch_pm_button"
},
{
"name": "start_stage_noResult_button",
"value": "start_stage_noResult_button"
},
{
"name": "start_stage_withResult_button",
"value": "start_stage_withResult_button"
},
{
"name": "start_stage_service_button",
"value": "start_stage_service_button"
},
{
"name": "worker_button",
"value": "worker_button"
},
{
"name": "create_service_button",
"value": "create_service_button"
},
{
"name": "connect_service_button",
"value": "connect_service_button"
},
{
"name": "connect_wrong_service_button",
"value": "connect_wrong_service_button"
},
{
"name": "reserve_title",
"value": "reserve_title"
},
{
"name": "insert_success_toast",
"value": "insert_success_toast"
},
{
"name": "insert_failed_toast",
"value": "insert_failed_toast"
},
{
"name": "delete_success_toast",
"value": "delete_success_toast"
},
{
"name": "delete_failed_toast",
"value": "delete_failed_toast"
},
{
"name": "update_success_toast",
"value": "update_success_toast"
},
{
"name": "update_failed_toast",
"value": "update_failed_toast"
},
{
"name": "query_success_toast",
"value": "query_success_toast"
},
{
"name": "query_failed_toast",
"value": "query_failed_toast"
},
{
"name": "batchInsert_success_toast",
"value": "batchInsert_success_toast"
},
{
"name": "batchInsert_failed_toast",
"value": "batchInsert_failed_toast"
},
{
"name": "executeBatch_success_toast",
"value": "executeBatch_success_toast"
},
{
"name": "executeBatch_failed_toast",
"value": "executeBatch_failed_toast"
},
{
"name": "start_service_success_toast",
"value": "start_service_success_toast"
},
{
"name": "connect_service_success_toast",
"value": "connect_service_success_toast"
},
{
"name": "connect_service_failed_toast",
"value": "connect_service_failed_toast"
},
{
"name": "disconnect_service_success_toast",
"value": "disconnect_service_success_toast"
},
{
"name": "PageAbility_Component_Develop",
"value": "page ability component develop"
},
{
"name": "SingleDevice",
"value": "single device"
},
{
"name": "multi_device",
"value": "multi device"
},
{
"name": "insertData",
"value": "insert data"
},
{
"name": "method_callback",
"value": "method callback"
},
{
"name": "method_promise",
"value": "method promise"
},
{
"name": "delete_data",
"value": "delete data"
},
{
"name": "no_content",
"value": "no content"
},
{
"name": "update_data",
"value": "update_data"
},
{
"name": "query_data",
"value": "query_data"
},
{
"name": "batchInsert_data",
"value": "batchInsert_data"
},
{
"name": "executeBatch_data",
"value": "executeBatch_data"
},
{
"name": "start_remote_success_toast",
"value": "start_remote_success_toast"
},
{
"name": "obtain_permissions_button",
"value": "obtain_permissions_button"
},
{
"name": "obtain_device_id_button",
"value": "obtain_device_id_button"
},
{
"name": "start_remote_ability_button",
"value": "start_remote_ability_button"
},
{
"name": "start_stage_service_extension_button",
"value": "start_stage_service_extension_button"
},
{
"name": "connect_service_extension_success_toast",
"value": "connect_service_extension_success_toast"
},
{
"name": "connect_service_extension_failed_toast",
"value": "connect_service_extension_failed_toast"
}
]
}

View File

@ -1,13 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_back</title>
<defs>
<path d="M5.56079777,13.7499686 L11.5303301,19.7196699 L11.5640714,19.7556673 C11.8227547,20.0502619 11.8115076,20.4991526 11.5303301,20.7803301 C11.2491526,21.0615076 10.8002619,21.0727547 10.5056673,20.8140714 L10.4696699,20.7803301 L3.43929777,13.7499686 L5.56079777,13.7499686 Z M10.4696699,3.21966991 C10.7625631,2.9267767 11.2374369,2.9267767 11.5303301,3.21966991 C11.8115076,3.5008474 11.8227547,3.94973814 11.5640714,4.24433269 L11.5303301,4.28033009 L4.5605,11.25 L21.25,11.25 C21.6494202,11.25 21.9759152,11.56223 21.9987268,11.9559318 L22,12 C22,12.3994202 21.68777,12.7259152 21.2940682,12.7487268 L21.25,12.75 L2.75,12.75 C2.09603793,12.75 1.76158663,11.9761547 2.19060357,11.5002723 L2.21966991,11.4696699 L10.4696699,3.21966991 Z" id="path-1"></path>
</defs>
<g id="ic_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#182431" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,13 +0,0 @@
<?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_check</title>
<defs>
<path d="M18.4837572,13.0088835 C19.1529369,13.6780631 19.1668781,14.7543557 18.5255809,15.4404984 L18.4837572,15.4837572 L12.7840097,21.1835047 C12.4911165,21.4763979 12.0162428,21.4763979 11.7233496,21.1835047 C11.4409168,20.9010719 11.4308299,20.4494252 11.6930889,20.1549057 L11.7233496,20.1228445 L17.0695436,14.7766504 C17.3519764,14.4942177 17.3620633,14.0425709 17.0998043,13.7480514 L17.0695436,13.7159903 L6.72334957,3.36979618 C6.43045635,3.07690296 6.43045635,2.60202923 6.72334957,2.30913601 C7.00578232,2.02670326 7.45742909,2.01661638 7.75194855,2.27887536 L7.78400974,2.30913601 L18.4837572,13.0088835 Z" id="path-1"></path>
</defs>
<g id="ic_check" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#182431" fill-rule="nonzero" transform="translate(12.750000, 11.746320) rotate(-270.000000) translate(-12.750000, -11.746320) " xlink:href="#path-1"></use>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>pic_empty</title>
<g id="pic_empty" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M72.3173684,96.5151117 C73.8679813,96.5315497 78.2712138,97.1257855 80.2099313,90.7893826 C86.6692105,92.1757402 90.75,94.2175519 90.75,96.4940318 C90.75,100.675369 76.9827561,104.065013 60,104.065013 C43.0172439,104.065013 29.25,100.675369 29.25,96.4940318 L29.251,96.5143826 Z" id="shadow" fill="#A1A7B3" opacity="0.15"></path>
<path d="M89.6271412,15.4449044 C94.6179581,15.4449044 98.1316055,19.7487672 98.1316055,24.5403259 C98.1316055,24.6405635 98.1299392,24.7404041 98.1266332,24.8398203 L98.1316055,33.8145473 L81.1226769,33.8145473 L81.1226769,24.8394944 C81.1243432,24.7404041 81.1226769,24.6405635 81.1226769,24.5403259 C81.1226769,19.7487672 84.6363243,15.4449044 89.6271412,15.4449044 Z" id="形状结合" fill="#A1A7B3" opacity="0.600000024"></path>
<path d="M89.7539954,15.5965666 C86.3875404,15.5965666 84.1818218,17.3578378 83.0669397,18.9023864 C81.6573733,20.8551881 81.1690409,22.657016 81.1458589,24.3124383 C81.1304042,25.4160531 81.1304042,26.5065743 81.1458589,27.5840021 L81.1457914,51.4435917 C72.8733201,53.2314678 66.675,60.5912079 66.675,69.3986432 C66.675,78.1241555 72.7585481,85.4287791 80.9154921,87.3023616 C79.7096443,97.324571 74.1091093,96.5341058 72.3173684,96.5151117 L25.3333912,96.51478 L25.333034,96.4935666 L13.2834473,96.4940318 C12.2927246,96.4940318 9.13545494,94.2417589 7.33515704,90.6729662 C6.13495845,88.293771 5.55847855,84.7631315 5.60571734,80.0810477 L25.333034,80.0805666 L25.3333912,25.4940528 C25.3333912,20.4595761 27.7355585,17.1921939 32.5398933,15.6919061 L32.8566252,15.5965666 L89.7539954,15.5965666 Z" id="形状结合" fill="#A1A7B3" opacity="0.300000012"></path>
<path d="M5.60571734,80.0810477 L62.729506,80.0810477 C62.3525731,85.7863224 63.0813003,89.8341336 64.9156877,92.2244812 C66.750075,94.6148288 69.4661267,96.0380124 73.0638428,96.4940318 C33.8707275,96.4940318 13.943929,96.4940318 13.2834473,96.4940318 C12.2927246,96.4940318 9.13545494,94.2417589 7.33515704,90.6729662 C6.13495845,88.293771 5.55847855,84.7631315 5.60571734,80.0810477 Z" id="矩形" fill="#A1A7B3" opacity="0.400000006"></path>
<path d="M98.5302859,81.8697759 L102.097608,85.4372528 C103.043246,85.0544679 104.167164,85.2464706 104.933954,86.0132607 L114.175162,95.2544691 C115.198092,96.2773987 115.198092,97.9358952 114.175162,98.9588248 L113.922423,99.2115639 C112.899493,100.234493 111.240997,100.234493 110.218067,99.2115639 L100.976859,89.9703555 C100.210208,89.2037048 100.018136,88.0800567 100.400642,87.1345259 L96.7894064,83.5216377 C97.4050227,83.0092055 97.9866118,82.457289 98.5302859,81.8697759 Z" id="形状结合" fill="#A1A7B3" opacity="0.600000024"></path>
<path d="M85.0446429,51.0267857 C95.1899165,51.0267857 103.414286,59.251155 103.414286,69.3964286 C103.414286,79.5417022 95.1899165,87.7660714 85.0446429,87.7660714 C74.8993692,87.7660714 66.675,79.5417022 66.675,69.3964286 C66.675,59.251155 74.8993692,51.0267857 85.0446429,51.0267857 Z M85.0446429,55.1089286 C77.1538745,55.1089286 70.7571429,61.5056602 70.7571429,69.3964286 C70.7571429,77.2871969 77.1538745,83.6839286 85.0446429,83.6839286 C92.9354112,83.6839286 99.3321429,77.2871969 99.3321429,69.3964286 C99.3321429,61.5056602 92.9354112,55.1089286 85.0446429,55.1089286 Z" id="形状结合" fill="#A1A7B3" opacity="0.5"></path>
<circle id="椭圆形" fill="#A1A7B3" opacity="0.200000003" cx="85.0446429" cy="69.3964286" r="14.2875"></circle>
<rect id="矩形" fill="#A1A7B3" opacity="0.200000003" transform="translate(93.714014, 70.183327) rotate(-255.000000) translate(-93.714014, -70.183327) " x="89.6318713" y="69.5029701" width="8.16428571" height="1.36071429" rx="0.680357143"></rect>
<rect id="矩形备份" fill="#A1A7B3" opacity="0.200000003" transform="translate(91.672943, 65.420827) rotate(-255.000000) translate(-91.672943, -65.420827) " x="89.6318713" y="64.7404701" width="4.08214286" height="1.36071429" rx="0.680357143"></rect>
<path d="M52.7160161,47.187668 C53.441911,46.9931651 54.188041,47.4239434 54.3825439,48.1498383 L56.2216997,55.0136613 C56.4162027,55.7395562 55.9854244,56.4856861 55.2595294,56.6801891 C54.5336345,56.8746921 53.7875046,56.4439138 53.5930016,55.7180188 L51.7538458,48.8541959 C51.5593428,48.1283009 51.9901211,47.382171 52.7160161,47.187668 Z M63.0592013,46.2642857 C63.8107031,46.2642857 64.4199156,46.8734983 64.4199156,47.625 L64.4199156,54.7309524 C64.4199156,55.4824541 63.8107031,56.0916667 63.0592013,56.0916667 C62.3076996,56.0916667 61.6984871,55.4824541 61.6984871,54.7309524 L61.6984871,47.625 C61.6984871,46.8734983 62.3076996,46.2642857 63.0592013,46.2642857 Z M72.6464342,47.187668 C73.3723292,47.382171 73.8031075,48.1283009 73.6086045,48.8541959 L71.7694487,55.7180188 C71.5749457,56.4439138 70.8288158,56.8746921 70.1029209,56.6801891 C69.3770259,56.4856861 68.9462476,55.7395562 69.1407506,55.0136613 L70.9799064,48.1498383 C71.1744093,47.4239434 71.9205393,46.9931651 72.6464342,47.187668 Z" id="形状结合" fill="#A1A7B3" opacity="0.300000012" transform="translate(62.681225, 51.495589) rotate(-53.000000) translate(-62.681225, -51.495589) "></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,340 +0,0 @@
{
"string": [
{
"name": "module_desc",
"value": "Test the functions of each component of the FA model"
},
{
"name": "MainAbility_desc",
"value": "Development guidance for FA model components"
},
{
"name": "MainAbility_label",
"value": "FAModel"
},
{
"name": "PageAbilitySingleton_desc",
"value": "PageAbilitySingleton"
},
{
"name": "PageAbilitySingleton_label",
"value": "PageAbilitySingleton"
},
{
"name": "PageAbilityStandard_desc",
"value": "PageAbilityStandard"
},
{
"name": "PageAbilityStandard_label",
"value": "PageAbilityStandard"
},
{
"name": "ServiceAbility_desc",
"value": "Ability based on Service Template"
},
{
"name": "DataAbility_desc",
"value": "Ability to use Data templates"
},
{
"name": "FormAbility_desc",
"value": "FA Service Card"
},
{
"name": "FormAbility_label",
"value": "FA Service Card"
},
{
"name": "ServiceAbilityStartUIAbility_desc",
"value": "ServiceAbility interworking with Stage"
},
{
"name": "main_title",
"value": "FA Model Component Development Guidance"
},
{
"name": "getDirectory_button",
"value": "Get Distributed Directory"
},
{
"name": "start_singleton_button",
"value": "Start PageAbilitySingleton"
},
{
"name": "start_standard_first_button",
"value": "Start PageAbilityStandard First"
},
{
"name": "start_standard_second_button",
"value": "Start PageAbilityStandard Second"
},
{
"name": "restart_singleton_button",
"value": "Restart PageAbilitySingleton"
},
{
"name": "stop_pageAbility_button",
"value": "Stop PageAbility"
},
{
"name": "singleton_first_title",
"value": "PageAbilitySingleton first page"
},
{
"name": "singleton_second_title",
"value": "PageAbilitySingleton second page"
},
{
"name": "standard_default_title",
"value": "PageAbilityStandard default page"
},
{
"name": "standard_first_title",
"value": "PageAbilityStandard first page"
},
{
"name": "standard_second_title",
"value": "PageAbilityStandard second page"
},
{
"name": "pageAbility_first_button",
"value": "PageAbility Component Development Guide First"
},
{
"name": "pageAbility_second_button",
"value": "PageAbility Component Development Guide Second"
},
{
"name": "serviceAbility_button",
"value": "ServiceAbility Component Development Guide"
},
{
"name": "dataAbility_button",
"value": "DataAbility Component Development Guide"
},
{
"name": "interflow_fa_and_stage_button",
"value": "Guidelines for interworking between FA model and Stage model application components"
},
{
"name": "insert_cb_button",
"value": "Insert data using callback method"
},
{
"name": "insert_pm_button",
"value": "Insert data using promise method"
},
{
"name": "delete_cb_button",
"value": "Delete data using callback method"
},
{
"name": "delete_pm_button",
"value": "Delete data using promise method"
},
{
"name": "update_cb_button",
"value": "Update data using callback method"
},
{
"name": "update_pm_button",
"value": "Update data using promise method"
},
{
"name": "query_cb_button",
"value": "Query data using callback method"
},
{
"name": "query_pm_button",
"value": "Query data using promise method"
},
{
"name": "batchInsert_cb_button",
"value": "BatchInsert data using callback method"
},
{
"name": "batchInsert_pm_button",
"value": "BatchInsert data using promise method"
},
{
"name": "executeBatch_cb_button",
"value": "ExcuteBatch data using callback method"
},
{
"name": "executeBatch_pm_button",
"value": "ExcuteBatch data using promise method"
},
{
"name": "start_stage_noResult_button",
"value": "Interworking with Stage model through PageAbility - no need to return results"
},
{
"name": "start_stage_withResult_button",
"value": "Interworking with Stage model through PageAbility - returning execution results"
},
{
"name": "start_stage_service_button",
"value": "Interworking with the Stage model through ServiceAbility"
},
{
"name": "worker_button",
"value": "Using Worker for inter thread communication"
},
{
"name": "create_service_button",
"value": "Start ServiceAbility"
},
{
"name": "connect_service_button",
"value": "Connecting to ServiceAbility"
},
{
"name": "connect_wrong_service_button",
"value": "Connecting to wrong ServiceAbility"
},
{
"name": "reserve_title",
"value": "Reserved page"
},
{
"name": "insert_success_toast",
"value": "Insert data success"
},
{
"name": "insert_failed_toast",
"value": "Insert data failed"
},
{
"name": "delete_success_toast",
"value": "Delete data success"
},
{
"name": "update_success_toast",
"value": "Update data success"
},
{
"name": "query_success_toast",
"value": "Query data success"
},
{
"name": "batchInsert_success_toast",
"value": "BatchInsert data success"
},
{
"name": "executeBatch_success_toast",
"value": "ExecuteBatch data success"
},
{
"name": "delete_failed_toast",
"value": "Delete data failed"
},
{
"name": "update_failed_toast",
"value": "Update data failed"
},
{
"name": "query_failed_toast",
"value": "Query data failed"
},
{
"name": "batchInsert_failed_toast",
"value": "BatchInsert data failed"
},
{
"name": "executeBatch_failed_toast",
"value": "ExecuteBatch data failed"
},
{
"name": "start_service_success_toast",
"value": "Start serviceAbility succeed"
},
{
"name": "connect_service_failed_toast",
"value": "Connect service failed"
},
{
"name": "connect_service_success_toast",
"value": "Connect service success"
},
{
"name": "disconnect_service_success_toast",
"value": "Disconnect service success"
},
{
"name": "PageAbility_Component_Develop",
"value": "page ability component develop"
},
{
"name": "SingleDevice",
"value": "single device"
},
{
"name": "multi_device",
"value": "multi device"
},
{
"name": "insertData",
"value": "insert data"
},
{
"name": "method_callback",
"value": "method callback"
},
{
"name": "method_promise",
"value": "method promise"
},
{
"name": "delete_data",
"value": "delete data"
},
{
"name": "no_content",
"value": "no content"
},
{
"name": "update_data",
"value": "update data"
},
{
"name": "query_data",
"value": "query data"
},
{
"name": "batchInsert_data",
"value": "batchInsert data"
},
{
"name": "executeBatch_data",
"value": "executeBatch data"
},
{
"name": "start_remote_success_toast",
"value": "Successfully started remote Ability"
},
{
"name": "obtain_permissions_button",
"value": "Obtain distributed data sync permissions"
},
{
"name": "obtain_device_id_button",
"value": "Obtain device id"
},
{
"name": "start_remote_ability_button",
"value": "Starting Remote Device PageAbility"
},
{
"name": "start_stage_service_extension_button",
"value": "Interworking with Stage model through PageAbility - ServiceExtensionAbility"
},
{
"name": "connect_service_extension_success_toast",
"value": "Successfully connected to ServiceExtensionAbility"
},
{
"name": "connect_service_extension_failed_toast",
"value": "Failed connected to ServiceExtensionAbility"
}
]
}

View File

@ -1,340 +0,0 @@
{
"string": [
{
"name": "module_desc",
"value": "测试FA模型各组件功能"
},
{
"name": "MainAbility_desc",
"value": "FA模型各组件的开发指导"
},
{
"name": "MainAbility_label",
"value": "FAModel"
},
{
"name": "PageAbilitySingleton_desc",
"value": "单例PageAbility"
},
{
"name": "PageAbilitySingleton_label",
"value": "单例PageAbility"
},
{
"name": "PageAbilityStandard_desc",
"value": "多例PageAbility"
},
{
"name": "PageAbilityStandard_label",
"value": "多例PageAbility"
},
{
"name": "ServiceAbility_desc",
"value": "基于Service模板的Ability"
},
{
"name": "DataAbility_desc",
"value": "使用Data模板的Ability"
},
{
"name": "FormAbility_desc",
"value": "FA服务卡片"
},
{
"name": "FormAbility_label",
"value": "FA服务卡片"
},
{
"name": "ServiceAbilityStartUIAbility_desc",
"value": "与Stage互通的ServiceAbility"
},
{
"name": "main_title",
"value": "FA模型组件开发指导"
},
{
"name": "getDirectory_button",
"value": "获取分布式目录"
},
{
"name": "start_singleton_button",
"value": "启动单例PageAbility"
},
{
"name": "start_standard_first_button",
"value": "启动多例PageAbility页面一"
},
{
"name": "start_standard_second_button",
"value": "启动多例PageAbility页面二"
},
{
"name": "restart_singleton_button",
"value": "再启动单例PageAbility"
},
{
"name": "stop_pageAbility_button",
"value": "停止PageAbility"
},
{
"name": "singleton_first_title",
"value": "PageAbilitySingleton页面一"
},
{
"name": "singleton_second_title",
"value": "PageAbilitySingleton页面二"
},
{
"name": "standard_default_title",
"value": "PageAbilityStandard默认页面"
},
{
"name": "standard_first_title",
"value": "PageAbilityStandard页面一"
},
{
"name": "standard_second_title",
"value": "PageAbilityStandard页面二"
},
{
"name": "pageAbility_first_button",
"value": "PageAbility组件开发指导-单设备"
},
{
"name": "pageAbility_second_button",
"value": "PageAbility组件开发指导-多设备"
},
{
"name": "serviceAbility_button",
"value": "ServiceAbility组件开发指导"
},
{
"name": "dataAbility_button",
"value": "DataAbility组件开发指导"
},
{
"name": "interflow_fa_and_stage_button",
"value": "FA模型与Stage模型应用组件互通指导"
},
{
"name": "insert_cb_button",
"value": "插入数据-callback方式"
},
{
"name": "insert_pm_button",
"value": "插入数据-promise方式"
},
{
"name": "delete_cb_button",
"value": "删除数据-callback方式"
},
{
"name": "delete_pm_button",
"value": "删除数据-promise方式"
},
{
"name": "update_cb_button",
"value": "更新数据-callback方式"
},
{
"name": "update_pm_button",
"value": "更新数据-promise方式"
},
{
"name": "query_cb_button",
"value": "查找数据-callback方式"
},
{
"name": "query_pm_button",
"value": "查找数据-promise方式"
},
{
"name": "batchInsert_cb_button",
"value": "批量插入数据-callback方式"
},
{
"name": "batchInsert_pm_button",
"value": "批量插入数据-promise方式"
},
{
"name": "executeBatch_cb_button",
"value": "批量处理数据-callback方式"
},
{
"name": "executeBatch_pm_button",
"value": "批量处理数据-promise方式"
},
{
"name": "start_stage_noResult_button",
"value": "通过PageAbility与Stage模型互通-无需返回结果"
},
{
"name": "start_stage_withResult_button",
"value": "通过PageAbility与Stage模型互通-返回执行结果"
},
{
"name": "start_stage_service_button",
"value": "通过ServiceAbility与Stage模型互通"
},
{
"name": "worker_button",
"value": "使用Worker进行线程间通信"
},
{
"name": "create_service_button",
"value": "启动ServiceAbility"
},
{
"name": "connect_service_button",
"value": "连接ServiceAbility"
},
{
"name": "connect_wrong_service_button",
"value": "连接错误的ServiceAbility"
},
{
"name": "reserve_title",
"value": "预留页面"
},
{
"name": "insert_success_toast",
"value": "插入数据成功"
},
{
"name": "insert_failed_toast",
"value": "插入数据失败"
},
{
"name": "delete_success_toast",
"value": "删除数据成功"
},
{
"name": "delete_failed_toast",
"value": "删除数据失败"
},
{
"name": "update_success_toast",
"value": "更新数据成功"
},
{
"name": "update_failed_toast",
"value": "更新数据失败"
},
{
"name": "query_success_toast",
"value": "查找数据成功"
},
{
"name": "query_failed_toast",
"value": "查找数据失败"
},
{
"name": "batchInsert_success_toast",
"value": "批量插入数据成功"
},
{
"name": "batchInsert_failed_toast",
"value": "批量插入数据失败"
},
{
"name": "executeBatch_success_toast",
"value": "批量处理数据成功"
},
{
"name": "executeBatch_failed_toast",
"value": "批量处理数据失败"
},
{
"name": "start_service_success_toast",
"value": "启动serviceAbility成功"
},
{
"name": "connect_service_success_toast",
"value": "连接serviceAbility成功"
},
{
"name": "connect_service_failed_toast",
"value": "连接serviceAbility失败"
},
{
"name": "disconnect_service_success_toast",
"value": "断开连接serviceAbility成功"
},
{
"name": "PageAbility_Component_Develop",
"value": "PageAbility组件开发指导"
},
{
"name": "SingleDevice",
"value": "单设备"
},
{
"name": "multi_device",
"value": "多设备"
},
{
"name": "insertData",
"value": "插入数据"
},
{
"name": "method_callback",
"value": "callback方式"
},
{
"name": "method_promise",
"value": "promise方式"
},
{
"name": "delete_data",
"value": "删除数据"
},
{
"name": "no_content",
"value": "暂无内容"
},
{
"name": "update_data",
"value": "更新数据"
},
{
"name": "query_data",
"value": "查找数据"
},
{
"name": "batchInsert_data",
"value": "批量插入数据"
},
{
"name": "executeBatch_data",
"value": "批量处理数据"
},
{
"name": "start_remote_success_toast",
"value": "启动远程Ability成功"
},
{
"name": "obtain_permissions_button",
"value": "获取分布式数据同步权限"
},
{
"name": "obtain_device_id_button",
"value": "获取设备id"
},
{
"name": "start_remote_ability_button",
"value": "启动远程设备PageAbility"
},
{
"name": "start_stage_service_extension_button",
"value": "通过PageAbility与Stage模型互通-ServiceExtensionAbility"
},
{
"name": "connect_service_extension_success_toast",
"value": "连接ServiceExtensionAbility成功"
},
{
"name": "connect_service_extension_failed_toast",
"value": "连接ServiceExtensionAbility失败"
}
]
}

View File

@ -1,67 +0,0 @@
{
"app": {
"bundleName": "com.samples.famodelabilitydevelop",
"vendor": "samples",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.samples.famodelabilitydevelop_test",
"name": ".entry_test",
"mainAbility": ".TestAbility",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry_test",
"moduleType": "feature",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
class TestAbility {
onCreate() {
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
}
}
export default new TestAbility();

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
aboutToAppear() {
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
})
}
.width('100%')
}
.height('100%')
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
}
async function addAbilityMonitorCallback(err: any) {
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
}
onRun() {
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug === 'true') {
cmd += ' -D'
}
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
})
}
};

View File

@ -1,458 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Want from '@ohos.app.ability.Want';
import featureAbility from '@ohos.ability.featureAbility'
import Base from '@ohos.base';
import { describe, it, expect } from '@ohos/hypium';
import { Driver, ON } from '@ohos.UiTest';
import hilog from '@ohos.hilog';
const BUNDLE = 'FAModelAbilityDevelop_';
const TAG = 'abilityTest';
const domain: number = 0xF811;
function sleep(time: number) {
return new Promise<void>((resolve: Function) => setTimeout(resolve, time));
}
export default function abilityTest() {
let driver = Driver.create();
describe('FAModelAbilityDevelopTest', () => {
/**
* @tc.number:FAModelAbilityDevelopTest_001
* @tc.name: FAModelAbilityDevelop_StartAbility_001
* @tc.size: MediumTest
* @tc.type: Function
* @tc.level Level 1
* @tc.desc: 测试Ability是否被成功拉起
*/
it(BUNDLE + 'StartAbility_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'StartAbility_001, begin');
// 启动需要测试的应用
let want: Want = {
bundleName: 'com.samples.famodelabilitydevelop',
abilityName: 'com.samples.famodelabilitydevelop.MainAbility'
};
featureAbility.startAbility({
want: want
}, (err: Base.BusinessError) => {
hilog.info(domain, TAG, BUNDLE + 'StartAbility_001 get err ' + JSON.stringify(err));
expect(0).assertEqual(err.code);
})
await sleep(1000);
hilog.info(domain, TAG, BUNDLE + 'StartAbility_001 end');
done();
})
/**
* @tc.number:FAModelAbilityDevelopTest_002
* @tc.name: FAModelAbilityDevelop_PageAbility_001
* @tc.size: MediumTest
* @tc.type: Function
* @tc.level Level 1
* @tc.desc: 测试PageAbility相关功能
*/
it(BUNDLE + 'PageAbility_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'PageAbility_001, begin');
// 跳转至'PageAbility组件开发指导-单设备'界面, fa模型不支持资源本地化故用中文
let button = await driver.findComponent(ON.text('单设备'));
if (button !== null) {
await button.click();
await sleep(500);
}
// 测试获取分布式目录
button = await driver.findComponent(ON.text('获取分布式目录'));
if (button !== null) {
await button.click();
await sleep(500);
let result = await driver.findComponent(ON.text('/data/storage/el2/distributedfiles'));
expect(result != null).assertTrue();
}
await sleep(1000);
// 测试启动单例PageAbility
button = await driver.findComponent(ON.text('启动单例PageAbility'));
if (button !== null) {
await button.click();
await sleep(2000);
await driver.assertComponentExist(ON.text('PageAbilitySingleton页面一'));
}
await sleep(2000);
// 回到桌面
await driver.pressHome();
await sleep(2000);
// 点击测试应用图标回到测试应用
let app = await driver.findComponent(ON.text('FAModel'));
if (app !== null) {
await app.click();
await sleep(500);
}
await sleep(2000)
// 测试再启动单例PageAbility
button = await driver.findComponent(ON.text('再启动单例PageAbility'));
if (button !== null) {
await button.click();
await sleep(2000);
await driver.assertComponentExist(ON.text('PageAbilitySingleton页面二'));
}
await sleep(2000);
// 回到桌面
await driver.pressHome();
await sleep(2000);
// 点击测试应用图标回到测试应用
app = await driver.findComponent(ON.text('FAModel'));
if (app !== null) {
await app.click();
await sleep(500);
}
await sleep(1000)
// 测试启动多例PageAbility页面一
button = await driver.findComponent(ON.text('启动多例PageAbility页面一'));
if (button !== null) {
await button.click();
await sleep(1000);
await driver.assertComponentExist(ON.text('PageAbilityStandard页面一'));
}
await sleep(1000);
// 回到桌面
await driver.pressHome();
await sleep(2000);
// 点击测试应用图标回到测试应用
app = await driver.findComponent(ON.text('FAModel'));
if (app !== null) {
await app.click();
await sleep(500);
}
await sleep(2000)
// 测试启动多例PageAbility页面二
button = await driver.findComponent(ON.text('启动多例PageAbility页面二'));
if (button !== null) {
await button.click();
await sleep(1000);
await driver.assertComponentExist(ON.text('PageAbilityStandard页面二'));
}
await sleep(500);
// 回到桌面
await driver.pressHome();
await sleep(2000);
// 点击测试应用图标回到测试应用
app = await driver.findComponent(ON.text('FAModel'));
if (app !== null) {
await app.click();
await sleep(500);
}
await sleep(2000)
// 测试使用worker进行线程间通信
button = await driver.findComponent(ON.text('使用Worker进行线程间通信'));
if (button !== null) {
await button.click();
await sleep(500);
let result = await driver.findComponent(ON.text('{"data":"message from worker thread."}'));
expect(result != null).assertTrue();
}
await sleep(2000);
// 测试停止PageAbility
button = await driver.findComponent(ON.text('停止PageAbility'));
if (button !== null) {
await button.click();
await sleep(1000);
}
await sleep(500);
// 点击测试应用图标回到测试应用
app = await driver.findComponent(ON.text('FAModel'));
if (app !== null) {
await app.click();
await sleep(500);
}
await sleep(1000)
hilog.info(domain, TAG, BUNDLE + 'PageAbility_001 end');
done();
})
/**
* @tc.number:FAModelAbilityDevelopTest_003
* @tc.name: FAModelAbilityDevelop_ServiceAbility_001
* @tc.size: MediumTest
* @tc.type: Function
* @tc.level Level 1
* @tc.desc: 测试ServiceAbility组件开发指导相关功能
*/
it(BUNDLE + 'ServiceAbility_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'ServiceAbility_001, begin');
// 跳转至'ServiceAbility组件开发指导'
let button = await driver.findComponent(ON.text('ServiceAbility组件开发指导'));
if (button !== null) {
await button.click();
await sleep(500);
}
// 测试启动ServiceAbility
button = await driver.findComponent(ON.text('启动ServiceAbility'));
if (button !== null) {
await button.click();
await sleep(500);
let result = await driver.findComponent(ON.text('启动serviceAbility成功'));
expect(result != null).assertTrue();
}
await sleep(1000);
// 测试连接ServiceAbility
button = await driver.findComponent(ON.text('连接ServiceAbility'));
if (button !== null) {
await button.click();
await sleep(500);
let result = await driver.findComponent(ON.text('连接serviceAbility成功'));
expect(result != null).assertTrue();
}
await sleep(1000);
// 测试连接错误的ServiceAbility
button = await driver.findComponent(ON.text('连接错误的ServiceAbility'));
if (button !== null) {
await button.click();
await sleep(500);
let result = await driver.findComponent(ON.text('连接serviceAbility失败'));
expect(result != null).assertTrue();
}
await sleep(1000);
// 返回至主页
await driver.pressBack();
await sleep(500);
hilog.info(domain, TAG, BUNDLE + 'ServiceAbility_001, end');
done();
})
/**
* @tc.number:FAModelAbilityDevelopTest_004
* @tc.name: FAModelAbilityDevelop_DataAbility_001
* @tc.size: MediumTest
* @tc.type: Function
* @tc.level Level 1
* @tc.desc: 测试DataAbility组件开发指导相关功能
*/
it(BUNDLE + 'DataAbility_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'DataAbility_001, begin');
// 跳转至'DataAbility组件开发指导'
let button = await driver.findComponent(ON.text('DataAbility组件开发指导'));
if (button !== null) {
await button.click();
await sleep(1500);
}
button = await driver.findComponent(ON.text('允许'));
if (button !== null) {
await button.click();
await sleep(500);
}
// 测试插入数据
await driver.click(300.000000, 306.000000);
let insertCallResult = await driver.findComponent(ON.text('插入数据成功'));
expect(insertCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 400.000000);
let insertPromiseResult = await driver.findComponent(ON.text('插入数据成功'));
expect(insertPromiseResult != null).assertTrue();
await sleep(2000);
// 测试删除数据
await driver.click(300.000000, 550.000000);
let deleteCallResult = await driver.findComponent(ON.text('删除数据成功'));
expect(deleteCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 632.000000);
let deletePromiseResult = await driver.findComponent(ON.text('删除数据成功'));
expect(deletePromiseResult != null).assertTrue();
await sleep(2000);
// 测试更新数据
await driver.click(300.000000, 800.000000);
let updateCallResult = await driver.findComponent(ON.text('更新数据成功'));
expect(updateCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 900.000000);
let updatePromiseResult = await driver.findComponent(ON.text('更新数据成功'));
expect(updatePromiseResult != null).assertTrue();
await sleep(2000);
// 测试查找数据
await driver.click(300.000000, 1053.000000);
let searchCallResult = await driver.findComponent(ON.text('查找数据成功'));
expect(searchCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 1163.000000);
let searchPromiseResult = await driver.findComponent(ON.text('查找数据成功'));
expect(searchPromiseResult != null).assertTrue();
await sleep(3000);
//滑动屏幕
await driver.swipe(400, 900, 400, 500);
await sleep(3000);
// 测试批量插入数据
await driver.click(300.000000, 838.000000);
let allInsertCallResult = await driver.findComponent(ON.text('批量插入数据成功'));
expect(allInsertCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 922.000000);
let allInsertPromiseResult = await driver.findComponent(ON.text('批量插入数据成功'));
expect(allInsertPromiseResult != null).assertTrue();
await sleep(2000);
// 测试批量处理数据
await driver.click(300.000000, 1104.000000);
let allUpdateCallResult = await driver.findComponent(ON.text('批量处理数据成功'));
expect(allUpdateCallResult != null).assertTrue();
await sleep(2000);
await driver.click(300.000000, 1183.000000);
let allUpdatePromiseResult = await driver.findComponent(ON.text('批量处理数据成功'));
expect(allUpdatePromiseResult != null).assertTrue();
await sleep(2000);
// 返回至主页
await driver.pressBack();
await sleep(500);
hilog.info(domain, TAG, BUNDLE + 'DataAbility_001, end');
done();
})
/**
* @tc.number:FAModelAbilityDevelopTest_005
* @tc.name: FAModelAbilityDevelop_InterflowFaAndStage_001
* @tc.type: 0 || TestType.FUNCTION || Size.SMALLTEST || Level.LEVEL0
* @tc.desc: 测试FA模型与Stage模型应用组件互通指导相关功能
*/
it(BUNDLE + 'InterflowFaAndStage_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'InterflowFaAndStage_001, begin');
// 跳转至'FA模型与Stage模型应用组件互通指导'
let button = await driver.findComponent(ON.text('FA模型与Stage模型应用组件互通指导'));
if (button !== null) {
await button.click();
await sleep(1000);
}
// 测试通过PageAbility启动UIAbility-无需返回结果
button = await driver.findComponent(ON.text('通过PageAbility与Stage模型互通-无需返回结果'));
if (button !== null) {
await button.click();
await sleep(500);
}
await sleep(1000);
// 返回至FA模型与Stage模型应用组件互通指导页面
await driver.pressBack();
await sleep(1000);
// 测试通过PageAbility启动UIAbility-返回执行结果
button = await driver.findComponent(ON.text('通过PageAbility与Stage模型互通-返回执行结果'));
if (button !== null) {
await button.click();
await sleep(500);
}
await sleep(1000);
// 返回至FA模型与Stage模型应用组件互通指导页面
await driver.pressBack();
await sleep(1000);
// 测试通过ServiceAbility启动UIAbility
button = await driver.findComponent(ON.text('通过ServiceAbility与Stage模型互通'));
if (button !== null) {
await button.click();
await sleep(500);
}
await sleep(1000);
hilog.info(domain, TAG, BUNDLE + 'InterflowFaAndStage_001, end');
done();
})
/**
* @tc.number:FAModelAbilityDevelopTest_006
* @tc.name: FAModelAbilityDevelop_FAServiceCard_001
* @tc.size: MediumTest
* @tc.type: Function
* @tc.level Level 1
* @tc.desc: 测试FA模型服务卡片相关功能
*/
it(BUNDLE + 'FAServiceCard_001', 0, async (done: Function) => {
hilog.info(domain, TAG, BUNDLE + 'FAServiceCard_001, begin');
// 回到桌面
await driver.pressHome();
await sleep(1000);
// 添加服务卡片
let app = await driver.findComponent(ON.text('FAModel'))
if (app !== null) {
// 获取应用图标位置并长按
let rect = await app.getBounds();
let height = rect.bottom - rect.top;
let point = await app.getBoundsCenter();
await driver.longClick(point.x, point.y - height);
hilog.info(domain, TAG, BUNDLE + `FAServiceCard_001 long click app, coordinate:(${point.x},` + `${point.y - height})`);
await sleep(500);
}
let service_card = await driver.findComponent(ON.text('服务卡片'));
await service_card.click();
await sleep(1000);
let addForm = await driver.findComponent(ON.text('添加到桌面'));
await addForm.click();
await sleep(1000);
// 获取卡片位置
let apps = await driver.findComponents(ON.text('FAModel'));
let rect = await apps[apps.length - 1].getBounds();
let point = await apps[apps.length - 1].getBoundsCenter();
hilog.info(domain, TAG, BUNDLE + `FAServiceCard_001 card rect:` + JSON.stringify(rect));
// 点击title跳转至应用界面
await driver.click(point.x, point.y - 80);
hilog.info(domain, TAG, BUNDLE + `FAServiceCard_001 click:${point.x} : ${point.y - 80}`);
await sleep(2000);
await driver.assertComponentExist(ON.text('FA模型与Stage模型应用组件互通指导'));
// 返回至桌面
await driver.pressHome();
await sleep(500);
// 点击detail更新服务卡片
await driver.click(point.x, point.y - 40);
hilog.info(domain, TAG, BUNDLE + `FAServiceCard_001 click:${point.x} : ${point.y - 40}`);
hilog.info(domain, TAG, BUNDLE + 'FAServiceCard_001, end');
done();
})
})
}

View File

@ -1,19 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test';
export default function testsuite() {
abilityTest();
}

View File

@ -1,12 +0,0 @@
{
"string": [
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}

View File

@ -1,21 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"hvigorVersion": "4.0.2",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "4.0.2"
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,17 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { legacyAppTasks } from '@ohos/hvigor-ohos-plugin';

View File

@ -1,48 +0,0 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
fail() {
error "$@"
exit 1
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"

View File

@ -1,64 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
goto start
:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
if "%ERRORLEVEL%" == "0" goto hvigorwEnd
:fail
exit /b 1
:hvigorwEnd
if "%OS%" == "Windows_NT" endlocal
:end

View File

@ -1,27 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"license": "",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
"author": "",
"name": "famodelabilitydevelop",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,33 +0,0 @@
# FAModelAbilityDevelop测试用例归档
## 用例表
|测试功能|预置条件|输入|预期输出|是否自动|测试结果|
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|拉起应用|设备正常运行| 点击应用图标 |成功拉起应用|是|Pass|
|PageAbility组件开发指导-单设备|进入首页| 点击[PageAbility组件开发指导-单设备] |PageAbility组件开发指导-单设备‘界面正常展示|是|Pass|
|获取分布式目录|进入PageAbility组件开发指导-单设备‘界面|点击[获取分布式目录]|弹出toast[/data/***]|是|Pass|
|启动单例PageAbility指定页面|进入PageAbility组件开发指导-单设备‘界面|点击[启动单例PageAbility]<br />再点击Home键回到桌面<br />再点击应用图标回到PageAbility组件开发指导-单设备‘界面<br />点击[再启动单例PageAbility]|点击[启动单例PageAbility]后跳转至Title为PageAbilitySingleton页面一的页面<br />点击[再启动单例PageAbility]后跳转至Title为PageAbilitySingleton页面二的页面<br />|是|Pass|
|启动多例PageAbility指定页面|进入PageAbility组件开发指导-单设备‘界面|点击[启动多例PageAbility页面一]<br />再点击Home键回到桌面<br />再点击应用图标回到PageAbility组件开发指导-单设备‘界面<br />点击[启动多例PageAbility页面二]|点击[启动多例PageAbility页面一]后跳转至Title为PageAbilityStandard页面一的页面<br />点击[启动多例PageAbility页面二]后跳转至Title为PageAbilityStandard页面二的页面<br />|是|Pass|
|使用worker进行线程间通信|进入PageAbility组件开发指导-单设备‘界面|点击[使用Worker进行线程间通信]|弹出toast[{"data":"message from worker thread."}]|是|Pass|
| 停止PageAbility | 进入PageAbility组件开发指导-单设备‘界面 | 点击[停止PageAbility] | 退出当前应用返回桌面 |是|Pass|
| PageAbility组件开发指导-多设备 | 进入首页且已设置README中依赖项内容 | 点击[PageAbility组件开发指导-多设备]<br />再点击[获取分布式数据同步权限],并在弹出的申请权限对话框中点击’允许‘,再点击[获取设备id]<br />再点击[启动远程设备PageAbility] | 'PageAbility组件开发指导-多设备’界面正常展示<br />弹出toast内容为对端设备的deviceId<br />弹出toast[启动远程Ability成功],同时打开对端设备音乐应用 |否|Pass|
| ServiceAbility组件开发指导 | 进入首页 | 点击[ServiceAbility组件开发指导] | ServiceAbility组件开发指导界面正常展示 |是|Pass|
| 创建ServiceAbility | 进入ServiceAbility组件开发指导界面 | 点击[启动ServiceAbility] | 弹出toast[启动serviceAbility成功] |是|Pass|
| 连接ServiceAbility | 进入ServiceAbility组件开发指导界面 | 点击[连接ServiceAbility] | 弹出toast[连接serviceAbility成功] |是|Pass|
| 连接错误的ServiceAbility | 进入ServiceAbility组件开发指导界面 | 点击[连接错误的ServiceAbility] | 弹出toast[连接serviceAbility失败] |是|Pass|
|DataAbility组件开发指导|进入首页|点击[DataAbility组件开发指导]并在弹出的对话框中点击’允许‘|DataAbility组件开发指导界面正常展示且弹出是否允许申请权限的对话框|是|Pass|
| 插入数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[插入数据-callback方式]<br />再点击[插入数据-promise方式] | 点击后均弹出toast[插入数据成功] |是|Pass|
| 删除数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[删除数据-callback方式]<br />再点击[删除数据-promise方式] | 点击后均弹出toast[删除数据成功] |是|Pass|
| 更新数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[更新数据-callback方式]<br />再点击[更新数据-promise方式] | 点击后均弹出toast[更新数据成功] |是|Pass|
| 查找数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[查找数据-callback方式]<br />再点击[查找数据-promise方式] | 点击后均弹出toast[查找数据成功] | 是 | Pass |
| 批量插入数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[批量插入数据-callback方式]<br />再点击[批量插入数据-promise方式] | 点击后均弹出toast[批量插入数据成功] | 是 | Pass |
| 批量处理数据 | 进入DataAbility组件开发指导界面且允许当前应用访问通讯录 | 点击[批量处理数据-callback方式]<br />再点击[批量处理数据-promise方式] | 点击后均弹出toast[批量处理数据成功] | 是 | Pass |
| FA模型与Stage模型应用组件互通指导 | 进入首页 | 点击[FA模型与Stage模型应用组件互通指导] | FA模型与Stage模型应用组件互通指导界面正常展示 | 是 | Pass |
| 通过PageAbility启动UIAbility-无需返回结果 | 进入FA模型与Stage模型应用组件互通指导界面 | 点击[通过PageAbility启动UIAbility-无需返回结果] | 成功启动时钟应用 | 是 | Pass |
| 通过PageAbility启动UIAbility-返回执行结果 | 进入FA模型与Stage模型应用组件互通指导界面 | 点击[通过PageAbility启动UIAbility-返回执行结果] | 成功启动时钟应用 | 是 | Pass |
| 通过ServiceAbility启动UIAbility | 进入FA模型与Stage模型应用组件互通指导界面 | 点击[通过ServiceAbility启动UIAbility] | 成功启动时钟应用 | 是 | Pass |
| 添加服务卡片 | 回到桌面 | 长按应用图标,在弹出框中点击服务卡片,进入服务卡片添加界面,点击添加至桌面 | 跳转会桌面并桌面上新增FAModel服务卡片 | 是 | Pass |
| 卡片跳转事件触发 | 已成功添加服务卡片 | 点击卡片内titleOnCreate' | 跳转至应用界面 | 是 | Pass |
| 卡片更新事件触发 | 已成功添加服务卡片 | 点击卡片内detailOnCreate' | 卡片内容会更新 | 是 | Pass |