diff --git a/ArkData/DataObject/CrossDeviceCollaboration/.gitignore b/ArkData/DataObject/CrossDeviceCollaboration/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/AppScope/app.json5 b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f3d07df02f2acafe9f1f7e298287bec4088b8dd --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.example.crossdevicecollaboration", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/element/string.json b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1080233f01384411ec684b58955cb8808746fdd3 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_background.png b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_background.png differ diff --git a/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_foreground.png b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_foreground.png differ diff --git a/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_layered_image.json b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..b71c16122943f248ace0f5fa26da38b71dbdbdde --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/AppScope/resources/base/media/app_layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:app_background", + "foreground" : "$media:app_foreground" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/README_zh.md b/ArkData/DataObject/CrossDeviceCollaboration/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e78b8c7353573a5605bcc32450fa0724e33d36b6 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/README_zh.md @@ -0,0 +1,86 @@ +# 分布式数据对象多端协同 (DataObject)指南文档示例 + +### 介绍 + + +本示例通过调用端拉起对端Ability后创建分布式数据对象并加入组网,被调用端被拉起后创建和恢复分布式数据对象。 + +### 效果预览 + +不涉及页面展示效果。 + +### 使用说明 + +1. 准备两台设备,一台作为发起端,一台作为接收端。 + +2. 使用IDE自动签名,编译,安装(两台设备都需要安装)。 + +3. 两台设备登录同一个华为账号,连接同一个wifi。 + +4. 发起端设备保存数据到分布式数据对象,并将分布式数据对象同步给接收端设备,对端能够感知到数据变化。 + +### 工程目录 +``` +entry/src/ +| |--- main/ +| |---ets/ +| |---entryability/EntryAbility.ets // 应用启动加载的入口ability +| |---entrybackupability/EntryBackupAbility.ets // extensionAbility。 +| |---pages/index.ets // entry主应用入口页面及接口调用实现 +``` + + +### 具体实现 + +* 调用端调用startAbilityByCall接口拉起对端Ability: + + * 调用genSessionId接口创建一个sessionId,通过分布式设备管理接口获取对端设备networkId。 + + * 组装want,并将sessionId放入want。 + + * 调用startAbilityByCall接口拉起对端Ability。 + +* 调用端拉起对端Ability后创建分布式数据对象并加入组网: + + * 创建分布式数据对象实例。 + + * 注册数据变更监听。 + + * 设置同步sessionId加入组网。 + +* 被调用端被拉起后创建和恢复分布式数据对象: + + * 创建分布式数据对象实例。 + + * 注册数据变更监听。 + + * 从want中获取源端放入的sessionId,使用这个sessionId加入组网。 + + +### 相关权限 + +ohos.permission.DISTRIBUTED_DATASYNC。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.53,镜像版本号:OpenHarmony_6.0.0.53。 + +3.本示例需要使用DevEco Studio 6.0.0 Release (Build Version: 6.0.0.858, built on September 5, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkData/DataObject/CrossDeviceCollaboration > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/build-profile.json5 b/ArkData/DataObject/CrossDeviceCollaboration/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4bf52df04feb18a7871f1a5bebe73aa11539a281 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.1.0(18)", + "compatibleSdkVersion": "5.1.0(18)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/code-linter.json5 b/ArkData/DataObject/CrossDeviceCollaboration/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed05653cca31b61d64cf6471529eaf50d4f70709 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/code-linter.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/.gitignore b/ArkData/DataObject/CrossDeviceCollaboration/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/build-profile.json5 b/ArkData/DataObject/CrossDeviceCollaboration/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/hvigorfile.ts b/ArkData/DataObject/CrossDeviceCollaboration/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/obfuscation-rules.txt b/ArkData/DataObject/CrossDeviceCollaboration/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/oh-package.json5 b/ArkData/DataObject/CrossDeviceCollaboration/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entryability/EntryAbility.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3ee54d2beea61d38866762868bd056d3e39e3c9 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..6386339681f868f24e628f133a8e59e876d27e64 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start data_sync_on_distributed_data_object_cross_device_collaboration] +import { AbilityConstant, Caller, UIAbility, Want } from '@kit.AbilityKit'; +import { distributedDataObject } from '@kit.ArkData'; +import { distributedDeviceManager } from '@kit.DistributedServiceKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { JSON } from '@kit.ArkTS'; +import hilog from '@ohos.hilog'; + +// 业务数据定义 +class Data { + public title: string | undefined; + public text: string | undefined; + + constructor(title: string | undefined, text: string | undefined) { + this.title = title; + this.text = text; + } +} + +const DOMAIN: number = 0x0000; +const TAG: string = '[DistributedDataObject]'; + +let sessionId: string; +let caller: Caller; +let dataObject: distributedDataObject.DataObject; +const changeCallBack: distributedDataObject.DataObserver = (sessionId: string, fields: Array) => { + console.info(`change, sessionId: ${sessionId}, fields: ${JSON.stringify(fields)}`); +} + +export default class EntryAbility extends UIAbility { + // 1. 调用端调用startAbilityByCall接口拉起对端Ability + callRemote() { + if (caller) { + hilog.error(DOMAIN, TAG, 'call remote already'); + return; + } + + // 1.1 调用genSessionId接口创建一个sessionId,通过分布式设备管理接口获取对端设备networkId + sessionId = distributedDataObject.genSessionId(); + hilog.info(DOMAIN, TAG, `gen sessionId: ${sessionId}`); + let deviceId = getRemoteDeviceId(); + if (deviceId === '') { + hilog.warn(DOMAIN, TAG, 'no remote device'); + return; + } + hilog.info(DOMAIN, TAG, `get remote deviceId: ${deviceId}`); + + // 1.2 组装want,并将sessionId放入want + let want: Want = { + bundleName: 'com.example.collaboration', + abilityName: 'EntryAbility', + deviceId: deviceId, + parameters: { + 'ohos.aafwk.param.callAbilityToForeground': true, // 前台启动,非必须 + 'distributedSessionId': sessionId + } + } + try { + // 1.3 调用startAbilityByCall接口拉起对端Ability + this.context.startAbilityByCall(want).then((res) => { + if (!res) { + hilog.error(DOMAIN, TAG, 'startAbilityByCall failed'); + } + caller = res; + }) + } catch (e) { + let err = e as BusinessError; + hilog.error(DOMAIN, TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); + } + } + + // 2. 拉起对端Ability后创建分布式数据对象 + createDataObject() { + if (!caller) { + hilog.error(DOMAIN, TAG, 'call remote first'); + return; + } + if (dataObject) { + hilog.error(DOMAIN, TAG, 'create dataObject already'); + return; + } + + // 2.1 创建分布式数据对象实例 + let data = new Data('The title', 'The text'); + dataObject = distributedDataObject.create(this.context, data); + + // 2.2 注册数据变更监听 + dataObject.on('change', changeCallBack); + // 2.3 设置同步sessionId加入组网 + dataObject.setSessionId(sessionId); + } + + // 3. 被调用端被拉起后创建和恢复分布式数据对象 + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + if (want.parameters && want.parameters.distributedSessionId) { + // 3.1 创建分布式数据对象实例 + let data = new Data(undefined, undefined); + dataObject = distributedDataObject.create(this.context, data); + + // 3.2 注册数据变更监听 + dataObject.on('change', changeCallBack); + // 3.3 从want中获取源端放入的sessionId,使用这个sessionId加入组网 + let sessionId = want.parameters.distributedSessionId as string; + hilog.info(DOMAIN, TAG, `onCreate get sessionId: ${sessionId}`); + dataObject.setSessionId(sessionId); + } + } +} + +// 获取可信组网中的设备 +function getRemoteDeviceId() { + let deviceId = ''; + try { + let deviceManager = distributedDeviceManager.createDeviceManager('com.example.collaboration'); + let devices = deviceManager.getAvailableDeviceListSync(); + if (devices[0] && devices[0].networkId) { + deviceId = devices[0].networkId; + } + } catch (e) { + let err = e as BusinessError; + hilog.error(DOMAIN, TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); + } + return deviceId; +} + +// [End data_sync_on_distributed_data_object_cross_device_collaboration] \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/pages/Index.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f481f696485b8c840d49ad9e7d7dff7f6b71241 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/module.json5 b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fad771a1a4ba8c8f8f43f841e56096645eac2adb --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/module.json5 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "wearable" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/color.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/float.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/string.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/background.png b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/background.png differ diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/foreground.png b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/layered_image.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/startIcon.png b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/backup_config.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/main_pages.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/dark/element/color.json b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/mock/mock-config.json5 b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ + +{ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/List.test.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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(); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/module.json5 b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0db960a52d7fca00a9966798b547432ca5220910 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/ohosTest/module.json5 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "wearable" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/List.test.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/LocalUnit.test.ets b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/hvigor/hvigor-config.json5 b/ArkData/DataObject/CrossDeviceCollaboration/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..abba3f8bb5fd7ae3ea4626a345f3f557ce010ccc --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.1.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/hvigorfile.ts b/ArkData/DataObject/CrossDeviceCollaboration/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3340f07e45ddc5dcadbb87012668555def2e6e0 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceCollaboration/oh-package.json5 b/ArkData/DataObject/CrossDeviceCollaboration/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..776afe9eb3d822abcfd3e4273f23581af1d1acc1 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.1.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkData/DataObject/CrossDeviceCollaboration/ohosTest.md b/ArkData/DataObject/CrossDeviceCollaboration/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..8b48c2de65cbc99c170aa400613a61532f0fe7b1 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceCollaboration/ohosTest.md @@ -0,0 +1,7 @@ +# CrossDeviceCollaboration 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- |---------------------------------------|----------| :------- | -------- | +| CrossDeviceCollaboration示例代码验证 | 设备正常运行 | 进入页面,页面内容显示正常 | 页面信息显示正常 | 是 | Pass | \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/.gitignore b/ArkData/DataObject/CrossDeviceMigration/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/AppScope/app.json5 b/ArkData/DataObject/CrossDeviceMigration/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a65b7a51f6507de6524ff62c757e8ff210b7ab83 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.example.crossdevicemigration", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/element/string.json b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1080233f01384411ec684b58955cb8808746fdd3 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_background.png b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_background.png differ diff --git a/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_foreground.png b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_foreground.png differ diff --git a/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_layered_image.json b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..b71c16122943f248ace0f5fa26da38b71dbdbdde --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/AppScope/resources/base/media/app_layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:app_background", + "foreground" : "$media:app_foreground" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/README_zh.md b/ArkData/DataObject/CrossDeviceMigration/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..fb703c8bc2fdbb4e9430606d50ad2e6a16264ae0 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/README_zh.md @@ -0,0 +1,77 @@ +# 分布式数据对象跨端迁移 (DataObject)指南文档示例 + +### 介绍 + + +本示例通过迁移发起端创建分布式数据对象并保存数据到接收端,接收端创建分布式数据对象并注册恢复状态监听,实现跨设备数据迁移。 + +### 效果预览 + +不涉及页面展示效果。 + +### 使用说明 + +1. 准备两台设备,一台作为发起端,一台作为接收端。 + +2. 使用IDE自动签名,编译,安装(两台设备都需要安装)。 + +3. 两台设备登录同一个华为账号,连接同一个wifi。 + +4. 发起端设备保存数据到分布式数据对象,并将分布式数据对象同步给接收端设备。 + +### 工程目录 +``` +entry/src/ +| |--- main/ +| |---ets/ +| |---entryability/EntryAbility.ets // 应用启动加载的入口ability +| |---entrybackupability/EntryBackupAbility.ets // extensionAbility。 +| |---pages/index.ets // entry主应用入口页面及接口调用实现 +``` + + +### 具体实现 + +* 迁移发起端在onContinue接口中创建分布式数据对象并保存数据到接收端: + + * 调用create接口创建并得到一个分布式数据对象实例。 + + * 调用genSessionId接口创建一个sessionId,调用setSessionId接口设置同步的sessionId,并将这个sessionId放入wantParam。 + + * 从wantParam获取接收端设备networkId,使用这个networkId调用save接口保存数据到接收端。 + +* 接收端在onCreate和onNewWant接口中创建分布式数据对象并注册恢复状态监听: + + * 调用create接口创建并得到一个分布式数据对象实例。 + + * 调用genSessionId接口创建一个sessionId,调用setSessionId接口设置同步的sessionId,并将这个sessionId放入wantParam。 + + * 从wantParam获取接收端设备networkId,使用这个networkId调用save接口保存数据到接收端。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.53,镜像版本号:OpenHarmony_6.0.0.53。 + +3.本示例需要使用DevEco Studio 6.0.0 Release (Build Version: 6.0.0.858, built on September 5, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkData/DataObject/CrossDeviceMigration > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/build-profile.json5 b/ArkData/DataObject/CrossDeviceMigration/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4bf52df04feb18a7871f1a5bebe73aa11539a281 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.1.0(18)", + "compatibleSdkVersion": "5.1.0(18)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/code-linter.json5 b/ArkData/DataObject/CrossDeviceMigration/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed05653cca31b61d64cf6471529eaf50d4f70709 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/code-linter.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/.gitignore b/ArkData/DataObject/CrossDeviceMigration/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/build-profile.json5 b/ArkData/DataObject/CrossDeviceMigration/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/hvigorfile.ts b/ArkData/DataObject/CrossDeviceMigration/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/obfuscation-rules.txt b/ArkData/DataObject/CrossDeviceMigration/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/oh-package.json5 b/ArkData/DataObject/CrossDeviceMigration/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entryability/EntryAbility.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3ee54d2beea61d38866762868bd056d3e39e3c9 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4cc652286a0ea328038dcd9f92abff732a24ff2f --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start data_sync_on_distributed_data_object_cross_device_migration] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { commonType, distributedDataObject } from '@kit.ArkData'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// 业务数据定义 +export class ContentInfo { + public mainTitle: string | undefined; + public textContent: string | undefined; + public imageUriArray: Array | undefined; + public isShowLocalInfo: boolean | undefined; + public isAddLocalInfo: boolean | undefined; + public selectLocalInfo: string | undefined; + public attachments?: commonType.Assets | undefined; + + constructor( + mainTitle: string | undefined, + textContent: string | undefined, + imageUriArray: Array | undefined, + isShowLocalInfo: boolean | undefined, + isAddLocalInfo: boolean | undefined, + selectLocalInfo: string | undefined, + attachments?: commonType.Assets | undefined + ) { + this.mainTitle = mainTitle; + this.textContent = textContent; + this.imageUriArray = imageUriArray; + this.isShowLocalInfo = isShowLocalInfo; + this.isAddLocalInfo = isAddLocalInfo; + this.selectLocalInfo = selectLocalInfo; + this.attachments = attachments; + } + + flatAssets(): object { + let obj: object = this; + if (!this.attachments) { + return obj; + } + for (let i = 0; i < this.attachments.length; i++) { + obj[`attachments${i}`] = this.attachments[i]; + } + return obj; + } +} + +export interface ImageInfo { + /** + * image PixelMap. + */ + imagePixelMap: PixelMap; + + /** + * Image name. + */ + imageName: string; +} + +const DOMAIN: number = 0x0000; +const TAG: string = '[DistributedDataObject]'; +let dataObject: distributedDataObject.DataObject; + +export default class EntryAbility extends UIAbility { + private imageUriArray: Array = []; + private distributedObject: distributedDataObject.DataObject | undefined = undefined; + + // 1. 迁移发起端在onContinue接口中创建分布式数据对象并保存数据到接收端 + async onContinue(wantParam: Record): Promise { + // 1.1 获取需要设置的分布式对象的资产关键uri + try { + let sessionId: string = distributedDataObject.genSessionId(); + wantParam.distributedSessionId = sessionId; + + let distrUriArray: string[] = []; + let assetUriArray = AppStorage.get>('assetUriArray'); + if (assetUriArray) { + distrUriArray = assetUriArray; + } + // 1.2 创建分布式数据对象 + let contentInfo: ContentInfo = new ContentInfo( + AppStorage.get('mainTitle'), + AppStorage.get('textContent'), + AppStorage.get('imageUriArray'), + AppStorage.get('isShowLocalInfo'), + AppStorage.get('isAddLocalInfo'), + AppStorage.get('selectLocalInfo'), + ); + let source = contentInfo.flatAssets(); + this.distributedObject = distributedDataObject.create(this.context, source); + + // 1.3 将需要设置的分布式对象的资产或资产数组填充完成 + if (assetUriArray?.length === 1) { + this.distributedObject?.setAsset('attachments', distrUriArray[0]).then(() => { + hilog.info(DOMAIN, TAG, 'OnContinue setAsset'); + }) + } else { + this.distributedObject?.setAssets('attachments', distrUriArray).then(() => { + hilog.info(DOMAIN, TAG, 'OnContinue setAssets'); + }) + } + // 1.4 将设置的资产或资产数组保存至迁移发起端 + this.distributedObject?.setSessionId(sessionId); + this.distributedObject?.save(wantParam.targetDevice as string).catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, 'OnContinue failed to save. code: ', err.code); + hilog.error(DOMAIN, TAG, 'OnContinue failed to save. message: ', err.message); + }); + } catch (error) { + hilog.error(DOMAIN, TAG, 'OnContinue failed code: ', error.code); + hilog.error(DOMAIN, TAG, 'OnContinue failed message: ', error.message); + } + hilog.info(DOMAIN, TAG, 'OnContinue success!'); + return AbilityConstant.OnContinueResult.AGREE; + } + + // 2. 接收端在onCreate和onNewWant接口中创建分布式数据对象并加入组网进行数据恢复 + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { + if (want.parameters && want.parameters.distributedSessionId) { + this.restoreDistributedObject(want); + } + } + } + + // 2. 接收端在onCreate和onNewWant接口中创建分布式数据对象并加入组网进行数据恢复 + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { + if (want.parameters && want.parameters.distributedSessionId) { + this.restoreDistributedObject(want); + } + } + } + + async restoreDistributedObject(want: Want): Promise { + if (!want.parameters || !want.parameters.distributedSessionId) { + hilog.error(DOMAIN, TAG, 'missing sessionId'); + return; + } + + // 2.1 调用create接口创建并得到一个分布式数据对象实例 + let mailInfo: ContentInfo = new ContentInfo(undefined, undefined, [], undefined, undefined, undefined, undefined); + dataObject = distributedDataObject.create(this.context, mailInfo); + + // 2.2 注册恢复状态监听。收到状态为'restored'的回调通知时,表示接收端分布式数据对象已恢复发起端保存过来的数据(有资产数据时,对应的文件也迁移过来了) + dataObject.on('status', (sessionId: string, networkId: string, status: string) => { + hilog.info(DOMAIN, TAG, `status change, sessionId: ${sessionId}`); + hilog.info(DOMAIN, TAG, `status change, networkId: ${networkId}`); + if (status === 'restored') { // 收到'restored'的状态通知表示已恢复发起端保存的数据 + hilog.info(DOMAIN, TAG, `title: ${dataObject['title']}, text: ${dataObject['text']}`); + AppStorage.setOrCreate('mainTitle', dataObject['mainTitle']); + AppStorage.setOrCreate('textContent', dataObject['textContent']); + AppStorage.setOrCreate('imageUriArray', dataObject['imageUriArray']); + AppStorage.setOrCreate('isShowLocalInfo', dataObject['isShowLocalInfo']); + AppStorage.setOrCreate('isAddLocalInfo', dataObject['isAddLocalInfo']); + AppStorage.setOrCreate('selectLocalInfo', dataObject['selectLocalInfo']); + AppStorage.setOrCreate>('imageUriArray', this.imageUriArray); + } + }); + + // 2.3 从want.parameters中获取发起端放入的sessionId,调用setSessionId接口设置同步的sessionId + let sessionId = want.parameters.distributedSessionId as string; + hilog.info(DOMAIN, TAG, `get sessionId: ${sessionId}`); + dataObject.setSessionId(sessionId); + } +} + +// [End data_sync_on_distributed_data_object_cross_device_migration] \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/pages/Index.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f481f696485b8c840d49ad9e7d7dff7f6b71241 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/module.json5 b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fad771a1a4ba8c8f8f43f841e56096645eac2adb --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/module.json5 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "wearable" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/color.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/float.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/string.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/background.png b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/background.png differ diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/foreground.png b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/layered_image.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/startIcon.png b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/backup_config.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/main_pages.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/dark/element/color.json b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/mock/mock-config.json5 b/ArkData/DataObject/CrossDeviceMigration/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ + +{ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/List.test.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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(); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/module.json5 b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0db960a52d7fca00a9966798b547432ca5220910 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/ohosTest/module.json5 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "wearable" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/test/List.test.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/entry/src/test/LocalUnit.test.ets b/ArkData/DataObject/CrossDeviceMigration/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/hvigor/hvigor-config.json5 b/ArkData/DataObject/CrossDeviceMigration/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..abba3f8bb5fd7ae3ea4626a345f3f557ce010ccc --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.1.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/ArkData/DataObject/CrossDeviceMigration/hvigorfile.ts b/ArkData/DataObject/CrossDeviceMigration/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3340f07e45ddc5dcadbb87012668555def2e6e0 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/ArkData/DataObject/CrossDeviceMigration/oh-package.json5 b/ArkData/DataObject/CrossDeviceMigration/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..776afe9eb3d822abcfd3e4273f23581af1d1acc1 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.1.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkData/DataObject/CrossDeviceMigration/ohosTest.md b/ArkData/DataObject/CrossDeviceMigration/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..b9d15d4fb713f2c9194f149d5ee609dc75842f07 --- /dev/null +++ b/ArkData/DataObject/CrossDeviceMigration/ohosTest.md @@ -0,0 +1,7 @@ +# CrossDeviceMigration 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- |---------------------------------------|----------| :------- | -------- | +| CrossDeviceMigration示例代码验证 | 设备正常运行 | 进入页面,页面内容显示正常 | 页面信息显示正常 | 是 | Pass | \ No newline at end of file